Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Add Node to BorderLayout
Add Node to BorderLayout [message #219592] Fri, 20 February 2009 17:24 Go to next message
Michael Buske is currently offline Michael BuskeFriend
Messages: 2
Registered: July 2009
Junior Member
Hallo,


I have a very simple model with a TopNode and a ChildNode.

Now I simply try to add a rectangel child node to the rectangel topnode
with border layout. But I get an internal class cast exception
(java.lang.ClassCastException: org.eclipse.draw2d.geometry.Rectangle
cannot be cast to java.lang.Integer)

The same problem was mentioned here too:
http://dev.eclipse.org/newslists/news.eclipse.modeling.gmf/m sg16059.html

But I dont get this working. May be I' ve done some modeling mistakes?
(gmfgraph and gmfmap are attached at the end)

In my little example I habe realized it to add an rect to the TopNode
directly in the gmfgraph. But not during runtime by adding the childNode
wiht exactly the same configuration.

gmfgraph:

<?xml version="1.0" encoding="UTF-8"?>
<gmfgraph:Canvas xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:gmfgraph="http://www.eclipse.org/gmf/2006/GraphicalDefinition"
name="MashupScreenFlow">
<figures
name="Default">
<figures
xsi:type="gmfgraph:PolygonDecoration"
name="Arrow"/>
<descriptors
name="ScreenFigure">
<actualFigure
xsi:type="gmfgraph:Rectangle"
name="ScreenFigure">
<layout
xsi:type="gmfgraph:BorderLayout"/>
<backgroundColor
xsi:type="gmfgraph:ConstantColor"
value="lightGreen"/>
<children
xsi:type="gmfgraph:Rectangle"
name="sfrect">
<layoutData
xsi:type="gmfgraph:BorderLayoutData"
alignment="END"
vertical="true"/>
<backgroundColor
xsi:type="gmfgraph:ConstantColor"
value="lightBlue"/>
<preferredSize
dx="20"
dy="20"/>
</children>
<children
xsi:type="gmfgraph:Rectangle"
name="sfrect2">
<layoutData
xsi:type="gmfgraph:BorderLayoutData"
alignment="BEGINNING"/>
<backgroundColor
xsi:type="gmfgraph:ConstantColor"
value="cyan"/>
<preferredSize
dx="30"
dy="30"/>
</children>
</actualFigure>
</descriptors>
<descriptors
name="LinkFigure">
<actualFigure
xsi:type="gmfgraph:PolylineConnection"
name="LinkFigure"
targetDecoration="//@figures.0/@figures.0"/>
</descriptors>
<descriptors
name="boFigure">
<actualFigure
xsi:type="gmfgraph:Rectangle"
name="boRect">
<layoutData
xsi:type="gmfgraph:BorderLayoutData"
alignment="BEGINNING"
vertical="true"/>
<backgroundColor
xsi:type="gmfgraph:ConstantColor"
value="yellow"/>
<preferredSize
dx="25"
dy="25"/>
</actualFigure>
</descriptors>
</figures>
<nodes
name="Screen"
figure="ScreenFigure"/>
<nodes
name="bo"
figure="boFigure"/>
<connections
name="Link"
figure="LinkFigure"/>
<labels
name="ScreenName"
figure="ScreenFigure"/>
</gmfgraph:Canvas>


gmfmap:

<?xml version="1.0" encoding="UTF-8"?>
<gmfmap:Mapping xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:gmfmap="http://www.eclipse.org/gmf/2008/mappings"
xmlns:gmftool="http://www.eclipse.org/gmf/2005/ToolDefinition">
<nodes>
<containmentFeature
href="BorderLayoutTest.ecore#//Application/screens"/>
<ownedChild>
<domainMetaElement
href="BorderLayoutTest.ecore#//Screen"/>
<tool
xsi:type="gmftool:CreationTool"
href="BorderLayoutTest.gmftool#//@palette/@tools.0/@tools.0 "/>
<diagramNode
href="BorderLayoutTest.gmfgraph#Screen"/>
<children>
<containmentFeature
href="BorderLayoutTest.ecore#//Screen/bos"/>
<childrenFeature
href="BorderLayoutTest.ecore#//Screen/bos"/>
<ownedChild>
<domainMetaElement
href="BorderLayoutTest.ecore#//Bo"/>
<tool
xsi:type="gmftool:CreationTool"

href="BorderLayoutTest.gmftool#//@palette/@tools.0/@tools.2 "/>
<diagramNode
href="BorderLayoutTest.gmfgraph#bo"/>
</ownedChild>
</children>
</ownedChild>
</nodes>
<links>
<domainMetaElement
href="BorderLayoutTest.ecore#//Link"/>
<containmentFeature
href="BorderLayoutTest.ecore#//Application/links"/>
<tool
xsi:type="gmftool:CreationTool"
href="BorderLayoutTest.gmftool#//@palette/@tools.0/@tools.1 "/>
<diagramLink
href="BorderLayoutTest.gmfgraph#Link"/>
<sourceMetaFeature
xsi:type="ecore:EReference"
href="BorderLayoutTest.ecore#//Link/SourceScreen"/>
<linkMetaFeature
xsi:type="ecore:EReference"
href="BorderLayoutTest.ecore#//Link/TrageScreen"/>
</links>
<diagram>
<diagramCanvas
href="BorderLayoutTest.gmfgraph#MashupScreenFlow"/>
<domainModel
href="BorderLayoutTest.ecore#/"/>
<domainMetaElement
href="BorderLayoutTest.ecore#//Application"/>
<palette
href="BorderLayoutTest.gmftool#//@palette"/>
</diagram>
</gmfmap:Mapping>


My bigger plan is to develop an Widget with labeled node at its borders:

______[Action1]__
| |
| Widget_A |
|_________________|
[Action2]
^
|
|
______[Event1]__
| |
| Widget_B |
|_________________|
[Action3]

I have several widgets(normal boxes may be with a picture in it)
These widgets "own" actions and events. When I choose one of them over the
context-menu (allready established :-) ) a docked, labeled box should
appear.
This docked box has to be hanging on the widget (moving with it).

I want do use the "Beginning" and "End" area of the borderlayout as
container for the labeled nodes. (The real 'widget' stays central)

But I am even not able to set an node in the borderlayout!

May be sameone can give me some real gmf-beginner help?

Thank you very much in advance!!
Re: Add Node to BorderLayout [message #219763 is a reply to message #219592] Mon, 23 February 2009 17:58 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Michael,

I think the following descriptor is wrong - you are using "BorderLayoutData"
there, but the layout menager of this figure parent will not be instance
of BorderLayout, i suppose:

<descriptors name="boFigure">
<actualFigure xsi:type="gmfgraph:Rectangle" name="boRect">
<layoutData xsi:type="gmfgraph:BorderLayoutData" alignment="BEGINNING"
vertical="true"/>
<backgroundColor xsi:type="gmfgraph:ConstantColor" value="yellow"/>
<preferredSize dx="25" dy="25"/>
</actualFigure>
</descriptors>

Try first removing layoutData reference from this figureand re-generate code.

-----------------
Alex Shatalin
Previous Topic:Building 2.2
Next Topic:nodes disapear after connecting them
Goto Forum:
  


Current Time: Wed Apr 24 23:51:20 GMT 2024

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

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

Back to the top