# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: /space/work/all3/openide/fs # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: src/org/openide/filesystems/FileChangeManager.java *** /space/work/all3/openide/fs/src/org/openide/filesystems/FileChangeManager.java No Base Revision --- /space/work/all3/openide/fs/src/org/openide/filesystems/FileChangeManager.java Locally New *************** *** 1,0 **** --- 1,71 ---- + /* + * The contents of this file are subject to the terms of the Common Development + * and Distribution License (the License). You may not use this file except in + * compliance with the License. + * + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html + * or http://www.netbeans.org/cddl.txt. + * + * When distributing Covered Code, include this CDDL Header Notice in each file + * and include the License file at http://www.netbeans.org/cddl.txt. + * If applicable, add the following below the CDDL Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun + * Microsystems, Inc. All Rights Reserved. + */ + + package org.openide.filesystems; + + import java.net.URI; + import java.util.EventListener; + import org.openide.filesystems.spi.FileModificationEventSource; + import org.openide.filesystems.spi.FileChangeSource; + import org.openide.util.Lookup; + /** + * + * @author Radek Matous + */ + public final class FileChangeManager { + private final FileChangeSource impl; + + public static boolean addFileModificationListener(URI uri, boolean recursive, FileModificationListener listener) { + FileChangeManager m = getInstance(getFileModificationEventSource(uri)); + if (m != null) { + m.addListener(uri, recursive, listener); + } + return m != null; + } + + public static boolean removeFileModificationListener(URI uri, FileModificationListener listener) { + FileChangeManager m = getInstance(getFileModificationEventSource(uri)); + if (m != null) { + m.removeListener(uri, listener); + } + return m != null; + } + + private static FileChangeSource getFileModificationEventSource(final URI uri) { + //TODO: if there are other providers - use Lookup.Result and listen on changes + FileModificationEventSource provider = Lookup.getDefault().lookup(FileModificationEventSource.class); + return (provider != null) ? provider.forScheme(uri.getScheme()) : null; + } + + private FileChangeManager(FileChangeSource impl) { + this.impl = impl; + } + + private void addListener(URI uri, boolean recursive, ListenerType listener) { + impl.addListener(uri, recursive, listener); + } + + private void removeListener(URI uri, ListenerType listener) { + impl.removeListener(uri, listener); + } + + private static final FileChangeManager getInstance(FileChangeSource provider) { + return (provider != null) ? new FileChangeManager(provider) : null; + } + } Index: src/org/openide/filesystems/spi/FileChangeSource.java *** /space/work/all3/openide/fs/src/org/openide/filesystems/spi/FileChangeSource.java No Base Revision --- /space/work/all3/openide/fs/src/org/openide/filesystems/spi/FileChangeSource.java Locally New *************** *** 1,0 **** --- 1,31 ---- + /* + * The contents of this file are subject to the terms of the Common Development + * and Distribution License (the License). You may not use this file except in + * compliance with the License. + * + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html + * or http://www.netbeans.org/cddl.txt. + * + * When distributing Covered Code, include this CDDL Header Notice in each file + * and include the License file at http://www.netbeans.org/cddl.txt. + * If applicable, add the following below the CDDL Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun + * Microsystems, Inc. All Rights Reserved. + */ + + package org.openide.filesystems.spi; + + import java.net.URI; + import java.util.EventListener; + + /** + * @author Radek Matous + */ + public interface FileChangeSource { + void addListener(URI uri, boolean recursive, T listener); + void removeListener(URI uri, T listener); + } Index: src/org/openide/filesystems/FileModificationEvent.java *** /space/work/all3/openide/fs/src/org/openide/filesystems/FileModificationEvent.java No Base Revision --- /space/work/all3/openide/fs/src/org/openide/filesystems/FileModificationEvent.java Locally New *************** *** 1,0 **** --- 1,62 ---- + /* + * The contents of this file are subject to the terms of the Common Development + * and Distribution License (the License). You may not use this file except in + * compliance with the License. + * + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html + * or http://www.netbeans.org/cddl.txt. + * + * When distributing Covered Code, include this CDDL Header Notice in each file + * and include the License file at http://www.netbeans.org/cddl.txt. + * If applicable, add the following below the CDDL Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun + * Microsystems, Inc. All Rights Reserved. + */ + + package org.openide.filesystems; + + import java.lang.IllegalArgumentException; + import java.net.URI; + import java.util.EventObject; + + /** + * + * @author Radek Matous + */ + public final class FileModificationEvent extends EventObject { + public static enum Type { CREATED, DELETED, MODIFIED, RENAMED}; + + private URI resource; + private URI oldResource; + private Type modificationType; + + public FileModificationEvent(Object source, Type modificationType, URI resource) { + this(source, modificationType, resource, resource); + if (modificationType.equals(Type.RENAMED)) { + throw new IllegalArgumentException(); + } + } + + public FileModificationEvent(Object source, Type modificationType, URI resource, URI oldResource) { + super(source); + this.resource = resource; + this.modificationType = modificationType; + this.oldResource = oldResource; + } + + public final Type getType() { + return modificationType; + } + + public final URI getOldFileResource() { + return oldResource; + } + + public final URI getFileResource() { + return resource; + } + } Index: src/org/openide/filesystems/spi/FileModificationEventSource.java *** /space/work/all3/openide/fs/src/org/openide/filesystems/spi/FileModificationEventSource.java No Base Revision --- /space/work/all3/openide/fs/src/org/openide/filesystems/spi/FileModificationEventSource.java Locally New *************** *** 1,0 **** --- 1,29 ---- + /* + * The contents of this file are subject to the terms of the Common Development + * and Distribution License (the License). You may not use this file except in + * compliance with the License. + * + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html + * or http://www.netbeans.org/cddl.txt. + * + * When distributing Covered Code, include this CDDL Header Notice in each file + * and include the License file at http://www.netbeans.org/cddl.txt. + * If applicable, add the following below the CDDL Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun + * Microsystems, Inc. All Rights Reserved. + */ + + package org.openide.filesystems.spi; + + import org.openide.filesystems.FileModificationListener; + + /** + * @author Radek Matous + */ + public interface FileModificationEventSource { + FileChangeSource forScheme(final String scheme); + } Index: src/org/openide/filesystems/FileModificationListener.java *** /space/work/all3/openide/fs/src/org/openide/filesystems/FileModificationListener.java No Base Revision --- /space/work/all3/openide/fs/src/org/openide/filesystems/FileModificationListener.java Locally New *************** *** 1,0 **** --- 1,30 ---- + /* + * The contents of this file are subject to the terms of the Common Development + * and Distribution License (the License). You may not use this file except in + * compliance with the License. + * + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html + * or http://www.netbeans.org/cddl.txt. + * + * When distributing Covered Code, include this CDDL Header Notice in each file + * and include the License file at http://www.netbeans.org/cddl.txt. + * If applicable, add the following below the CDDL Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun + * Microsystems, Inc. All Rights Reserved. + */ + + package org.openide.filesystems; + + import java.util.EventListener; + + /** + * + * @author Radek Matous + */ + public interface FileModificationListener extends EventListener { + public void fileChanged(FileModificationEvent event); + } Index: nbproject/project.xml *** /space/work/all3/openide/fs/nbproject/project.xml Base (1.11) --- /space/work/all3/openide/fs/nbproject/project.xml Locally Modified (Based On 1.11) *************** *** 47,52 **** --- 47,53 ---- org.openide.filesystems + org.openide.filesystems.spi