1 3 package org.jgroups.debug; 4 5 import javax.swing.*; 6 import javax.swing.table.DefaultTableModel ; 7 import org.jgroups.stack.Protocol; 8 import org.jgroups.stack.ProtocolObserver; 9 import org.jgroups.Event; 10 11 12 13 17 public class ProtocolView implements ProtocolObserver { 18 final DefaultTableModel model; 19 int my_index=-1; 20 Protocol prot=null; 21 String prot_name=null; 22 final JButton down_label=new JButton("0"); 23 final JButton up_label=new JButton("0"); 24 boolean cummulative=false; 25 long tot_up=0, tot_down=0; 26 27 28 29 public ProtocolView(Protocol p, DefaultTableModel model, int my_index) { 30 prot=p; prot_name=p.getName(); this.model=model; this.my_index=my_index; 31 } 32 33 34 public ProtocolView(Protocol p, DefaultTableModel model, int my_index, boolean cummulative) { 35 prot=p; prot_name=p.getName(); this.model=model; this.my_index=my_index; this.cummulative=cummulative; 36 } 37 38 39 40 41 42 public void setProtocol(Protocol prot) { 43 this.prot=prot; 44 } 45 46 47 public boolean up(Event evt, int num_evts) { 48 tot_up++; 49 if(cummulative) 50 model.setValueAt("" + tot_up, my_index, 2); 51 else 52 model.setValueAt("" + num_evts, my_index, 2); 53 return true; 54 } 55 56 57 public boolean passUp(Event evt) { 58 return true; 59 } 60 61 62 public boolean down(Event evt, int num_evts) { 63 tot_down++; 64 if(cummulative) 65 model.setValueAt("" + tot_down, my_index, 3); 66 else 67 model.setValueAt("" + num_evts, my_index, 3); 68 return true; 69 } 70 71 public boolean passDown(Event evt) { 72 return true; 73 } 74 75 76 77 78 79 public String toString() { 80 return prot != null ? prot.getName() : "<n|a>"; 81 } 82 83 84 } 85 | Popular Tags |