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
a47e1a9d
Commit
a47e1a9d
authored
13 years ago
by
Daniel Ratiu
Browse files
Options
Downloads
Patches
Plain Diff
resolving this issue
refs 332
parent
159cc390
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/editor/DiagramEditorBase.java
+82
-1
82 additions, 1 deletion
...org/fortiss/tooling/base/ui/editor/DiagramEditorBase.java
with
82 additions
and
1 deletion
org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editor/DiagramEditorBase.java
+
82
−
1
View file @
a47e1a9d
...
...
@@ -19,9 +19,14 @@ package org.fortiss.tooling.base.ui.editor;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
org.conqat.ide.commons.gef.editpart.EditPartUtils
;
import
org.eclipse.draw2d.ColorConstants
;
import
org.eclipse.draw2d.IFigure
;
import
org.eclipse.draw2d.geometry.Dimension
;
import
org.eclipse.draw2d.geometry.Point
;
import
org.eclipse.emf.ecore.EObject
;
...
...
@@ -37,6 +42,7 @@ import org.eclipse.gef.RootEditPart;
import
org.eclipse.gef.SnapToGeometry
;
import
org.eclipse.gef.SnapToGrid
;
import
org.eclipse.gef.commands.CommandStack
;
import
org.eclipse.gef.editparts.AbstractGraphicalEditPart
;
import
org.eclipse.gef.editparts.ScalableFreeformRootEditPart
;
import
org.eclipse.gef.editparts.ScalableRootEditPart
;
import
org.eclipse.gef.editparts.ZoomManager
;
...
...
@@ -59,6 +65,7 @@ import org.eclipse.jface.viewers.IPostSelectionProvider;
import
org.eclipse.jface.viewers.ISelection
;
import
org.eclipse.jface.viewers.ISelectionChangedListener
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.graphics.Color
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.swt.widgets.Menu
;
import
org.eclipse.ui.IActionBars
;
...
...
@@ -70,6 +77,7 @@ import org.eclipse.ui.PartInitException;
import
org.fortiss.tooling.base.layout.DefaultLayoutConstants
;
import
org.fortiss.tooling.base.ui.ToolingBaseUIActivator
;
import
org.fortiss.tooling.base.ui.dnd.ElementCompositionDropTargetListener
;
import
org.fortiss.tooling.base.ui.editpart.ConnectorEditPartBase
;
import
org.fortiss.tooling.base.ui.editpart.ExtendedLayerRootEditPart
;
import
org.fortiss.tooling.base.ui.editpart.figure.EVisualStyle
;
import
org.fortiss.tooling.kernel.ui.extension.base.EObjectActionBase
;
...
...
@@ -86,7 +94,7 @@ import org.fortiss.tooling.kernel.ui.util.EObjectSelectionUtils;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 6
3FF468A2D042586A22495828A0798EF
* @ConQAT.Rating YELLOW Hash: 6
8835BEA73B1CA070BA7EAD5C14D8C00
*/
public
class
DiagramEditorBase
<
T
extends
EObject
>
extends
GEFEditorBase
<
T
>
implements
IPostSelectionProvider
,
ContextMenuContextProvider
{
...
...
@@ -435,4 +443,77 @@ public class DiagramEditorBase<T extends EObject> extends GEFEditorBase<T>
public
void
setSelection
(
ISelection
selection
)
{
viewer
.
setSelection
(
selection
);
}
/** {@inheritDoc} */
@Override
public
void
setHighlight
(
EObject
element
,
boolean
highlighted
)
{
EditPart
ep
=
findEditPart
(
viewer
.
getRootEditPart
(),
element
);
if
(
ep
instanceof
AbstractGraphicalEditPart
)
{
IFigure
fig
=
((
AbstractGraphicalEditPart
)
ep
).
getFigure
();
setHighlight
(
fig
,
highlighted
);
}
}
/**
* Highlights a figure by setting its color to be RED. This implementation
* can be changed by more specific editors.
*/
protected
void
setHighlight
(
IFigure
fig
,
boolean
highlighted
)
{
if
(
highlighted
)
{
highlightedFigures2NormalColor
.
put
(
fig
,
fig
.
getForegroundColor
());
fig
.
setForegroundColor
(
ColorConstants
.
red
);
}
else
{
Color
normalColor
=
highlightedFigures2NormalColor
.
get
(
fig
);
fig
.
setForegroundColor
(
normalColor
);
highlightedFigures2NormalColor
.
remove
(
fig
);
}
}
/**
* A map from figures that are currently highlighted to their normal
* foreground color.
*/
private
HashMap
<
IFigure
,
Color
>
highlightedFigures2NormalColor
=
new
HashMap
<
IFigure
,
Color
>();
/**
* Returns the edit part corresponding to the EObject or null if it cannot
* be found.
*/
@SuppressWarnings
(
"unchecked"
)
private
EditPart
findEditPart
(
EditPart
container
,
EObject
element
)
{
if
(
container
.
getModel
().
equals
(
element
))
{
return
container
;
}
List
<
EditPart
>
subEditParts
=
new
ArrayList
<
EditPart
>();
if
(
container
.
getChildren
()
!=
null
)
{
subEditParts
.
addAll
(
container
.
getChildren
());
}
if
(
container
instanceof
ConnectorEditPartBase
)
{
ConnectorEditPartBase
<?>
connector
=
(
ConnectorEditPartBase
<?>)
container
;
if
(
connector
.
getSourceConnections
()
!=
null
)
{
subEditParts
.
addAll
(
connector
.
getSourceConnections
());
}
}
for
(
EditPart
child
:
subEditParts
)
{
EditPart
foundEditPart
=
findEditPart
(
child
,
element
);
if
(
foundEditPart
!=
null
)
{
return
foundEditPart
;
}
}
return
null
;
}
/** {@inheritDoc} */
@Override
public
void
clearAllHighlights
()
{
Set
<
IFigure
>
figs
=
new
HashSet
<
IFigure
>(
highlightedFigures2NormalColor
.
keySet
());
for
(
IFigure
figure
:
figs
)
{
setHighlight
(
figure
,
false
);
}
}
}
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