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.hub.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.hub.view.LogScopeTreeView; /** * ????<BR> * * @version 6.0.0 */ public class LogScopeTreeViewAction extends AbstractHandler { /** */ private static Log m_log = LogFactory.getLog(LogScopeTreeViewAction.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(LogScopeTreeView.ID); IViewPart viewPart = page.findView(LogScopeTreeView.ID); if (viewPart == null) throw new InternalError("viewPart is null."); LogScopeTreeView view = (LogScopeTreeView) viewPart.getAdapter(LogScopeTreeView.class); if (view == null) { m_log.info("execute: view is null"); return null; } view.setFocus(); } catch (PartInitException e) { } return null; } }