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/internal/tasklist/ui/actions/NewRepositoryTaskAction.java83
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasklist/ui/wizards/NewRepositoryTaskPage.java36
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/provisional/tasklist/AbstractRepositoryConnector.java121
3 files changed, 240 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasklist/ui/actions/NewRepositoryTaskAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasklist/ui/actions/NewRepositoryTaskAction.java
new file mode 100644
index 000000000..e38bde8f5
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasklist/ui/actions/NewRepositoryTaskAction.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2004 - 2006 University Of British Columbia 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:
+ * University Of British Columbia - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylar.internal.tasklist.ui.actions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.mylar.internal.tasklist.TaskListPreferenceConstants;
+import org.eclipse.mylar.internal.tasklist.ui.wizards.MultiRepositoryAwareWizard;
+import org.eclipse.mylar.internal.tasklist.ui.wizards.NewRepositoryTaskPage;
+import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryConnector;
+import org.eclipse.mylar.provisional.tasklist.MylarTaskListPlugin;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IViewActionDelegate;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * @author Mik Kersten and Ken Sueda
+ */
+public class NewRepositoryTaskAction extends Action implements IViewActionDelegate {
+
+ public static final String ID = "org.eclipse.mylar.tasklist.ui.repositories.actions.create";
+
+ @Override
+ public void run() {
+
+ boolean offline = MylarTaskListPlugin.getPrefs().getBoolean(TaskListPreferenceConstants.WORK_OFFLINE);
+ if (offline) {
+ MessageDialog.openInformation(null, "Unable to create bug report",
+ "Unable to create a new bug report since you are currently offline");
+ return;
+ }
+ // TaskRepository repository =
+ // MylarTaskListPlugin.getRepositoryManager().getDefaultRepository(BugzillaPlugin.REPOSITORY_KIND);
+ List<String> connectorKinds = new ArrayList<String>();
+ for (AbstractRepositoryConnector client: MylarTaskListPlugin.getRepositoryManager().getRepositoryClients()) {
+ if (client.canCreateTaskFromId()) {
+ connectorKinds.add(client.getRepositoryType());
+ }
+ }
+
+ IWizard wizard = new MultiRepositoryAwareWizard(new NewRepositoryTaskPage(connectorKinds));
+
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ if (wizard != null && shell != null && !shell.isDisposed()) {
+
+ WizardDialog dialog = new WizardDialog(shell, wizard);
+ dialog.setBlockOnOpen(true);
+ dialog.open();
+
+ } else {
+ // TODO handle not good
+ }
+ }
+
+ public void init(IViewPart view) {
+
+ }
+
+ public void run(IAction action) {
+ run();
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+
+ }
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasklist/ui/wizards/NewRepositoryTaskPage.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasklist/ui/wizards/NewRepositoryTaskPage.java
new file mode 100644
index 000000000..3ed78aae2
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasklist/ui/wizards/NewRepositoryTaskPage.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2004 - 2006 University Of British Columbia 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:
+ * University Of British Columbia - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylar.internal.tasklist.ui.wizards;
+
+import java.util.List;
+
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryConnector;
+import org.eclipse.mylar.provisional.tasklist.MylarTaskListPlugin;
+import org.eclipse.mylar.provisional.tasklist.TaskRepository;
+
+/**
+ * @author Mik Kersten
+ */
+public class NewRepositoryTaskPage extends SelectRepositoryPage {
+
+ public NewRepositoryTaskPage(List<String> kinds) {
+ super(kinds);
+ }
+
+ @Override
+ protected IWizard createWizard(TaskRepository taskRepository) {
+ AbstractRepositoryConnector connector = MylarTaskListPlugin.getRepositoryManager().getRepositoryClient(
+ taskRepository.getKind());
+ return connector.getNewTaskWizard(taskRepository);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/provisional/tasklist/AbstractRepositoryConnector.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/provisional/tasklist/AbstractRepositoryConnector.java
new file mode 100644
index 000000000..17528b384
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/provisional/tasklist/AbstractRepositoryConnector.java
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright (c) 2004 - 2006 University Of British Columbia 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:
+ * University Of British Columbia - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylar.provisional.tasklist;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.jobs.IJobChangeListener;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.mylar.internal.tasklist.ui.wizards.AbstractRepositorySettingsPage;
+
+/**
+ * @author Mik Kersten
+ */
+public abstract class AbstractRepositoryConnector {
+
+ private static final int MAX_REFRESH_JOBS = 5;
+
+ private List<AbstractRepositoryTask> toBeRefreshed = new LinkedList<AbstractRepositoryTask>();
+
+ private Map<AbstractRepositoryTask, Job> currentlyRefreshing = new HashMap<AbstractRepositoryTask, Job>();
+
+ public abstract boolean canCreateTaskFromId();
+
+ public abstract boolean canCreateNewTask();
+
+ public void requestRefresh(AbstractRepositoryTask task) {
+ if (!currentlyRefreshing.containsKey(task) && !toBeRefreshed.contains(task)) {
+ toBeRefreshed.add(task);
+ }
+ updateRefreshState();
+ }
+
+ public void removeTaskToBeRefreshed(AbstractRepositoryTask task) {
+ toBeRefreshed.remove(task);
+ if (currentlyRefreshing.get(task) != null) {
+ currentlyRefreshing.get(task).cancel();
+ currentlyRefreshing.remove(task);
+ }
+ updateRefreshState();
+ }
+
+ public void removeRefreshingTask(AbstractRepositoryTask task) {
+ if (currentlyRefreshing.containsKey(task)) {
+ currentlyRefreshing.remove(task);
+ }
+ updateRefreshState();
+ }
+
+ public void clearAllRefreshes() {
+ toBeRefreshed.clear();
+ List<Job> l = new ArrayList<Job>();
+ l.addAll(currentlyRefreshing.values());
+ for (Job j : l) {
+ if (j != null)
+ j.cancel();
+ }
+ currentlyRefreshing.clear();
+ }
+
+ private void updateRefreshState() {
+ if (currentlyRefreshing.size() < MAX_REFRESH_JOBS && toBeRefreshed.size() > 0) {
+ AbstractRepositoryTask bugzillaTask = toBeRefreshed.remove(0);
+ Job refreshJob = synchronize(bugzillaTask, true, null);
+ if (refreshJob != null) {
+ currentlyRefreshing.put(bugzillaTask, refreshJob);
+ }
+ }
+ }
+
+ public abstract String getLabel();
+
+ /**
+ * @return the unique type of the repository, e.g. "bugzilla"
+ */
+ public abstract String getRepositoryType();
+
+ /**
+ * @param id
+ * identifier, e.g. "123" bug Bugzilla bug 123
+ * @return null if task could not be created
+ */
+ public abstract ITask createTaskFromExistingId(TaskRepository repository, String id);
+
+ /**
+ * Synchronize state with the repository (e.g. queries, task contents)
+ */
+ public abstract void synchronize();
+
+ /**
+ * @param listener can be null
+ * @return TODO
+ */
+ public abstract Job synchronize(ITask task, boolean forceUpdate, IJobChangeListener listener);
+
+ public abstract void synchronize(AbstractRepositoryQuery repositoryQuery);
+
+ public abstract AbstractRepositorySettingsPage getSettingsPage();
+
+ public abstract IWizard getQueryWizard(TaskRepository repository);
+
+ public abstract void openEditQueryDialog(AbstractRepositoryQuery query);
+
+ public abstract IWizard getAddExistingTaskWizard(TaskRepository repository);
+
+ public abstract IWizard getNewTaskWizard(TaskRepository taskRepository);
+
+}

Back to the top