1 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 44 public class SchemasEditorLabelDecorator extends LabelProvider implements ILightweightLabelDecorator 45 { 46 49 public void decorate( Object 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 |