Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Setting custom workspace
Setting custom workspace [message #893177] Tue, 03 July 2012 06:12 Go to next message
Alok Mishra is currently offline Alok MishraFriend
Messages: 16
Registered: April 2012
Junior Member
Hello,

I'm trying to develop an RCP application and want to set my custom workspace programmatically.

I added the following line in the constructor of Activator.java file.
Location instanceLocation = Platform.getInstanceLocation();
if(instanceLocation.isSet())
	instanceLocation.release();
instanceLocation.set(new URL("file", null, MyWorkspacePath), false);

But I get the following Exception
java.lang.IllegalStateException: Cannot change the location once it is set.

I know if I add "-data @user.home/my_workspace" to the Program Argument in the Run Configuration the workspace will get changed, but I want to do it programmatically, so that I can change the workspace during runtime.

How can I ask my application to override the default workspace? Adding "-data @noDefault" to Program Argument didn't work; rather it results in "org.osgi.framework.BundleException" Exception, even before calling the constructor of Activator class.

Once I've set my workspace, how can I reset it during runtime?

Any help in this regard will be highly appreciated.

Regards,
-Alok
Re: Setting custom workspace [message #894011 is a reply to message #893177] Fri, 06 July 2012 11:50 Go to previous messageGo to next message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 242
Registered: July 2009
Senior Member
The workspace location is, IIRC, something managed by the OSGi framework (I.e., very low level).

What are you trying to accomplish?
Re: Setting custom workspace [message #894396 is a reply to message #894011] Mon, 09 July 2012 05:46 Go to previous messageGo to next message
Alok Mishra is currently offline Alok MishraFriend
Messages: 16
Registered: April 2012
Junior Member
Hi Brian,

I want to provide the option to set multiple workspace to my RCP application, something like what Eclipse does. This way the user can change the workspace whenever he/she desire.

Currently what I'm trying to do is programmatically set the workspace for my RCP application. But till now I've not succeeded. The only thing that I could find was to add "-data @user.home/my_workspace" to the Program Argument in the Run Configuration, which changes the workspace.

Regards,
-Alok
Re: Setting custom workspace [message #894525 is a reply to message #894396] Mon, 09 July 2012 14:06 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

In eclipse, that's done by the native launcher, before the OSGi framework is launched as setting the workspace is one of the first things that needs to be done. You can use that as part of your RCP app if you want.

The other option is something like org.eclipse.ui.internal.ide.application.IDEApplication.checkInstanceLocation(Shell, Map). If "-data @noDefault" is passed in, then your application has the chance to set it early.


PW


Re: Setting custom workspace [message #894914 is a reply to message #894525] Wed, 11 July 2012 05:42 Go to previous messageGo to next message
Alok Mishra is currently offline Alok MishraFriend
Messages: 16
Registered: April 2012
Junior Member
Thanks for the help, now I'm able to set the workspace programmatically. I'm still not clear about native launchers though... still looking into it.

I did the following to make it work:
1. Add -data @noDefault to the Program Argument.
2. Remove any workspace data location set in the argument. (I think this is what was conflicting in my first attempt)
3. Adding the code for setting location (see my first post) in Application.java file.

Regards,
Alok
Re: Setting custom workspace [message #898850 is a reply to message #894914] Sat, 28 July 2012 03:00 Go to previous messageGo to next message
Ahmed Osama is currently offline Ahmed OsamaFriend
Messages: 1
Registered: July 2012
Junior Member
Hi Alok,

I am facing the same problem as yours. So could you please tell me what you exactly mean by removing any previous setting to the workspace location (point 2).

Regards,
Ahmed
Re: Setting custom workspace [message #899727 is a reply to message #898850] Thu, 02 August 2012 06:44 Go to previous message
Alok Mishra is currently offline Alok MishraFriend
Messages: 16
Registered: April 2012
Junior Member
By default in Run Configuration your workspace location is mentioned as "${workspace_loc}/../runtime-"; remove it. Also add "-data @noDefault" to the Program Arguments. This worked for me.
Previous Topic:A tool to evaluate expressions at runtime
Next Topic:How do i initialize a ViewPart ?
Goto Forum:
  


Current Time: Tue Dec 03 17:08:38 GMT 2024

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

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

Back to the top