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;
60 protected Button fRemoteDebugTranslate;
62 protected Button fOpenDBGSessionInBrowserCheckBox;
64 protected Button fPathMapRemoveButton;
66 protected Button fPathMapAddButton;
68 protected Button fPathMapEditButton;
70 protected Text fRemoteSourcePath;
72 protected Table fRemoteDebugPathMapTable;
74 protected TabFolder tabFolder;
76 private class RemoteDebugTabListener extends SelectionAdapter implements ModifyListener {
81 * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
83 public void modifyText(ModifyEvent e) {
84 updateLaunchConfigurationDialog();
90 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
92 public void widgetSelected(SelectionEvent e) {
93 Object source = e.getSource();
94 if (source == fRemoteDebugPathMapTable) {
95 setPathMapButtonsEnableState();
96 } else if (source == fPathMapAddButton) {
97 handlePathMapAddButtonSelected();
98 } else if (source == fPathMapEditButton) {
99 handlePathMapEditButtonSelected();
100 } else if (source == fPathMapRemoveButton) {
101 handlePathMapRemoveButtonSelected();
102 } else if (source == fRemoteDebugCheckBox) {
103 setRemoteTabEnableState();
104 } else if (source == fRemoteDebugTranslate) {
105 setRemoteTabEnableState();
107 updateLaunchConfigurationDialog();
115 private static final String EMPTY_STRING = ""; //$NON-NLS-1$
117 private RemoteDebugTabListener fListener = new RemoteDebugTabListener();
119 private static final boolean DEFAULT_REMOTE_DEBUG = false;
121 private static final boolean DEFAULT_REMOTE_DEBUG_TRANSLATE = false;
123 private static final boolean DEFAULT_OPEN_DBGSESSION_IN_BROWSER = true;
125 static String[] columnTitles = {
126 PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMapTableTitle.local"),
127 PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMapTableTitle.remote") };
129 public PHPEnvironmentTab() {
133 public void createControl(Composite parent) {
134 Composite composite = createPageRoot(parent);
136 tabFolder = new TabFolder(composite, SWT.NONE);
137 GridData gridData = new GridData(GridData.FILL_BOTH);
138 tabFolder.setLayoutData(gridData);
140 // addLoadPathTab(tabFolder);
141 addInterpreterTab(tabFolder);
142 addRemoteDebugTab(tabFolder);
145 protected void addRemoteDebugTab(TabFolder tabFolder) {
148 TabItem remoteDebugTab = new TabItem(tabFolder, SWT.NONE, 0);
149 remoteDebugTab.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.label"));
151 Composite comp = new Composite(tabFolder, SWT.NONE);
152 comp.setLayout(new GridLayout());
153 remoteDebugTab.setControl(comp);
156 fRemoteDebugCheckBox = new Button(comp, SWT.CHECK);
157 fRemoteDebugCheckBox.setText(PHPDebugUiMessages
158 .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.RemoteCheckBox.label"));
159 fRemoteDebugCheckBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
160 fRemoteDebugCheckBox.addSelectionListener(fListener);
162 fRemoteDebugTranslate = new Button(comp, SWT.CHECK);
163 fRemoteDebugTranslate.setText(PHPDebugUiMessages
164 .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.RemoteTranslate.label"));
165 fRemoteDebugTranslate.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
166 fRemoteDebugTranslate.addSelectionListener(fListener);
168 fOpenDBGSessionInBrowserCheckBox = new Button(comp, SWT.CHECK);
169 fOpenDBGSessionInBrowserCheckBox.setText(PHPDebugUiMessages
170 .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.OpenDBGSessionInBrowserCheckBox.label"));
171 fOpenDBGSessionInBrowserCheckBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
172 fOpenDBGSessionInBrowserCheckBox.addSelectionListener(fListener);
174 label = new Label(comp, SWT.NONE);
175 label.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.RemoteSourcePath.label"));
176 fRemoteSourcePath = new Text(comp, SWT.BORDER | SWT.SINGLE);
177 gd = new GridData(GridData.FILL_HORIZONTAL);
178 fRemoteSourcePath.setLayoutData(gd);
179 fRemoteSourcePath.addModifyListener(fListener);
181 createVerticalSpacer(comp, 1);
183 Composite pathMapComp = new Composite(comp, SWT.NONE);
184 gd = new GridData(GridData.FILL_BOTH);
185 pathMapComp.setLayoutData(gd);
186 GridLayout parametersLayout = new GridLayout();
187 parametersLayout.numColumns = 2;
188 parametersLayout.marginHeight = 0;
189 parametersLayout.marginWidth = 0;
190 pathMapComp.setLayout(parametersLayout);
192 Label pathMapLabel = new Label(pathMapComp, SWT.NONE);
193 pathMapLabel.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.label"));
195 gd.horizontalSpan = 2;
196 pathMapLabel.setLayoutData(gd);
198 fRemoteDebugPathMapTable = new Table(pathMapComp, SWT.BORDER | SWT.MULTI);
199 TableLayout tableLayout = new TableLayout();
200 fRemoteDebugPathMapTable.setLayout(tableLayout);
202 gd = new GridData(GridData.FILL_BOTH);
203 fRemoteDebugPathMapTable.setLayoutData(gd);
204 TableColumn column1 = new TableColumn(this.fRemoteDebugPathMapTable, SWT.NONE);
205 column1.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Table.Title.local")); //$NON-NLS-1$
206 TableColumn column2 = new TableColumn(this.fRemoteDebugPathMapTable, SWT.NONE);
208 .setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Table.Title.remote")); //$NON-NLS-1$
209 tableLayout.addColumnData(new ColumnWeightData(100));
210 tableLayout.addColumnData(new ColumnWeightData(100));
211 fRemoteDebugPathMapTable.setHeaderVisible(true);
212 fRemoteDebugPathMapTable.setLinesVisible(true);
213 fRemoteDebugPathMapTable.addSelectionListener(fListener);
214 fRemoteDebugPathMapTable.addMouseListener(new MouseAdapter() {
215 public void mouseDoubleClick(MouseEvent e) {
216 setPathMapButtonsEnableState();
217 if (fPathMapEditButton.isEnabled()) {
218 handlePathMapEditButtonSelected();
222 // fRemoteDebugPathMapTable.setEnabled(false);
224 Composite envButtonComp = new Composite(pathMapComp, SWT.NONE);
225 GridLayout envButtonLayout = new GridLayout();
226 envButtonLayout.marginHeight = 0;
227 envButtonLayout.marginWidth = 0;
228 envButtonComp.setLayout(envButtonLayout);
229 gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL);
230 envButtonComp.setLayoutData(gd);
232 fPathMapAddButton = createPushButton(envButtonComp, PHPDebugUiMessages
233 .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Button.Add.label"), null); //$NON-NLS-1$
234 fPathMapAddButton.addSelectionListener(fListener);
235 // fPathMapAddButton.setEnabled(false);
237 fPathMapEditButton = createPushButton(envButtonComp, PHPDebugUiMessages
238 .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Button.Edit.label"), null); //$NON-NLS-1$
239 fPathMapEditButton.addSelectionListener(fListener);
240 // fPathMapEditButton.setEnabled(false);
242 fPathMapRemoveButton = createPushButton(envButtonComp, PHPDebugUiMessages
243 .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Button.Remove.label"), null); //$NON-NLS-1$
244 fPathMapRemoveButton.addSelectionListener(fListener);
245 // fPathMapRemoveButton.setEnabled(false);
249 void handlePathMapAddButtonSelected() {
250 EditPathMapDialog dialog = new EditPathMapDialog(getShell(), "Edit File Map", new String[] { EMPTY_STRING, EMPTY_STRING });
251 openNewPathMapDialog(dialog, null);
253 // if (dialog.open()==EditPathMapDialog.OK)
255 // TableItem item = new TableItem (fRemoteDebugPathMapTable, SWT.NONE);
256 // item.setText(0,dialog.getLocalPath());
257 // item.setText(1,dialog.getRemotePath());
258 // updateLaunchConfigurationDialog();
260 // updateLaunchConfigurationDialog();
261 setPathMapButtonsEnableState();
264 void handlePathMapRemoveButtonSelected() {
265 int[] selectedIndices = this.fRemoteDebugPathMapTable.getSelectionIndices();
266 this.fRemoteDebugPathMapTable.remove(selectedIndices);
267 setPathMapButtonsEnableState();
268 updateLaunchConfigurationDialog();
271 void handlePathMapEditButtonSelected() {
272 TableItem selectedItem = this.fRemoteDebugPathMapTable.getSelection()[0];
273 String local = selectedItem.getText(0);
274 String remote = selectedItem.getText(1);
275 EditPathMapDialog dialog = new EditPathMapDialog(getShell(), "Edit File Map", new String[] { local, remote });
276 openNewPathMapDialog(dialog, selectedItem);
280 * Set the enabled state of whole tab.
282 private void setRemoteTabEnableState() {
283 boolean state = fRemoteDebugCheckBox.getSelection();
284 fRemoteSourcePath.setEnabled(state);
285 fRemoteDebugTranslate.setEnabled(state);
287 fRemoteDebugPathMapTable.setEnabled(state);
289 fPathMapEditButton.setEnabled(false);
290 fPathMapRemoveButton.setEnabled(false);
291 fPathMapAddButton.setEnabled(false);
292 fOpenDBGSessionInBrowserCheckBox.setEnabled(false);
294 setPathMapButtonsEnableState();
297 updateLaunchConfigurationDialog();
301 * Set the enabled state of the three environment variable-related buttons based on the selection in the PathMapTable widget.
303 private void setPathMapButtonsEnableState() {
304 // just do nothing for now
306 if (fRemoteDebugCheckBox.getSelection()) {
307 fOpenDBGSessionInBrowserCheckBox.setEnabled(true);
308 fRemoteDebugTranslate.setEnabled(true);
309 int selectCount = this.fRemoteDebugPathMapTable.getSelectionIndices().length;
310 if (selectCount < 1) {
311 fPathMapEditButton.setEnabled(false);
312 fPathMapRemoveButton.setEnabled(false);
314 fPathMapRemoveButton.setEnabled(true);
315 if (selectCount == 1) {
316 fPathMapEditButton.setEnabled(true);
318 fPathMapEditButton.setEnabled(false);
321 fPathMapAddButton.setEnabled(true);
326 * Show the specified dialog and update the pathMapTable table based on its results.
329 * the item to update, or <code>null</code> if adding a new item
331 private void openNewPathMapDialog(EditPathMapDialog dialog, TableItem updateItem) {
332 if (dialog.open() != EditPathMapDialog.OK) {
335 String[] pathPair = dialog.getPathPair();
336 TableItem tableItem = updateItem;
337 if (tableItem == null) {
338 tableItem = getTableItemForName(pathPair[0]);
339 if (tableItem == null) {
340 tableItem = new TableItem(this.fRemoteDebugPathMapTable, SWT.NONE);
343 tableItem.setText(pathPair);
344 this.fRemoteDebugPathMapTable.setSelection(new TableItem[] { tableItem });
345 updateLaunchConfigurationDialog();
349 * Helper method that indicates whether the specified parameter name is already present in the parameters table.
351 private TableItem getTableItemForName(String candidateName) {
352 TableItem[] items = this.fRemoteDebugPathMapTable.getItems();
353 for (int i = 0; i < items.length; i++) {
354 String name = items[i].getText(0);
355 if (name.equals(candidateName)) {
362 // protected void addLoadPathTab(TabFolder tabFolder) {
363 // Composite loadPathComposite = new Composite(tabFolder, SWT.NONE);
364 // loadPathComposite.setLayout(new GridLayout());
366 // loadPathListViewer = new ListViewer(loadPathComposite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
367 // loadPathListViewer.setContentProvider(new ListContentProvider());
368 // loadPathListViewer.setLabelProvider(new LoadPathEntryLabelProvider());
369 // loadPathListViewer.getList().setLayoutData(new GridData(GridData.FILL_BOTH));
371 // TabItem loadPathTab = new TabItem(tabFolder, SWT.NONE, 0);
372 // loadPathTab.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.loadPathTab.label"));
373 // loadPathTab.setControl(loadPathComposite);
374 // loadPathTab.setData(loadPathListViewer);
376 // loadPathDefaultButton = new Button(loadPathComposite, SWT.CHECK);
377 // loadPathDefaultButton.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.loadPathDefaultButton.label"));
378 // loadPathDefaultButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
379 // loadPathDefaultButton.addSelectionListener(getLoadPathDefaultButtonSelectionListener());
381 // loadPathDefaultButton.setEnabled(false); //for now, until the load path is customizable on the configuration
384 protected SelectionListener getLoadPathSelectionListener() {
385 return new SelectionAdapter() {
386 public void widgetSelected(SelectionEvent e) {
387 System.out.println("Loadpath list selection occurred: " + e.getSource());
392 protected SelectionListener getLoadPathDefaultButtonSelectionListener() {
393 return new SelectionAdapter() {
394 public void widgetSelected(SelectionEvent e) {
395 setUseLoadPathDefaults(((Button) e.getSource()).getSelection());
400 protected void addInterpreterTab(TabFolder tabFolder) {
401 Composite interpreterComposite = new Composite(tabFolder, SWT.NONE);
402 GridLayout layout = new GridLayout();
403 layout.numColumns = 2;
404 layout.marginHeight = 0;
405 layout.marginWidth = 0;
406 interpreterComposite.setLayout(layout);
407 interpreterComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
409 createVerticalSpacer(interpreterComposite, 2);
411 interpreterCombo = new Combo(interpreterComposite, SWT.READ_ONLY);
412 interpreterCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
413 initializeInterpreterCombo(interpreterCombo);
414 interpreterCombo.addModifyListener(getInterpreterComboModifyListener());
416 Button interpreterAddButton = new Button(interpreterComposite, SWT.PUSH);
417 interpreterAddButton.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.interpreterAddButton.label"));
418 interpreterAddButton.addSelectionListener(new SelectionAdapter() {
419 public void widgetSelected(SelectionEvent evt) {
420 PHPInterpreter newInterpreter = new PHPInterpreter(null);
421 File phpRuntime = PHPInterpreterPreferencePage.getFile(getShell(), null);
422 if (phpRuntime != null) {
423 newInterpreter.setInstallLocation(phpRuntime);
424 PHPRuntime.getDefault().addInstalledInterpreter(newInterpreter);
425 interpreterCombo.add(newInterpreter.getInstallLocation().toString());
426 interpreterCombo.select(interpreterCombo.indexOf(newInterpreter.getInstallLocation().toString()));
431 TabItem interpreterTab = new TabItem(tabFolder, SWT.NONE);
432 interpreterTab.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.interpreterTab.label"));
433 interpreterTab.setControl(interpreterComposite);
436 protected ModifyListener getInterpreterComboModifyListener() {
437 return new ModifyListener() {
438 public void modifyText(ModifyEvent evt) {
439 updateLaunchConfigurationDialog();
444 protected void createVerticalSpacer(Composite comp, int colSpan) {
445 Label label = new Label(comp, SWT.NONE);
446 GridData gd = new GridData();
447 gd.horizontalSpan = colSpan;
448 label.setLayoutData(gd);
451 public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
452 PHPInterpreter selectedInterpreter = PHPRuntime.getDefault()
453 .getSelectedInterpreter();
454 if (selectedInterpreter != null) {
455 String interpreterLocation = selectedInterpreter
456 .getInstallLocation().toString();
457 configuration.setAttribute(
458 PHPLaunchConfigurationAttribute.SELECTED_INTERPRETER,
459 interpreterLocation);
462 String projectName = configuration.getAttribute(PHPLaunchConfigurationAttribute.PROJECT_NAME,"");
463 if (projectName!="") {
464 IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
466 IPath remotePath = project.getLocation();
467 String fileName=configuration.getAttribute(PHPLaunchConfigurationAttribute.FILE_NAME,"");
469 Path filePath = new Path(fileName);
470 remotePath=remotePath.append(filePath.removeLastSegments(1));
472 configuration.setAttribute(PHPLaunchConfigurationAttribute.REMOTE_PATH, remotePath.toOSString());
475 } catch (CoreException e) {
476 // TODO Auto-generated catch block
481 public void initializeFrom(ILaunchConfiguration configuration) {
482 // initializeLoadPath(configuration);
483 initializeInterpreterSelection(configuration);
484 initializeRemoteDebug(configuration);
487 protected void initializeRemoteDebug(ILaunchConfiguration configuration) {
489 fRemoteDebugCheckBox.setSelection(configuration.getAttribute(PHPLaunchConfigurationAttribute.REMOTE_DEBUG,
490 DEFAULT_REMOTE_DEBUG));
491 } catch (CoreException ce) {
492 fRemoteDebugCheckBox.setSelection(DEFAULT_REMOTE_DEBUG);
495 fRemoteDebugTranslate.setSelection(configuration.getAttribute(
496 PHPLaunchConfigurationAttribute.REMOTE_DEBUG_TRANSLATE, DEFAULT_REMOTE_DEBUG_TRANSLATE));
497 } catch (CoreException ce) {
498 fRemoteDebugTranslate.setSelection(DEFAULT_REMOTE_DEBUG_TRANSLATE);
501 fOpenDBGSessionInBrowserCheckBox.setSelection(configuration.getAttribute(
502 PHPLaunchConfigurationAttribute.OPEN_DBGSESSION_IN_BROWSER, DEFAULT_OPEN_DBGSESSION_IN_BROWSER));
503 } catch (CoreException ce) {
504 fOpenDBGSessionInBrowserCheckBox.setSelection(DEFAULT_OPEN_DBGSESSION_IN_BROWSER);
506 setRemoteTabEnableState();
508 fRemoteSourcePath.setText(configuration.getAttribute(PHPLaunchConfigurationAttribute.REMOTE_PATH, ""));
509 } catch (CoreException ce) {
510 fRemoteSourcePath.setText("");
513 updatePathMapFromConfig(configuration);
517 private void updatePathMapFromConfig(ILaunchConfiguration config) {
520 if (config != null) {
521 envVars = config.getAttribute(PHPLaunchConfigurationAttribute.FILE_MAP, (Map) null);
523 updatePathMapTable(envVars, this.fRemoteDebugPathMapTable);
524 setPathMapButtonsEnableState();
525 } catch (CoreException ce) {
530 private void updatePathMapTable(Map map, Table tableWidget) {
531 tableWidget.removeAll();
535 Iterator iterator = map.keySet().iterator();
536 while (iterator.hasNext()) {
537 String key = (String) iterator.next();
538 String value = (String) map.get(key);
539 TableItem tableItem = new TableItem(tableWidget, SWT.NONE);
540 tableItem.setText(new String[] { key, value });
544 // protected void initializeLoadPath(ILaunchConfiguration configuration) {
545 // boolean useDefaultLoadPath = true;
547 // useDefaultLoadPath = configuration.getAttribute(PHPLaunchConfigurationAttribute.USE_DEFAULT_LOAD_PATH, true);
548 // setUseLoadPathDefaults(useDefaultLoadPath);
549 // if (useDefaultLoadPath) {
550 // String projectName = configuration.getAttribute(PHPLaunchConfigurationAttribute.PROJECT_NAME, "");
551 // if (projectName != "") {
552 // IProject aProject = PHPeclipsePlugin.getWorkspace().getRoot().getProject(projectName);
553 // if ((aProject != null) && JavaCore.isPHPProject(aProject)) {
554 // JavaProject thePHPProject = new JavaProject();
555 // thePHPProject.setProject(aProject);
556 // List loadPathEntries = thePHPProject.getLoadPathEntries();
557 // loadPathListViewer.setInput(loadPathEntries);
561 // } catch (CoreException e) {
566 protected void setUseLoadPathDefaults(boolean useDefaults) {
567 loadPathListViewer.getList().setEnabled(!useDefaults);
568 // loadPathDefaultButton.setSelection(useDefaults);
571 protected void initializeInterpreterSelection(ILaunchConfiguration configuration) {
572 String interpreterName = null;
574 interpreterName = configuration.getAttribute(PHPLaunchConfigurationAttribute.SELECTED_INTERPRETER, "");
575 } catch (CoreException e) {
578 if (interpreterName != null && !interpreterName.equals(""))
579 interpreterCombo.select(interpreterCombo.indexOf(interpreterName));
582 protected void initializeInterpreterCombo(Combo interpreterCombo) {
583 installedInterpretersWorkingCopy = new ArrayList();
584 installedInterpretersWorkingCopy.addAll(PHPRuntime.getDefault().getInstalledInterpreters());
586 String[] interpreterNames = new String[installedInterpretersWorkingCopy.size()];
587 for (int interpreterIndex = 0; interpreterIndex < installedInterpretersWorkingCopy.size(); interpreterIndex++) {
588 PHPInterpreter interpreter = (PHPInterpreter) installedInterpretersWorkingCopy.get(interpreterIndex);
589 interpreterNames[interpreterIndex] = interpreter.getInstallLocation().toString();
591 interpreterCombo.setItems(interpreterNames);
593 PHPInterpreter selectedInterpreter = PHPRuntime.getDefault().getSelectedInterpreter();
594 if (selectedInterpreter != null)
595 interpreterCombo.select(interpreterCombo.indexOf(selectedInterpreter.getInstallLocation().toString()));
598 public void performApply(ILaunchConfigurationWorkingCopy configuration) {
599 int selectionIndex = interpreterCombo.getSelectionIndex();
600 if (selectionIndex >= 0)
601 configuration.setAttribute(PHPLaunchConfigurationAttribute.SELECTED_INTERPRETER, interpreterCombo.getItem(selectionIndex));
603 // configuration.setAttribute(PHPLaunchConfigurationAttribute.USE_DEFAULT_LOAD_PATH, loadPathDefaultButton.getSelection());
605 // if (!loadPathDefaultButton.getSelection()) {
606 // List loadPathEntries = (List) loadPathListViewer.getInput();
607 // List loadPathStrings = new ArrayList();
608 // for (Iterator iterator = loadPathEntries.iterator(); iterator.hasNext();) {
609 // LoadPathEntry entry = (LoadPathEntry) iterator.next();
610 // loadPathStrings.add(entry.getPath().toString());
612 // configuration.setAttribute(PHPLaunchConfigurationAttribute.CUSTOM_LOAD_PATH, loadPathStrings);
615 configuration.setAttribute(PHPLaunchConfigurationAttribute.REMOTE_DEBUG, fRemoteDebugCheckBox.getSelection());
616 configuration.setAttribute(PHPLaunchConfigurationAttribute.REMOTE_DEBUG_TRANSLATE, fRemoteDebugTranslate.getSelection());
617 configuration.setAttribute(PHPLaunchConfigurationAttribute.FILE_MAP, getMapFromPathMapTable());
618 configuration.setAttribute(PHPLaunchConfigurationAttribute.REMOTE_PATH, fRemoteSourcePath.getText());
619 configuration.setAttribute(PHPLaunchConfigurationAttribute.OPEN_DBGSESSION_IN_BROWSER, fOpenDBGSessionInBrowserCheckBox
623 protected Composite createPageRoot(Composite parent) {
624 Composite composite = new Composite(parent, SWT.NULL);
625 GridLayout layout = new GridLayout();
626 layout.numColumns = 2;
627 composite.setLayout(layout);
628 createVerticalSpacer(composite, 2);
629 setControl(composite);
634 private Map getMapFromPathMapTable() {
635 TableItem[] items = fRemoteDebugPathMapTable.getItems();
636 if (items.length == 0) {
639 Map map = new HashMap(items.length);
640 for (int i = 0; i < items.length; i++) {
641 TableItem item = items[i];
642 String key = item.getText(0);
643 String value = item.getText(1);
649 public String getName() {
650 return PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.name");
653 public boolean isValid(ILaunchConfiguration launchConfig) {
655 String selectedInterpreter = launchConfig.getAttribute(PHPLaunchConfigurationAttribute.SELECTED_INTERPRETER, "");
656 if (selectedInterpreter.length() == 0) {
657 setErrorMessage(PHPDebugUiMessages
658 .getString("LaunchConfigurationTab.PHPEnvironment.interpreter_not_selected_error_message"));
661 } catch (CoreException e) {
665 setErrorMessage(null);
669 protected void log(Throwable t) {
670 PHPDebugUiPlugin.log(t);
673 public Image getImage() {
674 return PHPUiImages.get(PHPUiImages.IMG_CTOOLS_PHP);