comparison org.eclipse.core.databinding.observable/src/org/eclipse/core/databinding/util/Policy.d @ 95:6208d4f6a277

Added trees for databinding.beans and observable
author Frank Benoit <benoit@tionex.de>
date Tue, 21 Apr 2009 10:55:51 +0200
parents
children b74ac5dfcc06
comparison
equal deleted inserted replaced
94:1d37a7813832 95:6208d4f6a277
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 package org.eclipse.core.databinding.util;
16
17 import org.eclipse.core.runtime.IStatus;
18
19 /**
20 * The Policy class handles settings for behaviour, debug flags and logging
21 * within JFace Data Binding.
22 *
23 * @since 1.1
24 */
25 public class Policy {
26
27 /**
28 * Constant for the the default setting for debug options.
29 */
30 public static final bool DEFAULT = false;
31
32 /**
33 * The unique identifier of the JFace plug-in.
34 */
35 public static final String JFACE_DATABINDING = "org.eclipse.core.databinding";//$NON-NLS-1$
36
37 private static ILogger log;
38
39 /**
40 * Returns the dummy log to use if none has been set
41 */
42 private static ILogger getDummyLog() {
43 return new class() ILogger {
44 public void log(IStatus status) {
45 System.err.println(status.getPlugin() + " - " + status.getCode() + " - " + status.getMessage()); //$NON-NLS-1$//$NON-NLS-2$
46 if( status.getException() !is null ) {
47 status.getException().printStackTrace(System.err);
48 }
49 }
50 };
51 }
52
53 /**
54 * Sets the logger used by JFace Data Binding to log errors.
55 *
56 * @param logger
57 * the logger to use, or <code>null</code> to use the default
58 * logger
59 */
60 public static synchronized void setLog(ILogger logger) {
61 log = logger;
62 }
63
64 /**
65 * Returns the logger used by JFace Data Binding to log errors.
66 * <p>
67 * The default logger prints the status to <code>System.err</code>.
68 * </p>
69 *
70 * @return the logger
71 */
72 public static synchronized ILogger getLog() {
73 if (log is null) {
74 log = getDummyLog();
75 }
76 return log;
77 }
78
79 }