01: /*
02: * uDig - User Friendly Desktop Internet GIS client
03: * http://udig.refractions.net
04: * (C) 2004, Refractions Research Inc.
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: */
17: package net.refractions.udig.render.internal.feature.basic;
18:
19: import org.eclipse.core.runtime.IStatus;
20: import org.eclipse.core.runtime.Platform;
21: import org.eclipse.core.runtime.Plugin;
22: import org.eclipse.core.runtime.Status;
23:
24: /**
25: * Plugin class for BasicGridCoverage
26: * @author jones
27: * @since 0.6.0
28: */
29: public class RendererPlugin extends Plugin {
30:
31: private static RendererPlugin plugin;
32:
33: public static String ID = "net.refractions.udig.render.feature.basic"; //$NON-NLS-1$
34:
35: /**
36: * Construct <code>RendererPlugin</code>.
37: *
38: */
39: public RendererPlugin() {
40: super ();
41: plugin = this ;
42: }
43:
44: public static Plugin getDefault() {
45: return plugin;
46: }
47:
48: /**
49: * Writes an info log in the plugin's log.
50: * <p>
51: * This should be used for user level messages.
52: * </p>
53: * @param message Message to tell the user
54: * @param e Throwable assocaited with this message
55: */
56: public static void log(String message, Throwable e) {
57: getDefault().getLog().log(
58: new Status(IStatus.INFO, ID, 0, message, e));
59: }
60:
61: /**
62: * Messages that only engage if getDefault().isDebugging()
63: * <p>
64: * It is much prefered to do this:<pre><code>
65: * private static final String RENDERING = "net.refractions.udig.project/render/trace";
66: * if( ProjectUIPlugin.getDefault().isDebugging() && "true".equalsIgnoreCase( RENDERING ) ){
67: * System.out.println( "your message here" );
68: * }
69: * @param message Message to send to standard out
70: * @param e Throwable associated with this trace
71: */
72: public static void trace(String message, Throwable e) {
73: if (getDefault().isDebugging()) {
74: if (message != null)
75: System.out.println(message);
76: if (e != null)
77: e.printStackTrace();
78: }
79: }
80:
81: /**
82: * Performs the Platform.getDebugOption true check on the provided trace
83: * <p>
84: * Note: ProjectUIPlugin.getDefault().isDebugging() must also be on.
85: * <ul>
86: * <li>Trace.RENDER - trace rendering progress
87: * </ul>
88: * </p>
89: * @param trace currently only RENDER is defined
90: * @return true if -debug is used with a .options file to enable tracing
91: */
92: public static boolean isDebugging(final String trace) {
93: boolean on = true; //getDefault().isDebugging();
94: boolean enable = "true".equalsIgnoreCase(Platform.getDebugOption(trace)); //$NON-NLS-1$
95: return on && enable;
96:
97: }
98: }
|