From: luukkainen Date: Thu, 26 Sep 2013 10:07:16 +0000 (+0000) Subject: Allow preference page to work without builtin OMC X-Git-Tag: 1.8.1~245 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=170f0ca8de18a4781d5ce568e8a2f529cc9d1d80;p=simantics%2Fsysdyn.git Allow preference page to work without builtin OMC fixes #4446 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@27890 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/preferences/ModelicaPreferencePage.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/preferences/ModelicaPreferencePage.java index 49213646..815fc997 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/preferences/ModelicaPreferencePage.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/preferences/ModelicaPreferencePage.java @@ -13,6 +13,8 @@ package org.simantics.sysdyn.ui.preferences; import java.io.File; import java.io.IOException; +import java.util.ArrayList; +import java.util.List; import org.eclipse.core.runtime.preferences.ConfigurationScope; import org.eclipse.core.runtime.preferences.IScopeContext; @@ -60,25 +62,22 @@ IWorkbenchPreferencePage { try { if(installed != null) installedVersion = ModelicaManager.getOMCVersion(installed); - - builtInVersion = ModelicaManager.getOMCVersion(builtIn); + if (builtIn != null) + builtInVersion = ModelicaManager.getOMCVersion(builtIn); } catch (IOException e) { } - - String[][] options; - if(installed != null) { - options = new String[][] - {{CUSTOM_PATH, CUSTOM_PATH}, - {"Local installation (" + installedVersion + ")", installed.getAbsolutePath() }, - {"Built-in (" + builtInVersion + ")", builtIn.getAbsolutePath()}, - }; - } else { - options = new String[][] - {{CUSTOM_PATH, CUSTOM_PATH}, - {"Built-in (" + builtInVersion + ")", builtIn.getAbsolutePath()}, - }; + List optionList = new ArrayList(); + optionList.add(new String[]{CUSTOM_PATH, CUSTOM_PATH}); + if (installed != null) { + optionList.add(new String[]{"Local installation (" + installedVersion + ")", installed.getAbsolutePath() }); } + if (builtIn != null) { + optionList.add(new String[]{"Built-in (" + builtInVersion + ")", builtIn.getAbsolutePath()}); + } + + String[][] options = optionList.toArray(new String[optionList.size()][]); + rg = new RadioGroupFieldEditor(OpenModelicaPreferences.OM_HOME, "&Choose the used OpenModelica version", 1, @@ -91,7 +90,7 @@ IWorkbenchPreferencePage { @Override protected void fireValueChanged(String property, Object oldValue, Object newValue) { - if((installed != null &&newValue.equals(installed.getAbsolutePath())) || newValue.equals(builtIn.getAbsolutePath())) { + if((installed != null &&newValue.equals(installed.getAbsolutePath())) || (builtIn != null && newValue.equals(builtIn.getAbsolutePath()))) { path.setStringValue((String)newValue); path.setEnabled(false, getFieldEditorParent()); } else {