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