| rcp application and editor ... [message #497073] |
Thu, 12 November 2009 08:02  |
Carmelo Messages: 224 Registered: July 2009 |
Senior Member |
|
|
Hi all,
I have an rcp application that use the ide open editor to edit external file
....
if I have dirty editor I will get the right message asking to save before
the application closes ...
what I don't wont is to find the editor opened again when the application is
restarted ...
where do I need to add the listener to check if there are still opened
editors before everything gets closed...
I have tried in the stop (Activator - abstractui plugin) with no result ...
probably I should play somewhere in the Application ... but I guess it will
be to late there to get some available page and from there list the editors
and close it ...
so what I would love is to be able to close the application and reopened it
again with NO EDITOR opened ...
thanks
Kar
|
|
|
| Re: rcp application and editor ... [message #497097 is a reply to message #497073] |
Thu, 12 November 2009 08:39   |
|
Originally posted by: wangqs_eclipse.yahoo.com
In your WorkbenchAdvisor::initialize method, call
configurer.setSaveAndRestore(false). This will disable the workbench
saving the state when existing.
Q.S.
Kar wrote:
> Hi all,
> I have an rcp application that use the ide open editor to edit external
> file ...
>
> if I have dirty editor I will get the right message asking to save
> before the application closes ...
> what I don't wont is to find the editor opened again when the
> application is restarted ...
>
> where do I need to add the listener to check if there are still opened
> editors before everything gets closed...
>
> I have tried in the stop (Activator - abstractui plugin) with no result
> ... probably I should play somewhere in the Application ... but I guess
> it will be to late there to get some available page and from there list
> the editors and close it ...
>
> so what I would love is to be able to close the application and reopened
> it again with NO EDITOR opened ...
>
> thanks
> Kar
>
>
|
|
|
|
|
| Re: rcp application and editor ... [message #498237 is a reply to message #497844] |
Sun, 15 November 2009 23:13   |
|
Originally posted by: wangqs_eclipse.yahoo.com
Kar wrote:
> Hi Wang,
> I know that ... but this means that even all the rearranged views will
> be dismissed and I don't want this :(
>
> any idea
>
> "Wang Q.S" <wangqs_eclipse@yahoo.com> wrote in message
> news:hdh35u$j42$1@build.eclipse.org...
>> In your WorkbenchAdvisor::initialize method, call
>> configurer.setSaveAndRestore(false). This will disable the workbench
>> saving the state when existing.
>>
>> Q.S.
>>
>>
>> Kar wrote:
>>> Hi all,
>>> I have an rcp application that use the ide open editor to edit
>>> external file ...
>>>
>>> if I have dirty editor I will get the right message asking to save
>>> before the application closes ...
>>> what I don't wont is to find the editor opened again when the
>>> application is restarted ...
>>>
>>> where do I need to add the listener to check if there are still
>>> opened editors before everything gets closed...
>>>
>>> I have tried in the stop (Activator - abstractui plugin) with no
>>> result ... probably I should play somewhere in the Application ...
>>> but I guess it will be to late there to get some available page and
>>> from there list the editors and close it ...
>>>
>>> so what I would love is to be able to close the application and
>>> reopened it again with NO EDITOR opened ...
>>>
>>> thanks
>>> Kar
>>>
>>>
You can try to open all the editor as Wim said in his message.
Or you can access the memento directly
IPath path = WorkbenchPlugin.getDefault().getDataLocation();
path = path.append("workbench.xml");
File stateFile = path.toFile();
FileInputStream input = new FileInputStream(stateFile);
BufferedReader reader = new BufferedReader(
new InputStreamReader(input, "utf-8")); //$NON-NLS-1$
IMemento memento = XMLMemento.createReadRoot(reader);
and delete all editor references under tag IWorkbenchConstants.TAG_EDITOR
Q.S Wang
http://www.myeclipsedev.com/
|
|
|
|
|
|
| Re: rcp application and editor ... [message #498665 is a reply to message #498564] |
Tue, 17 November 2009 18:25   |
|
Originally posted by: wangqs_eclipse.yahoo.com
Kar wrote:
> sorry for the delay in answering and thank u all for the replays ...
>
> BUT STILL I HAVE THE PROBLEM :-(
>
> so the only place where the test works fine is inside the preShutdown
> ... but
> let's say u have a few editors opened and dirty ... the preShutdown will
> be called before the save dialog will be displayed so I have to force to
> discar or save without even asking the user ...
>
> same thing if I the closing editors will be performed inside the
> preWindowShellClose
>
> the only place where I will get the dialog correctly displayed (so that
> I can save or discard changes) is inside the saveState ... I can close
> the editors correctly ...
> but I guess the memento have already been written and when I restart the
> rcp application I will get the editors opened again :-(
>
> what can I try ???
>
> in the meantime I will see if I can access the memento and modify it
> manually
>
> Thanks all of u
>
> Kar
>
>
>
> "Paul Webster" <pwebster@ca.ibm.com> wrote in message
> news:hdrlvi$4hr$1@build.eclipse.org...
>> Eclipse User wrote on Sun, 15 November 2009 23:13
>>> Originally posted by: wangqs_eclipse.yahoo.com
>>> You can try to open all the editor as Wim said in his message.
>>>
>>> Or you can access the memento directly
>>>
>>> IPath path = WorkbenchPlugin.getDefault().getDataLocation();
>>>
>>> path = path.append("workbench.xml");
>>> File stateFile = path.toFile();
>>>
>>> FileInputStream input = new FileInputStream(stateFile);
>>> BufferedReader reader = new BufferedReader(
>>> new InputStreamReader(input, "utf-8")); //$NON-NLS-1$
>>> IMemento memento = XMLMemento.createReadRoot(reader);
>>>
>>>
>>> and delete all editor references under tag
>>> IWorkbenchConstants.TAG_EDITOR
>>>
>>> Q.S Wang
>>> http://www.myeclipsedev.com/
>>
>>
>> Here be dragons. Just a note that this is not guaranteed to be the
>> same even between maintenance releases (3.5.0 to 3.5.1 for example).
>> This is considered hacking the internals.
>>
>> PW
>>
>>
>> --
>> Paul Webster
>> http://wiki.eclipse.org/Platform_Command_Framework
>> http://wiki.eclipse.org/Command_Core_Expressions
>> http://wiki.eclipse.org/Menu_Contributions
>
After the memento have been saved, you can access the memento file and
delete the whole editor node. You don't need do it at the closing stage
if you can't find the right place, but do it in pre-startup or wherever
fit to your requirements. The deleting just need be done before the
workbench tried to restore the editors.
But remember as what Paul said, assessing the memento file is kinds of
hacking way.
Q.S. Wang
--
http://www.myeclipsedev.com/
|
|
|
| Re: rcp application and editor ... [message #498696 is a reply to message #498665] |
Wed, 18 November 2009 03:36  |
Carmelo Messages: 224 Registered: July 2009 |
Senior Member |
|
|
I did check yesterday a bit better and the saveState is actually empty when
I start closing the editors ... probably the editor registry doesn't get
correctly updated when the shutdown process as already started ... and
that's why even if I close them they will be reopened afterwards.
so I guess I will clean up the memento on the startup phase avoiding even to
close the editors as they will be closed anyway during the editor dispose.
I know that this will probably change with new releases but for now I guess
this is the only solution I have got left.
thanks u all guys
Ciao
Carmelo
"Wang Q.S" <wangqs_eclipse@yahoo.com> wrote in message
news:hdvbce$ii2$1@build.eclipse.org...
> Kar wrote:
>> sorry for the delay in answering and thank u all for the replays ...
>>
>> BUT STILL I HAVE THE PROBLEM :-(
>>
>> so the only place where the test works fine is inside the preShutdown ...
>> but
>> let's say u have a few editors opened and dirty ... the preShutdown will
>> be called before the save dialog will be displayed so I have to force to
>> discar or save without even asking the user ...
>>
>> same thing if I the closing editors will be performed inside the
>> preWindowShellClose
>>
>> the only place where I will get the dialog correctly displayed (so that I
>> can save or discard changes) is inside the saveState ... I can close the
>> editors correctly ...
>> but I guess the memento have already been written and when I restart the
>> rcp application I will get the editors opened again :-(
>>
>> what can I try ???
>>
>> in the meantime I will see if I can access the memento and modify it
>> manually
>>
>> Thanks all of u
>>
>> Kar
>>
>>
>>
>> "Paul Webster" <pwebster@ca.ibm.com> wrote in message
>> news:hdrlvi$4hr$1@build.eclipse.org...
>>> Eclipse User wrote on Sun, 15 November 2009 23:13
>>>> Originally posted by: wangqs_eclipse.yahoo.com
>>>> You can try to open all the editor as Wim said in his message.
>>>>
>>>> Or you can access the memento directly
>>>>
>>>> IPath path = WorkbenchPlugin.getDefault().getDataLocation();
>>>>
>>>> path = path.append("workbench.xml");
>>>> File stateFile = path.toFile();
>>>>
>>>> FileInputStream input = new FileInputStream(stateFile);
>>>> BufferedReader reader = new BufferedReader(
>>>> new InputStreamReader(input, "utf-8")); //$NON-NLS-1$
>>>> IMemento memento = XMLMemento.createReadRoot(reader);
>>>>
>>>>
>>>> and delete all editor references under tag
>>>> IWorkbenchConstants.TAG_EDITOR
>>>>
>>>> Q.S Wang
>>>> http://www.myeclipsedev.com/
>>>
>>>
>>> Here be dragons. Just a note that this is not guaranteed to be the same
>>> even between maintenance releases (3.5.0 to 3.5.1 for example). This is
>>> considered hacking the internals.
>>>
>>> PW
>>>
>>>
>>> --
>>> Paul Webster
>>> http://wiki.eclipse.org/Platform_Command_Framework
>>> http://wiki.eclipse.org/Command_Core_Expressions
>>> http://wiki.eclipse.org/Menu_Contributions
>>
>
>
> After the memento have been saved, you can access the memento file and
> delete the whole editor node. You don't need do it at the closing stage if
> you can't find the right place, but do it in pre-startup or wherever fit
> to your requirements. The deleting just need be done before the workbench
> tried to restore the editors.
>
> But remember as what Paul said, assessing the memento file is kinds of
> hacking way.
>
> Q.S. Wang
>
> --
> http://www.myeclipsedev.com/
|
|
|
Powered by
FUDForum. Page generated in 0.06023 seconds