Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kernel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
af3
kernel
Commits
7faffeab
Commit
7faffeab
authored
9 years ago
by
Johannes Eder
Browse files
Options
Downloads
Patches
Plain Diff
sub diagram labels
refs 2446
parent
72a55e6f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editpart/allocation/AllocationSubDiagramEditPartBase.java
+92
-14
92 additions, 14 deletions
...editpart/allocation/AllocationSubDiagramEditPartBase.java
with
92 additions
and
14 deletions
org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editpart/allocation/AllocationSubDiagramEditPartBase.java
+
92
−
14
View file @
7faffeab
...
...
@@ -17,14 +17,19 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
+--------------------------------------------------------------------------*/
package
org.fortiss.tooling.base.ui.editpart.allocation
;
import
static
org
.
fortiss
.
tooling
.
base
.
layout
.
DefaultLayoutConstants
.
DEFAULT_SHAPE_INSETS
;
import
static
org
.
fortiss
.
tooling
.
base
.
ui
.
editpart
.
ExtendedLayerRootEditPart
.
DECORATION_LAYER
;
import
static
org
.
fortiss
.
tooling
.
base
.
ui
.
editpart
.
ExtendedLayerRootEditPart
.
LABEL_LAYER
;
import
static
org
.
fortiss
.
tooling
.
base
.
ui
.
utils
.
DecorationIconUtils
.
getMarkerServiceDecorationIcon
;
import
static
org
.
fortiss
.
tooling
.
kernel
.
utils
.
KernelModelElementUtils
.
getParentElement
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.conqat.ide.commons.ui.swt.FontUtils
;
import
org.eclipse.draw2d.IFigure
;
import
org.eclipse.draw2d.Label
;
import
org.eclipse.draw2d.PositionConstants
;
import
org.eclipse.draw2d.geometry.Insets
;
import
org.eclipse.draw2d.geometry.Point
;
import
org.eclipse.draw2d.geometry.Rectangle
;
...
...
@@ -34,16 +39,22 @@ import org.eclipse.gef.NodeEditPart;
import
org.eclipse.gef.Request
;
import
org.eclipse.gef.RequestConstants
;
import
org.eclipse.gef.RootEditPart
;
import
org.eclipse.jface.resource.JFaceResources
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.graphics.Color
;
import
org.eclipse.swt.graphics.Font
;
import
org.fortiss.tooling.base.layout.DefaultLayoutConstants
;
import
org.fortiss.tooling.base.model.element.IHierarchicElement
;
import
org.fortiss.tooling.base.model.layout.ILayoutedModelElement
;
import
org.fortiss.tooling.base.ui.editpart.GraphicalEditPartBase
;
import
org.fortiss.tooling.base.ui.editpart.PositionedEditPartBase
;
import
org.fortiss.tooling.base.ui.editpart.figure.PrettyRoundedRectangle
;
import
org.fortiss.tooling.base.ui.editpart.figure.TransparentLabel
;
import
org.fortiss.tooling.base.ui.layout.IDiagramLayoutConfiguration
;
import
org.fortiss.tooling.kernel.extension.data.IConstraintViolation.ESeverity
;
import
org.fortiss.tooling.kernel.model.INamedCommentedElement
;
import
org.fortiss.tooling.kernel.ui.service.IMarkerService
;
import
org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService
;
/**
* Implementation similar to {@link PositionedEditPartBase} except that <b>T</b> does not have to be
...
...
@@ -56,7 +67,7 @@ import org.fortiss.tooling.kernel.ui.service.IMarkerService;
* @param <T>
* @ConQAT.Rating RED Hash:
*/
public
abstract
class
AllocationSubDiagramEditPartBase
<
T
extends
EObjec
t
>
extends
public
abstract
class
AllocationSubDiagramEditPartBase
<
T
extends
INamedCommentedElemen
t
>
extends
GraphicalEditPartBase
<
T
>
implements
NodeEditPart
{
/** The base figure of this positioned edit part. */
...
...
@@ -73,6 +84,9 @@ public abstract class AllocationSubDiagramEditPartBase<T extends EObject> extend
/** List of all children visible in this edit part. */
private
List
<?>
modelChildren
=
new
ArrayList
<>();
/** The default font for titles. */
public
static
Font
DEFAULT_TITLE_FONT
=
FontUtils
.
derive
(
JFaceResources
.
getDefaultFont
(),
0
,
SWT
.
BOLD
);
/**
* @param modelElement
...
...
@@ -100,6 +114,73 @@ public abstract class AllocationSubDiagramEditPartBase<T extends EObject> extend
return
prettyRoundedRectangle
;
}
/** Creates the label figure. */
public
Label
createLabelFigure
()
{
Label
nameLabel
=
new
TransparentLabel
();
nameLabel
.
setForegroundColor
(
getForegroundColor
());
nameLabel
.
setFont
(
DEFAULT_TITLE_FONT
);
nameLabel
.
setTextAlignment
(
PositionConstants
.
LEFT
|
PositionConstants
.
TOP
);
nameLabel
.
setTextPlacement
(
PositionConstants
.
EAST
);
nameLabel
.
setIcon
(
IModelElementHandlerService
.
INSTANCE
.
getModelElementHandler
(
getModel
())
.
getIcon
(
getModel
()));
return
nameLabel
;
}
/**
* Creates the decoration figure. The default implementation does not create
* a figure.
*/
protected
Label
createDecorationFigure
()
{
return
new
TransparentLabel
();
}
/** {@inheritDoc} */
@Override
public
void
addNotify
()
{
labelFigure
=
createLabelFigure
();
if
(
labelFigure
!=
null
)
{
registerLabelFigure
(
labelFigure
);
}
decorationFigure
=
createDecorationFigure
();
if
(
decorationFigure
!=
null
)
{
registerDecorationFigure
(
decorationFigure
);
}
// called last, since it also refreshes label and decoration
super
.
addNotify
();
}
/** {@inheritDoc} */
@Override
public
void
removeNotify
()
{
if
(
labelFigure
!=
null
&&
labelFigure
.
getParent
()
!=
null
)
{
labelFigure
.
getParent
().
remove
(
labelFigure
);
}
if
(
decorationFigure
!=
null
&&
decorationFigure
.
getParent
()
!=
null
)
{
decorationFigure
.
getParent
().
remove
(
decorationFigure
);
}
super
.
removeNotify
();
}
/**
* Register the new label figure into the label figure structure.
*/
protected
void
registerLabelFigure
(
IFigure
figure
)
{
if
(
getParent
()
instanceof
AllocationSubDiagramEditPartBase
)
((
AllocationSubDiagramEditPartBase
<?>)
getParent
()).
registerLabelFigure
(
figure
);
else
getLayer
(
LABEL_LAYER
).
add
(
figure
);
}
/**
* Register the new decoration figure into the decoration figure structure.
*/
protected
void
registerDecorationFigure
(
IFigure
figure
)
{
if
(
getParent
()
instanceof
AllocationSubDiagramEditPartBase
)
((
AllocationSubDiagramEditPartBase
<?>)
getParent
()).
registerDecorationFigure
(
figure
);
else
getLayer
(
DECORATION_LAYER
).
add
(
figure
);
}
/** {@inheritDoc} */
@Override
protected
final
List
<?>
getModelChildren
()
{
...
...
@@ -199,7 +280,15 @@ public abstract class AllocationSubDiagramEditPartBase<T extends EObject> extend
* implementation returns an invisible rectangle.
*/
protected
Rectangle
determineLabelFigureBounds
()
{
return
new
Rectangle
();
Rectangle
textBounds
=
labelFigure
.
getTextBounds
();
textBounds
.
y
=
DEFAULT_SHAPE_INSETS
/
2
;
textBounds
.
x
=
DEFAULT_SHAPE_INSETS
;
textBounds
.
width
=
textBounds
.
width
+
4
*
DEFAULT_SHAPE_INSETS
;
textBounds
.
height
=
textBounds
.
height
*
2
;
if
(
isTargetDiagram
())
{
textBounds
.
y
+=
baseFigure
.
getBounds
().
y
;
}
return
textBounds
;
}
/**
...
...
@@ -208,7 +297,7 @@ public abstract class AllocationSubDiagramEditPartBase<T extends EObject> extend
* implementation returns an empty string.
*/
protected
String
determineLabelFigureText
()
{
return
getModel
().
toString
();
return
getModel
().
getName
();
}
/** Returns the current tooltip description. */
...
...
@@ -279,15 +368,4 @@ public abstract class AllocationSubDiagramEditPartBase<T extends EObject> extend
}
}
/** {@inheritDoc} */
@Override
public
void
removeNotify
()
{
if
(
labelFigure
!=
null
&&
labelFigure
.
getParent
()
!=
null
)
{
labelFigure
.
getParent
().
remove
(
labelFigure
);
}
if
(
decorationFigure
!=
null
&&
decorationFigure
.
getParent
()
!=
null
)
{
decorationFigure
.
getParent
().
remove
(
decorationFigure
);
}
super
.
removeNotify
();
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment