Issue #2033 moved text workstation file into plugin, fixed PlotModelDataDefinition null pointer.

Change-Id: I41287c0af4f21dc842f99988f84da476bb6e785b

Former-commit-id: 1afd52c5452925d7198fdcfa00fd5a0122ff4674
This commit is contained in:
Max Schenkelberg 2013-08-20 11:59:49 -05:00
parent d997b1b0fe
commit 2753c67345
2 changed files with 38 additions and 27 deletions

View file

@ -179,7 +179,6 @@ public class PlotModelDataDefinition extends
private void populateModels() {
if (models == null) {
Map<String, List<String>> models = new HashMap<String, List<String>>();
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationFile[] files = pm.listFiles(
pm.getLocalSearchHierarchy(LocalizationType.CAVE_STATIC),
@ -194,16 +193,19 @@ public class PlotModelDataDefinition extends
for (LocalizationFile file : files) {
String fileName = file.getName();
fileName = fileName.substring(PLOTLOCATION.length() + 1);
try {
if (models.containsKey(fileName) == false) {
List<String> params = new ArrayList<String>();
List<PlotModelElement> fields = new PlotModelFactory2(
fakeDescriptor, fileName).getPlotFields();
List<String> params = new ArrayList<String>();
for (PlotModelElement p : fields) {
if (!p.parameter.equals("")
&& !p.parameter.contains(",")) {
params.add(p.parameter);
} else if (p.parameter.contains(",")) {
String[] individualParams = p.parameter.split(",");
String[] individualParams = p.parameter
.split(",");
for (String param : individualParams) {
params.add(param);
}
@ -211,6 +213,12 @@ public class PlotModelDataDefinition extends
}
models.put(fileName, params);
}
} catch (Throwable t) {
// Ignore as some svg files are fonts and not plot models
// and the only way to tell is by catching exceptions thrown
// from PlotModelFactory2 when constructed with the non-plot
// model svg
}
}
PlotModelDataDefinition.models = models;
}
@ -254,7 +262,9 @@ public class PlotModelDataDefinition extends
possibleLevels.retainAll(returnQueue);
}
}
List<String> validLevels = new ArrayList<String>();
if (possibleLevels != null) {
for (String levelid : possibleLevels) {
try {
Level level = LevelFactory.getInstance().getLevel(
@ -266,8 +276,9 @@ public class PlotModelDataDefinition extends
.getLevelMappingForLevel(level)
.getDisplayName());
} catch (CommunicationException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
}
}
}
return validLevels.toArray(new String[0]);