Source Code Cross Referenced for JavaBasePreferencePage.java in  » IDE-Eclipse » jdt » org » eclipse » jdt » internal » ui » preferences » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Eclipse » jdt » org.eclipse.jdt.internal.ui.preferences 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2007 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.jdt.internal.ui.preferences;
011:
012:        import java.util.ArrayList;
013:
014:        import org.eclipse.swt.SWT;
015:        import org.eclipse.swt.events.SelectionEvent;
016:        import org.eclipse.swt.events.SelectionListener;
017:        import org.eclipse.swt.layout.GridData;
018:        import org.eclipse.swt.layout.GridLayout;
019:        import org.eclipse.swt.widgets.Button;
020:        import org.eclipse.swt.widgets.Composite;
021:        import org.eclipse.swt.widgets.Control;
022:        import org.eclipse.swt.widgets.Group;
023:        import org.eclipse.swt.widgets.Label;
024:        import org.eclipse.swt.widgets.Text;
025:
026:        import org.eclipse.jface.dialogs.Dialog;
027:        import org.eclipse.jface.dialogs.IDialogConstants;
028:        import org.eclipse.jface.dialogs.MessageDialog;
029:        import org.eclipse.jface.preference.IPreferenceStore;
030:        import org.eclipse.jface.preference.PreferencePage;
031:
032:        import org.eclipse.ui.IWorkbench;
033:        import org.eclipse.ui.IWorkbenchPreferencePage;
034:        import org.eclipse.ui.PlatformUI;
035:
036:        import org.eclipse.jdt.ui.PreferenceConstants;
037:
038:        import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
039:        import org.eclipse.jdt.internal.ui.JavaPlugin;
040:        import org.eclipse.jdt.internal.ui.dialogs.OptionalMessageDialog;
041:        import org.eclipse.jdt.internal.ui.refactoring.RefactoringSavePreferences;
042:        import org.eclipse.jdt.internal.ui.util.SWTUtil;
043:
044:        /*
045:         * The page for setting general java plugin preferences.
046:         * See PreferenceConstants to access or change these values through public API.
047:         */
048:        public class JavaBasePreferencePage extends PreferencePage implements 
049:                IWorkbenchPreferencePage {
050:
051:            public static final String JAVA_BASE_PREF_PAGE_ID = "org.eclipse.jdt.ui.preferences.JavaBasePreferencePage"; //$NON-NLS-1$
052:
053:            private static final String OPEN_TYPE_HIERARCHY = PreferenceConstants.OPEN_TYPE_HIERARCHY;
054:            private static final String OPEN_TYPE_HIERARCHY_IN_PERSPECTIVE = PreferenceConstants.OPEN_TYPE_HIERARCHY_IN_PERSPECTIVE;
055:            private static final String OPEN_TYPE_HIERARCHY_IN_VIEW_PART = PreferenceConstants.OPEN_TYPE_HIERARCHY_IN_VIEW_PART;
056:
057:            private static final String DOUBLE_CLICK = PreferenceConstants.DOUBLE_CLICK;
058:            private static final String DOUBLE_CLICK_GOES_INTO = PreferenceConstants.DOUBLE_CLICK_GOES_INTO;
059:            private static final String DOUBLE_CLICK_EXPANDS = PreferenceConstants.DOUBLE_CLICK_EXPANDS;
060:
061:            private ArrayList fCheckBoxes;
062:            private ArrayList fRadioButtons;
063:            private ArrayList fTextControls;
064:
065:            public JavaBasePreferencePage() {
066:                super ();
067:                setPreferenceStore(JavaPlugin.getDefault().getPreferenceStore());
068:                setDescription(PreferencesMessages.JavaBasePreferencePage_description);
069:
070:                fRadioButtons = new ArrayList();
071:                fCheckBoxes = new ArrayList();
072:                fTextControls = new ArrayList();
073:            }
074:
075:            /*
076:             * @see IWorkbenchPreferencePage#init(IWorkbench)
077:             */
078:            public void init(IWorkbench workbench) {
079:            }
080:
081:            /*
082:             * @see PreferencePage#createControl(Composite)
083:             */
084:            public void createControl(Composite parent) {
085:                super .createControl(parent);
086:                PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
087:                        IJavaHelpContextIds.JAVA_BASE_PREFERENCE_PAGE);
088:            }
089:
090:            private Button addRadioButton(Composite parent, String label,
091:                    String key, String value) {
092:                GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
093:
094:                Button button = new Button(parent, SWT.RADIO);
095:                button.setText(label);
096:                button.setData(new String[] { key, value });
097:                button.setLayoutData(gd);
098:
099:                button.setSelection(value.equals(getPreferenceStore()
100:                        .getString(key)));
101:
102:                fRadioButtons.add(button);
103:                return button;
104:            }
105:
106:            private Button addCheckBox(Composite parent, String label,
107:                    String key) {
108:                GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
109:
110:                Button button = new Button(parent, SWT.CHECK);
111:                button.setText(label);
112:                button.setData(key);
113:                button.setLayoutData(gd);
114:
115:                button.setSelection(getPreferenceStore().getBoolean(key));
116:
117:                fCheckBoxes.add(button);
118:                return button;
119:            }
120:
121:            protected Control createContents(Composite parent) {
122:                initializeDialogUnits(parent);
123:
124:                Composite result = new Composite(parent, SWT.NONE);
125:                GridLayout layout = new GridLayout();
126:                layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
127:                layout.marginWidth = 0;
128:                layout.verticalSpacing = convertVerticalDLUsToPixels(10);
129:                layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
130:                result.setLayout(layout);
131:
132:                // new Label(composite, SWT.NONE); // spacer
133:                // Group linkSettings= new Group(result, SWT.NONE);
134:                // linkSettings.setLayout(new GridLayout());
135:                // linkSettings.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
136:                // linkSettings.setText(PreferencesMessages.getString("JavaBasePreferencePage.linkSettings.text")); //$NON-NLS-1$
137:                //addCheckBox(linkSettings, PreferencesMessages.getString("JavaBasePreferencePage.linkJavaBrowsingViewsCheckbox.text"), LINK_BROWSING_VIEW_TO_EDITOR); //$NON-NLS-1$
138:                //addCheckBox(linkSettings, PreferencesMessages.getString("JavaBasePreferencePage.linkPackageView"), LINK_PACKAGES_TO_EDITOR); //$NON-NLS-1$
139:                //addCheckBox(linkSettings, PreferencesMessages.getString("JavaBasePreferencePage.linkTypeHierarchy"), LINK_TYPEHIERARCHY_TO_EDITOR); //$NON-NLS-1$
140:
141:                // new Label(result, SWT.NONE); // spacer
142:
143:                Group doubleClickGroup = new Group(result, SWT.NONE);
144:                doubleClickGroup.setLayout(new GridLayout());
145:                doubleClickGroup.setLayoutData(new GridData(
146:                        GridData.FILL_HORIZONTAL));
147:                doubleClickGroup
148:                        .setText(PreferencesMessages.JavaBasePreferencePage_doubleclick_action);
149:                addRadioButton(
150:                        doubleClickGroup,
151:                        PreferencesMessages.JavaBasePreferencePage_doubleclick_gointo,
152:                        DOUBLE_CLICK, DOUBLE_CLICK_GOES_INTO);
153:                addRadioButton(
154:                        doubleClickGroup,
155:                        PreferencesMessages.JavaBasePreferencePage_doubleclick_expand,
156:                        DOUBLE_CLICK, DOUBLE_CLICK_EXPANDS);
157:
158:                // new Label(result, SWT.NONE); // spacer
159:
160:                Group typeHierarchyGroup = new Group(result, SWT.NONE);
161:                typeHierarchyGroup.setLayout(new GridLayout());
162:                typeHierarchyGroup.setLayoutData(new GridData(
163:                        GridData.FILL_HORIZONTAL));
164:                typeHierarchyGroup
165:                        .setText(PreferencesMessages.JavaBasePreferencePage_openTypeHierarchy);
166:                addRadioButton(
167:                        typeHierarchyGroup,
168:                        PreferencesMessages.JavaBasePreferencePage_inPerspective,
169:                        OPEN_TYPE_HIERARCHY, OPEN_TYPE_HIERARCHY_IN_PERSPECTIVE);
170:                addRadioButton(typeHierarchyGroup,
171:                        PreferencesMessages.JavaBasePreferencePage_inView,
172:                        OPEN_TYPE_HIERARCHY, OPEN_TYPE_HIERARCHY_IN_VIEW_PART);
173:
174:                Group refactoringGroup = new Group(result, SWT.NONE);
175:                refactoringGroup.setLayout(new GridLayout());
176:                refactoringGroup.setLayoutData(new GridData(
177:                        GridData.FILL_HORIZONTAL));
178:                refactoringGroup
179:                        .setText(PreferencesMessages.JavaBasePreferencePage_refactoring_title);
180:                addCheckBox(
181:                        refactoringGroup,
182:                        PreferencesMessages.JavaBasePreferencePage_refactoring_auto_save,
183:                        RefactoringSavePreferences.PREF_SAVE_ALL_EDITORS);
184:                addCheckBox(
185:                        refactoringGroup,
186:                        PreferencesMessages.JavaBasePreferencePage_refactoring_lightweight,
187:                        PreferenceConstants.REFACTOR_LIGHTWEIGHT);
188:
189:                Group group = new Group(result, SWT.NONE);
190:                group.setLayout(new GridLayout());
191:                group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
192:                group
193:                        .setText(PreferencesMessages.JavaBasePreferencePage_search);
194:
195:                addCheckBox(
196:                        group,
197:                        PreferencesMessages.JavaBasePreferencePage_search_small_menu,
198:                        PreferenceConstants.SEARCH_USE_REDUCED_MENU);
199:
200:                layout = new GridLayout();
201:                layout.numColumns = 2;
202:
203:                Group dontAskGroup = new Group(result, SWT.NONE);
204:                dontAskGroup.setLayout(layout);
205:                dontAskGroup.setLayoutData(new GridData(
206:                        GridData.FILL_HORIZONTAL));
207:                dontAskGroup
208:                        .setText(PreferencesMessages.JavaBasePreferencePage_dialogs);
209:
210:                Label label = new Label(dontAskGroup, SWT.WRAP);
211:                label
212:                        .setText(PreferencesMessages.JavaBasePreferencePage_do_not_hide_description);
213:                GridData data = new GridData(GridData.FILL, GridData.CENTER,
214:                        true, false);
215:                data.widthHint = convertVerticalDLUsToPixels(50);
216:                label.setLayoutData(data);
217:
218:                Button clearButton = new Button(dontAskGroup, SWT.PUSH);
219:                clearButton
220:                        .setText(PreferencesMessages.JavaBasePreferencePage_do_not_hide_button);
221:                clearButton.setLayoutData(new GridData(GridData.FILL,
222:                        GridData.BEGINNING, false, false));
223:                clearButton.addSelectionListener(new SelectionListener() {
224:                    public void widgetSelected(SelectionEvent e) {
225:                        unhideAllDialogs();
226:                    }
227:
228:                    public void widgetDefaultSelected(SelectionEvent e) {
229:                        unhideAllDialogs();
230:                    }
231:                });
232:
233:                SWTUtil.setButtonDimensionHint(clearButton);
234:                Dialog.applyDialogFont(result);
235:                return result;
236:            }
237:
238:            protected final void unhideAllDialogs() {
239:                OptionalMessageDialog.clearAllRememberedStates();
240:                MessageDialog
241:                        .openInformation(
242:                                getShell(),
243:                                PreferencesMessages.JavaBasePreferencePage_do_not_hide_dialog_title,
244:                                PreferencesMessages.JavaBasePreferencePage_do_not_hide_dialog_message);
245:            }
246:
247:            /*
248:             * @see PreferencePage#performDefaults()
249:             */
250:            protected void performDefaults() {
251:                IPreferenceStore store = getPreferenceStore();
252:                for (int i = 0; i < fCheckBoxes.size(); i++) {
253:                    Button button = (Button) fCheckBoxes.get(i);
254:                    String key = (String) button.getData();
255:                    button.setSelection(store.getDefaultBoolean(key));
256:                }
257:                for (int i = 0; i < fRadioButtons.size(); i++) {
258:                    Button button = (Button) fRadioButtons.get(i);
259:                    String[] info = (String[]) button.getData();
260:                    button.setSelection(info[1].equals(store
261:                            .getDefaultString(info[0])));
262:                }
263:                for (int i = 0; i < fTextControls.size(); i++) {
264:                    Text text = (Text) fTextControls.get(i);
265:                    String key = (String) text.getData();
266:                    text.setText(store.getDefaultString(key));
267:                }
268:                super .performDefaults();
269:            }
270:
271:            /*
272:             * @see IPreferencePage#performOk()
273:             */
274:            public boolean performOk() {
275:                IPreferenceStore store = getPreferenceStore();
276:                for (int i = 0; i < fCheckBoxes.size(); i++) {
277:                    Button button = (Button) fCheckBoxes.get(i);
278:                    String key = (String) button.getData();
279:                    store.setValue(key, button.getSelection());
280:                }
281:                for (int i = 0; i < fRadioButtons.size(); i++) {
282:                    Button button = (Button) fRadioButtons.get(i);
283:                    if (button.getSelection()) {
284:                        String[] info = (String[]) button.getData();
285:                        store.setValue(info[0], info[1]);
286:                    }
287:                }
288:                for (int i = 0; i < fTextControls.size(); i++) {
289:                    Text text = (Text) fTextControls.get(i);
290:                    String key = (String) text.getData();
291:                    store.setValue(key, text.getText());
292:                }
293:
294:                JavaPlugin.getDefault().savePluginPreferences();
295:                return super.performOk();
296:            }
297:
298:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.