KickJava   Java API By Example, From Geeks To Geeks.

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


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.valueeditors.ValueEditorManager;
25 import org.eclipse.jface.action.IMenuManager;
26 import org.eclipse.jface.action.MenuManager;
27 import org.eclipse.jface.viewers.TableViewer;
28 import org.eclipse.swt.widgets.Menu;
29 import org.eclipse.ui.IWorkbenchPart;
30
31
32 public class SearchResultEditorConfiguration
33 {
34
35     private boolean disposed = false;
36
37     protected SearchResultEditorCursor cursor;
38
39     protected SearchResultEditorSorter sorter;
40
41     protected SearchResultEditorFilter filter;
42
43     protected SearchResultEditorContentProvider contentProvider;
44
45     protected SearchResultEditorLabelProvider labelProvider;
46
47     protected SearchResultEditorCellModifier cellModifier;
48
49     protected ValueEditorManager valueEditorManager;
50
51     protected MenuManager contextMenuManager;
52
53
54     public SearchResultEditorConfiguration( IWorkbenchPart part )
55     {
56         super();
57     }
58
59
60     public void dispose()
61     {
62         if ( !this.disposed )
63         {
64
65             if ( this.contentProvider != null )
66                 this.contentProvider.dispose();
67             this.contentProvider = null;
68
69             if ( this.labelProvider != null )
70                 this.labelProvider.dispose();
71             this.labelProvider = null;
72
73             if ( this.cellModifier != null )
74                 this.cellModifier.dispose();
75             this.cellModifier = null;
76
77             if ( this.valueEditorManager != null )
78                 this.valueEditorManager.dispose();
79             this.valueEditorManager = null;
80
81             if ( this.contextMenuManager != null )
82                 this.contextMenuManager.dispose();
83             this.contextMenuManager = null;
84
85             if ( this.cursor != null )
86                 this.cursor.dispose();
87             this.cursor = null;
88
89             this.disposed = true;
90         }
91     }
92
93
94     public SearchResultEditorSorter getSorter()
95     {
96         if ( this.sorter == null )
97             this.sorter = new SearchResultEditorSorter();
98
99         return sorter;
100     }
101
102
103     public SearchResultEditorFilter getFilter()
104     {
105         if ( this.filter == null )
106             this.filter = new SearchResultEditorFilter();
107
108         return filter;
109     }
110
111
112     public IMenuManager getContextMenuManager( TableViewer viewer )
113     {
114         if ( this.contextMenuManager == null )
115         {
116             this.contextMenuManager = new MenuManager();
117             Menu menu = this.contextMenuManager.createContextMenu( viewer.getControl() );
118             getCursor( viewer ).setMenu( menu );
119         }
120         return this.contextMenuManager;
121     }
122
123
124     public SearchResultEditorContentProvider getContentProvider( SearchResultEditorWidget mainWidget )
125     {
126         if ( this.contentProvider == null )
127             this.contentProvider = new SearchResultEditorContentProvider( mainWidget, this );
128
129         return contentProvider;
130     }
131
132
133     public SearchResultEditorLabelProvider getLabelProvider( TableViewer viewer )
134     {
135         if ( this.labelProvider == null )
136             this.labelProvider = new SearchResultEditorLabelProvider( viewer, this.getValueEditorManager( viewer ) );
137
138         return labelProvider;
139     }
140
141
142     public SearchResultEditorCellModifier getCellModifier( TableViewer viewer )
143     {
144         if ( this.cellModifier == null )
145             this.cellModifier = new SearchResultEditorCellModifier( viewer, this.getValueEditorManager( viewer ) );
146
147         return cellModifier;
148     }
149
150
151     public SearchResultEditorCursor getCursor( TableViewer viewer )
152     {
153         if ( this.cursor == null )
154             this.cursor = new SearchResultEditorCursor( viewer );
155
156         return cursor;
157     }
158
159
160     public ValueEditorManager getValueEditorManager( TableViewer viewer )
161     {
162         if ( this.valueEditorManager == null )
163             this.valueEditorManager = new ValueEditorManager( viewer.getTable() );
164
165         return valueEditorManager;
166     }
167
168 }
169
Popular Tags