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
6a6fb9e3
Commit
6a6fb9e3
authored
8 years ago
by
Vincent Aravantinos
Browse files
Options
Downloads
Patches
Plain Diff
moves the corresponding utility methods (after generalizing them)
refs 2708
parent
0c828311
No related branches found
No related tags found
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/utils/ConstraintsBaseUIUtils.java
+84
-0
84 additions, 0 deletions
...fortiss/tooling/base/ui/utils/ConstraintsBaseUIUtils.java
with
84 additions
and
0 deletions
org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/utils/ConstraintsBaseUIUtils.java
0 → 100644
+
84
−
0
View file @
6a6fb9e3
/*--------------------------------------------------------------------------+
$Id$
| |
| Copyright 2016 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package
org.fortiss.tooling.base.ui.utils
;
import
static
org
.
fortiss
.
tooling
.
base
.
utils
.
ConstraintsBaseUtils
.
getActiveConstraintsTransitively
;
import
java.util.List
;
import
org.fortiss.tooling.base.model.element.ConstraintConfiguration
;
import
org.fortiss.tooling.base.model.element.IConstraintBasedProcess
;
import
org.fortiss.tooling.kernel.extension.IConstraint
;
import
org.fortiss.tooling.kernel.model.constraints.IConstraintInstanceContainer
;
import
org.fortiss.tooling.kernel.ui.service.IConstraintUIService
;
/**
* Utility methods related to constraints.
*
* @author aravantinos
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 364E3DB6782217410744A36167874C40
*/
public
class
ConstraintsBaseUIUtils
{
/** Factorized behaviour. */
public
static
void
doActivateAll
(
IConstraintInstanceContainer
cstrContainer
,
IConstraintBasedProcess
cbdProcess
)
{
// First activate the constraints which should always be activated
for
(
Class
<?
extends
IConstraint
>
cstrClass
:
IConstraintUIService
.
getInstance
()
.
getAlwaysActivatedConstraints
())
{
IConstraintUIService
.
getInstance
().
activate
(
cstrClass
,
cstrContainer
);
}
// Then activate the constraints of the current objective
ConstraintConfiguration
currentObj
=
cbdProcess
.
getCurrentObjective
();
if
(
currentObj
!=
null
)
{
List
<
Class
<?
extends
IConstraint
>>
activeCstrs
=
getActiveConstraintsTransitively
(
currentObj
,
null
);
for
(
Class
<?
extends
IConstraint
>
cstrClass
:
activeCstrs
)
{
IConstraintUIService
.
getInstance
().
activate
(
cstrClass
,
cstrContainer
);
}
}
}
/**
* Activates all constraints which are active in the given configuration, potentially adding new
* constraint instances to the provided container.
*/
public
static
void
activateConfiguration
(
ConstraintConfiguration
config
,
IConstraintInstanceContainer
cstrContainer
)
{
for
(
Class
<?
extends
IConstraint
>
cstr
:
getActiveConstraintsTransitively
(
config
,
null
))
{
IConstraintUIService
.
getInstance
().
activate
(
cstr
,
cstrContainer
);
}
}
/**
* Deactivates all constraints which are active in the given configuration, if they are not
* still active in the provided context.
*/
public
static
void
deactivateConfiguration
(
ConstraintConfiguration
config
,
IConstraintInstanceContainer
cstrContainer
,
ConstraintConfiguration
context
)
{
List
<
Class
<?
extends
IConstraint
>>
stillActiveConstraints
=
getActiveConstraintsTransitively
(
context
,
config
);
for
(
Class
<?
extends
IConstraint
>
cstr
:
getActiveConstraintsTransitively
(
config
,
null
))
{
if
(!
stillActiveConstraints
.
contains
(
cstr
))
{
IConstraintUIService
.
getInstance
().
deactivate
(
cstr
,
cstrContainer
);
}
}
}
}
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