Java Code Examples for org.openide.filesystems.FileEvent#getTime()

The following examples show how to use org.openide.filesystems.FileEvent#getTime() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImageNavigatorPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void fileChanged(final FileEvent fe) {
    if (fe.getTime() > lastSaveTime) {
        lastSaveTime = System.currentTimeMillis();

        // Refresh image viewer
        SwingUtilities.invokeLater(new Runnable() {

            public void run() {
                try {
                    currentDataObject = DataObject.find(fe.getFile());
                    setNewContent(currentDataObject);
                } catch (DataObjectNotFoundException ex) {
                    Logger.getLogger(ImageNavigatorPanel.class.getName()).info(NbBundle.getMessage(ImageNavigatorPanel.class, "ERR_DataObject"));
                }
            }
        });
    }
}
 
Example 2
Source File: NbMavenProjectImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
        public void fileChanged(FileEvent fileEvent) {
                if (lastTime < fileEvent.getTime()) {
                    lastTime = System.currentTimeMillis();
//                    System.out.println("fired based on " + fileEvent.getFile() + fileEvent.getTime());
                    NbMavenProject.fireMavenProjectReload(NbMavenProjectImpl.this);
                }
        }
 
Example 3
Source File: NbMavenProjectImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
        public void fileDataCreated(FileEvent fileEvent) {
                if (lastTime < fileEvent.getTime()) {
                    lastTime = System.currentTimeMillis();
//                    System.out.println("fired based on " + fileEvent.getFile() + fileEvent.getTime());
                    NbMavenProject.fireMavenProjectReload(NbMavenProjectImpl.this);
                }
        }
 
Example 4
Source File: NbGradleProjectImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void fileDataCreated(FileEvent fe) {
    if (lastEventTime < fe.getTime()) {
        lastEventTime = System.currentTimeMillis();
        fireProjectReload(false);
    }
}
 
Example 5
Source File: NbGradleProjectImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void fileChanged(FileEvent fe) {
    if (lastEventTime < fe.getTime()) {
        lastEventTime = System.currentTimeMillis();
        fireProjectReload(false);
    }
}
 
Example 6
Source File: StorageImpl.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private boolean filterEvents(FileEvent event) {
    // filter out anything that does not match required file path pattern
    if (!controlledFilesPattern.matcher(event.getFile().getPath()).matches()) {
        if (LOG.isLoggable(Level.FINER)) {
            LOG.finer(event.getFile().getPath() + " does not match: " + controlledFilesPattern.pattern()); //NOI18N
        }
        return true;
    }

    // filter out our own events
    final FileSystem.AtomicAction aa = atomicAction;
    if (aa != null && event.firedFrom(aa)) {
        if (LOG.isLoggable(Level.FINER)) {
            LOG.finer("Filesystem event for " + event.getFile().getPath() + " caused by saving settings"); //NOI18N
        }
        return true;
    }
    
    // filter out duplicate events, maybe this does not have any effect
    synchronized (recentEvents) {
        for(Iterator<Reference<FileEvent>> i = recentEvents.iterator(); i.hasNext(); ) {
            Reference<FileEvent> ref = i.next();
            FileEvent e = ref.get();
            if (e == null) {
                i.remove();
            } else {
                if (e == event) {
                    if (LOG.isLoggable(Level.FINE)) {
                        LOG.fine("Filtering out duplicate filesystem event (1): original=[" + printEvent(e) + "]" //NOI18N
                            + ", duplicate=[" + printEvent(event) + "]"); //NOI18N
                    }
                    return true;
                }
                
                if (e.getTime() == event.getTime() && e.getFile().getPath().equals(event.getFile().getPath())) {
                    if (LOG.isLoggable(Level.FINE)) {
                        LOG.fine("Filtering out duplicate filesystem event (2): original=[" + printEvent(e) + "]" //NOI18N
                                + ", duplicate=[" + printEvent(event) + "]"); //NOI18N
                    }
                    return true;
                }
            }
        }

        if (recentEvents.size() > 100) {
            recentEvents.remove(recentEvents.size() - 1);
        }
        recentEvents.add(0, new WeakReference<FileEvent>(event));
        return false;
    }
}
 
Example 7
Source File: StorageImpl.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private String printEvent(FileEvent event) {
    return event.getClass().getSimpleName() + "@" + Integer.toHexString(System.identityHashCode(event)) //NOI18N
            + ", ts=" + event.getTime() //NOI18N
            + ", path=" + event.getFile().getPath(); //NOI18N
}