Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Child has parent, but that parent doesn't have the child??
Child has parent, but that parent doesn't have the child?? [message #484806] Wed, 09 September 2009 11:59
Eclipse UserFriend
Originally posted by: nbe.informatik.uni-kiel.de

Hi all,

I'm facing a strange problem here:

When debugging I found a TransitionEditPart that has a
RenderedDiagrammRootEditPart as parent, but this
RenderedDiagrammRootEditPart does not have that TransitionEditPart as
child!? How is that possible?

Context: For identification reasons and exchanging objects with other
plugins, I translate the EditPart to URIfragment and then later back to
EditPart. There however i fail to find an Editpart for the URIFragment...

public String translateToURI(Object sourceObject){
if (sourceObject instanceof EditPart){

View view = (View) ((EditPart) sourceObject).getModel();
EObject modelElement = view.getElement();
result = modelElement.eResource().getURIFragment(modelElement);

}
return result;


public EditPart translateToEditPart(String elementURIFragment,

EditPart parent) {
if (parent==null)
parent= getRootEPAsParent();
if (cachedEditParts == null) {
// if hashmap is not initialized, create it
cachedEditParts = new HashMap<String,EditPart>();
}
else {
//try to get from hashmap first
if (cachedEditParts.containsKey(elementURIFragment))
return
cachedEditParts.get(elementURIFragment);
}

List children = parent.getChildren();
for (Object child : children) {
if (child instanceof EditPart) {
View view = (View) ((EditPart) child).getModel();
EObject modelElement = (EObject) view.getElement();
if (modelElement.equals(
modelElement.eResource()
.getEObject(elementURIFragment))) {
//cache for later calls
cachedEditParts.put(
elementURIFragment,
(EditPart) child);
return (EditPart) child;
}

}
// if node was not found yet, search recursively
if (child instanceof EditPart) {
EditPart result = translateToEditPart(elementURIFragment,
(EditPart) child);
if (result != null) {
return result;
}
}
}
// we did not find anything in this trunk
return null;
}

I tried to set parent in translateToEditPart manually to the original
parent RenderedDiagramRootEditpart, but as stated above, it doesn't
recognize its child!

Any help with this strange problem would be appreciated!

Cheers,
Nils
Previous Topic:What is the best way to implement a container with no GMF mapping
Next Topic:Update connection when target-attribute changes
Goto Forum:
  


Current Time: Thu Apr 25 02:23:23 GMT 2024

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

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

Back to the top