/** * check if the drop is processable * * @return */ private boolean enable() { if (getTargetEditPart() == null) {; // alle EditPart fuer die Drop funktionieren soll } else if (getTargetEditPart() instanceof EnsembleEditPart || getTargetEditPart() instanceof Ensemble2EditPart || getTargetEditPart() instanceof ShapesDiagramEditPart) { return QueryBuilder.isProcessable(getTargetRequest().getExtendedData()); } return false; }
@Override protected Command getDirectEditCommand(DirectEditRequest request) { // TODO put "http://vespucci.editor" in some constant // Make sure that XXXEditPart is an instanceof GraphicalEditPart // so that it support resolveSemanticElement() // Furthermore make sure that the resolveSemanticElement() is from type // Shape if (getHost() instanceof GraphicalEditPart && ((GraphicalEditPart) getHost()).resolveSemanticElement() instanceof Shape) { // we need infos about the EMF meta modell so we refer to the // Singelton that save Vespucci_modelPackage EPackage epackage = org.eclipse.emf.ecore.EPackage.Registry.INSTANCE.getEPackage("http://vespucci.editor"); Vespucci_modelPackage vesPackage = (Vespucci_modelPackage) epackage; if ((((GraphicalEditPart) getHost()).resolveSemanticElement()) .eClass() .getEAllStructuralFeatures() .contains(vesPackage.getShape_Query())) { // get the old query // String name = (String)writer.eGet(LibraryPackage.eINSTANCE.getWriter_Name()); Object oldQuery = (((GraphicalEditPart) getHost()).resolveSemanticElement()) .eGet(vesPackage.getShape_Query()); @SuppressWarnings("unchecked") SetRequest sr = new SetRequest( ((GraphicalEditPart) getHost()).resolveSemanticElement(), vesPackage.getShape_Query(), QueryBuilder.createQueryForAMapOfIResource( request.getExtendedData(), (String) oldQuery)); org.eclipse.gmf.runtime.common.core.command.ICommand com = new SetValueCommand(sr); // return the edit Request in a Proxy so it can be handled return new org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy(com); // create a Request for the Query edit // @SuppressWarnings("unchecked") // EditQueryRequest editRequest = new EditQueryRequest( // ((GraphicalEditPart) getHost()).resolveSemanticElement(), // vesPackage.getShape_Query(), request.getExtendedData()); // ICommand com = new EditQueryCommand(editRequest); // return new // org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy(com); } return null; } return null; }