RCP e4 隐藏部件
RCP e4 hide parts
我实现了一个 e4 RCP 应用程序,我想为特殊用户隐藏部件。
在 e3 中,我知道我可以使用实现 IPerspectiveFactory 的透视图 class 来做到这一点。
我目前的解决方案是:
@PostConstruct
private void init(EPartService partService) {
MPart part = partService.findPart("part.id.activity");
partService.hidePart(part, true);
}
我在 class 部分执行此操作,当我 运行 我的应用程序时,我得到了这个注入:
!ENTRY org.eclipse.e4.ui.workbench 4 0 2017-08-01 09:08:06.139
!MESSAGE Unable to create class 'application.parts.activityPart.ActivityPart' from bundle '135'
!STACK 0
org.eclipse.e4.core.di.InjectionException: Unable to process "ActivityPart#createComposite()": no actual value was found for the argument "Composite".
at org.eclipse.e4.core.internal.di.InjectorImpl.reportUnresolvedArgument(InjectorImpl.java:476)
at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:987)
at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:124)
at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:399)
at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:318)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:105)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:74)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:56)
at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.createWidget(ContributedPartRenderer.java:129)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:997)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:666)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:772)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access[=11=](PartRenderingEngine.java:743)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:737)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:721)
at org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer.showTab(StackRenderer.java:1289)
at org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer.lambda[=11=](LazyStackRenderer.java:68)
at org.eclipse.e4.ui.services.internal.events.UIEventHandler.run(UIEventHandler.java:40)
at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:233)
at org.eclipse.swt.widgets.Display.syncExec(Display.java:4889)
...
不要在部件初始化期间尝试隐藏部件。
如果您知道不想在应用程序启动期间显示某个部分,您可以在 LifeCycle class.
中关闭其 'To be rendered' 标志
例如:
@ProcessAdditions
public void processAdditions(MApplication app, EModelService modelService)
{
MUIElement el = modelService.find("part.id.activity", app);
if (el != null) {
el.setToBeRendered(false);
}
}
我实现了一个 e4 RCP 应用程序,我想为特殊用户隐藏部件。
在 e3 中,我知道我可以使用实现 IPerspectiveFactory 的透视图 class 来做到这一点。
我目前的解决方案是:
@PostConstruct
private void init(EPartService partService) {
MPart part = partService.findPart("part.id.activity");
partService.hidePart(part, true);
}
我在 class 部分执行此操作,当我 运行 我的应用程序时,我得到了这个注入:
!ENTRY org.eclipse.e4.ui.workbench 4 0 2017-08-01 09:08:06.139 !MESSAGE Unable to create class 'application.parts.activityPart.ActivityPart' from bundle '135' !STACK 0 org.eclipse.e4.core.di.InjectionException: Unable to process "ActivityPart#createComposite()": no actual value was found for the argument "Composite". at org.eclipse.e4.core.internal.di.InjectorImpl.reportUnresolvedArgument(InjectorImpl.java:476) at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:987) at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:124) at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:399) at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:318) at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162) at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:105) at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:74) at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:56) at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.createWidget(ContributedPartRenderer.java:129) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:997) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:666) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:772) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access[=11=](PartRenderingEngine.java:743) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:737) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:721) at org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer.showTab(StackRenderer.java:1289) at org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer.lambda[=11=](LazyStackRenderer.java:68) at org.eclipse.e4.ui.services.internal.events.UIEventHandler.run(UIEventHandler.java:40) at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:233) at org.eclipse.swt.widgets.Display.syncExec(Display.java:4889) ...
不要在部件初始化期间尝试隐藏部件。
如果您知道不想在应用程序启动期间显示某个部分,您可以在 LifeCycle class.
中关闭其 'To be rendered' 标志例如:
@ProcessAdditions
public void processAdditions(MApplication app, EModelService modelService)
{
MUIElement el = modelService.find("part.id.activity", app);
if (el != null) {
el.setToBeRendered(false);
}
}