1 20 21 package org.apache.directory.ldapstudio.browser.ui.editors.searchresult; 22 23 24 import org.apache.directory.ldapstudio.browser.core.model.ISearch; 25 import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants; 26 import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin; 27 import org.eclipse.jface.resource.ImageDescriptor; 28 import org.eclipse.ui.IEditorInput; 29 import org.eclipse.ui.IPersistableElement; 30 31 32 50 public class SearchResultEditorInput implements IEditorInput 51 { 52 53 54 private ISearch search; 55 56 57 private static boolean oneInstanceHackEnabled = true; 58 59 60 65 public SearchResultEditorInput( ISearch search ) 66 { 67 this.search = search; 68 } 69 70 71 78 public boolean exists() 79 { 80 return false; 81 } 82 83 84 87 public ImageDescriptor getImageDescriptor() 88 { 89 return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_BROWSER_SEARCHRESULTEDITOR ); 90 } 91 92 93 96 public String getName() 97 { 98 return "Search Result Editor"; 99 } 100 101 102 105 public String getToolTipText() 106 { 107 return ""; 108 } 109 110 111 116 public IPersistableElement getPersistable() 117 { 118 return null; 119 } 120 121 122 125 public Object getAdapter( Class adapter ) 126 { 127 return null; 128 } 129 130 131 136 public ISearch getSearch() 137 { 138 return search; 139 } 140 141 142 145 public int hashCode() 146 { 147 return getToolTipText().hashCode(); 148 } 149 150 151 154 public boolean equals( Object obj ) 155 { 156 157 boolean equal; 158 159 if ( oneInstanceHackEnabled ) 160 { 161 equal = ( obj instanceof SearchResultEditorInput ); 162 } 163 else 164 { 165 if ( obj instanceof SearchResultEditorInput ) 166 { 167 SearchResultEditorInput other = ( SearchResultEditorInput ) obj; 168 if ( this.search == null && other.search == null ) 169 { 170 return true; 171 } 172 else if ( this.search == null || other.search == null ) 173 { 174 return false; 175 } 176 else 177 { 178 equal = other.search.equals( this.search ); 179 } 180 } 181 else 182 { 183 equal = false; 184 } 185 } 186 187 return equal; 188 } 189 190 191 198 public static void enableOneInstanceHack( boolean b ) 199 { 200 oneInstanceHackEnabled = b; 201 } 202 203 } 204 | Popular Tags |