Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrelves2010-05-25 16:07:15 -0400
committerrelves2010-05-25 16:07:15 -0400
commit105f9b524f9d34b780db0d0fbbc2517f53743651 (patch)
tree679270c961d7579079f7628125ad7a2d7e4c28fb /org.eclipse.mylyn.tasks.core
parent881b6c37cfae275e990e06dd3616b7e3a20e3012 (diff)
downloadorg.eclipse.mylyn.tasks-105f9b524f9d34b780db0d0fbbc2517f53743651.tar.gz
org.eclipse.mylyn.tasks-105f9b524f9d34b780db0d0fbbc2517f53743651.tar.xz
org.eclipse.mylyn.tasks-105f9b524f9d34b780db0d0fbbc2517f53743651.zip
NEW - bug 302907: [api] support categorization in Task Repositories view
https://bugs.eclipse.org/bugs/show_bug.cgi?id=302907
Diffstat (limited to 'org.eclipse.mylyn.tasks.core')
-rw-r--r--org.eclipse.mylyn.tasks.core/META-INF/MANIFEST.MF1
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/Category.java59
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/IRepositoryConstants.java12
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskRepositoryManager.java78
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryMigrator.java30
5 files changed, 177 insertions, 3 deletions
diff --git a/org.eclipse.mylyn.tasks.core/META-INF/MANIFEST.MF b/org.eclipse.mylyn.tasks.core/META-INF/MANIFEST.MF
index b9018cbd8..857a0009a 100644
--- a/org.eclipse.mylyn.tasks.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.tasks.core/META-INF/MANIFEST.MF
@@ -14,6 +14,7 @@ Export-Package: org.eclipse.mylyn.internal.provisional.tasks.core;x-internal:=tr
org.eclipse.mylyn.internal.tasks.core;x-friends:="org.eclipse.mylyn.tasks.ui,org.eclipse.mylyn.tasks.bugs",
org.eclipse.mylyn.internal.tasks.core.data;x-friends:="org.eclipse.mylyn.tasks.ui,org.eclipse.mylyn.tasks.bugs",
org.eclipse.mylyn.internal.tasks.core.externalization;x-friends:="org.eclipse.mylyn.tasks.ui,org.eclipse.mylyn.tasks.bugs",
+ org.eclipse.mylyn.internal.tasks.core.notifications;x-friends:="org.eclipse.mylyn.tasks.ui,org.eclipse.mylyn.tasks.bugs",
org.eclipse.mylyn.internal.tasks.core.sync;x-friends:="org.eclipse.mylyn.tasks.ui,org.eclipse.mylyn.tasks.bugs",
org.eclipse.mylyn.tasks.core,
org.eclipse.mylyn.tasks.core.data,
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/Category.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/Category.java
new file mode 100644
index 000000000..02c87dccc
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/Category.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.tasks.core;
+
+import org.eclipse.core.runtime.PlatformObject;
+
+/**
+ * Categories include Tasks, Bugs, Other...
+ *
+ * @author Robert Elves
+ */
+public class Category extends PlatformObject {
+
+ private final String id;
+
+ private final String label;
+
+ private final int rank;
+
+ public Category(String id, String label, int rank) {
+ this.id = id;
+ this.label = label;
+ this.rank = rank;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public int compareTo(Object arg0) {
+ if (arg0 instanceof Category) {
+ return this.getRank() - ((Category) arg0).getRank();
+ }
+ return 0;
+ }
+
+ public int getRank() {
+ return rank;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ @Override
+ public String toString() {
+ return getLabel();
+ };
+
+}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/IRepositoryConstants.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/IRepositoryConstants.java
index 5105c9e3c..f31e48a98 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/IRepositoryConstants.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/IRepositoryConstants.java
@@ -29,6 +29,8 @@ public interface IRepositoryConstants {
public static final String PROPERTY_CONNECTOR_KIND = "kind"; //$NON-NLS-1$
+ public static final String PROPERTY_CATEGORY = "category"; //$NON-NLS-1$
+
public static final String PROPERTY_URL = "url"; //$NON-NLS-1$
public static final String PROPERTY_LABEL = "label"; //$NON-NLS-1$
@@ -37,4 +39,14 @@ public interface IRepositoryConstants {
public static final String KIND_UNKNOWN = "<unknown>"; //$NON-NLS-1$
+ public static final String CATEGORY_TASKS = "org.eclipse.mylyn.category.tasks"; //$NON-NLS-1$
+
+ public static final String CATEGORY_BUGS = "org.eclipse.mylyn.category.bugs"; //$NON-NLS-1$
+
+ public static final String CATEGORY_BUILD = "org.eclipse.mylyn.category.build"; //$NON-NLS-1$
+
+ public static final String CATEGORY_REVIEW = "org.eclipse.mylyn.category.review"; //$NON-NLS-1$
+
+ public static final String CATEGORY_OTHER = "org.eclipse.mylyn.category.other"; //$NON-NLS-1$
+
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskRepositoryManager.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskRepositoryManager.java
index 62c7a8615..c3d64d2b5 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskRepositoryManager.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskRepositoryManager.java
@@ -33,6 +33,7 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryDelta.Type;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
+import org.eclipse.mylyn.tasks.core.AbstractRepositoryMigrator;
import org.eclipse.mylyn.tasks.core.IRepositoryListener;
import org.eclipse.mylyn.tasks.core.IRepositoryManager;
import org.eclipse.mylyn.tasks.core.ITask;
@@ -57,6 +58,7 @@ public class TaskRepositoryManager implements IRepositoryManager {
private final Map<String, AbstractRepositoryConnector> repositoryConnectors = new HashMap<String, AbstractRepositoryConnector>();
+ // connector kinds to corresponding repositories
private final Map<String, Set<TaskRepository>> repositoryMap = new HashMap<String, Set<TaskRepository>>();
private final Set<IRepositoryListener> listeners = new CopyOnWriteArraySet<IRepositoryListener>();
@@ -67,6 +69,8 @@ public class TaskRepositoryManager implements IRepositoryManager {
public static final String PREFIX_LOCAL = "local-"; //$NON-NLS-1$
+ private static final Map<String, Category> repositoryCategories = new HashMap<String, Category>();
+
private final PropertyChangeListener PROPERTY_CHANGE_LISTENER = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
TaskRepositoryManager.this.notifyRepositorySettingsChanged((TaskRepository) evt.getSource(),
@@ -76,7 +80,20 @@ public class TaskRepositoryManager implements IRepositoryManager {
private final TaskRepositoriesExternalizer externalizer = new TaskRepositoriesExternalizer();
+ private List<AbstractRepositoryMigrator> migrators;
+
public TaskRepositoryManager() {
+ this.migrators = Collections.emptyList();
+ Category catTasks = new Category(IRepositoryConstants.CATEGORY_TASKS, "Tasks", 0); //$NON-NLS-1$
+ repositoryCategories.put(catTasks.getId(), catTasks);
+ Category catBugs = new Category(IRepositoryConstants.CATEGORY_BUGS, "Bugs", 100); //$NON-NLS-1$
+ repositoryCategories.put(catBugs.getId(), catBugs);
+ Category catBuild = new Category(IRepositoryConstants.CATEGORY_BUILD, "Build", 200); //$NON-NLS-1$
+ repositoryCategories.put(catBuild.getId(), catBuild);
+ Category catReview = new Category(IRepositoryConstants.CATEGORY_REVIEW, "Review", 300); //$NON-NLS-1$
+ repositoryCategories.put(catReview.getId(), catReview);
+ Category catOther = new Category(IRepositoryConstants.CATEGORY_OTHER, "Other", 400); //$NON-NLS-1$
+ repositoryCategories.put(catOther.getId(), catOther);
}
public synchronized Collection<AbstractRepositoryConnector> getRepositoryConnectors() {
@@ -118,6 +135,7 @@ public class TaskRepositoryManager implements IRepositoryManager {
// TODO 4.0 return false to indicate that remove was unsuccessful
return;
}
+
repository.addChangeListener(PROPERTY_CHANGE_LISTENER);
}
@@ -182,6 +200,19 @@ public class TaskRepositoryManager implements IRepositoryManager {
return sb.toString();
}
+ public Category getCategory(String id) {
+ Category category = repositoryCategories.get(IRepositoryConstants.CATEGORY_OTHER);
+ Category cat = repositoryCategories.get(id);
+ if (cat != null) {
+ category = cat;
+ }
+ return category;
+ }
+
+ public Collection<Category> getCategories() {
+ return Collections.unmodifiableCollection(repositoryCategories.values());
+ }
+
public TaskRepository getRepository(String kind, String urlString) {
Assert.isNotNull(kind);
Assert.isNotNull(urlString);
@@ -233,11 +264,11 @@ public class TaskRepositoryManager implements IRepositoryManager {
return null;
}
- public Set<TaskRepository> getRepositories(String kind) {
- Assert.isNotNull(kind);
+ public Set<TaskRepository> getRepositories(String connectorKind) {
+ Assert.isNotNull(connectorKind);
Set<TaskRepository> result;
synchronized (this) {
- result = repositoryMap.get(kind);
+ result = repositoryMap.get(connectorKind);
}
if (result == null) {
return Collections.emptySet();
@@ -309,9 +340,14 @@ public class TaskRepositoryManager implements IRepositoryManager {
if (removeHttpAuthMigration(repository)) {
migration = true;
}
+ if (applyMigrators(repository)) {
+ migration = true;
+ }
if (repositoryMap.containsKey(repository.getConnectorKind())) {
repositoryMap.get(repository.getConnectorKind()).add(repository);
+
repository.addChangeListener(PROPERTY_CHANGE_LISTENER);
+
} else {
orphanedRepositories.add(repository);
}
@@ -323,6 +359,33 @@ public class TaskRepositoryManager implements IRepositoryManager {
}
}
+ private boolean applyMigrators(final TaskRepository repository) {
+ final boolean[] result = new boolean[1];
+ for (AbstractRepositoryMigrator migrator : migrators) {
+ if (migrator.getConnectorKind().equals(repository.getConnectorKind())) {
+
+ final AbstractRepositoryMigrator finalRepositoryMigrator = migrator;
+ result[0] = false;
+ SafeRunner.run(new ISafeRunnable() {
+
+ public void handleException(Throwable e) {
+ StatusHandler.log(new Status(IStatus.WARNING, ITasksCoreConstants.ID_PLUGIN,
+ "Repository migration failed for repository \"" + repository.getUrl() + "\"", e)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void run() throws Exception {
+ if (finalRepositoryMigrator.migrateRepository(repository)) {
+ result[0] = true;
+ }
+ }
+
+ });
+ break;
+ }
+ }
+ return result[0];
+ }
+
@SuppressWarnings("deprecation")
private boolean removeHttpAuthMigration(TaskRepository repository) {
String httpusername = repository.getProperty(TaskRepository.AUTH_HTTP_USERNAME);
@@ -447,4 +510,13 @@ public class TaskRepositoryManager implements IRepositoryManager {
}
}
+ public Category getCategory(TaskRepository repository) {
+ String categoryId = repository.getProperty(IRepositoryConstants.PROPERTY_CATEGORY);
+ return getCategory(categoryId);
+ }
+
+ public void initialize(List<AbstractRepositoryMigrator> repositoryMigrators) {
+ this.migrators = repositoryMigrators;
+
+ }
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryMigrator.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryMigrator.java
new file mode 100644
index 000000000..ed302de15
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryMigrator.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.tasks.core;
+
+/**
+ * Implement a connector specific repository migrator to perform connector specific migration procedures on task
+ * repositories of the same connector kind upon startup. Override and contribute by the
+ * org.eclipse.mylyn.tasks.ui.repositories extension point's taskListMigrator element.
+ *
+ * @author Robert Elves
+ * @since 3.4
+ */
+public abstract class AbstractRepositoryMigrator {
+
+ public abstract String getConnectorKind();
+
+ public boolean migrateRepository(TaskRepository repository) {
+ return false;
+ }
+
+}

Back to the top