Commit 682877db authored by Liana Soima's avatar Liana Soima
Browse files

YELLOW



Code review.
Signed-off-by: Liana Soima's avatarLiana Soima <soima@fortiss.org>
Issue-Ref: 4054
parent 09005ac1
PrototypeProvider.java 1f398ca9a394ae5ab50a8c8a6202dd0e50746008 GREEN
PrototypeProvider.java b5c6caca89d864dc1a2f22816da01f9dd2fa6e73 YELLOW
AF3SelectionDialogUtils.java 606c377620ecf8902101585cf60fa8117397bf30 GREEN
DropdownDialog.java 1ec9b26db0e5c2cf40f1761de7bb9a0e3b1b1355 GREEN
GSNSelectionDialogUtils.java 01cdc5c80a6d678e47b39d4dbd571de15b283d8f GREEN
GSNSelectionDialogUtils.java e088ec2d2e58a40cae8f70ba7b91ba55682fedde YELLOW
InstantiationOfGSNElementsUtils.java 17c317ebdf5b1ba3e98df37622a519d07c444ac4 GREEN
MaintenanceUtils.java 6666dea44eb6784c9f23c0c549bd6eada1eb1e17 GREEN
MultiPageWizard.java a901e2eb4967e3663b71a96cb22948283c200c2c GREEN
......
......@@ -17,7 +17,6 @@ package org.fortiss.af3.safetycases.ui.utils;
import static java.util.Arrays.asList;
import static org.eclipse.jface.dialogs.MessageDialog.openInformation;
import static org.fortiss.af3.requirementspatterns.utils.SafetyClaimPatternsCollectionModelElementFactory.createSafetyClaimPattern;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickInstanceOf;
import java.util.ArrayList;
......@@ -26,15 +25,7 @@ import java.util.List;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.fortiss.af3.requirementspatterns.model.PatternsDatabase;
import org.fortiss.af3.requirementspatterns.model.SafetyClaimPattern;
import org.fortiss.af3.requirementspatterns.model.SafetyClaimPatternsCollection;
import org.fortiss.af3.safetyargumentationpackage.model.SafetyArgumentationPackage;
import org.fortiss.af3.safetycases.model.ArgumentElement;
import org.fortiss.af3.safetycases.model.ArgumentElementBase;
......@@ -49,14 +40,10 @@ import org.fortiss.af3.safetycases.model.Goal;
import org.fortiss.af3.safetycases.model.SafetyCase;
import org.fortiss.af3.safetycases.model.SafetyModule;
import org.fortiss.af3.safetycases.model.Solution;
import org.fortiss.tooling.base.model.element.IHierarchicElementContainer;
import org.fortiss.tooling.base.ui.dialog.ElementTreeMultiSelectDialog;
import org.fortiss.tooling.base.ui.dialog.ElementTreeSingleSelectDialog;
import org.fortiss.tooling.base.ui.dialog.ModelElementTreeContentProvider;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.service.IPersistencyService;
import org.fortiss.tooling.kernel.ui.presentation.ModelElementLabelProvider;
import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService;
/**
* Utility class to let user select an {@link ArgumentElementBase} from
......@@ -246,180 +233,6 @@ public class GSNSelectionDialogUtils {
return null;
}
/**
* This method creates a tree dialog which displays all the available {@link SafetyClaimPattern}
* s
* within the given {@link PatternsDatabase}s which are defined for the type of argument element
* given as parameter. The user can choose only one {@link SafetyClaimPattern}.
*
* @param shell
* The parent shell.
* @param patternsDatabasesList
* The patterns databases.
* @param selected
* The currently selected sentence from the patterns database.
* @param argElement
* The argument element.
* @return The selected sentence from the tree dialog.
*/
public static SafetyClaimPattern openSafetyClaimPattern(final Shell shell,
final ArrayList<PatternsDatabase> patternsDatabasesList, SafetyClaimPattern selected,
final ArgumentElement argElement) {
ArrayList<PatternsDatabase> root = patternsDatabasesList;
ElementTreeSingleSelectDialog dialog = new ElementTreeSingleSelectDialog(shell, root,
selected, new ModelElementTreeContentProvider(root) {
/** {@inheritDoc} */
@Override
public List<? extends EObject> getChildren(EObject parent) {
List<? extends EObject> list =
pickInstanceOf(
asList(new Class<?>[] {SafetyClaimPatternsCollection.class,
SafetyClaimPattern.class}),
super.getChildren(parent));
List<SafetyClaimPattern> filteredList = new ArrayList<SafetyClaimPattern>();
for(EObject obj : list) {
for(SafetyClaimPattern s : ((SafetyClaimPatternsCollection)obj)
.getSentences()) {
// Check if the sentence is defined for the type of argument
// element the given element is.
if(s.getTypeOfGSNElement() != null &&
argElement.getClass().getSimpleName().contains(
s.getTypeOfGSNElement().getSimpleName())) {
filteredList.add(s);
}
}
}
return filteredList;
}
}, new ModelElementLabelProvider(), null) {
/** {@inheritDoc} */
@Override
public boolean acceptElement(Object element) {
return element instanceof SafetyClaimPattern;
}
@Override
protected void createButtonsForButtonBar(final Composite parent) {
super.createButtonsForButtonBar(parent);
// The user can also create a new sentence.
Button createSentencebutton = new Button(parent, SWT.PUSH);
createSentencebutton.setText("Create new Safety Claim Pattern");
createSentencebutton.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
// Get the container of one of the patterns database, since thy all
// would be in the same container.
IHierarchicElementContainer container =
patternsDatabasesList.get(0).getContainer();
final ITopLevelElement topLevel =
IPersistencyService.getInstance().getTopLevelElementFor(container);
topLevel.runAsCommand(new Runnable() {
@Override
public void run() {
SafetyClaimPatternsCollection selectedRequirementsPattern =
openSafetyClaimPatternsCollection(shell,
patternsDatabasesList, null);
if(selectedRequirementsPattern != null) {
SafetyClaimPattern sentence = createSafetyClaimPattern();
selectedRequirementsPattern.getContainedElements()
.add(sentence);
sentence.setTypeOfGSNElement(argElement.getClass());
IModelEditorBindingService.getInstance().openInEditor(sentence);
}
}
});
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// do nothing
}
});
}
};
if(Window.OK == dialog.open()) {
return (SafetyClaimPattern)dialog.getSelectedElement();
}
return selected;
}
/**
* This method creates a tree dialog which displays all the existing
* {@link SafetyClaimPatternsCollection} s within the given {@link PatternsDatabase}s. The user
* can choose only one {@link SafetyClaimPatternsCollection}.
*
* @param shell
* The parent shell.
* @param patternsDatabasesList
* The patterns databases.
* @param selected
* The currently selected requirements pattern from the patterns database.
* @return The selected requirements pattern from the tree dialog.
*/
public static SafetyClaimPatternsCollection openSafetyClaimPatternsCollection(final Shell shell,
List<PatternsDatabase> patternsDatabasesList, SafetyClaimPatternsCollection selected) {
List<PatternsDatabase> root = patternsDatabasesList;
ElementTreeSingleSelectDialog dialog = new ElementTreeSingleSelectDialog(shell, root,
selected, new ModelElementTreeContentProvider(root) {
/** {@inheritDoc} */
@Override
public List<? extends EObject> getChildren(EObject parent) {
return pickInstanceOf(SafetyClaimPatternsCollection.class,
super.getChildren(parent));
}
}, new ModelElementLabelProvider(), null) {
/** {@inheritDoc} */
@Override
public boolean acceptElement(Object element) {
return element instanceof SafetyClaimPatternsCollection;
}
};
if(Window.OK == dialog.open()) {
return (SafetyClaimPatternsCollection)dialog.getSelectedElement();
}
return selected;
}
/**
* This method creates a tree dialog which displays all the existing {@link SafetyClaimPattern}s
* within the given {@link PatternsDatabase}s. The user can choose only one
* {@link SafetyClaimPattern}.
*
* @param shell
* The parent shell.
* @param patternsDatabasesList
* The patterns database.
* @param selected
* The currently selected sentence from the patterns database.
* @return The selected sentence from the tree dialog.
*/
public static SafetyClaimPattern openSafetyClaimPatterns(final Shell shell,
List<PatternsDatabase> patternsDatabasesList, SafetyClaimPattern selected) {
List<PatternsDatabase> root = patternsDatabasesList;
ElementTreeSingleSelectDialog dialog = new ElementTreeSingleSelectDialog(shell, root,
selected, new ModelElementTreeContentProvider(root) {
/** {@inheritDoc} */
@Override
public List<? extends EObject> getChildren(EObject parent) {
return pickInstanceOf(asList(new Class<?>[] {SafetyClaimPattern.class}),
super.getChildren(parent));
}
}, new ModelElementLabelProvider(), null) {
/** {@inheritDoc} */
@Override
public boolean acceptElement(Object element) {
return element instanceof SafetyClaimPattern;
}
};
if(Window.OK == dialog.open()) {
return (SafetyClaimPattern)dialog.getSelectedElement();
}
return selected;
}
/**
* This method creates a tree dialog which displays all the existing {@link Context}s
* within the given {@link SafetyCase}. The user can choose only one {@link Context}.
......
......@@ -6,7 +6,7 @@ AwayGoalCompositor.java 4432c8934746be63dc16374bd923a4e9f3b6d1d0 GREEN
AwayGoalInContextOfConnectionCompositor.java 49daac2f7b70f9ceb708cb27a78fc190bf3293d2 GREEN
AwayGoalSupportedByConnectionCompositor.java 05735ae0a9c07c05a7008319fca34bd186e0e8c9 GREEN
AwaySolutionCompositor.java cce1a2056192a8f2c71b5af4dd52ede2982f94d2 GREEN
ConnectionCompositor.java 526784d8b19c71c724f645918473aba28ca33eb7 GREEN
ConnectionCompositor.java c5bb71ad4b60ab6190f0d358fe6106d89c87a498 YELLOW
ContextCompositor.java 0540ee7716235bb96fc48c37ff618d4117a446f5 GREEN
ContractModuleCompositor.java ac85daf1d00003404bf6ba1d9577590c5df92948 GREEN
GoalCompositor.java fde0cc8da148f5ad65263c999d35507b443697ac GREEN
......
LibraryModuleUtils.java c362ae13c59a8d76cff5dabf8ec11ac024105823 GREEN
ModuleLibraryModelElementFactory.java 5d882790170eb0ebc8be493e05d675e007cc5cca GREEN
SafetyCasesAnalysisUtils.java ee22d78b153c6f23aac5efab094efce52170d65c GREEN
SafetyCasesAnalysisUtils.java 6183d6b677046dfeb7d2cf648a9ebeb6b6946938 YELLOW
SafetyCasesModelElementFactory.java 264e24056a3fd782e81dc02870173fda63a49377 GREEN
SafetyCasesModellingUtils.java 8e3d8401066a59d17c03c169e25597e9396866f8 GREEN
SafetyCasesUtils.java be6c08065b38250bd80d9e892fd80bb0916165a0 GREEN
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