summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Muskalla2013-06-06 08:22:39 (EDT)
committerBenjamin Muskalla2013-06-06 08:22:39 (EDT)
commitab4249689cd86de3880f566b2fe453e20baaf6ba (patch)
treebd2d05994071929827b1e76bff1761f227134fd4
parent810a52cbbdadee42693d04d354031bcec400502b (diff)
downloadorg.eclipse.mylyn.tasks-ab4249689cd86de3880f566b2fe453e20baaf6ba.zip
org.eclipse.mylyn.tasks-ab4249689cd86de3880f566b2fe453e20baaf6ba.tar.gz
org.eclipse.mylyn.tasks-ab4249689cd86de3880f566b2fe453e20baaf6ba.tar.bz2
410062: settings page constructor should not rely on overridden methodsrefs/changes/15/13615/1
Change-Id: I56f339de4d58d745af067ea65ba521496c97b885 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=410062
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/RepositorySettingsPageTest.java12
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositorySettingsPage.java18
2 files changed, 27 insertions, 3 deletions
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/RepositorySettingsPageTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/RepositorySettingsPageTest.java
index 70ba21b..efaba79 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/RepositorySettingsPageTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/RepositorySettingsPageTest.java
@@ -16,6 +16,7 @@ import junit.framework.TestCase;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.mylyn.commons.net.AuthenticationType;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
+import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryConnector;
import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryConnectorUi;
@@ -228,12 +229,23 @@ public class RepositorySettingsPageTest extends TestCase {
assertTrue(page.isValidUrl("http://www.mylyn.org/bugzilla34"));
}
+ public void testInjectConnectorIntoSettingsPage() throws Exception {
+ TaskRepository repository = new TaskRepository(MockRepositoryConnector.CONNECTOR_KIND, "http://localhost/");
+ MockRepositoryConnector connector = new MockRepositoryConnector();
+ MockRepositorySettingsPage page = new MockRepositorySettingsPage(repository, connector);
+ assertSame(page.getConnector(), connector);
+ }
+
private class MockRepositorySettingsPage extends AbstractRepositorySettingsPage {
public MockRepositorySettingsPage(TaskRepository taskRepository) {
super("title", "summary", taskRepository);
}
+ public MockRepositorySettingsPage(TaskRepository taskRepository, AbstractRepositoryConnector connector) {
+ super("title", "summary", taskRepository, connector);
+ }
+
@Override
protected void createAdditionalControls(Composite parent) {
// ignore
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 c67a526..c9c4dab 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
@@ -89,6 +89,7 @@ import org.eclipse.ui.statushandlers.StatusManager;
* @author Frank Becker
* @author David Green
* @author Helen Bershadskaya
+ * @author Benjamin Muskalla
* @since 2.0
*/
public abstract class AbstractRepositorySettingsPage extends AbstractTaskRepositoryPage implements ITaskRepositoryPage,
@@ -244,12 +245,16 @@ public abstract class AbstractRepositorySettingsPage extends AbstractTaskReposit
protected SectionComposite innerComposite;
/**
- * @since 3.0
+ * @since 3.10
*/
- public AbstractRepositorySettingsPage(String title, String description, TaskRepository taskRepository) {
+ public AbstractRepositorySettingsPage(String title, String description, TaskRepository taskRepository,
+ AbstractRepositoryConnector connector) {
super(title, description, taskRepository);
repository = taskRepository;
- this.connector = TasksUi.getRepositoryManager().getRepositoryConnector(getConnectorKind());
+ if (connector == null) {
+ connector = TasksUi.getRepositoryManager().getRepositoryConnector(getConnectorKind());
+ }
+ this.connector = connector;
setNeedsAnonymousLogin(false);
setNeedsEncoding(true);
setNeedsTimeZone(true);
@@ -262,6 +267,13 @@ public abstract class AbstractRepositorySettingsPage extends AbstractTaskReposit
/**
* @since 3.0
*/
+ public AbstractRepositorySettingsPage(String title, String description, TaskRepository taskRepository) {
+ this(title, description, taskRepository, null);
+ }
+
+ /**
+ * @since 3.0
+ */
@Override
public abstract String getConnectorKind();