1 /*******************************************************************************
\r
2 * Copyright (c) 2013 Association for Decentralized Information Management in
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.modelica.preferences;
\r
14 import java.io.File;
\r
15 import java.io.IOException;
\r
17 import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
\r
18 import org.eclipse.core.runtime.preferences.ConfigurationScope;
\r
19 import org.eclipse.core.runtime.preferences.IScopeContext;
\r
20 import org.osgi.service.prefs.Preferences;
\r
21 import org.simantics.modelica.Activator;
\r
22 import org.simantics.modelica.ModelicaManager;
\r
24 public class ModelicaPreferenceInitializer extends AbstractPreferenceInitializer {
\r
26 public ModelicaPreferenceInitializer() {
\r
31 public void initializeDefaultPreferences() {
\r
33 IScopeContext context = ConfigurationScope.INSTANCE;
\r
34 Preferences node = context.getNode(Activator.PLUGIN_ID);
\r
36 String omHome = node.get(OpenModelicaPreferences.OM_HOME, null);
\r
41 File dir = new File(omHome);
\r
42 if(dir == null || !dir.isDirectory())
\r
43 // OM_HOME is not a directory
\r
46 ModelicaManager.getOMCVersion(dir);
\r
47 } catch (IOException e) {
\r
48 // OpenModelica not found from directory
\r
54 private void useDefault(Preferences node) {
\r
55 node.put(OpenModelicaPreferences.OM_HOME, ModelicaManager.getDefaultModelicaHome().getAbsolutePath());
\r