Lines 302-311
Link Here
|
302 |
|
302 |
|
303 |
private IOHandler getMoveHandlerIntern(File from, File to) { |
303 |
private IOHandler getMoveHandlerIntern(File from, File to) { |
304 |
DelegatingInterceptor dic = getInterceptor(from, to, "beforeMove", "doMove"); // NOI18N |
304 |
DelegatingInterceptor dic = getInterceptor(from, to, "beforeMove", "doMove"); // NOI18N |
305 |
return dic.beforeMove() ? dic : null; |
305 |
return dic.beforeMove() ? dic.getMoveHandler() : null; |
306 |
} |
306 |
} |
307 |
|
307 |
|
308 |
@Override |
308 |
@Override |
|
|
309 |
public void moveSuccess(FileObject from, File to) { |
310 |
getInterceptor(FileUtil.toFile(from), to, "afterMove").afterMove(); |
311 |
} |
312 |
|
313 |
@Override |
309 |
public void fileRenamed(FileRenameEvent fe) { |
314 |
public void fileRenamed(FileRenameEvent fe) { |
310 |
LOG.log(Level.FINE, "fileRenamed {0}", fe.getFile()); |
315 |
LOG.log(Level.FINE, "fileRenamed {0}", fe.getFile()); |
311 |
removeFromDeletedFiles(fe.getFile()); |
316 |
removeFromDeletedFiles(fe.getFile()); |
Lines 318-323
Link Here
|
318 |
// not interested |
323 |
// not interested |
319 |
} |
324 |
} |
320 |
|
325 |
|
|
|
326 |
// ================================================================================================== |
327 |
// COPY |
328 |
// ================================================================================================== |
329 |
|
330 |
@Override |
331 |
public IOHandler getCopyHandler(File from, File to) { |
332 |
LOG.log(Level.FINE, "getCopyHandler {0}, {1}", new Object[] {from, to}); |
333 |
return getCopyHandlerIntern(from, to); |
334 |
} |
335 |
|
336 |
private IOHandler getCopyHandlerIntern(File from, File to) { |
337 |
DelegatingInterceptor dic = getInterceptor(from, to, "beforeCopy", "doCopy"); // NOI18N |
338 |
return dic.beforeCopy() ? dic.getCopyHandler() : null; |
339 |
} |
340 |
|
341 |
@Override |
342 |
public void beforeCopy(FileObject from, File to) { } |
343 |
|
344 |
@Override |
345 |
public void copySuccess(FileObject from, File to) { |
346 |
getInterceptor(FileUtil.toFile(from), to, "afterCopy").afterCopy(); |
347 |
} |
348 |
|
349 |
@Override |
350 |
public void copyFailure(FileObject from, File to) { } |
351 |
|
321 |
/** |
352 |
/** |
322 |
* There is a contract that says that when a file is locked, it is expected to be changed. This is what openide/text |
353 |
* There is a contract that says that when a file is locked, it is expected to be changed. This is what openide/text |
323 |
* does when it creates a Document. A versioning system is expected to make the file r/w. |
354 |
* does when it creates a Document. A versioning system is expected to make the file r/w. |
Lines 407-413
Link Here
|
407 |
public void beforeEdit() { } |
438 |
public void beforeEdit() { } |
408 |
public void afterChange() { } |
439 |
public void afterChange() { } |
409 |
public void afterMove() { } |
440 |
public void afterMove() { } |
410 |
public void handle() throws IOException { } |
|
|
411 |
public boolean delete(File file) { throw new UnsupportedOperationException(); } |
441 |
public boolean delete(File file) { throw new UnsupportedOperationException(); } |
412 |
}; |
442 |
}; |
413 |
|
443 |
|
Lines 418-424
Link Here
|
418 |
*/ |
448 |
*/ |
419 |
private final Set<File> deletedFiles = new HashSet<File>(5); |
449 |
private final Set<File> deletedFiles = new HashSet<File>(5); |
420 |
|
450 |
|
421 |
private class DelegatingInterceptor implements IOHandler, DeleteHandler { |
451 |
private class DelegatingInterceptor implements DeleteHandler { |
422 |
|
452 |
|
423 |
final Collection<VCSInterceptor> interceptors; |
453 |
final Collection<VCSInterceptor> interceptors; |
424 |
final VCSInterceptor interceptor; |
454 |
final VCSInterceptor interceptor; |
Lines 426-431
Link Here
|
426 |
final File file; |
456 |
final File file; |
427 |
final File to; |
457 |
final File to; |
428 |
private final boolean isDirectory; |
458 |
private final boolean isDirectory; |
|
|
459 |
private IOHandler moveHandler; |
460 |
private IOHandler copyHandler; |
429 |
|
461 |
|
430 |
private DelegatingInterceptor() { |
462 |
private DelegatingInterceptor() { |
431 |
this((VCSInterceptor) null, null, null, null, false); |
463 |
this((VCSInterceptor) null, null, null, null, false); |
Lines 488-493
Link Here
|
488 |
interceptor.afterMove(file, to); |
520 |
interceptor.afterMove(file, to); |
489 |
} |
521 |
} |
490 |
|
522 |
|
|
|
523 |
public boolean beforeCopy() { |
524 |
lhInterceptor.beforeCopy(file, to); |
525 |
return interceptor.beforeCopy(file, to); |
526 |
} |
527 |
|
528 |
public void doCopy() throws IOException { |
529 |
lhInterceptor.doCopy(file, to); |
530 |
interceptor.doCopy(file, to); |
531 |
} |
532 |
|
533 |
public void afterCopy() { |
534 |
lhInterceptor.afterCopy(file, to); |
535 |
interceptor.afterCopy(file, to); |
536 |
} |
537 |
|
491 |
public boolean beforeCreate() { |
538 |
public boolean beforeCreate() { |
492 |
lhInterceptor.beforeCreate(file, isDirectory); |
539 |
lhInterceptor.beforeCreate(file, isDirectory); |
493 |
return interceptor.beforeCreate(file, isDirectory); |
540 |
return interceptor.beforeCreate(file, isDirectory); |
Lines 518-535
Link Here
|
518 |
interceptor.beforeEdit(file); |
565 |
interceptor.beforeEdit(file); |
519 |
} |
566 |
} |
520 |
|
567 |
|
521 |
/** |
568 |
private IOHandler getMoveHandler() { |
522 |
* We are doing MOVE here, inspite of the generic name of the method. |
569 |
if(moveHandler == null) { |
523 |
* |
570 |
moveHandler = new IOHandler() { |
524 |
* @throws IOException |
571 |
@Override |
525 |
*/ |
|
|
526 |
public void handle() throws IOException { |
572 |
public void handle() throws IOException { |
527 |
lhInterceptor.doMove(file, to); |
573 |
doMove(); |
528 |
interceptor.doMove(file, to); |
|
|
529 |
lhInterceptor.afterMove(file, to); |
530 |
interceptor.afterMove(file, to); |
531 |
} |
574 |
} |
|
|
575 |
}; |
576 |
} |
577 |
return moveHandler; |
578 |
} |
532 |
|
579 |
|
|
|
580 |
private IOHandler getCopyHandler() { |
581 |
if(copyHandler == null) { |
582 |
copyHandler = new IOHandler() { |
583 |
@Override |
584 |
public void handle() throws IOException { |
585 |
doCopy(); |
586 |
} |
587 |
}; |
588 |
} |
589 |
return copyHandler; |
590 |
} |
591 |
|
533 |
/** |
592 |
/** |
534 |
* This must act EXACTLY like java.io.File.delete(). This means: |
593 |
* This must act EXACTLY like java.io.File.delete(). This means: |
535 |
|
594 |
|