1 package net.sourceforge.phpdt.internal.debug.ui.launcher;
3 import java.util.ArrayList;
4 import java.util.HashMap;
5 import java.util.Iterator;
8 import net.sourceforge.phpdt.internal.debug.ui.PHPDebugUiMessages;
9 import net.sourceforge.phpdt.internal.debug.ui.PHPDebugUiPlugin;
10 import net.sourceforge.phpdt.internal.debug.ui.preferences.EditInterpreterDialog;
11 import net.sourceforge.phpdt.internal.debug.ui.preferences.EditPathMapDialog;
12 import net.sourceforge.phpdt.internal.launching.PHPInterpreter;
13 import net.sourceforge.phpdt.internal.launching.PHPLaunchConfigurationAttribute;
14 import net.sourceforge.phpdt.internal.launching.PHPRuntime;
15 import net.sourceforge.phpdt.internal.ui.PHPUiImages;
17 import org.eclipse.core.runtime.CoreException;
18 import org.eclipse.debug.core.ILaunchConfiguration;
19 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
20 import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
21 import org.eclipse.jface.viewers.ColumnWeightData;
22 import org.eclipse.jface.viewers.ListViewer;
23 import org.eclipse.jface.viewers.TableLayout;
24 import org.eclipse.swt.SWT;
25 import org.eclipse.swt.events.ModifyEvent;
26 import org.eclipse.swt.events.ModifyListener;
27 import org.eclipse.swt.events.MouseAdapter;
28 import org.eclipse.swt.events.MouseEvent;
29 import org.eclipse.swt.events.SelectionAdapter;
30 import org.eclipse.swt.events.SelectionEvent;
31 import org.eclipse.swt.events.SelectionListener;
32 import org.eclipse.swt.graphics.Image;
33 import org.eclipse.swt.layout.GridData;
34 import org.eclipse.swt.layout.GridLayout;
35 import org.eclipse.swt.widgets.Button;
36 import org.eclipse.swt.widgets.Combo;
37 import org.eclipse.swt.widgets.Composite;
38 import org.eclipse.swt.widgets.Label;
39 import org.eclipse.swt.widgets.TabFolder;
40 import org.eclipse.swt.widgets.TabItem;
41 import org.eclipse.swt.widgets.Table;
42 import org.eclipse.swt.widgets.TableColumn;
43 import org.eclipse.swt.widgets.TableItem;
44 import org.eclipse.swt.widgets.Text;
46 public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
47 protected ListViewer loadPathListViewer;
49 protected java.util.List installedInterpretersWorkingCopy;
51 protected Combo interpreterCombo;
53 // protected Button loadPathDefaultButton;
54 protected Button fRemoteDebugCheckBox;
55 protected Button fRemoteDebugTranslate;
57 protected Button fOpenDBGSessionInBrowserCheckBox;
59 protected Button fPathMapRemoveButton;
61 protected Button fPathMapAddButton;
63 protected Button fPathMapEditButton;
65 protected Text fRemoteSourcePath;
67 protected Table fRemoteDebugPathMapTable;
69 protected TabFolder tabFolder;
71 private class RemoteDebugTabListener extends SelectionAdapter implements ModifyListener {
76 * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
78 public void modifyText(ModifyEvent e) {
79 updateLaunchConfigurationDialog();
85 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
87 public void widgetSelected(SelectionEvent e) {
88 Object source = e.getSource();
89 if (source == fRemoteDebugPathMapTable) {
90 setPathMapButtonsEnableState();
91 } else if (source == fPathMapAddButton) {
92 handlePathMapAddButtonSelected();
93 } else if (source == fPathMapEditButton) {
94 handlePathMapEditButtonSelected();
95 } else if (source == fPathMapRemoveButton) {
96 handlePathMapRemoveButtonSelected();
97 } else if (source == fRemoteDebugCheckBox) {
98 setRemoteTabEnableState();
99 } else if (source == fRemoteDebugTranslate) {
100 setRemoteTabEnableState();
102 updateLaunchConfigurationDialog();
110 private static final String EMPTY_STRING = ""; //$NON-NLS-1$
112 private RemoteDebugTabListener fListener = new RemoteDebugTabListener();
114 private static final boolean DEFAULT_REMOTE_DEBUG = false;
116 private static final boolean DEFAULT_REMOTE_DEBUG_TRANSLATE = false;
118 private static final boolean DEFAULT_OPEN_DBGSESSION_IN_BROWSER = true;
120 static String[] columnTitles = {
121 PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMapTableTitle.local"),
122 PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMapTableTitle.remote") };
124 public PHPEnvironmentTab() {
128 public void createControl(Composite parent) {
129 Composite composite = createPageRoot(parent);
131 tabFolder = new TabFolder(composite, SWT.NONE);
132 GridData gridData = new GridData(GridData.FILL_BOTH);
133 tabFolder.setLayoutData(gridData);
135 // addLoadPathTab(tabFolder);
136 addInterpreterTab(tabFolder);
137 addRemoteDebugTab(tabFolder);
140 protected void addRemoteDebugTab(TabFolder tabFolder) {
143 TabItem remoteDebugTab = new TabItem(tabFolder, SWT.NONE, 0);
144 remoteDebugTab.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.label"));
146 Composite comp = new Composite(tabFolder, SWT.NONE);
147 comp.setLayout(new GridLayout());
148 remoteDebugTab.setControl(comp);
151 fRemoteDebugCheckBox = new Button(comp, SWT.CHECK);
152 fRemoteDebugCheckBox.setText(PHPDebugUiMessages
153 .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.RemoteCheckBox.label"));
154 fRemoteDebugCheckBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
155 fRemoteDebugCheckBox.addSelectionListener(fListener);
157 fRemoteDebugTranslate = new Button(comp, SWT.CHECK);
158 fRemoteDebugTranslate.setText(PHPDebugUiMessages
159 .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.RemoteTranslate.label"));
160 fRemoteDebugTranslate.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
161 fRemoteDebugTranslate.addSelectionListener(fListener);
163 fOpenDBGSessionInBrowserCheckBox = new Button(comp, SWT.CHECK);
164 fOpenDBGSessionInBrowserCheckBox.setText(PHPDebugUiMessages
165 .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.OpenDBGSessionInBrowserCheckBox.label"));
166 fOpenDBGSessionInBrowserCheckBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
167 fOpenDBGSessionInBrowserCheckBox.addSelectionListener(fListener);
169 label = new Label(comp, SWT.NONE);
170 label.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.RemoteSourcePath.label"));
171 fRemoteSourcePath = new Text(comp, SWT.BORDER | SWT.SINGLE);
172 gd = new GridData(GridData.FILL_HORIZONTAL);
173 fRemoteSourcePath.setLayoutData(gd);
174 fRemoteSourcePath.addModifyListener(fListener);
176 createVerticalSpacer(comp, 1);
178 Composite pathMapComp = new Composite(comp, SWT.NONE);
179 gd = new GridData(GridData.FILL_BOTH);
180 pathMapComp.setLayoutData(gd);
181 GridLayout parametersLayout = new GridLayout();
182 parametersLayout.numColumns = 2;
183 parametersLayout.marginHeight = 0;
184 parametersLayout.marginWidth = 0;
185 pathMapComp.setLayout(parametersLayout);
187 Label pathMapLabel = new Label(pathMapComp, SWT.NONE);
188 pathMapLabel.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.label"));
190 gd.horizontalSpan = 2;
191 pathMapLabel.setLayoutData(gd);
193 fRemoteDebugPathMapTable = new Table(pathMapComp, SWT.BORDER | SWT.MULTI);
194 TableLayout tableLayout = new TableLayout();
195 fRemoteDebugPathMapTable.setLayout(tableLayout);
197 gd = new GridData(GridData.FILL_BOTH);
198 fRemoteDebugPathMapTable.setLayoutData(gd);
199 TableColumn column1 = new TableColumn(this.fRemoteDebugPathMapTable, SWT.NONE);
200 column1.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Table.Title.local")); //$NON-NLS-1$
201 TableColumn column2 = new TableColumn(this.fRemoteDebugPathMapTable, SWT.NONE);
203 .setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Table.Title.remote")); //$NON-NLS-1$
204 tableLayout.addColumnData(new ColumnWeightData(100));
205 tableLayout.addColumnData(new ColumnWeightData(100));
206 fRemoteDebugPathMapTable.setHeaderVisible(true);
207 fRemoteDebugPathMapTable.setLinesVisible(true);
208 fRemoteDebugPathMapTable.addSelectionListener(fListener);
209 fRemoteDebugPathMapTable.addMouseListener(new MouseAdapter() {
210 public void mouseDoubleClick(MouseEvent e) {
211 setPathMapButtonsEnableState();
212 if (fPathMapEditButton.isEnabled()) {
213 handlePathMapEditButtonSelected();
217 // fRemoteDebugPathMapTable.setEnabled(false);
219 Composite envButtonComp = new Composite(pathMapComp, SWT.NONE);
220 GridLayout envButtonLayout = new GridLayout();
221 envButtonLayout.marginHeight = 0;
222 envButtonLayout.marginWidth = 0;
223 envButtonComp.setLayout(envButtonLayout);
224 gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL);
225 envButtonComp.setLayoutData(gd);
227 fPathMapAddButton = createPushButton(envButtonComp, PHPDebugUiMessages
228 .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Button.Add.label"), null); //$NON-NLS-1$
229 fPathMapAddButton.addSelectionListener(fListener);
230 // fPathMapAddButton.setEnabled(false);
232 fPathMapEditButton = createPushButton(envButtonComp, PHPDebugUiMessages
233 .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Button.Edit.label"), null); //$NON-NLS-1$
234 fPathMapEditButton.addSelectionListener(fListener);
235 // fPathMapEditButton.setEnabled(false);
237 fPathMapRemoveButton = createPushButton(envButtonComp, PHPDebugUiMessages
238 .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Button.Remove.label"), null); //$NON-NLS-1$
239 fPathMapRemoveButton.addSelectionListener(fListener);
240 // fPathMapRemoveButton.setEnabled(false);
244 void handlePathMapAddButtonSelected() {
245 EditPathMapDialog dialog = new EditPathMapDialog(getShell(), "Edit File Map", new String[] { EMPTY_STRING, EMPTY_STRING });
246 openNewPathMapDialog(dialog, null);
248 // if (dialog.open()==EditPathMapDialog.OK)
250 // TableItem item = new TableItem (fRemoteDebugPathMapTable, SWT.NONE);
251 // item.setText(0,dialog.getLocalPath());
252 // item.setText(1,dialog.getRemotePath());
253 // updateLaunchConfigurationDialog();
255 // updateLaunchConfigurationDialog();
256 setPathMapButtonsEnableState();
259 void handlePathMapRemoveButtonSelected() {
260 int[] selectedIndices = this.fRemoteDebugPathMapTable.getSelectionIndices();
261 this.fRemoteDebugPathMapTable.remove(selectedIndices);
262 setPathMapButtonsEnableState();
263 updateLaunchConfigurationDialog();
266 void handlePathMapEditButtonSelected() {
267 TableItem selectedItem = this.fRemoteDebugPathMapTable.getSelection()[0];
268 String local = selectedItem.getText(0);
269 String remote = selectedItem.getText(1);
270 EditPathMapDialog dialog = new EditPathMapDialog(getShell(), "Edit File Map", new String[] { local, remote });
271 openNewPathMapDialog(dialog, selectedItem);
275 * Set the enabled state of whole tab.
277 private void setRemoteTabEnableState() {
278 boolean state = fRemoteDebugCheckBox.getSelection();
279 fRemoteSourcePath.setEnabled(state);
280 fRemoteDebugTranslate.setEnabled(state);
282 fRemoteDebugPathMapTable.setEnabled(state);
284 fPathMapEditButton.setEnabled(false);
285 fPathMapRemoveButton.setEnabled(false);
286 fPathMapAddButton.setEnabled(false);
287 fOpenDBGSessionInBrowserCheckBox.setEnabled(false);
289 setPathMapButtonsEnableState();
292 updateLaunchConfigurationDialog();
296 * Set the enabled state of the three environment variable-related buttons based on the selection in the PathMapTable widget.
298 private void setPathMapButtonsEnableState() {
299 // just do nothing for now
301 if (fRemoteDebugCheckBox.getSelection()) {
302 fOpenDBGSessionInBrowserCheckBox.setEnabled(true);
303 fRemoteDebugTranslate.setEnabled(true);
304 int selectCount = this.fRemoteDebugPathMapTable.getSelectionIndices().length;
305 if (selectCount < 1) {
306 fPathMapEditButton.setEnabled(false);
307 fPathMapRemoveButton.setEnabled(false);
309 fPathMapRemoveButton.setEnabled(true);
310 if (selectCount == 1) {
311 fPathMapEditButton.setEnabled(true);
313 fPathMapEditButton.setEnabled(false);
316 fPathMapAddButton.setEnabled(true);
321 * Show the specified dialog and update the pathMapTable table based on its results.
324 * the item to update, or <code>null</code> if adding a new item
326 private void openNewPathMapDialog(EditPathMapDialog dialog, TableItem updateItem) {
327 if (dialog.open() != EditPathMapDialog.OK) {
330 String[] pathPair = dialog.getPathPair();
331 TableItem tableItem = updateItem;
332 if (tableItem == null) {
333 tableItem = getTableItemForName(pathPair[0]);
334 if (tableItem == null) {
335 tableItem = new TableItem(this.fRemoteDebugPathMapTable, SWT.NONE);
338 tableItem.setText(pathPair);
339 this.fRemoteDebugPathMapTable.setSelection(new TableItem[] { tableItem });
340 updateLaunchConfigurationDialog();
344 * Helper method that indicates whether the specified parameter name is already present in the parameters table.
346 private TableItem getTableItemForName(String candidateName) {
347 TableItem[] items = this.fRemoteDebugPathMapTable.getItems();
348 for (int i = 0; i < items.length; i++) {
349 String name = items[i].getText(0);
350 if (name.equals(candidateName)) {
357 // protected void addLoadPathTab(TabFolder tabFolder) {
358 // Composite loadPathComposite = new Composite(tabFolder, SWT.NONE);
359 // loadPathComposite.setLayout(new GridLayout());
361 // loadPathListViewer = new ListViewer(loadPathComposite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
362 // loadPathListViewer.setContentProvider(new ListContentProvider());
363 // loadPathListViewer.setLabelProvider(new LoadPathEntryLabelProvider());
364 // loadPathListViewer.getList().setLayoutData(new GridData(GridData.FILL_BOTH));
366 // TabItem loadPathTab = new TabItem(tabFolder, SWT.NONE, 0);
367 // loadPathTab.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.loadPathTab.label"));
368 // loadPathTab.setControl(loadPathComposite);
369 // loadPathTab.setData(loadPathListViewer);
371 // loadPathDefaultButton = new Button(loadPathComposite, SWT.CHECK);
372 // loadPathDefaultButton.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.loadPathDefaultButton.label"));
373 // loadPathDefaultButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
374 // loadPathDefaultButton.addSelectionListener(getLoadPathDefaultButtonSelectionListener());
376 // loadPathDefaultButton.setEnabled(false); //for now, until the load path is customizable on the configuration
379 protected SelectionListener getLoadPathSelectionListener() {
380 return new SelectionAdapter() {
381 public void widgetSelected(SelectionEvent e) {
382 System.out.println("Loadpath list selection occurred: " + e.getSource());
387 protected SelectionListener getLoadPathDefaultButtonSelectionListener() {
388 return new SelectionAdapter() {
389 public void widgetSelected(SelectionEvent e) {
390 setUseLoadPathDefaults(((Button) e.getSource()).getSelection());
395 protected void addInterpreterTab(TabFolder tabFolder) {
396 Composite interpreterComposite = new Composite(tabFolder, SWT.NONE);
397 GridLayout layout = new GridLayout();
398 layout.numColumns = 2;
399 layout.marginHeight = 0;
400 layout.marginWidth = 0;
401 interpreterComposite.setLayout(layout);
402 interpreterComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
404 createVerticalSpacer(interpreterComposite, 2);
406 interpreterCombo = new Combo(interpreterComposite, SWT.READ_ONLY);
407 interpreterCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
408 initializeInterpreterCombo(interpreterCombo);
409 interpreterCombo.addModifyListener(getInterpreterComboModifyListener());
411 Button interpreterAddButton = new Button(interpreterComposite, SWT.PUSH);
412 interpreterAddButton.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.interpreterAddButton.label"));
413 interpreterAddButton.addSelectionListener(new SelectionAdapter() {
414 public void widgetSelected(SelectionEvent evt) {
415 PHPInterpreter newInterpreter = new PHPInterpreter(null, null);
416 EditInterpreterDialog editor = new EditInterpreterDialog(getShell(), PHPDebugUiMessages
417 .getString("LaunchConfigurationTab.PHPEnvironment.editInterpreterDialog.title"));
419 editor.setInterpreterToEdit(newInterpreter);
420 if (EditInterpreterDialog.OK == editor.open()) {
421 PHPRuntime.getDefault().addInstalledInterpreter(newInterpreter);
422 interpreterCombo.add(newInterpreter.getName());
423 interpreterCombo.select(interpreterCombo.indexOf(newInterpreter.getName()));
428 TabItem interpreterTab = new TabItem(tabFolder, SWT.NONE);
429 interpreterTab.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.interpreterTab.label"));
430 interpreterTab.setControl(interpreterComposite);
433 protected ModifyListener getInterpreterComboModifyListener() {
434 return new ModifyListener() {
435 public void modifyText(ModifyEvent evt) {
436 updateLaunchConfigurationDialog();
441 protected void createVerticalSpacer(Composite comp, int colSpan) {
442 Label label = new Label(comp, SWT.NONE);
443 GridData gd = new GridData();
444 gd.horizontalSpan = colSpan;
445 label.setLayoutData(gd);
448 public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
451 public void initializeFrom(ILaunchConfiguration configuration) {
452 // initializeLoadPath(configuration);
453 initializeInterpreterSelection(configuration);
454 initializeRemoteDebug(configuration);
457 protected void initializeRemoteDebug(ILaunchConfiguration configuration) {
462 fRemoteDebugCheckBox.setSelection(configuration.getAttribute(PHPLaunchConfigurationAttribute.REMOTE_DEBUG,
463 DEFAULT_REMOTE_DEBUG));
464 } catch (CoreException ce) {
465 fRemoteDebugCheckBox.setSelection(DEFAULT_REMOTE_DEBUG);
468 fRemoteDebugTranslate.setSelection(configuration.getAttribute(
469 PHPLaunchConfigurationAttribute.REMOTE_DEBUG_TRANSLATE, DEFAULT_REMOTE_DEBUG_TRANSLATE));
470 } catch (CoreException ce) {
471 fRemoteDebugTranslate.setSelection(DEFAULT_REMOTE_DEBUG_TRANSLATE);
474 fOpenDBGSessionInBrowserCheckBox.setSelection(configuration.getAttribute(
475 PHPLaunchConfigurationAttribute.OPEN_DBGSESSION_IN_BROWSER, DEFAULT_OPEN_DBGSESSION_IN_BROWSER));
476 } catch (CoreException ce) {
477 fOpenDBGSessionInBrowserCheckBox.setSelection(DEFAULT_OPEN_DBGSESSION_IN_BROWSER);
479 setRemoteTabEnableState();
481 fRemoteSourcePath.setText(configuration.getAttribute(PHPLaunchConfigurationAttribute.REMOTE_PATH, ""));
482 } catch (CoreException ce) {
483 fRemoteSourcePath.setText("");
486 updatePathMapFromConfig(configuration);
490 private void updatePathMapFromConfig(ILaunchConfiguration config) {
493 if (config != null) {
494 envVars = config.getAttribute(PHPLaunchConfigurationAttribute.FILE_MAP, (Map) null);
496 updatePathMapTable(envVars, this.fRemoteDebugPathMapTable);
497 setPathMapButtonsEnableState();
498 } catch (CoreException ce) {
503 private void updatePathMapTable(Map map, Table tableWidget) {
504 tableWidget.removeAll();
508 Iterator iterator = map.keySet().iterator();
509 while (iterator.hasNext()) {
510 String key = (String) iterator.next();
511 String value = (String) map.get(key);
512 TableItem tableItem = new TableItem(tableWidget, SWT.NONE);
513 tableItem.setText(new String[] { key, value });
517 // protected void initializeLoadPath(ILaunchConfiguration configuration) {
518 // boolean useDefaultLoadPath = true;
520 // useDefaultLoadPath = configuration.getAttribute(PHPLaunchConfigurationAttribute.USE_DEFAULT_LOAD_PATH, true);
521 // setUseLoadPathDefaults(useDefaultLoadPath);
522 // if (useDefaultLoadPath) {
523 // String projectName = configuration.getAttribute(PHPLaunchConfigurationAttribute.PROJECT_NAME, "");
524 // if (projectName != "") {
525 // IProject aProject = PHPeclipsePlugin.getWorkspace().getRoot().getProject(projectName);
526 // if ((aProject != null) && JavaCore.isPHPProject(aProject)) {
527 // JavaProject thePHPProject = new JavaProject();
528 // thePHPProject.setProject(aProject);
529 // List loadPathEntries = thePHPProject.getLoadPathEntries();
530 // loadPathListViewer.setInput(loadPathEntries);
534 // } catch (CoreException e) {
539 protected void setUseLoadPathDefaults(boolean useDefaults) {
540 loadPathListViewer.getList().setEnabled(!useDefaults);
541 // loadPathDefaultButton.setSelection(useDefaults);
544 protected void initializeInterpreterSelection(ILaunchConfiguration configuration) {
545 String interpreterName = null;
547 interpreterName = configuration.getAttribute(PHPLaunchConfigurationAttribute.SELECTED_INTERPRETER, "");
548 } catch (CoreException e) {
551 if (interpreterName != null && !interpreterName.equals(""))
552 interpreterCombo.select(interpreterCombo.indexOf(interpreterName));
555 protected void initializeInterpreterCombo(Combo interpreterCombo) {
556 installedInterpretersWorkingCopy = new ArrayList();
557 installedInterpretersWorkingCopy.addAll(PHPRuntime.getDefault().getInstalledInterpreters());
559 String[] interpreterNames = new String[installedInterpretersWorkingCopy.size()];
560 for (int interpreterIndex = 0; interpreterIndex < installedInterpretersWorkingCopy.size(); interpreterIndex++) {
561 PHPInterpreter interpreter = (PHPInterpreter) installedInterpretersWorkingCopy.get(interpreterIndex);
562 interpreterNames[interpreterIndex] = interpreter.getName();
564 interpreterCombo.setItems(interpreterNames);
566 PHPInterpreter selectedInterpreter = PHPRuntime.getDefault().getSelectedInterpreter();
567 if (selectedInterpreter != null)
568 interpreterCombo.select(interpreterCombo.indexOf(selectedInterpreter.getName()));
571 public void performApply(ILaunchConfigurationWorkingCopy configuration) {
572 int selectionIndex = interpreterCombo.getSelectionIndex();
573 if (selectionIndex >= 0)
574 configuration.setAttribute(PHPLaunchConfigurationAttribute.SELECTED_INTERPRETER, interpreterCombo.getItem(selectionIndex));
576 // configuration.setAttribute(PHPLaunchConfigurationAttribute.USE_DEFAULT_LOAD_PATH, loadPathDefaultButton.getSelection());
578 // if (!loadPathDefaultButton.getSelection()) {
579 // List loadPathEntries = (List) loadPathListViewer.getInput();
580 // List loadPathStrings = new ArrayList();
581 // for (Iterator iterator = loadPathEntries.iterator(); iterator.hasNext();) {
582 // LoadPathEntry entry = (LoadPathEntry) iterator.next();
583 // loadPathStrings.add(entry.getPath().toString());
585 // configuration.setAttribute(PHPLaunchConfigurationAttribute.CUSTOM_LOAD_PATH, loadPathStrings);
588 configuration.setAttribute(PHPLaunchConfigurationAttribute.REMOTE_DEBUG, fRemoteDebugCheckBox.getSelection());
589 configuration.setAttribute(PHPLaunchConfigurationAttribute.REMOTE_DEBUG_TRANSLATE, fRemoteDebugTranslate.getSelection());
590 configuration.setAttribute(PHPLaunchConfigurationAttribute.FILE_MAP, getMapFromPathMapTable());
591 configuration.setAttribute(PHPLaunchConfigurationAttribute.REMOTE_PATH, fRemoteSourcePath.getText());
592 configuration.setAttribute(PHPLaunchConfigurationAttribute.OPEN_DBGSESSION_IN_BROWSER, fOpenDBGSessionInBrowserCheckBox
596 protected Composite createPageRoot(Composite parent) {
597 Composite composite = new Composite(parent, SWT.NULL);
598 GridLayout layout = new GridLayout();
599 layout.numColumns = 2;
600 composite.setLayout(layout);
601 createVerticalSpacer(composite, 2);
602 setControl(composite);
607 private Map getMapFromPathMapTable() {
608 TableItem[] items = fRemoteDebugPathMapTable.getItems();
609 if (items.length == 0) {
612 Map map = new HashMap(items.length);
613 for (int i = 0; i < items.length; i++) {
614 TableItem item = items[i];
615 String key = item.getText(0);
616 String value = item.getText(1);
622 public String getName() {
623 return PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.name");
626 public boolean isValid(ILaunchConfiguration launchConfig) {
628 String selectedInterpreter = launchConfig.getAttribute(PHPLaunchConfigurationAttribute.SELECTED_INTERPRETER, "");
629 if (selectedInterpreter.length() == 0) {
630 setErrorMessage(PHPDebugUiMessages
631 .getString("LaunchConfigurationTab.PHPEnvironment.interpreter_not_selected_error_message"));
634 } catch (CoreException e) {
638 setErrorMessage(null);
642 protected void log(Throwable t) {
643 PHPDebugUiPlugin.log(t);
646 public Image getImage() {
647 return PHPUiImages.get(PHPUiImages.IMG_CTOOLS_PHP);