Create index diff only once per repository
[egit/spearce.git] / org.eclipse.egit.core / src / org / eclipse / egit / core / internal / trace / GitTraceLocation.java
blob92f8510f19e01d83a017ed13321b4a27f3adcf01
1 /*******************************************************************************
2 * Copyright (c) 2010 SAP AG.
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
8 * Contributors:
9 * Mathias Kinzler (SAP AG) - initial implementation
10 *******************************************************************************/
11 package org.eclipse.egit.core.internal.trace;
13 import org.eclipse.egit.core.Activator;
14 import org.eclipse.osgi.service.debug.DebugOptions;
15 import org.eclipse.osgi.service.debug.DebugTrace;
17 /**
18 * EGit Trace locations
21 public enum GitTraceLocation implements ITraceLocation {
22 /** Core */
23 CORE("/debug/core"), //$NON-NLS-1$
24 /** UI */
25 UI("/debug/ui"); //$NON-NLS-1$
27 /**
28 * Initialize the locations
30 * @param options
31 * @param pluginIsDebugging
33 public static void initializeFromOptions(DebugOptions options, boolean pluginIsDebugging) {
35 // we evaluate the plug-in switch
36 if (pluginIsDebugging) {
37 myTrace = options.newDebugTrace(Activator.getPluginId());
38 for (GitTraceLocation loc : values()) {
39 boolean active = options.getBooleanOption(loc.getFullPath(), false);
40 loc.setActive(active);
42 } else {
43 // if the plug-in switch is off, we don't set the trace instance
44 // to null to avoid problems with possibly running trace calls
45 for (GitTraceLocation loc : values()) {
46 loc.setActive(false);
51 private final String location;
52 private final String fullPath;
54 private boolean active = false;
55 private static DebugTrace myTrace;
57 private GitTraceLocation(String path) {
58 this.fullPath = Activator.getPluginId() + path;
59 this.location = path;
62 /**
63 * Convenience method
65 * @return the debug trace (may be null)
67 **/
68 public static DebugTrace getTrace() {
69 return GitTraceLocation.myTrace;
72 /**
74 * @return <code>true</code> if this location is active
76 public boolean isActive() {
77 return this.active;
80 /**
81 * @return the full path
83 public String getFullPath() {
84 return this.fullPath;
87 public String getLocation() {
88 return this.location;
91 /**
92 * Sets the "active" flag for this location.
93 * <p>
94 * Used by the initializer
96 * @param active
97 * the "active" flag
99 private void setActive(boolean active) {
100 this.active = active;