Get the EditPart from the Model [message #149159] |
Thu, 06 September 2007 03:22  |
Eclipse User |
|
|
|
Hi all,
I am trying to create my own OutlineView for my GMF project.
I have succeded in showing the elements in the outline View along with the
icons and labels.
My problem is when i click on any of the element in the tree viewer it
does not select the same element on my canvas.Rather it always selects the
root.
While debugging i found out that following code is present in the class
AbstractEditPart :-
protected void refreshChildren() {
...
Map modelToEditPart = new HashMap();
List children = getChildren();
for (i = 0; i < children.size(); i++) {
editPart = (EditPart)children.get(i);
modelToEditPart.put(editPart.getModel(), editPart);
}
List modelObjects = getModelChildren();
for (i = 0; i < modelObjects.size(); i++) {
model = modelObjects.get(i);
if (i < children.size()
&& ((EditPart) children.get(i)).getModel() == model)
continue;
//Look to see if the EditPart is already around but in the wrong location
editPart = (EditPart)modelToEditPart.get(model);
if (editPart != null)
reorderChild (editPart, i);
else {
//An editpart for this model doesn't exist yet. Create and insert one.
editPart = createChild(model);
addChild(editPart, i);
}
}
List trash = new ArrayList();
for (; i < children.size(); i++)
trash.add(children.get(i));
for (i = 0; i < trash.size(); i++) {
EditPart ep = (EditPart)trash.get(i);
removeChild(ep);
}
}
|
|
|
Re: Get the EditPart from the Model [message #149406 is a reply to message #149159] |
Thu, 06 September 2007 07:19  |
Eclipse User |
|
|
|
Hi Arpit,
Take a look at class org.eclipse.gef.ui.parts.SelectionSynchronizer.
Best regards,
Boris
Arpit wrote:
> Hi all,
>
> I am trying to create my own OutlineView for my GMF project.
> I have succeded in showing the elements in the outline View along with
> the icons and labels.
>
> My problem is when i click on any of the element in the tree viewer it
> does not select the same element on my canvas.Rather it always selects
> the root.
>
> While debugging i found out that following code is present in the class
> AbstractEditPart :-
>
> protected void refreshChildren() {
> ...
>
> Map modelToEditPart = new HashMap();
> List children = getChildren();
>
> for (i = 0; i < children.size(); i++) {
> editPart = (EditPart)children.get(i);
> modelToEditPart.put(editPart.getModel(), editPart);
> }
>
> List modelObjects = getModelChildren();
>
> for (i = 0; i < modelObjects.size(); i++) {
> model = modelObjects.get(i);
> if (i < children.size()
> && ((EditPart) children.get(i)).getModel() == model)
> continue;
>
> //Look to see if the EditPart is already around but in the wrong
> location
> editPart = (EditPart)modelToEditPart.get(model);
>
> if (editPart != null)
> reorderChild (editPart, i);
> else {
> //An editpart for this model doesn't exist yet. Create and
> insert one.
> editPart = createChild(model);
> addChild(editPart, i);
> }
> }
> List trash = new ArrayList();
> for (; i < children.size(); i++)
> trash.add(children.get(i));
> for (i = 0; i < trash.size(); i++) {
> EditPart ep = (EditPart)trash.get(i);
> removeChild(ep);
> }
> }
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.24384 seconds