popup menu, how get view? [message #208618] |
Wed, 15 October 2008 07:33 |
Eclipse User |
|
|
|
Originally posted by: andrew.iaes.ru
Hi!
I created submenu in standard popup menu.
Here the code generated:
public class ActionExportDB implements IObjectActionDelegate {
private Shell shell;
/**
* Constructor for Action1.
*/
public ActionExportDB() {
super();
}
/**
* @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
*/
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
shell = targetPart.getSite().getShell();
}
/**
* @see IActionDelegate#run(IAction)
*/
public void run(IAction action) {
/// DO SOME ON CLICK
}
/**
* @see IActionDelegate#selectionChanged(IAction, ISelection)
*/
public void selectionChanged(IAction action, ISelection selection) {
}
}
How I get View object from this parameters or how i get nodes in diagramm?
Thanks!
|
|
|
Re: popup menu, how get view? [message #208653 is a reply to message #208618] |
Wed, 15 October 2008 10:12 |
Tatiana Fesenko Messages: 530 Registered: July 2009 |
Senior Member |
|
|
Hello Andrei,
You run action on EditPart, therefore the editpart should be calculated using
selection parameter:
public void selectionChanged(IAction action, ISelection selection) {
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection)
selection;
if (structuredSelection.getFirstElement() instanceof GraphicalEditPart)
{
mySelectedElement = (GraphicalEditPart) structuredSelection.getFirstElement();
}
}
}
mySelection is selected EditPart. View can be got from EditPart using GraphicalEditPart#getNotationView()
method.
Best wishes,
Tanya.
> Hi!
> I created submenu in standard popup menu.
> Here the code generated:
> public class ActionExportDB implements IObjectActionDelegate {
>
> private Shell shell;
>
> /**
> * Constructor for Action1.
> */
> public ActionExportDB() {
> super();
> }
> /**
> * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
> */
> public void setActivePart(IAction action, IWorkbenchPart targetPart)
> {
> shell = targetPart.getSite().getShell();
> }
> /**
> * @see IActionDelegate#run(IAction)
> */
> public void run(IAction action) {
> /// DO SOME ON CLICK
>
> }
>
> /**
> * @see IActionDelegate#selectionChanged(IAction, ISelection)
> */
> public void selectionChanged(IAction action, ISelection selection) {
> }
> }
>
> How I get View object from this parameters or how i get nodes in
> diagramm? Thanks!
>
|
|
|
Re: popup menu, how get view? [message #208918 is a reply to message #208653] |
Fri, 17 October 2008 08:07 |
Eclipse User |
|
|
|
Originally posted by: andrew.iaes.ru
Hi, Tatiana!
Thanks for your post.
I get Elements with
MainScheme modelElement = (MainScheme) view.getElement();
for (Iterator it = modelElement.getRefToWinGraphObject().iterator(); it
.hasNext();) {
WinGraphObject childElement = (WinGraphObject) it.next();
}
where WinGraphObject is a node(standard rectangle) of diagramm;
But, how i can get XY layout of this node?
Do i need get Figure from Element?
Thanks!
Andrei.
|
|
|
Re: popup menu, how get view? [message #208937 is a reply to message #208918] |
Fri, 17 October 2008 11:22 |
Tatiana Fesenko Messages: 530 Registered: July 2009 |
Senior Member |
|
|
Hi Andrei,
You need coordinates of the figure, am I correct?
To get coordinates you can
- Work with Nodes.
View can be either Node, or Edge or Diagram. For Node call getLayoutConstraint()
method. If LayoutConstraint is instance of org.eclipse.gmf.runtime.notation.Bounds,
you can easily get location and size.
or
- Work with with EditParts.
To get IFigure call GraphicalEditPart#getFigure() method, then call IFigure#getBounds().
Best wishes,
Tanya.
> Hi, Tatiana!
> Thanks for your post.
> I get Elements with
> MainScheme modelElement = (MainScheme) view.getElement();
> for (Iterator it = modelElement.getRefToWinGraphObject().iterator();
> it
> .hasNext();) {
> WinGraphObject childElement = (WinGraphObject) it.next();
> }
>
> where WinGraphObject is a node(standard rectangle) of diagramm;
>
> But, how i can get XY layout of this node?
>
> Do i need get Figure from Element?
>
> Thanks!
> Andrei.
|
|
|
Re: popup menu, how get view? [message #209016 is a reply to message #208937] |
Mon, 20 October 2008 09:32 |
Eclipse User |
|
|
|
Originally posted by: andrew.iaes.ru
Thank for your reponse.
my solution is :
Diagram myDiagram = view.getDiagram();
List<Node> nodeList = myDiagram.getChildren();
for (Node node : nodeList){
if (node.getLayoutConstraint() instanceof Bounds){
Bounds bounds = (Bounds)node.getLayoutConstraint();
Integer x = bounds.getX();
Integer y = bounds.getY();
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.03119 seconds