Commit ed9c9df8 authored by Kisslinger's avatar Kisslinger
Browse files

Code cleaned, setting to YELLOW

parent 9b719de5
......@@ -21,6 +21,7 @@ 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.dialog.SelectionDialogUtils.open;
import static org.fortiss.af3.mira.utils.MiraModelElementFactory.createScopeSpecification;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickFirstInstanceOf;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getRootElement;
......@@ -30,7 +31,6 @@ import org.fortiss.af3.component.model.ComponentArchitecture;
import org.fortiss.af3.mira.command.CreateRequirementSpecificationCommand;
import org.fortiss.af3.mira.model.usecase.ScopeSpecification;
import org.fortiss.af3.mira.model.usecase.UseCase;
import org.fortiss.af3.mira.model.usecase.UsecaseFactory;
import org.fortiss.tooling.kernel.service.ICommandStackService;
import org.fortiss.tooling.kernel.ui.extension.base.EObjectActionBase;
......@@ -40,18 +40,16 @@ import org.fortiss.tooling.kernel.ui.extension.base.EObjectActionBase;
* @author uden
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: A58C6F2E347AA8EB723A2647A832EFDC
* @ConQAT.Rating YELLOW Hash: A7EA35408119978E12B940611F92BF67
*/
public final class ConnectScopeToComponentAction extends
EObjectActionBase<UseCase> {
public final class ConnectScopeToComponentAction extends EObjectActionBase<UseCase> {
/** The default shell */
private final Shell shell;
/** Constructor */
/** Constructor. */
public ConnectScopeToComponentAction(UseCase editedObject, Shell shell) {
super("ConnectScopeToComponent", imageDescriptorFromPlugin(PLUGIN_ID,
"icons/sample.png"));
super("ConnectScopeToComponent", imageDescriptorFromPlugin(PLUGIN_ID, "icons/sample.png"));
setTarget(editedObject);
this.shell = shell;
}
......@@ -59,31 +57,27 @@ public final class ConnectScopeToComponentAction extends
/** {@inheritDoc} */
@Override
public void run() {
ComponentArchitecture arch = getRootElement(getTarget(),
ComponentArchitecture.class);
if (arch == null) {
openError(shell, "Component Architecture",
"Cannot find Component Architecture!");
ComponentArchitecture arch = getRootElement(getTarget(), ComponentArchitecture.class);
if(arch == null) {
openError(shell, "Component Architecture", "Cannot find Component Architecture!");
return;
}
Component selected = null;
ScopeSpecification spec = pickFirstInstanceOf(ScopeSpecification.class,
getTarget().getReferencedByList());
if (spec != null && spec.getSpecificationOf() instanceof Component) {
selected = (Component) spec.getSpecificationOf();
ScopeSpecification spec =
pickFirstInstanceOf(ScopeSpecification.class, getTarget().getReferencedByList());
if(spec != null && spec.getSpecificationOf() instanceof Component) {
selected = (Component)spec.getSpecificationOf();
}
final Component component = open(shell.getShell(), arch, selected);
if (component == null || component == selected) {
if(component == null || component == selected) {
return;
}
ICommandStackService.INSTANCE.runAsCommand(
component,
new CreateRequirementSpecificationCommand(getTarget(),
component, UsecaseFactory.eINSTANCE
.createScopeSpecification()));
ICommandStackService.INSTANCE.runAsCommand(component,
new CreateRequirementSpecificationCommand(getTarget(), component,
createScopeSpecification("", "")));
}
}
\ No newline at end of file
}
......@@ -20,6 +20,7 @@ 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.utils.MiraModelElementFactory.createInputSpecification;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickFirstInstanceOf;
import org.eclipse.swt.widgets.Shell;
......@@ -30,7 +31,6 @@ import org.fortiss.af3.mira.model.usecase.InputSpecification;
import org.fortiss.af3.mira.model.usecase.ScopeSpecification;
import org.fortiss.af3.mira.model.usecase.UseCase;
import org.fortiss.af3.mira.ui.dialog.SelectionDialogUtils;
import org.fortiss.af3.mira.utils.MiraModelElementFactory;
import org.fortiss.tooling.kernel.service.ICommandStackService;
import org.fortiss.tooling.kernel.ui.extension.base.EObjectActionBase;
......@@ -40,14 +40,14 @@ import org.fortiss.tooling.kernel.ui.extension.base.EObjectActionBase;
* @author uden
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 7FC97DD1F94C1391B2B99C427D4CFC14
* @ConQAT.Rating YELLOW Hash: 673042446C2CFF9BE018297BCD2170E1
*/
public final class ConnectTriggerToInputPortAction extends EObjectActionBase<UseCase> {
/** the default shell */
private final Shell shell;
/** constructor */
/** Constructor. */
public ConnectTriggerToInputPortAction(UseCase editedObject, Shell shell) {
super("ConnectTriggerToInputPort", imageDescriptorFromPlugin(PLUGIN_ID, "icons/sample.png"));
setTarget(editedObject);
......@@ -80,6 +80,6 @@ public final class ConnectTriggerToInputPortAction extends EObjectActionBase<Use
return;
ICommandStackService.INSTANCE.runAsCommand(port, new CreateRequirementSpecificationCommand(
getTarget(), port, MiraModelElementFactory.createInputSpecification("", "")));
getTarget(), port, createInputSpecification("", "")));
}
}
......@@ -17,12 +17,14 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.af3.mira.ui.action;
import static org.fortiss.af3.mira.ui.glossary.utils.GlossaryUtils.openGlossaryDialog;
import static org.fortiss.af3.mira.utils.MiraModelElementFactory.createGlossary;
import static org.fortiss.af3.mira.utils.MiraModelElementFactory.createGlossaryEntry;
import org.eclipse.swt.widgets.Shell;
import org.fortiss.af3.mira.model.Analysis;
import org.fortiss.af3.mira.model.glossary.Glossary;
import org.fortiss.af3.mira.model.glossary.GlossaryEntry;
import org.fortiss.af3.mira.ui.glossary.utils.GlossaryUtils;
import org.fortiss.af3.mira.utils.MiraModelElementFactory;
import org.fortiss.tooling.kernel.service.ICommandStackService;
import org.fortiss.tooling.kernel.ui.extension.base.EObjectActionBase;
import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService;
......@@ -37,7 +39,7 @@ import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService;
* @author kisslinger
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: D9E24A9EA63D046D959BA9E172228386
* @ConQAT.Rating YELLOW Hash: 9C86FD587D112CF8E2B6ADDB1B18C553
*/
public class CreateGlossaryEntryAction extends EObjectActionBase<Analysis> {
/** the name the entry should get */
......@@ -46,7 +48,7 @@ public class CreateGlossaryEntryAction extends EObjectActionBase<Analysis> {
private final Shell shell;
/**
* constructor
* Constructor.
*
* @param analysis
* the analysis in which a glossary should be searched to add the
......@@ -73,7 +75,7 @@ public class CreateGlossaryEntryAction extends EObjectActionBase<Analysis> {
ICommandStackService.INSTANCE.runAsCommand(getTarget(), new Runnable() {
@Override
public void run() {
Glossary newGlossary = MiraModelElementFactory.createGlossary("Glossary", "");
Glossary newGlossary = createGlossary("Glossary", "");
analysis.getContainedElementsList().add(newGlossary);
}
});
......@@ -82,12 +84,10 @@ public class CreateGlossaryEntryAction extends EObjectActionBase<Analysis> {
if(analysis.getGlossariesList().size() == 1)
glossary = analysis.getGlossariesList().get(0);
else if(analysis.getGlossariesList().size() > 1)
glossary =
GlossaryUtils.openGlossaryDialog(shell, analysis, analysis.getGlossariesList()
.get(0));
glossary = openGlossaryDialog(shell, analysis, analysis.getGlossariesList().get(0));
if(glossary != null) {
final GlossaryEntry entry = MiraModelElementFactory.createGlossaryEntry(name, "", "");
final GlossaryEntry entry = createGlossaryEntry(name, "", "");
ICommandStackService.INSTANCE.runAsCommand(glossary, new addToGlossaryAction(glossary,
entry));
IModelEditorBindingService.INSTANCE.openInEditor(entry);
......
......@@ -17,17 +17,17 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.af3.mira.ui.dialog;
import static org.eclipse.emf.ecore.util.EcoreUtil.delete;
import static org.eclipse.jface.dialogs.MessageDialog.openConfirm;
import static org.eclipse.jface.dialogs.MessageDialog.openInformation;
import static org.fortiss.af3.mira.utils.MiraModelElementFactory.createActor;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Shell;
import org.fortiss.af3.mira.model.usecase.Actor;
import org.fortiss.af3.mira.model.usecase.UseCase;
import org.fortiss.af3.mira.utils.MiraModelElementFactory;
import org.fortiss.tooling.base.ui.dialog.IDialogEditSupport;
import org.fortiss.tooling.kernel.service.ICommandStackService;
......@@ -37,14 +37,14 @@ import org.fortiss.tooling.kernel.service.ICommandStackService;
* @author mou
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 4BDE23F43857DC8DAE2CAB499AA744C7
* @ConQAT.Rating YELLOW Hash: 64E7B29F003FEB1A56192DB9F00E459B
*/
public class ActorEditingSupport implements IDialogEditSupport {
/** the parent shell passed from caller */
private final Shell parentShell;
/** Constructor */
/** Constructor. */
public ActorEditingSupport(Shell parentShell) {
this.parentShell = parentShell;
}
......@@ -84,7 +84,7 @@ public class ActorEditingSupport implements IDialogEditSupport {
new Runnable() {
@Override
public void run() {
EcoreUtil.delete((EObject)selected);
delete((EObject)selected);
}
});
......@@ -106,7 +106,7 @@ public class ActorEditingSupport implements IDialogEditSupport {
(uc.getActorLength() + 1), new ActorNameValidator(uc));
if(Window.OK == input.open()) {
final Actor a = MiraModelElementFactory.createActor(input.getValue(), "");
final Actor a = createActor(input.getValue(), "");
ICommandStackService.INSTANCE.runAsCommand(uc, new Runnable() {
@Override
......
......@@ -17,8 +17,10 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.af3.mira.ui.editor.glossary;
import static org.eclipse.core.databinding.validation.ValidationStatus.error;
import static org.eclipse.core.databinding.validation.ValidationStatus.ok;
import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.core.databinding.validation.ValidationStatus;
import org.eclipse.core.runtime.IStatus;
/**
......@@ -29,7 +31,7 @@ import org.eclipse.core.runtime.IStatus;
* @author kisslinger
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: CD9374C4FF8722FF1233363E6F28DD85
* @ConQAT.Rating YELLOW Hash: F3F3A1D5871FF557FE073A53663532B8
*/
public class GlossaryStringValidator implements IValidator {
......@@ -41,13 +43,10 @@ public class GlossaryStringValidator implements IValidator {
for(int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if(!(Character.isLetterOrDigit(c) || c == ' '))
// TODO: use static imports, since status is clear from method return type, only
// error, ok matter
return ValidationStatus
.error("Please use only letters and numbers, no punctuation marks");
return error("Please use only letters and numbers, no punctuation marks");
}
return ValidationStatus.ok();
return ok();
}
return ValidationStatus.error("Not a String");
return error("Not a String");
}
}
......@@ -21,6 +21,8 @@ import static org.eclipse.jface.dialogs.MessageDialog.openInformation;
import static org.eclipse.jface.dialogs.MessageDialog.openQuestion;
import static org.eclipse.jface.layout.GridDataFactory.swtDefaults;
import static org.fortiss.af3.mira.ui.glossary.utils.ImageUtils.copyFile;
import static org.fortiss.af3.mira.utils.MiraModelElementFactory.createImageItem;
import static org.fortiss.af3.project.ui.utils.NewProjectUtils.getDefaultGeneralProjectPath;
import java.io.File;
import java.io.IOException;
......@@ -39,8 +41,6 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.fortiss.af3.mira.model.IImageContainer;
import org.fortiss.af3.mira.model.ImageItem;
import org.fortiss.af3.mira.model.MiraFactory;
import org.fortiss.af3.project.ui.utils.NewProjectUtils;
import org.fortiss.tooling.kernel.service.ICommandStackService;
/**
......@@ -52,7 +52,7 @@ import org.fortiss.tooling.kernel.service.ICommandStackService;
* @author kisslinger
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: C6016DD1FD3C1B222BF6540B28E0A391
* @ConQAT.Rating YELLOW Hash: B48C67C64BB9DB3D9F380B74F9504D14
*/
public class ImageSection {
/** Composite on which all elements should created */
......@@ -65,7 +65,7 @@ public class ImageSection {
private final DataBindingContext dbc;
/**
* Constructor
* Constructor.
*
* @param composite
* Composite on which all elements should created. If the
......@@ -133,13 +133,12 @@ public class ImageSection {
String filename = openFileDialog(composite.getShell());
if(filename != null) {
final ImageItem newItem = MiraFactory.eINSTANCE.createImageItem();
final ImageItem newItem = createImageItem();
// the image will be copied to the images folder in the AF3
// Project directory
File sourceFile = new File(filename);
File imageFolder =
new File(NewProjectUtils.getDefaultGeneralProjectPath(), "images");
File imageFolder = new File(getDefaultGeneralProjectPath(), "images");
// create image directory if it does not exists
if(!imageFolder.exists() || !imageFolder.isDirectory())
imageFolder.mkdir();
......
......@@ -22,8 +22,25 @@ import static org.fortiss.af3.mira.model.RequirementStatus.ANALYZED;
import static org.fortiss.af3.mira.model.RequirementStatus.IN_ANALYSIS;
import static org.fortiss.af3.mira.model.usecase.ScenarioStepActionType.INPUT;
import static org.fortiss.af3.mira.model.usecase.ScenarioStepActionType.OUTPUT;
import static org.fortiss.af3.mira.utils.MiraModelElementFactory.createActor;
import static org.fortiss.af3.mira.utils.MiraModelElementFactory.createAnalysis;
import static org.fortiss.af3.mira.utils.MiraModelElementFactory.createGlossary;
import static org.fortiss.af3.mira.utils.MiraModelElementFactory.createGlossaryEntry;
import static org.fortiss.af3.mira.utils.MiraModelElementFactory.createInputSpecification;
import static org.fortiss.af3.mira.utils.MiraModelElementFactory.createMinimumgaranteeSpecification;
import static org.fortiss.af3.mira.utils.MiraModelElementFactory.createRefinementRequirementRelation;
import static org.fortiss.af3.mira.utils.MiraModelElementFactory.createRequirement;
import static org.fortiss.af3.mira.utils.MiraModelElementFactory.createScenario;
import static org.fortiss.af3.mira.utils.MiraModelElementFactory.createScenarioStep;
import static org.fortiss.af3.mira.utils.MiraModelElementFactory.createScopeSpecification;
import static org.fortiss.af3.mira.utils.MiraModelElementFactory.createSuccessgaranteeSpecification;
import static org.fortiss.af3.mira.utils.MiraModelElementFactory.createUseCase;
import static org.fortiss.af3.mira.utils.MiraModelElementFactory.createWordElement;
import static org.fortiss.af3.msc.utils.MSCModelElementFactory.createMSCEntity;
import static org.fortiss.af3.msc.utils.MSCModelElementFactory.createMSCSpecification;
import static org.fortiss.af3.msc.utils.MSCModelElementFactory.createMessage;
import static org.fortiss.af3.msc.utils.MSCModelElementFactory.createMessageEntryConnector;
import static org.fortiss.af3.msc.utils.MSCModelElementFactory.createMessageExitConnector;
import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_GRID_SIZE;
import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_SHAPE_MINIMUM_WIDTH;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUtils.getNodeBounds;
......@@ -32,6 +49,7 @@ import static org.fortiss.tooling.base.ui.utils.LayoutDataUtils.setNodeLayoutDat
import static org.fortiss.tooling.base.ui.utils.LayoutDataUtils.setStickyConnectorLayoutData;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickInstanceOf;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.findContentElementByNameAndClass;
import static org.fortiss.tooling.kernel.utils.UniqueIDUtils.generateAllIDs;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.component.model.ComponentArchitecture;
......@@ -50,18 +68,15 @@ import org.fortiss.af3.mira.model.usecase.ScenarioStep;
import org.fortiss.af3.mira.model.usecase.ScopeSpecification;
import org.fortiss.af3.mira.model.usecase.SuccessgaranteeSpecification;
import org.fortiss.af3.mira.model.usecase.UseCase;
import org.fortiss.af3.mira.utils.MiraModelElementFactory;
import org.fortiss.af3.msc.model.MSCObject;
import org.fortiss.af3.msc.model.MSCSpecification;
import org.fortiss.af3.msc.model.Message;
import org.fortiss.af3.msc.model.MessageEntryConnector;
import org.fortiss.af3.msc.model.MessageExitConnector;
import org.fortiss.af3.msc.utils.MSCModelElementFactory;
import org.fortiss.af3.project.model.FileProject;
import org.fortiss.af3.state.model.State;
import org.fortiss.af3.state.ui.examples.SimpleTrafficLightsStateAutomatonExample;
import org.fortiss.tooling.base.model.layout.EOrientation;
import org.fortiss.tooling.kernel.utils.UniqueIDUtils;
/**
* Traffic lights controller example for MIRA.
......@@ -72,7 +87,7 @@ import org.fortiss.tooling.kernel.utils.UniqueIDUtils;
* @author kisslinger
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 8BD1DFB16A26B8CE7E14BC95BCDCE103
* @ConQAT.Rating YELLOW Hash: FDA143416660271245C5D27C7D15E683
*/
public class SimpleTrafficLightsRequirementsExample extends
SimpleTrafficLightsStateAutomatonExample {
......@@ -92,16 +107,16 @@ public class SimpleTrafficLightsRequirementsExample extends
FileProject project = super.createProject(projectName);
// Add requirement analysis.
Analysis analysis = createAnalysis(project);
Analysis analysis = createExampleAnalysis(project);
// Set the IDs of the project uniquely.
UniqueIDUtils.generateAllIDs(project);
generateAllIDs(project);
// Set execution configuration referenced ID.
setExecutionConfigReferencedID(project);
// Create Glossary
createGlossary(analysis);
createExampleGlossary(analysis);
// Return the new project.
return project;
......@@ -133,9 +148,9 @@ public class SimpleTrafficLightsRequirementsExample extends
"Traffic light is 'green' and pedestrian light is 'no go'");
activateTLC.getSuccessGuarantee().setName(
"Traffic light is 'red' and pedestrian light is 'go' and indicator is deactivated");
Actor actorPedestrian = MiraModelElementFactory.createActor("Pedestrian", "");
Actor actorPedestrian = createActor("Pedestrian", "");
activateTLC.getActorList().add(actorPedestrian);
Actor actorController = MiraModelElementFactory.createActor("Controller", "");
Actor actorController = createActor("Controller", "");
activateTLC.getActorList().add(actorController);
// Set comment.
......@@ -143,45 +158,40 @@ public class SimpleTrafficLightsRequirementsExample extends
// Create success scenario.
Scenario activateTLCScenario =
MiraModelElementFactory.createScenario(
"Activate traffic light to 'red' and pedestrian light to 'go'", "", true,
activateTLC);
createScenario("Activate traffic light to 'red' and pedestrian light to 'go'", "",
true, activateTLC);
// Create failure scenario.
Scenario failureScenario =
MiraModelElementFactory.createScenario("Failure scenario", "", false, activateTLC);
Scenario failureScenario = createScenario("Failure scenario", "", false, activateTLC);
// Create failure scenario steps.
// step 0
ScenarioStep failureStep0 =
MiraModelElementFactory.createScenarioStep(
"Controller switches traffic lights to red.", actorController, OUTPUT,
null, failureScenario);
createScenarioStep("Controller switches traffic lights to red.", actorController,
OUTPUT, null, failureScenario);
// step 1
MiraModelElementFactory.createScenarioStep(
"Controller switches pedestrian light to 'no go'.", actorController, OUTPUT, null,
failureScenario);
createScenarioStep("Controller switches pedestrian light to 'no go'.", actorController,
OUTPUT, null, failureScenario);
// Create success scenario steps.
// step 0
MiraModelElementFactory.createScenarioStep(
createScenarioStep(
"Pedestrian activates the traffic light controller by pushing button A or B.",
actorPedestrian, INPUT, null, activateTLCScenario);
// step 1
MiraModelElementFactory.createScenarioStep("Light on indicator goes on.", actorController,
OUTPUT, null, activateTLCScenario);
createScenarioStep("Light on indicator goes on.", actorController, OUTPUT, null,
activateTLCScenario);
// step 2
MiraModelElementFactory.createScenarioStep(
"Controller switches traffic light to 'yellow'.", actorController, OUTPUT,
failureStep0, activateTLCScenario);
createScenarioStep("Controller switches traffic light to 'yellow'.", actorController,
OUTPUT, failureStep0, activateTLCScenario);
// step 3
MiraModelElementFactory.createScenarioStep("Controller switches traffic light to 'red'.",
actorController, OUTPUT, failureStep0, activateTLCScenario);
createScenarioStep("Controller switches traffic light to 'red'.", actorController, OUTPUT,
failureStep0, activateTLCScenario);
// step 4
MiraModelElementFactory.createScenarioStep("Controller switches pedestrian light to 'go'.",
actorController, OUTPUT, failureStep0, activateTLCScenario);
// step 5
MiraModelElementFactory.createScenarioStep("Light on indicator goes off.", actorController,
createScenarioStep("Controller switches pedestrian light to 'go'.", actorController,
OUTPUT, failureStep0, activateTLCScenario);
// step 5
createScenarioStep("Light on indicator goes off.", actorController, OUTPUT, failureStep0,
activateTLCScenario);
createSuccessScenarioAsMSC(activateTLC);
......@@ -206,34 +216,34 @@ public class SimpleTrafficLightsRequirementsExample extends
/** height all entities should get */
final int ENTITY_HEIGHT = 30 * DEFAULT_GRID_SIZE;
MSCSpecification mscSpec = MSCModelElementFactory.createMSCSpecification("");
MSCSpecification mscSpec = createMSCSpecification("");
parentUseCase.getContainedElementsList().add(mscSpec);
MSCObject topEntity = MSCModelElementFactory.createMSCEntity("Success scenario as MSC", "");
MSCObject topEntity = createMSCEntity("Success scenario as MSC", "");
mscSpec.setTopEntity(topEntity);
// create entities
MSCObject pedestrianEntity = createMSCEntity("Pedestrian", topEntity);
MSCObject pedestrianEntity = createAndAttachMSCEntity("Pedestrian", topEntity);
setNodeLayoutData(pedestrianEntity, BORDER_LEFT, BORDER_TOP, DEFAULT_SHAPE_MINIMUM_WIDTH,
ENTITY_HEIGHT);
MSCObject trafficLightControllerEntity =
createMSCEntity("Traffic light controller", topEntity);
createAndAttachMSCEntity("Traffic light controller", topEntity);
setNodeLayoutData(trafficLightControllerEntity, getNodePosition(pedestrianEntity).getX() +
getNodeBounds(pedestrianEntity).width + BORDER_LEFT, BORDER_TOP,
15 * DEFAULT_GRID_SIZE, ENTITY_HEIGHT);
MSCObject indicatorEntity = createMSCEntity("Indicator", topEntity);
MSCObject indicatorEntity = createAndAttachMSCEntity("Indicator", topEntity);
setNodeLayoutData(indicatorEntity, getNodePosition(trafficLightControllerEntity).getX() +
getNodeBounds(trafficLightControllerEntity).width + BORDER_LEFT, BORDER_TOP,
DEFAULT_SHAPE_MINIMUM_WIDTH, ENTITY_HEIGHT);
MSCObject trafficLightEntitiy = createMSCEntity("Traffic light", topEntity);
MSCObject trafficLightEntitiy = createAndAttachMSCEntity("Traffic light", topEntity);
setNodeLayoutData(trafficLightEntitiy, getNodePosition(indicatorEntity).getX() +
getNodeBounds(indicatorEntity).width + BORDER_LEFT, BORDER_TOP,
10 * DEFAULT_GRID_SIZE, ENTITY_HEIGHT);
MSCObject pedestrianLightEntity = createMSCEntity("Pedestrian light", topEntity);
MSCObject pedestrianLightEntity = createAndAttachMSCEntity("Pedestrian light", topEntity);
setNodeLayoutData(pedestrianLightEntity, getNodePosition(trafficLightEntitiy).getX() +
getNodeBounds(trafficLightEntitiy).width + BORDER_LEFT, BORDER_TOP,
12 * DEFAULT_GRID_SIZE, ENTITY_HEIGHT);
......@@ -257,8 +267,8 @@ public class SimpleTrafficLightsRequirementsExample extends
* creates and returns a MSC entity object with the given name and attaches it to the given
* topEntitiy
*/
private MSCObject createMSCEntity(String name, MSCObject topEntity) {
MSCObject entity = MSCModelElementFactory.createMSCEntity(name, "");
private MSCObject createAndAttachMSCEntity(String name, MSCObject topEntity) {
MSCObject entity = createMSCEntity(name, "");
topEntity.getContainedElementsList().add(entity);
return entity;
......@@ -281,19 +291,17 @@ public class SimpleTrafficLightsRequirementsExample extends
*/
private void createMSCMessageBetween(MSCObject sourceEntity, MSCObject targetEntitiy,
MSCObject topEntity, String message, int messagePos) {
MessageExitConnector exitConnector =
MSCModelElementFactory.createMessageExitConnector("", "");
MessageExitConnector exitConnector = createMessageExitConnector("", "");
sourceEntity.getConnectorsList().add(exitConnector);
setStickyConnectorLayoutData(exitConnector, EOrientation.WEST, messagePos * 2 *
DEFAULT_GRID_SIZE); // messagePos*2 to leave always one point in the grid free
MessageEntryConnector entryConnector =
MSCModelElementFactory.createMessageEntryConnector("", "");
MessageEntryConnector entryConnector = createMessageEntryConnector("", "");
targetEntitiy.getConnectorsList().add(entryConnector);
setStickyConnectorLayoutData(entryConnector, EOrientation.WEST, messagePos * 2 *
DEFAULT_GRID_SIZE); // messagePos*2 to leave always one point in the grid free
Message messageObject = MSCModelElementFactory.createMessage();
Message messageObject = createMessage();
messageObject.setSource(exitConnector);
messageObject.setTarget(entryConnector);
messageObject.setName(message);
......@@ -310,8 +318,7 @@ public class SimpleTrafficLightsRequirementsExample ex