use of au.gov.asd.tac.constellation.plugins.parameters.ParameterChange in project constellation by constellation-app.
the class SelectTopNPlugin method createParameters.
@Override
public PluginParameters createParameters() {
final PluginParameters params = new PluginParameters();
final List<String> modes = new ArrayList<>();
modes.add(NODE);
modes.add(TRANSACTION);
final PluginParameter<SingleChoiceParameterValue> modeParameter = SingleChoiceParameterType.build(MODE_PARAMETER_ID);
modeParameter.setName("Mode");
modeParameter.setDescription("Select either the Node or Transaction mode");
SingleChoiceParameterType.setOptions(modeParameter, modes);
params.addParameter(modeParameter);
final PluginParameter<SingleChoiceParameterValue> typeCategoryParameter = SingleChoiceParameterType.build(TYPE_CATEGORY_PARAMETER_ID);
typeCategoryParameter.setName("Type Category");
typeCategoryParameter.setDescription("The high level type category");
params.addParameter(typeCategoryParameter);
final PluginParameter<MultiChoiceParameterValue> typeParameter = MultiChoiceParameterType.build(TYPE_PARAMETER_ID);
typeParameter.setName("Specific Types");
typeParameter.setDescription("The specific types to include when calculating the top N");
params.addParameter(typeParameter);
final PluginParameter<IntegerParameterValue> limitParameter = IntegerParameterType.build(LIMIT_PARAMETER_ID);
limitParameter.setName("Limit");
limitParameter.setDescription("The limit, default being 10");
limitParameter.setIntegerValue(10);
params.addParameter(limitParameter);
params.addController(MODE_PARAMETER_ID, (PluginParameter<?> master, Map<String, PluginParameter<?>> parameters, ParameterChange change) -> {
if (change == ParameterChange.VALUE) {
final String mode = parameters.get(MODE_PARAMETER_ID).getStringValue();
if (mode != null) {
final List<String> types = new ArrayList<>();
switch(mode) {
case NODE:
for (final SchemaVertexType type : SchemaVertexTypeUtilities.getTypes()) {
if (type.isTopLevelType()) {
types.add(type.getName());
}
}
break;
case TRANSACTION:
for (final SchemaTransactionType type : SchemaTransactionTypeUtilities.getTypes()) {
if (type.isTopLevelType()) {
types.add(type.getName());
}
}
break;
default:
LOGGER.severe("Invalid mode provided. Mode values accepted are " + NODE + " or " + TRANSACTION);
}
// TYPE_CATEGORY_PARAMETER will always be of type SingleChoiceParameter
@SuppressWarnings("unchecked") final PluginParameter<SingleChoiceParameterValue> typeCategoryParamter = (PluginParameter<SingleChoiceParameterValue>) parameters.get(TYPE_CATEGORY_PARAMETER_ID);
types.sort(String::compareTo);
SingleChoiceParameterType.setOptions(typeCategoryParamter, types);
}
}
});
params.addController(TYPE_CATEGORY_PARAMETER_ID, (PluginParameter<?> master, Map<String, PluginParameter<?>> parameters, ParameterChange change) -> {
if (change == ParameterChange.VALUE) {
final String mode = parameters.get(MODE_PARAMETER_ID).getStringValue();
final String typeCategory = parameters.get(TYPE_CATEGORY_PARAMETER_ID).getStringValue();
if (mode != null && typeCategory != null) {
final List<String> types = new ArrayList<>();
switch(mode) {
case NODE:
final SchemaVertexType typeCategoryVertexType = SchemaVertexTypeUtilities.getType(typeCategory);
for (final SchemaVertexType type : SchemaVertexTypeUtilities.getTypes()) {
if (type.getSuperType().equals(typeCategoryVertexType)) {
types.add(type.getName());
}
}
break;
case TRANSACTION:
final SchemaTransactionType typeCategoryTransactionType = SchemaTransactionTypeUtilities.getType(typeCategory);
for (final SchemaTransactionType type : SchemaTransactionTypeUtilities.getTypes()) {
if (type.getSuperType().equals(typeCategoryTransactionType)) {
types.add(type.getName());
}
}
break;
default:
break;
}
// update the sub level types
// TYPE_PARAMETER will always be of type MultiChoiceParameter
@SuppressWarnings("unchecked") final PluginParameter<MultiChoiceParameterValue> typeParamter = (PluginParameter<MultiChoiceParameterValue>) parameters.get(TYPE_PARAMETER_ID);
types.sort(String::compareTo);
MultiChoiceParameterType.setOptions(typeParamter, types);
MultiChoiceParameterType.setChoices(typeParamter, types);
}
}
});
return params;
}
use of au.gov.asd.tac.constellation.plugins.parameters.ParameterChange in project constellation by constellation-app.
the class CompareGraphPlugin method createParameters.
@Override
public PluginParameters createParameters() {
final PluginParameters parameters = new PluginParameters();
final PluginParameter<SingleChoiceParameterValue> originalGraph = SingleChoiceParameterType.build(ORIGINAL_GRAPH_PARAMETER_ID);
originalGraph.setName("Original Graph");
originalGraph.setDescription("The graph used as the starting point for the comparison");
parameters.addParameter(originalGraph);
// Controller listens for value change so that the compare graph cannot be compared against itself
parameters.addController(ORIGINAL_GRAPH_PARAMETER_ID, (PluginParameter<?> master, Map<String, PluginParameter<?>> params, ParameterChange change) -> {
// When value has changed, remove choice from the comparison graph dialog
if (change == ParameterChange.VALUE) {
final String originalGraphName = params.get(ORIGINAL_GRAPH_PARAMETER_ID).getStringValue();
if (originalGraphName != null) {
final List<String> graphNames = new ArrayList<>();
final Map<String, Graph> allGraphs = GraphNode.getAllGraphs();
if (allGraphs != null) {
for (final String graphId : allGraphs.keySet()) {
graphNames.add(GraphNode.getGraphNode(graphId).getDisplayName());
}
}
// remove the current original graph selection from the list of graphs allowed to compare with
graphNames.remove(originalGraphName);
// sort drop down list
graphNames.sort(String::compareTo);
// COMPARE_GRAPH_PARAMETER_ID will always be of type SingleChoiceParameterValue
@SuppressWarnings("unchecked") final PluginParameter<SingleChoiceParameterValue> compareParamter = (PluginParameter<SingleChoiceParameterValue>) params.get(COMPARE_GRAPH_PARAMETER_ID);
SingleChoiceParameterType.setOptions(compareParamter, graphNames);
}
}
});
final PluginParameter<SingleChoiceParameterValue> compareGraph = SingleChoiceParameterType.build(COMPARE_GRAPH_PARAMETER_ID);
compareGraph.setName("Compare With Graph");
compareGraph.setDescription("The graph used to compare against the original graph");
parameters.addParameter(compareGraph);
final PluginParameter<MultiChoiceParameterValue> ignoreVertexAttributes = MultiChoiceParameterType.build(IGNORE_VERTEX_ATTRIBUTES_PARAMETER_ID);
ignoreVertexAttributes.setName("Ignore Node Attributes");
ignoreVertexAttributes.setDescription("Ignore these attributes when comparing nodes");
parameters.addParameter(ignoreVertexAttributes);
final PluginParameter<MultiChoiceParameterValue> ignoreTransactionAttributes = MultiChoiceParameterType.build(IGNORE_TRANSACTION_ATTRIBUTES_PARAMETER_ID);
ignoreTransactionAttributes.setName("Ignore Transaction Attributes");
ignoreTransactionAttributes.setDescription("Ignore these attributes when comparing transactions");
parameters.addParameter(ignoreTransactionAttributes);
final PluginParameter<ColorParameterValue> addedColour = ColorParameterType.build(ADDED_COLOUR_PARAMETER_ID);
addedColour.setName("Added Color");
addedColour.setDescription("The colour to indicate a node/transaction addition");
addedColour.setColorValue(ConstellationColor.GREEN);
parameters.addParameter(addedColour);
final PluginParameter<ColorParameterValue> removedColour = ColorParameterType.build(REMOVED_COLOUR_PARAMETER_ID);
removedColour.setName("Removed Color");
removedColour.setDescription("The colour to indicate a node/transaction removal");
removedColour.setColorValue(ConstellationColor.RED);
parameters.addParameter(removedColour);
final PluginParameter<ColorParameterValue> changedColour = ColorParameterType.build(CHANGED_COLOUR_PARAMETER_ID);
changedColour.setName("Changed Color");
changedColour.setDescription("The colour to indicate a node/transaction change");
changedColour.setColorValue(ConstellationColor.YELLOW);
parameters.addParameter(changedColour);
final PluginParameter<ColorParameterValue> unchangedColour = ColorParameterType.build(UNCHANGED_COLOUR_PARAMETER_ID);
unchangedColour.setName("Unchanged Color");
unchangedColour.setDescription("The colour to indicate no node/transaction change");
unchangedColour.setColorValue(ConstellationColor.GREY);
parameters.addParameter(unchangedColour);
return parameters;
}
use of au.gov.asd.tac.constellation.plugins.parameters.ParameterChange in project constellation by constellation-app.
the class DatetimeAttributeTranslator method createParameters.
@Override
public PluginParameters createParameters() {
final PluginParameters parameters = new PluginParameters();
final PluginParameter<SingleChoiceParameterValue> formatParam = SingleChoiceParameterType.build(FORMAT_PARAMETER_ID);
formatParam.setName("Datetime Format");
formatParam.setDescription("The datetime format");
final List<String> datetimeLabels = new ArrayList<>(DATETIME_FORMATS.keySet());
SingleChoiceParameterType.setOptions(formatParam, datetimeLabels);
SingleChoiceParameterType.setChoice(formatParam, datetimeLabels.get(0));
parameters.addParameter(formatParam);
final PluginParameter<StringParameterValue> customParam = StringParameterType.build(CUSTOM_PARAMETER_ID);
customParam.setName("Custom Format");
customParam.setDescription("A custom datetime format");
// customParam should be enabled and editable if "CUSTOM" format has been specified.
customParam.setEnabled(formatParam.getStringValue().equals(CUSTOM));
customParam.setStringValue("");
parameters.addParameter(customParam);
parameters.addController(FORMAT_PARAMETER_ID, (final PluginParameter<?> master, final Map<String, PluginParameter<?>> params, final ParameterChange change) -> {
if (change == ParameterChange.VALUE) {
final PluginParameter<?> slave = params.get(CUSTOM_PARAMETER_ID);
slave.setEnabled(master.getStringValue().equals(CUSTOM));
}
});
return parameters;
}
Aggregations