Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kernel
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
af3
kernel
Commits
986271bb
Commit
986271bb
authored
Nov 22, 2017
by
Levi Lucio
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added code to handle grouping of constraints
refs 3039
parent
5c712150
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
304 additions
and
49 deletions
+304
-49
org.fortiss.tooling.base.ui/trunk/META-INF/MANIFEST.MF
org.fortiss.tooling.base.ui/trunk/META-INF/MANIFEST.MF
+1
-0
org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editor/.ratings
....ui/trunk/src/org/fortiss/tooling/base/ui/editor/.ratings
+1
-1
org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editor/ConstraintBasedProcessEditor.java
.../tooling/base/ui/editor/ConstraintBasedProcessEditor.java
+243
-34
org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/utils/.ratings
...e.ui/trunk/src/org/fortiss/tooling/base/ui/utils/.ratings
+1
-1
org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/utils/StatusUtils.java
...nk/src/org/fortiss/tooling/base/ui/utils/StatusUtils.java
+34
-1
org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/.ratings
...l/trunk/src/org/fortiss/tooling/kernel/extension/.ratings
+1
-1
org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/IConstraint.java
...src/org/fortiss/tooling/kernel/extension/IConstraint.java
+6
-5
org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/ConstraintService.java
...rg/fortiss/tooling/kernel/internal/ConstraintService.java
+10
-0
org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/service/.ratings
...nel/trunk/src/org/fortiss/tooling/kernel/service/.ratings
+1
-1
org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/service/IConstraintService.java
...rg/fortiss/tooling/kernel/service/IConstraintService.java
+6
-5
No files found.
org.fortiss.tooling.base.ui/trunk/META-INF/MANIFEST.MF
View file @
986271bb
...
...
@@ -51,3 +51,4 @@ Bundle-ClassPath: .,
lib/de.cau.cs.kieler.klay.force-0.4.0.201602160301.jar,
lib/de.cau.cs.kieler.klay.layered-0.13.0.201602160301.jar,
lib/de.cau.cs.kieler.klay.tree-0.4.0.201602160301.jar
Import-Package: org.fortiss.af3.project.model.development
org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editor/.ratings
View file @
986271bb
AdvancedTreeViewerEditorBase.java c1275888a1552dac396d3f2968faca0c33232847 GREEN
AllocationDiagramEditorBase.java 54c21b4c04fdf7bb85cd1b687dcf4b70927f55d1 GREEN
CommonDiagramEditorBase.java 2a380b7dbefef8fb1b50c53d4eb7089d9594e244 RED
ConstraintBasedProcessEditor.java
fe439469c7209d1ff6a1f0b5d2cb8de1ed1719bc
YELLOW
ConstraintBasedProcessEditor.java
a178fb8d2333b774fcc4db19370e3a5d03ee33f8
YELLOW
DiagramEditorBase.java ffd082dc0572cbde9db536320cd7ff2158bc330c GREEN
DiagramKeyHandler.java 32d7e2713bb34afddf9a826c24663ca16af11c17 GREEN
FormsEditorBase.java e547415effcbba764aebb9f40d827fd1644f803c GREEN
...
...
org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editor/ConstraintBasedProcessEditor.java
View file @
986271bb
...
...
@@ -19,12 +19,14 @@ package org.fortiss.tooling.base.ui.editor;
import
static
org
.
eclipse
.
core
.
runtime
.
IStatus
.
ERROR
;
import
static
org
.
eclipse
.
jface
.
dialogs
.
ErrorDialog
.
openError
;
import
static
org
.
eclipse
.
swt
.
widgets
.
Display
.
getCurrent
;
import
static
org
.
fortiss
.
tooling
.
base
.
utils
.
ConstraintsBaseUtils
.
DEFAULT_CONFIGURATION_NAME
;
import
static
org
.
fortiss
.
tooling
.
base
.
utils
.
ConstraintsBaseUtils
.
getActiveConfigurationsTransitively
;
import
static
org
.
fortiss
.
tooling
.
base
.
utils
.
ConstraintsBaseUtils
.
getActiveConstraintsTransitively
;
import
static
org
.
fortiss
.
tooling
.
base
.
utils
.
ConstraintsBaseUtils
.
retrieveDefaultConfig
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
...
...
@@ -32,9 +34,11 @@ import java.util.stream.Collectors;
import
org.conqat.ide.commons.ui.jface.TreeContentProviderBase
;
import
org.eclipse.core.runtime.Status
;
import
org.eclipse.emf.common.notify.Notification
;
import
org.eclipse.emf.common.util.EList
;
import
org.eclipse.emf.ecore.EObject
;
import
org.eclipse.emf.ecore.util.EContentAdapter
;
import
org.eclipse.jface.action.MenuManager
;
import
org.eclipse.jface.util.IPropertyChangeListener
;
import
org.eclipse.jface.viewers.CellEditor
;
import
org.eclipse.jface.viewers.CheckStateChangedEvent
;
import
org.eclipse.jface.viewers.CheckboxTreeViewer
;
...
...
@@ -52,17 +56,19 @@ import org.eclipse.jface.viewers.TreeViewerColumn;
import
org.eclipse.jface.viewers.Viewer
;
import
org.eclipse.jface.viewers.ViewerComparator
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.graphics.Color
;
import
org.eclipse.swt.layout.GridData
;
import
org.eclipse.swt.layout.GridLayout
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.swt.widgets.Display
;
import
org.eclipse.swt.widgets.Menu
;
import
org.eclipse.swt.widgets.TreeColumn
;
import
org.fortiss.af3.project.model.development.ConstraintBasedDevelopmentProcess
;
import
org.fortiss.tooling.base.model.element.ConstraintConfiguration
;
import
org.fortiss.tooling.base.model.element.ElementFactory
;
import
org.fortiss.tooling.base.model.element.IConstraintBasedProcess
;
import
org.fortiss.tooling.base.ui.ToolingBaseUIActivator
;
import
org.fortiss.tooling.base.ui.utils.ConstraintsBaseUIUtils
;
import
org.fortiss.tooling.base.ui.utils.StatusUtils
;
import
org.fortiss.tooling.kernel.extension.IConstraint
;
import
org.fortiss.tooling.kernel.extension.data.ITopLevelElement
;
import
org.fortiss.tooling.kernel.model.constraints.IConstraintInstanceContainer
;
...
...
@@ -84,11 +90,16 @@ import org.fortiss.tooling.kernel.utils.EcoreUtils;
* @author aravantinos
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 8584EC3808931699CDD5E434E160D2BF
*/
public
class
ConstraintBasedProcessEditor
<
CBP
extends
IConstraintBasedProcess
>
extends
EditorBase
<
CBP
>
implements
ContextMenuContextProvider
,
ISelectionProvider
{
/** {@inheritDoc} */
@Override
public
void
addPartPropertyListener
(
IPropertyChangeListener
listener
)
{
super
.
addPartPropertyListener
(
listener
);
}
/** Model context of the edited project. */
private
ITopLevelElement
top
;
...
...
@@ -160,9 +171,8 @@ public class ConstraintBasedProcessEditor<CBP extends IConstraintBasedProcess> e
MenuManager
menuManager
=
IContextMenuService
.
getInstance
().
createDefaultContextMenu
(
this
);
Menu
menu
=
menuManager
.
createContextMenu
(
treeViewer
.
getTree
());
treeViewer
.
getTree
().
setMenu
(
menu
);
createCurrentObjectivePart
(
parent
);
refreshAdapter
=
new
EContentAdapter
()
{
@Override
public
void
notifyChanged
(
Notification
notification
)
{
treeViewer
.
refresh
();
...
...
@@ -180,6 +190,12 @@ public class ConstraintBasedProcessEditor<CBP extends IConstraintBasedProcess> e
super
.
dispose
();
}
/** Create current the controls "Current objective:". */
private
void
createCurrentObjectivePart
(
Composite
parent
)
{
Composite
currentObjComposite
=
new
Composite
(
parent
,
SWT
.
None
);
currentObjComposite
.
setLayout
(
new
GridLayout
(
2
,
false
));
}
/** Fake child used to add new elements. */
private
static
class
FakeChild
{
// Nothing to implement: just a marker class
...
...
@@ -187,6 +203,7 @@ public class ConstraintBasedProcessEditor<CBP extends IConstraintBasedProcess> e
/** Content provider for the configuration tree. */
private
class
ConfigTreeContentProvider
extends
TreeContentProviderBase
{
/** {@inheritDoc} */
@Override
public
Object
[]
getChildren
(
Object
parentElement
)
{
...
...
@@ -202,11 +219,7 @@ public class ConstraintBasedProcessEditor<CBP extends IConstraintBasedProcess> e
IConstraintUIService
.
getInstance
().
getAllConstraints
();
availableCstrs
.
removeAll
(
IConstraintUIService
.
getInstance
()
.
getAlwaysActivatedConstraints
());
types
.
addAll
(
availableCstrs
.
stream
()
.
map
(
c
->
new
ConstraintWithContextualConfiguration
(
c
,
(
ConstraintConfiguration
)
parentElement
))
.
collect
(
Collectors
.
toList
()));
if
(
editedObject
.
getConfigurations
().
size
()
>
1
)
{
List
<
ConfigurationRefWithContextualConfiguration
>
refs
=
editedObject
...
...
@@ -217,15 +230,60 @@ public class ConstraintBasedProcessEditor<CBP extends IConstraintBasedProcess> e
.
collect
(
Collectors
.
toList
());
types
.
add
(
refs
);
}
Set
<
Class
<?
extends
IConstraint
>>
availableConstraints
=
IConstraintUIService
.
getInstance
().
getAllConstraints
();
IConstraintUIService
cuis
=
IConstraintUIService
.
getInstance
();
// Collecting the groups and putting the constraints in the groups in the array list
List
<
String
>
groupName
=
new
ArrayList
<
String
>();
for
(
Class
<?
extends
IConstraint
>
c
:
availableConstraints
)
{
String
constGroupName
=
IConstraintService
.
getInstance
().
getGroupName
(
c
);
if
(!
groupName
.
contains
(
constGroupName
))
{
groupName
.
add
(
constGroupName
);
types
.
add
(
constGroupName
);
HashMap
<
String
,
String
>
constraintInfo
=
new
HashMap
<
String
,
String
>();
for
(
Class
<?
extends
IConstraint
>
ctr
:
availableConstraints
)
{
String
ctrGroupName
=
IConstraintService
.
getInstance
().
getGroupName
(
ctr
);
String
desc
=
cuis
.
getDescription
(
ctr
);
constraintMap
.
put
(
ctr
.
getName
(),
desc
);
if
(
ctrGroupName
.
equalsIgnoreCase
(
constGroupName
))
{
constraintInfo
.
put
(
ctr
.
getName
(),
cuis
.
getDescription
(
ctr
));
}
}
groupNameAndConstraints
.
put
(
constGroupName
,
constraintInfo
);
}
}
return
types
.
toArray
();
}
else
if
(
parentElement
instanceof
List
<?>)
{
return
((
List
<?>)
parentElement
).
toArray
();
}
// Add the constraints to the tree based on the group name.
else
if
(
parentElement
instanceof
String
)
{
// Loop over all the names of the groups
for
(
String
constraintGroupName
:
groupNameAndConstraints
.
keySet
())
{
if
(
parentElement
.
toString
().
equalsIgnoreCase
(
constraintGroupName
.
toString
()))
{
// Return complete keySet of the HashMap inside the value field of the
// HashMap groupNameAndConstraints<String, "HashMap<String",String>> that
// contains the names of the constraints that are grouped under a particular
// constraint group
return
groupNameAndConstraints
.
get
(
constraintGroupName
).
keySet
().
toArray
();
}
}
}
return
new
Object
[
0
];
}
}
/** Text labels for the tree of configuratinos. */
/** This constraint map contains the name and the description of all of the constraints */
HashMap
<
String
,
String
>
constraintMap
=
new
HashMap
<
String
,
String
>();
/** This HashMap contains the groups and the the grouped constraints (as a HashMap) */
HashMap
<
String
,
HashMap
<
String
,
String
>>
groupNameAndConstraints
=
new
HashMap
<
String
,
HashMap
<
String
,
String
>>();
/** Text labels for the tree of configurations. */
private
String
getLabelText
(
Object
element
)
{
if
(
element
instanceof
FakeChild
)
{
return
"click to add a new configuration"
;
...
...
@@ -238,6 +296,16 @@ public class ConstraintBasedProcessEditor<CBP extends IConstraintBasedProcess> e
return
((
ConfigurationRefWithContextualConfiguration
)
element
).
target
.
getName
();
}
else
if
(
element
instanceof
List
<?>)
{
return
"Required configurations"
;
}
else
if
(
element
instanceof
String
)
{
if
(
groupNameAndConstraints
.
containsKey
(
element
))
{
for
(
String
constraintGroupName
:
groupNameAndConstraints
.
keySet
())
{
if
(
element
.
toString
().
equalsIgnoreCase
(
constraintGroupName
.
toString
()))
{
return
constraintGroupName
;
}
}
}
else
if
(
constraintMap
.
containsKey
(
element
))
{
return
constraintMap
.
get
(
element
);
}
}
return
null
;
}
...
...
@@ -248,7 +316,9 @@ public class ConstraintBasedProcessEditor<CBP extends IConstraintBasedProcess> e
/** {@inheritDoc} */
@Override
public
boolean
isGrayed
(
Object
element
)
{
return
!(
element
instanceof
ConstraintWithContextualConfiguration
||
element
instanceof
ConfigurationRefWithContextualConfiguration
);
return
!(
element
instanceof
ConstraintWithContextualConfiguration
||
element
instanceof
ConfigurationRefWithContextualConfiguration
||
constraintMap
.
containsKey
(
element
));
}
/** {@inheritDoc} */
...
...
@@ -264,6 +334,8 @@ public class ConstraintBasedProcessEditor<CBP extends IConstraintBasedProcess> e
ConfigurationRefWithContextualConfiguration
configRef
=
(
ConfigurationRefWithContextualConfiguration
)
element
;
return
configRef
.
config
.
getIncludedConfigurations
().
contains
(
configRef
.
target
);
}
else
if
(
constraintMap
.
containsKey
(
element
))
{
return
editedObject
.
getCurrentObjective
().
getActiveConstraints
().
contains
(
element
);
}
return
true
;
}
...
...
@@ -274,28 +346,34 @@ public class ConstraintBasedProcessEditor<CBP extends IConstraintBasedProcess> e
/** {@inheritDoc} */
@Override
public
void
checkStateChanged
(
CheckStateChangedEvent
event
)
{
// Get object element from the state changed
Object
element
=
event
.
getElement
();
IConstraintService
cs
=
IConstraintService
.
getInstance
();
IConstraintUIService
cuis
=
IConstraintUIService
.
getInstance
();
ConstraintConfiguration
currentObj
=
editedObject
.
getCurrentObjective
();
if
(
element
instanceof
ConstraintWithContextualConfiguration
)
{
ConstraintWithContextualConfiguration
cstrInContext
=
(
ConstraintWithContextualConfiguration
)
element
;
IConstraintService
cs
=
IConstraintService
.
getInstance
();
String
name
=
cs
.
getName
(
cstrInContext
.
cstr
);
top
.
runAsCommand
(()
->
{
IConstraintUIService
cuis
=
IConstraintUIService
.
getInstance
();
ConstraintConfiguration
currentObj
=
editedObject
.
getCurrentObjective
();
if
(
event
.
getChecked
())
{
cstrInContext
.
config
.
getActiveConstraints
().
add
(
name
);
List
<
ConstraintConfiguration
>
activeConfigs
=
getActiveConfigurationsTransitively
(
currentObj
,
null
);
if
(
activeConfigs
.
contains
(
cstrInContext
.
config
))
{
cuis
.
activate
(
cstrInContext
.
cstr
,
cstrContainer
);
}
}
else
{
cstrInContext
.
config
.
getActiveConstraints
().
remove
(
name
);
List
<
Class
<?
extends
IConstraint
>>
stillActiveCstrs
=
getActiveConstraintsTransitively
(
currentObj
,
cstrInContext
.
config
);
if
(!
stillActiveCstrs
.
contains
(
cstrInContext
.
cstr
))
{
cuis
.
deactivate
(
cstrInContext
.
cstr
,
cstrContainer
);
top
.
runAsCommand
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
event
.
getChecked
())
{
cstrInContext
.
config
.
getActiveConstraints
().
add
(
name
);
List
<
ConstraintConfiguration
>
activeConfigs
=
getActiveConfigurationsTransitively
(
currentObj
,
null
);
if
(
activeConfigs
.
contains
(
cstrInContext
.
config
))
{
cuis
.
activate
(
cstrInContext
.
cstr
,
cstrContainer
);
}
}
else
{
cstrInContext
.
config
.
getActiveConstraints
().
remove
(
name
);
List
<
Class
<?
extends
IConstraint
>>
stillActiveCstrs
=
getActiveConstraintsTransitively
(
currentObj
,
cstrInContext
.
config
);
if
(!
stillActiveCstrs
.
contains
(
cstrInContext
.
cstr
))
{
cuis
.
deactivate
(
cstrInContext
.
cstr
,
cstrContainer
);
}
}
}
});
...
...
@@ -314,16 +392,69 @@ public class ConstraintBasedProcessEditor<CBP extends IConstraintBasedProcess> e
}
});
}
// Check if the constraint belongs to the constraints HashMap
else
if
(
constraintMap
.
containsKey
(
element
))
{
top
.
runAsCommand
(
new
Runnable
()
{
@Override
public
void
run
()
{
// Get the constraintName as a full class path (e.g.,
// a.b.c.constraintName.Java)
String
constraintName
=
element
.
toString
();
if
(
event
.
getChecked
())
{
// If the constraint is checked than add it to the active
// constraints list
editedObject
.
getCurrentObjective
().
getActiveConstraints
()
.
add
(
constraintName
);
// Collect all the active constraints in the list of constraints
List
<
ConstraintConfiguration
>
activeConfigs
=
getActiveConfigurationsTransitively
(
currentObj
,
null
);
// If the selected constraint is in the active constraints list
EList
<
String
>
activeConstraints
=
activeConfigs
.
get
(
0
).
getActiveConstraints
();
if
(
activeConstraints
.
contains
(
cs
.
getConstraintByName
(
constraintName
)
.
getCanonicalName
()))
{
// Activate the constraint
cuis
.
activate
(
cs
.
getConstraintByName
(
constraintName
),
cstrContainer
);
}
}
else
{
// If the constraint is unchecked from the tree remove the
// constraint from
// the active constraints list
editedObject
.
getCurrentObjective
().
getActiveConstraints
()
.
remove
(
constraintName
);
List
<
ConstraintConfiguration
>
stillActiveConfigs
=
getActiveConfigurationsTransitively
(
currentObj
,
null
);
// If the constraint is still not active
EList
<
String
>
stillActiveConstraints
=
stillActiveConfigs
.
get
(
0
).
getActiveConstraints
();
if
(!
stillActiveConstraints
.
contains
(
cs
.
getConstraintByName
(
constraintName
).
getCanonicalName
()))
{
Class
<?
extends
IConstraint
>
constrainttoDeActivate
=
cs
.
getConstraintByName
(
constraintName
);
// Deactivate the constraint
cuis
.
deactivate
(
constrainttoDeActivate
,
cstrContainer
);
}
}
}
});
}
}
}
/** Tree for configurations. */
private
class
ConfigTree
extends
CheckboxTreeViewer
implements
ISelectionChangedListener
{
/** {@inheritDoc} */
@Override
public
void
addSelectionChangedListener
(
ISelectionChangedListener
listener
)
{
super
.
addSelectionChangedListener
(
listener
);
}
/** Constructor. */
public
ConfigTree
(
Composite
parent
)
{
super
(
parent
);
getTree
().
setLayoutData
(
new
GridData
(
800
,
3
00
));
getTree
().
setLayoutData
(
new
GridData
(
800
,
6
00
));
setContentProvider
(
new
ConfigTreeContentProvider
());
setCheckStateProvider
(
new
ConfigTreeCheckStateProvider
());
addCheckStateListener
(
new
ConfigTreeCheckStateListener
());
...
...
@@ -343,8 +474,7 @@ public class ConstraintBasedProcessEditor<CBP extends IConstraintBasedProcess> e
treeViewer
=
new
ConfigTree
(
parent
);
TreeColumn
column
=
new
TreeColumn
(
treeViewer
.
getTree
(),
SWT
.
LEFT
);
column
.
setText
(
"Constraint configurations"
);
column
.
setWidth
(
800
);
column
.
setWidth
(
1300
);
TreeViewerColumn
onlyViewerColumn
=
new
TreeViewerColumn
(
treeViewer
,
column
);
onlyViewerColumn
.
setLabelProvider
(
new
ColumnLabelProvider
()
{
...
...
@@ -353,9 +483,27 @@ public class ConstraintBasedProcessEditor<CBP extends IConstraintBasedProcess> e
public
String
getText
(
Object
element
)
{
return
getLabelText
(
element
);
}
@Override
public
Color
getForeground
(
Object
element
)
{
return
getConstraintForeGround
(
element
,
colorCtr
);
}
@Override
public
Color
getBackground
(
Object
element
)
{
// Collect all the active constraints from the currentObject (i.e., the current
// active configuration)
List
<
String
>
activeConstraints
=
editedObject
.
getCurrentObjective
().
getActiveConstraints
();
if
(
constraintMap
.
containsKey
(
element
))
{
// Ask for the constraint color based on status
return
getConstraintBackgroundColor
(
element
,
activeConstraints
);
}
return
null
;
}
});
onlyViewerColumn
.
setEditingSupport
(
new
EditingSupport
(
treeViewer
)
{
onlyViewerColumn
.
setEditingSupport
(
new
EditingSupport
(
treeViewer
)
{
@Override
protected
void
setValue
(
Object
element
,
Object
value
)
{
if
(
element
instanceof
FakeChild
)
{
...
...
@@ -392,13 +540,74 @@ public class ConstraintBasedProcessEditor<CBP extends IConstraintBasedProcess> e
@Override
protected
boolean
canEdit
(
Object
element
)
{
return
element
instanceof
ConstraintConfiguration
||
element
instanceof
FakeChild
;
return
element
instanceof
ConstraintConfiguration
||
element
instanceof
FakeChild
||
constraintMap
.
containsKey
(
element
);
}
});
treeViewer
.
setComparator
(
new
ConstraintComparator
());
treeViewer
.
setInput
(
editedObject
);
}
/**
* @param element
* is the selected constraint
* @param activeConstraints
* active constraints in the current objective
* @return return the color (i.e., red (Failed), green (Successful) or white(not active))
*/
public
Color
getConstraintBackgroundColor
(
Object
element
,
List
<
String
>
activeConstraints
)
{
// Get the complete path of the constraint class (e.g., a.b.c.constraint.java)
String
constraintToFind
=
element
.
toString
();
// If the constraint is in the active constraint list and the status is true
// than make the background color green
if
(
activeConstraints
.
contains
(
constraintToFind
)
&&
StatusUtils
.
areAllInstancesSuccessful
(
constraintToFind
,
(
ConstraintBasedDevelopmentProcess
)
editedObject
)
==
true
)
{
return
getCurrent
().
getSystemColor
(
SWT
.
COLOR_GREEN
);
}
// If the constraint doesn't belong to the active list of constrains than let
// the color remain white
else
if
(
activeConstraints
.
contains
(
constraintToFind
)
==
false
)
{
return
getCurrent
().
getSystemColor
(
SWT
.
COLOR_WHITE
);
}
// If the constraint is active and the status is false than make the background
// color red
if
(
activeConstraints
.
contains
(
constraintToFind
)
&&
StatusUtils
.
areAllInstancesSuccessful
(
constraintToFind
,
(
ConstraintBasedDevelopmentProcess
)
editedObject
)
==
false
)
{
return
getCurrent
().
getSystemColor
(
SWT
.
COLOR_RED
);
}
return
null
;
}
/** Color Array for at least seven groups. */
int
[]
colorArray
=
{
SWT
.
COLOR_DARK_GREEN
,
SWT
.
COLOR_DARK_BLUE
,
SWT
.
COLOR_DARK_YELLOW
,
SWT
.
COLOR_BLACK
,
SWT
.
COLOR_DARK_RED
,
SWT
.
COLOR_GREEN
,
SWT
.
COLOR_CYAN
};
/** Counter for the colorArray */
int
colorCtr
=
0
;
/**
* @param element
* the groupName for which we need to set the background.
* @param colorIndex
* index used for the colors in the colorArray.
* @return color required for a particular group.
*/
public
Color
getConstraintForeGround
(
Object
element
,
int
colorIndex
)
{
if
(
groupNameAndConstraints
.
keySet
().
contains
(
element
))
{
if
(
colorIndex
!=
colorCtr
+
1
)
{
if
(
groupNameAndConstraints
.
keySet
().
size
()
==
colorCtr
+
1
)
{
colorCtr
=
0
;
}
else
{
colorCtr
++;
}
return
getCurrent
().
getSystemColor
(
colorArray
[
colorIndex
]);
}
}
return
null
;
}
/**
* Checks if the name already exists among current configurations, if so displays an error
* message and return true, otherwise returns false.
...
...
@@ -411,7 +620,7 @@ public class ConstraintBasedProcessEditor<CBP extends IConstraintBasedProcess> e
Status
status
=
new
Status
(
ERROR
,
ToolingBaseUIActivator
.
PLUGIN_ID
,
0
,
"A configuration with this name already exists."
,
null
);
openError
(
Display
.
getCurrent
().
getActiveShell
(),
"Error"
,
null
,
status
);
openError
(
getCurrent
().
getActiveShell
(),
"Error"
,
null
,
status
);
return
true
;
}
return
false
;
...
...
org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/utils/.ratings
View file @
986271bb
...
...
@@ -9,7 +9,7 @@ LayoutDataUIUtils.java 784e54b6d1b8014f7819155bf687bfd5ec632955 GREEN
PropertiesViewUtils.java 45f1f3881c045a4c0cc71b6c01a18a1f238e5172 GREEN
RectangleLayoutUIUtils.java 799776189a183e18a09fdf36a54253e23a7fe46d GREEN
SnapToGridUtils.java 680b3d588cd491375f3ca2d798db7e29e7827ffd GREEN
StatusUtils.java
6b340fb9a0d8ac7d92f25b873702491e62796db0 GREEN
StatusUtils.java
74ffb9c040c4343c70d67575d5530f78f360ad36 YELLOW
TableViewerUtils.java ec3ab989d2301df965a1c2fdca9656f9858dd098 GREEN
ZoomUIUtils.java 5e48ef038f4615e888c8be9ea8c0194cd67e1cf4 YELLOW
package.html 89adfd07995e699e7b8bfd787f7e39a3e5cfca72 GREEN
org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/utils/StatusUtils.java
View file @
986271bb
...
...
@@ -25,6 +25,9 @@ import org.eclipse.ui.IViewSite;
import
org.eclipse.ui.IWorkbenchPage
;
import
org.eclipse.ui.IWorkbenchPart
;
import
org.eclipse.ui.IWorkbenchPartSite
;
import
org.fortiss.af3.project.model.development.ConstraintBasedDevelopmentProcess
;
import
org.fortiss.tooling.kernel.model.constraints.ConstraintInstance
;
import
org.fortiss.tooling.kernel.model.constraints.FailedConstraintInstanceStatus
;
/**
* Methods for accessing the status line.
...
...
@@ -32,7 +35,6 @@ import org.eclipse.ui.IWorkbenchPartSite;
* @author gareis
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: E85DB1C82F0D19FF3569FE1B5CE19B69
*/
public
class
StatusUtils
{
...
...
@@ -65,9 +67,40 @@ public class StatusUtils {
* @param message
* the message
*/
// TODO(VA) This method is not used -> remove?
public
static
void
setStatusMessage
(
String
message
)
{
if
(
getStatusLine
()
!=
null
)
{
getStatusLine
().
setMessage
(
message
);
}
}
/**
* This function is to calculate the status of all of the instances of a particular constraint.
*
* @param constraintToFind
* name of the constraint
* @param editedObject
* current constraint
* @return true or false based on the status of the constraint (Failed or Success)
*/
public
static
boolean
areAllInstancesSuccessful
(
String
constraintToFind
,
ConstraintBasedDevelopmentProcess
editedObject
)
{
for
(
ConstraintInstance
ci
:
editedObject
.
getConstraintInstanceContainer
()
.
getConstraintInstances
())
{
if
(
constraintToFind
.
toString
().
equalsIgnoreCase
(
ci
.
getConstraintName
()))
{
if
(
editedObject
.
getCurrentObjective
().
getActiveConstraints
()
.
contains
(
constraintToFind
.
toString
()))
{
if
(
ci
.
getConstraintName
().
equalsIgnoreCase
(
constraintToFind
.
toString
()))
{
// If the constraint instance has a "failed status"
if
(
ci
.
getStatus
()
instanceof
FailedConstraintInstanceStatus
)
{
return
false
;
}
}
}
return
true
;
}
}
return
false
;
}
}
org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/.ratings
View file @
986271bb
.ratings 6cb16ca7e52fe845938683e6a4e4f276a6367197 GREEN
IConnectionCompositor.java c1d98379d5e1acef12350aad9e8b5b103dbd3712 GREEN
IConstraint.java
07efd8ae24fa2d918e5a520aaa5bbc6cca7c0122 GREEN
IConstraint.java
5266c705f81f1195eb304fa142c7b7de5e5a5d43 YELLOW
IConstraintChecker.java 44f9ab09e5e7f1e33d3f94556f9c3e8bfea582d2 GREEN
IEclipseResourcePostLoadProvider.java 35a0d1f3b6c9574113f16427f918a4e5a9825b9d GREEN
IEclipseResourceStorageLocationProvider.java e20a8aa7433f75ffd9639cf7ed9ca2996150088f GREEN
...
...
org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/IConstraint.java
View file @
986271bb
...
...
@@ -24,11 +24,6 @@ import org.fortiss.tooling.kernel.service.IConstraintService;
/**
* Interface for constraints as required by {@link IConstraintService}.
*
* @author aravantinos
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: DB8743455680591CD5D49DB1E2F479A1
*/
public
interface
IConstraint
{
...
...
@@ -52,4 +47,10 @@ public interface IConstraint {
* (whatever is the reason: the constraint is only judge here).
*/
ConstraintInstance
addConstraintInstanceIfNeeded
(
IConstrained
cstrd
);
/**
* @return The name of the Group. This method will be implemented in all of the classes that
* implements this interface
*/
String
getGroup
();
}
org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/ConstraintService.java
View file @
986271bb
...
...
@@ -345,4 +345,14 @@ public final class ConstraintService implements IIntrospectiveKernelService, ICo
public
void
markAsUpdating
(
ConstraintInstance
ci
)
{
currentlyUpdating
.
add
(
ci
);
}
/** {@inheritDoc} */
@Override
public
String
getGroupName
(
Class
<?
extends
IConstraint
>
cstrClass
)
{
// TODO Auto-generated method stub
if
(
instanceMap
.
get
(
cstrClass
).
getGroup
()
!=
null
)
{
return
instanceMap
.
get
(
cstrClass
).
getGroup
().
trim
().
toString
();
}
return
""
;
}
}
org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/service/.ratings
View file @
986271bb
ICommandStackService.java 892a161e3374913ae1b92af82595bbf730d5af3d GREEN
IConnectionCompositorService.java 6d6caf428532a6b0ff4511ed913c723ab5bdb10a GREEN
IConstraintCheckerService.java fb9f82e7e88b5fa2952d752d4c2f14a9daec9fc8 GREEN