[英]How to handle close tab in eclipse RCP 4
我想在Eclipse RCP 4应用程序中的选项卡的“脉冲关闭”按钮时进行验证,如果某些验证失败,则防止关闭。
If you don't want to use part.setDirty(true)
together with an ISaveHandler
like greg-449 montioned, you could listen to the model events and correct things there. 如果您不想将
part.setDirty(true)
与ISaveHandler
如greg-449 part.setDirty(true)
一起使用,则可以侦听模型事件并在那里进行更正。 Something in the direction of this: 朝着这个方向前进:
public class PreventCloseAddon {
@PostConstruct
public void init(final IEventBroker eventBroker, final EPartService partService) {
EventHandler tbrHandler = new EventHandler() {
@Override
public void handleEvent(Event event) {
if (!UIEvents.isSET(event))
return;
Object element = event.getProperty(UIEvents.EventTags.ELEMENT);
if (element instanceof MPart) {
MPart part = (MPart) element;
if (!part.isToBeRendered()) {
// ... validate here ...
part.setToBeRendered(true);
partService.activate(part);
}
}
}
};
eventBroker.subscribe(UIEvents.UIElement.TOPIC_TOBERENDERED, tbrHandler);
}
}
You should be aware that the part will be rendered again with this code. 您应该意识到,将使用此代码再次渲染零件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.