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

Former-commit-id: 5b1429a6b4 [formerly caf4774d38] [formerly a3e5ea25ee] [formerly 5b1429a6b4 [formerly caf4774d38] [formerly a3e5ea25ee] [formerly 51fcc6a3bc [formerly a3e5ea25ee [formerly 1b5898762a242744ee45c907599dca49ec8751af]]]]
Former-commit-id: 51fcc6a3bc
Former-commit-id: 95f35c3134 [formerly d4d6e1e2f6] [formerly 88e9bf949172f0172db55e11e2328c5e83acceda [formerly 4b29bdfb06]]
Former-commit-id: 2b06475dccd35360267320a2a4d587aed14a0ccc [formerly 924e51727a]
Former-commit-id: 7cb204d079
This commit is contained in:
Nate Jensen 2013-08-21 11:27:16 -05:00 committed by Gerrit Code Review
commit c020f9550d
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]);