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 06:41  |
Eclipse User |
|
|
|
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 #199541 is a reply to message #195298] |
Wed, 30 July 2008 09:49   |
Eclipse User |
|
|
|
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
|
|
| | |
Goto Forum:
Current Time: Fri May 09 16:34:26 EDT 2025
Powered by FUDForum. Page generated in 0.03805 seconds
|