Commit f82b6271 authored by Liana Soima's avatar Liana Soima
Browse files

Delete unnecessary classes



-Delete "Download a database ..." from the Context Menu of Assurance
Package elements
-Delete "Type" from the Properties View of Argument Modules and in the
metamodel
Signed-off-by: Liana Soima's avatarLiana Soima <soima@fortiss.org>
Issue-Ref: 4054
parent 96df8968
......@@ -236,9 +236,6 @@
<contextMenuContribution
contributor="org.fortiss.af3.safetycases.ui.library.ConvertReferenceToArgumentModule">
</contextMenuContribution>
<contextMenuContribution
contributor="org.fortiss.af3.safetycases.ui.action.DownloadSafetyClaimPatternsDatabaseFromLibrary">
</contextMenuContribution>
<contextMenuContribution
contributor="org.fortiss.af3.safetycases.ui.commands.GoalUndevelopedEntity">
</contextMenuContribution>
......@@ -349,15 +346,6 @@
type="org.fortiss.af3.safetycases.model.AwayArgumentElement">
</input>
</propertySection>
<propertySection
afterSection="org.fortiss.af3.safetycases.ui.properties.ArgumentElementPropertySection"
class="org.fortiss.af3.safetycases.ui.properties.ArgumentModulePropertySection"
id="org.fortiss.af3.safetycases.ui.properties.ArgumentModulePropertySection"
tab="org.fortiss.tooling.kernel.ui.property.tab.general">
<input
type="org.fortiss.af3.safetycases.model.ArgumentModule">
</input>
</propertySection>
<propertySection
afterSection="org.fortiss.af3.safetycases.ui.properties.ArgumentElementPropertySection"
class="org.fortiss.af3.safetycases.ui.properties.OptionEntityPropertySection"
......
/*-------------------------------------------------------------------------+
| Copyright 2013 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.action;
import static java.util.Collections.emptyList;
import static org.eclipse.emf.ecore.util.EcoreUtil.copy;
import static org.eclipse.jface.dialogs.MessageDialog.openError;
import static org.eclipse.ui.PlatformUI.getWorkbench;
import static org.fortiss.af3.safetycases.ui.utils.GSNSelectionDialogUtils.openClaimPatternsDatabaseFromLibrary;
import static org.fortiss.tooling.kernel.service.IPersistencyService.getInstance;
import static org.fortiss.tooling.kernel.ui.service.IContextMenuService.TOP_MOST_MENU_SECTION_ID;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.emf.common.util.EList;
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.Shell;
import org.fortiss.af3.project.model.FileProject;
import org.fortiss.af3.requirementspatterns.model.LibraryPatternsDatabase;
import org.fortiss.af3.requirementspatterns.model.PatternsDatabase;
import org.fortiss.af3.requirementspatterns.model.PatternsDatabaseRef;
import org.fortiss.af3.requirementspatterns.model.RequirementsPatternsFactory;
import org.fortiss.af3.requirementspatterns.model.SafetyClaimPatternsCollection;
import org.fortiss.af3.safetyargumentationpackage.model.SafetyArgumentationPackage;
import org.fortiss.af3.safetycases.ui.AF3SafetyCasesUIActivator;
import org.fortiss.tooling.base.model.element.IHierarchicElement;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.model.ILibraryElement;
import org.fortiss.tooling.kernel.service.ILibraryService;
import org.fortiss.tooling.kernel.ui.extension.IContextMenuContributor;
import org.fortiss.tooling.kernel.ui.extension.data.ContextMenuContextProvider;
/**
* This class implements the action of adding a {@link PatternsDatabase} from
* {@link LibraryPatternsDatabase} to a {@link FileProject}.
*
* @author carlan
*/
public class DownloadSafetyClaimPatternsDatabaseFromLibrary implements IContextMenuContributor {
/** {@inheritDoc} */
@Override
public List<IContributionItem> getContributedItems(EObject selection,
ContextMenuContextProvider contextProvider) {
if(selection instanceof SafetyArgumentationPackage) {
List<IContributionItem> contributionItems = new ArrayList<IContributionItem>();
DownloadSafetyClaimPatternsDatabaseFromLibraryAction action =
new DownloadSafetyClaimPatternsDatabaseFromLibraryAction(
(SafetyArgumentationPackage)selection);
contributionItems.add(new ActionContributionItem(action));
return contributionItems;
}
return emptyList();
}
/** {@inheritDoc} */
@Override
public String getMenuSectionID() {
return TOP_MOST_MENU_SECTION_ID;
}
/** The action. */
private class DownloadSafetyClaimPatternsDatabaseFromLibraryAction extends Action {
/** The selected {@link SafetyArgumentationPackage}. */
private SafetyArgumentationPackage selectedSafetyArgumentationPackage;
/** Constructor. */
DownloadSafetyClaimPatternsDatabaseFromLibraryAction(
SafetyArgumentationPackage selectedSafetyArgumentationPackage) {
super("Download a database containing claim patterns from the library",
AF3SafetyCasesUIActivator.getImageDescriptor("icons/download.png"));
this.selectedSafetyArgumentationPackage = selectedSafetyArgumentationPackage;
}
/** {@inheritDoc} */
@Override
public void run() {
ArrayList<LibraryPatternsDatabase> cpdl = new ArrayList<LibraryPatternsDatabase>();
List<ILibraryElement> libElems =
ILibraryService.getInstance().getLibraryElementsFromAllWorkspaceLibraries();
for(ILibraryElement libElem : libElems) {
if(libElem instanceof LibraryPatternsDatabase) {
cpdl.add((LibraryPatternsDatabase)libElem);
}
}
Shell shell = getWorkbench().getModalDialogShellProvider().getShell();
if(cpdl.size() == 0) {
openError(shell, "Information", "Cannot find Library Claims Database!");
return;
}
final LibraryPatternsDatabase claimsDatabaseLib =
openClaimPatternsDatabaseFromLibrary(shell, cpdl, null);
if(claimsDatabaseLib == null) {
return;
}
PatternsDatabase cpd = claimsDatabaseLib.getPatternsDatabase();
final PatternsDatabaseRef ref =
RequirementsPatternsFactory.eINSTANCE.createPatternsDatabaseRef();
ref.setLibraryElementShadow(copy(cpd));
EList<SafetyClaimPatternsCollection> scpc = cpd.getSafetyClaimPatternsCollections();
for(IHierarchicElement claimPattern : scpc) {
ref.getContainedElements().add(copy(claimPattern));
}
ref.setURI(claimsDatabaseLib.getURI());
ref.setName(claimsDatabaseLib.getPatternsDatabase().getName());
ref.setComment(claimsDatabaseLib.getPatternsDatabase().getComment());
final ITopLevelElement topLevel =
getInstance().getTopLevelElementFor(selectedSafetyArgumentationPackage);
topLevel.runAsCommand(new Runnable() {
@Override
public void run() {
selectedSafetyArgumentationPackage.getContainedElements().add(ref);
}
});
}
}
}
/*-------------------------------------------------------------------------+
| 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.properties;
import static org.eclipse.jface.databinding.viewers.ViewersObservables.observeSinglePostSelection;
import static org.fortiss.af3.safetycases.model.SafetyCasesPackage.Literals.ARGUMENT_MODULE__SAFETY_ARGUMENT_TYPE;
import static org.fortiss.tooling.kernel.ui.util.ObservableUtils.observeValue;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
import org.fortiss.af3.safetycases.model.ArgumentModule;
import org.fortiss.tooling.kernel.ui.extension.base.PropertySectionBase;
/**
* Property section of {@link ArgumentModule}.
*
* @author carlan
*/
public class ArgumentModulePropertySection extends PropertySectionBase {
/** Currently selected {@link ArgumentModule}. */
private ArgumentModule currentlySelectedModule;
/** {@link ComboViewer} to display the type of the selected {@link ArgumentModule}. */
private ComboViewer safetyArgTypeCombo;
/** {@inheritDoc} */
@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
super.createControls(parent, aTabbedPropertySheetPage);
safetyArgTypeCombo = createFormComboViewer("Type");
safetyArgTypeCombo.getControl().setBounds(130, 22, 400, 21);
safetyArgTypeCombo.add("N/A");
safetyArgTypeCombo.add("High-level");
safetyArgTypeCombo.add("Functional");
safetyArgTypeCombo.add("Software");
safetyArgTypeCombo.add("Hardware");
safetyArgTypeCombo.add("Procedural");
}
/** {@inheritDoc} */
@Override
protected void setSectionInput(Object input) {
currentlySelectedModule = (ArgumentModule)input;
}
/** {@inheritDoc} */
@Override
public void refresh() {
super.refresh();
dbc.bindValue(observeSinglePostSelection(safetyArgTypeCombo),
observeValue(currentlySelectedModule, ARGUMENT_MODULE__SAFETY_ARGUMENT_TYPE));
}
}
......@@ -15,7 +15,6 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.safetycases.ui.prototypes;
import static org.fortiss.af3.safetyargumentationpackage.utils.SafetyArgumentationPackageModelElementFactory.createSafetyArgumentationPackage;
import static org.fortiss.af3.safetycases.utils.SafetyCasesModelElementFactory.createArgumentModule;
import static org.fortiss.af3.safetycases.utils.SafetyCasesModelElementFactory.createAssumption;
......@@ -23,6 +22,7 @@ import static org.fortiss.af3.safetycases.utils.SafetyCasesModelElementFactory.c
import static org.fortiss.af3.safetycases.utils.SafetyCasesModelElementFactory.createAwayContractModule;
import static org.fortiss.af3.safetycases.utils.SafetyCasesModelElementFactory.createAwayGoal;
import static org.fortiss.af3.safetycases.utils.SafetyCasesModelElementFactory.createAwaySolution;
import static org.fortiss.af3.safetycases.utils.SafetyCasesModelElementFactory.createChange;
import static org.fortiss.af3.safetycases.utils.SafetyCasesModelElementFactory.createContext;
import static org.fortiss.af3.safetycases.utils.SafetyCasesModelElementFactory.createContractModule;
import static org.fortiss.af3.safetycases.utils.SafetyCasesModelElementFactory.createGoal;
......@@ -33,8 +33,6 @@ import static org.fortiss.af3.safetycases.utils.SafetyCasesModelElementFactory.c
import static org.fortiss.af3.safetycases.utils.SafetyCasesModelElementFactory.createSafetyExitConnector;
import static org.fortiss.af3.safetycases.utils.SafetyCasesModelElementFactory.createSolution;
import static org.fortiss.af3.safetycases.utils.SafetyCasesModelElementFactory.createStrategy;
import static org.fortiss.af3.safetycases.utils.SafetyCasesModelElementFactory.createChange;
import org.fortiss.af3.safetyargumentationpackage.model.SafetyArgumentationPackage;
import org.fortiss.af3.safetycases.model.Assumption;
......@@ -133,5 +131,4 @@ public class PrototypeProvider extends PrototypeProviderBase {
Change change = createChange();
registerPrimaryPrototype("Change", change, CATEGORY_NAME_SAFETY_CASES);
}
}
......@@ -32,7 +32,6 @@ 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.LibraryPatternsDatabase;
import org.fortiss.af3.requirementspatterns.model.PatternsDatabase;
import org.fortiss.af3.requirementspatterns.model.SafetyClaimPattern;
import org.fortiss.af3.requirementspatterns.model.SafetyClaimPatternsCollection;
......@@ -47,8 +46,8 @@ import org.fortiss.af3.safetycases.model.AwaySolution;
import org.fortiss.af3.safetycases.model.Context;
import org.fortiss.af3.safetycases.model.ContractModule;
import org.fortiss.af3.safetycases.model.Goal;
import org.fortiss.af3.safetycases.model.SafetyModule;
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;
......@@ -524,45 +523,6 @@ public class GSNSelectionDialogUtils {
return selected;
}
/**
* This method creates a tree dialog which displays all the existing
* {@link LibraryPatternsDatabase}s within the workspace. The user can choose only one
* {@link LibraryPatternsDatabase}.
*
* @param shell
* The parent shell.
* @param patternDatabasesLibraries
* The existing pattern databases libraries.
* @param selected
* The currently selected {@link LibraryPatternsDatabase} item.
* @return The selected {@link LibraryPatternsDatabase} item from the tree dialog.
*/
public static LibraryPatternsDatabase openClaimPatternsDatabaseFromLibrary(final Shell shell,
ArrayList<LibraryPatternsDatabase> patternDatabasesLibraries,
LibraryPatternsDatabase selected) {
ElementTreeSingleSelectDialog dialog =
new ElementTreeSingleSelectDialog(shell, patternDatabasesLibraries, selected,
new ModelElementTreeContentProvider(patternDatabasesLibraries) {
/** {@inheritDoc} */
@Override
public List<? extends EObject> getChildren(EObject parent) {
return pickInstanceOf(
asList(new Class<?>[] {PatternsDatabase.class}),
super.getChildren(parent));
}
}, new ModelElementLabelProvider(), null) {
/** {@inheritDoc} */
@Override
public boolean acceptElement(Object element) {
return element instanceof LibraryPatternsDatabase;
}
};
if(Window.OK == dialog.open()) {
return (LibraryPatternsDatabase)dialog.getSelectedElement();
}
return selected;
}
/**
* This method creates a tree dialog which displays all the existing {@link ArgumentElement}s.
* The user has to choose exactly the required number of {@link ArgumentElement}s.
......
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