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.runtime.CoreException;
19 import org.eclipse.debug.core.ILaunchConfiguration;
20 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
21 import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
22 import org.eclipse.jface.viewers.ColumnWeightData;
23 import org.eclipse.jface.viewers.ListViewer;
24 import org.eclipse.jface.viewers.TableLayout;
25 import org.eclipse.swt.SWT;
26 import org.eclipse.swt.events.ModifyEvent;
27 import org.eclipse.swt.events.ModifyListener;
28 import org.eclipse.swt.events.MouseAdapter;
29 import org.eclipse.swt.events.MouseEvent;
30 import org.eclipse.swt.events.SelectionAdapter;
31 import org.eclipse.swt.events.SelectionEvent;
32 import org.eclipse.swt.events.SelectionListener;
33 import org.eclipse.swt.graphics.Image;
34 import org.eclipse.swt.layout.GridData;
35 import org.eclipse.swt.layout.GridLayout;
36 import org.eclipse.swt.widgets.Button;
37 import org.eclipse.swt.widgets.Combo;
38 import org.eclipse.swt.widgets.Composite;
39 import org.eclipse.swt.widgets.Label;
40 import org.eclipse.swt.widgets.TabFolder;
41 import org.eclipse.swt.widgets.TabItem;
42 import org.eclipse.swt.widgets.Table;
43 import org.eclipse.swt.widgets.TableColumn;
44 import org.eclipse.swt.widgets.TableItem;
45 import org.eclipse.swt.widgets.Text;
47 public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
48 protected ListViewer loadPathListViewer;
50 protected java.util.List installedInterpretersWorkingCopy;
52 protected Combo interpreterCombo;
54 // protected Button loadPathDefaultButton;
55 protected Button fRemoteDebugCheckBox;
56 protected Button fRemoteDebugTranslate;
58 protected Button fOpenDBGSessionInBrowserCheckBox;
60 protected Button fPathMapRemoveButton;
62 protected Button fPathMapAddButton;
64 protected Button fPathMapEditButton;
66 protected Text fRemoteSourcePath;
68 protected Table fRemoteDebugPathMapTable;
70 protected TabFolder tabFolder;
72 private class RemoteDebugTabListener extends SelectionAdapter implements ModifyListener {
77 * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
79 public void modifyText(ModifyEvent e) {
80 updateLaunchConfigurationDialog();
86 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
88 public void widgetSelected(SelectionEvent e) {
89 Object source = e.getSource();
90 if (source == fRemoteDebugPathMapTable) {
91 setPathMapButtonsEnableState();
92 } else if (source == fPathMapAddButton) {
93 handlePathMapAddButtonSelected();
94 } else if (source == fPathMapEditButton) {
95 handlePathMapEditButtonSelected();
96 } else if (source == fPathMapRemoveButton) {
97 handlePathMapRemoveButtonSelected();
98 } else if (source == fRemoteDebugCheckBox) {
99 setRemoteTabEnableState();
100 } else if (source == fRemoteDebugTranslate) {
101 setRemoteTabEnableState();
103 updateLaunchConfigurationDialog();
111 private static final String EMPTY_STRING = ""; //$NON-NLS-1$
113 private RemoteDebugTabListener fListener = new RemoteDebugTabListener();
115 private static final boolean DEFAULT_REMOTE_DEBUG = false;
117 private static final boolean DEFAULT_REMOTE_DEBUG_TRANSLATE = false;
119 private static final boolean DEFAULT_OPEN_DBGSESSION_IN_BROWSER = true;
121 static String[] columnTitles = {
122 PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMapTableTitle.local"),
123 PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMapTableTitle.remote") };
125 public PHPEnvironmentTab() {
129 public void createControl(Composite parent) {
130 Composite composite = createPageRoot(parent);
132 tabFolder = new TabFolder(composite, SWT.NONE);
133 GridData gridData = new GridData(GridData.FILL_BOTH);
134 tabFolder.setLayoutData(gridData);
136 // addLoadPathTab(tabFolder);
137 addInterpreterTab(tabFolder);
138 addRemoteDebugTab(tabFolder);
141 protected void addRemoteDebugTab(TabFolder tabFolder) {
144 TabItem remoteDebugTab = new TabItem(tabFolder, SWT.NONE, 0);
145 remoteDebugTab.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.label"));
147 Composite comp = new Composite(tabFolder, SWT.NONE);
148 comp.setLayout(new GridLayout());
149 remoteDebugTab.setControl(comp);
152 fRemoteDebugCheckBox = new Button(comp, SWT.CHECK);
153 fRemoteDebugCheckBox.setText(PHPDebugUiMessages
154 .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.RemoteCheckBox.label"));
155 fRemoteDebugCheckBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
156 fRemoteDebugCheckBox.addSelectionListener(fListener);
158 fRemoteDebugTranslate = new Button(comp, SWT.CHECK);
159 fRemoteDebugTranslate.setText(PHPDebugUiMessages
160 .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.RemoteTranslate.label"));
161 fRemoteDebugTranslate.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
162 fRemoteDebugTranslate.addSelectionListener(fListener);
164 fOpenDBGSessionInBrowserCheckBox = new Button(comp, SWT.CHECK);
165 fOpenDBGSessionInBrowserCheckBox.setText(PHPDebugUiMessages
166 .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.OpenDBGSessionInBrowserCheckBox.label"));
167 fOpenDBGSessionInBrowserCheckBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
168 fOpenDBGSessionInBrowserCheckBox.addSelectionListener(fListener);
170 label = new Label(comp, SWT.NONE);
171 label.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.RemoteSourcePath.label"));
172 fRemoteSourcePath = new Text(comp, SWT.BORDER | SWT.SINGLE);
173 gd = new GridData(GridData.FILL_HORIZONTAL);
174 fRemoteSourcePath.setLayoutData(gd);
175 fRemoteSourcePath.addModifyListener(fListener);
177 createVerticalSpacer(comp, 1);
179 Composite pathMapComp = new Composite(comp, SWT.NONE);
180 gd = new GridData(GridData.FILL_BOTH);
181 pathMapComp.setLayoutData(gd);
182 GridLayout parametersLayout = new GridLayout();
183 parametersLayout.numColumns = 2;
184 parametersLayout.marginHeight = 0;
185 parametersLayout.marginWidth = 0;
186 pathMapComp.setLayout(parametersLayout);
188 Label pathMapLabel = new Label(pathMapComp, SWT.NONE);
189 pathMapLabel.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.label"));
191 gd.horizontalSpan = 2;
192 pathMapLabel.setLayoutData(gd);
194 fRemoteDebugPathMapTable = new Table(pathMapComp, SWT.BORDER | SWT.MULTI);
195 TableLayout tableLayout = new TableLayout();
196 fRemoteDebugPathMapTable.setLayout(tableLayout);
198 gd = new GridData(GridData.FILL_BOTH);
199 fRemoteDebugPathMapTable.setLayoutData(gd);
200 TableColumn column1 = new TableColumn(this.fRemoteDebugPathMapTable, SWT.NONE);
201 column1.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Table.Title.local")); //$NON-NLS-1$
202 TableColumn column2 = new TableColumn(this.fRemoteDebugPathMapTable, SWT.NONE);
204 .setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Table.Title.remote")); //$NON-NLS-1$
205 tableLayout.addColumnData(new ColumnWeightData(100));
206 tableLayout.addColumnData(new ColumnWeightData(100));
207 fRemoteDebugPathMapTable.setHeaderVisible(true);
208 fRemoteDebugPathMapTable.setLinesVisible(true);
209 fRemoteDebugPathMapTable.addSelectionListener(fListener);
210 fRemoteDebugPathMapTable.addMouseListener(new MouseAdapter() {
211 public void mouseDoubleClick(MouseEvent e) {
212 setPathMapButtonsEnableState();
213 if (fPathMapEditButton.isEnabled()) {
214 handlePathMapEditButtonSelected();
218 // fRemoteDebugPathMapTable.setEnabled(false);
220 Composite envButtonComp = new Composite(pathMapComp, SWT.NONE);
221 GridLayout envButtonLayout = new GridLayout();
222 envButtonLayout.marginHeight = 0;
223 envButtonLayout.marginWidth = 0;
224 envButtonComp.setLayout(envButtonLayout);
225 gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL);
226 envButtonComp.setLayoutData(gd);
228 fPathMapAddButton = createPushButton(envButtonComp, PHPDebugUiMessages
229 .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Button.Add.label"), null); //$NON-NLS-1$
230 fPathMapAddButton.addSelectionListener(fListener);
231 // fPathMapAddButton.setEnabled(false);
233 fPathMapEditButton = createPushButton(envButtonComp, PHPDebugUiMessages
234 .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Button.Edit.label"), null); //$NON-NLS-1$
235 fPathMapEditButton.addSelectionListener(fListener);
236 // fPathMapEditButton.setEnabled(false);
238 fPathMapRemoveButton = createPushButton(envButtonComp, PHPDebugUiMessages
239 .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Button.Remove.label"), null); //$NON-NLS-1$
240 fPathMapRemoveButton.addSelectionListener(fListener);
241 // fPathMapRemoveButton.setEnabled(false);
245 void handlePathMapAddButtonSelected() {
246 EditPathMapDialog dialog = new EditPathMapDialog(getShell(), "Edit File Map", new String[] { EMPTY_STRING, EMPTY_STRING });
247 openNewPathMapDialog(dialog, null);
249 // if (dialog.open()==EditPathMapDialog.OK)
251 // TableItem item = new TableItem (fRemoteDebugPathMapTable, SWT.NONE);
252 // item.setText(0,dialog.getLocalPath());
253 // item.setText(1,dialog.getRemotePath());
254 // updateLaunchConfigurationDialog();
256 // updateLaunchConfigurationDialog();
257 setPathMapButtonsEnableState();
260 void handlePathMapRemoveButtonSelected() {
261 int[] selectedIndices = this.fRemoteDebugPathMapTable.getSelectionIndices();
262 this.fRemoteDebugPathMapTable.remove(selectedIndices);
263 setPathMapButtonsEnableState();
264 updateLaunchConfigurationDialog();
267 void handlePathMapEditButtonSelected() {
268 TableItem selectedItem = this.fRemoteDebugPathMapTable.getSelection()[0];
269 String local = selectedItem.getText(0);
270 String remote = selectedItem.getText(1);
271 EditPathMapDialog dialog = new EditPathMapDialog(getShell(), "Edit File Map", new String[] { local, remote });
272 openNewPathMapDialog(dialog, selectedItem);
276 * Set the enabled state of whole tab.
278 private void setRemoteTabEnableState() {
279 boolean state = fRemoteDebugCheckBox.getSelection();
280 fRemoteSourcePath.setEnabled(state);
281 fRemoteDebugTranslate.setEnabled(state);
283 fRemoteDebugPathMapTable.setEnabled(state);
285 fPathMapEditButton.setEnabled(false);
286 fPathMapRemoveButton.setEnabled(false);
287 fPathMapAddButton.setEnabled(false);
288 fOpenDBGSessionInBrowserCheckBox.setEnabled(false);
290 setPathMapButtonsEnableState();
293 updateLaunchConfigurationDialog();
297 * Set the enabled state of the three environment variable-related buttons based on the selection in the PathMapTable widget.
299 private void setPathMapButtonsEnableState() {
300 // just do nothing for now
302 if (fRemoteDebugCheckBox.getSelection()) {
303 fOpenDBGSessionInBrowserCheckBox.setEnabled(true);
304 fRemoteDebugTranslate.setEnabled(true);
305 int selectCount = this.fRemoteDebugPathMapTable.getSelectionIndices().length;
306 if (selectCount < 1) {
307 fPathMapEditButton.setEnabled(false);
308 fPathMapRemoveButton.setEnabled(false);
310 fPathMapRemoveButton.setEnabled(true);
311 if (selectCount == 1) {
312 fPathMapEditButton.setEnabled(true);
314 fPathMapEditButton.setEnabled(false);
317 fPathMapAddButton.setEnabled(true);
322 * Show the specified dialog and update the pathMapTable table based on its results.
325 * the item to update, or <code>null</code> if adding a new item
327 private void openNewPathMapDialog(EditPathMapDialog dialog, TableItem updateItem) {
328 if (dialog.open() != EditPathMapDialog.OK) {
331 String[] pathPair = dialog.getPathPair();
332 TableItem tableItem = updateItem;
333 if (tableItem == null) {
334 tableItem = getTableItemForName(pathPair[0]);
335 if (tableItem == null) {
336 tableItem = new TableItem(this.fRemoteDebugPathMapTable, SWT.NONE);
339 tableItem.setText(pathPair);
340 this.fRemoteDebugPathMapTable.setSelection(new TableItem[] { tableItem });
341 updateLaunchConfigurationDialog();
345 * Helper method that indicates whether the specified parameter name is already present in the parameters table.
347 private TableItem getTableItemForName(String candidateName) {
348 TableItem[] items = this.fRemoteDebugPathMapTable.getItems();
349 for (int i = 0; i < items.length; i++) {
350 String name = items[i].getText(0);
351 if (name.equals(candidateName)) {
358 // protected void addLoadPathTab(TabFolder tabFolder) {
359 // Composite loadPathComposite = new Composite(tabFolder, SWT.NONE);
360 // loadPathComposite.setLayout(new GridLayout());
362 // loadPathListViewer = new ListViewer(loadPathComposite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
363 // loadPathListViewer.setContentProvider(new ListContentProvider());
364 // loadPathListViewer.setLabelProvider(new LoadPathEntryLabelProvider());
365 // loadPathListViewer.getList().setLayoutData(new GridData(GridData.FILL_BOTH));
367 // TabItem loadPathTab = new TabItem(tabFolder, SWT.NONE, 0);
368 // loadPathTab.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.loadPathTab.label"));
369 // loadPathTab.setControl(loadPathComposite);
370 // loadPathTab.setData(loadPathListViewer);
372 // loadPathDefaultButton = new Button(loadPathComposite, SWT.CHECK);
373 // loadPathDefaultButton.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.loadPathDefaultButton.label"));
374 // loadPathDefaultButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
375 // loadPathDefaultButton.addSelectionListener(getLoadPathDefaultButtonSelectionListener());
377 // loadPathDefaultButton.setEnabled(false); //for now, until the load path is customizable on the configuration
380 protected SelectionListener getLoadPathSelectionListener() {
381 return new SelectionAdapter() {
382 public void widgetSelected(SelectionEvent e) {
383 System.out.println("Loadpath list selection occurred: " + e.getSource());
388 protected SelectionListener getLoadPathDefaultButtonSelectionListener() {
389 return new SelectionAdapter() {
390 public void widgetSelected(SelectionEvent e) {
391 setUseLoadPathDefaults(((Button) e.getSource()).getSelection());
396 protected void addInterpreterTab(TabFolder tabFolder) {
397 Composite interpreterComposite = new Composite(tabFolder, SWT.NONE);
398 GridLayout layout = new GridLayout();
399 layout.numColumns = 2;
400 layout.marginHeight = 0;
401 layout.marginWidth = 0;
402 interpreterComposite.setLayout(layout);
403 interpreterComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
405 createVerticalSpacer(interpreterComposite, 2);
407 interpreterCombo = new Combo(interpreterComposite, SWT.READ_ONLY);
408 interpreterCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
409 initializeInterpreterCombo(interpreterCombo);
410 interpreterCombo.addModifyListener(getInterpreterComboModifyListener());
412 Button interpreterAddButton = new Button(interpreterComposite, SWT.PUSH);
413 interpreterAddButton.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.interpreterAddButton.label"));
414 interpreterAddButton.addSelectionListener(new SelectionAdapter() {
415 public void widgetSelected(SelectionEvent evt) {
416 PHPInterpreter newInterpreter = new PHPInterpreter(null);
417 File phpRuntime = PHPInterpreterPreferencePage.getFile(getShell(), null);
418 if (phpRuntime != null) {
419 newInterpreter.setInstallLocation(phpRuntime);
420 PHPRuntime.getDefault().addInstalledInterpreter(newInterpreter);
421 interpreterCombo.add(newInterpreter.getInstallLocation().toString());
422 interpreterCombo.select(interpreterCombo.indexOf(newInterpreter.getInstallLocation().toString()));
427 TabItem interpreterTab = new TabItem(tabFolder, SWT.NONE);
428 interpreterTab.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.interpreterTab.label"));
429 interpreterTab.setControl(interpreterComposite);
432 protected ModifyListener getInterpreterComboModifyListener() {
433 return new ModifyListener() {
434 public void modifyText(ModifyEvent evt) {
435 updateLaunchConfigurationDialog();
440 protected void createVerticalSpacer(Composite comp, int colSpan) {
441 Label label = new Label(comp, SWT.NONE);
442 GridData gd = new GridData();
443 gd.horizontalSpan = colSpan;
444 label.setLayoutData(gd);
447 public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
450 public void initializeFrom(ILaunchConfiguration configuration) {
451 // initializeLoadPath(configuration);
452 initializeInterpreterSelection(configuration);
453 initializeRemoteDebug(configuration);
456 protected void initializeRemoteDebug(ILaunchConfiguration configuration) {
461 fRemoteDebugCheckBox.setSelection(configuration.getAttribute(PHPLaunchConfigurationAttribute.REMOTE_DEBUG,
462 DEFAULT_REMOTE_DEBUG));
463 } catch (CoreException ce) {
464 fRemoteDebugCheckBox.setSelection(DEFAULT_REMOTE_DEBUG);
467 fRemoteDebugTranslate.setSelection(configuration.getAttribute(
468 PHPLaunchConfigurationAttribute.REMOTE_DEBUG_TRANSLATE, DEFAULT_REMOTE_DEBUG_TRANSLATE));
469 } catch (CoreException ce) {
470 fRemoteDebugTranslate.setSelection(DEFAULT_REMOTE_DEBUG_TRANSLATE);
473 fOpenDBGSessionInBrowserCheckBox.setSelection(configuration.getAttribute(
474 PHPLaunchConfigurationAttribute.OPEN_DBGSESSION_IN_BROWSER, DEFAULT_OPEN_DBGSESSION_IN_BROWSER));
475 } catch (CoreException ce) {
476 fOpenDBGSessionInBrowserCheckBox.setSelection(DEFAULT_OPEN_DBGSESSION_IN_BROWSER);
478 setRemoteTabEnableState();
480 fRemoteSourcePath.setText(configuration.getAttribute(PHPLaunchConfigurationAttribute.REMOTE_PATH, ""));
481 } catch (CoreException ce) {
482 fRemoteSourcePath.setText("");
485 updatePathMapFromConfig(configuration);
489 private void updatePathMapFromConfig(ILaunchConfiguration config) {
492 if (config != null) {
493 envVars = config.getAttribute(PHPLaunchConfigurationAttribute.FILE_MAP, (Map) null);
495 updatePathMapTable(envVars, this.fRemoteDebugPathMapTable);
496 setPathMapButtonsEnableState();
497 } catch (CoreException ce) {
502 private void updatePathMapTable(Map map, Table tableWidget) {
503 tableWidget.removeAll();
507 Iterator iterator = map.keySet().iterator();
508 while (iterator.hasNext()) {
509 String key = (String) iterator.next();
510 String value = (String) map.get(key);
511 TableItem tableItem = new TableItem(tableWidget, SWT.NONE);
512 tableItem.setText(new String[] { key, value });
516 // protected void initializeLoadPath(ILaunchConfiguration configuration) {
517 // boolean useDefaultLoadPath = true;
519 // useDefaultLoadPath = configuration.getAttribute(PHPLaunchConfigurationAttribute.USE_DEFAULT_LOAD_PATH, true);
520 // setUseLoadPathDefaults(useDefaultLoadPath);
521 // if (useDefaultLoadPath) {
522 // String projectName = configuration.getAttribute(PHPLaunchConfigurationAttribute.PROJECT_NAME, "");
523 // if (projectName != "") {
524 // IProject aProject = PHPeclipsePlugin.getWorkspace().getRoot().getProject(projectName);
525 // if ((aProject != null) && JavaCore.isPHPProject(aProject)) {
526 // JavaProject thePHPProject = new JavaProject();
527 // thePHPProject.setProject(aProject);
528 // List loadPathEntries = thePHPProject.getLoadPathEntries();
529 // loadPathListViewer.setInput(loadPathEntries);
533 // } catch (CoreException e) {
538 protected void setUseLoadPathDefaults(boolean useDefaults) {
539 loadPathListViewer.getList().setEnabled(!useDefaults);
540 // loadPathDefaultButton.setSelection(useDefaults);
543 protected void initializeInterpreterSelection(ILaunchConfiguration configuration) {
544 String interpreterName = null;
546 interpreterName = configuration.getAttribute(PHPLaunchConfigurationAttribute.SELECTED_INTERPRETER, "");
547 } catch (CoreException e) {
550 if (interpreterName != null && !interpreterName.equals(""))
551 interpreterCombo.select(interpreterCombo.indexOf(interpreterName));
554 protected void initializeInterpreterCombo(Combo interpreterCombo) {
555 installedInterpretersWorkingCopy = new ArrayList();
556 installedInterpretersWorkingCopy.addAll(PHPRuntime.getDefault().getInstalledInterpreters());
558 String[] interpreterNames = new String[installedInterpretersWorkingCopy.size()];
559 for (int interpreterIndex = 0; interpreterIndex < installedInterpretersWorkingCopy.size(); interpreterIndex++) {
560 PHPInterpreter interpreter = (PHPInterpreter) installedInterpretersWorkingCopy.get(interpreterIndex);
561 interpreterNames[interpreterIndex] = interpreter.getInstallLocation().toString();
563 interpreterCombo.setItems(interpreterNames);
565 PHPInterpreter selectedInterpreter = PHPRuntime.getDefault().getSelectedInterpreter();
566 if (selectedInterpreter != null)
567 interpreterCombo.select(interpreterCombo.indexOf(selectedInterpreter.getInstallLocation().toString()));
570 public void performApply(ILaunchConfigurationWorkingCopy configuration) {
571 int selectionIndex = interpreterCombo.getSelectionIndex();
572 if (selectionIndex >= 0)
573 configuration.setAttribute(PHPLaunchConfigurationAttribute.SELECTED_INTERPRETER, interpreterCombo.getItem(selectionIndex));
575 // configuration.setAttribute(PHPLaunchConfigurationAttribute.USE_DEFAULT_LOAD_PATH, loadPathDefaultButton.getSelection());
577 // if (!loadPathDefaultButton.getSelection()) {
578 // List loadPathEntries = (List) loadPathListViewer.getInput();
579 // List loadPathStrings = new ArrayList();
580 // for (Iterator iterator = loadPathEntries.iterator(); iterator.hasNext();) {
581 // LoadPathEntry entry = (LoadPathEntry) iterator.next();
582 // loadPathStrings.add(entry.getPath().toString());
584 // configuration.setAttribute(PHPLaunchConfigurationAttribute.CUSTOM_LOAD_PATH, loadPathStrings);
587 configuration.setAttribute(PHPLaunchConfigurationAttribute.REMOTE_DEBUG, fRemoteDebugCheckBox.getSelection());
588 configuration.setAttribute(PHPLaunchConfigurationAttribute.REMOTE_DEBUG_TRANSLATE, fRemoteDebugTranslate.getSelection());
589 configuration.setAttribute(PHPLaunchConfigurationAttribute.FILE_MAP, getMapFromPathMapTable());
590 configuration.setAttribute(PHPLaunchConfigurationAttribute.REMOTE_PATH, fRemoteSourcePath.getText());
591 configuration.setAttribute(PHPLaunchConfigurationAttribute.OPEN_DBGSESSION_IN_BROWSER, fOpenDBGSessionInBrowserCheckBox
595 protected Composite createPageRoot(Composite parent) {
596 Composite composite = new Composite(parent, SWT.NULL);
597 GridLayout layout = new GridLayout();
598 layout.numColumns = 2;
599 composite.setLayout(layout);
600 createVerticalSpacer(composite, 2);
601 setControl(composite);
606 private Map getMapFromPathMapTable() {
607 TableItem[] items = fRemoteDebugPathMapTable.getItems();
608 if (items.length == 0) {
611 Map map = new HashMap(items.length);
612 for (int i = 0; i < items.length; i++) {
613 TableItem item = items[i];
614 String key = item.getText(0);
615 String value = item.getText(1);
621 public String getName() {
622 return PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.name");
625 public boolean isValid(ILaunchConfiguration launchConfig) {
627 String selectedInterpreter = launchConfig.getAttribute(PHPLaunchConfigurationAttribute.SELECTED_INTERPRETER, "");
628 if (selectedInterpreter.length() == 0) {
629 setErrorMessage(PHPDebugUiMessages
630 .getString("LaunchConfigurationTab.PHPEnvironment.interpreter_not_selected_error_message"));
633 } catch (CoreException e) {
637 setErrorMessage(null);
641 protected void log(Throwable t) {
642 PHPDebugUiPlugin.log(t);
645 public Image getImage() {
646 return PHPUiImages.get(PHPUiImages.IMG_CTOOLS_PHP);