001: /**
002: * <copyright>
003: * </copyright>
004: *
005: * $Id: ProjectEditPlugin.java 23333 2006-12-08 19:40:41Z jeichar $
006: */package net.refractions.udig.project.internal.provider;
007:
008: import org.eclipse.core.runtime.IStatus;
009: import org.eclipse.core.runtime.Platform;
010: import org.eclipse.core.runtime.Status;
011: import org.eclipse.emf.common.EMFPlugin;
012: import org.eclipse.emf.common.util.ResourceLocator;
013: import org.osgi.framework.BundleContext;
014:
015: /**
016: * This is the central singleton for the Project edit plugin.
017: * <!-- begin-user-doc --> <!--
018: * end-user-doc -->
019: * @generated
020: */
021: public final class ProjectEditPlugin extends EMFPlugin {
022: /**
023: * @generated NOT
024: */
025: public static final String ID = "net.refractions.udig.project.edit"; //$NON-NLS-1$
026: /**
027: * <!-- begin-user-doc --> <!-- end-user-doc -->
028: * @generated
029: */
030: public static final String copyright = "uDig - User Friendly Desktop Internet GIS client http://udig.refractions.net (C) 2004, Refractions Research Inc. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; version 2.1 of the License. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details."; //$NON-NLS-1$
031:
032: /**
033: * Keep track of the singleton.
034: * <!-- begin-user-doc --> <!-- end-user-doc -->
035: * @generated
036: */
037: public static final ProjectEditPlugin INSTANCE = new ProjectEditPlugin();
038:
039: /**
040: * Keep track of the singleton.
041: * <!-- begin-user-doc --> <!-- end-user-doc -->
042: * @generated
043: */
044: private static Implementation plugin;
045:
046: /**
047: * Create the instance.
048: * <!-- begin-user-doc --> <!-- end-user-doc -->
049: * @generated
050: */
051: public ProjectEditPlugin() {
052: super (new ResourceLocator[] {});
053: }
054:
055: /**
056: * Returns the singleton instance of the Eclipse plugin.
057: * <!-- begin-user-doc --> <!--
058: * end-user-doc -->
059: * @return the singleton instance.
060: * @generated
061: */
062: public ResourceLocator getPluginResourceLocator() {
063: return plugin;
064: }
065:
066: /**
067: * Returns the singleton instance of the Eclipse plugin.
068: * <!-- begin-user-doc --> <!--
069: * end-user-doc -->
070: * @return the singleton instance.
071: * @generated
072: */
073: public static Implementation getPlugin() {
074: return plugin;
075: }
076:
077: /**
078: * The actual implementation of the Eclipse <b>Plugin</b>.
079: * <!-- begin-user-doc --> <!--
080: * end-user-doc -->
081: * @generated
082: */
083: public static class Implementation extends EclipsePlugin {
084: /**
085: * Creates an instance.
086: * <!-- begin-user-doc --> <!-- end-user-doc -->
087: * @generated
088: */
089: public Implementation() {
090: super ();
091:
092: // Remember the static instance.
093: //
094: plugin = this ;
095: }
096:
097: /*
098: * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
099: */
100: public void start(BundleContext context) throws Exception {
101: super .start(context);
102: }
103:
104: /*
105: * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
106: */
107: public void stop(BundleContext context) throws Exception {
108: super .stop(context);
109: }
110: }
111:
112: /**
113: * Logs the Throwable in the plugin's log.
114: * <p>
115: * This will be a user visable ERROR iff:
116: * <ul>
117: * <li>t is an Exception we are assuming it is human readable or if a message is provided
118: * </ul>
119: * </p>
120: *
121: * @param message
122: * @param t
123: */
124: public static void log(String message, Throwable t) {
125: int status = t instanceof Exception || message != null ? IStatus.ERROR
126: : IStatus.WARNING;
127: getPlugin().getLog().log(
128: new Status(status, ID, IStatus.OK, message, t));
129: }
130:
131: /**
132: * Messages that only engage if getDefault().isDebugging()
133: * <p>
134: * It is much prefered to do this:
135: *
136: * <pre><code>
137: * private static final String RENDERING = "net.refractions.udig.project/render/trace";
138: * if (ProjectUIPlugin.getDefault().isDebugging() && "true".equalsIgnoreCase(RENDERING)) {
139: * System.out.println("your message here");
140: * }
141: * </code></pre>
142: *
143: * </p>
144: *
145: * @param message
146: * @param e
147: */
148: public static void trace(String message, Throwable e) {
149: if (getPlugin().isDebugging()) {
150: if (message != null)
151: System.out.println(message);
152: if (e != null)
153: e.printStackTrace();
154: }
155: }
156:
157: /**
158: * Performs the Platform.getDebugOption true check on the provided trace
159: * <p>
160: * Note: ProjectUIPlugin.getDefault().isDebugging() must also be on.
161: * <ul>
162: * <li>Trace.RENDER - trace rendering progress
163: * </ul>
164: * </p>
165: *
166: * @param trace currently only RENDER is defined
167: * @return true if -debug is on for this plugin
168: */
169: public static boolean isDebugging(final String trace) {
170: return getPlugin().isDebugging()
171: && "true".equalsIgnoreCase(Platform.getDebugOption(trace)); //$NON-NLS-1$
172: }
173: }
|