Commit c2aa6345 authored by Vincent Aravantinos's avatar Vincent Aravantinos
Browse files

UI aspect of the constraint

refs 2967
parent cb8e5038
......@@ -25,6 +25,7 @@ import org.fortiss.af3.mira.constraints.GlossaryTermsDefinitionConstraint;
import org.fortiss.af3.mira.constraints.IDConstraint;
import org.fortiss.af3.mira.constraints.MultipleAspectsConstraint;
import org.fortiss.af3.mira.constraints.NameConstraint;
import org.fortiss.af3.mira.constraints.OnlyOneSILConstraint;
import org.fortiss.af3.mira.constraints.ParameterTypeConstraint;
import org.fortiss.af3.mira.constraints.RationaleConstraint;
import org.fortiss.af3.mira.constraints.RequirementContainsTestSuiteConstraint;
......@@ -38,6 +39,7 @@ import org.fortiss.af3.mira.ui.constraints.GlossaryTermDefinitionConstraintUI;
import org.fortiss.af3.mira.ui.constraints.IDConstraintUI;
import org.fortiss.af3.mira.ui.constraints.MultipleAspectsConstraintUI;
import org.fortiss.af3.mira.ui.constraints.NameConstraintUI;
import org.fortiss.af3.mira.ui.constraints.OnlyOneSILConstraintUI;
import org.fortiss.af3.mira.ui.constraints.ParameterTypeConstraintUI;
import org.fortiss.af3.mira.ui.constraints.RationaleConstraintUI;
import org.fortiss.af3.mira.ui.constraints.RequirementContainsTestSuiteConstraintUI;
......@@ -53,7 +55,7 @@ import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*
* @ConQAT.Rating GREEN Hash: 810FFAD65800F969C1783B30F2671EF6
* @ConQAT.Rating YELLOW Hash: F90FFDAC5B1C94C9AA7AEEB5CFD0EF04
*/
public class AF3MiraUIActivator extends AbstractUIPlugin {
......@@ -109,6 +111,8 @@ public class AF3MiraUIActivator extends AbstractUIPlugin {
DescriptionAndOrConstraint.class);
IConstraintUIService.getInstance().registerConstraintUI(
GlossaryTermDefinitionConstraintUI.class, GlossaryTermsDefinitionConstraint.class);
IConstraintUIService.getInstance().registerConstraintUI(OnlyOneSILConstraintUI.class,
OnlyOneSILConstraint.class);
}
/** {@inheritDoc} */
......
/*--------------------------------------------------------------------------+
$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.af3.mira.ui.constraints;
import static org.apache.commons.lang.StringUtils.join;
import java.util.List;
import java.util.stream.Collectors;
import org.fortiss.af3.mira.constraints.OnlyOneSILConstraint;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.tooling.kernel.model.constraints.ConstraintInstance;
import org.fortiss.tooling.kernel.model.constraints.FailedConstraintInstanceStatus;
import org.fortiss.tooling.kernel.model.constraints.IConstraintInstanceStatus;
import org.fortiss.tooling.kernel.service.IConstraintService;
import org.fortiss.tooling.kernel.ui.extension.base.ConstraintUIBases.ConstraintUIBaseAutocheck;
/**
* UI part of {@link org.fortiss.af3.mira.constraints.AuthorConstraint}
*
* @author abid
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: C19D2294FB80A861DEA9240D513A9E51
*/
public class OnlyOneSILConstraintUI extends ConstraintUIBaseAutocheck {
/** {@inheritDoc} */
@Override
public String getDescription() {
return "Only one requirement should define an safety level";
}
/** {@inheritDoc} */
@Override
public boolean shouldBeManuallyActivated() {
return true;
}
/** {@inheritDoc} */
@Override
public boolean canOpen(ConstraintInstance ci, IConstraintInstanceStatus status) {
return status instanceof FailedConstraintInstanceStatus;
}
/** {@inheritDoc} */
@Override
public String getMessage(ConstraintInstance ci, IConstraintInstanceStatus status) {
List<Requirement> reqs = OnlyOneSILConstraint.statusData.get(ci);
if(reqs == null) {
IConstraintService.getInstance().verify(ci);
reqs = OnlyOneSILConstraint.statusData.get(ci);
if(reqs == null) {
// should not happen
return super.getMessage(ci, status);
}
}
String res = "The following requirements define each a safety level: ";
res += join(reqs.stream().map(r -> r.getReqId()).collect(Collectors.toList()), ", ");
return res;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment