aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Kinzler2010-04-08 02:48:19 (EDT)
committerRobin Rosenberg2010-04-09 04:56:34 (EDT)
commita692ce8b504c7062120476a334a8d434ce5bafdd (patch)
tree5cc1e6b8898807367d7f83cbc8ff6e6ec1aaded7
parentdcd931cb2f0d39bb9cfbb4d2206fe08e34eeaed9 (diff)
downloadegit-a692ce8b504c7062120476a334a8d434ce5bafdd.zip
egit-a692ce8b504c7062120476a334a8d434ce5bafdd.tar.gz
egit-a692ce8b504c7062120476a334a8d434ce5bafdd.tar.bz2
Make tracing 3.4 compatible and plug-in localrefs/changes/08/508/7
Sharing trace classes between plug-ins is bad, as the OSGI tracing infrastructure will write the ID of plug-in that exposes the trace class into the trace file. Instead the ID of the plug-in that is writing the trace should be written. This is achieved by obtaining a separate Location for each plug-in. In order to achieve 3.4. compatibility, a temporary trace implementation using System.out is used. Bug: 306793 Change-Id: I2765961f9c0b886995e74b03404e1f20aadf7b28 Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com> Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
-rw-r--r--org.eclipse.egit.core/.options3
-rw-r--r--org.eclipse.egit.core/META-INF/MANIFEST.MF1
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java24
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/internal/trace/DebugTrace.java24
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/internal/trace/GitTraceLocation.java47
-rw-r--r--org.eclipse.egit.ui/.options4
-rw-r--r--org.eclipse.egit.ui/META-INF/MANIFEST.MF1
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java15
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/GitResourceNode.java10
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/BranchAction.java14
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitAction.java18
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ResetAction.java6
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitDocument.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitQuickDiffProvider.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitProjectPropertyPage.java6
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/trace/DebugTrace.java35
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/trace/GitTraceLocation.java145
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/trace/ITraceLocation.java30
19 files changed, 336 insertions, 55 deletions
diff --git a/org.eclipse.egit.core/.options b/org.eclipse.egit.core/.options
index 36f7a0d..efb197e 100644
--- a/org.eclipse.egit.core/.options
+++ b/org.eclipse.egit.core/.options
@@ -2,5 +2,4 @@
org.eclipse.egit.core/debug = false
# General trace location for the EGit Core Plugin
org.eclipse.egit.core/debug/core = false
-# General trace location for the EGit UI Plugin
-org.eclipse.egit.core/debug/ui = false
+
diff --git a/org.eclipse.egit.core/META-INF/MANIFEST.MF b/org.eclipse.egit.core/META-INF/MANIFEST.MF
index 44a6ada..029397b 100644
--- a/org.eclipse.egit.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.egit.core/META-INF/MANIFEST.MF
@@ -12,7 +12,6 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)",
org.eclipse.core.filesystem;bundle-version="[1.2.0,2.0.0)"
Export-Package: org.eclipse.egit.core;version="0.8.0",
org.eclipse.egit.core.internal.storage;version="0.8.0";x-friends:="org.eclipse.egit.ui",
- org.eclipse.egit.core.internal.trace;version="0.8.0";x-friends:="org.eclipse.egit.ui",
org.eclipse.egit.core.internal.util;version="0.8.0";x-friends:="org.eclipse.egit.ui",
org.eclipse.egit.core.op;version="0.8.0",
org.eclipse.egit.core.project;version="0.8.0"
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java
index 572c146..a63dcfc 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java
@@ -9,8 +9,6 @@
*******************************************************************************/
package org.eclipse.egit.core;
-import java.util.Hashtable;
-
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Plugin;
@@ -18,14 +16,14 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.egit.core.internal.trace.GitTraceLocation;
import org.eclipse.egit.core.project.GitProjectData;
import org.eclipse.osgi.service.debug.DebugOptions;
-import org.eclipse.osgi.service.debug.DebugOptionsListener;
import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.ServiceTracker;
/**
* The plugin class for the org.eclipse.egit.core plugin. This
* is a singleton class.
*/
-public class Activator extends Plugin implements DebugOptionsListener {
+public class Activator extends Plugin {
private static Activator plugin;
/**
@@ -73,12 +71,17 @@ public class Activator extends Plugin implements DebugOptionsListener {
}
public void start(final BundleContext context) throws Exception {
+
super.start(context);
- // register this as DebugOptions listener
- Hashtable<String, String> props = new Hashtable<String, String>(4);
- // we want to get notified about our own DebugOptions
- props.put(DebugOptions.LISTENER_SYMBOLICNAME, context.getBundle().getSymbolicName());
- context.registerService(DebugOptionsListener.class.getName(), this, props);
+
+ if (isDebugging()) {
+ ServiceTracker debugTracker = new ServiceTracker(context,
+ DebugOptions.class.getName(), null);
+ debugTracker.open();
+
+ DebugOptions opts = (DebugOptions) debugTracker.getService();
+ GitTraceLocation.initializeFromOptions(opts, true);
+ }
GitProjectData.reconfigureWindowCache();
GitProjectData.attachToWorkspace(true);
@@ -90,7 +93,4 @@ public class Activator extends Plugin implements DebugOptionsListener {
plugin = null;
}
- public void optionsChanged(DebugOptions options) {
- GitTraceLocation.initializeFromOptions(options, isDebugging());
- }
}
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/trace/DebugTrace.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/trace/DebugTrace.java
new file mode 100644
index 0000000..a7ecdc5
--- /dev/null
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/trace/DebugTrace.java
@@ -0,0 +1,24 @@
+package org.eclipse.egit.core.internal.trace;
+
+/**
+ * Just a place holder for OSGI Debug Trace support until
+ * we drop 3.4 support in EGit/JGit;
+ *
+ * TODO replace this by OSGI's DebugTrace once we drop 3.4 support
+ */
+public interface DebugTrace {
+
+ /**
+ * @param location
+ * @param message
+ */
+ public void trace(String location, String message);
+
+ /**
+ * @param location
+ * @param message
+ * @param error
+ */
+ public void trace(String location, String message, Throwable error);
+
+}
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/trace/GitTraceLocation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/trace/GitTraceLocation.java
index 92f8510..382283f 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/trace/GitTraceLocation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/trace/GitTraceLocation.java
@@ -10,9 +10,11 @@
*******************************************************************************/
package org.eclipse.egit.core.internal.trace;
+import org.eclipse.core.runtime.ILog;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.egit.core.Activator;
import org.eclipse.osgi.service.debug.DebugOptions;
-import org.eclipse.osgi.service.debug.DebugTrace;
/**
* EGit Trace locations
@@ -20,9 +22,7 @@ import org.eclipse.osgi.service.debug.DebugTrace;
*/
public enum GitTraceLocation implements ITraceLocation {
/** Core */
- CORE("/debug/core"), //$NON-NLS-1$
- /** UI */
- UI("/debug/ui"); //$NON-NLS-1$
+ CORE("/debug/core"); //$NON-NLS-1$
/**
* Initialize the locations
@@ -30,13 +30,15 @@ public enum GitTraceLocation implements ITraceLocation {
* @param options
* @param pluginIsDebugging
*/
- public static void initializeFromOptions(DebugOptions options, boolean pluginIsDebugging) {
+ public static void initializeFromOptions(DebugOptions options,
+ boolean pluginIsDebugging) {
// we evaluate the plug-in switch
if (pluginIsDebugging) {
- myTrace = options.newDebugTrace(Activator.getPluginId());
+ myTrace = new DebugTraceImpl();
for (GitTraceLocation loc : values()) {
- boolean active = options.getBooleanOption(loc.getFullPath(), false);
+ boolean active = options.getBooleanOption(loc.getFullPath(),
+ false);
loc.setActive(active);
}
} else {
@@ -49,9 +51,11 @@ public enum GitTraceLocation implements ITraceLocation {
}
private final String location;
+
private final String fullPath;
private boolean active = false;
+
private static DebugTrace myTrace;
private GitTraceLocation(String path) {
@@ -100,4 +104,33 @@ public enum GitTraceLocation implements ITraceLocation {
this.active = active;
}
+ private static final class DebugTraceImpl implements DebugTrace {
+
+ private ILog myLog;
+
+ public void trace(String location, String message) {
+ getLog().log(
+ new Status(IStatus.INFO, Activator.getPluginId(), message));
+
+ }
+
+ public void trace(String location, String message, Throwable error) {
+
+ getLog().log(
+ new Status(IStatus.INFO, Activator.getPluginId(), message));
+ if (error != null)
+ getLog().log(
+ new Status(IStatus.INFO, Activator.getPluginId(), error
+ .getMessage()));
+
+ }
+
+ private ILog getLog() {
+ if (myLog == null) {
+ myLog = Activator.getDefault().getLog();
+ }
+ return myLog;
+ }
+
+ }
}
diff --git a/org.eclipse.egit.ui/.options b/org.eclipse.egit.ui/.options
new file mode 100644
index 0000000..f7fc816
--- /dev/null
+++ b/org.eclipse.egit.ui/.options
@@ -0,0 +1,4 @@
+# Main Debug Trace switch
+org.eclipse.egit.ui/debug = false
+# General trace location for the EGit UI Plugin
+org.eclipse.egit.ui/debug/ui = false
diff --git a/org.eclipse.egit.ui/META-INF/MANIFEST.MF b/org.eclipse.egit.ui/META-INF/MANIFEST.MF
index d690eb6..ab1bb68 100644
--- a/org.eclipse.egit.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.egit.ui/META-INF/MANIFEST.MF
@@ -26,7 +26,6 @@ Bundle-RequiredExecutionEnvironment: J2SE-1.5
Import-Package: com.jcraft.jsch;version="[0.1.41,0.2.0)",
org.eclipse.egit.core;version="[0.8.0,0.9.0)",
org.eclipse.egit.core.internal.storage;version="[0.8.0,0.9.0)",
- org.eclipse.egit.core.internal.trace;version="0.8.0",
org.eclipse.egit.core.internal.util;version="[0.8.0,0.9.0)",
org.eclipse.egit.core.op;version="[0.8.0,0.9.0)",
org.eclipse.egit.core.project;version="[0.8.0,0.9.0)",
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java
index eeded22..d06b33d 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java
@@ -29,8 +29,8 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.egit.core.internal.trace.GitTraceLocation;
import org.eclipse.egit.core.project.RepositoryMapping;
+import org.eclipse.egit.ui.internal.trace.GitTraceLocation;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jgit.lib.IndexChangedEvent;
@@ -39,12 +39,14 @@ import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.RepositoryListener;
import org.eclipse.jgit.transport.SshSessionFactory;
import org.eclipse.jsch.core.IJSchService;
+import org.eclipse.osgi.service.debug.DebugOptions;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.ui.themes.ITheme;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
/**
* This is a plugin singleton mostly controlling logging.
@@ -167,6 +169,16 @@ public class Activator extends AbstractUIPlugin {
public void start(final BundleContext context) throws Exception {
super.start(context);
+
+ if (isDebugging()) {
+ ServiceTracker debugTracker = new ServiceTracker(context,
+ DebugOptions.class.getName(), null);
+ debugTracker.open();
+
+ DebugOptions opts = (DebugOptions) debugTracker.getService();
+ GitTraceLocation.initializeFromOptions(opts, true);
+ }
+
setupSSH(context);
setupProxy(context);
setupRepoChangeScanner();
@@ -402,4 +414,5 @@ public class Activator extends AbstractUIPlugin {
super.stop(context);
plugin = null;
}
+
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/GitResourceNode.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/GitResourceNode.java
index 1060c53..90a4ed4 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/GitResourceNode.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/GitResourceNode.java
@@ -19,7 +19,7 @@ import org.eclipse.compare.CompareUI;
import org.eclipse.compare.ITypedElement;
import org.eclipse.compare.structuremergeviewer.IStructureComparator;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.egit.core.internal.trace.GitTraceLocation;
+import org.eclipse.egit.ui.internal.trace.GitTraceLocation;
import org.eclipse.swt.graphics.Image;
import org.eclipse.jgit.lib.FileTreeEntry;
import org.eclipse.jgit.lib.ObjectId;
@@ -56,8 +56,8 @@ public class GitResourceNode extends BufferedContent implements IStructureCompar
}
} catch (IOException e) {
// TODO: eclipse error handling
- if (GitTraceLocation.CORE.isActive())
- GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e);
+ if (GitTraceLocation.UI.isActive())
+ GitTraceLocation.getTrace().trace(GitTraceLocation.UI.getLocation(), e.getMessage(), e);
children = new GitResourceNode[0];
}
}
@@ -77,8 +77,8 @@ public class GitResourceNode extends BufferedContent implements IStructureCompar
return new ByteArrayInputStream(bytes);
} catch (IOException e) {
// TODO: eclipse error handling
- if (GitTraceLocation.CORE.isActive())
- GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e);
+ if (GitTraceLocation.UI.isActive())
+ GitTraceLocation.getTrace().trace(GitTraceLocation.UI.getLocation(), e.getMessage(), e);
return null;
}
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/BranchAction.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/BranchAction.java
index d954efe..8c50543 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/BranchAction.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/BranchAction.java
@@ -14,11 +14,11 @@ import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.egit.core.internal.trace.GitTraceLocation;
import org.eclipse.egit.core.op.BranchOperation;
import org.eclipse.egit.ui.UIText;
import org.eclipse.egit.ui.internal.decorators.GitLightweightDecorator;
import org.eclipse.egit.ui.internal.dialogs.BranchSelectionDialog;
+import org.eclipse.egit.ui.internal.trace.GitTraceLocation;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
@@ -63,8 +63,8 @@ public class BranchAction extends RepositoryAction {
new BranchOperation(repository, refName).run(monitor);
GitLightweightDecorator.refresh();
} catch (final CoreException e) {
- if (GitTraceLocation.CORE.isActive())
- GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e);
+ if (GitTraceLocation.UI.isActive())
+ GitTraceLocation.getTrace().trace(GitTraceLocation.UI.getLocation(), e.getMessage(), e);
Display.getDefault().asyncExec(new Runnable() {
public void run() {
handle(
@@ -77,11 +77,11 @@ public class BranchAction extends RepositoryAction {
}
});
} catch (InvocationTargetException e) {
- if (GitTraceLocation.CORE.isActive())
- GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e);
+ if (GitTraceLocation.UI.isActive())
+ GitTraceLocation.getTrace().trace(GitTraceLocation.UI.getLocation(), e.getMessage(), e);
} catch (InterruptedException e) {
- if (GitTraceLocation.CORE.isActive())
- GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e);
+ if (GitTraceLocation.UI.isActive())
+ GitTraceLocation.getTrace().trace(GitTraceLocation.UI.getLocation(), e.getMessage(), e);
}
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitAction.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitAction.java
index d190103..d1cad20 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitAction.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CommitAction.java
@@ -25,11 +25,11 @@ import java.util.TimeZone;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.egit.core.internal.trace.GitTraceLocation;
import org.eclipse.egit.core.project.GitProjectData;
import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.ui.UIText;
import org.eclipse.egit.ui.internal.dialogs.CommitDialog;
+import org.eclipse.egit.ui.internal.trace.GitTraceLocation;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
@@ -410,8 +410,8 @@ public class CommitAction extends RepositoryAction {
"Couldn't find " + filename); //$NON-NLS-1$
}
} catch (Exception e) {
- if (GitTraceLocation.CORE.isActive())
- GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e);
+ if (GitTraceLocation.UI.isActive())
+ GitTraceLocation.getTrace().trace(GitTraceLocation.UI.getLocation(), e.getMessage(), e);
continue;
} // if it's outside the workspace, bad things happen
}
@@ -431,8 +431,8 @@ public class CommitAction extends RepositoryAction {
return true;
}
} catch (Exception e) {
- if (GitTraceLocation.CORE.isActive())
- GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e);
+ if (GitTraceLocation.UI.isActive())
+ GitTraceLocation.getTrace().trace(GitTraceLocation.UI.getLocation(), e.getMessage(), e);
}
return false;
}
@@ -447,11 +447,11 @@ public class CommitAction extends RepositoryAction {
return entry.isModified(map.getWorkDir());
return false;
} catch (UnsupportedEncodingException e) {
- if (GitTraceLocation.CORE.isActive())
- GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e);
+ if (GitTraceLocation.UI.isActive())
+ GitTraceLocation.getTrace().trace(GitTraceLocation.UI.getLocation(), e.getMessage(), e);
} catch (IOException e) {
- if (GitTraceLocation.CORE.isActive())
- GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e);
+ if (GitTraceLocation.UI.isActive())
+ GitTraceLocation.getTrace().trace(GitTraceLocation.UI.getLocation(), e.getMessage(), e);
}
return false;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ResetAction.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ResetAction.java
index c5c67e6..576816c 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ResetAction.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ResetAction.java
@@ -14,12 +14,12 @@ import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.egit.core.internal.trace.GitTraceLocation;
import org.eclipse.egit.core.op.ResetOperation;
import org.eclipse.egit.core.op.ResetOperation.ResetType;
import org.eclipse.egit.ui.UIText;
import org.eclipse.egit.ui.internal.decorators.GitLightweightDecorator;
import org.eclipse.egit.ui.internal.dialogs.BranchSelectionDialog;
+import org.eclipse.egit.ui.internal.trace.GitTraceLocation;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
@@ -60,8 +60,8 @@ public class ResetAction extends RepositoryAction {
new ResetOperation(repository, refName, type).run(monitor);
GitLightweightDecorator.refresh();
} catch (CoreException e) {
- if (GitTraceLocation.CORE.isActive())
- GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e);
+ if (GitTraceLocation.UI.isActive())
+ GitTraceLocation.getTrace().trace(GitTraceLocation.UI.getLocation(), e.getMessage(), e);
throw new InvocationTargetException(e);
}
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitDocument.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitDocument.java
index 14f572f..9b5a43d 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitDocument.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitDocument.java
@@ -16,12 +16,11 @@ import org.eclipse.core.resources.IEncodedStorage;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.egit.core.GitProvider;
-import org.eclipse.egit.core.internal.trace.GitTraceLocation;
import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.UIText;
+import org.eclipse.egit.ui.internal.trace.GitTraceLocation;
import org.eclipse.jface.text.Document;
-import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.jgit.lib.AnyObjectId;
import org.eclipse.jgit.lib.Commit;
import org.eclipse.jgit.lib.Constants;
@@ -34,6 +33,7 @@ import org.eclipse.jgit.lib.RepositoryListener;
import org.eclipse.jgit.lib.Tree;
import org.eclipse.jgit.lib.TreeEntry;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.team.core.RepositoryProvider;
class GitDocument extends Document implements RepositoryListener {
private final IResource resource;
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitQuickDiffProvider.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitQuickDiffProvider.java
index 8b3f8cd..f694b4d 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitQuickDiffProvider.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitQuickDiffProvider.java
@@ -16,9 +16,9 @@ import java.util.WeakHashMap;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.egit.core.internal.trace.GitTraceLocation;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.UIText;
+import org.eclipse.egit.ui.internal.trace.GitTraceLocation;
import org.eclipse.jface.text.IDocument;
import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.ui.IEditorInput;
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
index f34aa65..9491ab0 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
@@ -27,7 +27,6 @@ import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.egit.core.ResourceList;
import org.eclipse.egit.core.internal.storage.GitFileRevision;
-import org.eclipse.egit.core.internal.trace.GitTraceLocation;
import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.UIIcons;
@@ -35,6 +34,7 @@ import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.UIText;
import org.eclipse.egit.ui.internal.EditableRevision;
import org.eclipse.egit.ui.internal.GitCompareFileRevisionEditorInput;
+import org.eclipse.egit.ui.internal.trace.GitTraceLocation;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IAction;
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitProjectPropertyPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitProjectPropertyPage.java
index 82b8dc2..446e96b 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitProjectPropertyPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitProjectPropertyPage.java
@@ -12,9 +12,9 @@ import java.io.IOException;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.egit.core.internal.trace.GitTraceLocation;
import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.ui.UIText;
+import org.eclipse.egit.ui.internal.trace.GitTraceLocation;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -81,8 +81,8 @@ public class GitProjectPropertyPage extends PropertyPage {
try {
fillValues(repository);
} catch (IOException e) {
- if (GitTraceLocation.CORE.isActive())
- GitTraceLocation.getTrace().trace(GitTraceLocation.CORE.getLocation(), e.getMessage(), e);
+ if (GitTraceLocation.UI.isActive())
+ GitTraceLocation.getTrace().trace(GitTraceLocation.UI.getLocation(), e.getMessage(), e);
}
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/trace/DebugTrace.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/trace/DebugTrace.java
new file mode 100644
index 0000000..1bd3d9f
--- /dev/null
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/trace/DebugTrace.java
@@ -0,0 +1,35 @@
+package org.eclipse.egit.ui.internal.trace;
+
+/**
+ * Just a place holder for OSGI Debug Trace support until
+ * we drop 3.4 support in EGit/JGit;
+ *
+ * TODO replace this by OSGI's DebugTrace once we drop 3.4 support
+ */
+public interface DebugTrace {
+
+ /**
+ * @param location
+ * @param message
+ */
+ public void trace(String location, String message);
+
+ /**
+ * @param location
+ * @param message
+ * @param error
+ */
+ public void trace(String location, String message, Throwable error);
+
+ /**
+ * @param location
+ */
+ public void traceEntry(String location);
+
+ /**
+ * @param location
+ * @param message
+ */
+ public void traceEntry(String location, String message);
+
+}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/trace/GitTraceLocation.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/trace/GitTraceLocation.java
new file mode 100644
index 0000000..40682ac
--- /dev/null
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/trace/GitTraceLocation.java
@@ -0,0 +1,145 @@
+/*******************************************************************************
+ * Copyright (c) 2010 SAP AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mathias Kinzler (SAP AG) - initial implementation
+ *******************************************************************************/
+package org.eclipse.egit.ui.internal.trace;
+
+import org.eclipse.core.runtime.ILog;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.egit.ui.Activator;
+import org.eclipse.osgi.service.debug.DebugOptions;
+
+/**
+ * EGit Trace locations
+ */
+public enum GitTraceLocation implements ITraceLocation {
+
+ /** UI */
+ UI("/debug/ui"); //$NON-NLS-1$
+
+ /**
+ * Initialize the locations
+ *
+ * @param options
+ * @param pluginIsDebugging
+ */
+ public static void initializeFromOptions(DebugOptions options,
+ boolean pluginIsDebugging) {
+
+ // we evaluate the plug-in switch
+ if (pluginIsDebugging) {
+ myTrace = new DebugTraceImpl();
+
+ for (GitTraceLocation loc : values()) {
+ boolean active = options.getBooleanOption(loc.getFullPath(),
+ false);
+ loc.setActive(active);
+ }
+ } else {
+ // if the plug-in switch is off, we don't set the trace instance
+ // to null to avoid problems with possibly running trace calls
+ for (GitTraceLocation loc : values()) {
+ loc.setActive(false);
+ }
+ }
+ }
+
+ private final String location;
+
+ private final String fullPath;
+
+ private boolean active = false;
+
+ private static DebugTrace myTrace;
+
+ private GitTraceLocation(String path) {
+ this.fullPath = Activator.getPluginId() + path;
+ this.location = path;
+ }
+
+ /**
+ * Convenience method
+ *
+ * @return the debug trace (may be null)
+ *
+ **/
+ public static DebugTrace getTrace() {
+ return GitTraceLocation.myTrace;
+ }
+
+ /**
+ * @return <code>true</code> if this location is active
+ */
+ public boolean isActive() {
+ return this.active;
+ }
+
+ /**
+ * @return the full path
+ */
+ public String getFullPath() {
+ return this.fullPath;
+ }
+
+ public String getLocation() {
+ return this.location;
+ }
+
+ /**
+ * Sets the "active" flag for this location.
+ * <p>
+ * Used by the initializer
+ *
+ * @param active
+ * the "active" flag
+ */
+ private void setActive(boolean active) {
+ this.active = active;
+ }
+
+ private static final class DebugTraceImpl implements DebugTrace {
+
+ private ILog myLog;
+
+ public void trace(String location, String message) {
+ getLog().log(
+ new Status(IStatus.INFO, Activator.getPluginId(), message));
+
+ }
+
+ public void trace(String location, String message, Throwable error) {
+
+ getLog().log(
+ new Status(IStatus.INFO, Activator.getPluginId(), message));
+ if (error != null)
+ getLog().log(
+ new Status(IStatus.INFO, Activator.getPluginId(), error
+ .getMessage()));
+
+ }
+
+ public void traceEntry(String location) {
+ // not implemented
+ }
+
+ public void traceEntry(String location, String message) {
+ // not implemented
+ }
+
+ private ILog getLog() {
+ if (myLog == null) {
+ myLog = Activator.getDefault().getLog();
+ }
+ return myLog;
+ }
+
+ }
+
+}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/trace/ITraceLocation.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/trace/ITraceLocation.java
new file mode 100644
index 0000000..4301668
--- /dev/null
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/trace/ITraceLocation.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2010 SAP AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mathias Kinzler (SAP AG) - initial implementation
+ *******************************************************************************/
+package org.eclipse.egit.ui.internal.trace;
+
+/**
+ * Helper interface for trace location management
+ * <p>
+ * Additional methods could return a description or such...
+ */
+public interface ITraceLocation {
+
+ /**
+ * @return the location, e.g. "/debug/mainArea/subArea"
+ */
+ public String getLocation();
+
+ /**
+ * @return <code>true</code> if the location is active
+ */
+ public boolean isActive();
+
+}