From: Jan S. <st...@us...> - 2002-05-16 12:11:02
|
Update of /cvsroot/javaprofiler/module/net/sourceforge/javaprofiler/module/actions In directory usw-pr-cvs1:/tmp/cvs-serv30164 Added Files: TerminateListenerAction.java ListenAction.java Log Message: Listen and terminate listener actions. --- NEW FILE: TerminateListenerAction.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 javax.swing.Action; import org.openide.nodes.Node; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; import org.openide.util.actions.CookieAction; /** * Action that terminates listening for a connection * from a profiled process. * * @author Jan Stola */ public class TerminateListenerAction extends CookieAction { protected Class[] cookieClasses() { return new Class[]{ConListenerCookie.class}; } protected int mode() { return MODE_ALL; } protected void performAction(Node[] nodes) { for (int i=0; i<nodes.length; i++) { ConListenerCookie cookie=(ConListenerCookie)nodes[i].getCookie(ConListenerCookie.class); cookie.terminate(); } } public String getName() { return NbBundle.getMessage(TerminateListenerAction.class, "LBL_terminateAction"); } protected String iconResource() { return "/net/sourceforge/javaprofiler/module/resources/TerminateActionIcon.gif"; } public HelpCtx getHelpCtx() { return new HelpCtx(TerminateListenerAction.class); } protected void initialize() { super.initialize(); putProperty(Action.SHORT_DESCRIPTION, NbBundle.getMessage(TerminateListenerAction.class, "HINT_terminateAction")); } } /* * $Log: TerminateListenerAction.java,v $ * Revision 1.1 2002/05/16 12:11:00 stolis * Listen and terminate listener actions. * */ --- NEW FILE: ListenAction.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.awt.Dialog; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import org.openide.TopManager; import org.openide.DialogDescriptor; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; import org.openide.util.actions.CallableSystemAction; import net.sourceforge.javaprofiler.jpi.Bootstrap; import net.sourceforge.javaprofiler.jpi.connect.Connector; import net.sourceforge.javaprofiler.jpi.connect.ConnectingException; import net.sourceforge.javaprofiler.module.data.Session; import net.sourceforge.javaprofiler.module.data.ConListener; import net.sourceforge.javaprofiler.module.data.ProfilerData; /** * Action that performes listening for the connection from the profiled process. * * @author Jan Stola */ public class ListenAction extends CallableSystemAction { /** Listen to connection dialog. */ Dialog dialog; /** Inner pane of the dialog. */ AttachPanel panel; /** * Displays listen to connection dialog. */ public void performAction() { panel=new AttachPanel(Connector.LISTENING_CONNECTOR); DialogDescriptor descr = new DialogDescriptor ( panel, NbBundle.getBundle(ListenAction.class).getString("LBL_listenToConnection"), true, // modal new ListenListener() ); dialog=TopManager.getDefault().createDialog(descr); dialog.show(); } public String getName() { return NbBundle.getMessage(ListenAction.class, "LBL_listenAction"); } protected String iconResource() { return "/net/sourceforge/javaprofiler/module/resources/ListenActionIcon.gif"; } public HelpCtx getHelpCtx() { return new HelpCtx (ListenAction.class); } /** * Listener for the listen to connection dialog. */ private class ListenListener implements ActionListener { /** * Attaches to the profiled process. * * @param event ActionEvent from the Attach to VM dialog. */ public void actionPerformed(ActionEvent event) { if (event.getSource().equals(DialogDescriptor.OK_OPTION)) { // PENDING // switch workspace final String name=panel.name(); new Thread(new Runnable() { public void run() { ConListener conLis=null; try { conLis=new ConListener(name, Thread.currentThread()); ProfilerData.getData().addConListener(conLis); Session session=panel.connect(); ProfilerData.getData().removeConListener(conLis); ProfilerData.getData().addSession(session); panel=null; } catch (ConnectingException e) { ProfilerData.getData().removeConListener(conLis); TopManager.getDefault().notifyException(e); } } }).start(); } dialog.setVisible(false); dialog.dispose(); } } } /* * $Log: ListenAction.java,v $ * Revision 1.1 2002/05/16 12:11:00 stolis * Listen and terminate listener actions. * */ |