Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Invoke shortcut actio from editpart
Invoke shortcut actio from editpart [message #119386] Mon, 16 April 2007 07:15 Go to next message
Richy is currently offline RichyFriend
Messages: 33
Registered: July 2009
Member
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 #119505 is a reply to message #119386] Mon, 16 April 2007 11:17 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Richy,

Please check generated ???CreateShortcutAction - this code should correctly
handle the situation.

-----------------
Alex Shatalin
Re: Invoke shortcut actio from editpart [message #119719 is a reply to message #119505] Mon, 16 April 2007 15:19 Go to previous messageGo to next message
Richy is currently offline RichyFriend
Messages: 33
Registered: July 2009
Member
Hi Alex,
I have already checked that action but my question is how to invoke that
action from an EditPart, I mean how to invoke the run method, in the same
way that Create Shortcut… diagram popup menu action does.
I want to create a shortcut into an EditPart: I have installed an open
edit policy in the EditPart so when I double click the figure I am able to
open the dialog to choose the model file but I am not able to load the
model element as a shortcut on the EditPart.
I am working with Eclipse 3.3M6 and GMF 2.0M6.

Thanks.
Re: Invoke shortcut actio from editpart [message #119776 is a reply to message #119719] Mon, 16 April 2007 16:10 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
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
Re: Invoke shortcut actio from editpart [message #119886 is a reply to message #119776] Tue, 17 April 2007 10:09 Go to previous messageGo to next message
Richy is currently offline RichyFriend
Messages: 33
Registered: July 2009
Member
Hi Alex,

I have tried copying the logic from the action and it doesn't work. The
EditPart where I want to load the shortcut is not the same EditPart
(mySelectedElement) where the action loads the editPart. I have tried by
changing this and the problem appears in the execution of the following
sentence:

OperationHistoryFactory.getOperationHistory().execute(comman d, new
NullProgressMonitor(), null);

It doesn't fails but doesn't work, it can't execute the command, and I
don't know why:

public IStatus execute(IUndoableOperation operation,
IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
Assert.isNotNull(operation);

// error if operation is invalid
if (!operation.canExecute()) { <--------------- HERE
return IOperationHistory.OPERATION_INVALID_STATUS;
}

.......


It seems a problem with the command but I compose it in the way you say
(like in the action).
Anny suggestions?

Thanks a lot.
Re: Invoke shortcut actio from editpart [message #119947 is a reply to message #119886] Tue, 17 April 2007 10:43 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Richy,

Currently you can create shortcuts only on diagram. Looks like this is the
reason.

-----------------
Alex Shatalin
Previous Topic:Problem creating Editor: Invocation Target Exception
Next Topic:Standalone version of GMF diagram editor and output
Goto Forum:
  


Current Time: Sat Nov 09 03:40:03 GMT 2024

Powered by FUDForum. Page generated in 0.03689 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top