Skip to content
Snippets Groups Projects
Commit 00cd3b02 authored by Raphael GIRARDOT's avatar Raphael GIRARDOT
Browse files

- Display name bug correction (CONTROLGUI-390)

- Better EDT/not EDT management to avoid an undesired Exception (CONTROLGUI-390)
parent 4b777615
No related branches found
No related tags found
No related merge requests found
......@@ -748,14 +748,19 @@ public class TrendFile {
private void retrievePlotProperties(int index) {
String fullAttributeName = parameterMap.get(DV_PREFIX + index + DV_NAME_KEY);
if (fullAttributeName.indexOf(HistoryKey.SUFFIX) > 0) {
fullAttributeName = parameterMap.get(DV_PREFIX + index + DV_DISPLAY_NAME_KEY);
// Use display name to avoid case changes (CONTROLGUI-390)
String expectedName = parameterMap.get(DV_PREFIX + index + DV_DISPLAY_NAME_KEY);
if (expectedName != null && expectedName.indexOf('/') > -1) {
fullAttributeName = expectedName;
}
IKey key = controller.convertToKey(fullAttributeName);
PlotProperties plotProperties = controller.getPlotProperties(key);
if (plotProperties == null) {
plotProperties = new PlotProperties();
if (expectedName != null) {
plotProperties.getCurve().setName(expectedName);
}
controller.setPlotProperties(key, plotProperties);
}
String clickableName = parameterMap.get(DV_PREFIX + index + DV_CLICKABLE_KEY);
......
......@@ -36,7 +36,7 @@ import fr.soleil.lib.project.swing.Splash;
public class CometeTrend extends JFrame implements ITrendFileListener {
private static final long serialVersionUID = -4976136351985828913L;
private static final long serialVersionUID = -7735610945682267214L;
private static final Logger LOGGER = LoggerFactory.getLogger(CometeTrend.class);
......@@ -333,7 +333,9 @@ public class CometeTrend extends JFrame implements ITrendFileListener {
applyWindowConfiguration(reader);
});
}
SwingUtilities.invokeLater(() -> {
loadDataFile(firstFile);
});
} else {
if (reader.readFile(firstFile)) {
chartPanel.setConfigurationReader(reader);
......@@ -343,7 +345,9 @@ public class CometeTrend extends JFrame implements ITrendFileListener {
applyWindowConfiguration(reader);
});
}
SwingUtilities.invokeLater(() -> {
loadDataFile(secondFile);
});
}
mainPanel.revalidate();
mainPanel.repaint();
......@@ -467,7 +471,7 @@ public class CometeTrend extends JFrame implements ITrendFileListener {
}
}
}
boolean chartLoader = chartDetected == null ? false : chartDetected.booleanValue();
final boolean chartLoader = chartDetected == null ? false : chartDetected.booleanValue();
final String[] arguments = filteredArguments.toArray(new String[filteredArguments.size()]);
filteredArguments.clear();
// Display help
......@@ -492,24 +496,27 @@ public class CometeTrend extends JFrame implements ITrendFileListener {
}
SPLASH.setTitle(ResourcesUtil.MESSAGES.getString(msgKey));
final CometeTrend cometeTrend = new CometeTrend(cometeTrendController);
final boolean allowSampling = samplingEnabled;
// Setup CometeTrend according to arguments
if ((arguments == null) || (arguments.length == 0)) {
cometeTrend.initAttributeTrend(samplingEnabled);
SwingUtilities.invokeLater(() -> {
cometeTrend.initAttributeTrend(allowSampling);
SPLASH.progress(100);
SPLASH.setVisible(false);
cometeTrend.setVisible(true);
cometeTrend.toFront();
});
} else {
if (trendFiler) {
final boolean trendFilerMode = trendFiler;
// GUI initializations must be done in EDT
SwingUtilities.invokeLater(() -> {
if (trendFilerMode) {
cometeTrend.initConsole();
} else if (chartLoader) {
cometeTrend.initChartLoader(samplingEnabled);
cometeTrend.initChartLoader(allowSampling);
} else {
cometeTrend.initAttributeTrend(samplingEnabled);
cometeTrend.initAttributeTrend(allowSampling);
}
SwingUtilities.invokeLater(() -> {
SPLASH.progress(100);
SPLASH.setVisible(false);
cometeTrend.setVisible(true);
......@@ -519,7 +526,10 @@ public class CometeTrend extends JFrame implements ITrendFileListener {
if (chartLoader) {
String arg = arguments[0];
if (!COMMAND_DATA.equals(arg)) {
// Load data file must be done in EDT
SwingUtilities.invokeLater(() -> {
cometeTrend.loadDataFile(arg);
});
}
} else {
// Open application only with file in argument if it is an ATK Trend configuration file
......@@ -531,17 +541,33 @@ public class CometeTrend extends JFrame implements ITrendFileListener {
// With minimum 2 args
String firstArg = arguments[0];
String fileName = arguments[1];
// Invoke in EDT to ensure finishing previous initializations
SwingUtilities.invokeLater(() -> {
switch (firstArg) {
case COMMAND_DATA:
// Load data file must be done in EDT
cometeTrend.loadDataFile(fileName);
break;
case COMMAND_NOGUI:
// loadTrendFile can be done outside of EDT: do it in a separated thread
new Thread("Load trend file: " + fileName) {
@Override
public void run() {
cometeTrend.loadTrendFile(fileName);
}
}.start();
break;
default:
// loadDataAndConfigurationFile can be done outside of EDT: do it in a separated thread
new Thread("Load data and configuration files: " + firstArg + " & " + fileName) {
@Override
public void run() {
cometeTrend.loadDataAndConfigurationFile(firstArg, fileName);
}
}.start();
break;
}
});
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment