Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement/multi-choice input field replacements #2268

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
c972560
Initial checkin
andromeda-224 Dec 12, 2024
57584d9
Merge branch 'master' into enhancement/multichoice-parametertype-drop…
andromeda-224 Dec 18, 2024
430e349
Type ahead to match from start, click to drop down whole list, add se…
andromeda-224 Dec 18, 2024
a455f76
Merge branch 'master' into enhancement/multichoice-parametertype-drop…
andromeda-224 Jan 9, 2025
9bb88e5
Moved Constellation Input Support to framework, added unit tests
andromeda-224 Jan 15, 2025
cd865ac
Merge branch 'master' into enhancement/multichoice-parametertype-drop…
andromeda-224 Jan 15, 2025
74f311b
Added ConstellationTextAreaNGTest and updates to unit tests
andromeda-224 Jan 15, 2025
c4c0d82
TestParameters singleChoiceInput fix, new unit test, typo fix
andromeda-224 Jan 16, 2025
857b5bd
Update ParameterInputPaneNGTest.java
andromeda-224 Jan 20, 2025
0739aca
Delete ParameterInputPaneNGTest.java
andromeda-224 Jan 20, 2025
8356a62
Fix to filter property, trigger Select Top N specific type, enable ge…
andromeda-224 Jan 23, 2025
afffbb4
Replacing Error Report > Report Settings with Multi Choice type ahead…
andromeda-224 Jan 30, 2025
2f28971
Modified filter to use MultiChoiceInputPane
andromeda-224 Feb 6, 2025
a73eade
Merge branch 'master' into enhancement/multichoice-replacements
andromeda-224 Feb 11, 2025
51efa60
Fix to ErrorReportFullSuiteNGTest
andromeda-224 Feb 12, 2025
8321269
Merge branch 'master' into enhancement/multichoice-replacements
andromeda-224 Feb 25, 2025
6b04ede
Squashed commit of the following:
andromeda-224 Mar 2, 2025
1ff3b0d
Align the textbox and button
andromeda-224 Mar 3, 2025
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Constellation Changes

## Changes in February 2025
- Added multichoice type ahead parameter with infrastructure for future input implementations
- Multichoice input fields replaced with new multichoice type ahead parameter

## Changes in January 2025
- Removed classes `VideoCreator` and `VideoFrame` from Core Utilities as they are unused.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ protected void updateItem(final ParameterValue item, final boolean empty) {
final float f = empty ? 0 : item.toString().length() / 11F;
final Color c = Color.color(1 - f / 2F, 0, 0);
setTextFill(c);
setGraphic(new ImageView(img));
setGraphic(empty ? null : new ImageView(img));
}
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ public PluginParameters createParameters() {
types.sort(String::compareTo);
MultiChoiceParameterType.setOptions(typeParamter, types);
MultiChoiceParameterType.setChoices(typeParamter, types);
typeParamter.fireChangeEvent(ParameterChange.PROPERTY);
}
}
});
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
*/
package au.gov.asd.tac.constellation.views.errorreport;

import au.gov.asd.tac.constellation.plugins.parameters.ParameterChange;
import au.gov.asd.tac.constellation.plugins.parameters.PluginParameter;
import au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType;
import au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue;
import static au.gov.asd.tac.constellation.views.errorreport.ErrorReportTopComponent.REPORT_SETTINGS_PARAMETER_ID;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
Expand Down Expand Up @@ -204,19 +209,29 @@ public void runSessionDataTest() {

final ErrorReportEntry partialEntry5 = new ErrorReportEntry(Level.WARNING, null, "part summary", "part message", ErrorReportSessionData.getNextEntryId());
session.storeSessionError(partialEntry5);


// trigger new filter choice of WARNING
MultiChoiceParameterType.MultiChoiceParameterValue multiChoiceValue = ertcInstance.getParams().getMultiChoiceValue(REPORT_SETTINGS_PARAMETER_ID);
final List<String> checked = new ArrayList<>();
checked.add(ErrorReportTopComponent.SeverityCode.WARNING.getCode());
multiChoiceValue.setChoices(checked);
final PluginParameter<MultiChoiceParameterValue> filterTypeParameter
= (PluginParameter<MultiChoiceParameterValue>) ertcInstance.getParams().getParameters().get(REPORT_SETTINGS_PARAMETER_ID);
filterTypeParameter.fireChangeEvent(ParameterChange.PROPERTY);

System.out.println("\n\n>>>> Waiting for TC dialogs");
storedList = waitForDialogToBeDisplayed(new ArrayList<Level>(List.of(Level.WARNING)), 1);
System.out.println("\n\n>>>> Done Waiting");

System.out.println("\n>>>> Check WARNINGS list size");
assertEquals(storedList.size(), 1);

System.out.println("\n\n>>>> Waiting 5s for updates to flow through");
delay(5000);
final boolean isFlashing = ertcInstance.isIconFlashing();
assertTrue(isFlashing);

ertcInstance.setReportsExpanded(false);
ertcInstance.refreshSessionErrors();
ertcInstance.refreshSessionErrors(); // sync sessionErrors & SessionErrorsBox
final ErrorReportEntry checkEntry = ertcInstance.findActiveEntryWithId(storedList.get(0).getEntryId());
System.out.println("\n>>>> Check ErrorReportEntry : " + checkEntry.toString());
assertFalse(checkEntry.isExpanded());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ public PluginParameters createParameters() {
final PluginParameter<MultiChoiceParameterValue> attributesParameter = MultiChoiceParameterType.build(ATTRIBUTES_PARAMETER_ID, GraphAttributeParameterValue.class);
attributesParameter.setName("Attributes");
attributesParameter.setDescription("The list of attribute names to include in the export");
attributesParameter.setEnabled(false);
parameters.addParameter(attributesParameter);

final PluginParameter<BooleanParameterValue> selectedOnlyParameter = BooleanParameterType.build(SELECTED_ONLY_PARAMETER_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,18 @@
*/
package au.gov.asd.tac.constellation.plugins.gui;

import au.gov.asd.tac.constellation.plugins.parameters.ParameterChange;
import au.gov.asd.tac.constellation.plugins.parameters.PluginParameter;
import au.gov.asd.tac.constellation.plugins.parameters.PluginParameterListener;
import au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType;
import au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue;
import au.gov.asd.tac.constellation.plugins.parameters.types.ParameterValue;
import au.gov.asd.tac.constellation.utilities.gui.MultiChoiceInputField;
import au.gov.asd.tac.constellation.utilities.gui.field.MultiChoiceInput;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Platform;
import javafx.beans.property.BooleanProperty;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.scene.layout.HBox;
import au.gov.asd.tac.constellation.utilities.gui.field.framework.ConstellationInputListener;

/**
* A drop-down combo box allowing multiple selections, which is the GUI element
Expand All @@ -42,88 +40,61 @@
* au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType
*
* @author twinkle2_little
* @author capricornunicorn123
*/
public class MultiChoiceInputPane extends HBox {
public final class MultiChoiceInputPane extends ParameterInputPane<MultiChoiceParameterValue, List<ParameterValue>> {

private static final Logger LOGGER = Logger.getLogger(MultiChoiceInputPane.class.getName());

public static final int DEFAULT_WIDTH = 300;

private final ObservableList<ParameterValue> options = FXCollections.observableArrayList();
private final MultiChoiceInputField<ParameterValue> field;
private boolean isAdjusting = false;

public MultiChoiceInputPane(final PluginParameter<MultiChoiceParameterValue> parameter) {
options.addAll(MultiChoiceParameterType.getOptionsData(parameter));
field = new MultiChoiceInputField<>(options);
field.setPromptText(parameter.getDescription());
if (parameter.getParameterValue().getGuiInit() != null) {
parameter.getParameterValue().getGuiInit().init(field);
}
field.setDisable(!parameter.isEnabled());
field.setManaged(parameter.isVisible());
field.setVisible(parameter.isVisible());
this.setManaged(parameter.isVisible());
this.setVisible(parameter.isVisible());

// Set properties before adding listener to ensure unwanted onChanged events do not fire.
Platform.runLater(() -> {
@SuppressWarnings("unchecked") // Below cast will always work because getChoicesData returns List<? extends ParameterValue>.
final List<ParameterValue> checkedItems = (List<ParameterValue>) MultiChoiceParameterType.getChoicesData(parameter);
checkedItems.stream().forEach(checked -> {
final BooleanProperty bp = field.getItemBooleanProperty(checked);
if (bp != null) {
bp.setValue(true);
}
});

field.getCheckModel().getCheckedItems().addListener((final ListChangeListener.Change<? extends ParameterValue> c) -> {
if (!isAdjusting) {
MultiChoiceParameterType.setChoicesData(parameter, field.getCheckModel().getCheckedItems());
}
});
});
super(new MultiChoiceInput<ParameterValue>(), parameter);
final MultiChoiceParameterValue pv = parameter.getParameterValue();
((MultiChoiceInput) input).setOptions(pv.getOptionsData());
setFieldValue(pv.getChoicesData());

parameter.addListener((pluginParameter, change) -> Platform.runLater(() -> {
@SuppressWarnings("unchecked") //mcPluginParameter is a MultiChoiceParameter
final PluginParameter<MultiChoiceParameterValue> mcPluginParameter = (PluginParameter<MultiChoiceParameterValue>) pluginParameter;
switch (change) {
case VALUE -> {
isAdjusting = true;
field.getCheckModel().clearChecks(); //The order matters here- this should be called before clearing the options.
options.clear();
options.addAll(MultiChoiceParameterType.getOptionsData(mcPluginParameter));
@SuppressWarnings("unchecked") //checkedItems will be list of parameter values
final List<ParameterValue> checkedItems = (List<ParameterValue>) MultiChoiceParameterType.getChoicesData(mcPluginParameter);
}

field.getCheckModel().getCheckedItems();
checkedItems.forEach(checked ->
field.getCheckModel().check(checked));

// give a visual indicator if a required parameter is empty
field.setId(mcPluginParameter.isRequired() && field.getCheckModel().isEmpty() ? "invalid selection" : "");
field.setStyle("invalid selection".equals(field.getId()) ? "-fx-color: #8A1D1D" : "");
@Override
public ConstellationInputListener getFieldChangeListener(final PluginParameter<MultiChoiceParameterValue> parameter) {
return (ConstellationInputListener<List<ParameterValue>>) (final List<ParameterValue>newValue) -> {
if (newValue != null) {
MultiChoiceParameterType.setChoicesData(parameter, newValue);
}
};
}

isAdjusting = false;
@Override
public PluginParameterListener getPluginParameterListener() {
return (final PluginParameter<?> parameter, final ParameterChange change) -> Platform.runLater(() -> {
@SuppressWarnings("unchecked") //mcPluginParameter is a MultiChoiceParameter
final PluginParameter<MultiChoiceParameterValue> mcPluginParameter = (PluginParameter<MultiChoiceParameterValue>) parameter;
switch (change) {
case VALUE -> {
// Don't change the value if it isn't necessary.
final List<ParameterValue> selection = getFieldValue();
if (!selection.equals(MultiChoiceParameterType.getChoicesData(mcPluginParameter))){
setFieldValue(selection);
}
case ENABLED -> field.setDisable(!pluginParameter.isEnabled());
case VISIBLE -> {
field.setManaged(parameter.isVisible());
field.setVisible(parameter.isVisible());
this.setVisible(parameter.isVisible());
this.setManaged(parameter.isVisible());
}
case PROPERTY -> {
// Update the Pane if the Optons have changed
final List<ParameterValue> paramOptions = MultiChoiceParameterType.getOptionsData(mcPluginParameter);
if (!((MultiChoiceInput) input).getOptions().equals(paramOptions)) {
((MultiChoiceInput) input).setOptions(paramOptions);
final List<ParameterValue> choicesData = MultiChoiceParameterType.getChoicesData(mcPluginParameter);
// Only keep the value if it's in the new choices.
if (paramOptions.stream().anyMatch(choicesData::contains)) {
setFieldValue(MultiChoiceParameterType.getChoicesData(mcPluginParameter));
} else {
setFieldValue(null);
}
}
default -> LOGGER.log(Level.FINE, "ignoring parameter change type {0}.", change);
}
}));

//field width causes buttons to sit in pane space when available but retract to the same size as buttons if needed.
field.setPrefWidth(DEFAULT_WIDTH);
field.setMinWidth(50);

final HBox fieldAndButtons = new HBox();
fieldAndButtons.setSpacing(2);
fieldAndButtons.getChildren().addAll(field, field.getBulkSelectionOptionsMenuButton());
getChildren().add(fieldAndButtons);
case ENABLED -> updateFieldEnablement();
case VISIBLE -> updateFieldVisibility();
default -> LOGGER.log(Level.FINE, "ignoring parameter change type {0}.", change);
}
});
}
}
}
Loading