Skip to content

Commit

Permalink
Fixed bug 3270
Browse files Browse the repository at this point in the history
  • Loading branch information
KlasJoensson committed Aug 22, 2012
1 parent 1b543aa commit 0b4153c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 33 deletions.
Expand Up @@ -39,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 @@ -98,36 +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();

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;
}

@Override
Expand Down
Expand Up @@ -243,7 +243,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 +253,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

0 comments on commit 0b4153c

Please sign in to comment.