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.AttributeTypeDescription; 26 import org.apache.directory.ldapstudio.browser.core.model.schema.LdapSyntaxDescription; 27 import org.apache.directory.ldapstudio.browser.core.model.schema.MatchingRuleDescription; 28 import org.apache.directory.ldapstudio.browser.core.model.schema.MatchingRuleUseDescription; 29 import org.apache.directory.ldapstudio.browser.core.model.schema.ObjectClassDescription; 30 import org.apache.directory.ldapstudio.browser.core.model.schema.SchemaPart; 31 import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants; 32 import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin; 33 import org.eclipse.core.runtime.IProgressMonitor; 34 import org.eclipse.swt.SWT; 35 import org.eclipse.swt.custom.CTabFolder; 36 import org.eclipse.swt.custom.CTabItem; 37 import org.eclipse.swt.widgets.Composite; 38 import org.eclipse.swt.widgets.Control; 39 import org.eclipse.ui.IEditorInput; 40 import org.eclipse.ui.IEditorPart; 41 import org.eclipse.ui.IEditorSite; 42 import org.eclipse.ui.INavigationLocation; 43 import org.eclipse.ui.INavigationLocationProvider; 44 import org.eclipse.ui.IReusableEditor; 45 import org.eclipse.ui.PartInitException; 46 import org.eclipse.ui.PlatformUI; 47 import org.eclipse.ui.part.EditorPart; 48 49 50 56 public class SchemaBrowser extends EditorPart implements INavigationLocationProvider, IReusableEditor 57 { 58 59 60 private CTabFolder tabFolder; 61 62 63 private CTabItem ocdTab; 64 65 66 private ObjectClassDescriptionPage ocdPage; 67 68 69 private CTabItem atdTab; 70 71 72 private AttributeTypeDescriptionPage atdPage; 73 74 75 private CTabItem mrdTab; 76 77 78 private MatchingRuleDescriptionPage mrdPage; 79 80 81 private CTabItem mrudTab; 82 83 84 private MatchingRuleUseDescriptionPage mrudPage; 85 86 87 private CTabItem lsdTab; 88 89 90 private LdapSyntaxDescriptionPage lsdPage; 91 92 93 98 public static String getId() 99 { 100 return SchemaBrowser.class.getName(); 101 } 102 103 104 107 public void init( IEditorSite site, IEditorInput input ) throws PartInitException 108 { 109 setSite( site ); 110 111 setInput( new SchemaBrowserInput( null, null ) ); 114 getSite().getPage().getNavigationHistory().markLocation( this ); 115 116 setInput( input ); 118 } 119 120 121 124 public void dispose() 125 { 126 ocdPage.dispose(); 127 atdPage.dispose(); 128 mrdPage.dispose(); 129 mrudPage.dispose(); 130 lsdPage.dispose(); 131 tabFolder.dispose(); 132 super.dispose(); 133 } 134 135 136 139 public void createPartControl( Composite parent ) 140 { 141 tabFolder = new CTabFolder( parent, SWT.BOTTOM ); 142 143 ocdTab = new CTabItem( tabFolder, SWT.NONE ); 144 ocdTab.setText( "Object Classes" ); 145 ocdTab.setImage( BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_OCD ) ); 146 ocdPage = new ObjectClassDescriptionPage( this ); 147 Control ocdPageControl = ocdPage.createControl( tabFolder ); 148 ocdTab.setControl( ocdPageControl ); 149 150 atdTab = new CTabItem( tabFolder, SWT.NONE ); 151 atdTab.setText( "Attribute Types" ); 152 atdTab.setImage( BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_ATD ) ); 153 atdPage = new AttributeTypeDescriptionPage( this ); 154 Control atdPageControl = atdPage.createControl( tabFolder ); 155 atdTab.setControl( atdPageControl ); 156 157 mrdTab = new CTabItem( tabFolder, SWT.NONE ); 158 mrdTab.setText( "Matching Rules" ); 159 mrdTab.setImage( BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_MRD ) ); 160 mrdPage = new MatchingRuleDescriptionPage( this ); 161 Control mrdPageControl = mrdPage.createControl( tabFolder ); 162 mrdTab.setControl( mrdPageControl ); 163 164 mrudTab = new CTabItem( tabFolder, SWT.NONE ); 165 mrudTab.setImage( BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_MRUD ) ); 166 mrudTab.setText( "Matching Rule Use" ); 167 mrudPage = new MatchingRuleUseDescriptionPage( this ); 168 Control mrudPageControl = mrudPage.createControl( tabFolder ); 169 mrudTab.setControl( mrudPageControl ); 170 171 lsdTab = new CTabItem( tabFolder, SWT.NONE ); 172 lsdTab.setImage( BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_LSD ) ); 173 lsdTab.setText( "Syntaxes" ); 174 lsdPage = new LdapSyntaxDescriptionPage( this ); 175 Control lsdPageControl = lsdPage.createControl( tabFolder ); 176 lsdTab.setControl( lsdPageControl ); 177 178 tabFolder.setSelection( ocdTab ); 180 181 PlatformUI.getWorkbench().getHelpSystem().setHelp( parent, 183 BrowserUIPlugin.PLUGIN_ID + "." + "tools_schema_browser" ); 184 PlatformUI.getWorkbench().getHelpSystem().setHelp( tabFolder, 185 BrowserUIPlugin.PLUGIN_ID + "." + "tools_schema_browser" ); 186 PlatformUI.getWorkbench().getHelpSystem().setHelp( ocdPageControl, 187 BrowserUIPlugin.PLUGIN_ID + "." + "tools_schema_browser" ); 188 } 189 190 191 194 public void setInput( IEditorInput input ) 195 { 196 super.setInput( input ); 197 198 if ( input instanceof SchemaBrowserInput && tabFolder != null ) 199 { 200 SchemaBrowserInput sbi = ( SchemaBrowserInput ) input; 201 202 IConnection connection = sbi.getConnection(); 204 setConnection( connection ); 205 206 SchemaPart schemaElement = sbi.getSchemaElement(); 208 if ( schemaElement instanceof ObjectClassDescription ) 209 { 210 ocdPage.select( schemaElement ); 211 tabFolder.setSelection( ocdTab ); 212 } 213 else if ( schemaElement instanceof AttributeTypeDescription ) 214 { 215 atdPage.select( schemaElement ); 216 tabFolder.setSelection( atdTab ); 217 } 218 else if ( schemaElement instanceof MatchingRuleDescription ) 219 { 220 mrdPage.select( schemaElement ); 221 tabFolder.setSelection( mrdTab ); 222 } 223 else if ( schemaElement instanceof MatchingRuleUseDescription ) 224 { 225 mrudPage.select( schemaElement ); 226 tabFolder.setSelection( mrudTab ); 227 } 228 else if ( schemaElement instanceof LdapSyntaxDescription ) 229 { 230 lsdPage.select( schemaElement ); 231 tabFolder.setSelection( lsdTab ); 232 } 233 234 if ( connection != null && schemaElement != null ) 235 { 236 SchemaBrowserInput.enableOneInstanceHack( true ); 239 firePropertyChange( IEditorPart.PROP_INPUT ); 240 241 SchemaBrowserInput.enableOneInstanceHack( false ); 243 getSite().getPage().getNavigationHistory().markLocation( this ); 244 } 245 246 SchemaBrowserInput.enableOneInstanceHack( true ); 248 } 249 } 250 251 252 255 public void refresh() 256 { 257 ocdPage.refresh(); 258 atdPage.refresh(); 259 mrdPage.refresh(); 260 mrudPage.refresh(); 261 lsdPage.refresh(); 262 } 263 264 265 270 public void setShowDefaultSchema( boolean b ) 271 { 272 ocdPage.setShowDefaultSchema( b ); 273 atdPage.setShowDefaultSchema( b ); 274 mrdPage.setShowDefaultSchema( b ); 275 mrudPage.setShowDefaultSchema( b ); 276 lsdPage.setShowDefaultSchema( b ); 277 } 278 279 280 285 public void setConnection( IConnection connection ) 286 { 287 ocdPage.setConnection( connection ); 288 atdPage.setConnection( connection ); 289 mrdPage.setConnection( connection ); 290 mrudPage.setConnection( connection ); 291 lsdPage.setConnection( connection ); 292 } 293 294 295 298 public void setFocus() 299 { 300 } 301 302 303 306 public void doSave( IProgressMonitor monitor ) 307 { 308 } 309 310 311 314 public void doSaveAs() 315 { 316 } 317 318 319 322 public boolean isDirty() 323 { 324 return false; 325 } 326 327 328 331 public boolean isSaveAsAllowed() 332 { 333 return false; 334 } 335 336 337 340 public INavigationLocation createEmptyNavigationLocation() 341 { 342 return null; 343 } 344 345 346 349 public INavigationLocation createNavigationLocation() 350 { 351 return new SchemaBrowserNavigationLocation( this ); 352 } 353 354 } 355 | Popular Tags |