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 03:06
Eclipse User
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: Thu Jul 24 19:03:50 EDT 2014

Powered by FUDForum. Page generated in 0.02098 seconds