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 240423 | Differences between
and this patch

Collapse All | Expand All

(-)plugin.xml (-3 / +33 lines)
Lines 2-8 Link Here
2
<?eclipse version="3.0"?>
2
<?eclipse version="3.0"?>
3
<plugin>
3
<plugin>
4
    <extension-point id="taskEditorExtensions" name="Task Editor Extension" schema="schema/taskEditorExtensions.exsd"/>
4
    <extension-point id="taskEditorExtensions" name="Task Editor Extension" schema="schema/taskEditorExtensions.exsd"/>
5
5
    <extension-point id="resourceHyperlinkExtensions" name="Resource Hyperlink Extension" schema="schema/resourceHyperlinkExtensions.exsd"/>
6
    
6
	<extension point="org.eclipse.ui.views">
7
	<extension point="org.eclipse.ui.views">
7
     	<category name="Experimental" id="org.eclipse.mylyn.sandbox"/>
8
     	<category name="Experimental" id="org.eclipse.mylyn.sandbox"/>
8
    </extension>
9
    </extension>
Lines 404-411 Link Here
404
      </propertyTester>
405
      </propertyTester>
405
   </extension>
406
   </extension>
406
   
407
   
407
   
408
    <extension
408
   
409
         point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectors">
410
      <hyperlinkDetector
411
            class="org.eclipse.mylyn.internal.sandbox.ui.hyperlinks.ResourceHyperlinkDetector"
412
            id="org.eclipse.mylyn.sandbox.ui.hyperlinkDetector"
413
            name="Resource Hyperlink Detector"
414
            targetId="org.eclipse.ui.DefaultTextEditor">
415
      </hyperlinkDetector>
416
   </extension>
417
	<!--
418
    <extension
419
          point="org.eclipse.mylyn.sandbox.ui.resourceHyperlinkExtensions">
420
       <resourceHyperlinkExtension
421
             class="org.eclipse.mylyn.internal.sandbox.ui.hyperlinks.JavaResourceHyperlinkExtension"
422
             fileType="java"
423
             generatedPrefix="java class">
424
       </resourceHyperlinkExtension>
425
       <resourceHyperlinkExtension
426
             class="org.eclipse.mylyn.internal.sandbox.ui.hyperlinks.CppResourceHyperlinkExtension"
427
             
428
             fileType="cpp"
429
             generatedPrefix="cpp class">
430
431
       </resourceHyperlinkExtension>
432
       <resourceHyperlinkExtension
433
             class="org.eclipse.mylyn.internal.sandbox.ui.hyperlinks.UnknownResourceHyperlinkExtension"
434
             fileType="unknown"
435
             generatedPrefix="file">
436
       </resourceHyperlinkExtension>
437
    </extension>
438
	-->
409
   <!--
439
   <!--
410
   <extension point="org.eclipse.mylyn.tasks.ui.presentations">
440
   <extension point="org.eclipse.mylyn.tasks.ui.presentations">
411
      <presentation 
441
      <presentation 
(-)schema/resourceHyperlinkExtensions.exsd (+116 lines)
Added Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.mylyn.sandbox.ui" xmlns="http://www.w3.org/2001/XMLSchema">
4
<annotation>
5
      <appinfo>
6
         <meta.schema plugin="org.eclipse.mylyn.sandbox.ui" id="resourceHyperlinkExtensions" name="Resource Hyperlink Extension"/>
7
      </appinfo>
8
      <documentation>
9
         An extension to the Mylyn task editor that can detect resource hyperlinks.
10
      </documentation>
11
   </annotation>
12
13
   <element name="extension">
14
      <annotation>
15
         <appinfo>
16
            <meta.element />
17
         </appinfo>
18
      </annotation>
19
      <complexType>
20
         <sequence minOccurs="1" maxOccurs="unbounded">
21
            <element ref="resourceHyperlinkExtension"/>
22
         </sequence>
23
         <attribute name="point" type="string" use="required">
24
            <annotation>
25
               <documentation>
26
                  
27
               </documentation>
28
            </annotation>
29
         </attribute>
30
         <attribute name="id" type="string">
31
            <annotation>
32
               <documentation>
33
                  
34
               </documentation>
35
            </annotation>
36
         </attribute>
37
         <attribute name="name" type="string">
38
            <annotation>
39
               <documentation>
40
                  
41
               </documentation>
42
               <appinfo>
43
                  <meta.attribute translatable="true"/>
44
               </appinfo>
45
            </annotation>
46
         </attribute>
47
      </complexType>
48
   </element>
49
50
   <element name="resourceHyperlinkExtension">
51
      <complexType>
52
         <attribute name="class" type="string" use="required">
53
            <annotation>
54
               <documentation>
55
                  Should implement IResourceHyperlinkExtension, but may subclass AbstractResourceHyperlinkExtension instead which provides various helper methods.
56
               </documentation>
57
               <appinfo>
58
                  <meta.attribute kind="java" basedOn=":org.eclipse.mylyn.internal.sandbox.ui.hyperlinks.IResourceHyperlinkExtension"/>
59
               </appinfo>
60
            </annotation>
61
         </attribute>
62
         <attribute name="fileType" type="string" use="required">
63
            <annotation>
64
               <documentation>
65
                  the file type of the resource, e.g. *.java, *.cpp, *.txt
66
               </documentation>
67
            </annotation>
68
         </attribute>
69
         <attribute name="generatedPrefix" type="string" use="required">
70
            <annotation>
71
               <documentation>
72
                  correspondent prefix for a certain file type, e.g. for ITask.java, the generatedPrefix is &quot;java class&quot; and the whole is &quot;java class ITask&quot;.
73
               </documentation>
74
            </annotation>
75
         </attribute>
76
      </complexType>
77
   </element>
78
79
   <annotation>
80
      <appinfo>
81
         <meta.section type="since"/>
82
      </appinfo>
83
      <documentation>
84
         [Enter the first release in which this extension point appears.]
85
      </documentation>
86
   </annotation>
87
88
   <annotation>
89
      <appinfo>
90
         <meta.section type="examples"/>
91
      </appinfo>
92
      <documentation>
93
         [Enter extension point usage example here.]
94
      </documentation>
95
   </annotation>
96
97
   <annotation>
98
      <appinfo>
99
         <meta.section type="apiinfo"/>
100
      </appinfo>
101
      <documentation>
102
         [Enter API information here.]
103
      </documentation>
104
   </annotation>
105
106
   <annotation>
107
      <appinfo>
108
         <meta.section type="implementation"/>
109
      </appinfo>
110
      <documentation>
111
         [Enter information about supplied implementation of this extension point.]
112
      </documentation>
113
   </annotation>
114
115
116
</schema>
(-)src/org/eclipse/mylyn/internal/sandbox/ui/hyperlinks/ResourceHyperlinkExtensionReader.java (+64 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2007 Mylyn project 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.sandbox.ui.hyperlinks;
10
11
import org.eclipse.core.runtime.CoreException;
12
import org.eclipse.core.runtime.IConfigurationElement;
13
import org.eclipse.core.runtime.IExtension;
14
import org.eclipse.core.runtime.IExtensionPoint;
15
import org.eclipse.core.runtime.IExtensionRegistry;
16
import org.eclipse.core.runtime.IStatus;
17
import org.eclipse.core.runtime.Platform;
18
import org.eclipse.core.runtime.Status;
19
import org.eclipse.mylyn.commons.core.StatusHandler;
20
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
21
22
/**
23
 * @author Jingwen Ou
24
 */
25
public class ResourceHyperlinkExtensionReader {
26
	public static final String ATTR_FILE_TYPE = "fileType";
27
28
	public static final String ATTR_GENERATED_PREFIX = "generatedPrefix";
29
30
	public static final String EXTENSION_RESOURCE_HYPERLINK_EXTENSIONS = "org.eclipse.mylyn.sandbox.ui.resourceHyperlinkExtensions";
31
32
	private static final String RESOURCE_HYPERLINK_EXTENSION = "resourceHyperlinkExtension";
33
34
	public static void initExtensions() {
35
		IExtensionRegistry registry = Platform.getExtensionRegistry();
36
37
		IExtensionPoint editorExtensionPoint = registry.getExtensionPoint(EXTENSION_RESOURCE_HYPERLINK_EXTENSIONS);
38
		IExtension[] editorExtensions = editorExtensionPoint.getExtensions();
39
		for (IExtension extension : editorExtensions) {
40
			IConfigurationElement[] elements = extension.getConfigurationElements();
41
			for (IConfigurationElement element : elements) {
42
				if (element.getName().equals(RESOURCE_HYPERLINK_EXTENSION)) {
43
					readResourceHyperlinkExtension(element);
44
				}
45
			}
46
		}
47
	}
48
49
	private static void readResourceHyperlinkExtension(IConfigurationElement element) {
50
		try {
51
			String fileType = element.getAttribute(ATTR_FILE_TYPE);
52
			String generatedPrefix = element.getAttribute(ATTR_GENERATED_PREFIX);
53
			IResourceHyperlinkExtension extension = (IResourceHyperlinkExtension) element.createExecutableExtension("class");
54
			ResourceHyperlinkExtensions.addResourceHyperlinkExtension(fileType, generatedPrefix, extension);
55
		} catch (CoreException e) {
56
			StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN,
57
					"Could not load resourceHyperlinkExtension", e));
58
		} catch (Exception e) {
59
			StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN,
60
					"Could not load resourceHyperlinkExtension", e));
61
		}
62
63
	}
64
}
(-)src/org/eclipse/mylyn/internal/sandbox/ui/hyperlinks/ResourceHyperlinkExtensions.java (+109 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2007 Mylyn project 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.sandbox.ui.hyperlinks;
10
11
import java.util.ArrayList;
12
import java.util.HashMap;
13
import java.util.List;
14
import java.util.Map;
15
16
import org.eclipse.core.runtime.Assert;
17
import org.eclipse.core.runtime.IStatus;
18
import org.eclipse.core.runtime.Status;
19
import org.eclipse.mylyn.commons.core.StatusHandler;
20
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
21
22
/**
23
 * A manager that returns registered IResourceHyperlinkExtension
24
 * 
25
 * @author Jingwen Ou
26
 */
27
public class ResourceHyperlinkExtensions {
28
29
	public static class RegisteredResourceHyperlinkExtension {
30
		private final IResourceHyperlinkExtension extension;
31
32
		private final String fileType;
33
34
		private final String generatedPrefix;
35
36
		private RegisteredResourceHyperlinkExtension(IResourceHyperlinkExtension extension, String fileType,
37
				String generatedPrefix) {
38
			this.extension = extension;
39
			this.fileType = fileType;
40
			this.generatedPrefix = generatedPrefix;
41
		}
42
43
		public IResourceHyperlinkExtension getExtension() {
44
			return extension;
45
		}
46
47
		public String getFileType() {
48
			return fileType;
49
		}
50
51
		public String getGeneratedPrefix() {
52
			return generatedPrefix;
53
		}
54
	}
55
56
	private static Map<String, RegisteredResourceHyperlinkExtension> extensionByFileType = new HashMap<String, RegisteredResourceHyperlinkExtension>();
57
58
	private static boolean initialized = false;
59
60
	public static void addResourceHyperlinkExtension(String fileType, String generatedPrefix,
61
			IResourceHyperlinkExtension extension) {
62
		Assert.isNotNull(fileType);
63
64
		RegisteredResourceHyperlinkExtension previous = extensionByFileType.put(fileType,
65
				new RegisteredResourceHyperlinkExtension(extension, fileType, generatedPrefix));
66
67
		if (previous != null) {
68
			StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN,
69
					"Duplicate resourceHyperlinkExtension fileType=" + fileType, null));
70
		}
71
	}
72
73
	public static IResourceHyperlinkExtension getResourceHyperlinkExtension(String fileType) {
74
		init();
75
		RegisteredResourceHyperlinkExtension resourceHyperlinkExtension = extensionByFileType.get(fileType);
76
		return resourceHyperlinkExtension == null ? null : resourceHyperlinkExtension.getExtension();
77
	}
78
79
	public static String getGeneratedPrefix(String fileType) {
80
		init();
81
		RegisteredResourceHyperlinkExtension resourceHyperlinkExtension = extensionByFileType.get(fileType);
82
		return resourceHyperlinkExtension == null ? null : resourceHyperlinkExtension.getGeneratedPrefix();
83
	}
84
85
	public static String getUnknownGeneratedPrefix() {
86
		init();
87
		RegisteredResourceHyperlinkExtension unknownResourceHyperlinkExtension = extensionByFileType.get("unknown");
88
		return unknownResourceHyperlinkExtension == null ? null
89
				: unknownResourceHyperlinkExtension.getGeneratedPrefix();
90
	}
91
92
	public static List<IResourceHyperlinkExtension> getResourceHyperlinkExtensions() {
93
		init();
94
		ArrayList<IResourceHyperlinkExtension> resourceHyperlinkExtensions = new ArrayList<IResourceHyperlinkExtension>(
95
				extensionByFileType.size());
96
		for (RegisteredResourceHyperlinkExtension resourceHyperlinkExtension : extensionByFileType.values()) {
97
			resourceHyperlinkExtensions.add(resourceHyperlinkExtension.getExtension());
98
		}
99
100
		return resourceHyperlinkExtensions;
101
	}
102
103
	private static void init() {
104
		if (!initialized) {
105
			initialized = true;
106
			ResourceHyperlinkExtensionReader.initExtensions();
107
		}
108
	}
109
}
(-)src/org/eclipse/mylyn/internal/sandbox/ui/hyperlinks/IResourceHyperlinkExtension.java (+21 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2007 Mylyn project 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.sandbox.ui.hyperlinks;
10
11
import org.eclipse.jface.text.hyperlink.IHyperlink;
12
13
/**
14
 * @author Jingwen Ou
15
 */
16
public interface IResourceHyperlinkExtension {
17
	/**
18
	 * find specific hyperlinks in text
19
	 */
20
	IHyperlink[] findHyperlink(String text, int lineOffset, int regionOffset);
21
}

Return to bug 240423