1 23 24 package org.netbeans.swing.tabcontrol.event; 25 26 import org.netbeans.swing.tabcontrol.TabData; 27 28 import javax.swing.event.ListDataEvent ; 29 30 40 public class ComplexListDataEvent extends ListDataEvent { 41 private static final int LAST = INTERVAL_REMOVED; 42 45 public static final int ITEMS_ADDED = LAST + 1; 46 49 public static final int ITEMS_REMOVED = LAST + 2; 50 54 static final int ITEMS_CHANGED = LAST + 3; 55 private int[] indices; 56 private boolean textChanged; 57 private boolean componentChanged = false; 58 59 70 public ComplexListDataEvent(Object source, int id, int[] indices, 71 boolean textChanged) { 72 super(source, id, -1, -1); 73 this.textChanged = textChanged; 74 this.indices = indices; 75 } 76 77 86 public ComplexListDataEvent(Object source, int id, int start, int end) { 87 super(source, id, start, end); 88 textChanged = true; 89 indices = null; 90 } 91 92 public ComplexListDataEvent(Object source, int id, int start, int end, 93 boolean textChanged, boolean compChange) { 94 super(source, id, start, end); 95 textChanged = true; 96 indices = null; 97 componentChanged = compChange; 98 } 99 100 111 public ComplexListDataEvent(Object source, int id, int start, int end, 112 boolean textChanged) { 113 this(source, id, start, end); 114 this.textChanged = textChanged; 115 indices = null; 116 } 117 118 123 public int[] getIndices() { 124 return indices; 125 } 126 127 132 public boolean isTextChanged() { 133 return textChanged; 134 } 135 136 140 public boolean isUserObjectChanged() { 141 return componentChanged; 142 } 143 144 public String toString() { 145 String [] types = new String []{ 146 "CONTENTS_CHANGED", "INTERVAL_ADDED", "INTERVAL_REMOVED", "ITEMS_ADDED", 148 "ITEMS_REMOVED"}; StringBuffer out = new StringBuffer (getClass().getName()); 150 out.append(" - " + types[getType()] + " - "); 151 if (getType() <= INTERVAL_REMOVED) { 152 out.append("start=" + getIndex0() + " end=" + getIndex1() + " "); } else { 154 int[] ids = getIndices(); 155 if (ids != null) { 156 for (int i = 0; i < ids.length; i++) { 157 out.append(ids[i]); 158 if (i != ids.length - 1) { 159 out.append(','); } 161 } 162 } else { 163 out.append("null"); } 165 } 166 return out.toString(); 167 } 168 169 public void setAffectedItems(TabData[] td) { 170 affectedItems = td; 171 } 172 173 public TabData[] getAffectedItems() { 174 return affectedItems; 175 } 176 177 private TabData[] affectedItems = null; 178 } 179 | Popular Tags |