Skip to content

Commit

Permalink
Fixes bug 3303
Browse files Browse the repository at this point in the history
  • Loading branch information
KlasJoensson committed Sep 10, 2012
1 parent 55d5882 commit edff7e5
Showing 1 changed file with 12 additions and 3 deletions.
Expand Up @@ -12,6 +12,7 @@
package net.bioclipse.usermanager.preferences;

import net.bioclipse.usermanager.Activator;
import net.bioclipse.usermanager.User;
import net.bioclipse.usermanager.UserContainer;
import net.bioclipse.usermanager.business.IUserManager;
import net.bioclipse.usermanager.dialogs.CreateUserDialog;
Expand Down Expand Up @@ -64,6 +65,7 @@ public class UserManagerPreferencePage extends PreferencePage
private UserContainer sandBoxUserContainer;
private IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
private Logger logger = Logger.getLogger( this.getClass() );
private User loggedInUser;

@Override
protected Control createContents(Composite parent) {
Expand Down Expand Up @@ -219,18 +221,23 @@ public void widgetSelected(SelectionEvent e) {

@Override
public boolean performOk() {

IUserManager userManager = Activator.getDefault().getUserManager();
userManager.switchUserContainer(sandBoxUserContainer);
userManager.persist();
userManager.logOut();
if (loggedInUser == null) {
/* There where on one logged in when opening the page, so if any one
* are logged in now let's log any one logged-in out*/
userManager.switchUserContainer(sandBoxUserContainer);
userManager.logOut();
}
prefStore.setValue( Activator.PROMPT_ON_LOGOUT, !propOnLogoutButton.getSelection() );
try {
InstanceScope.INSTANCE.getNode( Activator.PLUGIN_ID ).flush();
} catch ( BackingStoreException e ) {
logger.error( e.getStackTrace() );
e.printStackTrace();
}

return super.performOk();
}

Expand All @@ -245,6 +252,8 @@ public void init(IWorkbench workbench) {
sandBoxUserContainer = Activator
.getDefault()
.getUserManager().getSandBoxUserContainer();
if (sandBoxUserContainer.isLoggedIn())
loggedInUser = sandBoxUserContainer.getLoggedInUser();
}

private String getSelectedUserName() {
Expand Down

0 comments on commit edff7e5

Please sign in to comment.