Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.mylyn.tasks.ui/plugin.xml171
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/commands/DisconnectHandler.java83
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/commands/RefreshRepositoryHandler.java35
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/commands/UpdateRepositoryConfiguration.java35
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskRepositoryPropertyTester.java4
5 files changed, 326 insertions, 2 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/plugin.xml b/org.eclipse.mylyn.tasks.ui/plugin.xml
index e82cf54bb..c8a0cd882 100644
--- a/org.eclipse.mylyn.tasks.ui/plugin.xml
+++ b/org.eclipse.mylyn.tasks.ui/plugin.xml
@@ -1939,7 +1939,7 @@
class="org.eclipse.mylyn.internal.tasks.ui.util.TaskRepositoryPropertyTester"
id="org.eclipse.mylyn.tasks.ui.propertyTester.taskRepository"
namespace="org.eclipse.mylyn.taskRepository"
- properties="connectorKind,userManaged"
+ properties="connectorKind,userManaged,disconnected"
type="org.eclipse.mylyn.tasks.core.TaskRepository">
</propertyTester>
<propertyTester
@@ -2384,5 +2384,172 @@
id="org.eclipse.mylyn.tasks.ui.urlHandler.TaskUrlHandler">
</handler>
</extension>
-
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="false"
+ locationURI="popup:org.eclipse.mylyn.commons.repositories.ui.navigator.Repositories?after=group.edit">
+ <command
+ commandId="org.eclipse.mylyn.tasks.ui.command.UpdateRepositoryConfiguration"
+ label="Update Repository Configuration"
+ style="toggle">
+ <visibleWhen
+ checkEnabled="false">
+ <iterate>
+ <instanceof
+ value="org.eclipse.mylyn.tasks.core.TaskRepository">
+ </instanceof>
+ </iterate>
+ </visibleWhen>
+ </command>
+ <separator
+ name="org.eclipse.mylyn.tasks.ui.separatorBeforeDisconnected"
+ visible="true">
+ </separator>
+ <command
+ commandId="org.eclipse.mylyn.tasks.ui.command.disconnected"
+ label="Disconnected"
+ style="toggle">
+ <visibleWhen
+ checkEnabled="false">
+ <iterate>
+ <instanceof
+ value="org.eclipse.mylyn.tasks.core.TaskRepository">
+ </instanceof>
+ </iterate>
+ </visibleWhen>
+ </command>
+ <separator
+ name="org.eclipse.mylyn.tasks.ui.separatorAfterDisconnected"
+ visible="true">
+ </separator>
+ <command
+ commandId="org.eclipse.mylyn.tasks.ui.command.RefreshRepositoryTasks"
+ icon="icons/etool16/repository-synchronize.gif"
+ label="Synchronize All Tasks"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <iterate>
+ <instanceof
+ value="org.eclipse.mylyn.tasks.core.TaskRepository">
+ </instanceof>
+ </iterate>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ </extension>
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="org.eclipse.mylyn.internal.tasks.ui.commands.UpdateRepositoryConfiguration"
+ commandId="org.eclipse.mylyn.tasks.ui.command.UpdateRepositoryConfiguration">
+ <activeWhen>
+ <iterate>
+ <and>
+ <instanceof
+ value="org.eclipse.mylyn.tasks.core.TaskRepository">
+ </instanceof>
+ <not>
+ <test
+ property="org.eclipse.mylyn.taskRepository.connectorKind"
+ value="local">
+ </test>
+ </not>
+ </and>
+ </iterate>
+ </activeWhen>
+ </handler>
+ <handler
+ class="org.eclipse.mylyn.internal.tasks.ui.commands.DisconnectHandler"
+ commandId="org.eclipse.mylyn.tasks.ui.command.disconnected">
+ <activeWhen>
+ <and>
+ <with
+ variable="activePartId">
+ <equals
+ value="org.eclipse.mylyn.commons.repositories.ui.navigator.Repositories">
+ </equals>
+ </with>
+ <iterate>
+ <and>
+ <instanceof
+ value="org.eclipse.mylyn.tasks.core.TaskRepository">
+ </instanceof>
+ <not>
+ <test
+ property="org.eclipse.mylyn.taskRepository.connectorKind"
+ value="local">
+ </test>
+ </not>
+ </and>
+ </iterate>
+ <or>
+ <iterate>
+ <and>
+ <instanceof
+ value="org.eclipse.mylyn.tasks.core.TaskRepository">
+ </instanceof>
+ <test
+ property="org.eclipse.mylyn.taskRepository.disconnected"
+ value="true">
+ </test>
+ </and>
+ </iterate>
+ <iterate>
+ <and>
+ <instanceof
+ value="org.eclipse.mylyn.tasks.core.TaskRepository">
+ </instanceof>
+ <test
+ property="org.eclipse.mylyn.taskRepository.disconnected"
+ value="false">
+ </test>
+ </and>
+ </iterate>
+ </or>
+ </and>
+ </activeWhen>
+ </handler>
+ <handler
+ class="org.eclipse.mylyn.internal.tasks.ui.commands.RefreshRepositoryHandler"
+ commandId="org.eclipse.mylyn.tasks.ui.command.RefreshRepositoryTasks">
+ <activeWhen>
+ <and>
+ <iterate>
+ <and>
+ <instanceof
+ value="org.eclipse.mylyn.tasks.core.TaskRepository">
+ </instanceof>
+ <not>
+ <test
+ property="org.eclipse.mylyn.taskRepository.connectorKind"
+ value="local">
+ </test>
+ </not>
+ </and>
+ </iterate>
+ </and>
+ </activeWhen>
+ </handler>
+ </extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ id="org.eclipse.mylyn.tasks.ui.command.UpdateRepositoryConfiguration"
+ name="Update Repository Configuration">
+ </command>
+ <command
+ id="org.eclipse.mylyn.tasks.ui.command.disconnected"
+ name="Disconnected">
+ <state
+ class="org.eclipse.ui.handlers.RegistryToggleState:false"
+ id="org.eclipse.ui.commands.toggleState">
+ </state>
+ </command>
+ <command
+ id="org.eclipse.mylyn.tasks.ui.command.RefreshRepositoryTasks"
+ name="%SynchronizeAllAction.label">
+ </command>
+ </extension>
</plugin>
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/commands/DisconnectHandler.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/commands/DisconnectHandler.java
new file mode 100644
index 000000000..6fcc16b0d
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/commands/DisconnectHandler.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Frank Becker 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:
+ * Frank Becker - initial API and implementation
+ * Tasktop Technologies - improvements
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.tasks.ui.commands;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.commands.IElementUpdater;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.internal.WorkbenchWindow;
+import org.eclipse.ui.menus.UIElement;
+
+/**
+ * @author Frank Becker
+ * @author Steffen Pingel
+ */
+public class DisconnectHandler extends AbstractHandler implements IElementUpdater {
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ Command command0 = event.getCommand();
+
+ boolean oldValue = HandlerUtil.toggleCommandState(command0);
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+ if (selection instanceof IStructuredSelection) {
+ for (Iterator<?> iter = ((IStructuredSelection) selection).iterator(); iter.hasNext();) {
+ Object item = iter.next();
+ if (item instanceof TaskRepository) {
+ ((TaskRepository) item).setOffline(!oldValue);
+ TasksUiPlugin.getRepositoryManager().notifyRepositorySettingsChanged((TaskRepository) item);
+ }
+ }
+ }
+ return null;
+ }
+
+ public void updateElement(UIElement element, @SuppressWarnings("rawtypes")
+ Map parameters) {
+ IWorkbenchWindow window = (IWorkbenchWindow) element.getServiceLocator().getService(IWorkbenchWindow.class);
+ if (window != null) {
+ IWorkbenchPage activePage = ((WorkbenchWindow) window).getActivePage();
+ if (activePage != null) {
+ IWorkbenchPart activePart = activePage.getActivePart();
+ if (activePart != null) {
+ ISelectionProvider selectionProvider = activePart.getSite().getSelectionProvider();
+ if (selectionProvider != null) {
+ ISelection selection = selectionProvider.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ // only for enabled Handlers the updateElement is called
+ // so we only need the first repository for set the state
+ Object firstRepository = ((IStructuredSelection) selection).getFirstElement();
+ if (firstRepository instanceof TaskRepository) {
+ boolean checked = ((TaskRepository) firstRepository).isOffline();
+ element.setChecked(checked);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/commands/RefreshRepositoryHandler.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/commands/RefreshRepositoryHandler.java
new file mode 100644
index 000000000..4d97bf80c
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/commands/RefreshRepositoryHandler.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Frank Becker 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:
+ * Frank Becker - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.tasks.ui.commands;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.mylyn.internal.tasks.ui.actions.RefreshRepositoryTasksAction;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * @author Frank Becker
+ */
+public class RefreshRepositoryHandler extends AbstractHandler {
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+ RefreshRepositoryTasksAction action = new RefreshRepositoryTasksAction();
+ action.selectionChanged((IStructuredSelection) selection);
+ action.run();
+ return null;
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/commands/UpdateRepositoryConfiguration.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/commands/UpdateRepositoryConfiguration.java
new file mode 100644
index 000000000..d782a0a34
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/commands/UpdateRepositoryConfiguration.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Frank Becker 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:
+ * Frank Becker - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.tasks.ui.commands;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.mylyn.internal.tasks.ui.views.UpdateRepositoryConfigurationAction;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * @author Frank Bwcker
+ */
+public class UpdateRepositoryConfiguration extends AbstractHandler {
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+ UpdateRepositoryConfigurationAction action = new UpdateRepositoryConfigurationAction();
+ action.selectionChanged((IStructuredSelection) selection);
+ action.run();
+ return null;
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskRepositoryPropertyTester.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskRepositoryPropertyTester.java
index b952773ad..22626fbfe 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskRepositoryPropertyTester.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskRepositoryPropertyTester.java
@@ -27,6 +27,8 @@ public class TaskRepositoryPropertyTester extends PropertyTester {
private static final String PROPERTY_USER_MANAGED = "userManaged"; //$NON-NLS-1$
+ private static final String PROPERTY_DISCONNECTED = "disconnected"; //$NON-NLS-1$
+
private boolean equals(boolean value, Object expectedValue) {
return new Boolean(value).equals(expectedValue);
}
@@ -40,6 +42,8 @@ public class TaskRepositoryPropertyTester extends PropertyTester {
AbstractRepositoryConnector connector = TasksUi.getRepositoryManager().getRepositoryConnector(
repository.getConnectorKind());
return equals(connector != null && connector.isUserManaged(), expectedValue);
+ } else if (PROPERTY_DISCONNECTED.equals(property)) {
+ return equals(!repository.isOffline(), expectedValue);
}
}

Back to the top