Java tutorial
/* Copyright (C) 2016 NTT DATA Corporation This program is free software; you can redistribute it and/or Modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ package com.clustercontrol.approval.etc.action; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PartInitException; import org.eclipse.ui.handlers.HandlerUtil; import com.clustercontrol.approval.view.ApprovalView; /** * ???<BR> * * @version 6.0.0 */ public class ApprovalAction extends AbstractHandler { /** */ private static Log m_log = LogFactory.getLog(ApprovalAction.class); /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() */ @Override public void dispose() { } @Override public Object execute(ExecutionEvent event) throws ExecutionException { //? IWorkbenchPage page = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage(); //? try { page.showView(ApprovalView.ID); IViewPart viewPart = page.findView(ApprovalView.ID); if (viewPart == null) throw new InternalError("viewPart is null."); ApprovalView view = (ApprovalView) viewPart.getAdapter(ApprovalView.class); if (view == null) { m_log.info("execute: view is null"); return null; } view.setFocus(); } catch (PartInitException e) { } return null; } }