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

(-)a/editor.lib2/src/org/netbeans/modules/editor/lib2/view/DocumentView.java (+3 lines)
Lines 1361-1366 Link Here
1361
    }
1361
    }
1362
1362
1363
    int getTextLimitWidth() {
1363
    int getTextLimitWidth() {
1364
        Object prop = textComponent.getClientProperty("TextLimitLine"); //NOI18N
1365
        if (prop instanceof Integer)
1366
            return (Integer)prop;
1364
        checkSettingsInfo();
1367
        checkSettingsInfo();
1365
        if (defaultLimitLineWidth > 0) {
1368
        if (defaultLimitLineWidth > 0) {
1366
            return defaultLimitLineWidth;
1369
            return defaultLimitLineWidth;
(-)a/java.source/apichanges.xml (+18 lines)
Lines 108-113 Link Here
108
    <!-- ACTUAL CHANGES BEGIN HERE: -->
108
    <!-- ACTUAL CHANGES BEGIN HERE: -->
109
109
110
    <changes>
110
    <changes>
111
        <change id="comments-reformat">
112
             <api name="general"/>
113
             <summary>Added several methods to <code>CodeStyle</code> to support reformatting of comments.</summary>
114
             <version major="0" minor="83"/>
115
             <date day="28" month="6" year="2011"/>
116
             <author login="dbalek"/>
117
             <compatibility addition="yes" binary="compatible" deletion="no" deprecation="no" modification="no" semantic="compatible" source="compatible"/>
118
             <description>
119
                 Added <code>CodeStyle.enableBlockCommentFormatting</code>, <code>CodeStyle.enableJavadocFormatting</code>,
120
                 <code>CodeStyle.wrapCommentText</code>, <code>CodeStyle.wrapOneLineComments</code>,
121
                 <code>CodeStyle.preserveNewLinesInCommentst</code>, <code>CodeStyle.blankLineAfterJavadocDescription</code>,
122
                 <code>CodeStyle.blankLineAfterJavadocParameterDescriptions</code>, <code>CodeStyle.blankLineAfterJavadocReturnTag</code>,
123
                 <code>CodeStyle.generateParagraphTagOnBlankLines</code>, <code>CodeStyle.alignJavadocParameterDescriptions</code>,
124
                 <code>CodeStyle.alignJavadocReturnDescriptions</code>, <code>CodeStyle.alignJavadocExceptionDescriptions</code>,
125
                 to support reformatting of comments.
126
             </description>
127
             <issue number="20672"/>
128
        </change>
111
        <change id="ClassIndex-package-scope">
129
        <change id="ClassIndex-package-scope">
112
             <api name="general"/>
130
             <api name="general"/>
113
             <summary>Added package search scope into <code>ClassIndex</code> to restrict search in given packages</summary>
131
             <summary>Added package search scope into <code>ClassIndex</code> to restrict search in given packages</summary>
(-)a/java.source/nbproject/project.properties (-1 / +1 lines)
Lines 46-52 Link Here
46
javadoc.title=Java Source
46
javadoc.title=Java Source
47
javadoc.arch=${basedir}/arch.xml
47
javadoc.arch=${basedir}/arch.xml
48
javadoc.apichanges=${basedir}/apichanges.xml
48
javadoc.apichanges=${basedir}/apichanges.xml
49
spec.version.base=0.82.0
49
spec.version.base=0.83.0
50
test.qa-functional.cp.extra=${refactoring.java.dir}/modules/ext/javac-api-nb-7.0-b07.jar
50
test.qa-functional.cp.extra=${refactoring.java.dir}/modules/ext/javac-api-nb-7.0-b07.jar
51
test.unit.run.cp.extra=${o.n.core.dir}/core/core.jar:\
51
test.unit.run.cp.extra=${o.n.core.dir}/core/core.jar:\
52
    ${o.n.core.dir}/lib/boot.jar:\
52
    ${o.n.core.dir}/lib/boot.jar:\
(-)a/java.source/src/org/netbeans/api/java/source/CodeStyle.java (+50 lines)
Lines 767-772 Link Here
767
        return null;
767
        return null;
768
    }
768
    }
769
769
770
    // Comments -----------------------------------------------------------------
771
772
    public boolean enableBlockCommentFormatting() {
773
        return preferences.getBoolean(enableCommentFormatting, getDefaultAsBoolean(enableCommentFormatting));
774
    }
775
776
    public boolean enableJavadocFormatting() {
777
        return preferences.getBoolean(enableCommentFormatting, getDefaultAsBoolean(enableCommentFormatting));
778
    }
779
780
    public boolean wrapCommentText() {
781
        return preferences.getBoolean(wrapCommentText, getDefaultAsBoolean(wrapCommentText));
782
    }
783
784
    public boolean wrapOneLineComments() {
785
        return preferences.getBoolean(wrapOneLineComment, getDefaultAsBoolean(wrapOneLineComment));
786
    }
787
788
    public boolean preserveNewLinesInComments() {
789
        return preferences.getBoolean(preserveNewLinesInComments, getDefaultAsBoolean(preserveNewLinesInComments));
790
    }
791
792
    public boolean blankLineAfterJavadocDescription() {
793
        return preferences.getBoolean(blankLineAfterJavadocDescription, getDefaultAsBoolean(blankLineAfterJavadocDescription));
794
    }
795
796
    public boolean blankLineAfterJavadocParameterDescriptions() {
797
        return preferences.getBoolean(blankLineAfterJavadocParameterDescriptions, getDefaultAsBoolean(blankLineAfterJavadocParameterDescriptions));
798
    }
799
800
    public boolean blankLineAfterJavadocReturnTag() {
801
        return preferences.getBoolean(blankLineAfterJavadocReturnTag, getDefaultAsBoolean(blankLineAfterJavadocReturnTag));
802
    }
803
804
    public boolean generateParagraphTagOnBlankLines() {
805
        return preferences.getBoolean(generateParagraphTagOnBlankLines, getDefaultAsBoolean(generateParagraphTagOnBlankLines));
806
    }
807
808
    public boolean alignJavadocParameterDescriptions() {
809
        return preferences.getBoolean(alignJavadocParameterDescriptions, getDefaultAsBoolean(alignJavadocParameterDescriptions));
810
    }
811
812
    public boolean alignJavadocReturnDescription() {
813
        return preferences.getBoolean(alignJavadocReturnDescription, getDefaultAsBoolean(alignJavadocReturnDescription));
814
    }
815
816
    public boolean alignJavadocExceptionDescriptions() {
817
        return preferences.getBoolean(alignJavadocExceptionDescriptions, getDefaultAsBoolean(alignJavadocExceptionDescriptions));
818
    }
819
770
    // Nested classes ----------------------------------------------------------
820
    // Nested classes ----------------------------------------------------------
771
821
772
    public enum BracePlacement {
822
    public enum BracePlacement {
(-)a/java.source/src/org/netbeans/modules/java/source/resources/layer.xml (+5 lines)
Lines 205-210 Link Here
205
                          <attr name="instanceCreate" methodvalue="org.netbeans.modules.java.ui.FmtSpaces.getController"/>
205
                          <attr name="instanceCreate" methodvalue="org.netbeans.modules.java.ui.FmtSpaces.getController"/>
206
                          <attr name="position" intvalue="600"/>
206
                          <attr name="position" intvalue="600"/>
207
                      </file>
207
                      </file>
208
                      <file name="Comments.instance">
209
                          <attr name="instanceOf" stringvalue="org.netbeans.modules.options.editor.spi.PreferencesCustomizer$Factory"/>
210
                          <attr name="instanceCreate" methodvalue="org.netbeans.modules.java.ui.FmtComments.getController"/>
211
                          <attr name="position" intvalue="700"/>
212
                      </file>
208
<!--
213
<!--
209
                      <file name="CodeGeneration.instance">
214
                      <file name="CodeGeneration.instance">
210
                          <attr name="instanceOf" stringvalue="org.netbeans.spi.options.OptionsPanelController"/>
215
                          <attr name="instanceOf" stringvalue="org.netbeans.spi.options.OptionsPanelController"/>
(-)a/java.source/src/org/netbeans/modules/java/source/save/Reformatter.java (-26 / +393 lines)
Lines 50-55 Link Here
50
50
51
import org.netbeans.api.java.classpath.ClassPath;
51
import org.netbeans.api.java.classpath.ClassPath;
52
import org.netbeans.api.java.lexer.JavaTokenId;
52
import org.netbeans.api.java.lexer.JavaTokenId;
53
import org.netbeans.api.java.lexer.JavadocTokenId;
53
import org.netbeans.api.java.platform.JavaPlatformManager;
54
import org.netbeans.api.java.platform.JavaPlatformManager;
54
import static org.netbeans.api.java.lexer.JavaTokenId.*;
55
import static org.netbeans.api.java.lexer.JavaTokenId.*;
55
import org.netbeans.api.java.source.*;
56
import org.netbeans.api.java.source.*;
Lines 63-68 Link Here
63
import org.netbeans.modules.java.source.JavaSourceAccessor;
64
import org.netbeans.modules.java.source.JavaSourceAccessor;
64
import org.netbeans.modules.java.source.parsing.FileObjects;
65
import org.netbeans.modules.java.source.parsing.FileObjects;
65
import org.netbeans.modules.java.source.parsing.JavacParser;
66
import org.netbeans.modules.java.source.parsing.JavacParser;
67
import org.netbeans.modules.java.source.usages.Pair;
66
import org.netbeans.modules.parsing.api.Embedding;
68
import org.netbeans.modules.parsing.api.Embedding;
67
import org.netbeans.modules.parsing.api.ParserManager;
69
import org.netbeans.modules.parsing.api.ParserManager;
68
import org.netbeans.modules.parsing.api.ResultIterator;
70
import org.netbeans.modules.parsing.api.ResultIterator;
Lines 369-374 Link Here
369
        private static final String EMPTY = ""; //NOI18N
371
        private static final String EMPTY = ""; //NOI18N
370
        private static final String SPACE = " "; //NOI18N
372
        private static final String SPACE = " "; //NOI18N
371
        private static final String NEWLINE = "\n"; //NOI18N
373
        private static final String NEWLINE = "\n"; //NOI18N
374
        private static final String LEADING_STAR = "*"; //NOI18N
375
        private static final String P_TAG = "<p/>"; //NOI18N
376
        private static final String PRE_TAG = "<pre>"; //NOI18N
377
        private static final String PRE_END_TAG = "</pre>"; //NOI18N
378
        private static final String PARAM_TAG = "@param"; //NOI18N
379
        private static final String RETURN_TAG = "@return"; //NOI18N
380
        private static final String THROWS_TAG = "@throws"; //NOI18N
372
        private static final String ERROR = "<error>"; //NOI18N
381
        private static final String ERROR = "<error>"; //NOI18N
373
        private static final int ANY_COUNT = -1;
382
        private static final int ANY_COUNT = -1;
374
383
Lines 400-405 Link Here
400
        private int startOffset;
409
        private int startOffset;
401
        private int endOffset;
410
        private int endOffset;
402
        private int tpLevel;
411
        private int tpLevel;
412
        private int lastCommentIndex = -1;
403
413
404
        private Pretty(CompilationInfo info, TreePath path, CodeStyle cs, int startOffset, int endOffset, boolean templateEdit) {
414
        private Pretty(CompilationInfo info, TreePath path, CodeStyle cs, int startOffset, int endOffset, boolean templateEdit) {
405
            this(info.getText(), info.getTokenHierarchy().tokenSequence(JavaTokenId.language()),
415
            this(info.getText(), info.getTokenHierarchy().tokenSequence(JavaTokenId.language()),
Lines 2508-2514 Link Here
2508
                        if (idx >= 0)
2518
                        if (idx >= 0)
2509
                            tokenText = tokenText.substring(idx + 1);
2519
                            tokenText = tokenText.substring(idx + 1);
2510
                        col += getCol(tokenText);
2520
                        col += getCol(tokenText);
2511
                        indentComment();
2521
                        reformatComment();
2512
                        after = 2; //javadoc comment
2522
                        after = 2; //javadoc comment
2513
                        break;
2523
                        break;
2514
                    case BLOCK_COMMENT:
2524
                    case BLOCK_COMMENT:
Lines 2541-2547 Link Here
2541
                        if (idx >= 0)
2551
                        if (idx >= 0)
2542
                            tokenText = tokenText.substring(idx + 1);
2552
                            tokenText = tokenText.substring(idx + 1);
2543
                        col += getCol(tokenText);
2553
                        col += getCol(tokenText);
2544
                        indentComment();
2554
                        reformatComment();
2545
                        after = 0;
2555
                        after = 0;
2546
                        break;
2556
                        break;
2547
                    default:
2557
                    default:
Lines 2653-2659 Link Here
2653
                        if (idx >= 0)
2663
                        if (idx >= 0)
2654
                            tokenText = tokenText.substring(idx + 1);
2664
                            tokenText = tokenText.substring(idx + 1);
2655
                        col += getCol(tokenText);
2665
                        col += getCol(tokenText);
2656
                        indentComment();
2666
                        reformatComment();
2657
                        after = 2; //javadoc comment
2667
                        after = 2; //javadoc comment
2658
                        break;
2668
                        break;
2659
                    case BLOCK_COMMENT:
2669
                    case BLOCK_COMMENT:
Lines 2698-2704 Link Here
2698
                        if (idx >= 0)
2708
                        if (idx >= 0)
2699
                            tokenText = tokenText.substring(idx + 1);
2709
                            tokenText = tokenText.substring(idx + 1);
2700
                        col += getCol(tokenText);
2710
                        col += getCol(tokenText);
2701
                        indentComment();
2711
                        reformatComment();
2702
                        after = 0;
2712
                        after = 0;
2703
                        break;
2713
                        break;
2704
                    default:
2714
                    default:
Lines 2795-2807 Link Here
2795
                                lastIdx = idx + 1;
2805
                                lastIdx = idx + 1;
2796
                            }
2806
                            }
2797
                            if (lastIdx > 0) {
2807
                            if (lastIdx > 0) {
2798
                                String indent = getIndent();
2808
                                String ind = getIndent();
2799
                                if (!indent.contentEquals(text.substring(lastIdx)))
2809
                                if (!ind.contentEquals(text.substring(lastIdx)))
2800
                                    addDiff(new Diff(offset + lastIdx, tokens.offset(), indent));
2810
                                    addDiff(new Diff(offset + lastIdx, tokens.offset(), ind));
2811
                                col = indent;
2801
                            }
2812
                            }
2802
                            lastToken = null;
2813
                            lastToken = null;
2803
                        }
2814
                        }
2804
                        indentComment();
2815
                        reformatComment();
2805
                        after = 3;
2816
                        after = 3;
2806
                        break;
2817
                        break;
2807
                    case JAVADOC_COMMENT:
2818
                    case JAVADOC_COMMENT:
Lines 2827-2844 Link Here
2827
                            if (lastIdx == 0 && count < 0 && after != 1) {
2838
                            if (lastIdx == 0 && count < 0 && after != 1) {
2828
                                count = count == ANY_COUNT ? 1 : 0;
2839
                                count = count == ANY_COUNT ? 1 : 0;
2829
                            }
2840
                            }
2830
                            String indent = after == 3 ? SPACE : getNewlines(count) + getIndent();
2841
                            String ind = after == 3 ? SPACE : getNewlines(count) + getIndent();
2831
                            if (!indent.contentEquals(text.substring(lastIdx)))
2842
                            if (!ind.contentEquals(text.substring(lastIdx)))
2832
                                addDiff(new Diff(offset + lastIdx, tokens.offset(), indent));
2843
                                addDiff(new Diff(offset + lastIdx, tokens.offset(), ind));
2833
                            lastToken = null;
2844
                            lastToken = null;
2845
                            col = after == 3 ? col + 1 : indent;
2834
                        } else {
2846
                        } else {
2835
                            if (lastBlankLines < 0 && count == ANY_COUNT)
2847
                            if (lastBlankLines < 0 && count == ANY_COUNT)
2836
                                count = lastBlankLines = 1;
2848
                                count = lastBlankLines = 1;
2837
                            String text = getNewlines(count) + getIndent();
2849
                            String text = getNewlines(count) + getIndent();
2838
                            if (text.length() > 0)
2850
                            if (text.length() > 0)
2839
                                addDiff(new Diff(tokens.offset(), tokens.offset(), text));
2851
                                addDiff(new Diff(tokens.offset(), tokens.offset(), text));
2852
                            col = indent;
2840
                        }
2853
                        }
2841
                        indentComment();
2854
                        reformatComment();
2842
                        count = 0;
2855
                        count = 0;
2843
                        after = 2;
2856
                        after = 2;
2844
                        break;
2857
                        break;
Lines 3253-3274 Link Here
3253
            }
3266
            }
3254
        }
3267
        }
3255
        
3268
        
3256
        private void indentComment() {
3269
        private void reformatComment() {
3257
            if (tokens.token().id() != BLOCK_COMMENT && tokens.token().id() != JAVADOC_COMMENT)
3270
            if ((tokens.token().id() != BLOCK_COMMENT && tokens.token().id() != JAVADOC_COMMENT)
3271
                    || tokens.index() <= lastCommentIndex)
3258
                return;
3272
                return;
3259
            String indent = getIndent();
3273
            lastCommentIndex = tokens.index();
3260
            String text = tokens.token().text().toString();
3274
            String text = tokens.token().text().toString();
3261
            int idx = 0;
3275
            int offset = tokens.offset();
3262
            while ((idx = text.indexOf('\n', idx)) >= 0) { //NOI18N
3276
            TokenSequence<JavadocTokenId> javadocTokens = tokens.embedded(JavadocTokenId.language());
3263
                int i = idx + 1;
3277
            LinkedList<Pair<Integer, Integer>> marks = new LinkedList<Pair<Integer, Integer>>();
3264
                while(i < text.length() && text.charAt(i) <= ' ' && text.charAt(i) != '\n') //NOI18N
3278
            int maxParamNameLength = 0;
3265
                    i++;
3279
            int maxExcNameLength = 0;
3266
                if (i >= text.length())
3280
            if (javadocTokens != null) {
3267
                    break;
3281
                int state = 0; // 0 - initial text, 1 - after param tag, 2 - param description, 3 - return description,
3268
                String s = text.charAt(i) == '*' ? indent + SPACE : indent;
3282
                               // 4 - after throws tag, 5 - exception description, 6 - after pre tag, 7 - after other tag
3269
                if (!s.equals(text.substring(idx + 1, i)))
3283
                int lastWSOffset = -1;
3270
                    addDiff(new Diff(tokens.offset() + idx + 1, tokens.offset() + i, s)); //NOI18N
3284
                while (javadocTokens.moveNext()) {
3271
                idx = i;
3285
                    switch (javadocTokens.token().id()) {
3286
                        case TAG:
3287
                            String tokenText = javadocTokens.token().text().toString();
3288
                            int newState;
3289
                            if (PARAM_TAG.equalsIgnoreCase(tokenText)) {
3290
                                newState = 1;
3291
                            } else if (RETURN_TAG.equalsIgnoreCase(tokenText)) {
3292
                                newState = 3;
3293
                            } else if (THROWS_TAG.equalsIgnoreCase(tokenText)) {
3294
                                newState = 4;
3295
                            } else {
3296
                                newState = 7;
3297
                            }
3298
                            if (lastWSOffset >= 0) {
3299
                                marks.add(Pair.of(lastWSOffset, state == 0 && cs.blankLineAfterJavadocDescription()
3300
                                        || state == 2 && newState != 1 && cs.blankLineAfterJavadocParameterDescriptions()
3301
                                        || state == 3 && cs.blankLineAfterJavadocReturnTag() ? 0 : 1));
3302
                            }
3303
                            state = newState;
3304
                            if (state == 3 && cs.alignJavadocReturnDescription()) {
3305
                                marks.add(Pair.of(javadocTokens.offset() + javadocTokens.token().length() - offset, 3));
3306
                            }
3307
                            lastWSOffset = -1;
3308
                            break;
3309
                        case IDENT:
3310
                            if (state == 1) {
3311
                                int len = javadocTokens.token().length();
3312
                                if (len > maxParamNameLength)
3313
                                    maxParamNameLength = len;
3314
                                if (cs.alignJavadocParameterDescriptions())
3315
                                    marks.add(Pair.of(javadocTokens.offset() + len - offset, 2));
3316
                                state = 2;
3317
                            } else if (state == 4) {
3318
                                int len = javadocTokens.token().length();
3319
                                if (len > maxExcNameLength)
3320
                                    maxExcNameLength = len;
3321
                                if (cs.alignJavadocExceptionDescriptions())
3322
                                    marks.add(Pair.of(javadocTokens.offset() + len - offset, 4));
3323
                                state = 5;
3324
                            }
3325
                            lastWSOffset = -1;
3326
                            break;
3327
                        case OTHER_TEXT:
3328
                            lastWSOffset = -1;
3329
                            CharSequence cseq = javadocTokens.token().text();
3330
                            int nlNum = 1;
3331
                            for (int i = cseq.length(); i >= 0; i--) {
3332
                                if (i == 0) {
3333
                                    lastWSOffset = javadocTokens.offset() - offset;
3334
                                } else {
3335
                                    char c = cseq.charAt(i - 1);
3336
                                    if (c == '\n') {
3337
                                        if (--nlNum < 0) {
3338
                                            break;
3339
                                        }
3340
                                    } else if (!Character.isWhitespace(c) && c != '*') {
3341
                                        lastWSOffset = javadocTokens.offset() + i - offset;
3342
                                        break;
3343
                                    }
3344
                                }
3345
                            }
3346
                            break;
3347
                        case HTML_TAG:
3348
                            tokenText = javadocTokens.token().text().toString();
3349
                            if (PRE_TAG.equalsIgnoreCase(tokenText)) {
3350
                                if (lastWSOffset >= 0) {
3351
                                    marks.add(Pair.of(lastWSOffset, 1));
3352
                                }
3353
                                marks.add(Pair.of(javadocTokens.offset() - offset, 5));
3354
                            } else if (PRE_END_TAG.equalsIgnoreCase(tokenText)) {
3355
                                marks.add(Pair.of(lastWSOffset >= 0 ? lastWSOffset : javadocTokens.offset() - offset, 6));
3356
                            }
3357
                            lastWSOffset = -1;
3358
                            break;
3359
                    }
3360
                }
3361
            }
3362
            int checkOffset, actionType; // 0 - add blank line, 1 - add newline, 2 - align params, 3 - align return,
3363
                                         // 4 - align exceptions, 5 - no format, 6 - format
3364
            Iterator<Pair<Integer, Integer>> it = marks.iterator();
3365
            if (it.hasNext()) {
3366
                Pair<Integer, Integer> next = it.next();
3367
                checkOffset = next.first;
3368
                actionType = next.second;
3369
            } else {
3370
                checkOffset = Integer.MAX_VALUE;
3371
                actionType = -1;
3372
            }
3373
            String indentString = getIndent();
3374
            String lineStartString = cs.addLeadingStarInComment() ? indentString + SPACE + LEADING_STAR + SPACE : indentString + SPACE;
3375
            String blankLineString;
3376
            if (cs.generateParagraphTagOnBlankLines()) {
3377
                blankLineString = cs.addLeadingStarInComment() ? indentString + SPACE + LEADING_STAR + SPACE + P_TAG : indentString + SPACE + P_TAG;
3378
            } else {
3379
                blankLineString = cs.addLeadingStarInComment() ? indentString + SPACE + LEADING_STAR : EMPTY;
3380
            }
3381
            int currNWSPos = -1;
3382
            int lastNWSPos = -1;
3383
            int currWSPos = -1;
3384
            int lastWSPos = -1;
3385
            int lastNewLinePos = -1;
3386
            Diff pendingDiff = null;
3387
            int start = javadocTokens != null ? 3 : 2;
3388
            col += start;
3389
            boolean preserveNewLines = true;
3390
            boolean firstLine = true;
3391
            boolean enableCommentFormatting = javadocTokens != null ? cs.enableJavadocFormatting() : cs.enableBlockCommentFormatting();
3392
            boolean noFormat = false;
3393
            int align = -1;
3394
            for (int i = start; i < text.length(); i++) {
3395
                char c = text.charAt(i);
3396
                if (Character.isWhitespace(c)) {
3397
                    if (enableCommentFormatting) {
3398
                        if (currNWSPos >= 0) {
3399
                            lastNWSPos = currNWSPos;
3400
                            currNWSPos = -1;
3401
                        }
3402
                        if (currWSPos < 0) {
3403
                            currWSPos = i;
3404
                            if (col > cs.getRightMargin() && cs.wrapCommentText() && !noFormat && lastWSPos >= 0) {
3405
                                int endOff = pendingDiff != null ? pendingDiff.getEndOffset() - offset : lastWSPos + 1;
3406
                                String s = NEWLINE + lineStartString;
3407
                                col = getCol(lineStartString) + i - endOff;
3408
                                if (align > 0) {
3409
                                    int num = align - lineStartString.length();
3410
                                    if (num > 0) {
3411
                                        s += getSpaces(num);
3412
                                        col += num;
3413
                                    }
3414
                                }
3415
                                addDiff(new Diff(offset + lastWSPos, offset + endOff, s));
3416
                            } else if (pendingDiff != null) {
3417
                                addDiff(pendingDiff);
3418
                                col++;
3419
                            } else {
3420
                                col++;
3421
                            }
3422
                            pendingDiff = null;
3423
                        }
3424
                    }
3425
                    if (c == '\n') {
3426
                        if (lastNewLinePos >= 0) {
3427
                            if (enableCommentFormatting) {
3428
                                String subs = text.substring(lastNewLinePos + 1, i);
3429
                                if (!blankLineString.equals(subs)) {
3430
                                    addDiff(new Diff(offset + lastNewLinePos + 1, offset + i, blankLineString));
3431
                                }
3432
                            }
3433
                            preserveNewLines = true;
3434
                        }
3435
                        firstLine = false;
3436
                        lastNewLinePos = i;
3437
                    }
3438
                } else {
3439
                    if (enableCommentFormatting) {
3440
                        if (currNWSPos < 0) {
3441
                            currNWSPos = i;
3442
                        }
3443
                        if (i >= checkOffset) {
3444
                            noFormat = false;                                    
3445
                            switch (actionType) {
3446
                                case 0:
3447
                                    addDiff(new Diff(currWSPos >= 0 ? offset + currWSPos : offset + i, offset + i, NEWLINE + blankLineString + NEWLINE));
3448
                                    lastNewLinePos = currWSPos >= 0 ? currWSPos : i - 1;
3449
                                    preserveNewLines = true;
3450
                                    align = -1;
3451
                                    break;
3452
                                case 1:
3453
                                    addDiff(new Diff(currWSPos >= 0 ? offset + currWSPos : offset + i, offset + i, NEWLINE));
3454
                                    lastNewLinePos = currWSPos >= 0 ? currWSPos : i - 1;
3455
                                    preserveNewLines = true;
3456
                                    align = -1;
3457
                                    break;
3458
                                case 2:
3459
                                    int num = maxParamNameLength + lastNWSPos - currWSPos;
3460
                                    if (num > 0) {
3461
                                        addDiff(new Diff(offset + i, offset + i, getSpaces(num)));
3462
                                        col += num;
3463
                                    }
3464
                                    align = col;
3465
                                    break;
3466
                                case 3:
3467
                                    align = col;
3468
                                    break;
3469
                                case 4:
3470
                                    num = maxExcNameLength + lastNWSPos - currWSPos;
3471
                                    if (num > 0) {
3472
                                        addDiff(new Diff(offset + i, offset + i, getSpaces(num)));
3473
                                        col += num;
3474
                                    }
3475
                                    align = col;
3476
                                    break;
3477
                                case 5:
3478
                                    noFormat = true;
3479
                                    align = -1;
3480
                                    break;
3481
                                case 6:
3482
                                    preserveNewLines = true;
3483
                                    align = -1;
3484
                                    break;
3485
                            }
3486
                            if (it.hasNext()) {
3487
                                Pair<Integer, Integer> next = it.next();
3488
                                checkOffset = next.first;
3489
                                actionType = next.second;
3490
                            } else {
3491
                                checkOffset = Integer.MAX_VALUE;
3492
                                actionType = -1;
3493
                            }
3494
                        }
3495
                    }
3496
                    if (lastNewLinePos >= 0) {
3497
                        if (pendingDiff != null) {
3498
                            addDiff(pendingDiff);
3499
                            pendingDiff = null;
3500
                        }
3501
                        if (!preserveNewLines && !noFormat && i < text.length() - 2 && enableCommentFormatting && !cs.preserveNewLinesInComments() && cs.wrapCommentText()) {
3502
                            lastWSPos = lastNewLinePos;
3503
                            pendingDiff = new Diff(offset + lastNewLinePos, offset + i, SPACE);
3504
                            lastNewLinePos = -1;
3505
                            if (c == '*') {
3506
                                while(++i < text.length()) {
3507
                                    col++;
3508
                                    c = text.charAt(i);
3509
                                    if (c == '\n') {
3510
                                        pendingDiff.start++;
3511
                                        pendingDiff.text = blankLineString;
3512
                                        preserveNewLines = true;
3513
                                        lastNewLinePos = i;
3514
                                        break;
3515
                                    } else if (!Character.isWhitespace(c)) {
3516
                                        break;
3517
                                    }
3518
                                }
3519
                                if (pendingDiff != null)
3520
                                    pendingDiff.end = offset + i;
3521
                            }
3522
                        } else {
3523
                            String s = indentString + SPACE;
3524
                            String subs = text.substring(lastNewLinePos + 1, i);
3525
                            if (!s.equals(subs))
3526
                                pendingDiff = new Diff(offset + lastNewLinePos + 1, offset + i, s);
3527
                            lastWSPos = currWSPos = -1;
3528
                            lastNewLinePos = -1;
3529
                            col = getCol(s);
3530
                            if (enableCommentFormatting) {
3531
                                if (c == '*') {
3532
                                    col++;
3533
                                    while (++i < text.length()) {
3534
                                        c = text.charAt(i);
3535
                                        if (c == '\n') {
3536
                                            if (!cs.addLeadingStarInComment()) {
3537
                                                if (pendingDiff != null) {
3538
                                                    pendingDiff.end = offset + i;
3539
                                                    pendingDiff.text = blankLineString;
3540
                                                } else {
3541
                                                    pendingDiff = new Diff(offset + lastNewLinePos + 1, offset + i, blankLineString);
3542
                                                }
3543
                                            } else if (currWSPos >= 0) {
3544
                                                if (pendingDiff != null) {
3545
                                                    addDiff(pendingDiff);
3546
                                                }
3547
                                                pendingDiff = new Diff(offset + currWSPos, offset + i, cs.generateParagraphTagOnBlankLines() ? SPACE + P_TAG : EMPTY);
3548
                                            }
3549
                                            currWSPos = -1;
3550
                                            lastNewLinePos = i;
3551
                                            break;
3552
                                        } else if (Character.isWhitespace(c)) {
3553
                                            if (currWSPos < 0) {
3554
                                                currWSPos = i;
3555
                                                col++;
3556
                                            }
3557
                                        } else if (c == '*' || c == '/') {
3558
                                            col++;
3559
                                            break;
3560
                                        } else {
3561
                                            if (!cs.addLeadingStarInComment()) {
3562
                                                if (noFormat) {
3563
                                                    if (pendingDiff != null) {
3564
                                                        pendingDiff.end = currWSPos >= 0 ? offset + currWSPos + 1 : pendingDiff.end + 1;
3565
                                                    } else {
3566
                                                        pendingDiff = new Diff(offset + lastNewLinePos + 1, currWSPos >= 0 ? offset + currWSPos + 1 : offset + i, indentString);
3567
                                                    }
3568
                                                    
3569
                                                } else {
3570
                                                    if (pendingDiff != null) {
3571
                                                        pendingDiff.end = offset + i;
3572
                                                    } else {
3573
                                                        pendingDiff = new Diff(offset + lastNewLinePos + 1, offset + i, indentString);
3574
                                                    }
3575
                                                    col = indent;
3576
                                                }
3577
                                            } else { 
3578
                                                if (currWSPos < 0) {
3579
                                                    currWSPos = i;
3580
                                                    col++;
3581
                                                }
3582
                                                subs = text.substring(currWSPos, i);
3583
                                                if (!noFormat && !SPACE.equals(subs)) {
3584
                                                    if (pendingDiff != null)
3585
                                                        addDiff(pendingDiff);
3586
                                                    pendingDiff = new Diff(offset + currWSPos, offset + i, SPACE);                                                    
3587
                                                }
3588
                                            }
3589
                                            currWSPos = -1;
3590
                                            break;
3591
                                        }
3592
                                    }
3593
                                } else if (cs.addLeadingStarInComment()) {
3594
                                    if (pendingDiff != null) {
3595
                                        pendingDiff.text += (LEADING_STAR + SPACE);
3596
                                    } else {
3597
                                        pendingDiff = new Diff(offset + i, offset + i, LEADING_STAR + SPACE);
3598
                                    }
3599
                                    col += 2;
3600
                                }
3601
                            }
3602
                            if (pendingDiff != null) {
3603
                                addDiff(pendingDiff);
3604
                                pendingDiff = null;
3605
                            }
3606
                        }
3607
                    } else if (enableCommentFormatting) {
3608
                        if (firstLine) {
3609
                            String s = cs.wrapOneLineComments() ? NEWLINE + lineStartString : SPACE;
3610
                            String sub = currWSPos >= 0 ? text.substring(currWSPos, i) : null;
3611
                            if (!s.equals(sub))
3612
                                addDiff(new Diff(currWSPos >= 0 ? offset + currWSPos : offset + i, offset + i, s));
3613
                            col = getCol(s);
3614
                            firstLine = false;
3615
                        } else if (currWSPos >= 0) {
3616
                            lastWSPos = currWSPos;
3617
                            if (currWSPos < i - 1)
3618
                                pendingDiff = new Diff(offset + currWSPos + 1, offset + i, null);
3619
                        } else if (c != '*') {
3620
                            preserveNewLines = false;
3621
                        }
3622
                    } else if (c != '*') {
3623
                        preserveNewLines = false;
3624
                    }
3625
                    currWSPos = -1;
3626
                    col++;
3627
                }
3628
            }
3629
            if (enableCommentFormatting) {
3630
                for (int i = text.length() - 3; i >= 0; i--) {
3631
                    char c = text.charAt(i);
3632
                    if (c == '\n') {
3633
                        break;
3634
                    } else if (!Character.isWhitespace(c)) {
3635
                        addDiff(new Diff(offset + i + 1, offset + text.length() - 2, cs.wrapOneLineComments() ? NEWLINE + indentString + SPACE : SPACE));
3636
                        break;
3637
                    }
3638
                }
3272
            }
3639
            }
3273
        }
3640
        }
3274
3641
(-)a/java.source/src/org/netbeans/modules/java/ui/Bundle.properties (-1 / +33 lines)
Lines 226-231 Link Here
226
226
227
LBL_IndentCasesFromSwitch=Indent Case Statements In &Switch
227
LBL_IndentCasesFromSwitch=Indent Case Statements In &Switch
228
228
229
LBL_Comments=Comments
230
LBL_doc_enableCommentFormat=Enable Comments Formatting
231
LBL_doc_generalLabel=General
232
LBL_doc_addLeadingStar=Add Leading Star
233
LBL_doc_wrapCommentText=Wrap Text At Right Margin
234
LBL_doc_wrapOneLineCheckBox=Wrap One Line Comments
235
LBL_doc_preserveNewLinesCheckBox=Preserve New Lines
236
LBL_doc_javadocLabel=Javadoc
237
LBL_doc_blankLineAfterDescCheckBox=Add Blank Line After Description
238
LBL_doc_blankLineAfterParamsCheckBox=Add Blank Line After Parameter Descriptions
239
LBL_doc_blankLineAfterReturnCheckBox=Add Blank Line After Return Tag
240
LBL_doc_generatePCheckBox=Genarete "<p/>" On Blank Lines
241
LBL_doc_alignParamsCheckBox=Align Parameter Descriptions
242
LBL_doc_alignReturnCheckBox=Align Return Value Descriptions
243
LBL_doc_alignExceptionsCheckBox=Align Exception Descriptions
244
229
# Following entries (marked) as samples are used as examples in the formating
245
# Following entries (marked) as samples are used as examples in the formating
230
# options. It is highly discourage to localize them unless absolutely necessary.
246
# options. It is highly discourage to localize them unless absolutely necessary.
231
247
Lines 402-412 Link Here
402
}\
418
}\
403
} }
419
} }
404
420
421
SAMPLE_Comments=public class ClassA {\n\
422
/**\n\
423
This  is  the first part of a  sample  method  description.\n\
424
The second part is placed after a manual newline.\n\
425
\n\
426
The last part is placed after an empty line.\n\
427
@param text the first parameter description\n\
428
@param number the second parameter description\n\
429
@return this is the return value description\n\
430
@throws ExcepA the first exception description\n\
431
@throws ExcB the second exception description\n\
432
*/\n\
433
public String meth(String text, int number) throws ExceptionA, ExcB {\n\
434
/*This is one line comment*/\n\
435
return number > 0 ? text : null;\n\
436
}\n\
437
}
405
438
406
439
407
nlFinallyCheckBox1.text="finall&y"
440
nlFinallyCheckBox1.text="finall&y"
408
441
409
410
AN_Preview=Preview
442
AN_Preview=Preview
411
AD_Preview=Preview
443
AD_Preview=Preview
412
FmtTabsIndents.absoluteLabelIndentCheckBox.AccessibleContext.accessibleDescription=Indent Labels absolutely
444
FmtTabsIndents.absoluteLabelIndentCheckBox.AccessibleContext.accessibleDescription=Indent Labels absolutely
(-)b43452695c7b (+221 lines)
Added Link Here
1
<?xml version="1.1" encoding="UTF-8" ?>
2
3
<Form version="1.5" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
4
  <Properties>
5
    <Property name="name" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
6
      <ResourceString bundle="org/netbeans/modules/java/ui/Bundle.properties" key="LBL_Comments" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
7
    </Property>
8
  </Properties>
9
  <AuxValues>
10
    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
11
    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
12
    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
13
    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
14
    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
15
    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
16
    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
17
    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
18
    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
19
  </AuxValues>
20
21
  <Layout>
22
    <DimensionLayout dim="0">
23
      <Group type="103" groupAlignment="0" attributes="0">
24
          <Group type="102" attributes="0">
25
              <Group type="103" groupAlignment="0" attributes="0">
26
                  <Component id="enableCommentFormatCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
27
                  <Group type="102" alignment="0" attributes="0">
28
                      <Component id="generalLabel" min="-2" max="-2" attributes="0"/>
29
                      <EmptySpace max="-2" attributes="0"/>
30
                      <Component id="jSeparator1" pref="329" max="32767" attributes="0"/>
31
                  </Group>
32
                  <Group type="102" alignment="0" attributes="0">
33
                      <EmptySpace min="12" pref="12" max="12" attributes="0"/>
34
                      <Group type="103" groupAlignment="0" attributes="0">
35
                          <Component id="wrapCommentTextCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
36
                          <Component id="addLeadingStarCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
37
                          <Component id="wrapOneLineCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
38
                          <Component id="preserveNewLinesCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
39
                      </Group>
40
                  </Group>
41
                  <Group type="102" alignment="0" attributes="0">
42
                      <Component id="javadocLabel" min="-2" max="-2" attributes="0"/>
43
                      <EmptySpace max="-2" attributes="0"/>
44
                      <Component id="jSeparator2" pref="328" max="32767" attributes="0"/>
45
                  </Group>
46
                  <Group type="102" alignment="0" attributes="0">
47
                      <EmptySpace min="12" pref="12" max="12" attributes="0"/>
48
                      <Group type="103" groupAlignment="0" attributes="0">
49
                          <Component id="blankLineAfterParamsCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
50
                          <Component id="blankLineAfterDescCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
51
                          <Component id="blankLineAfterReturnCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
52
                          <Component id="generatePCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
53
                          <Component id="alignParamsCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
54
                          <Component id="alignReturnCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
55
                          <Component id="alignExceptionsCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
56
                      </Group>
57
                  </Group>
58
              </Group>
59
              <EmptySpace max="-2" attributes="0"/>
60
          </Group>
61
      </Group>
62
    </DimensionLayout>
63
    <DimensionLayout dim="1">
64
      <Group type="103" groupAlignment="0" attributes="0">
65
          <Group type="102" alignment="0" attributes="0">
66
              <Component id="enableCommentFormatCheckBox" min="-2" max="-2" attributes="0"/>
67
              <Group type="103" groupAlignment="0" attributes="0">
68
                  <Group type="102" attributes="0">
69
                      <EmptySpace type="unrelated" max="-2" attributes="0"/>
70
                      <Component id="generalLabel" min="-2" max="-2" attributes="0"/>
71
                  </Group>
72
                  <Group type="102" alignment="1" attributes="0">
73
                      <EmptySpace min="-2" pref="16" max="-2" attributes="0"/>
74
                      <Component id="jSeparator1" min="-2" pref="7" max="-2" attributes="0"/>
75
                  </Group>
76
              </Group>
77
              <EmptySpace max="-2" attributes="0"/>
78
              <Component id="addLeadingStarCheckBox" min="-2" max="-2" attributes="0"/>
79
              <EmptySpace max="-2" attributes="0"/>
80
              <Component id="wrapCommentTextCheckBox" min="-2" max="-2" attributes="0"/>
81
              <EmptySpace max="-2" attributes="0"/>
82
              <Component id="wrapOneLineCheckBox" min="-2" max="-2" attributes="0"/>
83
              <EmptySpace max="-2" attributes="0"/>
84
              <Component id="preserveNewLinesCheckBox" min="-2" max="-2" attributes="0"/>
85
              <Group type="103" groupAlignment="0" attributes="0">
86
                  <Group type="102" attributes="0">
87
                      <EmptySpace type="unrelated" max="-2" attributes="0"/>
88
                      <Component id="javadocLabel" min="-2" max="-2" attributes="1"/>
89
                  </Group>
90
                  <Group type="102" alignment="0" attributes="0">
91
                      <EmptySpace min="-2" pref="15" max="-2" attributes="0"/>
92
                      <Component id="jSeparator2" min="-2" max="-2" attributes="1"/>
93
                  </Group>
94
              </Group>
95
              <EmptySpace max="-2" attributes="0"/>
96
              <Component id="blankLineAfterDescCheckBox" min="-2" max="-2" attributes="0"/>
97
              <EmptySpace max="-2" attributes="0"/>
98
              <Component id="blankLineAfterParamsCheckBox" min="-2" max="-2" attributes="0"/>
99
              <EmptySpace max="-2" attributes="0"/>
100
              <Component id="blankLineAfterReturnCheckBox" min="-2" max="-2" attributes="0"/>
101
              <EmptySpace max="-2" attributes="0"/>
102
              <Component id="generatePCheckBox" min="-2" max="-2" attributes="0"/>
103
              <EmptySpace max="-2" attributes="0"/>
104
              <Component id="alignParamsCheckBox" min="-2" max="-2" attributes="0"/>
105
              <EmptySpace max="-2" attributes="0"/>
106
              <Component id="alignReturnCheckBox" min="-2" max="-2" attributes="0"/>
107
              <EmptySpace max="-2" attributes="0"/>
108
              <Component id="alignExceptionsCheckBox" min="-2" max="-2" attributes="0"/>
109
              <EmptySpace pref="20" max="32767" attributes="0"/>
110
          </Group>
111
      </Group>
112
    </DimensionLayout>
113
  </Layout>
114
  <SubComponents>
115
    <Component class="javax.swing.JCheckBox" name="enableCommentFormatCheckBox">
116
      <Properties>
117
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
118
          <ResourceString bundle="org/netbeans/modules/java/ui/Bundle.properties" key="LBL_doc_enableCommentFormat" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
119
        </Property>
120
      </Properties>
121
      <Events>
122
        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="enableCommentFormatCheckBoxActionPerformed"/>
123
      </Events>
124
    </Component>
125
    <Component class="javax.swing.JLabel" name="generalLabel">
126
      <Properties>
127
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
128
          <ResourceString bundle="org/netbeans/modules/java/ui/Bundle.properties" key="LBL_doc_generalLabel" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
129
        </Property>
130
      </Properties>
131
    </Component>
132
    <Component class="javax.swing.JSeparator" name="jSeparator1">
133
    </Component>
134
    <Component class="javax.swing.JCheckBox" name="addLeadingStarCheckBox">
135
      <Properties>
136
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
137
          <ResourceString bundle="org/netbeans/modules/java/ui/Bundle.properties" key="LBL_doc_addLeadingStar" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
138
        </Property>
139
      </Properties>
140
    </Component>
141
    <Component class="javax.swing.JCheckBox" name="wrapCommentTextCheckBox">
142
      <Properties>
143
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
144
          <ResourceString bundle="org/netbeans/modules/java/ui/Bundle.properties" key="LBL_doc_wrapCommentText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
145
        </Property>
146
      </Properties>
147
    </Component>
148
    <Component class="javax.swing.JCheckBox" name="wrapOneLineCheckBox">
149
      <Properties>
150
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
151
          <ResourceString bundle="org/netbeans/modules/java/ui/Bundle.properties" key="LBL_doc_wrapOneLineCheckBox" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
152
        </Property>
153
      </Properties>
154
    </Component>
155
    <Component class="javax.swing.JCheckBox" name="preserveNewLinesCheckBox">
156
      <Properties>
157
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
158
          <ResourceString bundle="org/netbeans/modules/java/ui/Bundle.properties" key="LBL_doc_preserveNewLinesCheckBox" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
159
        </Property>
160
      </Properties>
161
    </Component>
162
    <Component class="javax.swing.JLabel" name="javadocLabel">
163
      <Properties>
164
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
165
          <ResourceString bundle="org/netbeans/modules/java/ui/Bundle.properties" key="LBL_doc_javadocLabel" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
166
        </Property>
167
      </Properties>
168
    </Component>
169
    <Component class="javax.swing.JSeparator" name="jSeparator2">
170
    </Component>
171
    <Component class="javax.swing.JCheckBox" name="blankLineAfterDescCheckBox">
172
      <Properties>
173
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
174
          <ResourceString bundle="org/netbeans/modules/java/ui/Bundle.properties" key="LBL_doc_blankLineAfterDescCheckBox" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
175
        </Property>
176
      </Properties>
177
    </Component>
178
    <Component class="javax.swing.JCheckBox" name="blankLineAfterParamsCheckBox">
179
      <Properties>
180
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
181
          <ResourceString bundle="org/netbeans/modules/java/ui/Bundle.properties" key="LBL_doc_blankLineAfterParamsCheckBox" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
182
        </Property>
183
      </Properties>
184
    </Component>
185
    <Component class="javax.swing.JCheckBox" name="blankLineAfterReturnCheckBox">
186
      <Properties>
187
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
188
          <ResourceString bundle="org/netbeans/modules/java/ui/Bundle.properties" key="LBL_doc_blankLineAfterReturnCheckBox" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
189
        </Property>
190
      </Properties>
191
    </Component>
192
    <Component class="javax.swing.JCheckBox" name="generatePCheckBox">
193
      <Properties>
194
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
195
          <ResourceString bundle="org/netbeans/modules/java/ui/Bundle.properties" key="LBL_doc_generatePCheckBox" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
196
        </Property>
197
      </Properties>
198
    </Component>
199
    <Component class="javax.swing.JCheckBox" name="alignParamsCheckBox">
200
      <Properties>
201
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
202
          <ResourceString bundle="org/netbeans/modules/java/ui/Bundle.properties" key="LBL_doc_alignParamsCheckBox" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
203
        </Property>
204
      </Properties>
205
    </Component>
206
    <Component class="javax.swing.JCheckBox" name="alignReturnCheckBox">
207
      <Properties>
208
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
209
          <ResourceString bundle="org/netbeans/modules/java/ui/Bundle.properties" key="LBL_doc_alignReturnCheckBox" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
210
        </Property>
211
      </Properties>
212
    </Component>
213
    <Component class="javax.swing.JCheckBox" name="alignExceptionsCheckBox">
214
      <Properties>
215
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
216
          <ResourceString bundle="org/netbeans/modules/java/ui/Bundle.properties" key="LBL_doc_alignExceptionsCheckBox" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
217
        </Property>
218
      </Properties>
219
    </Component>
220
  </SubComponents>
221
</Form>
(-)b43452695c7b (+258 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2011 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.java.ui;
44
45
import static org.netbeans.modules.java.ui.FmtOptions.*;
46
import static org.netbeans.modules.java.ui.FmtOptions.CategorySupport.OPTION_ID;
47
import org.netbeans.modules.options.editor.spi.PreferencesCustomizer;
48
49
/**
50
 *
51
 * @author Dusan Balek
52
 */
53
public class FmtComments extends javax.swing.JPanel implements Runnable {
54
55
    /** Creates new form FmtComments */
56
    public FmtComments() {
57
        initComponents();
58
        enableCommentFormatCheckBox.putClientProperty(OPTION_ID, enableCommentFormatting);
59
        addLeadingStarCheckBox.putClientProperty(OPTION_ID, addLeadingStarInComment);
60
        wrapCommentTextCheckBox.putClientProperty(OPTION_ID, wrapCommentText);
61
        wrapOneLineCheckBox.putClientProperty(OPTION_ID, wrapOneLineComment);
62
        preserveNewLinesCheckBox.putClientProperty(OPTION_ID, preserveNewLinesInComments);
63
        blankLineAfterDescCheckBox.putClientProperty(OPTION_ID, blankLineAfterJavadocDescription);
64
        blankLineAfterParamsCheckBox.putClientProperty(OPTION_ID, blankLineAfterJavadocParameterDescriptions);
65
        blankLineAfterReturnCheckBox.putClientProperty(OPTION_ID, blankLineAfterJavadocReturnTag);
66
        generatePCheckBox.putClientProperty(OPTION_ID, generateParagraphTagOnBlankLines);
67
        alignParamsCheckBox.putClientProperty(OPTION_ID, alignJavadocParameterDescriptions);
68
        alignReturnCheckBox.putClientProperty(OPTION_ID, alignJavadocReturnDescription);
69
        alignExceptionsCheckBox.putClientProperty(OPTION_ID, alignJavadocExceptionDescriptions);
70
    }
71
72
    public static PreferencesCustomizer.Factory getController() {
73
        return new CategorySupport.Factory("comments", FmtComments.class, //NOI18N
74
                org.openide.util.NbBundle.getMessage(FmtComments.class, "SAMPLE_Comments"), // NOI18N
75
                new String[] { FmtOptions.rightMargin, "45" }, //NOI18N
76
                new String[] { FmtOptions.blankLinesBeforeClass, "0" }); //NOI18N
77
    }    
78
79
    @Override
80
    public void run() {
81
        enableControls(enableCommentFormatCheckBox.isSelected());
82
    }
83
84
    /** This method is called from within the constructor to
85
     * initialize the form.
86
     * WARNING: Do NOT modify this code. The content of this method is
87
     * always regenerated by the Form Editor.
88
     */
89
    @SuppressWarnings("unchecked")
90
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
91
    private void initComponents() {
92
93
        enableCommentFormatCheckBox = new javax.swing.JCheckBox();
94
        generalLabel = new javax.swing.JLabel();
95
        jSeparator1 = new javax.swing.JSeparator();
96
        addLeadingStarCheckBox = new javax.swing.JCheckBox();
97
        wrapCommentTextCheckBox = new javax.swing.JCheckBox();
98
        wrapOneLineCheckBox = new javax.swing.JCheckBox();
99
        preserveNewLinesCheckBox = new javax.swing.JCheckBox();
100
        javadocLabel = new javax.swing.JLabel();
101
        jSeparator2 = new javax.swing.JSeparator();
102
        blankLineAfterDescCheckBox = new javax.swing.JCheckBox();
103
        blankLineAfterParamsCheckBox = new javax.swing.JCheckBox();
104
        blankLineAfterReturnCheckBox = new javax.swing.JCheckBox();
105
        generatePCheckBox = new javax.swing.JCheckBox();
106
        alignParamsCheckBox = new javax.swing.JCheckBox();
107
        alignReturnCheckBox = new javax.swing.JCheckBox();
108
        alignExceptionsCheckBox = new javax.swing.JCheckBox();
109
110
        setName(org.openide.util.NbBundle.getMessage(FmtComments.class, "LBL_Comments")); // NOI18N
111
112
        enableCommentFormatCheckBox.setText(org.openide.util.NbBundle.getMessage(FmtComments.class, "LBL_doc_enableCommentFormat")); // NOI18N
113
        enableCommentFormatCheckBox.addActionListener(new java.awt.event.ActionListener() {
114
            public void actionPerformed(java.awt.event.ActionEvent evt) {
115
                enableCommentFormatCheckBoxActionPerformed(evt);
116
            }
117
        });
118
119
        generalLabel.setText(org.openide.util.NbBundle.getMessage(FmtComments.class, "LBL_doc_generalLabel")); // NOI18N
120
121
        addLeadingStarCheckBox.setText(org.openide.util.NbBundle.getMessage(FmtComments.class, "LBL_doc_addLeadingStar")); // NOI18N
122
123
        wrapCommentTextCheckBox.setText(org.openide.util.NbBundle.getMessage(FmtComments.class, "LBL_doc_wrapCommentText")); // NOI18N
124
125
        wrapOneLineCheckBox.setText(org.openide.util.NbBundle.getMessage(FmtComments.class, "LBL_doc_wrapOneLineCheckBox")); // NOI18N
126
127
        preserveNewLinesCheckBox.setText(org.openide.util.NbBundle.getMessage(FmtComments.class, "LBL_doc_preserveNewLinesCheckBox")); // NOI18N
128
129
        javadocLabel.setText(org.openide.util.NbBundle.getMessage(FmtComments.class, "LBL_doc_javadocLabel")); // NOI18N
130
131
        blankLineAfterDescCheckBox.setText(org.openide.util.NbBundle.getMessage(FmtComments.class, "LBL_doc_blankLineAfterDescCheckBox")); // NOI18N
132
133
        blankLineAfterParamsCheckBox.setText(org.openide.util.NbBundle.getMessage(FmtComments.class, "LBL_doc_blankLineAfterParamsCheckBox")); // NOI18N
134
135
        blankLineAfterReturnCheckBox.setText(org.openide.util.NbBundle.getMessage(FmtComments.class, "LBL_doc_blankLineAfterReturnCheckBox")); // NOI18N
136
137
        generatePCheckBox.setText(org.openide.util.NbBundle.getMessage(FmtComments.class, "LBL_doc_generatePCheckBox")); // NOI18N
138
139
        alignParamsCheckBox.setText(org.openide.util.NbBundle.getMessage(FmtComments.class, "LBL_doc_alignParamsCheckBox")); // NOI18N
140
141
        alignReturnCheckBox.setText(org.openide.util.NbBundle.getMessage(FmtComments.class, "LBL_doc_alignReturnCheckBox")); // NOI18N
142
143
        alignExceptionsCheckBox.setText(org.openide.util.NbBundle.getMessage(FmtComments.class, "LBL_doc_alignExceptionsCheckBox")); // NOI18N
144
145
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
146
        this.setLayout(layout);
147
        layout.setHorizontalGroup(
148
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
149
            .addGroup(layout.createSequentialGroup()
150
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
151
                    .addComponent(enableCommentFormatCheckBox)
152
                    .addGroup(layout.createSequentialGroup()
153
                        .addComponent(generalLabel)
154
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
155
                        .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 329, Short.MAX_VALUE))
156
                    .addGroup(layout.createSequentialGroup()
157
                        .addGap(12, 12, 12)
158
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
159
                            .addComponent(wrapCommentTextCheckBox)
160
                            .addComponent(addLeadingStarCheckBox)
161
                            .addComponent(wrapOneLineCheckBox)
162
                            .addComponent(preserveNewLinesCheckBox)))
163
                    .addGroup(layout.createSequentialGroup()
164
                        .addComponent(javadocLabel)
165
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
166
                        .addComponent(jSeparator2, javax.swing.GroupLayout.DEFAULT_SIZE, 328, Short.MAX_VALUE))
167
                    .addGroup(layout.createSequentialGroup()
168
                        .addGap(12, 12, 12)
169
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
170
                            .addComponent(blankLineAfterParamsCheckBox)
171
                            .addComponent(blankLineAfterDescCheckBox)
172
                            .addComponent(blankLineAfterReturnCheckBox)
173
                            .addComponent(generatePCheckBox)
174
                            .addComponent(alignParamsCheckBox)
175
                            .addComponent(alignReturnCheckBox)
176
                            .addComponent(alignExceptionsCheckBox))))
177
                .addContainerGap())
178
        );
179
        layout.setVerticalGroup(
180
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
181
            .addGroup(layout.createSequentialGroup()
182
                .addComponent(enableCommentFormatCheckBox)
183
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
184
                    .addGroup(layout.createSequentialGroup()
185
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
186
                        .addComponent(generalLabel))
187
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
188
                        .addGap(16, 16, 16)
189
                        .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 7, javax.swing.GroupLayout.PREFERRED_SIZE)))
190
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
191
                .addComponent(addLeadingStarCheckBox)
192
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
193
                .addComponent(wrapCommentTextCheckBox)
194
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
195
                .addComponent(wrapOneLineCheckBox)
196
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
197
                .addComponent(preserveNewLinesCheckBox)
198
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
199
                    .addGroup(layout.createSequentialGroup()
200
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
201
                        .addComponent(javadocLabel))
202
                    .addGroup(layout.createSequentialGroup()
203
                        .addGap(15, 15, 15)
204
                        .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
205
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
206
                .addComponent(blankLineAfterDescCheckBox)
207
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
208
                .addComponent(blankLineAfterParamsCheckBox)
209
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
210
                .addComponent(blankLineAfterReturnCheckBox)
211
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
212
                .addComponent(generatePCheckBox)
213
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
214
                .addComponent(alignParamsCheckBox)
215
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
216
                .addComponent(alignReturnCheckBox)
217
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
218
                .addComponent(alignExceptionsCheckBox)
219
                .addContainerGap(20, Short.MAX_VALUE))
220
        );
221
    }// </editor-fold>//GEN-END:initComponents
222
223
private void enableCommentFormatCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_enableCommentFormatCheckBoxActionPerformed
224
    enableControls(enableCommentFormatCheckBox.isSelected());
225
}//GEN-LAST:event_enableCommentFormatCheckBoxActionPerformed
226
227
    // Variables declaration - do not modify//GEN-BEGIN:variables
228
    private javax.swing.JCheckBox addLeadingStarCheckBox;
229
    private javax.swing.JCheckBox alignExceptionsCheckBox;
230
    private javax.swing.JCheckBox alignParamsCheckBox;
231
    private javax.swing.JCheckBox alignReturnCheckBox;
232
    private javax.swing.JCheckBox blankLineAfterDescCheckBox;
233
    private javax.swing.JCheckBox blankLineAfterParamsCheckBox;
234
    private javax.swing.JCheckBox blankLineAfterReturnCheckBox;
235
    private javax.swing.JCheckBox enableCommentFormatCheckBox;
236
    private javax.swing.JLabel generalLabel;
237
    private javax.swing.JCheckBox generatePCheckBox;
238
    private javax.swing.JSeparator jSeparator1;
239
    private javax.swing.JSeparator jSeparator2;
240
    private javax.swing.JLabel javadocLabel;
241
    private javax.swing.JCheckBox preserveNewLinesCheckBox;
242
    private javax.swing.JCheckBox wrapCommentTextCheckBox;
243
    private javax.swing.JCheckBox wrapOneLineCheckBox;
244
    // End of variables declaration//GEN-END:variables
245
246
    private void enableControls(boolean b) {
247
        addLeadingStarCheckBox.setEnabled(b);
248
        alignExceptionsCheckBox.setEnabled(b);
249
        alignParamsCheckBox.setEnabled(b);
250
        blankLineAfterDescCheckBox.setEnabled(b);
251
        blankLineAfterParamsCheckBox.setEnabled(b);
252
        blankLineAfterReturnCheckBox.setEnabled(b);
253
        generatePCheckBox.setEnabled(b);
254
        preserveNewLinesCheckBox.setEnabled(b);
255
        wrapCommentTextCheckBox.setEnabled(b);
256
        wrapOneLineCheckBox.setEnabled(b);
257
    }
258
}
(-)a/java.source/src/org/netbeans/modules/java/ui/FmtOptions.java (-2 / +29 lines)
Lines 239-244 Link Here
239
    public static final String packagesForStarImport = "packagesForStarImport"; //NOI18N
239
    public static final String packagesForStarImport = "packagesForStarImport"; //NOI18N
240
    public static final String importsOrder = "importsOrder"; //NOI18N
240
    public static final String importsOrder = "importsOrder"; //NOI18N
241
    
241
    
242
    public static final String enableCommentFormatting = "enableCommentFormatting"; //NOI18N
243
    public static final String wrapCommentText = "wrapCommentText"; //NOI18N
244
    public static final String wrapOneLineComment = "wrapOneLineComment"; //NOI18N
245
    public static final String preserveNewLinesInComments = "preserveNewLinesInComments"; //NOI18N
246
    public static final String blankLineAfterJavadocDescription = "blankLineAfterJavadocDescription"; //NOI18N
247
    public static final String blankLineAfterJavadocParameterDescriptions = "blankLineAfterJavadocParameterDescriptions"; //NOI18N
248
    public static final String blankLineAfterJavadocReturnTag = "blankLineAfterJavadocReturnTag"; //NOI18N
249
    public static final String generateParagraphTagOnBlankLines = "generateParagraphTagOnBlankLines"; //NOI18N
250
    public static final String alignJavadocParameterDescriptions = "alignJavadocParameterDescriptions"; //NOI18N
251
    public static final String alignJavadocReturnDescription = "alignJavadocReturnDescription"; //NOI18N
252
    public static final String alignJavadocExceptionDescriptions = "alignJavadocExceptionDescriptions"; //NOI18N
253
242
    public static CodeStyleProducer codeStyleProducer;
254
    public static CodeStyleProducer codeStyleProducer;
243
    
255
    
244
    static final String CODE_STYLE_PROFILE = "CodeStyle"; // NOI18N
256
    static final String CODE_STYLE_PROFILE = "CodeStyle"; // NOI18N
Lines 477-482 Link Here
477
            { countForUsingStaticStarImport, "3"}, //NOI18N // XXX
489
            { countForUsingStaticStarImport, "3"}, //NOI18N // XXX
478
            { packagesForStarImport, ""}, //NOI18N // XXX
490
            { packagesForStarImport, ""}, //NOI18N // XXX
479
            { importsOrder, ""}, //NOI18N // XXX
491
            { importsOrder, ""}, //NOI18N // XXX
492
            
493
            { enableCommentFormatting, TRUE}, //NOI18N
494
            { wrapCommentText, TRUE}, //NOI18N
495
            { wrapOneLineComment, TRUE}, //NOI18N
496
            { preserveNewLinesInComments, FALSE}, //NOI18N
497
            { blankLineAfterJavadocDescription, TRUE}, //NOI18N
498
            { blankLineAfterJavadocParameterDescriptions, FALSE}, //NOI18N
499
            { blankLineAfterJavadocReturnTag, FALSE}, //NOI18N
500
            { generateParagraphTagOnBlankLines, TRUE}, //NOI18N
501
            { alignJavadocParameterDescriptions, FALSE}, //NOI18N
502
            { alignJavadocReturnDescription, FALSE}, //NOI18N
503
            { alignJavadocExceptionDescriptions, FALSE}, //NOI18N                        
480
        };
504
        };
481
        
505
        
482
        defaults = new HashMap<String,String>();
506
        defaults = new HashMap<String,String>();
Lines 543-549 Link Here
543
            for (String[] option : forcedOptions) {
567
            for (String[] option : forcedOptions) {
544
                forcedPrefs.put( option[0], option[1]);
568
                forcedPrefs.put( option[0], option[1]);
545
            }
569
            }
546
            this.previewPrefs = new ProxyPreferences(preferences, forcedPrefs);
570
            this.previewPrefs = new ProxyPreferences(forcedPrefs, preferences);
547
571
548
            // Load and hook up all the components
572
            // Load and hook up all the components
549
            loadFrom(preferences);
573
            loadFrom(preferences);
Lines 671-677 Link Here
671
695
672
            public PreferencesCustomizer create(Preferences preferences) {
696
            public PreferencesCustomizer create(Preferences preferences) {
673
                try {
697
                try {
674
                    return new CategorySupport(preferences, id, panelClass.newInstance(), previewText, forcedOptions);
698
                    CategorySupport categorySupport = new CategorySupport(preferences, id, panelClass.newInstance(), previewText, forcedOptions);
699
                    if (categorySupport.panel instanceof Runnable)
700
                        ((Runnable)categorySupport.panel).run();
701
                    return categorySupport;
675
                } catch (Exception e) {
702
                } catch (Exception e) {
676
                    return null;
703
                    return null;
677
                }
704
                }
(-)a/java.source/src/org/netbeans/modules/java/ui/FmtTabsIndents.form (-28 / +2 lines)
Lines 1-4 Link Here
1
<?xml version="1.0" encoding="UTF-8" ?>
1
<?xml version="1.1" encoding="UTF-8" ?>
2
2
3
<Form version="1.4" maxVersion="1.4" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
3
<Form version="1.4" maxVersion="1.4" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
4
  <Properties>
4
  <Properties>
Lines 7-15 Link Here
7
    </Property>
7
    </Property>
8
    <Property name="opaque" type="boolean" value="false"/>
8
    <Property name="opaque" type="boolean" value="false"/>
9
  </Properties>
9
  </Properties>
10
  <SyntheticProperties>
11
    <SyntheticProperty name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-60,0,0,0,-14"/>
12
  </SyntheticProperties>
13
  <AuxValues>
10
  <AuxValues>
14
    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
11
    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
15
    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
12
    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
Lines 39-48 Link Here
39
          <Component id="indentCasesFromSwitchCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
36
          <Component id="indentCasesFromSwitchCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
40
          <Component id="indentTopLevelClassMembersCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
37
          <Component id="indentTopLevelClassMembersCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
41
          <Component id="absoluteLabelIndentCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
38
          <Component id="absoluteLabelIndentCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
42
          <Group type="102" alignment="0" attributes="0">
43
              <Component id="addLeadingStarInCommentCheckBox" min="-2" max="-2" attributes="0"/>
44
              <EmptySpace max="-2" attributes="0"/>
45
          </Group>
46
      </Group>
39
      </Group>
47
    </DimensionLayout>
40
    </DimensionLayout>
48
    <DimensionLayout dim="1">
41
    <DimensionLayout dim="1">
Lines 64-72 Link Here
64
              <Component id="indentTopLevelClassMembersCheckBox" min="-2" max="-2" attributes="0"/>
57
              <Component id="indentTopLevelClassMembersCheckBox" min="-2" max="-2" attributes="0"/>
65
              <EmptySpace max="-2" attributes="0"/>
58
              <EmptySpace max="-2" attributes="0"/>
66
              <Component id="indentCasesFromSwitchCheckBox" min="-2" max="-2" attributes="0"/>
59
              <Component id="indentCasesFromSwitchCheckBox" min="-2" max="-2" attributes="0"/>
67
              <EmptySpace max="-2" attributes="0"/>
60
              <EmptySpace pref="33" max="32767" attributes="0"/>
68
              <Component id="addLeadingStarInCommentCheckBox" min="-2" max="-2" attributes="0"/>
69
              <EmptySpace max="32767" attributes="0"/>
70
          </Group>
61
          </Group>
71
      </Group>
62
      </Group>
72
    </DimensionLayout>
63
    </DimensionLayout>
Lines 157-178 Link Here
157
        </Property>
148
        </Property>
158
      </AccessibilityProperties>
149
      </AccessibilityProperties>
159
    </Component>
150
    </Component>
160
    <Component class="javax.swing.JCheckBox" name="addLeadingStarInCommentCheckBox">
161
      <Properties>
162
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
163
          <ResourceString bundle="org/netbeans/modules/java/ui/Bundle.properties" key="LBL_AddLeadingStarInComment" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
164
        </Property>
165
        <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
166
          <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
167
            <EmptyBorder bottom="0" left="0" right="0" top="0"/>
168
          </Border>
169
        </Property>
170
      </Properties>
171
      <AccessibilityProperties>
172
        <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
173
          <ResourceString bundle="org/netbeans/modules/java/ui/Bundle.properties" key="FmtTabsIndents.addLeadingStarInCommentCheckBox.AccessibleContext.accessibleDescription" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
174
        </Property>
175
      </AccessibilityProperties>
176
    </Component>
177
  </SubComponents>
151
  </SubComponents>
178
</Form>
152
</Form>
(-)a/java.source/src/org/netbeans/modules/java/ui/FmtTabsIndents.java (-15 / +2 lines)
Lines 44-50 Link Here
44
44
45
package org.netbeans.modules.java.ui;
45
package org.netbeans.modules.java.ui;
46
46
47
import org.netbeans.api.java.source.CodeStyle.WrapStyle;
48
import static org.netbeans.modules.java.ui.FmtOptions.*;
47
import static org.netbeans.modules.java.ui.FmtOptions.*;
49
import static org.netbeans.modules.java.ui.FmtOptions.CategorySupport.OPTION_ID;
48
import static org.netbeans.modules.java.ui.FmtOptions.CategorySupport.OPTION_ID;
50
import org.netbeans.modules.java.ui.FmtOptions.CategorySupport;
49
import org.netbeans.modules.java.ui.FmtOptions.CategorySupport;
Lines 68-74 Link Here
68
        absoluteLabelIndentCheckBox.putClientProperty(OPTION_ID, absoluteLabelIndent);
67
        absoluteLabelIndentCheckBox.putClientProperty(OPTION_ID, absoluteLabelIndent);
69
        indentTopLevelClassMembersCheckBox.putClientProperty(OPTION_ID, indentTopLevelClassMembers);
68
        indentTopLevelClassMembersCheckBox.putClientProperty(OPTION_ID, indentTopLevelClassMembers);
70
        indentCasesFromSwitchCheckBox.putClientProperty(OPTION_ID, indentCasesFromSwitch);
69
        indentCasesFromSwitchCheckBox.putClientProperty(OPTION_ID, indentCasesFromSwitch);
71
        addLeadingStarInCommentCheckBox.putClientProperty(OPTION_ID, addLeadingStarInComment);
72
//        rightMarginField.putClientProperty(OPTION_ID, rightMargin);
70
//        rightMarginField.putClientProperty(OPTION_ID, rightMargin);
73
    }
71
    }
74
    
72
    
Lines 94-100 Link Here
94
        absoluteLabelIndentCheckBox = new javax.swing.JCheckBox();
92
        absoluteLabelIndentCheckBox = new javax.swing.JCheckBox();
95
        indentTopLevelClassMembersCheckBox = new javax.swing.JCheckBox();
93
        indentTopLevelClassMembersCheckBox = new javax.swing.JCheckBox();
96
        indentCasesFromSwitchCheckBox = new javax.swing.JCheckBox();
94
        indentCasesFromSwitchCheckBox = new javax.swing.JCheckBox();
97
        addLeadingStarInCommentCheckBox = new javax.swing.JCheckBox();
98
95
99
        setName(org.openide.util.NbBundle.getMessage(FmtTabsIndents.class, "LBL_TabsAndIndents")); // NOI18N
96
        setName(org.openide.util.NbBundle.getMessage(FmtTabsIndents.class, "LBL_TabsAndIndents")); // NOI18N
100
        setOpaque(false);
97
        setOpaque(false);
Lines 114-122 Link Here
114
        org.openide.awt.Mnemonics.setLocalizedText(indentCasesFromSwitchCheckBox, org.openide.util.NbBundle.getMessage(FmtTabsIndents.class, "LBL_IndentCasesFromSwitch")); // NOI18N
111
        org.openide.awt.Mnemonics.setLocalizedText(indentCasesFromSwitchCheckBox, org.openide.util.NbBundle.getMessage(FmtTabsIndents.class, "LBL_IndentCasesFromSwitch")); // NOI18N
115
        indentCasesFromSwitchCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
112
        indentCasesFromSwitchCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
116
113
117
        org.openide.awt.Mnemonics.setLocalizedText(addLeadingStarInCommentCheckBox, org.openide.util.NbBundle.getMessage(FmtTabsIndents.class, "LBL_AddLeadingStarInComment")); // NOI18N
118
        addLeadingStarInCommentCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
119
120
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
114
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
121
        this.setLayout(layout);
115
        this.setLayout(layout);
122
        layout.setHorizontalGroup(
116
        layout.setHorizontalGroup(
Lines 132-143 Link Here
132
            .addComponent(indentCasesFromSwitchCheckBox)
126
            .addComponent(indentCasesFromSwitchCheckBox)
133
            .addComponent(indentTopLevelClassMembersCheckBox)
127
            .addComponent(indentTopLevelClassMembersCheckBox)
134
            .addComponent(absoluteLabelIndentCheckBox)
128
            .addComponent(absoluteLabelIndentCheckBox)
135
            .addGroup(layout.createSequentialGroup()
136
                .addComponent(addLeadingStarInCommentCheckBox)
137
                .addContainerGap())
138
        );
129
        );
139
130
140
        layout.linkSize( javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[]{continuationIndentSizeField, labelIndentField});
131
        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {continuationIndentSizeField, labelIndentField});
141
132
142
        layout.setVerticalGroup(
133
        layout.setVerticalGroup(
143
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
134
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
Lines 156-164 Link Here
156
                .addComponent(indentTopLevelClassMembersCheckBox)
147
                .addComponent(indentTopLevelClassMembersCheckBox)
157
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
148
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
158
                .addComponent(indentCasesFromSwitchCheckBox)
149
                .addComponent(indentCasesFromSwitchCheckBox)
159
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
150
                .addContainerGap(33, Short.MAX_VALUE))
160
                .addComponent(addLeadingStarInCommentCheckBox)
161
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
162
        );
151
        );
163
152
164
        continuationIndentSizeField.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(FmtTabsIndents.class, "FmtTabsIndents.continuationIndentSizeField.AccessibleContext.accessibleDescription")); // NOI18N
153
        continuationIndentSizeField.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(FmtTabsIndents.class, "FmtTabsIndents.continuationIndentSizeField.AccessibleContext.accessibleDescription")); // NOI18N
Lines 166-178 Link Here
166
        absoluteLabelIndentCheckBox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(FmtTabsIndents.class, "FmtTabsIndents.absoluteLabelIndentCheckBox.AccessibleContext.accessibleDescription")); // NOI18N
155
        absoluteLabelIndentCheckBox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(FmtTabsIndents.class, "FmtTabsIndents.absoluteLabelIndentCheckBox.AccessibleContext.accessibleDescription")); // NOI18N
167
        indentTopLevelClassMembersCheckBox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(FmtTabsIndents.class, "FmtTabsIndents.indentTopLevelClassMembersCheckBox.AccessibleContext.accessibleDescription")); // NOI18N
156
        indentTopLevelClassMembersCheckBox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(FmtTabsIndents.class, "FmtTabsIndents.indentTopLevelClassMembersCheckBox.AccessibleContext.accessibleDescription")); // NOI18N
168
        indentCasesFromSwitchCheckBox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(FmtTabsIndents.class, "FmtTabsIndents.indentCasesFromSwitchCheckBox.AccessibleContext.accessibleDescription")); // NOI18N
157
        indentCasesFromSwitchCheckBox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(FmtTabsIndents.class, "FmtTabsIndents.indentCasesFromSwitchCheckBox.AccessibleContext.accessibleDescription")); // NOI18N
169
        addLeadingStarInCommentCheckBox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(FmtTabsIndents.class, "FmtTabsIndents.addLeadingStarInCommentCheckBox.AccessibleContext.accessibleDescription")); // NOI18N
170
    }// </editor-fold>//GEN-END:initComponents
158
    }// </editor-fold>//GEN-END:initComponents
171
    
159
    
172
    
160
    
173
    // Variables declaration - do not modify//GEN-BEGIN:variables
161
    // Variables declaration - do not modify//GEN-BEGIN:variables
174
    private javax.swing.JCheckBox absoluteLabelIndentCheckBox;
162
    private javax.swing.JCheckBox absoluteLabelIndentCheckBox;
175
    private javax.swing.JCheckBox addLeadingStarInCommentCheckBox;
176
    private javax.swing.JTextField continuationIndentSizeField;
163
    private javax.swing.JTextField continuationIndentSizeField;
177
    private javax.swing.JLabel continuationIndentSizeLabel;
164
    private javax.swing.JLabel continuationIndentSizeLabel;
178
    private javax.swing.JCheckBox indentCasesFromSwitchCheckBox;
165
    private javax.swing.JCheckBox indentCasesFromSwitchCheckBox;
(-)a/java.source/test/unit/src/org/netbeans/modules/java/source/save/FormatingTest.java (-1 / +480 lines)
Lines 3041-3046 Link Here
3041
        preferences.putBoolean("absoluteLabelIndent", false);
3041
        preferences.putBoolean("absoluteLabelIndent", false);
3042
    }
3042
    }
3043
3043
3044
    public void testJavadoc() throws Exception {
3045
        testFile = new File(getWorkDir(), "Test.java");
3046
        TestUtilities.copyStringToFile(testFile,
3047
                "package hierbas.del.litoral;\n\n"
3048
                + "public class Test {\n"
3049
                + "    public void taragui(CharSequence cs, Object obj) {\n"
3050
                + "    }\n"
3051
                + "}\n");
3052
        FileObject testSourceFO = FileUtil.toFileObject(testFile);
3053
        DataObject testSourceDO = DataObject.find(testSourceFO);
3054
        EditorCookie ec = (EditorCookie)testSourceDO.getCookie(EditorCookie.class);
3055
        final Document doc = ec.openDocument();
3056
        doc.putProperty(Language.class, JavaTokenId.language());
3057
        String content =
3058
                "package hierbas.del.litoral;\n"
3059
                + "public class Test{\n"
3060
                + "/**\n"
3061
                + "*This is a test JavaDoc  for the taragui method.\n"
3062
                + "*  Method description is here.\n"
3063
                + "*<pre>\n"
3064
                + "* Test t = new Test();\n"
3065
                + "* try {\n"
3066
                + "*     t.taragui(\"TEST\", t);\n"
3067
                + "* } catch (Exception e) {}\n"
3068
                + "*</pre>\n"
3069
                + "* @param cs this is the first parameter description.\n"
3070
                + "* @param obj this is the second parameter description.\n"
3071
                + "*@return this is the return value description.\n"
3072
                + "*  @throws MyRuntimeException the first exception description.\n"
3073
                + "* @throws AnException the second exception description.\n"
3074
                + "*/\n"
3075
                + "public String taragui(CharSequence cs, Object obj) throws MyRuntimeException, AnExeption {\n"
3076
                + "/*  This is a block comment.*/\n"
3077
                + "return null;\n"
3078
                + "}\n"
3079
                + "}\n";
3080
3081
        Preferences preferences = MimeLookup.getLookup(JavaTokenId.language().mimeType()).lookup(Preferences.class);
3082
        preferences.putInt("text-limit-width", 45);
3083
3084
        String golden =
3085
                "package hierbas.del.litoral;\n"
3086
                + "\n"
3087
                + "public class Test {\n"
3088
                + "\n"
3089
                + "    /**\n"
3090
                + "     * This is a test JavaDoc for the taragui\n"
3091
                + "     * method. Method description is here.\n"
3092
                + "     * <pre>\n"
3093
                + "     * Test t = new Test();\n"
3094
                + "     * try {\n"
3095
                + "     *     t.taragui(\"TEST\", t);\n"
3096
                + "     * } catch (Exception e) {}\n"
3097
                + "     * </pre>\n"
3098
                + "     * <p/>\n"
3099
                + "     * @param cs this is the first parameter\n"
3100
                + "     * description.\n"
3101
                + "     * @param obj this is the second\n"
3102
                + "     * parameter description.\n"
3103
                + "     * @return this is the return value\n"
3104
                + "     * description.\n"
3105
                + "     * @throws MyRuntimeException the first\n"
3106
                + "     * exception description.\n"
3107
                + "     * @throws AnException the second\n"
3108
                + "     * exception description.\n"
3109
                + "     */\n"
3110
                + "    public String taragui(CharSequence cs, Object obj) throws MyRuntimeException, AnExeption {\n"
3111
                + "        /*\n"
3112
                + "         * This is a block comment.\n"
3113
                + "         */\n"
3114
                + "        return null;\n"
3115
                + "    }\n"
3116
                + "}\n";        
3117
        reformat(doc, content, golden);
3118
        
3119
        golden =
3120
                "package hierbas.del.litoral;\n"
3121
                + "\n"
3122
                + "public class Test {\n"
3123
                + "\n"
3124
                + "    /**\n"
3125
                + "     *This is a test JavaDoc  for the taragui method.\n"
3126
                + "     *  Method description is here.\n"
3127
                + "     *<pre>\n"
3128
                + "     * Test t = new Test();\n"
3129
                + "     * try {\n"
3130
                + "     *     t.taragui(\"TEST\", t);\n"
3131
                + "     * } catch (Exception e) {}\n"
3132
                + "     *</pre>\n"
3133
                + "     * @param cs this is the first parameter description.\n"
3134
                + "     * @param obj this is the second parameter description.\n"
3135
                + "     *@return this is the return value description.\n"
3136
                + "     *  @throws MyRuntimeException the first exception description.\n"
3137
                + "     * @throws AnException the second exception description.\n"
3138
                + "     */\n"
3139
                + "    public String taragui(CharSequence cs, Object obj) throws MyRuntimeException, AnExeption {\n"
3140
                + "        /*  This is a block comment.*/\n"
3141
                + "        return null;\n"
3142
                + "    }\n"
3143
                + "}\n";        
3144
        preferences.putBoolean("enableCommentFormatting", false);
3145
        reformat(doc, content, golden);
3146
        preferences.remove("enableCommentFormatting");
3147
        
3148
        golden =
3149
                "package hierbas.del.litoral;\n"
3150
                + "\n"
3151
                + "public class Test {\n"
3152
                + "\n"
3153
                + "    /**\n"
3154
                + "     * This is a test JavaDoc for the taragui method.\n"
3155
                + "     * Method description is here.\n"
3156
                + "     * <pre>\n"
3157
                + "     * Test t = new Test();\n"
3158
                + "     * try {\n"
3159
                + "     *     t.taragui(\"TEST\", t);\n"
3160
                + "     * } catch (Exception e) {}\n"
3161
                + "     * </pre>\n"
3162
                + "     * <p/>\n"
3163
                + "     * @param cs this is the first parameter description.\n"
3164
                + "     * @param obj this is the second parameter description.\n"
3165
                + "     * @return this is the return value description.\n"
3166
                + "     * @throws MyRuntimeException the first exception description.\n"
3167
                + "     * @throws AnException the second exception description.\n"
3168
                + "     */\n"
3169
                + "    public String taragui(CharSequence cs, Object obj) throws MyRuntimeException, AnExeption {\n"
3170
                + "        /*\n"
3171
                + "         * This is a block comment.\n"
3172
                + "         */\n"
3173
                + "        return null;\n"
3174
                + "    }\n"
3175
                + "}\n";        
3176
        preferences.putBoolean("wrapCommentText", false);
3177
        reformat(doc, content, golden);
3178
        preferences.remove("wrapCommentText");
3179
        
3180
        golden =
3181
                "package hierbas.del.litoral;\n"
3182
                + "\n"
3183
                + "public class Test {\n"
3184
                + "\n"
3185
                + "    /**\n"
3186
                + "     This is a test JavaDoc for the taragui\n"
3187
                + "     method. Method description is here.\n"
3188
                + "     <pre>\n"
3189
                + "     Test t = new Test();\n"
3190
                + "     try {\n"
3191
                + "         t.taragui(\"TEST\", t);\n"
3192
                + "     } catch (Exception e) {}\n"
3193
                + "     </pre>\n"
3194
                + "     <p/>\n"
3195
                + "     @param cs this is the first parameter\n"
3196
                + "     description.\n"
3197
                + "     @param obj this is the second parameter\n"
3198
                + "     description.\n"
3199
                + "     @return this is the return value\n"
3200
                + "     description.\n"
3201
                + "     @throws MyRuntimeException the first\n"
3202
                + "     exception description.\n"
3203
                + "     @throws AnException the second exception\n"
3204
                + "     description.\n"
3205
                + "     */\n"
3206
                + "    public String taragui(CharSequence cs, Object obj) throws MyRuntimeException, AnExeption {\n"
3207
                + "        /*\n"
3208
                + "         This is a block comment.\n"
3209
                + "         */\n"
3210
                + "        return null;\n"
3211
                + "    }\n"
3212
                + "}\n";        
3213
        preferences.putBoolean("addLeadingStarInComment", false);
3214
        reformat(doc, content, golden);
3215
3216
        golden =
3217
                "package hierbas.del.litoral;\n"
3218
                + "\n"
3219
                + "public class Test {\n"
3220
                + "\n"
3221
                + "    /**\n"
3222
                + "     This is a test JavaDoc for the taragui\n"
3223
                + "     method.\n"
3224
                + "     Method description is here.\n"
3225
                + "     <pre>\n"
3226
                + "     Test t = new Test();\n"
3227
                + "     try {\n"
3228
                + "         t.taragui(\"TEST\", t);\n"
3229
                + "     } catch (Exception e) {}\n"
3230
                + "     </pre>\n"
3231
                + "     <p/>\n"
3232
                + "     @param cs this is the first parameter\n"
3233
                + "     description.\n"
3234
                + "     @param obj this is the second parameter\n"
3235
                + "     description.\n"
3236
                + "     @return this is the return value\n"
3237
                + "     description.\n"
3238
                + "     @throws MyRuntimeException the first\n"
3239
                + "     exception description.\n"
3240
                + "     @throws AnException the second exception\n"
3241
                + "     description.\n"
3242
                + "     */\n"
3243
                + "    public String taragui(CharSequence cs, Object obj) throws MyRuntimeException, AnExeption {\n"
3244
                + "        /*\n"
3245
                + "         This is a block comment.\n"
3246
                + "         */\n"
3247
                + "        return null;\n"
3248
                + "    }\n"
3249
                + "}\n";        
3250
        preferences.putBoolean("preserveNewLinesInComments", true);
3251
        reformat(doc, content, golden);
3252
        preferences.remove("addLeadingStarInComment");
3253
3254
        golden =
3255
                "package hierbas.del.litoral;\n"
3256
                + "\n"
3257
                + "public class Test {\n"
3258
                + "\n"
3259
                + "    /**\n"
3260
                + "     * This is a test JavaDoc for the taragui\n"
3261
                + "     * method.\n"
3262
                + "     * Method description is here.\n"
3263
                + "     * <pre>\n"
3264
                + "     * Test t = new Test();\n"
3265
                + "     * try {\n"
3266
                + "     *     t.taragui(\"TEST\", t);\n"
3267
                + "     * } catch (Exception e) {}\n"
3268
                + "     * </pre>\n"
3269
                + "     * <p/>\n"
3270
                + "     * @param cs this is the first parameter\n"
3271
                + "     * description.\n"
3272
                + "     * @param obj this is the second\n"
3273
                + "     * parameter description.\n"
3274
                + "     * @return this is the return value\n"
3275
                + "     * description.\n"
3276
                + "     * @throws MyRuntimeException the first\n"
3277
                + "     * exception description.\n"
3278
                + "     * @throws AnException the second\n"
3279
                + "     * exception description.\n"
3280
                + "     */\n"
3281
                + "    public String taragui(CharSequence cs, Object obj) throws MyRuntimeException, AnExeption {\n"
3282
                + "        /*\n"
3283
                + "         * This is a block comment.\n"
3284
                + "         */\n"
3285
                + "        return null;\n"
3286
                + "    }\n"
3287
                + "}\n";        
3288
        reformat(doc, content, golden);
3289
        preferences.remove("preserveNewLinesInComments");
3290
3291
        golden =
3292
                "package hierbas.del.litoral;\n"
3293
                + "\n"
3294
                + "public class Test {\n"
3295
                + "\n"
3296
                + "    /**\n"
3297
                + "     * This is a test JavaDoc for the taragui\n"
3298
                + "     * method. Method description is here.\n"
3299
                + "     * <pre>\n"
3300
                + "     * Test t = new Test();\n"
3301
                + "     * try {\n"
3302
                + "     *     t.taragui(\"TEST\", t);\n"
3303
                + "     * } catch (Exception e) {}\n"
3304
                + "     * </pre>\n"
3305
                + "     *\n"
3306
                + "     * @param cs this is the first parameter\n"
3307
                + "     * description.\n"
3308
                + "     * @param obj this is the second\n"
3309
                + "     * parameter description.\n"
3310
                + "     * @return this is the return value\n"
3311
                + "     * description.\n"
3312
                + "     * @throws MyRuntimeException the first\n"
3313
                + "     * exception description.\n"
3314
                + "     * @throws AnException the second\n"
3315
                + "     * exception description.\n"
3316
                + "     */\n"
3317
                + "    public String taragui(CharSequence cs, Object obj) throws MyRuntimeException, AnExeption {\n"
3318
                + "        /*\n"
3319
                + "         * This is a block comment.\n"
3320
                + "         */\n"
3321
                + "        return null;\n"
3322
                + "    }\n"
3323
                + "}\n";        
3324
        preferences.putBoolean("generateParagraphTagOnBlankLines", false);
3325
        reformat(doc, content, golden);
3326
3327
        golden =
3328
                "package hierbas.del.litoral;\n"
3329
                + "\n"
3330
                + "public class Test {\n"
3331
                + "\n"
3332
                + "    /**\n"
3333
                + "     This is a test JavaDoc for the taragui\n"
3334
                + "     method. Method description is here.\n"
3335
                + "     <pre>\n"
3336
                + "     Test t = new Test();\n"
3337
                + "     try {\n"
3338
                + "         t.taragui(\"TEST\", t);\n"
3339
                + "     } catch (Exception e) {}\n"
3340
                + "     </pre>\n"
3341
                + "\n"
3342
                + "     @param cs this is the first parameter\n"
3343
                + "     description.\n"
3344
                + "     @param obj this is the second parameter\n"
3345
                + "     description.\n"
3346
                + "     @return this is the return value\n"
3347
                + "     description.\n"
3348
                + "     @throws MyRuntimeException the first\n"
3349
                + "     exception description.\n"
3350
                + "     @throws AnException the second exception\n"
3351
                + "     description.\n"
3352
                + "     */\n"
3353
                + "    public String taragui(CharSequence cs, Object obj) throws MyRuntimeException, AnExeption {\n"
3354
                + "        /*\n"
3355
                + "         This is a block comment.\n"
3356
                + "         */\n"
3357
                + "        return null;\n"
3358
                + "    }\n"
3359
                + "}\n";        
3360
        preferences.putBoolean("addLeadingStarInComment", false);
3361
        reformat(doc, content, golden);
3362
        preferences.remove("addLeadingStarInComment");
3363
        preferences.remove("generateParagraphTagOnBlankLines");
3364
        
3365
        golden =
3366
                "package hierbas.del.litoral;\n"
3367
                + "\n"
3368
                + "public class Test {\n"
3369
                + "\n"
3370
                + "    /**\n"
3371
                + "     * This is a test JavaDoc for the taragui\n"
3372
                + "     * method. Method description is here.\n"
3373
                + "     * <pre>\n"
3374
                + "     * Test t = new Test();\n"
3375
                + "     * try {\n"
3376
                + "     *     t.taragui(\"TEST\", t);\n"
3377
                + "     * } catch (Exception e) {}\n"
3378
                + "     * </pre>\n"
3379
                + "     * <p/>\n"
3380
                + "     * @param cs this is the first parameter\n"
3381
                + "     * description.\n"
3382
                + "     * @param obj this is the second\n"
3383
                + "     * parameter description.\n"
3384
                + "     * @return this is the return value\n"
3385
                + "     * description.\n"
3386
                + "     * @throws MyRuntimeException the first\n"
3387
                + "     * exception description.\n"
3388
                + "     * @throws AnException the second\n"
3389
                + "     * exception description.\n"
3390
                + "     */\n"
3391
                + "    public String taragui(CharSequence cs, Object obj) throws MyRuntimeException, AnExeption {\n"
3392
                + "        /* This is a block comment. */\n"
3393
                + "        return null;\n"
3394
                + "    }\n"
3395
                + "}\n";        
3396
        preferences.putBoolean("wrapOneLineComment", false);
3397
        reformat(doc, content, golden);
3398
        preferences.remove("wrapOneLineComment");
3399
        
3400
        golden =
3401
                "package hierbas.del.litoral;\n"
3402
                + "\n"
3403
                + "public class Test {\n"
3404
                + "\n"
3405
                + "    /**\n"
3406
                + "     * This is a test JavaDoc for the taragui\n"
3407
                + "     * method. Method description is here.\n"
3408
                + "     * <pre>\n"
3409
                + "     * Test t = new Test();\n"
3410
                + "     * try {\n"
3411
                + "     *     t.taragui(\"TEST\", t);\n"
3412
                + "     * } catch (Exception e) {}\n"
3413
                + "     * </pre>\n"
3414
                + "     * @param cs this is the first parameter\n"
3415
                + "     * description.\n"
3416
                + "     * @param obj this is the second\n"
3417
                + "     * parameter description.\n"
3418
                + "     * @return this is the return value\n"
3419
                + "     * description.\n"
3420
                + "     * @throws MyRuntimeException the first\n"
3421
                + "     * exception description.\n"
3422
                + "     * @throws AnException the second\n"
3423
                + "     * exception description.\n"
3424
                + "     */\n"
3425
                + "    public String taragui(CharSequence cs, Object obj) throws MyRuntimeException, AnExeption {\n"
3426
                + "        /*\n"
3427
                + "         * This is a block comment.\n"
3428
                + "         */\n"
3429
                + "        return null;\n"
3430
                + "    }\n"
3431
                + "}\n";        
3432
        preferences.putBoolean("blankLineAfterJavadocDescription", false);
3433
        reformat(doc, content, golden);
3434
        preferences.remove("blankLineAfterJavadocDescription");
3435
        
3436
        golden =
3437
                "package hierbas.del.litoral;\n"
3438
                + "\n"
3439
                + "public class Test {\n"
3440
                + "\n"
3441
                + "    /**\n"
3442
                + "     * This is a test JavaDoc for the taragui\n"
3443
                + "     * method. Method description is here.\n"
3444
                + "     * <pre>\n"
3445
                + "     * Test t = new Test();\n"
3446
                + "     * try {\n"
3447
                + "     *     t.taragui(\"TEST\", t);\n"
3448
                + "     * } catch (Exception e) {}\n"
3449
                + "     * </pre>\n"
3450
                + "     * <p/>\n"
3451
                + "     * @param cs  this is the first parameter\n"
3452
                + "     *            description.\n"
3453
                + "     * @param obj this is the second\n"
3454
                + "     *            parameter description.\n"
3455
                + "     * @return this is the return value\n"
3456
                + "     *         description.\n"
3457
                + "     * @throws MyRuntimeException the first\n"
3458
                + "     *                            exception\n"
3459
                + "     *                            description.\n"
3460
                + "     * @throws AnException        the second\n"
3461
                + "     *                            exception\n"
3462
                + "     *                            description.\n"
3463
                + "     */\n"
3464
                + "    public String taragui(CharSequence cs, Object obj) throws MyRuntimeException, AnExeption {\n"
3465
                + "        /*\n"
3466
                + "         * This is a block comment.\n"
3467
                + "         */\n"
3468
                + "        return null;\n"
3469
                + "    }\n"
3470
                + "}\n";        
3471
        preferences.putBoolean("alignJavadocParameterDescriptions", true);
3472
        preferences.putBoolean("alignJavadocReturnDescription", true);
3473
        preferences.putBoolean("alignJavadocExceptionDescriptions", true);
3474
        reformat(doc, content, golden);
3475
        preferences.remove("alignJavadocExceptionDescriptions");
3476
        preferences.remove("alignJavadocReturnDescription");
3477
        preferences.remove("alignJavadocParameterDescriptions");
3478
        
3479
        golden =
3480
                "package hierbas.del.litoral;\n"
3481
                + "\n"
3482
                + "public class Test {\n"
3483
                + "\n"
3484
                + "    /**\n"
3485
                + "     * This is a test JavaDoc for the taragui\n"
3486
                + "     * method. Method description is here.\n"
3487
                + "     * <pre>\n"
3488
                + "     * Test t = new Test();\n"
3489
                + "     * try {\n"
3490
                + "     *     t.taragui(\"TEST\", t);\n"
3491
                + "     * } catch (Exception e) {}\n"
3492
                + "     * </pre>\n"
3493
                + "     * <p/>\n"
3494
                + "     * @param cs this is the first parameter\n"
3495
                + "     * description.\n"
3496
                + "     * @param obj this is the second\n"
3497
                + "     * parameter description.\n"
3498
                + "     * <p/>\n"
3499
                + "     * @return this is the return value\n"
3500
                + "     * description.\n"
3501
                + "     * <p/>\n"
3502
                + "     * @throws MyRuntimeException the first\n"
3503
                + "     * exception description.\n"
3504
                + "     * @throws AnException the second\n"
3505
                + "     * exception description.\n"
3506
                + "     */\n"
3507
                + "    public String taragui(CharSequence cs, Object obj) throws MyRuntimeException, AnExeption {\n"
3508
                + "        /*\n"
3509
                + "         * This is a block comment.\n"
3510
                + "         */\n"
3511
                + "        return null;\n"
3512
                + "    }\n"
3513
                + "}\n";        
3514
        preferences.putBoolean("blankLineAfterJavadocParameterDescriptions", true);
3515
        preferences.putBoolean("blankLineAfterJavadocReturnTag", true);
3516
        reformat(doc, content, golden);
3517
        preferences.remove("blankLineAfterJavadocReturnTag");
3518
        preferences.remove("blankLineAfterJavadocParameterDescriptions");
3519
        
3520
        preferences.remove("text-limit-width");
3521
    }
3522
3044
    /**
3523
    /**
3045
     * Do not put spaces to parenthesis when method declaration has no
3524
     * Do not put spaces to parenthesis when method declaration has no
3046
     * parameters. The same rule should be applied to method invocation.
3525
     * parameters. The same rule should be applied to method invocation.
Lines 3281-3287 Link Here
3281
                + "    /**\n"
3760
                + "    /**\n"
3282
                + "     *\n"
3761
                + "     *\n"
3283
                + "     *\n"
3762
                + "     *\n"
3284
                + "    }\n";
3763
                + "     * }\n";
3285
        reformat(doc, content, golden);
3764
        reformat(doc, content, golden);
3286
    }
3765
    }
3287
3766

Return to bug 20672