Eclipse RCP - 如何打开“启动配置”对话框

时间:2009-03-22 16:08:42

标签: eclipse-plugin eclipse-rcp

如何通过命令在RCP应用程序中打开启动配置对话框(如在项目上按mouse_right - 运行 - 运行配置)?或任何其他方式,但命令首选。

2 个答案:

答案 0 :(得分:7)

如果您在“创建,管理和运行配置”中输入“ALT+SHIFT+F1”,plug-in Spy会告诉您它是LaunchConfigurationsDialog

Eclipse源代码中的快速搜索表明它是通过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];

这应该给你足够的材料来开始。


(来源:eclipse.org

答案 1 :(得分:4)

根据VonC的回答,我做了以下操作,其中config只是ILaunchConfigurationWorkingCopy的实例而mode"run"

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