我正在开发一个RCP应用程序,我试图通过工具栏菜单打开graphiti编辑器,但它给了我下面提到的例外... 请帮忙
java.lang.IllegalArgumentException:
at org.eclipse.core.runtime.Assert.isLegal(Assert.java:63)
at org.eclipse.core.runtime.Assert.isLegal(Assert.java:47)
org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.findElements(ModelServiceImp.
at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:3112)
at org.eclipse.ui.internal.WorkbenchPage.access$21(WorkbenchPage.java:3034)
at org.eclipse.ui.internal.WorkbenchPage$8.run(WorkbenchPage.java:3016)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3012)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2976)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2959)
at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:827)
at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:432)
at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:628)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4170)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:826)
at org.eclipse.jface.window.Window.open(Window.java:802)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:290)
at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4170)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
答案 0 :(得分:0)
使用RCP Eclipse打开编辑器
package rcp_demo.Editor;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.handlers.HandlerUtil;
public class UserCommand extends AbstractHandler{
public static final String ID = "rcp_demo.Editor.UserCommand";
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
IWorkbenchPage page = window.getActivePage();
//create UserEditorInput Class
//public class UserEditorInput implements IEditorInput{}
UserEditorInput input = new UserEditorInput();
try {
//Create UserEditor class
//public class UserEditor extends EditorPart { public static final String ID = "rcp_demo.Editor.user";}
page.openEditor(input, UserEditor.ID);
} catch (PartInitException e) {
System.out.println("Error:" + this.getClass().getName() + ":" + e);
e.printStackTrace();
throw new ExecutionException("Error open UserEditor");
}
return null;
}
}
plugin.xml文件
perspectives id和perspectiveExtensions targetID与此相同
// perspectives
<extension
point="org.eclipse.ui.perspectives">
<perspective
name="RCP Perspective"
class="rcp_demo.Perspective"
id="RCP_Demo.perspective">
</perspective>
</extension>
// perspectiveExtensions
<extension
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension
targetID="RCP_Demo.perspective">
<view
closeable="true"
id="RCP_Demo.Views.task"
minimized="false"
moveable="true"
relationship="right"
relative="org.eclipse.ui.editorss"
showTitle="true">
</view>
</perspectiveExtension>
</extension>
//User Command
<extension
point="org.eclipse.ui.commands">
<command
defaultHandler="rcp_demo.Editor.UserCommand"
id="rcp_demo.Editor.UserCommand"
name="Call UserEditor">
</command>
</extension>
/// user Editor
<extension
point="org.eclipse.ui.editors">
<editor
class="rcp_demo.Editor.UserEditor"
default="false"
id="rcp_demo.Editor.user"
name="UserEditor">
</editor>
</extension>