Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » rcp application and editor ...
rcp application and editor ... [message #497073] Thu, 12 November 2009 08:02 Go to next message
Carmelo  is currently offline 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 Go to previous messageGo to next message
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 #497844 is a reply to message #497097] Fri, 13 November 2009 08:18 Go to previous messageGo to next message
Carmelo  is currently offline Carmelo
Messages: 224
Registered: July 2009
Senior Member
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
>>
>>
Re: rcp application and editor ... [message #498082 is a reply to message #497844] Sat, 14 November 2009 06:29 Go to previous messageGo to next message
Wim Jongman is currently offline Wim Jongman
Messages: 418
Registered: July 2009
Senior Member
Hi Q.S.,

In one of the windowadvisor classes savestate method you can close all the
editors.

getWindowConfigurer().getWindow().getActivePage().getEditorR eferences();

You might want to run over all pages and not just the active page...

Regards,

Wim

> 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
>>>
>>>
Re: rcp application and editor ... [message #498237 is a reply to message #497844] Sun, 15 November 2009 23:13 Go to previous messageGo to next message
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 #498330 is a reply to message #498237] Mon, 16 November 2009 09:01 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

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



Re: rcp application and editor ... [message #498332 is a reply to message #498082] Mon, 16 November 2009 09:05 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Wim Jongman wrote on Sat, 14 November 2009 06:29
Hi Q.S.,

In one of the windowadvisor classes savestate method you can close all the
editors.

getWindowConfigurer().getWindow().getActivePage().getEditorR eferences();

You might want to run over all pages and not just the active page...




What Wim suggests is probably your best bet.

I would try in the WorkbenchWindowAdvisor preClose methods, and if they aren't complete enough then try org.eclipse.ui.application.WorkbenchAdvisor.preShutdown()

If your RCP app only has one window, then you just have to walk one window/one active page.

PW


Re: rcp application and editor ... [message #498564 is a reply to message #498330] Tue, 17 November 2009 09:28 Go to previous messageGo to next message
Carmelo  is currently offline Carmelo
Messages: 224
Registered: July 2009
Senior Member
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
Re: rcp application and editor ... [message #498665 is a reply to message #498564] Tue, 17 November 2009 18:25 Go to previous messageGo to next message
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/
Re: rcp application and editor ... [message #498696 is a reply to message #498665] Wed, 18 November 2009 03:36 Go to previous message
Carmelo  is currently offline 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/
Previous Topic:Get LabelProvider from active View
Next Topic:DateTime control in CellEditor Example
Goto Forum:
  


Current Time: Wed Aug 20 03:02:40 EDT 2014

Powered by FUDForum. Page generated in 0.02866 seconds