### Eclipse Workspace Patch 1.0
#P org.eclipse.ui.workbench
Index: Eclipse UI/org/eclipse/ui/internal/handlers/HandlerAuthority.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/HandlerAuthority.java,v
retrieving revision 1.24
diff -u -r1.24 HandlerAuthority.java
--- Eclipse UI/org/eclipse/ui/internal/handlers/HandlerAuthority.java 11 Apr 2006 13:53:54 -0000 1.24
+++ Eclipse UI/org/eclipse/ui/internal/handlers/HandlerAuthority.java 3 May 2006 14:08:06 -0000
@@ -11,7 +11,10 @@
package org.eclipse.ui.internal.handlers;
+import java.io.PrintWriter;
+import java.io.StringWriter;
import java.util.Collection;
+import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -22,8 +25,14 @@
import org.eclipse.core.commands.Command;
import org.eclipse.core.commands.util.Tracing;
import org.eclipse.core.expressions.Expression;
+import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.ISources;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.LegacyHandlerSubmissionExpression;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.handlers.IHandlerActivation;
import org.eclipse.ui.internal.misc.Policy;
@@ -65,31 +74,31 @@
* This causes the unresolvable handler conflicts to be printed to the
* console.
*/
- private static final boolean DEBUG = Policy.DEBUG_HANDLERS;
+ public static final boolean DEBUG = Policy.DEBUG_HANDLERS;
/**
* Whether the performance information should be printed about the
* performance of the handler authority.
*/
- private static final boolean DEBUG_PERFORMANCE = Policy.DEBUG_HANDLERS_PERFORMANCE;
+ public static final boolean DEBUG_PERFORMANCE = Policy.DEBUG_HANDLERS_PERFORMANCE;
/**
* Whether the workbench command support should kick into verbose debugging
* mode. This causes the resolvable handler conflicts to be printed to the
* console.
*/
- private static final boolean DEBUG_VERBOSE = Policy.DEBUG_HANDLERS
+ public static final boolean DEBUG_VERBOSE = Policy.DEBUG_HANDLERS
&& Policy.DEBUG_HANDLERS_VERBOSE;
/**
* The command identifier to which the verbose output should be restricted.
*/
- private static final String DEBUG_VERBOSE_COMMAND_ID = Policy.DEBUG_HANDLERS_VERBOSE_COMMAND_ID;
+ public static final String DEBUG_VERBOSE_COMMAND_ID = Policy.DEBUG_HANDLERS_VERBOSE_COMMAND_ID;
/**
* The component name to print when displaying tracing information.
*/
- private static final String TRACING_COMPONENT = "HANDLERS"; //$NON-NLS-1$
+ public static final String TRACING_COMPONENT = "HANDLERS"; //$NON-NLS-1$
/**
* A bucket sort of the handler activations based on source priority of its
@@ -117,6 +126,14 @@
*/
private final Map handlerActivationsByCommandId = new HashMap();
+ private IHandlerActivation tracingNullHandlerActivation;
+
+ private Exception tracingNullStack;
+
+ private Date sourceChangedStamp;
+
+ private Date resolveConflictsStamp;
+
/**
* Constructs a new instance of HandlerAuthority
.
*
@@ -149,6 +166,9 @@
final SortedSet handlerActivations = (SortedSet) value;
if (!handlerActivations.contains(activation)) {
handlerActivations.add(activation);
+ tracingNullHandlerActivation = activation;
+ tracingNullStack = new Exception();
+ tracingNullStack.fillInStackTrace();
updateCommand(commandId, resolveConflicts(commandId,
handlerActivations));
}
@@ -160,11 +180,17 @@
handlerActivations.add(activation);
handlerActivationsByCommandId
.put(commandId, handlerActivations);
+ tracingNullHandlerActivation = activation;
+ tracingNullStack = new Exception();
+ tracingNullStack.fillInStackTrace();
updateCommand(commandId, resolveConflicts(commandId,
handlerActivations));
}
} else {
handlerActivationsByCommandId.put(commandId, activation);
+ tracingNullHandlerActivation = activation;
+ tracingNullStack = new Exception();
+ tracingNullStack.fillInStackTrace();
updateCommand(commandId, (evaluate(activation) ? activation : null));
}
@@ -208,6 +234,9 @@
handlerActivations.remove(activation);
if (handlerActivations.isEmpty()) {
handlerActivationsByCommandId.remove(commandId);
+ tracingNullHandlerActivation = activation;
+ tracingNullStack = new Exception();
+ tracingNullStack.fillInStackTrace();
updateCommand(commandId, null);
} else if (handlerActivations.size() == 1) {
@@ -215,12 +244,19 @@
.iterator().next();
handlerActivationsByCommandId.put(commandId,
remainingActivation);
+ tracingNullHandlerActivation = remainingActivation;
+ tracingNullStack = new Exception();
+ tracingNullStack.fillInStackTrace();
+
updateCommand(
commandId,
(evaluate(remainingActivation) ? remainingActivation
: null));
} else {
+ tracingNullHandlerActivation = activation;
+ tracingNullStack = new Exception();
+ tracingNullStack.fillInStackTrace();
updateCommand(commandId, resolveConflicts(commandId,
handlerActivations));
}
@@ -228,6 +264,9 @@
} else if (value instanceof IHandlerActivation) {
if (value == activation) {
handlerActivationsByCommandId.remove(commandId);
+ tracingNullHandlerActivation = activation;
+ tracingNullStack = new Exception();
+ tracingNullStack.fillInStackTrace();
updateCommand(commandId, null);
}
}
@@ -286,9 +325,16 @@
final SortedSet activations) {
// If we don't have any, then there is no match.
if (activations.isEmpty()) {
+ if ((DEBUG_VERBOSE)
+ && ((DEBUG_VERBOSE_COMMAND_ID == null) || (DEBUG_VERBOSE_COMMAND_ID
+ .equals(commandId)))) {
+ Tracing.printTrace(TRACING_COMPONENT, " rc-empty"); //$NON-NLS-1$
+ }
return null;
}
+ resolveConflictsStamp = new Date();
+
// Cycle over the activations, remembered the current best.
final Iterator activationItr = activations.iterator();
IHandlerActivation bestActivation = null;
@@ -296,6 +342,12 @@
while (activationItr.hasNext()) {
final IHandlerActivation currentActivation = (IHandlerActivation) activationItr
.next();
+ if ((DEBUG_VERBOSE)
+ && ((DEBUG_VERBOSE_COMMAND_ID == null) || (DEBUG_VERBOSE_COMMAND_ID
+ .equals(commandId)))) {
+ Tracing.printTrace(TRACING_COMPONENT, " rc-con : " + currentActivation); //$NON-NLS-1$
+ }
+
if (!evaluate(currentActivation)) {
continue; // only consider potentially active handlers
}
@@ -304,7 +356,7 @@
if ((DEBUG_VERBOSE)
&& ((DEBUG_VERBOSE_COMMAND_ID == null) || (DEBUG_VERBOSE_COMMAND_ID
.equals(commandId)))) {
- Tracing.printTrace(TRACING_COMPONENT, " resolveConflicts: eval: " + currentActivation); //$NON-NLS-1$
+ Tracing.printTrace(TRACING_COMPONENT, " rc-eval: " + currentActivation); //$NON-NLS-1$
}
if (bestActivation == null) {
bestActivation = currentActivation;
@@ -346,6 +398,57 @@
}
}
+ if ((DEBUG_VERBOSE)
+ && ((DEBUG_VERBOSE_COMMAND_ID == null) || (DEBUG_VERBOSE_COMMAND_ID
+ .equals(commandId)))) {
+ if (conflict || bestActivation == null) {
+
+ IWorkbenchWindow wwin = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow();
+ if (wwin == null) {
+ Tracing.printTrace(TRACING_COMPONENT, " wwin is null"); //$NON-NLS-1$
+ return null;
+ }
+ IWorkbenchPage ap = wwin.getActivePage();
+ if (ap == null) {
+ Tracing.printTrace(TRACING_COMPONENT, " ap is null"); //$NON-NLS-1$
+ return null;
+ }
+ IEditorPart ae = ap.getActiveEditor();
+ if (ae == null) {
+ Tracing.printTrace(TRACING_COMPONENT, " ae is null"); //$NON-NLS-1$
+ } else {
+ boolean foundOne = false;
+ for (Iterator it = activations.iterator(); it.hasNext();) {
+ IHandlerActivation activation = (IHandlerActivation) it
+ .next();
+ Expression ex = activation.getExpression();
+ if (ex == null) {
+ Tracing.printTrace(TRACING_COMPONENT,
+ " ex is null : " + activation); //$NON-NLS-1$
+ } else {
+ if (!(ex instanceof LegacyHandlerSubmissionExpression)) {
+ Tracing
+ .printTrace(
+ TRACING_COMPONENT,
+ " ex is not instanceof LegacyHandlerSubmissionExpression: " + activation); //$NON-NLS-1$
+ } else {
+ LegacyHandlerSubmissionExpression lhex = (LegacyHandlerSubmissionExpression) ex;
+
+ if (lhex.activeSite == ae.getSite()) {
+ printTracing(wwin, ae, activation);
+ foundOne = true;
+ }
+ }
+ }
+ }
+ if (!foundOne) {
+ Tracing.printTrace(TRACING_COMPONENT,
+ " Did not find matching handler activation"); //$NON-NLS-1$
+ }
+ }
+ }
+ }
// Return the current best.
if (conflict) {
return null;
@@ -354,6 +457,46 @@
}
/**
+ * @param wwin
+ * @param ae
+ * @param activation
+ */
+ private void printTracing(IWorkbenchWindow wwin, IEditorPart ae,
+ IHandlerActivation activation) {
+
+ Tracing.printTrace(TRACING_COMPONENT,
+ " found matching handler activation: " + activation); //$NON-NLS-1$
+ ((HandlerActivation) activation).traceStamps();
+ long sc = (sourceChangedStamp==null?0L:sourceChangedStamp.getTime());
+ long rc = (resolveConflictsStamp==null?0L:resolveConflictsStamp.getTime());
+
+ Tracing
+ .printTrace(
+ TRACING_COMPONENT,
+ "\tsourceChanged: " + sc //$NON-NLS-1$
+ + " resolveConflicts: " + rc); //$NON-NLS-1$
+ Tracing
+ .printTrace(
+ TRACING_COMPONENT,
+ " matching handler activation evaluates to: " + evaluate(activation)); //$NON-NLS-1$
+
+
+ IEvaluationContext currentContext = getCurrentState();
+ Object cShell = currentContext.getVariable(ISources.ACTIVE_SHELL_NAME);
+ Object cSite = currentContext.getVariable(ISources.ACTIVE_SITE_NAME);
+ Tracing.printTrace(TRACING_COMPONENT, " current context shell: " //$NON-NLS-1$
+ + cShell + "\n\tshell-match: " //$NON-NLS-1$
+ + (cShell == wwin.getShell()));
+ Tracing.printTrace(TRACING_COMPONENT, " current context site: " //$NON-NLS-1$
+ + cSite + "\n\tsite-match: " //$NON-NLS-1$
+ + (cSite == ae.getSite()));
+
+ activation.clearResult();
+ Tracing.printTrace(TRACING_COMPONENT, " forced evaluation: " //$NON-NLS-1$
+ + evaluate(activation));
+ }
+
+ /**
* Carries out the actual source change notification. It assumed that by the
* time this method is called, context
is up-to-date with the
* current state of the application.
@@ -367,6 +510,8 @@
if (DEBUG_PERFORMANCE) {
startTime = System.currentTimeMillis();
}
+
+ sourceChangedStamp = new Date();
/*
* In this first phase, we cycle through all of the activations that
@@ -429,13 +574,22 @@
final Object value = handlerActivationsByCommandId.get(commandId);
if (value instanceof IHandlerActivation) {
final IHandlerActivation activation = (IHandlerActivation) value;
+ tracingNullHandlerActivation = activation;
+ tracingNullStack = new Exception();
+ tracingNullStack.fillInStackTrace();
updateCommand(commandId, (evaluate(activation) ? activation
: null));
} else if (value instanceof SortedSet) {
final IHandlerActivation activation = resolveConflicts(
commandId, (SortedSet) value);
+ tracingNullHandlerActivation = activation;
+ tracingNullStack = new Exception();
+ tracingNullStack.fillInStackTrace();
updateCommand(commandId, activation);
} else {
+ tracingNullHandlerActivation = null;
+ tracingNullStack = new Exception();
+ tracingNullStack.fillInStackTrace();
updateCommand(commandId, null);
}
}
@@ -465,8 +619,24 @@
final IHandlerActivation activation) {
final Command command = commandService.getCommand(commandId);
if (activation == null) {
+ if ((DEBUG_VERBOSE)
+ && ((DEBUG_VERBOSE_COMMAND_ID == null) || (DEBUG_VERBOSE_COMMAND_ID
+ .equals(commandId)))) {
+ Tracing.printTrace(TRACING_COMPONENT, "updateCommand: - " + tracingNullHandlerActivation); //$NON-NLS-1$
+ StringWriter wout = new StringWriter();
+ tracingNullStack.printStackTrace(new PrintWriter(wout));
+ Tracing.printTrace(TRACING_COMPONENT, "updateCommand: n " + wout.toString()); //$NON-NLS-1$
+ }
command.setHandler(null);
} else {
+ if ((DEBUG_VERBOSE)
+ && ((DEBUG_VERBOSE_COMMAND_ID == null) || (DEBUG_VERBOSE_COMMAND_ID
+ .equals(commandId)))) {
+ Tracing.printTrace(TRACING_COMPONENT, "updateCommand: + " + tracingNullHandlerActivation); //$NON-NLS-1$
+ StringWriter wout = new StringWriter();
+ tracingNullStack.printStackTrace(new PrintWriter(wout));
+ Tracing.printTrace(TRACING_COMPONENT, "updateCommand: s " + wout.toString()); //$NON-NLS-1$
+ }
command.setHandler(activation.getHandler());
}
}
Index: Eclipse UI/org/eclipse/ui/internal/handlers/HandlerActivation.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/HandlerActivation.java,v
retrieving revision 1.8
diff -u -r1.8 HandlerActivation.java
--- Eclipse UI/org/eclipse/ui/internal/handlers/HandlerActivation.java 18 Jan 2006 19:37:29 -0000 1.8
+++ Eclipse UI/org/eclipse/ui/internal/handlers/HandlerActivation.java 3 May 2006 14:08:05 -0000
@@ -11,7 +11,12 @@
package org.eclipse.ui.internal.handlers;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Date;
+
import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.commands.util.Tracing;
import org.eclipse.core.expressions.Expression;
import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.ui.ISources;
@@ -59,6 +64,16 @@
*/
private final IHandlerService handlerService;
+ private Date clearStamp;
+
+ private Date evaluateStamp;
+
+ private Date setStamp;
+
+ private Object cShell;
+
+ private Object cSite;
+
/**
* Constructs a new instance of HandlerActivation
.
*
@@ -123,6 +138,18 @@
final int thisDepth = this.getDepth();
final int thatDepth = activation.getDepth();
difference = thatDepth - thisDepth;
+ if (difference==0 && this!=activation) {
+ if ((HandlerAuthority.DEBUG_VERBOSE)
+ && ((HandlerAuthority.DEBUG_VERBOSE_COMMAND_ID == null) || (HandlerAuthority.DEBUG_VERBOSE_COMMAND_ID
+ .equals(commandId)))) {
+ StringWriter wout = new StringWriter();
+ Exception e = new Exception();
+ e.fillInStackTrace();
+ e.printStackTrace(new PrintWriter(wout));
+ Tracing.printTrace(HandlerAuthority.TRACING_COMPONENT, "compareTo returns 0 at " //$NON-NLS-1$
+ + wout.toString());
+ }
+ }
return difference;
}
@@ -161,4 +188,52 @@
return buffer.toString();
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.internal.services.EvaluationResultCache#clearResult()
+ */
+ public void clearResult() {
+ clearStamp = new Date();
+ super.clearResult();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.internal.services.EvaluationResultCache#evaluate(org.eclipse.core.expressions.IEvaluationContext)
+ */
+ public boolean evaluate(IEvaluationContext context) {
+ if (getExpression() != null && evaluationResult == null) {
+ cShell = context.getVariable(ISources.ACTIVE_SHELL_NAME);
+ cSite = context.getVariable(ISources.ACTIVE_SITE_NAME);
+ evaluateStamp = new Date();
+ }
+ return super.evaluate(context);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.internal.services.EvaluationResultCache#setResult(boolean)
+ */
+ public void setResult(boolean result) {
+ setStamp = new Date();
+ super.setResult(result);
+ }
+
+ /**
+ *
+ */
+ public void traceStamps() {
+ if ((HandlerAuthority.DEBUG_VERBOSE)
+ && ((HandlerAuthority.DEBUG_VERBOSE_COMMAND_ID == null) || (HandlerAuthority.DEBUG_VERBOSE_COMMAND_ID
+ .equals(commandId)))) {
+ long eval = (evaluateStamp==null?0L:evaluateStamp.getTime());
+ long set = (setStamp==null?0L:setStamp.getTime());
+ long clear = (clearStamp==null?0L:clearStamp.getTime());
+ Tracing.printTrace(HandlerAuthority.TRACING_COMPONENT,
+ " activation-eval: " + eval //$NON-NLS-1$
+ + " activation-set: " + set //$NON-NLS-1$
+ + " activation-clean: " + clear); //$NON-NLS-1$
+ Tracing.printTrace(HandlerAuthority.TRACING_COMPONENT,
+ " last evaluate used shell: " + cShell //$NON-NLS-1$
+ + " site: " + cSite); //$NON-NLS-1$
+ }
+ }
}
Index: Eclipse UI/org/eclipse/ui/LegacyHandlerSubmissionExpression.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/LegacyHandlerSubmissionExpression.java,v
retrieving revision 1.9
diff -u -r1.9 LegacyHandlerSubmissionExpression.java
--- Eclipse UI/org/eclipse/ui/LegacyHandlerSubmissionExpression.java 21 Apr 2006 20:43:38 -0000 1.9
+++ Eclipse UI/org/eclipse/ui/LegacyHandlerSubmissionExpression.java 3 May 2006 14:08:05 -0000
@@ -52,7 +52,7 @@
* true
. If this value is null
, then any
* site may be active.
*/
- private final IWorkbenchPartSite activeSite;
+ public final IWorkbenchPartSite activeSite;
/**
* Constructs a new instance of
Index: Eclipse UI/org/eclipse/ui/part/MultiPageEditorPart.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/MultiPageEditorPart.java,v
retrieving revision 1.37
diff -u -r1.37 MultiPageEditorPart.java
--- Eclipse UI/org/eclipse/ui/part/MultiPageEditorPart.java 21 Apr 2006 20:43:38 -0000 1.37
+++ Eclipse UI/org/eclipse/ui/part/MultiPageEditorPart.java 3 May 2006 14:08:06 -0000
@@ -806,8 +806,11 @@
*/
public Object getAdapter(Class adapter) {
Object result = super.getAdapter(adapter);
- if (result == null && getActiveEditor() != null) {
- result = getActiveEditor().getAdapter(adapter);
+ if (result == null) {
+ IEditorPart innerEditor = getActiveEditor();
+ if (innerEditor != null && innerEditor != this) {
+ result = innerEditor.getAdapter(adapter);
+ }
}
return result;
}
Index: Eclipse UI/org/eclipse/ui/internal/PartSite.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartSite.java,v
retrieving revision 1.85
diff -u -r1.85 PartSite.java
--- Eclipse UI/org/eclipse/ui/internal/PartSite.java 24 Feb 2006 18:36:13 -0000 1.85
+++ Eclipse UI/org/eclipse/ui/internal/PartSite.java 3 May 2006 14:08:05 -0000
@@ -536,6 +536,8 @@
buffer.append(getPluginId());
buffer.append(",registeredName="); //$NON-NLS-1$
buffer.append(getRegisteredName());
+ buffer.append(",hashCode="); //$NON-NLS-1$
+ buffer.append(hashCode());
buffer.append(')');
return buffer.toString();
}
Index: Eclipse UI/org/eclipse/ui/internal/services/EvaluationResultCache.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/services/EvaluationResultCache.java,v
retrieving revision 1.7
diff -u -r1.7 EvaluationResultCache.java
--- Eclipse UI/org/eclipse/ui/internal/services/EvaluationResultCache.java 24 Feb 2006 18:36:23 -0000 1.7
+++ Eclipse UI/org/eclipse/ui/internal/services/EvaluationResultCache.java 3 May 2006 14:08:06 -0000
@@ -32,7 +32,7 @@
* The previous computed evaluation result. If no evaluation result is
* available, then this value is null
.
*/
- private EvaluationResult evaluationResult = null;
+ public EvaluationResult evaluationResult = null;
/**
* The expression to evaluate. This value may be null
, in
@@ -60,11 +60,11 @@
.computeSourcePriority(expression);
}
- public final void clearResult() {
+ public void clearResult() {
evaluationResult = null;
}
- public final boolean evaluate(final IEvaluationContext context) {
+ public boolean evaluate(final IEvaluationContext context) {
if (expression == null) {
return true;
}
@@ -100,7 +100,7 @@
* @param result
* The cached result to use.
*/
- public final void setResult(final boolean result) {
+ public void setResult(final boolean result) {
if (result) {
evaluationResult = EvaluationResult.TRUE;
} else {