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
d8708134
Commit
d8708134
authored
9 years ago
by
Vincent Aravantinos
Browse files
Options
Downloads
Patches
Plain Diff
n-th attempt to display in a relevant manner the hint on connecting diagram elements
refs 2334
parent
c8a6061e
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/CommonDiagramEditorBase.java
+21
-15
21 additions, 15 deletions
...rtiss/tooling/base/ui/editor/CommonDiagramEditorBase.java
with
21 additions
and
15 deletions
org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editor/CommonDiagramEditorBase.java
+
21
−
15
View file @
d8708134
...
...
@@ -38,6 +38,7 @@ import java.util.List;
import
java.util.Set
;
import
org.conqat.ide.commons.ui.selection.SelectionUtils
;
import
org.eclipse.core.runtime.Platform
;
import
org.eclipse.draw2d.ColorConstants
;
import
org.eclipse.draw2d.IFigure
;
import
org.eclipse.draw2d.geometry.Dimension
;
...
...
@@ -116,7 +117,7 @@ import org.fortiss.tooling.kernel.ui.service.IEditPartFactoryService;
* @author hoelzl
* @author $Author: aravantinos $
* @version $Rev: 13954 $
* @ConQAT.Rating YELLOW Hash:
12D04B9F7350EF3487A8E98778EE8424
* @ConQAT.Rating YELLOW Hash:
A015DFFF58B1950E95D81CE8D7E39435
*/
abstract
class
CommonDiagramEditorBase
<
T
extends
EObject
>
extends
GEFEditorBase
<
T
>
implements
IPostSelectionProvider
,
ContextMenuContextProvider
{
...
...
@@ -143,10 +144,15 @@ abstract class CommonDiagramEditorBase<T extends EObject> extends GEFEditorBase<
private
final
ActionRegistry
actionRegistry
=
new
ActionRegistry
();
/**
* Number of
{@link IConnection}s to be created until the respective hint how to
*
create
connection
s using the GUI is hidden
.
* Number of
times the hint was displayed until we assume the user knows how to draw a
* connection.
*/
private
static
int
numberOfConnectionsToBeCreatedUntilCreationHintIsHidden
=
3
;
private
static
int
numberOfHintDisplays
=
1
;
/** Returns numberOfHintDisplays *and decrements it*. */
private
static
boolean
shouldDisplayHint
()
{
return
numberOfHintDisplays
--
>=
0
;
}
/** Constructor. */
public
CommonDiagramEditorBase
(
GraphicalViewer
viewer
,
EditPartFactory
factory
)
{
...
...
@@ -155,8 +161,8 @@ abstract class CommonDiagramEditorBase<T extends EObject> extends GEFEditorBase<
}
/**
* Adapter to watch for added {@link IConnection}s (used to update
*
{@link #numberOfConnectionsToBeCreatedUntilCreationHintIsHidden}
).
* Adapter to watch for added {@link IConnection}s (used to update
{@link #numberOfHintDisplays}
* ).
*/
private
static
final
Adapter
addConnectionAdapter
=
new
EContentAdapter
()
{
@Override
...
...
@@ -173,10 +179,7 @@ abstract class CommonDiagramEditorBase<T extends EObject> extends GEFEditorBase<
Object
newValue
=
notification
.
getNewValue
();
if
(
eventType
==
Notification
.
ADD
&&
newValue
instanceof
IConnection
&&
notification
.
getNotifier
()
==
((
EObject
)
newValue
).
eContainer
())
{
if
(
numberOfConnectionsToBeCreatedUntilCreationHintIsHidden
>
0
)
{
numberOfConnectionsToBeCreatedUntilCreationHintIsHidden
--;
}
else
if
(
numberOfConnectionsToBeCreatedUntilCreationHintIsHidden
<=
0
)
{
if
(!
shouldDisplayHint
())
{
// Hints will no longer be displayed: remove adapter
EObject
rootObj
=
(
EObject
)
notification
.
getNotifier
();
while
(
rootObj
.
eContainer
()
!=
null
)
{
...
...
@@ -204,13 +207,16 @@ abstract class CommonDiagramEditorBase<T extends EObject> extends GEFEditorBase<
Object
model
=
ep
.
getModel
();
String
hint
=
""
;
if
(
numberOfConnectionsToBeCreatedUntilCreationHintIsHidden
>
0
)
{
if
(
shouldDisplayHint
())
{
String
key
=
Platform
.
getOS
().
equals
(
Platform
.
OS_LINUX
)
?
"Ctrl"
:
"Alt"
;
String
commonStr
=
" by pressing "
+
key
+
" and dragging"
;
if
(
model
instanceof
IConnector
)
{
hint
=
"Link two connectors by pressing ALT and dragging from source to target."
;
hint
=
"Link two connectors"
+
commonStr
+
"from source to target"
;
}
else
if
(
model
instanceof
IHierarchicElement
)
{
hint
=
"Create a connection
by pressing ALT and dragging."
;
hint
=
"Create a connection
"
+
commonStr
;
}
hint
+=
" (select anything on the diagram to prevent further display of this message)."
;
}
control
.
setToolTipText
(
hint
);
}
...
...
@@ -227,7 +233,7 @@ abstract class CommonDiagramEditorBase<T extends EObject> extends GEFEditorBase<
.
addSelectionListener
(
selectionListener
);
// Install adapter to top-most object to watch for addition of IConnections.
if
(
numberOfConnectionsToBeCreatedUntilCreationHintIsHidden
>
0
)
{
if
(
shouldDisplayHint
()
)
{
EObject
model
=
getEditedObject
();
EObject
obj
=
model
;
while
(
obj
!=
null
)
{
...
...
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