Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/icons/symbols/deepHistory.svg33
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/icons/symbols/durationObservation.svg19
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/icons/symbols/shallowHistory.svg32
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/icons/symbols/timeObservation.svg19
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/AbstractBorderEditPart.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/AbstractInteractionEditPart.java54
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/ClassEditPart.java61
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/ClassifierEditPart.java13
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/FloatingLabelEditPart.java81
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/NamedElementEditPart.java131
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/RoundedBorderNamedElementEditPart.java189
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/RoundedCompartmentEditPart.java180
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/BorderItemResizableEditPolicy.java1
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/ConstrainedItemBorderLayoutEditPolicy.java3
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/MaskManagedFloatingLabelEditPolicy.java248
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/AffixedNamedElementFigure.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/AutomaticCompartmentLayoutManager.java30
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/ClassFigure.java93
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/ClassifierFigure.java58
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/DataTypeFigure.java3
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/DependencyNodeFigure.java1
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/EnumerationFigure.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/FinalNode.java1
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/FlowFinalNode.java1
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/ForkNode.java57
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/InitialNode.java1
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/InstanceSpecificationFigure.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/NodeNamedElementFigure.java19
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/PapyrusNodeFigure.java8
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/PrimitiveTypeFigure.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/RoundedCompartmentFigure.java404
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/SignalFigure.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/FloatingLabelHelper.java325
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/locator/ExternalLabelPositionLocator.java66
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/locator/PortPositionLocator.java274
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/locator/RoundedRectangleLabelPositionLocator.java714
36 files changed, 2864 insertions, 267 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/icons/symbols/deepHistory.svg b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/icons/symbols/deepHistory.svg
new file mode 100644
index 00000000000..15f8d64bca2
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/icons/symbols/deepHistory.svg
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="20" height="20" id="svg2" version="1.1" inkscape:version="0.48.5 r10040" sodipodi:docname="deepHistory.svg">
+ <defs id="defs4">
+ <linearGradient id="linearGradient3789">
+ <stop style="stop-color:#000005;stop-opacity:1;" offset="0" id="stop3791" />
+ <stop style="stop-color:white;stop-opacity:0;" offset="1" id="stop3793" />
+ </linearGradient>
+ <inkscape:perspective sodipodi:type="inkscape:persp3d" inkscape:vp_x="0 : 20 : 1" inkscape:vp_y="0 : 1000 : 0" inkscape:vp_z="85 : 20 : 1" inkscape:persp3d-origin="42.5 : 13.333333 : 1" id="perspective3063" />
+ <linearGradient id="linearGradient3786">
+ <stop style="stop-color:#000000;stop-opacity:0;" offset="0" id="stop3788" />
+ <stop id="stop3794" offset="1" style="stop-color:#919cd7;stop-opacity:1;" />
+ </linearGradient>
+ </defs>
+ <sodipodi:namedview id="base" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="5.6" inkscape:cx="7.9165719" inkscape:cy="-13.962009" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="false" units="px" inkscape:window-width="1920" inkscape:window-height="1005" inkscape:window-x="1591" inkscape:window-y="-9" inkscape:window-maximized="1" />
+ <metadata id="metadata7">
+ <rdf:RDF>
+ <cc:Work rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g inkscape:groupmode="layer" id="layer2" inkscape:label="Calque">
+ <path sodipodi:type="star" style="fill:white;fill-opacity:1;stroke:black;stroke-opacity:1;stroke-width:1.3;stroke-miterlimit:4;stroke-dasharray:none" id="PapyrusPath" sodipodi:sides="16" sodipodi:cx="10.357143" sodipodi:cy="10.357143" sodipodi:r1="8.9731035" sodipodi:r2="8.9731035" sodipodi:arg1="0.82762657" sodipodi:arg2="1.0239761" inkscape:flatsided="false" inkscape:rounded="0" inkscape:randomized="0" d="M 16.428572,16.964287 L 15.022922,18.021809 L 13.437968,18.784783 L 11.73462,19.223887 L 9.9783361,19.322248 L 8.2366099,19.076084 L 6.5763743,18.494856 L 5.0614318,17.600901 L 3.7500003,16.428572 L 2.6924778,15.022922 L 1.9295039,13.437968 L 1.4903996,11.73462 L 1.3920393,9.9783361 L 1.6382028,8.2366099 L 2.2194305,6.5763743 L 3.1133857,5.0614318 L 4.2857147,3.7500003 L 5.6913651,2.6924778 L 7.2763189,1.9295039 L 8.9796668,1.4903996 L 10.735951,1.3920393 L 12.477677,1.6382028 L 14.137912,2.2194305 L 15.652855,3.1133857 L 16.964287,4.2857147 L 18.021809,5.6913651 L 18.784783,7.2763189 L 19.223887,8.9796668 L 19.322248,10.735951 L 19.076084,12.477677 L 18.494856,14.137912 L 17.600901,15.652855 z" transform="translate(-0.3571434,-0.3571434)" />
+ </g>
+ <g inkscape:label="Calque 1" inkscape:groupmode="layer" id="layer1" transform="translate(0,-1032.3617)" style="display:inline">
+ <text xml:space="preserve" style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:black;fill-opacity:1;stroke:none;font-family:Sans" x="6.25" y="7.5" id="text2993" sodipodi:linespacing="125%" transform="translate(-3.1305805,1039.8724)"><tspan sodipodi:role="line" id="tspan2995" x="6.25" y="7.5" style="font-size:14px">H</tspan></text>
+ <text xml:space="preserve" style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:black;fill-opacity:1;stroke:none;font-family:Sans" x="-38.75" y="12.857143" id="text2994" sodipodi:linespacing="125%" transform="translate(51.071428,1035.0402)"><tspan sodipodi:role="line" id="tspan2996" x="-38.75" y="12.857143" style="font-size:14px">*</tspan></text>
+ </g>
+</svg>
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/icons/symbols/durationObservation.svg b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/icons/symbols/durationObservation.svg
new file mode 100644
index 00000000000..3f658349c4a
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/icons/symbols/durationObservation.svg
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="20" height="20" id="svg3787" version="1.1" inkscape:version="0.48.5 r10040" sodipodi:docname="TimeObservation.svg">
+ <defs id="defs3789" />
+ <sodipodi:namedview id="base" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="7.8481082" inkscape:cx="-46.07925" inkscape:cy="14.291126" inkscape:current-layer="svg3787" showgrid="true" inkscape:grid-bbox="true" inkscape:document-units="px" inkscape:window-width="1920" inkscape:window-height="1005" inkscape:window-x="1591" inkscape:window-y="-9" inkscape:window-maximized="1" />
+ <metadata id="metadata3792">
+ <rdf:RDF>
+ <cc:Work rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g id="layer1" inkscape:label="Layer 1" inkscape:groupmode="layer" transform="translate(0,4)" />
+ <text xml:space="preserve" style="font-size:12.61640644px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:116.99999571%;letter-spacing:0px;word-spacing:0px;fill:#476caa;fill-opacity:1;stroke:none;font-family:Arial;-inkscape-font-specification:Arial" x="1.0969616" y="10.079314" id="text3828" sodipodi:linespacing="117%" transform="matrix(1.0691606,0,0,0.93531316,-0.0887114,1.7064536)"><tspan sodipodi:role="line" x="1.0969616" y="10.079314" id="tspan3870" style="font-weight:bold;-inkscape-font-specification:Arial Bold">&amp;d<tspan style="font-size:8.83148575px;font-weight:bold;line-height:116.99999571%;fill:#476caa;fill-opacity:1;-inkscape-font-specification:Arial Bold" id="tspan3876" /></tspan></text>
+ <text xml:space="preserve" style="font-size:9.0160284px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#476caa;fill-opacity:1;stroke:none;font-family:Sans" x="5.4504604" y="19.354103" id="text3908" sodipodi:linespacing="125%" transform="matrix(1.2529306,0,0,0.7981288,2.0387078,1.5790345)"><tspan sodipodi:role="line" id="tspan3910" x="5.4504604" y="19.354103" style="font-weight:bold;-inkscape-font-specification:Sans Bold">l</tspan></text>
+</svg>
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/icons/symbols/shallowHistory.svg b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/icons/symbols/shallowHistory.svg
new file mode 100644
index 00000000000..78039462f47
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/icons/symbols/shallowHistory.svg
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="20" height="20" id="svg2" version="1.1" inkscape:version="0.48.5 r10040" sodipodi:docname="shallowHistory.svg">
+ <defs id="defs4">
+ <linearGradient id="linearGradient3789">
+ <stop style="stop-color:#000005;stop-opacity:1;" offset="0" id="stop3791" />
+ <stop style="stop-color:white;stop-opacity:0;" offset="1" id="stop3793" />
+ </linearGradient>
+ <inkscape:perspective sodipodi:type="inkscape:persp3d" inkscape:vp_x="0 : 20 : 1" inkscape:vp_y="0 : 1000 : 0" inkscape:vp_z="85 : 20 : 1" inkscape:persp3d-origin="42.5 : 13.333333 : 1" id="perspective3063" />
+ <linearGradient id="linearGradient3786">
+ <stop style="stop-color:#000000;stop-opacity:0;" offset="0" id="stop3788" />
+ <stop id="stop3794" offset="1" style="stop-color:#919cd7;stop-opacity:1;" />
+ </linearGradient>
+ </defs>
+ <sodipodi:namedview id="base" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="5.6" inkscape:cx="7.9165719" inkscape:cy="-13.962009" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="false" units="px" inkscape:window-width="1920" inkscape:window-height="1005" inkscape:window-x="1591" inkscape:window-y="-9" inkscape:window-maximized="1" />
+ <metadata id="metadata7">
+ <rdf:RDF>
+ <cc:Work rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g inkscape:groupmode="layer" id="layer2" inkscape:label="Calque">
+ <path sodipodi:type="star" style="fill:white;fill-opacity:1;stroke:black;stroke-opacity:1;stroke-width:1.3;stroke-miterlimit:4;stroke-dasharray:none" id="PapyrusPath" sodipodi:sides="16" sodipodi:cx="10.357143" sodipodi:cy="10.357143" sodipodi:r1="8.9731035" sodipodi:r2="8.9731035" sodipodi:arg1="0.82762657" sodipodi:arg2="1.0239761" inkscape:flatsided="false" inkscape:rounded="0" inkscape:randomized="0" d="M 16.428572,16.964287 L 15.022922,18.021809 L 13.437968,18.784783 L 11.73462,19.223887 L 9.9783361,19.322248 L 8.2366099,19.076084 L 6.5763743,18.494856 L 5.0614318,17.600901 L 3.7500003,16.428572 L 2.6924778,15.022922 L 1.9295039,13.437968 L 1.4903996,11.73462 L 1.3920393,9.9783361 L 1.6382028,8.2366099 L 2.2194305,6.5763743 L 3.1133857,5.0614318 L 4.2857147,3.7500003 L 5.6913651,2.6924778 L 7.2763189,1.9295039 L 8.9796668,1.4903996 L 10.735951,1.3920393 L 12.477677,1.6382028 L 14.137912,2.2194305 L 15.652855,3.1133857 L 16.964287,4.2857147 L 18.021809,5.6913651 L 18.784783,7.2763189 L 19.223887,8.9796668 L 19.322248,10.735951 L 19.076084,12.477677 L 18.494856,14.137912 L 17.600901,15.652855 z" transform="translate(-0.3571434,-0.3571434)" />
+ </g>
+ <g inkscape:label="Calque 1" inkscape:groupmode="layer" id="layer1" transform="translate(0,-1032.3617)" style="display:inline">
+ <text xml:space="preserve" style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:black;fill-opacity:1;stroke:none;font-family:Sans" x="6.25" y="7.5" id="text2993" sodipodi:linespacing="125%" transform="translate(-1.3017578,1039.8724)"><tspan sodipodi:role="line" id="tspan2995" x="6.25" y="7.5" style="font-size:14px">H</tspan></text>
+ </g>
+</svg>
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/icons/symbols/timeObservation.svg b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/icons/symbols/timeObservation.svg
new file mode 100644
index 00000000000..e4abb848686
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/icons/symbols/timeObservation.svg
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="20" height="20" id="svg3787" version="1.1" inkscape:version="0.48.5 r10040" sodipodi:docname="TimeObservation.svg">
+ <defs id="defs3789" />
+ <sodipodi:namedview id="base" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="7.8481082" inkscape:cx="-46.07925" inkscape:cy="13.972578" inkscape:current-layer="svg3787" showgrid="true" inkscape:grid-bbox="true" inkscape:document-units="px" inkscape:window-width="1920" inkscape:window-height="1005" inkscape:window-x="1591" inkscape:window-y="-9" inkscape:window-maximized="1" />
+ <metadata id="metadata3792">
+ <rdf:RDF>
+ <cc:Work rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g id="layer1" inkscape:label="Layer 1" inkscape:groupmode="layer" transform="translate(0,4)" />
+ <text xml:space="preserve" style="font-size:12.61640644px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:116.99999571%;letter-spacing:0px;word-spacing:0px;fill:#476caa;fill-opacity:1;stroke:none;font-family:Arial;-inkscape-font-specification:Arial" x="1.0969616" y="10.079314" id="text3828" sodipodi:linespacing="117%" transform="matrix(1.0691606,0,0,0.93531316,1.9112886,1.7064536)"><tspan sodipodi:role="line" x="1.0969616" y="10.079314" id="tspan3870" dy="0 1.6874446" style="font-weight:bold;-inkscape-font-specification:Arial Bold"><tspan style="font-size:8.83148575000000060px;line-height:116.99999570999999000%;fill:#476caa;fill-opacity:1;font-weight:bold;-inkscape-font-specification:Arial Bold" id="tspan3876" dy="-1.6874446">@</tspan>t</tspan></text>
+ <text xml:space="preserve" style="font-size:9.0160284px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#476caa;fill-opacity:1;stroke:none;font-family:Sans" x="5.4504604" y="19.354103" id="text3908" sodipodi:linespacing="125%" transform="matrix(1.2529306,0,0,0.7981288,2.0387078,1.5790345)"><tspan sodipodi:role="line" id="tspan3910" x="5.4504604" y="19.354103" style="font-weight:bold;-inkscape-font-specification:Sans Bold">l</tspan></text>
+</svg>
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/AbstractBorderEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/AbstractBorderEditPart.java
index 7811c76d3dd..cf89116e669 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/AbstractBorderEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/AbstractBorderEditPart.java
@@ -20,7 +20,7 @@ import org.eclipse.gmf.runtime.notation.View;
/**
* Abstract EditPart for Border elements like Port
*/
-public abstract class AbstractBorderEditPart extends BorderNamedElementEditPart implements IUMLNamedElementEditPart {
+public abstract class AbstractBorderEditPart extends RoundedBorderNamedElementEditPart implements IUMLNamedElementEditPart {
/** Constructor */
public AbstractBorderEditPart(View view) {
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/AbstractInteractionEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/AbstractInteractionEditPart.java
new file mode 100644
index 00000000000..45597f5676b
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/AbstractInteractionEditPart.java
@@ -0,0 +1,54 @@
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.common.editparts;
+
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.gmf.runtime.notation.View;
+
+/**
+ * @author Mickael ADAM
+ *
+ */
+public abstract class AbstractInteractionEditPart extends RoundedCompartmentEditPart {
+
+ /**
+ * Constructor.
+ *
+ * @param view
+ */
+ public AbstractInteractionEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.common.editparts.RoundedCompartmentEditPart#getDefaultHasHeader()
+ *
+ * @return
+ */
+ @Override
+ protected boolean getDefaultHasHeader() {
+ return true;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart#getDefaultNamePosition()
+ *
+ * @return
+ */
+ @Override
+ protected int getDefaultNamePosition() {
+ return PositionConstants.LEFT;
+ }
+
+} \ No newline at end of file
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/ClassEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/ClassEditPart.java
new file mode 100644
index 00000000000..0dea54d7ab4
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/ClassEditPart.java
@@ -0,0 +1,61 @@
+/*****************************************************************************
+ * Copyright (c) 2010, 2014 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - moved class behavior from classiferEditPart
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.common.editparts;
+
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ClassFigure;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ClassifierFigure;
+
+/**
+ * Class edit part.
+ *
+ */
+public abstract class ClassEditPart extends ClassifierEditPart {
+
+ /**
+ * Instantiates a new class edit part.
+ *
+ * @param view
+ * the view
+ */
+ public ClassEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.common.editparts.ClassifierEditPart#refreshVisuals()
+ *
+ */
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ if(getPrimaryShape() != null && resolveSemanticElement() != null) {
+ refreshIsActive();
+ }
+ }
+
+ /**
+ * Refresh is active.
+ *
+ * @see org.eclipse.papyrus.uml.diagram.common.editparts.ClassifierEditPart#refreshIsActive()
+ */
+ protected void refreshIsActive() {
+ if(getUMLElement() instanceof org.eclipse.uml2.uml.Class) {
+ if(getPrimaryShape() instanceof ClassifierFigure) {
+ ((ClassFigure)getPrimaryShape()).setActive(((org.eclipse.uml2.uml.Class)getUMLElement()).isActive());
+ }
+ }
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/ClassifierEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/ClassifierEditPart.java
index e627fb7196e..3f70c2f8c17 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/ClassifierEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/ClassifierEditPart.java
@@ -8,6 +8,7 @@
*
* Contributors:
* Thibault Landre (Atos Origin) - Initial API and implementation
+ * Mickaël ADAM (ALL4TEC) - mickael.adam@all4tec.net - moved class behavior to classEditPart
*
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.editparts;
@@ -15,7 +16,6 @@ package org.eclipse.papyrus.uml.diagram.common.editparts;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.gmf.runtime.notation.FontStyle;
import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.ClassifierFigure;
import org.eclipse.papyrus.uml.diagram.common.helper.BasicClassifierCompartmentLayoutHelper;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.FontData;
@@ -27,7 +27,7 @@ import org.eclipse.uml2.uml.UMLPackage;
*
* @author tlandre
*/
-public abstract class ClassifierEditPart extends NamedElementEditPart {
+public abstract class ClassifierEditPart extends RoundedCompartmentEditPart {
/**
* isAbstract Classifier property
@@ -65,15 +65,6 @@ public abstract class ClassifierEditPart extends NamedElementEditPart {
super.refreshVisuals();
if (getPrimaryShape() != null && resolveSemanticElement() != null) {
refreshAbstract();
- refreshIsActive();
- }
- }
-
- protected void refreshIsActive() {
- if (getUMLElement() instanceof org.eclipse.uml2.uml.Class) {
- if (getPrimaryShape() instanceof ClassifierFigure) {
- ((ClassifierFigure) getPrimaryShape()).setActive(((org.eclipse.uml2.uml.Class) getUMLElement()).isActive());
- }
}
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/FloatingLabelEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/FloatingLabelEditPart.java
new file mode 100644
index 00000000000..5b6f61cf08e
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/FloatingLabelEditPart.java
@@ -0,0 +1,81 @@
+/*****************************************************************************
+ * Copyright (c) 2010, 2014 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.common.editparts;
+
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.MaskManagedFloatingLabelEditPolicy;
+
+/**
+ * The Class FloatingNameEditPart.
+ */
+public class FloatingLabelEditPart extends PapyrusLabelEditPart {
+
+ /** The Constant DISPLAY_FLOATING_NAME. */
+ public static final String DISPLAY_FLOATING_LABEL = "visible";
+
+ // private static final String DISPLAY_FLOATING_LABEL = "displayFloatingLabel";
+
+
+ /** The Constant DEFAULT_LABEL_DISPLAYED. */
+ private static final boolean DEFAULT_LABEL_DISPLAYED = false;
+
+ /**
+ * Instantiates a new floating label edit part.
+ *
+ * @param view
+ * the view
+ */
+ public FloatingLabelEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @see org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart#createDefaultEditPolicies()
+ *
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ // installEditPolicy(org.eclipse.papyrus.uml.diagram.common.editpolicies.ExternalLabelDisplayEditPolicy.EXTERNAL_LABEL_POLICY, new ExternalLabelDisplayEditPolicy());
+ installEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL, new MaskManagedFloatingLabelEditPolicy());
+ // installEditPolicy("test", new FeedBackFloatingLabelEditPolicy());
+
+ }
+
+ /**
+ * @see org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart#refreshVisibility()
+ *
+ */
+ @Override
+ protected void refreshVisibility() {
+ super.refreshVisibility();
+ // get the value of the CSS property
+ boolean isLabelDisplayed = NotationUtils.getBooleanValue((View) getModel(), DISPLAY_FLOATING_LABEL, getDefaultLabelVisibility());
+
+ // Set the visibility of the label
+ getFigure().setVisible(isLabelDisplayed);
+ }
+
+ /**
+ * Gets the default label displayed value.
+ *
+ * @return the default label displayed value
+ */
+ protected boolean getDefaultLabelVisibility() {
+ return DEFAULT_LABEL_DISPLAYED;
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/NamedElementEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/NamedElementEditPart.java
index ccb6fea4c6b..a95fe1018f5 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/NamedElementEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/NamedElementEditPart.java
@@ -1,6 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2008-2014 CEA LIST.
- *
+ * Copyright (c) 2010, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,8 +7,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- * Céline Janssens (ALL4TEC) celine.janssens@all4tec.net - Bug 440230 : Label Margin
+ * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation
*
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.editparts;
@@ -17,10 +15,12 @@ package org.eclipse.papyrus.uml.diagram.common.editparts;
import java.util.List;
import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.PositionConstants;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
import org.eclipse.gmf.runtime.notation.BooleanValueStyle;
import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.StringValueStyle;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.emf.appearance.helper.AppearanceHelper;
import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart;
@@ -31,6 +31,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNo
import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils;
import org.eclipse.papyrus.infra.gmfdiag.common.utils.FigureUtils;
import org.eclipse.papyrus.uml.diagram.common.figure.node.IPapyrusNodeNamedElementFigure;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.NodeNamedElementFigure;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.uml2.uml.NamedElement;
@@ -42,39 +43,28 @@ import org.eclipse.uml2.uml.NamedElement;
*/
public abstract class NamedElementEditPart extends UMLNodeEditPart implements IUMLNamedElementEditPart {
- /**
- * CSS boolean property controlling whether stereotypes should be displayed
- */
+ /** The Constant NAME_POSITION. */
+ public static final String NAME_POSITION = "namePosition";
+
+ /** CSS boolean property controlling whether stereotypes should be displayed. */
public static final String DISPLAY_STEREOTYPES = "displayStereotypes"; // $NON-NLS$
- /**
- * CSS boolean property controlling whether tags should be displayed
- */
+ /** CSS boolean property controlling whether tags should be displayed. */
public static final String DISPLAY_TAGS = "displayTags"; // $NON-NLS$
- /**
- * Default Margin when not present in CSS
- */
+ /** Default Margin when not present in CSS. */
public static final int DEFAULT_MARGIN = 0;
- /**
- * CSS Integer property to define the horizontal Label Margin
- */
+ /** CSS Integer property to define the horizontal Label Margin. */
public static final String TOP_MARGIN_PROPERTY = "topMarginLabel"; // $NON-NLS$
- /**
- * CSS Integer property to define the vertical Label Margin
- */
+ /** CSS Integer property to define the vertical Label Margin. */
public static final String LEFT_MARGIN_PROPERTY = "leftMarginLabel"; // $NON-NLS$
- /**
- * CSS Integer property to define the horizontal Label Margin
- */
+ /** CSS Integer property to define the horizontal Label Margin. */
public static final String BOTTOM_MARGIN_PROPERTY = "bottomMarginLabel"; // $NON-NLS$
- /**
- * CSS Integer property to define the vertical Label Margin
- */
+ /** CSS Integer property to define the vertical Label Margin. */
public static final String RIGHT_MARGIN_PROPERTY = "rightMarginLabel"; // $NON-NLS$
@@ -86,6 +76,11 @@ public abstract class NamedElementEditPart extends UMLNodeEditPart implements IU
super(view);
}
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.common.editparts.IUMLNamedElementEditPart#getNamedElement()
+ *
+ * @return
+ */
@Override
public NamedElement getNamedElement() {
return (NamedElement) getUMLElement();
@@ -106,11 +101,30 @@ public abstract class NamedElementEditPart extends UMLNodeEditPart implements IU
}
}
+ /**
+ * Refresh icon named label.
+ */
private void refreshIconNamedLabel() {
getNodeNamedElementFigure().setNameLabelIcon(AppearanceHelper.showElementIcon((View) getModel()));
}
+ /**
+ * Refresh.
+ *
+ * @see org.eclipse.papyrus.uml.diagram.common.editparts.UMLNodeEditPart#refresh()
+ */
+ @Override
+ public void refresh() {
+ refreshNamePosition();
+ super.refresh();
+ }
+
+ /**
+ * Refresh visuals.
+ *
+ * @see org.eclipse.papyrus.uml.diagram.common.editparts.UMLNodeEditPart#refreshVisuals()
+ */
@Override
protected void refreshVisuals() {
super.refreshVisuals();
@@ -120,10 +134,55 @@ public abstract class NamedElementEditPart extends UMLNodeEditPart implements IU
refreshLabelDisplay();
refreshLabelMargin();
}
+ }
+
+
+ /**
+ * Refresh name position.
+ */
+ private void refreshNamePosition() {
+ if (getPrimaryShape() instanceof NodeNamedElementFigure) {
+ ((NodeNamedElementFigure) getPrimaryShape()).setNamePosition(getNamePosition());
+ }
+ }
+
+ /**
+ * Gets the name position.
+ *
+ * @return the name position
+ */
+ public int getNamePosition() {
+ // get the value of the CSS property
+ View model = (View) getModel();
+ StringValueStyle labelAlignment = (StringValueStyle) model.getNamedStyle(NotationPackage.eINSTANCE.getStringValueStyle(), NAME_POSITION);
+
+ int textAlignment = 0;
+ if (labelAlignment != null) {
+ if ("left".equals(labelAlignment.getStringValue())) {
+ textAlignment = PositionConstants.LEFT;
+ }
+ if ("right".equals(labelAlignment.getStringValue())) {
+ textAlignment = PositionConstants.RIGHT;
+ }
+ if ("center".equals(labelAlignment.getStringValue())) {
+ textAlignment = PositionConstants.CENTER;
+ }
+ } else {
+ textAlignment = getDefaultNamePosition();
+ }
+ return textAlignment;
}
+ /**
+ * Gets the default name position.
+ *
+ * @return the default name position
+ */
+ protected int getDefaultNamePosition() {
+ return PositionConstants.CENTER;
+ }
/**
* Refresh margin of named element children labels
@@ -132,6 +191,7 @@ public abstract class NamedElementEditPart extends UMLNodeEditPart implements IU
* <li>Get all the children figure</li>
* <li>If the child is a label then apply the margin</li>
* </ul>
+ * .
*/
private void refreshLabelMargin() {
IFigure figure = null;
@@ -167,11 +227,18 @@ public abstract class NamedElementEditPart extends UMLNodeEditPart implements IU
}
+ /**
+ * @see org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart#activate()
+ *
+ */
@Override
public void activate() {
super.activate();
}
+ /**
+ * Refresh label display.
+ */
protected void refreshLabelDisplay() {
View view = getNotationView();
// SVGNodePlate can be null!
@@ -227,6 +294,11 @@ public abstract class NamedElementEditPart extends UMLNodeEditPart implements IU
}
}
+ /**
+ * Gets the node named element figure.
+ *
+ * @return the node named element figure
+ */
private IPapyrusNodeNamedElementFigure getNodeNamedElementFigure() {
return (IPapyrusNodeNamedElementFigure) getPrimaryShape();
}
@@ -248,6 +320,10 @@ public abstract class NamedElementEditPart extends UMLNodeEditPart implements IU
}
}
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.common.editparts.UMLNodeEditPart#createDefaultEditPolicies()
+ *
+ */
@Override
protected void createDefaultEditPolicies() {
super.createDefaultEditPolicies();
@@ -255,6 +331,11 @@ public abstract class NamedElementEditPart extends UMLNodeEditPart implements IU
installEditPolicy(FollowSVGSymbolEditPolicy.FOLLOW_SVG_SYMBOL_EDITPOLICY, new FollowSVGSymbolEditPolicy());
}
+ /**
+ * @see org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderedShapeEditPart#createNodeFigure()
+ *
+ * @return
+ */
@Override
protected NodeFigure createNodeFigure() {
return new SelectableBorderedNodeFigure(createMainFigureWithSVG());
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/RoundedBorderNamedElementEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/RoundedBorderNamedElementEditPart.java
new file mode 100644
index 00000000000..93c1e2ec40f
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/RoundedBorderNamedElementEditPart.java
@@ -0,0 +1,189 @@
+package org.eclipse.papyrus.uml.diagram.common.editparts;
+
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderedShapeEditPart;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IRoundedRectangleFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.helper.PapyrusRoundedEditPartHelper;
+import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.locator.PortPositionLocator;
+
+
+public abstract class RoundedBorderNamedElementEditPart extends BorderNamedElementEditPart {
+
+ /** The port position namedStyle property */
+ private static final String PORT_POSITION = "portPosition";
+
+ /** The Constant DEFAULT_BORDER_STYLE. */
+ private static final int DEFAULT_BORDER_STYLE = Graphics.LINE_SOLID;
+
+ /** The Constant DEFAULT_CORNER_HEIGHT. */
+ private static final int DEFAULT_CORNER_HEIGHT = 0;
+
+ /** The Constant DEFAULT_CORNER_WIDTH. */
+ private static final int DEFAULT_CORNER_WIDTH = 0;
+
+ private static final int[] DEFAULT_CUTOM_DASH = new int[] { 5, 5 };
+
+ /** The Constant DEFAULT_FLOATING_LABEL_OFFSET_HEIGHT. */
+ private static final int DEFAULT_FLOATING_LABEL_OFFSET_HEIGHT = 0;
+
+ /** The Constant DEFAULT_FLOATING_LABEL_OFFSET_WIDTH. */
+ private static final int DEFAULT_FLOATING_LABEL_OFFSET_WIDTH = 0;
+
+ /** The Constant DEFAULT_IS_FLOATING_LABEL_CONSTRAINED. */
+ private static final boolean DEFAULT_IS_FLOATING_LABEL_CONSTRAINED = false;
+
+ /** The Constant DEFAULT_IS_OVAL. */
+ private static final boolean DEFAULT_IS_OVAL = false;
+
+ private static final boolean DEFAULT_USE_ORIGINAL_COLORS = true;
+
+ private static final boolean DEFAULT_HAS_HEADER = false;
+
+ private static final String DEFAULT_PORT_POSITION_VALUE = "onLine";
+
+ /**
+ * Constructor.
+ *
+ * @param view
+ */
+ public RoundedBorderNamedElementEditPart(View view) {
+ super(view);
+ }
+
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart#createDefaultEditPolicies()
+ *
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ // Install Edit Policy to Hide/show compartment, in particular for the symbol compartment
+ installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy());
+ }
+
+ /**
+ * Gets the default border style.
+ *
+ * @return the default border style
+ */
+ protected int getDefaultBorderStyle() {
+ return DEFAULT_BORDER_STYLE;
+ }
+
+ /**
+ * Gets the default corner height value.
+ *
+ * @return the default corner height value
+ */
+ protected int getDefaultCornerHeight() {
+ return DEFAULT_CORNER_HEIGHT;
+ }
+
+
+ /**
+ * Gets the default corner width value.
+ *
+ * @return the default corner width value
+ */
+ protected int getDefaultCornerWidth() {
+ return DEFAULT_CORNER_WIDTH;
+ }
+
+ private int[] getDefaultCutomDash() {
+ return DEFAULT_CUTOM_DASH;
+ }
+
+ /**
+ * Gets the default floating name offset height.
+ *
+ * @return the default floating name offset height
+ */
+ protected int getDefaultFloatingLabelOffsetHeight() {
+ return DEFAULT_FLOATING_LABEL_OFFSET_HEIGHT;
+ }
+
+ /**
+ * Gets the default floating name offset width.
+ *
+ * @return the default floating name offset width
+ */
+ protected int getDefaultFloatingLabelOffsetWidth() {
+ return DEFAULT_FLOATING_LABEL_OFFSET_WIDTH;
+ }
+
+ /**
+ * Gets the default is name constrained.
+ *
+ * @return the default is name constrained
+ */
+ protected boolean getDefaultIsFloatingNameConstrained() {
+ return DEFAULT_IS_FLOATING_LABEL_CONSTRAINED;
+ }
+
+ /**
+ * Gets the default is oval value.
+ *
+ * @return the default is oval value
+ */
+ protected boolean getDefaultIsOvalValue() {
+ return DEFAULT_IS_OVAL;
+ }
+
+ /**
+ * @return
+ */
+ private boolean getDefaultUseOriginalColors() {
+ return DEFAULT_USE_ORIGINAL_COLORS;
+ }
+
+ /**
+ * Refresh visuals.
+ *
+ * @see org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart#refreshVisuals()
+ */
+ @Override
+ protected void refreshVisuals() {
+ PapyrusRoundedEditPartHelper.refreshRadius(this, getDefaultCornerWidth(), getDefaultCornerHeight());
+ PapyrusRoundedEditPartHelper.refreshOval(this, getDefaultIsOvalValue());
+ PapyrusRoundedEditPartHelper.refreshFloatingName(this, getDefaultIsFloatingNameConstrained(), getDefaultFloatingLabelOffsetWidth(), getDefaultFloatingLabelOffsetHeight());
+ PapyrusRoundedEditPartHelper.refreshBorderStyle(this, getDefaultBorderStyle(), getDefaultCutomDash());
+ PapyrusRoundedEditPartHelper.refreshSVGOriginalColors(this, getDefaultUseOriginalColors());
+ PapyrusRoundedEditPartHelper.refreshHasHeader(this, getDefaultHasHeader());
+ refreshPortPosition();
+ super.refreshVisuals();
+ }
+
+ /**
+ * Refresh the port position
+ */
+ private void refreshPortPosition() {
+ if (getPrimaryShape() instanceof IRoundedRectangleFigure) {
+ if (getModel() instanceof View) {
+ Object constraint = ((AbstractBorderedShapeEditPart) getParent()).getBorderedFigure().getBorderItemContainer().getLayoutManager().getConstraint(getFigure());
+ if (constraint instanceof PortPositionLocator) {
+ PortPositionLocator portLocator = (PortPositionLocator) constraint;
+ String position = NotationUtils.getStringValue((View) getModel(), PORT_POSITION, "onLine");
+ portLocator.setPortPosition(position);
+ }
+ }
+ }
+ }
+
+ /**
+ * get the default Port Position(can be inside, outside or onLine).
+ */
+ protected String getDefaultPortPosition() {
+ return DEFAULT_PORT_POSITION_VALUE;
+ }
+
+ /**
+ * @return
+ */
+ protected boolean getDefaultHasHeader() {
+ return DEFAULT_HAS_HEADER;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/RoundedCompartmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/RoundedCompartmentEditPart.java
new file mode 100644
index 00000000000..281df051d41
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/RoundedCompartmentEditPart.java
@@ -0,0 +1,180 @@
+/*****************************************************************************
+ * Copyright (c) 2010, 2014 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.common.editparts;
+
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.common.helper.PapyrusRoundedEditPartHelper;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
+
+/**
+ * The Class RoundedCompartmentEditPart.
+ */
+public abstract class RoundedCompartmentEditPart extends NamedElementEditPart {
+
+ /** The Constant DEFAULT_HAS_HEADER. True if has a header, as interaction figure */
+ private static final boolean DEFAULT_HAS_HEADER = false;
+
+ /** The Constant DEFAULT_BORDER_STYLE. */
+ private static final int DEFAULT_BORDER_STYLE = Graphics.LINE_SOLID;
+
+ /** The Constant DEFAULT_CORNER_HEIGHT. */
+ private static final int DEFAULT_CORNER_HEIGHT = 0;
+
+ /** The Constant DEFAULT_CORNER_WIDTH. */
+ private static final int DEFAULT_CORNER_WIDTH = 0;
+
+ private static final int[] DEFAULT_CUTOM_DASH = new int[] { 5, 5 };
+
+ /** The Constant DEFAULT_FLOATING_LABEL_OFFSET_HEIGHT. */
+ private static final int DEFAULT_FLOATING_LABEL_OFFSET_HEIGHT = 0;
+
+ /** The Constant DEFAULT_FLOATING_LABEL_OFFSET_WIDTH. */
+ private static final int DEFAULT_FLOATING_LABEL_OFFSET_WIDTH = 0;
+
+ /** The Constant DEFAULT_IS_FLOATING_LABEL_CONSTRAINED. */
+ private static final boolean DEFAULT_IS_FLOATING_LABEL_CONSTRAINED = false;
+
+ /** The Constant DEFAULT_IS_OVAL. */
+ private static final boolean DEFAULT_IS_OVAL = false;
+
+ /** The Constant DEFAULT_USE_ORIGINAL_COLORS. */
+ private static final boolean DEFAULT_USE_ORIGINAL_COLORS = true;
+
+ /**
+ * Instantiates a new rounded compartment edit part.
+ *
+ * @param view
+ * the view
+ */
+ public RoundedCompartmentEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * Creates the default edit policies.
+ *
+ * @see org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart#createDefaultEditPolicies()
+ */
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ // Install Edit Policy to Hide/show compartment, in particular for the symbol compartment
+ installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy());
+ }
+
+ /**
+ * Gets the default border style.
+ *
+ * @return the default border style
+ */
+ protected int getDefaultBorderStyle() {
+ return DEFAULT_BORDER_STYLE;
+ }
+
+ /**
+ * Gets the default corner height value.
+ *
+ * @return the default corner height value
+ */
+ protected int getDefaultCornerHeight() {
+ return DEFAULT_CORNER_HEIGHT;
+ }
+
+ /**
+ * Gets the default corner width value.
+ *
+ * @return the default corner width value
+ */
+ protected int getDefaultCornerWidth() {
+ return DEFAULT_CORNER_WIDTH;
+ }
+
+ /**
+ * Gets the default cutom dash.
+ *
+ * @return the default cutom dash
+ */
+ private int[] getDefaultCutomDash() {
+ return DEFAULT_CUTOM_DASH;
+ }
+
+ /**
+ * Gets the default floating name offset height.
+ *
+ * @return the default floating name offset height
+ */
+ protected int getDefaultFloatingLabelOffsetHeight() {
+ return DEFAULT_FLOATING_LABEL_OFFSET_HEIGHT;
+ }
+
+ /**
+ * Gets the default floating name offset width.
+ *
+ * @return the default floating name offset width
+ */
+ protected int getDefaultFloatingLabelOffsetWidth() {
+ return DEFAULT_FLOATING_LABEL_OFFSET_WIDTH;
+ }
+
+ /**
+ * Gets the default is name constrained.
+ *
+ * @return the default is name constrained
+ */
+ protected boolean getDefaultIsFloatingNameConstrained() {
+ return DEFAULT_IS_FLOATING_LABEL_CONSTRAINED;
+ }
+
+ /**
+ * Gets the default is oval value.
+ *
+ * @return the default is oval value
+ */
+ protected boolean getDefaultIsOvalValue() {
+ return DEFAULT_IS_OVAL;
+ }
+
+ /**
+ * Gets the default setting of use original colors.
+ *
+ * @return the default use original colors
+ */
+ protected boolean getDefaultUseOriginalColors() {
+ return DEFAULT_USE_ORIGINAL_COLORS;
+ }
+
+ /**
+ * Refresh visuals.
+ *
+ * @see org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart#refreshVisuals()
+ */
+ @Override
+ protected void refreshVisuals() {
+ // Refresh all visual settings for the Rounded Compartment Figure child
+ PapyrusRoundedEditPartHelper.refreshRadius(this, getDefaultCornerWidth(), getDefaultCornerHeight());
+ PapyrusRoundedEditPartHelper.refreshOval(this, getDefaultIsOvalValue());
+ PapyrusRoundedEditPartHelper.refreshFloatingName(this, getDefaultIsFloatingNameConstrained(), getDefaultFloatingLabelOffsetWidth(), getDefaultFloatingLabelOffsetHeight());
+ PapyrusRoundedEditPartHelper.refreshBorderStyle(this, getDefaultBorderStyle(), getDefaultCutomDash());
+ PapyrusRoundedEditPartHelper.refreshSVGOriginalColors(this, getDefaultUseOriginalColors());
+ PapyrusRoundedEditPartHelper.refreshHasHeader(this, getDefaultHasHeader());
+ super.refreshVisuals();
+ }
+
+ /**
+ * @return
+ */
+ protected boolean getDefaultHasHeader() {
+ return DEFAULT_HAS_HEADER;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/BorderItemResizableEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/BorderItemResizableEditPolicy.java
index b259fe07015..44cd007701d 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/BorderItemResizableEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/BorderItemResizableEditPolicy.java
@@ -96,6 +96,7 @@ public class BorderItemResizableEditPolicy extends ResizableShapeEditPolicy {
rect.resize(request.getSizeDelta());
getHostFigure().translateToRelative(rect);
Rectangle realLocation = borderItemLocator.getValidLocation(rect.getCopy(), borderItemEP.getFigure());
+ realLocation.translate(-borderItemEP.getFigure().getSize().width / 2, -borderItemEP.getFigure().getSize().height / 2);
getHostFigure().translateToAbsolute(realLocation);
feedback.translateToRelative(realLocation);
feedback.setBounds(realLocation);
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/ConstrainedItemBorderLayoutEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/ConstrainedItemBorderLayoutEditPolicy.java
index 7eeb8b7b31e..d172be41470 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/ConstrainedItemBorderLayoutEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/ConstrainedItemBorderLayoutEditPolicy.java
@@ -33,6 +33,7 @@ import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages;
import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.editparts.FloatingLabelEditPart;
/**
* @author Patrick Tessier
@@ -65,7 +66,7 @@ public class ConstrainedItemBorderLayoutEditPolicy extends ConstrainedLayoutEdit
*/
@Override
protected EditPolicy createChildEditPolicy(EditPart child) {
- if (child instanceof IBorderItemEditPart) {
+ if ((child instanceof IBorderItemEditPart) && !(child instanceof FloatingLabelEditPart)) {
// return new BorderItemSelectionEditPolicy();
return new BorderItemResizableEditPolicy();
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/MaskManagedFloatingLabelEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/MaskManagedFloatingLabelEditPolicy.java
new file mode 100644
index 00000000000..40e1d1ebd95
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/MaskManagedFloatingLabelEditPolicy.java
@@ -0,0 +1,248 @@
+/*****************************************************************************
+ * Copyright (c) 2010, 2014 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.common.editpolicies;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Map;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.Activator;
+import org.eclipse.papyrus.uml.diagram.common.helper.FloatingLabelHelper;
+import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance;
+import org.eclipse.uml2.uml.InstanceSpecification;
+import org.eclipse.uml2.uml.MultiplicityElement;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Operation;
+import org.eclipse.uml2.uml.Parameter;
+import org.eclipse.uml2.uml.Port;
+import org.eclipse.uml2.uml.Signal;
+import org.eclipse.uml2.uml.TypedElement;
+import org.eclipse.uml2.uml.UMLPackage;
+
+// TODO: Auto-generated Javadoc
+/**
+ * Specific edit policy for label displaying stereotypes and their properties for edges representing
+ * UML elements.
+ */
+public class MaskManagedFloatingLabelEditPolicy extends AbstractMaskManagedEditPolicy {
+
+ /**
+ * Creates a new PropertyLabelEditPolicy.
+ */
+ public MaskManagedFloatingLabelEditPolicy() {
+ super();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addAdditionalListeners() {
+ super.addAdditionalListeners();
+ NamedElement umlElement = getUMLElement();
+ // check host semantic element is not null
+ if (umlElement == null) {
+ Activator.log.error("No semantic element present when adding listeners in FloatingLabelEditPolicy", null);
+ return;
+ }
+ // adds a listener to the element itself, and to linked elements, like Type
+ if (umlElement instanceof TypedElement) {
+ if (((TypedElement) umlElement).getType() != null) {
+ getDiagramEventBroker().addNotificationListener(((TypedElement) umlElement).getType(), this);
+ }
+ }
+ if (umlElement instanceof MultiplicityElement) {
+ getDiagramEventBroker().addNotificationListener(((MultiplicityElement) umlElement).getUpperValue(), this);
+ getDiagramEventBroker().addNotificationListener(((MultiplicityElement) umlElement).getLowerValue(), this);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Collection<String> getDefaultDisplayValue() {
+ NamedElement umlElement = getUMLElement();
+ if (umlElement != null) {
+
+ /**
+ * default uml operation display.
+ */
+ if (umlElement instanceof Operation) {
+ return ICustomAppearance.DEFAULT_UML_OPERATION;
+ }
+
+ /**
+ * default uml Port ins composite diagrams.
+ */
+ if (umlElement instanceof Port) {
+ return ICustomAppearance.DEFAULT_UML_PORT;
+ }
+
+ /**
+ * default uml Parameter in composite diagrams.
+ */
+ if (umlElement instanceof Parameter) {
+ return ICustomAppearance.DEFAULT_UML_PARAMETER;
+ }
+
+ /**
+ * default uml instancespecification .
+ */
+ if (umlElement instanceof InstanceSpecification) {
+ return ICustomAppearance.DEFAULT_UML_INSTANCESPECIFICATION;
+ }
+
+ /**
+ * default uml Signal .
+ */
+ if (umlElement instanceof Signal) {
+ return Arrays.asList(ICustomAppearance.DISP_NAME, ICustomAppearance.DISP_TYPE);
+ }
+
+ }
+ return ICustomAppearance.DEFAULT_UML_FLOATING_LABEL;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Map<String, String> getMasks() {
+ return FloatingLabelHelper.getInstance().getMasks();
+ }
+
+ /**
+ * {@inheritedDoc}.
+ *
+ * @return the UML element
+ */
+ @Override
+ public NamedElement getUMLElement() {
+ EObject element = super.getUMLElement();
+ if (element instanceof NamedElement) {
+ return (NamedElement) element;
+ }
+ return null;
+ }
+
+ /**
+ * {@inheritedDoc}.
+ *
+ * @param notification
+ * the notification
+ */
+ @Override
+ public void notifyChanged(Notification notification) {
+ super.notifyChanged(notification);
+ // change the label of the figure managed by the host edit part (managed by the parent edit
+ // part in general...)
+ // it must be changed only if:
+ // - the annotation corresponding to the display of the stereotype changes
+ // - the stereotype application list has changed
+ Object object = notification.getNotifier();
+ NamedElement property = getUMLElement();
+ if (object == null || property == null) {
+ return;
+ }
+ if (notification.getFeature().equals(UMLPackage.eINSTANCE.getLiteralInteger_Value())) {
+ refreshDisplay();
+ } else if (notification.getFeature().equals(UMLPackage.eINSTANCE.getLiteralUnlimitedNatural_Value())) {
+ refreshDisplay();
+ }
+ if (object.equals(property)) {
+ notifyNamedElementChanged(property, notification);
+ }
+ if (isMaskManagedAnnotation(object)) {
+ refreshDisplay();
+ }
+ if (isRemovedMaskManagedLabelAnnotation(object, notification)) {
+ refreshDisplay();
+ }
+ }
+
+ /**
+ * notifies that the named element has changed.
+ *
+ * @param namedElement
+ * the property that has changed
+ * @param notification
+ * the notification send when the element has been changed
+ */
+ protected void notifyNamedElementChanged(NamedElement namedElement, Notification notification) {
+ switch (notification.getFeatureID(NamedElement.class)) {
+ case UMLPackage.NAMED_ELEMENT__NAME:
+ refreshDisplay();
+ break;
+ case UMLPackage.NAMED_ELEMENT__VISIBILITY:
+ refreshDisplay();
+ break;
+ default:
+ // does nothing in other cases
+ break;
+ }
+ }
+
+ /**
+ * Returns the view controlled by the host edit part.
+ *
+ * @return the view controlled by the host edit part
+ */
+ @Override
+ protected View getView() {
+ if (getHost().getModel() instanceof View) {
+ if (((View) getHost().getModel()).eContainer() instanceof View) {
+ return (View) ((View) getHost().getModel()).eContainer();
+ }
+ return null;
+ }
+ return null;
+ }
+
+
+ /**
+ * Refreshes the display of the edit part.
+ */
+ @Override
+ public void refreshDisplay() {
+ // calls the helper for this edit Part
+ FloatingLabelHelper.getInstance().refreshEditPartDisplay((GraphicalEditPart) getHost());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void removeAdditionalListeners() {
+ super.removeAdditionalListeners();
+ NamedElement umlElement = getUMLElement();
+ if (umlElement == null) {
+ // check semantic element is not null and this is really an instance of NamedElement
+ return;
+ }
+ // remove listener to the element itself, and to linked elements, like Type
+ if (umlElement instanceof TypedElement) {
+ if (((TypedElement) umlElement).getType() != null) {
+ getDiagramEventBroker().removeNotificationListener(((TypedElement) umlElement).getType(), this);
+ }
+ }
+ if (umlElement instanceof MultiplicityElement) {
+ getDiagramEventBroker().removeNotificationListener(((MultiplicityElement) umlElement).getUpperValue(), this);
+ getDiagramEventBroker().removeNotificationListener(((MultiplicityElement) umlElement).getLowerValue(), this);
+ }
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/AffixedNamedElementFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/AffixedNamedElementFigure.java
index 4ab975e0ff3..d6bc4b26b68 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/AffixedNamedElementFigure.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/AffixedNamedElementFigure.java
@@ -24,7 +24,7 @@ import org.eclipse.swt.graphics.Image;
* Figure for Affixed NamedElement representation. The name label is shown as an
* external label.
*/
-public class AffixedNamedElementFigure extends NodeNamedElementFigure {
+public class AffixedNamedElementFigure extends RoundedCompartmentFigure {
/** Container for icon (stereotype icon) */
// protected ScalableImageFigure icon;
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/AutomaticCompartmentLayoutManager.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/AutomaticCompartmentLayoutManager.java
index 56d18cb91b9..9baab5ce45e 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/AutomaticCompartmentLayoutManager.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/AutomaticCompartmentLayoutManager.java
@@ -80,6 +80,7 @@ public class AutomaticCompartmentLayoutManager extends AbstractLayout {
collectInformation(container);
int minimumWith = 0;
int minimumHeight = 0;
+ // CompartementFigure shall be replace by RoundedCompartmentFigure and this condition may be remove
if (container instanceof CompartmentFigure) {
CompartmentFigure cf = (CompartmentFigure) container;
WrappingLabel wl = cf.getNameLabel();
@@ -90,11 +91,25 @@ public class AutomaticCompartmentLayoutManager extends AbstractLayout {
}
}
}
+ if (container instanceof RoundedCompartmentFigure) {
+ RoundedCompartmentFigure cf = (RoundedCompartmentFigure) container;
+ WrappingLabel wl = cf.getNameLabel();
+ // display name
+ if (wl != null && container.getChildren().contains(wl)) {
+ if (wl.getPreferredSize().width > minimumWith) {
+ minimumWith = wl.getPreferredSize().width + 2;
+ }
+ }
+
+ }
if (!visibleCompartments.isEmpty()) {
for (Object o : container.getChildren()) {
- IFigure child = (IFigure) o;
- minimumHeight += child.getPreferredSize().height;
- minimumWith = Math.max(minimumWith, child.getPreferredSize().width);
+ //only for child which are compartment
+ if (o instanceof ResizableCompartmentFigure) {
+ IFigure child = (IFigure) o;
+ minimumHeight += child.getPreferredSize().height;
+ minimumWith = Math.max(minimumWith, child.getPreferredSize().width);
+ }
}
} else {
for (IFigure child : visibleOthers) {
@@ -112,7 +127,7 @@ public class AutomaticCompartmentLayoutManager extends AbstractLayout {
*/
@Override
public Dimension getMinimumSize(IFigure container, int wHint, int hHint) {
- return new Dimension(20, 20);
+ return new Dimension(10, 10);
}
/**
@@ -180,16 +195,15 @@ public class AutomaticCompartmentLayoutManager extends AbstractLayout {
}
if (previous != null) {
bound.y = previous.getBounds().getBottomLeft().y + 1;
- bound.x = container.x + 3;
+ bound.x = container.x + 1;
bound.width = container.width;
} else {
- bound.x = container.x + 3;
+ bound.x = container.x + 1;
// in the case where the content is grater than the container
// it is forbidden to change the y coordinate
if (((container.height - totalHeight) / 2) > 0) {
bound.y = container.y + ((container.height - totalHeight) / 2);
- }
- else {
+ } else {
bound.y = container.y;
}
bound.width = container.width;
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/ClassFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/ClassFigure.java
new file mode 100644
index 00000000000..b23752b2da0
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/ClassFigure.java
@@ -0,0 +1,93 @@
+/*****************************************************************************
+ * Copyright (c) 2008 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.common.figure.node;
+
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+
+/**
+ * Represents a class.
+ */
+public class ClassFigure extends ClassifierFigure {
+
+ protected static final int SPACE_FOR_ACTIVE_CLASS = 4;
+
+ /* to present the class as an active class */
+ /** The active. Default value is false */
+ private boolean active = false;
+
+ /**
+ * Default Constructor
+ */
+ public ClassFigure() {
+ this(null);
+ }
+
+ /**
+ * Create a new Classifier figure with the given tag
+ *
+ * @param tagLabel
+ * a String that will be displayed at the top of the figure
+ */
+ public ClassFigure(String tagLabel) {
+ super(tagLabel);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void paint(Graphics graphics) {
+ super.paint(graphics);
+ if(active) {
+ Rectangle rect = this.getBounds();
+ graphics.pushState();
+ graphics.setForegroundColor(getForegroundColor());
+ // do not forget to set line width to 1, if not the color will
+ // change because of the anti-aliasing
+ graphics.setLineWidth(1);
+
+ graphics.drawLine(new Point(rect.x + SPACE_FOR_ACTIVE_CLASS, rect.y), new Point(rect.x + SPACE_FOR_ACTIVE_CLASS, rect.y + rect.height - 1));
+ graphics.drawLine(new Point(rect.x - SPACE_FOR_ACTIVE_CLASS - 1 + rect.width, rect.y), new Point(rect.x - SPACE_FOR_ACTIVE_CLASS - 1 + rect.width, rect.y + rect.height - 1));
+ graphics.setBackgroundColor(getBackgroundColor());
+ graphics.setForegroundColor(getBackgroundColor());
+ graphics.setLineWidth(3);
+
+ graphics.drawLine(new Point(rect.x + 2, rect.y + 1), new Point(rect.x + 2, rect.y + rect.height - 2));
+ graphics.drawLine(new Point(rect.x - 3 + rect.width, rect.y + 1), new Point(rect.x - 3 + rect.width, rect.y + rect.height - 2));
+
+ graphics.popState();
+ }
+ }
+
+ /**
+ * Checks if is active.
+ *
+ * @return true, if is active
+ */
+ // @unused
+ public boolean isActive() {
+ return active;
+ }
+
+ /**
+ * Set the active
+ *
+ * @param active
+ */
+ public void setActive(boolean active) {
+ this.active = active;
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/ClassifierFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/ClassifierFigure.java
index d45a9be93dd..d2621553b3c 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/ClassifierFigure.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/ClassifierFigure.java
@@ -9,6 +9,7 @@
*
* Contributors:
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ * Mickaël ADAM (ALL4TEC) - mickael.adam@all4tec.net - moved class behavior to classEditPart
*
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.figure.node;
@@ -16,21 +17,12 @@ package org.eclipse.papyrus.uml.diagram.common.figure.node;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
/**
* Represents a classifier.
*/
-public class ClassifierFigure extends CompartmentFigure {
-
- protected static final int SPACE_FOR_ACTIVE_CLASS = 4;
-
- /* to present the class as an active class */
- /** The active. Default value is false */
- private boolean active = false;
+public class ClassifierFigure extends RoundedCompartmentFigure {
/** The Attribute Compartment */
private final static String ATTRIBUTE_COMPARTMENT = "attributeCompartment";
@@ -70,33 +62,6 @@ public class ClassifierFigure extends CompartmentFigure {
}
/**
- * {@inheritDoc}
- */
- @Override
- public void paint(Graphics graphics) {
- super.paint(graphics);
- if (active) {
- Rectangle rect = this.getBounds();
- graphics.pushState();
- graphics.setForegroundColor(getForegroundColor());
- // do not forget to set line width to 1, if not the color will
- // change because of the anti-aliasing
- graphics.setLineWidth(1);
-
- graphics.drawLine(new Point(rect.x + SPACE_FOR_ACTIVE_CLASS, rect.y), new Point(rect.x + SPACE_FOR_ACTIVE_CLASS, rect.y + rect.height - 1));
- graphics.drawLine(new Point(rect.x - SPACE_FOR_ACTIVE_CLASS - 1 + rect.width, rect.y), new Point(rect.x - SPACE_FOR_ACTIVE_CLASS - 1 + rect.width, rect.y + rect.height - 1));
- graphics.setBackgroundColor(getBackgroundColor());
- graphics.setForegroundColor(getBackgroundColor());
- graphics.setLineWidth(3);
-
- graphics.drawLine(new Point(rect.x + 2, rect.y + 1), new Point(rect.x + 2, rect.y + rect.height - 2));
- graphics.drawLine(new Point(rect.x - 3 + rect.width, rect.y + 1), new Point(rect.x - 3 + rect.width, rect.y + rect.height - 2));
-
- graphics.popState();
- }
- }
-
- /**
* Get the attribute's compartment figure
*
* @return
@@ -123,23 +88,4 @@ public class ClassifierFigure extends CompartmentFigure {
return getCompartment(NESTEDCLASSIFIER_COMPARTMENT);
}
- /**
- * Checks if is active.
- *
- * @return true, if is active
- */
- // @unused
- public boolean isActive() {
- return active;
- }
-
- /**
- * Set the active
- *
- * @param active
- */
- public void setActive(boolean active) {
- this.active = active;
- }
-
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/DataTypeFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/DataTypeFigure.java
index d7d2f0f6467..5477952b98f 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/DataTypeFigure.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/DataTypeFigure.java
@@ -21,7 +21,7 @@ import org.eclipse.draw2d.IFigure;
/**
* Represents a datatype
*/
-public class DataTypeFigure extends CompartmentFigure {
+public class DataTypeFigure extends RoundedCompartmentFigure {
/** Attribute Compartment */
private final static String ATTRIBUTE_COMPARTMENT = "attributeCompartment";
@@ -33,7 +33,6 @@ public class DataTypeFigure extends CompartmentFigure {
private final static List<String> COMPARTMENT = new ArrayList<String>() {
private static final long serialVersionUID = -2841645169151618170L;
-
{
add(ATTRIBUTE_COMPARTMENT);
add(OPERATION_COMPARTMENT);
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/DependencyNodeFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/DependencyNodeFigure.java
index 235afd59e0d..1ea31b61d27 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/DependencyNodeFigure.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/DependencyNodeFigure.java
@@ -18,6 +18,7 @@ import org.eclipse.draw2d.geometry.Rectangle;
/**
* this figure is fill circle
*/
+// TODO: use rounded compartment figure instead with CSS square.
public class DependencyNodeFigure extends PapyrusNodeFigure {
/**
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/EnumerationFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/EnumerationFigure.java
index 3c4f4af5314..06c364866c0 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/EnumerationFigure.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/EnumerationFigure.java
@@ -21,7 +21,7 @@ import org.eclipse.draw2d.IFigure;
/**
* Represents an enumeration
*/
-public class EnumerationFigure extends CompartmentFigure {
+public class EnumerationFigure extends RoundedCompartmentFigure {
/** The Literals Compartment */
private static final String LITERALS_COMPARTMENT = "literalsCompartment";
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/FinalNode.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/FinalNode.java
index 863fd653caf..c4eef3a9724 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/FinalNode.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/FinalNode.java
@@ -25,6 +25,7 @@ import org.eclipse.swt.graphics.Image;
* this figure is a final node a circle into a circle
*
*/
+// unused! to delete
public class FinalNode extends PapyrusNodeFigure implements IPapyrusNodeUMLElementFigure {
/**
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/FlowFinalNode.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/FlowFinalNode.java
index 3e159c2645b..59e6b630fe6 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/FlowFinalNode.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/FlowFinalNode.java
@@ -28,6 +28,7 @@ import org.eclipse.swt.graphics.Image;
*
* this figure is a circle with cross
*/
+// Unused: To delete
public class FlowFinalNode extends PapyrusNodeFigure implements IPapyrusNodeUMLElementFigure {
/**
* {@inheritDoc}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/ForkNode.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/ForkNode.java
index 2a6e02f03a6..7dd9e8a0cfb 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/ForkNode.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/ForkNode.java
@@ -13,29 +13,24 @@
*/
package org.eclipse.papyrus.uml.diagram.common.figure.node;
-import org.eclipse.draw2d.Border;
-import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Insets;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gmf.runtime.draw2d.ui.graphics.ColorRegistry;
-import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
/**
* this figure is small rectangle
*
*/
-public class ForkNode extends PapyrusNodeFigure implements IPapyrusNodeUMLElementFigure {
+// Unused: to delete
+public class ForkNode extends RoundedCompartmentFigure implements IPapyrusNodeUMLElementFigure {
- /**
- * {@inheritDoc}
- */
- @Override
- protected Border getDefaultBorder(Color borderColor) {
- return null;
- }
+ // /**
+ // * {@inheritDoc}
+ // */
+ // @Override
+ // protected Border getDefaultBorder(Color borderColor) {
+ // return null;
+ // }
/**
* {@inheritDoc}
@@ -45,23 +40,23 @@ public class ForkNode extends PapyrusNodeFigure implements IPapyrusNodeUMLElemen
return new Dimension(10, 10);
}
- /**
- * {@inheritDoc}
- */
- @Override
- public void paintFigure(Graphics graphics) {
- Rectangle r = getBounds().getCopy().crop(new Insets(0, 0, 1, 1));
- if (isUsingGradient()) {
- graphics.setBackgroundColor(ColorRegistry.getInstance().getColor(getGradientColor2()));
- // graphics.setForegroundColor(ColorRegistry.getInstance().getColor(getGradientColor2()));
- } else {
- graphics.setBackgroundColor(getBackgroundColor());
- // graphics.setForegroundColor(getForegroundColor());
- }
- graphics.fillRectangle(r);
- graphics.setLineWidth(1);
- graphics.drawRectangle(r);
- }
+ // /**
+ // * {@inheritDoc}
+ // */
+ // @Override
+ // public void paintFigure(Graphics graphics) {
+ // Rectangle r = getBounds().getCopy().crop(new Insets(0, 0, 1, 1));
+ // if (isUsingGradient()) {
+ // graphics.setBackgroundColor(ColorRegistry.getInstance().getColor(getGradientColor2()));
+ // // graphics.setForegroundColor(ColorRegistry.getInstance().getColor(getGradientColor2()));
+ // } else {
+ // graphics.setBackgroundColor(getBackgroundColor());
+ // // graphics.setForegroundColor(getForegroundColor());
+ // }
+ // graphics.fillRectangle(r);
+ // graphics.setLineWidth(1);
+ // graphics.drawRectangle(r);
+ // }
/**
* {@inheritDoc}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/InitialNode.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/InitialNode.java
index 42448634406..b29ba5fd5ed 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/InitialNode.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/InitialNode.java
@@ -23,6 +23,7 @@ import org.eclipse.swt.graphics.Image;
/**
* this figure is fill circle
*/
+// Unused: to delete
public class InitialNode extends PapyrusNodeFigure implements IPapyrusNodeUMLElementFigure {
/**
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/InstanceSpecificationFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/InstanceSpecificationFigure.java
index 9da171728bd..ca92ee9a20a 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/InstanceSpecificationFigure.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/InstanceSpecificationFigure.java
@@ -21,7 +21,7 @@ import org.eclipse.draw2d.RectangleFigure;
/**
* Represents an InstanceSpecification.
*/
-public class InstanceSpecificationFigure extends CompartmentFigure {
+public class InstanceSpecificationFigure extends RoundedCompartmentFigure {
/** Slot Compartment */
private static final String SLOT_COMPARTMENT = "slotCompartment";
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/NodeNamedElementFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/NodeNamedElementFigure.java
index f6e0bf356f4..0767b6fbaa3 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/NodeNamedElementFigure.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/NodeNamedElementFigure.java
@@ -80,6 +80,8 @@ public class NodeNamedElementFigure extends PapyrusNodeFigure implements IPapyru
*/
protected Label stereotypesLabel;
+ private int namePosition = PositionConstants.MIDDLE;
+
/**
* Create a basic figure.
*/
@@ -161,22 +163,33 @@ public class NodeNamedElementFigure extends PapyrusNodeFigure implements IPapyru
* Create a label that contains the name of the element.
*/
protected void createNameLabel() {
-
+
nameLabel = new PapyrusWrappingLabel();
nameLabel.setOpaque(false);
- nameLabel.setAlignment(PositionConstants.MIDDLE);
+ nameLabel.setAlignment(namePosition);
getNameLabelContainer().add(nameLabel, getNameLabelConstraint(), -1);
}
+ /**
+ * @param namePosition
+ * the labelAlignment to set
+ */
+ public void setNamePosition(int namePosition) {
+ this.namePosition = namePosition;
+ }
+
@Override
public void restoreNameLabel() {
nameLabel.setOpaque(false);
- nameLabel.setAlignment(PositionConstants.MIDDLE);
+ nameLabel.setAlignment(namePosition);
getNameLabelContainer().add(nameLabel, getNameLabelConstraint(), getNameLabelPosition());
}
+
+
+
/**
* Create a label that contains the name of the element.
*/
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/PapyrusNodeFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/PapyrusNodeFigure.java
index 58712ab9b80..c7a8e29044c 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/PapyrusNodeFigure.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/PapyrusNodeFigure.java
@@ -41,7 +41,7 @@ public class PapyrusNodeFigure extends NodeFigure implements IPapyrusNodeFigure
/**
* The shadow
*/
- private boolean shadow = true;
+ private boolean shadow = false;
/** Default custom dash values */
public static final int[] DEFAULT_CUSTOM_DASH = { 5, 5 };
@@ -220,7 +220,7 @@ public class PapyrusNodeFigure extends NodeFigure implements IPapyrusNodeFigure
/**
* <pre>
* This figure manages the border representation with custom dashes.
- *
+ *
* {@inheritDoc}
* </pre>
*/
@@ -236,7 +236,7 @@ public class PapyrusNodeFigure extends NodeFigure implements IPapyrusNodeFigure
/**
* <pre>
* This method propagates the new line style to the border
- *
+ *
* @see org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure#setLineStyle(int)
* </pre>
*
@@ -255,7 +255,7 @@ public class PapyrusNodeFigure extends NodeFigure implements IPapyrusNodeFigure
/**
* <pre>
* This method propagates the new line width to the border
- *
+ *
* @see org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure#setLineWidth(int)
* </pre>
*
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/PrimitiveTypeFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/PrimitiveTypeFigure.java
index 9d44b9de98d..ad59c98e29f 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/PrimitiveTypeFigure.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/PrimitiveTypeFigure.java
@@ -22,7 +22,7 @@ import org.eclipse.draw2d.IFigure;
/**
* Represents a Primitive Type
*/
-public class PrimitiveTypeFigure extends CompartmentFigure {
+public class PrimitiveTypeFigure extends RoundedCompartmentFigure {
/** Attribute Compartment */
private final static String ATTRIBUTE_COMPARTMENT = "attributeCompartment";
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/RoundedCompartmentFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/RoundedCompartmentFigure.java
new file mode 100644
index 00000000000..036c9d1679c
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/RoundedCompartmentFigure.java
@@ -0,0 +1,404 @@
+/*****************************************************************************
+ * Copyright (c) 2010, 2014 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.common.figure.node;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.RectangleFigure;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Insets;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.PointList;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.RoundedRectangleBorder;
+import org.eclipse.gmf.runtime.draw2d.ui.graphics.ColorRegistry;
+import org.eclipse.gmf.runtime.notation.GradientStyle;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IRoundedRectangleFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.RoundedRectangleShadowBorder;
+
+/**
+ * A rectangular figure that supports compartment.
+ */
+public class RoundedCompartmentFigure extends NodeNamedElementFigure implements IRoundedRectangleFigure {
+
+ /** The container figures. */
+ private Map<String, RectangleFigure> containerFigures;
+
+ /** The corner dimension. */
+ protected Dimension cornerDimension = new Dimension();
+
+ /** True if the figure is oval. */
+ protected boolean isOval = false;
+
+ /** The is label constrained. */
+ protected boolean isLabelConstrained = false;
+
+ /** The floating name offset. */
+ protected Dimension floatingNameOffset = new Dimension();
+
+ /** The border style. */
+ protected int borderStyle = Graphics.LINE_SOLID;
+
+ /** True if the figure has header. */
+ private boolean hasHeader = false;
+
+ /**
+ * @param borderStyle
+ * the borderStyle to set
+ */
+ public void setBorderStyle(int borderStyle) {
+ this.borderStyle = borderStyle;
+ if (shadowborder != null) {
+ shadowborder.setStyle(borderStyle);
+ }
+ }
+
+ /**
+ * Instantiates a new rounded compartment figure.
+ */
+ public RoundedCompartmentFigure() {
+ this(null, null);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param compartmentFigure
+ * the compartment figure
+ */
+ public RoundedCompartmentFigure(List<String> compartmentFigure) {
+ this(compartmentFigure, null);
+ }
+
+ /**
+ * Constructor with a tagged value.
+ *
+ * @param compartmentFigure
+ * a list of id for the compartment figure
+ * @param taggedLabelValue
+ * the value to display as tagged value
+ */
+ public RoundedCompartmentFigure(List<String> compartmentFigure, String taggedLabelValue) {
+ super(taggedLabelValue);
+ setOpaque(false);
+ shadowborder = new RoundedRectangleShadowBorder(getForegroundColor(), cornerDimension);
+ setLayoutManager(new AutomaticCompartmentLayoutManager());
+ if (compartmentFigure != null) {
+ createContentPane(compartmentFigure);
+ }
+ }
+
+ /**
+ * Creates the content pane.
+ *
+ * @param compartmentFigure
+ * the compartment figure
+ */
+ protected void createContentPane(List<String> compartmentFigure) {
+ containerFigures = new HashMap<String, RectangleFigure>();
+ for (String id : compartmentFigure) {
+ RectangleFigure newFigure = new RectangleFigure();
+ newFigure.setLayoutManager(new SubCompartmentLayoutManager());
+ // to debug graphically: newFigure.setFill(true);
+ newFigure.setFill(false);
+ newFigure.setBorder(null);
+ newFigure.setOutline(false);
+ newFigure.setOpaque(false);
+ this.add(newFigure);
+ containerFigures.put(id, newFigure);
+ }
+ }
+
+ /**
+ * Get the RectangleFigure containing the wanted compartment.
+ *
+ * @param id
+ * the id to find the right compartment
+ * @return the RectangleFigure
+ */
+ public RectangleFigure getCompartment(String id) {
+ return containerFigures.get(id);
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IRoundedRectangleFigure#getCornerDimensions()
+ *
+ * @return
+ */
+ @Override
+ public Dimension getCornerDimensions() {
+ return cornerDimension;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IRoundedRectangleFigure#getRoundedRectangleBounds()
+ *
+ * @return
+ */
+ @Override
+ public Rectangle getRoundedRectangleBounds() {
+ return getBounds();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void paintFigure(Graphics graphics) {
+
+ shadowborder.setColor(getForegroundColor());
+ graphics.pushState();
+ Rectangle rectangle = getBounds().getCopy();
+
+ refreshCornerSizeWhenOval();
+
+ // paintBackground:
+ applyTransparency(graphics);
+ if (isUsingGradient()) {
+ boolean isVertical = (getGradientStyle() == GradientStyle.VERTICAL) ? true : false;
+ if (isVertical && rectangle.height > ((3 * cornerDimension.height) / 2)) {
+ Rectangle upperBounds = getBounds().getCopy();
+ upperBounds.height = cornerDimension.height - getLineWidth() / 2;
+ upperBounds.y += getLineWidth() / 2;
+ Rectangle upperClip = upperBounds.getCopy().shrink(new Insets(0, 0, cornerDimension.height / 2, 0));
+ Rectangle lowerBounds = getBounds().getCopy();
+ lowerBounds.y = lowerBounds.bottom() - cornerDimension.height;
+ lowerBounds.height = cornerDimension.height - getLineWidth() / 2;
+ Rectangle lowerClip = lowerBounds.getCopy().shrink(new Insets(cornerDimension.height / 2, 0, 0, 0));
+ Rectangle innerBounds = getBounds().getCopy();
+ innerBounds.y = upperClip.bottom();
+ innerBounds.height = lowerClip.y - upperClip.bottom() + 1;
+ // fill the upper part
+ graphics.pushState();
+ graphics.setBackgroundColor(ColorRegistry.getInstance().getColor(getGradientColor2()));
+ graphics.clipRect(upperClip);
+ graphics.fillRoundRectangle(upperBounds, cornerDimension.width, cornerDimension.height);
+ graphics.popState();
+ // fill the inner part
+ graphics.pushState();
+ graphics.setForegroundColor(ColorRegistry.getInstance().getColor(getGradientColor2()));
+ graphics.setBackgroundColor(ColorRegistry.getInstance().getColor(getGradientColor1()));
+ graphics.fillGradient(innerBounds, true);
+ graphics.popState();
+ // fill the lower part
+ graphics.pushState();
+ graphics.setBackgroundColor(ColorRegistry.getInstance().getColor(getGradientColor1()));
+ graphics.clipRect(lowerClip);
+ graphics.fillRoundRectangle(lowerBounds, cornerDimension.width, cornerDimension.height);
+ graphics.popState();
+ } else if (!isVertical && rectangle.width > ((3 * cornerDimension.width) / 2)) {
+ Rectangle leftBounds = getBounds().getCopy();
+ leftBounds.width = cornerDimension.width - getLineWidth() / 2;
+ leftBounds.x += getLineWidth() / 2;
+ Rectangle leftClip = leftBounds.getCopy().shrink(new Insets(0, 0, 0, cornerDimension.width / 2));
+ Rectangle rightBounds = getBounds().getCopy();
+ rightBounds.x = rightBounds.right() - cornerDimension.width;
+ rightBounds.width = cornerDimension.width - getLineWidth() / 2;
+ Rectangle rightClip = rightBounds.getCopy().shrink(new Insets(0, cornerDimension.width / 2, 0, 0));
+ Rectangle innerBounds = getBounds().getCopy();
+ innerBounds.x = leftClip.right();// - getLineWidth();
+ innerBounds.width = rightClip.x - leftClip.right() + 1;// + 2 * getLineWidth();
+ // fill the left part
+ graphics.pushState();
+ graphics.setBackgroundColor(ColorRegistry.getInstance().getColor(getGradientColor2()));
+ graphics.clipRect(leftClip);
+ graphics.fillRoundRectangle(leftBounds, cornerDimension.width, cornerDimension.height);
+ graphics.popState();
+ // fill the inner part
+ graphics.pushState();
+ graphics.setBackgroundColor(ColorRegistry.getInstance().getColor(getGradientColor1()));
+ graphics.setForegroundColor(ColorRegistry.getInstance().getColor(getGradientColor2()));
+ graphics.fillGradient(innerBounds, false);
+ graphics.popState();
+ // fill the right part
+ graphics.pushState();
+ graphics.setBackgroundColor(ColorRegistry.getInstance().getColor(getGradientColor1()));
+ graphics.clipRect(rightClip);
+ graphics.fillRoundRectangle(rightBounds, cornerDimension.width, cornerDimension.height);
+ graphics.popState();
+ } else {
+ graphics.pushState();
+ graphics.setBackgroundColor(ColorRegistry.getInstance().getColor(getGradientColor1()));
+ graphics.setForegroundColor(ColorRegistry.getInstance().getColor(getGradientColor2()));
+ graphics.fillRoundRectangle(rectangle, cornerDimension.width, cornerDimension.height);
+ graphics.popState();
+ }
+ } else {
+ graphics.pushState();
+ graphics.setBackgroundColor(getBackgroundColor());
+ graphics.setForegroundColor(getForegroundColor());
+ graphics.fillRoundRectangle(rectangle, cornerDimension.width, cornerDimension.height);
+ graphics.popState();
+ }
+
+ if (hasHeader) {
+ graphics.drawPolyline(getHeader());
+ }
+
+ graphics.popState();
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.common.figure.node.PapyrusNodeFigure#setShadow(boolean)
+ *
+ * @param shadow
+ */
+ @Override
+ public void setShadow(boolean shadow) {
+ super.setShadow(shadow);
+ if (!shadow) {
+ // If shadow is set to false we set the border
+ if (getBorder() != null) {
+
+ refreshCornerSizeWhenOval();
+
+ RoundedRectangleBorder border = new RoundedRectangleBorder(cornerDimension.width, cornerDimension.height);
+ border.setWidth(getLineWidth());
+ border.setStyle(borderStyle);
+ this.setBorder(border);
+ }
+ }
+ setLineStyle(borderStyle);
+ }
+
+ /**
+ *
+ */
+ private void refreshCornerSizeWhenOval() {
+ // Set the corner dimension if is oval in case of resizing
+ if (isOval) {
+ if (cornerDimension.width != getBounds().width || cornerDimension.height != getBounds().height) {
+ cornerDimension.width = getBounds().width;
+ cornerDimension.height = getBounds().height;
+ // Force to repaint the border thought setShadow()
+ setShadow(isShadow());
+ }
+ }
+ }
+
+ /**
+ * Sets the corner dimension.
+ *
+ * @param cornerDimension
+ * the new corner dimension
+ */
+ @Override
+ public void setCornerDimensions(Dimension cornerDimension) {
+ this.cornerDimension = cornerDimension;
+ }
+
+ @Override
+ public void setOval(boolean booleanValue) {
+ isOval = booleanValue;
+ if (booleanValue) {
+ refreshCornerSizeWhenOval();
+ }
+ }
+
+ @Override
+ public boolean isOval() {
+ return isOval;
+ }
+
+ @Override
+ public void setFloatingNameConstrained(boolean booleanValue) {
+ isLabelConstrained = booleanValue;
+ }
+
+ @Override
+ public boolean isFloatingNameConstrained() {
+ return isLabelConstrained;
+ }
+
+ @Override
+ public void setFloatingNameOffset(Dimension offset) {
+ this.floatingNameOffset = offset;
+
+ }
+
+ @Override
+ public Dimension getFloatingNameOffset() {
+ return floatingNameOffset;
+ }
+
+
+ protected PointList getHeader() {
+
+ Rectangle labelBounds = nameLabel.getBounds().getCopy();
+ PointList points = new PointList();
+
+ int labelWidth = -1;
+ labelWidth = Math.max(labelWidth, nameLabel.getPreferredSize().width);
+
+ // case the size of the label is 0 or -1 (no label)
+ if (labelWidth <= 0) {
+ labelWidth = getBounds().width / 4;
+ }
+
+ Point verticalStart = new Point();
+ Point verticalEnd = new Point();
+ Point diagonalStart = new Point();
+ Point diagonalEnd = new Point();
+ Point horizontalStart = new Point();
+ Point horizontalEnd = new Point();
+
+ verticalStart.x = labelBounds.x + labelWidth + 4;
+ verticalStart.y = getBounds().y; // labelBounds.y;
+ points.addPoint(verticalStart);
+
+ verticalEnd.x = verticalStart.x;
+ verticalEnd.y = verticalStart.y + labelBounds.height / 2 + 3;
+ points.addPoint(verticalEnd);
+
+ diagonalStart.x = verticalEnd.x;
+ diagonalStart.y = verticalEnd.y;
+ points.addPoint(diagonalStart);
+
+ diagonalEnd.x = diagonalStart.x - labelBounds.height / 2 + 3;
+ diagonalEnd.y = labelBounds.y + labelBounds.height - 1;
+ points.addPoint(diagonalEnd);
+
+ horizontalStart.x = diagonalEnd.x;
+ horizontalStart.y = diagonalEnd.y;
+ points.addPoint(horizontalStart);
+
+ horizontalEnd.x = labelBounds.x;
+ horizontalEnd.y = horizontalStart.y;
+ points.addPoint(horizontalEnd);
+ return points;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IRoundedRectangleFigure#setHasHeader(boolean)
+ *
+ * @param hasHeader
+ */
+ @Override
+ public void setHasHeader(boolean hasHeader) {
+ this.hasHeader = hasHeader;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IRoundedRectangleFigure#hasHeader()
+ *
+ * @return
+ */
+ @Override
+ public boolean hasHeader() {
+ return hasHeader;
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/SignalFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/SignalFigure.java
index 53f56857073..231a9bb8223 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/SignalFigure.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/SignalFigure.java
@@ -21,7 +21,7 @@ import org.eclipse.draw2d.IFigure;
/**
* Represents a signal.
*/
-public class SignalFigure extends CompartmentFigure {
+public class SignalFigure extends RoundedCompartmentFigure {
/** Attribute Compartment */
private final static String ATTRIBUTE_COMPARTMENT = "attributeCompartment";
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/FloatingLabelHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/FloatingLabelHelper.java
new file mode 100644
index 00000000000..05014b9ec21
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/FloatingLabelHelper.java
@@ -0,0 +1,325 @@
+/*****************************************************************************
+ * Copyright (c) 2010, 2014 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.common.helper;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
+import org.eclipse.papyrus.uml.tools.utils.CollaborationUseUtil;
+import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance;
+import org.eclipse.papyrus.uml.tools.utils.InstanceSpecificationUtil;
+import org.eclipse.papyrus.uml.tools.utils.MultiplicityElementUtil;
+import org.eclipse.papyrus.uml.tools.utils.NamedElementUtil;
+import org.eclipse.papyrus.uml.tools.utils.OperationUtil;
+import org.eclipse.papyrus.uml.tools.utils.ParameterUtil;
+import org.eclipse.papyrus.uml.tools.utils.PortUtil;
+import org.eclipse.papyrus.uml.tools.utils.PropertyUtil;
+import org.eclipse.papyrus.uml.tools.utils.SignalUtil;
+import org.eclipse.papyrus.uml.tools.utils.TypeUtil;
+import org.eclipse.uml2.uml.Association;
+import org.eclipse.uml2.uml.CollaborationUse;
+import org.eclipse.uml2.uml.InstanceSpecification;
+import org.eclipse.uml2.uml.MultiplicityElement;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Operation;
+import org.eclipse.uml2.uml.Parameter;
+import org.eclipse.uml2.uml.Port;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Signal;
+import org.eclipse.uml2.uml.TemplateParameter;
+import org.eclipse.uml2.uml.TypedElement;
+
+//TODO Check for usefull property to display
+
+/**
+ * Helper for labels displaying {@link NamedElement}.
+ */
+public class FloatingLabelHelper extends StereotypedElementLabelHelper {
+
+ // Einstance
+ /** The label helper. */
+ private static FloatingLabelHelper labelHelper;
+
+ /**
+ * Gets the single instance of FloatingLabelHelper.
+ *
+ * @return single instance of FloatingLabelHelper
+ */
+ public static FloatingLabelHelper getInstance() {
+ if (labelHelper == null) {
+ labelHelper = new FloatingLabelHelper();
+ }
+ return labelHelper;
+ }
+
+ /** Map for masks. */
+ protected final Map<String, String> masks = new HashMap<String, String>();
+
+ /**
+ * Instantiates a new floating label helper.
+ */
+ protected FloatingLabelHelper() {
+ // initialize the map
+
+ /**
+ * Style constant for visibility display in labels.
+ */
+ masks.put(ICustomAppearance.DISP_VISIBILITY, "Visibility");
+
+ /**
+ * Style constant for isDerive display in labels.
+ */
+ masks.put(ICustomAppearance.DISP_DERIVE, "Derived");
+
+ /**
+ * Style constant for name display in labels.
+ */
+ masks.put(ICustomAppearance.DISP_NAME, "Name");
+
+ /**
+ * Style constant for type display in labels.
+ */
+ masks.put(ICustomAppearance.DISP_TYPE, "Type");
+
+ /**
+ * Style constant for multiplicity display in labels.
+ */
+ masks.put(ICustomAppearance.DISP_MULTIPLICITY, "Multiplicity");
+
+ /**
+ * Style constant for default value display in labels.
+ */
+ masks.put(ICustomAppearance.DISP_DEFAULT_VALUE, "Default Value");
+
+ /**
+ * Style constant for modifiers display in labels.
+ */
+ masks.put(ICustomAppearance.DISP_MODIFIERS, "Modifiers");
+
+ /** Style constant for carriage return in labels */
+ masks.put(ICustomAppearance.DISP_MULTI_LINE, "Multiline");
+
+ /** Style constant for operation#parameter direction display in labels */
+ masks.put(ICustomAppearance.DISP_PARAMETER_DIRECTION, "Parameters Direction");
+
+ /** Style constant for direction display in labels */
+ masks.put(ICustomAppearance.DISP_DIRECTION, "Direction");
+
+ /** Style constant for operation#parameter name display in labels */
+ masks.put(ICustomAppearance.DISP_PARAMETER_NAME, "Parameters Name");
+
+ /** Style constant for operation#parameter type display in labels */
+ masks.put(ICustomAppearance.DISP_PARAMETER_TYPE, "Parameters Type");
+
+ /** Style constant for operation#parameter multiplicity display in labels */
+ masks.put(ICustomAppearance.DISP_PARAMETER_MULTIPLICITY, "Parameters Multiplicity");
+
+ /** Style constant for operation#parameter default value display in labels */
+ masks.put(ICustomAppearance.DISP_PARAMETER_DEFAULT, "Parameters Default");
+
+ /** Style constant for operation#parameter modifiers display in labels */
+ masks.put(ICustomAppearance.DISP_PARAMETER_MODIFIERS, "Parameters Modifiers");
+
+ /** Style constant for return type display in labels */
+ masks.put(ICustomAppearance.DISP_RT_TYPE, "returnType");
+
+ /** Style constant for return multiplicity display in labels */
+ masks.put(ICustomAppearance.DISP_RT_MULTIPLICITY, "Return Multiplicity");
+
+ /** Style constant for conjugated labels */
+ masks.put(ICustomAppearance.DISP_CONJUGATED, "Conjugated");
+ }
+
+ /**
+ * Computes the label that should be displayed by the figure managed by this
+ * edit part.
+ *
+ * @param editPart
+ * the edit part that controls the {@link NamedElement} to be
+ * displayed
+ * @return the label corresponding to the specific display of the property
+ * ("default" display given by preferences or specific display given
+ * by eAnnotation).
+ */
+ @Override
+ protected String elementLabel(GraphicalEditPart editPart) {
+ IMaskManagedLabelEditPolicy policy = (IMaskManagedLabelEditPolicy) editPart.getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (policy == null) {
+ policy = (IMaskManagedLabelEditPolicy) editPart.getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
+ }
+
+ Collection<String> displayValue = Collections.emptySet();
+
+ if (policy != null) {
+ displayValue = policy.getCurrentDisplayValue();
+ }
+
+ return parseString(editPart, displayValue);
+ }
+
+ /**
+ * Parses the string.
+ *
+ * @param editPart
+ * the edit part
+ * @param displayValue
+ * the display value
+ * @return the string
+ */
+ protected String parseString(GraphicalEditPart editPart, Collection<String> displayValue) {
+ NamedElement namedElement = getUMLElement(editPart);
+
+ if (namedElement != null) {
+ return getCustomLabel(namedElement, displayValue);
+ }
+
+ return "";
+ }
+
+
+ /**
+ * Returns the map of masks used to display a {@link NamedElement}.
+ *
+ * @return the {@link Map} of masks used to display a {@link NamedElement}
+ */
+ public Map<String, String> getMasks() {
+ return masks;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NamedElement getUMLElement(GraphicalEditPart editPart) {
+ if (editPart.getModel() instanceof View) {
+ View view = (View) editPart.getModel();
+ if (view.getElement() instanceof NamedElement) {
+ return (NamedElement) view.getElement();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * return the custom label of the property, given UML2 specification and a custom style.
+ *
+ * @param namedElement
+ * the integer representing the style of the label
+ * @param maskValues
+ * the mask values
+ * @return the string corresponding to the label of the property
+ */
+ public static String getCustomLabel(NamedElement namedElement, Collection<String> maskValues) {
+
+ // Use of specific existing custom label
+
+ // use CollaborationUse custom label
+ if (namedElement instanceof CollaborationUse) {
+ return CollaborationUseUtil.getCustomLabel((CollaborationUse) namedElement, maskValues);
+ }
+
+ // use InstanceSpecification custom label
+ if (namedElement instanceof InstanceSpecification) {
+ return InstanceSpecificationUtil.getCustomLabel((InstanceSpecification) namedElement, maskValues);
+ }
+
+ // use Operation custom label
+ if (namedElement instanceof Operation) {
+ return OperationUtil.getCustomLabel((Operation) namedElement, maskValues);
+ }
+
+ // use Parameter custom label
+ if (namedElement instanceof Parameter) {
+ return ParameterUtil.getCustomLabel((Parameter) namedElement, maskValues);
+ }
+
+ // use Signal custom label
+ if (namedElement instanceof Signal) {
+ return SignalUtil.getCustomLabel((Signal) namedElement, maskValues);
+ }
+
+ // use Port custom label
+ if (namedElement instanceof Port) {
+ return PortUtil.getCustomLabel((Port) namedElement, maskValues);
+ }
+
+ // use Property custom label
+ if (namedElement instanceof Property) {
+ return PropertyUtil.getCustomLabel((Property) namedElement, maskValues);
+ }
+ // TODO add others usefull properties
+
+ // default custom label
+ StringBuffer buffer = new StringBuffer();
+
+ // visibility
+ if (maskValues.contains(ICustomAppearance.DISP_VISIBILITY)) {
+ buffer.append(" ");
+ buffer.append(NamedElementUtil.getVisibilityAsSign(namedElement));
+ }
+
+ // derived property for association
+ if (namedElement instanceof Association) {
+ if (maskValues.contains(ICustomAppearance.DISP_DERIVE)) {
+ if (((Association) namedElement).isDerived()) {
+ buffer.append("/");
+ }
+ }
+ }
+ // name
+ if (maskValues.contains(ICustomAppearance.DISP_NAME)) {
+ buffer.append(" ");
+ buffer.append(namedElement.getName());
+ }
+
+ // Type of TypedElement
+ if (namedElement instanceof TypedElement) {
+ if (maskValues.contains(ICustomAppearance.DISP_TYPE)) {
+ // type
+ if (((TypedElement) namedElement).getType() != null) {
+ buffer.append(": " + ((TypedElement) namedElement).getType().getName());
+ } else {
+ buffer.append(": " + TypeUtil.UNDEFINED_TYPE_NAME);
+ }
+ }
+ }
+
+ // Multiplicity
+ if (namedElement instanceof MultiplicityElement) {
+ if (maskValues.contains(ICustomAppearance.DISP_MULTIPLICITY)) {
+ // multiplicity -> do not display [1]
+ String multiplicity = MultiplicityElementUtil.getMultiplicityAsString((MultiplicityElement) namedElement);
+ buffer.append(multiplicity);
+ }
+ }
+
+ // Template Parameter(not sure of the uml element
+ if (namedElement instanceof TemplateParameter) {
+ if (maskValues.contains(ICustomAppearance.DISP_DEFAULT_VALUE)) {
+ // default value
+ if (((TemplateParameter) namedElement).getDefault() != null) {
+ buffer.append(" = ");
+ buffer.append(((TemplateParameter) namedElement).getDefault());
+ }
+ }
+ }
+
+ return buffer.toString();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/locator/ExternalLabelPositionLocator.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/locator/ExternalLabelPositionLocator.java
index 1ba388b783a..2d4175b28c9 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/locator/ExternalLabelPositionLocator.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/locator/ExternalLabelPositionLocator.java
@@ -35,6 +35,8 @@ import org.eclipse.papyrus.commands.wrappers.GEFtoEMFCommandWrapper;
import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart;
import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart;
import org.eclipse.papyrus.infra.gmfdiag.common.locator.IPapyrusBorderItemLocator;
+import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils;
+import org.eclipse.papyrus.uml.diagram.common.editparts.RoundedCompartmentEditPart;
/**
* This class is used to constrain the position of ExternalNodeLabel. The
@@ -53,7 +55,7 @@ public class ExternalLabelPositionLocator implements IPapyrusBorderItemLocator {
private boolean isConstrained = false;
/** The margin. */
- private Point margin;
+ private Point margin = new Point();
/** The offset. */
private Dimension offset = new Dimension();
@@ -99,7 +101,7 @@ public class ExternalLabelPositionLocator implements IPapyrusBorderItemLocator {
*/
@Override
public int getCurrentSideOfParent() {
- return position;
+ return getPosition();
}
/**
@@ -119,6 +121,27 @@ public class ExternalLabelPositionLocator implements IPapyrusBorderItemLocator {
*/
@Override
public int getPosition() {
+ // Get the forced value(CSS, Notation)
+ String ForcedPosition = NotationUtils.getStringValue(view, "position", "AUTO").toUpperCase();
+ // if there is a forced position
+ if (!"AUTO".equals(ForcedPosition)) {
+ if ("EAST".equals(ForcedPosition)) {
+ position = PositionConstants.EAST;
+ }
+ if ("WEST".equals(ForcedPosition)) {
+ position = PositionConstants.WEST;
+ }
+ if ("NORTH".equals(ForcedPosition)) {
+ position = PositionConstants.NORTH;
+ }
+ if ("SOUTH".equals(ForcedPosition)) {
+ position = PositionConstants.SOUTH;
+ }
+ } else {
+ // Return the position on parent
+ position = getPositionOnParent();
+ }
+
return position;
}
@@ -128,7 +151,7 @@ public class ExternalLabelPositionLocator implements IPapyrusBorderItemLocator {
* @return the position on parent
*/
public int getPositionOnParent() {
- Rectangle portBounds = null;
+ Rectangle bounds = null;
Rectangle parentBounds = null;
int position = this.position;
@@ -137,24 +160,43 @@ public class ExternalLabelPositionLocator implements IPapyrusBorderItemLocator {
EditPart parent = editPart.getParent();
if (parent instanceof IPapyrusEditPart) {
IFigure portPrimaryShape = ((IPapyrusEditPart) parent).getPrimaryShape();
- portBounds = portPrimaryShape.getBounds();
+ bounds = portPrimaryShape.getBounds();
// Get the port's parent figure
// if it's a papyrus edit part and the figure is paint(width !=0)
- if (parent.getParent() instanceof IPapyrusEditPart && portBounds.width != 0) {
+ if (parent.getParent() instanceof IPapyrusEditPart && bounds.width != 0) {
IFigure parentPrimaryShape = ((IPapyrusEditPart) parent.getParent()).getPrimaryShape();
parentBounds = parentPrimaryShape.getBounds();
- if (portBounds.x + portBounds.width / 2 == parentBounds.x) {
+ if (bounds.x + bounds.width / 2 == parentBounds.x) {
// West position
position = PositionConstants.WEST;
- } else if (portBounds.x + portBounds.width / 2 == parentBounds.getBottomRight().x) {
+ } else if (bounds.x + bounds.width / 2 == parentBounds.getBottomRight().x) {
// East Position
position = PositionConstants.EAST;
- } else if (portBounds.y + portBounds.height / 2 == parentBounds.y) {
+ } else if (bounds.y + bounds.height / 2 == parentBounds.y) {
+ // North Position
position = PositionConstants.NORTH;
- } else if (portBounds.y + portBounds.height / 2 == parentBounds.getBottomRight().y) {
+ } else if (bounds.y + bounds.height / 2 == parentBounds.getBottomRight().y) {
+ // South Position
position = PositionConstants.SOUTH;
+ } else
+
+ // Take into account of rounded corner
+ if (parent.getParent() instanceof RoundedCompartmentEditPart && bounds.width != 0) {
+ // West position
+ if (bounds.x + bounds.width / 2 < parentBounds.x + parentBounds.width / 4) {
+ position = PositionConstants.WEST;
+ // East Position
+ } else if (bounds.x + bounds.width / 2 > parentBounds.x + parentBounds.width / 4 * 3) {
+ position = PositionConstants.EAST;
+ // North Position
+ } else if (bounds.y + bounds.height / 2 < parentBounds.y + parentBounds.height / 2) {
+ position = PositionConstants.NORTH;
+ // South Position
+ } else if (bounds.y + bounds.height / 2 > parentBounds.y + parentBounds.height / 2) {
+ position = PositionConstants.SOUTH;
+ }
}
}
}
@@ -227,10 +269,10 @@ public class ExternalLabelPositionLocator implements IPapyrusBorderItemLocator {
Point newConstraint;
// The new Offset to be saved one the resource
Point newOffset;
- // get the nummber of labels and set the number of this label
+ // get the number of labels and set the number of this label
int numberOfLabel = getNumberOfVisibleLabels();
// Set the translation when alignment is auto
- switch (getPositionOnParent()) {
+ switch (getPosition()) {
case PositionConstants.WEST:
// alignRight:
newConstraint = new Point(-proposedBounds.width - offset.width, offset.height);
@@ -261,7 +303,7 @@ public class ExternalLabelPositionLocator implements IPapyrusBorderItemLocator {
proposedBounds.setLocation(newConstraint.translate(parentFigure.getBounds().getTopLeft()));
// translate the label in case of multiple label
- switch (getPositionOnParent()) {
+ switch (getPosition()) {
case PositionConstants.WEST:
proposedBounds.translate(0, (numLabel - 1) * proposedBounds.height + margin.y - (numberOfLabel - 1) * (proposedBounds.height + margin.y) / 2);
break;
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/locator/PortPositionLocator.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/locator/PortPositionLocator.java
index ec6ba1db783..0a18f5b1487 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/locator/PortPositionLocator.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/locator/PortPositionLocator.java
@@ -13,11 +13,17 @@
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.locator;
+import org.eclipse.draw2d.ConnectionAnchor;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.RoundedRectangleNodePlateFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SlidableRoundedRectangleAnchor;
+import org.eclipse.papyrus.infra.gmfdiag.common.utils.FigureUtils;
/**
*
@@ -47,6 +53,8 @@ public class PortPositionLocator implements IBorderItemLocator {
/** the figure around which this border item appears */
protected IFigure parentFigure = null;
+ String position = "onLine";
+
/** the width of the area surrounding the parent figure where border item can be put */
protected int borderItemOffset = 10;
@@ -55,7 +63,6 @@ public class PortPositionLocator implements IBorderItemLocator {
return borderItemOffset;
}
-
public void setBorderItemOffset(int borderItemOffset) {
this.borderItemOffset = borderItemOffset;
}
@@ -72,7 +79,17 @@ public class PortPositionLocator implements IBorderItemLocator {
/** the position constraint */
protected Rectangle constraint = new Rectangle(0, 0, 0, 0);
- /** Constructor **/
+ /** the figure */
+ private IFigure figure;
+
+ /**
+ * Constructor *.
+ *
+ * @param parentFigure
+ * the parent figure
+ * @param preferredSide
+ * the preferred side
+ */
public PortPositionLocator(IFigure parentFigure, int preferredSide) {
// The preferredSide parameter is not used, just kept here to ensure compatibility
// with GMF generated code.
@@ -80,12 +97,14 @@ public class PortPositionLocator implements IBorderItemLocator {
}
/**
- *
- * @see org.eclipse.gmf.runtime.draw2d.ui.figures.IBorderItemLocator#getValidLocation(org.eclipse.draw2d.geometry.Rectangle, org.eclipse.draw2d.IFigure)
+ * Gets the valid location.
*
* @param proposedLocation
+ * the proposed location
* @param borderItem
+ * the border item
* @return a valid location
+ * @see org.eclipse.gmf.runtime.draw2d.ui.figures.IBorderItemLocator#getValidLocation(org.eclipse.draw2d.geometry.Rectangle, org.eclipse.draw2d.IFigure)
*/
@Override
public Rectangle getValidLocation(Rectangle proposedLocation, IFigure borderItem) {
@@ -93,6 +112,7 @@ public class PortPositionLocator implements IBorderItemLocator {
}
/**
+ * Gets the preferred location.
*
* @param proposedLocation
* the proposed location
@@ -102,108 +122,142 @@ public class PortPositionLocator implements IBorderItemLocator {
// Initialize port location with proposed location
// and resolve the bounds of it graphical parent
- Rectangle realLocation = new Rectangle(proposedLocation);
+ Rectangle realLocation = new Rectangle(proposedLocation);
Rectangle parentRec = getParentFigure().getBounds().getCopy();
- // Calculate Max position around the graphical parent (1/2 size or the port around
- // the graphical parent bounds.
- int xMin = parentRec.x - borderItemOffset;
- int xMax = parentRec.x - borderItemOffset + parentRec.width;
- int yMin = parentRec.y - borderItemOffset;
- int yMax = parentRec.y - borderItemOffset + parentRec.height;
-
- // Modify Port location if MAX X or Y are exceeded
- if (realLocation.x < xMin) {
- realLocation.x = xMin;
- }
-
- if (realLocation.x > xMax) {
- realLocation.x = xMax;
- }
- if (realLocation.y < yMin) {
- realLocation.y = yMin;
- }
-
- if (realLocation.y > yMax) {
- realLocation.y = yMax;
+ // If it's a SVGNodePlate get the anchor to get the position
+ if (parentFigure instanceof SVGNodePlateFigure && ((SVGNodePlateFigure) parentFigure).getConnectionAnchor("") instanceof SlidableRoundedRectangleAnchor) {
+
+ // Translate location to absolute before calculate location Point
+ parentFigure.translateToAbsolute(proposedLocation);
+ parentFigure.translateToAbsolute(parentRec);
+
+ ConnectionAnchor connectionAnchor = ((SVGNodePlateFigure) parentFigure).getConnectionAnchor("");
+ // Get the location point, with anchor.
+ ((SlidableRoundedRectangleAnchor) connectionAnchor).setOffset(getPortOffset());
+ Point locationForPort = ((SlidableRoundedRectangleAnchor) connectionAnchor).getLocation(parentRec.getCenter(), proposedLocation.getLocation());
+ ((SlidableRoundedRectangleAnchor) connectionAnchor).setOffset(new Dimension());
+ if (locationForPort != null) {
+ proposedLocation.setLocation(locationForPort);
+ }
+
+ // Translate to relative the location
+ parentFigure.translateToRelative(proposedLocation);
+ // Set the location
+ realLocation.setLocation(proposedLocation.getLocation());
+ } else {
+
+ // Calculate Max position around the graphical parent (1/2 size or the port around
+ // the graphical parent bounds.
+ int xMin = parentRec.x - borderItemOffset;
+ int xMax = parentRec.x - borderItemOffset + parentRec.width;
+ int yMin = parentRec.y - borderItemOffset;
+ int yMax = parentRec.y - borderItemOffset + parentRec.height;
+
+ // Modify Port location if MAX X or Y are exceeded
+ if (realLocation.x < xMin) {
+ realLocation.x = xMin;
+ }
+ if (realLocation.x > xMax) {
+ realLocation.x = xMax;
+ }
+ if (realLocation.y < yMin) {
+ realLocation.y = yMin;
+ }
+ if (realLocation.y > yMax) {
+ realLocation.y = yMax;
+ }
+
+ final Rectangle maxRect = parentRec.getCopy();
+ maxRect.shrink(-borderItemOffset, -borderItemOffset);
+ while (maxRect.contains(realLocation.getLocation())) {
+ maxRect.shrink(1, 1);
+ }
+ int pos = maxRect.getPosition(realLocation.getLocation());
+
+ switch (pos) {
+ case PositionConstants.NORTH:
+ realLocation.y = yMin;
+ break;
+ case PositionConstants.SOUTH:
+ realLocation.y = yMax;
+ break;
+ case PositionConstants.EAST:
+ realLocation.x = xMax;
+ break;
+ case PositionConstants.WEST:
+ realLocation.x = xMin;
+ break;
+ case PositionConstants.NORTH_EAST:
+ realLocation.x = xMax;
+ realLocation.y = yMin;
+ break;
+ case PositionConstants.NORTH_WEST:
+ realLocation.x = xMin;
+ realLocation.y = yMin;
+ break;
+ case PositionConstants.SOUTH_EAST:
+ realLocation.x = xMax;
+ realLocation.y = yMax;
+ break;
+ case PositionConstants.SOUTH_WEST:
+ realLocation.x = xMin;
+ realLocation.y = yMax;
+ break;
+ }
}
+ // Return constrained location
+ return realLocation;
+ }
- // commented by V. Lorenzo to allow to create port on the top of a figure
- // replaced by the next block of code
-
- // Ensure the port is positioned on its parent borders and not in the middle.
- // Modify position if needed.
- // if((realLocation.y != yMin) && (realLocation.y != yMax)) {
- // if((realLocation.x != xMin) && (realLocation.x != xMax)) {
- //
- // if(realLocation.x <= (xMin + (parentRec.width / 2))) {
- // realLocation.x = xMin;
- // } else {
- // realLocation.x = xMax;
- // }
- // }
- // }
-
- // this code replaces the previous commented lines
- final Rectangle maxRect = parentRec.getCopy();
- maxRect.shrink(-borderItemOffset, -borderItemOffset);
- while (maxRect.contains(realLocation.getLocation())) {
- maxRect.shrink(1, 1);
- }
- int pos = maxRect.getPosition(realLocation.getLocation());
- switch (pos) {
- case PositionConstants.NORTH:
- realLocation.y = yMin;
- break;
- case PositionConstants.SOUTH:
- realLocation.y = yMax;
- break;
- case PositionConstants.EAST:
- realLocation.x = xMax;
- break;
- case PositionConstants.WEST:
- realLocation.x = xMin;
- break;
- case PositionConstants.NORTH_EAST:
- realLocation.x = xMax;
- realLocation.y = yMin;
- break;
- case PositionConstants.NORTH_WEST:
- realLocation.x = xMin;
- realLocation.y = yMin;
- break;
- case PositionConstants.SOUTH_EAST:
- realLocation.x = xMax;
- realLocation.y = yMax;
- break;
- case PositionConstants.SOUTH_WEST:
- realLocation.x = xMin;
- realLocation.y = yMax;
- break;
+ /**
+ * @return
+ */
+ private Dimension getPortOffset() {
+ Dimension portOffset = new Dimension();
+ if (figure != null) {
+ if ("inside".equals(position)) {
+ portOffset.width = -figure.getBounds().width / 2;
+ portOffset.height = -figure.getBounds().height / 2;
+ } else if ("outside".equals(position)) {
+ portOffset.width = figure.getBounds().width / 2;
+ portOffset.height = figure.getBounds().height / 2;
+ }
+ // Else onLine: no offset is applied and the port is on the line.
}
+ return portOffset;
+ }
- // Return constrained location
- return realLocation;
+ /**
+ * @param position
+ * the position to set
+ */
+ public void setPortPosition(String position) {
+ this.position = position;
}
/**
+ * @param view
+ * the view to set
+ *
+ * /**
+ * Gets the current side of parent.
*
+ * @return the current side of parent
* @see org.eclipse.gmf.runtime.draw2d.ui.figures.IBorderItemLocator#getCurrentSideOfParent()
- *
- * @return
- * the position of the port around its parent. This position can be
- * <ul>
- * <li>{@linkplain PositionConstants#NORTH}</li>
- * <li> {@linkplain PositionConstants#SOUTH}</li>
- * <li> {@linkplain PositionConstants#EAST}</li>
- * <li> {@linkplain PositionConstants#WEST}</li>
- * <li> {@linkplain PositionConstants#NORTH_EAST}</li>
- * <li> {@linkplain PositionConstants#NORTH_WEST}</li>
- * <li> {@linkplain PositionConstants#SOUTH_EAST}</li>
- * <li> {@linkplain PositionConstants#SOUTH_WEST}</li>
- * </ul>
+ * the position of the port around its parent. This position can be
+ * <ul>
+ * <li>{@linkplain PositionConstants#NORTH}</li>
+ * <li> {@linkplain PositionConstants#SOUTH}</li>
+ * <li> {@linkplain PositionConstants#EAST}</li>
+ * <li> {@linkplain PositionConstants#WEST}</li>
+ * <li> {@linkplain PositionConstants#NORTH_EAST}</li>
+ * <li> {@linkplain PositionConstants#NORTH_WEST}</li>
+ * <li> {@linkplain PositionConstants#SOUTH_EAST}</li>
+ * <li> {@linkplain PositionConstants#SOUTH_WEST}</li>
+ * </ul>
*/
@Override
public int getCurrentSideOfParent() {
@@ -212,65 +266,69 @@ public class PortPositionLocator implements IBorderItemLocator {
// we are not on EAST, not on WEST, but we are on the NORTH
if ((constraint.x != parentFigure.getBounds().width - borderItemOffset) && (constraint.x != -this.borderItemOffset) && (constraint.y == -this.borderItemOffset)) {
position = PositionConstants.NORTH;
-
// we are not on the EAST and not on the WEST, but we are on the SOUTH
} else if ((constraint.x != parentFigure.getBounds().width - borderItemOffset) && (constraint.x != -this.borderItemOffset) && (constraint.y == parentFigure.getBounds().height - borderItemOffset)) {
position = PositionConstants.SOUTH;
-
// we are on the EAST, but we are not on the NORTH and not on the SOUTH
} else if ((constraint.x == parentFigure.getBounds().width - borderItemOffset) && (constraint.y != -this.borderItemOffset) && (constraint.y != parentFigure.getBounds().height - borderItemOffset)) {
position = PositionConstants.EAST;
-
// we are on the WEST, but we are not on the on the NORTH and not on the SOUTH
} else if ((constraint.x == -this.borderItemOffset) && (constraint.y != -this.borderItemOffset) && (constraint.y != parentFigure.getBounds().height - borderItemOffset)) {
position = PositionConstants.WEST;
-
// we are on the NORTH and on the EAST
} else if ((constraint.x == parentFigure.getBounds().width - borderItemOffset) && (constraint.y == -this.borderItemOffset)) {
position = PositionConstants.NORTH_EAST;
-
// we are on the NORTH and on the WEST
} else if ((constraint.x == -this.borderItemOffset) && (constraint.y == -this.borderItemOffset)) {
position = PositionConstants.NORTH_WEST;
-
// we are on the EAST and on the SOUTH
} else if ((constraint.x == parentFigure.getBounds().width - borderItemOffset) && (constraint.y == parentFigure.getBounds().height - borderItemOffset)) {
position = PositionConstants.SOUTH_EAST;
-
// we are on the WEST and on the SOUTH
} else if ((constraint.x == -this.borderItemOffset) && (constraint.y == parentFigure.getBounds().height - borderItemOffset)) {
position = PositionConstants.SOUTH_WEST;
}
-
return position;
}
/**
- *
- * @see org.eclipse.gmf.runtime.draw2d.ui.figures.IBorderItemLocator#setConstraint(org.eclipse.draw2d.geometry.Rectangle)
+ * Sets the constraint.
*
* @param constraint
+ * the new constraint
+ * @see org.eclipse.gmf.runtime.draw2d.ui.figures.IBorderItemLocator#setConstraint(org.eclipse.draw2d.geometry.Rectangle)
*/
@Override
public void setConstraint(Rectangle constraint) {
this.constraint = constraint;
-
}
/**
- *
- * @see org.eclipse.draw2d.Locator#relocate(org.eclipse.draw2d.IFigure)
+ * Relocate.
*
* @param target
+ * the target
+ * @see org.eclipse.draw2d.Locator#relocate(org.eclipse.draw2d.IFigure)
*/
@Override
public void relocate(IFigure target) {
+ if (figure == null) {
+ figure = target;
+ }
+
Rectangle proposedLocation = constraint.getCopy();
proposedLocation.setLocation(constraint.getLocation().translate(parentFigure.getBounds().getTopLeft()));
Point validLocation = getValidLocation(proposedLocation, target).getLocation();
-
- target.setBounds(new Rectangle(validLocation, target.getPreferredSize()));
+ if (FigureUtils.findChildFigureInstance(figure, RoundedRectangleNodePlateFigure.class) != null) {
+
+ Dimension preferredSize = target.getPreferredSize();
+ Rectangle rect = new Rectangle(validLocation, preferredSize);
+ rect.translate(-preferredSize.width / 2, -preferredSize.height / 2);
+ target.setBounds(rect);
+ } else {
+ target.setBounds(new Rectangle(validLocation, target.getPreferredSize()));
+ }
}
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/locator/RoundedRectangleLabelPositionLocator.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/locator/RoundedRectangleLabelPositionLocator.java
new file mode 100644
index 00000000000..5756ef7e19c
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/locator/RoundedRectangleLabelPositionLocator.java
@@ -0,0 +1,714 @@
+/*****************************************************************************
+ * Copyright (c) 2010, 2014 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.common.locator;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gmf.runtime.draw2d.ui.mapmode.MapModeUtil;
+import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IRoundedRectangleFigure;
+
+/**
+ * This class is used to constrain the position of ExternalNodeLabel. The
+ * locator let the external node label be freely located by used anywhere around
+ * the parent figure.
+ */
+public class RoundedRectangleLabelPositionLocator extends ExternalLabelPositionLocator {
+
+ /** the figure around which this label appears. */
+ protected IFigure parentFigure = null;
+
+ /** The border item offset. */
+ private Dimension borderItemOffset = new Dimension(1, 1);
+
+ /** The preferred side. */
+ private int preferredSide = PositionConstants.NORTH;
+
+ /** remembers the preferred side used when the locator was created. */
+ private int originalPreferredSide = PositionConstants.NORTH;
+
+ /** The current side. */
+ private int currentSide = PositionConstants.NORTH;
+
+ /** The interval. */
+ private int interval;
+
+ /**
+ * The preferred side determines placement of figure.
+ *
+ * @param interval
+ * interval between border items used in collision resolving (must be > 0)
+ * @param parentFigure
+ * the parent figure
+ */
+ public RoundedRectangleLabelPositionLocator(int interval, IFigure parentFigure) {
+ super(parentFigure);
+ Assert.isTrue(interval > 0);
+ Assert.isNotNull(parentFigure);
+ this.parentFigure = parentFigure;
+ this.interval = interval;
+ }
+
+ /**
+ * The preferred side determines placement of figure.
+ *
+ * @param parentFigure
+ * the parent figure
+ */
+ public RoundedRectangleLabelPositionLocator(IFigure parentFigure) {
+ this(MapModeUtil.getMapMode(parentFigure).DPtoLP(8), parentFigure);
+ }
+
+ /**
+ * The preferred side determines placement of figure.
+ *
+ * @param parentFigure
+ * the parent figure
+ * @param preferredSide
+ * the preferred side of the parent figure on which to place this
+ * border item as defined in {@link PositionConstants}
+ */
+ public RoundedRectangleLabelPositionLocator(IFigure parentFigure, int preferredSide) {
+ this(parentFigure);
+ this.preferredSide = preferredSide;
+ this.originalPreferredSide = preferredSide;
+ }
+
+ /**
+ * The preferred side determines placement of figure.
+ *
+ * @param parentFigure
+ * the parent figure
+ * @param preferredSide
+ * the preferred side of the parent figure on which to place this
+ * border item as defined in {@link PositionConstants}
+ * @param interval
+ * interval between border items used in collision resolving (must be > 0)
+ */
+ public RoundedRectangleLabelPositionLocator(IFigure parentFigure, int preferredSide, int interval) {
+ this(interval, parentFigure);
+ this.preferredSide = preferredSide;
+ this.originalPreferredSide = preferredSide;
+ }
+
+ /**
+ * The preferred location overrides the preferred side.
+ *
+ * @param borderItem
+ * the border item
+ * @param parentFigure
+ * the parent figure
+ * @param constraint
+ * the constraint
+ */
+ public RoundedRectangleLabelPositionLocator(IFigure borderItem, IFigure parentFigure, Rectangle constraint) {
+ this(parentFigure);
+ setConstraint(constraint);
+ }
+
+ /**
+ * The preferred location overrides the preferred side.
+ *
+ * @param borderItem
+ * the border item
+ * @param parentFigure
+ * the parent figure
+ * @param constraint
+ * the constraint
+ * @param interval
+ * interval between border items used in collision resolving (must be > 0)
+ */
+ public RoundedRectangleLabelPositionLocator(IFigure borderItem, IFigure parentFigure, Rectangle constraint, int interval) {
+ this(interval, parentFigure);
+ setConstraint(constraint);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator#resetPosition(org.eclipse.draw2d.geometry.Rectangle)
+ */
+ /**
+ * @see org.eclipse.gmf.runtime.draw2d.ui.figures.IBorderItemLocator#setConstraint(org.eclipse.draw2d.geometry.Rectangle)
+ *
+ * @param theConstraint
+ */
+
+ public void setConstraint(Rectangle theConstraint) {
+ this.constraint = theConstraint;
+ if (!isLabelConstrained()) {
+ if (theConstraint.getTopLeft().x == 0 || theConstraint.getTopLeft().y == 0) {
+ setCurrentSideOfParent(getPreferredSideOfParent());
+ }
+ }
+
+ }
+
+ /**
+ * Get the preferred location. If none has been previously set, use the
+ * preferred side to take an initial guess.
+ *
+ * @param borderItem
+ * the border item
+ * @return point
+ */
+ protected Point getPreferredLocation(IFigure borderItem) {
+ Point constraintLocation = getConstraint().getLocation();
+ Point ptAbsoluteLocation = this.getAbsoluteToBorder(constraintLocation);
+ if (constraintLocation.x == 0 || constraintLocation.y == 0) {
+ return getPreferredLocation(getPreferredSideOfParent(), borderItem);
+ } else {
+ return ptAbsoluteLocation;
+ }
+ }
+
+ /**
+ * Utility to calculate the parent bounds with consideration for the handle
+ * bounds inset.
+ *
+ * @return <code>Rectangle</code> that is the bounds of the parent.
+ */
+ protected Rectangle getParentBorder() {
+ Rectangle bounds = getParentFigure().getBounds().getCopy();
+ if (getParentFigure() instanceof NodeFigure) {
+ bounds = ((NodeFigure) getParentFigure()).getHandleBounds().getCopy();
+ }
+ return bounds;
+ }
+
+ /**
+ * Get an initial location based on the side. ( choose middle of the side )
+ *
+ * @param side
+ * the preferred side of the parent figure on which to place this
+ * border item as defined in {@link PositionConstants}
+ * @param borderItem
+ * the border item
+ * @return point
+ */
+ protected Point getPreferredLocation(int side, IFigure borderItem) {
+
+ // get bounds of the parent
+ Rectangle bounds = getParentBorder();
+ int parentFigureWidth = bounds.width;
+ int parentFigureHeight = bounds.height;
+ int parentFigureX = bounds.x;
+ int parentFigureY = bounds.y;
+ int x = parentFigureX;
+ int y = parentFigureY;
+ Dimension borderItemSize = getSize(borderItem);
+
+ if (!isLabelConstrained()) {
+ // position if the label is free, taking into account of the offset
+ x = parentFigureX + getFloatingItemOffset().width;
+ y = parentFigureY + getFloatingItemOffset().height;
+
+ } else {
+ // position if a constraint position
+ if (side == PositionConstants.WEST) {
+ x = parentFigureX - borderItemSize.width + getBorderItemOffset().width;
+ y += parentFigureHeight / 2;
+ } else if (side == PositionConstants.EAST) {
+ x = parentFigureX + parentFigureWidth - getBorderItemOffset().width;
+ y += parentFigureHeight / 2;
+ } else if (side == PositionConstants.NORTH) {
+ y = parentFigureY - borderItemSize.height + getBorderItemOffset().height;
+ x += parentFigureWidth / 2;
+ } else if (side == PositionConstants.SOUTH) {
+ x += parentFigureWidth / 2;
+ y = parentFigureY + parentFigureHeight - getBorderItemOffset().height;
+ }
+ }
+
+ return new Point(x, y);
+ }
+
+ /**
+ * Ensure the suggested location actually lies on the parent boundary. The
+ * side takes precedence.
+ *
+ * @param suggestedLocation
+ * the suggested location
+ * @param suggestedSide
+ * the suggested side
+ * @param borderItem
+ * the border item
+ * @return point
+ */
+ protected Point locateOnParent(Point suggestedLocation, int suggestedSide, IFigure borderItem) {
+
+ Rectangle bounds = getParentBorder();
+ int parentFigureWidth = bounds.width;
+ int parentFigureHeight = bounds.height;
+ int parentFigureX = bounds.x;
+ int parentFigureY = bounds.y;
+ Dimension borderItemSize = getSize(borderItem);
+ int newX = suggestedLocation.x;
+ int newY = suggestedLocation.y;
+ int westX = parentFigureX - borderItemSize.width + getBorderItemOffset().width;
+ int eastX = parentFigureX + parentFigureWidth - getBorderItemOffset().width;
+ int southY = parentFigureY + parentFigureHeight - getBorderItemOffset().height;
+ int northY = parentFigureY - borderItemSize.height + getBorderItemOffset().height;
+
+ if (suggestedSide == PositionConstants.WEST) {
+ if (suggestedLocation.x != westX) {
+ newX = westX;
+ }
+ if (suggestedLocation.y < bounds.getTopLeft().y) {
+ newY = northY + borderItemSize.height;
+ } else if (suggestedLocation.y > bounds.getBottomLeft().y - borderItemSize.height) {
+ newY = southY - borderItemSize.height;
+ }
+ } else if (suggestedSide == PositionConstants.EAST) {
+ if (suggestedLocation.x != eastX) {
+ newX = eastX;
+ }
+ if (suggestedLocation.y < bounds.getTopLeft().y) {
+ newY = northY + borderItemSize.height;
+ } else if (suggestedLocation.y > bounds.getBottomLeft().y - borderItemSize.height) {
+ newY = southY - borderItemSize.height;
+ }
+ } else if (suggestedSide == PositionConstants.SOUTH) {
+ if (suggestedLocation.y != southY) {
+ newY = southY;
+ }
+ if (suggestedLocation.x < bounds.getBottomLeft().x) {
+ newX = westX + borderItemSize.width;
+ } else if (suggestedLocation.x > bounds.getBottomRight().x - borderItemSize.width) {
+ newX = eastX - borderItemSize.width;
+ }
+ } else { // NORTH
+ if (suggestedLocation.y != northY) {
+ newY = northY;
+ }
+ if (suggestedLocation.x < bounds.getBottomLeft().x) {
+ newX = westX + borderItemSize.width;
+ } else if (suggestedLocation.x > bounds.getBottomRight().x - borderItemSize.width) {
+ newX = eastX - borderItemSize.width;
+ }
+ }
+ return new Point(newX, newY);
+ }
+
+ /**
+ * Determine if the the given point conflicts with the position of an
+ * existing borderItemFigure and returns the conflicting border item figure.
+ *
+ * @param recommendedLocation
+ * the recommended location
+ * @param targetBorderItem
+ * the target border item
+ * @return the conflicting border item figure
+ */
+ protected IFigure getConflictingBorderItemFigure(Point recommendedLocation, IFigure targetBorderItem) {
+ Rectangle recommendedRect = new Rectangle(recommendedLocation, getSize(targetBorderItem));
+ List borderItems = targetBorderItem.getParent().getChildren();
+ // Only check those border items that would have already been
+ // relocated. See Bugzilla#214799.
+ int currentIndex = borderItems.indexOf(targetBorderItem);
+ for (int i = 0; i < currentIndex; i++) {
+ IFigure borderItem = (IFigure) borderItems.get(i);
+ if (borderItem.isVisible()) {
+ Rectangle rect = borderItem.getBounds().getCopy();
+ if (rect.intersects(recommendedRect)) {
+ return borderItem;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * The preferred side takes precedence.
+ *
+ * @param suggestedLocation
+ * the suggested location
+ * @param suggestedSide
+ * the suggested side
+ * @param circuitCount
+ * recursion count to avoid an infinite loop
+ * @param borderItem
+ * the border item
+ * @return point
+ */
+ protected Point locateOnBorder(Point suggestedLocation, int suggestedSide, int circuitCount, IFigure borderItem) {
+ Point recommendedLocation = locateOnParent(suggestedLocation, suggestedSide, borderItem);
+ Dimension borderItemSize = getSize(borderItem);
+ IFigure conflictingBorderItem = getConflictingBorderItemFigure(recommendedLocation, borderItem);
+ if (circuitCount < 4 && conflictingBorderItem != null) {
+ if (suggestedSide == PositionConstants.WEST) {
+ do {
+ calculateNextNonConflictingPosition(recommendedLocation, interval, suggestedSide, borderItem, conflictingBorderItem.getBounds());
+ conflictingBorderItem = getConflictingBorderItemFigure(recommendedLocation, borderItem);
+ } while (conflictingBorderItem != null);
+ if (recommendedLocation.y > getParentBorder().getBottomLeft().y - borderItemSize.height) { // off the bottom,
+ // wrap south
+ return locateOnBorder(recommendedLocation, PositionConstants.SOUTH, circuitCount + 1, borderItem);
+ } else if (recommendedLocation.y < getParentBorder().getTopLeft().y - borderItemSize.height) { // off the top, wrap north
+ return locateOnBorder(recommendedLocation, PositionConstants.NORTH, circuitCount + 1, borderItem);
+ }
+ } else if (suggestedSide == PositionConstants.SOUTH) {
+ do {
+ calculateNextNonConflictingPosition(recommendedLocation, interval, suggestedSide, borderItem, conflictingBorderItem.getBounds());
+ conflictingBorderItem = getConflictingBorderItemFigure(recommendedLocation, borderItem);
+ } while (conflictingBorderItem != null);
+ if (recommendedLocation.x > getParentBorder().getBottomRight().x - borderItemSize.width) {
+ return locateOnBorder(recommendedLocation, PositionConstants.EAST, circuitCount + 1, borderItem);
+ } else if (recommendedLocation.x < getParentBorder().getBottomLeft().x - borderItemSize.width) {
+ return locateOnBorder(recommendedLocation, PositionConstants.WEST, circuitCount + 1, borderItem);
+ }
+ } else if (suggestedSide == PositionConstants.EAST) {
+ // move up the east side
+ do {
+ calculateNextNonConflictingPosition(recommendedLocation, interval, suggestedSide, borderItem, conflictingBorderItem.getBounds());
+ conflictingBorderItem = getConflictingBorderItemFigure(recommendedLocation, borderItem);
+ } while (conflictingBorderItem != null);
+ if (recommendedLocation.y < getParentBorder().getTopRight().y) {
+ // east is full, try north.
+ return locateOnBorder(recommendedLocation, PositionConstants.NORTH, circuitCount + 1, borderItem);
+ } else if (recommendedLocation.y > getParentBorder().getBottomRight().y) {
+ // east is full, try south.
+ return locateOnBorder(recommendedLocation, PositionConstants.SOUTH, circuitCount + 1, borderItem);
+ }
+ } else { // NORTH
+ do {
+ calculateNextNonConflictingPosition(recommendedLocation, interval, suggestedSide, borderItem, conflictingBorderItem.getBounds());
+ conflictingBorderItem = getConflictingBorderItemFigure(recommendedLocation, borderItem);
+ } while (conflictingBorderItem != null);
+ if (recommendedLocation.x < getParentBorder().getTopLeft().x) {
+ return locateOnBorder(recommendedLocation, PositionConstants.WEST, circuitCount + 1, borderItem);
+ } else if (recommendedLocation.x > getParentBorder().getTopRight().x) {
+ return locateOnBorder(recommendedLocation, PositionConstants.EAST, circuitCount + 1, borderItem);
+ }
+ }
+ }
+ return recommendedLocation;
+ }
+
+ /**
+ * Modifies the location of the border item (currentLocation) to avoid
+ * overlapping with the obstacle rectangle (another border item bounds).
+ *
+ * @param currentLocation
+ * The current location of the border item
+ * @param interval
+ * The suggested spacing to try to find the next non-conflicting
+ * position
+ * @param currentSide
+ * The current side of the border item
+ * @param borderItem
+ * The borderItem being relocated (here to be used by subclasses
+ * if needed)
+ * @param obstacle
+ * The bounds of the border item conflicting with the border item
+ * currently being relocated
+ */
+ protected void calculateNextNonConflictingPosition(Point currentLocation, int interval, int currentSide, IFigure borderItem, Rectangle obstacle) {
+ switch (currentSide) {
+ case PositionConstants.WEST:
+ currentLocation.y = obstacle.getBottomLeft().y + interval;
+ break;
+ case PositionConstants.SOUTH: // Move towards the east side
+ currentLocation.x = obstacle.getBottomRight().x + interval;
+ break;
+ case PositionConstants.EAST:
+ currentLocation.y = obstacle.getTopRight().y - interval - getSize(borderItem).height;
+ break;
+ case PositionConstants.NORTH: // Move towards the west side
+ currentLocation.x = obstacle.getTopLeft().x - interval - getSize(borderItem).width;
+ break;
+ default:
+ throw new IllegalArgumentException("Invalid side argument: " //$NON-NLS-1$
+ + currentSide + ". Should be the value from PositionConstants: WEST, EAST, NORTH or SOUTH"); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Convert the relative coords in the model to ones that are Relative to the
+ * container (absolute in respect to the main figure).
+ *
+ * @param ptRelativeOffset
+ * the pt relative offset
+ * @return point
+ */
+ protected Point getAbsoluteToBorder(Point ptRelativeOffset) {
+ Point parentOrigin = getParentBorder().getTopLeft();
+ return parentOrigin.translate(ptRelativeOffset);
+ }
+
+ /**
+ * @see org.eclipse.gmf.runtime.draw2d.ui.figures.IBorderItemLocator#getValidLocation(org.eclipse.draw2d.geometry.Rectangle, org.eclipse.draw2d.IFigure)
+ *
+ * @param proposedLocation
+ * @param borderItem
+ * @return
+ */
+ public Rectangle getValidLocation(Rectangle proposedLocation, IFigure borderItem) {
+ Rectangle realLocation = new Rectangle(proposedLocation);
+ if (!isLabelConstrained())
+ return realLocation;
+ int side = findClosestSideOfParent(proposedLocation, getParentBorder());
+ Point newTopLeft = locateOnBorder(realLocation.getTopLeft(), side, 0, borderItem);
+ realLocation.setLocation(newTopLeft);
+ return realLocation;
+ }
+
+ /**
+ * Checks if the label is constrained.
+ *
+ * @return true, if the label is constrained
+ */
+ public boolean isLabelConstrained() {
+ if (getParentFigure().getChildren().get(0) instanceof IRoundedRectangleFigure)
+ return ((IRoundedRectangleFigure) ((IFigure) getParentFigure().getChildren().get(0))).isFloatingNameConstrained();
+ return false;
+ }
+
+ /**
+ * Find the closest side when x,y is inside parent.
+ *
+ * @param proposedLocation
+ * the proposed location
+ * @param parentBorder
+ * the parent border
+ * @return draw constant
+ */
+ public static int findClosestSideOfParent(Rectangle proposedLocation, Rectangle parentBorder) {
+ // Rectangle parentBorder = getParentBorder();
+ Point parentCenter = parentBorder.getCenter();
+ Point childCenter = proposedLocation.getCenter();
+ if (childCenter.x < parentCenter.x) // West, North or South.
+ {
+ if (childCenter.y < parentCenter.y) // west or north
+ {
+ // closer to west or north?
+ Point parentTopLeft = parentBorder.getTopLeft();
+ if ((childCenter.x - parentTopLeft.x) <= (childCenter.y - parentTopLeft.y)) {
+ return PositionConstants.WEST;
+ } else {
+ return PositionConstants.NORTH;
+ }
+ } else { // west or south
+ Point parentBottomLeft = parentBorder.getBottomLeft();
+ if ((childCenter.x - parentBottomLeft.x) <= (parentBottomLeft.y - childCenter.y)) {
+ return PositionConstants.WEST;
+ } else {
+ return PositionConstants.SOUTH;
+ }
+ }
+ } else { // EAST, NORTH or SOUTH
+ if (childCenter.y < parentCenter.y) // north or east
+ {
+ Point parentTopRight = parentBorder.getTopRight();
+ if ((parentTopRight.x - childCenter.x) <= (childCenter.y - parentTopRight.y)) {
+ return PositionConstants.EAST;
+ } else {
+ return PositionConstants.NORTH;
+ }
+ } else { // south or east.
+ Point parentBottomRight = parentBorder.getBottomRight();
+ if ((parentBottomRight.x - childCenter.x) <= (parentBottomRight.y - childCenter.y)) {
+ return PositionConstants.EAST;
+ } else {
+ return PositionConstants.SOUTH;
+ }
+ }
+ }
+ }
+
+ /**
+ * Relocate the label
+ *
+ * @see org.eclipse.draw2d.Locator#relocate(org.eclipse.draw2d.IFigure)
+ *
+ * @param target
+ */
+
+ public void relocate(IFigure target) {
+ Dimension size = getSize(target);
+
+ // set the position of the floating label by setting the bounds
+ if (!isLabelConstrained()) {
+ // If you want to fix the label use this code
+ // Rectangle proposedBounds = constraint.getCopy();//To block the Label
+ // proposedBounds.setLocation((parentFigure.getBounds().getTopLeft().translate(getFloatingItemOffset())));//To block the Label
+ // proposedBounds.setSize(target.getPreferredSize());//To block the Label
+ // target.setBounds(proposedBounds);//To block the Label
+
+ super.relocate(target);
+ // target.setBounds(new Rectangle(getPreferredLocation(target), size));
+
+ } else {
+ Rectangle rectSuggested = new Rectangle(getPreferredLocation(target), size);
+ if (constraint.x == 0 && constraint.y == 0) {
+ // if setting back to the original position, use the preferred
+ // side that client indicated then
+ setPreferredSideOfParent(originalPreferredSide);
+ } else {
+ int closestSide = findClosestSideOfParent(rectSuggested, getParentBorder());
+ setPreferredSideOfParent(closestSide);
+ }
+ Point ptNewLocation = locateOnBorder(getPreferredLocation(target), getPreferredSideOfParent(), 0, target);
+ Rectangle proposedBounds = new Rectangle(ptNewLocation, size);
+
+ // Translate the label when it's on north or on south according to the text alignment
+ switch (getPreferredSideOfParent()) {
+ case PositionConstants.NORTH:
+ case PositionConstants.SOUTH:
+ int x;
+ // Set Location
+ switch (getTextAlignment()) {
+ case PositionConstants.LEFT:
+ x = 0;
+ break;
+ case PositionConstants.RIGHT:
+ x = -proposedBounds.width;
+ break;
+ case PositionConstants.CENTER:
+ x = -proposedBounds.width / 2;
+ break;
+ default:
+ x = 0;
+ break;
+ }
+ proposedBounds.translate(x, 0);
+ break;
+ default:
+ break;
+ }
+
+ target.setBounds(proposedBounds);
+ setCurrentSideOfParent(findClosestSideOfParent(new Rectangle(ptNewLocation, size), getParentBorder()));
+ }
+ }
+
+ /**
+ * getter for the parent figure.
+ *
+ * @return <code>IFigure</code>
+ */
+ public IFigure getParentFigure() {
+ return parentFigure;
+ }
+
+ /**
+ * Gets the border item offset.
+ *
+ * @return Returns the borderItemOffset.
+ */
+ public Dimension getBorderItemOffset() {
+ return borderItemOffset;
+ }
+
+ /**
+ * Sets the border item offset.
+ *
+ * @param borderItemOffset
+ * The borderItemOffset to set.
+ */
+ public void setBorderItemOffset(Dimension borderItemOffset) {
+ this.borderItemOffset = borderItemOffset;
+ }
+
+ /**
+ * Returns the preferred side of the parent figure on which to place this
+ * border item.
+ *
+ * @return the preferred side of the parent figure on which to place this
+ * border item as defined in {@link PositionConstants}
+ */
+ public int getPreferredSideOfParent() {
+ return preferredSide;
+ }
+
+ /**
+ * Sets the preferred side of the parent figure on which to place this
+ * border item.
+ *
+ * @param preferredSide
+ * the preferred side of the parent figure on which to place this
+ * border item as defined in {@link PositionConstants}
+ */
+ public void setPreferredSideOfParent(int preferredSide) {
+ this.preferredSide = preferredSide;
+ setCurrentSideOfParent(preferredSide);
+ }
+
+ /**
+ * @see org.eclipse.gmf.runtime.draw2d.ui.figures.IBorderItemLocator#getCurrentSideOfParent()
+ *
+ * @return
+ */
+ public int getCurrentSideOfParent() {
+ if (!isLabelConstrained())
+ return PositionConstants.NONE;
+ return currentSide;
+ }
+
+ /**
+ * Sets the side of the parent figure on which the border item should
+ * appear.
+ *
+ * @param side
+ * the side on which this border item appears as defined in {@link PositionConstants}
+ */
+ public void setCurrentSideOfParent(int side) {
+ this.currentSide = side;
+ }
+
+ /**
+ * Gets the size of the border item figure.
+ *
+ * @param borderItem
+ * the border item
+ * @return the size of the border item figure.
+ */
+ protected final Dimension getSize(IFigure borderItem) {
+ Dimension size = getConstraint().getSize();
+ if (size.isEmpty()) {
+ size = borderItem.getPreferredSize();
+ }
+ return size;
+ }
+
+ /**
+ * Sets the floating item offset.
+ *
+ * @param dimension
+ * the new floating item offset
+ */
+ public void setFloatingItemOffset(Dimension dimension) {
+ if (getParentFigure().getChildren().get(0) instanceof IRoundedRectangleFigure)
+ // Set the rounded rectangle figure offset properties
+ ((IRoundedRectangleFigure) ((IFigure) getParentFigure().getChildren().get(0))).setFloatingNameOffset(dimension);
+ }
+
+ /**
+ * Gets the floating item offset.
+ *
+ * @return the floating item offset
+ */
+ public Dimension getFloatingItemOffset() {
+ if (getParentFigure().getChildren().get(0) instanceof IRoundedRectangleFigure)
+ // Get the rounded rectangle figure offset properties
+ return ((IRoundedRectangleFigure) ((IFigure) getParentFigure().getChildren().get(0))).getFloatingNameOffset();
+ return new Dimension();
+ }
+}

Back to the top