Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Get the EditPart from the Model
Get the EditPart from the Model [message #149159] Thu, 06 September 2007 07:22 Go to next message
Arpit Khandelwal is currently offline Arpit KhandelwalFriend
Messages: 28
Registered: July 2009
Junior Member
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 11:19 Go to previous message
Boris Blajer is currently offline Boris BlajerFriend
Messages: 217
Registered: July 2009
Senior Member
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);
> }
> }
>
>
Previous Topic:Compartment and Generalization
Next Topic:export: Deployable plug-ins and fragments fails to create correct jar
Goto Forum:
  


Current Time: Sun Oct 20 05:08:06 GMT 2024

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

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

Back to the top