use of org.obeonetwork.dsl.interaction.Interaction in project InformationSystem by ObeoNetwork.
the class DeleteServices method getCombinedFragmentsForParticipant.
private List<CombinedFragment> getCombinedFragmentsForParticipant(Participant participant) {
Interaction interaction = (Interaction) participant.eContainer();
List<CombinedFragment> result = new ArrayList<CombinedFragment>();
for (CombinedFragment combinedFragment : interaction.getCombinedFragments()) {
if (combinedFragment.getCoveredParticipants().size() == 1 && combinedFragment.getCoveredParticipants().contains(participant)) {
result.add(combinedFragment);
}
}
return result;
}
use of org.obeonetwork.dsl.interaction.Interaction in project InformationSystem by ObeoNetwork.
the class DeleteServices method getStateInvariantsForParticipant.
private List<StateInvariant> getStateInvariantsForParticipant(Participant participant) {
Interaction interaction = (Interaction) participant.eContainer();
List<StateInvariant> result = new ArrayList<StateInvariant>();
for (StateInvariant stateInvariant : interaction.getStateInvariants()) {
if (participant.equals(stateInvariant.getOwner())) {
result.add(stateInvariant);
}
}
return result;
}
use of org.obeonetwork.dsl.interaction.Interaction in project InformationSystem by ObeoNetwork.
the class InteractionServices method computeContainmentStructure.
private List<EventContext> computeContainmentStructure(Participant owner) {
if (!(owner.eContainer() instanceof Interaction)) {
return Collections.emptyList();
} else {
Interaction interaction = (Interaction) owner.eContainer();
Stack<EObject> ancestors = new Stack<EObject>();
ancestors.push(owner);
List<EventContext> result = new ArrayList<EventContext>();
for (End end : interaction.getEnds()) {
if (end.getContext() != owner) {
continue;
}
if (end.isStartingEnd() && end.isExecutionEnd()) {
result.add(new EventContext(ancestors.peek(), end.getExecution(), true, ancestors.size() + 1));
ancestors.push(end.getExecution());
}
if (end.isStartingEnd() && end.isStateInvariantEnd()) {
result.add(new EventContext(ancestors.peek(), end.getStateInvariant(), true, ancestors.size() + 1));
ancestors.push(end.getStateInvariant());
}
if (end.isMessageEnd()) {
Message msg = end.getMessage();
if (msg != null) {
result.add(new EventContext(ancestors.peek(), end.getMessage(), end.equals(msg.getStartingEnd()), ancestors.size()));
}
}
if (end.isFinishingEnd() && end.isExecutionEnd()) {
ancestors.pop();
result.add(new EventContext(ancestors.peek(), end.getExecution(), false, ancestors.size() + 1));
}
if (end.isFinishingEnd() && (end.isStateInvariantEnd())) {
ancestors.pop();
result.add(new EventContext(ancestors.peek(), end.getStateInvariant(), false, ancestors.size() + 1));
}
}
return result;
}
}
use of org.obeonetwork.dsl.interaction.Interaction in project InformationSystem by ObeoNetwork.
the class CreateSequenceDiagramAction method run.
@Override
public void run() {
if (context == null) {
return;
}
final Shell shell = Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell();
Session session = SessionManager.INSTANCE.getSession(context);
if (session == null) {
return;
}
TransactionalEditingDomain editingDomain = session.getTransactionalEditingDomain();
if (editingDomain == null) {
return;
}
RecordingCommand cmd = new RecordingCommand(editingDomain, "Create Sequence diagram") {
protected void doExecute() {
// Get Session
Session session = SessionManager.INSTANCE.getSession(context);
if (session != null) {
// Ask the user to provide a name for the diagram
InputDialog dialog = new InputDialog(shell, "New representation", "New representation name", "new Sequence diagram", null);
int buttonPressed = dialog.open();
if (buttonPressed == InputDialog.OK) {
String diagramName = dialog.getValue();
// Create a new interaction instance
Interaction interaction = InteractionFactory.eINSTANCE.createInteraction();
interaction.setName(diagramName);
context.getBehaviours().add(interaction);
Collection<RepresentationDescription> descs = DialectManager.INSTANCE.getAvailableRepresentationDescriptions(session.getSelectedViewpoints(false), interaction);
for (RepresentationDescription desc : descs) {
Viewpoint viewpoint = (Viewpoint) desc.eContainer();
if (InteractionAnalysisContextMenuActionProvider.isInteractionViewpoint(viewpoint) && "Sequence Diagram".equals(desc.getName())) {
// Create the new diagram
if (DialectManager.INSTANCE.canCreate(interaction, desc)) {
DRepresentation sequenceDiagram = DialectManager.INSTANCE.createRepresentation(diagramName, interaction, desc, session, new NullProgressMonitor());
if (sequenceDiagram != null) {
DialectUIManager.INSTANCE.openEditor(session, sequenceDiagram, new NullProgressMonitor());
}
}
}
}
}
}
}
};
editingDomain.getCommandStack().execute(cmd);
}
use of org.obeonetwork.dsl.interaction.Interaction in project InformationSystem by ObeoNetwork.
the class DeleteInteractionHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
final Interaction interaction = extractInteraction(event);
if (interaction == null) {
return null;
}
boolean confirm = MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), "Delete interaction", "Delete the selected interaction ?");
if (confirm) {
final Session session = SessionManager.INSTANCE.getSession(interaction);
final ModelAccessor modelAccessor = session.getModelAccessor();
final ECrossReferenceAdapter semanticCrossReferencer = session.getSemanticCrossReferencer();
TransactionalEditingDomain transactionalEditingDomain = session.getTransactionalEditingDomain();
transactionalEditingDomain.getCommandStack().execute(new RecordingCommand(transactionalEditingDomain) {
@Override
protected void doExecute() {
// Retrieve associated representations
Collection<DRepresentationDescriptor> representationDescriptors = DialectManager.INSTANCE.getRepresentationDescriptors(interaction, session);
// Delete representations
for (DRepresentationDescriptor representationDescriptor : representationDescriptors) {
closeEditor(session, representationDescriptor.getRepresentation());
DialectManager.INSTANCE.deleteRepresentation(representationDescriptor, session);
}
// Delete interaction
modelAccessor.eDelete(interaction, semanticCrossReferencer);
}
});
}
return null;
}
Aggregations