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
1844ccac
Commit
1844ccac
authored
8 years ago
by
Vincent Aravantinos
Browse files
Options
Downloads
Patches
Plain Diff
label provider for constraint statuses
refs 2553
parent
ea08c647
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/util/ConstraintsUIUtils.java
+69
-1
69 additions, 1 deletion
...rg/fortiss/tooling/kernel/ui/util/ConstraintsUIUtils.java
with
69 additions
and
1 deletion
org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/util/ConstraintsUIUtils.java
+
69
−
1
View file @
1844ccac
...
...
@@ -21,8 +21,10 @@ import static org.fortiss.tooling.kernel.extension.data.IConstraintViolation.SEV
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.function.Function
;
import
org.eclipse.emf.ecore.EObject
;
import
org.eclipse.jface.viewers.ColumnLabelProvider
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.graphics.Color
;
import
org.eclipse.swt.widgets.Display
;
...
...
@@ -36,6 +38,7 @@ 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
;
import
org.fortiss.tooling.kernel.ui.service.IConstraintVerificationUIService
;
import
org.fortiss.tooling.kernel.utils.EcoreUtils
;
/**
...
...
@@ -44,7 +47,7 @@ import org.fortiss.tooling.kernel.utils.EcoreUtils;
* @author aravantinos
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash:
8DDA51FFF889B7476EF1FBDC78FA3CDF
* @ConQAT.Rating YELLOW Hash:
78F01666E8A80F35348F431EC6DA2895
*/
public
class
ConstraintsUIUtils
{
...
...
@@ -160,6 +163,9 @@ public class ConstraintsUIUtils {
* @return Standard text describing the status of <code>c</code>.
*/
public
static
String
getText
(
IConstraint
c
)
{
if
(
c
==
null
)
{
return
""
;
}
IConstraintVerificationStatus
status
=
c
.
getVerificationStatus
();
String
mainMsg
=
"ERROR"
;
if
(
status
instanceof
SuccessVerificationStatus
)
{
...
...
@@ -172,12 +178,32 @@ public class ConstraintsUIUtils {
return
mainMsg
;
}
/**
* @param c
* @return Standard "hint" indicating possible action on the status of <code>c</code>.
*/
public
static
String
getHint
(
IConstraint
c
)
{
if
(
c
==
null
)
{
return
""
;
}
IConstraintVerificationStatus
status
=
c
.
getVerificationStatus
();
if
(
status
instanceof
OutdatedVerificationStatus
)
{
return
"(double-click to update)"
;
}
else
if
(
IConstraintVerificationUIService
.
INSTANCE
.
canOpen
(
status
))
{
return
"(double-click for more details)"
;
}
return
""
;
}
/**
* @param c
* @return Standard colour corresponding to the status of <code>c</code>.
*/
public
static
Color
getColor
(
IConstraint
c
)
{
Display
display
=
Display
.
getCurrent
();
if
(
c
==
null
)
{
return
display
.
getSystemColor
(
SWT
.
COLOR_GRAY
);
}
IConstraintVerificationStatus
status
=
c
.
getVerificationStatus
();
if
(
status
instanceof
FailVerificationStatus
||
status
instanceof
ErrorVerificationStatus
)
{
return
display
.
getSystemColor
(
SWT
.
COLOR_RED
);
...
...
@@ -186,4 +212,46 @@ public class ConstraintsUIUtils {
}
return
display
.
getSystemColor
(
SWT
.
COLOR_GRAY
);
}
/** A label provider for the status of an {@link IConstraint}. */
public
static
class
StatusLabelProvider
extends
ColumnLabelProvider
{
/** See constructor. */
private
boolean
withHint
;
/** Function to retrieve a constraint from the embedded objects. */
private
Function
<
Object
,
IConstraint
>
getConstraint
;
/**
* Constructor.
*
* @param withHint
* <code>true</code> if you want to display hints like "double-click for more
* details" in the status. If you set it to <code>true</code>, you are
* responsible for providing the corresponding behaviour (e.g., that
* double-clicking will open the status).
* @param getConstraint
* Function returning a constraint from the object to be provided.
*/
public
StatusLabelProvider
(
boolean
withHint
,
Function
<
Object
,
IConstraint
>
getConstraint
)
{
super
();
this
.
getConstraint
=
getConstraint
;
this
.
withHint
=
withHint
;
}
/** {@inheritDoc} */
@Override
public
String
getText
(
Object
element
)
{
IConstraint
cstr
=
getConstraint
.
apply
(
element
);
String
mainMsg
=
ConstraintsUIUtils
.
getText
(
cstr
);
return
mainMsg
+
(
withHint
?
" "
+
ConstraintsUIUtils
.
getHint
(
cstr
)
:
""
);
}
/** {@inheritDoc} */
@Override
public
Color
getBackground
(
Object
element
)
{
IConstraint
cstr
=
getConstraint
.
apply
(
element
);
return
ConstraintsUIUtils
.
getColor
(
cstr
);
}
}
}
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