Eclipse RCP4退出时关闭部件/禁用部件的持久性?
我正在从事一个EclipseRCP4项目。我从不同的角度展示了一组可供选择的信息。选择要查看的内容后,将打开一个新零件,并显示要编辑/查看其姿态的对象。 我可以打开许多相同类型的零件。如果关闭应用程序,eclipse框架将保留所有打开部件的位置。如果我重新启动应用程序,以前打开的所有部分都已打开,但没有任何信息 -如何防止日食使零件的状态保持不变 -如何关闭退出时的部件 我正在寻找一种方法,将“removeOnExit”标记添加到零件,然后在退出时关闭这样一个标记的零件Eclipse RCP4退出时关闭部件/禁用部件的持久性?,eclipse,eclipse-rcp,rcp,Eclipse,Eclipse Rcp,Rcp,我正在从事一个EclipseRCP4项目。我从不同的角度展示了一组可供选择的信息。选择要查看的内容后,将打开一个新零件,并显示要编辑/查看其姿态的对象。 我可以打开许多相同类型的零件。如果关闭应用程序,eclipse框架将保留所有打开部件的位置。如果我重新启动应用程序,以前打开的所有部分都已打开,但没有任何信息 -如何防止日食使零件的状态保持不变 -如何关闭退出时的部件 我正在寻找一种方法,将“removeOnExit”标记添加到零件,然后在退出时关闭这样一个标记的零件 提前感谢:)使用此功能,
提前感谢:)使用此功能,您可以使用特定标记关闭MPart 似乎您必须切换到部件所在的透视图,否则它不会从上下文中删除,这将导致空指针异常
@Inject
@Optional
public void doEvent(@EventTopic(EventConstants.EventTopics.CLOSE_PARTS_WITH_TAGS) String tagToClose, MApplication app,
EModelService eModelService, EPartService ePartService) {
MUIElement activePart = ePartService.getActivePart();
EPartService activePeServcie = null;
MPerspective activePerspective = null;
if (activePart instanceof MPart) {
activePeServcie = ((MPart) activePart).getContext().get(EPartService.class);
activePerspective = eModelService.getPerspectiveFor(activePart);
}
List<String> tags = new ArrayList<String>();
tags.add(tagToClose);
List<MPart> elementsWithTags = eModelService.findElements(app, null, MPart.class, tags);
for (MPart part : elementsWithTags) {
try {
logger.info("Closing part " + part.toString());
EPartService peService = part.getContext().get(EPartService.class);
peService.switchPerspective(eModelService.getPerspectiveFor(part));
peService.hidePart(part);
} catch (Exception e) {
logger.error(e);
}
}
if (activePart instanceof MPart && activePeServcie != null && activePerspective != null) {
activePeServcie.switchPerspective(activePerspective);
}
}
@Inject
@可选的
public void doEvent(@EventTopic(EventConstants.EventTopics.CLOSE_PARTS_WITH_TAGS)字符串tagToClose,MApplication app,
EModelService EModelService,EPartService EPartService){
MUIElement activePart=ePartService.getActivePart();
EPartService activePeServcie=null;
MPerspective activePerspective=null;
if(MPart的活动部件实例){
activePeServcie=((MPart)activePart.getContext().get(EPartService.class);
activePerspective=eModelService.getPerspectiveFor(activePart);
}
列表标记=新的ArrayList();
tags.add(tagToClose);
List elementsWithTags=eModelService.findElements(app,null,MPart.class,tags);
用于(MPart部件:elementsWithTags){
试一试{
logger.info(“关闭部分”+部分.toString());
EPartService peService=part.getContext().get(EPartService.class);
peService.switchPerspective(eModelService.getPerspectiveFor(part));
peService.hidePart(部分);
}捕获(例外e){
错误(e);
}
}
if(MPart&&activePeServcie!=null&&activePerspective!=null的activePart实例){
activePeServcie.switchPerspective(activePerspective);
}
}
我们也尝试从Eclipse3迁移到Eclipse4。我们使用了comp层,在迁移过程中遇到了很多问题。我在eclipse工作台的持久存储中遇到了类似的问题。因此,零件和视图的位置与重新启动前相同
Eclipse4中的持久性范例已经改变。请看一看:
就我所记得的,
configurer.setSaveAndRestore(false)
的调用在Eclipse4中不能正常工作 是否可以使用configurer.setSaveAndRestore(false)在的ApplicationWorkbenchHadVisor中切换布局持久性?