1 20 21 package org.apache.directory.ldapstudio.browser.ui.dialogs.properties; 22 23 24 import org.apache.directory.ldapstudio.browser.core.model.IConnection; 25 import org.apache.directory.ldapstudio.browser.core.model.IEntry; 26 27 import org.eclipse.jface.viewers.ArrayContentProvider; 28 import org.eclipse.jface.viewers.LabelProvider; 29 import org.eclipse.jface.viewers.TableViewer; 30 import org.eclipse.jface.viewers.ViewerSorter; 31 import org.eclipse.swt.SWT; 32 import org.eclipse.swt.layout.GridData; 33 import org.eclipse.swt.widgets.Composite; 34 import org.eclipse.swt.widgets.Control; 35 import org.eclipse.swt.widgets.Table; 36 import org.eclipse.swt.widgets.TableColumn; 37 import org.eclipse.ui.IWorkbenchPropertyPage; 38 import org.eclipse.ui.dialogs.PropertyPage; 39 40 41 public class SchemaObjectClassesPropertyPage extends PropertyPage implements IWorkbenchPropertyPage 42 { 43 44 public SchemaObjectClassesPropertyPage() 45 { 46 super(); 47 super.noDefaultAndApplyButton(); 48 } 49 50 51 protected Control createContents( Composite parent ) 52 { 53 54 Table table = new Table( parent, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION 55 | SWT.HIDE_SELECTION ); 56 GridData gridData = new GridData( GridData.FILL_BOTH ); 57 gridData.grabExcessVerticalSpace = true; 58 gridData.horizontalSpan = 3; 59 table.setLayoutData( gridData ); 60 table.setHeaderVisible( true ); 61 table.setLinesVisible( true ); 62 TableViewer viewer = new TableViewer( table ); 63 TableColumn column = new TableColumn( table, SWT.LEFT, 0 ); 64 column.setText( "Object Class Definition" ); 65 column.setWidth( 200 ); 66 column.setResizable( true ); 67 viewer.setColumnProperties( new String [] 68 { "Object Class Definition" } ); 69 70 viewer.setSorter( new ViewerSorter() ); 71 viewer.setContentProvider( new ArrayContentProvider() ); 72 viewer.setLabelProvider( new LabelProvider() ); 73 74 if ( getElement() instanceof IConnection ) 75 { 76 IConnection connection = ( IConnection ) getElement(); 77 if ( connection != null ) 78 { 79 Object [] ocds = connection.getSchema().getObjectClassDescriptions(); 80 viewer.setInput( ocds ); 81 column.pack(); 82 } 83 } 84 else if ( getElement() instanceof IEntry ) 85 { 86 IEntry entry = ( IEntry ) getElement(); 87 if ( entry != null ) 88 { 89 Object [] ocds = entry.getSubschema().getObjectClassNames(); 90 viewer.setInput( ocds ); 91 column.pack(); 92 } 93 } 94 95 return parent; 96 } 97 98 } 99 | Popular Tags |