Search in sources :

Example 1 with RepresentationDescription

use of org.eclipse.sirius.viewpoint.description.RepresentationDescription 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());
        }
    }
}
Also used : RepresentationDescription(org.eclipse.sirius.viewpoint.description.RepresentationDescription) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) Viewpoint(org.eclipse.sirius.viewpoint.description.Viewpoint) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) DRepresentation(org.eclipse.sirius.viewpoint.DRepresentation) Session(org.eclipse.sirius.business.api.session.Session)

Example 2 with RepresentationDescription

use of org.eclipse.sirius.viewpoint.description.RepresentationDescription in project Palladio-Editors-Sirius by PalladioSimulator.

the class Activator method start.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.
	 * BundleContext)
	 */
public void start(BundleContext context) throws Exception {
    super.start(context);
    plugin = this;
    Set<Viewpoint> viewpoints = ViewpointRegistry.getInstance().getViewpoints();
    // Set viewpoint constants
    for (final Viewpoint v : viewpoints) {
        if (v.getName().equals(VIEWPOINT_NAME)) {
            this.viewpoint = v;
            break;
        }
    }
    // Set diagram description constants
    for (final RepresentationDescription representationDescription : this.viewpoint.getOwnedRepresentations()) {
        if (representationDescription.getName().equals(REPRESENTATION_NAME)) {
            this.representationDescription = representationDescription;
            break;
        }
    }
}
Also used : RepresentationDescription(org.eclipse.sirius.viewpoint.description.RepresentationDescription) Viewpoint(org.eclipse.sirius.viewpoint.description.Viewpoint)

Example 3 with RepresentationDescription

use of org.eclipse.sirius.viewpoint.description.RepresentationDescription in project Palladio-Editors-Sirius by PalladioSimulator.

the class Activator method start.

/*
	 * (non-Javadoc)
	 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
	 */
public void start(BundleContext bundleContext) throws Exception {
    Activator.context = bundleContext;
    Activator.plugin = this;
    Set<Viewpoint> viewpoints = ViewpointRegistry.getInstance().getViewpoints();
    // Set viewpoint constants
    for (final Viewpoint v : viewpoints) {
        if (v.getName().equals(VIEWPOINT_NAME)) {
            this.viewpoint = v;
            break;
        }
    }
    // Set diagram description constants
    for (final RepresentationDescription representationDescription : this.viewpoint.getOwnedRepresentations()) {
        if (representationDescription.getName().equals(REPRESENTATION_NAME)) {
            this.representationDescription = representationDescription;
            break;
        }
    }
}
Also used : RepresentationDescription(org.eclipse.sirius.viewpoint.description.RepresentationDescription) Viewpoint(org.eclipse.sirius.viewpoint.description.Viewpoint)

Example 4 with RepresentationDescription

use of org.eclipse.sirius.viewpoint.description.RepresentationDescription 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();
}
Also used : RepresentationDescription(org.eclipse.sirius.viewpoint.description.RepresentationDescription) Viewpoint(org.eclipse.sirius.viewpoint.description.Viewpoint) URI(org.eclipse.emf.common.util.URI) DRepresentation(org.eclipse.sirius.viewpoint.DRepresentation) Session(org.eclipse.sirius.business.api.session.Session) HashSet(java.util.HashSet)

Example 5 with RepresentationDescription

use of org.eclipse.sirius.viewpoint.description.RepresentationDescription in project Palladio-Editors-Sirius by PalladioSimulator.

the class Activator method start.

/*
	 * (non-Javadoc)
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
	 */
public void start(BundleContext context) throws Exception {
    super.start(context);
    plugin = this;
    Set<Viewpoint> viewpoints = ViewpointRegistry.getInstance().getViewpoints();
    // Set viewpoint constants
    for (final Viewpoint v : viewpoints) {
        if (v.getName().equals(VIEWPOINT_NAME)) {
            this.viewpoint = v;
            break;
        }
    }
    // Set diagram description constants
    for (final RepresentationDescription representationDescription : this.viewpoint.getOwnedRepresentations()) {
        if (representationDescription.getName().equals(REPRESENTATION_NAME)) {
            this.representationDescription = representationDescription;
            break;
        }
    }
}
Also used : RepresentationDescription(org.eclipse.sirius.viewpoint.description.RepresentationDescription) Viewpoint(org.eclipse.sirius.viewpoint.description.Viewpoint)

Aggregations

RepresentationDescription (org.eclipse.sirius.viewpoint.description.RepresentationDescription)8 Viewpoint (org.eclipse.sirius.viewpoint.description.Viewpoint)8 Session (org.eclipse.sirius.business.api.session.Session)2 DRepresentation (org.eclipse.sirius.viewpoint.DRepresentation)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 URI (org.eclipse.emf.common.util.URI)1 EObject (org.eclipse.emf.ecore.EObject)1