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 230821
Collapse All | Expand All

(-)a/openide.loaders/apichanges.xml (+20 lines)
Lines 109-114 Link Here
109
<!-- ACTUAL CHANGES BEGIN HERE: -->
109
<!-- ACTUAL CHANGES BEGIN HERE: -->
110
110
111
  <changes>
111
  <changes>
112
      <change id="org.openide.loaders.DataFolder.SortMode.EXTENSIONS">
113
          <api name="loaders"/>
114
          <summary>Introduces SortMode for sorting by file extension.</summary>
115
          <version major="7" minor="54"/>
116
          <date day="10" month="10" year="2013"/>
117
          <author login="jhavlin"/>
118
          <compatibility addition="yes" binary="compatible" source="compatible"
119
                         semantic="compatible" deprecation="no" deletion="no"
120
                         modification="no"/>
121
          <description>
122
              <p>It's possible to sort files using sort mode "By Type", which
123
                  means using SortMode.CLASS. It may be confusing, as users
124
                  expect that the files will be sorted by file type, i.e. by
125
                  extension. "By Type" was renamed to "By Class" and new
126
                  sort mode "By Extension" (SortMode.EXTENSIONS) was added.
127
              </p>
128
          </description>
129
          <class package="org.openide.loaders" name="DataFolder"/>
130
          <issue number="230821"/>
131
      </change>
112
      <change id="org.openide.text.big.file.size">
132
      <change id="org.openide.text.big.file.size">
113
          <api name="editor"/>
133
          <api name="editor"/>
114
          <summary>Introduces system property to change file size threshold.</summary>
134
          <summary>Introduces system property to change file size threshold.</summary>
(-)a/openide.loaders/manifest.mf (-1 / +1 lines)
Lines 1-6 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.openide.loaders
2
OpenIDE-Module: org.openide.loaders
3
OpenIDE-Module-Specification-Version: 7.53
3
OpenIDE-Module-Specification-Version: 7.54
4
OpenIDE-Module-Localizing-Bundle: org/openide/loaders/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/openide/loaders/Bundle.properties
5
OpenIDE-Module-Provides: org.netbeans.modules.templates.v1_0
5
OpenIDE-Module-Provides: org.netbeans.modules.templates.v1_0
6
OpenIDE-Module-Layer: org/netbeans/modules/openide/loaders/layer.xml
6
OpenIDE-Module-Layer: org/netbeans/modules/openide/loaders/layer.xml
(-)a/openide.loaders/src/org/openide/loaders/Bundle.properties (-1 / +2 lines)
Lines 105-114 Link Here
105
# SortModeEditor
105
# SortModeEditor
106
VALUE_sort_none=Unsorted
106
VALUE_sort_none=Unsorted
107
VALUE_sort_names=By Name
107
VALUE_sort_names=By Name
108
VALUE_sort_class=By Type
108
VALUE_sort_class=By Class
109
VALUE_sort_folder_names=By Name (Packages First)
109
VALUE_sort_folder_names=By Name (Packages First)
110
VALUE_sort_last_modified=By Modification Time
110
VALUE_sort_last_modified=By Modification Time
111
VALUE_sort_size=By File Size
111
VALUE_sort_size=By File Size
112
VALUE_sort_extensions=By Extension
112
113
113
114
114
#
115
#
(-)a/openide.loaders/src/org/openide/loaders/DataFolder.java (+8 lines)
Lines 1100-1105 Link Here
1100
         */
1100
         */
1101
        public static final SortMode SIZE = new FolderComparator(FolderComparator.SIZE);
1101
        public static final SortMode SIZE = new FolderComparator(FolderComparator.SIZE);
1102
1102
1103
        /**
1104
         * Folders go first (sorted by name) followed by files sorted by
1105
         * extension and then by name.
1106
         *
1107
         * @since org.openide.loaders 7.54
1108
         */
1109
        public static final SortMode EXTENSIONS = new FolderComparator(FolderComparator.EXTENSIONS);
1110
1103
        /** Method to write the sort mode to a folder's attributes.
1111
        /** Method to write the sort mode to a folder's attributes.
1104
        * @param folder folder write this mode to
1112
        * @param folder folder write this mode to
1105
        */
1113
        */
(-)a/openide.loaders/src/org/openide/loaders/FolderComparator.java (+27 lines)
Lines 67-72 Link Here
67
    public static final int LAST_MODIFIED = 4;
67
    public static final int LAST_MODIFIED = 4;
68
    /** by folders, then size */
68
    /** by folders, then size */
69
    public static final int SIZE = 5;
69
    public static final int SIZE = 5;
70
    /** by extension, then name */
71
    public static final int EXTENSIONS = 6;
70
72
71
73
72
    /** mode to use */
74
    /** mode to use */
Lines 106-111 Link Here
106
            return compareLastModified(obj1, obj2);
108
            return compareLastModified(obj1, obj2);
107
        case SIZE:
109
        case SIZE:
108
            return compareSize(obj1, obj2);
110
            return compareSize(obj1, obj2);
111
        case EXTENSIONS:
112
            return compareExtensions(obj1, obj2);
109
        default:
113
        default:
110
            assert false : mode;
114
            assert false : mode;
111
            return 0;
115
            return 0;
Lines 158-163 Link Here
158
        return compareNames(o1, o2);
162
        return compareNames(o1, o2);
159
    }
163
    }
160
164
165
    /** for sorting folders first and then by extensions and then by names */
166
    private int compareExtensions(Object o1, Object o2) {
167
        FileObject obj1 = findFileObject(o1);
168
        FileObject obj2 = findFileObject(o2);
169
170
        boolean folder1 = obj1.isFolder();
171
        boolean folder2 = obj2.isFolder();
172
173
        if (folder1 != folder2) {
174
            return folder1 ? -1 : 1; // folders first
175
        } else if (folder1) { // && folder2
176
            return obj1.getNameExt().compareTo(obj2.getNameExt()); // by nameExt
177
        } else {
178
            String ext1 = obj1.getExt();
179
            String ext2 = obj2.getExt();
180
            if (ext1.equals(ext2)) { // same extensions
181
                return obj1.getName().compareTo(obj2.getName()); // by name
182
            } else { // different extensions
183
                return ext1.compareTo(ext2); // by extension
184
            }
185
        }
186
    }
187
161
    /** for sorting data objects by their classes */
188
    /** for sorting data objects by their classes */
162
    private int compareClass(Object o1, Object o2) {
189
    private int compareClass(Object o1, Object o2) {
163
        DataObject obj1 = findDataObject(o1);
190
        DataObject obj1 = findDataObject(o1);
(-)a/openide.loaders/src/org/openide/loaders/SortModeEditor.java (+2 lines)
Lines 58-63 Link Here
58
        DataFolder.SortMode.FOLDER_NAMES,
58
        DataFolder.SortMode.FOLDER_NAMES,
59
        DataFolder.SortMode.LAST_MODIFIED,
59
        DataFolder.SortMode.LAST_MODIFIED,
60
        DataFolder.SortMode.SIZE,
60
        DataFolder.SortMode.SIZE,
61
        DataFolder.SortMode.EXTENSIONS
61
    };
62
    };
62
63
63
    /** Names for modes. First is for displaying files */
64
    /** Names for modes. First is for displaying files */
Lines 68-73 Link Here
68
        DataObject.getString ("VALUE_sort_folder_names"),
69
        DataObject.getString ("VALUE_sort_folder_names"),
69
        DataObject.getString ("VALUE_sort_last_modified"),
70
        DataObject.getString ("VALUE_sort_last_modified"),
70
        DataObject.getString ("VALUE_sort_size"),
71
        DataObject.getString ("VALUE_sort_size"),
72
        DataObject.getString ("VALUE_sort_extensions")
71
    };
73
    };
72
74
73
    /** @return names of the two possible modes */
75
    /** @return names of the two possible modes */
(-)a/openide.loaders/test/unit/src/org/openide/loaders/DataFolderTest.java (+2 lines)
Lines 588-593 Link Here
588
        assertEquals("next order is alphabetical", "a/b.xml/c/d.instance/e.xml", childrenOrder(folder));
588
        assertEquals("next order is alphabetical", "a/b.xml/c/d.instance/e.xml", childrenOrder(folder));
589
        folder.setSortMode(DataFolder.SortMode.CLASS);
589
        folder.setSortMode(DataFolder.SortMode.CLASS);
590
        assertEquals("last order is by type", "d.instance/a/c/b.xml/e.xml", childrenOrder(folder));
590
        assertEquals("last order is by type", "d.instance/a/c/b.xml/e.xml", childrenOrder(folder));
591
        folder.setSortMode(DataFolder.SortMode.EXTENSIONS);
592
        assertEquals("last order is by extension", "a/c/d.instance/b.xml/e.xml", childrenOrder(folder));
591
    }
593
    }
592
594
593
    public void testPositionalSort() throws Exception {
595
    public void testPositionalSort() throws Exception {

Return to bug 230821