diff options
author | David Green | 2013-11-01 16:11:12 +0000 |
---|---|---|
committer | David Green | 2013-11-01 17:12:11 +0000 |
commit | 7f02c47b9bdfbb3c167f4aea45472828a2e11af5 (patch) | |
tree | 3ea1c2a3a8d5aae218999497c48581a6b497be27 /org.eclipse.mylyn.tasks.ui | |
parent | 6458ca90102c0fba2b901412541111a7ad1efb58 (diff) | |
download | org.eclipse.mylyn.tasks-7f02c47b9bdfbb3c167f4aea45472828a2e11af5.tar.gz org.eclipse.mylyn.tasks-7f02c47b9bdfbb3c167f4aea45472828a2e11af5.tar.xz org.eclipse.mylyn.tasks-7f02c47b9bdfbb3c167f4aea45472828a2e11af5.zip |
SDK-541: Username and password fields on repository should be optional
Change-Id: Ie5921de64c9c98cfe9775d0b91dad0c703f29e95
Task-Url: https://tasktop.atlassian.net/browse/SDK-541
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui')
-rw-r--r-- | org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositorySettingsPage.java | 258 |
1 files changed, 143 insertions, 115 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositorySettingsPage.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositorySettingsPage.java index 26ab6ad49..a2bc3a2ba 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositorySettingsPage.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositorySettingsPage.java @@ -188,6 +188,8 @@ public abstract class AbstractRepositorySettingsPage extends AbstractTaskReposit private boolean needsAdvanced; + private boolean needsRepositoryCredentials = true; + protected Composite compositeContainer; private Composite advancedComp; @@ -323,7 +325,9 @@ public abstract class AbstractRepositorySettingsPage extends AbstractTaskReposit } Point p = innerComposite.getContent().computeSize(SWT.DEFAULT, SWT.DEFAULT, true); innerComposite.setMinSize(p); - swapUserNameWithAnonymousInTabList(); + if (needsRepositoryCredentials()) { + swapUserNameWithAnonymousInTabList(); + } Dialog.applyDialogFont(innerComposite); setControl(innerComposite); } @@ -445,6 +449,120 @@ public abstract class AbstractRepositorySettingsPage extends AbstractTaskReposit } }); + if (needsRepositoryCredentials()) { + createRepositoryCredentialsSection(); + } + + // TODO: put this back if we can't get the info from all connectors + // if (needsTimeZone()) { + // Label timeZoneLabel = new Label(container, SWT.NONE); + // timeZoneLabel.setText("Repository time zone: "); + // timeZonesCombo = new Combo(container, SWT.READ_ONLY); + // String[] timeZoneIds = TimeZone.getAvailableIDs(); + // Arrays.sort(timeZoneIds); + // for (String zone : timeZoneIds) { + // timeZonesCombo.add(zone); + // } + // boolean setZone = false; + // if (repository != null) { + // if (timeZonesCombo.indexOf(repository.getTimeZoneId()) > -1) { + // timeZonesCombo.select(timeZonesCombo.indexOf(repository.getTimeZoneId())); + // setZone = true; + // } + // } + // if (!setZone) { + // timeZonesCombo.select(timeZonesCombo.indexOf(TimeZone.getDefault().getID())); + // } + // } + + if (needsAdvanced() || needsEncoding()) { + createAdvancedSection(); + } + + if (needsCertAuth()) { + createCertAuthSection(); + } + + if (needsHttpAuth()) { + createHttpAuthSection(); + } + + if (needsProxy()) { + createProxySection(); + } + + createContributionControls(innerComposite); + + Composite managementComposite = new Composite(compositeContainer, SWT.NULL); + GridLayout managementLayout = new GridLayout(4, false); + managementLayout.marginHeight = 0; + managementLayout.marginWidth = 0; + managementLayout.horizontalSpacing = 10; + managementComposite.setLayout(managementLayout); + managementComposite.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 2, 1)); + + createAccountHyperlink = toolkit.createHyperlink(managementComposite, + Messages.AbstractRepositorySettingsPage_Create_new_account, SWT.NONE); + createAccountHyperlink.setBackground(managementComposite.getBackground()); + createAccountHyperlink.addHyperlinkListener(new HyperlinkAdapter() { + @Override + public void linkActivated(HyperlinkEvent e) { +// TaskRepository repository = getRepository(); + TaskRepository repository = createTaskRepository(); +// if (repository == null && getServerUrl() != null && getServerUrl().length() > 0) { +// repository = createTaskRepository(); +// } + if (repository != null) { + String accountCreationUrl = TasksUiPlugin.getConnectorUi(connector.getConnectorKind()) + .getAccountCreationUrl(repository); + if (accountCreationUrl != null) { + BrowserUtil.openUrl(accountCreationUrl, IWorkbenchBrowserSupport.AS_EXTERNAL); + } + } + } + }); + + manageAccountHyperlink = toolkit.createHyperlink(managementComposite, + Messages.AbstractRepositorySettingsPage_Change_account_settings, SWT.NONE); + manageAccountHyperlink.setBackground(managementComposite.getBackground()); + manageAccountHyperlink.addHyperlinkListener(new HyperlinkAdapter() { + @Override + public void linkActivated(HyperlinkEvent e) { + TaskRepository repository = getRepository(); + if (repository == null && getRepositoryUrl() != null && getRepositoryUrl().length() > 0) { + repository = createTaskRepository(); + } + if (repository != null) { + String accountManagementUrl = TasksUiPlugin.getConnectorUi(connector.getConnectorKind()) + .getAccountManagementUrl(repository); + if (accountManagementUrl != null) { + BrowserUtil.openUrl(accountManagementUrl, IWorkbenchBrowserSupport.AS_EXTERNAL); + } + } + } + }); + + if (needsRepositoryCredentials()) { + // bug 131656: must set echo char after setting value on Mac + ((RepositoryStringFieldEditor) repositoryPasswordEditor).getTextControl().setEchoChar('*'); + + if (needsAnonymousLogin()) { + // do this after username and password widgets have been intialized + if (repository != null) { + setAnonymous(isAnonymousAccess()); + } + } + } + + updateHyperlinks(); + if (repository != null) { + saveToValidatedProperties(createTaskRepository()); + } + GridLayout layout = new GridLayout(3, false); + compositeContainer.setLayout(layout); + } + + private void createRepositoryCredentialsSection() { repositoryUserNameEditor = new StringFieldEditor("", LABEL_USER, StringFieldEditor.UNLIMITED, //$NON-NLS-1$ compositeContainer) { @@ -557,112 +675,6 @@ public abstract class AbstractRepositorySettingsPage extends AbstractTaskReposit } else { savePasswordButton.setSelection(false); } - - // TODO: put this back if we can't get the info from all connectors - // if (needsTimeZone()) { - // Label timeZoneLabel = new Label(container, SWT.NONE); - // timeZoneLabel.setText("Repository time zone: "); - // timeZonesCombo = new Combo(container, SWT.READ_ONLY); - // String[] timeZoneIds = TimeZone.getAvailableIDs(); - // Arrays.sort(timeZoneIds); - // for (String zone : timeZoneIds) { - // timeZonesCombo.add(zone); - // } - // boolean setZone = false; - // if (repository != null) { - // if (timeZonesCombo.indexOf(repository.getTimeZoneId()) > -1) { - // timeZonesCombo.select(timeZonesCombo.indexOf(repository.getTimeZoneId())); - // setZone = true; - // } - // } - // if (!setZone) { - // timeZonesCombo.select(timeZonesCombo.indexOf(TimeZone.getDefault().getID())); - // } - // } - - if (needsAdvanced() || needsEncoding()) { - createAdvancedSection(); - } - - if (needsCertAuth()) { - createCertAuthSection(); - } - - if (needsHttpAuth()) { - createHttpAuthSection(); - } - - if (needsProxy()) { - createProxySection(); - } - - createContributionControls(innerComposite); - - Composite managementComposite = new Composite(compositeContainer, SWT.NULL); - GridLayout managementLayout = new GridLayout(4, false); - managementLayout.marginHeight = 0; - managementLayout.marginWidth = 0; - managementLayout.horizontalSpacing = 10; - managementComposite.setLayout(managementLayout); - managementComposite.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 2, 1)); - - createAccountHyperlink = toolkit.createHyperlink(managementComposite, - Messages.AbstractRepositorySettingsPage_Create_new_account, SWT.NONE); - createAccountHyperlink.setBackground(managementComposite.getBackground()); - createAccountHyperlink.addHyperlinkListener(new HyperlinkAdapter() { - @Override - public void linkActivated(HyperlinkEvent e) { -// TaskRepository repository = getRepository(); - TaskRepository repository = createTaskRepository(); -// if (repository == null && getServerUrl() != null && getServerUrl().length() > 0) { -// repository = createTaskRepository(); -// } - if (repository != null) { - String accountCreationUrl = TasksUiPlugin.getConnectorUi(connector.getConnectorKind()) - .getAccountCreationUrl(repository); - if (accountCreationUrl != null) { - BrowserUtil.openUrl(accountCreationUrl, IWorkbenchBrowserSupport.AS_EXTERNAL); - } - } - } - }); - - manageAccountHyperlink = toolkit.createHyperlink(managementComposite, - Messages.AbstractRepositorySettingsPage_Change_account_settings, SWT.NONE); - manageAccountHyperlink.setBackground(managementComposite.getBackground()); - manageAccountHyperlink.addHyperlinkListener(new HyperlinkAdapter() { - @Override - public void linkActivated(HyperlinkEvent e) { - TaskRepository repository = getRepository(); - if (repository == null && getRepositoryUrl() != null && getRepositoryUrl().length() > 0) { - repository = createTaskRepository(); - } - if (repository != null) { - String accountManagementUrl = TasksUiPlugin.getConnectorUi(connector.getConnectorKind()) - .getAccountManagementUrl(repository); - if (accountManagementUrl != null) { - BrowserUtil.openUrl(accountManagementUrl, IWorkbenchBrowserSupport.AS_EXTERNAL); - } - } - } - }); - - // bug 131656: must set echo char after setting value on Mac - ((RepositoryStringFieldEditor) repositoryPasswordEditor).getTextControl().setEchoChar('*'); - - if (needsAnonymousLogin()) { - // do this after username and password widgets have been intialized - if (repository != null) { - setAnonymous(isAnonymousAccess()); - } - } - - updateHyperlinks(); - if (repository != null) { - saveToValidatedProperties(createTaskRepository()); - } - GridLayout layout = new GridLayout(3, false); - compositeContainer.setLayout(layout); } private void createAdvancedSection() { @@ -1586,8 +1598,8 @@ public abstract class AbstractRepositorySettingsPage extends AbstractTaskReposit if (!isValidUrl(url)) { errorMessage = Messages.AbstractRepositorySettingsPage_Enter_a_valid_server_url; } - if (errorMessage == null && (!needsAnonymousLogin() || !anonymousButton.getSelection()) - && isMissingCredentials()) { + if (errorMessage == null && needsRepositoryCredentials() + && (!needsAnonymousLogin() || !anonymousButton.getSelection()) && isMissingCredentials()) { errorMessage = Messages.AbstractRepositorySettingsPage_Enter_a_user_id_Message0; } setMessage(errorMessage, repository == null ? IMessageProvider.NONE : IMessageProvider.ERROR); @@ -1603,7 +1615,7 @@ public abstract class AbstractRepositorySettingsPage extends AbstractTaskReposit * @since 3.4 */ protected boolean isMissingCredentials() { - return repositoryUserNameEditor.getStringValue().trim().equals("") //$NON-NLS-1$ + return needsRepositoryCredentials() && repositoryUserNameEditor.getStringValue().trim().equals("") //$NON-NLS-1$ || (getSavePassword() && repositoryPasswordEditor.getStringValue().trim().equals("")); //$NON-NLS-1$ } @@ -1706,11 +1718,13 @@ public abstract class AbstractRepositorySettingsPage extends AbstractTaskReposit repository.setCharacterEncoding(getCharacterEncoding()); } - if (isAnonymousAccess()) { - repository.setCredentials(AuthenticationType.REPOSITORY, null, getSavePassword()); - } else { - AuthenticationCredentials credentials = new AuthenticationCredentials(getUserName(), getPassword()); - repository.setCredentials(AuthenticationType.REPOSITORY, credentials, getSavePassword()); + if (needsRepositoryCredentials()) { + if (isAnonymousAccess()) { + repository.setCredentials(AuthenticationType.REPOSITORY, null, getSavePassword()); + } else { + AuthenticationCredentials credentials = new AuthenticationCredentials(getUserName(), getPassword()); + repository.setCredentials(AuthenticationType.REPOSITORY, credentials, getSavePassword()); + } } repository.setRepositoryLabel(getRepositoryLabel()); @@ -1783,6 +1797,13 @@ public abstract class AbstractRepositorySettingsPage extends AbstractTaskReposit } /** + * @since 3.10 + */ + public boolean needsRepositoryCredentials() { + return needsRepositoryCredentials; + } + + /** * @since 2.0 */ public boolean needsAdvanced() { @@ -1859,6 +1880,13 @@ public abstract class AbstractRepositorySettingsPage extends AbstractTaskReposit this.needsAnonymousLogin = needsAnonymousLogin; } + /** + * @since 3.10 + */ + public void setNeedsRepositoryCredentials(boolean needsCredentials) { + this.needsRepositoryCredentials = needsCredentials; + } + public void setNeedsValidation(boolean needsValidation) { this.needsValidation = needsValidation; } |