|
36 | 36 | import au.gov.asd.tac.constellation.plugins.PluginNotificationLevel; |
37 | 37 | import au.gov.asd.tac.constellation.plugins.PluginRegistry; |
38 | 38 | import au.gov.asd.tac.constellation.plugins.PluginType; |
| 39 | +import au.gov.asd.tac.constellation.plugins.parameters.ParameterChange; |
39 | 40 | import au.gov.asd.tac.constellation.plugins.parameters.PluginParameter; |
40 | 41 | import au.gov.asd.tac.constellation.plugins.parameters.PluginParameters; |
41 | 42 | import au.gov.asd.tac.constellation.plugins.parameters.types.ColorParameterType; |
@@ -111,12 +112,40 @@ public PluginParameters createParameters() { |
111 | 112 | originalGraph.setName("Original Graph"); |
112 | 113 | originalGraph.setDescription("The graph used as the starting point for the comparison"); |
113 | 114 | parameters.addParameter(originalGraph); |
| 115 | + |
| 116 | + // Controller listens for value change so that the compare graph cannot be compared against itself |
| 117 | + parameters.addController(ORIGINAL_GRAPH_PARAMETER_ID, (PluginParameter<?> master, Map<String, PluginParameter<?>> params, ParameterChange change) -> { |
| 118 | + // When value has changed, remove choice from the comparison graph dialog |
| 119 | + if (change == ParameterChange.VALUE) { |
| 120 | + final String originalGraphName = params.get(ORIGINAL_GRAPH_PARAMETER_ID).getStringValue(); |
| 121 | + if (originalGraphName != null) { |
| 122 | + |
| 123 | + final List<String> graphNames = new ArrayList<>(); |
| 124 | + final Map<String, Graph> allGraphs = GraphNode.getAllGraphs(); |
| 125 | + if (allGraphs != null) { |
| 126 | + for (final String graphId : allGraphs.keySet()) { |
| 127 | + graphNames.add(GraphNode.getGraphNode(graphId).getDisplayName()); |
| 128 | + } |
| 129 | + } |
| 130 | + // remove the current original graph selection from the list of graphs allowed to compare with |
| 131 | + graphNames.remove(originalGraphName); |
| 132 | + |
| 133 | + // sort drop down list |
| 134 | + graphNames.sort(String::compareTo); |
| 135 | + |
| 136 | + |
| 137 | + @SuppressWarnings("unchecked") //COMPARE_GRAPH_PARAMETER_ID will always be of type SingleChoiceParameterValue |
| 138 | + final PluginParameter<SingleChoiceParameterValue> compareParamter = (PluginParameter<SingleChoiceParameterValue>) params.get(COMPARE_GRAPH_PARAMETER_ID); |
| 139 | + SingleChoiceParameterType.setOptions(compareParamter, graphNames); |
| 140 | + } |
| 141 | + } |
| 142 | + }); |
114 | 143 |
|
115 | 144 | final PluginParameter<SingleChoiceParameterValue> compareGraph = SingleChoiceParameterType.build(COMPARE_GRAPH_PARAMETER_ID); |
116 | 145 | compareGraph.setName("Compare With Graph"); |
117 | 146 | compareGraph.setDescription("The graph used to compare against the original graph"); |
118 | 147 | parameters.addParameter(compareGraph); |
119 | | - |
| 148 | + |
120 | 149 | final PluginParameter<MultiChoiceParameterValue> ignoreVertexAttributes = MultiChoiceParameterType.build(IGNORE_VERTEX_ATTRIBUTES_PARAMETER_ID); |
121 | 150 | ignoreVertexAttributes.setName("Ignore Node Attributes"); |
122 | 151 | ignoreVertexAttributes.setDescription("Ignore these attributes when comparing nodes"); |
@@ -198,10 +227,6 @@ public void updateParameters(final Graph graph, final PluginParameters parameter |
198 | 227 | SingleChoiceParameterType.setOptions(originalGraph, graphNames); |
199 | 228 | SingleChoiceParameterType.setChoice(originalGraph, GraphNode.getGraphNode(graph.getId()).getDisplayName()); |
200 | 229 |
|
201 | | - @SuppressWarnings("unchecked") //COMPARE_GRAPH_PARAMETER will always be of type SingleChoiceParameter |
202 | | - final PluginParameter<SingleChoiceParameterValue> compareGraph = (PluginParameter<SingleChoiceParameterValue>) parameters.getParameters().get(COMPARE_GRAPH_PARAMETER_ID); |
203 | | - SingleChoiceParameterType.setOptions(compareGraph, graphNames); |
204 | | - |
205 | 230 | @SuppressWarnings("unchecked") //IGNORE_VERTEX_ATTRIBUTES_PARAMETER will always be of type MultiChoiceParameter |
206 | 231 | final PluginParameter<MultiChoiceParameterValue> ignoreVertexAttributes = (PluginParameter<MultiChoiceParameterValue>) parameters.getParameters().get(IGNORE_VERTEX_ATTRIBUTES_PARAMETER_ID); |
207 | 232 | MultiChoiceParameterType.setOptions(ignoreVertexAttributes, new ArrayList<>(registeredVertexAttributes)); |
|
0 commit comments