# HG changeset patch # User Ed Swartz # Date 1272295744 18000 # Node ID 06478ac50ae0499e89b415539fe06cc614a991a5 # Parent 49840c7f58f4b300697fd155ad062413fc9256f3# Parent 7f978d9fb8f6a9a72aead80b71d1f01c43aad5da Merge commit diff -r 7f978d9fb8f6 -r 06478ac50ae0 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 Mon Apr 26 08:38:43 2010 -0500 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/DebugRunProcessDialog.java Mon Apr 26 10:29:04 2010 -0500 @@ -19,7 +19,11 @@ 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; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent; @@ -64,8 +68,10 @@ import com.nokia.carbide.cdt.builder.project.ICarbideBuildConfiguration; import com.nokia.carbide.cdt.builder.project.ICarbideProjectInfo; import com.nokia.carbide.cdt.builder.project.ISISBuilderInfo; +import com.nokia.cdt.internal.debug.launch.LaunchPlugin; import com.nokia.cdt.internal.debug.launch.newwizard.LaunchWizardData.EExeSelection; import com.nokia.cpp.internal.api.utils.core.PathUtils; +import com.nokia.cpp.internal.api.utils.core.TextUtils; import com.nokia.cpp.internal.api.utils.ui.BrowseDialogUtils; /** @@ -73,7 +79,7 @@ */ public class DebugRunProcessDialog extends AbstractLaunchSettingsDialog implements ICProjectDescriptionListener { private ComboViewer projectExecutableViewer; - private Text remoteProgramEntry; + private ComboViewer remoteProgramViewer; private Button projectExecutableRadioButton; private Button remoteExecutableRadioButton; private Button attachToProcessRadioButton; @@ -85,6 +91,8 @@ private Button sisBrowse; private Composite installPackageUI; + private List remotePathEntries = new ArrayList(); + protected DebugRunProcessDialog(Shell shell, LaunchWizardData data) { super(shell, data); } @@ -100,6 +108,14 @@ data.isDebug() ? LaunchWizardHelpIds.WIZARD_DIALOG_CHANGE_DEBUG_PROCESS : LaunchWizardHelpIds.WIZARD_DIALOG_CHANGE_RUN_PROCESS); + loadRemoteProgramEntries(); + + composite.addDisposeListener(new DisposeListener() { + + public void widgetDisposed(DisposeEvent e) { + saveRemoteProgramEntries(); + } + }); createProcessSelector(composite); @@ -115,6 +131,51 @@ return composite; } + // pref key for paths the user has manually entered + final static String USER_REMOTE_PATHS = "user.remote.paths"; //$NON-NLS-1$ + + /** + * + */ + protected void saveRemoteProgramEntries() { + // 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 + } + + Set uniqueRemotePathEntries = new LinkedHashSet(remotePathEntries); + + for (Iterator iter = uniqueRemotePathEntries.iterator(); iter.hasNext(); ) { + IPath path = iter.next(); + if (path.isEmpty() || data.getExes().contains(path)) + iter.remove(); + } + + // truncate size, removing from end + List mruPathEntries = new ArrayList(uniqueRemotePathEntries); + while (mruPathEntries.size() > 10) { + mruPathEntries.remove(mruPathEntries.size() - 1); + } + + String pathSoup = TextUtils.catenateStrings(mruPathEntries.toArray(), "|"); //$NON-NLS-1$ + LaunchPlugin.getDefault().getPreferenceStore().setValue(USER_REMOTE_PATHS, pathSoup); + } + + + /** + * + */ + protected void loadRemoteProgramEntries() { + String pathSoup = LaunchPlugin.getDefault().getPreferenceStore().getString(USER_REMOTE_PATHS); + if (pathSoup != null) { + String[] paths = pathSoup.split("\\|"); //$NON-NLS-1$ + for (String path : paths) + remotePathEntries.add(PathUtils.createPath(path)); + } + } + private void createProcessSelector(Composite composite) { Label label; @@ -363,21 +424,44 @@ 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 = createSuggestedRemotePath(exeSelectionPath); - remoteProgramEntry.setText(PathUtils.convertPathToWindows(remotePath)); + + if (remoteProgramViewer != null) { + if (!remotePathEntries.contains(remotePath)) { + remotePathEntries.add(0, remotePath); // MRU + remoteProgramViewer.add(remotePath); + } + remoteProgramViewer.setSelection(new StructuredSelection(remotePath)); + } } 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) { @@ -435,9 +519,10 @@ data.setExeSelectionPath((IPath) sel); // track the default remote program from the executable, for easy editing - if (remoteProgramEntry != null) { + if (remoteProgramViewer != null) { IPath exeSelectionPath = createSuggestedRemotePath(data.getExeSelectionPath()); - remoteProgramEntry.setText(PathUtils.convertPathToWindows(exeSelectionPath)); + // path should already be in model + remoteProgramViewer.setSelection(new StructuredSelection(exeSelectionPath)); } validate(); @@ -472,10 +557,25 @@ remoteExecutableRadioButton.setData(UID, "radio_remote_program"); //$NON-NLS-1$ - remoteProgramEntry = new Text(radioGroup, SWT.BORDER); - GridDataFactory.fillDefaults().grab(true, false).applyTo(remoteProgramEntry); + remoteProgramViewer = new ComboViewer(radioGroup, SWT.BORDER); + GridDataFactory.fillDefaults().grab(true, false).applyTo(remoteProgramViewer.getControl()); + + remotePathEntries.addAll(data.getExes()); - remoteProgramEntry.setData(UID, "text_remote_program"); //$NON-NLS-1$ + remoteProgramViewer.setContentProvider(new ArrayContentProvider()); + remoteProgramViewer.setLabelProvider(new LabelProvider() { + @Override + public String getText(Object element) { + if (element instanceof IPath) + return PathUtils.convertPathToWindows((IPath) element); + return super.getText(element); + } + }); + remoteProgramViewer.setInput(remotePathEntries); + remoteProgramViewer.getCombo().setVisibleItemCount(remotePathEntries.size()); + + + remoteProgramViewer.setData(UID, "combo_remote_program"); //$NON-NLS-1$ remoteExecutableRadioButton.addSelectionListener(new SelectionAdapter() { @Override @@ -485,9 +585,15 @@ }); - remoteProgramEntry.addModifyListener(new ModifyListener() { + remoteProgramViewer.getCombo().addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { - data.setExeSelectionPath(new Path(remoteProgramEntry.getText().trim())); + IPath path = PathUtils.createPath(remoteProgramViewer.getCombo().getText().trim()); + data.setExeSelectionPath(path); + + // MRU behavior + remotePathEntries.remove(path); + remotePathEntries.add(0, path); + validate(); } }); @@ -495,13 +601,13 @@ private void handleRemoteExecutableRadioSelected() { if (remoteExecutableRadioButton.getSelection()) { - remoteProgramEntry.setEnabled(true); + remoteProgramViewer.getControl().setEnabled(true); data.setExeSelection(EExeSelection.USE_REMOTE_EXECUTABLE); - IPath path = PathUtils.createPath(remoteProgramEntry.getText()); + IPath path = PathUtils.createPath(remoteProgramViewer.getCombo().getText()); data.setExeSelectionPath(path); validate(); } else { - remoteProgramEntry.setEnabled(false); + remoteProgramViewer.getControl().setEnabled(false); // another button becomes active and sets the new launch process } } diff -r 7f978d9fb8f6 -r 06478ac50ae0 debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/messages.properties --- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/messages.properties Mon Apr 26 08:38:43 2010 -0500 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/messages.properties Mon Apr 26 10:29:04 2010 -0500 @@ -25,7 +25,7 @@ DebugRunProcessDialog.InstallBeforeLaunchLabel=Install package before launch DebugRunProcessDialog.InstallFilterName=Installation Files DebugRunProcessDialog.LaunchProjectExeLabel=Launch project &executable: -DebugRunProcessDialog.LaunchRemoteProgLabel=Launch &remote program: +DebugRunProcessDialog.LaunchRemoteProgLabel=Launch program on &device: DebugRunProcessDialog.ModeLabel={0} method: DebugRunProcessDialog.NoExesError=The project builds no executables. DebugRunProcessDialog.NoneItem=None