Imaskar
Imaskar

Reputation: 2969

Eclipse RCP - How to open Launch Configuration dialog

How to open Launch Configuration dialog (like when press mouse_right on project - run as - run configurations) in RCP app via command? or any other way, but command preferred.

Upvotes: 4

Views: 4261

Answers (2)

VonC
VonC

Reputation: 1329692

If you type 'ALT+SHIFT+F1' on an 'Create, manage and run configurations', the plug-in Spy will tell you it is a LaunchConfigurationsDialog

A quick search in the Eclipse sources indicates it is created through an DebugUITools.openLaunchConfigurationDialogOnGroup()

     final int[] result = new int[1];
         Runnable JavaDoc r = new Runnable JavaDoc() {
             /**
              * @see java.lang.Runnable#run()
              */
             public void run() {
                 LaunchConfigurationsDialog dialog = (LaunchConfigurationsDialog) LaunchConfigurationsDialog.getCurrentlyVisibleLaunchConfigurationDialog();
                 if (dialog != null) {
                     dialog.setInitialSelection(selection);
                     dialog.doInitialTreeSelection();
                     if (status != null) {
                         dialog.handleStatus(status);
                     }
                     result[0] = Window.OK;
                 } else {
                     dialog = new LaunchConfigurationsDialog(shell, DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(groupIdentifier));
                     dialog.setOpenMode(LaunchConfigurationsDialog.LAUNCH_CONFIGURATION_DIALOG_OPEN_ON_SELECTION);
                     dialog.setInitialSelection(selection);
                     dialog.setInitialStatus(status);
                     result[0] = dialog.open();
                 }
             }
         };
         BusyIndicator.showWhile(DebugUIPlugin.getStandardDisplay(), r);
         return result[0];

That should give you enough material to get started.


(source: eclipse.org)

Upvotes: 7

C-Otto
C-Otto

Reputation: 5853

Based on VonC's answer I did the following, where config just is my instance of ILaunchConfigurationWorkingCopy and mode is "run":

DebugUITools.openLaunchConfigurationDialog(
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                config,
                DebugUITools.getLaunchGroup(savedConfig, mode).getIdentifier(),
                null);

Upvotes: 4

Related Questions