1 20 21 package org.apache.directory.ldapstudio.schemas.view.views.wrappers; 22 23 24 import org.apache.directory.ldapstudio.schemas.Activator; 25 import org.apache.directory.ldapstudio.schemas.PluginConstants; 26 import org.apache.directory.ldapstudio.schemas.model.ObjectClass; 27 import org.eclipse.swt.graphics.Image; 28 import org.eclipse.ui.ISharedImages; 29 import org.eclipse.ui.PlatformUI; 30 import org.eclipse.ui.plugin.AbstractUIPlugin; 31 32 33 39 public class ObjectClassWrapper extends TreeNode 40 { 41 47 public enum State 48 { 49 resolved, unResolved 50 } 51 52 53 private State state; 54 55 56 private ObjectClass myObjectClass; 57 58 59 67 public ObjectClassWrapper( ObjectClass myObjectClass, ITreeNode parent ) 68 { 69 super( parent ); 70 this.myObjectClass = myObjectClass; 71 this.state = State.resolved; 72 } 73 74 75 81 public ObjectClass getMyObjectClass() 82 { 83 return myObjectClass; 84 } 85 86 87 93 public State getState() 94 { 95 return state; 96 } 97 98 99 105 public void setState( State state ) 106 { 107 this.state = state; 108 } 109 110 111 114 public Image getImage() 115 { 116 String imageKey = ISharedImages.IMG_OBJS_WARN_TSK; 117 118 if ( state == State.resolved ) 119 return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, PluginConstants.IMG_OBJECT_CLASS ) 120 .createImage(); 121 else if ( state == State.unResolved ) 122 return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, 123 PluginConstants.IMG_OBJECT_CLASS_WARNING ).createImage(); 124 125 return PlatformUI.getWorkbench().getSharedImages().getImage( imageKey ); 126 } 127 128 129 132 public boolean equals( Object obj ) 133 { 134 if ( obj instanceof ObjectClassWrapper ) 135 { 136 ObjectClassWrapper compared = ( ObjectClassWrapper ) obj; 137 return compared.getMyObjectClass().getOid().equals( this.getMyObjectClass().getOid() ); 138 } 139 return false; 140 } 141 142 143 146 public String toString() 147 { 148 return myObjectClass + " wrapper"; } 150 } 151 | Popular Tags |