# HG changeset patch # User Ed Swartz # Date 1272295730 18000 # Node ID 49840c7f58f4b300697fd155ad062413fc9256f3 # Parent 12fd76372d9527560818f1585fcbdabac41a1895 Fix remote program selector changes: was not properly initializing from project EXE, and MRU logic was not correct. diff -r 12fd76372d95 -r 49840c7f58f4 debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/DebugRunProcessDialog.java --- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/DebugRunProcessDialog.java Fri Apr 23 15:24:20 2010 -0500 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/DebugRunProcessDialog.java Mon Apr 26 10:28:50 2010 -0500 @@ -19,6 +19,7 @@ import java.io.File; import java.text.MessageFormat; +import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; @@ -90,7 +91,7 @@ private Button sisBrowse; private Composite installPackageUI; - private Set remotePathEntries = new LinkedHashSet(); + private List remotePathEntries = new ArrayList(); protected DebugRunProcessDialog(Shell shell, LaunchWizardData data) { super(shell, data); @@ -137,11 +138,14 @@ * */ protected void saveRemoteProgramEntries() { - Set uniqueRemotePathEntries = new LinkedHashSet(remotePathEntries); + // in case user was typing, ensure that entry is present + if(remoteProgramViewer != null) { + IPath currentPath = PathUtils.createPath(remoteProgramViewer.getCombo().getText().trim()); + remotePathEntries.remove(currentPath); + remotePathEntries.add(0, currentPath); // MRU + } - // in case user was typing, ensure that entry is present - if(remoteProgramViewer != null) - uniqueRemotePathEntries.add(PathUtils.createPath(remoteProgramViewer.getCombo().getText().trim())); + Set uniqueRemotePathEntries = new LinkedHashSet(remotePathEntries); for (Iterator iter = uniqueRemotePathEntries.iterator(); iter.hasNext(); ) { IPath path = iter.next(); @@ -149,11 +153,13 @@ iter.remove(); } - // truncate size - while (uniqueRemotePathEntries.size() > 10) - uniqueRemotePathEntries.remove(uniqueRemotePathEntries.iterator().next()); + // truncate size, removing from end + List mruPathEntries = new ArrayList(uniqueRemotePathEntries); + while (mruPathEntries.size() > 10) { + mruPathEntries.remove(mruPathEntries.size() - 1); + } - String pathSoup = TextUtils.catenateStrings(uniqueRemotePathEntries.toArray(), "|"); //$NON-NLS-1$ + String pathSoup = TextUtils.catenateStrings(mruPathEntries.toArray(), "|"); //$NON-NLS-1$ LaunchPlugin.getDefault().getPreferenceStore().setValue(USER_REMOTE_PATHS, pathSoup); } @@ -418,16 +424,32 @@ protected void initUI() { List exes = data.getLaunchableExes(); projectExecutableViewer.setInput(exes); + + // this path may either be a project-relative or remote path IPath exeSelectionPath = data.getExeSelectionPath(); if (exeSelectionPath.equals(Path.EMPTY) && !exes.isEmpty()) exeSelectionPath = exes.get(0); + if (!Path.EMPTY.equals(exeSelectionPath)) { + // keep previous path if possible... + IPath remotePath = exeSelectionPath; + if (data.getExes().contains(remotePath)) { + // unless that was actually a host-side path, which should be converted + remotePath = createSuggestedRemotePath(exeSelectionPath); + } else { + // selection is already a remote path; map back to project if possible + for (IPath exe : data.getExes()) { + if (exe.lastSegment().equals(remotePath.lastSegment())) { + exeSelectionPath = exe; + break; + } + } + } projectExecutableViewer.setSelection(new StructuredSelection(exeSelectionPath)); - IPath remotePath = exeSelectionPath; + if (remoteProgramViewer != null) { if (!remotePathEntries.contains(remotePath)) { - remotePath = createSuggestedRemotePath(exeSelectionPath); - remotePathEntries.add(remotePath); + remotePathEntries.add(0, remotePath); // MRU remoteProgramViewer.add(remotePath); } remoteProgramViewer.setSelection(new StructuredSelection(remotePath)); @@ -435,11 +457,11 @@ } if (data.getExeSelection() == EExeSelection.USE_PROJECT_EXECUTABLE && exeSelectionPath != null) { - projectExecutableRadioButton.forceFocus(); + projectExecutableViewer.getControl().forceFocus(); } if (data.getExeSelection() == EExeSelection.USE_REMOTE_EXECUTABLE && exeSelectionPath != null) { - remoteExecutableRadioButton.forceFocus(); + remoteProgramViewer.getControl().forceFocus(); } if (data.getExeSelection() == EExeSelection.ATTACH_TO_PROCESS) { @@ -565,7 +587,13 @@ remoteProgramViewer.getCombo().addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { - data.setExeSelectionPath(PathUtils.createPath(remoteProgramViewer.getCombo().getText().trim())); + IPath path = PathUtils.createPath(remoteProgramViewer.getCombo().getText().trim()); + data.setExeSelectionPath(path); + + // MRU behavior + remotePathEntries.remove(path); + remotePathEntries.add(0, path); + validate(); } });