Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 137091 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse UI/org/eclipse/ui/internal/EditorReference.java (-1 / +1 lines)
Lines 405-411 Link Here
405
            
405
            
406
            EditorSite site = new EditorSite(this, part, manager.page, descr);
406
            EditorSite site = new EditorSite(this, part, manager.page, descr);
407
            
407
            
408
            site.setActionBars(new EditorActionBars(manager.page, site, getId()));
408
            site.setActionBars(new EditorActionBars(manager.page, site.getWorkbenchWindow(), getId()));
409
            try {
409
            try {
410
                part.init(site, input);
410
                part.init(site, input);
411
            } catch (PartInitException e) {
411
            } catch (PartInitException e) {
(-)Eclipse UI/org/eclipse/ui/internal/EditorActionBars.java (-1 / +15 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.internal;
11
package org.eclipse.ui.internal;
12
12
13
import org.eclipse.core.expressions.Expression;
13
import org.eclipse.jface.action.ActionContributionItem;
14
import org.eclipse.jface.action.ActionContributionItem;
14
import org.eclipse.jface.action.ContributionManager;
15
import org.eclipse.jface.action.ContributionManager;
15
import org.eclipse.jface.action.GroupMarker;
16
import org.eclipse.jface.action.GroupMarker;
Lines 31-36 Link Here
31
import org.eclipse.ui.IWorkbenchPart;
32
import org.eclipse.ui.IWorkbenchPart;
32
import org.eclipse.ui.SubActionBars2;
33
import org.eclipse.ui.SubActionBars2;
33
import org.eclipse.ui.actions.RetargetAction;
34
import org.eclipse.ui.actions.RetargetAction;
35
import org.eclipse.ui.internal.expressions.LegacyEditorActionBarExpression;
34
import org.eclipse.ui.internal.misc.Policy;
36
import org.eclipse.ui.internal.misc.Policy;
35
import org.eclipse.ui.internal.provisional.presentations.IActionBarPresentationFactory;
37
import org.eclipse.ui.internal.provisional.presentations.IActionBarPresentationFactory;
36
import org.eclipse.ui.services.IServiceLocator;
38
import org.eclipse.ui.services.IServiceLocator;
Lines 89-94 Link Here
89
	
91
	
90
	private IActionBarPresentationFactory actionBarPresentation;
92
	private IActionBarPresentationFactory actionBarPresentation;
91
93
94
92
	/**
95
	/**
93
	 * Constructs the EditorActionBars for an editor.
96
	 * Constructs the EditorActionBars for an editor.
94
	 */
97
	 */
Lines 327-333 Link Here
327
		super.partChanged(part);
330
		super.partChanged(part);
328
		if (part instanceof IEditorPart) {
331
		if (part instanceof IEditorPart) {
329
			IEditorPart editor = (IEditorPart) part;
332
			IEditorPart editor = (IEditorPart) part;
330
			setServiceLocator(editor.getEditorSite());
331
			if (editorContributor != null) {
333
			if (editorContributor != null) {
332
				editorContributor.setActiveEditor(editor);
334
				editorContributor.setActiveEditor(editor);
333
			}
335
			}
Lines 470-473 Link Here
470
			}
472
			}
471
		}
473
		}
472
	}
474
	}
475
476
	private LegacyEditorActionBarExpression fEditorHandlerExpression = null;
477
	
478
	/* (non-Javadoc)
479
	 * @see org.eclipse.ui.SubActionBars#getHandlerExpression()
480
	 */
481
	protected Expression getHandlerExpression() {
482
		if (fEditorHandlerExpression == null) {
483
			fEditorHandlerExpression = new LegacyEditorActionBarExpression(type);
484
		}
485
		return fEditorHandlerExpression;
486
	}
473
}
487
}
(-)Eclipse UI/org/eclipse/ui/internal/EditorManager.java (-2 / +2 lines)
Lines 301-307 Link Here
301
		}
301
		}
302
302
303
		// Create a new action bar set.
303
		// Create a new action bar set.
304
		actionBars = new EditorActionBars(page, site, type);
304
		actionBars = new EditorActionBars(page, site.getWorkbenchWindow(), type);
305
		actionBars.addRef();
305
		actionBars.addRef();
306
		actionCache.put(type, actionBars);
306
		actionCache.put(type, actionBars);
307
307
Lines 333-339 Link Here
333
333
334
		// Create a new action bar set.
334
		// Create a new action bar set.
335
		// Note: It is an empty set.
335
		// Note: It is an empty set.
336
		EditorActionBars actionBars = new EditorActionBars(page, site, type);
336
		EditorActionBars actionBars = new EditorActionBars(page, site.getWorkbenchWindow(), type);
337
		actionBars.addRef();
337
		actionBars.addRef();
338
		actionCache.put(type, actionBars);
338
		actionCache.put(type, actionBars);
339
339
(-)Eclipse UI/org/eclipse/ui/internal/PartSite.java (+2 lines)
Lines 536-541 Link Here
536
		buffer.append(getPluginId());
536
		buffer.append(getPluginId());
537
		buffer.append(",registeredName="); //$NON-NLS-1$
537
		buffer.append(",registeredName="); //$NON-NLS-1$
538
		buffer.append(getRegisteredName());
538
		buffer.append(getRegisteredName());
539
		buffer.append(",hashCode="); //$NON-NLS-1$
540
		buffer.append(hashCode());
539
		buffer.append(')');
541
		buffer.append(')');
540
		return buffer.toString();
542
		return buffer.toString();
541
	}
543
	}
(-)Eclipse UI/org/eclipse/ui/SubActionBars.java (-5 / +16 lines)
Lines 50-63 Link Here
50
	 * over handlers contributed to the {@link IHandlerService}.
50
	 * over handlers contributed to the {@link IHandlerService}.
51
	 */
51
	 */
52
	private static final Expression EXPRESSION = new Expression() {
52
	private static final Expression EXPRESSION = new Expression() {
53
		public final EvaluationResult evaluate(final IEvaluationContext context) {
54
			return EvaluationResult.TRUE;
55
		}
56
57
		public final void collectExpressionInfo(final ExpressionInfo info) {
53
		public final void collectExpressionInfo(final ExpressionInfo info) {
58
			info
54
			info
59
					.addVariableNameAccess(SourcePriorityNameMapping.LEGACY_LEGACY_NAME);
55
					.addVariableNameAccess(SourcePriorityNameMapping.LEGACY_LEGACY_NAME);
60
		}
56
		}
57
58
		public final EvaluationResult evaluate(final IEvaluationContext context) {
59
			return EvaluationResult.TRUE;
60
		}
61
	};
61
	};
62
62
63
	/**
63
	/**
Lines 317-322 Link Here
317
	}
317
	}
318
318
319
	/**
319
	/**
320
	 * The expression used for action handler activation. This method should not
321
	 * be extended or overridden by subclasses.
322
	 * 
323
	 * @return the expression for use with action handler activation.
324
	 * @since 3.2
325
	 */
326
	protected Expression getHandlerExpression() {
327
		return EXPRESSION;
328
	}
329
330
	/**
320
	 * Returns the abstract menu manager. If items are added or removed from the
331
	 * Returns the abstract menu manager. If items are added or removed from the
321
	 * manager be sure to call <code>updateActionBars</code>.
332
	 * manager be sure to call <code>updateActionBars</code>.
322
	 * 
333
	 * 
Lines 506-512 Link Here
506
					final IHandler actionHandler = new ActionHandler(handler);
517
					final IHandler actionHandler = new ActionHandler(handler);
507
					final IHandlerActivation activation = service
518
					final IHandlerActivation activation = service
508
							.activateHandler(commandId, actionHandler,
519
							.activateHandler(commandId, actionHandler,
509
									EXPRESSION);
520
									getHandlerExpression());
510
					activationsByActionId.put(actionID, activation);
521
					activationsByActionId.put(actionID, activation);
511
				}
522
				}
512
			}
523
			}
(-)Eclipse (+109 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
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
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
12
package org.eclipse.ui.internal.expressions;
13
14
import org.eclipse.core.expressions.EvaluationResult;
15
import org.eclipse.core.expressions.Expression;
16
import org.eclipse.core.expressions.ExpressionInfo;
17
import org.eclipse.core.expressions.IEvaluationContext;
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.ui.ISources;
20
import org.eclipse.ui.internal.services.SourcePriorityNameMapping;
21
22
/**
23
 * <p>
24
 * An expression representing the <code>part id</code> of the legacy editor
25
 * action bar contribution.
26
 * </p>
27
 * <p>
28
 * This class is not intended for use outside of the
29
 * <code>org.eclipse.ui.workbench</code> plug-in.
30
 * </p>
31
 * 
32
 * @since 3.2
33
 */
34
public class LegacyEditorActionBarExpression extends Expression {
35
	/**
36
	 * The seed for the hash code for all schemes.
37
	 */
38
	private static final int HASH_INITIAL = LegacyEditorActionBarExpression.class
39
			.getName().hashCode();
40
41
	/**
42
	 * The identifier for the editor that must be active for this expression to
43
	 * evaluate to <code>true</code>. This value is never <code>null</code>.
44
	 */
45
	private final String fActiveEditorId;
46
47
	/**
48
	 * Constructs a new instance of <code>LegacyEditorActionBarExpression</code>
49
	 * 
50
	 * @param activeEditorId
51
	 *            The identifier of the editor to match with the active editor;
52
	 *            must not be <code>null</code>
53
	 */
54
	public LegacyEditorActionBarExpression(final String activeEditorId) {
55
56
		if (activeEditorId == null) {
57
			throw new NullPointerException(
58
					"The targetId for an editor contribution must not be null"); //$NON-NLS-1$
59
		}
60
		fActiveEditorId = activeEditorId;
61
	}
62
63
	public final void collectExpressionInfo(final ExpressionInfo info) {
64
		info.addVariableNameAccess(ISources.ACTIVE_EDITOR_ID_NAME);
65
		info
66
				.addVariableNameAccess(SourcePriorityNameMapping.LEGACY_LEGACY_NAME);
67
	}
68
69
	protected final int computeHashCode() {
70
		int hashCode = HASH_INITIAL * HASH_FACTOR + hashCode(fActiveEditorId);
71
		return hashCode;
72
	}
73
74
	public final boolean equals(final Object object) {
75
		if (object instanceof LegacyEditorActionBarExpression) {
76
			final LegacyEditorActionBarExpression that = (LegacyEditorActionBarExpression) object;
77
			return equals(fActiveEditorId, that.fActiveEditorId);
78
		}
79
80
		return false;
81
	}
82
83
	/*
84
	 * (non-Javadoc)
85
	 * 
86
	 * @see org.eclipse.core.expressions.Expression#evaluate(org.eclipse.core.expressions.IEvaluationContext)
87
	 */
88
	public final EvaluationResult evaluate(final IEvaluationContext context)
89
			throws CoreException {
90
		if ("org.eclipse.jdt.ui.CompilationUnitEditor".equals(fActiveEditorId)) { //$NON-NLS-1$
91
			System.out.println();
92
		}
93
94
		final Object variable = context
95
				.getVariable(ISources.ACTIVE_EDITOR_ID_NAME);
96
		if (equals(fActiveEditorId, variable)) {
97
			return EvaluationResult.TRUE;
98
		}
99
		return EvaluationResult.FALSE;
100
	}
101
102
	public final String toString() {
103
		final StringBuffer buffer = new StringBuffer();
104
		buffer.append("LegacyEditorActionBarExpression("); //$NON-NLS-1$
105
		buffer.append(fActiveEditorId);
106
		buffer.append(')');
107
		return buffer.toString();
108
	}
109
}

Return to bug 137091