1 | package de.uka.ipd.sdq.simulation.preferences; |
2 | |
3 | import org.apache.log4j.Logger; |
4 | import org.eclipse.core.runtime.CoreException; |
5 | import org.eclipse.jface.preference.ComboFieldEditor; |
6 | import org.eclipse.jface.preference.FieldEditorPreferencePage; |
7 | import org.eclipse.ui.IWorkbench; |
8 | import org.eclipse.ui.IWorkbenchPreferencePage; |
9 | |
10 | import de.uka.ipd.sdq.simulation.Activator; |
11 | import de.uka.ipd.sdq.simulation.abstractsimengine.util.AbstractSimEngineExtensionHelper; |
12 | |
13 | /** |
14 | * The preference page for the abstract simulation engine. |
15 | * |
16 | * @author Philipp Merkle |
17 | * |
18 | */ |
19 | public class SimulationPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { |
20 | |
21 | private static final Logger logger = Logger.getLogger(SimulationPreferencePage.class); |
22 | |
23 | /** the id for the simulation engine preference **/ |
24 | public static final String PREFERENCE_SIMULATION_ENGINE_ID = "simulationEngineField"; |
25 | |
26 | /** |
27 | * Default constructor. |
28 | */ |
29 | public SimulationPreferencePage() { |
30 | // use grid layout |
31 | super(GRID); |
32 | } |
33 | |
34 | @Override |
35 | public void init(IWorkbench workbench) { |
36 | this.setDescription("Select the simulation engine to be used for simulation runs."); |
37 | this.setPreferenceStore(Activator.getDefault().getPreferenceStore()); |
38 | } |
39 | |
40 | @Override |
41 | protected void createFieldEditors() { |
42 | // retrieve simulation engine names and ids |
43 | String[][] engineNamesAndIds = null; |
44 | try { |
45 | engineNamesAndIds = AbstractSimEngineExtensionHelper.getEngineNamesAndIds(); |
46 | } catch (CoreException e) { |
47 | logger.warn("Could not retrieve simulation engine names and ids.", e); |
48 | } |
49 | |
50 | // create field editor |
51 | ComboFieldEditor simulationEngineEditor = new ComboFieldEditor(PREFERENCE_SIMULATION_ENGINE_ID, |
52 | "Simulation Engine", engineNamesAndIds, getFieldEditorParent()); |
53 | addField(simulationEngineEditor); |
54 | |
55 | } |
56 | |
57 | } |