1 19 20 package org.netbeans.modules.properties; 21 22 import java.util.EventObject ; 23 24 29 public class PropertyBundleEvent extends EventObject { 30 31 static final long serialVersionUID = 1702449038200791321L; 32 33 34 public static final int CHANGE_STRUCT = 1; 35 36 37 public static final int CHANGE_ALL = 2; 38 39 40 public static final int CHANGE_FILE = 3; 41 42 43 public static final int CHANGE_ITEM = 4; 44 45 46 protected String entryName; 47 48 49 protected String itemName; 50 51 52 protected int changeType; 53 54 61 public PropertyBundleEvent(Object source, int changeType) { 62 super(source); 63 this.changeType = changeType; 64 } 65 66 72 public PropertyBundleEvent(Object source, String entryName) { 73 super(source); 74 this.entryName = entryName; 75 changeType = CHANGE_FILE; 76 } 77 78 86 public PropertyBundleEvent(Object source, String entryName, String itemName) { 87 super(source); 88 this.entryName = entryName; 89 this.itemName = itemName; 90 changeType = CHANGE_ITEM; 91 } 92 93 99 public int getChangeType() { 100 return changeType; 101 } 102 103 109 public String getEntryName() { 110 return entryName; 111 } 112 113 119 public String getItemName() { 120 return itemName; 121 } 122 123 126 public String toString() { 127 try { 128 String bundleName; 129 Object source = getSource(); 130 bundleName = source instanceof BundleStructure 131 ? ((BundleStructure) source).obj.getPrimaryFile().getName() 132 : ""; 134 String changeType; 135 switch (getChangeType()) { 136 case CHANGE_STRUCT : changeType = "STRUCT"; break; case CHANGE_ALL : changeType = "ALL"; break; case CHANGE_FILE : changeType = "FILE"; break; case CHANGE_ITEM : changeType = "ITEM"; break; default : changeType = "?"; break; } 142 143 StringBuffer buf = new StringBuffer (80); 144 buf.append("PropertyBundleEvent: bundle ") .append(bundleName); 146 buf.append(", changeType ").append(changeType); buf.append(", entry ").append(getEntryName()); buf.append(", item ").append(getItemName()); return buf.toString(); 150 } 151 catch (Exception e) { 152 return "some PropertyBundleEvent exception (" + e.toString() + ") occurred"; } 155 } 156 157 } 158 | Popular Tags |