001package jmri.jmrix.pricom.pockettester; 002 003 004/** 005 * Simple GUI for access to PRICOM Pocket Monitor. 006 * <p> 007 * For more info on the product, see http://www.pricom.com 008 * 009 * @author Bob Jacobsen Copyright (C) 2005 010 */ 011public class MonitorFrame extends jmri.jmrix.AbstractMonFrame implements DataListener { 012 013 public MonitorFrame() { 014 super(); 015 } 016 017 @Override 018 public void init() { 019 } 020 021 @Override 022 protected String title() { 023 String title = filter; 024 if (filter == null) { 025 title = ""; 026 } 027 return java.text.MessageFormat.format(Bundle.getMessage("TitleMonitor"), 028 new Object[]{title}); 029 } 030 031 @Override 032 public void dispose() { 033 // and clean up parent 034 super.dispose(); 035 } 036 037 @Override 038 public void asciiFormattedMessage(String m) { 039 if ((filter == null) || m.startsWith(filter)) { 040 nextLine(m, ""); 041 } 042 } 043 String filter = null; 044 045 /** 046 * Start filtering input to include only lines that start with a specific 047 * string. 048 * A null input passes all. 049 * @param s string to filter, can be null. 050 */ 051 public void setFilter(String s) { 052 filter = s; 053 setTitle(title()); 054 } 055 056}