|
What this is
Other links
The source code/* * 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 NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.test.editor.app.core; import org.netbeans.test.editor.app.gui.*; import java.io.Serializable; import org.netbeans.modules.editor.*; import javax.swing.text.JTextComponent; import javax.swing.text.EditorKit; import javax.swing.Action; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.IOException; import java.io.Serializable; import java.io.DataOutputStream; import java.io.DataInputStream; import java.util.Vector; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeSupport; import java.lang.reflect.Method; import org.netbeans.test.editor.app.util.Scheduler; import javax.swing.SwingUtilities; import org.netbeans.test.editor.app.Main; import org.netbeans.test.editor.app.core.TestAction; public class Logger implements Serializable { static final String COMPLETION_ACTION="completion-action"; static final long serialVersionUID = 8269484241745322111L; static final String PERFORMING="Performing"; static final String LOGGING="Logging"; private Vector actions = new Vector(); private Vector events = new Vector(); private Vector testActions = new Vector(); /** Property about delay between steps of simulation */ private int delay = 20; /** Property about logging */ private boolean logging=false; /** Property about running gathered actions */ private boolean performing=false; /** Property change support. */ private PropertyChangeSupport changeSupport; public EventLoggingEditorPane editor; public Logger(EventLoggingEditorPane editor){ this.editor=(EventLoggingEditorPane)editor; changeSupport = new PropertyChangeSupport(this); } /** * Start/Restart the logging of actions into this logger. Everybody interested * can hook-up listener * * @see addPropertyChangeListener */ public void startLogging() { if( logging == true ) return; logging = true; editor.setLogger(this); firePropertyChange(LOGGING, Boolean.FALSE, Boolean.TRUE ); } /** * Stop the logging of actions into this logger. Everybody interested * can hook-up listener * * @see addPropertyChangeListener */ public void stopLogging() { if( logging == false ) return; logging = false; editor.setLogger(null); firePropertyChange(LOGGING, Boolean.TRUE, Boolean.FALSE ); } /** * Returns the actual state of logging. */ public boolean isLogging() { return logging; } /** * Start performing of logged actions from beginning. Everybody interested * can hook-up listener. * * @see addPropertyChangeListener */ public synchronized void startPerforming() { if( performing == true ) return; performing = true; firePropertyChange(PERFORMING, Boolean.FALSE, Boolean.TRUE ); System.err.println("creating SimulationPerformer"); Thread sim = new SimulationPerformer( delay, this ); sim.start(); } /** * Stop the logging of actions into this logger. Everybody interested * can hook-up listener. * * @see addPropertyChangeListener */ public synchronized void stopPerforming() { if( performing == false ) return; performing = false; firePropertyChange(PERFORMING, Boolean.TRUE, Boolean.FALSE ); } /** * Returns the actual state of logging. */ public synchronized boolean isPerforming() { return performing; } /** * Forget all the bufferred actions */ public void setDelay(int value) { delay=value; } public int getDelay() { return delay; } public void clear() { actions = new Vector(); events = new Vector(); testActions = new Vector(); } public TestNode[] saveActions( TestStep step ) { TestNode[] nodes; String name; String cmd; nodes=new TestNode[actions.size()]; for( int i=0; i < actions.size(); i++ ) { name=(String)(actions.get(i)); if (name.compareTo(COMPLETION_ACTION) != 0) { cmd = ((ActionEvent)events.get(i)).getActionCommand(); if (cmd == null) cmd=""; nodes[i]=new TestLogAction(name,cmd); } else { nodes[i]=new TestCompletionAction(name,(String)(events.get(i))); } } step.addNodes(nodes); return nodes; } /* public void loadAction(TestLogAction action) { actions.add(action.getName()); events.add(new ActionEvent(editor,ActionEvent.ACTION_PERFORMED, action.getCommand())); } public void loadActions(TestStep step) { TestLogAction a; TestAction ta; for(int i=0;i < step.getChildCount();i++) { a=(TestLogAction)(step.get(i)); loadAction(a); } }*/ public void loadActions(TestStep step) { for(int i=0;i < step.getChildCount();i++) { testActions.add(step.get(i)); } } /** * Add a {@link PropertyChangeListener} to the listener list. * * @param listener the |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.