Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Workspace save participation
Workspace save participation [message #328455] Sun, 25 May 2008 15:51 Go to next message
Lars Vogel is currently offline Lars VogelFriend
Messages: 1098
Registered: July 2009
Senior Member

Hi,

I tried to follow the Eclipse Help for participating with a RCP application
in the workbench saving.

http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/resAdv_saving.htmIn my RCP application I adjusted the start method in the class Activator (please see below for the coding). Here I register the classMyWorkspaceSaveParticipant. I checked the class SaveManager and can see thatit is registered.But during shutdown the saving method in MyWorkspaceSaveParticipant is notcalled.Do I have to do do something else, e.g. set the changed status of my pluginsomewhere?Best regards, Larspublic void start(BundleContext context) throws Exception {super.start(context);plugin = this;saveParticipant = new MyWorkspaceSaveParticipant(plugin);ISavedState lastState = ResourcesPlugin.getWorkspace().addSaveParticipant(plugin, saveParticipant);if (lastState == null)return;IPath location = lastState.lookup(new Path("save"));if (location == null)return;// the plugin instance should read any important state from the file.File f = getStateLocation().append(location).toFile();readStateFrom(f );}
Re: Workspace save participation [message #328504 is a reply to message #328455] Mon, 26 May 2008 19:02 Go to previous messageGo to next message
Rahul Kamdar is currently offline Rahul KamdarFriend
Messages: 63
Registered: July 2009
Member
I also use Workspace save participation and referred to the same article.
Why your saveParticipant is not getting called inspite of registering it
with the workspace initially probably might depend on your implementation of
the "saving" method of the class ISavedParticipant. Maybe you could post
that part here and someone could help you better.

Rahul

"Lars Vogel" <Lars.Vogel@gmail.com> wrote in message
news:g1c1uc$9bv$1@build.eclipse.org...
> Hi,
>
> I tried to follow the Eclipse Help for participating with a RCP
> application in the workbench saving.
>
> http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/resAdv_saving.htmIn
> my RCP application I adjusted the start method in the class Activator
> (please see below for the coding). Here I register the
> classMyWorkspaceSaveParticipant. I checked the class SaveManager and can
> see thatit is registered.But during shutdown the saving method in
> MyWorkspaceSaveParticipant is notcalled.Do I have to do do something else,
> e.g. set the changed status of my pluginsomewhere?Best regards, Larspublic
> void start(BundleContext context) throws Exception
> {super.start(context);plugin = this;saveParticipant = new
> MyWorkspaceSaveParticipant(plugin);ISavedState lastState =
> ResourcesPlugin.getWorkspace().addSaveParticipant(plugin,
> saveParticipant);if (lastState == null)return;IPath location =
> lastState.lookup(new Path("save"));if (location == null)return;// the
> plugin instance should read any important state from the file.File f =
> getStateLocation().append(location).toFile();readStateFrom(f );}
>
Re: Workspace save participation [message #328510 is a reply to message #328504] Mon, 26 May 2008 23:07 Go to previous messageGo to next message
Lars Vogel is currently offline Lars VogelFriend
Messages: 1098
Registered: July 2009
Senior Member

Hi Rahul,

thank you. I didn't know what the implementation for saving matters expect
that I read that the method should never thrown an exception. In
implementing the method I followed closely the example (please see below for
the code). The method is never called.

The called method plugin.writeImportantState(f); in the class Activator
currently only contains: System.out.println("Writing");

My assumption is that my Activtator Plugin needs to tell the workbench that
is has changed / information to save.

Best regards, Lars

public void saving(ISaveContext context) throws CoreException {

System.out.println("I'm not called");

switch (context.getKind()) {

case ISaveContext.FULL_SAVE:

// save the plug-in state

int saveNumber = context.getSaveNumber();

String saveFileName = "save-" + Integer.toString(saveNumber);

File f = plugin.getStateLocation().append(saveFileName).toFile();

// if we fail to write, an exception is thrown and we do not update

// the path

plugin.writeImportantState(f);

context.map(new Path("save"), new Path(saveFileName));

context.needSaveNumber();

break;

case ISaveContext.PROJECT_SAVE:

// get the project related to this save operation

IProject project = context.getProject();

// save its information, if necessary

break;

case ISaveContext.SNAPSHOT:

// This operation needs to be really fast because

// snapshots can be requested frequently by the

// workspace.

break;

}


}


"Rahul Kamdar" <rtkamdar@kamdars-india.com> wrote in message
news:g1f1h1$e0o$1@build.eclipse.org...
>I also use Workspace save participation and referred to the same article.
>Why your saveParticipant is not getting called inspite of registering it
>with the workspace initially probably might depend on your implementation
>of the "saving" method of the class ISavedParticipant. Maybe you could post
>that part here and someone could help you better.
>
> Rahul
>
> "Lars Vogel" <Lars.Vogel@gmail.com> wrote in message
> news:g1c1uc$9bv$1@build.eclipse.org...
>> Hi,
>>
>> I tried to follow the Eclipse Help for participating with a RCP
>> application in the workbench saving.
>>
>> http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/resAdv_saving.htmIn
>> my RCP application I adjusted the start method in the class Activator
>> (please see below for the coding). Here I register the
>> classMyWorkspaceSaveParticipant. I checked the class SaveManager and can
>> see thatit is registered.But during shutdown the saving method in
>> MyWorkspaceSaveParticipant is notcalled.Do I have to do do something
>> else, e.g. set the changed status of my pluginsomewhere?Best regards,
>> Larspublic void start(BundleContext context) throws Exception
>> {super.start(context);plugin = this;saveParticipant = new
>> MyWorkspaceSaveParticipant(plugin);ISavedState lastState =
>> ResourcesPlugin.getWorkspace().addSaveParticipant(plugin,
>> saveParticipant);if (lastState == null)return;IPath location =
>> lastState.lookup(new Path("save"));if (location == null)return;// the
>> plugin instance should read any important state from the file.File f =
>> getStateLocation().append(location).toFile();readStateFrom(f );}
>>
>
>
Re: Workspace save participation [message #328527 is a reply to message #328510] Tue, 27 May 2008 10:01 Go to previous messageGo to next message
Rahul Kamdar is currently offline Rahul KamdarFriend
Messages: 63
Registered: July 2009
Member
Hi Lars,

Couple of things:

1] I just re-read the article and found this: The provided class must
implement IResourceChangeListener, as described in Tracking resource changes
( http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/resAdv_events.htm).
The changes since the last save are reported as part of the POST_AUTO_BUILD
resource change event. << Are you doing this? I have a
resourceChangeListener defined on one of my content providers, which in
effect is triggering the call to the Save Participant when a project is
saved or the workspace is being closed.

2] I just ran a debug for my project. Whenever a project defined in my
plugin is created, there is a call made to saving method and subsequently to
the doneSaving method (this is other than the calls made when the workspace
is being switched or Eclipse is being closed). I have pretty much done the
same thing as you. While fetching the ISavedState, as long as you are
registering and adding your save Participant, the same should be configured
with the workspace. Please check if there is a folder being created in the
..metadata directory of your Workspace with the name of your plug-in though I
am not sure if it is created even though you are not writing any contents to
the file as of now.

Anyway I am not exactly the best person to help you out, I just thought of
trying to see if we can compare your work to mine and figure out the issue
:) Best luck!

Rahul

"Lars Vogel" <Lars.Vogel@gmail.com> wrote in message
news:g1ffs8$p8n$1@build.eclipse.org...
> Hi Rahul,
>
> thank you. I didn't know what the implementation for saving matters expect
> that I read that the method should never thrown an exception. In
> implementing the method I followed closely the example (please see below
> for the code). The method is never called.
>
> The called method plugin.writeImportantState(f); in the class Activator
> currently only contains: System.out.println("Writing");
>
> My assumption is that my Activtator Plugin needs to tell the workbench
> that is has changed / information to save.
>
> Best regards, Lars
>
> public void saving(ISaveContext context) throws CoreException {
>
> System.out.println("I'm not called");
>
> switch (context.getKind()) {
>
> case ISaveContext.FULL_SAVE:
>
> // save the plug-in state
>
> int saveNumber = context.getSaveNumber();
>
> String saveFileName = "save-" + Integer.toString(saveNumber);
>
> File f = plugin.getStateLocation().append(saveFileName).toFile();
>
> // if we fail to write, an exception is thrown and we do not update
>
> // the path
>
> plugin.writeImportantState(f);
>
> context.map(new Path("save"), new Path(saveFileName));
>
> context.needSaveNumber();
>
> break;
>
> case ISaveContext.PROJECT_SAVE:
>
> // get the project related to this save operation
>
> IProject project = context.getProject();
>
> // save its information, if necessary
>
> break;
>
> case ISaveContext.SNAPSHOT:
>
> // This operation needs to be really fast because
>
> // snapshots can be requested frequently by the
>
> // workspace.
>
> break;
>
> }
>
>
> }
>
>
> "Rahul Kamdar" <rtkamdar@kamdars-india.com> wrote in message
> news:g1f1h1$e0o$1@build.eclipse.org...
>>I also use Workspace save participation and referred to the same article.
>>Why your saveParticipant is not getting called inspite of registering it
>>with the workspace initially probably might depend on your implementation
>>of the "saving" method of the class ISavedParticipant. Maybe you could
>>post that part here and someone could help you better.
>>
>> Rahul
>>
>> "Lars Vogel" <Lars.Vogel@gmail.com> wrote in message
>> news:g1c1uc$9bv$1@build.eclipse.org...
>>> Hi,
>>>
>>> I tried to follow the Eclipse Help for participating with a RCP
>>> application in the workbench saving.
>>>
>>> http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/resAdv_saving.htmIn
>>> my RCP application I adjusted the start method in the class Activator
>>> (please see below for the coding). Here I register the
>>> classMyWorkspaceSaveParticipant. I checked the class SaveManager and can
>>> see thatit is registered.But during shutdown the saving method in
>>> MyWorkspaceSaveParticipant is notcalled.Do I have to do do something
>>> else, e.g. set the changed status of my pluginsomewhere?Best regards,
>>> Larspublic void start(BundleContext context) throws Exception
>>> {super.start(context);plugin = this;saveParticipant = new
>>> MyWorkspaceSaveParticipant(plugin);ISavedState lastState =
>>> ResourcesPlugin.getWorkspace().addSaveParticipant(plugin,
>>> saveParticipant);if (lastState == null)return;IPath location =
>>> lastState.lookup(new Path("save"));if (location == null)return;// the
>>> plugin instance should read any important state from the file.File f =
>>> getStateLocation().append(location).toFile();readStateFrom(f );}
>>>
>>
>>
>
>
Re: Workspace save participation [message #328556 is a reply to message #328527] Tue, 27 May 2008 16:31 Go to previous messageGo to next message
Lars Vogel is currently offline Lars VogelFriend
Messages: 1098
Registered: July 2009
Senior Member

Hi Rahul,

thank you very much for your answer.

I actually did not register to the resources, as I was under the assumption
that the saving Method is always called at the end of the Eclipse Workbench.

I'll try to register and will report if it works.

Thanks again, Lars


"Rahul Kamdar" <rtkamdar@kamdars-india.com> wrote in message
news:g1gm6a$1p8$1@build.eclipse.org...
> Hi Lars,
>
> Couple of things:
>
> 1] I just re-read the article and found this: The provided class must
> implement IResourceChangeListener, as described in Tracking resource
> changes
> ( http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/resAdv_events.htm).
> The changes since the last save are reported as part of the
> POST_AUTO_BUILD resource change event. << Are you doing this? I have a
> resourceChangeListener defined on one of my content providers, which in
> effect is triggering the call to the Save Participant when a project is
> saved or the workspace is being closed.
>
> 2] I just ran a debug for my project. Whenever a project defined in my
> plugin is created, there is a call made to saving method and subsequently
> to the doneSaving method (this is other than the calls made when the
> workspace is being switched or Eclipse is being closed). I have pretty
> much done the same thing as you. While fetching the ISavedState, as long
> as you are registering and adding your save Participant, the same should
> be configured with the workspace. Please check if there is a folder being
> created in the .metadata directory of your Workspace with the name of your
> plug-in though I am not sure if it is created even though you are not
> writing any contents to the file as of now.
>
> Anyway I am not exactly the best person to help you out, I just thought of
> trying to see if we can compare your work to mine and figure out the issue
> :) Best luck!
>
> Rahul
>
> "Lars Vogel" <Lars.Vogel@gmail.com> wrote in message
> news:g1ffs8$p8n$1@build.eclipse.org...
>> Hi Rahul,
>>
>> thank you. I didn't know what the implementation for saving matters
>> expect that I read that the method should never thrown an exception. In
>> implementing the method I followed closely the example (please see below
>> for the code). The method is never called.
>>
>> The called method plugin.writeImportantState(f); in the class Activator
>> currently only contains: System.out.println("Writing");
>>
>> My assumption is that my Activtator Plugin needs to tell the workbench
>> that is has changed / information to save.
>>
>> Best regards, Lars
>>
>> public void saving(ISaveContext context) throws CoreException {
>>
>> System.out.println("I'm not called");
>>
>> switch (context.getKind()) {
>>
>> case ISaveContext.FULL_SAVE:
>>
>> // save the plug-in state
>>
>> int saveNumber = context.getSaveNumber();
>>
>> String saveFileName = "save-" + Integer.toString(saveNumber);
>>
>> File f = plugin.getStateLocation().append(saveFileName).toFile();
>>
>> // if we fail to write, an exception is thrown and we do not update
>>
>> // the path
>>
>> plugin.writeImportantState(f);
>>
>> context.map(new Path("save"), new Path(saveFileName));
>>
>> context.needSaveNumber();
>>
>> break;
>>
>> case ISaveContext.PROJECT_SAVE:
>>
>> // get the project related to this save operation
>>
>> IProject project = context.getProject();
>>
>> // save its information, if necessary
>>
>> break;
>>
>> case ISaveContext.SNAPSHOT:
>>
>> // This operation needs to be really fast because
>>
>> // snapshots can be requested frequently by the
>>
>> // workspace.
>>
>> break;
>>
>> }
>>
>>
>> }
>>
>>
>> "Rahul Kamdar" <rtkamdar@kamdars-india.com> wrote in message
>> news:g1f1h1$e0o$1@build.eclipse.org...
>>>I also use Workspace save participation and referred to the same article.
>>>Why your saveParticipant is not getting called inspite of registering it
>>>with the workspace initially probably might depend on your implementation
>>>of the "saving" method of the class ISavedParticipant. Maybe you could
>>>post that part here and someone could help you better.
>>>
>>> Rahul
>>>
>>> "Lars Vogel" <Lars.Vogel@gmail.com> wrote in message
>>> news:g1c1uc$9bv$1@build.eclipse.org...
>>>> Hi,
>>>>
>>>> I tried to follow the Eclipse Help for participating with a RCP
>>>> application in the workbench saving.
>>>>
>>>> http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/resAdv_saving.htmIn
>>>> my RCP application I adjusted the start method in the class Activator
>>>> (please see below for the coding). Here I register the
>>>> classMyWorkspaceSaveParticipant. I checked the class SaveManager and
>>>> can see thatit is registered.But during shutdown the saving method in
>>>> MyWorkspaceSaveParticipant is notcalled.Do I have to do do something
>>>> else, e.g. set the changed status of my pluginsomewhere?Best regards,
>>>> Larspublic void start(BundleContext context) throws Exception
>>>> {super.start(context);plugin = this;saveParticipant = new
>>>> MyWorkspaceSaveParticipant(plugin);ISavedState lastState =
>>>> ResourcesPlugin.getWorkspace().addSaveParticipant(plugin,
>>>> saveParticipant);if (lastState == null)return;IPath location =
>>>> lastState.lookup(new Path("save"));if (location == null)return;// the
>>>> plugin instance should read any important state from the file.File f =
>>>> getStateLocation().append(location).toFile();readStateFrom(f );}
>>>>
>>>
>>>
>>
>>
>
>
Re: Workspace save participation [message #330568 is a reply to message #328527] Sun, 03 August 2008 18:40 Go to previous message
Lars Vogel is currently offline Lars VogelFriend
Messages: 1098
Registered: July 2009
Senior Member

Hi Rahul,

unfortunately it didn't work. I now manually call my SaveParticipant in
the stop method of my plug-in; this is course works. ;-)

Thank you for your advice.

Best regards, Lars

Rahul Kamdar wrote:
> Hi Lars,
>
> Couple of things:
>
> 1] I just re-read the article and found this: The provided class must
> implement IResourceChangeListener, as described in Tracking resource changes
> ( http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/resAdv_events.htm).
> The changes since the last save are reported as part of the POST_AUTO_BUILD
> resource change event. << Are you doing this? I have a
> resourceChangeListener defined on one of my content providers, which in
> effect is triggering the call to the Save Participant when a project is
> saved or the workspace is being closed.
>
> 2] I just ran a debug for my project. Whenever a project defined in my
> plugin is created, there is a call made to saving method and subsequently to
> the doneSaving method (this is other than the calls made when the workspace
> is being switched or Eclipse is being closed). I have pretty much done the
> same thing as you. While fetching the ISavedState, as long as you are
> registering and adding your save Participant, the same should be configured
> with the workspace. Please check if there is a folder being created in the
> .metadata directory of your Workspace with the name of your plug-in though I
> am not sure if it is created even though you are not writing any contents to
> the file as of now.
>
> Anyway I am not exactly the best person to help you out, I just thought of
> trying to see if we can compare your work to mine and figure out the issue
> :) Best luck!
>
> Rahul
>
> "Lars Vogel" <Lars.Vogel@gmail.com> wrote in message
> news:g1ffs8$p8n$1@build.eclipse.org...
>> Hi Rahul,
>>
>> thank you. I didn't know what the implementation for saving matters expect
>> that I read that the method should never thrown an exception. In
>> implementing the method I followed closely the example (please see below
>> for the code). The method is never called.
>>
>> The called method plugin.writeImportantState(f); in the class Activator
>> currently only contains: System.out.println("Writing");
>>
>> My assumption is that my Activtator Plugin needs to tell the workbench
>> that is has changed / information to save.
>>
>> Best regards, Lars
>>
>> public void saving(ISaveContext context) throws CoreException {
>>
>> System.out.println("I'm not called");
>>
>> switch (context.getKind()) {
>>
>> case ISaveContext.FULL_SAVE:
>>
>> // save the plug-in state
>>
>> int saveNumber = context.getSaveNumber();
>>
>> String saveFileName = "save-" + Integer.toString(saveNumber);
>>
>> File f = plugin.getStateLocation().append(saveFileName).toFile();
>>
>> // if we fail to write, an exception is thrown and we do not update
>>
>> // the path
>>
>> plugin.writeImportantState(f);
>>
>> context.map(new Path("save"), new Path(saveFileName));
>>
>> context.needSaveNumber();
>>
>> break;
>>
>> case ISaveContext.PROJECT_SAVE:
>>
>> // get the project related to this save operation
>>
>> IProject project = context.getProject();
>>
>> // save its information, if necessary
>>
>> break;
>>
>> case ISaveContext.SNAPSHOT:
>>
>> // This operation needs to be really fast because
>>
>> // snapshots can be requested frequently by the
>>
>> // workspace.
>>
>> break;
>>
>> }
>>
>>
>> }
>>
>>
>> "Rahul Kamdar" <rtkamdar@kamdars-india.com> wrote in message
>> news:g1f1h1$e0o$1@build.eclipse.org...
>>> I also use Workspace save participation and referred to the same article.
>>> Why your saveParticipant is not getting called inspite of registering it
>>> with the workspace initially probably might depend on your implementation
>>> of the "saving" method of the class ISavedParticipant. Maybe you could
>>> post that part here and someone could help you better.
>>>
>>> Rahul
>>>
>>> "Lars Vogel" <Lars.Vogel@gmail.com> wrote in message
>>> news:g1c1uc$9bv$1@build.eclipse.org...
>>>> Hi,
>>>>
>>>> I tried to follow the Eclipse Help for participating with a RCP
>>>> application in the workbench saving.
>>>>
>>>> http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/resAdv_saving.htmIn
>>>> my RCP application I adjusted the start method in the class Activator
>>>> (please see below for the coding). Here I register the
>>>> classMyWorkspaceSaveParticipant. I checked the class SaveManager and can
>>>> see thatit is registered.But during shutdown the saving method in
>>>> MyWorkspaceSaveParticipant is notcalled.Do I have to do do something
>>>> else, e.g. set the changed status of my pluginsomewhere?Best regards,
>>>> Larspublic void start(BundleContext context) throws Exception
>>>> {super.start(context);plugin = this;saveParticipant = new
>>>> MyWorkspaceSaveParticipant(plugin);ISavedState lastState =
>>>> ResourcesPlugin.getWorkspace().addSaveParticipant(plugin,
>>>> saveParticipant);if (lastState == null)return;IPath location =
>>>> lastState.lookup(new Path("save"));if (location == null)return;// the
>>>> plugin instance should read any important state from the file.File f =
>>>> getStateLocation().append(location).toFile();readStateFrom(f );}
>>>>
>>>
>>
>
>
Previous Topic:Giving focus to a JFace ToolTip
Next Topic:problems in using a custom IApplication class : AssertionFailedException
Goto Forum:
  


Current Time: Thu Nov 07 13:20:01 GMT 2024

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

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

Back to the top