Я пытался, чтобы копирование и вставка работали с командой org.mdmi.provider.BagItemProvider.createCopyCommand (домен EditingDomain, владелец EObject, помощник Helper). Одна копия узла не дает никакой ошибки, но когда я вставляю ее, она дает узел с нулевыми значениями. Он не копирует свою семантику или значения. Когда я пытаюсь скопировать несколько узлов, выдает ошибку:
Ошибка:
org.eclipse.emf.common.util.WrappedException: An exception was ignored during command execution
at org.eclipse.emf.common.command.BasicCommandStack.handleError(BasicCommandStack.java:281)
at org.eclipse.emf.common.command.BasicCommandStack.execute(BasicCommandStack.java:112)
at org.eclipse.emf.edit.ui.action.CommandActionHandler.run(CommandActionHandler.java:86)
at org.eclipse.ui.actions.BaseSelectionListenerAction.runWithEvent(BaseSelectionListenerAction.java:171)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:580)
at org.eclipse.jface.action.ActionContributionItem.lambda$4(ActionContributionItem.java:412)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4173)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3986)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3585)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1160)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1049)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:633)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:557)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:150)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:660)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:597)
at org.eclipse.equinox.launcher.Main.run(Main.java:1468)
at org.eclipse.equinox.launcher.Main.main(Main.java:1441)
Caused by: java.lang.NullPointerException
at org.eclipse.emf.edit.command.InitializeCopyCommand.copyAttributes(InitializeCopyCommand.java:136)
at org.eclipse.emf.edit.command.InitializeCopyCommand.doExecute(InitializeCopyCommand.java:114)
at org.mdmi.provider.BagItemProvider$1.doExecute(BagItemProvider.java:228)
at org.eclipse.emf.edit.command.AbstractOverrideableCommand.execute(AbstractOverrideableCommand.java:125)
at org.eclipse.emf.edit.command.CopyToClipboardCommand.doExecute(CopyToClipboardCommand.java:108)
at org.eclipse.emf.edit.command.AbstractOverrideableCommand.execute(AbstractOverrideableCommand.java:125)
at org.eclipse.emf.common.command.BasicCommandStack.execute(BasicCommandStack.java:78)
... 31 more
Код:
@Override
protected Command createCopyCommand(EditingDomain domain, EObject owner, Helper helper) {
InitializeCopyCommand initializeCopyCommand = new InitializeCopyCommand(domain, owner, helper) {
@Override
public void doExecute() {
// TODO Auto-generated method stub
super.doExecute();
}
@Override
public boolean doCanExecute() {
// TODO Auto-generated method stub
return true;
}
};
return initializeCopyCommand;
}
Я не понимаю, что можно сделатьчтобы сработала эта команда? Cut, Paste и DragAndDropCommand отлично работают, но почему не работает команда копирования?