Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Green2013-11-01 16:11:12 +0000
committerSteffen Pingel2013-11-08 12:12:29 +0000
commit692f3d53eb4ce18ea8280008b83f9960f5b29251 (patch)
tree45485d73bc43741750997dee1a697aef8d3281fc /org.eclipse.mylyn.tasks.ui/src/org
parentce086e61ebf3d576ef6521c7505f0b7c2355d9e4 (diff)
downloadorg.eclipse.mylyn.tasks-692f3d53eb4ce18ea8280008b83f9960f5b29251.tar.gz
org.eclipse.mylyn.tasks-692f3d53eb4ce18ea8280008b83f9960f5b29251.tar.xz
org.eclipse.mylyn.tasks-692f3d53eb4ce18ea8280008b83f9960f5b29251.zip
420877: enhance AbstractRepositorySettingsPage to support repositories
that take no credentials Change-Id: Ifd82eeb43025d4684a068bfc8b60fc81ca2888f6 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=420877
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui/src/org')
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositorySettingsPage.java237
1 files changed, 122 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..79dfc2f82 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;
+
protected Composite compositeContainer;
private Composite advancedComp;
@@ -269,6 +271,7 @@ public abstract class AbstractRepositorySettingsPage extends AbstractTaskReposit
throw new IllegalArgumentException(
"connectorKind of repository does not match connectorKind of page, expected '" + getConnectorKind() + "', got '" + repository.getConnectorKind() + "'"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
+ setNeedsRepositoryCredentials(true);
setNeedsAnonymousLogin(false);
setNeedsEncoding(true);
setNeedsTimeZone(true);
@@ -323,7 +326,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 +450,98 @@ public abstract class AbstractRepositorySettingsPage extends AbstractTaskReposit
}
});
+ if (needsRepositoryCredentials()) {
+ createRepositoryCredentialsSection();
+ }
+
+ 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 +654,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 +1577,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 +1594,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 +1697,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 +1776,13 @@ public abstract class AbstractRepositorySettingsPage extends AbstractTaskReposit
}
/**
+ * @since 3.11
+ */
+ public boolean needsRepositoryCredentials() {
+ return needsRepositoryCredentials;
+ }
+
+ /**
* @since 2.0
*/
public boolean needsAdvanced() {
@@ -1859,6 +1859,13 @@ public abstract class AbstractRepositorySettingsPage extends AbstractTaskReposit
this.needsAnonymousLogin = needsAnonymousLogin;
}
+ /**
+ * @since 3.11
+ */
+ public void setNeedsRepositoryCredentials(boolean needsRepositoryCredentials) {
+ this.needsRepositoryCredentials = needsRepositoryCredentials;
+ }
+
public void setNeedsValidation(boolean needsValidation) {
this.needsValidation = needsValidation;
}

Back to the top