Lines 27-32
Link Here
|
27 |
import javax.annotation.PostConstruct; |
27 |
import javax.annotation.PostConstruct; |
28 |
import javax.inject.Inject; |
28 |
import javax.inject.Inject; |
29 |
import org.eclipse.core.expressions.ExpressionInfo; |
29 |
import org.eclipse.core.expressions.ExpressionInfo; |
|
|
30 |
import org.eclipse.e4.core.commands.ExpressionContext; |
30 |
import org.eclipse.e4.core.contexts.ContextInjectionFactory; |
31 |
import org.eclipse.e4.core.contexts.ContextInjectionFactory; |
31 |
import org.eclipse.e4.core.contexts.IContextFunction; |
32 |
import org.eclipse.e4.core.contexts.IContextFunction; |
32 |
import org.eclipse.e4.core.contexts.IEclipseContext; |
33 |
import org.eclipse.e4.core.contexts.IEclipseContext; |
Lines 40-45
Link Here
|
40 |
import org.eclipse.e4.ui.internal.workbench.swt.CSSRenderingUtils; |
41 |
import org.eclipse.e4.ui.internal.workbench.swt.CSSRenderingUtils; |
41 |
import org.eclipse.e4.ui.model.application.MApplication; |
42 |
import org.eclipse.e4.ui.model.application.MApplication; |
42 |
import org.eclipse.e4.ui.model.application.MApplicationElement; |
43 |
import org.eclipse.e4.ui.model.application.MApplicationElement; |
|
|
44 |
import org.eclipse.e4.ui.model.application.ui.MCoreExpression; |
43 |
import org.eclipse.e4.ui.model.application.ui.MElementContainer; |
45 |
import org.eclipse.e4.ui.model.application.ui.MElementContainer; |
44 |
import org.eclipse.e4.ui.model.application.ui.MUIElement; |
46 |
import org.eclipse.e4.ui.model.application.ui.MUIElement; |
45 |
import org.eclipse.e4.ui.model.application.ui.SideValue; |
47 |
import org.eclipse.e4.ui.model.application.ui.SideValue; |
Lines 191-197
Link Here
|
191 |
} |
193 |
} |
192 |
|
194 |
|
193 |
if (parent == null) { |
195 |
if (parent == null) { |
194 |
ici.setVisible(itemModel.isVisible()); |
196 |
ici.setVisible(isVisible(itemModel)); |
195 |
return; |
197 |
return; |
196 |
} |
198 |
} |
197 |
|
199 |
|
Lines 199-211
Link Here
|
199 |
// partial fix for bug 383569: only change state if there are no |
201 |
// partial fix for bug 383569: only change state if there are no |
200 |
// extra override mechanics controlling element visibility |
202 |
// extra override mechanics controlling element visibility |
201 |
if (ov == null) { |
203 |
if (ov == null) { |
202 |
ici.setVisible(itemModel.isVisible()); |
204 |
ici.setVisible(isVisible(itemModel)); |
203 |
} else { |
205 |
} else { |
204 |
Boolean visible = ov.getVisible(ici); |
206 |
Boolean visible = ov.getVisible(ici); |
205 |
if (visible == null) { |
207 |
if (visible == null) { |
206 |
// same as above: only change state if there are no extra |
208 |
// same as above: only change state if there are no extra |
207 |
// override mechanics controlling element visibility |
209 |
// override mechanics controlling element visibility |
208 |
ici.setVisible(itemModel.isVisible()); |
210 |
ici.setVisible(isVisible(itemModel)); |
209 |
} |
211 |
} |
210 |
} |
212 |
} |
211 |
|
213 |
|
Lines 711-717
Link Here
|
711 |
} |
713 |
} |
712 |
itemModel.setRenderer(this); |
714 |
itemModel.setRenderer(this); |
713 |
AbstractGroupMarker marker = null; |
715 |
AbstractGroupMarker marker = null; |
714 |
if (itemModel.isVisible() && !itemModel.getTags().contains(MenuManagerRenderer.GROUP_MARKER)) { |
716 |
if (isVisible(itemModel) && !itemModel.getTags().contains(MenuManagerRenderer.GROUP_MARKER)) { |
715 |
marker = new Separator(); |
717 |
marker = new Separator(); |
716 |
marker.setId(itemModel.getElementId()); |
718 |
marker.setId(itemModel.getElementId()); |
717 |
} else { |
719 |
} else { |
Lines 734-740
Link Here
|
734 |
final IEclipseContext lclContext = getContext(itemModel); |
736 |
final IEclipseContext lclContext = getContext(itemModel); |
735 |
ToolControlContribution ci = ContextInjectionFactory.make(ToolControlContribution.class, lclContext); |
737 |
ToolControlContribution ci = ContextInjectionFactory.make(ToolControlContribution.class, lclContext); |
736 |
ci.setModel(itemModel); |
738 |
ci.setModel(itemModel); |
737 |
ci.setVisible(itemModel.isVisible()); |
739 |
ci.setVisible(isVisible(itemModel)); |
738 |
addToManager(parentManager, itemModel, ci); |
740 |
addToManager(parentManager, itemModel, ci); |
739 |
linkModelToContribution(itemModel, ci); |
741 |
linkModelToContribution(itemModel, ci); |
740 |
} |
742 |
} |
Lines 748-754
Link Here
|
748 |
final IEclipseContext lclContext = getContext(itemModel); |
750 |
final IEclipseContext lclContext = getContext(itemModel); |
749 |
DirectContributionItem ci = ContextInjectionFactory.make(DirectContributionItem.class, lclContext); |
751 |
DirectContributionItem ci = ContextInjectionFactory.make(DirectContributionItem.class, lclContext); |
750 |
ci.setModel(itemModel); |
752 |
ci.setModel(itemModel); |
751 |
ci.setVisible(itemModel.isVisible()); |
753 |
ci.setVisible(isVisible(itemModel)); |
752 |
addToManager(parentManager, itemModel, ci); |
754 |
addToManager(parentManager, itemModel, ci); |
753 |
linkModelToContribution(itemModel, ci); |
755 |
linkModelToContribution(itemModel, ci); |
754 |
} |
756 |
} |
Lines 762-768
Link Here
|
762 |
final IEclipseContext lclContext = getContext(itemModel); |
764 |
final IEclipseContext lclContext = getContext(itemModel); |
763 |
HandledContributionItem ci = ContextInjectionFactory.make(HandledContributionItem.class, lclContext); |
765 |
HandledContributionItem ci = ContextInjectionFactory.make(HandledContributionItem.class, lclContext); |
764 |
ci.setModel(itemModel); |
766 |
ci.setModel(itemModel); |
765 |
ci.setVisible(itemModel.isVisible()); |
767 |
ci.setVisible(isVisible(itemModel)); |
766 |
addToManager(parentManager, itemModel, ci); |
768 |
addToManager(parentManager, itemModel, ci); |
767 |
linkModelToContribution(itemModel, ci); |
769 |
linkModelToContribution(itemModel, ci); |
768 |
} |
770 |
} |
Lines 780-790
Link Here
|
780 |
} else { |
782 |
} else { |
781 |
return; |
783 |
return; |
782 |
} |
784 |
} |
783 |
ici.setVisible(itemModel.isVisible()); |
785 |
ici.setVisible(isVisible(itemModel)); |
784 |
addToManager(parentManager, itemModel, ici); |
786 |
addToManager(parentManager, itemModel, ici); |
785 |
linkModelToContribution(itemModel, ici); |
787 |
linkModelToContribution(itemModel, ici); |
786 |
} |
788 |
} |
787 |
|
789 |
|
|
|
790 |
private boolean isVisible(MToolBarElement element) { |
791 |
return isVisible(element, getContext(element)); |
792 |
} |
793 |
|
794 |
static boolean isVisible(MToolBarElement element, IEclipseContext contextForEvaluation) { |
795 |
boolean visible = element.isVisible(); |
796 |
if (visible && (element.getVisibleWhen() instanceof MCoreExpression)) { |
797 |
final ExpressionContext evalContext = new ExpressionContext(contextForEvaluation); |
798 |
visible = ContributionsAnalyzer.isVisible((MCoreExpression) element.getVisibleWhen(), evalContext); |
799 |
} |
800 |
return visible; |
801 |
} |
802 |
|
788 |
private void addToManager(ToolBarManager parentManager, |
803 |
private void addToManager(ToolBarManager parentManager, |
789 |
MToolBarElement model, IContributionItem ci) { |
804 |
MToolBarElement model, IContributionItem ci) { |
790 |
MElementContainer<MUIElement> parent = model.getParent(); |
805 |
MElementContainer<MUIElement> parent = model.getParent(); |