diff --git a/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/.ratings b/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/.ratings index a8825abaa088209a82f0f227e033063e062425e2..d57aa8dffc5a892c3a88bdbda2f46cc8d9453fb6 100644 --- a/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/.ratings +++ b/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/.ratings @@ -1,2 +1,2 @@ AF3SafetyCasesUIActivator.java 607baeaa170508d975867f5f7bdfcb3d346fed4e GREEN -DefaultStyle.java 3ba5df36d48da2b55bc8137932fc6defacba466e GREEN +DefaultStyle.java 7caa804c1ab2ca5a3ec0b8b01627e54bf68633e5 GREEN diff --git a/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/DefaultStyle.java b/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/DefaultStyle.java index 3ba5df36d48da2b55bc8137932fc6defacba466e..7caa804c1ab2ca5a3ec0b8b01627e54bf68633e5 100644 --- a/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/DefaultStyle.java +++ b/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/DefaultStyle.java @@ -51,4 +51,7 @@ public class DefaultStyle { /** color for marking the "challenged" argument elements. */ public static Color CHALLENGED_COLOR = getColor(255, 0, 0); + + /** color for marking the "modified" argument elements. */ + public static Color MODIFIED_COLOR = getColor(228, 63, 87); } diff --git a/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/action/.ratings b/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/action/.ratings index 59cbc366d384f89ac8940586e97645ba201020df..fa48622b59adaeaa942fb358182f0b366a9a7927 100644 --- a/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/action/.ratings +++ b/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/action/.ratings @@ -3,4 +3,4 @@ ConnectAwayGoalToGoalAction.java 0fddac2bde4e8253555d02a497f92f15bfb86863 GREEN ConnectAwaySolutionToSolutionAction.java b0baf4e04bfffd557380bc048062bc77ab77388f GREEN ConnectToSystemModelElementsAction.java 7ccfe4fe066a718b6c938bb06d21ca678b98434f GREEN SetAsImpactedAction.java cf4e53f5a568bd37674d864526194b3d64f3d95a GREEN -SolveImpactAction.java 275ffd50dcf0e933fa9cdee829700aadca1b550e GREEN +SolveImpactAction.java e554f439a0ae443e1382a8d3a52afe051a1341cc GREEN diff --git a/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/action/SolveImpactAction.java b/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/action/SolveImpactAction.java index 275ffd50dcf0e933fa9cdee829700aadca1b550e..e554f439a0ae443e1382a8d3a52afe051a1341cc 100644 --- a/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/action/SolveImpactAction.java +++ b/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/action/SolveImpactAction.java @@ -15,25 +15,21 @@ +--------------------------------------------------------------------------*/ package org.fortiss.af3.safetycases.ui.action; -import static org.eclipse.jface.dialogs.MessageDialog.openConfirm; -import static org.eclipse.swt.widgets.Display.getCurrent; -import static org.fortiss.af3.safetycases.ui.utils.MaintenanceUtils.removePropagatedImpactOnAwayElements; import static org.fortiss.af3.safetycases.ui.utils.Utils.getNameAndClass; -import static org.fortiss.af3.safetycases.ui.utils.Utils.returnStringTypeOfChanges; +import static org.fortiss.af3.safetycases.ui.utils.Utils.modifiedAttributeString; +import static org.fortiss.af3.safetycases.ui.utils.Utils.removeSelectedImpact; import static org.fortiss.af3.safetycases.ui.utils.Utils.returnStringTypeOfMaintenance; import static org.fortiss.tooling.kernel.service.IPersistencyService.getInstance; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; -import java.util.stream.Collectors; -import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.jface.window.Window; import org.eclipse.swt.widgets.Shell; import org.fortiss.af3.safetycases.model.ArgumentElement; import org.fortiss.af3.safetycases.model.AwayArgumentElement; import org.fortiss.af3.safetycases.model.Change; +import org.fortiss.af3.safetycases.model.maintenanceStatus; import org.fortiss.af3.safetycases.ui.utils.DropdownDialog; import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; import org.fortiss.tooling.kernel.ui.extension.base.EObjectActionBase; @@ -61,6 +57,7 @@ public class SolveImpactAction extends EObjectActionBase { public SolveImpactAction(ArgumentElement target, String text, Shell shell) { super(target, text); this.shell = shell; + selectedArgumentElement = target; } /** {@inheritDoc} */ @@ -71,11 +68,6 @@ public class SolveImpactAction extends EObjectActionBase { topLevel.runAsCommand(new Runnable() { @Override public void run() { - boolean go = openConfirm(getCurrent().getActiveShell(), "", - "Are you sure you want to set as unchallenged or remove the potentially/actually impacts on this node?"); - if(!go) { - return; - } if(selectedArgumentElement != null) { List changes; if(selectedArgumentElement instanceof AwayArgumentElement && @@ -90,21 +82,31 @@ public class SolveImpactAction extends EObjectActionBase { } entryList = new ArrayList(); for(Change currentChange : changes) { - if(currentChange.getModelElement() != null && - getNameAndClass(currentChange) != null) { - List specifications = getNameAndClass(currentChange); - // first element of the list contains name - String name = specifications.get(0); - // second element contains the class name - String className = specifications.get(1); - changeDescription = - name + ", " + className + ", " + returnStringTypeOfMaintenance( - currentChange.getMaintainanceCause()) + ", "; - } - if(currentChange.getPersonalizedTypeOfChange() != null) { - changeDescription += currentChange.getPersonalizedTypeOfChange(); + // Change made by setting maintenance status manually. + if(currentChange.getMaintainanceCause() + .equals(maintenanceStatus.MODIFIED)) { + changeDescription = "Modified, "; + if(currentChange.getModifiedAttribute() != null) { + changeDescription += modifiedAttributeString( + currentChange.getModifiedAttribute()); + } } else { - changeDescription += currentChange.getPredefinedTypeOfChange(); + if(currentChange.getModelElement() != null && + getNameAndClass(currentChange) != null) { + List specifications = getNameAndClass(currentChange); + // first element of the list contains name + String name = specifications.get(0); + // second element contains the class name + String className = specifications.get(1); + changeDescription = name + ", " + className + ", "; + } + changeDescription += returnStringTypeOfMaintenance( + currentChange.getMaintainanceCause()) + ", "; + if(currentChange.getPersonalizedTypeOfChange() != null) { + changeDescription += currentChange.getPersonalizedTypeOfChange(); + } else { + changeDescription += currentChange.getPredefinedTypeOfChange(); + } } entryList.add(changeDescription); } @@ -120,26 +122,7 @@ public class SolveImpactAction extends EObjectActionBase { } else { return; } - for(Change change : changes) { - List selectedSpecification = - Arrays.stream(selected.split(", ")).collect(Collectors.toList()); - List actualChangeSpecifications = getNameAndClass(change); - actualChangeSpecifications - .add(returnStringTypeOfMaintenance(change.getMaintainanceCause())); - if(change.getPersonalizedTypeOfChange() != null) { - actualChangeSpecifications.add(change.getPersonalizedTypeOfChange()); - } else { - actualChangeSpecifications.add( - returnStringTypeOfChanges(change.getPredefinedTypeOfChange())); - } - if(selectedSpecification.equals(actualChangeSpecifications)) { - - selectedArgumentElement.getAffectedByCurrentChanges().remove(change); - removePropagatedImpactOnAwayElements(selectedArgumentElement, change); - EcoreUtil.delete(change); - break; - } - } + removeSelectedImpact(selected, selectedArgumentElement); } } }); diff --git a/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/commands/.ratings b/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/commands/.ratings index 0b39cecaabb3c2918b9fb43b5331fb40cd341837..111a688afaccaec3f4a46bc3c10b68b045f1cd3c 100644 --- a/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/commands/.ratings +++ b/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/commands/.ratings @@ -10,8 +10,8 @@ GoToReferencedSolution.java a8722e0c0568ff2d7f7209a844b488daef482715 GREEN GoalToBeSupportedByContract.java 77a97f68382aa99350120a91f84517eee1d363ad GREEN GoalUndevelopedEntity.java 8b83d59da580cb431a00d0072e5fbefb022d3637 GREEN MakeAChoice.java f8e7f4185bfeb451faf47b111826830aee3f55e3 GREEN -SCElementIsImpacted.java 745436bf71435bd50e28450cdd3090201e1a175c GREEN +SCElementIsImpacted.java 376cd9699768a4fc4c14fa37617acd632fbab9e6 GREEN SCElementIsInstantiated.java cefa135b7a6ec514405d26e3a5c32f60aacc21a0 GREEN SCElementIsPrivate.java 30a3bf574a42284a97d6a840de31aad61f4258f8 GREEN -ShowPotentialChangeImpact.java 747a3c979e9a58e025bb6b9377f9125809a04a7d GREEN +ShowPotentialChangeImpact.java d0ddfc20e9a5e3b4e2168a097343ceaaaaae7a4d GREEN StrategyUndevelopedEntity.java 753b40ae7d6a5230ee12becea6a01971dc64eb46 GREEN diff --git a/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/commands/SCElementIsImpacted.java b/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/commands/SCElementIsImpacted.java index 745436bf71435bd50e28450cdd3090201e1a175c..376cd9699768a4fc4c14fa37617acd632fbab9e6 100644 --- a/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/commands/SCElementIsImpacted.java +++ b/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/commands/SCElementIsImpacted.java @@ -3,33 +3,23 @@ package org.fortiss.af3.safetycases.ui.commands; import static java.util.Collections.emptyList; import static org.eclipse.jface.dialogs.MessageDialog.openConfirm; import static org.eclipse.swt.widgets.Display.getCurrent; -import static org.fortiss.af3.safetycases.ui.utils.MaintenanceUtils.removePropagatedImpactOnAwayElements; -import static org.fortiss.af3.safetycases.ui.utils.Utils.getNameAndClass; -import static org.fortiss.af3.safetycases.ui.utils.Utils.returnStringTypeOfChanges; -import static org.fortiss.af3.safetycases.ui.utils.Utils.returnStringTypeOfMaintenance; import static org.fortiss.tooling.kernel.service.IPersistencyService.getInstance; import static org.fortiss.tooling.kernel.ui.service.IContextMenuService.AFTER_GLOBAL_MENU_SECTION_ID; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; -import java.util.stream.Collectors; import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.ActionContributionItem; import org.eclipse.jface.action.IContributionItem; -import org.eclipse.jface.window.Window; import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; import org.fortiss.af3.safetycases.model.ArgumentElement; import org.fortiss.af3.safetycases.model.ArgumentModule; import org.fortiss.af3.safetycases.model.AwayArgumentElement; -import org.fortiss.af3.safetycases.model.Change; import org.fortiss.af3.safetycases.ui.AF3SafetyCasesUIActivator; import org.fortiss.af3.safetycases.ui.action.SetAsImpactedAction; -import org.fortiss.af3.safetycases.ui.utils.DropdownDialog; +import org.fortiss.af3.safetycases.ui.action.SolveImpactAction; 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; @@ -85,7 +75,7 @@ public class SCElementIsImpacted implements IContextMenuContributor { @Override public void run() { boolean go = openConfirm(getCurrent().getActiveShell(), "", - "Are you sure you want to set this argument element as Challenged or Potentially/Actually Impacted?"); + "Are you sure you want to set this argument element as Challenged, Potentially/Actually Impacted or Modified?"); if(!go) { return; } @@ -98,19 +88,12 @@ public class SCElementIsImpacted implements IContextMenuContributor { private class SolveImpact extends Action { /** The selected argument element. */ private ArgumentElement selectedArgumentElement = null; - /** Default shell. */ - private Shell shell; - /** */ - private String changeDescription = ""; - /** */ - private List entryList; /** Constructor. */ SolveImpact(ArgumentElement selectedArgumentElement) { super("Set to Up-to-Date", AF3SafetyCasesUIActivator.getImageDescriptor("icons/set_up-to-date.png")); this.selectedArgumentElement = selectedArgumentElement; - this.shell = Display.getCurrent().getActiveShell(); } /** {@inheritDoc} */ @@ -122,81 +105,12 @@ public class SCElementIsImpacted implements IContextMenuContributor { @Override public void run() { boolean go = openConfirm(getCurrent().getActiveShell(), "", - "Are you sure you want to set as unchallenged or remove the potentially/actually impacts on this node?"); + "Are you sure you want to set as unchallenged or remove the potentially/actually/modified impacts on this node?"); if(!go) { return; } - if(selectedArgumentElement != null) { - List changes; - if(selectedArgumentElement instanceof AwayArgumentElement && - ((AwayArgumentElement)selectedArgumentElement) - .getPointsTo() != null) { - changes = ((AwayArgumentElement)selectedArgumentElement).getPointsTo() - .getAffectedByCurrentChanges(); - } else { - changes = selectedArgumentElement.getAffectedByCurrentChanges(); - } - if(changes == null) { - return; - } - entryList = new ArrayList(); - for(Change currentChange : changes) { - if(currentChange.getModelElement() != null && - getNameAndClass(currentChange) != null) { - List specifications = getNameAndClass(currentChange); - // first element of the list contains name - String name = specifications.get(0); - // second element contains the class name - String className = specifications.get(1); - changeDescription = - name + ", " + className + ", " + - returnStringTypeOfMaintenance( - currentChange.getMaintainanceCause()) + - ", "; - } - if(currentChange.getPersonalizedTypeOfChange() != null) { - changeDescription += currentChange.getPersonalizedTypeOfChange(); - } else { - changeDescription += currentChange.getPredefinedTypeOfChange(); - } - entryList.add(changeDescription); - } - DropdownDialog dialog = new DropdownDialog(shell.getShell(), - "Remove maintainance status", - "Select the maintainance status you want to remove", entryList); - String selected = ""; - if(dialog.open() == Window.OK) { - selected = dialog.getSelection(); - if(dialog.getSelection() == null) { - return; - } - } else { - return; - } - for(Change change : changes) { - List selectedSpecification = Arrays.stream(selected.split(", ")) - .collect(Collectors.toList()); - List actualChangeSpecifications = getNameAndClass(change); - actualChangeSpecifications.add( - returnStringTypeOfMaintenance(change.getMaintainanceCause())); - if(change.getPersonalizedTypeOfChange() != null) { - actualChangeSpecifications - .add(change.getPersonalizedTypeOfChange()); - } else { - actualChangeSpecifications.add(returnStringTypeOfChanges( - change.getPredefinedTypeOfChange())); - } - if(selectedSpecification.equals(actualChangeSpecifications)) { - - selectedArgumentElement.getAffectedByCurrentChanges() - .remove(change); - removePropagatedImpactOnAwayElements(selectedArgumentElement, - change); - EcoreUtil.delete(change); - break; - } - } - } + new SolveImpactAction(selectedArgumentElement, "", + Display.getCurrent().getActiveShell()).run(); } }); } diff --git a/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/commands/ShowPotentialChangeImpact.java b/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/commands/ShowPotentialChangeImpact.java index 747a3c979e9a58e025bb6b9377f9125809a04a7d..d0ddfc20e9a5e3b4e2168a097343ceaaaaae7a4d 100644 --- a/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/commands/ShowPotentialChangeImpact.java +++ b/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/commands/ShowPotentialChangeImpact.java @@ -17,6 +17,7 @@ package org.fortiss.af3.safetycases.ui.commands; import static java.util.Collections.emptyList; import static org.fortiss.af3.safetycases.model.maintenanceStatus.CHALLENGED; +import static org.fortiss.af3.safetycases.model.maintenanceStatus.MODIFIED; import static org.fortiss.af3.safetycases.ui.utils.MaintenanceUtils.getActualMaintainanceStatus; import static org.fortiss.af3.safetycases.ui.utils.MaintenanceUtils.getChallengedOrPotentiallyChange; import static org.fortiss.af3.safetycases.ui.utils.MaintenanceUtils.propagatePotentialImpactForChallengedArgElement; @@ -50,7 +51,9 @@ public class ShowPotentialChangeImpact implements IContextMenuContributor { ContextMenuContextProvider contextProvider) { if((selection instanceof ArgumentElement) && getActualMaintainanceStatus((ArgumentElement)selection) != null && - getActualMaintainanceStatus((ArgumentElement)selection).equals(CHALLENGED)) { + (getActualMaintainanceStatus((ArgumentElement)selection).equals(CHALLENGED) || + (getActualMaintainanceStatus((ArgumentElement)selection) + .equals(MODIFIED)))) { List contributionItems = new ArrayList(); contributionItems.add(new ActionContributionItem( new ShowPotentialChangeImpactAction((ArgumentElement)selection))); @@ -86,6 +89,7 @@ public class ShowPotentialChangeImpact implements IContextMenuContributor { @Override public void run() { propagatePotentialImpactForChallengedArgElement(selectedArgumentElement, + selectedArgumentElement, getChallengedOrPotentiallyChange(selectedArgumentElement)); } }); diff --git a/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/editor/fx/visual/.ratings b/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/editor/fx/visual/.ratings index b00222f9a4df265125ccf22d1ba32a8a6ec2387f..7863242f8a1daf4df0590608967d437e87f363d3 100644 --- a/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/editor/fx/visual/.ratings +++ b/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/editor/fx/visual/.ratings @@ -1,10 +1,10 @@ -AssumptionVisual.java 25ffc5d4466c37bcb2c4c9478cce16413a902874 GREEN -AwayContextVisual.java 49b39ab6fd3b6f648a51b01bdcc0b4dab53bccd4 GREEN -AwayGoalVisual.java fcef9ff50c54ba67e5e2a8764540c6dc26ef4348 GREEN -AwaySolutionVisual.java f7bcd8fd29c47ed4cf9c14ac603c9c31e13cabbf GREEN -ContextVisual.java df2551a9c280863652bf38356952501f8e3aa1e8 GREEN -GoalVisual.java 712f1bdddbd54f5f62c1a1a9be9955563b8c67cf GREEN -JustificationVisual.java 0618a99b469bf1c1edf317fa015aec627d545af2 GREEN +AssumptionVisual.java 9f7d1c5ca0f1ab4f6c502cf47739f0c40c817b7d GREEN +AwayContextVisual.java aec9855b0228a60253bee123942f7d9bae2278c6 GREEN +AwayGoalVisual.java e9fb7708b5e716737ef4be0a9f46ace96f20cc37 GREEN +AwaySolutionVisual.java ace31b82a37f17c31803991d9d3120fa8a6b6e21 GREEN +ContextVisual.java aad26cf41298cb4158239da0cb1db99af9673109 GREEN +GoalVisual.java ca99ac2520dcf476f34a8d5a11b00076519b4c6f GREEN +JustificationVisual.java 7bfee6fef9ff8aa662c4f7e3ad65d94ead4685f9 GREEN LayoutedCircularContentVisualBase.java b9a5fc8417787845800c1618faf2749af2c83803 GREEN LayoutedDiamondContentVisualBase.java ed4f7b76fd078be03fe2a8ad9a9ee05e319035be GREEN LayoutedEllipticContentVisualBase.java ee6deed6583ec9e860efa67e62c42149cfb8b436 GREEN @@ -13,5 +13,5 @@ OptionEntityVisual.java f5b07bc1147c50080047281cecc5d8fd65fdbb48 GREEN SafetyCasesConnectionVisual.java 242424629ffdbd4fa996c4367b6fd0173d8cd873 GREEN SafetyCasesConnectorVisual.java 00224439af1c86f7bf4702a5d505270a39bdb21f GREEN SafetyModuleVisual.java 372b1c84d5fd66d92a79ce750137e3f9291223d9 GREEN -SolutionVisual.java ab6f374a1252bee314c129e0cf52dbf1d8402401 GREEN -StrategyVisual.java e24dc62c52e63357df3529f8922b0317d20d39a8 GREEN +SolutionVisual.java e7112a800c713fedeb9e2e751eeeee9d4d9d0c27 GREEN +StrategyVisual.java 69af14c13d45ed71fca79ceda1ecd85409a18da5 GREEN diff --git a/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/editor/fx/visual/AssumptionVisual.java b/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/editor/fx/visual/AssumptionVisual.java index 25ffc5d4466c37bcb2c4c9478cce16413a902874..9f7d1c5ca0f1ab4f6c502cf47739f0c40c817b7d 100644 --- a/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/editor/fx/visual/AssumptionVisual.java +++ b/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/editor/fx/visual/AssumptionVisual.java @@ -15,14 +15,12 @@ +--------------------------------------------------------------------------*/ package org.fortiss.af3.safetycases.ui.editor.fx.visual; -import static org.fortiss.af3.safetycases.model.maintenanceStatus.ACTUALLY_IMPACTED; -import static org.fortiss.af3.safetycases.model.maintenanceStatus.CHALLENGED; -import static org.fortiss.af3.safetycases.model.maintenanceStatus.POTENTIALLY_IMPACTED; import static org.fortiss.af3.safetycases.ui.AF3SafetyCasesUIActivator.convertColor; import static org.fortiss.af3.safetycases.ui.AF3SafetyCasesUIActivator.getFXImage; import static org.fortiss.af3.safetycases.ui.DefaultStyle.ACTUALLY_IMPACTED_COLOR; import static org.fortiss.af3.safetycases.ui.DefaultStyle.CHALLENGED_COLOR; import static org.fortiss.af3.safetycases.ui.DefaultStyle.DEFAULT; +import static org.fortiss.af3.safetycases.ui.DefaultStyle.MODIFIED_COLOR; import static org.fortiss.af3.safetycases.ui.DefaultStyle.POTENTIALLY_IMPACTED_COLOR; import static org.fortiss.af3.safetycases.ui.DefaultStyle.TO_BE_FINALIZED_COLOR; @@ -50,6 +48,9 @@ public class AssumptionVisual extends LayoutedEllipticContentVisualBase { /** Returns whether an {@link Goal} is actually impacted. */ private boolean isActuallyImpacted = false; + /** Returns whether the attributes of an {@link Goal} were modified. */ + private boolean isModified = false; + /** The considered goal. */ Goal goal = getGoal(); @@ -79,12 +80,15 @@ public class GoalVisual extends NamedLayoutedRectangularContentVisual { protected Paint getFillColor() { if(!goal.getAffectedByCurrentChanges().isEmpty()) { for(Change goalTypeOfChange : goal.getAffectedByCurrentChanges()) { - if(goalTypeOfChange.getMaintainanceCause().equals(CHALLENGED)) { - return convertColor(CHALLENGED_COLOR); - } else if(goalTypeOfChange.getMaintainanceCause().equals(ACTUALLY_IMPACTED)) { - isActuallyImpacted = true; - } else if(goalTypeOfChange.getMaintainanceCause().equals(POTENTIALLY_IMPACTED)) { - isPotentiallyImpacted = true; + switch(goalTypeOfChange.getMaintainanceCause()) { + case CHALLENGED: + return convertColor(CHALLENGED_COLOR); + case ACTUALLY_IMPACTED: + isActuallyImpacted = true; + case POTENTIALLY_IMPACTED: + isPotentiallyImpacted = true; + case MODIFIED: + isModified = true; } } } @@ -102,6 +106,9 @@ public class GoalVisual extends NamedLayoutedRectangularContentVisual { */ isPotentiallyImpacted = false; return convertColor(POTENTIALLY_IMPACTED_COLOR); + } else if(isModified) { + isModified = false; + return convertColor(MODIFIED_COLOR); } else if(goal.isToBeDeveloped() || goal.isToBeInstantiated()) { return convertColor(TO_BE_FINALIZED_COLOR); } else if(goal.isToBeSupportedByContract()) { diff --git a/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/editor/fx/visual/JustificationVisual.java b/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/editor/fx/visual/JustificationVisual.java index 0618a99b469bf1c1edf317fa015aec627d545af2..7bfee6fef9ff8aa662c4f7e3ad65d94ead4685f9 100644 --- a/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/editor/fx/visual/JustificationVisual.java +++ b/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/editor/fx/visual/JustificationVisual.java @@ -15,14 +15,12 @@ +--------------------------------------------------------------------------*/ package org.fortiss.af3.safetycases.ui.editor.fx.visual; -import static org.fortiss.af3.safetycases.model.maintenanceStatus.ACTUALLY_IMPACTED; -import static org.fortiss.af3.safetycases.model.maintenanceStatus.CHALLENGED; -import static org.fortiss.af3.safetycases.model.maintenanceStatus.POTENTIALLY_IMPACTED; import static org.fortiss.af3.safetycases.ui.AF3SafetyCasesUIActivator.convertColor; import static org.fortiss.af3.safetycases.ui.AF3SafetyCasesUIActivator.getFXImage; import static org.fortiss.af3.safetycases.ui.DefaultStyle.ACTUALLY_IMPACTED_COLOR; import static org.fortiss.af3.safetycases.ui.DefaultStyle.CHALLENGED_COLOR; import static org.fortiss.af3.safetycases.ui.DefaultStyle.DEFAULT; +import static org.fortiss.af3.safetycases.ui.DefaultStyle.MODIFIED_COLOR; import static org.fortiss.af3.safetycases.ui.DefaultStyle.POTENTIALLY_IMPACTED_COLOR; import static org.fortiss.af3.safetycases.ui.DefaultStyle.TO_BE_FINALIZED_COLOR; @@ -50,6 +48,9 @@ public class JustificationVisual extends LayoutedEllipticContentVisualBase /** Returns whether an {@link Solution} is actually impacted. */ private boolean isActuallyImpacted = false; + /** Returns whether the attributes of an {@link Solution} were modified. */ + private boolean isModified = false; + /** Constructor. */ public SolutionVisual(IContentMVCBundle mvcb) { super(mvcb, Solution.class); @@ -97,13 +98,15 @@ public class SolutionVisual extends LayoutedCircularContentVisualBase protected Paint getFillColor() { if(!solution.getAffectedByCurrentChanges().isEmpty()) { for(Change solutionTypeOfChange : solution.getAffectedByCurrentChanges()) { - if(solutionTypeOfChange.getMaintainanceCause().equals(CHALLENGED)) { - return convertColor(CHALLENGED_COLOR); - } else if(solutionTypeOfChange.getMaintainanceCause().equals(ACTUALLY_IMPACTED)) { - isActuallyImpacted = true; - } else if(solutionTypeOfChange.getMaintainanceCause() - .equals(POTENTIALLY_IMPACTED)) { - isPotentiallyImpacted = true; + switch(solutionTypeOfChange.getMaintainanceCause()) { + case CHALLENGED: + return convertColor(CHALLENGED_COLOR); + case ACTUALLY_IMPACTED: + isActuallyImpacted = true; + case POTENTIALLY_IMPACTED: + isPotentiallyImpacted = true; + case MODIFIED: + isModified = true; } } } @@ -121,6 +124,9 @@ public class SolutionVisual extends LayoutedCircularContentVisualBase */ isPotentiallyImpacted = false; return convertColor(POTENTIALLY_IMPACTED_COLOR); + } else if(isModified) { + isModified = false; + return convertColor(MODIFIED_COLOR); } else if(solution.getStatus() == EvidenceStatus.OK) { return convertColor(DEFAULT); } else if(solution.getStatus() == EvidenceStatus.NOT_OK) { diff --git a/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/editor/fx/visual/StrategyVisual.java b/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/editor/fx/visual/StrategyVisual.java index e24dc62c52e63357df3529f8922b0317d20d39a8..69af14c13d45ed71fca79ceda1ecd85409a18da5 100644 --- a/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/editor/fx/visual/StrategyVisual.java +++ b/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/editor/fx/visual/StrategyVisual.java @@ -15,14 +15,12 @@ +--------------------------------------------------------------------------*/ package org.fortiss.af3.safetycases.ui.editor.fx.visual; -import static org.fortiss.af3.safetycases.model.maintenanceStatus.ACTUALLY_IMPACTED; -import static org.fortiss.af3.safetycases.model.maintenanceStatus.CHALLENGED; -import static org.fortiss.af3.safetycases.model.maintenanceStatus.POTENTIALLY_IMPACTED; import static org.fortiss.af3.safetycases.ui.AF3SafetyCasesUIActivator.convertColor; import static org.fortiss.af3.safetycases.ui.AF3SafetyCasesUIActivator.getFXImage; import static org.fortiss.af3.safetycases.ui.DefaultStyle.ACTUALLY_IMPACTED_COLOR; import static org.fortiss.af3.safetycases.ui.DefaultStyle.CHALLENGED_COLOR; import static org.fortiss.af3.safetycases.ui.DefaultStyle.DEFAULT; +import static org.fortiss.af3.safetycases.ui.DefaultStyle.MODIFIED_COLOR; import static org.fortiss.af3.safetycases.ui.DefaultStyle.POTENTIALLY_IMPACTED_COLOR; import static org.fortiss.af3.safetycases.ui.DefaultStyle.TO_BE_FINALIZED_COLOR; @@ -50,6 +48,9 @@ public class StrategyVisual extends LayoutedRhomboidContentVisualBase /** Returns whether an {@link Strategy} is actually impacted. */ private boolean isActuallyImpacted = false; + /** Returns whether the attributes of an {@link Strategy} were modified. */ + private boolean isModified = false; + /** The considered strategy. */ Strategy strategy = getStrategy(); @@ -74,13 +75,15 @@ public class StrategyVisual extends LayoutedRhomboidContentVisualBase protected Paint getFillColor() { if(!strategy.getAffectedByCurrentChanges().isEmpty()) { for(Change strategyTypeOfChange : strategy.getAffectedByCurrentChanges()) { - if(strategyTypeOfChange.getMaintainanceCause().equals(CHALLENGED)) { - return convertColor(CHALLENGED_COLOR); - } else if(strategyTypeOfChange.getMaintainanceCause().equals(ACTUALLY_IMPACTED)) { - isActuallyImpacted = true; - } else if(strategyTypeOfChange.getMaintainanceCause() - .equals(POTENTIALLY_IMPACTED)) { - isPotentiallyImpacted = true; + switch(strategyTypeOfChange.getMaintainanceCause()) { + case CHALLENGED: + return convertColor(CHALLENGED_COLOR); + case ACTUALLY_IMPACTED: + isActuallyImpacted = true; + case POTENTIALLY_IMPACTED: + isPotentiallyImpacted = true; + case MODIFIED: + isModified = true; } } } @@ -98,6 +101,9 @@ public class StrategyVisual extends LayoutedRhomboidContentVisualBase */ isPotentiallyImpacted = false; return convertColor(POTENTIALLY_IMPACTED_COLOR); + } else if(isModified) { + isModified = false; + return convertColor(MODIFIED_COLOR); } else if(strategy.isToBeDeveloped() || strategy.isToBeInstantiated()) { return convertColor(TO_BE_FINALIZED_COLOR); } diff --git a/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/properties/.ratings b/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/properties/.ratings index e620aa8f4ac48ed34ff9244a8b07cfd070fc8647..6c653fdcf110bd0b842a9884a31680d1b9acbc47 100644 --- a/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/properties/.ratings +++ b/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/properties/.ratings @@ -2,7 +2,7 @@ ArgumentElementPropertySection.java eee21888537f7aadcc1ee8d959f221a8a225d2b3 GRE ArgumentModuleQuantitativeProperty.java af0fb6a505221a6517debe550ad29b8f91fe66a6 GREEN AssumptionPropertySection.java 6baa436009dd5f0ea65080026ca95ab5c605ed89 GREEN AwayEntityPropertySection.java d842ca008db9bc2fb370718221a65c995dd475bd GREEN -ChangePropertySection.java fdcd457de707448a7f7d98c42db1f284fb678cc4 GREEN +ChangePropertySection.java 037bcd2e317676ab7624d251fa0465c7aa0d84ac GREEN ConnectionPropertySection.java a6fc5ef611528cd5002175b5ce84948debcb1092 GREEN ContextPropertySection.java 3901c88aee6a6e659a997d1fe76ab333a227c526 GREEN GSNStatesPropertySection.java ef75c66659b87cdf4fcafac7f02555cd296362fe GREEN diff --git a/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/properties/ChangePropertySection.java b/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/properties/ChangePropertySection.java index fdcd457de707448a7f7d98c42db1f284fb678cc4..037bcd2e317676ab7624d251fa0465c7aa0d84ac 100644 --- a/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/properties/ChangePropertySection.java +++ b/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/properties/ChangePropertySection.java @@ -16,7 +16,6 @@ package org.fortiss.af3.safetycases.ui.properties; import static org.fortiss.af3.safetycases.ui.utils.Utils.returnStringTypeOfMaintenance; -import static org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService.getInstance; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; @@ -27,8 +26,11 @@ import org.eclipse.swt.widgets.Link; import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; import org.fortiss.af3.safetycases.model.Change; import org.fortiss.af3.safetycases.model.Goal; +import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; import org.fortiss.tooling.kernel.model.INamedCommentedElement; +import org.fortiss.tooling.kernel.service.IPersistencyService; import org.fortiss.tooling.kernel.ui.extension.base.PropertySectionBase; +import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService; /** * Property section of a {@link Change}s. @@ -38,6 +40,8 @@ import org.fortiss.tooling.kernel.ui.extension.base.PropertySectionBase; public class ChangePropertySection extends PropertySectionBase { /** Link for referenced ModelElement section. */ private Link referenceLink; + /** Link for referenced ModelElement section. */ + private Link referenceArgEl; /** Currently selected {@link Goal}. */ private Change selectedChange; /** Maintenance status of the selected Change */ @@ -58,7 +62,34 @@ public class ChangePropertySection extends PropertySectionBase { referenceLink.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { - getInstance().openInEditor(selectedChange.getModelElement()); + IModelEditorBindingService.getInstance() + .openInEditor(selectedChange.getModelElement()); + return; + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + // Do nothing + } + }); + getWidgetFactory().createLabel(composite, "Propagated Impact From:"); + referenceArgEl = new Link(composite, SWT.MULTI); + referenceArgEl.addSelectionListener(new SelectionListener() { + @Override + public void widgetSelected(SelectionEvent e) { + final ITopLevelElement topLevel = + IPersistencyService.getInstance().getTopLevelElementFor(selectedChange); + topLevel.runAsCommand(new Runnable() { + @Override + public void run() { + IModelEditorBindingService.getInstance().closeEditor(selectedChange); + IModelEditorBindingService.getInstance() + .openInEditor(selectedChange.getReferencedImpactPropagation()); + IModelEditorBindingService.getInstance().getActiveEditor().setHighlight( + selectedChange.getReferencedImpactPropagation(), true); + } + }); + return; } @@ -91,9 +122,19 @@ public class ChangePropertySection extends PropertySectionBase { } maintenanceStatusContent .setText(returnStringTypeOfMaintenance(selectedChange.getMaintainanceCause())); + String name; if(selectedChange.getModelElement() != null) { - String name = ((INamedCommentedElement)selectedChange.getModelElement()).getName(); + name = ((INamedCommentedElement)selectedChange.getModelElement()).getName(); referenceLink.setText("" + name + ""); + } else { + referenceLink.setText("No Reference"); + } + if(selectedChange.getReferencedImpactPropagation() != null) { + name = ((INamedCommentedElement)selectedChange.getReferencedImpactPropagation()) + .getName(); + referenceArgEl.setText("" + name + ""); + } else { + referenceArgEl.setText("No propagated impact"); } } } diff --git a/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/utils/.ratings b/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/utils/.ratings index 91f15c2002b91489d7c651df15efce51bd0040dc..b89458e602637597234c9d35233c6b1465705de5 100644 --- a/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/utils/.ratings +++ b/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/utils/.ratings @@ -2,7 +2,7 @@ AF3SelectionDialogUtils.java 606c377620ecf8902101585cf60fa8117397bf30 GREEN DropdownDialog.java 1ec9b26db0e5c2cf40f1761de7bb9a0e3b1b1355 GREEN GSNSelectionDialogUtils.java e088ec2d2e58a40cae8f70ba7b91ba55682fedde GREEN InstantiationOfGSNElementsUtils.java c9babdd5984bdb15c178699605d6346d1865d2f4 GREEN -MaintenanceUtils.java 6666dea44eb6784c9f23c0c549bd6eada1eb1e17 GREEN +MaintenanceUtils.java fff5c555763da83273b916c1e7cdcb334d69e56f GREEN MultiPageWizard.java a901e2eb4967e3663b71a96cb22948283c200c2c GREEN OptionEntityInstantiation.java 05f5cf61184d6db033b47d58c19492799468943e GREEN QuantitativeEvaluationUtils.java 26f06e285252af1b0061fbc0ec7be8a5671fca09 GREEN @@ -10,4 +10,4 @@ SafetyCasesLibraryUIUtils.java 9496176dd4c161f58f48b2cf929f1d596cc08280 GREEN StringToClaimValidator.java 1cb681f25dfe96ff328e4d8d754fce6108f07697 GREEN StringToGsnIdValidator.java 197f42de3e3022ca918a1aa324b2b3d3314d8c44 GREEN TextHyperlinkingUtils.java 4c572f100e237eff1fe3ff01700d65d56331ff1c GREEN -Utils.java 49df8838110e6f1a01487b84f0869667443a289b GREEN +Utils.java 8ac648d4874d6dd8b9a037b4ba83db8498759cee GREEN diff --git a/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/utils/MaintenanceUtils.java b/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/utils/MaintenanceUtils.java index 6666dea44eb6784c9f23c0c549bd6eada1eb1e17..fff5c555763da83273b916c1e7cdcb334d69e56f 100644 --- a/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/utils/MaintenanceUtils.java +++ b/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/utils/MaintenanceUtils.java @@ -17,11 +17,13 @@ package org.fortiss.af3.safetycases.ui.utils; import static org.fortiss.af3.safetycases.model.maintenanceStatus.ACTUALLY_IMPACTED; import static org.fortiss.af3.safetycases.model.maintenanceStatus.CHALLENGED; +import static org.fortiss.af3.safetycases.model.maintenanceStatus.MODIFIED; import static org.fortiss.af3.safetycases.model.maintenanceStatus.POTENTIALLY_IMPACTED; import static org.fortiss.af3.safetycases.utils.SafetyCasesModelElementFactory.createChange; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; import org.fortiss.af3.safetycases.model.ArgumentElement; import org.fortiss.af3.safetycases.model.AwayArgumentElement; @@ -31,6 +33,7 @@ import org.fortiss.af3.safetycases.model.Goal; import org.fortiss.af3.safetycases.model.SafetyCase; import org.fortiss.af3.safetycases.model.Solution; import org.fortiss.af3.safetycases.model.Strategy; +import org.fortiss.af3.safetycases.model.TypeOfChange; import org.fortiss.af3.safetycases.model.maintenanceStatus; /** @@ -44,11 +47,11 @@ import org.fortiss.af3.safetycases.model.maintenanceStatus; public class MaintenanceUtils { /** This method propagates the impact of a challenged {@link ArgumentElement}. */ - public static void propagatePotentialImpactForChallengedArgElement(ArgumentElement e, - Change referencedChange) { + public static void propagatePotentialImpactForChallengedArgElement( + ArgumentElement propagatedArgEl, ArgumentElement e, Change referencedChange) { if(e instanceof Goal || e instanceof Strategy) { - propagateGoalOrStrategy(e, referencedChange); + propagateGoalOrStrategy(propagatedArgEl, e, referencedChange); } else { ArgumentElement temp; AwayArgumentElement temp2; @@ -66,19 +69,21 @@ public class MaintenanceUtils { temp2 = (AwayArgumentElement)e.getConnectors().get(i).getIncoming() .get(0).getSource().getOwner(); if(!containsEqualChange(referencedChange, temp2.getPointsTo())) { - Change change = - createImpactedChange(temp2.getPointsTo(), referencedChange); + Change change = createImpactedChange(propagatedArgEl, + temp2.getPointsTo(), referencedChange); temp2.getPointsTo().getAffectedByCurrentChanges().add(change); temp.getAffectedByCurrentChanges().add(change); } - propagatePotentialImpactForChallengedArgElement(temp2.getPointsTo(), - referencedChange); + propagatePotentialImpactForChallengedArgElement(propagatedArgEl, + temp2.getPointsTo(), referencedChange); } else if(!containsEqualChange(referencedChange, temp)) { - Change change = createImpactedChange(temp, referencedChange); + Change change = + createImpactedChange(propagatedArgEl, temp, referencedChange); temp.getAffectedByCurrentChanges().add(change); // get(0) there can be only one channel per connector - propagatedImpactOnAllAwayElements(temp, change); - propagatePotentialImpactForChallengedArgElement(temp, referencedChange); + propagatedImpactOnAllAwayElements(propagatedArgEl, temp, change); + propagatePotentialImpactForChallengedArgElement(propagatedArgEl, temp, + referencedChange); } } } @@ -104,6 +109,11 @@ public class MaintenanceUtils { return maintenanceStatus.POTENTIALLY_IMPACTED; } } + for(Change change : argElement.getAffectedByCurrentChanges()) { + if(change.getMaintainanceCause().equals(MODIFIED)) { + return maintenanceStatus.MODIFIED; + } + } } return null; } @@ -114,36 +124,57 @@ public class MaintenanceUtils { */ public static Change getChallengedOrPotentiallyChange(ArgumentElement argElement) { if(!argElement.getAffectedByCurrentChanges().isEmpty()) { - for(Change change : argElement.getAffectedByCurrentChanges()) { - if(change.getMaintainanceCause().equals(CHALLENGED)) { - return change; - } + List challengedElements = argElement.getAffectedByCurrentChanges().stream() + .filter(i -> i.getMaintainanceCause().equals(CHALLENGED)) + .collect(Collectors.toList()); + if(!challengedElements.isEmpty()) { + // Propagates a challenged impact. + return challengedElements.get(0); } - for(Change change : argElement.getAffectedByCurrentChanges()) { - if(change.getMaintainanceCause().equals(POTENTIALLY_IMPACTED)) { - return change; - } + List modifiedElements = argElement.getAffectedByCurrentChanges().stream() + .filter(i -> i.getMaintainanceCause().equals(MODIFIED)) + .collect(Collectors.toList()); + if(!modifiedElements.isEmpty()) { + // Propagates modified impact. + return modifiedElements.get(0); } + List potentiallyImpElements = argElement.getAffectedByCurrentChanges().stream() + .filter(i -> i.getMaintainanceCause().equals(POTENTIALLY_IMPACTED)) + .collect(Collectors.toList()); + // Propagates a potential impact. + return potentiallyImpElements.get(0); } return null; } /** This method creates a new change. */ - public static Change createImpactedChange(ArgumentElement e, Change referencedChange) { + public static Change createImpactedChange(ArgumentElement propagatedArgEl, ArgumentElement e, + Change referencedChange) { Change change = createChange(); change.setContainer(e); change.setMaintainanceCause(POTENTIALLY_IMPACTED); - change.setModelElement(referencedChange.getModelElement()); - if(referencedChange.getPersonalizedTypeOfChange() != null) { - change.setPersonalizedTypeOfChange(referencedChange.getPersonalizedTypeOfChange()); - } else if(!referencedChange.getPredefinedTypeOfChange().equals("NONE")) { - change.setPredefinedTypeOfChange(referencedChange.getPredefinedTypeOfChange()); + // If element is modified, set typeofchange as modified. + if(getChallengedOrPotentiallyChange(propagatedArgEl).equals(MODIFIED)) { + change.setPredefinedTypeOfChange(TypeOfChange.MODIFIED); + } else { + if(referencedChange.getModelElement() != null) { + change.setModelElement(referencedChange.getModelElement()); + } + if(referencedChange.getPersonalizedTypeOfChange() != null) { + change.setPersonalizedTypeOfChange(referencedChange.getPersonalizedTypeOfChange()); + } else if(!referencedChange.getPredefinedTypeOfChange().equals("NONE")) { + change.setPredefinedTypeOfChange(referencedChange.getPredefinedTypeOfChange()); + } } + change.setReferencedImpactPropagation(propagatedArgEl); return change; } /** This method checks whether 2 changes are equal. */ public static boolean equalsChange(Change change1, Change change2) { + if(change1 == null || change2 == null) { + return false; + } if(change2.getPersonalizedTypeOfChange() != null && change1.getPersonalizedTypeOfChange() != null) { if(!change1.getPersonalizedTypeOfChange() @@ -151,11 +182,18 @@ public class MaintenanceUtils { return false; } } else { - if(!change1.getPredefinedTypeOfChange().equals(change2.getPredefinedTypeOfChange())) { + if((change2.getPersonalizedTypeOfChange() == null && + change1.getPersonalizedTypeOfChange() != null) || + (change2.getPersonalizedTypeOfChange() != null && + change1.getPersonalizedTypeOfChange() == null) && + !change1.getPredefinedTypeOfChange() + .equals(change2.getPredefinedTypeOfChange())) { return false; } } - if(!change1.getModelElement().equals(change2.getModelElement())) { + if((change1.getModelElement() == null && change2.getModelElement() != null) || + (change1.getModelElement() != null && change2.getModelElement() == null) && + !change1.getModelElement().equals(change2.getModelElement())) { return false; } @@ -186,8 +224,8 @@ public class MaintenanceUtils { * This methods propagate the impact on a Solution/Goal/Context AND on all referenced * AwayArguments AND the ArgumentElements connected with the AwayArguments. */ - public static void propagatedImpactOnAllAwayElements(ArgumentElement selectedArgumentElement, - Change change) { + public static void propagatedImpactOnAllAwayElements(ArgumentElement propagatedArgEl, + ArgumentElement selectedArgumentElement, Change change) { if(selectedArgumentElement instanceof Goal || selectedArgumentElement instanceof Solution || selectedArgumentElement instanceof Context) { List awayElements = new ArrayList(); @@ -202,7 +240,7 @@ public class MaintenanceUtils { for(AwayArgumentElement el : awayElements) { if(!containsEqualChange(change, el)) { el.getAffectedByCurrentChanges().add(change); - propagatePotentialImpactForChallengedArgElement(el, change); + propagatePotentialImpactForChallengedArgElement(propagatedArgEl, el, change); } } } @@ -260,12 +298,14 @@ public class MaintenanceUtils { } /** This method propagates the impact of a challenged {@link Goal} or {@link Strategy}. */ - public static void propagateGoalOrStrategy(ArgumentElement e, Change referencedChange) { + public static void propagateGoalOrStrategy(ArgumentElement propagatedArgEl, ArgumentElement e, + Change referencedChange) { ArgumentElement temp; AwayArgumentElement temp2; for(int i = 0; i < e.getConnectors().size(); i++) { if(!(e.getConnectors().get(i).getOutgoing().isEmpty())) { // get(0) there can be only one channel per connector + temp = (ArgumentElement)e.getConnectors().get(i).getOutgoing().get(0).getTarget() .getOwner(); if(temp instanceof AwayArgumentElement) { @@ -276,18 +316,20 @@ public class MaintenanceUtils { temp2 = (AwayArgumentElement)e.getConnectors().get(i).getOutgoing().get(0) .getTarget().getOwner(); if(!containsEqualChange(referencedChange, temp2.getPointsTo())) { - Change change = createImpactedChange(temp2.getPointsTo(), referencedChange); + Change change = createImpactedChange(propagatedArgEl, temp2.getPointsTo(), + referencedChange); temp2.getPointsTo().getAffectedByCurrentChanges().add(change); temp.getAffectedByCurrentChanges().add(change); } - propagatePotentialImpactForChallengedArgElement(temp2.getPointsTo(), - referencedChange); + propagatePotentialImpactForChallengedArgElement(propagatedArgEl, + temp2.getPointsTo(), referencedChange); } else if(!containsEqualChange(referencedChange, temp)) { // get(0) there can be only one channel per connector - Change change = createImpactedChange(temp, referencedChange); + Change change = createImpactedChange(propagatedArgEl, temp, referencedChange); temp.getAffectedByCurrentChanges().add(change); - propagatedImpactOnAllAwayElements(temp, change); - propagatePotentialImpactForChallengedArgElement(temp, referencedChange); + propagatedImpactOnAllAwayElements(propagatedArgEl, temp, change); + propagatePotentialImpactForChallengedArgElement(propagatedArgEl, temp, + referencedChange); } } else if(!(e.getConnectors().get(i).getIncoming().isEmpty())) { // get(0) there can be only one channel per connector @@ -301,18 +343,20 @@ public class MaintenanceUtils { temp2 = (AwayArgumentElement)e.getConnectors().get(i).getIncoming().get(0) .getSource().getOwner(); if(!containsEqualChange(referencedChange, temp2.getPointsTo())) { - Change change = createImpactedChange(temp2.getPointsTo(), referencedChange); + Change change = createImpactedChange(propagatedArgEl, temp2.getPointsTo(), + referencedChange); temp2.getPointsTo().getAffectedByCurrentChanges().add(change); temp.getAffectedByCurrentChanges().add(change); } - propagatePotentialImpactForChallengedArgElement(temp2.getPointsTo(), - referencedChange); + propagatePotentialImpactForChallengedArgElement(propagatedArgEl, + temp2.getPointsTo(), referencedChange); } else if(!containsEqualChange(referencedChange, temp)) { // get(0) there can be only one channel per connector - Change change = createImpactedChange(temp, referencedChange); + Change change = createImpactedChange(propagatedArgEl, temp, referencedChange); temp.getAffectedByCurrentChanges().add(change); - propagatedImpactOnAllAwayElements(temp, change); - propagatePotentialImpactForChallengedArgElement(temp, referencedChange); + propagatedImpactOnAllAwayElements(propagatedArgEl, temp, change); + propagatePotentialImpactForChallengedArgElement(propagatedArgEl, temp, + referencedChange); } } } diff --git a/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/utils/Utils.java b/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/utils/Utils.java index 49df8838110e6f1a01487b84f0869667443a289b..8ac648d4874d6dd8b9a037b4ba83db8498759cee 100644 --- a/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/utils/Utils.java +++ b/org.fortiss.af3.safetycases.ui/src/org/fortiss/af3/safetycases/ui/utils/Utils.java @@ -23,6 +23,7 @@ import static org.eclipse.swt.widgets.Display.getCurrent; import static org.fortiss.af3.safetycases.model.maintenanceStatus.ACTUALLY_IMPACTED; import static org.fortiss.af3.safetycases.model.maintenanceStatus.CHALLENGED; import static org.fortiss.af3.safetycases.model.maintenanceStatus.POTENTIALLY_IMPACTED; +import static org.fortiss.af3.safetycases.ui.utils.MaintenanceUtils.removePropagatedImpactOnAwayElements; import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickInstanceOf; import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getRootElements; @@ -33,6 +34,7 @@ import java.util.function.Predicate; import java.util.stream.Collectors; import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Display; @@ -41,6 +43,7 @@ import org.eclipse.swt.widgets.Shell; import org.fortiss.af3.safetyargumentationpackage.model.SafetyArgumentationPackage; import org.fortiss.af3.safetycases.model.ArgumentElement; import org.fortiss.af3.safetycases.model.ArgumentModule; +import org.fortiss.af3.safetycases.model.AwayArgumentElement; import org.fortiss.af3.safetycases.model.AwayGoal; import org.fortiss.af3.safetycases.model.Change; import org.fortiss.af3.safetycases.model.Context; @@ -241,6 +244,62 @@ public class Utils { return ""; } + /** This method the type of modified attribute of an {@link ArgumentElement}. */ + public static String modifiedAttributeString(String attribute) { + switch(attribute) { + case "name": + return "Name"; + case "comment": + return "Comment"; + case "textualInformation": + return "Claim"; + case "author": + return "Author"; + case "creator": + return "Creator"; + case "lastModified": + return "Last Modified"; + case "assessmentStatus": + return "Assessment Status"; + case "lastAssessmentDate": + return "Last Assessment Date"; + case "visibility": + return "Visibility"; + case "documentReference": + return "Document Reference"; + default: + return ""; + } + } + + /** This method the type of modified attribute of an {@link ArgumentElement}. */ + public static String modifiedAttribute(String string) { + switch(string) { + case "Name": + return "name"; + case "Comment": + return "comment"; + case "Claim": + return "textualInformation"; + case "Author": + return "author"; + case "Creator": + return "creator"; + case "Last Modified": + return "lastModified"; + case "Assessment Status": + return "assessmentStatus"; + case "Last Assessment Date": + return "lastAssessmentDate"; + case "Visibility": + return "visibility"; + case "Document Reference": + return "documentReference"; + default: + return ""; + } + } + /** This method returns a list of all elements referenced by an {@link ArgumentElement}. */ public static List alreadyReferencedElements(ArgumentElement argElem) { List existingReferences = new ArrayList(); @@ -315,4 +374,79 @@ public class Utils { .collect(Collectors.toList()); return referenced; } + + /** + * Method to remove the challenged/potentially/actually/modified impacts. + * + * @param selected + * @param selectedArgumentElement + */ + public static void removeSelectedImpact(String selected, + ArgumentElement selectedArgumentElement) { + List changes; + if(selectedArgumentElement instanceof AwayArgumentElement && + ((AwayArgumentElement)selectedArgumentElement).getPointsTo() != null) { + changes = ((AwayArgumentElement)selectedArgumentElement).getPointsTo() + .getAffectedByCurrentChanges(); + } else { + changes = selectedArgumentElement.getAffectedByCurrentChanges(); + } + if(changes == null) { + return; + } + for(Change change : changes) { + List selectedSpecification = + Arrays.stream(selected.split(", ")).collect(Collectors.toList()); + /* + * Manually added changes have 4 parameters: Name, Class, Maintenance + * Status, Type of Change. + */ + if(selectedSpecification.size() == 4 && change.getModelElement() != null) { + List actualChangeSpecifications = getNameAndClass(change); + actualChangeSpecifications + .add(returnStringTypeOfMaintenance(change.getMaintainanceCause())); + if(change.getPersonalizedTypeOfChange() != null) { + actualChangeSpecifications.add(change.getPersonalizedTypeOfChange()); + } else { + actualChangeSpecifications + .add(returnStringTypeOfChanges(change.getPredefinedTypeOfChange())); + } + if(selectedSpecification.equals(actualChangeSpecifications)) { + + selectedArgumentElement.getAffectedByCurrentChanges().remove(change); + removePropagatedImpactOnAwayElements(selectedArgumentElement, change); + EcoreUtil.delete(change); + break; + } + } + if(change.getMaintainanceCause() == maintenanceStatus.POTENTIALLY_IMPACTED && + selectedSpecification.size() == 2) { + List actualChangeSpecifications = new ArrayList(); + actualChangeSpecifications + .add(returnStringTypeOfMaintenance(change.getMaintainanceCause())); + actualChangeSpecifications + .add(returnStringTypeOfChanges(change.getPredefinedTypeOfChange())); + if(selectedSpecification.equals(actualChangeSpecifications)) { + selectedArgumentElement.getAffectedByCurrentChanges().remove(change); + removePropagatedImpactOnAwayElements(selectedArgumentElement, change); + EcoreUtil.delete(change); + break; + } + } + if(change.getMaintainanceCause() == maintenanceStatus.MODIFIED) { + /* + * Automated added changes have 2 parameters: Maintenance Status and + * Modified attribute name. + */ + if(selectedSpecification.get(1) != null && + modifiedAttribute(selectedSpecification.get(1)) + .equals(change.getModifiedAttribute())) { + selectedArgumentElement.getAffectedByCurrentChanges().remove(change); + removePropagatedImpactOnAwayElements(selectedArgumentElement, change); + EcoreUtil.delete(change); + break; + } + } + } + } } diff --git a/org.fortiss.af3.safetycases/model/.ratings b/org.fortiss.af3.safetycases/model/.ratings index 57c5826e9a1323c32d49ff72b1d3a62ef29d94f5..c081886667419e29ee04761c43607338278a77a3 100644 --- a/org.fortiss.af3.safetycases/model/.ratings +++ b/org.fortiss.af3.safetycases/model/.ratings @@ -1,2 +1,2 @@ safetyargumentationpackage.ecore e95d1c0c64d12fa1660899df86cc9009dbae1754 GREEN -safetycases.ecore cd86afd94aefa889038b637270747b8af6a419fb YELLOW +safetycases.ecore f568e17fa1249e0704375499c06d221c3659552f GREEN diff --git a/org.fortiss.af3.safetycases/model/safetycases.ecore b/org.fortiss.af3.safetycases/model/safetycases.ecore index 5624cfbb0512a7d5887501d47861c99b5f5069a7..f568e17fa1249e0704375499c06d221c3659552f 100644 --- a/org.fortiss.af3.safetycases/model/safetycases.ecore +++ b/org.fortiss.af3.safetycases/model/safetycases.ecore @@ -352,10 +352,11 @@ + - + @@ -365,6 +366,9 @@ + + diff --git a/org.fortiss.af3.safetycases/model/safetycases.genmodel b/org.fortiss.af3.safetycases/model/safetycases.genmodel index e3b6e2bcdbfed8bb49d296adfa5d356ede806ab7..4fc4801fd6d2e867be1ac77cc506fb89d3452287 100644 --- a/org.fortiss.af3.safetycases/model/safetycases.genmodel +++ b/org.fortiss.af3.safetycases/model/safetycases.genmodel @@ -37,10 +37,11 @@ + - + @@ -244,6 +245,8 @@ + + diff --git a/org.fortiss.af3.safetycases/src/org/fortiss/af3/safetycases/listener/.ratings b/org.fortiss.af3.safetycases/src/org/fortiss/af3/safetycases/listener/.ratings index 6ed1f855c847f0f23ba564c3b53dd20a7157b65e..27d1086687f6f7a1f0b6805731ee13db4cd1fee3 100644 --- a/org.fortiss.af3.safetycases/src/org/fortiss/af3/safetycases/listener/.ratings +++ b/org.fortiss.af3.safetycases/src/org/fortiss/af3/safetycases/listener/.ratings @@ -1,2 +1,2 @@ -AutomaticSetListener.java 3f5c9ea1b51d5772d2223b3fba8cdb31ce1547f3 GREEN +AutomaticSetListener.java 9412a667eec055a85ac6660dc35a94fbb8c4f10a GREEN AutomaticSetListenerPersistency.java fdf9f4af3ec798af6c5f95d7b1f6a3ed39de2b14 GREEN diff --git a/org.fortiss.af3.safetycases/src/org/fortiss/af3/safetycases/listener/AutomaticSetListener.java b/org.fortiss.af3.safetycases/src/org/fortiss/af3/safetycases/listener/AutomaticSetListener.java index 3f5c9ea1b51d5772d2223b3fba8cdb31ce1547f3..9412a667eec055a85ac6660dc35a94fbb8c4f10a 100644 --- a/org.fortiss.af3.safetycases/src/org/fortiss/af3/safetycases/listener/AutomaticSetListener.java +++ b/org.fortiss.af3.safetycases/src/org/fortiss/af3/safetycases/listener/AutomaticSetListener.java @@ -15,6 +15,8 @@ +--------------------------------------------------------------------------*/ package org.fortiss.af3.safetycases.listener; +import static org.fortiss.af3.safetycases.model.maintenanceStatus.MODIFIED; +import static org.fortiss.af3.safetycases.utils.SafetyCasesModelElementFactory.createChange; import static org.fortiss.af3.safetycases.utils.SafetyCasesUtils.getAllAllocations; import static org.fortiss.af3.safetycases.utils.SafetyCasesUtils.getAllLogicalComponents; import static org.fortiss.af3.safetycases.utils.SafetyCasesUtils.getAllModes; @@ -25,6 +27,7 @@ import static org.fortiss.tooling.common.util.LambdaUtils.filter; import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickInstanceOf; import static org.fortiss.tooling.kernel.utils.LoggingUtils.warning; +import java.util.Arrays; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -43,8 +46,10 @@ import org.fortiss.af3.project.model.FileProject; import org.fortiss.af3.safetyargumentationpackage.model.SafetyArgumentationPackage; import org.fortiss.af3.safetycases.AF3SafetyCasesActivator; import org.fortiss.af3.safetycases.model.ArgumentElement; +import org.fortiss.af3.safetycases.model.Change; import org.fortiss.af3.safetycases.model.DecomposableSpinalElement; import org.fortiss.af3.safetycases.model.ExitConnector; +import org.fortiss.af3.safetycases.model.TypeOfChange; import org.fortiss.af3.state.model.State; import org.fortiss.tooling.base.model.base.HierarchicElementBase; import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; @@ -60,6 +65,11 @@ public class AutomaticSetListener extends EContentAdapter { /** Holds the instance of the {@link AutomaticSetListener}. */ private volatile static AutomaticSetListener INSTANCE; + /** Properties Attributes of ArgumentElements. */ + private List argumentElementAttributes = Arrays.asList("textualInformation", + "rationale", "author", "creator", "lastModified", "assessmentStatus", + "lastAssessmentDate", "comment", "name", "visibility", "documentReference", "id"); + /** Constructor. */ private AutomaticSetListener() { // Prevents direct instantiation. @@ -96,15 +106,14 @@ public class AutomaticSetListener extends EContentAdapter { @Override public void notifyChanged(Notification notification) { super.notifyChanged(notification); - // Automatic set as instantiated/uninstantiated ArgumentElement. if(notification.getNotifier() instanceof ArgumentElement && notification.getEventType() == Notification.SET) { // Input checks. if(!(notification.getFeature() instanceof EAttribute)) { return; } - EAttribute attribute = (EAttribute)notification.getFeature(); + // Automatic set as instantiated/uninstantiated ArgumentElement. if(attribute.getName().equals("textualInformation")) { ArgumentElement argElement = ((ArgumentElement)notification.getNotifier()); String textualInformation = argElement.getTextualInformation(); @@ -120,8 +129,38 @@ public class AutomaticSetListener extends EContentAdapter { } else { argElement.setToBeInstantiated(true); } - // Search for patterns in a claim.  + // Search for patterns in a claim. matchMe(textualInformation, argElement); + if(textualInformation.equals("Claim")) { + return; + } + } + // Automatic set maintenance status as modified. + if(argumentElementAttributes.contains(attribute.getName())) { + ArgumentElement argElement = ((ArgumentElement)notification.getNotifier()); + // Fix bug: When creating a new argument element in the argument module, it + // automatically adds a new modified change + if(attribute.getName().equals("comment")) { + if(argElement.getTextualInformation().equals("{Claim}")) { + return; + } + } + List changes = argElement.getAffectedByCurrentChanges(); + boolean alreadyModifiedAttribute = changes.stream() + .filter(i -> i.getMaintainanceCause().equals(MODIFIED) && + i.getModifiedAttribute().equals(attribute.getName())) + .findAny().isPresent(); + if(!alreadyModifiedAttribute) { + Change change = createChange(); + change.setMaintainanceCause(MODIFIED); + change.setModifiedAttribute(attribute.getName()); + change.setContainer(argElement); + change.setPredefinedTypeOfChange(TypeOfChange.MODIFIED); + change.setComment(attribute.getName()); + change.setModelElement(null); + argElement.getContainedElements().add(change); + argElement.getAffectedByCurrentChanges().add(change); + } } return; }