This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 181684
Collapse All | Expand All

(-)a/openide.filesystems/src/org/openide/filesystems/FileObject.java (-21 / +26 lines)
Lines 172-178 Link Here
172
    public String toString() {
172
    public String toString() {
173
        String cname = getClass().getName();
173
        String cname = getClass().getName();
174
        String cnameShort = cname.substring(cname.lastIndexOf('.') + 1);
174
        String cnameShort = cname.substring(cname.lastIndexOf('.') + 1);
175
        
175
176
        try {
176
        try {
177
            return cnameShort + '@' + Integer.toHexString(System.identityHashCode(this)) + '[' + (isRoot() ? "root of " + getFileSystem() : getPath()) + ']'; // NOI18N
177
            return cnameShort + '@' + Integer.toHexString(System.identityHashCode(this)) + '[' + (isRoot() ? "root of " + getFileSystem() : getPath()) + ']'; // NOI18N
178
        } catch (FileStateInvalidException x) {
178
        } catch (FileStateInvalidException x) {
Lines 612-618 Link Here
612
    /** Reads the full content of the file object and returns it as string.
612
    /** Reads the full content of the file object and returns it as string.
613
     * This is similar to calling {@link #asText(java.lang.String)} with
613
     * This is similar to calling {@link #asText(java.lang.String)} with
614
     * default system encoding.
614
     * default system encoding.
615
     * 
615
     *
616
     * @return string representing the content of the file
616
     * @return string representing the content of the file
617
     * @exception IOException in case the content cannot be fully read
617
     * @exception IOException in case the content cannot be fully read
618
     * @since 7.21
618
     * @since 7.21
Lines 641-647 Link Here
641
    public List<String> asLines() throws IOException {
641
    public List<String> asLines() throws IOException {
642
        return asLines(Charset.defaultCharset().name());
642
        return asLines(Charset.defaultCharset().name());
643
    }
643
    }
644
    
644
645
    /** Reads the full content of the file line by line. Typical usage is
645
    /** Reads the full content of the file line by line. Typical usage is
646
     * in <code>for</code> loops:
646
     * in <code>for</code> loops:
647
     * <pre>
647
     * <pre>
Lines 712-718 Link Here
712
        }
712
        }
713
    }
713
    }
714
714
715
    
715
716
    /** Lock this file.
716
    /** Lock this file.
717
    * @return lock that can be used to perform various modifications on the file
717
    * @return lock that can be used to perform various modifications on the file
718
    * @throws FileAlreadyLockedException if the file is already locked
718
    * @throws FileAlreadyLockedException if the file is already locked
Lines 830-836 Link Here
830
830
831
        FileObject myObj = this;
831
        FileObject myObj = this;
832
        StringTokenizer st = new StringTokenizer(relativePath, "/");
832
        StringTokenizer st = new StringTokenizer(relativePath, "/");
833
        
833
834
        if(relativePath.startsWith("//")) {
834
        if(relativePath.startsWith("//")) {
835
            // if it is UNC absolute path, start with //ComputerName/sharedFolder
835
            // if it is UNC absolute path, start with //ComputerName/sharedFolder
836
            myObj = myObj.getFileObject("//"+st.nextToken()+"/"+st.nextToken(), null);
836
            myObj = myObj.getFileObject("//"+st.nextToken()+"/"+st.nextToken(), null);
Lines 879-885 Link Here
879
     * @see FileUtil#createData
879
     * @see FileUtil#createData
880
     */
880
     */
881
    public FileObject createData(String name) throws IOException {
881
    public FileObject createData(String name) throws IOException {
882
        return createData(name, ""); // NOI18N        
882
        return createData(name, ""); // NOI18N
883
    }
883
    }
884
884
885
    /** Test whether this file can be written to or not.
885
    /** Test whether this file can be written to or not.
Lines 1023-1035 Link Here
1023
1023
1024
    interface PriorityFileChangeListener extends FileChangeListener {}
1024
    interface PriorityFileChangeListener extends FileChangeListener {}
1025
1025
1026
    private class ED extends FileSystem.EventDispatcher {
1026
    private static class ED extends FileSystem.EventDispatcher {
1027
        private FCLSupport.Op op;
1027
        private FCLSupport.Op op;
1028
        private Enumeration<FileChangeListener> en;
1028
        private Enumeration<FileChangeListener> en;
1029
        final private List<FileChangeListener> fsList;
1029
        final private List<FileChangeListener> fsList;
1030
        final private List<FileChangeListener> repList;
1030
        final private List<FileChangeListener> repList;
1031
        
1031
1032
        
1032
1033
        private FileEvent fe;
1033
        private FileEvent fe;
1034
1034
1035
        public ED(FCLSupport.Op op, Enumeration<FileChangeListener> en, FileEvent fe) {
1035
        public ED(FCLSupport.Op op, Enumeration<FileChangeListener> en, FileEvent fe) {
Lines 1044-1054 Link Here
1044
            }
1044
            }
1045
            ListenerList<FileChangeListener> fsll = (fs != null) ? fs.getFCLSupport().listeners : null;
1045
            ListenerList<FileChangeListener> fsll = (fs != null) ? fs.getFCLSupport().listeners : null;
1046
            ListenerList<FileChangeListener> repll = (fs != null && fs.getRepository() != null) ? fs.getRepository().getFCLSupport().listeners : null;
1046
            ListenerList<FileChangeListener> repll = (fs != null && fs.getRepository() != null) ? fs.getRepository().getFCLSupport().listeners : null;
1047
            fsList = (fsll != null) ? new ArrayList<FileChangeListener>(fsll.getAllListeners()) :
1047
            if (fsll != null && fsll.hasListeners()) {
1048
                new ArrayList<FileChangeListener>();
1048
                fsList = new ArrayList<FileChangeListener>(fsll.getAllListeners());
1049
            repList = (repll != null) ? new ArrayList<FileChangeListener>(repll.getAllListeners()) :
1049
            } else {
1050
                new ArrayList<FileChangeListener>();
1050
                fsList = Collections.<FileChangeListener>emptyList();
1051
            
1051
            }
1052
            if (repll != null && repll.hasListeners()) {
1053
                repList = new ArrayList<FileChangeListener>(repll.getAllListeners());
1054
            } else {
1055
                repList = Collections.<FileChangeListener>emptyList();
1056
            }
1052
        }
1057
        }
1053
1058
1054
        public ED(Enumeration<FileChangeListener> en, FileEvent fe) {
1059
        public ED(Enumeration<FileChangeListener> en, FileEvent fe) {
Lines 1063-1069 Link Here
1063
                this.op = fe.getFile().isFolder() ? FCLSupport.Op.FOLDER_CREATED : FCLSupport.Op.DATA_CREATED;
1068
                this.op = fe.getFile().isFolder() ? FCLSupport.Op.FOLDER_CREATED : FCLSupport.Op.DATA_CREATED;
1064
            }
1069
            }
1065
1070
1066
            LinkedList<FileChangeListener> newEnum = new LinkedList<FileChangeListener>(); // later lazy                
1071
            LinkedList<FileChangeListener> newEnum = new LinkedList<FileChangeListener>(); // later lazy
1067
1072
1068
            while (en.hasMoreElements()) {
1073
            while (en.hasMoreElements()) {
1069
                FileChangeListener fcl = en.nextElement();
1074
                FileChangeListener fcl = en.nextElement();
Lines 1084-1090 Link Here
1084
             * FileSystem and from Repository mustn`t be forked.
1089
             * FileSystem and from Repository mustn`t be forked.
1085
             */
1090
             */
1086
            FileObject fo = fe.getFile();
1091
            FileObject fo = fe.getFile();
1087
            boolean transmit = false;            
1092
            boolean transmit = false;
1088
            if (fo != null) {
1093
            if (fo != null) {
1089
                switch (op) {
1094
                switch (op) {
1090
                    case FILE_CHANGED:
1095
                    case FILE_CHANGED:
Lines 1094-1103 Link Here
1094
                        transmit = !fo.equals(fe.getSource());
1099
                        transmit = !fo.equals(fe.getSource());
1095
                        if (!transmit && fe instanceof Enumeration && !((Enumeration) fe).hasMoreElements()) {
1100
                        if (!transmit && fe instanceof Enumeration && !((Enumeration) fe).hasMoreElements()) {
1096
                            transmit = true;
1101
                            transmit = true;
1097
                        } 
1102
                        }
1098
                }
1103
                }
1099
                
1104
1100
            }                
1105
            }
1101
1106
1102
            if (!en.hasMoreElements() && transmit && !onlyPriority) {
1107
            if (!en.hasMoreElements() && transmit && !onlyPriority) {
1103
                FileSystem fs = null;
1108
                FileSystem fs = null;
Lines 1112-1125 Link Here
1112
                if (fs != null && fsList != null) {
1117
                if (fs != null && fsList != null) {
1113
                    for (FileChangeListener fcl : fsList) {
1118
                    for (FileChangeListener fcl : fsList) {
1114
                        FCLSupport.dispatchEvent(fcl, fe, op, postNotify);
1119
                        FCLSupport.dispatchEvent(fcl, fe, op, postNotify);
1115
                    }  
1120
                    }
1116
                }
1121
                }
1117
1122
1118
1123
1119
                if (rep != null && repList != null) {
1124
                if (rep != null && repList != null) {
1120
                    for (FileChangeListener fcl : repList) {
1125
                    for (FileChangeListener fcl : repList) {
1121
                        FCLSupport.dispatchEvent(fcl, fe, op, postNotify);
1126
                        FCLSupport.dispatchEvent(fcl, fe, op, postNotify);
1122
                    }                      
1127
                    }
1123
                }
1128
                }
1124
            }
1129
            }
1125
        }
1130
        }

Return to bug 181684