1 20 21 package org.apache.directory.ldapstudio.actions; 22 23 24 import org.eclipse.core.runtime.IPath; 25 import org.eclipse.core.runtime.Platform; 26 import org.eclipse.jface.resource.ImageDescriptor; 27 import org.eclipse.ui.IPathEditorInput; 28 import org.eclipse.ui.IPersistableElement; 29 30 31 39 public class PathEditorInput implements IPathEditorInput 40 { 41 42 43 private IPath path; 44 45 46 private ImageDescriptor imageDescriptor; 47 48 49 56 public PathEditorInput( IPath path, ImageDescriptor imageDescriptor ) 57 { 58 if ( path == null ) 59 { 60 throw new IllegalArgumentException (); 61 } 62 63 this.path = path; 64 this.imageDescriptor = imageDescriptor; 65 } 66 67 68 71 public int hashCode() 72 { 73 return path.hashCode(); 74 } 75 76 77 80 public boolean equals( Object o ) 81 { 82 if ( this == o ) 83 { 84 return true; 85 } 86 87 if ( o instanceof PathEditorInput ) 88 { 89 PathEditorInput input = ( PathEditorInput ) o; 90 return path.equals( input.path ); 91 } 92 93 return false; 94 } 95 96 97 100 public boolean exists() 101 { 102 return path.toFile().exists(); 103 } 104 105 106 109 public ImageDescriptor getImageDescriptor() 110 { 111 return imageDescriptor; 112 } 113 114 115 118 public String getName() 119 { 120 return path.toFile().getName(); 121 } 123 124 125 128 public String getToolTipText() 129 { 130 return path.makeRelative().toOSString(); 131 } 132 133 134 137 public IPath getPath() 138 { 139 return path; 140 } 141 142 143 146 public Object getAdapter( Class adapter ) 147 { 148 return Platform.getAdapterManager().getAdapter( this, adapter ); 149 } 150 151 152 155 public IPersistableElement getPersistable() 156 { 157 return null; 158 } 159 160 161 164 public IPath getPath( Object element ) 165 { 166 if ( element instanceof PathEditorInput ) 167 { 168 PathEditorInput input = ( PathEditorInput ) element; 169 return input.getPath(); 170 } 171 172 return null; 173 } 174 } 175 | Popular Tags |