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);
}
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());
}
}
}
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;
}
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);
}
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);
}
Aggregations