Search in sources :

Example 1 with PluginParameterController

use of au.gov.asd.tac.constellation.plugins.parameters.PluginParameterController in project constellation by constellation-app.

the class MergeNodesPluginNGTest method createParameters.

@Test
public void createParameters() {
    final PluginParameters actual = mergeNodesPlugin.createParameters();
    final Map<String, PluginParameter<?>> parameters = actual.getParameters();
    assertEquals(parameters.keySet(), Set.of("MergeNodesPlugin.merge_type", "MergeNodesPlugin.threshold", "MergeNodesPlugin.merger", "MergeNodesPlugin.lead", "MergeNodesPlugin.selected"));
    final PluginParameter<SingleChoiceParameterValue> mergeTypeParameter = (PluginParameter<SingleChoiceParameterValue>) parameters.get("MergeNodesPlugin.merge_type");
    assertEquals(mergeTypeParameter.getName(), "Merge By");
    assertEquals(mergeTypeParameter.getDescription(), "Nodes will be merged based on this");
    assertEquals(mergeTypeParameter.getParameterValue().getOptions(), List.of(TestMergeType.NAME, "Geospatial Distance", "Identifier Prefix Length", "Identifier Suffix Length", "Supported Type"));
    assertEquals(mergeTypeParameter.getProperty("choices").getClass(), Object.class);
    final PluginParameter<IntegerParameterValue> thresholdParameter = (PluginParameter<IntegerParameterValue>) parameters.get("MergeNodesPlugin.threshold");
    assertEquals(thresholdParameter.getName(), "Threshold");
    assertEquals(thresholdParameter.getDescription(), "The maximum nodes to merge");
    assertFalse(thresholdParameter.isEnabled());
    final PluginParameter<SingleChoiceParameterValue> mergingRuleParameter = (PluginParameter<SingleChoiceParameterValue>) parameters.get("MergeNodesPlugin.merger");
    assertEquals(mergingRuleParameter.getName(), "Merging Rule");
    assertEquals(mergingRuleParameter.getDescription(), "The rule deciding how attributes are merged");
    assertEquals(mergingRuleParameter.getParameterValue().getOptions(), List.of("Retain lead vertex attributes if present", "Retain lead vertex attributes always", "Copy merged vertex attributes if present", "Copy merged vertex attributes always"));
    assertEquals(mergingRuleParameter.getProperty("choices").getClass(), Object.class);
    assertEquals(mergingRuleParameter.getParameterValue().getChoice(), "Retain lead vertex attributes if present");
    assertFalse(mergingRuleParameter.isEnabled());
    final PluginParameter<SingleChoiceParameterValue> leadNodeParameter = (PluginParameter<SingleChoiceParameterValue>) parameters.get("MergeNodesPlugin.lead");
    assertEquals(leadNodeParameter.getName(), "Lead Node");
    assertEquals(leadNodeParameter.getDescription(), "The rule deciding how to choose the lead node");
    assertEquals(leadNodeParameter.getParameterValue().getOptions(), List.of("Longest Value", "Shortest Value", "Ask Me"));
    assertEquals(leadNodeParameter.getProperty("choices").getClass(), Object.class);
    assertEquals(leadNodeParameter.getParameterValue().getChoice(), "Longest Value");
    assertFalse(leadNodeParameter.isEnabled());
    final PluginParameter<BooleanParameterValue> selectedOnlyParameter = (PluginParameter<BooleanParameterValue>) parameters.get("MergeNodesPlugin.selected");
    assertEquals(selectedOnlyParameter.getName(), "Selected Only");
    assertEquals(selectedOnlyParameter.getDescription(), "Merge Only Selected Nodes");
    assertTrue(selectedOnlyParameter.getBooleanValue());
    assertFalse(selectedOnlyParameter.isEnabled());
    final Map<String, PluginParameterController> controllers = actual.getControllers();
    assertEquals(controllers.keySet(), Set.of("MergeNodesPlugin.merge_type"));
}
Also used : BooleanParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue) IntegerParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.IntegerParameterType.IntegerParameterValue) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) PluginParameterController(au.gov.asd.tac.constellation.plugins.parameters.PluginParameterController) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) SingleChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue) Test(org.testng.annotations.Test)

Example 2 with PluginParameterController

use of au.gov.asd.tac.constellation.plugins.parameters.PluginParameterController in project constellation by constellation-app.

the class MapViewTopComponent method createParameters.

private PluginParameters createParameters() {
    final PluginParameters parameters = new PluginParameters();
    final PluginParameter<SingleChoiceParameterValue> geoTypeParameter = SingleChoiceParameterType.build(PARAMETER_TYPE);
    geoTypeParameter.setName("Geo Type");
    SingleChoiceParameterType.setOptions(geoTypeParameter, Arrays.asList(GEO_TYPE_COORDINATE, GEO_TYPE_GEOHASH, GEO_TYPE_MGRS));
    SingleChoiceParameterType.setChoice(geoTypeParameter, GEO_TYPE_COORDINATE);
    parameters.addParameter(geoTypeParameter);
    final PluginParameter<StringParameterValue> locationParameter = StringParameterType.build(PARAMETER_LOCATION);
    locationParameter.setName("Location");
    locationParameter.setDescription("Enter a coordinate in decimal degrees (and optionally " + "a radius in kilometers) with components separated by spaces or commas");
    locationParameter.setStringValue(null);
    parameters.addParameter(locationParameter);
    PluginParameterController controller = ((master, params, change) -> {
        // master will need to be of type SingleChoiceParameter
        @SuppressWarnings("unchecked") final PluginParameter<SingleChoiceParameterValue> typedMaster = (PluginParameter<SingleChoiceParameterValue>) master;
        switch(SingleChoiceParameterType.getChoice(typedMaster)) {
            case GEO_TYPE_COORDINATE:
                params.get(PARAMETER_LOCATION).setDescription("Enter a coordinate in decimal degrees (and optionally a radius " + "in kilometers) with components separated by spaces or commas");
                break;
            case GEO_TYPE_GEOHASH:
                params.get(PARAMETER_LOCATION).setDescription("Enter a base-16 geohash value");
                break;
            case GEO_TYPE_MGRS:
                params.get(PARAMETER_LOCATION).setDescription("Enter an MGRS value");
                break;
            default:
                break;
        }
    });
    parameters.addController(PARAMETER_TYPE, controller);
    return parameters;
}
Also used : StringParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.StringParameterValue) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) PluginParameterController(au.gov.asd.tac.constellation.plugins.parameters.PluginParameterController) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) SingleChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue)

Aggregations

PluginParameter (au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)2 PluginParameterController (au.gov.asd.tac.constellation.plugins.parameters.PluginParameterController)2 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)2 SingleChoiceParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue)2 BooleanParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue)1 IntegerParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.IntegerParameterType.IntegerParameterValue)1 StringParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.StringParameterValue)1 Test (org.testng.annotations.Test)1