]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Allow preference page to work without builtin OMC
authorluukkainen <luukkainen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 26 Sep 2013 10:07:16 +0000 (10:07 +0000)
committerluukkainen <luukkainen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 26 Sep 2013 10:07:16 +0000 (10:07 +0000)
fixes #4446

git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@27890 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/preferences/ModelicaPreferencePage.java

index 492136460e9881cb536200c16ffc0a77c88b5afa..815fc997eb576d575d119b796d9e7f5b1b8ac48d 100644 (file)
@@ -13,6 +13,8 @@ package org.simantics.sysdyn.ui.preferences;
 \r
 import java.io.File;\r
 import java.io.IOException;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
 \r
 import org.eclipse.core.runtime.preferences.ConfigurationScope;\r
 import org.eclipse.core.runtime.preferences.IScopeContext;\r
@@ -60,25 +62,22 @@ IWorkbenchPreferencePage {
         try {\r
             if(installed != null)\r
                 installedVersion = ModelicaManager.getOMCVersion(installed);\r
-\r
-            builtInVersion = ModelicaManager.getOMCVersion(builtIn);\r
+            if (builtIn != null)\r
+               builtInVersion = ModelicaManager.getOMCVersion(builtIn);\r
         } catch (IOException e) {\r
         }\r
 \r
-\r
-        String[][] options;\r
-        if(installed != null) {\r
-            options = new String[][] \r
-                    {{CUSTOM_PATH, CUSTOM_PATH},\r
-                    {"Local installation (" + installedVersion + ")", installed.getAbsolutePath() },\r
-                    {"Built-in (" + builtInVersion + ")", builtIn.getAbsolutePath()},\r
-                    };\r
-        } else {\r
-            options = new String[][] \r
-                    {{CUSTOM_PATH, CUSTOM_PATH},\r
-                    {"Built-in (" + builtInVersion + ")", builtIn.getAbsolutePath()},\r
-                    }; \r
+        List<String[]> optionList = new ArrayList<String[]>();\r
+        optionList.add(new String[]{CUSTOM_PATH, CUSTOM_PATH});\r
+        if (installed != null) {\r
+                optionList.add(new String[]{"Local installation (" + installedVersion + ")", installed.getAbsolutePath() });\r
         }\r
+        if (builtIn != null) {\r
+               optionList.add(new String[]{"Built-in (" + builtInVersion + ")", builtIn.getAbsolutePath()});\r
+        }\r
+        \r
+        String[][] options = optionList.toArray(new String[optionList.size()][]);\r
+       \r
 \r
         rg = new RadioGroupFieldEditor(OpenModelicaPreferences.OM_HOME,\r
                 "&Choose the used OpenModelica version", 1,\r
@@ -91,7 +90,7 @@ IWorkbenchPreferencePage {
 \r
             @Override\r
             protected void fireValueChanged(String property, Object oldValue, Object newValue) {\r
-                if((installed != null &&newValue.equals(installed.getAbsolutePath())) ||  newValue.equals(builtIn.getAbsolutePath())) {\r
+                if((installed != null &&newValue.equals(installed.getAbsolutePath())) ||  (builtIn != null && newValue.equals(builtIn.getAbsolutePath()))) {\r
                     path.setStringValue((String)newValue);\r
                     path.setEnabled(false, getFieldEditorParent());\r
                 } else {\r