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
559374cd
Commit
559374cd
authored
8 years ago
by
Vincent Aravantinos
Browse files
Options
Downloads
Patches
Plain Diff
improves the constraint context menu: adapts to the change, implements the warning display
refs 2553
parent
543631a6
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
+39
-29
39 additions, 29 deletions
...tiss/tooling/kernel/ui/internal/views/ConstraintMenu.java
with
39 additions
and
29 deletions
org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/views/ConstraintMenu.java
+
39
−
29
View file @
559374cd
...
...
@@ -29,10 +29,10 @@ import org.eclipse.swt.graphics.Image;
import
org.eclipse.swt.widgets.Display
;
import
org.eclipse.swt.widgets.Shell
;
import
org.fortiss.tooling.kernel.model.constraints.ConstrainedWithChecksum
;
import
org.fortiss.tooling.kernel.model.constraints.Constraint
;
import
org.fortiss.tooling.kernel.model.constraints.ErrorVerificationStatus
;
import
org.fortiss.tooling.kernel.model.constraints.FailVerificationStatus
;
import
org.fortiss.tooling.kernel.model.constraints.IConstrained
;
import
org.fortiss.tooling.kernel.model.constraints.IConstraint
;
import
org.fortiss.tooling.kernel.model.constraints.IConstraintVerificationStatus
;
import
org.fortiss.tooling.kernel.model.constraints.OutdatedVerificationStatus
;
import
org.fortiss.tooling.kernel.model.constraints.SuccessVerificationStatus
;
...
...
@@ -55,7 +55,7 @@ import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash:
265A5183E7E403DDC53A61F5B27D8B5A
* @ConQAT.Rating YELLOW Hash:
3F5A89AA4B903D0407589F4EC4E7E7B9
*/
public
class
ConstraintMenu
implements
IContextMenuContributor
{
...
...
@@ -77,7 +77,7 @@ public class ConstraintMenu implements IContextMenuContributor {
* @return <code>true</code> iff <code>c</code> should get a menu entry, i.e., if not successful
* and activated.
*/
private
boolean
shouldGetMenuEntry
(
I
Constraint
c
)
{
private
boolean
shouldGetMenuEntry
(
Constraint
c
)
{
IConstraintVerificationStatus
status
=
IConstraintVerificationUIService
.
getInstance
().
getStatus
(
c
);
return
!(
status
==
null
||
status
instanceof
SuccessVerificationStatus
);
...
...
@@ -90,7 +90,7 @@ public class ConstraintMenu implements IContextMenuContributor {
* <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
(
I
Constraint
c
,
IConstrained
elt
)
{
private
IContributionItem
constraintToAction
(
Constraint
c
,
IConstrained
elt
)
{
IConstraintVerificationStatus
status
=
IConstraintVerificationUIService
.
getInstance
().
getStatus
(
c
);
ConstraintSubMenuBase
m
;
...
...
@@ -109,7 +109,7 @@ public class ConstraintMenu implements IContextMenuContributor {
}
IAction
uniqueAction
=
m
.
getTopActionContribution
().
getAction
();
String
txt
=
m
.
getMenuText
();
String
newText
=
txt
.
substring
(
0
,
txt
.
length
()
-
1
)
+
" -> "
+
uniqueAction
.
getText
();
String
newText
=
txt
+
" -> "
+
uniqueAction
.
getText
();
uniqueAction
.
setText
(
newText
);
uniqueAction
.
setImageDescriptor
(
m
.
getImageDescriptor
());
return
m
.
getTopActionContribution
();
...
...
@@ -145,14 +145,18 @@ public class ConstraintMenu implements IContextMenuContributor {
}
/** Get the icon of the prototype. */
public
static
String
getName
(
IConstraint
c
,
String
prefix
)
{
String
name
=
IModelElementHandlerService
.
getInstance
().
getName
(
c
);
return
prefix
+
(
name
==
null
?
"Constraint"
:
name
);
public
static
String
getText
(
Constraint
c
,
String
suffix
)
{
String
id
=
c
.
getConstraintTypeID
();
String
desc
=
IConstraintVerificationUIService
.
getInstance
().
getDescription
(
id
);
return
"\""
+
desc
+
"\": "
+
suffix
;
}
/** Get the icon of the prototype. */
public
static
ImageDescriptor
getIcon
(
IConstraint
c
,
ImageDescriptor
overlay
)
{
Image
img
=
IModelElementHandlerService
.
getInstance
().
getIcon
(
c
);
public
static
ImageDescriptor
getIcon
(
Constraint
c
,
ImageDescriptor
overlay
)
{
String
id
=
c
.
getConstraintTypeID
();
ImageDescriptor
imgd
=
IConstraintVerificationUIService
.
getInstance
().
getIconImageDescriptor
(
id
);
Image
img
=
imgd
==
null
?
null
:
imgd
.
createImage
();
if
(
img
==
null
)
{
return
null
;
}
...
...
@@ -165,7 +169,7 @@ public class ConstraintMenu implements IContextMenuContributor {
private
static
class
ConstraintSubMenuBase
extends
MenuManager
{
/** The constraint. */
protected
I
Constraint
c
;
protected
Constraint
c
;
/**
* The action to get more information about the constraint status.
...
...
@@ -176,9 +180,9 @@ public class ConstraintMenu implements IContextMenuContributor {
protected
ActionContributionItem
moreInfoAction
;
/** Constructor. */
public
ConstraintSubMenuBase
(
I
Constraint
c
,
IConstrained
selectedElt
,
String
pre
fix
,
public
ConstraintSubMenuBase
(
Constraint
c
,
IConstrained
selectedElt
,
String
suf
fix
,
ImageDescriptor
overlay
)
{
super
(
get
Name
(
c
,
pre
fix
),
getIcon
(
c
,
overlay
),
null
);
super
(
get
Text
(
c
,
suf
fix
),
getIcon
(
c
,
overlay
),
null
);
this
.
c
=
c
;
moreInfoAction
=
new
ActionContributionItem
(
new
OpenStatusAction
());
this
.
add
(
moreInfoAction
);
...
...
@@ -202,7 +206,7 @@ public class ConstraintMenu implements IContextMenuContributor {
/** Constructor. */
public
OpenStatusAction
()
{
super
(
"
Get m
ore information"
,
ToolingKernelUIActivator
super
(
"
M
ore information
...
"
,
ToolingKernelUIActivator
.
getImageDescriptor
(
"icons/info.gif"
));
}
...
...
@@ -227,18 +231,17 @@ public class ConstraintMenu implements IContextMenuContributor {
// In the very rare cases where the status cannot be open (if the defaults are
// used, this should not happen), we provide some defaults.
Shell
sh
=
Display
.
getCurrent
().
getActiveShell
();
String
name
=
IModelElementHandlerService
.
getInstance
().
getName
(
c
);
String
fullName
=
name
==
null
?
"constraint"
:
name
;
String
name
=
ConstraintMenu
.
getText
(
c
,
""
);
if
(
status
instanceof
FailVerificationStatus
)
{
String
msg
=
(
name
==
null
?
"The "
:
fullN
ame
);
String
msg
=
(
name
==
null
?
"The "
:
n
ame
);
msg
+=
" is not satisfied."
;
MessageDialog
.
openInformation
(
sh
,
"Unsatisfied constraint"
,
msg
);
}
else
if
(
status
instanceof
ErrorVerificationStatus
)
{
String
msg
=
"There was an error while verifying "
;
msg
+=
(
name
==
null
?
"the "
:
""
)
+
fullN
ame
+
"."
;
msg
+=
(
name
==
null
?
"the "
:
""
)
+
n
ame
+
"."
;
openError
(
sh
,
"Error while verifying constraint"
,
msg
);
}
else
if
(
status
instanceof
OutdatedVerificationStatus
)
{
String
msg
=
(
name
==
null
?
"The "
:
fullN
ame
)
+
" is outdated."
;
String
msg
=
(
name
==
null
?
"The "
:
n
ame
)
+
" is outdated."
;
MessageDialog
.
openWarning
(
sh
,
"Outdated constraint"
,
msg
);
}
}
...
...
@@ -250,9 +253,8 @@ public class ConstraintMenu implements IContextMenuContributor {
private
static
class
CheckOutdatedConstraintAction
extends
ConstraintSubMenuBase
{
/** Constructor. */
public
CheckOutdatedConstraintAction
(
IConstraint
c
,
IConstrained
selectedElt
)
{
super
(
c
,
selectedElt
,
"Outdated constraint: "
,
ESharedImages
.
WARNING_OVERLAY
.
getImageDescriptor
());
public
CheckOutdatedConstraintAction
(
Constraint
c
,
IConstrained
selectedElt
)
{
super
(
c
,
selectedElt
,
"Outdated"
,
ESharedImages
.
WARNING_OVERLAY
.
getImageDescriptor
());
IAction
action
=
moreInfoAction
.
getAction
();
action
.
setImageDescriptor
(
ToolingKernelUIActivator
.
getImageDescriptor
(
"icons/ok.png"
));
action
.
setText
(
"Check"
);
...
...
@@ -263,9 +265,9 @@ public class ConstraintMenu implements IContextMenuContributor {
private
static
class
CheckUnsuccessfulConstraintAction
extends
ConstraintSubMenuBase
{
/** Constructor. */
public
CheckUnsuccessfulConstraintAction
(
I
Constraint
c
,
IConstrained
selectedElt
,
String
pre
fix
)
{
super
(
c
,
selectedElt
,
pre
fix
,
ESharedImages
.
ERROR_OVERLAY
.
getImageDescriptor
(
));
public
CheckUnsuccessfulConstraintAction
(
Constraint
c
,
IConstrained
selectedElt
,
String
suf
fix
)
{
super
(
c
,
selectedElt
,
suf
fix
,
getOverlay
(
c
));
List
<
IFix
>
fixes
=
IConstraintVerificationService
.
getInstance
().
fixes
(
c
);
if
(
fixes
!=
null
)
{
for
(
IFix
fix
:
fixes
)
{
...
...
@@ -274,6 +276,14 @@ public class ConstraintMenu implements IContextMenuContributor {
}
}
/** Get the correct overlay for the given constraint. */
private
static
ImageDescriptor
getOverlay
(
Constraint
c
)
{
if
(
IConstraintVerificationUIService
.
getInstance
().
shallDisplayAsWarning
(
c
))
{
return
ESharedImages
.
WARNING_OVERLAY
.
getImageDescriptor
();
}
return
ESharedImages
.
ERROR_OVERLAY
.
getImageDescriptor
();
}
/** Action to update a constraint. */
private
class
FixAction
extends
Action
{
...
...
@@ -305,8 +315,8 @@ public class ConstraintMenu implements IContextMenuContributor {
private
static
class
CheckFailingConstraintAction
extends
CheckUnsuccessfulConstraintAction
{
/** Constructor. */
public
CheckFailingConstraintAction
(
I
Constraint
c
,
IConstrained
selectedElt
)
{
super
(
c
,
selectedElt
,
"Unsatisfied
constraint:
"
);
public
CheckFailingConstraintAction
(
Constraint
c
,
IConstrained
selectedElt
)
{
super
(
c
,
selectedElt
,
"Unsatisfied"
);
}
}
...
...
@@ -314,8 +324,8 @@ public class ConstraintMenu implements IContextMenuContributor {
private
static
class
CheckErrorConstraintAction
extends
CheckUnsuccessfulConstraintAction
{
/** Constructor. */
public
CheckErrorConstraintAction
(
I
Constraint
c
,
IConstrained
selectedElt
)
{
super
(
c
,
selectedElt
,
"Error
while checking constraint:
"
);
public
CheckErrorConstraintAction
(
Constraint
c
,
IConstrained
selectedElt
)
{
super
(
c
,
selectedElt
,
"Error
encountered
"
);
}
}
}
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