1 14 package org.wings.tree; 15 16 import javax.swing.event.TreeSelectionEvent ; 17 import javax.swing.tree.DefaultTreeSelectionModel ; 18 import javax.swing.tree.TreePath ; 19 import java.util.ArrayList ; 20 import java.util.Iterator ; 21 22 26 public class SDefaultTreeSelectionModel 27 extends DefaultTreeSelectionModel 28 implements STreeSelectionModel { 29 30 34 private boolean delayEvents = false; 35 36 39 protected final ArrayList delayedEvents = new ArrayList (); 40 41 public SDefaultTreeSelectionModel() { 42 super(); 43 } 44 45 public boolean getDelayEvents() { 46 return delayEvents; 47 } 48 49 public void setDelayEvents(boolean b) { 50 delayEvents = b; 51 } 52 53 56 public void fireDelayedIntermediateEvents() {} 57 58 public void fireDelayedFinalEvents() { 59 for (Iterator iter = delayedEvents.iterator(); iter.hasNext();) { 60 TreeSelectionEvent e = (TreeSelectionEvent ) iter.next(); 61 62 fireValueChanged(e); 63 } 64 delayedEvents.clear(); 65 } 66 67 protected void fireValueChanged(TreeSelectionEvent e) { 68 if (delayEvents) { 69 delayedEvents.add(e); 70 } else { 71 super.fireValueChanged(e); 72 } 73 } 74 75 76 79 public static final SDefaultTreeSelectionModel NO_SELECTION_MODEL = 80 new SDefaultTreeSelectionModel() { 81 84 public void setSelectionPaths(TreePath [] pPaths) { 85 } 86 87 90 public void addSelectionPaths(TreePath [] paths) { 91 } 92 93 96 public void removeSelectionPaths(TreePath [] paths) { 97 } 98 99 protected void fireValueChanged(TreeSelectionEvent e) {} 101 102 }; 103 104 } 105 106 107 | Popular Tags |