1 | package de.uka.ipd.sdq.codegen.ejb; |
2 | |
3 | |
4 | import org.eclipse.core.runtime.CoreException; |
5 | import org.eclipse.debug.core.ILaunchConfiguration; |
6 | import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; |
7 | import org.eclipse.swt.SWT; |
8 | import org.eclipse.swt.events.ModifyEvent; |
9 | import org.eclipse.swt.events.ModifyListener; |
10 | import org.eclipse.swt.widgets.Combo; |
11 | import org.eclipse.swt.widgets.Composite; |
12 | |
13 | import de.uka.ipd.sdq.codegen.simucontroller.runconfig.SimuConfigurationTab; |
14 | import de.uka.ipd.sdq.workflow.pcm.ConstantsContainer; |
15 | |
16 | |
17 | public class CodeGenerationConfigurationTab extends SimuConfigurationTab { |
18 | |
19 | protected Combo comboModelToTextTarget; |
20 | |
21 | @Override |
22 | public void createControl(Composite parent) { |
23 | super.createControl(parent); |
24 | |
25 | final ModifyListener modifyListener = new ModifyListener() { |
26 | |
27 | public void modifyText(ModifyEvent e) { |
28 | CodeGenerationConfigurationTab.this.setDirty(true); |
29 | CodeGenerationConfigurationTab.this.updateLaunchConfigurationDialog(); |
30 | } |
31 | }; |
32 | |
33 | Composite container = (Composite) getControl(); |
34 | |
35 | comboModelToTextTarget = new Combo (container, SWT.READ_ONLY); |
36 | comboModelToTextTarget.setItems (new String [] { |
37 | ConstantsContainer.MODEL_TO_TEXT_TARGET_EJB, |
38 | ConstantsContainer.MODEL_TO_TEXT_TARGET_PROTO |
39 | }); |
40 | comboModelToTextTarget.setSize (400, 200); |
41 | comboModelToTextTarget.addModifyListener(modifyListener); |
42 | |
43 | |
44 | } |
45 | |
46 | @Override |
47 | public void initializeFrom(ILaunchConfiguration configuration) { |
48 | super.initializeFrom(configuration); |
49 | |
50 | try{ |
51 | String solverStr = configuration.getAttribute(ConstantsContainer.MODEL_TO_TEXT_CHOICE, |
52 | ConstantsContainer.MODEL_TO_TEXT_TARGET_EJB); |
53 | String[] items = comboModelToTextTarget.getItems(); |
54 | for (int i=0; i<items.length; i++){ |
55 | String str = items[i]; |
56 | if (str.equals(solverStr)){ |
57 | comboModelToTextTarget.select(i); |
58 | } |
59 | } |
60 | } catch(CoreException e){ |
61 | comboModelToTextTarget.select(0); |
62 | } |
63 | |
64 | |
65 | } |
66 | |
67 | @Override |
68 | public void performApply(ILaunchConfigurationWorkingCopy configuration) { |
69 | super.performApply(configuration); |
70 | |
71 | configuration.setAttribute(ConstantsContainer.MODEL_TO_TEXT_CHOICE, |
72 | comboModelToTextTarget.getText()); |
73 | |
74 | } |
75 | |
76 | |
77 | |
78 | } |