Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » refreshing EditParts
refreshing EditParts [message #200304] Fri, 21 October 2005 14:17 Go to next message
Eclipse UserFriend
Originally posted by: jgreen.upb.de

Hi,
I have another EditPart refresh problem. I thought I understood it all
well, but I still can't figure out, why the following doesn't work:

I have something like an editor for tracks of a toy train, these can
snap together an then the anchors/ports/snap-points (whatever you name
it) should appear to be deactivated, set to a gray filling. These ports
are child-EditParts that implement an extra method

public void setDeactivated(boolean deact) {
if (deactivated != deact){
deactivated = deact;
refreshVisuals();
}
}
so, the deactivation state is not in the model, but in the EditPart.
refreshVisuals() changes the Figure:
....
if (deactivated)
getFigure().setBackgroundColor(gray);
getFigure().setForegroundColor(gray);
}else{
getFigure().setBackgroundColor(getBackgroundColor());
getFigure().setForegroundColor(getColor());
}
Rectangle r = new Rectangle(getLocation(),getSize());
((ComponentInstanceViewEditPart)getParent()).setLayoutConstr aint(this,
getFigure(), r);
....

the setDeactivated() method is directly invoked by the
ChangePositionCommand that changes the position of the parent-EditPart.
That's where the snapping/unsnapping is performed, too. I know that I
should rather perform changes on the model, but so far I saw no problem
doing it this way. - And it works if I drag and snap/unsnap the
track-EditParts. BUT, if I perform an undo, the figures are not
refreshed correctly even though the refreshVisuals()-method is called
with the right values. Do I have to trigger more refreshs, repaints?

Any suggestions, solutions, opinions?
Thanks a lot

Joel
Re: refreshing EditParts [message #200329 is a reply to message #200304] Fri, 21 October 2005 16:53 Go to previous message
Felix L J Mayer is currently offline Felix L J MayerFriend
Messages: 202
Registered: July 2009
Senior Member
One possibility is that this is caused by undo() executing commands in
reverse order, thereby overwriting whatever your call to refreshVisuals()
does. You might have to look at the entire undo() process; I use logging a
lot for things like that.

"Joel Greenyer" <jgreen@upb.de> wrote in message
news:djatgk$8kn$1@news.eclipse.org...
> Hi,
> I have another EditPart refresh problem. I thought I understood it all
> well, but I still can't figure out, why the following doesn't work:
>
> I have something like an editor for tracks of a toy train, these can snap
> together an then the anchors/ports/snap-points (whatever you name it)
> should appear to be deactivated, set to a gray filling. These ports are
> child-EditParts that implement an extra method
>
> public void setDeactivated(boolean deact) {
> if (deactivated != deact){
> deactivated = deact;
> refreshVisuals();
> }
> }
> so, the deactivation state is not in the model, but in the EditPart.
> refreshVisuals() changes the Figure:
> ...
> if (deactivated)
> getFigure().setBackgroundColor(gray);
> getFigure().setForegroundColor(gray);
> }else{
> getFigure().setBackgroundColor(getBackgroundColor());
> getFigure().setForegroundColor(getColor());
> }
> Rectangle r = new Rectangle(getLocation(),getSize());
> ((ComponentInstanceViewEditPart)getParent()).setLayoutConstr aint(this,
> getFigure(), r);
> ...
>
> the setDeactivated() method is directly invoked by the
> ChangePositionCommand that changes the position of the parent-EditPart.
> That's where the snapping/unsnapping is performed, too. I know that I
> should rather perform changes on the model, but so far I saw no problem
> doing it this way. - And it works if I drag and snap/unsnap the
> track-EditParts. BUT, if I perform an undo, the figures are not refreshed
> correctly even though the refreshVisuals()-method is called with the right
> values. Do I have to trigger more refreshs, repaints?
>
> Any suggestions, solutions, opinions?
> Thanks a lot
>
> Joel
Previous Topic:Connections stop one pixel short of node
Next Topic:Palette Viewer Exception
Goto Forum:
  


Current Time: Fri Apr 19 16:52:28 GMT 2024

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

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

Back to the top