Source Code Cross Referenced for WorkbenchPreferencePage.java in  » IDE-Eclipse » ui-workbench » org » eclipse » ui » internal » dialogs » 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 » ui workbench » org.eclipse.ui.internal.dialogs 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2005 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.ui.internal.dialogs;
011:
012:        import org.eclipse.jface.dialogs.IDialogConstants;
013:        import org.eclipse.jface.preference.IPreferenceStore;
014:        import org.eclipse.jface.preference.PreferencePage;
015:        import org.eclipse.jface.util.OpenStrategy;
016:        import org.eclipse.swt.SWT;
017:        import org.eclipse.swt.events.SelectionAdapter;
018:        import org.eclipse.swt.events.SelectionEvent;
019:        import org.eclipse.swt.graphics.Font;
020:        import org.eclipse.swt.layout.GridData;
021:        import org.eclipse.swt.layout.GridLayout;
022:        import org.eclipse.swt.widgets.Button;
023:        import org.eclipse.swt.widgets.Combo;
024:        import org.eclipse.swt.widgets.Composite;
025:        import org.eclipse.swt.widgets.Control;
026:        import org.eclipse.swt.widgets.Group;
027:        import org.eclipse.swt.widgets.Label;
028:        import org.eclipse.ui.IWorkbench;
029:        import org.eclipse.ui.IWorkbenchPreferenceConstants;
030:        import org.eclipse.ui.IWorkbenchPreferencePage;
031:        import org.eclipse.ui.IWorkbenchWindow;
032:        import org.eclipse.ui.PlatformUI;
033:        import org.eclipse.ui.internal.IPreferenceConstants;
034:        import org.eclipse.ui.internal.IWorkbenchHelpContextIds;
035:        import org.eclipse.ui.internal.WorkbenchMessages;
036:        import org.eclipse.ui.internal.WorkbenchPlugin;
037:        import org.eclipse.ui.internal.WorkbenchWindow;
038:        import org.eclipse.ui.internal.util.PrefUtil;
039:
040:        /**
041:         * Generic workbench main preference page.
042:         */
043:        public class WorkbenchPreferencePage extends PreferencePage implements 
044:                IWorkbenchPreferencePage {
045:            private Button stickyCycleButton;
046:
047:            private Button doubleClickButton;
048:
049:            private Button singleClickButton;
050:
051:            private Button selectOnHoverButton;
052:
053:            private Button openAfterDelayButton;
054:
055:            private Button showUserDialogButton;
056:
057:            private boolean openOnSingleClick;
058:
059:            private boolean selectOnHover;
060:
061:            private boolean openAfterDelay;
062:
063:            private Button showHeapStatusButton;
064:
065:            /*
066:             * (non-Javadoc)
067:             * 
068:             * @see org.eclipse.jface.preference.PreferencePage
069:             */
070:            protected Control createContents(Composite parent) {
071:
072:                // @issue if the product subclasses this page, then it should provide
073:                // the help content
074:                PlatformUI.getWorkbench().getHelpSystem().setHelp(parent,
075:                        IWorkbenchHelpContextIds.WORKBENCH_PREFERENCE_PAGE);
076:
077:                Composite composite = createComposite(parent);
078:
079:                createButtons(composite);
080:
081:                createSpace(composite);
082:                createOpenModeGroup(composite);
083:
084:                applyDialogFont(composite);
085:
086:                return composite;
087:            }
088:
089:            /**
090:             * Create the buttons at the top of the preference page.
091:             * @param composite
092:             */
093:            protected void createButtons(Composite composite) {
094:                createShowUserDialogPref(composite);
095:                createStickyCyclePref(composite);
096:                createHeapStatusPref(composite);
097:            }
098:
099:            /**
100:             * Create the widget for the user dialog preference.
101:             * 
102:             * @param composite
103:             */
104:            protected void createShowUserDialogPref(Composite composite) {
105:                showUserDialogButton = new Button(composite, SWT.CHECK);
106:                showUserDialogButton
107:                        .setText(WorkbenchMessages.WorkbenchPreference_RunInBackgroundButton);
108:                showUserDialogButton
109:                        .setToolTipText(WorkbenchMessages.WorkbenchPreference_RunInBackgroundToolTip);
110:                showUserDialogButton.setSelection(WorkbenchPlugin.getDefault()
111:                        .getPreferenceStore().getBoolean(
112:                                IPreferenceConstants.RUN_IN_BACKGROUND));
113:            }
114:
115:            /**
116:             * Create the widget for the heap status preference.
117:             * 
118:             * @param composite
119:             */
120:            protected void createHeapStatusPref(Composite composite) {
121:                showHeapStatusButton = new Button(composite, SWT.CHECK);
122:                showHeapStatusButton
123:                        .setText(WorkbenchMessages.WorkbenchPreference_HeapStatusButton);
124:                showHeapStatusButton
125:                        .setToolTipText(WorkbenchMessages.WorkbenchPreference_HeapStatusButtonToolTip);
126:
127:                showHeapStatusButton
128:                        .setSelection(PrefUtil
129:                                .getAPIPreferenceStore()
130:                                .getBoolean(
131:                                        IWorkbenchPreferenceConstants.SHOW_MEMORY_MONITOR));
132:            }
133:
134:            /**
135:             * Creates the composite which will contain all the preference controls for
136:             * this page.
137:             * 
138:             * @param parent
139:             *            the parent composite
140:             * @return the composite for this page
141:             */
142:            protected Composite createComposite(Composite parent) {
143:                Composite composite = new Composite(parent, SWT.NONE);
144:                GridLayout layout = new GridLayout();
145:                layout.marginWidth = 0;
146:                layout.marginHeight = 0;
147:                composite.setLayout(layout);
148:                composite.setLayoutData(new GridData(
149:                        GridData.VERTICAL_ALIGN_FILL
150:                                | GridData.HORIZONTAL_ALIGN_FILL));
151:                return composite;
152:            }
153:
154:            protected void createStickyCyclePref(Composite composite) {
155:                stickyCycleButton = new Button(composite, SWT.CHECK);
156:                stickyCycleButton
157:                        .setText(WorkbenchMessages.WorkbenchPreference_stickyCycleButton);
158:                stickyCycleButton.setSelection(getPreferenceStore().getBoolean(
159:                        IPreferenceConstants.STICKY_CYCLE));
160:            }
161:
162:            protected void createOpenModeGroup(Composite composite) {
163:
164:                Font font = composite.getFont();
165:
166:                Group buttonComposite = new Group(composite, SWT.LEFT);
167:                GridLayout layout = new GridLayout();
168:                buttonComposite.setLayout(layout);
169:                GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL
170:                        | GridData.GRAB_HORIZONTAL);
171:                buttonComposite.setLayoutData(data);
172:                buttonComposite
173:                        .setText(WorkbenchMessages.WorkbenchPreference_openMode);
174:
175:                String label = WorkbenchMessages.WorkbenchPreference_doubleClick;
176:                doubleClickButton = createRadioButton(buttonComposite, label);
177:                doubleClickButton.addSelectionListener(new SelectionAdapter() {
178:
179:                    public void widgetSelected(SelectionEvent e) {
180:                        selectClickMode(singleClickButton.getSelection());
181:                    }
182:                });
183:                doubleClickButton.setSelection(!openOnSingleClick);
184:
185:                label = WorkbenchMessages.WorkbenchPreference_singleClick;
186:                singleClickButton = createRadioButton(buttonComposite, label);
187:                singleClickButton.addSelectionListener(new SelectionAdapter() {
188:
189:                    public void widgetSelected(SelectionEvent e) {
190:                        selectClickMode(singleClickButton.getSelection());
191:                    }
192:                });
193:                singleClickButton.setSelection(openOnSingleClick);
194:
195:                label = WorkbenchMessages.WorkbenchPreference_singleClick_SelectOnHover;
196:                selectOnHoverButton = new Button(buttonComposite, SWT.CHECK
197:                        | SWT.LEFT);
198:                selectOnHoverButton.setText(label);
199:                selectOnHoverButton.setEnabled(openOnSingleClick);
200:                selectOnHoverButton.setSelection(selectOnHover);
201:                selectOnHoverButton
202:                        .addSelectionListener(new SelectionAdapter() {
203:
204:                            public void widgetSelected(SelectionEvent e) {
205:                                selectOnHover = selectOnHoverButton
206:                                        .getSelection();
207:                            }
208:                        });
209:                data = new GridData();
210:                data.horizontalIndent = 20;
211:                selectOnHoverButton.setLayoutData(data);
212:
213:                label = WorkbenchMessages.WorkbenchPreference_singleClick_OpenAfterDelay;
214:                openAfterDelayButton = new Button(buttonComposite, SWT.CHECK
215:                        | SWT.LEFT);
216:                openAfterDelayButton.setText(label);
217:                openAfterDelayButton.setEnabled(openOnSingleClick);
218:                openAfterDelayButton.setSelection(openAfterDelay);
219:                openAfterDelayButton
220:                        .addSelectionListener(new SelectionAdapter() {
221:
222:                            public void widgetSelected(SelectionEvent e) {
223:                                openAfterDelay = openAfterDelayButton
224:                                        .getSelection();
225:                            }
226:                        });
227:                data = new GridData();
228:                data.horizontalIndent = 20;
229:                openAfterDelayButton.setLayoutData(data);
230:
231:                createNoteComposite(
232:                        font,
233:                        buttonComposite,
234:                        WorkbenchMessages.Preference_note,
235:                        WorkbenchMessages.WorkbenchPreference_noEffectOnAllViews);
236:            }
237:
238:            private void selectClickMode(boolean singleClick) {
239:                openOnSingleClick = singleClick;
240:                selectOnHoverButton.setEnabled(openOnSingleClick);
241:                openAfterDelayButton.setEnabled(openOnSingleClick);
242:            }
243:
244:            /**
245:             * Utility method that creates a radio button instance and sets the default
246:             * layout data.
247:             * 
248:             * @param parent
249:             *            the parent for the new button
250:             * @param label
251:             *            the label for the new button
252:             * @return the newly-created button
253:             */
254:            protected static Button createRadioButton(Composite parent,
255:                    String label) {
256:                Button button = new Button(parent, SWT.RADIO | SWT.LEFT);
257:                button.setText(label);
258:                return button;
259:            }
260:
261:            /**
262:             * Utility method that creates a combo box
263:             * 
264:             * @param parent
265:             *            the parent for the new label
266:             * @return the new widget
267:             */
268:            protected static Combo createCombo(Composite parent) {
269:                Combo combo = new Combo(parent, SWT.READ_ONLY);
270:                GridData data = new GridData(GridData.FILL_HORIZONTAL);
271:                data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
272:                combo.setLayoutData(data);
273:                return combo;
274:            }
275:
276:            /**
277:             * Utility method that creates a label instance and sets the default layout
278:             * data.
279:             * 
280:             * @param parent
281:             *            the parent for the new label
282:             * @param text
283:             *            the text for the new label
284:             * @return the new label
285:             */
286:            protected static Label createLabel(Composite parent, String text) {
287:                Label label = new Label(parent, SWT.LEFT);
288:                label.setText(text);
289:                GridData data = new GridData();
290:                data.horizontalSpan = 1;
291:                data.horizontalAlignment = GridData.FILL;
292:                label.setLayoutData(data);
293:                return label;
294:            }
295:
296:            /**
297:             * Creates a tab of one horizontal spans.
298:             * 
299:             * @param parent
300:             *            the parent in which the tab should be created
301:             */
302:            protected static void createSpace(Composite parent) {
303:                Label vfiller = new Label(parent, SWT.LEFT);
304:                GridData gridData = new GridData();
305:                gridData = new GridData();
306:                gridData.horizontalAlignment = GridData.BEGINNING;
307:                gridData.grabExcessHorizontalSpace = false;
308:                gridData.verticalAlignment = GridData.CENTER;
309:                gridData.grabExcessVerticalSpace = false;
310:                vfiller.setLayoutData(gridData);
311:            }
312:
313:            /**
314:             * Returns preference store that belongs to the our plugin.
315:             * 
316:             * @return the preference store for this plugin
317:             */
318:            protected IPreferenceStore doGetPreferenceStore() {
319:                return WorkbenchPlugin.getDefault().getPreferenceStore();
320:            }
321:
322:            /**
323:             * @see IWorkbenchPreferencePage
324:             */
325:            public void init(IWorkbench aWorkbench) {
326:                IPreferenceStore store = getPreferenceStore();
327:                openOnSingleClick = store
328:                        .getBoolean(IPreferenceConstants.OPEN_ON_SINGLE_CLICK);
329:                selectOnHover = store
330:                        .getBoolean(IPreferenceConstants.SELECT_ON_HOVER);
331:                openAfterDelay = store
332:                        .getBoolean(IPreferenceConstants.OPEN_AFTER_DELAY);
333:            }
334:
335:            /**
336:             * The default button has been pressed.
337:             */
338:            protected void performDefaults() {
339:                IPreferenceStore store = getPreferenceStore();
340:                stickyCycleButton.setSelection(store
341:                        .getBoolean(IPreferenceConstants.STICKY_CYCLE));
342:                openOnSingleClick = store
343:                        .getDefaultBoolean(IPreferenceConstants.OPEN_ON_SINGLE_CLICK);
344:                selectOnHover = store
345:                        .getDefaultBoolean(IPreferenceConstants.SELECT_ON_HOVER);
346:                openAfterDelay = store
347:                        .getDefaultBoolean(IPreferenceConstants.OPEN_AFTER_DELAY);
348:                singleClickButton.setSelection(openOnSingleClick);
349:                doubleClickButton.setSelection(!openOnSingleClick);
350:                selectOnHoverButton.setSelection(selectOnHover);
351:                openAfterDelayButton.setSelection(openAfterDelay);
352:                selectOnHoverButton.setEnabled(openOnSingleClick);
353:                openAfterDelayButton.setEnabled(openOnSingleClick);
354:                stickyCycleButton.setSelection(store
355:                        .getDefaultBoolean(IPreferenceConstants.STICKY_CYCLE));
356:                showUserDialogButton
357:                        .setSelection(store
358:                                .getDefaultBoolean(IPreferenceConstants.RUN_IN_BACKGROUND));
359:                showHeapStatusButton
360:                        .setSelection(PrefUtil
361:                                .getAPIPreferenceStore()
362:                                .getDefaultBoolean(
363:                                        IWorkbenchPreferenceConstants.SHOW_MEMORY_MONITOR));
364:
365:                super .performDefaults();
366:            }
367:
368:            /**
369:             * The user has pressed Ok. Store/apply this page's values appropriately.
370:             */
371:            public boolean performOk() {
372:                IPreferenceStore store = getPreferenceStore();
373:
374:                // store the keep cycle part dialogs sticky preference
375:                store.setValue(IPreferenceConstants.STICKY_CYCLE,
376:                        stickyCycleButton.getSelection());
377:                store.setValue(IPreferenceConstants.OPEN_ON_SINGLE_CLICK,
378:                        openOnSingleClick);
379:                store.setValue(IPreferenceConstants.SELECT_ON_HOVER,
380:                        selectOnHover);
381:                store.setValue(IPreferenceConstants.OPEN_AFTER_DELAY,
382:                        openAfterDelay);
383:                store.setValue(IPreferenceConstants.RUN_IN_BACKGROUND,
384:                        showUserDialogButton.getSelection());
385:                PrefUtil.getAPIPreferenceStore().setValue(
386:                        IWorkbenchPreferenceConstants.SHOW_MEMORY_MONITOR,
387:                        showHeapStatusButton.getSelection());
388:                updateHeapStatus(showHeapStatusButton.getSelection());
389:
390:                int singleClickMethod = openOnSingleClick ? OpenStrategy.SINGLE_CLICK
391:                        : OpenStrategy.DOUBLE_CLICK;
392:                if (openOnSingleClick) {
393:                    if (selectOnHover) {
394:                        singleClickMethod |= OpenStrategy.SELECT_ON_HOVER;
395:                    }
396:                    if (openAfterDelay) {
397:                        singleClickMethod |= OpenStrategy.ARROW_KEYS_OPEN;
398:                    }
399:                }
400:                OpenStrategy.setOpenMethod(singleClickMethod);
401:
402:                PrefUtil.savePrefs();
403:                return true;
404:            }
405:
406:            /**
407:             * Show or hide the heap status based on selection.
408:             * @param selection
409:             */
410:            private void updateHeapStatus(boolean selection) {
411:                IWorkbenchWindow[] windows = PlatformUI.getWorkbench()
412:                        .getWorkbenchWindows();
413:                for (int i = 0; i < windows.length; i++) {
414:                    IWorkbenchWindow window = windows[i];
415:                    if (window instanceof  WorkbenchWindow) {
416:                        ((WorkbenchWindow) window).showHeapStatus(selection);
417:                    }
418:                }
419:
420:            }
421:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.