Skip to content

Commit

Permalink
Create Bioclipse account if none exist.
Browse files Browse the repository at this point in the history
Also changed from Keyring to Bioclipse Account.

Sadly though I also gave rice to Bug 3161
  • Loading branch information
jonalv committed Mar 6, 2012
1 parent 55d6e13 commit 5f03ca4
Show file tree
Hide file tree
Showing 8 changed files with 511 additions and 10 deletions.
Expand Up @@ -10,11 +10,17 @@
******************************************************************************/
package net.bioclipse.usermanager;

import net.bioclipse.usermanager.business.IUserManager;
import net.bioclipse.usermanager.dialogs.CreateUserDialog;
import net.bioclipse.usermanager.dialogs.LoginDialog;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;

/**
* A wizard for handling the users third parts accounts
Expand All @@ -27,6 +33,39 @@ public class NewAccountWizard extends Wizard implements INewWizard {
private NewAccountWizardPage mainPage;

public NewAccountWizard() {
boolean cancel = false;
IUserManager usermanager = Activator.getDefault().getUserManager();
if (usermanager.getUserNames().size() == 0) {
UserContainer sandbox = usermanager.getSandBoxUserContainer();
CreateUserDialog dialog
= new CreateUserDialog( PlatformUI.getWorkbench()
.getActiveWorkbenchWindow()
.getShell(), sandbox );
dialog.open();
if (dialog.getReturnCode() == dialog.OK) {
usermanager.switchUserContainer( sandbox );
}
else if (dialog.getReturnCode() == dialog.CANCEL) {
cancel = true;
}
}

if ( !cancel && !usermanager.isLoggedIn() ) {
UserContainer sandbox = usermanager.getSandBoxUserContainer();
LoginDialog loginDialog
= new LoginDialog( PlatformUI.getWorkbench()
.getActiveWorkbenchWindow()
.getShell(),
sandbox );

loginDialog.open();
if ( loginDialog.getReturnCode() == LoginDialog.OK ) {
if ( loginDialog.isUserContainerEdited() ) {
Activator.getDefault().getUserManager()
.switchUserContainer(sandbox);
}
}
}
}

@Override
Expand Down
Expand Up @@ -12,6 +12,7 @@
package net.bioclipse.usermanager;
import java.util.ArrayList;

import net.bioclipse.core.business.BioclipseException;
import net.bioclipse.usermanager.business.IUserManager;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
Expand All @@ -24,6 +25,8 @@
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;

import com.sun.xml.internal.ws.Closeable;

/**
* The wizard page that handles the different parts accounts.
*
Expand All @@ -42,11 +45,11 @@ public class NewAccountWizardPage extends WizardPage implements Listener {

protected NewAccountWizardPage(String pageName) {
super(pageName);

}

@Override
public void createControl(Composite parent) {

Composite container = new Composite(parent, SWT.NONE);
GridLayout containerLayout = new GridLayout(1, false);
container.setLayout(containerLayout);
Expand Down Expand Up @@ -92,6 +95,12 @@ public void createControl(Composite parent) {
giveFocus();
}
setControl(container);
if ( !Activator.getDefault().getUserManager().isLoggedIn() ) {
System.out.println("CANCEL!" + this.getWizard().performCancel());
// TODO FIXME find a better way to do this that does not cause an
// Exception.
this.getShell().close();
}
}


Expand Down
Expand Up @@ -105,7 +105,7 @@ protected Point getInitialSize() {
}
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText("Change password for Keyring user");
newShell.setText("Change password for Bioclipse Account");
}
protected void buttonPressed(int buttonId) {
if (buttonId == IDialogConstants.OK_ID) {
Expand Down
Expand Up @@ -29,6 +29,7 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
import org.eclipse.wb.swt.SWTResourceManager;

/**
* Dialog for creating a user
Expand Down Expand Up @@ -62,6 +63,8 @@ public CreateUserDialog( Shell parentShell,
*/
@Override
protected Control createDialogArea(Composite parent) {
setMessage("Bioclipse wants to create an account for storing all your different passwords in one password encrypted file.");
setTitleImage(SWTResourceManager.getImage(CreateUserDialog.class, "/net/bioclipse/usermanager/BioclipseAccountLogo3_medium.png"));
Composite area = (Composite) super.createDialogArea(parent);
Composite container = new Composite(area, SWT.NONE);
container.setLayout(new FormLayout());
Expand Down Expand Up @@ -115,7 +118,7 @@ protected Control createDialogArea(Composite parent) {
passwordLabel,
repeatPasswordLabel });

setTitle("Create User");
setTitle("Create Bioclipse Account");

return area;
}
Expand Down Expand Up @@ -174,6 +177,6 @@ protected void buttonPressed(int buttonId) {
}
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText("Create User");
newShell.setText("Create Bioclipse Account");
}
}
Expand Up @@ -318,7 +318,7 @@ public void widgetSelected(SelectionEvent e) {
formData_8.top = new FormAttachment(0, 21);
formData_8.left = new FormAttachment(0, 33);
changeKeyringUserButton.setLayoutData(formData_8);
changeKeyringUserButton.setText("Change Keyring User Password");
changeKeyringUserButton.setText("Change Bioclipse Account Password");
container.setTabList(new Control[] { changeKeyringUserButton,
addAccountButton,
deleteAccountButton,
Expand Down Expand Up @@ -350,7 +350,7 @@ protected Point getInitialSize() {

protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText("Keyring User Properties");
newShell.setText("Bioclipse Account Properties");
}

private void refreshList() {
Expand Down
Expand Up @@ -42,6 +42,7 @@
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.wb.swt.SWTResourceManager;

/**
* Dialog for logging in to the given UserContainer
Expand Down Expand Up @@ -81,6 +82,7 @@ public LoginDialog( Shell parentShell,
*/
@Override
protected Control createDialogArea(Composite parent) {
setTitleImage(SWTResourceManager.getImage(LoginDialog.class, "/net/bioclipse/usermanager/BioclipseAccountLogo3_medium.png"));
Composite area = (Composite) super.createDialogArea(parent);
Composite container = new Composite(area, SWT.NONE);
container.setLayout(new FormLayout());
Expand Down Expand Up @@ -147,13 +149,13 @@ public void widgetSelected(SelectionEvent e) {
formData_4.right = new FormAttachment(100, -34);
formData_4.top = new FormAttachment(0, 136);
createNewKeyringButton.setLayoutData(formData_4);
createNewKeyringButton.setText("Create new Keyring user...");
createNewKeyringButton.setText("Create new Account...");
container.setTabList(new Control[] { usernameText,
passwordText,
passwordLabel,
usernameLabel,
createNewKeyringButton });
setTitle("Log In to the User Manager");
setTitle("Log In To Your Bioclipse Account");
//
return area;
}
Expand Down
Expand Up @@ -174,8 +174,9 @@ public void widgetSelected(SelectionEvent e) {
.getActiveWorkbenchWindow()
.getShell(),
"Confirm removing " +
"of Keyring user",
"Really remove the user: "
"of Account",
"Really remove the " +
"account with username: "
+ userName + "?" ) ) {
sandBoxUserContainer.deleteUser(userName);
}
Expand Down

0 comments on commit 5f03ca4

Please sign in to comment.