Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Ritchie2015-11-13 18:54:07 -0500
committerGerrit Code Review @ Eclipse.org2015-11-16 20:47:06 -0500
commitcaeb07755d6648012df20b98664dc11a3101d7e5 (patch)
tree94f80cf9d13859e8067baa5f26b03e5f329fa693
parentf3dc0e76e5e8c3bf88211b175b6a67b01e267ffa (diff)
downloadorg.eclipse.mylyn.tasks-caeb07755d6648012df20b98664dc11a3101d7e5.tar.gz
org.eclipse.mylyn.tasks-caeb07755d6648012df20b98664dc11a3101d7e5.tar.xz
org.eclipse.mylyn.tasks-caeb07755d6648012df20b98664dc11a3101d7e5.zip
BUG 482186: AbstractRepositorySettingsPage server URL disabled
* Add API to the AbstractRepositorySettingsPage to disable the serverUrlCombo. Change-Id: I7b1024759122e0542eb8bd6cf65f4927664e384d Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=482186 Signed-off-by: Colin Ritchie <colin.ritchie@tasktop.com>
-rw-r--r--org.eclipse.mylyn.tasks.ui.tests/src/org/eclipse/mylyn/tasks/ui/wizards/RepositorySettingsPageTest.java43
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositorySettingsPage.java63
2 files changed, 86 insertions, 20 deletions
diff --git a/org.eclipse.mylyn.tasks.ui.tests/src/org/eclipse/mylyn/tasks/ui/wizards/RepositorySettingsPageTest.java b/org.eclipse.mylyn.tasks.ui.tests/src/org/eclipse/mylyn/tasks/ui/wizards/RepositorySettingsPageTest.java
index 90cf7fb74..1a595dc87 100644
--- a/org.eclipse.mylyn.tasks.ui.tests/src/org/eclipse/mylyn/tasks/ui/wizards/RepositorySettingsPageTest.java
+++ b/org.eclipse.mylyn.tasks.ui.tests/src/org/eclipse/mylyn/tasks/ui/wizards/RepositorySettingsPageTest.java
@@ -12,7 +12,9 @@
package org.eclipse.mylyn.tasks.ui.wizards;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
@@ -28,6 +30,7 @@ import org.eclipse.jface.wizard.IWizardContainer;
import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryConnector;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.PlatformUI;
import org.junit.Test;
@@ -63,6 +66,10 @@ public class RepositorySettingsPageTest {
protected void createAdditionalControls(Composite parent) {
// ignore
}
+
+ Combo getServerUrlCombo() {
+ return serverUrlCombo;
+ }
}
public static class RepositorySettingsPageWithNoCredentials extends TestRepositorySettingsPage {
@@ -172,6 +179,42 @@ public class RepositorySettingsPageTest {
assertEquals("Title", page.getTitle());
}
+ @Test
+ public void setUrlReadOnlyNotCalled() throws Exception {
+ TestRepositorySettingsPage page = new TestRepositorySettingsPage(createTaskRepository());
+ page.createControl(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+ Combo serverUrlCombo = page.getServerUrlCombo();
+ assertTrue(serverUrlCombo.isEnabled());
+ }
+
+ @Test
+ public void setUrlReadOnlyTrue() throws Exception {
+ TestRepositorySettingsPage page = new TestRepositorySettingsPage(createTaskRepository());
+ page.setUrlReadOnly(true);
+ page.createControl(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+ Combo serverUrlCombo = page.getServerUrlCombo();
+ assertFalse(serverUrlCombo.isEnabled());
+ }
+
+ @Test
+ public void setUrlReadOnlyFalse() throws Exception {
+ TestRepositorySettingsPage page = new TestRepositorySettingsPage(createTaskRepository());
+ page.setUrlReadOnly(false);
+ page.createControl(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+ Combo serverUrlCombo = page.getServerUrlCombo();
+ assertTrue(serverUrlCombo.isEnabled());
+ }
+
+ @Test
+ public void isUrlReadOnly() throws Exception {
+ TestRepositorySettingsPage page = new TestRepositorySettingsPage(createTaskRepository());
+ assertFalse(page.isUrlReadOnly());
+ page.setUrlReadOnly(true);
+ assertTrue(page.isUrlReadOnly());
+ page.setUrlReadOnly(false);
+ assertFalse(page.isUrlReadOnly());
+ }
+
private AbstractRepositorySettingsPage createPage(TaskRepository repository) {
AbstractRepositorySettingsPage page = spy(new RepositorySettingsPageWithNoCredentials(repository));
doReturn("label").when(page).getRepositoryLabel();
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 4a7836934..9c51e174e 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
@@ -133,6 +133,8 @@ public abstract class AbstractRepositorySettingsPage extends AbstractTaskReposit
protected Combo serverUrlCombo;
+ private boolean serverUrlReadOnly = false;
+
private String serverVersion = TaskRepository.NO_VERSION_SPECIFIED;
protected StringFieldEditor repositoryUserNameEditor;
@@ -420,28 +422,32 @@ public abstract class AbstractRepositorySettingsPage extends AbstractTaskReposit
Label serverLabel = new Label(compositeContainer, SWT.NONE);
serverLabel.setText(LABEL_SERVER);
serverUrlCombo = new Combo(compositeContainer, SWT.DROP_DOWN);
- serverUrlCombo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- if (getWizard() != null) {
- getWizard().getContainer().updateButtons();
+ if (serverUrlReadOnly) {
+ serverUrlCombo.setEnabled(false);
+ } else {
+ serverUrlCombo.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ if (getWizard() != null) {
+ getWizard().getContainer().updateButtons();
+ }
}
- }
- });
- serverUrlCombo.addFocusListener(new FocusAdapter() {
+ });
+ serverUrlCombo.addFocusListener(new FocusAdapter() {
- @Override
- public void focusLost(FocusEvent e) {
- updateHyperlinks();
- }
- });
- serverUrlCombo.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (getWizard() != null) {
- getWizard().getContainer().updateButtons();
+ @Override
+ public void focusLost(FocusEvent e) {
+ updateHyperlinks();
}
- }
- });
+ });
+ serverUrlCombo.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (getWizard() != null) {
+ getWizard().getContainer().updateButtons();
+ }
+ }
+ });
+ }
GridDataFactory.fillDefaults()
.hint(300, SWT.DEFAULT)
@@ -692,7 +698,7 @@ public abstract class AbstractRepositorySettingsPage extends AbstractTaskReposit
}
private void updateUrl() {
- serverUrlCombo.setText(repository.getRepositoryUrl());
+ setUrl(repository.getRepositoryUrl());
}
private void createAdvancedSection() {
@@ -1969,6 +1975,23 @@ public abstract class AbstractRepositorySettingsPage extends AbstractTaskReposit
}
/**
+ * Sets the URL control is read only, or can be edited.
+ *
+ * @since 3.18
+ */
+ public void setUrlReadOnly(boolean value) {
+ serverUrlReadOnly = value;
+ }
+
+ /**
+ * @return if the URL control is read-only.
+ * @since 3.18
+ */
+ public boolean isUrlReadOnly() {
+ return serverUrlReadOnly;
+ }
+
+ /**
* Public for testing.
*
* @since 2.0

Back to the top