2 * Created on 25.11.2004
4 * TODO To change the template for this generated file go to
5 * Window - Preferences - Java - Code Style - Code Templates
7 package net.sourceforge.phpeclipse.xdebug.ui;
9 import org.eclipse.core.resources.IFile;
10 import org.eclipse.core.resources.IResource;
11 import org.eclipse.core.resources.ResourcesPlugin;
12 import org.eclipse.core.runtime.CoreException;
13 import org.eclipse.core.runtime.IPath;
14 import org.eclipse.core.runtime.Path;
15 import org.eclipse.debug.core.ILaunchConfiguration;
16 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
17 import net.sourceforge.phpeclipse.xdebug.core.IXDebugConstants;
18 import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
19 import org.eclipse.jface.window.Window;
20 import org.eclipse.swt.SWT;
21 import org.eclipse.swt.events.ModifyEvent;
22 import org.eclipse.swt.events.ModifyListener;
23 import org.eclipse.swt.events.SelectionAdapter;
24 import org.eclipse.swt.events.SelectionEvent;
25 import org.eclipse.swt.graphics.Font;
26 import org.eclipse.swt.layout.GridData;
27 import org.eclipse.swt.layout.GridLayout;
28 import org.eclipse.swt.widgets.Button;
29 import org.eclipse.swt.widgets.Composite;
30 import org.eclipse.swt.widgets.Label;
31 import org.eclipse.swt.widgets.Text;
32 import org.eclipse.ui.dialogs.ResourceListSelectionDialog;
37 * TODO To change the template for this generated type comment go to
38 * Window - Preferences - Java - Code Style - Code Templates
40 public class XDebugMainTab extends AbstractLaunchConfigurationTab {
42 private Text fProgramText;
43 private Button fProgramButton;
46 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
48 public void createControl(Composite parent) {
49 Font font = parent.getFont();
51 Composite comp = new Composite(parent, SWT.NONE);
53 GridLayout topLayout = new GridLayout();
54 topLayout.verticalSpacing = 0;
55 topLayout.numColumns = 3;
56 comp.setLayout(topLayout);
59 createVerticalSpacer(comp, 3);
61 Label programLabel = new Label(comp, SWT.NONE);
62 programLabel.setText("&Program:");
63 GridData gd = new GridData(GridData.BEGINNING);
64 programLabel.setLayoutData(gd);
65 programLabel.setFont(font);
67 fProgramText = new Text(comp, SWT.SINGLE | SWT.BORDER);
68 gd = new GridData(GridData.FILL_HORIZONTAL);
69 fProgramText.setLayoutData(gd);
70 fProgramText.setFont(font);
71 fProgramText.addModifyListener(new ModifyListener() {
72 public void modifyText(ModifyEvent e) {
73 updateLaunchConfigurationDialog();
77 fProgramButton = createPushButton(comp, "&Browse...", null); //$NON-NLS-1$
78 fProgramButton.addSelectionListener(new SelectionAdapter() {
79 public void widgetSelected(SelectionEvent e) {
86 * Open a resource chooser to select a PDA program
88 protected void browsePDAFiles() {
89 ResourceListSelectionDialog dialog = new ResourceListSelectionDialog(getShell(), ResourcesPlugin.getWorkspace().getRoot(), IResource.FILE);
90 dialog.setTitle("PDA Program");
91 dialog.setMessage("Select PDA Program");
92 // TODO: single select
93 if (dialog.open() == Window.OK) {
94 Object[] files = dialog.getResult();
95 IFile file = (IFile) files[0];
96 fProgramText.setText(file.getFullPath().toString());
101 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
103 public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
106 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
108 public void initializeFrom(ILaunchConfiguration configuration) {
110 String program = configuration.getAttribute(IXDebugConstants.ATTR_XDEBUG_PROGRAM, (String)null);
111 if (program != null) {
112 fProgramText.setText(program);
114 } catch (CoreException e) {
115 setErrorMessage(e.getMessage());
119 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
121 public void performApply(ILaunchConfigurationWorkingCopy configuration) {
122 String program = fProgramText.getText().trim();
123 if (program.length() == 0) {
126 configuration.setAttribute(IXDebugConstants.ATTR_XDEBUG_PROGRAM, program);
129 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
131 public String getName() {
135 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration)
137 public boolean isValid(ILaunchConfiguration launchConfig) {
138 String text = fProgramText.getText();
139 if (text.length() > 0) {
140 IPath path = new Path(text);
141 if (ResourcesPlugin.getWorkspace().getRoot().findMember(path) == null) {
142 setErrorMessage("Specified program does not exist");
146 setMessage("Specify a program");
148 return super.isValid(launchConfig);