Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » how to set the value of a new element referencing a dragged element
how to set the value of a new element referencing a dragged element [message #484410] Mon, 07 September 2009 12:26
Eclipse UserFriend
Originally posted by: xuesong.wen.gmail.com

Hello,

I implemented drag and drop from common navigator to a GMF diagram. Now
I can drag a element form common navigator to editor and create a new
empty element. But I want this new element have the same properties
referencing the dragged element.

I have tried to follow this tipps using "SetRequest". But it doesn't work.
Collection results = DiagramCommandStack.getReturnValues(cmd);
for (Object res: results) {
if (res instanceof IAdaptable) {
IAdaptable adapter = (IAdaptable) res;
View view = (View) adapter.getAdapter(View.class); //everytime
"view=null", I don't know why. :(
if (view != null) {
.....
}
}
}

I have also tried to do like this:

public Command getDropObjectsCommand(DropObjectsRequest dropRequest) {
List viewandelementDescriptors = new ArrayList();
for (Iterator it = dropRequest.getObjects().iterator();it.hasNext();) {
final Object nextObject = it.next();
if (false == nextObject instanceof EObject) {
continue;
}

IElementType type = RulesModelerElementTypes.getElementType(((EObject)
nextObject).eClass());
final CreateElementRequest req = new CreateElementRequest(type);
req.setNewElement(((EObject) nextObject));// set element to this request
ViewAndElementDescriptor viewDescriptor = new
ViewAndElementDescriptor(new CreateElementRequestAdapter(req),
Node.class,
((IHintedType)type).getSemanticHint(),
getDiagramPreferencesHint());
viewandelementDescriptors.add(viewDescriptor);
...
}
But it doesn't work either.I can just create new empty element and its
view. How to set the value of this new element?

Thanks
Xuesong
Previous Topic:Create node for abstract class with EUGENIA
Next Topic:add a "console-like" view to the diagram
Goto Forum:
  


Current Time: Sat Apr 27 04:18:17 GMT 2024

Powered by FUDForum. Page generated in 0.02744 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top