|
Re: rcp application and editor ... [message #497097 is a reply to message #497073] |
Thu, 12 November 2009 13:39 |
Eclipse User |
|
|
|
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] |
Mon, 16 November 2009 04:13 |
Eclipse User |
|
|
|
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 23:25 |
Eclipse User |
|
|
|
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/
|
|
|
|
Powered by
FUDForum. Page generated in 0.04948 seconds