Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » XYLayoutEditPolicy in GMF generated code
XYLayoutEditPolicy in GMF generated code [message #196969] Mon, 14 July 2008 16:42 Go to next message
Eclipse UserFriend
Originally posted by: jk6803.yahoo.com

Hi

I have an issues on XYLayoutEditPolicy.In GMF generated code itself,
shapes and connection works properly but after adding XYLayoutEditPolicy
to draw something, the shapes are always located at the left-top corner.
Here is part of DiagramEditPart code.

What should I override the methods?


protected void createDefaultEditPolicies() {
super.createDefaultEditPolicies();
installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE,
new DiagramItemSemanticEditPolicy());
installEditPolicy(EditPolicyRoles.CANONICAL_ROLE,
new DiagramCanonicalEditPolicy());

installEditPolicy(EditPolicy.LAYOUT_ROLE,
new PointShapeXYLayoutEditPolicy());
}

thanks
Re: XYLayoutEditPolicy in GMF generated code [message #197304 is a reply to message #196969] Wed, 16 July 2008 10:03 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello hosoo,

I have to following code in the super class of ???EditPart generated for
diagram element (DiagramEditPart):

installEditPolicy(EditPolicy.LAYOUT_ROLE, new XYLayoutEditPolicy());

So, if you are overriding this EditPolicy with your custom one (PointShapeXYLayoutEditPolicy)
then it looks like a problem is in this EditPolicy implementation.

-----------------
Alex Shatalin
Re: XYLayoutEditPolicy in GMF generated code [message #197494 is a reply to message #197304] Wed, 16 July 2008 23:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jk6803.yahoo.com

Hi Alex,

What I did is that after generating GMF model, I added my own menu on the
palette and created "XXcreateCommand" which implemented Command interface
of GEF. There are two problems in case of adding menu.

1. Whenever I tried to cast Diagram object, it raised classcasting
exeception.

protected MyDiagram getCastedModel() {
return (MyDiagram) getModel();
}

2. I cannot add my own editpart in the EditFactoryPartClass.

public EditPart createEditPart(EditPart context, Object model) {
if (model instanceof View) {
View view = (View) model;
switch (Test.diagram.part.MyVisualIDRegistry.getVisualID(view))
MyEditPart();
}

Once a custom menu is added on the palette, what classes are should be
modified?.
Previois one is related this thread: Re: DiagramImpl ClassCastException [message #197501 is a reply to message #197494] Wed, 16 July 2008 23:45 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jk6803.yahoo.com

sorry for wrong posting.
Re: XYLayoutEditPolicy in GMF generated code [message #197581 is a reply to message #197494] Thu, 17 July 2008 09:28 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello YJ,

> 1. Whenever I tried to cast Diagram object, it raised classcasting
> exeception.
> protected MyDiagram getCastedModel() {
> return (MyDiagram) getModel();
> }
If you are placing this code in an EditPart then you have to type something
like:

(MyDiagram) ((org.eclipse.gmf.runtime.notation.Diagram) getModel()).getElement()

> 2. I cannot add my own editpart in the EditFactoryPartClass.
The problem is: you do not have corresponding View createt isn't it?

> Once a custom menu is added on the palette, what classes are should be
> modified?.
You have to register own ???ViewProvider cresting corresponding View instance
for new diagram element (or modify generated ???ViewProvider in accordance)
+ register/modify generated ???EditPartProvider to create EditPart based
on a view created on step 1.

-----------------
Alex Shatalin
Previous Topic:Border & Links color
Next Topic:Changing connection handle icons
Goto Forum:
  


Current Time: Fri Sep 25 20:52:39 GMT 2020

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

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

Back to the top