Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add expanded annotation to Parameter and related implementations
  • Loading branch information
karlduderstadt committed Jul 30, 2021
commit cdca0e52136ad9103e7c33b92a866b452ea46b45
5 changes: 5 additions & 0 deletions src/main/java/org/scijava/command/CommandModuleItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ public String getWidgetStyle() {
public String getWidgetGroup() {
return getParameter().group();
}

@Override
public boolean isExpanded() {
return getParameter().expanded();
}

@Override
public T getMinimumValue() {
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/org/scijava/module/AbstractModuleItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public String toString() {
sm.append("callback", getCallback());
sm.append("widgetStyle", getWidgetStyle());
sm.append("widgetGroup", getWidgetGroup());
sm.append("expanded", isExpanded());
sm.append("default", getDefaultValue());
sm.append("min", getMinimumValue());
sm.append("max", getMaximumValue());
Expand Down Expand Up @@ -237,6 +238,11 @@ public String getWidgetStyle() {
public String getWidgetGroup() {
return null;
}

@Override
public boolean isExpanded() {
return true;
}

@Override
public T getDefaultValue() {
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/org/scijava/module/DefaultMutableModuleItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public class DefaultMutableModuleItem<T> extends AbstractModuleItem<T>
private String callback;
private String widgetStyle;
private String widgetGroup;
private boolean expanded;
private T defaultValue;
private T minimumValue;
private T maximumValue;
Expand Down Expand Up @@ -96,6 +97,7 @@ public DefaultMutableModuleItem(final ModuleInfo info, final String name,
callback = super.getCallback();
widgetStyle = super.getWidgetStyle();
widgetGroup = super.getWidgetGroup();
expanded = super.isExpanded();
minimumValue = super.getMinimumValue();
maximumValue = super.getMaximumValue();
stepSize = super.getStepSize();
Expand Down Expand Up @@ -125,6 +127,7 @@ public DefaultMutableModuleItem(final ModuleInfo info,
callback = item.getCallback();
widgetStyle = item.getWidgetStyle();
widgetGroup = item.getWidgetGroup();
expanded = item.isExpanded();
minimumValue = item.getMinimumValue();
maximumValue = item.getMaximumValue();
softMinimum = item.getSoftMinimum();
Expand Down Expand Up @@ -188,6 +191,16 @@ public void setCallback(final String callback) {
public void setWidgetStyle(final String widgetStyle) {
this.widgetStyle = widgetStyle;
}

@Override
public void setWidgetGroup(final String widgetGroup) {
this.widgetGroup = widgetGroup;
}

@Override
public void setExpanded(final boolean expanded) {
this.expanded = expanded;
}

@Override
public void setDefaultValue(final T defaultValue) {
Expand Down Expand Up @@ -296,6 +309,11 @@ public String getWidgetStyle() {
public String getWidgetGroup() {
return widgetGroup;
}

@Override
public boolean isExpanded() {
return expanded;
}

@Override
public T getDefaultValue() {
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/scijava/module/ModuleItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ public interface ModuleItem<T> extends BasicDetails {
* the group.
*/
String getWidgetGroup();

/** Returns the state of the widget group, expanded and visible or not expanded and hidden. */
boolean isExpanded();

/** Gets the default value. */
T getDefaultValue();
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/scijava/module/MutableModuleItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ public interface MutableModuleItem<T> extends ModuleItem<T> {
void setCallback(String callback);

void setWidgetStyle(String widgetStyle);

void setWidgetGroup(String widgetGroup);

void setExpanded(boolean expanded);

void setDefaultValue(T defaultValue);

Expand Down
9 changes: 9 additions & 0 deletions src/main/java/org/scijava/plugin/Parameter.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@
* output, such as a "verbose" flag.</li>
* <li>MESSAGE: parameter value is intended as a message only, not editable by
* the user nor included as an input or output parameter.</li>
* <li>GROUP: parameter value specifies a widget group, not editable by
* the user nor included as an input or output parameter. Members are added
* to the group using the group parameter annotation.</li>
* </ul>
*/
ItemVisibility visibility() default ItemVisibility.NORMAL;
Expand Down Expand Up @@ -145,6 +148,12 @@

/** Defines the widget group. */
String group() default "";

/**
* Defines the state of the widget group. When true the group is expanded and visible.
* Otherwise, group members are hidden.
* */
boolean expanded() default true;

/** Defines the minimum allowed value (numeric parameters only). */
String min() default "";
Expand Down