use of org.eclipse.gmf.runtime.diagram.ui.providers.DiagramGlobalActionHandler in project statecharts by Yakindu.
the class StatechartDiagramGlobalActionHandlerProvider method getGlobalActionHandler.
/*
* (non-Javadoc)
*
* @see org.eclipse.gmf.runtime.common.ui.services.action.global.IGlobalActionHandlerProvider#getGlobalActionHandler(org.eclipse.gmf.runtime.common.ui.services.action.global.IGlobalActionHandlerContext)
*/
@SuppressWarnings("unchecked")
public IGlobalActionHandler getGlobalActionHandler(final IGlobalActionHandlerContext context) {
/* create the handler */
if (!getHandlerList().containsKey(context.getActivePart())) {
// PATCH START
getHandlerList().put(context.getActivePart(), new StatechartDiagramGlobalActionHandler());
// PATCH END
/*
* register as a part listener so that the cache can be cleared when
* the part is disposed
*/
context.getActivePart().getSite().getPage().addPartListener(new IPartListener() {
private IWorkbenchPart localPart = context.getActivePart();
/**
* @see org.eclipse.ui.IPartListener#partActivated(IWorkbenchPart)
*/
public void partActivated(IWorkbenchPart part) {
// NULL implementation
}
/**
* @see org.eclipse.ui.IPartListener#partBroughtToTop(IWorkbenchPart)
*/
public void partBroughtToTop(IWorkbenchPart part) {
// NULL implementation
}
/**
* @see org.eclipse.ui.IPartListener#partClosed(IWorkbenchPart)
*/
public void partClosed(IWorkbenchPart part) {
/* remove the cache associated with the part */
if (part != null && part == localPart && getHandlerList().containsKey(part)) {
getHandlerList().remove(part);
localPart.getSite().getPage().removePartListener(this);
localPart = null;
}
}
/**
* @see org.eclipse.ui.IPartListener#partDeactivated(IWorkbenchPart)
*/
public void partDeactivated(IWorkbenchPart part) {
// NULL implementation
}
/**
* @see org.eclipse.ui.IPartListener#partOpened(IWorkbenchPart)
*/
public void partOpened(IWorkbenchPart part) {
// NULL implementation
}
});
}
return (DiagramGlobalActionHandler) getHandlerList().get(context.getActivePart());
}
Aggregations