Commit 8241650a authored by Johannes Eder's avatar Johannes Eder
Browse files

Merge branch '4054' into 'master'

4054

See merge request af3/af3!368
parents 15c17c27 167db2d7
......@@ -236,12 +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.library.ConvertReferenceToArgumentModule">
</contextMenuContribution>
<contextMenuContribution
contributor="org.fortiss.af3.safetycases.ui.commands.GoalUndevelopedEntity">
</contextMenuContribution>
......@@ -352,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 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.handler;
import static org.conqat.lib.commons.collections.CollectionUtils.emptyList;
import static org.fortiss.af3.safetycases.ui.AF3SafetyCasesUIActivator.PLUGIN_ID;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.requirementspatterns.model.LibraryPatternsDatabase;
import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
import org.fortiss.tooling.kernel.ui.extension.base.NamedCommentedModelElementHandlerBase;
/**
* {@link IModelElementHandler} for {@link LibraryPatternsDatabase}.
*
* @author carlan
*/
public class LibraryPatternsDatabaseHandler
extends NamedCommentedModelElementHandlerBase<LibraryPatternsDatabase> {
/** {@inheritDoc} */
@Override
public String getName(LibraryPatternsDatabase element) {
return element.getPatternsDatabase().getName();
}
/** {@inheritDoc} */
@Override
protected String getPluginId() {
return PLUGIN_ID;
}
/** {@inheritDoc} */
@Override
protected String getIconPath(LibraryPatternsDatabase element) {
return "icons/patterns.png";
}
/** {@inheritDoc} */
@Override
public List<EObject> getSubnodes(LibraryPatternsDatabase element) {
return emptyList();
}
}
/*-------------------------------------------------------------------------+
| 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.handler;
import static org.fortiss.af3.safetycases.ui.AF3SafetyCasesUIActivator.PLUGIN_ID;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.requirementspatterns.model.LibraryPatternsDatabase;
import org.fortiss.af3.requirementspatterns.model.LibraryPatternsDatabasePackage;
import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
import org.fortiss.tooling.kernel.ui.extension.base.NamedCommentedModelElementHandlerBase;
/**
* {@link IModelElementHandler} for {@link LibraryPatternsDatabasePackage}.
*
* @author carlan
*/
public class LibraryPatternsDatabasePackageHandler
extends NamedCommentedModelElementHandlerBase<LibraryPatternsDatabasePackage> {
/** {@inheritDoc} */
@Override
protected String getPluginId() {
return PLUGIN_ID;
}
/** {@inheritDoc} */
@Override
protected String getIconPath(LibraryPatternsDatabasePackage element) {
return "icons/package.gif";
}
/** {@inheritDoc} */
@Override
public List<EObject> getSubnodes(LibraryPatternsDatabasePackage element) {
List<EObject> subNodes = new ArrayList<EObject>();
for(LibraryPatternsDatabase lpd : element.getLibraryPatternsDatabases()) {
subNodes.add(lpd);
}
subNodes.addAll(element.getSubPackages());
return subNodes;
}
}
/*-------------------------------------------------------------------------+
| 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.handler;
import static org.fortiss.af3.safetycases.ui.AF3SafetyCasesUIActivator.PLUGIN_ID;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.requirementspatterns.model.SafetyClaimPattern;
import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
import org.fortiss.tooling.kernel.ui.extension.base.NamedCommentedModelElementHandlerBase;
/**
* {@link IModelElementHandler} for {@link SafetyClaimPattern}.
*
* @author carlan
*/
@SuppressWarnings({"rawtypes", "unchecked"})
public class SafetyClaimPatternHandler
extends NamedCommentedModelElementHandlerBase<SafetyClaimPattern> {
/** {@inheritDoc} */
@Override
protected String getPluginId() {
return PLUGIN_ID;
}
/** {@inheritDoc} */
@Override
protected String getIconPath(SafetyClaimPattern element) {
return "icons/claim.png";
}
/** {@inheritDoc} */
@Override
public List<EObject> getSubnodes(SafetyClaimPattern element) {
return (List)element.getContainedElements();
}
}
/*-------------------------------------------------------------------------+
| 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.handler;
import static org.fortiss.af3.safetycases.ui.AF3SafetyCasesUIActivator.PLUGIN_ID;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.requirementspatterns.model.SafetyClaimPatternsCollection;
import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
import org.fortiss.tooling.kernel.ui.extension.base.NamedCommentedModelElementHandlerBase;
/**
* {@link IModelElementHandler} for {@link SafetyClaimPatternsCollection}.
*
* @author carlan
*/
@SuppressWarnings({"rawtypes", "unchecked"})
public class SafetyClaimPatternsCollectionHandler
extends NamedCommentedModelElementHandlerBase<SafetyClaimPatternsCollection> {
/** {@inheritDoc} */
@Override
protected String getPluginId() {
return PLUGIN_ID;
}
/** {@inheritDoc} */
@Override
protected String getIconPath(SafetyClaimPatternsCollection element) {
return "icons/patterns.png";
}
/** {@inheritDoc} */
@Override
public List<EObject> getSubnodes(SafetyClaimPatternsCollection element) {
return (List)element.getContainedElements();
}
}
/*-------------------------------------------------------------------------+
| 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.handler;
import static org.fortiss.af3.safetycases.ui.AF3SafetyCasesUIActivator.PLUGIN_ID;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.requirementspatterns.model.PatternsDatabase;
import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
import org.fortiss.tooling.kernel.ui.extension.base.NamedCommentedModelElementHandlerBase;
/**
* {@link IModelElementHandler} for {@link PatternsDatabase}.
*
* @author carlan
*/
public class SafetyClaimPatternsDatabaseHandler
extends NamedCommentedModelElementHandlerBase<PatternsDatabase> {
/** {@inheritDoc} */
@Override
protected String getPluginId() {
return PLUGIN_ID;
}
/** {@inheritDoc} */
@Override
protected String getIconPath(PatternsDatabase element) {
return "icons/patterns.png";
}
/** {@inheritDoc} */
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
public List<EObject> getSubnodes(PatternsDatabase element) {
return (List)element.getContainedElements();
}
}
/*-------------------------------------------------------------------------+
| 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.handler;
import static org.fortiss.af3.safetycases.ui.AF3SafetyCasesUIActivator.PLUGIN_ID;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.requirementspatterns.model.WordAndObjectType;
import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
import org.fortiss.tooling.kernel.ui.extension.base.NamedCommentedModelElementHandlerBase;
/**
* {@link IModelElementHandler} for {@link WordAndObjectType}.
*
* @author carlan
*/
@SuppressWarnings({"rawtypes", "unchecked"})
public class WordAndObjectTypeHandler
extends NamedCommentedModelElementHandlerBase<WordAndObjectType> {
/** {@inheritDoc} */
@Override
protected String getPluginId() {
return PLUGIN_ID;
}
/** {@inheritDoc} */
@Override
protected String getIconPath(WordAndObjectType element) {
return "icons/word.png";
}
/** {@inheritDoc} */
@Override
public List<EObject> getSubnodes(WordAndObjectType element) {
return (List)element.getContainedElements();
}
}
/*-------------------------------------------------------------------------+
| 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");