Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2010 Daniel Murphy Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
Created at Aug 3, 2010, 10:06:41 PM
 
 package com.dmurph.mvc.monitor;
 
 
 
This is an event monitor gui, for displaying all com.dmurph.mvc.MVCEvents that are dispatched. This makes it easy to debug your program and find out what is dispatched when.

Author(s):
Daniel Murphy
 
 public class EventMonitor extends JFrame implements IGlobalEventMonitor {
 	private static final long serialVersionUID = 1L;

Default number of messages logged.
 
 	public static final int DEFAULT_NUM_MESSAGES_LOGGED = 500;
Tells the monitor to log all messages
 
 	public static final int LOG_ALL_MESSAGES = .;
 	
 	private JTable table = new JTable();
 	private JButton enableDisable = new JButton();
 	private JLabel info = new JLabel();
 	private final EventTableModel model;
 	private final IGlobalEventMonitor delegate;
 	
 	private boolean enabled = true;
 	
 	private int numEvents = 0;
 	private int numSilentEvents = 0;
 	private int numExceptions = 0;

Creates a simple event monitor.
 
 	public EventMonitor(){
 	}

Parameters:
argMaxLogEntries max log entries (LOG_ALL_MESSAGES to log all).
 
 	public EventMonitor(int argMaxLogEntries){
 		this(nullargMaxLogEntries);
 	}

Creates an event monitor with a delegate (decorator pattern) to delegate calls to before processing them with this monitor.

Parameters:
argDelegate
 
 	public EventMonitor(IGlobalEventMonitor argDelegate){
 		this(argDelegate);
 	}

Parameters:
argDelegate the delegate to forward calls to. Can be null.
argMaxMessages the maximum messages to keep. Use LOG_ALL_MESSAGES to try to log all messages.
	public EventMonitor(IGlobalEventMonitor argDelegateint argMaxMessages){
		super("JMVC Event Monitor");
		setSize(500, 400);
		 = argDelegate;
		if(argMaxMessages < 0){
			throw new IllegalArgumentException("Number cannot be negative");
		}
		 = new EventTableModel(argMaxMessages);
			public void windowClosed(WindowEvent argE) {
			}
		});
	}

Returns:
the delegate
		return ;
	}
	private void initializeComponents() {
		add(new JScrollPane(), "Center");
		Box box = Box.createHorizontalBox();
		box.add(Box.createRigidArea(new Dimension(10, 10)));
		box.add();
		add(box"South");
			public void actionPerformed(ActionEvent argE) {
				}else{
				}
			}
		});
	}


If the monitor is enabled

Returns:
the enabled
	public boolean isMonitorEnabled() {
		return ;
	}

Sets if the monitor should no longer listen for events

Parameters:
argEnabled the enabled to set
	public void setMonitorEnabled(boolean argEnabled) {
		 = argEnabled;
		}else{
		}
	}

	public void afterDispatch(MVCEvent argEvent) {
		if( != null){
		}
	}

	public void beforeDispatch(MVCEvent argEvent) {
		if( != null){
		}
		}
	}

	public void noListeners(MVCEvent argEvent) {
		if( != null){
		}
		}
	}
	private void updateInfo(){
		.setText(I18n.getText("monitor.gui.info"+""+""+""));
	}
	protected static enum EventType{
		LISTENERS, NO_LISTENERS, EXCEPTION
	}

	public void exceptionThrown(MVCEvent argEventException argException) {
		if( != null){
			.exceptionThrown(argEventargException);
		}
		}
	}
//	public static void main(String[] args) {
//		EventMonitor monitor = new EventMonitor(EventMonitorType.BEFORE_DISPATCH, MVC.getGlobalEventMonitor());
//		MVC.setGlobalEventMonitor(monitor);
//		monitor.setVisible(true);
//		
//		MVCEvent event = new MVCEvent("HI");
//		event.dispatch();
//		event = new MVCEvent("HI");
//		event.dispatch();event = new MVCEvent("HI2");
//		event.dispatch();event = new MVCEvent("HI2");
//		event.dispatch();event = new MVCEvent("HI2");
//		event.dispatch();
//	}
New to GrepCode? Check out our FAQ X