Search in sources :

Example 1 with ClipboardActionHandler

use of org.talend.designer.business.model.business.diagram.handler.ClipboardActionHandler in project tdi-studio-se by Talend.

the class ClipboardActionHandlerProvider method getGlobalActionHandler.

@Override
public IGlobalActionHandler getGlobalActionHandler(final IGlobalActionHandlerContext context) {
    if (!getHandlerList().containsKey(context.getActivePart())) {
        getHandlerList().put(context.getActivePart(), new ClipboardActionHandler());
        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
            }

            public void partBroughtToTop(IWorkbenchPart part) {
            // NULL implementation
            }

            public void partClosed(IWorkbenchPart 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 (ClipboardActionHandler) getHandlerList().get(context.getActivePart());
}
Also used : IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) IPartListener(org.eclipse.ui.IPartListener) ClipboardActionHandler(org.talend.designer.business.model.business.diagram.handler.ClipboardActionHandler)

Aggregations

IPartListener (org.eclipse.ui.IPartListener)1 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)1 ClipboardActionHandler (org.talend.designer.business.model.business.diagram.handler.ClipboardActionHandler)1