Bonjour à tous.
Développant une appli en RCP, je tente en vain d'utiliser l'extension "org.eclipse.ui.decorators" afin de rajouter des éléments graphiques sur les icones de mes noeuds de treeviews selon leur état de synchronisation.
J'ai donc un plugin.xml qui contient :
Comme vous aurez pu le deviner en voyant ce code, les éléments contenus dans mes treeviews sont des TreeNode
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 <extension point="org.eclipse.ui.decorators"> <decorator adaptable="true" class="com.lectra.plmadminsuite.sharedcomponents.gui.decorators.SynchronizationDecorator" id="com.lectra.plmadminsuite.sharedcomponents.gui.synchrodecorator" label="Synchronization Decorator" lightweight="true" location="BOTTOM_RIGHT" state="true"> <enablement> <objectClass name="com.lectra.plmadminsuite.sharedcomponents.models.TreeNode"> </objectClass> </enablement> </decorator>
Le code de mon décorateur est le suivant :
Premier Problème :
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 public class SynchronizationDecorator implements ILightweightLabelDecorator { public static String ID = "com.lectra.plmadminsuite.sharedcomponents.gui.synchrodecorator"; /** * {@inheritDoc} */ public final void decorate(final Object element, final IDecoration decoration) { /** * Checks that the element is a TreeNode with the {@link SynchroStatus#REMOTE SynchroStatus.REMOTE} status * and adds the decorator based on the specified image description and the integer representation of the * placement option. */ if (!(element instanceof TreeNode)) { return; } final SynchroStatus status = ((TreeNode) element).getSynchronizer().getStatus(); if (SynchroStatus.EQUALS.equals(status)) { return; } ImageDescriptor descriptor = null; if (SynchroStatus.REMOTE.equals(status)) { descriptor = AbstractPluginActivator.getImageDescriptor(SharedImagesPaths.BULLET_REMOTE); } else if (SynchroStatus.LOCAL.equals(status)) { descriptor = AbstractPluginActivator.getImageDescriptor(SharedImagesPaths.BULLET_LOCAL); } else if (SynchroStatus.DIFERENT.equals(status)) { descriptor = AbstractPluginActivator.getImageDescriptor(SharedImagesPaths.BULLET_DIFFERENT); } decoration.addOverlay(descriptor, IDecoration.BOTTOM_RIGHT); } /** * {@inheritDoc} */ public void addListener(final ILabelProviderListener listener) { } /** * {@inheritDoc} */ public void dispose() { } /** * {@inheritDoc} */ public final boolean isLabelProperty(final Object element, final String property) { return false; } /** * {@inheritDoc} */ public void removeListener(final ILabelProviderListener listener) { } }
Si je ne fais pas un appel à "PlatformUI.getWorkbench().getDecoratorManager()" quelque part dans mon code (en l'occurence, je l'ai fait dans l'activateur du plugin), mon décorateur n'est jamais appelé.
Deuxième Problème :
Même dans le cas où le code passe dans la méthode "decorate" de mon decorator, il n'y a aucun changement sur les icones de mon treeView.
Si quelqu'un pouvait m'aider à trouver ce qui se passe, je lui en serait grandement reconnaissant.
PS : mon treeview a un labelprovider dans lequel j'ai même tenté de rajouter le décorateur de la façon suivante sans résultat non plus :
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 public Image getImageImpl(final Object obj) { final AbstractSynchronizer sync = ((TreeNode) obj).getSynchronizer(); final SecurityInfos infos = (SecurityInfos) ((TreeNode) obj).getInfos(); String iconPath = null; if (sync instanceof GroupSynchronizer) { // if (infos.hasRights()) { // iconPath = ICON_GROUP_KEY; // } else { iconPath = ICON_GROUP; // } } else if (sync instanceof UserSynchronizer) { iconPath = ICON_USER; } else if (sync instanceof ProfileSynchronizer) { iconPath = ICON_LOCK; } if (iconPath != null) { final Image ret = AbstractPluginActivator.getImageDescriptor(iconPath).createImage(); PlatformUI.getWorkbench().getDecoratorManager().decorateImage(ret, obj); return ret; } return super.getImage(obj); }
Partager