您好 我正在尝试添加一个导出向导,类似于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>
但是在“文件”菜单条目中看不到任何向导。 我错过了什么?
谢谢:)
答案 0 :(得分:6)
你必须做两件事:
使用org.eclipse.ui.exportWizards
扩展点(您已经做过)
在您的应用程序action bar advisor
课程中,首先创建用于导出的标准工作台操作,然后将其添加到任何菜单中。
代码段
// Creating and registering the action
IWorkbenchAction export = ActionFactory.EXPORT.create(window);
register(export);
// adding it to standard file menu
fileMenu.add(export);
&gt;&gt;完整代码 - 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) {
}
}
&gt;&gt;菜单条目
&gt;&gt;导出向导
答案 1 :(得分:1)
你应该在你的向导中实现这个界面INewWizard,如:
公共类LoadDataWizard扩展向导实现了INewWizard {}
并添加此扩展程序:
org.eclipse.ui.newWizards
到你的plugin.xml
答案 2 :(得分:0)
()您尚未在plugin.xml中指定文件的类别 ()如果您没有看到File-&gt; New项本身,则需要通过ActionFactory.NEW或ActionFactory.NEW_WIZARD_DROP_DOWN操作或通过命令提供它们来创建它们
答案 3 :(得分:0)
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();
}
});