Search in sources :

Example 1 with Viewpoint

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

the class Activator method stop.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.
	 * BundleContext)
	 */
public void stop(BundleContext context) throws Exception {
    plugin = null;
    if (viewpoints != null) {
        for (final Viewpoint viewpoint : viewpoints) {
            ViewpointRegistry.getInstance().disposeFromPlugin(viewpoint);
        }
        viewpoints.clear();
        viewpoints = null;
    }
    super.stop(context);
}
Also used : Viewpoint(org.eclipse.sirius.viewpoint.description.Viewpoint)

Example 2 with Viewpoint

use of org.eclipse.sirius.viewpoint.description.Viewpoint 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 3 with Viewpoint

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

the class SiriusCustomUtil method getSelectedViewpointByName.

public static Viewpoint getSelectedViewpointByName(Session session, String viewpointName) {
    Viewpoint selectedViewpoint = null;
    Collection<Viewpoint> selectedViewpoints = session.getSelectedViewpoints(false);
    for (Viewpoint v : selectedViewpoints) {
        if (viewpointName.equals(v.getName())) {
            selectedViewpoint = v;
            break;
        }
    }
    return selectedViewpoint;
}
Also used : Viewpoint(org.eclipse.sirius.viewpoint.description.Viewpoint)

Example 4 with Viewpoint

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

the class SiriusCustomUtil method selectViewpoints.

public static void selectViewpoints(Session session, List<String> viewpointNames, boolean createRepresentation, IProgressMonitor monitor) {
    final Set<Viewpoint> registry = ViewpointRegistry.getInstance().getViewpoints();
    HashSet<Viewpoint> viewpoints = new HashSet<Viewpoint>();
    for (Viewpoint viewpoint : registry) {
        if (viewpointNames.contains(viewpoint.getName())) {
            viewpoints.add(viewpoint);
        }
    }
    selectViewpoints(session, viewpoints, createRepresentation, monitor);
}
Also used : Viewpoint(org.eclipse.sirius.viewpoint.description.Viewpoint) HashSet(java.util.HashSet)

Example 5 with Viewpoint

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

the class SiriusCustomUtil method selectViewpoints.

public static void selectViewpoints(Session session, HashSet<Viewpoint> viewpoints, boolean createRepresentation, IProgressMonitor monitor) {
    final ViewpointSelectionCallback selectionCallback = new ViewpointSelectionCallback();
    final TransactionalEditingDomain domain = session.getTransactionalEditingDomain();
    Collection<Viewpoint> selectedViewpoints = session.getSelectedViewpoints(false);
    for (Viewpoint v : viewpoints) {
        if (selectedViewpoints.contains(v))
            viewpoints.remove(v);
    }
    @SuppressWarnings("restriction") final Command command = new ChangeViewpointSelectionCommand(session, selectionCallback, viewpoints, new HashSet<Viewpoint>(), createRepresentation, SubMonitor.convert(monitor));
    domain.getCommandStack().execute(command);
}
Also used : TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) CreateRepresentationCommand(org.eclipse.sirius.business.api.dialect.command.CreateRepresentationCommand) ChangeViewpointSelectionCommand(org.eclipse.sirius.ui.business.internal.commands.ChangeViewpointSelectionCommand) Command(org.eclipse.emf.common.command.Command) Viewpoint(org.eclipse.sirius.viewpoint.description.Viewpoint) ChangeViewpointSelectionCommand(org.eclipse.sirius.ui.business.internal.commands.ChangeViewpointSelectionCommand) ViewpointSelectionCallback(org.eclipse.sirius.ui.business.api.viewpoint.ViewpointSelectionCallback)

Aggregations

Viewpoint (org.eclipse.sirius.viewpoint.description.Viewpoint)18 RepresentationDescription (org.eclipse.sirius.viewpoint.description.RepresentationDescription)8 HashSet (java.util.HashSet)3 Session (org.eclipse.sirius.business.api.session.Session)3 URI (org.eclipse.emf.common.util.URI)2 DRepresentation (org.eclipse.sirius.viewpoint.DRepresentation)2 ArrayList (java.util.ArrayList)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 Command (org.eclipse.emf.common.command.Command)1 EObject (org.eclipse.emf.ecore.EObject)1 TransactionalEditingDomain (org.eclipse.emf.transaction.TransactionalEditingDomain)1 CreateRepresentationCommand (org.eclipse.sirius.business.api.dialect.command.CreateRepresentationCommand)1 ViewpointSelectionCallback (org.eclipse.sirius.ui.business.api.viewpoint.ViewpointSelectionCallback)1 ChangeViewpointSelectionCommand (org.eclipse.sirius.ui.business.internal.commands.ChangeViewpointSelectionCommand)1