KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > browser > ui > dialogs > properties > SchemaObjectClassesPropertyPage


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  *
19  */

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 JavaDoc[]
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 JavaDoc[] 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 JavaDoc[] ocds = entry.getSubschema().getObjectClassNames();
90                 viewer.setInput( ocds );
91                 column.pack();
92             }
93         }
94
95         return parent;
96     }
97
98 }
99
Popular Tags