Commit afcb06a5 authored by Hernan Ponce de Leon's avatar Hernan Ponce de Leon
Browse files

Still some references in the code I needed to remove


Issue-Ref:3368
Signed-off-by: Hernan Ponce de Leon's avatarHernan Ponce de Leon <ponce@fortiss.org>
parent f4d04e25
/*-------------------------------------------------------------------------+
| Copyright 2015 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.mira.ui.action;
import static org.eclipse.jface.dialogs.MessageDialog.openError;
import static org.eclipse.ui.plugin.AbstractUIPlugin.imageDescriptorFromPlugin;
import static org.fortiss.af3.mira.ui.AF3MiraUIActivator.PLUGIN_ID;
import static org.fortiss.af3.mira.ui.utils.SelectionDialogUtils.openComponentSingleSelectDialog;
import static org.fortiss.af3.mira.utils.MiraModelElementFactory.createScopeSpecificationIB;
import org.eclipse.emf.common.util.EList;
import org.eclipse.swt.widgets.Shell;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.component.model.ComponentArchitecture;
import org.fortiss.af3.mira.command.CreateRequirementSpecificationCommand;
import org.fortiss.af3.mira.model.interfacebehaviour.InterfaceBehaviour;
import org.fortiss.af3.mira.model.interfacebehaviour.ScopeSpecification;
import org.fortiss.tooling.kernel.service.ICommandStackService;
import org.fortiss.tooling.kernel.ui.extension.base.EObjectActionBase;
/**
* Action to connect scope to a component by using {@link ScopeSpecification}.
*
* @author pham
*/
public final class ConnectIBScopeToComponentAction extends EObjectActionBase<InterfaceBehaviour> {
/** The default shell. */
private final Shell shell;
/** Constructor. */
public ConnectIBScopeToComponentAction(InterfaceBehaviour editedObject, Shell shell) {
super("ConnectScopeToComponent", imageDescriptorFromPlugin(PLUGIN_ID, "icons/sample.png"));
setTarget(editedObject);
this.shell = shell;
}
/** {@inheritDoc} */
@Override
public void run() {
EList<ComponentArchitecture> arch =
getTarget().getAnalysis().getAssociatedComponentArchitectures();
if(arch == null) {
openError(shell, "Component Architecture", "Cannot find Component Architecture!");
return;
}
Component selected = null;
ScopeSpecification spec = getTarget().getScopeSpecification();
if(spec != null && spec.getSpecificationOf() instanceof Component) {
selected = (Component)spec.getSpecificationOf();
}
final Component component =
(Component)openComponentSingleSelectDialog(shell.getShell(), arch, selected);
if(component == null || component == selected) {
return;
}
CreateRequirementSpecificationCommand cmd =
new CreateRequirementSpecificationCommand(getTarget(), component,
createScopeSpecificationIB("", ""), true);
ICommandStackService.getInstance().runAsCommand(component, cmd);
}
}
/*-------------------------------------------------------------------------+
| Copyright 2012 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.mira.ui.action;
import static org.eclipse.emf.ecore.util.EcoreUtil.delete;
import org.fortiss.af3.mira.model.ExternalRelation;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.mira.model.RequirementRelation;
import org.fortiss.af3.mira.model.interfacebehaviour.InterfaceBehaviour;
import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService;
/**
* Command to change a {@link Requirement} to {@link InterfaceBehaviour} and vice versa
*
* @author wenwenchen
*/
public class ConvertRequirementAction implements Runnable {
/** The old requirement. */
private Requirement oldReq;
/** The new empty requirement. */
private Requirement newReq;
/** Create the command with the selected requirement. */
public ConvertRequirementAction(Requirement oldReq, Requirement newReq) {
this.oldReq = oldReq;
this.newReq = newReq;
}
/** {@inheritDoc} */
@Override
public void run() {
IModelEditorBindingService.getInstance().closeEditors(oldReq);
newReq.setId(oldReq.getId());
newReq.setName(oldReq.getName());
newReq.setReqId(oldReq.getReqId());
newReq.setDescription(oldReq.getDescription());
newReq.setRationale(oldReq.getRationale());
newReq.setAuthor(oldReq.getAuthor());
newReq.setSources(oldReq.getSources());
newReq.setStatus(oldReq.getStatus());
newReq.setPriority(oldReq.getPriority());
newReq.setTodo(oldReq.getTodo());
newReq.setRationale(oldReq.getRationale());
newReq.setComment(oldReq.getComment());
newReq.getImages().addAll(oldReq.getImages());
newReq.getConnections().clear();
newReq.getConnections().addAll(oldReq.getConnections());
newReq.getConnectors().clear();
newReq.getConnectors().addAll(oldReq.getConnectors());
newReq.getContainedElements().addAll(oldReq.getFormalSpecifications());
oldReq.getContainer().getContainedElements().add(newReq);
// adjust requirement relations
for(RequirementRelation requirementRelation : oldReq.getAnalysis().getRequirementRelation()) {
if(requirementRelation.getTargetRequirement().contains(oldReq)) {
requirementRelation.getTargetRequirement().remove(oldReq);
requirementRelation.getTargetRequirement().add(newReq);
}
if(requirementRelation.getSourceRequirement().contains(oldReq)) {
requirementRelation.getSourceRequirement().remove(oldReq);
requirementRelation.getSourceRequirement().add(newReq);
}
}
// adjust external relations
for(ExternalRelation externalRelation : oldReq.getAnalysis().getExternalRelation()) {
if(externalRelation.getSourceRequirement().equals(oldReq)) {
externalRelation.setSourceRequirement(newReq);
}
}
newReq.setSafetyRequirementType(oldReq.getSafetyRequirementType());
delete(oldReq, true);
IModelEditorBindingService.getInstance().openInEditor(newReq);
}
}
......@@ -11,7 +11,7 @@ FunctionalAspectsHaveNonFunctionalAspectsConstraintsUI.java f2366397cf580145ed3b
GlossaryTermDefinitionConstraintUI.java 54b4ce377f86a40820592eed18622a10bacbdaf5 GREEN
IDConstraintUI.java 9554fb8c08df717cc0690eef869d3198c8b5634a GREEN
IdentifiedInputOutputDefinedConstraintUI.java fe3272581afcbc58969b458bcd363b857a6a99a4 GREEN
MultipleAspectsConstraintUI.java 8a57413a2a14d1208f8c36818d277b2d0a2447f4 GREEN
MultipleAspectsConstraintUI.java 19b7556303236825a381688024c027cb150216cc YELLOW
NameConstraintUI.java 675f9e5d578c275fdf660a9fd3cf178569d6feb4 GREEN
NonFunctionalAspectsHaveFunctionalAspectsConstraintUI.java f678e56fec1ed0e53453a09dff21ecf378bd68d5 GREEN
NonFunctionalReqsHaveExactlyOneFunctionalReqUI.java cf600a1f4498896a3536ff901e90794c5889b254 GREEN
......
......@@ -30,7 +30,6 @@ import org.fortiss.af3.mira.model.SafetyLevelRequirementSpecification;
import org.fortiss.af3.mira.model.functional.FormalSpecification;
import org.fortiss.af3.mira.model.functional.FunctionalFactory;
import org.fortiss.af3.mira.model.functional.SignalContainerSpecification;
import org.fortiss.af3.mira.model.interfacebehaviour.InterfaceBehaviourSpecification;
import org.fortiss.af3.mira.model.timing.TimingRequirement;
import org.fortiss.af3.mira.utils.MiraModelElementFactory;
import org.fortiss.af3.project.model.ParameterDefinition;
......@@ -139,9 +138,7 @@ public class MultipleAspectsConstraintUI extends ConstraintUIBases.ConstraintUIB
if(spec instanceof DerivedRequirementSpecification) {
aspectCounter++;
}
if(spec instanceof InterfaceBehaviourSpecification) {
aspectCounter++;
}
}
// send message to the user to have at least one aspect attached
if(aspectCounter == 0) {
......@@ -253,16 +250,6 @@ public class MultipleAspectsConstraintUI extends ConstraintUIBases.ConstraintUIB
modelContext.runAsCommand(() -> req.getContainer().getContainedElements()
.add(newDerivedReqSpec));
}
if(spec instanceof InterfaceBehaviourSpecification) {
Requirement newInterfaceBehaviourReqSpec =
MiraFactory.eINSTANCE.createRequirement();
InterfaceBehaviourSpecification interfaceReqSpec =
MiraModelElementFactory.createInterfaceBehaviourSpecification();
CopyRequirementProperties(newInterfaceBehaviourReqSpec, req, spec);
newInterfaceBehaviourReqSpec.addSpecification(interfaceReqSpec);
modelContext.runAsCommand(() -> req.getContainer().getContainedElements()
.add(newInterfaceBehaviourReqSpec));
}
}
/**
* Check if parametersDefs are there and at least one than create the parameters
......@@ -379,15 +366,6 @@ public class MultipleAspectsConstraintUI extends ConstraintUIBases.ConstraintUIB
newReq.setName(newReq.getRequirementName() + "-DesignChoiceAspect");
}
}
if(spec instanceof InterfaceBehaviourSpecification) {
if(oldReq.getReqId() != null) {
newReq.setReqId(oldReq.getReqId() + ".1" + "-InterfaceBehaviorSpecification");
}
if(oldReq.getRequirementName() != null) {
newReq.setName(newReq.getRequirementName() + "-InterfaceBehaviorAspect");
}
}
if(oldReq.getDescription() != null) {
newReq.setDescription("<This is Automated text Generated>" + "\n" +
oldReq.getDescription());
......
......@@ -11,7 +11,7 @@ InterfaceBehaviourEditor.java be0a51fa8116f1c47b5d706935dfb17a19c775e5 GREEN
InterfaceBehaviourSectionExtension.java ead6ef67dd9aeafb070db4bd1fc9a0e8829af418 GREEN
InterfaceEditor.java 0e9f292c180ee06f6972a484e050252653df6178 GREEN
ModeDefinitionEditor.java 2ea1404961c2f75156d1214339b0c9b53058d4bc GREEN
OtherEditor.java adb5f3b3523fb1e6d1e2510a4d457f7f6a547e05 GREEN
OtherEditor.java cb8c948d6dcc3fd0a620ead5ab2fc5b693d8bdeb YELLOW
ParameterDefinitionEditor.java 620497ad99059484a47d1e1f2c922215b46dfcdc GREEN
RequirementEditor.java c53c4be1eb900341fd4b74ff0e744908fb59d8ac GREEN
RequirementsContainerEditor.java 720bdefcc6ac66161673117f6082a6a71fd25c59 GREEN
......
/*-------------------------------------------------------------------------+
| Copyright 2011 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.mira.ui.editor;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickFirstInstanceOf;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickInstanceOf;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import org.conqat.ide.commons.ui.jface.TreeContentProviderBase;
import org.eclipse.emf.common.util.EList;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.EditingSupport;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.TreeViewerColumn;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
import org.fortiss.af3.mira.model.IFunctionalRequirement;
import org.fortiss.af3.mira.model.MiraFactory;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.mira.model.interfacebehaviour.InterfaceBehaviourSpecification;
import org.fortiss.tooling.base.model.element.IModelElementSpecification;
import org.fortiss.tooling.base.ui.editor.StyledTextCellEditor;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.service.IElementCompositorService;
import org.fortiss.tooling.kernel.service.IPersistencyService;
import org.fortiss.tooling.kernel.ui.presentation.ModelElementLabelProvider;
/**
* Editor for the "interface behaviour" aspect of a {@link Requirement}.
*
* @author mou
*/
public class InterfaceBehaviourAspectEditor<T extends Requirement> extends AspectEditorBase<T> {
/** The edited interface behavior specification. */
private InterfaceBehaviourSpecification ibsSpec;
/**
* The tree viewer for displaying the table that contains the relationships between the
* functional and the non-functional requirement
*/
private TreeViewer reqViewer;
/** Top level element for the edited object. */
private ITopLevelElement top;
/** The default shell - for functional requirement dialog. */
private Shell shell;
/** {@inheritDoc} */
@Override
protected void createAspectSection() {
EList<IModelElementSpecification> specs = editedObject.getSpecifications();
InterfaceBehaviourSpecification ibs =
pickFirstInstanceOf(InterfaceBehaviourSpecification.class, specs);
createBehaviourSpecificationSection(ibs);
createNonFunctionalRelationshipSection(ibs);
}
/** Section for behaviour specification. */
private Composite createBehaviourSpecificationSection(InterfaceBehaviourSpecification ibs) {
Composite behaviourSection =
createNewSection("Behaviour Specification",
"This requirement defines the following behaviour:");
new InterfaceBehaviourSectionExtension(behaviourSection, ibs, toolkit, form, dbc,
registeredSourceViewers).apply();
Button deleteButton = toolkit.createButton(behaviourSection, "Remove aspect", SWT.None);
deleteButton.addSelectionListener(new SelectionAdapter() {
/** {@inheritDoc} */
@Override
public void widgetSelected(SelectionEvent e) {
ITopLevelElement modelContext =
IPersistencyService.getInstance().getTopLevelElementFor(editedObject);
modelContext.runAsCommand(() -> {
IElementCompositorService.getInstance().decompose(ibs);
});
}
});
return behaviourSection;
}
/** {@inheritDoc} */
@Override
protected List<IModelElementSpecification> getElementsToDelete() {
ArrayList<IModelElementSpecification> res = new ArrayList<>();
res.addAll(pickInstanceOf(InterfaceBehaviourSpecification.class,
editedObject.getSpecifications()));
return res;
}
/**
* @return section for relationships between this non-functional requirement and functional
* requirement(s)
*/
private Composite createNonFunctionalRelationshipSection(
InterfaceBehaviourSpecification ibsRequirement) {
Composite relatedToSection =
createNewSection("Relationships Section",
"Related to the following functional requirement(s):");
relatedToSection.setLayout(new GridLayout(1, false));
createFunctionalRequirementTable(relatedToSection, ibsRequirement);
reqViewer.setContentProvider(new TreeContentProviderBase() {
@Override
public Object[] getChildren(Object parentElement) {
if(parentElement instanceof List<?>) {
List<Object> range = new ArrayList<Object>();
range.add(new FakeChild());
range.addAll(IntStream.rangeClosed(0, ibsRequirement.getRelatedTo().size() - 1)
.boxed().collect(Collectors.toList()));
return range.toArray();
}
return new Object[0];
}
});
reqViewer.setInput(ibsRequirement.getRelatedTo());
Button addButton = toolkit.createButton(relatedToSection, "Add", SWT.FLAT);
Button deleteButton = toolkit.createButton(relatedToSection, "Delete", SWT.FLAT);
addButton.addSelectionListener(new SelectionAdapter() {
/** {@inheritDoc} */
@Override
public void widgetSelected(SelectionEvent e) {
// Open dialog of components
ITreeContentProvider tcp = new FormalSpecificationTreeContentProvider();
ElementTreeSelectionDialog dlg =
new ElementTreeSelectionDialog(shell, new ModelElementLabelProvider(), tcp);
dlg.setAllowMultiple(false);
dlg.setTitle("Select the Functional Requirement(s)");
List<Requirement> reqsList =
pickInstanceOf(Requirement.class, ((Requirement)editedObject)
.getContainer().getContainedElements());
List<Requirement> funcReqList = new ArrayList<Requirement>();
for(Requirement req : reqsList) {
if(pickInstanceOf(IFunctionalRequirement.class, req.getSpecifications()).size() > 0) {
funcReqList.add(req);
}
}
dlg.setInput(funcReqList);
if(dlg.open() == 1 || dlg.getResult().length == 0) {
return;
}
modelContext.runAsCommand(new Runnable() {
@Override
public void run() {
ibsRequirement.getRelatedTo().add((Requirement)dlg.getFirstResult());
reqViewer.refresh();
}
});
}
});
deleteButton.addSelectionListener(new SelectionAdapter() {
/** {@inheritDoc} */
@Override
public void widgetSelected(SelectionEvent e) {
// Open dialog of components
ITreeContentProvider tcp = new FormalSpecificationTreeContentProvider();
ElementTreeSelectionDialog dlg =
new ElementTreeSelectionDialog(shell, new ModelElementLabelProvider(), tcp);
dlg.setAllowMultiple(false);
dlg.setTitle("Delete Related Functional Requirement(s)");
List<Requirement> nonFuncReqList = new ArrayList<Requirement>();
nonFuncReqList.addAll(pickFirstInstanceOf(InterfaceBehaviourSpecification.class,
((Requirement)editedObject).getSpecifications()).getRelatedTo());
dlg.setInput(nonFuncReqList);
if(dlg.open() == 1 || dlg.getResult().length == 0) {
return;
}
modelContext.runAsCommand(new Runnable() {
@Override
public void run() {
ibsRequirement.getRelatedTo().remove(dlg.getFirstResult());
reqViewer.refresh();
}
});
}
});
return relatedToSection;
}
/** Fake child used to add new elements. */
public static class FakeChild {
// Nothing to implement: just a marker class
}
/**
* @param relatedToSection
* section for relating the non-functional requirement to functional requirements
* @param ibsSpecification
* functional specification of the functional requirement
*/
public void createFunctionalRequirementTable(Composite relatedToSection,
InterfaceBehaviourSpecification ibsSpecification) {
reqViewer = new TreeViewer(relatedToSection, SWT.BORDER | SWT.FULL_SELECTION);
Tree tree = reqViewer.getTree();
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).minSize(300, 300)
.applyTo(tree);
tree.setLinesVisible(true);
tree.setHeaderVisible(true);
TreeViewerColumn nameColumn = new TreeViewerColumn(reqViewer, SWT.NONE);
TreeColumn trclmnMode = nameColumn.getColumn();
trclmnMode.setWidth(300);
trclmnMode.setText("Functional Requirement Name");
nameColumn.setLabelProvider(new ColumnLabelProvider() {
/** {@inheritDoc} */
@Override
public String getText(Object element) {
if(element instanceof FakeChild) {
return "";
}
return ibsSpecification.getRelatedTo().get((Integer)element).getReqId() + "-" +
ibsSpecification.getRelatedTo().get((Integer)element).getName();
}
});
nameColumn.setEditingSupport(createNonFunctionalRequirementNameEditingSupport(reqViewer,
nameColumn));
}
/** {@link EditingSupport} for the name column of the Relationships Table. */
private EditingSupport createNonFunctionalRequirementNameEditingSupport(TreeViewer viewer,
TreeViewerColumn funcCompColumn) {
top = IPersistencyService.getInstance().getTopLevelElementFor(getEditedObject());
return new EditingSupport(funcCompColumn.getViewer()) {
@Override
protected void setValue(Object element, Object value) {
if(element instanceof Integer) {
if((ibsSpec.getRelatedTo().get((Integer)element)).getName().equals(value)) {
return;
}
if(value != null) {
top.runAsCommand(() -> {
Requirement newReq = MiraFactory.eINSTANCE.createRequirement();
newReq.setName((String)value);
ibsSpec.getRelatedTo().add(newReq);
viewer.refresh();
});
}
}
}
@Override
protected Object getValue(Object element) {
return element instanceof Requirement ? ((Requirement)element).getName() : "";
}
@Override
protected CellEditor getCellEditor(Object element) {
return new StyledTextCellEditor(getTextStyledTextActionHandler(),
(Composite)getViewer().getControl());
}
@Override
protected boolean canEdit(Object element) {
return false;
}
};
}
}