How do I know if Save button is pressed? [message #330929] |
Mon, 18 August 2008 07:11  |
Eclipse User |
|
|
|
Hello,
How do I come to know if user presses 'Save' button in Eclipse IDE?
Is there any listener or some other place where I get a notification about
the save button having been pressed?
Please guide.
Thanks.
|
|
|
Re: How do I know if Save button is pressed? [message #330930 is a reply to message #330929] |
Mon, 18 August 2008 09:47   |
Eclipse User |
|
|
|
On Mon, 18 Aug 2008 07:11:10 +0000 (UTC), kaprasannagt@gmail.com
(kaprasanna) wrote:
>Hello,
>
>How do I come to know if user presses 'Save' button in Eclipse IDE?
>Is there any listener or some other place where I get a notification about
>the save button having been pressed?
>Please guide.
>
>Thanks.
I assume you are talking about saving an editor. You save your editor
by implementing IEditorPart (which comes for free if you subclass your
editor from EditorPart). You have to implement the save() and saveAs()
methods.
If you are not using an editor it should be sufficient to implement
ISaveablePart where the save/saveAs methods are introduced.
Achim
--
Achim Lörke
Eclipse-Stammtisch in the Braunschweig, Germany area:
http://www.bredex.de/de/news/events.html
|
|
|
|
Re: How do I know if Save button is pressed? [message #330951 is a reply to message #330938] |
Tue, 19 August 2008 13:25   |
Eclipse User |
|
|
|
Hi,
Thanks for the replies.
I am indeed using Eclipse 3.3.2.
I tried with ISaveablePart but it doesn't allow me to save some swing
components which are on top of a view.
As in, when some change happens (say in a text field), I'd like to have
the save button on the toolbar to be enabled and then I can take action in
the doSave() method.
What's the solution?
Thanks in advance.
|
|
|
|
Re: How do I know if Save button is pressed? [message #330979 is a reply to message #330957] |
Wed, 20 August 2008 10:55   |
Eclipse User |
|
|
|
Hi Paul,
My view implements ISaveablePart so I implement following methods :
isSaveOnCloseNeeded, isDirty, doSave.
Save on close works just great..
Problem is I can't get the save buton to be enabled on demand. This is how
isDirty() looks like :
public boolean isDirty () {
if(something) {
firePropertyChange(PROP_DIRTY);
return true;
}
else
return false;
}
Not only the save button doesn't get enabled, I get this error : unhandled
event loop exception java.lang.StackOverFlow at the firePropertyChange()
line.
What is wrong? What I must be doing?
Please guide.
Thanks.
|
|
|
Re: How do I know if Save button is pressed? [message #330983 is a reply to message #330979] |
Wed, 20 August 2008 13:32   |
Eclipse User |
|
|
|
On Wed, 20 Aug 2008 10:55:57 +0000 (UTC), kaprasannagt@gmail.com
(kaprasanna) wrote:
>Hi Paul,
>
>My view implements ISaveablePart so I implement following methods :
>isSaveOnCloseNeeded, isDirty, doSave.
>Save on close works just great..
>Problem is I can't get the save buton to be enabled on demand. This is how
>isDirty() looks like :
>
> ...
>
>Not only the save button doesn't get enabled, I get this error : unhandled
>event loop exception java.lang.StackOverFlow at the firePropertyChange()
>line.
>
>What is wrong? What I must be doing?
>Please guide.
>
>Thanks.
You should implement something like
private boolean isDirty = false;
public boolean isDirty() {
return isDirty;
}
public void setDirty(boolean dirty) {
isDirty = dirty;
firePropertyChange(PROP_DIRTY);
}
firePropertyChange() whill notify the platform which will in turn call
isDirty() to get the dirty state. Using your implementation triggers
another property change and therefore goes into an indefinite
recursion.
Achim
--
Achim Lörke
Eclipse-Stammtisch in the Braunschweig, Germany area:
http://www.bredex.de/de/news/events.html
|
|
|
|
Powered by
FUDForum. Page generated in 0.09841 seconds