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 249995 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse UI Tests/org/eclipse/ui/tests/contexts/ContextsTestSuite.java (+1 lines)
Lines 39-43 Link Here
39
        addTestSuite(Bug84763Test.class);
39
        addTestSuite(Bug84763Test.class);
40
        addTestSuite(ExtensionTestCase.class);
40
        addTestSuite(ExtensionTestCase.class);
41
        addTestSuite(PartContextTest.class);
41
        addTestSuite(PartContextTest.class);
42
        addTestSuite(Bug249995Test.class);
42
    }
43
    }
43
}
44
}
(-)Eclipse (+55 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 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.tests.contexts;
13
14
import java.lang.reflect.Field;
15
import java.util.Map;
16
import java.util.Set;
17
18
import org.eclipse.ui.IWorkbenchWindow;
19
import org.eclipse.ui.contexts.IContextService;
20
import org.eclipse.ui.internal.contexts.SlaveContextService;
21
import org.eclipse.ui.tests.harness.util.UITestCase;
22
23
/**
24
 * @since 3.5
25
 * 
26
 */
27
public class Bug249995Test extends UITestCase {
28
	public Bug249995Test(String test) {
29
		super(test);
30
	}
31
32
	public void testMultipleSlaveActivations() throws Exception {
33
		IWorkbenchWindow window = getWorkbench().getActiveWorkbenchWindow();
34
		IContextService cs = (IContextService) window
35
				.getService(IContextService.class);
36
		assertTrue(cs instanceof SlaveContextService);
37
		Field localActivationsField = SlaveContextService.class
38
				.getDeclaredField("fLocalActivations");
39
		localActivationsField.setAccessible(true);
40
		Field parentActivationsField = SlaveContextService.class
41
				.getDeclaredField("fParentActivations");
42
		parentActivationsField.setAccessible(true);
43
44
		Map local = (Map) localActivationsField.get(cs);
45
		int localStart = local.size();
46
		Set parent = (Set) parentActivationsField.get(cs);
47
		int parentStart = parent.size();
48
		for (int i = 0; i < 5; i++) {
49
			window.getActivePage().hideActionSet(
50
					"org.eclipse.ui.tests.contexts.Bug249995Test");
51
			assertEquals("on: " + i, localStart, local.size());
52
			assertEquals("on: " + i, parentStart, parent.size());
53
		}
54
	}
55
}
(-)Eclipse UI/org/eclipse/ui/internal/contexts/ContextService.java (-2 / +14 lines)
Lines 49-54 Link Here
49
	 */
49
	 */
50
	private final ContextPersistence contextPersistence;
50
	private final ContextPersistence contextPersistence;
51
51
52
	private ContextActivation SEND_ACTIVATION;
53
54
	private ContextActivation DEFER_ACTIVATION;
55
52
	/**
56
	/**
53
	 * Constructs a new instance of <code>ContextService</code> using a
57
	 * Constructs a new instance of <code>ContextService</code> using a
54
	 * context manager.
58
	 * context manager.
Lines 64-69 Link Here
64
		this.contextManager = contextManager;
68
		this.contextManager = contextManager;
65
		this.contextAuthority = new ContextAuthority(contextManager, this);
69
		this.contextAuthority = new ContextAuthority(contextManager, this);
66
		this.contextPersistence = new ContextPersistence(contextManager);
70
		this.contextPersistence = new ContextPersistence(contextManager);
71
		SEND_ACTIVATION = new ContextActivation(ContextAuthority.SEND_EVENTS, null, this);
72
		DEFER_ACTIVATION = new ContextActivation(ContextAuthority.DEFER_EVENTS, null, this);
67
	}
73
	}
68
74
69
	/*
75
	/*
Lines 83-90 Link Here
83
	 */
89
	 */
84
	public final IContextActivation activateContext(final String contextId,
90
	public final IContextActivation activateContext(final String contextId,
85
			final Expression expression) {
91
			final Expression expression) {
86
		final IContextActivation activation = new ContextActivation(contextId,
92
		final IContextActivation activation;
87
				expression, this);
93
		if (ContextAuthority.SEND_EVENTS.equals(contextId)) {
94
			activation = SEND_ACTIVATION;
95
		} else if (ContextAuthority.DEFER_EVENTS.equals(contextId)) {
96
			activation = DEFER_ACTIVATION;
97
		} else {
98
			activation = new ContextActivation(contextId, expression, this);
99
		}
88
		contextAuthority.activateContext(activation);
100
		contextAuthority.activateContext(activation);
89
		return activation;
101
		return activation;
90
	}
102
	}
(-)Eclipse UI/org/eclipse/ui/internal/contexts/SlaveContextService.java (-5 / +24 lines)
Lines 86-91 Link Here
86
	 */
86
	 */
87
	private Collection fRegisteredShells;
87
	private Collection fRegisteredShells;
88
88
89
	private ContextActivation SEND_ACTIVATION;
90
91
	private ContextActivation DEFER_ACTIVATION;
92
89
	/**
93
	/**
90
	 * Construct the new slave.
94
	 * Construct the new slave.
91
	 * 
95
	 * 
Lines 109-114 Link Here
109
		fContextManagerListeners = new ArrayList();
113
		fContextManagerListeners = new ArrayList();
110
		fSourceProviders = new ArrayList();
114
		fSourceProviders = new ArrayList();
111
		fRegisteredShells = new ArrayList();
115
		fRegisteredShells = new ArrayList();
116
		SEND_ACTIVATION = new ContextActivation(ContextAuthority.SEND_EVENTS, null, this);
117
		DEFER_ACTIVATION = new ContextActivation(ContextAuthority.DEFER_EVENTS, null, this);
112
	}
118
	}
113
119
114
	/*
120
	/*
Lines 117-124 Link Here
117
	 * @see org.eclipse.ui.contexts.IContextService#activateContext(java.lang.String)
123
	 * @see org.eclipse.ui.contexts.IContextService#activateContext(java.lang.String)
118
	 */
124
	 */
119
	public IContextActivation activateContext(String contextId) {
125
	public IContextActivation activateContext(String contextId) {
120
		ContextActivation activation = new ContextActivation(contextId,
126
		final ContextActivation activation;
121
				fDefaultExpression, this);
127
		if (ContextAuthority.SEND_EVENTS.equals(contextId)) {
128
			activation = SEND_ACTIVATION;
129
		} else if (ContextAuthority.DEFER_EVENTS.equals(contextId)) {
130
			activation = DEFER_ACTIVATION;
131
		} else {
132
			activation = new ContextActivation(contextId, fDefaultExpression,
133
					this);
134
		}
122
		return doActivateContext(activation);
135
		return doActivateContext(activation);
123
	}
136
	}
124
137
Lines 156-166 Link Here
156
				andExpression.add(expression);
169
				andExpression.add(expression);
157
			}
170
			}
158
		}
171
		}
159
		if (fDefaultExpression!=null) {
172
		if (fDefaultExpression != null) {
160
			andExpression.add(fDefaultExpression);
173
			andExpression.add(fDefaultExpression);
161
		}
174
		}
162
		ContextActivation activation = new ContextActivation(contextId,
175
		final ContextActivation activation;
163
				andExpression, this);
176
		if (ContextAuthority.SEND_EVENTS.equals(contextId)) {
177
			activation = SEND_ACTIVATION;
178
		} else if (ContextAuthority.DEFER_EVENTS.equals(contextId)) {
179
			activation = DEFER_ACTIVATION;
180
		} else {
181
			activation = new ContextActivation(contextId, andExpression, this);
182
		}
164
		return doActivateContext(activation);
183
		return doActivateContext(activation);
165
	}
184
	}
166
185

Return to bug 249995