KickJava   Java API By Example, From Geeks To Geeks.

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


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.browser.common.BrowserCommonActivator;
25 import org.apache.directory.ldapstudio.browser.common.BrowserCommonConstants;
26 import org.apache.directory.ldapstudio.browser.core.BrowserCoreConstants;
27 import org.eclipse.jface.util.IPropertyChangeListener;
28 import org.eclipse.jface.util.PropertyChangeEvent;
29 import org.eclipse.jface.viewers.TreeViewer;
30 import org.eclipse.jface.viewers.Viewer;
31
32
33 /**
34  * This class is a wrapper for the preferences of the entry editor widget.
35  *
36  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
37  * @version $Rev$, $Date$
38  */

39 public class EntryEditorWidgetPreferences implements IPropertyChangeListener
40 {
41
42     /** The viewer. */
43     protected Viewer viewer;
44
45
46     /**
47      * Creates a new instance of EntryEditorWidgetPreferences.
48      */

49     public EntryEditorWidgetPreferences()
50     {
51         BrowserCommonActivator.getDefault().getPreferenceStore().addPropertyChangeListener( this );
52     }
53
54
55     /**
56      * Connects this preferences with the given viewer.
57      *
58      * @param viewer the viewer
59      */

60     public void connect( TreeViewer viewer )
61     {
62         this.viewer = viewer;
63     }
64
65
66     /**
67      * Disposes this preferences.
68      */

69     public void dispose()
70     {
71         BrowserCommonActivator.getDefault().getPreferenceStore().removePropertyChangeListener( this );
72         viewer = null;
73     }
74
75
76     /**
77      * Checks if folding is enabled.
78      *
79      * @return true, if folding is enabled
80      */

81     public boolean isUseFolding()
82     {
83         return BrowserCommonActivator.getDefault().getPreferenceStore().getBoolean(
84             BrowserCommonConstants.PREFERENCE_ENTRYEDITOR_ENABLE_FOLDING );
85     }
86
87
88     /**
89      * Gets the folding threshold.
90      *
91      * @return the folding threshold
92      */

93     public int getFoldingThreshold()
94     {
95         return BrowserCommonActivator.getDefault().getPreferenceStore().getInt(
96             BrowserCommonConstants.PREFERENCE_ENTRYEDITOR_FOLDING_THRESHOLD );
97     }
98
99
100     /**
101      * Checks if may attributes should be shown.
102      *
103      * @return true, if may attributes should be shown
104      */

105     public boolean isShowMayAttributes()
106     {
107         return BrowserCommonActivator.getDefault().getPreferenceStore().getBoolean(
108             BrowserCommonConstants.PREFERENCE_ENTRYEDITOR_SHOW_MAY_ATTRIBUTES );
109     }
110
111
112     /**
113      * Checks if must attributes should be shown.
114      *
115      * @return true, if must attributes should be shown
116      */

117     public boolean isShowMustAttributes()
118     {
119         return BrowserCommonActivator.getDefault().getPreferenceStore().getBoolean(
120             BrowserCommonConstants.PREFERENCE_ENTRYEDITOR_SHOW_MUST_ATTRIBUTES );
121     }
122
123
124     /**
125      * Checks if object class attribute should be shown.
126      *
127      * @return true, if object class attribute should be shown
128      */

129     public boolean isShowObjectClassAttribute()
130     {
131         return BrowserCommonActivator.getDefault().getPreferenceStore().getBoolean(
132             BrowserCommonConstants.PREFERENCE_ENTRYEDITOR_SHOW_OBJECTCLASS_ATTRIBUTES );
133     }
134
135
136     /**
137      * Checks if operational attributes should be shown.
138      *
139      * @return true, if operational attributes should be shown
140      */

141     public boolean isShowOperationalAttributes()
142     {
143         return BrowserCommonActivator.getDefault().getPreferenceStore().getBoolean(
144             BrowserCommonConstants.PREFERENCE_ENTRYEDITOR_SHOW_OPERATIONAL_ATTRIBUTES );
145     }
146
147
148     /**
149      * Checks if object class and must attributes should be
150      * grouped before may attributes.
151      *
152      * @return true, if object class and must attributes first
153      */

154     public boolean isObjectClassAndMustAttributesFirst()
155     {
156         return BrowserCommonActivator.getDefault().getPreferenceStore().getBoolean(
157             BrowserCommonConstants.PREFERENCE_ENTRYEDITOR_OBJECTCLASS_AND_MUST_ATTRIBUTES_FIRST );
158     }
159
160
161     /**
162      * Checks if operational attributes should be grouped after may attributes.
163      *
164      * @return true, if operational attributes last
165      */

166     public boolean isOperationalAttributesLast()
167     {
168         return BrowserCommonActivator.getDefault().getPreferenceStore().getBoolean(
169             BrowserCommonConstants.PREFERENCE_ENTRYEDITOR_OPERATIONAL_ATTRIBUTES_LAST );
170     }
171
172
173     /**
174      * Gets the default sort property, one of
175      * {@link BrowserCoreConstants#SORT_BY_ATTRIBUTE_DESCRIPTION} or
176      * {@link BrowserCoreConstants#SORT_BY_VALUE}.
177      *
178      * @return the default sort property
179      */

180     public int getDefaultSortBy()
181     {
182         return BrowserCommonActivator.getDefault().getPreferenceStore().getInt(
183             BrowserCommonConstants.PREFERENCE_ENTRYEDITOR_DEFAULT_SORT_BY );
184     }
185
186
187     /**
188      * Gets the default sort property, one of
189      * {@link BrowserCoreConstants#SORT_ORDER_NONE},
190      * {@link BrowserCoreConstants#SORT_ORDER_ASCENDING} or
191      * {@link BrowserCoreConstants#SORT_ORDER_DESCENDING}.
192      *
193      * @return the default sort property
194      */

195     public int getDefaultSortOrder()
196     {
197         return BrowserCommonActivator.getDefault().getPreferenceStore().getInt(
198             BrowserCommonConstants.PREFERENCE_ENTRYEDITOR_DEFAULT_SORT_ORDER );
199     }
200
201
202     /**
203      * {@inheritDoc}
204      */

205     public void propertyChange( PropertyChangeEvent event )
206     {
207         if ( this.viewer != null )
208         {
209             this.viewer.refresh();
210         }
211     }
212
213 }
214
Popular Tags