KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > browser > ui > dialogs > preferences > SearchResultEditorPreferencePage


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.preferences;
22
23
24 import org.apache.directory.ldapstudio.browser.common.widgets.BaseWidgetUtils;
25 import org.apache.directory.ldapstudio.browser.common.widgets.WidgetModifyEvent;
26 import org.apache.directory.ldapstudio.browser.common.widgets.WidgetModifyListener;
27 import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
28 import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
29 import org.eclipse.jface.preference.PreferencePage;
30 import org.eclipse.swt.widgets.Button;
31 import org.eclipse.swt.widgets.Composite;
32 import org.eclipse.swt.widgets.Control;
33 import org.eclipse.ui.IWorkbench;
34 import org.eclipse.ui.IWorkbenchPreferencePage;
35
36
37 public class SearchResultEditorPreferencePage extends PreferencePage implements IWorkbenchPreferencePage,
38     WidgetModifyListener
39 {
40
41     private Button showDnButton;
42
43     private Button showLinksButton;
44
45
46     public SearchResultEditorPreferencePage()
47     {
48         super();
49         super.setPreferenceStore( BrowserUIPlugin.getDefault().getPreferenceStore() );
50         super.setDescription( "General settings for the LDAP search result editor:" );
51     }
52
53
54     public void init( IWorkbench workbench )
55     {
56     }
57
58
59     protected Control createContents( Composite parent )
60     {
61
62         Composite composite = BaseWidgetUtils.createColumnContainer( parent, 1, 1 );
63
64         BaseWidgetUtils.createSpacer( composite, 1 );
65         BaseWidgetUtils.createSpacer( composite, 1 );
66         showDnButton = BaseWidgetUtils.createCheckbox( composite, "Show DN as first column", 1 );
67         showDnButton.setSelection( getPreferenceStore().getBoolean(
68             BrowserUIConstants.PREFERENCE_SEARCHRESULTEDITOR_SHOW_DN ) );
69         showLinksButton = BaseWidgetUtils.createCheckbox( composite, "Show DN a link", 1 );
70         showLinksButton.setSelection( getPreferenceStore().getBoolean(
71             BrowserUIConstants.PREFERENCE_SEARCHRESULTEDITOR_SHOW_LINKS ) );
72
73         updateEnabled();
74         validate();
75
76         applyDialogFont( composite );
77         return composite;
78     }
79
80
81     private void updateEnabled()
82     {
83
84     }
85
86
87     public boolean performOk()
88     {
89
90         getPreferenceStore().setValue( BrowserUIConstants.PREFERENCE_SEARCHRESULTEDITOR_SHOW_DN,
91             this.showDnButton.getSelection() );
92         getPreferenceStore().setValue( BrowserUIConstants.PREFERENCE_SEARCHRESULTEDITOR_SHOW_LINKS,
93             this.showLinksButton.getSelection() );
94
95         updateEnabled();
96         validate();
97
98         return true;
99     }
100
101
102     protected void performDefaults()
103     {
104
105         this.showDnButton.setSelection( getPreferenceStore().getDefaultBoolean(
106             BrowserUIConstants.PREFERENCE_SEARCHRESULTEDITOR_SHOW_DN ) );
107         this.showLinksButton.setSelection( getPreferenceStore().getDefaultBoolean(
108             BrowserUIConstants.PREFERENCE_SEARCHRESULTEDITOR_SHOW_LINKS ) );
109
110         updateEnabled();
111         validate();
112
113         super.performDefaults();
114     }
115
116
117     public void widgetModified( WidgetModifyEvent event )
118     {
119         updateEnabled();
120         validate();
121     }
122
123
124     protected void validate()
125     {
126
127     }
128
129 }
130
Popular Tags