use of org.eclipse.sirius.business.api.session.Session in project Palladio-Editors-Sirius by PalladioSimulator.
the class OpenRepresentation method execute.
@Override
public void execute(Collection<? extends EObject> selections, Map<String, Object> parameters) {
EObject semantic = (EObject) parameters.get("element");
Session session = SessionManager.INSTANCE.getSession(semantic);
String viewpointName = (String) parameters.get("Viewpoint");
String representationDescriptionName = (String) parameters.get("RepresentationDescription");
String diagramName = (String) parameters.get("Diagram name");
// Select viewpoint
List<String> selectedViewpoints = new ArrayList<String>();
selectedViewpoints.add(viewpointName);
SiriusCustomUtil.selectViewpoints(session, selectedViewpoints, false, new NullProgressMonitor());
// Getting selected viewpoint and representation
Viewpoint viewpoint = SiriusCustomUtil.getSelectedViewpointByName(session, viewpointName);
RepresentationDescription description = SiriusCustomUtil.findDescription(viewpoint, representationDescriptionName);
// Find representations
Collection<DRepresentation> representations = DialectManager.INSTANCE.getRepresentations(semantic, session);
// create a new representation if none exists and open it
if (representations.isEmpty()) {
String representationName = null;
if (diagramName != null && !diagramName.isEmpty()) {
representationName = diagramName;
} else {
representationName = ((description.getLabel() == null) ? description.getName() : description.getLabel());
}
DRepresentation representation = SiriusCustomUtil.createRepresentation(session, representationName, description, semantic, new NullProgressMonitor());
DialectUIManager.INSTANCE.openEditor(session, representation, new NullProgressMonitor());
} else {
// open available representations
for (DRepresentation representation : representations) {
DialectUIManager.INSTANCE.openEditor(session, representation, new NullProgressMonitor());
}
}
}
use of org.eclipse.sirius.business.api.session.Session in project Palladio-Editors-Sirius by PalladioSimulator.
the class AddLinkingResourceAction method execute.
@Override
public void execute(final Collection<? extends EObject> selections, final Map<String, Object> parameters) {
final Object parameter = parameters.get(NEW_COMMUNICATION_LINK_RESOURCE_SPECIFICATION);
if (parameter == null || !(parameter instanceof CommunicationLinkResourceSpecification)) {
return;
}
final CommunicationLinkResourceSpecification communicationLinkResourceSpecification = (CommunicationLinkResourceSpecification) parameter;
// latency
final PCMRandomVariable latency = getRandomVariableFromStoExDialog(LATENCY_DISPLAY_TITLE);
if (latency == null) {
return;
}
communicationLinkResourceSpecification.setLatency_CommunicationLinkResourceSpecification(latency);
// throughput
final PCMRandomVariable throughput = getRandomVariableFromStoExDialog(THROUGHPUT_DISPLAY_TITLE);
if (throughput == null) {
return;
}
communicationLinkResourceSpecification.setThroughput_CommunicationLinkResourceSpecification(throughput);
// Communication Link
Session session = SessionManager.INSTANCE.getSession(communicationLinkResourceSpecification);
URI uri = URI.createURI("pathmap://PCM_MODELS/Palladio.resourcetype");
Resource palladioResources = SiriusCustomUtil.getResourceByURI(uri, session);
if (palladioResources != null) {
ResourceRepository rep = (ResourceRepository) palladioResources.getContents().iterator().next();
for (EObject o : rep.eContents()) {
if ((o instanceof CommunicationLinkResourceType) && ((CommunicationLinkResourceType) o).getEntityName().equals("LAN")) {
communicationLinkResourceSpecification.setCommunicationLinkResourceType_CommunicationLinkResourceSpecification((CommunicationLinkResourceType) o);
break;
}
}
}
}
use of org.eclipse.sirius.business.api.session.Session in project Palladio-Editors-Sirius by PalladioSimulator.
the class NewModelWizard method createModel.
private void createModel(final IProject project, final boolean createRepresentation, final String representationName, final IProgressMonitor monitor) throws CoreException {
monitor.beginTask("Creating Model File", 6000);
if (!project.hasNature(ModelingProject.NATURE_ID)) {
ModelingProjectManager.INSTANCE.convertToModelingProject(project, SubMonitor.convert(monitor, "Converting to Modeling Project", 1000));
}
final URI representationsURI = SiriusCustomUtil.getRepresentationsURI(project);
final Session session = SessionManager.INSTANCE.getSession(representationsURI, SubMonitor.convert(monitor, "Getting Session", 1000));
createResource(session, SubMonitor.convert(monitor, "Creating Resource", 1000));
HashSet<Viewpoint> selectedViewpoints = new HashSet<Viewpoint>();
selectedViewpoints.add(viewpoint);
SiriusCustomUtil.selectViewpoints(session, selectedViewpoints, false, SubMonitor.convert(monitor, "Selecting Viewpoint", 1000));
// Apparently the selected viewpoint's instance is not the same as the passed instance
// We retrieve here the actually selected Viewpoint
Viewpoint selectedViewpoint = SiriusCustomUtil.getSelectedViewpointByName(session, viewpoint.getName());
RepresentationDescription actualRepresentationDescription = SiriusCustomUtil.findDescription(selectedViewpoint, representationDescription.getName());
if (createRepresentation) {
final DRepresentation createdRepresentation = SiriusCustomUtil.createRepresentation(session, representationName, actualRepresentationDescription, this.modelObject, SubMonitor.convert(monitor, "Creating Representation", 1000));
DialectUIManager.INSTANCE.openEditor(session, createdRepresentation, SubMonitor.convert(monitor, "Opening representation", 1000));
}
monitor.done();
}
use of org.eclipse.sirius.business.api.session.Session in project Palladio-Editors-Sirius by PalladioSimulator.
the class NewPalladioProjectWizard method activateViewpoints.
/**
* Activate viewpoints.
*/
private void activateViewpoints(final IProject projectHandle, final SubMonitor subMonitor) {
final URI representationsURI = SiriusCustomUtil.getRepresentationsURI(projectHandle);
final Session session = SessionManager.INSTANCE.getSession(representationsURI, subMonitor);
final Set<Viewpoint> registry = ViewpointRegistry.getInstance().getViewpoints();
final HashSet<Viewpoint> viewpoints = new HashSet<>();
final List<String> extensions = getExtensions(session);
for (final Viewpoint viewpoint : registry) {
final String ext = viewpoint.getModelFileExtension();
if (extensions.contains(ext)) {
viewpoints.add(viewpoint);
}
}
SiriusCustomUtil.selectViewpoints(session, viewpoints, true, subMonitor);
}
use of org.eclipse.sirius.business.api.session.Session in project Palladio-Editors-Sirius by PalladioSimulator.
the class ActivateViewpoint method execute.
@Override
public void execute(Collection<? extends EObject> selections, Map<String, Object> parameters) {
EObject element = (EObject) parameters.get("element");
Session session = SessionManager.INSTANCE.getSession(element);
String viewpointName = (String) parameters.get("Viewpoint");
List<String> selectedViewpoints = new ArrayList<String>();
selectedViewpoints.add(viewpointName);
SiriusCustomUtil.selectViewpoints(session, selectedViewpoints, true, new NullProgressMonitor());
}
Aggregations