68 import com.nokia.carbide.cdt.builder.CarbideBuilderPlugin; |
68 import com.nokia.carbide.cdt.builder.CarbideBuilderPlugin; |
69 import com.nokia.carbide.cdt.builder.project.ICarbideBuildConfiguration; |
69 import com.nokia.carbide.cdt.builder.project.ICarbideBuildConfiguration; |
70 import com.nokia.carbide.cdt.builder.project.ICarbideProjectInfo; |
70 import com.nokia.carbide.cdt.builder.project.ICarbideProjectInfo; |
71 import com.nokia.carbide.cdt.builder.project.ISISBuilderInfo; |
71 import com.nokia.carbide.cdt.builder.project.ISISBuilderInfo; |
72 import com.nokia.cdt.internal.debug.launch.LaunchPlugin; |
72 import com.nokia.cdt.internal.debug.launch.LaunchPlugin; |
73 import com.nokia.cdt.internal.debug.launch.newwizard.LaunchWizardData.EExeSelection; |
73 import com.nokia.cdt.internal.debug.launch.newwizard.IDebugRunProcessWizardData.EExeSelection; |
74 import com.nokia.cpp.internal.api.utils.core.PathUtils; |
74 import com.nokia.cpp.internal.api.utils.core.PathUtils; |
75 import com.nokia.cpp.internal.api.utils.core.TextUtils; |
75 import com.nokia.cpp.internal.api.utils.core.TextUtils; |
76 import com.nokia.cpp.internal.api.utils.ui.BrowseDialogUtils; |
76 import com.nokia.cpp.internal.api.utils.ui.BrowseDialogUtils; |
77 |
77 |
78 /** |
78 /** |
93 private Composite installPackageUI; |
93 private Composite installPackageUI; |
94 |
94 |
95 private List<IPath> remotePathEntries = new ArrayList<IPath>(); |
95 private List<IPath> remotePathEntries = new ArrayList<IPath>(); |
96 private List<IPath> projectGeneratedRemotePaths; |
96 private List<IPath> projectGeneratedRemotePaths; |
97 |
97 |
98 protected DebugRunProcessDialog(Shell shell, LaunchWizardData data) { |
98 private IDebugRunProcessWizardData debugRunProcessWizardData; |
|
99 |
|
100 protected DebugRunProcessDialog(Shell shell, IWizardData data) { |
99 super(shell, data); |
101 super(shell, data); |
|
102 debugRunProcessWizardData = (IDebugRunProcessWizardData) data; |
100 } |
103 } |
101 |
104 |
102 |
105 |
103 /* (non-Javadoc) |
106 /* (non-Javadoc) |
104 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) |
107 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) |
201 msg = Messages.getString("DebugRunProcessDialog.DebugConfigureMsg"); //$NON-NLS-1$ |
204 msg = Messages.getString("DebugRunProcessDialog.DebugConfigureMsg"); //$NON-NLS-1$ |
202 else |
205 else |
203 msg = Messages.getString("DebugRunProcessDialog.RunConfigureMsg"); //$NON-NLS-1$ |
206 msg = Messages.getString("DebugRunProcessDialog.RunConfigureMsg"); //$NON-NLS-1$ |
204 setMessage(msg); |
207 setMessage(msg); |
205 |
208 |
206 switch (data.getExeSelection()) { |
209 switch (debugRunProcessWizardData.getExeSelection()) { |
207 case USE_PROJECT_EXECUTABLE: |
210 case USE_PROJECT_EXECUTABLE: |
208 projectExecutableRadioButton.setSelection(true); |
211 projectExecutableRadioButton.setSelection(true); |
209 break; |
212 break; |
210 case USE_REMOTE_EXECUTABLE: |
213 case USE_REMOTE_EXECUTABLE: |
211 remoteExecutableRadioButton.setSelection(true); |
214 remoteExecutableRadioButton.setSelection(true); |
247 |
250 |
248 |
251 |
249 installPackageCheckbox.addSelectionListener(new SelectionAdapter() { |
252 installPackageCheckbox.addSelectionListener(new SelectionAdapter() { |
250 @Override |
253 @Override |
251 public void widgetSelected(SelectionEvent e) { |
254 public void widgetSelected(SelectionEvent e) { |
252 data.setInstallPackage(installPackageCheckbox.getSelection()); |
255 debugRunProcessWizardData.setInstallPackage(installPackageCheckbox.getSelection()); |
253 updatePackageUI(); |
256 updatePackageUI(); |
254 } |
257 } |
255 }); |
258 }); |
256 |
259 |
257 |
260 |
258 if (data.isInstallPackage()) { |
261 if (debugRunProcessWizardData.isInstallPackage()) { |
259 installPackageCheckbox.setSelection(true); |
262 installPackageCheckbox.setSelection(true); |
260 updatePackageUI(); |
263 updatePackageUI(); |
261 } |
264 } |
262 |
265 |
263 updateSisFile(); |
266 updateSisFile(); |
325 public void modifyText(ModifyEvent e) { |
328 public void modifyText(ModifyEvent e) { |
326 updateSisFile(); |
329 updateSisFile(); |
327 validate(); |
330 validate(); |
328 } |
331 } |
329 }); |
332 }); |
330 String sisPath = data.getSisPath(); |
333 String sisPath = debugRunProcessWizardData.getSisPath(); |
331 if (sisPath != null) |
334 if (sisPath != null) |
332 sisEdit.setText(sisPath); |
335 sisEdit.setText(sisPath); |
333 sisEdit.setData(UID, "DebugRunProcessDialog.sisEdit"); //$NON-NLS-1$ |
336 sisEdit.setData(UID, "DebugRunProcessDialog.sisEdit"); //$NON-NLS-1$ |
334 |
337 |
335 sisBrowse = new Button(composite, SWT.NONE); |
338 sisBrowse = new Button(composite, SWT.NONE); |
382 */ |
385 */ |
383 protected void updateSisFile() { |
386 protected void updateSisFile() { |
384 String sisPath; |
387 String sisPath; |
385 if (sisFile != null) { |
388 if (sisFile != null) { |
386 sisPath = sisFile.getSelectionIndex() == 0 ? null : sisFile.getText(); //$NON-NLS-1$ |
389 sisPath = sisFile.getSelectionIndex() == 0 ? null : sisFile.getText(); //$NON-NLS-1$ |
387 data.setSisPath(sisPath); |
390 debugRunProcessWizardData.setSisPath(sisPath); |
388 } else if (sisEdit != null) { |
391 } else if (sisEdit != null) { |
389 sisPath = sisEdit.getText(); |
392 sisPath = sisEdit.getText(); |
390 data.setSisPath(sisPath); |
393 debugRunProcessWizardData.setSisPath(sisPath); |
391 } |
394 } |
392 } |
395 } |
393 |
396 |
394 |
397 |
395 private void updatePackageUI() { |
398 private void updatePackageUI() { |
396 installPackageUI.setEnabled(data.isInstallPackage()); |
399 installPackageUI.setEnabled(debugRunProcessWizardData.isInstallPackage()); |
397 for (Control kid : installPackageUI.getChildren()) |
400 for (Control kid : installPackageUI.getChildren()) |
398 kid.setEnabled(data.isInstallPackage()); |
401 kid.setEnabled(debugRunProcessWizardData.isInstallPackage()); |
399 } |
402 } |
400 |
403 |
401 |
404 |
402 public void handleEvent(CProjectDescriptionEvent event) { |
405 public void handleEvent(CProjectDescriptionEvent event) { |
403 Shell shell = getShell(); |
406 Shell shell = getShell(); |
420 } |
423 } |
421 } |
424 } |
422 } |
425 } |
423 |
426 |
424 protected void initUI() { |
427 protected void initUI() { |
425 List<IPath> exes = data.getLaunchableExes(); |
428 List<IPath> exes = debugRunProcessWizardData.getLaunchableExes(); |
426 projectExecutableViewer.setInput(exes); |
429 projectExecutableViewer.setInput(exes); |
427 |
430 |
428 // this path may either be a project-relative or remote path |
431 // this path may either be a project-relative or remote path |
429 IPath exeSelectionPath = data.getExeSelectionPath(); |
432 IPath exeSelectionPath = debugRunProcessWizardData.getExeSelectionPath(); |
430 if (exeSelectionPath.equals(Path.EMPTY) && !exes.isEmpty()) |
433 if (exeSelectionPath.equals(Path.EMPTY) && !exes.isEmpty()) |
431 exeSelectionPath = exes.get(0); |
434 exeSelectionPath = exes.get(0); |
432 |
435 |
433 if (!Path.EMPTY.equals(exeSelectionPath)) { |
436 if (!Path.EMPTY.equals(exeSelectionPath)) { |
434 // keep previous path if possible... |
437 // keep previous path if possible... |
435 IPath remotePath = exeSelectionPath; |
438 IPath remotePath = exeSelectionPath; |
436 if (data.getExes().contains(remotePath)) { |
439 if (debugRunProcessWizardData.getExes().contains(remotePath)) { |
437 // unless that was actually a host-side path, which should be converted |
440 // unless that was actually a host-side path, which should be converted |
438 remotePath = createSuggestedRemotePath(exeSelectionPath); |
441 remotePath = createSuggestedRemotePath(exeSelectionPath); |
439 } else { |
442 } else { |
440 // selection is already a remote path; map back to project if possible |
443 // selection is already a remote path; map back to project if possible |
441 IPath projPath = getHostFileForRemoteLocation(exeSelectionPath); |
444 IPath projPath = getHostFileForRemoteLocation(exeSelectionPath); |
457 } |
460 } |
458 remoteProgramViewer.setSelection(new StructuredSelection(remotePath)); |
461 remoteProgramViewer.setSelection(new StructuredSelection(remotePath)); |
459 } |
462 } |
460 } |
463 } |
461 |
464 |
462 if (data.getExeSelection() == EExeSelection.USE_PROJECT_EXECUTABLE && exeSelectionPath != null) { |
465 if (debugRunProcessWizardData.getExeSelection() == EExeSelection.USE_PROJECT_EXECUTABLE && exeSelectionPath != null) { |
463 projectExecutableViewer.getControl().forceFocus(); |
466 projectExecutableViewer.getControl().forceFocus(); |
464 } |
467 } |
465 |
468 |
466 if (data.getExeSelection() == EExeSelection.USE_REMOTE_EXECUTABLE && exeSelectionPath != null) { |
469 if (debugRunProcessWizardData.getExeSelection() == EExeSelection.USE_REMOTE_EXECUTABLE && exeSelectionPath != null) { |
467 remoteProgramViewer.getControl().forceFocus(); |
470 remoteProgramViewer.getControl().forceFocus(); |
468 } |
471 } |
469 |
472 |
470 if (data.getExeSelection() == EExeSelection.ATTACH_TO_PROCESS) { |
473 if (debugRunProcessWizardData.getExeSelection() == EExeSelection.ATTACH_TO_PROCESS) { |
471 attachToProcessRadioButton.forceFocus(); |
474 attachToProcessRadioButton.forceFocus(); |
472 } |
475 } |
473 |
476 |
474 handleProjectExecutableRadioSelected(); |
477 handleProjectExecutableRadioSelected(); |
475 handleRemoteExecutableRadioSelected(); |
478 handleRemoteExecutableRadioSelected(); |
488 * {@link #createSuggestedRemotePath(IPath)}. |
491 * {@link #createSuggestedRemotePath(IPath)}. |
489 * @param path |
492 * @param path |
490 * @return host path or <code>null</code> |
493 * @return host path or <code>null</code> |
491 */ |
494 */ |
492 private IPath getHostFileForRemoteLocation(IPath path) { |
495 private IPath getHostFileForRemoteLocation(IPath path) { |
493 for (IPath exe : data.getExes()) { |
496 for (IPath exe : debugRunProcessWizardData.getExes()) { |
494 // no... we don't have any knowledge (yet) of the actual install path, |
497 // no... we don't have any knowledge (yet) of the actual install path, |
495 // so comparing the exact path will fail if the user edited it. |
498 // so comparing the exact path will fail if the user edited it. |
496 // IPath remoteSuggested = createSuggestedRemotePath(exe); |
499 // IPath remoteSuggested = createSuggestedRemotePath(exe); |
497 |
500 |
498 // be pretty loose in the matching for now |
501 // be pretty loose in the matching for now |
542 |
545 |
543 public void selectionChanged(SelectionChangedEvent event) { |
546 public void selectionChanged(SelectionChangedEvent event) { |
544 Object sel = ((IStructuredSelection) event.getSelection()).getFirstElement(); |
547 Object sel = ((IStructuredSelection) event.getSelection()).getFirstElement(); |
545 if (sel instanceof IPath) { |
548 if (sel instanceof IPath) { |
546 if (projectExecutableRadioButton.getSelection()) { |
549 if (projectExecutableRadioButton.getSelection()) { |
547 data.setExeSelectionPath((IPath) sel); |
550 debugRunProcessWizardData.setExeSelectionPath((IPath) sel); |
548 } |
551 } |
549 |
552 |
550 // track the default remote program from the executable, for easy editing |
553 // track the default remote program from the executable, for easy editing |
551 if (remoteProgramViewer != null && !remoteExecutableRadioButton.getSelection()) { |
554 if (remoteProgramViewer != null && !remoteExecutableRadioButton.getSelection()) { |
552 IPath exeSelectionPath = createSuggestedRemotePath(data.getExeSelectionPath()); |
555 IPath exeSelectionPath = createSuggestedRemotePath(debugRunProcessWizardData.getExeSelectionPath()); |
553 // path should already be in model |
556 // path should already be in model |
554 remoteProgramViewer.setSelection(new StructuredSelection(exeSelectionPath)); |
557 remoteProgramViewer.setSelection(new StructuredSelection(exeSelectionPath)); |
555 } |
558 } |
556 |
559 |
557 validate(); |
560 validate(); |
561 } |
564 } |
562 |
565 |
563 private void handleProjectExecutableRadioSelected() { |
566 private void handleProjectExecutableRadioSelected() { |
564 if (projectExecutableRadioButton.getSelection()) { |
567 if (projectExecutableRadioButton.getSelection()) { |
565 projectExecutableViewer.getControl().setEnabled(true); |
568 projectExecutableViewer.getControl().setEnabled(true); |
566 data.setExeSelection(EExeSelection.USE_PROJECT_EXECUTABLE); |
569 debugRunProcessWizardData.setExeSelection(EExeSelection.USE_PROJECT_EXECUTABLE); |
567 IPath selectedPath = (IPath) ((IStructuredSelection) projectExecutableViewer.getSelection()).getFirstElement(); |
570 IPath selectedPath = (IPath) ((IStructuredSelection) projectExecutableViewer.getSelection()).getFirstElement(); |
568 if (selectedPath != null) { |
571 if (selectedPath != null) { |
569 data.setExeSelectionPath(selectedPath); |
572 debugRunProcessWizardData.setExeSelectionPath(selectedPath); |
570 } |
573 } |
571 validate(); |
574 validate(); |
572 } else { |
575 } else { |
573 projectExecutableViewer.getControl().setEnabled(false); |
576 projectExecutableViewer.getControl().setEnabled(false); |
574 // another button becomes active and sets the new launch process |
577 // another button becomes active and sets the new launch process |
589 |
592 |
590 remoteProgramViewer = new ComboViewer(radioGroup, SWT.BORDER); |
593 remoteProgramViewer = new ComboViewer(radioGroup, SWT.BORDER); |
591 GridDataFactory.fillDefaults().grab(true, false).applyTo(remoteProgramViewer.getControl()); |
594 GridDataFactory.fillDefaults().grab(true, false).applyTo(remoteProgramViewer.getControl()); |
592 |
595 |
593 projectGeneratedRemotePaths = new ArrayList<IPath>(); |
596 projectGeneratedRemotePaths = new ArrayList<IPath>(); |
594 for (IPath launchable : data.getLaunchableExes()) { |
597 for (IPath launchable : debugRunProcessWizardData.getLaunchableExes()) { |
595 projectGeneratedRemotePaths.add(createSuggestedRemotePath(launchable)); |
598 projectGeneratedRemotePaths.add(createSuggestedRemotePath(launchable)); |
596 } |
599 } |
597 |
600 |
598 // add the entries before the user MRU entries |
601 // add the entries before the user MRU entries |
599 remotePathEntries.addAll(0, projectGeneratedRemotePaths); |
602 remotePathEntries.addAll(0, projectGeneratedRemotePaths); |
623 |
626 |
624 remoteProgramViewer.getCombo().addModifyListener(new ModifyListener() { |
627 remoteProgramViewer.getCombo().addModifyListener(new ModifyListener() { |
625 public void modifyText(ModifyEvent e) { |
628 public void modifyText(ModifyEvent e) { |
626 IPath path = PathUtils.createPath(remoteProgramViewer.getCombo().getText().trim()); |
629 IPath path = PathUtils.createPath(remoteProgramViewer.getCombo().getText().trim()); |
627 if (remoteExecutableRadioButton.getSelection()) { |
630 if (remoteExecutableRadioButton.getSelection()) { |
628 data.setExeSelectionPath(path); |
631 debugRunProcessWizardData.setExeSelectionPath(path); |
629 } |
632 } |
630 |
633 |
631 if (!projectExecutableRadioButton.getSelection()) { |
634 if (!projectExecutableRadioButton.getSelection()) { |
632 IPath projPath = getHostFileForRemoteLocation(path); |
635 IPath projPath = getHostFileForRemoteLocation(path); |
633 if (projPath != null) { |
636 if (projPath != null) { |
655 } |
658 } |
656 |
659 |
657 private void handleRemoteExecutableRadioSelected() { |
660 private void handleRemoteExecutableRadioSelected() { |
658 if (remoteExecutableRadioButton.getSelection()) { |
661 if (remoteExecutableRadioButton.getSelection()) { |
659 remoteProgramViewer.getControl().setEnabled(true); |
662 remoteProgramViewer.getControl().setEnabled(true); |
660 data.setExeSelection(EExeSelection.USE_REMOTE_EXECUTABLE); |
663 debugRunProcessWizardData.setExeSelection(EExeSelection.USE_REMOTE_EXECUTABLE); |
661 IPath path = PathUtils.createPath(remoteProgramViewer.getCombo().getText()); |
664 IPath path = PathUtils.createPath(remoteProgramViewer.getCombo().getText()); |
662 data.setExeSelectionPath(path); |
665 debugRunProcessWizardData.setExeSelectionPath(path); |
663 validate(); |
666 validate(); |
664 } else { |
667 } else { |
665 remoteProgramViewer.getControl().setEnabled(false); |
668 remoteProgramViewer.getControl().setEnabled(false); |
666 // another button becomes active and sets the new launch process |
669 // another button becomes active and sets the new launch process |
667 } |
670 } |
694 |
697 |
695 } |
698 } |
696 |
699 |
697 private void handleAttachToProcessRadioSelected() { |
700 private void handleAttachToProcessRadioSelected() { |
698 if (attachToProcessRadioButton.getSelection()) { |
701 if (attachToProcessRadioButton.getSelection()) { |
699 data.setExeSelection(EExeSelection.ATTACH_TO_PROCESS); |
702 debugRunProcessWizardData.setExeSelection(EExeSelection.ATTACH_TO_PROCESS); |
700 data.setExeSelectionPath(null); |
703 debugRunProcessWizardData.setExeSelectionPath(null); |
701 validate(); |
704 validate(); |
702 } else { |
705 } else { |
703 // another button becomes active and sets the new launch process |
706 // another button becomes active and sets the new launch process |
704 } |
707 } |
705 } |
708 } |
707 @Override |
710 @Override |
708 protected void validate() { |
711 protected void validate() { |
709 IStatus status = Status.OK_STATUS; |
712 IStatus status = Status.OK_STATUS; |
710 |
713 |
711 // check launch method |
714 // check launch method |
712 IPath exePath = data.getExeSelectionPath(); |
715 IPath exePath = debugRunProcessWizardData.getExeSelectionPath(); |
713 switch (data.getExeSelection()) { |
716 switch (debugRunProcessWizardData.getExeSelection()) { |
714 case USE_PROJECT_EXECUTABLE: |
717 case USE_PROJECT_EXECUTABLE: |
715 if (exePath.isEmpty()) { |
718 if (exePath.isEmpty()) { |
716 status = error(Messages.getString("DebugRunProcessDialog.NoExesError")); //$NON-NLS-1$ |
719 status = error(Messages.getString("DebugRunProcessDialog.NoExesError")); //$NON-NLS-1$ |
717 } |
720 } |
718 break; |
721 break; |
736 case ATTACH_TO_PROCESS: |
739 case ATTACH_TO_PROCESS: |
737 break; |
740 break; |
738 } |
741 } |
739 |
742 |
740 // check SIS selection |
743 // check SIS selection |
741 if (data.isInstallPackage()) { |
744 if (debugRunProcessWizardData.isInstallPackage()) { |
742 if (sisEdit != null) { |
745 if (sisEdit != null) { |
743 String text = sisEdit.getText().trim(); |
746 String text = sisEdit.getText().trim(); |
744 if (text.length() > 0) { |
747 if (text.length() > 0) { |
745 // empty is allowed, but if they specify something, make sure |
748 // empty is allowed, but if they specify something, make sure |
746 // it exists |
749 // it exists |