1 19 20 package org.openide.filesystems; 21 22 import java.util.Date ; 23 import java.util.EventObject ; 24 25 32 public class FileEvent extends EventObject { 33 34 private static final long serialVersionUID = 1028087432345400108L; 35 36 37 private FileObject file; 38 39 40 private long time; 41 42 43 private boolean expected; 44 45 46 private EventControl.AtomicActionLink atomActionID; 47 48 52 public FileEvent(FileObject src) { 53 this(src, src); 54 } 55 56 66 public FileEvent(FileObject src, FileObject file) { 67 super(src); 68 this.file = file; 69 this.time = System.currentTimeMillis(); 70 } 71 72 76 FileEvent(FileObject src, FileObject file, long time) { 77 this(src, file); 78 this.time = time; 79 } 80 81 92 public FileEvent(FileObject src, FileObject file, boolean expected) { 93 this(src, file); 94 this.expected = expected; 95 } 96 97 99 public final FileObject getFile() { 100 return file; 101 } 102 103 106 public final long getTime() { 107 return time; 108 } 109 110 112 public final boolean isExpected() { 113 return expected; 114 } 115 116 @Override 117 public String toString() { 118 StringBuilder b = new StringBuilder (); 119 b.append(getClass().getName().replaceFirst(".+\\.", "")); 120 b.append('['); 121 FileObject src = (FileObject) getSource(); 122 if (src != file) { 123 b.append("src="); 124 b.append(FileUtil.getFileDisplayName(src)); 125 b.append(','); 126 } 127 b.append("file="); 128 b.append(FileUtil.getFileDisplayName(file)); 129 b.append(",time="); 130 b.append(new Date (time)); 131 b.append(",expected="); 132 b.append(expected); 133 insertIntoToString(b); 134 b.append(']'); 135 return b.toString(); 136 } 137 void insertIntoToString(StringBuilder b) {} 138 139 140 void setAtomicActionLink(EventControl.AtomicActionLink atomActionID) { 141 this.atomActionID = atomActionID; 142 } 143 144 149 public boolean firedFrom(FileSystem.AtomicAction run) { 150 EventControl.AtomicActionLink currentPropID = this.atomActionID; 151 152 if (run == null) { 153 return false; 154 } 155 156 while (currentPropID != null) { 157 if (run.equals(currentPropID.getAtomicAction())) { 158 return true; 159 } 160 161 currentPropID = currentPropID.getPreviousLink(); 162 } 163 164 return false; 165 } 166 } 167 | Popular Tags |