Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » graphdef.editor -> Problems when generating diagram code
graphdef.editor -> Problems when generating diagram code [message #195037] Tue, 01 July 2008 10:41 Go to next message
Nikolay Georgiev is currently offline Nikolay GeorgievFriend
Messages: 13
Registered: July 2009
Junior Member
Hello,

I'm trying to run the graphdef editor (2007/11/25 version), so I tried to
generate the diagram code from the "graphdef.gmfgen", but there were 2
kinds of exceptions, which I don't see how to resolve.

=====
1) Can't organize imports due to syntax errors in the compilation unit
Ellipse2EditPart.java (or others XXXPart.java)
When I open one of the files, it is obvious that the keyword
"extends" is missing:
public class Ellipse2EditPart
org.eclipse.gmf.graphdef.editor.edit.parts.AbstractFigureEdi tPart

My suggestion for solution was that I have to add "extends" somewhere in a
xpt or .ext file, but I didn't find where.

=====
2) Exception (Couldn't resolve type for 'propsheet::Group'. Did you forget
to configure the corresponding metamodel?:in
aspects::xpt::propsheet::Utils on line 30 'propsheet::FeatureReference
getModelElement(propsheet::Group modelElementOwner)') while generating code

It has something to do with the type "propsheet::Group", but I don't know
what exactly. In the "propsheet.ecore" file there is already a Group
element.
=====

Do you have any ideas or suggestions?

Thank You,
Nikolay Georgiev

My Session Data for the Exceptions are:
eclipse.buildId=M20080221-1800
java.version=1.6.0_06
Re: graphdef.editor -> Problems when generating diagram code [message #195046 is a reply to message #195037] Tue, 01 July 2008 11:11 Go to previous messageGo to next message
Nikolay Georgiev is currently offline Nikolay GeorgievFriend
Messages: 13
Registered: July 2009
Junior Member
I think I solved the two problems, but I got another exception (luckily
only one :).

In NodeEditPart.xpt at the beginning of line 137 (before
" «getDiagram().editPartsPackageName».AbstractFigureEditPart « ") I added the
keywords " extends " and re-ran the diagram code generation. The old
exception were gone and the new exception is the following:

=====
Problems while generating code
Exception (java.lang.ClassCastException: The value of type 'class
org.eclipse.emf.codegen.ecore.genmodel.impl.GenFeatureImpl' must be of
type 'org.eclipse.emf.ecore.impl.EClassImpl@19320bf (name: GenFeature)
(instanceClassName: null) (abstract: false, interface: false)':in
aspects::xpt::propsheet::PropertySection on line 153
'getReferencingObjects(this)') while generating code
=====

in "PropertySection.xpt", on line 152,153 and 154 there is the code:

«DEFINE modelExtensionExample FOR gmfgen::GenCustomPropertyTab-»
«EXPAND processModelExtensionExample FOREACH
getReferencingObjects(this).typeSelect(propsheet::CustomProp ertySection)»
«ENDDEFINE»

and here I'm lost again :). I don't know what the argument "this" refers
and I suspect that it is the reason for the exception.

Nikolay
Re: graphdef.editor -> Problems when generating diagram code [message #195142 is a reply to message #195037] Tue, 01 July 2008 12:14 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Nikolay,

> I'm trying to run the graphdef editor (2007/11/25 version), so I tried
First i suggest you to get latest version of this plugin - it was significantly
changed.

-----------------
Alex Shatalin
Re: graphdef.editor -> Problems when generating diagram code [message #195180 is a reply to message #195142] Tue, 01 July 2008 14:30 Go to previous messageGo to next message
Nikolay Georgiev is currently offline Nikolay GeorgievFriend
Messages: 13
Registered: July 2009
Junior Member
Hi Alex,

I downloaded the last version of the editor, but I got an assertion
exception when trying to Open the "graphdef.gmfgen" file:

=====
org.eclipse.core.runtime.AssertionFailedException: assertion failed:
at org.eclipse.core.runtime.Assert.isTrue(Assert.java:109)
at org.eclipse.core.runtime.Assert.isTrue(Assert.java:95)
at
org.eclipse.ui.part.MultiPageEditorPart.setActivePage(MultiP ageEditorPart.java:695)
at
org.eclipse.ui.part.MultiPageEditorPart.createPartControl(Mu ltiPageEditorPart.java:287)
=====

Can I ask you something about this graphdef editor?

I want to implement a GUI editor, and for most of the elements/widgets I
want to have as properties their X and Y coordinates, Height and Width.
How can I program this? As far as I understood from your response in this
article
( http://www.eclipse.org/newsportal/article.php?id=13363&g roup=eclipse.modeling.gmf#13363)
the graphdef editor can be used as an example of such properties, and
that's why I want to start it and see how they are implemented there.
Unfortunately I couldn't understand you when you say that one should
implement "domain model listener" and overwrite the "refreshBounds()"
method. What is domain model listener and where is this method?

I have also tried this with "model.eSet(e, model);", but this didn't work
out:
http://dev.eclipse.org/mhonarc/newsLists/news.eclipse.modeli ng.gmf/msg06998.html

Greetings,
Nikolay
Re: graphdef.editor -> Problems when generating diagram code [message #195298 is a reply to message #195180] Wed, 02 July 2008 10:31 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Nikolay,

> org.eclipse.core.runtime.AssertionFailedException: assertion failed:
Any other information in the .log? Can not recognize the reason from this
trace..

> overwrite the "refreshBounds()" method. What is domain model listener
> and where is this method?
You can download sources of org.eclipse.gmf.graphdef.editor plugin and open
RoundedRectangleEditPart - this class contains all necessary methods performing
synchronization between domain model properties and figure layouting options.

In particular see refreshBounds() + all the places where this method is called.
I have to mention that org.eclipse.gmf.graphdef.editor plugin is rather complex,
but it is mostly generated and in additional contains such features as figure
layout/layout data synchronization with actual figure positions/layouts.
So, if you simply need to get x/y/width/height of all nodes from domain model
elements you have to override refreshBounds() keeping ShapeEditPart.refreshBounds()
in mind, but simply load positions from domain model element. In addition
you have to listen for corresponsing EMf notification from domain model element
+ call this method from there.

The reason why I'm mentioning org.eclipse.gmf.graphdef.editor plugin in all
the questions about domain properties->figure layouting options synchronization
is: you can potentially use existing code generation templates/models for
generating your synchronization mechanizms, but you have to be ready to dig
into this unripe technique. :-)

-----------------
Alex Shatalin
Re: graphdef.editor -> Problems when generating diagram code [message #199541 is a reply to message #195298] Wed, 30 July 2008 13:49 Go to previous messageGo to next message
Nikolay Georgiev is currently offline Nikolay GeorgievFriend
Messages: 13
Registered: July 2009
Junior Member
Thank You Alex for the tips!

For those who are interested I solved the synchronization in the following
way:

==================================================
1) I copied the AbstractFigureEditPart class from the graphdef editor
(version 25. Nov. 2007) in my .diagram project.

2) The following things are added in the AbstractFigureEditPart:

===== AbstractFigureEditPart.java BEGIN =====

private final TransactionalEditingDomain editingDomain;

public AbstractFigureEditPart(View view) {
super(view);
editingDomain =
TransactionalEditingDomain.Factory.INSTANCE.createEditingDom ain();
}

public TransactionalEditingDomain getTransactionalEditingDomain()
{
return editingDomain;
}

/**
* @generated NOT
*/
@Override
public void activate() {

if (isActive()) {
return;
}
View view = (View) getModel();
if (view.getElement() == null) {
super.activate();
return;
}

final EObject modelElement = view.getElement();
final EClass eClass = modelElement.eClass();

final EStructuralFeature eFX = eClass.getEStructuralFeature("x");
final EStructuralFeature eFY = eClass.getEStructuralFeature("y");
final EStructuralFeature eFWidth = eClass.getEStructuralFeature("width");
final EStructuralFeature eFHeight =
eClass.getEStructuralFeature("height");

if (eFWidth != null)
{
addListenerFilter("Model_Width_Listener",
new NotificationListener() {
public void notifyChanged(Notification notification) {

// width from model
final EStructuralFeature eFWidth =
eClass.getEStructuralFeature("width");
String modelWidthStr = (String)modelElement.eGet(eFWidth);
if(!isInteger(modelWidthStr))
{
refreshBounds();
}
else
{
final Integer modelWidthInt = Integer.decode(modelWidthStr);
setStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_ Width(),
modelWidthInt);
}
}
}, modelElement, eFWidth);
}
if (eFHeight != null)
{
addListenerFilter("Model_Height_Listener",
new NotificationListener() {
public void notifyChanged(Notification notification) {

// height from model
final EStructuralFeature eFHeight =
eClass.getEStructuralFeature("height");
String modelHeightStr = (String)modelElement.eGet(eFHeight);
if(!isInteger(modelHeightStr))
{
refreshBounds();
}
else
{
final Integer modelHeightInt = Integer.decode(modelHeightStr);
setStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_ Height(),
modelHeightInt);
}
}
}, modelElement, eFHeight);
}
if (eFX != null)
{
addListenerFilter("Model_X_Listener",
new NotificationListener() {
public void notifyChanged(Notification notification) {

final EStructuralFeature eFX = eClass.getEStructuralFeature("x");
String modelXStr = (String)modelElement.eGet(eFX);
if(!isInteger(modelXStr))
{
refreshBounds();
}
else
{
final Integer modelXInt = Integer.decode(modelXStr);
setStructuralFeatureValue(NotationPackage.eINSTANCE.getLocat ion_X(),
modelXInt);
}
}
}, modelElement, eFX);
}
if (eFY != null)
{
addListenerFilter("Model_Y_Listener",
new NotificationListener() {
public void notifyChanged(Notification notification) {

// height from model
final EStructuralFeature eFY = eClass.getEStructuralFeature("y");
String modelYStr = (String)modelElement.eGet(eFY);
if(!isInteger(modelYStr))
{
refreshBounds();
}
else
{
final Integer modelYInt = Integer.decode(modelYStr);
setStructuralFeatureValue(NotationPackage.eINSTANCE.getLocat ion_Y(),
modelYInt);
}
}
}, modelElement, eFY);
}

final Bounds bounds = (Bounds) ((Node) view).getLayoutConstraint();

addListenerFilter("BoundsListener", new NotificationListener() {
public void notifyChanged(final Notification notification) {
try {
new AbstractEMFOperation(
getEditingDomain(),
"Synchronizing model size with the view",
Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) {
//$NON-NLS-1$
protected IStatus doExecute(IProgressMonitor monitor,
IAdaptable info) throws ExecutionException {

refreshBounds();

return Status.OK_STATUS;
}
}.execute(new NullProgressMonitor(), null);
} catch (ExecutionException e) {
// GMFGraphDiagramEditorPlugin
// .getInstance()
// .logError(
// "Unable to synchronize model size with the view", e);
//$NON-NLS-1$
System.err.println("Unable to synchronize model size with the view");
}
if (getRoot() != null) {
handleMajorSemanticChange();
}
}
}, bounds);

super.activate();
}

/**
* Checks whether the given string is an integer
*
* @param string a string
* @return true or false
*/
private static boolean isInteger(String string)
{
boolean res = true;
try
{
Integer.parseInt(string);
}
catch(NumberFormatException e)
{
res = false;
}

return res;
}

===== AbstractFigureEditPart.java END =====

3) All *EditPart.java extend the AbstractFigureEditPart and the following
things are added:

===== *EditPart.java BEGIN =====

/**
* @generated NOT
*/
private Figure myNodeFigure;

/**
* @generated
*/
protected NodeFigure createNodePlate() {
DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(getMapMode()
.DPtoLP(40), getMapMode().DPtoLP(40));
myNodeFigure = result;
return result;
}

/**
* @generated NOT
*/
protected void refreshBounds() {
super.refreshBounds();

View view = getNotationView();
final EObject element = view.getElement();
EClass eClass = element.eClass();

final EStructuralFeature eFX = eClass.getEStructuralFeature("x");
final EStructuralFeature eFY = eClass.getEStructuralFeature("y");

final int x = ((Integer)
getStructuralFeatureValue(NotationPackage.eINSTANCE
.getLocation_X())).intValue();
final int y = ((Integer)
getStructuralFeatureValue(NotationPackage.eINSTANCE
.getLocation_Y())).intValue();

// update x,y,w,h of the model
TransactionalEditingDomain editingDomain =
getTransactionalEditingDomain();
RecordingCommand updateModelCmd = new RecordingCommand(editingDomain) {
@Override
protected void doExecute() {
element.eSet(eFX, String.valueOf(x));
element.eSet(eFY, String.valueOf(y));
}
};
TransactionalCommandStack tstack = (TransactionalCommandStack)
editingDomain.getCommandStack();
tstack.execute(updateModelCmd);
}

/**
* @generated NOT
*/
protected LayoutManager getFigureLayoutManager() {
return contentPane.getLayoutManager();
}

/**
* @generated NOT
*/
protected void setFigureLayoutManager(LayoutManager layoutManager) {
contentPane.setLayoutManager(layoutManager);
}
===== *EditPart.java END =====
==================================================

Greetings,
Nikolay
Re: graphdef.editor -> Problems when generating diagram code [message #696905 is a reply to message #199541] Fri, 15 July 2011 04:58 Go to previous messageGo to next message
Karthikeyan Missing name is currently offline Karthikeyan Missing nameFriend
Messages: 47
Registered: July 2011
Member
Hi,

Myself generating GMF editor with single "Task" element. While generating diagram code from gmfgen, its showing the following error
"Can't organize imports due to syntax errors in the compilation unit Task3EditPart.java"
"Can't organize imports due to syntax errors in the compilation unit Task2EditPart.java"
can any one suggest any solution for the same.

Regards,
Karthikeyan
Re: graphdef.editor -> Problems when generating diagram code [message #697534 is a reply to message #195037] Sun, 17 July 2011 05:19 Go to previous message
Karthikeyan Missing name is currently offline Karthikeyan Missing nameFriend
Messages: 47
Registered: July 2011
Member
Hi,

Myself having BPMN20.ecore and I am trying to create gmfgraph, gmftool and gmfmap using GMF. Can any one tell me, which one is the root element in BPMN20 ecore and also if any one having gmfgraph, gmftool and gmfmap for the corresponding ecore, kindly provide me the link or send it to my mail ID - karthik_park22@yahoo.co.in

Regards,
Karthikeyan.B

[Updated on: Mon, 18 July 2011 08:39]

Report message to a moderator

Previous Topic:Phantom node bugs on GMF Tooling
Next Topic:Impl Setter not called by diagram
Goto Forum:
  


Current Time: Tue Mar 09 08:31:28 GMT 2021

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

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

Back to the top