public static void main(String[] args) { ReplicatedTree tree=null; HashMap m=new HashMap(); String props=null; try { tree=new ReplicatedTree(null, props, 10000); // tree.setRemoteCalls(false); tree.addReplicatedTreeListener(new MyListener()); tree.put("/a/b/c", null); tree.put("/a/b/c1", null); tree.put("/a/b/c2", null); tree.put("/a/b1/chat", null); tree.put("/a/b1/chat2", null); tree.put("/a/b1/chat5", null); System.out.println(tree); m.put("name", "Bela Ban"); m.put("age",36); m.put("cube", "240-17"); tree.put("/a/b/c", m); System.out.println("info for for \"/a/b/c\" is " + tree.print("/a/b/c")); tree.put("/a/b/c", "age",37); System.out.println("info for for \"/a/b/c\" is " + tree.print("/a/b/c")); tree.remove("/a/b"); System.out.println(tree); tree.stop(); } catch(Exception ex) { System.err.println(ex); } }
static void populateTree(ReplicatedTree tree, String dir) { File file=new File(dir); if(!file.exists()) return; tree.put(dir, null); if(file.isDirectory()) { String[] children=file.list(); if(children != null && children.length > 0) { for(int i=0; i < children.length; i++) populateTree(tree, dir + '/' + children[i]); } } }
public void actionPerformed(ActionEvent e) { JTextField fqnTextField=new JTextField(); if(selected_node != null) fqnTextField.setText(selected_node); Object[] information={"Enter fully qualified name", fqnTextField}; final String btnString1="OK"; final String btnString2="Cancel"; Object[] options={btnString1, btnString2}; int userChoice=JOptionPane.showOptionDialog(null, information, "Add Node", JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[0]); if(userChoice == 0) { String userInput=fqnTextField.getText(); tree.put(userInput, null); } } }
public static void main(String[] args) { ReplicatedTree tree=null; HashMap m=new HashMap(); String props=null; try { tree=new ReplicatedTree(null, props, 10000); // tree.setRemoteCalls(false); tree.addReplicatedTreeListener(new MyListener()); tree.put("/a/b/c", null); tree.put("/a/b/c1", null); tree.put("/a/b/c2", null); tree.put("/a/b1/chat", null); tree.put("/a/b1/chat2", null); tree.put("/a/b1/chat5", null); System.out.println(tree); m.put("name", "Bela Ban"); m.put("age",36); m.put("cube", "240-17"); tree.put("/a/b/c", m); System.out.println("info for for \"/a/b/c\" is " + tree.print("/a/b/c")); tree.put("/a/b/c", "age",37); System.out.println("info for for \"/a/b/c\" is " + tree.print("/a/b/c")); tree.remove("/a/b"); System.out.println(tree); tree.stop(); } catch(Exception ex) { System.err.println(ex); } }
tree.put("/a/b/c", null); tree.put("/a/b/c1", null); tree.put("/a/b/c2", null); tree.put("/a/b1/chat", null); tree.put("/a/b1/chat2", null); tree.put("/a/b1/chat5", null); System.out.println(tree); m.put("name", "Bela Ban"); m.put("age", new Integer(36)); m.put("cube", "240-17"); tree.put("/a/b/c", m); System.out.println("info for for \"/a/b/c\" is " + tree.print("/a/b/c")); tree.put("/a/b/c", "age", new Integer(37)); System.out.println("info for for \"/a/b/c\" is " + tree.print("/a/b/c")); tree.remove("/a/b");
public void tableChanged(TableModelEvent evt) { int row, col; String key, val; if(evt.getType() == TableModelEvent.UPDATE) { row=evt.getFirstRow(); col=evt.getColumn(); if(col == 0) { // set() key=(String)table_model.getValueAt(row, col); val=(String)table_model.getValueAt(row, col + 1); if(key != null && val != null) { tree.put(selected_node, key, val); } } else { // add() key=(String)table_model.getValueAt(row, col - 1); val=(String)table.getValueAt(row, col); if(key != null && val != null) { tree.put(selected_node, key, val); } } } }