Esempio n. 1
0
 private VirtualFileSystemEntry applyEvent(@NotNull VFileEvent event) {
   try {
     if (event instanceof VFileCreateEvent) {
       final VFileCreateEvent createEvent = (VFileCreateEvent) event;
       return executeCreateChild(createEvent.getParent(), createEvent.getChildName());
     } else if (event instanceof VFileDeleteEvent) {
       final VFileDeleteEvent deleteEvent = (VFileDeleteEvent) event;
       executeDelete(deleteEvent.getFile());
     } else if (event instanceof VFileContentChangeEvent) {
       final VFileContentChangeEvent contentUpdateEvent = (VFileContentChangeEvent) event;
       executeTouch(
           contentUpdateEvent.getFile(),
           contentUpdateEvent.isFromRefresh(),
           contentUpdateEvent.getModificationStamp());
     } else if (event instanceof VFileCopyEvent) {
       final VFileCopyEvent copyEvent = (VFileCopyEvent) event;
       return executeCreateChild(copyEvent.getNewParent(), copyEvent.getNewChildName());
     } else if (event instanceof VFileMoveEvent) {
       final VFileMoveEvent moveEvent = (VFileMoveEvent) event;
       executeMove(moveEvent.getFile(), moveEvent.getNewParent());
     } else if (event instanceof VFilePropertyChangeEvent) {
       final VFilePropertyChangeEvent propertyChangeEvent = (VFilePropertyChangeEvent) event;
       if (VirtualFile.PROP_NAME.equals(propertyChangeEvent.getPropertyName())) {
         executeRename(propertyChangeEvent.getFile(), (String) propertyChangeEvent.getNewValue());
       } else if (VirtualFile.PROP_WRITABLE.equals(propertyChangeEvent.getPropertyName())) {
         executeSetWritable(
             propertyChangeEvent.getFile(),
             ((Boolean) propertyChangeEvent.getNewValue()).booleanValue());
       } else if (VirtualFile.PROP_HIDDEN.equals(propertyChangeEvent.getPropertyName())) {
         executeSetHidden(
             propertyChangeEvent.getFile(),
             ((Boolean) propertyChangeEvent.getNewValue()).booleanValue());
       } else if (VirtualFile.PROP_SYMLINK_TARGET.equals(propertyChangeEvent.getPropertyName())) {
         executeSetTarget(
             propertyChangeEvent.getFile(), (String) propertyChangeEvent.getNewValue());
       }
     }
   } catch (Exception e) {
     // Exception applying single event should not prevent other events from applying.
     LOG.error(e);
   }
   return null;
 }