import net.sourceforge.phpdt.internal.debug.ui.PHPDebugUiMessages;
import net.sourceforge.phpdt.internal.debug.ui.PHPDebugUiPlugin;
import net.sourceforge.phpdt.internal.debug.ui.preferences.EditInterpreterDialog;
+import net.sourceforge.phpdt.internal.debug.ui.preferences.EditPathMapDialog;
import net.sourceforge.phpdt.internal.launching.PHPInterpreter;
import net.sourceforge.phpdt.internal.launching.PHPLaunchConfigurationAttribute;
import net.sourceforge.phpdt.internal.launching.PHPRuntime;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
protected Combo interpreterCombo;
protected Button loadPathDefaultButton;
protected Button fRemoteDebugCheckBox;
- protected Button fFileMapRemoveButton;
- protected Button fFileMapAddButton;
- protected Button fFileMapEditButton;
+ protected Button fPathMapRemoveButton;
+ protected Button fPathMapAddButton;
+ protected Button fPathMapEditButton;
protected Text fRemoteSourcePath;
- protected Table fRemoteDebugFileMapTable;
+ protected Table fRemoteDebugPathMapTable;
protected TabFolder tabFolder;
private class RemoteDebugTabListener extends SelectionAdapter implements ModifyListener {
*/
public void widgetSelected(SelectionEvent e) {
Object source= e.getSource();
- if (source == fRemoteDebugFileMapTable) {
- setFileMapButtonsEnableState();
- } else if (source == fFileMapAddButton) {
- handleFileMapAddButtonSelected();
- } else if (source == fFileMapEditButton) {
- handleFileMapEditButtonSelected();
- } else if (source == fFileMapRemoveButton) {
- handleFileMapRemoveButtonSelected();
+ if (source == fRemoteDebugPathMapTable) {
+ setPathMapButtonsEnableState();
+ } else if (source == fPathMapAddButton) {
+ handlePathMapAddButtonSelected();
+ } else if (source == fPathMapEditButton) {
+ handlePathMapEditButtonSelected();
+ } else if (source == fPathMapRemoveButton) {
+ handlePathMapRemoveButtonSelected();
} else if (source == fRemoteDebugCheckBox) {
setRemoteTabEnableState();
} else {
}
+ private static final String EMPTY_STRING = ""; //$NON-NLS-1$
private RemoteDebugTabListener fListener= new RemoteDebugTabListener();
private static final boolean DEFAULT_REMOTE_DEBUG= false;
- static String [] columnTitles = { PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.FileMapTableTitle.local"),
- PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.FileMapTableTitle.remote")
+ static String [] columnTitles = { PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMapTableTitle.local"),
+ PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMapTableTitle.remote")
};
public PHPEnvironmentTab() {
super();
createVerticalSpacer(comp,1);
- Composite fileMapComp = new Composite(comp, SWT.NONE);
+ Composite pathMapComp = new Composite(comp, SWT.NONE);
gd = new GridData(GridData.FILL_BOTH);
- fileMapComp.setLayoutData(gd);
+ pathMapComp.setLayoutData(gd);
GridLayout parametersLayout = new GridLayout();
parametersLayout.numColumns = 2;
parametersLayout.marginHeight = 0;
parametersLayout.marginWidth = 0;
- fileMapComp.setLayout(parametersLayout);
+ pathMapComp.setLayout(parametersLayout);
- Label fileMapLabel = new Label(fileMapComp, SWT.NONE);
- fileMapLabel.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.FileMap.label"));
+ Label pathMapLabel = new Label(pathMapComp, SWT.NONE);
+ pathMapLabel.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.label"));
gd = new GridData();
gd.horizontalSpan = 2;
- fileMapLabel.setLayoutData(gd);
+ pathMapLabel.setLayoutData(gd);
- fRemoteDebugFileMapTable = new Table(fileMapComp, SWT.BORDER | SWT.MULTI);
+ fRemoteDebugPathMapTable = new Table(pathMapComp, SWT.BORDER | SWT.MULTI);
TableLayout tableLayout = new TableLayout();
- fRemoteDebugFileMapTable.setLayout(tableLayout);
+ fRemoteDebugPathMapTable.setLayout(tableLayout);
gd = new GridData(GridData.FILL_BOTH);
- fRemoteDebugFileMapTable.setLayoutData(gd);
- TableColumn column1 = new TableColumn(this.fRemoteDebugFileMapTable, SWT.NONE);
- column1.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.FileMap.Table.Title.local")); //$NON-NLS-1$
- TableColumn column2 = new TableColumn(this.fRemoteDebugFileMapTable, SWT.NONE);
- column2.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.FileMap.Table.Title.remote")); //$NON-NLS-1$
+ fRemoteDebugPathMapTable.setLayoutData(gd);
+ TableColumn column1 = new TableColumn(this.fRemoteDebugPathMapTable, SWT.NONE);
+ column1.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Table.Title.local")); //$NON-NLS-1$
+ TableColumn column2 = new TableColumn(this.fRemoteDebugPathMapTable, SWT.NONE);
+ column2.setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Table.Title.remote")); //$NON-NLS-1$
tableLayout.addColumnData(new ColumnWeightData(100));
tableLayout.addColumnData(new ColumnWeightData(100));
- fRemoteDebugFileMapTable.setHeaderVisible(true);
- fRemoteDebugFileMapTable.setLinesVisible(true);
- fRemoteDebugFileMapTable.addSelectionListener(fListener);
- fRemoteDebugFileMapTable.setEnabled(false);
+ fRemoteDebugPathMapTable.setHeaderVisible(true);
+ fRemoteDebugPathMapTable.setLinesVisible(true);
+ fRemoteDebugPathMapTable.addSelectionListener(fListener);
+ fRemoteDebugPathMapTable.addMouseListener(new MouseAdapter() {
+ public void mouseDoubleClick(MouseEvent e) {
+ setPathMapButtonsEnableState();
+ if (fPathMapEditButton.isEnabled()) {
+ handlePathMapEditButtonSelected();
+ }
+ }
+ });
+// fRemoteDebugPathMapTable.setEnabled(false);
- Composite envButtonComp = new Composite(fileMapComp, SWT.NONE);
+ Composite envButtonComp = new Composite(pathMapComp, SWT.NONE);
GridLayout envButtonLayout = new GridLayout();
envButtonLayout.marginHeight = 0;
envButtonLayout.marginWidth = 0;
envButtonComp.setLayoutData(gd);
- fFileMapAddButton = createPushButton(envButtonComp ,PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.FileMap.Button.Add.label"), null); //$NON-NLS-1$
- fFileMapAddButton.addSelectionListener(fListener);
- fFileMapAddButton.setEnabled(false);
+ fPathMapAddButton = createPushButton(envButtonComp ,PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Button.Add.label"), null); //$NON-NLS-1$
+ fPathMapAddButton.addSelectionListener(fListener);
+// fPathMapAddButton.setEnabled(false);
- fFileMapEditButton = createPushButton(envButtonComp,PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.FileMap.Button.Edit.label"), null); //$NON-NLS-1$
- fFileMapEditButton.addSelectionListener(fListener);
- fFileMapEditButton.setEnabled(false);
+ fPathMapEditButton = createPushButton(envButtonComp,PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Button.Edit.label"), null); //$NON-NLS-1$
+ fPathMapEditButton.addSelectionListener(fListener);
+// fPathMapEditButton.setEnabled(false);
- fFileMapRemoveButton = createPushButton(envButtonComp,PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.FileMap.Button.Remove.label"), null); //$NON-NLS-1$
- fFileMapRemoveButton.addSelectionListener(fListener);
- fFileMapRemoveButton.setEnabled(false);
+ fPathMapRemoveButton = createPushButton(envButtonComp,PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Button.Remove.label"), null); //$NON-NLS-1$
+ fPathMapRemoveButton.addSelectionListener(fListener);
+// fPathMapRemoveButton.setEnabled(false);
}
- void handleFileMapAddButtonSelected()
+ void handlePathMapAddButtonSelected()
{
- TableItem item = new TableItem (fRemoteDebugFileMapTable, SWT.NONE);
- updateLaunchConfigurationDialog();
+ EditPathMapDialog dialog=
+ new EditPathMapDialog(
+ getShell(),
+ "Edit File Map",
+ new String[] {EMPTY_STRING, EMPTY_STRING});
+ openNewPathMapDialog(dialog,null);
+// dialog.create();
+// if (dialog.open()==EditPathMapDialog.OK)
+// {
+// TableItem item = new TableItem (fRemoteDebugPathMapTable, SWT.NONE);
+// item.setText(0,dialog.getLocalPath());
+// item.setText(1,dialog.getRemotePath());
+// updateLaunchConfigurationDialog();
+// }
+// updateLaunchConfigurationDialog();
+ setPathMapButtonsEnableState();
}
- void handleFileMapRemoveButtonSelected()
+ void handlePathMapRemoveButtonSelected()
{
- int idx=fRemoteDebugFileMapTable.getSelectionIndex();
- if (idx !=-1)
- fRemoteDebugFileMapTable.remove(idx);
+ int[] selectedIndices = this.fRemoteDebugPathMapTable.getSelectionIndices();
+ this.fRemoteDebugPathMapTable.remove(selectedIndices);
+ setPathMapButtonsEnableState();
updateLaunchConfigurationDialog();
}
- void handleFileMapEditButtonSelected()
+ void handlePathMapEditButtonSelected()
{
+ TableItem selectedItem = this.fRemoteDebugPathMapTable.getSelection()[0];
+ String local = selectedItem.getText(0);
+ String remote = selectedItem.getText(1);
+ EditPathMapDialog dialog=
+ new EditPathMapDialog(
+ getShell(),
+ "Edit File Map",
+ new String[] {local, remote});
+ openNewPathMapDialog(dialog, selectedItem);
}
private void setRemoteTabEnableState() {
boolean state=fRemoteDebugCheckBox.getSelection();
fRemoteSourcePath.setEnabled(state);
-
-// TODO: (cperkonig) not implemented yet
-// fRemoteDebugFileMapTable.setEnabled(state);
-// if (!state)
-// {
-// fFileMapEditButton.setEnabled(false);
-// fFileMapRemoveButton.setEnabled(false);
-// fFileMapAddButton.setEnabled(false);
-// } else {
-// setFileMapButtonsEnableState();
-// }
+
+ fRemoteDebugPathMapTable.setEnabled(state);
+ if (!state)
+ {
+ fPathMapEditButton.setEnabled(false);
+ fPathMapRemoveButton.setEnabled(false);
+ fPathMapAddButton.setEnabled(false);
+ } else {
+ setPathMapButtonsEnableState();
+ }
updateLaunchConfigurationDialog();
}
/**
* Set the enabled state of the three environment variable-related buttons based on the
- * selection in the FileMapTable widget.
+ * selection in the PathMapTable widget.
*/
- private void setFileMapButtonsEnableState() {
+ private void setPathMapButtonsEnableState() {
// just do nothing for now
//
if(fRemoteDebugCheckBox.getSelection())
{
- int selectCount = this.fRemoteDebugFileMapTable.getSelectionIndices().length;
+ int selectCount = this.fRemoteDebugPathMapTable.getSelectionIndices().length;
if (selectCount < 1) {
- fFileMapEditButton.setEnabled(false);
- fFileMapRemoveButton.setEnabled(false);
+ fPathMapEditButton.setEnabled(false);
+ fPathMapRemoveButton.setEnabled(false);
} else {
- fFileMapRemoveButton.setEnabled(true);
+ fPathMapRemoveButton.setEnabled(true);
if (selectCount == 1) {
- fFileMapEditButton.setEnabled(true);
+ fPathMapEditButton.setEnabled(true);
} else {
- fFileMapEditButton.setEnabled(false);
+ fPathMapEditButton.setEnabled(false);
}
}
- fFileMapAddButton.setEnabled(true);
+ fPathMapAddButton.setEnabled(true);
}
}
+ /**
+ * Show the specified dialog and update the pathMapTable table based on its results.
+ *
+ * @param updateItem the item to update, or <code>null</code> if
+ * adding a new item
+ */
+ private void openNewPathMapDialog(EditPathMapDialog dialog, TableItem updateItem) {
+ if (dialog.open() != EditPathMapDialog.OK) {
+ return;
+ }
+ String[] pathPair = dialog.getPathPair();
+ TableItem tableItem = updateItem;
+ if (tableItem == null) {
+ tableItem = getTableItemForName(pathPair[0]);
+ if (tableItem == null) {
+ tableItem = new TableItem(this.fRemoteDebugPathMapTable, SWT.NONE);
+ }
+ }
+ tableItem.setText(pathPair);
+ this.fRemoteDebugPathMapTable.setSelection(new TableItem[] {tableItem});
+ updateLaunchConfigurationDialog();
+ }
+
+ /**
+ * Helper method that indicates whether the specified parameter name is already present
+ * in the parameters table.
+ */
+ private TableItem getTableItemForName(String candidateName) {
+ TableItem[] items = this.fRemoteDebugPathMapTable.getItems();
+ for (int i = 0; i < items.length; i++) {
+ String name = items[i].getText(0);
+ if (name.equals(candidateName)) {
+ return items[i];
+ }
+ }
+ return null;
+ }
+
protected void addLoadPathTab(TabFolder tabFolder) {
fRemoteSourcePath.setText("");
}
- updateFileMapFromConfig(configuration);
+ updatePathMapFromConfig(configuration);
}
- private void updateFileMapFromConfig(ILaunchConfiguration config) {
- Map envVars = null;
- try {
- if (config != null) {
- envVars = config.getAttribute(PHPLaunchConfigurationAttribute.FILE_MAP, (Map)null);
- }
- updateFileMapTable(envVars, this.fRemoteDebugFileMapTable);
- setFileMapButtonsEnableState();
- } catch (CoreException ce) {
- log(ce);
+ private void updatePathMapFromConfig(ILaunchConfiguration config) {
+ Map envVars = null;
+ try {
+ if (config != null) {
+ envVars = config.getAttribute(PHPLaunchConfigurationAttribute.FILE_MAP, (Map)null);
}
+ updatePathMapTable(envVars, this.fRemoteDebugPathMapTable);
+ setPathMapButtonsEnableState();
+ } catch (CoreException ce) {
+ log(ce);
}
+ }
- private void updateFileMapTable(Map map, Table tableWidget) {
- tableWidget.removeAll();
- if (map == null) {
- return;
- }
- Iterator iterator = map.keySet().iterator();
- while (iterator.hasNext()) {
- String key = (String) iterator.next();
- String value = (String) map.get(key);
- TableItem tableItem = new TableItem(tableWidget, SWT.NONE);
- tableItem.setText(new String[] {key, value});
- }
+ private void updatePathMapTable(Map map, Table tableWidget) {
+ tableWidget.removeAll();
+ if (map == null) {
+ return;
+ }
+ Iterator iterator = map.keySet().iterator();
+ while (iterator.hasNext()) {
+ String key = (String) iterator.next();
+ String value = (String) map.get(key);
+ TableItem tableItem = new TableItem(tableWidget, SWT.NONE);
+ tableItem.setText(new String[] {key, value});
}
+ }
protected void initializeLoadPath(ILaunchConfiguration configuration) {
boolean useDefaultLoadPath = true;
}
configuration.setAttribute(PHPLaunchConfigurationAttribute.REMOTE_DEBUG, fRemoteDebugCheckBox.getSelection());
- configuration.setAttribute(PHPLaunchConfigurationAttribute.FILE_MAP, getMapFromFileMapTable());
+ configuration.setAttribute(PHPLaunchConfigurationAttribute.FILE_MAP, getMapFromPathMapTable());
configuration.setAttribute(PHPLaunchConfigurationAttribute.REMOTE_PATH, fRemoteSourcePath.getText());
}
return composite;
}
- private Map getMapFromFileMapTable() {
- TableItem[] items = fRemoteDebugFileMapTable.getItems();
+ private Map getMapFromPathMapTable() {
+ TableItem[] items = fRemoteDebugPathMapTable.getItems();
if (items.length == 0) {
return null;
}