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
e567a9f8
Commit
e567a9f8
authored
8 years ago
by
Vincent Aravantinos
Browse files
Options
Downloads
Patches
Plain Diff
new actions in case there is not enough information for submenus
refs 2553
parent
f7897288
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.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/views/ConstraintMenu.java
+102
-33
102 additions, 33 deletions
...tiss/tooling/kernel/ui/internal/views/ConstraintMenu.java
with
102 additions
and
33 deletions
org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/views/ConstraintMenu.java
+
102
−
33
View file @
e567a9f8
...
...
@@ -3,14 +3,8 @@
| |
$Id$
| |
| Copyright (c) 20
04-2008 Technische Universitaet Muenchen
|
| Copyright (c) 20
16-today fortiss GmbH
|
| |
| Technische Universitaet Muenchen ######### ########## |
| Institut fuer Informatik - Lehrstuhl IV ## ## ## ## ## |
| Prof. Dr. Manfred Broy ## ## ## ## ## |
| Boltzmannstr. 3 ## ## ## ## ## |
| 85748 Garching bei Muenchen ## ## ## ## ## |
| Germany ## ###### ## ## |
+-----------------------------------------------------------------------*/
package
org.fortiss.tooling.kernel.ui.internal.views
;
...
...
@@ -26,10 +20,12 @@ import org.eclipse.jface.action.ActionContributionItem;
import
org.eclipse.jface.action.IAction
;
import
org.eclipse.jface.action.IContributionItem
;
import
org.eclipse.jface.action.MenuManager
;
import
org.eclipse.jface.dialogs.MessageDialog
;
import
org.eclipse.jface.resource.ImageDescriptor
;
import
org.eclipse.jface.viewers.DecorationOverlayIcon
;
import
org.eclipse.jface.viewers.IDecoration
;
import
org.eclipse.swt.graphics.Image
;
import
org.eclipse.swt.widgets.Display
;
import
org.fortiss.tooling.kernel.model.constraints.ConstrainedWithChecksum
;
import
org.fortiss.tooling.kernel.model.constraints.ErrorVerificationStatus
;
import
org.fortiss.tooling.kernel.model.constraints.FailVerificationStatus
;
...
...
@@ -56,7 +52,7 @@ import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash:
0F49BEEDC5B047EB57A50736B039DA0
0
* @ConQAT.Rating YELLOW Hash:
B817A3E9DF60439556DDA0454A6E101
0
*/
public
class
ConstraintMenu
implements
IContextMenuContributor
{
...
...
@@ -76,18 +72,21 @@ public class ConstraintMenu implements IContextMenuContributor {
/**
* @param c
* @param elt
* @return The submenu corresponding to the status of <code>c</code>.
<code>elt</code> is needed
* to prevent displaying an entry to go to <code>elt</code>
(not hurtful, but useless,
* since the user is already seeing it).
* @return The submenu
or menu entry
corresponding to the status of <code>c</code>.
*
<code>elt</code> is needed
to prevent displaying an entry to go to <code>elt</code>
*
(not hurtful, but useless,
since the user is already seeing it).
*/
private
IContributionItem
constraintToAction
(
IConstraint
c
,
IConstrained
elt
)
{
IConstraintVerificationStatus
status
=
c
.
getVerificationStatus
();
if
(
status
instanceof
FailVerificationStatus
)
{
return
new
CheckFailingConstraintAction
(
c
,
elt
);
CheckFailingConstraintAction
m
=
new
CheckFailingConstraintAction
(
c
,
elt
);
return
m
.
getItems
().
length
!=
0
?
m
:
new
ActionContributionItem
(
new
FailedAction
(
c
));
}
else
if
(
status
instanceof
ErrorVerificationStatus
)
{
return
new
CheckErrorConstraintAction
(
c
,
elt
);
CheckErrorConstraintAction
m
=
new
CheckErrorConstraintAction
(
c
,
elt
);
return
m
.
getItems
().
length
!=
0
?
m
:
new
ActionContributionItem
(
new
ErrorAction
(
c
));
}
else
{
return
new
CheckOutdatedConstraintAction
(
c
,
elt
);
CheckOutdatedConstraintAction
m
=
new
CheckOutdatedConstraintAction
(
c
,
elt
);
return
m
.
getItems
().
length
!=
0
?
m
:
new
ActionContributionItem
(
new
OutdatedAction
(
c
));
}
}
...
...
@@ -120,6 +119,91 @@ public class ConstraintMenu implements IContextMenuContributor {
}
}
/********************************************************************************************
* Simple actions: no submenus. Normally should not be used: every constraint verifier should
* provide sufficient information to populate the menu with decent information. But this
* provides at least a default.
*/
/** Base class. */
private
class
InformationAsAction
extends
Action
{
/** Constructor. */
public
InformationAsAction
(
IConstraint
c
,
String
prefix
,
ImageDescriptor
overlay
)
{
super
(
getName
(
c
,
prefix
),
getIcon
(
c
,
overlay
));
}
}
/** Information action for outdated constraints. */
private
class
OutdatedAction
extends
InformationAsAction
{
/** Constructor. */
public
OutdatedAction
(
IConstraint
c
)
{
super
(
c
,
"Outdated constraint: "
,
ESharedImages
.
WARNING_OVERLAY
.
getImageDescriptor
());
}
/** {@inheritDoc} */
@Override
public
void
run
()
{
MessageDialog
.
openWarning
(
Display
.
getDefault
().
getActiveShell
(),
"Outdated constraint"
,
this
.
getText
());
}
}
/** Information action for failing constraints. */
private
class
FailedAction
extends
InformationAsAction
{
/** Constructor. */
public
FailedAction
(
IConstraint
c
)
{
super
(
c
,
"Unsatisfied constraint: "
,
ESharedImages
.
ERROR_OVERLAY
.
getImageDescriptor
());
}
/** {@inheritDoc} */
@Override
public
void
run
()
{
MessageDialog
.
openError
(
Display
.
getDefault
().
getActiveShell
(),
"Unsatisfied constraint"
,
this
.
getText
());
}
}
/** Information action for failing constraints. */
private
class
ErrorAction
extends
InformationAsAction
{
/** Constructor. */
public
ErrorAction
(
IConstraint
c
)
{
super
(
c
,
"Error while checking constraint: "
,
ESharedImages
.
ERROR_OVERLAY
.
getImageDescriptor
());
}
/** {@inheritDoc} */
@Override
public
void
run
()
{
MessageDialog
.
openError
(
Display
.
getDefault
().
getActiveShell
(),
"Error while checking constraint"
,
this
.
getText
());
}
}
/** Get the icon of the prototype. */
public
static
String
getName
(
IConstraint
c
,
String
prefix
)
{
String
name
=
IModelElementHandlerService
.
INSTANCE
.
getName
(
c
);
return
prefix
+
(
name
==
null
?
"Constraint"
:
name
);
}
/** Get the icon of the prototype. */
public
static
ImageDescriptor
getIcon
(
IConstraint
c
,
ImageDescriptor
overlay
)
{
Image
img
=
IModelElementHandlerService
.
INSTANCE
.
getIcon
(
c
);
if
(
img
==
null
)
{
return
null
;
}
ImageDescriptor
[]
descriptors
=
new
ImageDescriptor
[
5
];
descriptors
[
IDecoration
.
BOTTOM_LEFT
]
=
overlay
;
return
new
DecorationOverlayIcon
(
img
,
descriptors
);
}
/********************************************************************************************
* Submenus.
*/
/** Action for creating a new prototype. */
private
static
class
ConstraintSubMenuBase
extends
MenuManager
{
...
...
@@ -139,8 +223,10 @@ public class ConstraintMenu implements IContextMenuContributor {
ImageDescriptor
overlay
)
{
super
(
getName
(
c
,
prefix
),
getIcon
(
c
,
overlay
),
null
);
this
.
c
=
c
;
moreInfoAction
=
new
ActionContributionItem
(
new
OpenStatusAction
());
this
.
add
(
moreInfoAction
);
if
(
IConstraintVerificationUIService
.
INSTANCE
.
canOpen
(
c
.
getVerificationStatus
()))
{
moreInfoAction
=
new
ActionContributionItem
(
new
OpenStatusAction
());
this
.
add
(
moreInfoAction
);
}
for
(
ConstrainedWithChecksum
cwc
:
c
.
getConstrainedsWithChecksum
())
{
if
(!
selectedElt
.
equals
(
cwc
.
getConstrained
()))
{
this
.
add
(
new
ActionContributionItem
(
new
GoToConstrained
(
cwc
.
getConstrained
())));
...
...
@@ -148,23 +234,6 @@ public class ConstraintMenu implements IContextMenuContributor {
}
}
/** Get the icon of the prototype. */
public
static
String
getName
(
IConstraint
c
,
String
prefix
)
{
String
name
=
IModelElementHandlerService
.
INSTANCE
.
getName
(
c
);
return
prefix
+
(
name
==
null
?
"Constraint"
:
name
);
}
/** Get the icon of the prototype. */
public
static
ImageDescriptor
getIcon
(
IConstraint
c
,
ImageDescriptor
overlay
)
{
Image
img
=
IModelElementHandlerService
.
INSTANCE
.
getIcon
(
c
);
if
(
img
==
null
)
{
return
null
;
}
ImageDescriptor
[]
descriptors
=
new
ImageDescriptor
[
5
];
descriptors
[
IDecoration
.
BOTTOM_LEFT
]
=
overlay
;
return
new
DecorationOverlayIcon
(
img
,
descriptors
);
}
/** Action to update a constraint. */
protected
class
OpenStatusAction
extends
Action
{
...
...
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