Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui')
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositorySettingsPage.java258
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;
}

Back to the top