Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Custom Multi-Workspace
Custom Multi-Workspace [message #512697] Sat, 06 February 2010 08:06
Eclipse UserFriend
Originally posted by: jedlicka.poll.cz

Hi,
i would like to use multi-workspace by user for save preferences, e.g.:

my_application/workspace/user1/.metadata
my_application/workspace/user2/.metadata

etc.

I have followed guide http://hexapixel.com/2009/01/12/rcp-workspaces

It is:

1. turn off default workspace
-data @noDefault

2. create custom workspace in the Aplication.java

// create dirs
File workspace = new File("workspace/" + username);
if (!workspace.exists()) workspace.mkdirs();

// create URL and set Location
URL url = new URL("file", null, workspace.getAbsolutePath());

if (url != null) {
Location instanceLoc = Platform.getInstanceLocation();
instanceLoc.set(url, false);
}


That's OK. After user login will be workspace created.

My problem:

In my application I use save preferences (e.g. show chart) in method
saveState(memento) of View this way:

Activator.getDefault().getPreferenceStore().setValue(Prefere nceConstants.SHOW_CHART,
m_chartVisible);

Before I have loaded this preferences as per description mention above,
this way has been followed:

Platform.getPreferencesService().getBoolean(Activator.PLUGIN _ID,
PreferenceConstants.SHOW_CHART, true, null);

But I started to use custome workspace the loading preferences doesn't
work anymore. When I close View these preferences are saved with any
problem into file 'xx.prefs', but after open View
preferences are not loading.

I understood the problem is because of not turn on default workspace
(@noDefault). Do I have to these preferences again somehow loaded? Am I
using for the loading correct getPreferencesService() ?

I have tried after View open loaded preferences again by:

private IPreferenceStore m_preferences =
Activator.getDefault().getPreferenceStore();
try {
m_preferences = new PreferenceStore("xx.prefs");
((PreferenceStore) m_preferences).load();
} catch (IOException e) {
e.printStackTrace();
}
m_preferences.getBoolean(PreferenceConstants.UPDATE_VAR);

It gets better but doesn't work for default values.

How to use loading preferences into workspace? What am I doing wrong?

Thanks!

Martin
Previous Topic:Can't launch RCP app from new Product Config
Next Topic:Adding Update Manager
Goto Forum:
  


Current Time: Fri Apr 26 08:54:05 GMT 2024

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

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

Back to the top