Regarding DND [message #215256] |
Thu, 15 January 2009 09:37 |
Shiva Selvadurai Messages: 25 Registered: July 2009 Location: Bangalore |
Junior Member |
|
|
I tried DND from a treeviewer to a graphical editor and succedded to update the diagram but not the model.
My Model looks like this
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="test"
nsURI="http://test/1.0" nsPrefix="test">
<eClassifiers xsi:type="ecore:EClass" name="E">
<eStructuralFeatures xsi:type="ecore:EReference" name="instance" lowerBound="1"
eType="#//C" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="C">
<eStructuralFeatures xsi:type="ecore:EReference" name="instance" upperBound="-1"
eType="#//C" containment="true"/>
</eClassifiers>
</ecore:EPackage>
Transfer on both sides are LocalSelectionTransfer.
I add a DropTargetListener to my graphical viewer which extends DiagramDropTargetListener.
I install a DragDropPolicy in my EditParts. The getDropObjectsCommand() contains following code :
public Command getDropObjectsCommand(DropObjectsRequest dropRequest) {
List<CreateViewRequest.ViewDescriptor) viewDescriptors = new ArrayList<CreateViewRequest.ViewDescriptors>() ;
for (Iterator it = dropRequest.getObjects().iterator(); it.hasNext();) {
String nextObj = (String)it.next();
C cObj = XXXFactorg.eINSTANCE.createC() ;
cObj.setName(nextObj) ;
EObject eObj = cObj ;
if(obj != null)
viewDescriptors.add(new CreateViewRequest.ViewDescriptor(new EObjectAdapter(cObj),Node.class, null, getDiagramPreferencesHint()) ;
}
return createCommand(dropRequest, viewDescriptors) ;
}
private Command createCommand(DropObjectsRequest dropRequest, List viewDescriptors) {
Command command = createViewsAndArrangeCommand(dropRequest, viewDescriptors);
if (command != null)
return command.chain(new ICommandProxy(new CreateCCommand(getEditingDomain(),(View) getModel(),viewDescriptors)));
return null;
}
CreateCCommand extends AbstractTransactionalCommand.
After all these when I drop a object from treeviewer to the editor I get the diagram C drawn in the diagram. But when I do getModel() from the Root
EditPart I don't see this object reflected.
When I click the newly created diagram and do getModel() in that editpart I get the object, but its eContainer is NULL.
So could anyone let me know if I'm going wrong anywhere.
How could I update my domain model with that of the diagram.
-Shiva.S
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03458 seconds