|
|
|
Re: Invoke shortcut actio from editpart [message #119776 is a reply to message #119719] |
Mon, 16 April 2007 16:10 |
Alexander Shatalin Messages: 2928 Registered: July 2009 |
Senior Member |
|
|
Hello Richy,
Well, any problems with copying the logic from action? e.g.:
EcoreElementChooserDialog elementChooser = new EcoreElementChooserDialog(myShell,
view);
int result = elementChooser.open();
if (result != Window.OK) {
return;
}
URI selectedModelElementURI = elementChooser.getSelectedModelElementURI();
final EObject selectedElement;
try {
selectedElement = mySelectedElement.getEditingDomain().getResourceSet().getEOb ject(selectedModelElementURI,
true);
} catch (WrappedException e) {
EcoreDiagramEditorPlugin.getInstance().logError("Exception while loading
object: " + selectedModelElementURI.toString(), e); //$NON-NLS-1$
return;
}
if (selectedElement == null) {
return;
}
CreateViewRequest.ViewDescriptor viewDescriptor = new CreateViewRequest.ViewDescriptor(new
EObjectAdapter(selectedElement), Node.class, null, EcoreDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
ICommand command = new CreateCommand(mySelectedElement.getEditingDomain(),
viewDescriptor, view);
command = command.compose(new EcoreCreateShortcutDecorationsCommand(mySelectedElement.getE ditingDomain(),
view, viewDescriptor));
try {
OperationHistoryFactory.getOperationHistory().execute(comman d, new NullProgressMonitor(),
null);
} catch (ExecutionException e) {
EcoreDiagramEditorPlugin.getInstance().logError("Unable to create shortcut",
e); //$NON-NLS-1$
}
-----------------
Alex Shatalin
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03689 seconds