+++ /dev/null
-package org.argeo.slc.ui.launch.script;\r
-\r
-import org.eclipse.core.resources.IResource;\r
-import org.eclipse.core.resources.ResourcesPlugin;\r
-import org.eclipse.core.runtime.CoreException;\r
-import org.eclipse.debug.core.ILaunchConfiguration;\r
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;\r
-import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;\r
-import org.eclipse.jface.window.Window;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.events.ModifyEvent;\r
-import org.eclipse.swt.events.ModifyListener;\r
-import org.eclipse.swt.events.SelectionEvent;\r
-import org.eclipse.swt.events.SelectionListener;\r
-import org.eclipse.swt.layout.GridData;\r
-import org.eclipse.swt.layout.GridLayout;\r
-import org.eclipse.swt.widgets.Button;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Label;\r
-import org.eclipse.swt.widgets.Text;\r
-import org.eclipse.ui.dialogs.ResourceSelectionDialog;\r
-\r
-public class SlcScriptLaunchConfigurationTab extends\r
- AbstractLaunchConfigurationTab {\r
-\r
- private Text scriptTF;\r
- private Text propertiesTF;\r
- private Text runtimeTF;\r
- private Text targetsTF;\r
- private Button pre093B;\r
-\r
- public void createControl(Composite parent) {\r
- Composite body = new Composite(parent, SWT.NONE);\r
- setControl(body);\r
- body.setLayout(new GridLayout(1, false));\r
- body.setFont(parent.getFont());\r
-\r
- createLabel(body, "Script location");\r
- scriptTF = createSingleText(body);\r
- createWorkspaceButton(body);\r
-\r
- createLabel(body, "Runtime");\r
- runtimeTF = createSingleText(body);\r
-\r
- createLabel(body, "Targets");\r
- targetsTF = createSingleText(body);\r
-\r
- createLabel(body, "Properties");\r
- propertiesTF = createMultipleText(body, 10);\r
-\r
- pre093B = createCheckBox(body, "Pre SLC v0.9.3");\r
- }\r
-\r
- public String getName() {\r
- return "SLC";\r
- }\r
-\r
- public void initializeFrom(ILaunchConfiguration configuration) {\r
- try {\r
- scriptTF.setText(configuration.getAttribute(\r
- SlcScriptUtils.ATTR_SCRIPT, ""));\r
-\r
- boolean pre093 = configuration.getAttribute(\r
- SlcScriptUtils.ATTR_PRE093, false);\r
-\r
- propertiesTF.setText(configuration.getAttribute(\r
- SlcScriptUtils.ATTR_PROPERTIES, ""));\r
- runtimeTF.setText(configuration.getAttribute(\r
- SlcScriptUtils.ATTR_RUNTIME, ""));\r
- targetsTF.setText(configuration.getAttribute(\r
- SlcScriptUtils.ATTR_TARGETS, ""));\r
- pre093B.setSelection(pre093);\r
- } catch (CoreException e) {\r
- throw new RuntimeException("Cannot initialize tab", e);\r
- }\r
-\r
- }\r
-\r
- public void performApply(ILaunchConfigurationWorkingCopy configuration) {\r
- configuration.setAttribute(SlcScriptUtils.ATTR_SCRIPT, scriptTF\r
- .getText());\r
- configuration.setAttribute(SlcScriptUtils.ATTR_PROPERTIES, propertiesTF\r
- .getText());\r
- configuration.setAttribute(SlcScriptUtils.ATTR_RUNTIME, runtimeTF\r
- .getText());\r
- configuration.setAttribute(SlcScriptUtils.ATTR_TARGETS, targetsTF\r
- .getText());\r
- configuration.setAttribute(SlcScriptUtils.ATTR_PRE093, pre093B\r
- .getSelection());\r
- }\r
-\r
- public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {\r
- configuration.setAttribute(SlcScriptUtils.ATTR_SCRIPT, "");\r
- configuration.setAttribute(SlcScriptUtils.ATTR_PROPERTIES, "");\r
- configuration.setAttribute(SlcScriptUtils.ATTR_RUNTIME, "");\r
- configuration.setAttribute(SlcScriptUtils.ATTR_TARGETS, "");\r
- configuration.setAttribute(SlcScriptUtils.ATTR_PRE093, false);\r
- }\r
-\r
- // UI Utils\r
- protected Label createLabel(Composite parent, String text) {\r
- Label t = new Label(parent, SWT.NONE | SWT.WRAP);\r
- t.setText(text);\r
- t.setFont(parent.getFont());\r
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);\r
- gd.horizontalSpan = 1;\r
- t.setLayoutData(gd);\r
- return t;\r
- }\r
-\r
- protected Text createSingleText(Composite parent) {\r
- Text t = new Text(parent, SWT.SINGLE | SWT.BORDER);\r
- t.setFont(parent.getFont());\r
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);\r
- gd.horizontalSpan = 1;\r
- t.setLayoutData(gd);\r
- t.addModifyListener(modifyListener);\r
- return t;\r
- }\r
-\r
- protected Text createMultipleText(Composite parent, int verticalSpan) {\r
- Text t = new Text(parent, SWT.MULTI | SWT.BORDER);\r
- t.setFont(parent.getFont());\r
- GridData gd = new GridData(GridData.FILL, GridData.FILL, true, true);\r
- gd.horizontalSpan = 1;\r
- gd.verticalSpan = verticalSpan;\r
- t.setLayoutData(gd);\r
- t.addModifyListener(modifyListener);\r
- return t;\r
- }\r
-\r
- protected Button createCheckBox(Composite parent, String label) {\r
- Button b = new Button(parent, SWT.CHECK);\r
- b.setFont(parent.getFont());\r
- b.setText(label);\r
- b.addSelectionListener(selectionListener);\r
- return b;\r
-\r
- }\r
-\r
- protected Button createWorkspaceButton(Composite parent) {\r
- Button b = new Button(parent, SWT.PUSH);\r
- b.setFont(parent.getFont());\r
- b.setText("Workspace...");\r
- b.addSelectionListener(new SelectionListener() {\r
- public void widgetDefaultSelected(SelectionEvent e) {\r
- }\r
-\r
- public void widgetSelected(SelectionEvent e) {\r
- handleWorkspaceLocationButtonSelected();\r
- }\r
- });\r
- return b;\r
- }\r
-\r
- protected void handleWorkspaceLocationButtonSelected() {\r
- ResourceSelectionDialog dialog;\r
- dialog = new ResourceSelectionDialog(getShell(), ResourcesPlugin\r
- .getWorkspace().getRoot(), "Select a file");\r
- if (dialog.open() == Window.OK) {\r
- Object[] results = dialog.getResult();\r
- if (results == null || results.length < 1) {\r
- return;\r
- }\r
- IResource resource = (IResource) results[0];\r
- scriptTF.setText(SlcScriptUtils\r
- .convertToWorkspaceLocation(resource));\r
- updateLaunchConfigurationDialog();\r
- }\r
- }\r
-\r
- // LISTENERS\r
- /**\r
- * Modify listener that simply updates the owning launch configuration\r
- * dialog.\r
- */\r
- private ModifyListener modifyListener = new ModifyListener() {\r
- public void modifyText(ModifyEvent evt) {\r
- updateLaunchConfigurationDialog();\r
- }\r
- };\r
- private SelectionListener selectionListener = new SelectionListener() {\r
- public void widgetDefaultSelected(SelectionEvent e) {\r
- }\r
-\r
- public void widgetSelected(SelectionEvent e) {\r
- updateLaunchConfigurationDialog();\r
- }\r
- };\r
-\r
-}\r