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 4, 2010, 2:03:17 AM
 package com.dmurph.mvc.monitor;

Daniel Murphy
 public class EventTableModel extends AbstractTableModel {
 	private static final long serialVersionUID = 1L;
 	private final ArrayList<LogEntryevents = new ArrayList<LogEntry>();
 	private int nextMessageIndex = 0;
 	private final int maxMessagesLogged;

 	public EventTableModel(int argMaxMessagesLogged){
 		 = argMaxMessagesLogged;
 	public void logEvent(MVCEvent argEventEventType argType){
 			LogEntry entry = new LogEntry();
 		LogEntry entry = new LogEntry();
 	final String[] columns = {
 			I18n.getText("monitor.gui.eventID"), I18n.getText("monitor.gui.eventKey"),
 			I18n.getText("monitor.gui.eventClass"), I18n.getText("monitor.gui.eventValue"),
 			I18n.getText("monitor.gui.warnings"), I18n.getText("monitor.gui.thread")

 	public String getColumnName(int argColumn) {
 		return [argColumn];

 	public int getColumnCount() {
 		return .;

 	public int getRowCount() {
 		return .size();

	public Object getValueAt(int argRowIndexint argColumnIndex) {
			argRowIndex += ;
			argRowIndex %= ;
		LogEntry entry = .get(argRowIndex);
			case 0:
				return entry.eventId;
			case 1:
				return entry.eventKey;
			case 2:
				return entry.eventClass;
			case 3:
				return (entry.eventValue != null)?entry.eventValue : "";
			case 4:
				if(entry.type == .){
					return I18n.getText("monitor.gui.noListeners");
				}else if(entry.type == .){
					return "<html><font color=\"FF0000\">"+I18n.getText("monitor.gui.exception")+"</font></html>";
				return null;
			case 5:
				return entry.threadName;
				return "?";
	public void exceptionThrown(MVCEvent argEvent){
		for(int i = .size()-1; i>=0; i--){
			LogEntry log = .get(i);
			if(log.eventId =={
				log.type = .;
	private static class LogEntry{
		int eventId;
		public void populate(MVCEvent argEventEventType argType){
			 = argType;
			 = argEvent.key;
			if(argEvent instanceof ObjectEvent<?>){
				Object value = ((ObjectEvent<?>) argEvent).getValue();
				 = value != null ? value.toString() : null;
				 = null;
New to GrepCode? Check out our FAQ X