KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > schemas > view > SchemasEditorLabelDecorator


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  *
19  */

20 package org.apache.directory.ldapstudio.schemas.view;
21
22
23 import org.apache.directory.ldapstudio.schemas.Activator;
24 import org.apache.directory.ldapstudio.schemas.PluginConstants;
25 import org.apache.directory.ldapstudio.schemas.model.AttributeType;
26 import org.apache.directory.ldapstudio.schemas.model.ObjectClass;
27 import org.apache.directory.ldapstudio.schemas.view.views.wrappers.AttributeTypeWrapper;
28 import org.apache.directory.ldapstudio.schemas.view.views.wrappers.ObjectClassWrapper;
29 import org.apache.directory.shared.ldap.schema.ObjectClassTypeEnum;
30 import org.apache.directory.shared.ldap.schema.UsageEnum;
31 import org.eclipse.jface.viewers.IDecoration;
32 import org.eclipse.jface.viewers.ILightweightLabelDecorator;
33 import org.eclipse.jface.viewers.LabelProvider;
34 import org.eclipse.ui.plugin.AbstractUIPlugin;
35
36
37 /**
38  * This class is the Schemas Editor Label Decorator.
39  * It displays specific icons overlays for attribute types and object classes.
40  *
41  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
42  * @version $Rev$, $Date$
43  */

44 public class SchemasEditorLabelDecorator extends LabelProvider implements ILightweightLabelDecorator
45 {
46     /* (non-Javadoc)
47      * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object, org.eclipse.jface.viewers.IDecoration)
48      */

49     public void decorate( Object JavaDoc element, IDecoration decoration )
50     {
51         if ( element instanceof AttributeTypeWrapper )
52         {
53             AttributeTypeWrapper atw = ( AttributeTypeWrapper ) element;
54
55             UsageEnum usage = atw.getMyAttributeType().getUsage();
56
57             if ( usage == UsageEnum.USER_APPLICATIONS )
58             {
59                 decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
60                     PluginConstants.IMG_ATTRIBUTE_TYPE_OVERLAY_USER_APPLICATION ), IDecoration.BOTTOM_RIGHT );
61             }
62             else if ( ( usage == UsageEnum.DIRECTORY_OPERATION ) || ( usage == UsageEnum.DISTRIBUTED_OPERATION )
63                 || ( usage == UsageEnum.DSA_OPERATION ) )
64             {
65                 decoration.addOverlay( Activator.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
66                     PluginConstants.IMG_ATTRIBUTE_TYPE_OVERLAY_OPERATION ), IDecoration.BOTTOM_RIGHT );
67             }
68         }
69         else if ( element instanceof ObjectClassWrapper )
70         {
71             ObjectClassWrapper ocw = ( ObjectClassWrapper ) element;
72
73             ObjectClassTypeEnum classType = ocw.getMyObjectClass().getClassType();
74
75             if ( classType == ObjectClassTypeEnum.ABSTRACT )
76             {
77                 decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
78                     PluginConstants.IMG_OBJECT_CLASS_OVERLAY_ABSTRACT ), IDecoration.BOTTOM_RIGHT );
79             }
80             else if ( classType == ObjectClassTypeEnum.STRUCTURAL )
81             {
82                 decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
83                     PluginConstants.IMG_OBJECT_CLASS_OVERLAY_STRUCTURAL ), IDecoration.BOTTOM_RIGHT );
84             }
85             else if ( classType == ObjectClassTypeEnum.AUXILIARY )
86             {
87                 decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
88                     PluginConstants.IMG_OBJECT_CLASS_OVERLAY_AUXILIARY ), IDecoration.BOTTOM_RIGHT );
89             }
90         }
91         else if ( element instanceof AttributeType )
92         {
93             AttributeType at = ( AttributeType ) element;
94
95             UsageEnum usage = at.getUsage();
96
97             if ( usage == UsageEnum.USER_APPLICATIONS )
98             {
99                 decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
100                     PluginConstants.IMG_ATTRIBUTE_TYPE_OVERLAY_USER_APPLICATION ), IDecoration.BOTTOM_RIGHT );
101             }
102             else if ( ( usage == UsageEnum.DIRECTORY_OPERATION ) || ( usage == UsageEnum.DISTRIBUTED_OPERATION )
103                 || ( usage == UsageEnum.DSA_OPERATION ) )
104             {
105                 decoration.addOverlay( Activator.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
106                     PluginConstants.IMG_ATTRIBUTE_TYPE_OVERLAY_OPERATION ), IDecoration.BOTTOM_RIGHT );
107             }
108         }
109         else if ( element instanceof ObjectClass )
110         {
111             ObjectClass oc = ( ObjectClass ) element;
112
113             ObjectClassTypeEnum classType = oc.getClassType();
114
115             if ( classType == ObjectClassTypeEnum.ABSTRACT )
116             {
117                 decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
118                     PluginConstants.IMG_OBJECT_CLASS_OVERLAY_ABSTRACT ), IDecoration.BOTTOM_RIGHT );
119             }
120             else if ( classType == ObjectClassTypeEnum.STRUCTURAL )
121             {
122                 decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
123                     PluginConstants.IMG_OBJECT_CLASS_OVERLAY_STRUCTURAL ), IDecoration.BOTTOM_RIGHT );
124             }
125             else if ( classType == ObjectClassTypeEnum.AUXILIARY )
126             {
127                 decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
128                     PluginConstants.IMG_OBJECT_CLASS_OVERLAY_AUXILIARY ), IDecoration.BOTTOM_RIGHT );
129             }
130         }
131     }
132 }
133
Popular Tags