Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Layout information persistence
Layout information persistence [message #233641] Mon, 15 June 2009 10:16 Go to next message
Bence Ol is currently offline Bence OlFriend
Messages: 4
Registered: July 2009
Junior Member
Hello,

Im working on a model to text transformer to generate html file from the
GMF model.
I have some problem with the persisted model because it does not contain
all the relevant information for the transformation, for example: the
width and the height fields are set to auto-size (-1) or if the diagram
was not 'touched' then the file contains only the root diagram node.

My question is that how can I persist the relevant nodes and fields even
if their graphical information was not modified?


Thanks in advance,
Bence
B2International
Re: Layout information persistence [message #233855 is a reply to message #233641] Wed, 17 June 2009 07:52 Go to previous messageGo to next message
Bence Ol is currently offline Bence OlFriend
Messages: 4
Registered: July 2009
Junior Member
I found a workaround for the problem, by getting the child editparts from
the OffscreenEditPart and iterating through the children list. With this
solution there is no need to open an editor. The editparts' figures are
containing the 'real' layout information, not just '-1' values.


Sample code:
...
CopyToImageUtil util = new CopyToImageUtil();
DiagramEditPart diagramEditPart = util.createDiagramEditPart(diagram,
shell, preferencesHint);

List editparts = diagramEditPart.getChildren();

foreach(EditPart editpart: editpars)
{
if(editpart instanceof GraphicalEditPart)
{
Bounds bounds = ((GraphicalEditPart)editpart).getFigure().getBounds();
}
}


However it would be nice if I could persist all the graphical information
to the diagram file and later load it back.
[Solved] Layout information persistence [message #234121 is a reply to message #233855] Thu, 18 June 2009 15:24 Go to previous message
Bence Ol is currently offline Bence OlFriend
Messages: 4
Registered: July 2009
Junior Member
I have overriden the
XXXMetamodelDiagramEditor.initializeGraphicalViewerContents( ) method to
execute an auto-layout command and then the diagram file is saved:

Sample:
@Override
protected void initializeGraphicalViewerContents() {
super.initializeGraphicalViewerContents();

ArrangeRequest arrangeRequest = new
ArrangeRequest(ActionIds.ACTION_ARRANGE_ALL);
IGraphicalEditPart rootEP = (IGraphicalEditPart)
getDiagramGraphicalViewer().getRootEditPart().getContents();
List l = new ArrayList();
l.add(rootEP);
arrangeRequest.setPartsToArrange(l);
Command cmd = rootEP.getCommand(arrangeRequest);
// execute command
getCommandStack().execute(cmd);

// save the file
performSave(true, new NullProgressMonitor());
}

After the auto-layout I can get all the tranformation relevant infromation!
Previous Topic:Do I need a Top Node Reference anymore?
Next Topic:OffscreenEditPart factory during build requires UI thread
Goto Forum:
  


Current Time: Thu Feb 25 17:17:22 GMT 2021

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

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

Back to the top