Skip to content

Commit 1832e63

Browse files
Warn user when comparing graphs of the same name (#1618)
* add a check to exit and warn the user * Revert "add a check to exit and warn the user" This reverts commit 963df95. * add controller but not functioning * remove update parameter code * remove commented code * Update whatsnew.txt
1 parent bc908aa commit 1832e63

File tree

2 files changed

+37
-9
lines changed

2 files changed

+37
-9
lines changed

CoreFunctionality/src/au/gov/asd/tac/constellation/functionality/compare/CompareGraphPlugin.java

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import au.gov.asd.tac.constellation.plugins.PluginNotificationLevel;
3737
import au.gov.asd.tac.constellation.plugins.PluginRegistry;
3838
import au.gov.asd.tac.constellation.plugins.PluginType;
39+
import au.gov.asd.tac.constellation.plugins.parameters.ParameterChange;
3940
import au.gov.asd.tac.constellation.plugins.parameters.PluginParameter;
4041
import au.gov.asd.tac.constellation.plugins.parameters.PluginParameters;
4142
import au.gov.asd.tac.constellation.plugins.parameters.types.ColorParameterType;
@@ -111,12 +112,40 @@ public PluginParameters createParameters() {
111112
originalGraph.setName("Original Graph");
112113
originalGraph.setDescription("The graph used as the starting point for the comparison");
113114
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+
});
114143

115144
final PluginParameter<SingleChoiceParameterValue> compareGraph = SingleChoiceParameterType.build(COMPARE_GRAPH_PARAMETER_ID);
116145
compareGraph.setName("Compare With Graph");
117146
compareGraph.setDescription("The graph used to compare against the original graph");
118147
parameters.addParameter(compareGraph);
119-
148+
120149
final PluginParameter<MultiChoiceParameterValue> ignoreVertexAttributes = MultiChoiceParameterType.build(IGNORE_VERTEX_ATTRIBUTES_PARAMETER_ID);
121150
ignoreVertexAttributes.setName("Ignore Node Attributes");
122151
ignoreVertexAttributes.setDescription("Ignore these attributes when comparing nodes");
@@ -198,10 +227,6 @@ public void updateParameters(final Graph graph, final PluginParameters parameter
198227
SingleChoiceParameterType.setOptions(originalGraph, graphNames);
199228
SingleChoiceParameterType.setChoice(originalGraph, GraphNode.getGraphNode(graph.getId()).getDisplayName());
200229

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-
205230
@SuppressWarnings("unchecked") //IGNORE_VERTEX_ATTRIBUTES_PARAMETER will always be of type MultiChoiceParameter
206231
final PluginParameter<MultiChoiceParameterValue> ignoreVertexAttributes = (PluginParameter<MultiChoiceParameterValue>) parameters.getParameters().get(IGNORE_VERTEX_ATTRIBUTES_PARAMETER_ID);
207232
MultiChoiceParameterType.setOptions(ignoreVertexAttributes, new ArrayList<>(registeredVertexAttributes));

CoreWhatsNewView/src/au/gov/asd/tac/constellation/views/whatsnew/whatsnew.txt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
== 3030-12-31 Getting Started
22
<p>If you're new to Constellation, read the <a href="" helpId="au.gov.asd.tac.constellation.functionality.gettingstarted">getting started guide</a>.</p>
33

4+
== 2022-02-21 Compare Graph Parameters
5+
<p>The dialog for comparing graphs in the Tools -> Compare graph menu will now update to prevent the user from comparing against the original graph.</p>
6+
47
== 2022-02-17 Add description to Step Tab names in Data Access View
58
<p> The Step Tab names in the Data Access View can now be double clicked to add a brief decription. E.g. If "Initial run" is entered, "Step 1 - Initial run" will be displayed in the Tab name. This is also saved and loaded as part of the templates.</p>
69

710
== 2022-01-24 Histogram Bins Selected Count
811
<p>The Histogram now shows the amount of bins selected out of the total bins present.</p>
912

1013
== 2022-01-21 File Importer
11-
<p>File Importer enforces all files that are being added have the same column structure.
12-
When the 'Files Include Headers' option is enabled, the column headings of all the files should be the same. When it is disabled,
13-
the number of columns should be the same. Otherwise a warning message is displayed and the files with a different structure to the
14+
<p>File Importer enforces all files that are being added have the same column structure.
15+
When the 'Files Include Headers' option is enabled, the column headings of all the files should be the same. When it is disabled,
16+
the number of columns should be the same. Otherwise a warning message is displayed and the files with a different structure to the
1417
first file added are removed.</p>
1518

1619
== 2021-12-16 Quality Control Categories
@@ -24,7 +27,7 @@ first file added are removed.</p>
2427

2528
== 2021-10-29 New Online & Offline Help
2629
<p>The help documentation is now able to be viewed both online through the constellation-app.com website and offline through a local server.</p>
27-
<p>A preference has been added where you choose to view help documentation either online or offline. This can be found via
30+
<p>A preference has been added where you choose to view help documentation either online or offline. This can be found via
2831
Setup -> Options -> CONSTELLATION -> Help -> Online Help. The help documentation is accessible through the blue question mark icons found in each view. </p>
2932

3033
== 2021-10-27 Layers View Graph Context

0 commit comments

Comments
 (0)