Java tutorial
/* Copyright (C) 2014 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.infra.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.infra.view.InfraFileManagerView; /** * [?]??<BR> * * @version 5.0.0 * @since 5.0.0 */ public class InfraFileManagerAction extends AbstractHandler { /** */ private static Log m_log = LogFactory.getLog(InfraFileManagerAction.class); /** * ????? * * @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(InfraFileManagerView.ID); IViewPart viewPart = page.findView(InfraFileManagerView.ID); if (viewPart == null) throw new InternalError("viewPart is null."); InfraFileManagerView view = (InfraFileManagerView) viewPart.getAdapter(InfraFileManagerView.class); if (view == null) { m_log.info("execute: view is null"); return null; } view.setFocus(); } catch (PartInitException e) { e.printStackTrace(); } return null; } }