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

Change-Id: I41287c0af4f21dc842f99988f84da476bb6e785b

Former-commit-id: 4ae5dde2df [formerly 99a7e6a425] [formerly 4ae5dde2df [formerly 99a7e6a425] [formerly 2753c67345 [formerly 1afd52c5452925d7198fdcfa00fd5a0122ff4674]]]
Former-commit-id: 2753c67345
Former-commit-id: 44d1c31b8d [formerly 0e5cbc8dd7]
Former-commit-id: a1c4b38d3b
This commit is contained in:
Max Schenkelberg 2013-08-20 11:59:49 -05:00
parent 2ad455691f
commit 151f453686
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,22 +193,31 @@ public class PlotModelDataDefinition extends
for (LocalizationFile file : files) {
String fileName = file.getName();
if (models.containsKey(fileName) == false) {
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(",");
for (String param : individualParams) {
params.add(param);
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();
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(",");
for (String param : individualParams) {
params.add(param);
}
}
}
models.put(fileName, params);
}
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,20 +262,23 @@ public class PlotModelDataDefinition extends
possibleLevels.retainAll(returnQueue);
}
}
List<String> validLevels = new ArrayList<String>();
for (String levelid : possibleLevels) {
try {
Level level = LevelFactory.getInstance().getLevel(
Long.parseLong(levelid));
validLevels
.add(LevelMappingFactory
.getInstance(
LevelMappingFactory.VOLUMEBROWSER_LEVEL_MAPPING_FILE)
.getLevelMappingForLevel(level)
.getDisplayName());
} catch (CommunicationException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
if (possibleLevels != null) {
for (String levelid : possibleLevels) {
try {
Level level = LevelFactory.getInstance().getLevel(
Long.parseLong(levelid));
validLevels
.add(LevelMappingFactory
.getInstance(
LevelMappingFactory.VOLUMEBROWSER_LEVEL_MAPPING_FILE)
.getLevelMappingForLevel(level)
.getDisplayName());
} catch (CommunicationException e) {
statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
}
}
}
return validLevels.toArray(new String[0]);