KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > browser > common > widgets > entryeditor > EntryEditorWidgetConfiguration


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.common.widgets.entryeditor;
22
23
24 import org.apache.directory.ldapstudio.valueeditors.ValueEditorManager;
25 import org.eclipse.jface.viewers.TreeViewer;
26
27
28 /**
29  * The BrowserConfiguration contains the content provider,
30  * label provider, sorter, filter the context menu manager and the
31  * preferences for the entry editor widget.
32  *
33  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
34  * @version $Rev$, $Date$
35  */

36 public class EntryEditorWidgetConfiguration
37 {
38
39     /** The disposed flag */
40     private boolean disposed = false;
41
42     /** The sorter. */
43     protected EntryEditorWidgetSorter sorter;
44
45     /** The filter. */
46     protected EntryEditorWidgetFilter filter;
47
48     /** The preferences. */
49     protected EntryEditorWidgetPreferences preferences;
50
51     /** The content provider. */
52     protected EntryEditorWidgetContentProvider contentProvider;
53
54     /** The label provider. */
55     protected EntryEditorWidgetLabelProvider labelProvider;
56
57     /** The cell modifier. */
58     protected EntryEditorWidgetCellModifier cellModifier;
59
60     /** The value editor manager. */
61     protected ValueEditorManager valueEditorManager;
62
63
64     /**
65      * Creates a new instance of EntryEditorWidgetConfiguration.
66      */

67     public EntryEditorWidgetConfiguration()
68     {
69     }
70
71
72     /**
73      * Disposes this configuration.
74      */

75     public void dispose()
76     {
77         if ( !disposed )
78         {
79             if ( sorter != null )
80             {
81                 sorter.dispose();
82                 sorter = null;
83             }
84
85             if ( filter != null )
86             {
87                 filter.dispose();
88                 filter = null;
89             }
90
91             if ( preferences != null )
92             {
93                 preferences.dispose();
94                 preferences = null;
95             }
96
97             if ( contentProvider != null )
98             {
99                 contentProvider.dispose();
100                 contentProvider = null;
101             }
102
103             if ( labelProvider != null )
104             {
105                 labelProvider.dispose();
106                 labelProvider = null;
107             }
108
109             if ( cellModifier != null )
110             {
111                 cellModifier.dispose();
112                 cellModifier = null;
113             }
114
115             if ( valueEditorManager != null )
116             {
117                 valueEditorManager.dispose();
118                 valueEditorManager = null;
119             }
120
121             disposed = true;
122         }
123     }
124
125
126     /**
127      * Gets the content provider.
128      *
129      * @param mainWidget the main widget
130      *
131      * @return the content provider
132      */

133     public EntryEditorWidgetContentProvider getContentProvider( EntryEditorWidget mainWidget )
134     {
135         if ( contentProvider == null )
136         {
137             contentProvider = new EntryEditorWidgetContentProvider( getPreferences(), mainWidget );
138         }
139
140         return contentProvider;
141     }
142
143
144     /**
145      * Gets the label provider.
146      *
147      * @param viewer the viewer
148      *
149      * @return the label provider
150      */

151     public EntryEditorWidgetLabelProvider getLabelProvider( TreeViewer viewer )
152     {
153         if ( labelProvider == null )
154         {
155             labelProvider = new EntryEditorWidgetLabelProvider( getValueEditorManager( viewer ) );
156         }
157
158         return labelProvider;
159     }
160
161
162     /**
163      * Gets the cell modifier.
164      *
165      * @param viewer the viewer
166      *
167      * @return the cell modifier
168      */

169     public EntryEditorWidgetCellModifier getCellModifier( TreeViewer viewer )
170     {
171         if ( cellModifier == null )
172         {
173             cellModifier = new EntryEditorWidgetCellModifier( getValueEditorManager( viewer ) );
174         }
175
176         return cellModifier;
177     }
178
179
180     /**
181      * Gets the value editor manager.
182      *
183      * @param viewer the viewer
184      *
185      * @return the value editor manager
186      */

187     public ValueEditorManager getValueEditorManager( TreeViewer viewer )
188     {
189         if ( valueEditorManager == null )
190         {
191             valueEditorManager = new ValueEditorManager( viewer.getTree() );
192         }
193
194         return valueEditorManager;
195     }
196
197
198     /**
199      * Gets the sorter.
200      *
201      * @return the sorter
202      */

203     public EntryEditorWidgetSorter getSorter()
204     {
205         if ( sorter == null )
206         {
207             sorter = new EntryEditorWidgetSorter( getPreferences() );
208         }
209
210         return sorter;
211     }
212
213
214     /**
215      * Gets the filter.
216      *
217      * @return the filter
218      */

219     public EntryEditorWidgetFilter getFilter()
220     {
221         if ( filter == null )
222         {
223             filter = new EntryEditorWidgetFilter();
224         }
225
226         return filter;
227     }
228
229
230     /**
231      * Gets the preferences.
232      *
233      * @return the preferences
234      */

235     public EntryEditorWidgetPreferences getPreferences()
236     {
237         if ( preferences == null )
238         {
239             preferences = new EntryEditorWidgetPreferences();
240         }
241
242         return preferences;
243     }
244
245 }
246
Popular Tags