1 20 21 package org.apache.directory.ldapstudio.browser.ui.editors.schemabrowser; 22 23 24 import org.apache.directory.ldapstudio.browser.core.model.IConnection; 25 import org.apache.directory.ldapstudio.browser.core.model.schema.SchemaPart; 26 import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants; 27 import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin; 28 import org.eclipse.jface.resource.ImageDescriptor; 29 import org.eclipse.ui.IEditorInput; 30 import org.eclipse.ui.IPersistableElement; 31 32 33 51 public class SchemaBrowserInput implements IEditorInput 52 { 53 54 55 private IConnection connection; 56 57 58 private SchemaPart schemaElement; 59 60 61 private static boolean oneInstanceHackEnabled = true; 62 63 64 70 public SchemaBrowserInput( IConnection connection, SchemaPart schemaElement ) 71 { 72 this.connection = connection; 73 this.schemaElement = schemaElement; 74 } 75 76 77 84 public boolean exists() 85 { 86 return false; 87 } 88 89 90 93 public ImageDescriptor getImageDescriptor() 94 { 95 return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_BROWSER_SCHEMABROWSEREDITOR ); 96 } 97 98 99 102 public String getName() 103 { 104 return "Schema Browser"; 105 } 106 107 108 113 public IPersistableElement getPersistable() 114 { 115 return null; 116 } 117 118 119 122 public String getToolTipText() 123 { 124 return ""; 125 } 126 127 128 131 public Object getAdapter( Class adapter ) 132 { 133 return null; 134 } 135 136 137 142 public IConnection getConnection() 143 { 144 return connection; 145 } 146 147 148 154 public SchemaPart getSchemaElement() 155 { 156 return schemaElement; 157 } 158 159 160 163 public int hashCode() 164 { 165 return getToolTipText().hashCode(); 166 } 167 168 169 172 public boolean equals( Object obj ) 173 { 174 175 boolean equal; 176 177 if ( oneInstanceHackEnabled ) 178 { 179 equal = ( obj instanceof SchemaBrowserInput ); 180 } 181 else 182 { 183 if ( obj instanceof SchemaBrowserInput ) 184 { 185 SchemaBrowserInput other = ( SchemaBrowserInput ) obj; 186 if ( this.connection == null && other.connection == null) 187 { 188 return true; 189 } 190 else if ( this.connection == null || other.connection == null) 191 { 192 return false; 193 } 194 else if ( !this.connection.equals( other.connection )) 195 { 196 return false; 197 } 198 else if ( this.schemaElement == null && other.schemaElement == null ) 199 { 200 return true; 201 } 202 else if ( this.schemaElement == null || other.schemaElement == null ) 203 { 204 return false; 205 } 206 else 207 { 208 equal = other.schemaElement.equals( this.schemaElement ); 209 } 210 } 211 else 212 { 213 equal = false; 214 } 215 } 216 217 return equal; 218 } 219 220 221 228 public static void enableOneInstanceHack( boolean b ) 229 { 230 oneInstanceHackEnabled = b; 231 } 232 233 } 234 | Popular Tags |