Invoke shortcut actio from editpart [message #119386] |
Mon, 16 April 2007 03:15  |
Eclipse User |
|
|
|
Hi to all,
The question is if it's possible to invoke the shorcut action from
editparts. I am able to open the create shortcut dialog from the editpart
by installing and open edit policy but I am not able to invoke the
shortcut action to load the resource.
Thanks.
|
|
|
|
|
Re: Invoke shortcut actio from editpart [message #119776 is a reply to message #119719] |
Mon, 16 April 2007 12:10   |
Eclipse User |
|
|
|
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.03774 seconds