1 /*******************************************************************************
2 * Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
3 * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
5 * All rights reserved. This program and the accompanying materials
6 * are made available under the terms of the Eclipse Public License v1.0
7 * See LICENSE for the full license text, also available.
8 *******************************************************************************/
9 package org
.spearce
.egit
.core
;
11 import org
.eclipse
.core
.runtime
.CoreException
;
12 import org
.eclipse
.core
.runtime
.IStatus
;
13 import org
.eclipse
.core
.runtime
.Platform
;
14 import org
.eclipse
.core
.runtime
.Status
;
15 import org
.eclipse
.ui
.plugin
.AbstractUIPlugin
;
16 import org
.osgi
.framework
.BundleContext
;
17 import org
.spearce
.egit
.core
.project
.GitProjectData
;
20 * The plugin class for the org.spearce.egit.core plugin. This
21 * is a singleton class.
23 public class Activator
extends AbstractUIPlugin
{
24 private static Activator plugin
;
27 * @return the singleton {@link Activator}
29 public static Activator
getDefault() {
34 * @return the name of this plugin
36 public static String
getPluginId() {
37 return getDefault().getBundle().getSymbolicName();
41 * Utility method to help throwing errors in the Egit plugin. This method
42 * does not actually throw the exception, but just creates an instance.
44 * @param message User comprehensible message
46 * @return an Initialized {@link CoreException}
48 public static CoreException
error(final String message
, final Throwable thr
) {
49 return new CoreException(new Status(IStatus
.ERROR
, getPluginId(), 0,
54 * Utility method to log errors in the Egit plugin.
55 * @param message User comprehensible message
56 * @param thr The exception through which we noticed the error
58 public static void logError(final String message
, final Throwable thr
) {
59 getDefault().getLog().log(
60 new Status(IStatus
.ERROR
, getPluginId(), 0, message
, thr
));
63 private static boolean isOptionSet(final String optionId
) {
64 final String option
= getPluginId() + optionId
;
65 final String value
= Platform
.getDebugOption(option
);
66 return value
!= null && value
.equals("true");
70 * Utility method for debug logging.
74 public static void trace(final String what
) {
75 if (getDefault().traceVerbose
) {
76 System
.out
.println("[" + getPluginId() + "] " + what
);
80 private boolean traceVerbose
;
83 * Construct the {@link Activator} singleton instance
89 public void start(final BundleContext context
) throws Exception
{
91 traceVerbose
= isOptionSet("/trace/verbose");
92 GitProjectData
.reconfigureWindowCache();
93 GitProjectData
.attachToWorkspace(true);
96 public void stop(final BundleContext context
) throws Exception
{
97 GitProjectData
.detachFromWorkspace();