cbateman | 2ff89c3 | 2008-11-05 21:49:35 +0000 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2001, 2008 Oracle 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 | * Oracle Corporation - initial API and implementation |
| 10 | *******************************************************************************/ |
| 11 | package org.eclipse.jst.pagedesigner; |
| 12 | |
| 13 | import org.eclipse.osgi.framework.debug.FrameworkDebugOptions; |
| 14 | import org.eclipse.osgi.service.debug.DebugOptions; |
| 15 | |
| 16 | /** |
| 17 | * Defines that standard runtime trace options for debugging. See .options file |
| 18 | * for definitions. |
| 19 | * |
| 20 | * NOT API |
| 21 | * |
| 22 | * @author cbateman |
| 23 | * |
| 24 | */ |
| 25 | public final class PageDesignerTraceOptions |
| 26 | { |
| 27 | /** |
| 28 | * True if debug tracing is enabled. Other tracing cannot be enabled unless |
| 29 | * this is enabled. |
| 30 | */ |
| 31 | public static final boolean ENABLED; |
| 32 | |
| 33 | /** |
| 34 | * True if tag converter ext load tracing is enabled |
| 35 | */ |
| 36 | public static final boolean TRACE_CONVERTERLOAD; |
| 37 | /** |
| 38 | * True if tag converter selection tracing is enabled |
| 39 | */ |
| 40 | public static final boolean TRACE_CONVERTERSELECT; |
| 41 | /** |
| 42 | * True if tag element edit ext load tracing is enabled |
| 43 | */ |
| 44 | public static final boolean TRACE_ELEMENTEDITLOAD; |
| 45 | /** |
| 46 | * True if tag element edit selection tracing is enabled |
| 47 | */ |
| 48 | public static final boolean TRACE_ELEMENTEDITSELECTION; |
| 49 | |
gkessler | cfc5308 | 2008-11-18 22:25:04 +0000 | [diff] [blame] | 50 | private static final String KEY_DEBUG_ENABLED = "/debug"; //$NON-NLS-1$ |
| 51 | private static final String KEY_CONVERTER = KEY_DEBUG_ENABLED+"/converter"; //$NON-NLS-1$ |
| 52 | private static final String KEY_CONVERTER_LOAD = KEY_CONVERTER + "/load"; //$NON-NLS-1$ |
| 53 | private static final String KEY_CONVERTER_SELECTION = KEY_CONVERTER + "/selection"; //$NON-NLS-1$ |
cbateman | 2ff89c3 | 2008-11-05 21:49:35 +0000 | [diff] [blame] | 54 | |
gkessler | cfc5308 | 2008-11-18 22:25:04 +0000 | [diff] [blame] | 55 | private static final String KEY_ELEMENTEDIT = KEY_DEBUG_ENABLED+"/elementedit"; //$NON-NLS-1$ |
| 56 | private static final String KEY_ELEMENTEDIT_LOAD = KEY_ELEMENTEDIT + "/load"; //$NON-NLS-1$ |
| 57 | private static final String KEY_ELEMENTEDIT_SELECTION = KEY_ELEMENTEDIT + "/selection"; //$NON-NLS-1$ |
cbateman | 2ff89c3 | 2008-11-05 21:49:35 +0000 | [diff] [blame] | 58 | |
| 59 | |
| 60 | static |
| 61 | { |
| 62 | final DebugOptions debugOptions = FrameworkDebugOptions.getDefault(); |
| 63 | final String pluginId = PDPlugin.getPluginId(); |
| 64 | ENABLED = debugOptions != null |
| 65 | && debugOptions.getBooleanOption(pluginId |
| 66 | + KEY_DEBUG_ENABLED, false); |
| 67 | |
| 68 | if (ENABLED) |
| 69 | { |
| 70 | TRACE_CONVERTERLOAD = debugOptions.getBooleanOption( |
| 71 | pluginId + KEY_CONVERTER_LOAD, false); |
| 72 | TRACE_CONVERTERSELECT = debugOptions.getBooleanOption( |
| 73 | pluginId + KEY_CONVERTER_SELECTION, false); |
| 74 | TRACE_ELEMENTEDITLOAD = debugOptions.getBooleanOption( |
| 75 | pluginId + KEY_ELEMENTEDIT_LOAD, false); |
| 76 | TRACE_ELEMENTEDITSELECTION = debugOptions.getBooleanOption( |
| 77 | pluginId + KEY_ELEMENTEDIT_SELECTION, false); |
| 78 | } |
| 79 | else |
| 80 | { |
| 81 | TRACE_CONVERTERLOAD = false; |
| 82 | TRACE_CONVERTERSELECT = false; |
| 83 | TRACE_ELEMENTEDITLOAD = false; |
| 84 | TRACE_ELEMENTEDITSELECTION = false; |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * @param message |
| 90 | */ |
| 91 | public static void log(final String message) |
| 92 | { |
| 93 | System.out.println(message); |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * @param msg A short label placed before the trace of t to show the source |
| 98 | * @param t |
| 99 | */ |
| 100 | public static void log(final String msg, final Throwable t) |
| 101 | { |
gkessler | cfc5308 | 2008-11-18 22:25:04 +0000 | [diff] [blame] | 102 | System.out.printf("%s: Exception Trace:\n\n",msg); //$NON-NLS-1$ |
cbateman | 2ff89c3 | 2008-11-05 21:49:35 +0000 | [diff] [blame] | 103 | t.printStackTrace(System.out); |
gkessler | cfc5308 | 2008-11-18 22:25:04 +0000 | [diff] [blame] | 104 | System.out.print("\n\n\n"); //$NON-NLS-1$ |
cbateman | 2ff89c3 | 2008-11-05 21:49:35 +0000 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | private PageDesignerTraceOptions() |
| 108 | { |
| 109 | // no instantiation |
| 110 | } |
| 111 | } |