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
d905681a
Commit
d905681a
authored
12 years ago
by
Kisslinger
Browse files
Options
Downloads
Patches
Plain Diff
MSCs are now added to the report (as images)
refs 290
parent
c6c831c6
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
+56
-62
56 additions, 62 deletions
...org/fortiss/tooling/base/ui/editor/DiagramEditorBase.java
with
56 additions
and
62 deletions
org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editor/DiagramEditorBase.java
+
56
−
62
View file @
d905681a
...
...
@@ -97,10 +97,10 @@ import org.fortiss.tooling.kernel.ui.util.EObjectSelectionUtils;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating
GREEN
Hash: D2
4DC3964E442C60B5F30A1EC8EBB3D0
* @ConQAT.Rating
YELLOW
Hash:
2
D2
A8FF3A3D4451380702E1183DFE746
*/
public
class
DiagramEditorBase
<
T
extends
EObject
>
extends
GEFEditorBase
<
T
>
implements
IPostSelectionProvider
,
ContextMenuContextProvider
{
public
class
DiagramEditorBase
<
T
extends
EObject
>
extends
GEFEditorBase
<
T
>
implements
IPostSelectionProvider
,
ContextMenuContextProvider
{
/** Stores the viewer. */
protected
EditPartViewer
viewer
=
new
ScrollingGraphicalViewer
();
...
...
@@ -130,8 +130,7 @@ public class DiagramEditorBase<T extends EObject> extends GEFEditorBase<T>
/** {@inheritDoc} */
@Override
public
void
init
(
IEditorSite
site
,
IEditorInput
input
)
throws
PartInitException
{
public
void
init
(
IEditorSite
site
,
IEditorInput
input
)
throws
PartInitException
{
super
.
init
(
site
,
input
);
getSite
().
getWorkbenchWindow
().
getSelectionService
()
...
...
@@ -142,17 +141,16 @@ public class DiagramEditorBase<T extends EObject> extends GEFEditorBase<T>
/** {@inheritDoc} */
@Override
public
EObject
getSelectedModelElement
()
{
if
(
getSite
().
getSelectionProvider
()
!=
null
)
{
return
EObjectSelectionUtils
.
getFirstElement
(
getSite
()
.
getSelectionProvider
()
.
getSelection
());
if
(
getSite
().
getSelectionProvider
()
!=
null
)
{
return
EObjectSelectionUtils
.
getFirstElement
(
getSite
()
.
getSelectionProvider
()
.
getSelection
());
}
return
null
;
}
/** Creates the context menu. */
private
void
createContextMenu
()
{
MenuManager
menuManager
=
IContextMenuService
.
INSTANCE
.
createDefaultContextMenu
(
this
);
MenuManager
menuManager
=
IContextMenuService
.
INSTANCE
.
createDefaultContextMenu
(
this
);
Menu
contextMenu
=
menuManager
.
createContextMenu
(
viewer
.
getControl
());
viewer
.
getControl
().
setMenu
(
contextMenu
);
...
...
@@ -181,18 +179,16 @@ public class DiagramEditorBase<T extends EObject> extends GEFEditorBase<T>
createZoomSupport
();
// drag and drop
viewer
.
addDropTargetListener
(
new
ElementCompositionDropTargetListener
(
viewer
));
viewer
.
addDropTargetListener
(
new
ElementCompositionDropTargetListener
(
viewer
));
viewer
.
getControl
().
setBackground
(
parent
.
getBackground
());
if
(
enableSnapToGrid
())
{
if
(
enableSnapToGrid
())
{
viewer
.
setProperty
(
SnapToGeometry
.
PROPERTY_SNAP_ENABLED
,
true
);
viewer
.
setProperty
(
SnapToGrid
.
PROPERTY_GRID_ORIGIN
,
new
Point
(
DEFAULT_GRID_ORIGIN_X
,
DEFAULT_GRID_ORIGIN_Y
));
viewer
.
setProperty
(
SnapToGrid
.
PROPERTY_GRID_ORIGIN
,
new
Point
(
DEFAULT_GRID_ORIGIN_X
,
DEFAULT_GRID_ORIGIN_Y
));
Dimension
gridSpacing
=
new
Dimension
(
DEFAULT_GRID_SIZE
,
DEFAULT_GRID_SIZE
);
Dimension
gridSpacing
=
new
Dimension
(
DEFAULT_GRID_SIZE
,
DEFAULT_GRID_SIZE
);
viewer
.
setProperty
(
SnapToGrid
.
PROPERTY_GRID_SPACING
,
gridSpacing
);
viewer
.
setProperty
(
SnapToGrid
.
PROPERTY_GRID_ENABLED
,
true
);
viewer
.
setProperty
(
SnapToGrid
.
PROPERTY_GRID_VISIBLE
,
true
);
...
...
@@ -200,12 +196,11 @@ public class DiagramEditorBase<T extends EObject> extends GEFEditorBase<T>
// this is needed by direct connection feature. the root edit part
// becomes transparent when GEF selects a tool on button down event.
// we have to relocate the call to the underlying root's content
((
ScalableRootEditPart
)
viewer
.
getRootEditPart
()).
installEditPolicy
(
"Test"
,
new
AbstractEditPolicy
()
{
((
ScalableRootEditPart
)
viewer
.
getRootEditPart
()).
installEditPolicy
(
"Test"
,
new
AbstractEditPolicy
()
{
@Override
public
EditPart
getTargetEditPart
(
Request
request
)
{
return
getHost
().
getRoot
().
getContents
()
.
getTargetEditPart
(
request
);
return
getHost
().
getRoot
().
getContents
().
getTargetEditPart
(
request
);
}
});
}
...
...
@@ -220,8 +215,8 @@ public class DiagramEditorBase<T extends EObject> extends GEFEditorBase<T>
}
/**
* Returns whether snap-to-grid should be enabled. The default is
*
<code>true</code>. IMPORTANT:
The return value provided here must match
* Returns whether snap-to-grid should be enabled. The default is
<code>true</code>. IMPORTANT:
* The return value provided here must match
* the value of {@link IDiagramLayoutConfiguration#useGrid()} provided by
* the {@link DiagramEditPartBase} of the diagram element.
*/
...
...
@@ -235,14 +230,13 @@ public class DiagramEditorBase<T extends EObject> extends GEFEditorBase<T>
/** Installs zoom suport for this graphical viewer. */
private
void
createZoomSupport
()
{
RootEditPart
rootPart
=
viewer
.
getRootEditPart
();
if
(
rootPart
instanceof
ScalableFreeformRootEditPart
)
{
zoomManager
=
((
ScalableFreeformRootEditPart
)
rootPart
)
.
getZoomManager
();
}
else
if
(
viewer
.
getRootEditPart
()
instanceof
ScalableRootEditPart
)
{
zoomManager
=
((
ScalableRootEditPart
)
rootPart
).
getZoomManager
();
if
(
rootPart
instanceof
ScalableFreeformRootEditPart
)
{
zoomManager
=
((
ScalableFreeformRootEditPart
)
rootPart
).
getZoomManager
();
}
else
if
(
viewer
.
getRootEditPart
()
instanceof
ScalableRootEditPart
)
{
zoomManager
=
((
ScalableRootEditPart
)
rootPart
).
getZoomManager
();
}
if
(
zoomManager
!=
null
)
{
if
(
zoomManager
!=
null
)
{
zoomManager
.
setZoomLevelContributions
(
getZoomLevelContributions
());
registerZoomAction
();
}
...
...
@@ -274,11 +268,11 @@ public class DiagramEditorBase<T extends EObject> extends GEFEditorBase<T>
@Override
public
Object
getAdapter
(
Class
adapter
)
{
// This is called, e.g., from the PrintAction
if
(
adapter
==
GraphicalViewer
.
class
)
{
if
(
adapter
==
GraphicalViewer
.
class
)
{
return
viewer
;
}
// This adapter is required for the ZoomComboContributionItem
if
(
adapter
==
ZoomManager
.
class
)
{
if
(
adapter
==
ZoomManager
.
class
)
{
return
getZoomManager
();
}
return
super
.
getAdapter
(
adapter
);
...
...
@@ -304,8 +298,8 @@ public class DiagramEditorBase<T extends EObject> extends GEFEditorBase<T>
/**
* Default zoom level contributions.
*/
private
static
final
List
<
String
>
defaultZoomLevelContribution
=
Arrays
.
asList
(
new
String
[]
{
FIT_ALL
,
FIT_WIDTH
,
FIT_HEIGHT
});
private
static
final
List
<
String
>
defaultZoomLevelContribution
=
Arrays
.
asList
(
new
String
[]
{
FIT_ALL
,
FIT_WIDTH
,
FIT_HEIGHT
});
/** Registers global actions (including zoom action). */
@Override
...
...
@@ -348,7 +342,7 @@ public class DiagramEditorBase<T extends EObject> extends GEFEditorBase<T>
* prevent the action registering.
*/
protected
void
registerEditActions
()
{
registerSelectionAction
(
new
DeleteAction
((
IWorkbenchPart
)
this
));
registerSelectionAction
(
new
DeleteAction
((
IWorkbenchPart
)
this
));
}
/** Registers and returns the id of the given selection action */
...
...
@@ -367,15 +361,15 @@ public class DiagramEditorBase<T extends EObject> extends GEFEditorBase<T>
}
/** Updates a list of actions. */
@SuppressWarnings
({
"rawtypes"
,
"unchecked"
})
@SuppressWarnings
({
"rawtypes"
,
"unchecked"
})
private
void
updateActions
(
List
<
String
>
actionIds
)
{
EObject
element
=
getSelectedModelElement
();
for
(
String
id
:
actionIds
)
{
for
(
String
id
:
actionIds
)
{
IAction
action
=
actionRegistry
.
getAction
(
id
);
if
(
action
instanceof
UpdateAction
)
{
((
UpdateAction
)
action
).
update
();
}
else
if
(
action
instanceof
EObjectActionBase
)
{
((
EObjectActionBase
)
action
).
refresh
(
element
);
if
(
action
instanceof
UpdateAction
)
{
((
UpdateAction
)
action
).
update
();
}
else
if
(
action
instanceof
EObjectActionBase
)
{
((
EObjectActionBase
)
action
).
refresh
(
element
);
}
}
}
...
...
@@ -398,15 +392,13 @@ public class DiagramEditorBase<T extends EObject> extends GEFEditorBase<T>
/** {@inheritDoc} */
@Override
public
void
addPostSelectionChangedListener
(
ISelectionChangedListener
listener
)
{
public
void
addPostSelectionChangedListener
(
ISelectionChangedListener
listener
)
{
viewer
.
addSelectionChangedListener
(
listener
);
}
/** {@inheritDoc} */
@Override
public
void
removePostSelectionChangedListener
(
ISelectionChangedListener
listener
)
{
public
void
removePostSelectionChangedListener
(
ISelectionChangedListener
listener
)
{
viewer
.
removeSelectionChangedListener
(
listener
);
}
...
...
@@ -424,8 +416,7 @@ public class DiagramEditorBase<T extends EObject> extends GEFEditorBase<T>
/** {@inheritDoc} */
@Override
public
void
removeSelectionChangedListener
(
ISelectionChangedListener
listener
)
{
public
void
removeSelectionChangedListener
(
ISelectionChangedListener
listener
)
{
viewer
.
removeSelectionChangedListener
(
listener
);
}
...
...
@@ -439,8 +430,8 @@ public class DiagramEditorBase<T extends EObject> extends GEFEditorBase<T>
@Override
public
void
setHighlight
(
EObject
element
,
boolean
highlighted
)
{
EditPart
ep
=
findEditPart
(
viewer
.
getRootEditPart
(),
element
);
if
(
ep
instanceof
AbstractGraphicalEditPart
)
{
IFigure
fig
=
((
AbstractGraphicalEditPart
)
ep
).
getFigure
();
if
(
ep
instanceof
AbstractGraphicalEditPart
)
{
IFigure
fig
=
((
AbstractGraphicalEditPart
)
ep
).
getFigure
();
setHighlight
(
fig
,
highlighted
);
}
}
...
...
@@ -450,10 +441,9 @@ public class DiagramEditorBase<T extends EObject> extends GEFEditorBase<T>
* can be changed by more specific editors.
*/
protected
void
setHighlight
(
IFigure
fig
,
boolean
highlighted
)
{
if
(
highlighted
)
{
if
(!
highlightedFigures2NormalColor
.
containsKey
(
fig
))
{
highlightedFigures2NormalColor
.
put
(
fig
,
fig
.
getForegroundColor
());
if
(
highlighted
)
{
if
(!
highlightedFigures2NormalColor
.
containsKey
(
fig
))
{
highlightedFigures2NormalColor
.
put
(
fig
,
fig
.
getForegroundColor
());
fig
.
setForegroundColor
(
ColorConstants
.
red
);
}
}
else
{
...
...
@@ -475,24 +465,24 @@ public class DiagramEditorBase<T extends EObject> extends GEFEditorBase<T>
*/
@SuppressWarnings
(
"unchecked"
)
private
EditPart
findEditPart
(
EditPart
container
,
EObject
element
)
{
if
(
container
.
getModel
().
equals
(
element
))
{
if
(
container
.
getModel
().
equals
(
element
))
{
return
container
;
}
List
<
EditPart
>
subEditParts
=
new
ArrayList
<
EditPart
>();
if
(
container
.
getChildren
()
!=
null
)
{
if
(
container
.
getChildren
()
!=
null
)
{
subEditParts
.
addAll
(
container
.
getChildren
());
}
if
(
container
instanceof
ConnectorEditPartBase
)
{
ConnectorEditPartBase
<?>
connector
=
(
ConnectorEditPartBase
<?>)
container
;
if
(
connector
.
getSourceConnections
()
!=
null
)
{
if
(
container
instanceof
ConnectorEditPartBase
)
{
ConnectorEditPartBase
<?>
connector
=
(
ConnectorEditPartBase
<?>)
container
;
if
(
connector
.
getSourceConnections
()
!=
null
)
{
subEditParts
.
addAll
(
connector
.
getSourceConnections
());
}
}
for
(
EditPart
child
:
subEditParts
)
{
for
(
EditPart
child
:
subEditParts
)
{
EditPart
foundEditPart
=
findEditPart
(
child
,
element
);
if
(
foundEditPart
!=
null
)
{
if
(
foundEditPart
!=
null
)
{
return
foundEditPart
;
}
}
...
...
@@ -503,11 +493,15 @@ public class DiagramEditorBase<T extends EObject> extends GEFEditorBase<T>
/** {@inheritDoc} */
@Override
public
void
clearAllHighlights
()
{
Set
<
IFigure
>
figs
=
new
HashSet
<
IFigure
>(
highlightedFigures2NormalColor
.
keySet
());
Set
<
IFigure
>
figs
=
new
HashSet
<
IFigure
>(
highlightedFigures2NormalColor
.
keySet
());
for
(
IFigure
figure
:
figs
)
{
for
(
IFigure
figure
:
figs
)
{
setHighlight
(
figure
,
false
);
}
}
/** Returns viewer. */
public
EditPartViewer
getViewer
()
{
return
viewer
;
}
}
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