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

Collapse All | Expand All

(-)src/org/eclipse/e4/ui/workbench/renderers/swt/MenuRenderer.java (+23 lines)
Lines 56-61 Link Here
56
		return newMenu;
56
		return newMenu;
57
	}
57
	}
58
58
59
	/*
60
	 * (non-Javadoc)
61
	 * 
62
	 * @see
63
	 * org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer#processContents
64
	 * (org.eclipse.e4.ui.model.application.ui.MElementContainer)
65
	 */
66
	@Override
67
	public void processContents(MElementContainer<MUIElement> container) {
68
		Object obj = container.getWidget();
69
		Object menuModel = container;
70
		if ((obj instanceof Menu) && (((Menu) obj).getStyle() & SWT.BAR) != 0
71
				&& (menuModel instanceof MMenu)) {
72
			// we don't process the children of the main menu bar
73
			// are we bad people?
74
			// IEclipseContext ctx = getContext(container);
75
			// MenuServiceFilter filter = ctx.get(MenuServiceFilter.class);
76
			// filter.showMenu(null, (Menu) obj, (MMenu) menuModel);
77
			return;
78
		}
79
		super.processContents(container);
80
	}
81
59
	private void setItemText(MMenu model, MenuItem item) {
82
	private void setItemText(MMenu model, MenuItem item) {
60
		String text = model.getLabel();
83
		String text = model.getLabel();
61
		if (text == null) {
84
		if (text == null) {
(-)src/org/eclipse/e4/ui/workbench/swt/modeling/MenuServiceFilter.java (-5 / +9 lines)
Lines 101-106 Link Here
101
101
102
	private void handleMenu(final Event event, final Menu menu,
102
	private void handleMenu(final Event event, final Menu menu,
103
			final MMenu menuModel) {
103
			final MMenu menuModel) {
104
		if ((menu.getStyle() & SWT.BAR) != 0) {
105
			// don't process the menu bar, it's not fair :-)
106
			return;
107
		}
104
		switch (event.type) {
108
		switch (event.type) {
105
		case SWT.Show:
109
		case SWT.Show:
106
			if (DEBUG) {
110
			if (DEBUG) {
Lines 124-130 Link Here
124
		}
128
		}
125
	}
129
	}
126
130
127
	private void showMenu(final Event event, final Menu menu,
131
	public void showMenu(final Event event, final Menu menu,
128
			final MMenu menuModel) {
132
			final MMenu menuModel) {
129
		final IEclipseContext parentContext = modelService
133
		final IEclipseContext parentContext = modelService
130
				.getContainingContext(menuModel);
134
				.getContainingContext(menuModel);
Lines 174-180 Link Here
174
		}
178
		}
175
	}
179
	}
176
180
177
	private void hidePopup(Event event, Menu menu, MPopupMenu menuModel) {
181
	public void hidePopup(Event event, Menu menu, MPopupMenu menuModel) {
178
		final IEclipseContext popupContext = menuModel.getContext();
182
		final IEclipseContext popupContext = menuModel.getContext();
179
		final IEclipseContext parentContext = popupContext.getParent();
183
		final IEclipseContext parentContext = popupContext.getParent();
180
		final IEclipseContext originalChild = (IEclipseContext) popupContext
184
		final IEclipseContext originalChild = (IEclipseContext) popupContext
Lines 190-196 Link Here
190
		}
194
		}
191
	}
195
	}
192
196
193
	private void showPopup(final Event event, final Menu menu,
197
	public void showPopup(final Event event, final Menu menu,
194
			final MPopupMenu menuModel) {
198
			final MPopupMenu menuModel) {
195
		final IEclipseContext popupContext = menuModel.getContext();
199
		final IEclipseContext popupContext = menuModel.getContext();
196
		final IEclipseContext parentContext = popupContext.getParent();
200
		final IEclipseContext parentContext = popupContext.getParent();
Lines 313-319 Link Here
313
		}
317
		}
314
	}
318
	}
315
319
316
	private void showRenderedMenu(final Event event, final Menu menu,
320
	public void showRenderedMenu(final Event event, final Menu menu,
317
			final MRenderedMenu menuModel) {
321
			final MRenderedMenu menuModel) {
318
		if (!(menuModel.getContributionManager() instanceof MenuManager)) {
322
		if (!(menuModel.getContributionManager() instanceof MenuManager)) {
319
			return;
323
			return;
Lines 347-353 Link Here
347
		event.doit = false;
351
		event.doit = false;
348
	}
352
	}
349
353
350
	private void cleanUp(final Menu menu) {
354
	public void cleanUp(final Menu menu) {
351
		if (DEBUG) {
355
		if (DEBUG) {
352
			trace("cleanUp", menu, null);
356
			trace("cleanUp", menu, null);
353
		}
357
		}
(-)Eclipse (+180 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 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.menus;
13
14
import java.util.ArrayList;
15
import org.eclipse.core.runtime.IConfigurationElement;
16
import org.eclipse.core.runtime.Path;
17
import org.eclipse.e4.core.contexts.IEclipseContext;
18
import org.eclipse.e4.ui.model.application.MApplication;
19
import org.eclipse.e4.ui.model.application.ui.MElementContainer;
20
import org.eclipse.e4.ui.model.application.ui.menu.MMenu;
21
import org.eclipse.e4.ui.model.application.ui.menu.MMenuContribution;
22
import org.eclipse.e4.ui.model.application.ui.menu.MMenuElement;
23
import org.eclipse.e4.ui.model.application.ui.menu.impl.MenuFactoryImpl;
24
import org.eclipse.e4.ui.workbench.swt.modeling.MenuServiceFilter;
25
import org.eclipse.ui.IWorkbenchActionConstants;
26
import org.eclipse.ui.internal.e4.compatibility.E4Util;
27
import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
28
29
/**
30
 * @since e4
31
 * 
32
 */
33
public class ActionSet {
34
35
	private IConfigurationElement configElement;
36
37
	private MApplication application;
38
39
	public ActionSet(MApplication application, IEclipseContext appContext,
40
			IConfigurationElement element) {
41
		this.application = application;
42
		this.configElement = element;
43
	}
44
45
	public void addToModel(ArrayList<MMenuContribution> contributions) {
46
47
		String idContrib = MenuHelper.getId(configElement);
48
		IConfigurationElement[] menus = configElement
49
				.getChildren(IWorkbenchRegistryConstants.TAG_MENU);
50
		for (IConfigurationElement element : menus) {
51
			addContribution(idContrib, contributions, element, true);
52
		}
53
54
		IConfigurationElement[] actions = configElement
55
				.getChildren(IWorkbenchRegistryConstants.TAG_ACTION);
56
		for (IConfigurationElement element : actions) {
57
			addContribution(idContrib, contributions, element, false);
58
		}
59
60
		// for entertainment purposes only
61
		// printContributions(contributions);
62
	}
63
64
	void printContributions(ArrayList<MMenuContribution> contributions) {
65
		for (MMenuContribution c : contributions) {
66
			for (MMenuElement element : c.getChildren()) {
67
				printElement(1, element);
68
			}
69
		}
70
	}
71
72
	private void printElement(int level, MMenuElement element) {
73
		for (int i = 0; i < level; i++) {
74
			System.out.print('\t');
75
		}
76
		System.out.println(element);
77
		if (element instanceof MMenu) {
78
			for (MMenuElement item : ((MMenu) element).getChildren()) {
79
				printElement(level + 1, item);
80
			}
81
		}
82
	}
83
84
	private void addContribution(String idContrib, ArrayList<MMenuContribution> contributions,
85
			IConfigurationElement element, boolean isMenu) {
86
		MMenuContribution menuContribution = MenuFactoryImpl.eINSTANCE.createMenuContribution();
87
		menuContribution.getTags().add(MenuServiceFilter.MC_MENU);
88
		final String elementId = MenuHelper.getId(element);
89
		if (idContrib != null && idContrib.length() > 0) {
90
			menuContribution.setElementId(idContrib + "/" + elementId); //$NON-NLS-1$
91
		} else {
92
			menuContribution.setElementId(elementId);
93
		}
94
95
		String path = isMenu ? MenuHelper.getPath(element) : MenuHelper.getMenuBarPath(element);
96
		if (path == null || path.length() == 0) {
97
			if (!isMenu) {
98
				return;
99
			}
100
			path = IWorkbenchActionConstants.MB_ADDITIONS;
101
		}
102
		Path menuPath = new Path(path);
103
		String parentId = "org.eclipse.ui.main.menu"; //$NON-NLS-1$
104
		String positionInParent = "after=" + menuPath.segment(0); //$NON-NLS-1$
105
		int segmentCount = menuPath.segmentCount();
106
		if (segmentCount > 1) {
107
			parentId = menuPath.segment(segmentCount - 2);
108
			positionInParent = "after=" + menuPath.segment(segmentCount - 1); //$NON-NLS-1$
109
		}
110
		menuContribution.setParentID(parentId);
111
		menuContribution.setPositionInParent(positionInParent);
112
		if (isMenu) {
113
			MMenu menu = MenuHelper.createMenuAddition(element);
114
			menuContribution.getChildren().add(menu);
115
		} else {
116
			if (parentId.equals("org.eclipse.ui.main.menu")) { //$NON-NLS-1$
117
				E4Util.unsupported("****MC: bad pie: " + menuPath); //$NON-NLS-1$
118
				parentId = IWorkbenchActionConstants.M_WINDOW;
119
				menuContribution.setParentID(parentId);
120
			}
121
			MMenuElement action = MenuHelper.createLegacyActionAdditions(application, element);
122
			if (action != null) {
123
				menuContribution.getChildren().add(action);
124
			}
125
		}
126
		if (menuContribution.getChildren().size() > 0) {
127
			contributions.add(menuContribution);
128
		}
129
		if (isMenu) {
130
			processGroups(idContrib, contributions, element);
131
		}
132
	}
133
134
	private void processGroups(String idContrib, ArrayList<MMenuContribution> contributions,
135
			IConfigurationElement element) {
136
		MMenuContribution menuContribution = MenuFactoryImpl.eINSTANCE.createMenuContribution();
137
		menuContribution.getTags().add(MenuServiceFilter.MC_MENU);
138
		final String elementId = MenuHelper.getId(element);
139
		if (idContrib != null && idContrib.length() > 0) {
140
			menuContribution.setElementId(idContrib + "/" + elementId + ".groups"); //$NON-NLS-1$ //$NON-NLS-2$
141
		} else {
142
			menuContribution.setElementId(elementId + ".groups"); //$NON-NLS-1$
143
		}
144
		menuContribution.setParentID(elementId);
145
		IConfigurationElement[] children = element.getChildren();
146
		for (IConfigurationElement sepAddition : children) {
147
			String name = sepAddition.getAttribute(IWorkbenchRegistryConstants.ATT_NAME);
148
			MMenuElement sep = MenuFactoryImpl.eINSTANCE.createMenuSeparator();
149
			sep.setElementId(name);
150
			if (!MenuHelper.isSeparatorVisible(sepAddition)) {
151
				sep.setVisible(false);
152
			}
153
			menuContribution.getChildren().add(sep);
154
		}
155
		if (menuContribution.getChildren().size() > 0) {
156
			contributions.add(menuContribution);
157
		}
158
	}
159
160
	MElementContainer<MMenuElement> findMenuFromPath(MElementContainer<MMenuElement> menu,
161
			Path menuPath, int segment) {
162
		int idx = MenuHelper.indexForId(menu, menuPath.segment(segment));
163
		if (idx == -1) {
164
			if (segment + 1 < menuPath.segmentCount() || !menuPath.hasTrailingSeparator()) {
165
				return null;
166
			}
167
			return menu;
168
		}
169
		MElementContainer<MMenuElement> item = (MElementContainer<MMenuElement>) menu.getChildren()
170
				.get(idx);
171
		if (item.getChildren().size() == 0) {
172
			if (segment + 1 == menuPath.segmentCount()) {
173
				return menu;
174
			} else {
175
				return null;
176
			}
177
		}
178
		return findMenuFromPath(item, menuPath, segment + 1);
179
	}
180
}
(-)Eclipse UI/org/eclipse/ui/internal/menus/MenuAdditionCacheEntry.java (-41 / +31 lines)
Lines 12-17 Link Here
12
12
13
package org.eclipse.ui.internal.menus;
13
package org.eclipse.ui.internal.menus;
14
14
15
import java.util.ArrayList;
15
import java.util.Map;
16
import java.util.Map;
16
import org.eclipse.core.runtime.IConfigurationElement;
17
import org.eclipse.core.runtime.IConfigurationElement;
17
import org.eclipse.e4.core.contexts.IEclipseContext;
18
import org.eclipse.e4.core.contexts.IEclipseContext;
Lines 41-47 Link Here
41
	// private IEclipseContext appContext;
42
	// private IEclipseContext appContext;
42
	private IConfigurationElement configElement;
43
	private IConfigurationElement configElement;
43
	private MenuLocationURI location;
44
	private MenuLocationURI location;
44
	private MMenuContribution menuContribution;
45
45
46
	private MToolBarContribution toolBarContribution;
46
	private MToolBarContribution toolBarContribution;
47
47
Lines 158-165 Link Here
158
				MMenu element = createMenuAddition(items[i]);
158
				MMenu element = createMenuAddition(items[i]);
159
				element.getTags().add(filter);
159
				element.getTags().add(filter);
160
				container.getChildren().add(element);
160
				container.getChildren().add(element);
161
				addMenuChildren(element, items[i], filter);
162
				// newItem = createMenuAdditionContribution(items[i]);
163
			} else if (IWorkbenchRegistryConstants.TAG_TOOLBAR.equals(itemType)) {
161
			} else if (IWorkbenchRegistryConstants.TAG_TOOLBAR.equals(itemType)) {
164
				E4Util.unsupported("Toolbar: " + id + " in " + location); //$NON-NLS-1$//$NON-NLS-2$
162
				E4Util.unsupported("Toolbar: " + id + " in " + location); //$NON-NLS-1$//$NON-NLS-2$
165
			}
163
			}
Lines 188-231 Link Here
188
			if (IWorkbenchRegistryConstants.TAG_COMMAND.equals(itemType)) {
186
			if (IWorkbenchRegistryConstants.TAG_COMMAND.equals(itemType)) {
189
				MToolBarElement element = createToolBarCommandAddition(items[i]);
187
				MToolBarElement element = createToolBarCommandAddition(items[i]);
190
				container.getChildren().add(element);
188
				container.getChildren().add(element);
191
				// } else if
192
				// (IWorkbenchRegistryConstants.TAG_DYNAMIC.equals(itemType)) {
193
				//				E4Util.unsupported("Dynamic: " + id + " in " + location); //$NON-NLS-1$//$NON-NLS-2$
194
				// } else if
195
				// (IWorkbenchRegistryConstants.TAG_CONTROL.equals(itemType)) {
196
				//				E4Util.unsupported("Control: " + id + " in " + location); //$NON-NLS-1$//$NON-NLS-2$
197
				// } else if
198
				// (IWorkbenchRegistryConstants.TAG_SEPARATOR.equals(itemType))
199
				// {
200
				// MMenuElement element = createSeparatorAddition(items[i]);
201
				// container.getChildren().add(element);
202
				// } else if
203
				// (IWorkbenchRegistryConstants.TAG_MENU.equals(itemType)) {
204
				// MMenu element = createMenuAddition(items[i]);
205
				// element.getTags().add(filter);
206
				// container.getChildren().add(element);
207
				// addMenuChildren(element, items[i], filter);
208
				// // newItem = createMenuAdditionContribution(items[i]);
209
				// } else if
210
				// (IWorkbenchRegistryConstants.TAG_TOOLBAR.equals(itemType)) {
211
				//				E4Util.unsupported("Toolbar: " + id + " in " + location); //$NON-NLS-1$//$NON-NLS-2$
212
			}
189
			}
213
190
214
			// if (newItem instanceof InternalControlContribution) {
215
			// ((InternalControlContribution)
216
			// newItem).setWorkbenchWindow(window);
217
			// }
218
219
			// Cache the relationship between the ICI and the
220
			// registry element used to back it
221
			// if (newItem != null) {
222
			// additions.addContributionItem(newItem,
223
			// getVisibleWhenForItem(newItem, items[i]));
224
			// }
225
		}
191
		}
226
	}
192
	}
227
193
228
	public void addToModel() {
194
	public void addToModel(ArrayList<MMenuContribution> contributions) {
229
		if (inToolbar()) {
195
		if (inToolbar()) {
230
			toolBarContribution = MenuFactoryImpl.eINSTANCE.createToolBarContribution();
196
			toolBarContribution = MenuFactoryImpl.eINSTANCE.createToolBarContribution();
231
			String idContrib = MenuHelper.getId(configElement);
197
			String idContrib = MenuHelper.getId(configElement);
Lines 243-249 Link Here
243
209
244
			return;
210
			return;
245
		}
211
		}
246
		menuContribution = MenuFactoryImpl.eINSTANCE.createMenuContribution();
212
		MMenuContribution menuContribution = MenuFactoryImpl.eINSTANCE.createMenuContribution();
247
		String idContrib = MenuHelper.getId(configElement);
213
		String idContrib = MenuHelper.getId(configElement);
248
		if (idContrib != null && idContrib.length() > 0) {
214
		if (idContrib != null && idContrib.length() > 0) {
249
			menuContribution.setElementId(idContrib);
215
			menuContribution.setElementId(idContrib);
Lines 266-276 Link Here
266
		menuContribution.getTags().add(filter);
232
		menuContribution.getTags().add(filter);
267
		menuContribution.setVisibleWhen(MenuHelper.getVisibleWhen(configElement));
233
		menuContribution.setVisibleWhen(MenuHelper.getVisibleWhen(configElement));
268
		addMenuChildren(menuContribution, configElement, filter);
234
		addMenuChildren(menuContribution, configElement, filter);
269
		application.getMenuContributions().add(menuContribution);
235
		contributions.add(menuContribution);
236
		processMenuChildren(contributions, configElement, filter);
270
	}
237
	}
271
238
272
	public void dispose() {
239
	/**
273
		application.getMenuContributions().remove(menuContribution);
240
	 * @param contributions
274
		application.getToolBarContributions().remove(toolBarContribution);
241
	 * @param element
242
	 * @param filter
243
	 */
244
	private void processMenuChildren(ArrayList<MMenuContribution> contributions,
245
			IConfigurationElement element, String filter) {
246
		IConfigurationElement[] menus = element.getChildren(IWorkbenchRegistryConstants.TAG_MENU);
247
		if (menus.length == 0) {
248
			return;
249
		}
250
		for (IConfigurationElement menu : menus) {
251
			MMenuContribution menuContribution = MenuFactoryImpl.eINSTANCE.createMenuContribution();
252
			String idContrib = MenuHelper.getId(menu);
253
			if (idContrib != null && idContrib.length() > 0) {
254
				menuContribution.setElementId(idContrib);
255
			}
256
			menuContribution.setParentID(idContrib);
257
			menuContribution.getTags().add("scheme:" + location.getScheme()); //$NON-NLS-1$
258
			menuContribution.getTags().add(filter);
259
			menuContribution.setVisibleWhen(MenuHelper.getVisibleWhen(menu));
260
			addMenuChildren(menuContribution, menu, filter);
261
			contributions.add(menuContribution);
262
			processMenuChildren(contributions, menu, filter);
263
		}
275
	}
264
	}
265
276
}
266
}
(-)Eclipse UI/org/eclipse/ui/internal/menus/MenuPersistence.java (-25 / +52 lines)
Lines 12-17 Link Here
12
package org.eclipse.ui.internal.menus;
12
package org.eclipse.ui.internal.menus;
13
13
14
import java.util.ArrayList;
14
import java.util.ArrayList;
15
import java.util.Arrays;
15
import java.util.Collections;
16
import java.util.Collections;
16
import java.util.Comparator;
17
import java.util.Comparator;
17
import java.util.Iterator;
18
import java.util.Iterator;
Lines 22-27 Link Here
22
import org.eclipse.core.runtime.Platform;
23
import org.eclipse.core.runtime.Platform;
23
import org.eclipse.e4.core.contexts.IEclipseContext;
24
import org.eclipse.e4.core.contexts.IEclipseContext;
24
import org.eclipse.e4.ui.model.application.MApplication;
25
import org.eclipse.e4.ui.model.application.MApplication;
26
import org.eclipse.e4.ui.model.application.ui.menu.MMenuContribution;
25
import org.eclipse.ui.PlatformUI;
27
import org.eclipse.ui.PlatformUI;
26
import org.eclipse.ui.internal.e4.compatibility.E4Util;
28
import org.eclipse.ui.internal.e4.compatibility.E4Util;
27
import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
29
import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
Lines 42-48 Link Here
42
44
43
	private MApplication application;
45
	private MApplication application;
44
	private IEclipseContext appContext;
46
	private IEclipseContext appContext;
45
	private ArrayList<MenuAdditionCacheEntry> contributions = new ArrayList<MenuAdditionCacheEntry>();
47
	private ArrayList<MenuAdditionCacheEntry> cacheEntries = new ArrayList<MenuAdditionCacheEntry>();
48
	private ArrayList<ActionSet> actionContributions = new ArrayList<ActionSet>();
49
	private ArrayList<MMenuContribution> menuContributions = new ArrayList<MMenuContribution>();
46
50
47
	/**
51
	/**
48
	 * Constructs a new instance of {@link MenuPersistence}.
52
	 * Constructs a new instance of {@link MenuPersistence}.
Lines 59-68 Link Here
59
	}
63
	}
60
64
61
	public final void dispose() {
65
	public final void dispose() {
62
		for (MenuAdditionCacheEntry mc : contributions) {
66
		application.getMenuContributions().removeAll(menuContributions);
63
			mc.dispose();
67
		menuContributions.clear();
64
		}
68
		cacheEntries.clear();
65
		contributions.clear();
69
		actionContributions.clear();
66
		super.dispose();
70
		super.dispose();
67
	}
71
	}
68
72
Lines 99-106 Link Here
99
		// Read legacy 3.2 'trim' additions
103
		// Read legacy 3.2 'trim' additions
100
		readTrimAdditions();
104
		readTrimAdditions();
101
105
106
		ArrayList<MMenuContribution> contributions = new ArrayList<MMenuContribution>();
102
		// read the 3.3 menu additions
107
		// read the 3.3 menu additions
103
		readAdditions();
108
		readAdditions(contributions);
109
110
		// convert actionSets to MenuContributions
111
		readActionSets(contributions);
112
113
		// can I rationalize them?
114
		MenuHelper.mergeContributions(contributions, menuContributions);
115
		application.getMenuContributions().addAll(menuContributions);
104
	}
116
	}
105
117
106
	//
118
	//
Lines 165-173 Link Here
165
		// }
177
		// }
166
	}
178
	}
167
179
168
	public void readAdditions() {
180
	public void readAdditions(ArrayList<MMenuContribution> contributions) {
169
		final IExtensionRegistry registry = Platform.getExtensionRegistry();
181
		final IExtensionRegistry registry = Platform.getExtensionRegistry();
170
		ArrayList configElements = new ArrayList();
182
		ArrayList<IConfigurationElement> configElements = new ArrayList<IConfigurationElement>();
171
183
172
		final IConfigurationElement[] menusExtensionPoint = registry
184
		final IConfigurationElement[] menusExtensionPoint = registry
173
				.getConfigurationElementsFor(EXTENSION_MENUS);
185
				.getConfigurationElementsFor(EXTENSION_MENUS);
Lines 178-199 Link Here
178
				configElements.add(menusExtensionPoint[i]);
190
				configElements.add(menusExtensionPoint[i]);
179
			}
191
			}
180
		}
192
		}
181
		Comparator comparer = new Comparator() {
193
		Comparator<IConfigurationElement> comparer = new Comparator<IConfigurationElement>() {
182
			public int compare(Object o1, Object o2) {
194
			public int compare(IConfigurationElement c1, IConfigurationElement c2) {
183
				IConfigurationElement c1 = (IConfigurationElement) o1;
195
				return c1.getNamespaceIdentifier().compareToIgnoreCase(c2.getNamespaceIdentifier());
184
				IConfigurationElement c2 = (IConfigurationElement) o2;
185
				return c1.getNamespaceIdentifier().compareToIgnoreCase(
186
						c2.getNamespaceIdentifier());
187
			}
196
			}
188
		};
197
		};
189
		Collections.sort(configElements, comparer);
198
		Collections.sort(configElements, comparer);
190
199
191
		Iterator i = configElements.iterator();
200
		Iterator<IConfigurationElement> i = configElements.iterator();
192
		while (i.hasNext()) {
201
		while (i.hasNext()) {
193
			final IConfigurationElement configElement = (IConfigurationElement) i
202
			final IConfigurationElement configElement = i.next();
194
					.next();
203
195
			
196
			
197
			if (isProgramaticContribution(configElement)) {
204
			if (isProgramaticContribution(configElement)) {
198
				// newFactory = new ProxyMenuAdditionCacheEntry(
205
				// newFactory = new ProxyMenuAdditionCacheEntry(
199
				// configElement
206
				// configElement
Lines 202-214 Link Here
202
				E4Util.unsupported("Programmatic Contribution Factories not supported"); //$NON-NLS-1$
209
				E4Util.unsupported("Programmatic Contribution Factories not supported"); //$NON-NLS-1$
203
210
204
			} else {
211
			} else {
205
				MenuAdditionCacheEntry menuContribution = new MenuAdditionCacheEntry(application, appContext,
212
				MenuAdditionCacheEntry menuContribution = new MenuAdditionCacheEntry(application,
206
						configElement,
213
						appContext, configElement,
207
						configElement
214
						configElement.getAttribute(IWorkbenchRegistryConstants.TAG_LOCATION_URI),
208
								.getAttribute(IWorkbenchRegistryConstants.TAG_LOCATION_URI),
209
						configElement.getNamespaceIdentifier());
215
						configElement.getNamespaceIdentifier());
210
				contributions.add(menuContribution);
216
				cacheEntries.add(menuContribution);
211
				menuContribution.addToModel();
217
				menuContribution.addToModel(contributions);
212
			}
218
			}
213
		}
219
		}
214
	}
220
	}
Lines 223-226 Link Here
223
	private boolean isProgramaticContribution(IConfigurationElement menuAddition) {
229
	private boolean isProgramaticContribution(IConfigurationElement menuAddition) {
224
		return menuAddition.getAttribute(IWorkbenchRegistryConstants.ATT_CLASS) != null;
230
		return menuAddition.getAttribute(IWorkbenchRegistryConstants.ATT_CLASS) != null;
225
	}
231
	}
232
233
	private void readActionSets(ArrayList<MMenuContribution> contributions) {
234
		final IExtensionRegistry registry = Platform.getExtensionRegistry();
235
		ArrayList<IConfigurationElement> configElements = new ArrayList<IConfigurationElement>();
236
237
		configElements.addAll(Arrays.asList(registry
238
				.getConfigurationElementsFor(IWorkbenchRegistryConstants.EXTENSION_ACTION_SETS)));
239
240
		Comparator<IConfigurationElement> comparer = new Comparator<IConfigurationElement>() {
241
			public int compare(IConfigurationElement c1, IConfigurationElement c2) {
242
				return c1.getNamespaceIdentifier().compareToIgnoreCase(c2.getNamespaceIdentifier());
243
			}
244
		};
245
		Collections.sort(configElements, comparer);
246
247
		for (IConfigurationElement element : configElements) {
248
			ActionSet actionSet = new ActionSet(application, appContext, element);
249
			actionContributions.add(actionSet);
250
			actionSet.addToModel(contributions);
251
		}
252
	}
226
}
253
}

Return to bug 316303