KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > browser > ui > editors > searchresult > SearchResultEditorWidget


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.editors.searchresult;
22
23
24 import org.apache.directory.ldapstudio.browser.common.widgets.ViewFormWidget;
25 import org.eclipse.jface.viewers.TableViewer;
26 import org.eclipse.swt.SWT;
27 import org.eclipse.swt.layout.GridData;
28 import org.eclipse.swt.widgets.Composite;
29 import org.eclipse.swt.widgets.Control;
30 import org.eclipse.swt.widgets.Table;
31
32
33 public class SearchResultEditorWidget extends ViewFormWidget
34 {
35
36     private SearchResultEditorConfiguration configuration;
37
38     private SearchResultEditorQuickFilterWidget quickFilterWidget;
39
40     private Table table;
41
42     private TableViewer viewer;
43
44
45     public SearchResultEditorWidget( SearchResultEditorConfiguration configuration )
46     {
47         this.configuration = configuration;
48     }
49
50
51     protected Control createContent( Composite parent )
52     {
53
54         // create quick filter
55
this.quickFilterWidget = new SearchResultEditorQuickFilterWidget( this.configuration.getFilter() );
56         this.quickFilterWidget.createComposite( parent );
57
58         // create table widget and viewer
59
this.table = new Table( parent, SWT.BORDER | SWT.HIDE_SELECTION | SWT.VIRTUAL );
60         this.table.setHeaderVisible( true );
61         this.table.setLinesVisible( true );
62         this.table.setLayoutData( new GridData( GridData.FILL_BOTH ) );
63         this.viewer = new TableViewer( this.table );
64         this.viewer.setUseHashlookup( true );
65
66         // setup providers
67
this.viewer.setContentProvider( configuration.getContentProvider( this ) );
68         this.viewer.setLabelProvider( configuration.getLabelProvider( this.viewer ) );
69
70         // set table cell editors
71
this.viewer.setCellModifier( configuration.getCellModifier( this.viewer ) );
72
73         return this.table;
74     }
75
76
77     public void setInput( Object JavaDoc input )
78     {
79         this.viewer.setInput( input );
80     }
81
82
83     public void setFocus()
84     {
85         this.configuration.getCursor( this.viewer ).setFocus();
86     }
87
88
89     public void dispose()
90     {
91         if ( this.viewer != null )
92         {
93             this.configuration.dispose();
94
95             if ( this.quickFilterWidget != null )
96             {
97                 this.quickFilterWidget.dispose();
98                 this.quickFilterWidget = null;
99             }
100
101             // this.table.dispose();
102
this.table = null;
103             this.viewer = null;
104         }
105
106         super.dispose();
107     }
108
109
110     public TableViewer getViewer()
111     {
112         return viewer;
113     }
114
115
116     public SearchResultEditorQuickFilterWidget getQuickFilterWidget()
117     {
118         return quickFilterWidget;
119     }
120
121 }
122
Popular Tags