Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Problems while saving/closing an editor
Problems while saving/closing an editor [message #175098] Sat, 02 April 2005 12:40 Go to next message
Eclipse UserFriend
Originally posted by: tuhlmann.gmx.de

Hi,

in my model I have properties that can be changed through the Eclipse
Property view. If a propertiy is changed it fire an event so the edit
part can refresh. This works fine.

When I save the editor that also works without problems. The asterisk in
the editor label disappears.

When I then try and close the editor the asterisk suddenly reappears and
the editor ask if I want to save changes.

This beaviour seems to only occur when I change properties. When I move
a figure, resize it or edit connections everything works fine.

Do you have an idea where I can look for the problem. I'm sure it's my
mistake and I simply forgot to inform some mechanism...

thanks for your help,
Torsten.
Re: Problems while saving/closing an editor [message #175215 is a reply to message #175098] Mon, 04 April 2005 03:23 Go to previous messageGo to next message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
What does your editor's isDirty() method do? In commandStackChanged(), I
take it you're firing IEditorPart.PROP_DIRTY.

"Torsten Uhlmann" <tuhlmann@gmx.de> wrote in message
news:d2m40a$694$1@news.eclipse.org...
> Hi,
>
> in my model I have properties that can be changed through the Eclipse
> Property view. If a propertiy is changed it fire an event so the edit
> part can refresh. This works fine.
>
> When I save the editor that also works without problems. The asterisk in
> the editor label disappears.
>
> When I then try and close the editor the asterisk suddenly reappears and
> the editor ask if I want to save changes.
>
> This beaviour seems to only occur when I change properties. When I move
> a figure, resize it or edit connections everything works fine.
>
> Do you have an idea where I can look for the problem. I'm sure it's my
> mistake and I simply forgot to inform some mechanism...
>
> thanks for your help,
> Torsten.
Re: Problems while saving/closing an editor [message #175247 is a reply to message #175215] Mon, 04 April 2005 06:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tuhlmann.gmx.de

The code there looks as follow:

public void commandStackChanged(EventObject event)
{
super.commandStackChanged(event);
setDirty(getCommandStack().isDirty());
}

public void setDirty(boolean dirty)
{
if (isDirty != dirty)
{
isDirty = dirty;
firePropertyChange(IEditorPart.PROP_DIRTY);
}
}

public boolean isDirty()
{
return isDirty || getCommandStack().isDirty();
}

Is this ok? What else do I need to watch out for?

Torsten.

Pratik Shah wrote:
> What does your editor's isDirty() method do? In commandStackChanged(), I
> take it you're firing IEditorPart.PROP_DIRTY.
>
> "Torsten Uhlmann" <tuhlmann@gmx.de> wrote in message
> news:d2m40a$694$1@news.eclipse.org...
>
>>Hi,
>>
>>in my model I have properties that can be changed through the Eclipse
>>Property view. If a propertiy is changed it fire an event so the edit
>>part can refresh. This works fine.
>>
>>When I save the editor that also works without problems. The asterisk in
>>the editor label disappears.
>>
>>When I then try and close the editor the asterisk suddenly reappears and
>>the editor ask if I want to save changes.
>>
>>This beaviour seems to only occur when I change properties. When I move
>>a figure, resize it or edit connections everything works fine.
>>
>>Do you have an idea where I can look for the problem. I'm sure it's my
>>mistake and I simply forgot to inform some mechanism...
>>
>>thanks for your help,
>>Torsten.
>
>
>
Re: Problems while saving/closing an editor [message #175473 is a reply to message #175247] Mon, 04 April 2005 21:38 Go to previous messageGo to next message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
Try doing what ShapesEditor and EDiagramEditor do:

public void commandStackChanged(EventObject event) {
firePropertyChange(IEditorPart.PROP_DIRTY);
super.commandStackChanged(event);
}
public boolean isDirty() {
return getCommandStack().isDirty();
}

BTW, with the latest code, you don't need to override the isDirty() method
(GraphicalEditor does that).

"Torsten Uhlmann" <tuhlmann@gmx.de> wrote in message
news:d2qnmb$4gr$1@news.eclipse.org...
> The code there looks as follow:
>
> public void commandStackChanged(EventObject event)
> {
> super.commandStackChanged(event);
> setDirty(getCommandStack().isDirty());
> }
>
> public void setDirty(boolean dirty)
> {
> if (isDirty != dirty)
> {
> isDirty = dirty;
> firePropertyChange(IEditorPart.PROP_DIRTY);
> }
> }
>
> public boolean isDirty()
> {
> return isDirty || getCommandStack().isDirty();
> }
>
> Is this ok? What else do I need to watch out for?
>
> Torsten.
>
> Pratik Shah wrote:
> > What does your editor's isDirty() method do? In commandStackChanged(),
I
> > take it you're firing IEditorPart.PROP_DIRTY.
> >
> > "Torsten Uhlmann" <tuhlmann@gmx.de> wrote in message
> > news:d2m40a$694$1@news.eclipse.org...
> >
> >>Hi,
> >>
> >>in my model I have properties that can be changed through the Eclipse
> >>Property view. If a propertiy is changed it fire an event so the edit
> >>part can refresh. This works fine.
> >>
> >>When I save the editor that also works without problems. The asterisk in
> >>the editor label disappears.
> >>
> >>When I then try and close the editor the asterisk suddenly reappears and
> >>the editor ask if I want to save changes.
> >>
> >>This beaviour seems to only occur when I change properties. When I move
> >>a figure, resize it or edit connections everything works fine.
> >>
> >>Do you have an idea where I can look for the problem. I'm sure it's my
> >>mistake and I simply forgot to inform some mechanism...
> >>
> >>thanks for your help,
> >>Torsten.
> >
> >
> >
Re: Problems while saving/closing an editor [message #175577 is a reply to message #175473] Tue, 05 April 2005 09:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tuhlmann.gmx.de

Sorry, that doesn't help. But I found out a bit more. It has to do with
which object is selected:

Say I only display one of my elements (compound figure with one label
and an image). I change the font of the label (the editor is marked as
dirty), then WHILE THE FIGURE IS STILL SELECTED I save the editor
(asterisk disappears). When I then click in the background (selecting
the content editpart) the asterisk reappears and the editor is again
marked as dirty.

When I repeat the same scenario with the exception that after changing
the font a select the content editpart and THEN SAVE the editor, I can
close the editor or do what I want, the asterisk will not reappear.

This behaviours only occurs with two of the complex figures, it does not
occur with a simple image (ImageFigure) or the StickyNote figure.

I have verified that the changes get persisted after the first save
operation, so the second must be triggered by some subsequent event. I
just don't know where it could come from.

I hope you got an idea, mine are gone :)

Torsten.

Pratik Shah wrote:
> Try doing what ShapesEditor and EDiagramEditor do:
>
> public void commandStackChanged(EventObject event) {
> firePropertyChange(IEditorPart.PROP_DIRTY);
> super.commandStackChanged(event);
> }
> public boolean isDirty() {
> return getCommandStack().isDirty();
> }
>
> BTW, with the latest code, you don't need to override the isDirty() method
> (GraphicalEditor does that).
>
> "Torsten Uhlmann" <tuhlmann@gmx.de> wrote in message
> news:d2qnmb$4gr$1@news.eclipse.org...
>
>>The code there looks as follow:
>>
>>public void commandStackChanged(EventObject event)
>>{
>> super.commandStackChanged(event);
>> setDirty(getCommandStack().isDirty());
>>}
>>
>>public void setDirty(boolean dirty)
>>{
>> if (isDirty != dirty)
>> {
>> isDirty = dirty;
>> firePropertyChange(IEditorPart.PROP_DIRTY);
>> }
>>}
>>
>>public boolean isDirty()
>>{
>> return isDirty || getCommandStack().isDirty();
>>}
>>
>>Is this ok? What else do I need to watch out for?
>>
>>Torsten.
>>
>>Pratik Shah wrote:
>>
>>>What does your editor's isDirty() method do? In commandStackChanged(),
>
> I
>
>>>take it you're firing IEditorPart.PROP_DIRTY.
>>>
>>>"Torsten Uhlmann" <tuhlmann@gmx.de> wrote in message
>>>news:d2m40a$694$1@news.eclipse.org...
>>>
>>>
>>>>Hi,
>>>>
>>>>in my model I have properties that can be changed through the Eclipse
>>>>Property view. If a propertiy is changed it fire an event so the edit
>>>>part can refresh. This works fine.
>>>>
>>>>When I save the editor that also works without problems. The asterisk in
>>>>the editor label disappears.
>>>>
>>>>When I then try and close the editor the asterisk suddenly reappears and
>>>>the editor ask if I want to save changes.
>>>>
>>>>This beaviour seems to only occur when I change properties. When I move
>>>>a figure, resize it or edit connections everything works fine.
>>>>
>>>>Do you have an idea where I can look for the problem. I'm sure it's my
>>>>mistake and I simply forgot to inform some mechanism...
>>>>
>>>>thanks for your help,
>>>>Torsten.
>>>
>>>
>>>
>
>
Re: Problems while saving/closing an editor [message #175639 is a reply to message #175577] Tue, 05 April 2005 17:38 Go to previous message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
After you've selected the first figure, and changed the font, and saved the
diagram, set a breakpoint in setDirty(). Then click on the background in
the editor. Selection change should not cause a command to be executed or
the diagram to become dirty.

"Torsten Uhlmann" <tuhlmann@gmx.de> wrote in message
news:d2tlqc$c3b$1@news.eclipse.org...
> Sorry, that doesn't help. But I found out a bit more. It has to do with
> which object is selected:
>
> Say I only display one of my elements (compound figure with one label
> and an image). I change the font of the label (the editor is marked as
> dirty), then WHILE THE FIGURE IS STILL SELECTED I save the editor
> (asterisk disappears). When I then click in the background (selecting
> the content editpart) the asterisk reappears and the editor is again
> marked as dirty.
>
> When I repeat the same scenario with the exception that after changing
> the font a select the content editpart and THEN SAVE the editor, I can
> close the editor or do what I want, the asterisk will not reappear.
>
> This behaviours only occurs with two of the complex figures, it does not
> occur with a simple image (ImageFigure) or the StickyNote figure.
>
> I have verified that the changes get persisted after the first save
> operation, so the second must be triggered by some subsequent event. I
> just don't know where it could come from.
>
> I hope you got an idea, mine are gone :)
>
> Torsten.
>
> Pratik Shah wrote:
> > Try doing what ShapesEditor and EDiagramEditor do:
> >
> > public void commandStackChanged(EventObject event) {
> > firePropertyChange(IEditorPart.PROP_DIRTY);
> > super.commandStackChanged(event);
> > }
> > public boolean isDirty() {
> > return getCommandStack().isDirty();
> > }
> >
> > BTW, with the latest code, you don't need to override the isDirty()
method
> > (GraphicalEditor does that).
> >
> > "Torsten Uhlmann" <tuhlmann@gmx.de> wrote in message
> > news:d2qnmb$4gr$1@news.eclipse.org...
> >
> >>The code there looks as follow:
> >>
> >>public void commandStackChanged(EventObject event)
> >>{
> >> super.commandStackChanged(event);
> >> setDirty(getCommandStack().isDirty());
> >>}
> >>
> >>public void setDirty(boolean dirty)
> >>{
> >> if (isDirty != dirty)
> >> {
> >> isDirty = dirty;
> >> firePropertyChange(IEditorPart.PROP_DIRTY);
> >> }
> >>}
> >>
> >>public boolean isDirty()
> >>{
> >> return isDirty || getCommandStack().isDirty();
> >>}
> >>
> >>Is this ok? What else do I need to watch out for?
> >>
> >>Torsten.
> >>
> >>Pratik Shah wrote:
> >>
> >>>What does your editor's isDirty() method do? In commandStackChanged(),
> >
> > I
> >
> >>>take it you're firing IEditorPart.PROP_DIRTY.
> >>>
> >>>"Torsten Uhlmann" <tuhlmann@gmx.de> wrote in message
> >>>news:d2m40a$694$1@news.eclipse.org...
> >>>
> >>>
> >>>>Hi,
> >>>>
> >>>>in my model I have properties that can be changed through the Eclipse
> >>>>Property view. If a propertiy is changed it fire an event so the edit
> >>>>part can refresh. This works fine.
> >>>>
> >>>>When I save the editor that also works without problems. The asterisk
in
> >>>>the editor label disappears.
> >>>>
> >>>>When I then try and close the editor the asterisk suddenly reappears
and
> >>>>the editor ask if I want to save changes.
> >>>>
> >>>>This beaviour seems to only occur when I change properties. When I
move
> >>>>a figure, resize it or edit connections everything works fine.
> >>>>
> >>>>Do you have an idea where I can look for the problem. I'm sure it's my
> >>>>mistake and I simply forgot to inform some mechanism...
> >>>>
> >>>>thanks for your help,
> >>>>Torsten.
> >>>
> >>>
> >>>
> >
> >
Previous Topic:Export graphic to a file
Next Topic:How to refresh a View
Goto Forum:
  


Current Time: Mon Jan 30 12:38:34 GMT 2023

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

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

Back to the top