|
Added
Link Here
|
| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2004 - 2006 Mylar committers and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
| 6 |
* http://www.eclipse.org/legal/epl-v10.html |
| 7 |
*******************************************************************************/ |
| 8 |
|
| 9 |
package org.eclipse.mylyn.internal.tasks.ui.views; |
| 10 |
|
| 11 |
import java.util.Iterator; |
| 12 |
|
| 13 |
import org.eclipse.core.runtime.CoreException; |
| 14 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 15 |
import org.eclipse.core.runtime.IStatus; |
| 16 |
import org.eclipse.core.runtime.Status; |
| 17 |
import org.eclipse.core.runtime.jobs.Job; |
| 18 |
import org.eclipse.jface.action.Action; |
| 19 |
import org.eclipse.jface.action.IAction; |
| 20 |
import org.eclipse.jface.viewers.ISelection; |
| 21 |
import org.eclipse.jface.viewers.ISelectionChangedListener; |
| 22 |
import org.eclipse.jface.viewers.IStructuredSelection; |
| 23 |
import org.eclipse.jface.viewers.SelectionChangedEvent; |
| 24 |
import org.eclipse.jface.viewers.StructuredSelection; |
| 25 |
import org.eclipse.mylyn.internal.monitor.core.util.StatusManager; |
| 26 |
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector; |
| 27 |
import org.eclipse.mylyn.tasks.core.TaskRepository; |
| 28 |
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin; |
| 29 |
|
| 30 |
/** |
| 31 |
* @author Steffen Pingel |
| 32 |
*/ |
| 33 |
public class RepositoryOfflineAction extends Action implements ISelectionChangedListener { |
| 34 |
|
| 35 |
private static final String ID = "org.eclipse.mylyn.tasklist.repositories.offline"; |
| 36 |
|
| 37 |
private TaskRepository repository; |
| 38 |
|
| 39 |
public RepositoryOfflineAction() { |
| 40 |
super("Offline", Action.AS_CHECK_BOX); |
| 41 |
setId(ID); |
| 42 |
setEnabled(false); |
| 43 |
} |
| 44 |
|
| 45 |
@Override |
| 46 |
public void run() { |
| 47 |
repository.setOffline(isChecked()); |
| 48 |
TasksUiPlugin.getRepositoryManager().notifyRepositorySettingsChagned(repository); |
| 49 |
} |
| 50 |
|
| 51 |
public void selectionChanged(IAction action, ISelection selection) { |
| 52 |
} |
| 53 |
|
| 54 |
public void selectionChanged(SelectionChangedEvent event) { |
| 55 |
ISelection selection = event.getSelection(); |
| 56 |
if (selection instanceof IStructuredSelection) { |
| 57 |
Object selectedObject = ((IStructuredSelection)selection).getFirstElement(); |
| 58 |
if (selectedObject instanceof TaskRepository) { |
| 59 |
AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector( |
| 60 |
((TaskRepository) selectedObject).getKind()); |
| 61 |
if (connector.isUserManaged()) { |
| 62 |
this.repository = (TaskRepository) selectedObject; |
| 63 |
setChecked(this.repository.isOffline()); |
| 64 |
setEnabled(true); |
| 65 |
return; |
| 66 |
} |
| 67 |
} |
| 68 |
} |
| 69 |
this.repository = null; |
| 70 |
setChecked(false); |
| 71 |
setEnabled(false); |
| 72 |
} |
| 73 |
|
| 74 |
} |