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

Collapse All | Expand All

(-)src/org/eclipse/e4/ui/model/application/ui/menu/MHandledToolItem.java (+24 lines)
Lines 21-24 Link Here
21
 * @generated
21
 * @generated
22
 */
22
 */
23
public interface MHandledToolItem extends MToolItem, MHandledItem {
23
public interface MHandledToolItem extends MToolItem, MHandledItem {
24
	/**
25
	 * Returns the value of the '<em><b>Contribution Item</b></em>' attribute.
26
	 * <!-- begin-user-doc -->
27
	 * <p>
28
	 * If the meaning of the '<em>Contribution Item</em>' attribute isn't clear,
29
	 * there really should be more of a description here...
30
	 * </p>
31
	 * <!-- end-user-doc -->
32
	 * @return the value of the '<em>Contribution Item</em>' attribute.
33
	 * @see #setContributionItem(Object)
34
	 * @model transient="true"
35
	 * @generated
36
	 */
37
	Object getContributionItem();
38
39
	/**
40
	 * Sets the value of the '{@link org.eclipse.e4.ui.model.application.ui.menu.MRenderedMenuItem#getContributionItem <em>Contribution Item</em>}' attribute.
41
	 * <!-- begin-user-doc -->
42
	 * <!-- end-user-doc -->
43
	 * @param value the new value of the '<em>Contribution Item</em>' attribute.
44
	 * @see #getContributionItem()
45
	 * @generated
46
	 */
47
	void setContributionItem(Object value);
24
} // MHandledToolItem
48
} // MHandledToolItem
(-)src/org/eclipse/e4/ui/model/application/ui/menu/impl/HandledToolItemImpl.java (+51 lines)
Lines 82-87 Link Here
82
	 * @ordered
82
	 * @ordered
83
	 */
83
	 */
84
	protected EList<MParameter> parameters;
84
	protected EList<MParameter> parameters;
85
	
86
	/**
87
	 * The default value of the '{@link #getContributionItem() <em>Contribution Item</em>}' attribute.
88
	 * <!-- begin-user-doc -->
89
	 * <!-- end-user-doc -->
90
	 * @see #getContributionItem()
91
	 * @generated
92
	 * @ordered
93
	 */
94
	protected static final Object CONTRIBUTION_ITEM_EDEFAULT = null;
95
	
96
	/**
97
	 * The cached value of the '{@link #getContributionItem() <em>Contribution Item</em>}' attribute.
98
	 * <!-- begin-user-doc -->
99
	 * <!-- end-user-doc -->
100
	 * @see #getContributionItem()
101
	 * @generated
102
	 * @ordered
103
	 */
104
	protected Object contributionItem = CONTRIBUTION_ITEM_EDEFAULT;
85
105
86
	/**
106
	/**
87
	 * <!-- begin-user-doc -->
107
	 * <!-- begin-user-doc -->
Lines 186-191 Link Here
186
		}
206
		}
187
		return super.eInverseRemove(otherEnd, featureID, msgs);
207
		return super.eInverseRemove(otherEnd, featureID, msgs);
188
	}
208
	}
209
	
210
	/**
211
	 * <!-- begin-user-doc -->
212
	 * <!-- end-user-doc -->
213
	 * @generated
214
	 */
215
	public Object getContributionItem() {
216
		return contributionItem;
217
	}
218
219
	/**
220
	 * <!-- begin-user-doc -->
221
	 * <!-- end-user-doc -->
222
	 * @generated
223
	 */
224
	public void setContributionItem(Object newContributionItem) {
225
		Object oldContributionItem = contributionItem;
226
		contributionItem = newContributionItem;
227
		if (eNotificationRequired())
228
			eNotify(new ENotificationImpl(this, Notification.SET, MenuPackageImpl.HANDLED_TOOL_ITEM__CONTRIBUTION_MANAGER, oldContributionItem, contributionItem));
229
	}
189
230
190
	/**
231
	/**
191
	 * <!-- begin-user-doc -->
232
	 * <!-- begin-user-doc -->
Lines 202-207 Link Here
202
				return getWbCommand();
243
				return getWbCommand();
203
			case MenuPackageImpl.HANDLED_TOOL_ITEM__PARAMETERS:
244
			case MenuPackageImpl.HANDLED_TOOL_ITEM__PARAMETERS:
204
				return getParameters();
245
				return getParameters();
246
			case MenuPackageImpl.HANDLED_TOOL_ITEM__CONTRIBUTION_MANAGER:
247
				return getContributionItem();
205
		}
248
		}
206
		return super.eGet(featureID, resolve, coreType);
249
		return super.eGet(featureID, resolve, coreType);
207
	}
250
	}
Lines 225-230 Link Here
225
				getParameters().clear();
268
				getParameters().clear();
226
				getParameters().addAll((Collection<? extends MParameter>)newValue);
269
				getParameters().addAll((Collection<? extends MParameter>)newValue);
227
				return;
270
				return;
271
			case MenuPackageImpl.HANDLED_TOOL_ITEM__CONTRIBUTION_MANAGER:
272
				setContributionItem(newValue);
273
				return;
228
		}
274
		}
229
		super.eSet(featureID, newValue);
275
		super.eSet(featureID, newValue);
230
	}
276
	}
Lines 246-251 Link Here
246
			case MenuPackageImpl.HANDLED_TOOL_ITEM__PARAMETERS:
292
			case MenuPackageImpl.HANDLED_TOOL_ITEM__PARAMETERS:
247
				getParameters().clear();
293
				getParameters().clear();
248
				return;
294
				return;
295
			case MenuPackageImpl.HANDLED_TOOL_ITEM__CONTRIBUTION_MANAGER:
296
				setContributionItem(CONTRIBUTION_ITEM_EDEFAULT);
297
				return;
249
		}
298
		}
250
		super.eUnset(featureID);
299
		super.eUnset(featureID);
251
	}
300
	}
Lines 264-269 Link Here
264
				return WB_COMMAND_EDEFAULT == null ? wbCommand != null : !WB_COMMAND_EDEFAULT.equals(wbCommand);
313
				return WB_COMMAND_EDEFAULT == null ? wbCommand != null : !WB_COMMAND_EDEFAULT.equals(wbCommand);
265
			case MenuPackageImpl.HANDLED_TOOL_ITEM__PARAMETERS:
314
			case MenuPackageImpl.HANDLED_TOOL_ITEM__PARAMETERS:
266
				return parameters != null && !parameters.isEmpty();
315
				return parameters != null && !parameters.isEmpty();
316
			case MenuPackageImpl.HANDLED_TOOL_ITEM__CONTRIBUTION_MANAGER:
317
				return CONTRIBUTION_ITEM_EDEFAULT == null ? contributionItem != null : !CONTRIBUTION_ITEM_EDEFAULT.equals(contributionItem);
267
		}
318
		}
268
		return super.eIsSet(featureID);
319
		return super.eIsSet(featureID);
269
	}
320
	}
(-)src/org/eclipse/e4/ui/model/application/ui/menu/impl/MenuPackageImpl.java (-1 / +13 lines)
Lines 3736-3741 Link Here
3736
	 * @ordered
3736
	 * @ordered
3737
	 */
3737
	 */
3738
	public static final int HANDLED_TOOL_ITEM__PARAMETERS = TOOL_ITEM_FEATURE_COUNT + 2;
3738
	public static final int HANDLED_TOOL_ITEM__PARAMETERS = TOOL_ITEM_FEATURE_COUNT + 2;
3739
	
3740
	/**
3741
	 * The feature id for the '<em><b>Contribution Manager</b></em>' attribute.
3742
	 * <!-- begin-user-doc -->
3743
	 * <!-- end-user-doc -->
3744
	 * @generated
3745
	 * @ordered
3746
	 */
3747
	public static final int HANDLED_TOOL_ITEM__CONTRIBUTION_MANAGER = TOOL_ITEM_FEATURE_COUNT + 3;
3739
3748
3740
	/**
3749
	/**
3741
	 * The number of structural features of the '<em>Handled Tool Item</em>' class.
3750
	 * The number of structural features of the '<em>Handled Tool Item</em>' class.
Lines 3744-3750 Link Here
3744
	 * @generated
3753
	 * @generated
3745
	 * @ordered
3754
	 * @ordered
3746
	 */
3755
	 */
3747
	public static final int HANDLED_TOOL_ITEM_FEATURE_COUNT = TOOL_ITEM_FEATURE_COUNT + 3;
3756
	public static final int HANDLED_TOOL_ITEM_FEATURE_COUNT = TOOL_ITEM_FEATURE_COUNT + 4;
3757
	
3758
	
3748
3759
3749
	/**
3760
	/**
3750
	 * The operation id for the '<em>Get Localized Accessibility Phrase</em>' operation.
3761
	 * The operation id for the '<em>Get Localized Accessibility Phrase</em>' operation.
Lines 7630-7635 Link Here
7630
		toolControlEClass = createEClass(TOOL_CONTROL);
7641
		toolControlEClass = createEClass(TOOL_CONTROL);
7631
7642
7632
		handledToolItemEClass = createEClass(HANDLED_TOOL_ITEM);
7643
		handledToolItemEClass = createEClass(HANDLED_TOOL_ITEM);
7644
		createEAttribute(handledToolItemEClass, HANDLED_TOOL_ITEM__CONTRIBUTION_MANAGER);
7633
7645
7634
		directToolItemEClass = createEClass(DIRECT_TOOL_ITEM);
7646
		directToolItemEClass = createEClass(DIRECT_TOOL_ITEM);
7635
7647
(-)src/org/eclipse/e4/ui/workbench/renderers/swt/HandledContributionItem.java (+1 lines)
Lines 228-233 Link Here
228
							return;
228
							return;
229
						}
229
						}
230
						model.setEnabled(canExecuteItem());
230
						model.setEnabled(canExecuteItem());
231
						// model.setSelected(canExecuteItem());
231
						update();
232
						update();
232
					}
233
					}
233
234
(-)src/org/eclipse/e4/ui/workbench/renderers/swt/ToolBarManagerRenderer.java (+9 lines)
Lines 19-24 Link Here
19
import javax.annotation.PreDestroy;
19
import javax.annotation.PreDestroy;
20
import javax.inject.Inject;
20
import javax.inject.Inject;
21
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
21
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
22
import org.eclipse.e4.core.contexts.IContextFunction;
22
import org.eclipse.e4.core.contexts.IEclipseContext;
23
import org.eclipse.e4.core.contexts.IEclipseContext;
23
import org.eclipse.e4.core.contexts.RunAndTrack;
24
import org.eclipse.e4.core.contexts.RunAndTrack;
24
import org.eclipse.e4.core.services.events.IEventBroker;
25
import org.eclipse.e4.core.services.events.IEventBroker;
Lines 694-699 Link Here
694
		if (ici != null) {
695
		if (ici != null) {
695
			return;
696
			return;
696
		}
697
		}
698
		Object obj = itemModel.getContributionItem();
699
		if (obj instanceof IContextFunction) {
700
			final IEclipseContext lclContext = getContext(itemModel);
701
			lclContext.set("copiedItemModel", itemModel); //$NON-NLS-1$
702
			ici = (IContributionItem) ((IContextFunction) obj)
703
					.compute(lclContext);
704
			itemModel.setContributionItem(ici);
705
		}
697
		final IEclipseContext lclContext = getContext(itemModel);
706
		final IEclipseContext lclContext = getContext(itemModel);
698
		HandledContributionItem ci = ContextInjectionFactory.make(
707
		HandledContributionItem ci = ContextInjectionFactory.make(
699
				HandledContributionItem.class, lclContext);
708
				HandledContributionItem.class, lclContext);
(-)Eclipse UI/org/eclipse/ui/internal/menus/MenuHelper.java (+34 lines)
Lines 58-63 Link Here
58
import org.eclipse.jface.action.IMenuCreator;
58
import org.eclipse.jface.action.IMenuCreator;
59
import org.eclipse.jface.action.MenuManager;
59
import org.eclipse.jface.action.MenuManager;
60
import org.eclipse.jface.resource.ImageDescriptor;
60
import org.eclipse.jface.resource.ImageDescriptor;
61
import org.eclipse.jface.util.IPropertyChangeListener;
62
import org.eclipse.jface.util.PropertyChangeEvent;
61
import org.eclipse.swt.widgets.Control;
63
import org.eclipse.swt.widgets.Control;
62
import org.eclipse.swt.widgets.Menu;
64
import org.eclipse.swt.widgets.Menu;
63
import org.eclipse.ui.IActionDelegate;
65
import org.eclipse.ui.IActionDelegate;
Lines 475-480 Link Here
475
			item.setType(ItemType.PUSH);
477
			item.setType(ItemType.PUSH);
476
		} else if (IWorkbenchRegistryConstants.STYLE_TOGGLE.equals(style)) {
478
		} else if (IWorkbenchRegistryConstants.STYLE_TOGGLE.equals(style)) {
477
			item.setType(ItemType.CHECK);
479
			item.setType(ItemType.CHECK);
480
			IContextFunction generator = new ContextFunction() {
481
				@Override
482
				public Object compute(IEclipseContext context) {
483
					IWorkbenchWindow window = context.get(IWorkbenchWindow.class);
484
					if (window == null) {
485
						return null;
486
					}
487
					ActionDescriptor desc = new ActionDescriptor(element,
488
							ActionDescriptor.T_WORKBENCH, window);
489
					final PluginAction action = desc.getAction();
490
					final MHandledToolItem copiedToolItem = (MHandledToolItem) context
491
							.get("copiedItemModel"); //$NON-NLS-1$
492
					action.addPropertyChangeListener(new IPropertyChangeListener() {
493
494
						public void propertyChange(PropertyChangeEvent event) {
495
							if (event.getProperty().equals("checked")) { //$NON-NLS-1$
496
								Boolean checkedValue = (Boolean) event.getNewValue();
497
								copiedToolItem.setSelected(checkedValue);
498
							}
499
						}
500
					});
501
					return new ActionContributionItem(action) {
502
						@Override
503
						public void dispose() {
504
							super.dispose();
505
							action.disposeDelegate();
506
						}
507
					};
508
				}
509
			};
510
			item.setContributionItem(generator);
511
			// return item;
478
		} else if (IWorkbenchRegistryConstants.STYLE_RADIO.equals(style)) {
512
		} else if (IWorkbenchRegistryConstants.STYLE_RADIO.equals(style)) {
479
			item.setType(ItemType.RADIO);
513
			item.setType(ItemType.RADIO);
480
		} else if (IWorkbenchRegistryConstants.STYLE_PULLDOWN.equals(style)) {
514
		} else if (IWorkbenchRegistryConstants.STYLE_PULLDOWN.equals(style)) {

Return to bug 325768