1 20 21 package org.apache.directory.ldapstudio.browser.ui.editors.schemabrowser; 22 23 24 import org.apache.directory.ldapstudio.browser.core.model.schema.ObjectClassDescription; 25 import org.apache.directory.ldapstudio.browser.core.model.schema.Schema; 26 import org.eclipse.jface.viewers.IStructuredContentProvider; 27 import org.eclipse.jface.viewers.ITableLabelProvider; 28 import org.eclipse.jface.viewers.LabelProvider; 29 import org.eclipse.jface.viewers.Viewer; 30 import org.eclipse.jface.viewers.ViewerFilter; 31 import org.eclipse.jface.viewers.ViewerSorter; 32 import org.eclipse.swt.graphics.Image; 33 34 35 42 public class ObjectClassDescriptionPage extends SchemaPage 43 { 44 45 50 public ObjectClassDescriptionPage( SchemaBrowser schemaBrowser ) 51 { 52 super( schemaBrowser ); 53 } 54 55 56 59 protected String getTitle() 60 { 61 return "Object Classes"; 62 } 63 64 65 68 protected String getFilterDescription() 69 { 70 return "Please select an object class. Enter a filter to restrict the list."; 71 } 72 73 74 77 protected IStructuredContentProvider getContentProvider() 78 { 79 return new OCDContentProvider(); 80 } 81 82 83 86 protected ITableLabelProvider getLabelProvider() 87 { 88 return new OCDLabelProvider(); 89 } 90 91 92 95 protected ViewerSorter getSorter() 96 { 97 return new OCDViewerSorter(); 98 } 99 100 101 104 protected ViewerFilter getFilter() 105 { 106 return new OCDViewerFilter(); 107 } 108 109 110 113 protected SchemaDetailsPage getDetailsPage() 114 { 115 return new ObjectClassDescriptionDetailsPage( this, this.toolkit ); 116 } 117 118 124 class OCDContentProvider implements IStructuredContentProvider 125 { 126 129 public Object [] getElements( Object inputElement ) 130 { 131 if ( inputElement instanceof Schema ) 132 { 133 Schema schema = ( Schema ) inputElement; 134 if ( schema != null ) 135 { 136 return schema.getObjectClassDescriptions(); 137 } 138 } 139 return new Object [0]; 140 } 141 142 143 146 public void dispose() 147 { 148 } 149 150 151 154 public void inputChanged( Viewer viewer, Object oldInput, Object newInput ) 155 { 156 } 157 } 158 159 165 class OCDLabelProvider extends LabelProvider implements ITableLabelProvider 166 { 167 170 public String getColumnText( Object obj, int index ) 171 { 172 return obj.toString(); 173 } 174 175 176 179 public Image getColumnImage( Object obj, int index ) 180 { 181 return null; 182 } 183 } 184 185 191 class OCDViewerSorter extends ViewerSorter 192 { 193 196 public int compare( Viewer viewer, Object e1, Object e2 ) 197 { 198 return e1.toString().compareTo( e2.toString() ); 199 } 200 } 201 202 208 class OCDViewerFilter extends ViewerFilter 209 { 210 213 public boolean select( Viewer viewer, Object parentElement, Object element ) 214 { 215 if ( element instanceof ObjectClassDescription ) 216 { 217 ObjectClassDescription ocd = ( ObjectClassDescription ) element; 218 boolean matched = false; 219 220 if ( !matched ) 221 matched = ocd.toString().toLowerCase().indexOf( filterText.getText().toLowerCase() ) != -1; 222 if ( !matched ) 223 matched = ocd.getNumericOID().toLowerCase().indexOf( filterText.getText().toLowerCase() ) != -1; 224 225 return matched; 226 } 227 return false; 228 } 229 } 230 231 } 232 | Popular Tags |