Bonjour a tous,
Voila j'essai d utiliser un point d'extension dans un plugin pour creer une extension dans un autre :
voila le .XML du point d'extension
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119 <?xml version='1.0' encoding='UTF-8'?> <!-- Schema file written by PDE --> <schema targetNamespace="Main"> <annotation> <appInfo> <meta.schema plugin="Main" id="idextension" name="nameextension"/> </appInfo> <documentation> [Enter description of this extension point.] </documentation> </annotation> <element name="extension"> <complexType> <sequence> <element ref="overideview" minOccurs="0" maxOccurs="unbounded"/> </sequence> <attribute name="point" type="string" use="required"> <annotation> <documentation> </documentation> </annotation> </attribute> <attribute name="id" type="string"> <annotation> <documentation> </documentation> </annotation> </attribute> <attribute name="name" type="string"> <annotation> <documentation> </documentation> <appInfo> <meta.attribute translatable="true"/> </appInfo> </annotation> </attribute> </complexType> </element> <element name="overideview"> <complexType> <attribute name="id_override" type="string" use="required"> <annotation> <documentation> </documentation> </annotation> </attribute> <attribute name="nameoverride" type="string" use="required"> <annotation> <documentation> </documentation> </annotation> </attribute> <attribute name="classe_override" type="string" use="required"> <annotation> <documentation> </documentation> <appInfo> <meta.attribute kind="java" basedOn="main.View:"/> </appInfo> </annotation> </attribute> </complexType> </element> <annotation> <appInfo> <meta.section type="since"/> </appInfo> <documentation> [Enter the first release in which this extension point appears.] </documentation> </annotation> <annotation> <appInfo> <meta.section type="examples"/> </appInfo> <documentation> [Enter extension point usage example here.] </documentation> </annotation> <annotation> <appInfo> <meta.section type="apiInfo"/> </appInfo> <documentation> [Enter API information here.] </documentation> </annotation> <annotation> <appInfo> <meta.section type="implementation"/> </appInfo> <documentation> [Enter information about supplied implementation of this extension point.] </documentation> </annotation> <annotation> <appInfo> <meta.section type="copyright"/> </appInfo> <documentation> </documentation> </annotation> </schema>
l'extension définie
le probleme c est que j essais de reperer si un extension est présente avec le code suivant :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 <?xml version="1.0" encoding="UTF-8"?> <?eclipse version="3.2"?> <plugin> <extension point="Main.idextension"> <overideview classe_override="extension1.OverrideView" id_override="id_extension1" nameoverride="name_extension1"> </overideview> </extension> </plugin>
Et je ne comprend pas pourquoi ca ne marche pas (je ne repere aucune extension présente....
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56 package main; import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.Platform; public abstract class TrackExtension { public static boolean getExtension(){ boolean res = false; // Récupération de l'extension associée au nom d'horloge String extensionPointId = "Main.idextension"; IExtensionPoint contributions = Platform.getExtensionRegistry().getExtensionPoint(extensionPointId);//.getConfigurationElementsFor(extensionPointId); System.out.println("****" + contributions.getContributor().getName()); System.out.println("----" + contributions.getExtensions().length);//.getConfigurationElements().length); //IConfigurationElement extensionview = null; /* if (contributions.length == 0) { System.out.println("any extension for current view"); } else System.out.println(contributions.length + " extension(s) for current view"); */ /*for (int i = 0; i < contributions.length; i++) { if(contributions[i].getAttribute("name").equals(nomHorlogeCourante)) { extensionview = contributions[i]; break; } } // Si une extension est disponible, la classe 'Horloge' correspondante // est instanciée via la méthode 'createExecutableExtension' if(extensionHorloge != null) { try { System.out.println("passes par la"); Horloge horloge = (Horloge)extensionHorloge.createExecutableExtension("classe"); horloge.afficher(parent); } catch (CoreException e) { String msg = "Impossible d'afficher l'horloge"; System.out.println(msg); parent.setLayout(new RowLayout()); (new Label(parent, SWT.NONE)).setText(msg); }*/ return res; } }
help me please
merci d avance
Partager