1 19 20 package org.netbeans.modules.masterfs; 21 22 import java.io.File ; 23 import java.io.IOException ; 24 import java.util.Collection ; 25 import java.util.Iterator ; 26 import org.netbeans.modules.masterfs.providers.AnnotationProvider; 27 import org.netbeans.modules.masterfs.providers.InterceptionListener; 28 import org.netbeans.modules.masterfs.providers.ProvidedExtensions; 29 import org.netbeans.modules.masterfs.providers.ProvidedExtensions.IOHandler; 30 import org.openide.filesystems.FileObject; 31 32 36 public class ProvidedExtensionsProxy extends ProvidedExtensions { 37 private Collection annotationProviders; 38 39 40 public ProvidedExtensionsProxy(Collection annotationProviders) { 41 this.annotationProviders = annotationProviders; 42 } 43 44 public ProvidedExtensions.DeleteHandler getDeleteHandler(final File f) { 45 ProvidedExtensions.DeleteHandler retValue = null; 46 for (Iterator it = annotationProviders.iterator(); it.hasNext() && retValue == null;) { 47 AnnotationProvider provider = (AnnotationProvider) it.next(); 48 final InterceptionListener iListener = (provider != null) ? provider.getInterceptionListener() : null; 49 if (iListener instanceof ProvidedExtensions) { 50 retValue = ((ProvidedExtensions)iListener).getDeleteHandler(f); 51 } 52 } 53 return retValue; 54 } 55 56 public ProvidedExtensions.IOHandler getRenameHandler(final File from, final String newName) { 57 final File to = new File (from.getParentFile(), newName); 58 IOHandler retValue = null; 59 for (Iterator it = annotationProviders.iterator(); it.hasNext() && retValue == null;) { 60 AnnotationProvider provider = (AnnotationProvider) it.next(); 61 final InterceptionListener iListener = (provider != null) ? provider.getInterceptionListener() : null; 62 if (iListener instanceof ProvidedExtensions) { 63 retValue = ((ProvidedExtensions)iListener).getRenameHandler(from, newName); 64 } 65 } 66 return retValue; 67 } 68 69 public ProvidedExtensions.IOHandler getMoveHandler(final File from, final File to) { 70 IOHandler retValue = null; 71 for (Iterator it = annotationProviders.iterator(); it.hasNext() && retValue == null;) { 72 AnnotationProvider provider = (AnnotationProvider) it.next(); 73 InterceptionListener iListener = (provider != null) ? provider.getInterceptionListener() : null; 74 if (iListener instanceof ProvidedExtensions) { 75 retValue = ((ProvidedExtensions)iListener).getMoveHandler(from, to); 76 } 77 } 78 return retValue; 79 } 80 81 public void createFailure(FileObject parent, String name, boolean isFolder) { 82 for (Iterator it = annotationProviders.iterator(); it.hasNext();) { 83 AnnotationProvider provider = (AnnotationProvider) it.next(); 84 InterceptionListener iListener = (provider != null) ? provider.getInterceptionListener() : null; 85 if (iListener != null) { 86 iListener.createFailure(parent, name, isFolder); 87 } 88 } 89 } 90 91 public void beforeCreate(FileObject parent, String name, boolean isFolder) { 92 for (Iterator it = annotationProviders.iterator(); it.hasNext();) { 93 AnnotationProvider provider = (AnnotationProvider) it.next(); 94 InterceptionListener iListener = (provider != null) ? provider.getInterceptionListener() : null; 95 if (iListener != null) { 96 iListener.beforeCreate(parent, name, isFolder); 97 } 98 } 99 } 100 101 public void deleteSuccess(FileObject fo) { 102 for (Iterator it = annotationProviders.iterator(); it.hasNext();) { 103 AnnotationProvider provider = (AnnotationProvider) it.next(); 104 InterceptionListener iListener = (provider != null) ? provider.getInterceptionListener() : null; 105 if (iListener != null) { 106 iListener.deleteSuccess(fo); 107 } 108 } 109 } 110 111 public void deleteFailure(FileObject fo) { 112 for (Iterator it = annotationProviders.iterator(); it.hasNext();) { 113 AnnotationProvider provider = (AnnotationProvider) it.next(); 114 InterceptionListener iListener = (provider != null) ? provider.getInterceptionListener() : null; 115 if (iListener != null) { 116 iListener.deleteFailure(fo); 117 } 118 } 119 } 120 121 public void createSuccess(FileObject fo) { 122 for (Iterator it = annotationProviders.iterator(); it.hasNext();) { 123 AnnotationProvider provider = (AnnotationProvider) it.next(); 124 InterceptionListener iListener = (provider != null) ? provider.getInterceptionListener() : null; 125 if (iListener != null) { 126 iListener.createSuccess(fo); 127 } 128 } 129 } 130 131 public void beforeDelete(FileObject fo) { 132 for (Iterator it = annotationProviders.iterator(); it.hasNext();) { 133 AnnotationProvider provider = (AnnotationProvider) it.next(); 134 InterceptionListener iListener = (provider != null) ? provider.getInterceptionListener() : null; 135 if (iListener != null) { 136 iListener.beforeDelete(fo); 137 } 138 } 139 } 140 141 public void beforeChange(FileObject f) { 142 for (Iterator it = annotationProviders.iterator(); it.hasNext();) { 143 AnnotationProvider provider = (AnnotationProvider) it.next(); 144 InterceptionListener iListener = (provider != null) ? provider.getInterceptionListener() : null; 145 if (iListener instanceof ProvidedExtensions) { 146 ((ProvidedExtensions)iListener).beforeChange(f); 147 } 148 } 149 } 150 } 151 | Popular Tags |