Author: fhanik Date: Tue May 30 13:13:46 2006 New Revision: 410362 URL: http://svn.apache.org/viewvc?rev=410362&view=rev Log: Fixed sizing and randomness
Modified: tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/demos/MapDemo.java Modified: tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/demos/MapDemo.java URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/demos/MapDemo.java?rev=410362&r1=410361&r2=410362&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/demos/MapDemo.java (original) +++ tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/demos/MapDemo.java Tue May 30 13:13:46 2006 @@ -30,6 +30,8 @@ import java.awt.Color; import java.awt.Component; import javax.swing.table.TableColumn; +import org.apache.catalina.tribes.util.UUIDGenerator; +import org.apache.catalina.tribes.util.Arrays; /** * <p>Title: </p> @@ -143,7 +145,7 @@ private LazyReplicatedMap map; private boolean DEBUG = false; - TableModel dataModel = new AbstractTableModel() { + AbstractTableModel dataModel = new AbstractTableModel() { String[] columnNames = { @@ -187,6 +189,7 @@ case 5: return new Boolean(entry.isBackup()); default: return ""; } + } public void update() { @@ -200,7 +203,7 @@ JTextField txtChangeKey = new JTextField(20); JTextField txtChangeValue = new JTextField(20); - + JTable table = null; public SimpleTableDemo(LazyReplicatedMap map) { super(); this.map = map; @@ -208,7 +211,7 @@ this.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); //final JTable table = new JTable(data, columnNames); - final JTable table = new JTable(dataModel); + table = new JTable(dataModel); table.setPreferredScrollableViewportSize(new Dimension(WIDTH, 150)); for ( int i=0; i<table.getColumnCount(); i++ ) { @@ -240,6 +243,7 @@ addpanel.add(createButton("Add","add")); addpanel.add(txtAddKey); addpanel.add(txtAddValue); + addpanel.setMaximumSize(new Dimension(WIDTH,30)); add(addpanel); //create a remove value button @@ -247,7 +251,7 @@ removepanel.setPreferredSize(new Dimension(WIDTH,30)); removepanel.add(createButton("Remove","remove")); removepanel.add(txtRemoveKey); - + removepanel.setMaximumSize(new Dimension(WIDTH,30)); add(removepanel); //create a change value button @@ -256,15 +260,17 @@ changepanel.add(txtChangeKey); changepanel.add(txtChangeValue); changepanel.setPreferredSize(new Dimension(WIDTH,30)); - + changepanel.setMaximumSize(new Dimension(WIDTH,30)); add(changepanel); - + + //create sync button JPanel syncpanel = new JPanel( ); syncpanel.add(createButton("Synchronize","sync")); syncpanel.add(createButton("Replicate","replicate")); + syncpanel.add(createButton("Random","random")); syncpanel.setPreferredSize(new Dimension(WIDTH,30)); - + syncpanel.setMaximumSize(new Dimension(WIDTH,30)); add(syncpanel); @@ -304,6 +310,25 @@ System.out.println("Syncing from another node."); map.transferState(); } + if ( "random".equals(e.getActionCommand()) ) { + Thread t = new Thread() { + public void run() { + for (int i = 0; i < 100; i++) { + String key = Arrays.toString(UUIDGenerator.randomUUID(false)); + map.put(key, key); + dataModel.fireTableDataChanged(); + table.paint(table.getGraphics()); + try { + Thread.sleep(500); + } catch (InterruptedException x) { + Thread.currentThread().interrupted(); + } + } + } + }; + t.start(); + } + if ( "replicate".equals(e.getActionCommand()) ) { System.out.println("Replicating out to the other nodes."); map.replicate(true); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]