Examples of FileEvent


Examples of org.springframework.roo.file.monitor.event.FileEvent

                final Map<File, Long> priorFiles = priorExecution.get(request);
                for (final Entry<File, Long> entry : priorFiles.entrySet()) {
                    final File thisFile = entry.getKey();
                    final Long lastModified = entry.getValue();
                    eventsToPublish.add(new FileEvent(new FileDetails(thisFile,
                            lastModified), FileOperation.MONITORING_FINISH,
                            null));
                }
                publish(eventsToPublish);
            }
View Full Code Here

Examples of org.springframework.roo.file.monitor.event.FileEvent

                        final File thisFile = entry.getKey();
                        final Long currentTimestamp = entry.getValue();
                        if (!priorFiles.containsKey(thisFile)) {
                            // This file did not exist last execution, so it
                            // must be new
                            eventsToPublish.add(new FileEvent(new FileDetails(
                                    thisFile, currentTimestamp),
                                    FileOperation.CREATED, null));
                            try {
                                // If this file was already going to be
                                // notified, there is no need to do it twice
                                notifyCreated.remove(thisFile
                                        .getCanonicalPath());
                            }
                            catch (final IOException ignored) {
                            }
                            continue;
                        }

                        final Long previousTimestamp = priorFiles.get(thisFile);
                        if (!currentTimestamp.equals(previousTimestamp)) {
                            // Modified
                            eventsToPublish.add(new FileEvent(new FileDetails(
                                    thisFile, currentTimestamp),
                                    FileOperation.UPDATED, null));
                            try {
                                // If this file was already going to be
                                // notified, there is no need to do it twice
                                notifyChanged.remove(thisFile
                                        .getCanonicalPath());
                            }
                            catch (final IOException ignored) {
                            }
                        }
                    }

                    // Now locate deleted files
                    priorFiles.keySet().removeAll(currentExecution.keySet());
                    for (final Entry<File, Long> entry : priorFiles.entrySet()) {
                        final File deletedFile = entry.getKey();
                        eventsToPublish.add(new FileEvent(new FileDetails(
                                deletedFile, entry.getValue()),
                                FileOperation.DELETED, null));
                        try {
                            // If this file was already going to be notified,
                            // there is no need to do it twice
                            notifyDeleted
                                    .remove(deletedFile.getCanonicalPath());
                        }
                        catch (final IOException ignored) {
                        }
                    }
                }
                else {
                    // No data from previous execution, so it's a
                    // newly-monitored location
                    for (final Entry<File, Long> entry : currentExecution
                            .entrySet()) {
                        eventsToPublish.add(new FileEvent(new FileDetails(entry
                                .getKey(), entry.getValue()),
                                FileOperation.MONITORING_START, null));
                    }
                }

                // Record the monitored location's contents, ready for next
                // execution
                priorExecution.put(request, currentExecution);

                // We can discard the created and deleted notifications, as they
                // would have been correctly discovered in the above loop
                notifyCreated.clear();
                notifyDeleted.clear();

                // Explicitly handle any undiscovered update notifications, as
                // this indicates an identical millisecond update occurred
                for (final String canonicalPath : notifyChanged) {
                    final File file = new File(canonicalPath);
                    eventsToPublish.add(new FileEvent(new FileDetails(file,
                            file.lastModified()), FileOperation.UPDATED, null));
                }
                notifyChanged.clear();
                publish(eventsToPublish);
View Full Code Here

Examples of rabbit.data.store.model.FileEvent

      // But both are views, not editors,so they are not added,
      // one for the newly opened editor.
      assertEquals(1, tracker.getData().size());

      Iterator<FileEvent> it = tracker.getData().iterator();
      FileEvent event = it.next();
      assertTrue(hasSamePart(event, editor));

      long start = event.getInterval().getStartMillis();
      long end = event.getInterval().getEndMillis();
      checkTime(preStart, start, postStart, preEnd, end, postEnd);
      assertTrue(hasSamePart(event, editor));

    } finally {
      win.close();
View Full Code Here

Examples of rabbit.data.store.model.FileEvent

    }
  }

  @Override
  protected FileEvent createEvent() {
    return new FileEvent(new Interval(0, 1),
        Path.fromPortableString("/p/f/a.txt"));
  }
View Full Code Here

Examples of rabbit.data.store.model.FileEvent

                               DataStore.FILE_STORE);
  }

  @Override
  protected FileEvent createEvent(DateTime t) {
    return new FileEvent(new Interval(t, t.plus(1)), new Path("/some"));
  }
View Full Code Here

Examples of rabbit.data.store.model.FileEvent

    return new FileEvent(new Interval(t, t.plus(1)), new Path("/some"));
  }

  @Override
  protected FileEvent createEventDiff(DateTime t) {
    return new FileEvent(new Interval(t, t.plus(2)), new Path("/some/some"));
  }
View Full Code Here

Examples of rabbit.data.store.model.FileEvent

    return new FileEventConverter();
  }

  @Override
  public void testConvert() throws Exception {
    FileEvent event = new FileEvent(new Interval(0, 1), new Path("/file/acb"));
    FileEventType type = converter.convert(event);
    assertEquals(event.getFilePath().toString(), type.getFilePath());
    assertEquals(event.getInterval().toDurationMillis(), type.getDuration());
  }
View Full Code Here

Examples of rabbit.data.store.model.FileEvent

  }

  @Test
  public void testGetFilePath() {
    IPath path = Path.fromPortableString("/project/folder/me.txt");
    FileEvent event = createEvent(new Interval(0, 1), path);
    assertEquals(path, event.getFilePath());
  }
View Full Code Here

Examples of rabbit.data.store.model.FileEvent

 
  /**
   * @see FileEvent#FileEvent(Interval, IPath)
   */
  protected FileEvent createEvent(Interval interval, IPath filePath) {
    return new FileEvent(interval, filePath);
  }
View Full Code Here

Examples of rabbit.data.store.model.FileEvent

       * "C:/a.txt". We want workspace paths wherever possible.
       */
      if (input instanceof IFileEditorInput) {
        // Contains a file in the workspace
        IFile file = ((IFileEditorInput) input).getFile();
        return new FileEvent(new Interval(start, end), file.getFullPath());

      } else if (input instanceof IURIEditorInput) {
        // A file outside of workspace
        URI uri = ((IURIEditorInput) input).getURI();
        IPath path = new Path(uri.getPath());
        return new FileEvent(new Interval(start, end), path);
      }
    }
    return null;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.