|
Lines 13-36
Link Here
|
| 13 |
import java.io.File; |
13 |
import java.io.File; |
| 14 |
import java.util.ArrayList; |
14 |
import java.util.ArrayList; |
| 15 |
import java.util.Collection; |
15 |
import java.util.Collection; |
|
|
16 |
import java.util.Comparator; |
| 16 |
import java.util.Date; |
17 |
import java.util.Date; |
| 17 |
import java.util.HashMap; |
18 |
import java.util.HashMap; |
| 18 |
import java.util.HashSet; |
19 |
import java.util.HashSet; |
| 19 |
import java.util.List; |
20 |
import java.util.List; |
| 20 |
import java.util.Map; |
21 |
import java.util.Map; |
| 21 |
import java.util.Set; |
22 |
import java.util.Set; |
|
|
23 |
import java.util.TreeSet; |
| 22 |
|
24 |
|
| 23 |
import org.eclipse.core.resources.IProject; |
|
|
| 24 |
import org.eclipse.core.resources.IResource; |
25 |
import org.eclipse.core.resources.IResource; |
| 25 |
import org.eclipse.core.resources.ProjectScope; |
|
|
| 26 |
import org.eclipse.core.resources.ResourcesPlugin; |
26 |
import org.eclipse.core.resources.ResourcesPlugin; |
| 27 |
import org.eclipse.core.runtime.CoreException; |
27 |
import org.eclipse.core.runtime.CoreException; |
| 28 |
import org.eclipse.core.runtime.IPath; |
28 |
import org.eclipse.core.runtime.IPath; |
| 29 |
import org.eclipse.core.runtime.Platform; |
29 |
import org.eclipse.core.runtime.Platform; |
| 30 |
import org.eclipse.core.runtime.Preferences.IPropertyChangeListener; |
30 |
import org.eclipse.core.runtime.Preferences.IPropertyChangeListener; |
| 31 |
import org.eclipse.core.runtime.Preferences.PropertyChangeEvent; |
31 |
import org.eclipse.core.runtime.Preferences.PropertyChangeEvent; |
| 32 |
import org.eclipse.core.runtime.preferences.IEclipsePreferences; |
|
|
| 33 |
import org.eclipse.core.runtime.preferences.IScopeContext; |
| 34 |
import org.eclipse.jface.dialogs.MessageDialog; |
32 |
import org.eclipse.jface.dialogs.MessageDialog; |
| 35 |
import org.eclipse.jface.preference.IPreferenceStore; |
33 |
import org.eclipse.jface.preference.IPreferenceStore; |
| 36 |
import org.eclipse.jface.resource.ImageDescriptor; |
34 |
import org.eclipse.jface.resource.ImageDescriptor; |
|
Lines 84-90
Link Here
|
| 84 |
import org.eclipse.ui.plugin.AbstractUIPlugin; |
82 |
import org.eclipse.ui.plugin.AbstractUIPlugin; |
| 85 |
import org.osgi.framework.Bundle; |
83 |
import org.osgi.framework.Bundle; |
| 86 |
import org.osgi.framework.BundleContext; |
84 |
import org.osgi.framework.BundleContext; |
| 87 |
import org.osgi.service.prefs.BackingStoreException; |
|
|
| 88 |
|
85 |
|
| 89 |
/** |
86 |
/** |
| 90 |
* @author Mik Kersten |
87 |
* @author Mik Kersten |
|
Lines 97-108
Link Here
|
| 97 |
|
94 |
|
| 98 |
public static final String PLUGIN_ID = "org.eclipse.mylar.tasklist"; |
95 |
public static final String PLUGIN_ID = "org.eclipse.mylar.tasklist"; |
| 99 |
|
96 |
|
| 100 |
private static final String PROPERTY_PREFIX = "project.repository"; |
|
|
| 101 |
|
| 102 |
private static final String PROJECT_REPOSITORY_KIND = PROPERTY_PREFIX + ".kind"; |
| 103 |
|
| 104 |
private static final String PROJECT_REPOSITORY_URL = PROPERTY_PREFIX + ".url"; |
| 105 |
|
| 106 |
private static final String NAME_DATA_DIR = ".mylar"; |
97 |
private static final String NAME_DATA_DIR = ".mylar"; |
| 107 |
|
98 |
|
| 108 |
private static final char DEFAULT_PATH_SEPARATOR = '/'; |
99 |
private static final char DEFAULT_PATH_SEPARATOR = '/'; |
|
Lines 133-138
Link Here
|
| 133 |
|
124 |
|
| 134 |
private ArrayList<IHyperlinkDetector> hyperlinkDetectors = new ArrayList<IHyperlinkDetector>(); |
125 |
private ArrayList<IHyperlinkDetector> hyperlinkDetectors = new ArrayList<IHyperlinkDetector>(); |
| 135 |
|
126 |
|
|
|
127 |
private TreeSet<AbstractTaskRepositoryLinkProvider> repositoryLinkProviders = new TreeSet<AbstractTaskRepositoryLinkProvider>(new OrderComparator()); |
| 128 |
|
| 136 |
private TaskListWriter taskListWriter; |
129 |
private TaskListWriter taskListWriter; |
| 137 |
|
130 |
|
| 138 |
private ITaskHighlighter highlighter; |
131 |
private ITaskHighlighter highlighter; |
|
Lines 147-152
Link Here
|
| 147 |
|
140 |
|
| 148 |
private boolean eclipse_3_3_workbench = false; |
141 |
private boolean eclipse_3_3_workbench = false; |
| 149 |
|
142 |
|
|
|
143 |
private static final class OrderComparator implements Comparator<AbstractTaskRepositoryLinkProvider> { |
| 144 |
public int compare(AbstractTaskRepositoryLinkProvider p1, AbstractTaskRepositoryLinkProvider p2) { |
| 145 |
return p1.getOrder()-p2.getOrder(); |
| 146 |
} |
| 147 |
} |
| 148 |
|
| 150 |
public enum TaskListSaveMode { |
149 |
public enum TaskListSaveMode { |
| 151 |
ONE_HOUR, THREE_HOURS, DAY; |
150 |
ONE_HOUR, THREE_HOURS, DAY; |
| 152 |
@Override |
151 |
@Override |
|
Lines 671-676
Link Here
|
| 671 |
this.hyperlinkDetectors.add(listener); |
670 |
this.hyperlinkDetectors.add(listener); |
| 672 |
} |
671 |
} |
| 673 |
|
672 |
|
|
|
673 |
public void addRepositoryLinkProvider(AbstractTaskRepositoryLinkProvider repositoryLinkProvider) { |
| 674 |
if (repositoryLinkProvider != null) |
| 675 |
this.repositoryLinkProviders.add(repositoryLinkProvider); |
| 676 |
} |
| 677 |
|
| 674 |
public TaskListBackupManager getBackupManager() { |
678 |
public TaskListBackupManager getBackupManager() { |
| 675 |
return taskListBackupManager; |
679 |
return taskListBackupManager; |
| 676 |
} |
680 |
} |
|
Lines 736-741
Link Here
|
| 736 |
return getDataDirectory() + File.separator + TaskRepositoryManager.DEFAULT_REPOSITORIES_FILE; |
740 |
return getDataDirectory() + File.separator + TaskRepositoryManager.DEFAULT_REPOSITORIES_FILE; |
| 737 |
} |
741 |
} |
| 738 |
|
742 |
|
|
|
743 |
public boolean canSetRepositoryForResource(IResource resource) { |
| 744 |
if (resource == null) { |
| 745 |
return false; |
| 746 |
} |
| 747 |
|
| 748 |
for (AbstractTaskRepositoryLinkProvider linkProvider : repositoryLinkProviders) { |
| 749 |
TaskRepository repository = linkProvider.getTaskRepository(resource, getRepositoryManager()); |
| 750 |
if (repository != null) { |
| 751 |
return linkProvider.canSetTaskRepository(resource); |
| 752 |
} |
| 753 |
} |
| 754 |
return false; |
| 755 |
} |
| 756 |
|
| 739 |
/** |
757 |
/** |
| 740 |
* Associate a Task Repository with a workbench project |
758 |
* Associate a Task Repository with a workbench project |
| 741 |
* |
759 |
* |
|
Lines 746-766
Link Here
|
| 746 |
* @throws CoreException |
764 |
* @throws CoreException |
| 747 |
*/ |
765 |
*/ |
| 748 |
public void setRepositoryForResource(IResource resource, TaskRepository repository) throws CoreException { |
766 |
public void setRepositoryForResource(IResource resource, TaskRepository repository) throws CoreException { |
| 749 |
if (resource == null || repository == null || !resource.getProject().isOpen()) { |
767 |
if (resource == null || repository == null) { |
| 750 |
return; |
768 |
return; |
| 751 |
} |
769 |
} |
| 752 |
IProject project = resource.getProject(); |
770 |
|
| 753 |
if (project == null) |
771 |
for (AbstractTaskRepositoryLinkProvider linkProvider : repositoryLinkProviders) { |
| 754 |
return; |
772 |
TaskRepository r = linkProvider.getTaskRepository(resource, getRepositoryManager()); |
| 755 |
IScopeContext projectScope = new ProjectScope(project); |
773 |
boolean canSetRepository = linkProvider.canSetTaskRepository(resource); |
| 756 |
IEclipsePreferences projectNode = projectScope.getNode(PLUGIN_ID); |
774 |
if (r != null && !canSetRepository) { |
| 757 |
if (projectNode != null) { |
775 |
return; |
| 758 |
projectNode.put(PROJECT_REPOSITORY_KIND, repository.getKind()); |
776 |
} |
| 759 |
projectNode.put(PROJECT_REPOSITORY_URL, repository.getUrl()); |
777 |
if (canSetRepository) { |
| 760 |
try { |
778 |
linkProvider.setTaskRepository(resource, repository); |
| 761 |
projectNode.flush(); |
779 |
return; |
| 762 |
} catch (BackingStoreException e) { |
|
|
| 763 |
MylarStatusHandler.fail(e, "Failed to save task repository to project association preference", false); |
| 764 |
} |
780 |
} |
| 765 |
} |
781 |
} |
| 766 |
} |
782 |
} |
|
Lines 770-794
Link Here
|
| 770 |
* project (or resource belonging to a project) |
786 |
* project (or resource belonging to a project) |
| 771 |
*/ |
787 |
*/ |
| 772 |
public TaskRepository getRepositoryForResource(IResource resource, boolean silent) { |
788 |
public TaskRepository getRepositoryForResource(IResource resource, boolean silent) { |
| 773 |
if (resource == null) |
789 |
if (resource == null) { |
| 774 |
return null; |
790 |
return null; |
| 775 |
IProject project = resource.getProject(); |
791 |
} |
| 776 |
if (project == null) |
792 |
|
| 777 |
return null; |
793 |
for (AbstractTaskRepositoryLinkProvider linkProvider : repositoryLinkProviders) { |
| 778 |
TaskRepository taskRepository = null; |
794 |
TaskRepository repository = linkProvider.getTaskRepository(resource, getRepositoryManager()); |
| 779 |
IScopeContext projectScope = new ProjectScope(project); |
795 |
if (repository != null) { |
| 780 |
IEclipsePreferences projectNode = projectScope.getNode(PLUGIN_ID); |
796 |
return repository; |
| 781 |
if (projectNode != null) { |
|
|
| 782 |
String kind = projectNode.get(PROJECT_REPOSITORY_KIND, ""); |
| 783 |
String urlString = projectNode.get(PROJECT_REPOSITORY_URL, ""); |
| 784 |
taskRepository = getRepositoryManager().getRepository(kind, urlString); |
| 785 |
if (taskRepository == null && !silent) { |
| 786 |
MessageDialog |
| 787 |
.openInformation(null, "No Repository Found", |
| 788 |
"No repository was found. Associate a Task Repository with this project via the project's property page."); |
| 789 |
} |
797 |
} |
| 790 |
} |
798 |
} |
| 791 |
return taskRepository; |
799 |
|
|
|
800 |
if (!silent) { |
| 801 |
MessageDialog |
| 802 |
.openInformation(null, "No Repository Found", |
| 803 |
"No repository was found. Associate a Task Repository with this project via the project's property page."); |
| 804 |
} |
| 805 |
|
| 806 |
return null; |
| 792 |
} |
807 |
} |
| 793 |
|
808 |
|
| 794 |
public boolean isEclipse_3_3_workbench() { |
809 |
public boolean isEclipse_3_3_workbench() { |