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.eclipse.swt.graphics.Image; 27 import org.eclipse.ui.ISharedImages; 28 import org.eclipse.ui.PlatformUI; 29 import org.eclipse.ui.plugin.AbstractUIPlugin; 30 31 32 39 public class IntermediateNode extends TreeNode 40 { 41 42 public enum IntermediateNodeType 43 { 44 NONE, OBJECT_CLASS_FOLDER, ATTRIBUTE_TYPE_FOLDER 45 } 46 47 48 private String name; 49 50 51 private IntermediateNodeType type; 52 53 54 60 public IntermediateNode( String name, ITreeNode parent ) 61 { 62 super( parent ); 63 this.name = name; 64 this.type = IntermediateNodeType.NONE; 65 } 66 67 68 78 public IntermediateNode( String name, ITreeNode parent, IntermediateNodeType type ) 79 { 80 super( parent ); 81 this.name = name; 82 this.type = type; 83 } 84 85 86 89 90 93 public String getName() 94 { 95 return name; 96 } 97 98 99 102 public Image getImage() 103 { 104 switch ( type ) 105 { 106 case NONE: 107 String imageKey = ISharedImages.IMG_OBJ_FOLDER; 108 return PlatformUI.getWorkbench().getSharedImages().getImage( imageKey ); 109 case ATTRIBUTE_TYPE_FOLDER: 110 return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, 111 PluginConstants.IMG_FOLDER_ATTRIBUTE_TYPE ).createImage(); 112 case OBJECT_CLASS_FOLDER: 113 return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, 114 PluginConstants.IMG_FOLDER_OBJECT_CLASS ).createImage(); 115 } 116 117 String imageKey = ISharedImages.IMG_OBJ_FOLDER; 118 return PlatformUI.getWorkbench().getSharedImages().getImage( imageKey ); 119 } 120 121 122 125 public String toString() 126 { 127 return name; 128 } 129 130 131 134 public boolean equals( Object obj ) 135 { 136 if ( obj instanceof IntermediateNode ) 137 { 138 IntermediateNode compared = ( IntermediateNode ) obj; 139 if ( compared.getName().equals( this.getName() ) ) 140 { 141 if ( ( compared.getParent() == null ) || ( this.getParent() == null ) ) 142 return true; 143 if ( compared.getParent().equals( this.getParent() ) ) 144 return true; 145 } 146 } 147 return false; 148 } 149 150 151 157 public IntermediateNodeType getType() 158 { 159 return type; 160 } 161 162 163 169 public void setType( IntermediateNodeType type ) 170 { 171 this.type = type; 172 } 173 } 174 | Popular Tags |