Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 159135 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/mylar/tasks/ui/properties/ProjectTaskRepositoryPage.java (-2 / +5 lines)
Lines 104-110 Link Here
104
		listViewer.setInput(project.getWorkspace());
104
		listViewer.setInput(project.getWorkspace());
105
105
106
		TaskRepository repository = TasksUiPlugin.getDefault().getRepositoryForResource(project, true);
106
		TaskRepository repository = TasksUiPlugin.getDefault().getRepositoryForResource(project, true);
107
108
		if (repository != null) {
107
		if (repository != null) {
109
			listViewer.setCheckedElements(new Object[] { repository });
108
			listViewer.setCheckedElements(new Object[] { repository });
110
		}
109
		}
Lines 118-123 Link Here
118
				modified = true;
117
				modified = true;
119
			}
118
			}
120
		});
119
		});
120
		listViewer.getControl().setEnabled(TasksUiPlugin.getDefault().canSetRepositoryForResource(project));
121
121
122
		final AddRepositoryAction action = new AddRepositoryAction();
122
		final AddRepositoryAction action = new AddRepositoryAction();
123
123
Lines 167-173 Link Here
167
		if (listViewer.getCheckedElements().length > 0) {
167
		if (listViewer.getCheckedElements().length > 0) {
168
			TaskRepository selectedRepository = (TaskRepository) listViewer.getCheckedElements()[0];
168
			TaskRepository selectedRepository = (TaskRepository) listViewer.getCheckedElements()[0];
169
			try {
169
			try {
170
				TasksUiPlugin.getDefault().setRepositoryForResource(project, selectedRepository);
170
				TasksUiPlugin plugin = TasksUiPlugin.getDefault();
171
				if(plugin.canSetRepositoryForResource(project)) {
172
					plugin.setRepositoryForResource(project, selectedRepository);
173
				}
171
			} catch (CoreException e) {
174
			} catch (CoreException e) {
172
				MylarStatusHandler.fail(e, "Unable to associate project with task repository", true);
175
				MylarStatusHandler.fail(e, "Unable to associate project with task repository", true);
173
			}
176
			}
(-)plugin.xml (+10 lines)
Lines 4-9 Link Here
4
    <extension-point id="actions" name="Tasklist Actions" schema="schema/actions.exsd"/>
4
    <extension-point id="actions" name="Tasklist Actions" schema="schema/actions.exsd"/>
5
    <extension-point id="repositories" name="Task Repositories" schema="schema/repositories.exsd"/>
5
    <extension-point id="repositories" name="Task Repositories" schema="schema/repositories.exsd"/>
6
    <extension-point id="editors" name="Task Editors" schema="schema/editors.exsd"/>
6
    <extension-point id="editors" name="Task Editors" schema="schema/editors.exsd"/>
7
    <extension-point id="projectLinkProviders" name="Linking Provider from Project to the Task Repository" schema="schema/projectLinkProviders.exsd"/>
7
8
8
	<!--
9
	<!--
9
    <extension
10
    <extension
Lines 711-716 Link Here
711
          </commandParameter>
712
          </commandParameter>
712
       </command>
713
       </command>
713
    </extension>
714
    </extension>
715
    <extension
716
          point="org.eclipse.mylar.tasks.ui.projectLinkProviders">
717
       <linkProvider
718
             class="org.eclipse.mylar.tasks.ui.ProjectPreferencesLinkProvider"
719
             name="Default Repository Link"
720
             order="1000"
721
             id="org.eclipse.mylar.tasks.ui.defaultRepositoryLinkProvider">
722
       </linkProvider>
723
    </extension>
714
  
724
  
715
</plugin>
725
</plugin>
716
726
(-)src/org/eclipse/mylar/tasks/ui/TasksUiPlugin.java (-48 / +64 lines)
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 296-302 Link Here
296
							if (connector != null) {
295
							if (connector != null) {
297
								ITaskDataHandler offlineHandler = connector.getTaskDataHandler();
296
								ITaskDataHandler offlineHandler = connector.getTaskDataHandler();
298
								if (offlineHandler != null && repositoryTask.getTaskData().getLastModified() != null) {
297
								if (offlineHandler != null && repositoryTask.getTaskData().getLastModified() != null) {
299
									Date modified = repositoryTask.getTaskData().getAttributeFactory().getDateForAttributeType(
298
									Date modified = offlineHandler.getDateForAttributeType(
300
											RepositoryTaskAttribute.DATE_MODIFIED, repositoryTask.getTaskData()
299
											RepositoryTaskAttribute.DATE_MODIFIED, repositoryTask.getTaskData()
301
													.getLastModified());
300
													.getLastModified());
302
									notification.setDate(modified);
301
									notification.setDate(modified);
Lines 382-403 Link Here
382
			taskRepositoryManager = new TaskRepositoryManager(taskListManager.getTaskList());
381
			taskRepositoryManager = new TaskRepositoryManager(taskListManager.getTaskList());
383
			synchronizationManager = new RepositorySynchronizationManager();
382
			synchronizationManager = new RepositorySynchronizationManager();
384
383
385
			
386
			// NOTE: initializing extensions in start(..) has caused race
384
			// NOTE: initializing extensions in start(..) has caused race
387
			// conditions previously
385
			// conditions previously
388
			TasksUiExtensionReader.initStartupExtensions(taskListWriter);
386
			TasksUiExtensionReader.initStartupExtensions(taskListWriter);
389
			
390
			// The repositories need to be read before the tasks so that the getAttributeFactory 
391
			// can use the repository to get the information it needs
392
			taskRepositoryManager.readRepositories(getRepositoriesFilePath());
393
			
394
			readOfflineReports();
387
			readOfflineReports();
395
			for (ITaskListExternalizer externalizer : taskListWriter.getExternalizers()) {
388
			for (ITaskListExternalizer externalizer : taskListWriter.getExternalizers()) {
396
				if (externalizer instanceof DelegatingTaskExternalizer) {
389
				if (externalizer instanceof DelegatingTaskExternalizer) {
397
					((DelegatingTaskExternalizer) externalizer).init(offlineTaskManager);
390
					((DelegatingTaskExternalizer) externalizer).init(offlineTaskManager);
398
				}
391
				}
399
			}
392
			}
400
			
393
			taskRepositoryManager.readRepositories(getRepositoriesFilePath());
401
			taskListWriter.setTaskDataManager(offlineTaskManager);
394
			taskListWriter.setTaskDataManager(offlineTaskManager);
402
			
395
			
403
			// NOTE: task list must be read before Task List view can be initialized
396
			// NOTE: task list must be read before Task List view can be initialized
Lines 677-682 Link Here
677
			this.hyperlinkDetectors.add(listener);
670
			this.hyperlinkDetectors.add(listener);
678
	}
671
	}
679
672
673
	public void addRepositoryLinkProvider(AbstractTaskRepositoryLinkProvider repositoryLinkProvider) {
674
		if (repositoryLinkProvider != null)
675
			this.repositoryLinkProviders.add(repositoryLinkProvider);
676
	}
677
	
680
	public TaskListBackupManager getBackupManager() {
678
	public TaskListBackupManager getBackupManager() {
681
		return taskListBackupManager;
679
		return taskListBackupManager;
682
	}
680
	}
Lines 742-747 Link Here
742
		return getDataDirectory() + File.separator + TaskRepositoryManager.DEFAULT_REPOSITORIES_FILE;
740
		return getDataDirectory() + File.separator + TaskRepositoryManager.DEFAULT_REPOSITORIES_FILE;
743
	}
741
	}
744
742
743
	public boolean canSetRepositoryForResource(IResource resource) {
744
		if (resource == null) {
745
			return false;
746
		}
747
748
		// find first provider that can link repository 
749
		for (AbstractTaskRepositoryLinkProvider linkProvider : repositoryLinkProviders) {
750
			TaskRepository repository = linkProvider.getTaskRepository(resource, getRepositoryManager());
751
			if (repository != null) {
752
				return linkProvider.canSetTaskRepository(resource);
753
			}
754
		}
755
		// find first provider that can set new repository
756
		for (AbstractTaskRepositoryLinkProvider linkProvider : repositoryLinkProviders) {
757
			if (linkProvider.canSetTaskRepository(resource)) {
758
				return true;
759
			}
760
		}
761
		return false;
762
	}
763
745
	/**
764
	/**
746
	 * Associate a Task Repository with a workbench project
765
	 * Associate a Task Repository with a workbench project
747
	 * 
766
	 * 
Lines 752-772 Link Here
752
	 * @throws CoreException
771
	 * @throws CoreException
753
	 */
772
	 */
754
	public void setRepositoryForResource(IResource resource, TaskRepository repository) throws CoreException {
773
	public void setRepositoryForResource(IResource resource, TaskRepository repository) throws CoreException {
755
		if (resource == null || repository == null || !resource.getProject().isOpen()) {
774
		if (resource == null || repository == null) {
756
			return;
775
			return;
757
		}
776
		}
758
		IProject project = resource.getProject();
777
759
		if (project == null)
778
		for (AbstractTaskRepositoryLinkProvider linkProvider : repositoryLinkProviders) {
760
			return;
779
			TaskRepository r = linkProvider.getTaskRepository(resource, getRepositoryManager());
761
		IScopeContext projectScope = new ProjectScope(project);
780
			boolean canSetRepository = linkProvider.canSetTaskRepository(resource);
762
		IEclipsePreferences projectNode = projectScope.getNode(PLUGIN_ID);
781
			if (r != null && !canSetRepository) {
763
		if (projectNode != null) {
782
				return;
764
			projectNode.put(PROJECT_REPOSITORY_KIND, repository.getKind());
783
			}
765
			projectNode.put(PROJECT_REPOSITORY_URL, repository.getUrl());
784
			if (canSetRepository) {
766
			try {
785
				linkProvider.setTaskRepository(resource, repository);
767
				projectNode.flush();
786
				return;
768
			} catch (BackingStoreException e) {
769
				MylarStatusHandler.fail(e, "Failed to save task repository to project association preference", false);
770
			}
787
			}
771
		}
788
		}
772
	}
789
	}
Lines 776-800 Link Here
776
	 * project (or resource belonging to a project)
793
	 * project (or resource belonging to a project)
777
	 */
794
	 */
778
	public TaskRepository getRepositoryForResource(IResource resource, boolean silent) {
795
	public TaskRepository getRepositoryForResource(IResource resource, boolean silent) {
779
		if (resource == null)
796
		if (resource == null) {
780
			return null;
797
			return null;
781
		IProject project = resource.getProject();
798
		}
782
		if (project == null)
799
783
			return null;
800
		for (AbstractTaskRepositoryLinkProvider linkProvider : repositoryLinkProviders) {
784
		TaskRepository taskRepository = null;
801
			TaskRepository repository = linkProvider.getTaskRepository(resource, getRepositoryManager());
785
		IScopeContext projectScope = new ProjectScope(project);
802
			if (repository != null) {
786
		IEclipsePreferences projectNode = projectScope.getNode(PLUGIN_ID);
803
				return repository;
787
		if (projectNode != null) {
788
			String kind = projectNode.get(PROJECT_REPOSITORY_KIND, "");
789
			String urlString = projectNode.get(PROJECT_REPOSITORY_URL, "");
790
			taskRepository = getRepositoryManager().getRepository(kind, urlString);
791
			if (taskRepository == null && !silent) {
792
				MessageDialog
793
						.openInformation(null, "No Repository Found",
794
								"No repository was found. Associate a Task Repository with this project via the project's property page.");
795
			}
804
			}
796
		}
805
		}
797
		return taskRepository;
806
807
		if (!silent) {
808
			MessageDialog
809
					.openInformation(null, "No Repository Found",
810
							"No repository was found. Associate a Task Repository with this project via the project's property page.");
811
		}
812
813
		return null;
798
	}
814
	}
799
815
800
	public boolean isEclipse_3_3_workbench() {
816
	public boolean isEclipse_3_3_workbench() {
(-)src/org/eclipse/mylar/internal/tasks/ui/util/TasksUiExtensionReader.java (+31 lines)
Lines 28-33 Link Here
28
import org.eclipse.mylar.tasks.core.ITaskListExternalizer;
28
import org.eclipse.mylar.tasks.core.ITaskListExternalizer;
29
import org.eclipse.mylar.tasks.core.RepositoryTemplate;
29
import org.eclipse.mylar.tasks.core.RepositoryTemplate;
30
import org.eclipse.mylar.tasks.ui.AbstractRepositoryConnectorUi;
30
import org.eclipse.mylar.tasks.ui.AbstractRepositoryConnectorUi;
31
import org.eclipse.mylar.tasks.ui.AbstractTaskRepositoryLinkProvider;
31
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
32
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
32
import org.eclipse.mylar.tasks.ui.editors.ITaskEditorFactory;
33
import org.eclipse.mylar.tasks.ui.editors.ITaskEditorFactory;
33
import org.eclipse.ui.plugin.AbstractUIPlugin;
34
import org.eclipse.ui.plugin.AbstractUIPlugin;
Lines 41-46 Link Here
41
42
42
	public static final String EXTENSION_REPOSITORIES = "org.eclipse.mylar.tasks.ui.repositories";
43
	public static final String EXTENSION_REPOSITORIES = "org.eclipse.mylar.tasks.ui.repositories";
43
44
45
	public static final String EXTENSION_REPOSITORY_LINKS_PROVIDERS = "org.eclipse.mylar.tasks.ui.projectLinkProviders";
46
44
	public static final String EXTENSION_TEMPLATES = "org.eclipse.mylar.tasks.core.templates";
47
	public static final String EXTENSION_TEMPLATES = "org.eclipse.mylar.tasks.core.templates";
45
48
46
	public static final String EXTENSION_TMPL_REPOSITORY = "repository";
49
	public static final String EXTENSION_TMPL_REPOSITORY = "repository";
Lines 69-74 Link Here
69
72
70
	public static final String ELMNT_REPOSITORY_CONNECTOR = "connectorCore";
73
	public static final String ELMNT_REPOSITORY_CONNECTOR = "connectorCore";
71
74
75
	public static final String ELMNT_REPOSITORY_LINK_PROVIDER = "linkProvider";
76
	
72
	public static final String ELMNT_REPOSITORY_UI= "connectorUi";
77
	public static final String ELMNT_REPOSITORY_UI= "connectorUi";
73
	
78
	
74
	public static final String ELMNT_EXTERNALIZER = "externalizer";
79
	public static final String ELMNT_EXTERNALIZER = "externalizer";
Lines 174-181 Link Here
174
				} 
179
				} 
175
			}
180
			}
176
		}
181
		}
182
183
		IExtensionPoint linkProvidersExtensionPoint = registry.getExtensionPoint(EXTENSION_REPOSITORY_LINKS_PROVIDERS);
184
		IExtension[] linkProvidersExtensions = linkProvidersExtensionPoint.getExtensions();
185
		for (int i = 0; i < linkProvidersExtensions.length; i++) {
186
			IConfigurationElement[] elements = linkProvidersExtensions[i].getConfigurationElements();
187
			for (int j = 0; j < elements.length; j++) {
188
				if (elements[j].getName().equals(ELMNT_REPOSITORY_LINK_PROVIDER)) {
189
					readLinkProvider(elements[j]);
190
				} 
191
			}
192
		}
193
	
177
	}
194
	}
178
	
195
	
196
	private static void readLinkProvider(IConfigurationElement element) {
197
		try {
198
			Object repositoryLinkProvider = element.createExecutableExtension(ATTR_CLASS);
199
			if (repositoryLinkProvider instanceof AbstractTaskRepositoryLinkProvider) {
200
				TasksUiPlugin.getDefault().addRepositoryLinkProvider((AbstractTaskRepositoryLinkProvider) repositoryLinkProvider);
201
			} else {
202
				MylarStatusHandler.log("Could not load repository link provider: " + repositoryLinkProvider.getClass().getCanonicalName(),
203
						null);
204
			}
205
		} catch (CoreException e) {
206
			MylarStatusHandler.log(e, "Could not load repository link provider extension");
207
		}
208
	}
209
179
	private static void readHyperlinkDetector(IConfigurationElement element) {
210
	private static void readHyperlinkDetector(IConfigurationElement element) {
180
		try {
211
		try {
181
			Object hyperlinkDetector = element.createExecutableExtension(ATTR_CLASS);
212
			Object hyperlinkDetector = element.createExecutableExtension(ATTR_CLASS);
(-)src/org/eclipse/mylar/tasks/ui/ProjectPreferencesLinkProvider.java (+79 lines)
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.mylar.tasks.ui;
10
11
import org.eclipse.core.resources.IProject;
12
import org.eclipse.core.resources.IResource;
13
import org.eclipse.core.resources.ProjectScope;
14
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
15
import org.eclipse.core.runtime.preferences.IScopeContext;
16
import org.eclipse.mylar.core.MylarStatusHandler;
17
import org.eclipse.mylar.tasks.core.TaskRepository;
18
import org.eclipse.mylar.tasks.core.TaskRepositoryManager;
19
import org.osgi.service.prefs.BackingStoreException;
20
21
/**
22
 * Default Task Repository link provider
23
 * 
24
 * @author Eugene Kuleshov
25
 */
26
public class ProjectPreferencesLinkProvider extends AbstractTaskRepositoryLinkProvider {
27
28
	private static final String PROPERTY_PREFIX = "project.repository";
29
30
	private static final String PROJECT_REPOSITORY_KIND = PROPERTY_PREFIX + ".kind";
31
32
	private static final String PROJECT_REPOSITORY_URL = PROPERTY_PREFIX + ".url";
33
34
	public TaskRepository getTaskRepository(IResource resource, TaskRepositoryManager repositoryManager) {
35
		IProject project = resource.getProject();
36
		if (project == null || !project.isAccessible()) {
37
			return null;
38
		}
39
40
		IScopeContext projectScope = new ProjectScope(project);
41
		IEclipsePreferences projectNode = projectScope.getNode(TasksUiPlugin.PLUGIN_ID);
42
		if (projectNode != null) {
43
			String kind = projectNode.get(PROJECT_REPOSITORY_KIND, "");
44
			String urlString = projectNode.get(PROJECT_REPOSITORY_URL, "");
45
			return repositoryManager.getRepository(kind, urlString);
46
		}
47
		return null;
48
	}
49
50
51
	@Override
52
	public boolean canSetTaskRepository(IResource resource) {
53
		IProject project = resource.getProject();
54
		return project != null && project.isAccessible();
55
	}
56
57
	@Override
58
	public boolean setTaskRepository(IResource resource, TaskRepository repository) {
59
		IProject project = resource.getProject();
60
		if (project == null || !project.isAccessible()) {
61
			return false;
62
		}
63
		
64
		IScopeContext projectScope = new ProjectScope(project);
65
		IEclipsePreferences projectNode = projectScope.getNode(TasksUiPlugin.PLUGIN_ID);
66
		if (projectNode != null) {
67
			projectNode.put(PROJECT_REPOSITORY_KIND, repository.getKind());
68
			projectNode.put(PROJECT_REPOSITORY_URL, repository.getUrl());
69
			try {
70
				projectNode.flush();
71
				return true;
72
			} catch (BackingStoreException e) {
73
				MylarStatusHandler.fail(e, "Failed to save task repository to project association preference", false);
74
			}
75
		}
76
		return false;
77
	}
78
79
}
(-)schema/projectLinkProviders.exsd (+126 lines)
Added Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.mylar.tasks.ui">
4
<annotation>
5
      <appInfo>
6
         <meta.schema plugin="org.eclipse.mylar.tasks.ui" id="projectLinkProviders" name="Task Repository Link Provider"/>
7
      </appInfo>
8
      <documentation>
9
         Providers responsible for linking Workspace resources/projects to the Task Repositories.
10
      </documentation>
11
   </annotation>
12
13
   <element name="extension">
14
      <complexType>
15
         <sequence>
16
            <element ref="linkProvider"/>
17
         </sequence>
18
         <attribute name="point" type="string" use="required">
19
            <annotation>
20
               <documentation>
21
                  
22
               </documentation>
23
            </annotation>
24
         </attribute>
25
         <attribute name="id" type="string">
26
            <annotation>
27
               <documentation>
28
                  
29
               </documentation>
30
            </annotation>
31
         </attribute>
32
         <attribute name="name" type="string">
33
            <annotation>
34
               <documentation>
35
                  
36
               </documentation>
37
               <appInfo>
38
                  <meta.attribute translatable="true"/>
39
               </appInfo>
40
            </annotation>
41
         </attribute>
42
      </complexType>
43
   </element>
44
45
   <element name="linkProvider">
46
      <complexType>
47
         <attribute name="id" type="string">
48
            <annotation>
49
               <documentation>
50
                  
51
               </documentation>
52
            </annotation>
53
         </attribute>
54
         <attribute name="name" type="string" use="required">
55
            <annotation>
56
               <documentation>
57
                  
58
               </documentation>
59
            </annotation>
60
         </attribute>
61
         <attribute name="class" type="string" use="required">
62
            <annotation>
63
               <documentation>
64
                  
65
               </documentation>
66
               <appInfo>
67
                  <meta.attribute kind="java" basedOn="org.eclipse.mylar.tasks.ui.AbstractTaskRepositoryLinkProvider"/>
68
               </appInfo>
69
            </annotation>
70
         </attribute>
71
         <attribute name="order" type="string" use="required">
72
            <annotation>
73
               <documentation>
74
                  
75
               </documentation>
76
            </annotation>
77
         </attribute>
78
      </complexType>
79
   </element>
80
81
   <annotation>
82
      <appInfo>
83
         <meta.section type="since"/>
84
      </appInfo>
85
      <documentation>
86
         [Enter the first release in which this extension point appears.]
87
      </documentation>
88
   </annotation>
89
90
   <annotation>
91
      <appInfo>
92
         <meta.section type="examples"/>
93
      </appInfo>
94
      <documentation>
95
         [Enter extension point usage example here.]
96
      </documentation>
97
   </annotation>
98
99
   <annotation>
100
      <appInfo>
101
         <meta.section type="apiInfo"/>
102
      </appInfo>
103
      <documentation>
104
         See org.eclipse.mylar.tasks.ui.TasksUiPlugin.getRepositoryForResource(IResource resource, boolean silent)
105
      </documentation>
106
   </annotation>
107
108
   <annotation>
109
      <appInfo>
110
         <meta.section type="implementation"/>
111
      </appInfo>
112
      <documentation>
113
         [Enter information about supplied implementation of this extension point.]
114
      </documentation>
115
   </annotation>
116
117
   <annotation>
118
      <appInfo>
119
         <meta.section type="copyright"/>
120
      </appInfo>
121
      <documentation>
122
         
123
      </documentation>
124
   </annotation>
125
126
</schema>
(-)src/org/eclipse/mylar/tasks/ui/AbstractTaskRepositoryLinkProvider.java (+62 lines)
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.mylar.tasks.ui;
10
11
import org.eclipse.core.resources.IResource;
12
import org.eclipse.core.runtime.IConfigurationElement;
13
import org.eclipse.core.runtime.IExecutableExtension;
14
import org.eclipse.mylar.tasks.core.TaskRepository;
15
import org.eclipse.mylar.tasks.core.TaskRepositoryManager;
16
17
/**
18
 * Abstract Task Repository link provider
19
 * 
20
 * @author Eugene Kuleshov
21
 */
22
public abstract class AbstractTaskRepositoryLinkProvider implements IExecutableExtension {
23
24
	private static final int DEFAULT_ORDER = 1000;
25
	
26
	private String id;
27
	private String name;
28
	private int order;
29
30
	public void setInitializationData(IConfigurationElement config, String propertyName, Object data) {
31
		id = config.getAttribute("id");
32
		name = config.getAttribute("name");
33
		try {
34
			order = Integer.parseInt(config.getAttribute("order"));
35
		} catch(NumberFormatException ex) {
36
			order = DEFAULT_ORDER;
37
		}
38
	}
39
	
40
	public abstract TaskRepository getTaskRepository(IResource resource, TaskRepositoryManager repositoryManager);
41
	
42
	public boolean canSetTaskRepository(IResource resource) {
43
		return false;
44
	}
45
46
	public boolean setTaskRepository(IResource resource, TaskRepository repository) {
47
		return false;
48
	}
49
50
	public String getId() {
51
		return id;
52
	}
53
54
	public String getName() {
55
		return name;
56
	}
57
58
	public int getOrder() {
59
		return order;
60
	}
61
	
62
}

Return to bug 159135