Commit 5b91f39e authored by Liana Soima's avatar Liana Soima

Delete classes

Signed-off-by: Liana Soima's avatarLiana Soima <soima@fortiss.org>
Issue-Ref: 3170
parent 9f545fd7
/*-------------------------------------------------------------------------+
| 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));
}
}
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