|
From: Pavel V. <va...@us...> - 2002-09-11 19:12:24
|
Update of /cvsroot/javaprofiler/module/net/sourceforge/javaprofiler/module/actions In directory usw-pr-cvs1:/tmp/cvs-serv4977 Added Files: StartProfiler.java Log Message: start action --- NEW FILE: StartProfiler.java --- /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"); you may not use this file except * in compliance with the License. A copy of the License is available * at http://www.sun.com/ * * The Original Code is the Java Profiler module. The Initial Developers * of the Original Code are Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. * * Portions created by Jan Stola are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Pavel Vacha are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Michal Pise are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Petr Luner are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Lukas Petru are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Marek Przeczek are Copyright (C) 2000-2001. * All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ package net.sourceforge.javaprofiler.module.actions; import java.io.IOException; import org.openide.TopManager; import org.openide.cookies.ExecCookie; import org.openide.cookies.SourceCookie; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; import org.openide.util.actions.CookieAction; import org.openide.loaders.DataObject; import org.openide.execution.Executor; import net.sourceforge.javaprofiler.module.ProfilerExecutor; import org.openide.nodes.Node; import java.util.ResourceBundle; public class StartProfiler extends CookieAction { private static ResourceBundle bundle=NbBundle.getBundle(StartProfiler.class ); protected Class[] cookieClasses() { return new Class[]{ExecCookie.class}; } protected int mode() { return MODE_EXACTLY_ONE; } protected boolean enable(Node[] activatedNodes) { if (! super.enable(activatedNodes)) return false; // to be more restrictive, we require the SourceCookie // both java and class modules will add this cookie SourceCookie sc=(SourceCookie)activatedNodes[0].getCookie( SourceCookie.class); return sc!=null; } protected void performAction(Node[] activatedNodes) { System.err.println("Perform action."); if (activatedNodes.length != 1) return; //System.err.println("After test1"); DataObject dt=(DataObject) activatedNodes[0].getCookie(DataObject.class ); if (dt==null) return; //System.err.println("After test2"); ProfilerExecutor ex=(ProfilerExecutor) Executor.find( ProfilerExecutor.class); if (ex==null) throw new IllegalStateException("Cannot find ProfilerExecutor"); try { //System.err.println("About to start profiler"); ex.execute(dt); //System.err.println("Done"); } catch (IOException e) { TopManager.getDefault().notifyException(e); } } public String getName() { return bundle.getString("LBL_Start"); } public HelpCtx getHelpCtx() { return new HelpCtx(getClass()); } protected String iconResource() { return "/net/sourceforge/javaprofiler/module/resources/StartIcon.gif"; } } /* * $Log: StartProfiler.java,v $ * Revision 1.1 2002/09/11 19:12:19 vachis * start action * */ |