Lines 119-124
Link Here
|
119 |
import org.openide.filesystems.FileStateInvalidException; |
119 |
import org.openide.filesystems.FileStateInvalidException; |
120 |
import org.openide.filesystems.FileUtil; |
120 |
import org.openide.filesystems.FileUtil; |
121 |
import org.openide.filesystems.URLMapper; |
121 |
import org.openide.filesystems.URLMapper; |
|
|
122 |
import org.openide.util.Exceptions; |
122 |
import org.openide.util.Lookup; |
123 |
import org.openide.util.Lookup; |
123 |
import org.openide.util.NbBundle; |
124 |
import org.openide.util.NbBundle; |
124 |
import org.openide.util.Parameters; |
125 |
import org.openide.util.Parameters; |
Lines 350-355
Link Here
|
350 |
// ----------------------------------------------------------------------- |
351 |
// ----------------------------------------------------------------------- |
351 |
// FileChangeListener implementation |
352 |
// FileChangeListener implementation |
352 |
// ----------------------------------------------------------------------- |
353 |
// ----------------------------------------------------------------------- |
|
|
354 |
|
355 |
final FileEventLog eventQueue = new FileEventLog(); |
353 |
|
356 |
|
354 |
public void fileFolderCreated(FileEvent fe) { |
357 |
public void fileFolderCreated(FileEvent fe) { |
355 |
if (!authorize(fe)) { |
358 |
if (!authorize(fe)) { |
Lines 369-381
Link Here
|
369 |
boolean sourcForBinaryRoot = sourcesForBinaryRoots.contains(root); |
372 |
boolean sourcForBinaryRoot = sourcesForBinaryRoots.contains(root); |
370 |
ClassPath.Entry entry = sourcForBinaryRoot ? null : getClassPathEntry(URLMapper.findFileObject(root)); |
373 |
ClassPath.Entry entry = sourcForBinaryRoot ? null : getClassPathEntry(URLMapper.findFileObject(root)); |
371 |
if (entry == null || entry.includes(fo)) { |
374 |
if (entry == null || entry.includes(fo)) { |
372 |
scheduleWork(new FileListWork(scannedRoots2Dependencies, root, Collections.singleton(fo), false, false, true, sourcForBinaryRoot), false); |
375 |
final Work wrk = new FileListWork(scannedRoots2Dependencies, root, Collections.singleton(fo), false, false, true, sourcForBinaryRoot); |
|
|
376 |
eventQueue.record(FileEventLog.FileOp.CREATE, root, fe, wrk); |
373 |
processed = true; |
377 |
processed = true; |
374 |
} |
378 |
} |
375 |
} else { |
379 |
} else { |
376 |
root = getOwningBinaryRoot(fo); |
380 |
root = getOwningBinaryRoot(fo); |
377 |
if (root != null) { |
381 |
if (root != null) { |
378 |
scheduleWork(new BinaryWork(root), false); |
382 |
final Work wrk = new BinaryWork(root); |
|
|
383 |
eventQueue.record(FileEventLog.FileOp.CREATE, root, root, fe, wrk); |
379 |
processed = true; |
384 |
processed = true; |
380 |
} |
385 |
} |
381 |
} |
386 |
} |
Lines 406-418
Link Here
|
406 |
boolean sourceForBinaryRoot = sourcesForBinaryRoots.contains(root); |
411 |
boolean sourceForBinaryRoot = sourcesForBinaryRoots.contains(root); |
407 |
ClassPath.Entry entry = sourceForBinaryRoot ? null : getClassPathEntry(URLMapper.findFileObject(root)); |
412 |
ClassPath.Entry entry = sourceForBinaryRoot ? null : getClassPathEntry(URLMapper.findFileObject(root)); |
408 |
if (entry == null || entry.includes(fo)) { |
413 |
if (entry == null || entry.includes(fo)) { |
409 |
scheduleWork(new FileListWork(scannedRoots2Dependencies, root, Collections.singleton(fo), false, false, true, sourceForBinaryRoot), false); |
414 |
final Work wrk = new FileListWork(scannedRoots2Dependencies, root, Collections.singleton(fo), false, false, true, sourceForBinaryRoot); |
|
|
415 |
eventQueue.record(FileEventLog.FileOp.CREATE, root, fe, wrk); |
410 |
processed = true; |
416 |
processed = true; |
411 |
} |
417 |
} |
412 |
} else { |
418 |
} else { |
413 |
root = getOwningBinaryRoot(fo); |
419 |
root = getOwningBinaryRoot(fo); |
414 |
if (root != null) { |
420 |
if (root != null) { |
415 |
scheduleWork(new BinaryWork(root), false); |
421 |
final Work wrk = new BinaryWork(root); |
|
|
422 |
eventQueue.record(FileEventLog.FileOp.CREATE, root, root, fe, wrk); |
416 |
processed = true; |
423 |
processed = true; |
417 |
} |
424 |
} |
418 |
} |
425 |
} |
Lines 439-451
Link Here
|
439 |
if (fo.isData() /*&& FileUtil.getMIMEType(fo, recognizers.getMimeTypes())!=null*/) { |
446 |
if (fo.isData() /*&& FileUtil.getMIMEType(fo, recognizers.getMimeTypes())!=null*/) { |
440 |
String relativePath = FileUtil.getRelativePath(URLMapper.findFileObject(root), fo); |
447 |
String relativePath = FileUtil.getRelativePath(URLMapper.findFileObject(root), fo); |
441 |
assert relativePath != null : "FileObject not under root: f=" + fo + ", root=" + root; //NOI18N |
448 |
assert relativePath != null : "FileObject not under root: f=" + fo + ", root=" + root; //NOI18N |
442 |
scheduleWork(new DeleteWork(root, Collections.singleton(relativePath)), false); |
449 |
final Work wrk = new DeleteWork(root, Collections.singleton(relativePath)); |
|
|
450 |
eventQueue.record(FileEventLog.FileOp.DELETE, root, fe, wrk); |
443 |
processed = true; |
451 |
processed = true; |
444 |
} |
452 |
} |
445 |
} else { |
453 |
} else { |
446 |
root = getOwningBinaryRoot(fo); |
454 |
root = getOwningBinaryRoot(fo); |
447 |
if (root != null) { |
455 |
if (root != null) { |
448 |
scheduleWork(new BinaryWork(root), false); |
456 |
final Work wrk = new BinaryWork(root); |
|
|
457 |
eventQueue.record(FileEventLog.FileOp.DELETE, root, root, fe, wrk); |
449 |
processed = true; |
458 |
processed = true; |
450 |
} |
459 |
} |
451 |
} |
460 |
} |
Lines 472-497
Link Here
|
472 |
if (root != null) { |
481 |
if (root != null) { |
473 |
FileObject rootFo = URLMapper.findFileObject(root); |
482 |
FileObject rootFo = URLMapper.findFileObject(root); |
474 |
String oldFilePath = FileUtil.getRelativePath(rootFo, newFile.getParent()) + "/" + oldNameExt; //NOI18N |
483 |
String oldFilePath = FileUtil.getRelativePath(rootFo, newFile.getParent()) + "/" + oldNameExt; //NOI18N |
475 |
|
|
|
476 |
if (newFile.isData()) { |
484 |
if (newFile.isData()) { |
477 |
scheduleWork(new DeleteWork(root, Collections.singleton(oldFilePath)), false); |
485 |
final Work work = new DeleteWork(root, Collections.singleton(oldFilePath)); |
|
|
486 |
try { |
487 |
eventQueue.record(FileEventLog.FileOp.DELETE, root, Util.resolveUrl(root, oldFilePath), fe, work); |
488 |
} catch (MalformedURLException e) { |
489 |
Exceptions.printStackTrace(e); |
490 |
} |
478 |
} else { |
491 |
} else { |
479 |
Set<String> oldFilePaths = new HashSet<String>(); |
492 |
Set<String> oldFilePaths = new HashSet<String>(); |
480 |
collectFilePaths(newFile, oldFilePath, oldFilePaths); |
493 |
collectFilePaths(newFile, oldFilePath, oldFilePaths); |
481 |
scheduleWork(new DeleteWork(root, oldFilePaths), false); |
494 |
//ugly: need to register work for every file |
|
|
495 |
for (String path : oldFilePaths) { |
496 |
try { |
497 |
final Work work = new DeleteWork(root, oldFilePaths); |
498 |
eventQueue.record(FileEventLog.FileOp.DELETE, root, Util.resolveUrl(root, path), fe, work); |
499 |
} catch (MalformedURLException e) { |
500 |
Exceptions.printStackTrace(e); |
501 |
} |
502 |
} |
482 |
} |
503 |
} |
|
|
504 |
|
483 |
|
505 |
|
484 |
if (VisibilityQuery.getDefault().isVisible(newFile) && newFile.isData()) { |
506 |
if (VisibilityQuery.getDefault().isVisible(newFile) && newFile.isData()) { |
485 |
final boolean sourceForBinaryRoot = sourcesForBinaryRoots.contains(root); |
507 |
final boolean sourceForBinaryRoot = sourcesForBinaryRoots.contains(root); |
486 |
ClassPath.Entry entry = sourceForBinaryRoot ? null : getClassPathEntry(rootFo); |
508 |
ClassPath.Entry entry = sourceForBinaryRoot ? null : getClassPathEntry(rootFo); |
487 |
if (entry == null || entry.includes(newFile)) { |
509 |
if (entry == null || entry.includes(newFile)) { |
488 |
// delaying of this task was just copied from the old java.source RepositoryUpdater |
|
|
489 |
final FileListWork flw = new FileListWork(scannedRoots2Dependencies,root, Collections.singleton(newFile), false, false, true, sourceForBinaryRoot); |
510 |
final FileListWork flw = new FileListWork(scannedRoots2Dependencies,root, Collections.singleton(newFile), false, false, true, sourceForBinaryRoot); |
490 |
RequestProcessor.getDefault().create(new Runnable() { |
511 |
eventQueue.record(FileEventLog.FileOp.CREATE, root, fe,flw); |
491 |
public void run() { |
|
|
492 |
scheduleWork(flw, false); |
493 |
} |
494 |
}).schedule(FILE_LOCKS_DELAY); |
495 |
} |
512 |
} |
496 |
} |
513 |
} |
497 |
processed = true; |
514 |
processed = true; |
Lines 502-514
Link Here
|
502 |
if (parentFile != null) { |
519 |
if (parentFile != null) { |
503 |
try { |
520 |
try { |
504 |
URL oldBinaryRoot = new File (parentFile, oldNameExt).toURI().toURL(); |
521 |
URL oldBinaryRoot = new File (parentFile, oldNameExt).toURI().toURL(); |
505 |
scheduleWork(new BinaryWork(oldBinaryRoot), false); |
522 |
eventQueue.record(FileEventLog.FileOp.DELETE, oldBinaryRoot, oldBinaryRoot, fe, new BinaryWork(oldBinaryRoot)); |
506 |
} catch (MalformedURLException mue) { |
523 |
} catch (MalformedURLException mue) { |
507 |
LOGGER.log(Level.WARNING, null, mue); |
524 |
LOGGER.log(Level.WARNING, null, mue); |
508 |
} |
525 |
} |
509 |
} |
526 |
} |
510 |
|
527 |
|
511 |
scheduleWork(new BinaryWork(root), false); |
528 |
eventQueue.record(FileEventLog.FileOp.CREATE, root, root, fe,new BinaryWork(root)); |
512 |
processed = true; |
529 |
processed = true; |
513 |
} |
530 |
} |
514 |
} |
531 |
} |