Launch wizard: sync project and remote paths but don't thwart actually editing the path; be looser finding a project file matching the user-edited entry
--- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/DebugRunProcessDialog.java Mon Apr 26 13:43:17 2010 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/DebugRunProcessDialog.java Mon Apr 26 14:55:33 2010 -0500
@@ -20,7 +20,6 @@
import java.io.File;
import java.text.MessageFormat;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
@@ -94,6 +93,7 @@
private Composite installPackageUI;
private List<IPath> remotePathEntries = new ArrayList<IPath>();
+ private ArrayList<IPath> projectGeneratedRemotePaths;
protected DebugRunProcessDialog(Shell shell, LaunchWizardData data) {
super(shell, data);
@@ -146,14 +146,11 @@
remotePathEntries.remove(currentPath);
remotePathEntries.add(0, currentPath); // MRU
}
-
+
+ // make a set, removing user dupes, and also removing the entries we added
Set<IPath> uniqueRemotePathEntries = new LinkedHashSet<IPath>(remotePathEntries);
-
- for (Iterator<IPath> iter = uniqueRemotePathEntries.iterator(); iter.hasNext(); ) {
- IPath path = iter.next();
- if (path.isEmpty() || getHostFileForRemoteLocation(path) != null)
- iter.remove();
- }
+ if (projectGeneratedRemotePaths != null)
+ uniqueRemotePathEntries.removeAll(projectGeneratedRemotePaths);
// truncate size, removing from end
List<IPath> mruPathEntries = new ArrayList<IPath>(uniqueRemotePathEntries);
@@ -445,6 +442,11 @@
if (projPath != null) {
exeSelectionPath = projPath;
}
+ else {
+ // remote path does not correspond to anything; select some project exe so
+ // the combo isn't empty
+ exeSelectionPath = exes.get(0);
+ }
}
projectExecutableViewer.setSelection(new StructuredSelection(exeSelectionPath));
@@ -489,8 +491,12 @@
*/
private IPath getHostFileForRemoteLocation(IPath path) {
for (IPath exe : data.getExes()) {
- IPath remoteSuggested = createSuggestedRemotePath(exe);
- if (remoteSuggested.equals(path)) {
+ // no... we don't have any knowledge (yet) of the actual install path,
+ // so comparing the exact path will fail if the user edited it.
+ // IPath remoteSuggested = createSuggestedRemotePath(exe);
+
+ // be pretty loose in the matching for now
+ if (exe.lastSegment().equalsIgnoreCase(path.lastSegment())) {
return exe;
}
}
@@ -537,10 +543,12 @@
public void selectionChanged(SelectionChangedEvent event) {
Object sel = ((IStructuredSelection) event.getSelection()).getFirstElement();
if (sel instanceof IPath) {
- data.setExeSelectionPath((IPath) sel);
+ if (projectExecutableRadioButton.getSelection()) {
+ data.setExeSelectionPath((IPath) sel);
+ }
// track the default remote program from the executable, for easy editing
- if (remoteProgramViewer != null) {
+ if (remoteProgramViewer != null && !remoteExecutableRadioButton.getSelection()) {
IPath exeSelectionPath = createSuggestedRemotePath(data.getExeSelectionPath());
// path should already be in model
remoteProgramViewer.setSelection(new StructuredSelection(exeSelectionPath));
@@ -582,12 +590,14 @@
remoteProgramViewer = new ComboViewer(radioGroup, SWT.BORDER);
GridDataFactory.fillDefaults().grab(true, false).applyTo(remoteProgramViewer.getControl());
- // add the entries before the user MRU entries
- int addIdx = 0;
+ projectGeneratedRemotePaths = new ArrayList<IPath>();
for (IPath launchable : data.getLaunchableExes()) {
- remotePathEntries.add(addIdx++, createSuggestedRemotePath(launchable));
+ projectGeneratedRemotePaths.add(createSuggestedRemotePath(launchable));
}
+ // add the entries before the user MRU entries
+ remotePathEntries.addAll(0, projectGeneratedRemotePaths);
+
remoteProgramViewer.setContentProvider(new ArrayContentProvider());
remoteProgramViewer.setLabelProvider(new LabelProvider() {
@Override
@@ -615,7 +625,17 @@
remoteProgramViewer.getCombo().addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
IPath path = PathUtils.createPath(remoteProgramViewer.getCombo().getText().trim());
- data.setExeSelectionPath(path);
+ if (remoteExecutableRadioButton.getSelection()) {
+ data.setExeSelectionPath(path);
+ }
+
+ if (!projectExecutableRadioButton.getSelection()) {
+ IPath projPath = getHostFileForRemoteLocation(path);
+ if (projPath != null) {
+ projectExecutableViewer.setSelection(new StructuredSelection(projPath));
+ }
+ }
+
validate();
}
});