Accessing Underlying Objects from outside the Canvas [message #198142] |
Mon, 21 July 2008 13:19  |
Eclipse User |
|
|
|
Originally posted by: wayneage.gmail.com
Hi,
I am wondering if it is possible to access the model objects from say a
menu, or even a button on the pallete.
I know you can do this from the canvas with edit policys and such, this
makes sense becasue the request origninates from the graphical element and
you can access it's model part, and therefore the other model objects.
But can this be done outside the canvas?
Any help is appreciated,
Wayne
|
|
|
Re: Accessing Underlying Objects from outside the Canvas [message #198191 is a reply to message #198142] |
Mon, 21 July 2008 22:14  |
Eclipse User |
|
|
|
Originally posted by: lifesting.gmail.com
wayneage wrote:
> Hi,
> I am wondering if it is possible to access the model objects from say a
> menu, or even a button on the pallete.
> I know you can do this from the canvas with edit policys and such, this
> makes sense becasue the request origninates from the graphical element
> and you can access it's model part, and therefore the other model objects.
>
> But can this be done outside the canvas?
>
> Any help is appreciated,
> Wayne
>
maybe you can do it like the method below:
in a view:
IEditorPart editor = getSite().getPage.getActiveEditor();
in a delegate action (org.eclipse.ui.actionSet/popmenu):
IEditorPart editor = workbenchWindow.getActivePage().getActiveEditor();
if (editor instanceof DiagramDocumentEditor)
{
GraphicalViewer gviewer = ((GraphicalEditor)editor).getGraphicalViewer();
List selection = gviewer.getSelectedEditParts();
for (Iterator ite = selection.iterator(); ite.hasNext();)
{
View notation = ite.next(); //must be View in a GMF editor.
EObject biz_model = motation.getElement();
anyReadOnlyActionOnModel(biz_model);
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.03350 seconds