Source Code Cross Referenced for WorkbenchPreferenceDialog.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, 2006 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.core.runtime.Assert;
013:        import org.eclipse.jface.dialogs.IDialogSettings;
014:        import org.eclipse.jface.preference.IPreferenceNode;
015:        import org.eclipse.jface.preference.PreferenceManager;
016:        import org.eclipse.swt.widgets.Shell;
017:        import org.eclipse.ui.IWorkbench;
018:        import org.eclipse.ui.IWorkbenchWindow;
019:        import org.eclipse.ui.PlatformUI;
020:        import org.eclipse.ui.activities.WorkbenchActivityHelper;
021:        import org.eclipse.ui.internal.IWorkbenchHelpContextIds;
022:        import org.eclipse.ui.internal.WorkbenchPlugin;
023:
024:        /**
025:         * Prefence dialog for the workbench including the ability to load/save
026:         * preferences.
027:         */
028:        public class WorkbenchPreferenceDialog extends FilteredPreferenceDialog {
029:            /**
030:             * There can only ever be one instance of the workbench's preference dialog.
031:             * This keeps a handle on this instance, so that attempts to create a second
032:             * dialog should just fail (or return the original instance).
033:             * 
034:             * @since 3.1
035:             */
036:            private static WorkbenchPreferenceDialog instance = null;
037:
038:            /**
039:             * The bounds of this dialog will be persisted in the dialog settings.
040:             * This is defined at the most concrete level of the hierarchy so that
041:             * different concrete implementations don't necessarily store their bounds 
042:             * in the same settings.
043:             * 
044:             * @since 3.2
045:             */
046:            private static final String DIALOG_SETTINGS_SECTION = "WorkbenchPreferenceDialogSettings"; //$NON-NLS-1$
047:
048:            /**
049:             * Creates a workbench preference dialog to a particular preference page. It
050:             * is the responsibility of the caller to then call <code>open()</code>.
051:             * The call to <code>open()</code> will not return until the dialog
052:             * closes, so this is the last chance to manipulate the dialog.
053:             * 
054:             * @param shell
055:             * 			The Shell to parent the dialog off of if it is not
056:             * 			already created. May be <code>null</code>
057:             * 			in which case the active workbench window will be used
058:             * 			if available.
059:             * @param preferencePageId
060:             *            The identifier of the preference page to open; may be
061:             *            <code>null</code>. If it is <code>null</code>, then the
062:             *            preference page is not selected or modified in any way.
063:             * @return The selected preference page.
064:             * @since 3.1
065:             */
066:            public static final WorkbenchPreferenceDialog createDialogOn(
067:                    Shell shell, final String preferencePageId) {
068:                final WorkbenchPreferenceDialog dialog;
069:
070:                if (instance == null) {
071:                    /*
072:                     * There is no existing preference dialog, so open a new one with
073:                     * the given selected page.
074:                     */
075:
076:                    Shell parentShell = shell;
077:                    if (parentShell == null) {
078:                        // Determine a decent parent shell.
079:                        final IWorkbench workbench = PlatformUI.getWorkbench();
080:                        final IWorkbenchWindow workbenchWindow = workbench
081:                                .getActiveWorkbenchWindow();
082:                        if (workbenchWindow != null) {
083:                            parentShell = workbenchWindow.getShell();
084:                        } else {
085:                            parentShell = null;
086:                        }
087:                    }
088:
089:                    // Create the dialog
090:                    final PreferenceManager preferenceManager = PlatformUI
091:                            .getWorkbench().getPreferenceManager();
092:                    dialog = new WorkbenchPreferenceDialog(parentShell,
093:                            preferenceManager);
094:                    if (preferencePageId != null) {
095:                        dialog.setSelectedNode(preferencePageId);
096:                    }
097:                    dialog.create();
098:                    PlatformUI.getWorkbench().getHelpSystem().setHelp(
099:                            dialog.getShell(),
100:                            IWorkbenchHelpContextIds.PREFERENCE_DIALOG);
101:
102:                } else {
103:                    /*
104:                     * There is an existing preference dialog, so let's just select the
105:                     * given preference page.
106:                     */
107:                    dialog = instance;
108:                    if (preferencePageId != null) {
109:                        dialog.setCurrentPageId(preferencePageId);
110:                    }
111:
112:                }
113:
114:                // Get the selected node, and return it.
115:                return dialog;
116:            }
117:
118:            /**
119:             * Creates a new preference dialog under the control of the given preference
120:             * manager.
121:             * 
122:             * @param parentShell
123:             *            the parent shell
124:             * @param manager
125:             *            the preference manager
126:             */
127:            public WorkbenchPreferenceDialog(Shell parentShell,
128:                    PreferenceManager manager) {
129:                super (parentShell, manager);
130:                Assert
131:                        .isTrue((instance == null),
132:                                "There cannot be two preference dialogs at once in the workbench."); //$NON-NLS-1$
133:                instance = this ;
134:
135:            }
136:
137:            /* (non-Javadoc)
138:             * @see org.eclipse.jface.window.Window#close()
139:             */
140:            public boolean close() {
141:                instance = null;
142:                return super .close();
143:            }
144:
145:            /**
146:             * Differs from super implementation in that if the node is found but should
147:             * be filtered based on a call to
148:             * <code>WorkbenchActivityHelper.filterItem()</code> then
149:             * <code>null</code> is returned.
150:             * 
151:             * @see org.eclipse.jface.preference.PreferenceDialog#findNodeMatching(java.lang.String)
152:             */
153:            protected IPreferenceNode findNodeMatching(String nodeId) {
154:                IPreferenceNode node = super .findNodeMatching(nodeId);
155:                if (WorkbenchActivityHelper.filterItem(node)) {
156:                    return null;
157:                }
158:                return node;
159:            }
160:
161:            /* (non-Javadoc)
162:             * @see org.eclipse.jface.dialogs.Dialog#okPressed()
163:             */
164:            protected void okPressed() {
165:                super .okPressed();
166:            }
167:
168:            /* (non-Javadoc)
169:             * @see org.eclipse.jface.window.Dialog#getDialogBoundsSettings()
170:             * 
171:             * @since 3.2
172:             */
173:            protected IDialogSettings getDialogBoundsSettings() {
174:                IDialogSettings settings = WorkbenchPlugin.getDefault()
175:                        .getDialogSettings();
176:                IDialogSettings section = settings
177:                        .getSection(DIALOG_SETTINGS_SECTION);
178:                if (section == null) {
179:                    section = settings.addNewSection(DIALOG_SETTINGS_SECTION);
180:                }
181:                return section;
182:            }
183:
184:            /* (non-Javadoc)
185:             * @see org.eclipse.jface.window.Dialog#getDialogBoundsStrategy()
186:             * 
187:             * Overridden to persist only the location, not the size, since the current
188:             * page dictates the most appropriate size for the dialog.
189:             * @since 3.2
190:             */
191:            protected int getDialogBoundsStrategy() {
192:                return DIALOG_PERSISTLOCATION;
193:            }
194:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.