1 package org
.argeo
.slc
.ui
.launch
.script
;
3 import org
.eclipse
.core
.resources
.IFile
;
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
.debug
.ui
.AbstractLaunchConfigurationTab
;
8 import org
.eclipse
.swt
.SWT
;
9 import org
.eclipse
.swt
.events
.ModifyEvent
;
10 import org
.eclipse
.swt
.events
.ModifyListener
;
11 import org
.eclipse
.swt
.events
.SelectionEvent
;
12 import org
.eclipse
.swt
.events
.SelectionListener
;
13 import org
.eclipse
.swt
.layout
.GridData
;
14 import org
.eclipse
.swt
.layout
.GridLayout
;
15 import org
.eclipse
.swt
.widgets
.Button
;
16 import org
.eclipse
.swt
.widgets
.Composite
;
17 import org
.eclipse
.swt
.widgets
.Label
;
18 import org
.eclipse
.swt
.widgets
.Text
;
20 public class SlcScriptLaunchConfigurationTab
extends
21 AbstractLaunchConfigurationTab
{
24 private Text propertiesTF
;
25 private Text runtimeTF
;
26 private Text targetsTF
;
27 private Button pre093B
;
29 public void createControl(Composite parent
) {
30 Composite body
= new Composite(parent
, SWT
.NONE
);
32 body
.setLayout(new GridLayout(1, false));
33 body
.setFont(parent
.getFont());
35 createLabel(body
, "Script location");
36 scriptL
= createSingleText(body
);
37 scriptL
.setEditable(false);
38 scriptL
.setBackground(body
.getBackground());
40 createLabel(body
, "Runtime");
41 runtimeTF
= createSingleText(body
);
43 createLabel(body
, "Targets");
44 targetsTF
= createSingleText(body
);
46 createLabel(body
, "Properties");
47 propertiesTF
= createMultipleText(body
, 10);
49 pre093B
= createCheckBox(body
, "Pre SLC v0.9.3");
52 public String
getName() {
56 public void initializeFrom(ILaunchConfiguration configuration
) {
58 IFile script
= (IFile
) configuration
.getMappedResources()[0];
59 scriptL
.setText(script
.getLocation().toFile().getAbsolutePath());
61 boolean pre093
= configuration
.getAttribute(
62 SlcScriptLaunchDelegate
.ATTR_PRE093
, false);
64 propertiesTF
.setText(configuration
.getAttribute(
65 SlcScriptLaunchDelegate
.ATTR_PROPERTIES
, ""));
66 runtimeTF
.setText(configuration
.getAttribute(
67 SlcScriptLaunchDelegate
.ATTR_RUNTIME
, ""));
68 targetsTF
.setText(configuration
.getAttribute(
69 SlcScriptLaunchDelegate
.ATTR_TARGETS
, ""));
70 pre093B
.setSelection(pre093
);
71 } catch (CoreException e
) {
72 throw new RuntimeException("Cannot initialize tab", e
);
77 public void performApply(ILaunchConfigurationWorkingCopy configuration
) {
78 configuration
.setAttribute(SlcScriptLaunchDelegate
.ATTR_PROPERTIES
,
79 propertiesTF
.getText());
80 configuration
.setAttribute(SlcScriptLaunchDelegate
.ATTR_RUNTIME
,
82 configuration
.setAttribute(SlcScriptLaunchDelegate
.ATTR_TARGETS
,
84 configuration
.setAttribute(SlcScriptLaunchDelegate
.ATTR_PRE093
, pre093B
88 public void setDefaults(ILaunchConfigurationWorkingCopy configuration
) {
92 protected Label
createLabel(Composite parent
, String text
) {
93 Label t
= new Label(parent
, SWT
.NONE
| SWT
.WRAP
);
95 t
.setFont(parent
.getFont());
96 GridData gd
= new GridData(GridData
.FILL_HORIZONTAL
);
97 gd
.horizontalSpan
= 1;
102 protected Text
createSingleText(Composite parent
) {
103 Text t
= new Text(parent
, SWT
.SINGLE
| SWT
.BORDER
);
104 t
.setFont(parent
.getFont());
105 GridData gd
= new GridData(GridData
.FILL_HORIZONTAL
);
106 gd
.horizontalSpan
= 1;
108 t
.addModifyListener(modifyListener
);
112 protected Text
createMultipleText(Composite parent
, int verticalSpan
) {
113 Text t
= new Text(parent
, SWT
.MULTI
| SWT
.BORDER
);
114 t
.setFont(parent
.getFont());
115 GridData gd
= new GridData(GridData
.FILL
, GridData
.FILL
, true, true);
116 gd
.horizontalSpan
= 1;
117 gd
.verticalSpan
= verticalSpan
;
119 t
.addModifyListener(modifyListener
);
123 protected Button
createCheckBox(Composite parent
, String label
) {
124 Button b
= new Button(parent
, SWT
.CHECK
);
125 b
.setFont(parent
.getFont());
127 b
.addSelectionListener(selectionListener
);
134 * Modify listener that simply updates the owning launch configuration
137 private ModifyListener modifyListener
= new ModifyListener() {
138 public void modifyText(ModifyEvent evt
) {
139 updateLaunchConfigurationDialog();
142 private SelectionListener selectionListener
= new SelectionListener() {
143 public void widgetDefaultSelected(SelectionEvent e
) {
146 public void widgetSelected(SelectionEvent e
) {
147 updateLaunchConfigurationDialog();