/** * @generated */ protected void updateSelection(IStructuredSelection selection) { selectedModelElement = null; if (selection.size() == 1) { Object selectedElement = selection.getFirstElement(); if (selectedElement instanceof IWrapperItemProvider) { selectedElement = ((IWrapperItemProvider) selectedElement) .getValue(); } if (selectedElement instanceof FeatureMap.Entry) { selectedElement = ((FeatureMap.Entry) selectedElement) .getValue(); } if (selectedElement instanceof EObject) { selectedModelElement = (EObject) selectedElement; } } setPageComplete(validatePage()); }
/** * @generated */ public void selectionChanged(SelectionChangedEvent event) { if (event.getSelection() instanceof IStructuredSelection) { IStructuredSelection selection = (IStructuredSelection) event .getSelection(); if (selection.size() == 1) { Object selectedElement = selection.getFirstElement(); if (selectedElement instanceof IWrapperItemProvider) { selectedElement = ((IWrapperItemProvider) selectedElement) .getValue(); } if (selectedElement instanceof FeatureMap.Entry) { selectedElement = ((FeatureMap.Entry) selectedElement) .getValue(); } if (selectedElement instanceof EObject) { EObject selectedModelElement = (EObject) selectedElement; setOkButtonEnabled(ViewService .getInstance() .provides( Node.class, new EObjectAdapter(selectedModelElement), myView, null, ViewUtil.APPEND, true, edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.part.NECSIS14_ClassDiagramDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT)); mySelectedModelElementURI = EcoreUtil .getURI(selectedModelElement); return; } } } mySelectedModelElementURI = null; setOkButtonEnabled(false); }
/** * @generated */ public void selectionChanged(SelectionChangedEvent event) { if (event.getSelection() instanceof IStructuredSelection) { IStructuredSelection selection = (IStructuredSelection) event .getSelection(); if (selection.size() == 1) { Object selectedElement = selection.getFirstElement(); if (selectedElement instanceof IWrapperItemProvider) { selectedElement = ((IWrapperItemProvider) selectedElement) .getValue(); } if (selectedElement instanceof FeatureMap.Entry) { selectedElement = ((FeatureMap.Entry) selectedElement) .getValue(); } if (selectedElement instanceof EObject) { EObject selectedModelElement = (EObject) selectedElement; setOkButtonEnabled(ViewService .getInstance() .provides( Node.class, new EObjectAdapter(selectedModelElement), myView, null, ViewUtil.APPEND, true, edu.toronto.cs.se.modelepedia.necsis14_databaseschema.diagram.part.NECSIS14_DatabaseSchemaDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT)); mySelectedModelElementURI = EcoreUtil .getURI(selectedModelElement); return; } } } mySelectedModelElementURI = null; setOkButtonEnabled(false); }
/** * @generated */ public void selectionChanged(SelectionChangedEvent event) { if (event.getSelection() instanceof IStructuredSelection) { IStructuredSelection selection = (IStructuredSelection) event .getSelection(); if (selection.size() == 1) { Object selectedElement = selection.getFirstElement(); if (selectedElement instanceof IWrapperItemProvider) { selectedElement = ((IWrapperItemProvider) selectedElement) .getValue(); } if (selectedElement instanceof FeatureMap.Entry) { selectedElement = ((FeatureMap.Entry) selectedElement) .getValue(); } if (selectedElement instanceof EObject) { EObject selectedModelElement = (EObject) selectedElement; setOkButtonEnabled(ViewService .getInstance() .provides( Node.class, new EObjectAdapter(selectedModelElement), myView, null, ViewUtil.APPEND, true, RelationalDatabaseDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT)); mySelectedModelElementURI = EcoreUtil .getURI(selectedModelElement); return; } } } mySelectedModelElementURI = null; setOkButtonEnabled(false); }
/** * @generated */ public void selectionChanged(SelectionChangedEvent event) { if (event.getSelection() instanceof IStructuredSelection) { IStructuredSelection selection = (IStructuredSelection) event .getSelection(); if (selection.size() == 1) { Object selectedElement = selection.getFirstElement(); if (selectedElement instanceof IWrapperItemProvider) { selectedElement = ((IWrapperItemProvider) selectedElement) .getValue(); } if (selectedElement instanceof FeatureMap.Entry) { selectedElement = ((FeatureMap.Entry) selectedElement) .getValue(); } if (selectedElement instanceof EObject) { EObject selectedModelElement = (EObject) selectedElement; setOkButtonEnabled(ViewService .getInstance() .provides( Node.class, new EObjectAdapter(selectedModelElement), myView, null, ViewUtil.APPEND, true, IStarDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT)); mySelectedModelElementURI = EcoreUtil .getURI(selectedModelElement); return; } } } mySelectedModelElementURI = null; setOkButtonEnabled(false); }
private EObject getEObject(Object object) { if (object instanceof Collection) { List<EObject> eObjects = new ArrayList<EObject>(); Collection<?> collection = (Collection<?>) object; for (Object o : collection) { EObject eObject = getEObject(o); if (eObject != null) { eObjects.add(eObject); } } if (eObjects.size() != collection.size()) { return null; } if (eObjects.size() == 1) { object = eObjects.get(0); } else { final MultiItemPropertySource source; final Option<String> label; final Option<Image> icon; if (collection instanceof MultiObject) { final MultiObject multiObject = (MultiObject) collection; source = (multiObject.getType() == Type.UNION) ? new MultiItemUnionPropertySource(eObjects) : new MultiItemIntersectionPropertySource(eObjects); label = multiObject.getLabel(); icon = multiObject.getIcon(); } else { source = new MultiItemIntersectionPropertySource(eObjects); label = Option.none(); icon = Option.none(); } return new MultiEObject(eObjects, source, label, icon); } } if (object instanceof EObject) { return (EObject) object; } else if (object instanceof IAdaptable) { IAdaptable adaptable = (IAdaptable) object; Object result = adaptable.getAdapter(EObject.class); if (result instanceof EObject) { return (EObject) result; } else { if (adaptable instanceof Resource) { // TODO: maybe something more elaborate here? Resource resource = (Resource) adaptable; EList<EObject> contents = resource.getContents(); return contents.iterator().next(); } result = EMFUtils.adapt(object, EObject.class); if (result instanceof EObject) { return (EObject) result; } } } else if (object instanceof IWrapperItemProvider) { return (EObject) AdapterFactoryEditingDomain.unwrap(object); } return null; }