Skip to content

Use @Parameter callbacks for GUI interactivity #403

Description

@mdoube

Legacy plugins used GenericDialog and DialogListener from AWT to achieve GUI interactivity when an option was dependent on another option's state. In IJ2, this is achieved with callback = someMethod which updates the fields based on the method's logic. AnisotropyWrapper uses it, like this:

See also the use of the validater = someValidationMethod @Parameter option to run a check on the input Dataset prior to running the Command.

	@Parameter(label = "Lines per direction",
		description = "How many lines are sampled per direction",
		min = "1", style = NumberWidget.SPINNER_STYLE, required = false,
		callback = "applyMinimum")
	private Integer lines = DEFAULT_LINES;

	@Parameter(label = "Recommended minimums",
		description = "Apply minimum recommended values to directions, lines, and increment",
		persist = false, required = false, callback = "applyMinimum")
	private boolean recommendedMin;

	@SuppressWarnings("unused")
	private void applyMinimum() {
		if (recommendedMin) {
			lines = DEFAULT_LINES;
			directions = DEFAULT_DIRECTIONS;
			samplingIncrement = minIncrement;
		}
	}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions