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

(-)java.source.base/src/org/netbeans/api/java/source/CodeStyle.java (+12 lines)
Lines 294-299 Link Here
294
        }
294
        }
295
        return false;
295
        return false;
296
    }
296
    }
297
    /**
298
     * Determines whether fields will be sorted.
299
     * It returns true only if some sorting option is available (default: off) and the "Sort but ignore fields" option is enabled (default: true).
300
     * <p/>
301
     * @since 2.3
302
     */
303
    public boolean sortIgnoringFieldOrdering() {
304
        if (sortMembersInGroupsAlphabetically() || preferences.getBoolean(sortMembersByVisibility, getDefaultAsBoolean(sortMembersByVisibility))) {
305
            return preferences.getBoolean(sortIgnoreFields, getDefaultAsBoolean(sortIgnoreFields));
306
        }
307
        return false;
308
    }
297
309
298
    /**
310
    /**
299
     * Returns an information about the desired insertion point of a new class member.
311
     * Returns an information about the desired insertion point of a new class member.
(-)java.source.base/src/org/netbeans/api/java/source/GeneratorUtilities.java (+6 lines)
Lines 332-337 Link Here
332
        if (maxIndex < Integer.MAX_VALUE) {
332
        if (maxIndex < Integer.MAX_VALUE) {
333
            idx = Math.min(maxIndex, idx);
333
            idx = Math.min(maxIndex, idx);
334
        }
334
        }
335
336
        //https://netbeans.org/bugzilla/show_bug.cgi?id=251519 ignore ordering of fields
337
        if (member.getKind() == Kind.VARIABLE && codeStyle.sortIgnoringFieldOrdering()) {
338
            idx = i;
339
        }
340
        
335
        return copy.getTreeMaker().insertClassMember(clazz, idx, member);
341
        return copy.getTreeMaker().insertClassMember(clazz, idx, member);
336
    }
342
    }
337
    
343
    
(-)java.source.base/src/org/netbeans/modules/java/ui/FmtOptions.java (+2 lines)
Lines 93-98 Link Here
93
     * @since 2.3
93
     * @since 2.3
94
     */
94
     */
95
    public static final String sortUsesDependencies = "sortUsesDependencies"; // NO18N
95
    public static final String sortUsesDependencies = "sortUsesDependencies"; // NO18N
96
    public static final String sortIgnoreFields = "sortIgnoreFields"; // NO18N
96
    
97
    
97
    public static final String classDeclBracePlacement = "classDeclBracePlacement"; //NOI18N
98
    public static final String classDeclBracePlacement = "classDeclBracePlacement"; //NOI18N
98
    public static final String methodDeclBracePlacement = "methodDeclBracePlacement"; //NOI18N
99
    public static final String methodDeclBracePlacement = "methodDeclBracePlacement"; //NOI18N
Lines 380-385 Link Here
380
            { keepGettersAndSettersTogether, FALSE}, //NOI18N
381
            { keepGettersAndSettersTogether, FALSE}, //NOI18N
381
            { sortMembersInGroups, FALSE}, //NOI18N
382
            { sortMembersInGroups, FALSE}, //NOI18N
382
            { sortUsesDependencies, TRUE}, //NOI18N
383
            { sortUsesDependencies, TRUE}, //NOI18N
384
            { sortIgnoreFields, FALSE}, //NOI18N
383
            { classMemberInsertionPoint, IP_CARET},
385
            { classMemberInsertionPoint, IP_CARET},
384
386
385
            { classDeclBracePlacement, BP_SAME_LINE}, //NOI18N
387
            { classDeclBracePlacement, BP_SAME_LINE}, //NOI18N
(-)java.source/src/org/netbeans/modules/java/ui/Bundle.properties (-1 / +2 lines)
Lines 578-581 Link Here
578
TITLE_LowMemory=Low Memory
578
TITLE_LowMemory=Low Memory
579
MSG_LowMemory=Not enough memory to compile: {0}.
579
MSG_LowMemory=Not enough memory to compile: {0}.
580
URL_LowMemory=http://wiki.netbeans.org/InsufficientMemoryToIndexRoot
580
URL_LowMemory=http://wiki.netbeans.org/InsufficientMemoryToIndexRoot
581
FmtCodeGeneration.sortUsesDependenciesCheckBox.text=Sort uses dependencies
581
FmtCodeGeneration.sortUsesDependenciesCheckBox.text=Analyse Dependencies
582
FmtCodeGeneration.sortIgnoreFieldsCheckBox.text=Ignore Fields
(-)java.source/src/org/netbeans/modules/java/ui/FmtCodeGeneration.form (-3 / +23 lines)
Lines 40-46 Link Here
40
          </Group>
40
          </Group>
41
          <Group type="102" alignment="0" attributes="0">
41
          <Group type="102" alignment="0" attributes="0">
42
              <Group type="103" groupAlignment="1" max="-2" attributes="0">
42
              <Group type="103" groupAlignment="1" max="-2" attributes="0">
43
                  <Component id="jSeparator1" alignment="0" max="32767" attributes="0"/>
44
                  <Group type="102" alignment="0" attributes="0">
43
                  <Group type="102" alignment="0" attributes="0">
45
                      <Component id="insertionPointLabel" min="-2" max="-2" attributes="0"/>
44
                      <Component id="insertionPointLabel" min="-2" max="-2" attributes="0"/>
46
                      <EmptySpace max="-2" attributes="0"/>
45
                      <EmptySpace max="-2" attributes="0"/>
Lines 64-73 Link Here
64
                      </Group>
63
                      </Group>
65
                  </Group>
64
                  </Group>
66
                  <Component id="sortMembersAlphaCheckBox" alignment="0" max="32767" attributes="0"/>
65
                  <Component id="sortMembersAlphaCheckBox" alignment="0" max="32767" attributes="0"/>
67
                  <Component id="sortUsesDependenciesCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
66
                  <Group type="102" alignment="0" attributes="0">
67
                      <EmptySpace min="21" pref="21" max="-2" attributes="0"/>
68
                      <Group type="103" groupAlignment="0" attributes="0">
69
                          <Component id="sortIgnoreFieldsCheckBox" min="-2" max="-2" attributes="0"/>
70
                          <Component id="sortUsesDependenciesCheckBox" min="-2" max="-2" attributes="0"/>
68
              </Group>
71
              </Group>
72
                  </Group>
73
              </Group>
69
              <EmptySpace max="32767" attributes="0"/>
74
              <EmptySpace max="32767" attributes="0"/>
70
          </Group>
75
          </Group>
76
          <Component id="jSeparator1" alignment="0" max="32767" attributes="0"/>
71
      </Group>
77
      </Group>
72
    </DimensionLayout>
78
    </DimensionLayout>
73
    <DimensionLayout dim="1">
79
    <DimensionLayout dim="1">
Lines 111-119 Link Here
111
              <Component id="keepGASTogetherCheckBox" min="-2" max="-2" attributes="0"/>
117
              <Component id="keepGASTogetherCheckBox" min="-2" max="-2" attributes="0"/>
112
              <EmptySpace type="unrelated" max="-2" attributes="0"/>
118
              <EmptySpace type="unrelated" max="-2" attributes="0"/>
113
              <Component id="sortMembersAlphaCheckBox" min="-2" max="-2" attributes="0"/>
119
              <Component id="sortMembersAlphaCheckBox" min="-2" max="-2" attributes="0"/>
114
              <EmptySpace type="unrelated" max="-2" attributes="0"/>
120
              <EmptySpace max="-2" attributes="0"/>
115
              <Component id="sortUsesDependenciesCheckBox" min="-2" max="-2" attributes="0"/>
121
              <Component id="sortUsesDependenciesCheckBox" min="-2" max="-2" attributes="0"/>
116
              <EmptySpace max="-2" attributes="0"/>
122
              <EmptySpace max="-2" attributes="0"/>
123
              <Component id="sortIgnoreFieldsCheckBox" min="-2" max="-2" attributes="0"/>
124
              <EmptySpace max="-2" attributes="0"/>
117
              <Component id="jSeparator1" min="-2" pref="2" max="-2" attributes="0"/>
125
              <Component id="jSeparator1" min="-2" pref="2" max="-2" attributes="0"/>
118
              <EmptySpace max="-2" attributes="0"/>
126
              <EmptySpace max="-2" attributes="0"/>
119
              <Group type="103" groupAlignment="3" attributes="0">
127
              <Group type="103" groupAlignment="3" attributes="0">
Lines 355-359 Link Here
355
        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="sortUsesDependenciesCheckBoxActionPerformed"/>
363
        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="sortUsesDependenciesCheckBoxActionPerformed"/>
356
      </Events>
364
      </Events>
357
    </Component>
365
    </Component>
366
    <Component class="javax.swing.JCheckBox" name="sortIgnoreFieldsCheckBox">
367
      <Properties>
368
        <Property name="selected" type="boolean" value="true"/>
369
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
370
          <ResourceString bundle="org/netbeans/modules/java/ui/Bundle.properties" key="FmtCodeGeneration.sortIgnoreFieldsCheckBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
371
        </Property>
372
        <Property name="enabled" type="boolean" value="false"/>
373
      </Properties>
374
      <Events>
375
        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="sortIgnoreFieldsCheckBoxActionPerformed"/>
376
      </Events>
377
    </Component>
358
  </SubComponents>
378
  </SubComponents>
359
</Form>
379
</Form>
(-)java.source/src/org/netbeans/modules/java/ui/FmtCodeGeneration.java (-3 / +25 lines)
Lines 103-108 Link Here
103
        keepGASTogetherCheckBox.putClientProperty(OPTION_ID, keepGettersAndSettersTogether);
103
        keepGASTogetherCheckBox.putClientProperty(OPTION_ID, keepGettersAndSettersTogether);
104
        sortMembersAlphaCheckBox.putClientProperty(OPTION_ID, sortMembersInGroups);
104
        sortMembersAlphaCheckBox.putClientProperty(OPTION_ID, sortMembersInGroups);
105
        sortUsesDependenciesCheckBox.putClientProperty(OPTION_ID, sortUsesDependencies);
105
        sortUsesDependenciesCheckBox.putClientProperty(OPTION_ID, sortUsesDependencies);
106
        sortIgnoreFieldsCheckBox.putClientProperty(OPTION_ID, sortIgnoreFields);
106
        insertionPointComboBox.putClientProperty(OPTION_ID, classMemberInsertionPoint);
107
        insertionPointComboBox.putClientProperty(OPTION_ID, classMemberInsertionPoint);
107
    }
108
    }
108
    
109
    
Lines 172-177 Link Here
172
        jSeparator1 = new javax.swing.JSeparator();
173
        jSeparator1 = new javax.swing.JSeparator();
173
        insertionPointComboBox = new javax.swing.JComboBox();
174
        insertionPointComboBox = new javax.swing.JComboBox();
174
        sortUsesDependenciesCheckBox = new javax.swing.JCheckBox();
175
        sortUsesDependenciesCheckBox = new javax.swing.JCheckBox();
176
        sortIgnoreFieldsCheckBox = new javax.swing.JCheckBox();
175
177
176
        setName(org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_CodeGeneration")); // NOI18N
178
        setName(org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "LBL_CodeGeneration")); // NOI18N
177
        setOpaque(false);
179
        setOpaque(false);
Lines 274-279 Link Here
274
            }
276
            }
275
        });
277
        });
276
278
279
        sortIgnoreFieldsCheckBox.setSelected(true);
280
        org.openide.awt.Mnemonics.setLocalizedText(sortIgnoreFieldsCheckBox, org.openide.util.NbBundle.getMessage(FmtCodeGeneration.class, "FmtCodeGeneration.sortIgnoreFieldsCheckBox.text")); // NOI18N
281
        sortIgnoreFieldsCheckBox.setEnabled(false);
282
        sortIgnoreFieldsCheckBox.addActionListener(new java.awt.event.ActionListener() {
283
            public void actionPerformed(java.awt.event.ActionEvent evt) {
284
                sortIgnoreFieldsCheckBoxActionPerformed(evt);
285
            }
286
        });
287
277
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
288
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
278
        this.setLayout(layout);
289
        this.setLayout(layout);
279
        layout.setHorizontalGroup(
290
        layout.setHorizontalGroup(
Lines 292-298 Link Here
292
                .addGap(0, 0, Short.MAX_VALUE))
303
                .addGap(0, 0, Short.MAX_VALUE))
293
            .addGroup(layout.createSequentialGroup()
304
            .addGroup(layout.createSequentialGroup()
294
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
305
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
295
                    .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.LEADING)
296
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
306
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
297
                        .addComponent(insertionPointLabel)
307
                        .addComponent(insertionPointLabel)
298
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
308
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
Lines 312-319 Link Here
312
                            .addComponent(visDownButton, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
322
                            .addComponent(visDownButton, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
313
                            .addComponent(visUpButton, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)))
323
                            .addComponent(visUpButton, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)))
314
                    .addComponent(sortMembersAlphaCheckBox, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
324
                    .addComponent(sortMembersAlphaCheckBox, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
315
                    .addComponent(sortUsesDependenciesCheckBox, javax.swing.GroupLayout.Alignment.LEADING))
325
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
326
                        .addGap(21, 21, 21)
327
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
328
                            .addComponent(sortIgnoreFieldsCheckBox)
329
                            .addComponent(sortUsesDependenciesCheckBox))))
316
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
330
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
331
            .addComponent(jSeparator1)
317
        );
332
        );
318
        layout.setVerticalGroup(
333
        layout.setVerticalGroup(
319
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
334
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
Lines 352-360 Link Here
352
                .addComponent(keepGASTogetherCheckBox)
367
                .addComponent(keepGASTogetherCheckBox)
353
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
368
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
354
                .addComponent(sortMembersAlphaCheckBox)
369
                .addComponent(sortMembersAlphaCheckBox)
355
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
370
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
356
                .addComponent(sortUsesDependenciesCheckBox)
371
                .addComponent(sortUsesDependenciesCheckBox)
357
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
372
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
373
                .addComponent(sortIgnoreFieldsCheckBox)
374
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
358
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
375
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
359
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
376
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
360
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
377
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
Lines 417-425 Link Here
417
    private void sortUsesDependenciesCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sortUsesDependenciesCheckBoxActionPerformed
434
    private void sortUsesDependenciesCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sortUsesDependenciesCheckBoxActionPerformed
418
    }//GEN-LAST:event_sortUsesDependenciesCheckBoxActionPerformed
435
    }//GEN-LAST:event_sortUsesDependenciesCheckBoxActionPerformed
419
    
436
    
437
    private void sortIgnoreFieldsCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sortIgnoreFieldsCheckBoxActionPerformed
438
    }//GEN-LAST:event_sortIgnoreFieldsCheckBoxActionPerformed
439
    
420
    private void enableDependencyOrder() {
440
    private void enableDependencyOrder() {
421
        boolean b = sortByVisibilityCheckBox.isSelected()|| sortMembersAlphaCheckBox.isSelected();
441
        boolean b = sortByVisibilityCheckBox.isSelected()|| sortMembersAlphaCheckBox.isSelected();
422
        sortUsesDependenciesCheckBox.setEnabled(b);
442
        sortUsesDependenciesCheckBox.setEnabled(b);
443
        sortIgnoreFieldsCheckBox.setEnabled(b);
423
    }
444
    }
424
    
445
    
425
    private void enableMembersOrderButtons() {
446
    private void enableMembersOrderButtons() {
Lines 476-481 Link Here
476
    private javax.swing.JCheckBox parametersFinalCheckBox;
497
    private javax.swing.JCheckBox parametersFinalCheckBox;
477
    private javax.swing.JCheckBox qualifyFieldAccessCheckBox;
498
    private javax.swing.JCheckBox qualifyFieldAccessCheckBox;
478
    private javax.swing.JCheckBox sortByVisibilityCheckBox;
499
    private javax.swing.JCheckBox sortByVisibilityCheckBox;
500
    private javax.swing.JCheckBox sortIgnoreFieldsCheckBox;
479
    private javax.swing.JCheckBox sortMembersAlphaCheckBox;
501
    private javax.swing.JCheckBox sortMembersAlphaCheckBox;
480
    private javax.swing.JCheckBox sortUsesDependenciesCheckBox;
502
    private javax.swing.JCheckBox sortUsesDependenciesCheckBox;
481
    private javax.swing.JButton upButton;
503
    private javax.swing.JButton upButton;

Return to bug 251519