1 33 34 package edu.rice.cs.drjava.model; 35 36 import java.io.File ; 37 import java.io.Serializable ; 38 import java.util.List ; 39 40 import edu.rice.cs.drjava.model.compiler.CompilerListener; 41 import edu.rice.cs.util.FileOpenSelector; 42 import edu.rice.cs.util.classloader.ClassFileError; 43 import edu.rice.cs.util.swing.AsyncTask; 44 45 67 public class GlobalEventNotifier extends EventNotifier<GlobalModelListener> 68 implements GlobalModelListener, Serializable { 69 70 public <P,R> void executeAsyncTask(AsyncTask<P,R> task, P param, boolean showProgress, boolean lockUI) { 71 _lock.startRead(); 72 try { for (GlobalModelListener l : _listeners) { l.executeAsyncTask(task, param, showProgress, lockUI); } } 73 finally { _lock.endRead(); } 74 } 75 76 public void fileNotFound(File f) { 77 _lock.startRead(); 78 try { for (GlobalModelListener l : _listeners) { l.fileNotFound(f); } } 79 finally { _lock.endRead(); } 80 } 81 82 88 public void handleAlreadyOpenDocument(OpenDefinitionsDocument doc) { 89 _lock.startRead(); 90 try { for(GlobalModelListener l : _listeners) { l.handleAlreadyOpenDocument(doc); } } 91 finally { _lock.endRead(); } 92 } 93 94 95 public void projectOpened(File pfile, FileOpenSelector files) { 96 _lock.startRead(); 97 try { for (GlobalModelListener l : _listeners) { l.projectOpened(pfile, files); } } 98 finally { _lock.endRead(); } 99 } 100 101 public void projectClosed() { 102 _lock.startRead(); 103 try { for (GlobalModelListener l : _listeners) { l.projectClosed();} } 104 finally { _lock.endRead(); } 105 } 106 107 public void projectModified() { 108 _lock.startRead(); 109 try { for (GlobalModelListener l : _listeners) { l.projectModified(); } } 110 finally { _lock.endRead(); } 111 } 112 113 public void projectBuildDirChanged() { 114 _lock.startRead(); 115 try { for (GlobalModelListener l : _listeners) { l.projectBuildDirChanged(); } } 116 finally { _lock.endRead(); } 117 } 118 119 public void projectWorkDirChanged() { 120 _lock.startRead(); 121 try { for (GlobalModelListener l : _listeners) { l.projectWorkDirChanged(); } } 122 finally { _lock.endRead(); } 123 } 124 125 public void projectRunnableChanged() { 126 _lock.startRead(); 127 try { for (GlobalModelListener l : _listeners) { l.projectRunnableChanged(); } } 128 finally { _lock.endRead(); } 129 } 130 131 132 133 134 137 public void notifyListeners(Notifier n) { 138 _lock.startRead(); 139 try { for (GlobalModelListener l : _listeners) { n.notifyListener(l); } } 140 finally { _lock.endRead(); } 141 } 142 143 149 @Deprecated 150 public boolean pollListeners(Poller p) { 151 _lock.startRead(); 152 try { 153 for (GlobalModelListener l: _listeners) { if (! p.poll(l)) return false; } 154 return true; 155 } 156 finally { _lock.endRead(); } 157 } 158 159 163 @Deprecated 164 public abstract static class Notifier { 165 public abstract void notifyListener(GlobalModelListener l); 166 } 167 168 172 @Deprecated 173 public abstract static class Poller { 174 public abstract boolean poll(GlobalModelListener l); 175 } 176 177 179 180 181 183 184 public void runStarted(OpenDefinitionsDocument doc) { 185 _lock.startRead(); 186 try { for (GlobalModelListener l : _listeners) { l.runStarted(doc); } } 187 finally { _lock.endRead(); } 188 } 189 190 191 public void newFileCreated(OpenDefinitionsDocument doc) { 192 _lock.startRead(); 193 try { for (GlobalModelListener l : _listeners) { l.newFileCreated(doc); } } 194 finally { _lock.endRead(); } 195 } 196 197 198 public void consoleReset() { 199 _lock.startRead(); 200 try { for (GlobalModelListener l : _listeners) { l.consoleReset(); } } 201 finally { _lock.endRead(); } 202 } 203 204 205 public void fileSaved(OpenDefinitionsDocument doc) { 206 _lock.startRead(); 209 try { for (GlobalModelListener l : _listeners) { l.fileSaved(doc); } } 210 finally { _lock.endRead(); } 211 } 212 213 214 public void fileOpened(OpenDefinitionsDocument doc) { 215 _lock.startRead(); 216 try { for (GlobalModelListener l : _listeners) { l.fileOpened(doc); } } 217 finally { _lock.endRead(); } 218 } 219 220 221 public void fileClosed(OpenDefinitionsDocument doc) { 222 _lock.startRead(); 223 try { for (GlobalModelListener l : _listeners) { l.fileClosed(doc); } } 224 finally { _lock.endRead(); } 225 } 226 227 228 public void fileReverted(OpenDefinitionsDocument doc) { 229 _lock.startRead(); 230 try { for (GlobalModelListener l : _listeners) { l.fileReverted(doc); } } 231 finally { _lock.endRead(); } 232 } 233 234 235 public void undoableEditHappened() { 236 _lock.startRead(); 237 try { for (GlobalModelListener l : _listeners) { l.undoableEditHappened(); } } 238 finally { _lock.endRead(); } 239 } 240 241 242 public boolean canAbandonFile(OpenDefinitionsDocument doc) { 243 _lock.startRead(); 244 try { 245 for (GlobalModelListener l: _listeners) { if (! l.canAbandonFile(doc)) return false; } 246 return true; 247 } 248 finally { _lock.endRead(); } 249 } 250 251 253 public boolean quitFile(OpenDefinitionsDocument doc) { 254 _lock.startRead(); 255 try { 256 for (GlobalModelListener l: _listeners) { if (!l.quitFile(doc)) return false; } 258 } 259 finally { _lock.endRead(); } 260 return true; 261 } 262 263 264 public boolean shouldRevertFile(OpenDefinitionsDocument doc) { 265 _lock.startRead(); 266 try { 267 for (GlobalModelListener l: _listeners) { if (! l.shouldRevertFile(doc)) return false; } 268 return true; 269 } 270 finally { _lock.endRead(); } 271 } 272 273 274 public void currentDirectoryChanged(File dir) { 275 _lock.startRead(); 276 try { for (GlobalModelListener l : _listeners) { l.currentDirectoryChanged(dir); } } 277 finally { _lock.endRead(); } 278 } 279 280 281 public void activeDocumentChanged(OpenDefinitionsDocument active) { 282 _lock.startRead(); 283 try { for (GlobalModelListener l : _listeners) { l.activeDocumentChanged(active); } } 284 finally { _lock.endRead(); } 285 } 286 287 288 public void focusOnDefinitionsPane() { 289 _lock.startRead(); 290 try { for (GlobalModelListener l : _listeners) { l.focusOnDefinitionsPane(); } } 291 finally { _lock.endRead(); } 292 } 293 302 304 305 public void interactionStarted() { 306 _lock.startRead(); 307 try { for (GlobalModelListener l : _listeners) { l.interactionStarted(); } } 308 finally { _lock.endRead(); } 309 } 310 311 312 public void interactionEnded() { 313 _lock.startRead(); 314 try { for (GlobalModelListener l : _listeners) { l.interactionEnded(); } } 315 finally { _lock.endRead(); } 316 } 317 318 322 public void interactionErrorOccurred(int offset, int length) { 323 _lock.startRead(); 324 try { for (GlobalModelListener l : _listeners) { l.interactionErrorOccurred(offset, length); } } 325 finally { _lock.endRead(); } 326 } 327 328 329 public void interpreterResetting() { 330 _lock.startRead(); 331 try { for (GlobalModelListener l : _listeners) { l.interpreterResetting(); } } 332 finally { _lock.endRead(); } 333 } 334 335 336 public void interpreterReady(File wd) { 337 _lock.startRead(); 338 try { for (GlobalModelListener l : _listeners) { l.interpreterReady(wd); } } 339 finally { _lock.endRead(); } 340 } 341 342 346 public void interpreterResetFailed(final Throwable t) { 347 _lock.startRead(); 348 try { for (GlobalModelListener l : _listeners) { l.interpreterResetFailed(t); } } 349 finally { _lock.endRead(); } 350 } 351 352 356 public void interpreterExited(int status) { 357 _lock.startRead(); 358 try { for (GlobalModelListener l : _listeners) { l.interpreterExited(status); } } 359 finally { _lock.endRead(); } 360 } 361 362 366 public void interpreterChanged(boolean inProgress) { 367 _lock.startRead(); 368 try { for (GlobalModelListener l : _listeners) { l.interpreterChanged(inProgress); } } 369 finally { _lock.endRead(); } 370 } 371 372 374 375 public void compileStarted() { 376 _lock.startRead(); 377 try { for (GlobalModelListener l : _listeners) { l.compileStarted(); } 378 } 379 finally { _lock.endRead(); } 380 } 381 382 383 public void compileEnded(File workDir, List <? extends File > excludedFiles) { 384 _lock.startRead(); 385 try { for (GlobalModelListener l : _listeners) { l.compileEnded(workDir, excludedFiles); } } 386 finally { _lock.endRead(); } 387 } 388 389 392 public void saveBeforeCompile() { 393 _lock.startRead(); 394 try { for (GlobalModelListener l : _listeners) { l.saveBeforeCompile(); } } 395 finally { _lock.endRead(); } 396 } 397 398 399 public void saveUntitled() { 400 _lock.startRead(); 401 try { for (GlobalModelListener l : _listeners) { l.saveUntitled(); } } 402 finally { _lock.endRead(); } 403 } 404 405 407 410 public void nonTestCase(boolean isTestAll) { 411 _lock.startRead(); 412 try { for (GlobalModelListener l : _listeners) { l.nonTestCase(isTestAll); } } 413 finally { _lock.endRead(); } 414 } 415 416 419 public void classFileError(ClassFileError e) { 420 _lock.startRead(); 421 try { for (GlobalModelListener l : _listeners) { l.classFileError(e); } } 422 finally { _lock.endRead(); } 423 } 424 425 428 public void compileBeforeJUnit(final CompilerListener cl) { 429 _lock.startRead(); 431 try { for (GlobalModelListener l : _listeners) { l.compileBeforeJUnit(cl); } } 432 finally { _lock.endRead(); } 433 } 434 435 436 public void junitStarted() { 437 _lock.startRead(); 438 try { for (GlobalModelListener l : _listeners) { l.junitStarted(); } } 439 finally { _lock.endRead(); } 440 } 441 442 443 public void junitClassesStarted() { 444 _lock.startRead(); 445 try { for (GlobalModelListener l : _listeners) { l.junitClassesStarted(); } } 446 finally { _lock.endRead(); } 447 } 448 449 452 public void junitSuiteStarted(int numTests) { 453 _lock.startRead(); 454 try { for (GlobalModelListener l : _listeners) { l.junitSuiteStarted(numTests); } } 455 finally { _lock.endRead(); } 456 } 457 458 461 public void junitTestStarted(String name) { 462 _lock.startRead(); 463 try { for (GlobalModelListener l : _listeners) { l.junitTestStarted(name); } } 464 finally { _lock.endRead(); } 465 } 466 467 472 public void junitTestEnded(String name, boolean wasSuccessful, boolean causedError) { 473 _lock.startRead(); 474 try { 475 for (GlobalModelListener l : _listeners) { l.junitTestEnded(name, wasSuccessful, causedError); } 476 } 477 finally { _lock.endRead(); } 478 } 479 480 481 public void junitEnded() { 482 _lock.startRead(); 483 try { for (GlobalModelListener l : _listeners) { l.junitEnded(); } } 484 finally { _lock.endRead(); } 485 } 486 487 502 504 505 public void javadocStarted() { 506 _lock.startRead(); 507 try { for (GlobalModelListener l : _listeners) { l.javadocStarted(); } } 508 finally { _lock.endRead(); } 509 } 510 511 516 public void javadocEnded(boolean success, File destDir, boolean allDocs) { 517 _lock.startRead(); 518 try { for (GlobalModelListener l : _listeners) { l.javadocEnded(success, destDir, allDocs); } } 519 finally { _lock.endRead(); } 520 } 521 522 523 526 public void saveBeforeJavadoc() { 527 _lock.startRead(); 528 try { for (GlobalModelListener l : _listeners) { l.saveBeforeJavadoc(); } } 529 finally { _lock.endRead(); } 530 } 531 532 541 542 public void interactionIncomplete() { 543 _lock.startRead(); 544 try { for (GlobalModelListener l : _listeners) { l.interactionIncomplete(); } } 545 finally { _lock.endRead(); } 546 } 547 548 public void slaveJVMUsed() { 549 _lock.startRead(); 550 try { for (GlobalModelListener l : _listeners) { l.slaveJVMUsed(); } } 551 finally { _lock.endRead(); } 552 } 553 554 555 public void filePathContainsPound() { 556 _lock.startRead(); 557 try { for (GlobalModelListener l : _listeners) { l.filePathContainsPound(); } } 558 finally { _lock.endRead(); } 559 } 560 561 public void documentNotFound(OpenDefinitionsDocument d, File f) { 563 _lock.startRead(); 564 try { for (GlobalModelListener l : _listeners) { l.documentNotFound(d,f); } } 565 finally { _lock.endRead(); } 566 } 567 } 568 | Popular Tags |