Skip to content

Commit

Permalink
Merge pull request #23 from KlasJoenssson/BetaBugs
Browse files Browse the repository at this point in the history
Beta bugs
  • Loading branch information
jonalv committed Aug 22, 2012
2 parents 9a4d6aa + fd60bd5 commit 42fc9ee
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 34 deletions.
Expand Up @@ -324,21 +324,21 @@ public boolean createAccount() {

return false;
}
Collection<Account> accounts = sandbox.getLoggedInUser().getAccounts().values();
Iterator<Account> itr = accounts.iterator();
Account account;
while (itr.hasNext()) {
account = itr.next();
if ( account.getAccountType().equals( accountType ) ) {
MessageDialog.openInformation( PlatformUI.getWorkbench()
.getActiveWorkbenchWindow()
.getShell(),
"Account type already used",
"There is already an account of " +
"that type." );
return false;
}
}
// Collection<Account> accounts = sandbox.getLoggedInUser().getAccounts().values();
// Iterator<Account> itr = accounts.iterator();
// Account account;
// while (itr.hasNext()) {
// account = itr.next();
// if ( account.getAccountType().equals( accountType ) ) {
// MessageDialog.openInformation( PlatformUI.getWorkbench()
// .getActiveWorkbenchWindow()
// .getShell(),
// "Account type already used",
// "There is already an account of " +
// "that type." );
// return false;
// }
// }

int i = 0;
HashMap<String, String> properties = new HashMap<String, String>();
Expand Down
Expand Up @@ -10,11 +10,14 @@
******************************************************************************/
package net.bioclipse.usermanager;

import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;

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

import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
Expand All @@ -36,13 +39,17 @@ public class NewAccountWizard extends Wizard implements INewWizard {
private IUserManager usermanager;
private UserContainer sandbox;
private CreateUserWizardPage createUserPage;
public NewAccountWizard(UserContainer userContainer) {
private boolean manipulateUserContainer;

public NewAccountWizard(UserContainer userContainer, boolean manipulateUserContainer) {
sandbox = userContainer;
this.manipulateUserContainer = manipulateUserContainer;
}

public NewAccountWizard() {
usermanager = Activator.getDefault().getUserManager();
sandbox = usermanager.getSandBoxUserContainer();
manipulateUserContainer = true;
// if ( usermanager.getUserNames().size() == 0) {
// CreateUserDialog dialog
// = new CreateUserDialog( PlatformUI.getWorkbench()
Expand Down Expand Up @@ -95,20 +102,40 @@ public void addPages() {

@Override
public boolean performFinish() {

if ( !sandbox.isLoggedIn() ) {
if (usermanager == null)
usermanager = Activator.getDefault().getUserManager();
usermanager.logIn(loginPage.getUsername(), loginPage.getPassword());
}

if (manipulateUserContainer) {
Collection<Account> accounts = sandbox.getLoggedInUser().getAccounts().values();
Iterator<Account> itr = accounts.iterator();
Account account;
while (itr.hasNext()) {
account = itr.next();
if ( account.getAccountType().equals( addAccountPage.getAccountType() ) ) {
MessageDialog.openInformation( PlatformUI.getWorkbench()
.getActiveWorkbenchWindow()
.getShell(),
"Account type already used",
"There is already an account of " +
"that type." );
return false;
}
}

if (addAccountPage.createAccount()) {
if (usermanager != null)
usermanager.switchUserContainer( sandbox );
dispose();
return true;
} else
return false;
} else
return addAccountPage.createAccount();

if (addAccountPage.createAccount()) {
if (usermanager != null)
usermanager.switchUserContainer( sandbox );
dispose();
return true;
} else
return false;
}

@Override
Expand Down
Expand Up @@ -58,6 +58,8 @@
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;

import sun.swing.AccumulativeRunnable;

/**
* Dialog for editing an user and the users accounts
*
Expand Down Expand Up @@ -243,7 +245,7 @@ public void widgetSelected(SelectionEvent e) {
*/
public void widgetSelected(SelectionEvent e) {
dummySandbox = sandBoxUserContainer.clone();
NewAccountWizard wizard = new NewAccountWizard(dummySandbox);
NewAccountWizard wizard = new NewAccountWizard(dummySandbox, false);
NewAcccountWizardDialog wd = new NewAcccountWizardDialog(
PlatformUI.getWorkbench()
.getActiveWorkbenchWindow()
Expand All @@ -253,13 +255,13 @@ public void widgetSelected(SelectionEvent e) {

for( DummyAccount ac : model.dummyAccounts.values() ) {
if( ac.accountType.equals( wizard.getAccountType() ) ) {
// MessageDialog.openInformation(
// PlatformUI
// .getWorkbench()
// .getActiveWorkbenchWindow()
// .getShell(),
// "Account type already used",
// ALREADY_SUCH_AN_ACCOUNT );
MessageDialog.openInformation(
PlatformUI
.getWorkbench()
.getActiveWorkbenchWindow()
.getShell(),
"Account type already used",
ALREADY_SUCH_AN_ACCOUNT );
return;
}
}
Expand Down Expand Up @@ -437,8 +439,11 @@ private void refreshOnSelectionChanged() {
/* If there's no item selected (e.g. if the user clicked below the last
* item in the list) we'll select the last item in the list. */
if ( accountsListViewer.getList().getSelectionCount() == 0 )
accountsListViewer.getList().select(accountsListViewer
.getList().getItemCount() - 1 );
if (accountsListViewer.getList().getItemCount() > 0)
accountsListViewer.getList()
.select(accountsListViewer.getList().getItemCount() - 1 );
else
return;

String selectedAccountId =
extractAccountId( accountsListViewer.getList()
Expand Down

0 comments on commit 42fc9ee

Please sign in to comment.