comparison org.eclipse.core.databinding/src/org/eclipse/core/databinding/util/Policy.d @ 78:0a55d2d5a946

Added file for databinding
author Frank Benoit <benoit@tionex.de>
date Tue, 14 Apr 2009 11:35:29 +0200
parents
children 383ce7bd736b
comparison
equal deleted inserted replaced
76:f05e6e8b2f2d 78:0a55d2d5a946
1 /*******************************************************************************
2 * Copyright (c) 2004, 2007 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * IBM Corporation - initial API and implementation
10 * Chris Gross (schtoo@schtoo.com) - support for ILogger added
11 * (bug 49497 [RCP] JFace dependency on org.eclipse.core.runtime enlarges standalone JFace applications)
12 * Brad Reynolds - bug 164653
13 * Tom Schindl <tom.schindl@bestsolution.at> - bug 194587
14 *******************************************************************************/
15 module org.eclipse.core.databinding.util.Policy;
16
17 import java.lang.all;
18
19 import org.eclipse.core.runtime.IStatus;
20
21 /**
22 * The Policy class handles settings for behaviour, debug flags and logging
23 * within JFace Data Binding.
24 *
25 * @since 1.1
26 */
27 public class Policy {
28
29 /**
30 * Constant for the the default setting for debug options.
31 */
32 public static final bool DEFAULT = false;
33
34 /**
35 * The unique identifier of the JFace plug-in.
36 */
37 public static final String JFACE_DATABINDING = "org.eclipse.core.databinding";//$NON-NLS-1$
38
39 private static ILogger log;
40
41 /**
42 * Returns the dummy log to use if none has been set
43 */
44 private static ILogger getDummyLog() {
45 return new class() ILogger {
46 public void log(IStatus status) {
47 System.err.println(status.getPlugin() + " - " + status.getCode() + " - " + status.getMessage()); //$NON-NLS-1$//$NON-NLS-2$
48 if( status.getException() !is null ) {
49 status.getException().printStackTrace(System.err);
50 }
51 }
52 };
53 }
54
55 /**
56 * Sets the logger used by JFace Data Binding to log errors.
57 *
58 * @param logger
59 * the logger to use, or <code>null</code> to use the default
60 * logger
61 */
62 public static synchronized void setLog(ILogger logger) {
63 log = logger;
64 }
65
66 /**
67 * Returns the logger used by JFace Data Binding to log errors.
68 * <p>
69 * The default logger prints the status to <code>System.err</code>.
70 * </p>
71 *
72 * @return the logger
73 */
74 public static synchronized ILogger getLog() {
75 if (log is null) {
76 log = getDummyLog();
77 }
78 return log;
79 }
80
81 }