Commit 0997adf1 authored by Liana Soima's avatar Liana Soima
Browse files

Delete unnecessary classes



Unnecessary classes were deleted + changed name (Safety Case ->
Assurance Case)
Signed-off-by: Liana Soima's avatarLiana Soima <soima@fortiss.org>
Issue-Ref: 3976
parent 9ebbe2e6
......@@ -332,9 +332,6 @@
<contextMenuContribution
contributor="org.fortiss.af3.safetycases.ui.commands.GenerateModuleConnections">
</contextMenuContribution>
<contextMenuContribution
contributor="org.fortiss.af3.safetycases.ui.exporter.commands.ExportAssuranceArgumentsToImage">
</contextMenuContribution>
<contextMenuContribution
contributor="org.fortiss.af3.safetycases.ui.commands.ShowPotentialChangeImpact">
</contextMenuContribution>
......@@ -410,15 +407,6 @@
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.RequirementLinkPropertySection"
id="org.fortiss.af3.safetycases.ui.properties.RequirementLinkPropertySection"
tab="org.fortiss.tooling.kernel.ui.property.tab.general">
<input
type="org.fortiss.af3.safetycases.model.Solution">
</input>
</propertySection>
<propertySection
afterSection="org.fortiss.af3.safetycases.ui.properties.ArgumentElementPropertySection"
class="org.fortiss.af3.safetycases.ui.properties.GoalPropertySection"
......@@ -428,15 +416,6 @@
type="org.fortiss.af3.safetycases.model.Goal">
</input>
</propertySection>
<propertySection
afterSection="org.fortiss.af3.safetycases.ui.properties.GoalPropertySection"
class="org.fortiss.af3.safetycases.ui.properties.RequirementLinkPropertySection"
id="org.fortiss.af3.safetycases.ui.properties.RequirementLinkPropertySection"
tab="org.fortiss.tooling.kernel.ui.property.tab.general">
<input
type="org.fortiss.af3.safetycases.model.Goal">
</input>
</propertySection>
<propertySection
afterSection="org.fortiss.af3.safetycases.ui.properties.RequirementLinkPropertySection"
class="org.fortiss.af3.safetycases.ui.properties.QuantitativeEvaluationPropertySection"
......
......@@ -54,13 +54,13 @@ public class ConnectTheAwayEntity implements IContextMenuContributor {
String commandName = "";
String iconPath = "";
if(selection instanceof AwayGoal) {
commandName = "Connect 2 Goal";
commandName = "Connect to Goal";
iconPath = "icons/goal.png";
} else if(selection instanceof AwayContext) {
commandName = "Connect 2 Context";
commandName = "Connect to Context";
iconPath = "icons/context.png";
} else if(selection instanceof AwaySolution) {
commandName = "Connect 2 Solution";
commandName = "Connect to Solution";
iconPath = "icons/solution.png";
}
contributionItems.add(new ActionContributionItem(new ConnectTheAwayEntityAction(
......
AbstractAssuranceArgumentsToImage.java 36c4d94fef1660d9ce57071ce08231874a9edc5b GREEN
ExportAssuranceArgumentsToImage.java 8ec4299a942ab1a29a5f2b0c6bfe34938772757c GREEN
/*-------------------------------------------------------------------------+
| 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.exporter.commands;
import static java.awt.Desktop.getDesktop;
import static java.util.Collections.emptyList;
import static org.eclipse.core.resources.ResourcesPlugin.getWorkspace;
import static org.eclipse.swt.custom.BusyIndicator.showWhile;
import static org.eclipse.ui.PlatformUI.getWorkbench;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
import java.io.File;
import java.io.IOException;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
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.SWT;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.fortiss.af3.safetycases.model.ArgumentModule;
import org.fortiss.af3.safetycases.model.SafetyCase;
import org.fortiss.af3.safetycases.model.SafetyModuleRef;
import org.fortiss.af3.safetycases.ui.AF3SafetyCasesUIActivator;
import org.fortiss.af3.safetycases.ui.editor.ArgumentModuleEditor;
import org.fortiss.af3.safetycases.ui.editor.SafetyCasesEditor;
import org.fortiss.af3.safetycases.ui.exporter.dialog.AssuranceArgumentationToImageDialog;
import org.fortiss.tooling.base.model.base.HierarchicElementBase;
import org.fortiss.tooling.kernel.ui.extension.data.ContextMenuContextProvider;
import org.fortiss.tooling.kernel.ui.internal.views.NavigatorViewPart;
/**
* This class exports an {@link ArgumentModule} or a {@link SafetyCase} as a document.
*
* @author tsalidis
*/
public class ExportAssuranceArgumentsToImage extends AbstractAssuranceArgumentsToImage {
/** The selected GSN-based argumentation to be exported */
private HierarchicElementBase selectedArgumentation;
/** {@inheritDoc} */
@Override
public List<IContributionItem> getContributedItems(EObject selection,
ContextMenuContextProvider contextProvider) {
if(contextProvider instanceof ArgumentModuleEditor ||
contextProvider instanceof NavigatorViewPart) {
if(selection instanceof ArgumentModule && !(selection instanceof SafetyModuleRef)) {
selectedArgumentation = (ArgumentModule)selection;
final List<IContributionItem> contributionItems =
new ArrayList<IContributionItem>();
contributionItems.add(new ActionContributionItem(
new ExportDiagramToImageAction("Export Argument Module Diagram ...")));
return contributionItems;
}
}
if(contextProvider instanceof SafetyCasesEditor ||
contextProvider instanceof NavigatorViewPart) {
if(selection instanceof SafetyCase) {
selectedArgumentation = (SafetyCase)selection;
final List<IContributionItem> contributionItems =
new ArrayList<IContributionItem>();
contributionItems.add(new ActionContributionItem(
new ExportDiagramToImageAction("Export Assurance Case ...")));
return contributionItems;
}
}
return emptyList();
}
/** Setting the possible extensions to export the file in the right order. */
public String setFileOptionsForExporting(AssuranceArgumentationToImageDialog parameterDialog,
Shell shell, HierarchicElementBase argumentation) {
final FileDialog fd = new FileDialog(shell, SWT.SAVE);
fd.setText("Set file ...");
fd.setFilterPath(getWorkspace().getRoot().getLocation().toString());
final String[] filterExt = {"*.svg", "*.png", "*.pdf"};
fd.setFilterExtensions(filterExt);
if(parameterDialog.getImageFormat().equals("svg")) {
filterExt[0] = "*.svg";
fd.setFilterExtensions(filterExt);
} else if(parameterDialog.getImageFormat().equals("png")) {
filterExt[0] = "*.png";
filterExt[1] = "*.svg";
filterExt[2] = "*.pdf";
fd.setFilterExtensions(filterExt);
} else if(parameterDialog.getImageFormat().equals("pdf")) {
filterExt[0] = "*.pdf";
filterExt[1] = "*.svg";
filterExt[2] = "*.png";
fd.setFilterExtensions(filterExt);
}
LocalDate date = LocalDate.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
fd.setFileName(date.format(formatter) + "_" + argumentation.getName() + "." +
parameterDialog.getImageFormat());
return fd.open();
}
/** The action to export the argument module. */
private class ExportDiagramToImageAction extends Action {
/** Constructor. */
ExportDiagramToImageAction(String name) {
super(name, AF3SafetyCasesUIActivator.getImageDescriptor("icons/export.png"));
}
/** {@inheritDoc} */
@Override
public void run() {
if(selectedArgumentation != null) {
final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
final AssuranceArgumentationToImageDialog parameterDialog =
new AssuranceArgumentationToImageDialog(shell);
parameterDialog.open();
if(!parameterDialog.goAhead()) {
return;
}
String fileName =
setFileOptionsForExporting(parameterDialog, shell, selectedArgumentation);
if(fileName != null) {
setShowPortLabels(parameterDialog.getShowPortLabels());
setAutomaticLabelLayout(parameterDialog.getAutomaticPortLabelLayout());
// coordinates for positioning the dialog
setXTranslation(200);
setYTranslation(100);
final Runnable exporterJob = new Runnable() {
@Override
public void run() {
colored = parameterDialog.isColored();
export(fileName, selectedArgumentation);
try {
getDesktop().open(new File(fileName));
} catch(IOException e) {
error(AF3SafetyCasesUIActivator.getDefault(),
"Could not open the created file!", e);
}
}
};
showWhile(getWorkbench().getDisplay(), exporterJob);
}
}
}
}
}
ArgumentModuleToImageDialog.java 0aedb567e68c8f8ae85e4189812c2d59d853dd3c GREEN
AssuranceArgumentationToImageDialog.java 96a287e5d8c5b455971c9972f7c7f7b32f815d99 GREEN
/*-------------------------------------------------------------------------+
| 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.exporter.dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
/**
* Exporter dialog.
*
* @author tsalidis
*/
public class AssuranceArgumentationToImageDialog extends TitleAreaDialog {
/** The combo format. */
private Combo comboFormat;
/** The checkbox. */
private Button colorsCheckBox;
/** The image format. */
private String imageFormat;
/** The show port labels. */
private boolean showPortLabels;
/** The automatic port label layout. */
private boolean automaticPortLabelLayout;
/** The go ahead. */
private boolean goAhead = false;
/** The flag for colors. */
private boolean colored = true;
/** Constructor. */
public AssuranceArgumentationToImageDialog(Shell parentShell) {
super(parentShell);
}
/** {@inheritDoc} */
@Override
protected void okPressed() {
imageFormat = comboFormat.getItems()[comboFormat.getSelectionIndex()];
if(colorsCheckBox.getSelection())
colored = false;
else
colored = true;
goAhead = true;
super.okPressed();
}
/** {@inheritDoc} */
@Override
protected Control createDialogArea(Composite parent) {
setTitle("Module Diagram Exporter");
parent.setToolTipText("");
final Composite container = (Composite)super.createDialogArea(parent);
final Composite container2 = new Composite(container, SWT.NONE);
// 2 columns for the grid
container2.setLayout(new GridLayout(2, false));
final Label lblOutputFormat = new Label(container2, SWT.NONE);
// 1 column cell and 1 row cell for the griddata
lblOutputFormat.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblOutputFormat.setText("Output format");
comboFormat = new Combo(container2, SWT.NONE | SWT.READ_ONLY);
comboFormat.setItems(new String[] {"svg", "png", "pdf"});
// 1 column cell and 1 row cell for the griddata
final GridData gd_combo = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1);
// 195 is the preferred size
gd_combo.widthHint = 195;
comboFormat.setLayoutData(gd_combo);
comboFormat.select(0);
colorsCheckBox = new Button(container2, SWT.CHECK);
colorsCheckBox.setText("Export without colors");
return container;
}
/** {@inheritDoc} */
@Override
protected void createButtonsForButtonBar(Composite parent) {
createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}
/** {@inheritDoc} */
@Override
protected Point getInitialSize() {
// 500, 300 the size of the dialog
return new Point(500, 300);
}
/** Getter for {@link #goAhead}. */
public boolean goAhead() {
return goAhead;
}
/** Getter for {@link #imageFormat}. */
public String getImageFormat() {
return imageFormat;
}
/** Getter for {@link #showPortLabels}. */
public boolean getShowPortLabels() {
return showPortLabels;
}
/** Getter for {@link #automaticPortLabelLayout}. */
public boolean getAutomaticPortLabelLayout() {
return automaticPortLabelLayout;
}
/** Getter for {@link #colored}. */
public boolean isColored() {
return colored;
}
}
......@@ -15,27 +15,9 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.safetycases.ui.properties;
import static org.eclipse.jface.dialogs.MessageDialog.openConfirm;
import static org.eclipse.swt.widgets.Display.getCurrent;
import static org.fortiss.af3.safetycases.utils.SafetyCasesUtils.getAllLogicalComponents;
import static org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService.getInstance;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
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.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.safetycases.model.Goal;
import org.fortiss.af3.safetycases.ui.action.ConnectGoalToAF3LogicalComponentAction;
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;
/**
......@@ -44,102 +26,14 @@ import org.fortiss.tooling.kernel.ui.extension.base.PropertySectionBase;
* @author tsalidis
*/
public class GoalPropertySection extends PropertySectionBase {
/** Label for referenced button section. */
private Label scopedAF3LogicalComponentLabel;
/** Link for referenced button section. */
private Link scopedAF3LogicalComponentLink;
/** Currently selected {@link Goal}. */
private Goal currentlySelectedGoal;
/** Button for eliminating reference. */
private Button eliminateScopeButton;
/** Button for creating reference. */
private Button scopeButton;
/** {@inheritDoc} */
@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
super.createControls(parent, aTabbedPropertySheetPage);
scopedAF3LogicalComponentLabel = getWidgetFactory().createLabel(composite,
"Scope ");
scopedAF3LogicalComponentLabel.setToolTipText(
"The claim made by this goal reffers to a certain logical component");
scopedAF3LogicalComponentLink = new Link(composite, SWT.MULTI);
scopedAF3LogicalComponentLink.setText("<a>No referenced AF3 element</a>");
scopedAF3LogicalComponentLink.setToolTipText("The referenced AF3 logical component");
scopedAF3LogicalComponentLink.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
for(Component comp : getAllLogicalComponents(currentlySelectedGoal)) {
if(e.text.contains(comp.getName())) {
getInstance().openInEditor(comp);
return;
}
}
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// Do nothing.
}
});
scopeButton = getWidgetFactory().createButton(composite,
" Add scope ", SWT.PUSH);
scopeButton.setToolTipText("Select referenced AF3 logical component");
scopeButton.setVisible(true);
scopeButton.addSelectionListener(new SelectionAdapter() {
/** {@inheritDoc} */
@Override
public void widgetSelected(SelectionEvent e) {
if(currentlySelectedGoal != null) {
if(currentlySelectedGoal.getAf3Element() != null) {
boolean go = openConfirm(getCurrent().getActiveShell(), "",
"This goal has already a scope. Are you sure you want to replace it?");
if(!go) {
return;
}
}
new ConnectGoalToAF3LogicalComponentAction(currentlySelectedGoal,
Display.getCurrent().getActiveShell()).run();
}
}
});
eliminateScopeButton = getWidgetFactory().createButton(composite,
" Delete scope ", SWT.NONE);
eliminateScopeButton.setToolTipText("Eliminate referenced AF3 logical component");
eliminateScopeButton.setVisible(true);
eliminateScopeButton.setEnabled(false);
eliminateScopeButton.addSelectionListener(new SelectionAdapter() {
/** {@inheritDoc} */
@Override
public void widgetSelected(SelectionEvent e) {
if(currentlySelectedGoal != null) {
boolean go = openConfirm(getCurrent().getActiveShell(), "",
"Are you sure you want to delete the reference to the " +
((INamedCommentedElement)currentlySelectedGoal.getAf3Element())
.getName() +
" element?");
if(!go) {
return;
}
final ITopLevelElement topLevel = IPersistencyService.getInstance()
.getTopLevelElementFor(currentlySelectedGoal);
topLevel.runAsCommand(new Runnable() {
@Override
public void run() {
currentlySelectedGoal.setAf3Element(null);
}
});
}
}
});
}
/** {@inheritDoc} */
......@@ -147,23 +41,4 @@ public class GoalPropertySection extends PropertySectionBase {
protected void setSectionInput(Object input) {
currentlySelectedGoal = (Goal)input;
}
/**
* {@inheritDoc}
*
* <p>
* Sub-classes may override, but must call super.refresh() first.
*/
@Override
public void refresh() {
if(currentlySelectedGoal.getAf3Element() != null) {
String name = ((INamedCommentedElement)currentlySelectedGoal.getAf3Element()).getName();
scopedAF3LogicalComponentLink.setText("<a>" + name + "</a>");
scopedAF3LogicalComponentLink.setEnabled(true);
eliminateScopeButton.setEnabled(true);
} else {
scopedAF3LogicalComponentLink.setText("<a>No referenced AF3 element</a>");
eliminateScopeButton.setEnabled(false);
}
}
}
/*-------------------------------------------------------------------------+
| Copyright 2018 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 |
| |