use of org.eclipse.e4.ui.workbench.UIEvents in project eclipse.platform.ui by eclipse-platform.
the class TrimStack method handleTransientDataEvents.
/**
* This is the new way to handle UIEvents (as opposed to subscring and unsubscribing them with
* the event broker.
*
* The method is described in detail at http://wiki.eclipse.org/Eclipse4/RCP/Event_Model
*/
@SuppressWarnings("unchecked")
@Inject
@Optional
private void handleTransientDataEvents(@UIEventTopic(UIEvents.ApplicationElement.TOPIC_TRANSIENTDATA) org.osgi.service.event.Event event) {
// Prevent exceptions on shutdown
if (trimStackTB == null || trimStackTB.isDisposed() || minimizedElement.getWidget() == null) {
return;
}
Object changedElement = event.getProperty(UIEvents.EventTags.ELEMENT);
if (!(changedElement instanceof MUIElement)) {
return;
}
String key;
if (UIEvents.isREMOVE(event)) {
key = ((Entry<String, Object>) event.getProperty(UIEvents.EventTags.OLD_VALUE)).getKey();
} else {
key = ((Entry<String, Object>) event.getProperty(UIEvents.EventTags.NEW_VALUE)).getKey();
}
if (key.equals(IPresentationEngine.OVERRIDE_ICON_IMAGE_KEY)) {
ToolItem toolItem = getChangedToolItem((MUIElement) changedElement);
if (toolItem != null) {
toolItem.setImage(getImage((MUILabel) toolItem.getData()));
}
} else if (key.equals(IPresentationEngine.OVERRIDE_TITLE_TOOL_TIP_KEY)) {
ToolItem toolItem = getChangedToolItem((MUIElement) changedElement);
if (toolItem != null) {
toolItem.setToolTipText(getLabelText((MUILabel) toolItem.getData()));
}
}
}
Aggregations