Source Code Cross Referenced for Policy.java in  » IDE-Eclipse » jface » org » eclipse » jface » util » 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 » jface » org.eclipse.jface.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2004, 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:         *     Chris Gross (schtoo@schtoo.com) - support for ILogger added
011:         *       (bug 49497 [RCP] JFace dependency on org.eclipse.core.runtime enlarges standalone JFace applications)
012:         *******************************************************************************/package org.eclipse.jface.util;
013:
014:        import java.util.Comparator;
015:
016:        import org.eclipse.core.runtime.IStatus;
017:        import org.eclipse.jface.dialogs.AnimatorFactory;
018:        import org.eclipse.jface.dialogs.ErrorSupportProvider;
019:
020:        /**
021:         * The Policy class handles settings for behaviour, debug flags and logging
022:         * within JFace.
023:         * 
024:         * @since 3.0
025:         */
026:        public class Policy {
027:
028:            /**
029:             * Constant for the the default setting for debug options.
030:             */
031:            public static final boolean DEFAULT = false;
032:
033:            /**
034:             * The unique identifier of the JFace plug-in.
035:             */
036:            public static final String JFACE = "org.eclipse.jface";//$NON-NLS-1$
037:
038:            private static ILogger log;
039:
040:            private static Comparator viewerComparator;
041:
042:            private static AnimatorFactory animatorFactory;
043:
044:            /**
045:             * A flag to indicate whether unparented dialogs should be checked.
046:             */
047:            public static boolean DEBUG_DIALOG_NO_PARENT = DEFAULT;
048:
049:            /**
050:             * A flag to indicate whether actions are being traced.
051:             */
052:            public static boolean TRACE_ACTIONS = DEFAULT;
053:
054:            /**
055:             * A flag to indicate whether toolbars are being traced.
056:             */
057:
058:            public static boolean TRACE_TOOLBAR = DEFAULT;
059:
060:            private static ErrorSupportProvider errorSupportProvider;
061:
062:            /**
063:             * Returns the dummy log to use if none has been set
064:             */
065:            private static ILogger getDummyLog() {
066:                return new ILogger() {
067:                    public void log(IStatus status) {
068:                        System.err.println(status.getMessage());
069:                        if (status.getException() != null) {
070:                            status.getException().printStackTrace(System.err);
071:                        }
072:                    }
073:                };
074:            }
075:
076:            /**
077:             * Sets the logger used by JFace to log errors.
078:             * 
079:             * @param logger
080:             *            the logger to use, or <code>null</code> to use the default
081:             *            logger
082:             * @since 3.1
083:             */
084:            public static void setLog(ILogger logger) {
085:                log = logger;
086:            }
087:
088:            /**
089:             * Returns the logger used by JFace to log errors.
090:             * <p>
091:             * The default logger prints the status to <code>System.err</code>.
092:             * </p>
093:             * 
094:             * @return the logger
095:             * @since 3.1
096:             */
097:            public static ILogger getLog() {
098:                if (log == null) {
099:                    log = getDummyLog();
100:                }
101:                return log;
102:            }
103:
104:            /**
105:             * Return the default comparator used by JFace to sort strings.
106:             * 
107:             * @return a default comparator used by JFace to sort strings
108:             */
109:            private static Comparator getDefaultComparator() {
110:                return new Comparator() {
111:                    /**
112:                     * Compares string s1 to string s2.
113:                     * 
114:                     * @param s1
115:                     *            string 1
116:                     * @param s2
117:                     *            string 2
118:                     * @return Returns an integer value. Value is less than zero if
119:                     *         source is less than target, value is zero if source and
120:                     *         target are equal, value is greater than zero if source is
121:                     *         greater than target.
122:                     * @exception ClassCastException
123:                     *                the arguments cannot be cast to Strings.
124:                     */
125:                    public int compare(Object s1, Object s2) {
126:                        return ((String) s1).compareTo((String) s2);
127:                    }
128:                };
129:            }
130:
131:            /**
132:             * Return the comparator used by JFace to sort strings.
133:             * 
134:             * @return the comparator used by JFace to sort strings
135:             * @since 3.2
136:             */
137:            public static Comparator getComparator() {
138:                if (viewerComparator == null) {
139:                    viewerComparator = getDefaultComparator();
140:                }
141:                return viewerComparator;
142:            }
143:
144:            /**
145:             * Sets the comparator used by JFace to sort strings.
146:             * 
147:             * @param comparator
148:             *            comparator used by JFace to sort strings
149:             * @since 3.2
150:             */
151:            public static void setComparator(Comparator comparator) {
152:                org.eclipse.core.runtime.Assert
153:                        .isTrue(viewerComparator == null);
154:                viewerComparator = comparator;
155:            }
156:
157:            /**
158:             * Sets the animator factory used by JFace to create control animator
159:             * instances.
160:             * 
161:             * @param factory
162:             *            the AnimatorFactory to use.
163:             * @since 3.2
164:             * @deprecated this is no longer in use as of 3.3
165:             */
166:            public static void setAnimatorFactory(AnimatorFactory factory) {
167:                animatorFactory = factory;
168:            }
169:
170:            /**
171:             * Returns the animator factory used by JFace to create control animator
172:             * instances.
173:             * 
174:             * @return the animator factory used to create control animator instances.
175:             * @since 3.2
176:             * @deprecated this is no longer in use as of 3.3
177:             */
178:            public static AnimatorFactory getAnimatorFactory() {
179:                if (animatorFactory == null)
180:                    animatorFactory = new AnimatorFactory();
181:                return animatorFactory;
182:            }
183:
184:            /**
185:             * Set the error support provider for error dialogs.
186:             * 
187:             * @param provider
188:             * @since 3.3
189:             */
190:            public static void setErrorSupportProvider(
191:                    ErrorSupportProvider provider) {
192:                errorSupportProvider = provider;
193:            }
194:
195:            /**
196:             * Return the ErrorSupportProvider for the receiver.
197:             * 
198:             * @return ErrorSupportProvider or <code>null</code> if this has not been set
199:             * @since 3.3
200:             */
201:            public static ErrorSupportProvider getErrorSupportProvider() {
202:                return errorSupportProvider;
203:            }
204:
205:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.