use of org.eclipse.sirius.viewpoint.DSemanticDecorator in project InformationSystem by ObeoNetwork.
the class ViewpointMultiSelectionListener method selectionChanged.
/**
* {@inheritDoc}
*
* @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart,
* org.eclipse.jface.viewers.ISelection)
*/
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
if (part != owningPart) {
List<EObject> selectedEObjects = new ArrayList<EObject>();
Session session = null;
if (!selection.isEmpty() && selection instanceof StructuredSelection) {
for (Object selectedObject : ((StructuredSelection) selection).toList()) {
if (selectedObject instanceof GraphicalEditPart) {
GraphicalEditPart graphicalEditPart = (GraphicalEditPart) selectedObject;
if (graphicalEditPart.getModel() instanceof View) {
View node = (View) graphicalEditPart.getModel();
if (node.getElement() instanceof DSemanticDecorator) {
DSemanticDecorator semanticDecorator = (DSemanticDecorator) node.getElement();
if (session == null) {
session = new EObjectQuery(semanticDecorator.getTarget()).getSession();
}
selectedEObjects.add(semanticDecorator.getTarget());
}
}
} else if (selectedObject instanceof EObject) {
EObject selectedEObject = (EObject) selectedObject;
session = new EObjectQuery(selectedEObject).getSession();
if (!ViewpointPackage.eINSTANCE.getDRepresentation().isInstance(selectedObject)) {
selectedEObjects.add(selectedEObject);
}
}
}
}
eObjectSelected(session, selectedEObjects);
}
}
Aggregations