1 package net.sourceforge.phpdt.internal.debug.ui.launcher;
4 import java.util.ArrayList;
5 import java.util.HashMap;
6 import java.util.Iterator;
9 import net.sourceforge.phpdt.internal.debug.ui.PHPDebugUiMessages;
10 import net.sourceforge.phpdt.internal.debug.ui.PHPDebugUiPlugin;
11 import net.sourceforge.phpdt.internal.debug.ui.preferences.EditPathMapDialog;
12 import net.sourceforge.phpdt.internal.debug.ui.preferences.PHPInterpreterPreferencePage;
13 import net.sourceforge.phpdt.internal.launching.PHPInterpreter;
14 import net.sourceforge.phpdt.internal.launching.PHPLaunchConfigurationAttribute;
15 import net.sourceforge.phpdt.internal.launching.PHPRuntime;
16 import net.sourceforge.phpdt.internal.ui.PHPUiImages;
18 import org.eclipse.core.resources.IProject;
19 import org.eclipse.core.resources.ResourcesPlugin;
20 import org.eclipse.core.runtime.CoreException;
21 import org.eclipse.core.runtime.IPath;
22 import org.eclipse.core.runtime.Path;
23 import org.eclipse.debug.core.ILaunchConfiguration;
24 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
25 import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
26 import org.eclipse.jface.viewers.ColumnWeightData;
27 import org.eclipse.jface.viewers.ListViewer;
28 import org.eclipse.jface.viewers.TableLayout;
29 import org.eclipse.swt.SWT;
30 import org.eclipse.swt.events.ModifyEvent;
31 import org.eclipse.swt.events.ModifyListener;
32 import org.eclipse.swt.events.MouseAdapter;
33 import org.eclipse.swt.events.MouseEvent;
34 import org.eclipse.swt.events.SelectionAdapter;
35 import org.eclipse.swt.events.SelectionEvent;
36 import org.eclipse.swt.events.SelectionListener;
37 import org.eclipse.swt.graphics.Image;
38 import org.eclipse.swt.layout.GridData;
39 import org.eclipse.swt.layout.GridLayout;
40 import org.eclipse.swt.widgets.Button;
41 import org.eclipse.swt.widgets.Combo;
42 import org.eclipse.swt.widgets.Composite;
43 import org.eclipse.swt.widgets.Label;
44 import org.eclipse.swt.widgets.TabFolder;
45 import org.eclipse.swt.widgets.TabItem;
46 import org.eclipse.swt.widgets.Table;
47 import org.eclipse.swt.widgets.TableColumn;
48 import org.eclipse.swt.widgets.TableItem;
49 import org.eclipse.swt.widgets.Text;
51 public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
52 protected ListViewer loadPathListViewer;
54 protected java.util.List installedInterpretersWorkingCopy;
56 protected Combo interpreterCombo;
58 // protected Button loadPathDefaultButton;
59 protected Button fRemoteDebugCheckBox;
61 protected Button fRemoteDebugTranslate;
63 protected Button fOpenDBGSessionInBrowserCheckBox;
65 protected Button fPathMapRemoveButton;
67 protected Button fPathMapAddButton;
69 protected Button fPathMapEditButton;
71 protected Text fRemoteSourcePath;
73 protected Table fRemoteDebugPathMapTable;
75 protected TabFolder tabFolder;
77 private class RemoteDebugTabListener extends SelectionAdapter implements
83 * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
85 public void modifyText(ModifyEvent e) {
86 updateLaunchConfigurationDialog();
92 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
94 public void widgetSelected(SelectionEvent e) {
95 Object source = e.getSource();
96 if (source == fRemoteDebugPathMapTable) {
97 setPathMapButtonsEnableState();
98 } else if (source == fPathMapAddButton) {
99 handlePathMapAddButtonSelected();
100 } else if (source == fPathMapEditButton) {
101 handlePathMapEditButtonSelected();
102 } else if (source == fPathMapRemoveButton) {
103 handlePathMapRemoveButtonSelected();
104 } else if (source == fRemoteDebugCheckBox) {
105 setRemoteTabEnableState();
106 } else if (source == fRemoteDebugTranslate) {
107 setRemoteTabEnableState();
109 updateLaunchConfigurationDialog();
117 private static final String EMPTY_STRING = ""; //$NON-NLS-1$
119 private RemoteDebugTabListener fListener = new RemoteDebugTabListener();
121 private static final boolean DEFAULT_REMOTE_DEBUG = false;
123 private static final boolean DEFAULT_REMOTE_DEBUG_TRANSLATE = false;
125 private static final boolean DEFAULT_OPEN_DBGSESSION_IN_BROWSER = true;
127 static String[] columnTitles = {
129 .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMapTableTitle.local"),
131 .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMapTableTitle.remote") };
133 public PHPEnvironmentTab() {
137 public void createControl(Composite parent) {
138 Composite composite = createPageRoot(parent);
140 tabFolder = new TabFolder(composite, SWT.NONE);
141 GridData gridData = new GridData(GridData.FILL_BOTH);
142 tabFolder.setLayoutData(gridData);
144 // addLoadPathTab(tabFolder);
145 addInterpreterTab(tabFolder);
146 addRemoteDebugTab(tabFolder);
149 protected void addRemoteDebugTab(TabFolder tabFolder) {
152 TabItem remoteDebugTab = new TabItem(tabFolder, SWT.NONE, 0);
154 .setText(PHPDebugUiMessages
155 .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.label"));
157 Composite comp = new Composite(tabFolder, SWT.NONE);
158 comp.setLayout(new GridLayout());
159 remoteDebugTab.setControl(comp);
162 fRemoteDebugCheckBox = new Button(comp, SWT.CHECK);
164 .setText(PHPDebugUiMessages
165 .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.RemoteCheckBox.label"));
166 fRemoteDebugCheckBox.setLayoutData(new GridData(
167 GridData.HORIZONTAL_ALIGN_BEGINNING));
168 fRemoteDebugCheckBox.addSelectionListener(fListener);
170 fRemoteDebugTranslate = new Button(comp, SWT.CHECK);
171 fRemoteDebugTranslate
172 .setText(PHPDebugUiMessages
173 .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.RemoteTranslate.label"));
174 fRemoteDebugTranslate.setLayoutData(new GridData(
175 GridData.HORIZONTAL_ALIGN_BEGINNING));
176 fRemoteDebugTranslate.addSelectionListener(fListener);
178 fOpenDBGSessionInBrowserCheckBox = new Button(comp, SWT.CHECK);
179 fOpenDBGSessionInBrowserCheckBox
180 .setText(PHPDebugUiMessages
181 .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.OpenDBGSessionInBrowserCheckBox.label"));
182 fOpenDBGSessionInBrowserCheckBox.setLayoutData(new GridData(
183 GridData.HORIZONTAL_ALIGN_BEGINNING));
184 fOpenDBGSessionInBrowserCheckBox.addSelectionListener(fListener);
186 label = new Label(comp, SWT.NONE);
188 .setText(PHPDebugUiMessages
189 .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.RemoteSourcePath.label"));
190 fRemoteSourcePath = new Text(comp, SWT.BORDER | SWT.SINGLE);
191 gd = new GridData(GridData.FILL_HORIZONTAL);
192 fRemoteSourcePath.setLayoutData(gd);
193 fRemoteSourcePath.addModifyListener(fListener);
195 createVerticalSpacer(comp, 1);
197 Composite pathMapComp = new Composite(comp, SWT.NONE);
198 gd = new GridData(GridData.FILL_BOTH);
199 pathMapComp.setLayoutData(gd);
200 GridLayout parametersLayout = new GridLayout();
201 parametersLayout.numColumns = 2;
202 parametersLayout.marginHeight = 0;
203 parametersLayout.marginWidth = 0;
204 pathMapComp.setLayout(parametersLayout);
206 Label pathMapLabel = new Label(pathMapComp, SWT.NONE);
208 .setText(PHPDebugUiMessages
209 .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.label"));
211 gd.horizontalSpan = 2;
212 pathMapLabel.setLayoutData(gd);
214 fRemoteDebugPathMapTable = new Table(pathMapComp, SWT.BORDER
216 TableLayout tableLayout = new TableLayout();
217 fRemoteDebugPathMapTable.setLayout(tableLayout);
219 gd = new GridData(GridData.FILL_BOTH);
220 fRemoteDebugPathMapTable.setLayoutData(gd);
221 TableColumn column1 = new TableColumn(this.fRemoteDebugPathMapTable,
224 .setText(PHPDebugUiMessages
225 .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Table.Title.local")); //$NON-NLS-1$
226 TableColumn column2 = new TableColumn(this.fRemoteDebugPathMapTable,
229 .setText(PHPDebugUiMessages
230 .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Table.Title.remote")); //$NON-NLS-1$
231 tableLayout.addColumnData(new ColumnWeightData(100));
232 tableLayout.addColumnData(new ColumnWeightData(100));
233 fRemoteDebugPathMapTable.setHeaderVisible(true);
234 fRemoteDebugPathMapTable.setLinesVisible(true);
235 fRemoteDebugPathMapTable.addSelectionListener(fListener);
236 fRemoteDebugPathMapTable.addMouseListener(new MouseAdapter() {
237 public void mouseDoubleClick(MouseEvent e) {
238 setPathMapButtonsEnableState();
239 if (fPathMapEditButton.isEnabled()) {
240 handlePathMapEditButtonSelected();
244 // fRemoteDebugPathMapTable.setEnabled(false);
246 Composite envButtonComp = new Composite(pathMapComp, SWT.NONE);
247 GridLayout envButtonLayout = new GridLayout();
248 envButtonLayout.marginHeight = 0;
249 envButtonLayout.marginWidth = 0;
250 envButtonComp.setLayout(envButtonLayout);
251 gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING
252 | GridData.HORIZONTAL_ALIGN_FILL);
253 envButtonComp.setLayoutData(gd);
255 fPathMapAddButton = createPushButton(
258 .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Button.Add.label"), null); //$NON-NLS-1$
259 fPathMapAddButton.addSelectionListener(fListener);
260 // fPathMapAddButton.setEnabled(false);
262 fPathMapEditButton = createPushButton(
265 .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Button.Edit.label"), null); //$NON-NLS-1$
266 fPathMapEditButton.addSelectionListener(fListener);
267 // fPathMapEditButton.setEnabled(false);
269 fPathMapRemoveButton = createPushButton(
272 .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Button.Remove.label"), null); //$NON-NLS-1$
273 fPathMapRemoveButton.addSelectionListener(fListener);
274 // fPathMapRemoveButton.setEnabled(false);
278 void handlePathMapAddButtonSelected() {
279 EditPathMapDialog dialog = new EditPathMapDialog(getShell(),
280 "Edit File Map", new String[] { EMPTY_STRING, EMPTY_STRING });
281 openNewPathMapDialog(dialog, null);
283 // if (dialog.open()==EditPathMapDialog.OK)
285 // TableItem item = new TableItem (fRemoteDebugPathMapTable, SWT.NONE);
286 // item.setText(0,dialog.getLocalPath());
287 // item.setText(1,dialog.getRemotePath());
288 // updateLaunchConfigurationDialog();
290 // updateLaunchConfigurationDialog();
291 setPathMapButtonsEnableState();
294 void handlePathMapRemoveButtonSelected() {
295 int[] selectedIndices = this.fRemoteDebugPathMapTable
296 .getSelectionIndices();
297 this.fRemoteDebugPathMapTable.remove(selectedIndices);
298 setPathMapButtonsEnableState();
299 updateLaunchConfigurationDialog();
302 void handlePathMapEditButtonSelected() {
303 TableItem selectedItem = this.fRemoteDebugPathMapTable.getSelection()[0];
304 String local = selectedItem.getText(0);
305 String remote = selectedItem.getText(1);
306 EditPathMapDialog dialog = new EditPathMapDialog(getShell(),
307 "Edit File Map", new String[] { local, remote });
308 openNewPathMapDialog(dialog, selectedItem);
312 * Set the enabled state of whole tab.
314 private void setRemoteTabEnableState() {
315 boolean state = fRemoteDebugCheckBox.getSelection();
316 fRemoteSourcePath.setEnabled(state);
317 fRemoteDebugTranslate.setEnabled(state);
319 fRemoteDebugPathMapTable.setEnabled(state);
321 fPathMapEditButton.setEnabled(false);
322 fPathMapRemoveButton.setEnabled(false);
323 fPathMapAddButton.setEnabled(false);
324 fOpenDBGSessionInBrowserCheckBox.setEnabled(false);
326 setPathMapButtonsEnableState();
329 updateLaunchConfigurationDialog();
333 * Set the enabled state of the three environment variable-related buttons
334 * based on the selection in the PathMapTable widget.
336 private void setPathMapButtonsEnableState() {
337 // just do nothing for now
339 if (fRemoteDebugCheckBox.getSelection()) {
340 fOpenDBGSessionInBrowserCheckBox.setEnabled(true);
341 fRemoteDebugTranslate.setEnabled(true);
342 int selectCount = this.fRemoteDebugPathMapTable
343 .getSelectionIndices().length;
344 if (selectCount < 1) {
345 fPathMapEditButton.setEnabled(false);
346 fPathMapRemoveButton.setEnabled(false);
348 fPathMapRemoveButton.setEnabled(true);
349 if (selectCount == 1) {
350 fPathMapEditButton.setEnabled(true);
352 fPathMapEditButton.setEnabled(false);
355 fPathMapAddButton.setEnabled(true);
360 * Show the specified dialog and update the pathMapTable table based on its
364 * the item to update, or <code>null</code> if adding a new
367 private void openNewPathMapDialog(EditPathMapDialog dialog,
368 TableItem updateItem) {
369 if (dialog.open() != EditPathMapDialog.OK) {
372 String[] pathPair = dialog.getPathPair();
373 TableItem tableItem = updateItem;
374 if (tableItem == null) {
375 tableItem = getTableItemForName(pathPair[0]);
376 if (tableItem == null) {
377 tableItem = new TableItem(this.fRemoteDebugPathMapTable,
381 tableItem.setText(pathPair);
382 this.fRemoteDebugPathMapTable
383 .setSelection(new TableItem[] { tableItem });
384 updateLaunchConfigurationDialog();
388 * Helper method that indicates whether the specified parameter name is
389 * already present in the parameters table.
391 private TableItem getTableItemForName(String candidateName) {
392 TableItem[] items = this.fRemoteDebugPathMapTable.getItems();
393 for (int i = 0; i < items.length; i++) {
394 String name = items[i].getText(0);
395 if (name.equals(candidateName)) {
402 // protected void addLoadPathTab(TabFolder tabFolder) {
403 // Composite loadPathComposite = new Composite(tabFolder, SWT.NONE);
404 // loadPathComposite.setLayout(new GridLayout());
406 // loadPathListViewer = new ListViewer(loadPathComposite, SWT.BORDER |
407 // SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
408 // loadPathListViewer.setContentProvider(new ListContentProvider());
409 // loadPathListViewer.setLabelProvider(new LoadPathEntryLabelProvider());
410 // loadPathListViewer.getList().setLayoutData(new
411 // GridData(GridData.FILL_BOTH));
413 // TabItem loadPathTab = new TabItem(tabFolder, SWT.NONE, 0);
414 // loadPathTab.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.loadPathTab.label"));
415 // loadPathTab.setControl(loadPathComposite);
416 // loadPathTab.setData(loadPathListViewer);
418 // loadPathDefaultButton = new Button(loadPathComposite, SWT.CHECK);
419 // loadPathDefaultButton.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.loadPathDefaultButton.label"));
420 // loadPathDefaultButton.setLayoutData(new
421 // GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
422 // loadPathDefaultButton.addSelectionListener(getLoadPathDefaultButtonSelectionListener());
424 // loadPathDefaultButton.setEnabled(false); //for now, until the load path
425 // is customizable on the configuration
428 protected SelectionListener getLoadPathSelectionListener() {
429 return new SelectionAdapter() {
430 public void widgetSelected(SelectionEvent e) {
431 System.out.println("Loadpath list selection occurred: "
437 protected SelectionListener getLoadPathDefaultButtonSelectionListener() {
438 return new SelectionAdapter() {
439 public void widgetSelected(SelectionEvent e) {
440 setUseLoadPathDefaults(((Button) e.getSource()).getSelection());
445 protected void addInterpreterTab(TabFolder tabFolder) {
446 Composite interpreterComposite = new Composite(tabFolder, SWT.NONE);
447 GridLayout layout = new GridLayout();
448 layout.numColumns = 2;
449 layout.marginHeight = 0;
450 layout.marginWidth = 0;
451 interpreterComposite.setLayout(layout);
452 interpreterComposite.setLayoutData(new GridData(
453 GridData.FILL_HORIZONTAL));
455 createVerticalSpacer(interpreterComposite, 2);
457 interpreterCombo = new Combo(interpreterComposite, SWT.READ_ONLY);
458 interpreterCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
459 initializeInterpreterCombo(interpreterCombo);
460 interpreterCombo.addModifyListener(getInterpreterComboModifyListener());
462 Button interpreterAddButton = new Button(interpreterComposite, SWT.PUSH);
464 .setText(PHPDebugUiMessages
465 .getString("LaunchConfigurationTab.PHPEnvironment.interpreterAddButton.label"));
466 interpreterAddButton.addSelectionListener(new SelectionAdapter() {
467 public void widgetSelected(SelectionEvent evt) {
468 PHPInterpreter newInterpreter = new PHPInterpreter(null);
469 File phpRuntime = PHPInterpreterPreferencePage.getFile(
471 if (phpRuntime != null) {
472 newInterpreter.setInstallLocation(phpRuntime);
473 PHPRuntime.getDefault().addInstalledInterpreter(
475 interpreterCombo.add(newInterpreter.getInstallLocation()
477 interpreterCombo.select(interpreterCombo
478 .indexOf(newInterpreter.getInstallLocation()
484 TabItem interpreterTab = new TabItem(tabFolder, SWT.NONE);
486 .setText(PHPDebugUiMessages
487 .getString("LaunchConfigurationTab.PHPEnvironment.interpreterTab.label"));
488 interpreterTab.setControl(interpreterComposite);
491 protected ModifyListener getInterpreterComboModifyListener() {
492 return new ModifyListener() {
493 public void modifyText(ModifyEvent evt) {
494 updateLaunchConfigurationDialog();
499 protected void createVerticalSpacer(Composite comp, int colSpan) {
500 Label label = new Label(comp, SWT.NONE);
501 GridData gd = new GridData();
502 gd.horizontalSpan = colSpan;
503 label.setLayoutData(gd);
506 public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
507 PHPInterpreter selectedInterpreter = PHPRuntime.getDefault()
508 .getSelectedInterpreter();
509 if (selectedInterpreter != null) {
510 String interpreterLocation = selectedInterpreter
511 .getInstallLocation().toString();
512 configuration.setAttribute(
513 PHPLaunchConfigurationAttribute.SELECTED_INTERPRETER,
514 interpreterLocation);
517 String projectName = configuration.getAttribute(
518 PHPLaunchConfigurationAttribute.PROJECT_NAME, "");
519 if (projectName != "") {
520 IProject project = ResourcesPlugin.getWorkspace().getRoot()
521 .getProject(projectName);
522 if (project != null) {
523 IPath remotePath = project.getLocation();
524 String fileName = configuration.getAttribute(
525 PHPLaunchConfigurationAttribute.FILE_NAME, "");
526 if (fileName != "") {
527 Path filePath = new Path(fileName);
528 remotePath = remotePath.append(filePath
529 .removeLastSegments(1));
531 configuration.setAttribute(
532 PHPLaunchConfigurationAttribute.REMOTE_PATH,
533 remotePath.toOSString());
536 } catch (CoreException e) {
537 // TODO Auto-generated catch block
542 public void initializeFrom(ILaunchConfiguration configuration) {
543 // initializeLoadPath(configuration);
544 initializeInterpreterSelection(configuration);
545 initializeRemoteDebug(configuration);
548 protected void initializeRemoteDebug(ILaunchConfiguration configuration) {
550 fRemoteDebugCheckBox.setSelection(configuration.getAttribute(
551 PHPLaunchConfigurationAttribute.REMOTE_DEBUG,
552 DEFAULT_REMOTE_DEBUG));
553 } catch (CoreException ce) {
554 fRemoteDebugCheckBox.setSelection(DEFAULT_REMOTE_DEBUG);
557 fRemoteDebugTranslate.setSelection(configuration.getAttribute(
558 PHPLaunchConfigurationAttribute.REMOTE_DEBUG_TRANSLATE,
559 DEFAULT_REMOTE_DEBUG_TRANSLATE));
560 } catch (CoreException ce) {
561 fRemoteDebugTranslate.setSelection(DEFAULT_REMOTE_DEBUG_TRANSLATE);
564 fOpenDBGSessionInBrowserCheckBox
565 .setSelection(configuration
567 PHPLaunchConfigurationAttribute.OPEN_DBGSESSION_IN_BROWSER,
568 DEFAULT_OPEN_DBGSESSION_IN_BROWSER));
569 } catch (CoreException ce) {
570 fOpenDBGSessionInBrowserCheckBox
571 .setSelection(DEFAULT_OPEN_DBGSESSION_IN_BROWSER);
573 setRemoteTabEnableState();
575 fRemoteSourcePath.setText(configuration.getAttribute(
576 PHPLaunchConfigurationAttribute.REMOTE_PATH, ""));
577 } catch (CoreException ce) {
578 fRemoteSourcePath.setText("");
581 updatePathMapFromConfig(configuration);
585 private void updatePathMapFromConfig(ILaunchConfiguration config) {
588 if (config != null) {
589 envVars = config.getAttribute(
590 PHPLaunchConfigurationAttribute.FILE_MAP, (Map) null);
592 updatePathMapTable(envVars, this.fRemoteDebugPathMapTable);
593 setPathMapButtonsEnableState();
594 } catch (CoreException ce) {
599 private void updatePathMapTable(Map map, Table tableWidget) {
600 tableWidget.removeAll();
604 Iterator iterator = map.keySet().iterator();
605 while (iterator.hasNext()) {
606 String key = (String) iterator.next();
607 String value = (String) map.get(key);
608 TableItem tableItem = new TableItem(tableWidget, SWT.NONE);
609 tableItem.setText(new String[] { key, value });
613 // protected void initializeLoadPath(ILaunchConfiguration configuration) {
614 // boolean useDefaultLoadPath = true;
616 // useDefaultLoadPath =
617 // configuration.getAttribute(PHPLaunchConfigurationAttribute.USE_DEFAULT_LOAD_PATH,
619 // setUseLoadPathDefaults(useDefaultLoadPath);
620 // if (useDefaultLoadPath) {
621 // String projectName =
622 // configuration.getAttribute(PHPLaunchConfigurationAttribute.PROJECT_NAME,
624 // if (projectName != "") {
625 // IProject aProject =
626 // PHPeclipsePlugin.getWorkspace().getRoot().getProject(projectName);
627 // if ((aProject != null) && JavaCore.isPHPProject(aProject)) {
628 // JavaProject thePHPProject = new JavaProject();
629 // thePHPProject.setProject(aProject);
630 // List loadPathEntries = thePHPProject.getLoadPathEntries();
631 // loadPathListViewer.setInput(loadPathEntries);
635 // } catch (CoreException e) {
640 protected void setUseLoadPathDefaults(boolean useDefaults) {
641 loadPathListViewer.getList().setEnabled(!useDefaults);
642 // loadPathDefaultButton.setSelection(useDefaults);
645 protected void initializeInterpreterSelection(
646 ILaunchConfiguration configuration) {
647 String interpreterName = null;
649 interpreterName = configuration.getAttribute(
650 PHPLaunchConfigurationAttribute.SELECTED_INTERPRETER, "");
651 } catch (CoreException e) {
654 if (interpreterName != null && !interpreterName.equals(""))
655 interpreterCombo.select(interpreterCombo.indexOf(interpreterName));
658 protected void initializeInterpreterCombo(Combo interpreterCombo) {
659 installedInterpretersWorkingCopy = new ArrayList();
660 installedInterpretersWorkingCopy.addAll(PHPRuntime.getDefault()
661 .getInstalledInterpreters());
663 String[] interpreterNames = new String[installedInterpretersWorkingCopy
665 for (int interpreterIndex = 0; interpreterIndex < installedInterpretersWorkingCopy
666 .size(); interpreterIndex++) {
667 PHPInterpreter interpreter = (PHPInterpreter) installedInterpretersWorkingCopy
668 .get(interpreterIndex);
669 interpreterNames[interpreterIndex] = interpreter
670 .getInstallLocation().toString();
672 interpreterCombo.setItems(interpreterNames);
674 PHPInterpreter selectedInterpreter = PHPRuntime.getDefault()
675 .getSelectedInterpreter();
676 if (selectedInterpreter != null)
677 interpreterCombo.select(interpreterCombo
678 .indexOf(selectedInterpreter.getInstallLocation()
682 public void performApply(ILaunchConfigurationWorkingCopy configuration) {
683 int selectionIndex = interpreterCombo.getSelectionIndex();
684 if (selectionIndex >= 0)
685 configuration.setAttribute(
686 PHPLaunchConfigurationAttribute.SELECTED_INTERPRETER,
687 interpreterCombo.getItem(selectionIndex));
689 // configuration.setAttribute(PHPLaunchConfigurationAttribute.USE_DEFAULT_LOAD_PATH,
690 // loadPathDefaultButton.getSelection());
692 // if (!loadPathDefaultButton.getSelection()) {
693 // List loadPathEntries = (List) loadPathListViewer.getInput();
694 // List loadPathStrings = new ArrayList();
695 // for (Iterator iterator = loadPathEntries.iterator();
696 // iterator.hasNext();) {
697 // LoadPathEntry entry = (LoadPathEntry) iterator.next();
698 // loadPathStrings.add(entry.getPath().toString());
700 // configuration.setAttribute(PHPLaunchConfigurationAttribute.CUSTOM_LOAD_PATH,
704 configuration.setAttribute(
705 PHPLaunchConfigurationAttribute.REMOTE_DEBUG,
706 fRemoteDebugCheckBox.getSelection());
707 configuration.setAttribute(
708 PHPLaunchConfigurationAttribute.REMOTE_DEBUG_TRANSLATE,
709 fRemoteDebugTranslate.getSelection());
710 configuration.setAttribute(PHPLaunchConfigurationAttribute.FILE_MAP,
711 getMapFromPathMapTable());
712 configuration.setAttribute(PHPLaunchConfigurationAttribute.REMOTE_PATH,
713 fRemoteSourcePath.getText());
714 configuration.setAttribute(
715 PHPLaunchConfigurationAttribute.OPEN_DBGSESSION_IN_BROWSER,
716 fOpenDBGSessionInBrowserCheckBox.getSelection());
719 protected Composite createPageRoot(Composite parent) {
720 Composite composite = new Composite(parent, SWT.NULL);
721 GridLayout layout = new GridLayout();
722 layout.numColumns = 2;
723 composite.setLayout(layout);
724 createVerticalSpacer(composite, 2);
725 setControl(composite);
730 private Map getMapFromPathMapTable() {
731 TableItem[] items = fRemoteDebugPathMapTable.getItems();
732 if (items.length == 0) {
735 Map map = new HashMap(items.length);
736 for (int i = 0; i < items.length; i++) {
737 TableItem item = items[i];
738 String key = item.getText(0);
739 String value = item.getText(1);
745 public String getName() {
746 return PHPDebugUiMessages
747 .getString("LaunchConfigurationTab.PHPEnvironment.name");
750 public boolean isValid(ILaunchConfiguration launchConfig) {
752 String selectedInterpreter = launchConfig.getAttribute(
753 PHPLaunchConfigurationAttribute.SELECTED_INTERPRETER, "");
754 if (selectedInterpreter.length() == 0) {
755 setErrorMessage(PHPDebugUiMessages
756 .getString("LaunchConfigurationTab.PHPEnvironment.interpreter_not_selected_error_message"));
759 } catch (CoreException e) {
763 setErrorMessage(null);
767 protected void log(Throwable t) {
768 PHPDebugUiPlugin.log(t);
771 public Image getImage() {
772 return PHPUiImages.get(PHPUiImages.IMG_CTOOLS_PHP);