Commit 26b3bc10 authored by Johannes Eder's avatar Johannes Eder
Browse files

YELLOW

Issue-Ref: 3886
Issue-Url: https://af3-developer.fortiss.org/issues/3886

Signed-off-by: Johannes Eder's avatarJohannes Eder <eder@fortiss.org>
parent cdc862f1
package org.fortiss.af3.safetycases.ui.action;
import static org.eclipse.jface.dialogs.MessageDialog.openError;
import static org.eclipse.ui.plugin.AbstractUIPlugin.imageDescriptorFromPlugin;
import static org.fortiss.af3.safetycases.ui.AF3SafetyCasesUIActivator.PLUGIN_ID;
import static org.fortiss.af3.safetycases.ui.utils.AF3SelectionDialogUtils.openSR;
import static org.fortiss.tooling.kernel.service.IPersistencyService.getInstance;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getRootElements;
import java.util.List;
import org.eclipse.swt.widgets.Shell;
import org.fortiss.af3.mira.model.Analysis;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.safetycases.model.Goal;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.ui.extension.base.EObjectActionBase;
/**
* This class implements the action of designating a safety {@link Requirement} to a {@link Goal} in
* order to show that the {@link Goal} specifies the respective requirement.
*
* @author carlan
*/
public class ConnectGoalToSafetyRequirementAction extends EObjectActionBase<Goal> {
/** The default shell. */
private final Shell shell;
/** Constructor. */
public ConnectGoalToSafetyRequirementAction(Goal editedObject, Shell shell) {
super("ConnectSRToGoal", imageDescriptorFromPlugin(PLUGIN_ID, "Icon_Requirement.png"));
setTarget(editedObject);
this.shell = shell;
}
/** {@inheritDoc} */
@Override
public void run() {
List<Analysis> analysisList = getRootElements(getTarget(), Analysis.class);
if(analysisList.isEmpty()) {
openError(shell, "Requirements Analysis", "Cannot find Requirements Analysis!");
return;
}
Requirement selected = null;
if(getTarget().getSafetyRequirement() != null) {
selected = getTarget().getSafetyRequirement();
}
final Requirement sr = openSR(shell.getShell(), analysisList, selected);
if(sr == null || sr == selected) {
return;
}
final ITopLevelElement topLevelAnalysis =
getInstance().getTopLevelElementFor(sr.getContainer());
topLevelAnalysis.runAsCommand(new Runnable() {
@Override
public void run() {
getTarget().setSafetyRequirement(sr);
if(sr.getDescription() != null) {
getTarget().setTextualInformation(sr.getDescription());
}
if(sr.getName() != null) {
getTarget().setName("Goal: " + sr.getName());
}
// FIXME (AB) - Broken due to minimalized MIRA
// for(ExternalRelation er : sr.getExternalRelation()) {
// if(er.getExternalRelationSpecification().getSpecificationOf() != null &&
// er.getExternalRelationSpecification()
// .getSpecificationOf() instanceof Component) {
// getTarget().setAf3Element(
// er.getExternalRelationSpecification().getSpecificationOf());
// }
// }
}
});
}
}
/*-------------------------------------------------------------------------+
| Copyright 2017 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.safetycases.ui.commands;
import static java.util.Collections.emptyList;
import static org.eclipse.jface.dialogs.MessageDialog.openError;
import static org.fortiss.af3.safetycases.ui.utils.AF3SelectionDialogUtils.openSR;
import static org.fortiss.tooling.kernel.service.IPersistencyService.getInstance;
import static org.fortiss.tooling.kernel.ui.service.IContextMenuService.AFTER_GLOBAL_MENU_SECTION_ID;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getRootElements;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.fortiss.af3.mira.model.Analysis;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.safetycases.model.Goal;
import org.fortiss.af3.safetycases.model.Solution;
import org.fortiss.af3.safetycases.ui.AF3SafetyCasesUIActivator;
import org.fortiss.af3.safetycases.ui.action.ConnectGoalToSafetyRequirementAction;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.ui.extension.IContextMenuContributor;
import org.fortiss.tooling.kernel.ui.extension.data.ContextMenuContextProvider;
/**
* This class implements the action of referencing a {@link Requirement} from a {@link Goal} or from
* a {@link Solution}.
*
* @author carlan
*/
public class ReferenceRequirement implements IContextMenuContributor {
/** {@inheritDoc} */
@Override
public List<IContributionItem> getContributedItems(EObject selection,
ContextMenuContextProvider contextProvider) {
if(selection instanceof Goal) {
List<IContributionItem> contributionItems = new ArrayList<IContributionItem>();
contributionItems.add(
new ActionContributionItem(new ReferenceRequirementAction((Goal)selection)));
return contributionItems;
}
if(selection instanceof Solution) {
List<IContributionItem> contributionItems = new ArrayList<IContributionItem>();
contributionItems.add(new ActionContributionItem(
new ReferenceSolutionRequirementAction((Solution)selection)));
return contributionItems;
}
return emptyList();
}
/** {@inheritDoc} */
@Override
public String getMenuSectionID() {
return AFTER_GLOBAL_MENU_SECTION_ID;
}
/** The action. */
private class ReferenceRequirementAction extends Action {
/** The selected goal. */
private Goal selectedGoal;
/** Constructor. */
ReferenceRequirementAction(Goal selected) {
super("Connect 2 Requirement",
AF3SafetyCasesUIActivator.getImageDescriptor("icons/Icon_Requirement.png"));
this.selectedGoal = selected;
}
/** {@inheritDoc} */
@Override
public void run() {
new ConnectGoalToSafetyRequirementAction(selectedGoal,
Display.getCurrent().getActiveShell()).run();
}
}
/** The action. */
private class ReferenceSolutionRequirementAction extends Action {
/** The selected goal. */
private Solution selectedSolution;
/** The current shell. */
private Shell shell;
/** Constructor. */
ReferenceSolutionRequirementAction(Solution selected) {
super("Connect 2 Requirement",
AF3SafetyCasesUIActivator.getImageDescriptor("icons/Icon_Requirement.png"));
this.selectedSolution = selected;
this.shell = Display.getCurrent().getActiveShell();
}
/** {@inheritDoc} */
@Override
public void run() {
List<Analysis> analysisList = getRootElements(selectedSolution, Analysis.class);
if(analysisList.isEmpty()) {
openError(shell, "Requirements Analysis", "Cannot find Requirements Analysis!");
return;
}
Requirement selected = null;
if(selectedSolution.getSafetyRequirement() != null) {
selected = selectedSolution.getSafetyRequirement();
}
final Requirement sr = openSR(shell.getShell(), analysisList, selected);
if(sr == null || sr == selected) {
return;
}
final ITopLevelElement topLevelAnalysis =
getInstance().getTopLevelElementFor(sr.getContainer());
topLevelAnalysis.runAsCommand(new Runnable() {
@Override
public void run() {
selectedSolution.setSafetyRequirement(sr);
if(sr.getDescription() != null) {
selectedSolution.setTextualInformation(sr.getDescription());
}
if(sr.getName() != null) {
selectedSolution.setName("Solution: " + sr.getName());
}
// FIXME (AB) - Broken due to minimalized MIRA
// for(ExternalRelation er : sr.getExternalRelation()) {
// IModelElement erSpecification =
// er.getExternalRelationSpecification().getSpecificationOf();
// if(erSpecification != null && erSpecification instanceof Component) {
// selectedSolution.setAf3Element(erSpecification);
// }
// }
}
});
}
}
}
......@@ -8,4 +8,4 @@ ContextPropertySection.java 3901c88aee6a6e659a997d1fe76ab333a227c526 GREEN
GoalPropertySection.java bd19bf5e23555bdcaeed24ef2962942aa17afdf0 GREEN
OptionEntityPropertySection.java 783afb90532861c185a2e4ea5bd3c1b7e92483c2 GREEN
QuantitativeEvaluationPropertySection.java 3abfb63be471ff17ac97cc19078da83f99e48a41 GREEN
RequirementLinkPropertySection.java 7b7aa5574f9d4e1d13e33bf076f6bb0dba905b25 GREEN
RequirementLinkPropertySection.java 1702f8d5933208240527478b68fda6292da03d6b YELLOW
......@@ -235,10 +235,6 @@ public class RequirementLinkPropertySection extends PropertySectionBase {
public Object[] getChildren(Object parentElement) {
if(parentElement instanceof Analysis)
return ((Analysis)(parentElement)).getContainedElements().toArray();
// FIXME (AB) - Broken due to minimalized MIRA
// if(parentElement instanceof Requirement) {
// return ((Requirement)parentElement).getFormalSpecifications().toArray();
// }
if(parentElement instanceof RequirementsContainer) {
return ((RequirementsContainer)parentElement).getRequirementsList()
.toArray();
......
AF3SelectionDialogUtils.java 3c4e1b2beb29adf4e57fa5237aecfe35d62ad32d YELLOW
AF3SelectionDialogUtils.java ba2c3537413f10d1727215c412a79016ea1fd2de YELLOW
GSNSelectionDialogUtils.java 01cdc5c80a6d678e47b39d4dbd571de15b283d8f GREEN
InstantiationOfGSNElementsUtils.java 7f928f584cf3d978c35e9aad3f93049f6e82c832 RED
MaintenanceUtils.java d283c302c902309eac641187b33a5737c833ce1d GREEN
......@@ -7,5 +7,5 @@ QuantitativeEvaluationUtils.java 26f06e285252af1b0061fbc0ec7be8a5671fca09 GREEN
SafetyCasesLibraryUIUtils.java 9496176dd4c161f58f48b2cf929f1d596cc08280 GREEN
StringToClaimValidator.java 468f6f2178b1e109e113e1ef5cf3e0fca3459028 GREEN
StringToGsnIdValidator.java 3f08520777cc58340136d52f3d2d6afe0cfa8201 GREEN
TextHyperlinkingUtils.java ba5d347e417a7497adc94a63c9d8b61ec7686966 GREEN
TextHyperlinkingUtils.java 4c572f100e237eff1fe3ff01700d65d56331ff1c YELLOW
Utils.java 05467c80c7b03d3f2fe44155a5d651fff681b6b9 GREEN
......@@ -128,10 +128,7 @@ public class AF3SelectionDialogUtils {
// Selecting only safety requirements
List<EObject> filteredList = new ArrayList<EObject>();
for(EObject ele : list) {
if(ele instanceof Requirement
// FIXME (AB) Broken due to minimalized MIRA.
// && ((Requirement)ele).isSafetyRelevant()
) {
if(ele instanceof Requirement) {
filteredList.add(ele);
}
}
......
......@@ -19,7 +19,6 @@ import static java.util.stream.Collectors.toList;
import static org.fortiss.af3.allocation.utils.AllocationUtils.getAllocationTables;
import static org.fortiss.af3.safetycases.utils.SafetyCasesUtils.getAllLogicalComponents;
import static org.fortiss.af3.safetycases.utils.SafetyCasesUtils.getAllOfSameType;
import static org.fortiss.af3.safetycases.utils.SafetyCasesUtils.getAllSafetyRequirements;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickInstanceOf;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getRootElement;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getRootElements;
......@@ -41,7 +40,6 @@ import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.component.model.ComponentArchitecture;
import org.fortiss.af3.mira.model.Analysis;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.mode.model.Mode;
import org.fortiss.af3.mode.model.ModeAutomaton;
......@@ -143,12 +141,7 @@ public class TextHyperlinkingUtils {
string = identifyPlatformElementNames(string, textualInfo, listOfParch);
// Checking for references to safety requirements.
final ArrayList<Requirement> listOfRequirements;
if(getRootElement(argEle, Analysis.class) != null) {
listOfRequirements = getAllSafetyRequirements(argEle);
} else {
listOfRequirements = null;
}
final ArrayList<Requirement> listOfRequirements = null;
string = identifyRequirementNames(string, textualInfo, listOfRequirements);
// Checking for references to goals.
......
......@@ -3,4 +3,4 @@ ModuleLibraryModelElementFactory.java 5d882790170eb0ebc8be493e05d675e007cc5cca G
SafetyCasesAnalysisUtils.java ee22d78b153c6f23aac5efab094efce52170d65c GREEN
SafetyCasesModelElementFactory.java 9f32fdb87683c117013d226ea8cd31f0508d2c08 GREEN
SafetyCasesModellingUtils.java 8e3d8401066a59d17c03c169e25597e9396866f8 GREEN
SafetyCasesUtils.java aeb507722d7a4aa569d7f7310a820204541ef80b RED
SafetyCasesUtils.java be6c08065b38250bd80d9e892fd80bb0916165a0 YELLOW
......@@ -25,8 +25,6 @@ import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.component.model.ComponentArchitecture;
import org.fortiss.af3.mira.model.Analysis;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.requirementspatterns.model.PatternsDatabase;
import org.fortiss.af3.requirementspatterns.model.SafetyClaimPatternsCollection;
import org.fortiss.af3.safetyargumentationpackage.model.SafetyArgumentationPackage;
......@@ -46,28 +44,6 @@ import org.fortiss.tooling.base.model.element.IConnector;
*/
public class SafetyCasesUtils {
/**
* Computes all the modeled safety {@link Requirement}s within the project which contains
* the {@link HierarchicElementBase} given as parameter.
*
* @param element
* The given element.
* @return The list of the found safety requirements.
*/
public static ArrayList<Requirement> getAllSafetyRequirements(HierarchicElementBase element) {
List<Analysis> analysisList = getRootElements(element, Analysis.class);
ArrayList<Requirement> safetyReqList = new ArrayList<Requirement>();
for(Analysis analysis : analysisList) {
// FIXME (AB) - Broken due to minimalized MIRA
// for(Requirement req : analysis.getRequirementsList()) {
// if(req.isSafetyRequirement()) {
// safetyReqList.add(req);
// }
// }
}
return safetyReqList;
}
/**
* This method returns a list of all modeled {@link ArgumentElement}s which have the same type
* as the given one within the containing project.
......
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