添加导出向导到 eclipse RCP 独立应用程序

发布于 2024-11-04 11:32:39 字数 419 浏览 0 评论 0原文

你好 我正在尝试添加一个导出向导,类似于 Eclipse 中向独立 RCP 应用程序提供的导出向导。 我将以下代码放入plugin.xml中:

   <extension
     id="exportScript"
     point="org.eclipse.ui.exportWizards">
  <wizard
        class="com.myApplication.scriptGenerator.ExportWizard"
        id="com.myApplication.scriptGenerator.exid"
        name="Export as Script">
  </wizard>

但在“文件”菜单项中看不到向导。 我缺少什么?

谢谢 :)

Hi
I'm trying to add an export wizard, similar to the export wizard available in Eclipse to a standalone RCP Application.
I put the following code in plugin.xml:

   <extension
     id="exportScript"
     point="org.eclipse.ui.exportWizards">
  <wizard
        class="com.myApplication.scriptGenerator.ExportWizard"
        id="com.myApplication.scriptGenerator.exid"
        name="Export as Script">
  </wizard>

But no wizard can be seen in the File menu entry..
What am I missing?

thanks :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

梦忆晨望 2024-11-11 11:32:39

您必须做两件事:

  • 使用org.eclipse.ui.exportWizards扩展点(您已经这样做了)

  • 在您的应用程序操作栏顾问类中,首先创建用于导出的标准工作台操作,然后将其添加到任何菜单中。

代码片段

// Creating and registering the action 
IWorkbenchAction export = ActionFactory.EXPORT.create(window);
register(export);

 // adding it to standard file menu
fileMenu.add(export);

>>完整代码 - ApplicationActionBarAdvisor

package wiztest;

import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.ICoolBarManager;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;

public class ApplicationActionBarAdvisor extends ActionBarAdvisor {

    private IWorkbenchAction exitAction;
    private IWorkbenchAction export;

    public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
        super(configurer);
    }

    protected void makeActions(final IWorkbenchWindow window) {

        exitAction = ActionFactory.QUIT.create(window);
        register(exitAction);


        export = ActionFactory.EXPORT.create(window);
        register(export);
    }

    protected void fillMenuBar(IMenuManager menuBar) {
        MenuManager fileMenu = new MenuManager("&File", IWorkbenchActionConstants.M_FILE);

        menuBar.add(fileMenu);
        menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
        fileMenu.add(export);
        fileMenu.add(exitAction);        
    }

    protected void fillCoolBar(ICoolBarManager coolBar) {

    }
}

>>菜单条目

在此处输入图像描述

>>导出向导

在此输入图像描述

You have to do two things:

  • Use org.eclipse.ui.exportWizards extension point (which you already did)

  • In your Applications action bar advisor class first create the standard workbench action for export and then add it in any of your menu.

Code Snippet

// Creating and registering the action 
IWorkbenchAction export = ActionFactory.EXPORT.create(window);
register(export);

 // adding it to standard file menu
fileMenu.add(export);

>>Full Code - ApplicationActionBarAdvisor

package wiztest;

import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.ICoolBarManager;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;

public class ApplicationActionBarAdvisor extends ActionBarAdvisor {

    private IWorkbenchAction exitAction;
    private IWorkbenchAction export;

    public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
        super(configurer);
    }

    protected void makeActions(final IWorkbenchWindow window) {

        exitAction = ActionFactory.QUIT.create(window);
        register(exitAction);


        export = ActionFactory.EXPORT.create(window);
        register(export);
    }

    protected void fillMenuBar(IMenuManager menuBar) {
        MenuManager fileMenu = new MenuManager("&File", IWorkbenchActionConstants.M_FILE);

        menuBar.add(fileMenu);
        menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
        fileMenu.add(export);
        fileMenu.add(exitAction);        
    }

    protected void fillCoolBar(ICoolBarManager coolBar) {

    }
}

>>Menu Entry

enter image description here

>>Export Wizard

enter image description here

£噩梦荏苒 2024-11-11 11:32:39

您应该在向导中实现此接口 INewWizard,例如:

公共类 LoadDataWizard 扩展 Wizard 实现 INewWizard{}

并添加此扩展:

org.eclipse.ui.newWizards

到你的plugin.xml

You should implement in your Wizard this interface INewWizard, like:

public class LoadDataWizard extends Wizard implements INewWizard{}

and add this extension:

org.eclipse.ui.newWizards

to your plugin.xml

窝囊感情。 2024-11-11 11:32:39

() 您尚未在plugin.xml 中指定文件的类别
(
) 如果您没有看到 File->New 项目本身,则需要通过 ActionFactory.NEW 或 ActionFactory.NEW_WIZARD_DROP_DOWN 操作或通过命令贡献它们来创建它们

() You have not specified the category of the File in your plugin.xml
(
) If you are not seeing the File->New item itself, you need create them by the ActionFactory.NEW or ActionFactory.NEW_WIZARD_DROP_DOWN actions or by contributing them by commands

彩虹直至黑白 2024-11-11 11:32:39

1.创建菜单

2.在菜单上添加监听器

示例:-

mntmExportProject.addSelectionListener(
new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            ImportExportWizard wizard = new ImportExportWizard(ImportExportWizard.EXPORT);
            IStructuredSelection selectionToPass = new StructuredSelection(treeViewer.getSelection());

            wizard.init(PlatformUI.getWorkbench(), selectionToPass);
            IDialogSettings workbenchSettings = WorkbenchPlugin.getDefault().getDialogSettings();
            IDialogSettings wizardSettings = workbenchSettings.getSection("ImportExportAction"); //$NON-NLS-1$
            if (wizardSettings == null) {
                wizardSettings = workbenchSettings.addNewSection("ImportExportAction"); //$NON-NLS-1$
            }
            wizard.setDialogSettings(wizardSettings);
            wizard.setForcePreviousAndNextButtons(true);
            Shell parent = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
            WizardDialog dialog = new WizardDialog(parent, wizard);
            dialog.create();
            dialog.getShell().setSize(Math.max(470, dialog.getShell().getSize().x), 550);
            dialog.open();
        }
    });

1.Create a menu

2.add a listener on the menu

Example :-

mntmExportProject.addSelectionListener(
new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            ImportExportWizard wizard = new ImportExportWizard(ImportExportWizard.EXPORT);
            IStructuredSelection selectionToPass = new StructuredSelection(treeViewer.getSelection());

            wizard.init(PlatformUI.getWorkbench(), selectionToPass);
            IDialogSettings workbenchSettings = WorkbenchPlugin.getDefault().getDialogSettings();
            IDialogSettings wizardSettings = workbenchSettings.getSection("ImportExportAction"); //$NON-NLS-1$
            if (wizardSettings == null) {
                wizardSettings = workbenchSettings.addNewSection("ImportExportAction"); //$NON-NLS-1$
            }
            wizard.setDialogSettings(wizardSettings);
            wizard.setForcePreviousAndNextButtons(true);
            Shell parent = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
            WizardDialog dialog = new WizardDialog(parent, wizard);
            dialog.create();
            dialog.getShell().setSize(Math.max(470, dialog.getShell().getSize().x), 550);
            dialog.open();
        }
    });
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文