Search in sources :

Example 6 with DSemanticDecorator

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);
    }
}
Also used : DSemanticDecorator(org.eclipse.sirius.viewpoint.DSemanticDecorator) EObjectQuery(org.eclipse.sirius.business.api.query.EObjectQuery) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) EObject(org.eclipse.emf.ecore.EObject) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) View(org.eclipse.gmf.runtime.notation.View) Session(org.eclipse.sirius.business.api.session.Session)

Aggregations

EObject (org.eclipse.emf.ecore.EObject)6 DSemanticDecorator (org.eclipse.sirius.viewpoint.DSemanticDecorator)6 Resource (org.eclipse.emf.ecore.resource.Resource)2 FeatureEditorDialog (org.eclipse.emf.edit.ui.celleditor.FeatureEditorDialog)2 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)2 View (org.eclipse.gmf.runtime.notation.View)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 EObjectQuery (org.eclipse.sirius.business.api.query.EObjectQuery)2 Session (org.eclipse.sirius.business.api.session.Session)2 ArrayList (java.util.ArrayList)1 DAnalysis (org.eclipse.sirius.viewpoint.DAnalysis)1 Profile (org.modelversioning.emfprofile.Profile)1 Stereotype (org.modelversioning.emfprofile.Stereotype)1