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

(-)a/java.editor/src/org/netbeans/modules/java/editor/TalkToEditorImpl.java (+110 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 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 2012 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.java.editor;
43
44
import java.beans.PropertyChangeListener;
45
import java.util.prefs.Preferences;
46
import javax.swing.text.BadLocationException;
47
import javax.swing.text.Document;
48
import javax.swing.text.JTextComponent;
49
import org.netbeans.api.editor.EditorRegistry;
50
import org.netbeans.editor.GuardedDocument;
51
import org.netbeans.modules.editor.indent.api.IndentUtils;
52
import org.netbeans.modules.editor.indent.spi.CodeStylePreferences;
53
import org.netbeans.modules.java.preprocessorbridge.api.FmtConstants;
54
import org.netbeans.modules.java.preprocessorbridge.spi.TalkToEditor;
55
import org.openide.filesystems.FileObject;
56
import org.openide.util.lookup.ServiceProvider;
57
58
/**
59
 *
60
 * @author Jaroslav Tulach <jtulach@netbeans.org>
61
 */
62
@ServiceProvider(service=TalkToEditor.class)
63
public final class TalkToEditorImpl extends TalkToEditor {
64
    @Override
65
    protected Preferences implCodePreferences(FileObject file) {
66
        return CodeStylePreferences.get(file, FmtConstants.JAVA_MIME_TYPE).getPreferences();
67
    }
68
69
    @Override
70
    protected Preferences implCodePreferences(Document doc) {
71
        return CodeStylePreferences.get(doc, FmtConstants.JAVA_MIME_TYPE).getPreferences();
72
    }
73
74
    @Override
75
    protected JTextComponent implLastFocusedComponent() {
76
        return EditorRegistry.lastFocusedComponent();
77
    }
78
    
79
    @Override
80
    protected JTextComponent implFocusedComponent() {
81
        return EditorRegistry.focusedComponent();
82
    }
83
84
    @Override
85
    protected void implAddRemoveListener(PropertyChangeListener pcl, boolean toAdd) {
86
        if (toAdd) {
87
            EditorRegistry.addPropertyChangeListener(pcl);
88
        } else {
89
            EditorRegistry.removePropertyChangeListener(pcl);
90
        }
91
    }
92
93
    @Override
94
    protected int implOffsetIndent(Document doc, int offset) throws BadLocationException {
95
        int lineStartOffset = IndentUtils.lineStartOffset(doc, offset);
96
        return IndentUtils.lineIndent(doc, lineStartOffset);
97
    }
98
99
    @Override
100
    protected boolean implCheckGuarded(Document doc, int pos, long treePos) {
101
        if (!(doc instanceof GuardedDocument)) {
102
            return true;
103
        }
104
        pos = ((GuardedDocument) doc).getGuardedBlockChain().adjustToBlockEnd(pos);
105
        if (treePos < 0 || pos <= treePos) {
106
            return true;
107
        }
108
        return false;
109
    }
110
}
(-)a/java.source/src/org/netbeans/modules/java/ui/Bundle.properties (-470 / +7 lines)
Lines 1-6 Link Here
1
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
1
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
#
2
#
3
# Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
3
# Copyright 2012 Oracle and/or its affiliates. All rights reserved.
4
#
4
#
5
# Oracle and Java are registered trademarks of Oracle and/or its affiliates.
5
# Oracle and Java are registered trademarks of Oracle and/or its affiliates.
6
# Other names may be trademarks of their respective owners.
6
# Other names may be trademarks of their respective owners.
Lines 23-34 Link Here
23
# your own identifying information:
23
# your own identifying information:
24
# "Portions Copyrighted [year] [name of copyright owner]"
24
# "Portions Copyrighted [year] [name of copyright owner]"
25
#
25
#
26
# Contributor(s):
27
#
28
# The Original Software is NetBeans. The Initial Developer of the Original
29
# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
30
# Microsystems, Inc. All Rights Reserved.
31
#
32
# If you wish your version of this file to be governed by only the CDDL
26
# If you wish your version of this file to be governed by only the CDDL
33
# or only the GPL Version 2, indicate your decision by adding
27
# or only the GPL Version 2, indicate your decision by adding
34
# "[Contributor] elects to include this software in this distribution
28
# "[Contributor] elects to include this software in this distribution
Lines 39-508 Link Here
39
# However, if you add GPL Version 2 code and therefore, elected the GPL
33
# However, if you add GPL Version 2 code and therefore, elected the GPL
40
# Version 2 license, then the option applies only if the new code is
34
# Version 2 license, then the option applies only if the new code is
41
# made subject to such option by the copyright holder.
35
# made subject to such option by the copyright holder.
36
#
37
# Contributor(s):
38
#
39
# Portions Copyrighted 2012 Sun Microsystems, Inc.
42
40
43
# Formating options
41
FmtTabsIndents.continuationIndentSizeField.AccessibleContext.accessibleDescription=Indent size in spaces
44
45
LBL_TabsAndIndents=Tabs and Indents
46
LBL_CodeGeneration=Code Generation
47
LBL_Alignment=Alignment
48
LBL_Braces=Braces
49
LBL_Wrapping=Wrapping
50
LBL_BlankLines=Blank Lines
51
LBL_Spaces=Spaces
52
LBL_Imports=Imports
53
54
LBL_bp_SAME_LINE=Same Line
55
LBL_bp_NEW_LINE=New Line
56
LBL_bp_NEW_LINE_HALF_INDENTED=New Line Half Indented
57
LBL_bp_NEW_LINE_INDENTED= New Line Indented
58
    
59
LBL_bg_GENERATE=Generate
60
LBL_bg_LEAVE_ALONE=Leave Alone
61
LBL_bg_ELIMINATE=Eliminate
62
       
63
LBL_wrp_WRAP_ALWAYS=Always
64
LBL_wrp_WRAP_IF_LONG=If Long
65
LBL_wrp_WRAP_NEVER=Never
66
67
LBL_ip_CARET_LOCATION=Caret Location
68
LBL_ip_FIRST_IN_CATEGORY=First In Category
69
LBL_ip_LAST_IN_CATEGORY=Last In Category
70
71
LBL_ExpandTabToSpaces=&Expand Tab to Spaces
72
LBL_TabSize=&Tab Size:
73
LBL_IndentSize=&Indentation Size:
74
LBL_ContinuationIndentSize=&Continuation Indentation Size:
75
LBL_LabelIndent=&Label Indentation\:
76
LBL_AbsoluteLabelIndent=&Absolute Label Indentation
77
LBL_IndentTopLevelClassMemberts=&Indent Top Level Class Members
78
LBL_AddLeadingStarInComment=A&dd Leading Star In Comment
79
LBL_RightMargin=&Right Margin:
80
 
81
LBL_gen_Naming=Naming Conventions\:
82
LBL_gen_PreferLongerNames=Prefer Longer Names
83
LBL_gen_UseIsForBooleanGetters=Use Is For Boolean Getters
84
LBL_gen_Prefix=Prefix
85
LBL_gen_Suffix=Suffix
86
LBL_gen_Field=Field\:
87
LBL_gen_StaticField=Static Field\:
88
LBL_gen_Parameter=Parameter\:
89
LBL_gen_LocalVariable=Local Variable\:
90
LBL_gen_Other=Other\:
91
LBL_gen_QualifyFieldAccess=Qualify Field Access
92
LBL_gen_AddOverrideAnnotation=Add Override Annotation
93
LBL_gen_ParametersFinal=Make Generated Parameters Final
94
LBL_gen_LocalVariablesFinal=Make Generated Local variables Final
95
LBL_gen_MembersOreder=Members Sort Order\:
96
LBL_gen_MembersOrederUp=Move Up
97
LBL_gen_MembersOrederDown=Move Down
98
LBL_gen_SortByVisibility=Sort Members By Visibility
99
LBL_gen_InsertionPoint=Insertion Point\:
100
101
VAL_gen_STATIC=Static
102
VAL_gen_CLASS=Classes
103
VAL_gen_CONSTRUCTOR=Constructors
104
VAL_gen_FIELD=Fields
105
VAL_gen_INSTANCE_INIT=Instance Initializers
106
VAL_gen_METHOD=Methods
107
VAL_gen_STATIC_INIT=Static Initializers
108
109
VAL_gen_PUBLIC=Public
110
VAL_gen_PRIVATE=Private
111
VAL_gen_PROTECTED=Protected
112
VAL_gen_DEFAULT=Default
113
114
LBL_blBeforePackage=Before &Package\:
115
LBL_blAfterPackage=After Packa&ge\:
116
LBL_blBeforeImports=Before &Imports\:
117
LBL_blAfterImports=After Imports\:
118
LBL_blBeforeClass=Before &Class\:
119
LBL_blAfterClass=After C&lass\:
120
LBL_blAfterClassHeader=After Class &Header\:
121
LBL_blAfterAnonymousClassHeader=After &Anonymous Class Header:
122
LBL_blBeforeFields=Before &Field\:
123
LBL_blAfterFields=After Fi&eld\:
124
LBL_blBeforeMethods=Before &Method\:
125
LBL_blAfterMethods=After Me&thod\:
126
127
LBL_BeforeKeywords=Before Keywords
128
LBL_spaceBeforeWhile="while"
129
LBL_spaceBeforeElse="else"
130
LBL_spaceBeforeCatch="catch"
131
LBL_spaceBeforeFinally="finally"
132
133
LBL_BeforeParentheses=Before Parentheses
134
LBL_spaceBeforeMethodDeclParen=Method Declaration
135
LBL_spaceBeforeMethodCallParen=Method Call
136
LBL_spaceBeforeIfParen="if"
137
LBL_spaceBeforeForParen="for"
138
LBL_spaceBeforeWhileParen="while"
139
LBL_spaceBeforeTryParen="try"
140
LBL_spaceBeforeCatchParen="catch"
141
LBL_spaceBeforeSwitchParen="switch"
142
LBL_spaceBeforeSynchronizedParen="synchronized"
143
LBL_spaceBeforeAnnotationParen=Annotation Parameters
144
145
LBL_AroundOperators=Around Operators
146
LBL_spaceAroundUnaryOps=Unary Operators
147
LBL_spaceAroundBinaryOps=Binary Operators
148
LBL_spaceAroundTernaryOps=Ternary Operators
149
LBL_spaceAroundAssignOps=Assignment Operators
150
LBL_spaceAroundAnnotationValueAssignOps=Annotation Value Assignment Operator
151
152
LBL_BeforeLeftBraces=Before Left Braces
153
LBL_spaceBeforeClassDeclLeftBrace=Class Declaration
154
LBL_spaceBeforeMethodDeclLeftBrace=Method Declaration
155
LBL_spaceBeforeIfLeftBrace="if"
156
LBL_spaceBeforeElseLeftBrace="else"
157
LBL_spaceBeforeWhileLeftBrace="while"
158
LBL_spaceBeforeForLeftBrace="for"
159
LBL_spaceBeforeDoLeftBrace="do"
160
LBL_spaceBeforeSwitchLeftBrace="switch"
161
LBL_spaceBeforeTryLeftBrace="try"
162
LBL_spaceBeforeCatchLeftBrace="catch"
163
LBL_spaceBeforeFinallyLeftBrace="finally"
164
LBL_spaceBeforeSynchronizedLeftBrace="synchronized"
165
LBL_spaceBeforeStaticInitLeftBrace=Static Initializer
166
LBL_spaceBeforeArrayInitLeftBrace=Array Initializer
167
168
LBL_WithinParentheses=Within Parentheses
169
LBL_spaceWithinParens=Parentheses
170
LBL_spaceWithinMethodDeclParens=Method Declaration
171
LBL_spaceWithinMethodCallParens=Method Call
172
LBL_spaceWithinIfParens="if"
173
LBL_spaceWithinForParens="for"
174
LBL_spaceWithinWhileParens="while"
175
LBL_spaceWithinSwitchParens="switch"
176
LBL_spaceWithinTryParens="try"
177
LBL_spaceWithinCatchParens="catch"
178
LBL_spaceWithinSynchronizedParens="synchronized"
179
LBL_spaceWithinTypeCastParens=Type Cast
180
LBL_spaceWithinAnnotationParens=Annotation
181
LBL_spaceWithinBraces=Braces
182
LBL_spaceWithinArrayInitBrackets=Array Initializer Brackets
183
184
LBL_Other=Other
185
LBL_spaceBeforeComma=Before Comma
186
LBL_spaceAfterComma=After Comma
187
LBL_spaceBeforeSemi=Before Semicolon
188
LBL_spaceAfterSemi=After Semicolon
189
LBL_spaceBeforeColon=Before Colon
190
LBL_spaceAfterColon=After Colon
191
LBL_spaceAfterTypeCast=After Type Cast
192
193
LBL_wrp_extendsImplementsKeyword=&Extends/Implements Keyword\: 
194
LBL_wrp_extendsImplementsList=E&xtends/Implements List\:
195
LBL_wrp_methodParameters=Method &Parameters\:
196
LBL_wrp_throwsKeyword=&Throws Keyword\:
197
LBL_wrp_throwsList=Th&rows List\:
198
LBL_wrp_methodCallArgs=Method Call Arguments\:
199
LBL_wrp_annotationArgs=Annotation Arg&uments\:
200
LBL_wrp_chainedMethodCalls=C&hained Method Calls\:
201
LBL_wrp_afeterDot=Wrap After Dot In Chained Method Call
202
LBL_wrp_arrayInit=Array Initiali&zer\:
203
LBL_wrp_tryResources=Try Re&sources\:
204
LBL_wrp_multiCatches=Dis&junctive Catch Types\:
205
LBL_wrp_for=&For\:
206
LBL_wrp_forStatement=F&or Statement\:
207
LBL_wrp_ifStatement=&If Statement\:
208
LBL_wrp_whileStatement=&While Statement\:
209
LBL_wrp_doWhileStatement=&Do ... While Statement
210
LBL_wrp_assert=&Assert\:
211
LBL_wrp_enumConstants=Enum &Constants\:
212
LBL_wrp_annotations=A&nnotations\:
213
LBL_wrp_binaryOps=&Binary Operators\:
214
LBL_wrp_afeterBinaryOps=Wrap After Binary Operators
215
LBL_wrp_ternaryOps=Ternar&y Operators\:
216
LBL_wrp_afterTernaryOps=Wrap After Ternary Operators
217
LBL_wrp_assignOps=Assi&gnment Operators\:
218
219
LBL_br_bracesPlacement=Braces Placement
220
LBL_br_bracesGeneration=Braces Generation
221
LBL_al_newLines=New Lines
222
LBL_al_multilineAlignment=Multiline Alignment
223
LBL_bp_ClassDecl=&Class Declaration\:
224
LBL_bp_MethodDecl=&Method Declaration\:
225
LBL_bp_Other=&Other\:
226
LBL_bp_SpecialElseIf=&Special "else if" Treatment
227
LBL_bg_If="&if"\:
228
LBL_bg_For="&for"\:
229
LBL_bg_While="&while"\:
230
LBL_bg_DoWhile="&do ... while"\:
231
LBL_nl_Else="&else"
232
LBL_nl_While="w&hile"
233
LBL_nl_Catch="c&atch"
234
LBL_nl_Finally="finall&y"
235
LBL_nl_Modifiers=After modifie&rs
236
LBL_am_MethodParams=Method &Parameters
237
LBL_am_CallArgs=Method Call Arg&uments
238
LBL_am_AnnotationArgs=&Annotation Arguments
239
LBL_an_Implements=I&mplements List
240
LBL_am_Throws=&Throws List
241
LBL_am_Paren=Parenthesize&d
242
LBL_am_BinaryOp=&Binary Operators
243
LBL_am_TernaryOp=Ter&nary Operators
244
LBL_am_Assign=Assi&gnment
245
LBL_am_For=&For
246
LBL_am_ArrayInit=Array Initiali&zer
247
LBL_am_TryResources=Try Re&sources
248
LBL_am_MultiCatch=Dis&junctive Catch Types
249
250
LBL_IndentCasesFromSwitch=Indent Case Statements In &Switch
251
252
LBL_Comments=Comments
253
LBL_doc_enableCommentFormat=Enable Comments Formatting
254
LBL_doc_enableBlockCommentFormat=Format Block Comments
255
LBL_doc_generalLabel=General
256
LBL_doc_addLeadingStar=Add Leading Star
257
LBL_doc_wrapCommentText=Wrap Text At Right Margin
258
LBL_doc_wrapOneLineCheckBox=Wrap One Line Comments
259
LBL_doc_preserveNewLinesCheckBox=Preserve New Lines
260
LBL_doc_javadocLabel=Javadoc
261
LBL_doc_blankLineAfterDescCheckBox=Add Blank Line After Description
262
LBL_doc_blankLineAfterParamsCheckBox=Add Blank Line After Parameter Descriptions
263
LBL_doc_blankLineAfterReturnCheckBox=Add Blank Line After Return Tag
264
LBL_doc_generatePCheckBox=Generate "<p/>" On Blank Lines
265
LBL_doc_alignParamsCheckBox=Align Parameter Descriptions
266
LBL_doc_alignReturnCheckBox=Align Return Value Descriptions
267
LBL_doc_alignExceptionsCheckBox=Align Exception Descriptions
268
269
LBL_imp_useSingleClass=Use Single Class Imports
270
LBL_imp_usePackage=Use Package Imports
271
LBL_imp_useFQN=Use Fully Qualified Names
272
LBL_imp_importTreshold=Class Count To Use Star Import
273
LBL_imp_staticImportTreshold=Members Count To Use Static Star Import
274
LBL_imp_importInnerClasses=Import Inner Classes
275
LBL_imp_starImportPackages=Packages To Use Star Import: 
276
LBL_imp_importLayout=Import Layout:
277
LBL_imp_separateStaticImports=Separate Static Imports
278
LBL_imp_add=Add
279
LBL_imp_remove=Remove
280
LBL_imp_moveUp=Move Up
281
LBL_imp_moveDown=Move Down
282
LBL_imp_separateGroups=Separate Groups
283
LBL_imp_allOtherImports=<all other imports>
284
LBL_imp_Package=Package
285
LBL_imp_WithSub=*
286
LBL_imp_Static=Static
287
288
# Following entries (marked) as samples are used as examples in the formating
289
# options. It is highly discourage to localize them unless absolutely necessary.
290
291
SAMPLE_Default=public class ClassA {\
292
public int number = 1;\
293
private String text ="A";\
294
public ClassA() {\
295
}\
296
public void meth(String text, int number) {\
297
}\
298
}
299
300
SAMPLE_TabsIndents=public class ClassA {\
301
public int number = 1;\
302
private String letters[] = new String[]{ "A", "B" };\
303
public int meth(String text, int number) {\
304
if ( text == null ) {\
305
    text = "a";\
306
}\
307
else if (text.length() == 0) {\
308
    text = "empty";\
309
}\
310
else {\
311
    number++;\
312
}\
313
label:\
314
switch(number) {\
315
case 1\:\
316
    return meth("text", 22);\
317
case 2\:\
318
    return 20;\
319
default\:\
320
    return -1;\
321
}\
322
} }
323
324
SAMPLE_Align=@Anno(paramA="aValue", paramB="bValue")\
325
public class ClassA implements InterfaceA, InterfaceB {\
326
private String letters[] = new String[]{"A", "B"};\
327
public int meth(String text, int number) throws ExceptionA, ExceptionB {\
328
if ( text != null ) {\
329
try {\
330
meth( "Some text", text.length());\
331
} catch ( Throwable t ) {\
332
} finally {\
333
}\
334
} else {\
335
text = number == 0 ? "empty" : "nonempty";\
336
}\
337
do {\
338
number =\nnumber + 1;\
339
} while (number < 2);\
340
for( int i = 1; i < 100; i++ ) {\
341
number = (number +\ni) * 2;\
342
}\
343
}\
344
}
345
346
SAMPLE_Braces=public class ClassA {\
347
private String letters[] = new String[]{"A", "B"};\
348
public int meth(String text, int number) {\
349
if ( text != null ) {\
350
try {\
351
meth( "Some text", text.length());\
352
} catch ( Throwable t ) {\
353
} finally {\
354
}\
355
} else {\
356
text = number == 0 ? "empty" : "nonempty";\
357
}\
358
do {\
359
number = number + 1;\
360
} while (number < 2);\
361
for( int i = 1; i < 100; i++ ) {\
362
number = number + i;\
363
}\
364
while(number > 0) {\
365
number--;\
366
}\
367
}\
368
}
369
370
SAMPLE_Wrapping=@Anno(paramA="a Value", paramB="bValue")\
371
@Deprecated \
372
public class ClassA extends Object implements InterfaceA, InterfaceB, InterfaceC {\
373
private static final String letters[] = new String[]{ "A", "B", "C", "D" };\
374
public int number = 1;\
375
public ClassA() {\
376
}\
377
public int method(String text, int number, Object object) throws ExceptionA, ExceptionB {\
378
assert nuber + text.length() < 20 : "message";\
379
if (number==13 && object instanceof Runnable )\
380
method( "Some text", 12, new Object());\
381
for( int i = 1; i < 100; i++ )\
382
System.out.print(i);\
383
while ( this.number < 2 && number != 3 )\
384
this.number++;\
385
do \
386
method1().method2().method3();\
387
while ( this.number < 2 && number != 3 );\
388
return number > 100 ? -1 : -2;\
389
}\
390
public enum Where {\
391
NORTH, EAST, SOUTH, WEST;\
392
}\
393
}
394
395
396
SAMPLE_BlankLines=package org.netbeans.samples;\
397
import java.util.List;\
398
import java.util.Map;\
399
\
400
public class ClassA {\
401
public int i;\
402
public int j;\
403
\
404
public ClassA() {\
405
}\
406
public void methodA() {\
407
new Runnable() {\
408
public void run() {\
409
}\
410
};\
411
}\
412
public void methodB() {\
413
}\
414
public class innerClass {\
415
}\
416
public static interface innerInterface {\
417
}\
418
}
419
420
SAMPLE_Spaces=@Anno(paramA="aValue", paramB="bValue")\
421
public class ClassA {\
422
public int number = 1;\
423
private String text ="A";\
424
static float[] floats = new float[3];\
425
protected double[] doubles = new double[]{3.67,40,2e-30};\
426
\
427
static {\
428
    floats[0]=12.6f;\
429
}\
430
\
431
public ClassA() {\
432
}\
433
public int meth(String text, int number) {\
434
if (number==13) {\
435
return (int)System.currentTimeMillis();\
436
}else {\
437
}\
438
\
439
for( int i = 20; i < 100; i++) {\
440
    synchronized(this) {\
441
        while(i%13>5)\
442
            meth( text + " ", number++);\
443
    }\
444
}\
445
\
446
for(float f : floats)\
447
    System.out.println(f);\
448
\
449
switch(number) {\
450
case 1\:\
451
    do { out( (2+3)*this.number--); } while(this.number > 6);\
452
    return 10;\
453
case 2\:\
454
    try {\
455
        toString();\
456
    }\
457
    catch ( IllegalStateException illegalStateException ) {\
458
        illegalStateException.printStackTrace();\
459
    }\
460
    finally {\
461
        return 20;\
462
    }\
463
default\:\
464
   return number > 100 ? -1 : -2;\
465
}\
466
} }
467
468
SAMPLE_Comments=public class ClassA {\n\
469
/**\n\
470
This  is  the first part of a  sample  method  description.\n\
471
The second part is placed after a manual newline.\n\
472
\n\
473
The last part is placed after an empty line.\n\
474
@param text the first parameter description\n\
475
@param number the second parameter description\n\
476
@return this is the return value description\n\
477
@throws ExcepA the first exception description\n\
478
@throws ExcB the second exception description\n\
479
*/\n\
480
public String meth(String text, int number) throws ExceptionA, ExcB {\n\
481
/*This is one line comment*/\n\
482
return number > 0 ? text : null;\n\
483
}\n\
484
}
485
486
SAMPLE_Imports=package org.netbeans.samples;\
487
\
488
public class ClassA {\
489
\
490
public void method() {\
491
}\
492
}
493
494
SAMPLE_CodeGen=public class ClassA {\
495
\
496
private String name;\
497
}
498
499
nlFinallyCheckBox1.text="finall&y"
500
501
AN_Preview=Preview
502
AD_Preview=Preview
503
FmtTabsIndents.absoluteLabelIndentCheckBox.AccessibleContext.accessibleDescription=Indent Labels absolutely
42
FmtTabsIndents.absoluteLabelIndentCheckBox.AccessibleContext.accessibleDescription=Indent Labels absolutely
504
FmtTabsIndents.addLeadingStarInCommentCheckBox.AccessibleContext.accessibleDescription=Comment lines starting with leading star
43
FmtTabsIndents.labelIndentField.AccessibleContext.accessibleDescription=Label indentation size in spaces
505
FmtTabsIndents.indentCasesFromSwitchCheckBox.AccessibleContext.accessibleDescription=Additional indent for case statements
44
FmtTabsIndents.indentCasesFromSwitchCheckBox.AccessibleContext.accessibleDescription=Additional indent for case statements
506
FmtTabsIndents.indentTopLevelClassMembersCheckBox.AccessibleContext.accessibleDescription=Indent for top-level class members
45
FmtTabsIndents.indentTopLevelClassMembersCheckBox.AccessibleContext.accessibleDescription=Indent for top-level class members
507
FmtTabsIndents.continuationIndentSizeField.AccessibleContext.accessibleDescription=Indent size in spaces
508
FmtTabsIndents.labelIndentField.AccessibleContext.accessibleDescription=Label indentation size in spaces
(-)a/java.editor/src/org/netbeans/modules/java/ui/CategorySupport.java (+496 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 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 2012 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.java.ui;
43
44
import java.awt.Component;
45
import java.awt.Container;
46
import java.awt.Rectangle;
47
import java.awt.event.ActionEvent;
48
import java.awt.event.ActionListener;
49
import java.util.LinkedList;
50
import java.util.List;
51
import java.util.prefs.Preferences;
52
import javax.swing.ComboBoxModel;
53
import javax.swing.DefaultComboBoxModel;
54
import javax.swing.JComboBox;
55
import javax.swing.JComponent;
56
import javax.swing.JEditorPane;
57
import javax.swing.JList;
58
import javax.swing.JPanel;
59
import javax.swing.JSpinner;
60
import javax.swing.JTable;
61
import javax.swing.JTextField;
62
import javax.swing.JToggleButton;
63
import javax.swing.event.ChangeEvent;
64
import javax.swing.event.ChangeListener;
65
import javax.swing.event.DocumentEvent;
66
import javax.swing.event.DocumentListener;
67
import javax.swing.event.ListDataEvent;
68
import javax.swing.event.ListDataListener;
69
import javax.swing.event.TableModelEvent;
70
import javax.swing.event.TableModelListener;
71
import org.netbeans.api.editor.settings.SimpleValueNames;
72
import org.netbeans.api.java.source.CodeStyle;
73
import org.netbeans.api.java.source.CodeStyle.BracePlacement;
74
import org.netbeans.api.java.source.CodeStyle.BracesGenerationStyle;
75
import org.netbeans.api.java.source.CodeStyle.InsertionPoint;
76
import org.netbeans.api.java.source.CodeStyle.WrapStyle;
77
import org.netbeans.modules.java.preprocessorbridge.api.FmtConstants;
78
//XXX: import org.netbeans.modules.java.source.save.Reformatter;
79
import org.netbeans.modules.options.editor.spi.PreferencesCustomizer;
80
import org.netbeans.modules.options.editor.spi.PreviewProvider;
81
import org.openide.text.CloneableEditorSupport;
82
import org.openide.util.HelpCtx;
83
import org.openide.util.NbBundle;
84
85
// Support section ---------------------------------------------------------
86
87
public class CategorySupport implements ActionListener, ChangeListener, ListDataListener, TableModelListener, DocumentListener, PreviewProvider, PreferencesCustomizer {
88
    public static final String OPTION_ID = "org.netbeans.modules.java.ui.FormatingOptions.ID";
89
    private static final int LOAD = 0;
90
    private static final int STORE = 1;
91
    private static final int ADD_LISTENERS = 2;
92
    private static final ComboItem[] bracePlacement = new ComboItem[]{new ComboItem(BracePlacement.SAME_LINE.name(), "LBL_bp_SAME_LINE"), new ComboItem(BracePlacement.NEW_LINE.name(), "LBL_bp_NEW_LINE"), new ComboItem(BracePlacement.NEW_LINE_HALF_INDENTED.name(), "LBL_bp_NEW_LINE_HALF_INDENTED"), new ComboItem(BracePlacement.NEW_LINE_INDENTED.name(), "LBL_bp_NEW_LINE_INDENTED")};
93
    private static final ComboItem[] bracesGeneration = new ComboItem[]{new ComboItem(BracesGenerationStyle.GENERATE.name(), "LBL_bg_GENERATE"), new ComboItem(BracesGenerationStyle.LEAVE_ALONE.name(), "LBL_bg_LEAVE_ALONE"), new ComboItem(BracesGenerationStyle.ELIMINATE.name(), "LBL_bg_ELIMINATE")};
94
    private static final ComboItem[] wrap = new ComboItem[]{new ComboItem(WrapStyle.WRAP_ALWAYS.name(), "LBL_wrp_WRAP_ALWAYS"), new ComboItem(WrapStyle.WRAP_IF_LONG.name(), "LBL_wrp_WRAP_IF_LONG"), new ComboItem(WrapStyle.WRAP_NEVER.name(), "LBL_wrp_WRAP_NEVER")};
95
    private static final ComboItem[] insertionPoint = new ComboItem[]{new ComboItem(InsertionPoint.LAST_IN_CATEGORY.name(), "LBL_ip_LAST_IN_CATEGORY"), new ComboItem(InsertionPoint.FIRST_IN_CATEGORY.name(), "LBL_ip_FIRST_IN_CATEGORY"), new ComboItem(InsertionPoint.CARET_LOCATION.name(), "LBL_ip_CARET_LOCATION")};
96
    protected final String previewText;
97
    //        private String forcedOptions[][];
98
    //        private boolean changed = false;
99
    //        private boolean loaded = false;
100
    private final String id;
101
    protected final JPanel panel;
102
    private final List<JComponent> components = new LinkedList<JComponent>();
103
    private JEditorPane previewPane;
104
    protected final Preferences preferences;
105
    protected final Preferences previewPrefs;
106
107
    protected CategorySupport(Preferences preferences, String id, JPanel panel, String previewText, String[]... forcedOptions) {
108
        this.preferences = preferences;
109
        this.id = id;
110
        this.panel = panel;
111
        this.previewText = previewText != null ? previewText : NbBundle.getMessage(CategorySupport.class, "SAMPLE_Default"); //NOI18N
112
        // Scan the panel for its components
113
        scan(panel, components);
114
        // Initialize the preview preferences
115
        Preferences forcedPrefs = new PreviewPreferences();
116
        for (String[] option : forcedOptions) {
117
            forcedPrefs.put(option[0], option[1]);
118
        }
119
        this.previewPrefs = new ProxyPreferences(forcedPrefs, preferences);
120
        // Load and hook up all the components
121
        loadFrom(preferences);
122
        addListeners();
123
    }
124
125
    protected void addListeners() {
126
        scan(ADD_LISTENERS, null);
127
    }
128
129
    protected void loadFrom(Preferences preferences) {
130
        //            loaded = true;
131
        scan(LOAD, preferences);
132
        //            loaded = false;
133
    }
134
135
    //
136
    //        public void applyChanges() {
137
    //            storeTo(preferences);
138
    //        }
139
    //
140
    protected void storeTo(Preferences p) {
141
        scan(STORE, p);
142
    }
143
144
    protected void notifyChanged() {
145
        //            if (loaded)
146
        //                return;
147
        storeTo(preferences);
148
        refreshPreview();
149
    }
150
151
    protected void loadListData(final JList list, final String optionID, final Preferences p) {
152
    }
153
154
    protected void storeListData(final JList list, final String optionID, final Preferences node) {
155
    }
156
157
    protected void loadTableData(final JTable table, final String optionID, final Preferences p) {
158
    }
159
160
    protected void storeTableData(final JTable table, final String optionID, final Preferences node) {
161
    }
162
163
    // ActionListener implementation ---------------------------------------
164
    public void actionPerformed(ActionEvent e) {
165
        notifyChanged();
166
    }
167
168
    // ChangeListener implementation ---------------------------------------
169
    @Override
170
    public void stateChanged(ChangeEvent e) {
171
        notifyChanged();
172
    }
173
174
    // ListDataListener implementation -----------------------------------
175
    @Override
176
    public void contentsChanged(ListDataEvent e) {
177
    }
178
179
    @Override
180
    public void intervalAdded(ListDataEvent e) {
181
        notifyChanged();
182
    }
183
184
    @Override
185
    public void intervalRemoved(ListDataEvent e) {
186
    }
187
188
    // TableModelListener implementation -----------------------------------
189
    @Override
190
    public void tableChanged(TableModelEvent e) {
191
        notifyChanged();
192
    }
193
194
    // DocumentListener implementation -------------------------------------
195
    public void insertUpdate(DocumentEvent e) {
196
        notifyChanged();
197
    }
198
199
    public void removeUpdate(DocumentEvent e) {
200
        notifyChanged();
201
    }
202
203
    public void changedUpdate(DocumentEvent e) {
204
        notifyChanged();
205
    }
206
207
    // PreviewProvider methods -----------------------------------------------------
208
    public JComponent getPreviewComponent() {
209
        if (previewPane == null) {
210
            previewPane = new JEditorPane();
211
            previewPane.getAccessibleContext().setAccessibleName(NbBundle.getMessage(CategorySupport.class, "AN_Preview")); //NOI18N
212
            previewPane.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CategorySupport.class, "AD_Preview")); //NOI18N
213
            previewPane.putClientProperty("HighlightsLayerIncludes", "^org\\.netbeans\\.modules\\.editor\\.lib2\\.highlighting\\.SyntaxHighlighting$"); //NOI18N
214
            previewPane.setEditorKit(CloneableEditorSupport.getEditorKit("text/x-java"));
215
            previewPane.setEditable(false);
216
        }
217
        return previewPane;
218
    }
219
220
    public void refreshPreview() {
221
        JEditorPane jep = (JEditorPane) getPreviewComponent();
222
        try {
223
            int rm = previewPrefs.getInt(FmtConstants.rightMargin, FmtConstants.getDefaultAsInt(FmtConstants.rightMargin));
224
            jep.putClientProperty("TextLimitLine", rm); //NOI18N
225
            jep.getDocument().putProperty(SimpleValueNames.TEXT_LINE_WRAP, ""); //NOI18N
226
            jep.getDocument().putProperty(SimpleValueNames.TAB_SIZE, ""); //NOI18N
227
            jep.getDocument().putProperty(SimpleValueNames.TEXT_LIMIT_WIDTH, ""); //NOI18N
228
        } catch (NumberFormatException e) {
229
            // Ignore it
230
        }
231
        try {
232
            Class.forName(CodeStyle.class.getName(), true, CodeStyle.class.getClassLoader());
233
        } catch (ClassNotFoundException cnfe) {
234
            // ignore
235
        }
236
        
237
        /** XXX: Another reference to Reformatter:
238
        CodeStyle codeStyle = FmtConstants.codeStyleProducer.create(previewPrefs);
239
        jep.setIgnoreRepaint(true);
240
        jep.setText(Reformatter.reformat(previewText, codeStyle));
241
        */
242
        jep.setIgnoreRepaint(false);
243
        jep.scrollRectToVisible(new Rectangle(0, 0, 10, 10));
244
        jep.repaint(100);
245
    }
246
247
    // PreferencesCustomizer implementation --------------------------------
248
    public JComponent getComponent() {
249
        return panel;
250
    }
251
252
    public String getDisplayName() {
253
        return panel.getName();
254
    }
255
256
    public String getId() {
257
        return id;
258
    }
259
260
    public HelpCtx getHelpCtx() {
261
        return null;
262
    }
263
264
    // PreferencesCustomizer.Factory implementation ------------------------
265
    public static final class Factory implements PreferencesCustomizer.Factory {
266
267
        private final String id;
268
        private final Class<? extends JPanel> panelClass;
269
        private final String previewText;
270
        private final String[][] forcedOptions;
271
272
        public Factory(String id, Class<? extends JPanel> panelClass, String previewText, String[]... forcedOptions) {
273
            this.id = id;
274
            this.panelClass = panelClass;
275
            this.previewText = previewText;
276
            this.forcedOptions = forcedOptions;
277
        }
278
279
        public PreferencesCustomizer create(Preferences preferences) {
280
            try {
281
                CategorySupport categorySupport = new CategorySupport(preferences, id, panelClass.newInstance(), previewText, forcedOptions);
282
                if (categorySupport.panel instanceof Runnable) {
283
                    ((Runnable) categorySupport.panel).run();
284
                }
285
                return categorySupport;
286
            } catch (Exception e) {
287
                return null;
288
            }
289
        }
290
    } // End of CategorySupport.Factory class
291
292
    // Private methods -----------------------------------------------------
293
    private void performOperation(int operation, JComponent jc, String optionID, Preferences p) {
294
        switch (operation) {
295
            case LOAD:
296
                loadData(jc, optionID, p);
297
                break;
298
            case STORE:
299
                storeData(jc, optionID, p);
300
                break;
301
            case ADD_LISTENERS:
302
                addListener(jc);
303
                break;
304
        }
305
    }
306
307
    private void scan(int what, Preferences p) {
308
        for (JComponent jc : components) {
309
            Object o = jc.getClientProperty(OPTION_ID);
310
            if (o instanceof String) {
311
                performOperation(what, jc, (String) o, p);
312
            } else if (o instanceof String[]) {
313
                for (String oid : (String[]) o) {
314
                    performOperation(what, jc, oid, p);
315
                }
316
            }
317
        }
318
    }
319
320
    private void scan(Container container, List<JComponent> components) {
321
        for (Component c : container.getComponents()) {
322
            if (c instanceof JComponent) {
323
                JComponent jc = (JComponent) c;
324
                Object o = jc.getClientProperty(OPTION_ID);
325
                if (o instanceof String || o instanceof String[]) {
326
                    components.add(jc);
327
                }
328
            }
329
            if (c instanceof Container) {
330
                scan((Container) c, components);
331
            }
332
        }
333
    }
334
335
    /** Very smart method which tries to set the values in the components correctly
336
     */
337
    private void loadData(JComponent jc, String optionID, Preferences node) {
338
        if (jc instanceof JTextField) {
339
            JTextField field = (JTextField) jc;
340
            field.setText(node.get(optionID, FmtConstants.getDefaultAsString(optionID)));
341
        } else if (jc instanceof JSpinner) {
342
            JSpinner js = (JSpinner) jc;
343
            js.setValue(node.getInt(optionID, FmtConstants.getDefaultAsInt(optionID)));
344
        } else if (jc instanceof JToggleButton) {
345
            JToggleButton toggle = (JToggleButton) jc;
346
            boolean df = FmtConstants.getDefaultAsBoolean(optionID);
347
            toggle.setSelected(node.getBoolean(optionID, df));
348
        } else if (jc instanceof JComboBox) {
349
            JComboBox cb = (JComboBox) jc;
350
            String value = node.get(optionID, FmtConstants.getDefaultAsString(optionID));
351
            ComboBoxModel model = createModel(value);
352
            cb.setModel(model);
353
            ComboItem item = whichItem(value, model);
354
            cb.setSelectedItem(item);
355
        } else if (jc instanceof JList) {
356
            loadListData((JList) jc, optionID, node);
357
        } else if (jc instanceof JTable) {
358
            loadTableData((JTable) jc, optionID, node);
359
        }
360
    }
361
362
    private void storeData(JComponent jc, String optionID, Preferences node) {
363
        if (jc instanceof JTextField) {
364
            JTextField field = (JTextField) jc;
365
            String text = field.getText();
366
            // XXX test for numbers
367
            String val = FmtConstants.getDefaultAsString(optionID);
368
            try {
369
                Integer.parseInt(val);
370
                try {
371
                    int i = Integer.parseInt(text);
372
                } catch (NumberFormatException e) {
373
                    return;
374
                }
375
            } catch (NumberFormatException ex) {
376
                // OK, default is not number
377
            }
378
            // XXX: watch out, tabSize, spacesPerTab, indentSize and expandTabToSpaces
379
            // fall back on getGlopalXXX() values and not getDefaultAsXXX value,
380
            // which is why we must not remove them. Proper solution would be to
381
            // store formatting preferences to MimeLookup and not use NbPreferences.
382
            // The problem currently is that MimeLookup based Preferences do not support subnodes.
383
            if (!optionID.equals(FmtConstants.tabSize) && !optionID.equals(FmtConstants.spacesPerTab) && !optionID.equals(FmtConstants.indentSize) && FmtConstants.getDefaultAsString(optionID).equals(text)) {
384
                node.remove(optionID);
385
            } else {
386
                node.put(optionID, text);
387
            }
388
        } else if (jc instanceof JSpinner) {
389
            JSpinner js = (JSpinner) jc;
390
            Object value = js.getValue();
391
            if (FmtConstants.getDefaultAsInt(optionID) == ((Integer) value).intValue()) {
392
                node.remove(optionID);
393
            } else {
394
                node.putInt(optionID, ((Integer) value).intValue());
395
            }
396
        } else if (jc instanceof JToggleButton) {
397
            JToggleButton toggle = (JToggleButton) jc;
398
            if (!optionID.equals(FmtConstants.expandTabToSpaces) && FmtConstants.getDefaultAsBoolean(optionID) == toggle.isSelected()) {
399
                node.remove(optionID);
400
            } else {
401
                node.putBoolean(optionID, toggle.isSelected());
402
            }
403
        } else if (jc instanceof JComboBox) {
404
            JComboBox cb = (JComboBox) jc;
405
            // Logger.global.info( cb.getSelectedItem() + " " + optionID);
406
            String value = ((ComboItem) cb.getSelectedItem()).value;
407
            if (FmtConstants.getDefaultAsString(optionID).equals(value)) {
408
                node.remove(optionID);
409
            } else {
410
                node.put(optionID, value);
411
            }
412
        } else if (jc instanceof JList) {
413
            storeListData((JList) jc, optionID, node);
414
        } else if (jc instanceof JTable) {
415
            storeTableData((JTable) jc, optionID, node);
416
        }
417
    }
418
419
    private void addListener(JComponent jc) {
420
        if (jc instanceof JTextField) {
421
            JTextField field = (JTextField) jc;
422
            field.addActionListener(this);
423
            field.getDocument().addDocumentListener(this);
424
        } else if (jc instanceof JSpinner) {
425
            JSpinner spinner = (JSpinner) jc;
426
            spinner.addChangeListener(this);
427
        } else if (jc instanceof JToggleButton) {
428
            JToggleButton toggle = (JToggleButton) jc;
429
            toggle.addActionListener(this);
430
        } else if (jc instanceof JComboBox) {
431
            JComboBox cb = (JComboBox) jc;
432
            cb.addActionListener(this);
433
        } else if (jc instanceof JList) {
434
            JList jl = (JList) jc;
435
            jl.getModel().addListDataListener(this);
436
        } else if (jc instanceof JTable) {
437
            JTable jt = (JTable) jc;
438
            jt.getModel().addTableModelListener(this);
439
        }
440
    }
441
442
    private ComboBoxModel createModel(String value) {
443
        // is it braces placement?
444
        for (ComboItem comboItem : bracePlacement) {
445
            if (value.equals(comboItem.value)) {
446
                return new DefaultComboBoxModel(bracePlacement);
447
            }
448
        }
449
        // is it braces generation?
450
        for (ComboItem comboItem : bracesGeneration) {
451
            if (value.equals(comboItem.value)) {
452
                return new DefaultComboBoxModel(bracesGeneration);
453
            }
454
        }
455
        // is it wrap?
456
        for (ComboItem comboItem : wrap) {
457
            if (value.equals(comboItem.value)) {
458
                return new DefaultComboBoxModel(wrap);
459
            }
460
        }
461
        // is it insertion point?
462
        for (ComboItem comboItem : insertionPoint) {
463
            if (value.equals(comboItem.value)) {
464
                return new DefaultComboBoxModel(insertionPoint);
465
            }
466
        }
467
        return null;
468
    }
469
470
    private static ComboItem whichItem(String value, ComboBoxModel model) {
471
        for (int i = 0; i < model.getSize(); i++) {
472
            ComboItem item = (ComboItem) model.getElementAt(i);
473
            if (value.equals(item.value)) {
474
                return item;
475
            }
476
        }
477
        return null;
478
    }
479
480
    private static class ComboItem {
481
482
        String value;
483
        String displayName;
484
485
        public ComboItem(String value, String key) {
486
            this.value = value;
487
            this.displayName = NbBundle.getMessage(FmtConstants.class, key);
488
        }
489
490
        @Override
491
        public String toString() {
492
            return displayName;
493
        }
494
    }
495
    
496
}
(-)a/java.source/src/org/netbeans/modules/java/ui/FmtAlignment.form (-1 / +1 lines)
Lines 1-4 Link Here
1
<?xml version="1.1" encoding="UTF-8" ?>
1
<?xml version="1.0" 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>
(-)a/java.source/src/org/netbeans/modules/java/ui/FmtAlignment.java (-13 / +12 lines)
Lines 45-53 Link Here
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;
47
import org.netbeans.api.java.source.CodeStyle.WrapStyle;
48
import static org.netbeans.modules.java.ui.FmtOptions.*;
48
import static org.netbeans.modules.java.preprocessorbridge.api.FmtConstants.*;
49
import static org.netbeans.modules.java.ui.FmtOptions.CategorySupport.OPTION_ID;
49
import static org.netbeans.modules.java.ui.CategorySupport.OPTION_ID;
50
import org.netbeans.modules.java.ui.FmtOptions.CategorySupport;
51
import org.netbeans.modules.options.editor.spi.PreferencesCustomizer;
50
import org.netbeans.modules.options.editor.spi.PreferencesCustomizer;
52
51
53
52
Lines 83-98 Link Here
83
    public static PreferencesCustomizer.Factory getController() {
82
    public static PreferencesCustomizer.Factory getController() {
84
        return new CategorySupport.Factory("alignment", FmtAlignment.class, //NOI18N
83
        return new CategorySupport.Factory("alignment", FmtAlignment.class, //NOI18N
85
                org.openide.util.NbBundle.getMessage(FmtAlignment.class, "SAMPLE_Align"), // NOI18N
84
                org.openide.util.NbBundle.getMessage(FmtAlignment.class, "SAMPLE_Align"), // NOI18N
86
                new String[] { FmtOptions.wrapArrayInit, WrapStyle.WRAP_ALWAYS.name() },
85
                new String[] { wrapArrayInit, WrapStyle.WRAP_ALWAYS.name() },
87
                new String[] { FmtOptions.wrapEnumConstants, WrapStyle.WRAP_ALWAYS.name() },
86
                new String[] { wrapEnumConstants, WrapStyle.WRAP_ALWAYS.name() },
88
                new String[] { FmtOptions.wrapExtendsImplementsList, WrapStyle.WRAP_ALWAYS.name() },
87
                new String[] { wrapExtendsImplementsList, WrapStyle.WRAP_ALWAYS.name() },
89
                new String[] { FmtOptions.wrapFor, WrapStyle.WRAP_ALWAYS.name() },
88
                new String[] { wrapFor, WrapStyle.WRAP_ALWAYS.name() },
90
                new String[] { FmtOptions.wrapMethodCallArgs, WrapStyle.WRAP_ALWAYS.name() },
89
                new String[] { wrapMethodCallArgs, WrapStyle.WRAP_ALWAYS.name() },
91
                new String[] { FmtOptions.wrapAnnotationArgs, WrapStyle.WRAP_ALWAYS.name() },
90
                new String[] { wrapAnnotationArgs, WrapStyle.WRAP_ALWAYS.name() },
92
                new String[] { FmtOptions.wrapMethodParams, WrapStyle.WRAP_ALWAYS.name() },
91
                new String[] { wrapMethodParams, WrapStyle.WRAP_ALWAYS.name() },
93
                new String[] { FmtOptions.wrapTernaryOps, WrapStyle.WRAP_ALWAYS.name() },
92
                new String[] { wrapTernaryOps, WrapStyle.WRAP_ALWAYS.name() },
94
                new String[] { FmtOptions.wrapThrowsList, WrapStyle.WRAP_ALWAYS.name() },
93
                new String[] { wrapThrowsList, WrapStyle.WRAP_ALWAYS.name() },
95
                new String[] { FmtOptions.blankLinesBeforeClass, "0" });
94
                new String[] { blankLinesBeforeClass, "0" });
96
    }
95
    }
97
    
96
    
98
    /** This method is called from within the constructor to
97
    /** This method is called from within the constructor to
(-)a/java.source/src/org/netbeans/modules/java/ui/FmtBlankLines.java (-3 / +2 lines)
Lines 44-52 Link Here
44
44
45
package org.netbeans.modules.java.ui;
45
package org.netbeans.modules.java.ui;
46
46
47
import static org.netbeans.modules.java.ui.FmtOptions.*;
47
import static org.netbeans.modules.java.preprocessorbridge.api.FmtConstants.*;
48
import static org.netbeans.modules.java.ui.FmtOptions.CategorySupport.OPTION_ID;
48
import static org.netbeans.modules.java.ui.CategorySupport.OPTION_ID;
49
import org.netbeans.modules.java.ui.FmtOptions.CategorySupport;
50
import org.netbeans.modules.options.editor.spi.PreferencesCustomizer;
49
import org.netbeans.modules.options.editor.spi.PreferencesCustomizer;
51
50
52
/**
51
/**
(-)a/java.source/src/org/netbeans/modules/java/ui/FmtBraces.form (-36 / +24 lines)
Lines 10-15 Link Here
10
  <AuxValues>
10
  <AuxValues>
11
    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
11
    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
12
    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
12
    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
13
    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
13
    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
14
    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
14
    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
15
    <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_layoutCodeTarget" type="java.lang.Integer" value="1"/>
Lines 24-39 Link Here
24
          <Group type="102" attributes="0">
25
          <Group type="102" attributes="0">
25
              <Group type="103" groupAlignment="0" attributes="0">
26
              <Group type="103" groupAlignment="0" attributes="0">
26
                  <Group type="102" alignment="0" attributes="0">
27
                  <Group type="102" alignment="0" attributes="0">
28
                      <Component id="bracesPlacementLabel" min="-2" max="-2" attributes="0"/>
29
                      <EmptySpace max="-2" attributes="0"/>
30
                      <Component id="jSeparator1" pref="103" max="32767" attributes="0"/>
31
                  </Group>
32
                  <Group type="102" alignment="0" attributes="0">
33
                      <Component id="bracesGenerationLabel" min="-2" max="-2" attributes="0"/>
34
                      <EmptySpace max="-2" attributes="0"/>
35
                      <Component id="jSeparator2" pref="98" max="32767" attributes="0"/>
36
                  </Group>
37
                  <Group type="102" attributes="0">
27
                      <EmptySpace max="-2" attributes="0"/>
38
                      <EmptySpace max="-2" attributes="0"/>
28
                      <Group type="103" groupAlignment="0" attributes="0">
39
                      <Group type="103" groupAlignment="0" attributes="0">
29
                          <Component id="doWhileBracesLabel" alignment="0" min="-2" max="-2" attributes="0"/>
40
                          <Group type="102" alignment="0" attributes="0">
30
                          <Component id="otherLabel" alignment="0" min="-2" max="-2" attributes="0"/>
41
                              <Group type="103" groupAlignment="0" attributes="0">
31
                          <Component id="methodDeclLabel" alignment="0" min="-2" max="-2" attributes="0"/>
42
                                  <Component id="doWhileBracesLabel" alignment="0" min="-2" max="-2" attributes="0"/>
32
                          <Component id="whileBracesLabel" alignment="0" min="-2" max="-2" attributes="0"/>
43
                                  <Component id="otherLabel" alignment="0" min="-2" max="-2" attributes="0"/>
33
                      </Group>
44
                                  <Component id="methodDeclLabel" alignment="0" min="-2" max="-2" attributes="0"/>
34
                      <EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
45
                                  <Component id="whileBracesLabel" alignment="0" min="-2" max="-2" attributes="0"/>
35
                      <Group type="103" groupAlignment="1" attributes="0">
46
                              </Group>
36
                          <Group type="102" attributes="0">
47
                              <EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
37
                              <Group type="103" groupAlignment="1" attributes="0">
48
                              <Group type="103" groupAlignment="1" attributes="0">
38
                                  <Group type="103" groupAlignment="0" attributes="0">
49
                                  <Group type="103" groupAlignment="0" attributes="0">
39
                                      <Component id="otherCombo" linkSize="1" alignment="0" min="-2" max="-2" attributes="1"/>
50
                                      <Component id="otherCombo" linkSize="1" alignment="0" min="-2" max="-2" attributes="1"/>
Lines 43-80 Link Here
43
                                      <Component id="whileBracesCombo" linkSize="1" alignment="1" min="-2" max="-2" attributes="0"/>
54
                                      <Component id="whileBracesCombo" linkSize="1" alignment="1" min="-2" max="-2" attributes="0"/>
44
                                  </Group>
55
                                  </Group>
45
                                  <Component id="doWhileBracesCombo" linkSize="1" min="-2" max="-2" attributes="0"/>
56
                                  <Component id="doWhileBracesCombo" linkSize="1" min="-2" max="-2" attributes="0"/>
57
                                  <Component id="methodDeclCombo" linkSize="1" alignment="1" min="-2" max="-2" attributes="1"/>
46
                              </Group>
58
                              </Group>
47
                              <EmptySpace max="-2" attributes="0"/>
48
                          </Group>
59
                          </Group>
49
                          <Component id="methodDeclCombo" linkSize="1" alignment="1" min="-2" max="-2" attributes="1"/>
60
                          <Component id="classDeclLabel" alignment="0" min="-2" max="-2" attributes="0"/>
61
                          <Component id="specialElseIfCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
62
                          <Component id="ifBracesLabel" alignment="0" min="-2" max="-2" attributes="0"/>
63
                          <Component id="forBracesLabel" alignment="0" min="-2" max="-2" attributes="0"/>
50
                      </Group>
64
                      </Group>
51
                  </Group>
65
                  </Group>
52
                  <Group type="102" alignment="0" attributes="0">
53
                      <Component id="bracesPlacementLabel" min="-2" max="-2" attributes="0"/>
54
                      <EmptySpace max="-2" attributes="0"/>
55
                      <Component id="jSeparator1" pref="103" max="32767" attributes="0"/>
56
                  </Group>
57
                  <Group type="102" alignment="0" attributes="0">
58
                      <EmptySpace max="-2" attributes="0"/>
59
                      <Component id="classDeclLabel" min="-2" max="-2" attributes="0"/>
60
                  </Group>
61
                  <Group type="102" alignment="0" attributes="0">
62
                      <EmptySpace max="-2" attributes="0"/>
63
                      <Component id="specialElseIfCheckBox" min="-2" max="-2" attributes="0"/>
64
                  </Group>
65
                  <Group type="102" alignment="0" attributes="0">
66
                      <EmptySpace max="-2" attributes="0"/>
67
                      <Component id="ifBracesLabel" min="-2" max="-2" attributes="0"/>
68
                  </Group>
69
                  <Group type="102" alignment="0" attributes="0">
70
                      <EmptySpace max="-2" attributes="0"/>
71
                      <Component id="forBracesLabel" min="-2" max="-2" attributes="0"/>
72
                  </Group>
73
                  <Group type="102" alignment="0" attributes="0">
74
                      <Component id="bracesGenerationLabel" min="-2" max="-2" attributes="0"/>
75
                      <EmptySpace max="-2" attributes="0"/>
76
                      <Component id="jSeparator2" pref="98" max="32767" attributes="0"/>
77
                  </Group>
78
              </Group>
66
              </Group>
79
              <EmptySpace max="-2" attributes="0"/>
67
              <EmptySpace max="-2" attributes="0"/>
80
          </Group>
68
          </Group>
(-)a/java.source/src/org/netbeans/modules/java/ui/FmtBraces.java (-9 / +7 lines)
Lines 44-53 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;
47
import static org.netbeans.modules.java.ui.CategorySupport.OPTION_ID;
48
import static org.netbeans.modules.java.ui.FmtOptions.*;
48
import static org.netbeans.modules.java.preprocessorbridge.api.FmtConstants.*;
49
import static org.netbeans.modules.java.ui.FmtOptions.CategorySupport.OPTION_ID;
50
import org.netbeans.modules.java.ui.FmtOptions.CategorySupport;
51
import org.netbeans.modules.options.editor.spi.PreferencesCustomizer;
49
import org.netbeans.modules.options.editor.spi.PreferencesCustomizer;
52
50
53
51
Lines 73-79 Link Here
73
    public static PreferencesCustomizer.Factory getController() {
71
    public static PreferencesCustomizer.Factory getController() {
74
        return new CategorySupport.Factory("braces", FmtBraces.class, //NOI18N
72
        return new CategorySupport.Factory("braces", FmtBraces.class, //NOI18N
75
                org.openide.util.NbBundle.getMessage(FmtBraces.class, "SAMPLE_Braces"), // NOI18N
73
                org.openide.util.NbBundle.getMessage(FmtBraces.class, "SAMPLE_Braces"), // NOI18N
76
                new String[] { FmtOptions.blankLinesBeforeClass, "0" });
74
                new String[] { blankLinesBeforeClass, "0" });
77
    }
75
    }
78
    
76
    
79
    /** This method is called from within the constructor to
77
    /** This method is called from within the constructor to
Lines 176-184 Link Here
176
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
174
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
177
                                        .addComponent(otherCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
175
                                        .addComponent(otherCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
178
                                        .addComponent(classDeclCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
176
                                        .addComponent(classDeclCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
179
                                        .addComponent( ifBracesCombo, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
177
                                        .addComponent(ifBracesCombo, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
180
                                        .addComponent( forBracesCombo, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
178
                                        .addComponent(forBracesCombo, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
181
                                        .addComponent( whileBracesCombo, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
179
                                        .addComponent(whileBracesCombo, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
182
                                    .addComponent(doWhileBracesCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
180
                                    .addComponent(doWhileBracesCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
183
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
181
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
184
                            .addComponent(methodDeclCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
182
                            .addComponent(methodDeclCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
Lines 205-211 Link Here
205
                .addContainerGap())
203
                .addContainerGap())
206
        );
204
        );
207
205
208
        layout.linkSize( javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[]{classDeclCombo, doWhileBracesCombo, forBracesCombo, ifBracesCombo, methodDeclCombo, otherCombo, whileBracesCombo});
206
        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {classDeclCombo, doWhileBracesCombo, forBracesCombo, ifBracesCombo, methodDeclCombo, otherCombo, whileBracesCombo});
209
207
210
        layout.setVerticalGroup(
208
        layout.setVerticalGroup(
211
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
209
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
(-)a/java.source/src/org/netbeans/modules/java/ui/FmtCodeGeneration.java (-6 / +7 lines)
Lines 73-80 Link Here
73
import com.sun.source.tree.Tree;
73
import com.sun.source.tree.Tree;
74
import com.sun.source.tree.TypeParameterTree;
74
import com.sun.source.tree.TypeParameterTree;
75
import com.sun.source.tree.VariableTree;
75
import com.sun.source.tree.VariableTree;
76
import org.netbeans.api.java.source.CodeStyle;
76
77
77
import org.netbeans.api.java.source.CodeStyle;
78
import org.netbeans.api.java.source.GeneratorUtilities;
78
import org.netbeans.api.java.source.GeneratorUtilities;
79
import org.netbeans.api.java.source.JavaSource.Phase;
79
import org.netbeans.api.java.source.JavaSource.Phase;
80
import org.netbeans.api.java.source.ModificationResult;
80
import org.netbeans.api.java.source.ModificationResult;
Lines 82-90 Link Here
82
import org.netbeans.api.java.source.WorkingCopy;
82
import org.netbeans.api.java.source.WorkingCopy;
83
import org.netbeans.editor.BaseDocument;
83
import org.netbeans.editor.BaseDocument;
84
import org.netbeans.modules.editor.indent.api.Reformat;
84
import org.netbeans.modules.editor.indent.api.Reformat;
85
import static org.netbeans.modules.java.ui.FmtOptions.*;
85
import static org.netbeans.modules.java.ui.CategorySupport.OPTION_ID;
86
import org.netbeans.modules.java.ui.FmtOptions.CategorySupport;
86
import static org.netbeans.modules.java.preprocessorbridge.api.FmtConstants.*;
87
import static org.netbeans.modules.java.ui.FmtOptions.CategorySupport.OPTION_ID;
88
import org.netbeans.modules.options.editor.spi.PreferencesCustomizer;
87
import org.netbeans.modules.options.editor.spi.PreferencesCustomizer;
89
import org.netbeans.modules.parsing.api.ResultIterator;
88
import org.netbeans.modules.parsing.api.ResultIterator;
90
import org.netbeans.modules.parsing.api.Source;
89
import org.netbeans.modules.parsing.api.Source;
Lines 649-655 Link Here
649
648
650
        private CodeGenCategorySupport(Preferences preferences, JPanel panel) {
649
        private CodeGenCategorySupport(Preferences preferences, JPanel panel) {
651
            super(preferences, "code-generation", panel, NbBundle.getMessage(FmtCodeGeneration.class, "SAMPLE_CodeGen"), //NOI18N
650
            super(preferences, "code-generation", panel, NbBundle.getMessage(FmtCodeGeneration.class, "SAMPLE_CodeGen"), //NOI18N
652
                    new String[] { FmtOptions.blankLinesBeforeFields, "1" }); //NOI18N
651
                    new String[] { blankLinesBeforeFields, "1" }); //NOI18N
653
        }
652
        }
654
    
653
    
655
        @Override
654
        @Override
Lines 709-715 Link Here
709
                // ignore
708
                // ignore
710
            }
709
            }
711
710
712
            final CodeStyle codeStyle = codeStyleProducer.create(previewPrefs);
711
            // XXX: CodeStyleProducer is not visible
712
            Object codeStyle = null;
713
            //final CodeStyle codeStyle = codeStyleProducer.create(previewPrefs);
713
            jep.setIgnoreRepaint(true);
714
            jep.setIgnoreRepaint(true);
714
            try {
715
            try {
715
                if (source == null) {
716
                if (source == null) {
(-)a/java.source/src/org/netbeans/modules/java/ui/FmtComments.java (-4 / +4 lines)
Lines 42-49 Link Here
42
42
43
package org.netbeans.modules.java.ui;
43
package org.netbeans.modules.java.ui;
44
44
45
import static org.netbeans.modules.java.ui.FmtOptions.*;
45
import static org.netbeans.modules.java.ui.CategorySupport.OPTION_ID;
46
import static org.netbeans.modules.java.ui.FmtOptions.CategorySupport.OPTION_ID;
46
import static org.netbeans.modules.java.preprocessorbridge.api.FmtConstants.*;
47
import org.netbeans.modules.options.editor.spi.PreferencesCustomizer;
47
import org.netbeans.modules.options.editor.spi.PreferencesCustomizer;
48
48
49
/**
49
/**
Lines 73-80 Link Here
73
    public static PreferencesCustomizer.Factory getController() {
73
    public static PreferencesCustomizer.Factory getController() {
74
        return new CategorySupport.Factory("comments", FmtComments.class, //NOI18N
74
        return new CategorySupport.Factory("comments", FmtComments.class, //NOI18N
75
                org.openide.util.NbBundle.getMessage(FmtComments.class, "SAMPLE_Comments"), // NOI18N
75
                org.openide.util.NbBundle.getMessage(FmtComments.class, "SAMPLE_Comments"), // NOI18N
76
                new String[] { FmtOptions.rightMargin, "45" }, //NOI18N
76
                new String[] { rightMargin, "45" }, //NOI18N
77
                new String[] { FmtOptions.blankLinesBeforeClass, "0" }); //NOI18N
77
                new String[] { blankLinesBeforeClass, "0" }); //NOI18N
78
    }    
78
    }    
79
79
80
    @Override
80
    @Override
(-)a/java.source/src/org/netbeans/modules/java/ui/FmtImports.java (-3 / +5 lines)
Lines 81-88 Link Here
81
import org.openide.filesystems.FileObject;
81
import org.openide.filesystems.FileObject;
82
import org.openide.loaders.DataObject;
82
import org.openide.loaders.DataObject;
83
import org.openide.util.NbBundle;
83
import org.openide.util.NbBundle;
84
import static org.netbeans.modules.java.ui.FmtOptions.*;
84
import static org.netbeans.modules.java.ui.CategorySupport.OPTION_ID;
85
import static org.netbeans.modules.java.ui.FmtOptions.CategorySupport.OPTION_ID;
85
import static org.netbeans.modules.java.preprocessorbridge.api.FmtConstants.*;
86
import org.netbeans.modules.options.editor.spi.PreferencesCustomizer;
86
import org.netbeans.modules.options.editor.spi.PreferencesCustomizer;
87
import org.netbeans.modules.parsing.api.Source;
87
import org.netbeans.modules.parsing.api.Source;
88
import org.netbeans.modules.parsing.api.UserTask;
88
import org.netbeans.modules.parsing.api.UserTask;
Lines 659-665 Link Here
659
                // ignore
659
                // ignore
660
            }
660
            }
661
661
662
            final CodeStyle codeStyle = codeStyleProducer.create(previewPrefs);
662
            // XXX: CodeStyleProducer is not visible
663
            Object codeStyle = null;
664
            //final CodeStyle codeStyle = codeStyleProducer.create(previewPrefs);
663
            jep.setIgnoreRepaint(true);
665
            jep.setIgnoreRepaint(true);
664
            try {
666
            try {
665
                if (source == null) {
667
                if (source == null) {
(-)a/java.source/src/org/netbeans/modules/java/ui/FmtSpaces.java (-9 / +9 lines)
Lines 63-71 Link Here
63
import javax.swing.tree.DefaultTreeModel;
63
import javax.swing.tree.DefaultTreeModel;
64
import javax.swing.tree.TreeCellRenderer;
64
import javax.swing.tree.TreeCellRenderer;
65
import javax.swing.tree.TreePath;
65
import javax.swing.tree.TreePath;
66
import static org.netbeans.modules.java.preprocessorbridge.api.FmtConstants.*;
66
import org.netbeans.modules.options.editor.spi.PreferencesCustomizer;
67
import org.netbeans.modules.options.editor.spi.PreferencesCustomizer;
67
import org.openide.util.NbBundle;
68
import org.openide.util.NbBundle;
68
import static org.netbeans.modules.java.ui.FmtOptions.*;
69
69
70
/**
70
/**
71
 *
71
 *
Lines 357-372 Link Here
357
        
357
        
358
    }
358
    }
359
    
359
    
360
    private static final class SpacesCategorySupport extends FmtOptions.CategorySupport {
360
    private static final class SpacesCategorySupport extends CategorySupport {
361
361
362
        public SpacesCategorySupport(Preferences preferences, FmtSpaces panel) {
362
        public SpacesCategorySupport(Preferences preferences, FmtSpaces panel) {
363
            super(preferences, "spaces", panel, //NOI18N
363
            super(preferences, "spaces", panel, //NOI18N
364
                  NbBundle.getMessage( FmtSpaces.class ,"SAMPLE_Spaces"), // NOI18N
364
                  NbBundle.getMessage( FmtSpaces.class ,"SAMPLE_Spaces"), // NOI18N
365
                  new String[] {FmtOptions.placeCatchOnNewLine, Boolean.FALSE.toString()},
365
                  new String[] {placeCatchOnNewLine, Boolean.FALSE.toString()},
366
                  new String[] {FmtOptions.placeElseOnNewLine, Boolean.FALSE.toString()},
366
                  new String[] {placeElseOnNewLine, Boolean.FALSE.toString()},
367
                  new String[] {FmtOptions.placeWhileOnNewLine, Boolean.FALSE.toString()},
367
                  new String[] {placeWhileOnNewLine, Boolean.FALSE.toString()},
368
                  new String[] {FmtOptions.placeFinallyOnNewLine, Boolean.FALSE.toString()},
368
                  new String[] {placeFinallyOnNewLine, Boolean.FALSE.toString()},
369
                  new String[] { FmtOptions.blankLinesBeforeClass, "0" });
369
                  new String[] {blankLinesBeforeClass, "0" });
370
            panel.scs = this;
370
            panel.scs = this;
371
        }
371
        }
372
372
Lines 378-384 Link Here
378
        @Override
378
        @Override
379
        protected void loadFrom(Preferences preferences) {
379
        protected void loadFrom(Preferences preferences) {
380
            for (Item item : getAllItems()) {
380
            for (Item item : getAllItems()) {
381
                boolean df = FmtOptions.getDefaultAsBoolean(item.id);
381
                boolean df = getDefaultAsBoolean(item.id);
382
                item.value = preferences.getBoolean(item.id, df);
382
                item.value = preferences.getBoolean(item.id, df);
383
            }
383
            }
384
        }
384
        }
Lines 397-403 Link Here
397
        @Override
397
        @Override
398
        protected void storeTo(Preferences preferences) {
398
        protected void storeTo(Preferences preferences) {
399
            for (Item item : getAllItems()) {
399
            for (Item item : getAllItems()) {
400
                boolean df = FmtOptions.getDefaultAsBoolean(item.id);
400
                boolean df = getDefaultAsBoolean(item.id);
401
                if (df == item.value)
401
                if (df == item.value)
402
                    preferences.remove(item.id);
402
                    preferences.remove(item.id);
403
                else
403
                else
(-)a/java.source/src/org/netbeans/modules/java/ui/FmtTabsIndents.form (-1 / +1 lines)
Lines 1-4 Link Here
1
<?xml version="1.1" encoding="UTF-8" ?>
1
<?xml version="1.0" 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>
(-)a/java.source/src/org/netbeans/modules/java/ui/FmtTabsIndents.java (-5 / +4 lines)
Lines 44-52 Link Here
44
44
45
package org.netbeans.modules.java.ui;
45
package org.netbeans.modules.java.ui;
46
46
47
import static org.netbeans.modules.java.ui.FmtOptions.*;
47
import static org.netbeans.modules.java.ui.CategorySupport.OPTION_ID;
48
import static org.netbeans.modules.java.ui.FmtOptions.CategorySupport.OPTION_ID;
48
import static org.netbeans.modules.java.preprocessorbridge.api.FmtConstants.*;
49
import org.netbeans.modules.java.ui.FmtOptions.CategorySupport;
50
import org.netbeans.modules.options.editor.spi.PreferencesCustomizer;
49
import org.netbeans.modules.options.editor.spi.PreferencesCustomizer;
51
50
52
/**
51
/**
Lines 73-79 Link Here
73
    public static PreferencesCustomizer.Factory getController() {
72
    public static PreferencesCustomizer.Factory getController() {
74
        return new CategorySupport.Factory(PreferencesCustomizer.TABS_AND_INDENTS_ID, FmtTabsIndents.class, //NOI18N
73
        return new CategorySupport.Factory(PreferencesCustomizer.TABS_AND_INDENTS_ID, FmtTabsIndents.class, //NOI18N
75
                org.openide.util.NbBundle.getMessage(FmtTabsIndents.class, "SAMPLE_TabsIndents"), // NOI18N
74
                org.openide.util.NbBundle.getMessage(FmtTabsIndents.class, "SAMPLE_TabsIndents"), // NOI18N
76
                new String[] { FmtOptions.blankLinesBeforeClass, "0" }
75
                new String[] { blankLinesBeforeClass, "0" }
77
                );
76
                );
78
    }
77
    }
79
    
78
    
Lines 117-123 Link Here
117
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
116
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
118
            .addGroup(layout.createSequentialGroup()
117
            .addGroup(layout.createSequentialGroup()
119
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
118
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
120
                    .addComponent(continuationIndentSizeLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
119
                    .addComponent(continuationIndentSizeLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 200, Short.MAX_VALUE)
121
                    .addComponent(labelIndentLabel))
120
                    .addComponent(labelIndentLabel))
122
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
121
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
123
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
122
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
(-)a/java.source/src/org/netbeans/modules/java/ui/FmtWrapping.java (-10 / +10 lines)
Lines 47-55 Link Here
47
import java.awt.event.FocusEvent;
47
import java.awt.event.FocusEvent;
48
import java.awt.event.FocusListener;
48
import java.awt.event.FocusListener;
49
import org.netbeans.api.java.source.CodeStyle;
49
import org.netbeans.api.java.source.CodeStyle;
50
import static org.netbeans.modules.java.ui.FmtOptions.*;
50
import static org.netbeans.modules.java.ui.CategorySupport.OPTION_ID;
51
import static org.netbeans.modules.java.ui.FmtOptions.CategorySupport.OPTION_ID;
51
import org.netbeans.modules.java.preprocessorbridge.api.FmtConstants;
52
import org.netbeans.modules.java.ui.FmtOptions.CategorySupport;
52
import static org.netbeans.modules.java.preprocessorbridge.api.FmtConstants.*;
53
import org.netbeans.modules.options.editor.spi.PreferencesCustomizer;
53
import org.netbeans.modules.options.editor.spi.PreferencesCustomizer;
54
54
55
55
Lines 120-132 Link Here
120
    public static PreferencesCustomizer.Factory getController() {
120
    public static PreferencesCustomizer.Factory getController() {
121
        return new CategorySupport.Factory("wrapping", FmtWrapping.class, //NOI18N
121
        return new CategorySupport.Factory("wrapping", FmtWrapping.class, //NOI18N
122
                org.openide.util.NbBundle.getMessage(FmtWrapping.class, "SAMPLE_Wrapping"), //NOI18N
122
                org.openide.util.NbBundle.getMessage(FmtWrapping.class, "SAMPLE_Wrapping"), //NOI18N
123
                new String[] { FmtOptions.rightMargin, "35" }, //NOI18N
123
                new String[] { FmtConstants.rightMargin, "35" }, //NOI18N
124
                new String[] { FmtOptions.redundantDoWhileBraces, CodeStyle.BracesGenerationStyle.LEAVE_ALONE.name() },
124
                new String[] { FmtConstants.redundantDoWhileBraces, CodeStyle.BracesGenerationStyle.LEAVE_ALONE.name() },
125
                new String[] { FmtOptions.redundantForBraces, CodeStyle.BracesGenerationStyle.LEAVE_ALONE.name() },
125
                new String[] { FmtConstants.redundantForBraces, CodeStyle.BracesGenerationStyle.LEAVE_ALONE.name() },
126
                new String[] { FmtOptions.redundantIfBraces, CodeStyle.BracesGenerationStyle.LEAVE_ALONE.name() },
126
                new String[] { FmtConstants.redundantIfBraces, CodeStyle.BracesGenerationStyle.LEAVE_ALONE.name() },
127
                new String[] { FmtOptions.redundantWhileBraces, CodeStyle.BracesGenerationStyle.LEAVE_ALONE.name() },
127
                new String[] { FmtConstants.redundantWhileBraces, CodeStyle.BracesGenerationStyle.LEAVE_ALONE.name() },
128
                new String[] { FmtOptions.blankLinesBeforeClass, "0" },
128
                new String[] { FmtConstants.blankLinesBeforeClass, "0" },
129
                new String[] { FmtOptions.blankLinesAfterMethods, "1" }
129
                new String[] { FmtConstants.blankLinesAfterMethods, "1" }
130
        ); // NOI18N
130
        ); // NOI18N
131
    }
131
    }
132
132
(-)a/java.editor/src/org/netbeans/modules/java/ui/PreviewPreferences.java (+97 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 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 2012 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.java.ui;
43
44
import java.util.HashMap;
45
import java.util.Map;
46
import java.util.prefs.AbstractPreferences;
47
import java.util.prefs.BackingStoreException;
48
49
/**
50
 *
51
 * @author Jaroslav Tulach <jtulach@netbeans.org>
52
 */
53
public class PreviewPreferences extends AbstractPreferences {
54
    private Map<String, Object> map = new HashMap<String, Object>();
55
56
    public PreviewPreferences() {
57
        super(null, ""); // NOI18N
58
    }
59
60
    protected void putSpi(String key, String value) {
61
        map.put(key, value);
62
    }
63
64
    protected String getSpi(String key) {
65
        return (String) map.get(key);
66
    }
67
68
    protected void removeSpi(String key) {
69
        map.remove(key);
70
    }
71
72
    protected void removeNodeSpi() throws BackingStoreException {
73
        throw new UnsupportedOperationException("Not supported yet.");
74
    }
75
76
    protected String[] keysSpi() throws BackingStoreException {
77
        String[] array = new String[map.keySet().size()];
78
        return map.keySet().toArray(array);
79
    }
80
81
    protected String[] childrenNamesSpi() throws BackingStoreException {
82
        throw new UnsupportedOperationException("Not supported yet.");
83
    }
84
85
    protected AbstractPreferences childSpi(String name) {
86
        throw new UnsupportedOperationException("Not supported yet.");
87
    }
88
89
    protected void syncSpi() throws BackingStoreException {
90
        throw new UnsupportedOperationException("Not supported yet.");
91
    }
92
93
    protected void flushSpi() throws BackingStoreException {
94
        throw new UnsupportedOperationException("Not supported yet.");
95
    }
96
    
97
}
(-)a/java.editor/src/org/netbeans/modules/java/ui/ProxyPreferences.java (+107 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 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 2012 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.java.ui;
43
44
import java.util.Arrays;
45
import java.util.HashSet;
46
import java.util.Set;
47
import java.util.prefs.AbstractPreferences;
48
import java.util.prefs.BackingStoreException;
49
import java.util.prefs.Preferences;
50
51
// read-only, no subnodes
52
53
public final class ProxyPreferences extends AbstractPreferences {
54
    private final Preferences[] delegates;
55
56
    public ProxyPreferences(Preferences... delegates) {
57
        super(null, ""); // NOI18N
58
        this.delegates = delegates;
59
    }
60
61
    protected void putSpi(String key, String value) {
62
        throw new UnsupportedOperationException("Not supported yet.");
63
    }
64
65
    protected String getSpi(String key) {
66
        for (Preferences p : delegates) {
67
            String value = p.get(key, null);
68
            if (value != null) {
69
                return value;
70
            }
71
        }
72
        return null;
73
    }
74
75
    protected void removeSpi(String key) {
76
        throw new UnsupportedOperationException("Not supported yet.");
77
    }
78
79
    protected void removeNodeSpi() throws BackingStoreException {
80
        throw new UnsupportedOperationException("Not supported yet.");
81
    }
82
83
    protected String[] keysSpi() throws BackingStoreException {
84
        Set<String> keys = new HashSet<String>();
85
        for (Preferences p : delegates) {
86
            keys.addAll(Arrays.asList(p.keys()));
87
        }
88
        return keys.toArray(new String[keys.size()]);
89
    }
90
91
    protected String[] childrenNamesSpi() throws BackingStoreException {
92
        throw new UnsupportedOperationException("Not supported yet.");
93
    }
94
95
    protected AbstractPreferences childSpi(String name) {
96
        throw new UnsupportedOperationException("Not supported yet.");
97
    }
98
99
    protected void syncSpi() throws BackingStoreException {
100
        throw new UnsupportedOperationException("Not supported yet.");
101
    }
102
103
    protected void flushSpi() throws BackingStoreException {
104
        throw new UnsupportedOperationException("Not supported yet.");
105
    }
106
    
107
} // End of ProxyPreferences class
(-)a/java.editor/test/unit/src/org/netbeans/modules/editor/java/JavaFormatterUnitTest.java (-1 / +1 lines)
Lines 47-53 Link Here
47
import java.util.prefs.Preferences;
47
import java.util.prefs.Preferences;
48
import org.netbeans.api.editor.mimelookup.MimeLookup;
48
import org.netbeans.api.editor.mimelookup.MimeLookup;
49
import org.netbeans.api.java.source.CodeStyle;
49
import org.netbeans.api.java.source.CodeStyle;
50
import org.netbeans.modules.java.ui.FmtOptions;
50
import org.netbeans.modules.java.uisupport.FmtOptions;
51
import org.openide.modules.ModuleInfo;
51
import org.openide.modules.ModuleInfo;
52
import org.openide.util.Lookup;
52
import org.openide.util.Lookup;
53
53
(-)a/java.kit/test/qa-functional/src/org/netbeans/test/ide/VerifyJavaSourceDependenciesTest.java (+101 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 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 2012 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.test.ide;
43
44
import junit.framework.Test;
45
import org.netbeans.api.java.source.JavaSource;
46
import org.netbeans.junit.NbModuleSuite;
47
import org.netbeans.junit.NbTestCase;
48
import org.openide.modules.ModuleInfo;
49
import org.openide.modules.Modules;
50
import org.openide.util.Lookup;
51
52
/**
53
 *
54
 * @author Jaroslav Tulach <jtulach@netbeans.org>
55
 */
56
public class VerifyJavaSourceDependenciesTest extends NbTestCase {
57
    public VerifyJavaSourceDependenciesTest(String n) {
58
        super(n);
59
    }
60
    
61
    public static Test suite() {
62
        return NbModuleSuite.emptyConfiguration().
63
            honorAutoloadEager(true).
64
            enableClasspathModules(false).gui(false).
65
            addTest(VerifyJavaSourceDependenciesTest.class).
66
            clusters("ide|java").
67
            autoloadModules("ide", ".*").
68
            autoloadModules("java", ".*").
69
            enableModules("java", "org.netbeans.modules.java.source").suite();
70
    }
71
    
72
    public void testJavaSourceEnabled() {
73
        ModuleInfo mi = Modules.getDefault().ownerOf(JavaSource.class);
74
        assertTrue("Module is enabled", mi.isEnabled());
75
    }
76
    
77
    public void testEditorDisabled() {
78
        StringBuilder sb = new StringBuilder();
79
        for (ModuleInfo mi : Lookup.getDefault().lookupAll(ModuleInfo.class)) {
80
            if (mi.getCodeNameBase().contains("mimelookup")) {
81
                continue;
82
            }
83
            if (mi.getCodeNameBase().equals("org.netbeans.modules.editor.util")) {
84
                // this one is lightweight
85
                continue;
86
            }
87
            if (mi.getCodeNameBase().equals("org.netbeans.modules.editor.guards")) {
88
                // this one is lightweight and already in JDev anyway
89
                continue;
90
            }
91
            if (mi.getCodeNameBase().contains("editor")) {
92
                if (mi.isEnabled()) {
93
                    sb.append(mi.getCodeNameBase()).append('\n');
94
                }
95
            }
96
        }
97
        if (sb.length() > 0) {
98
            fail("Enabled editor module:\n" + sb);
99
        }
100
    }
101
}
(-)a/java.preprocessorbridge/nbproject/project.xml (+9 lines)
Lines 23-28 Link Here
23
                    </run-dependency>
23
                    </run-dependency>
24
                </dependency>
24
                </dependency>
25
                <dependency>
25
                <dependency>
26
                    <code-name-base>org.netbeans.modules.editor.settings</code-name-base>
27
                    <build-prerequisite/>
28
                    <compile-dependency/>
29
                    <run-dependency>
30
                        <release-version>1</release-version>
31
                        <specification-version>1.43</specification-version>
32
                    </run-dependency>
33
                </dependency>
34
                <dependency>
26
                    <code-name-base>org.netbeans.modules.parsing.api</code-name-base>
35
                    <code-name-base>org.netbeans.modules.parsing.api</code-name-base>
27
                    <build-prerequisite/>
36
                    <build-prerequisite/>
28
                    <compile-dependency/>
37
                    <compile-dependency/>
(-)a/java.preprocessorbridge/src/org/netbeans/modules/java/preprocessorbridge/api/FmtConstants.java (+248 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 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 2012 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.java.preprocessorbridge.api;
43
44
import org.netbeans.api.editor.settings.SimpleValueNames;
45
import org.openide.util.Lookup;
46
47
/**
48
 *
49
 * @author Jaroslav Tulach <jtulach@netbeans.org>
50
 */
51
public abstract class FmtConstants {
52
    public static final String expandTabToSpaces = SimpleValueNames.EXPAND_TABS;
53
    public static final String tabSize = SimpleValueNames.TAB_SIZE;
54
    public static final String spacesPerTab = SimpleValueNames.SPACES_PER_TAB;
55
    public static final String indentSize = SimpleValueNames.INDENT_SHIFT_WIDTH;
56
    public static final String continuationIndentSize = "continuationIndentSize"; //NOI18N
57
    public static final String labelIndent = "labelIndent"; //NOI18N
58
    public static final String absoluteLabelIndent = "absoluteLabelIndent"; //NOI18N
59
    public static final String indentTopLevelClassMembers = "indentTopLevelClassMembers"; //NOI18N
60
    public static final String indentCasesFromSwitch = "indentCasesFromSwitch"; //NOI18N
61
    public static final String rightMargin = SimpleValueNames.TEXT_LIMIT_WIDTH;
62
    
63
    public static final String addLeadingStarInComment = "addLeadingStarInComment"; //NOI18N
64
65
    public static final String preferLongerNames = "preferLongerNames"; //NOI18N
66
    public static final String fieldNamePrefix = "fieldNamePrefix"; //NOI18N
67
    public static final String fieldNameSuffix = "fieldNameSuffix"; //NOI18N
68
    public static final String staticFieldNamePrefix = "staticFieldNamePrefix"; //NOI18N
69
    public static final String staticFieldNameSuffix = "staticFieldNameSuffix"; //NOI18N
70
    public static final String parameterNamePrefix = "parameterNamePrefix"; //NOI18N
71
    public static final String parameterNameSuffix = "parameterNameSuffix"; //NOI18N
72
    public static final String localVarNamePrefix = "localVarNamePrefix"; //NOI18N
73
    public static final String localVarNameSuffix = "localVarNameSuffix"; //NOI18N
74
    public static final String qualifyFieldAccess = "qualifyFieldAccess"; //NOI18N
75
    public static final String useIsForBooleanGetters = "useIsForBooleanGetters"; //NOI18N
76
    public static final String addOverrideAnnotation = "addOverrideAnnotation"; //NOI18N
77
    public static final String makeLocalVarsFinal = "makeLocalVarsFinal"; //NOI18N
78
    public static final String makeParametersFinal = "makeParametersFinal"; //NOI18N
79
    public static final String classMembersOrder = "classMembersOrder"; //NOI18N
80
    public static final String sortMembersByVisibility = "sortMembersByVisibility"; //NOI18N
81
    public static final String visibilityOrder = "visibilityOrder"; //NOI18N
82
    public static final String classMemberInsertionPoint = "classMemberInsertionPoint"; //NOI18N
83
    
84
    public static final String classDeclBracePlacement = "classDeclBracePlacement"; //NOI18N
85
    public static final String methodDeclBracePlacement = "methodDeclBracePlacement"; //NOI18N
86
    public static final String otherBracePlacement = "otherBracePlacement"; //NOI18N
87
    public static final String specialElseIf = "specialElseIf"; //NOI18N
88
    public static final String redundantIfBraces = "redundantIfBraces"; //NOI18N
89
    public static final String redundantForBraces = "redundantForBraces"; //NOI18N
90
    public static final String redundantWhileBraces = "redundantWhileBraces"; //NOI18N
91
    public static final String redundantDoWhileBraces = "redundantDoWhileBraces"; //NOI18N
92
    public static final String alignMultilineMethodParams = "alignMultilineMethodParams"; //NOI18N
93
    public static final String alignMultilineCallArgs = "alignMultilineCallArgs"; //NOI18N
94
    public static final String alignMultilineAnnotationArgs = "alignMultilineAnnotationArgs"; //NOI18N
95
    public static final String alignMultilineImplements = "alignMultilineImplements"; //NOI18N
96
    public static final String alignMultilineThrows = "alignMultilineThrows"; //NOI18N
97
    public static final String alignMultilineParenthesized = "alignMultilineParenthesized"; //NOI18N
98
    public static final String alignMultilineBinaryOp = "alignMultilineBinaryOp"; //NOI18N
99
    public static final String alignMultilineTernaryOp = "alignMultilineTernaryOp"; //NOI18N
100
    public static final String alignMultilineAssignment = "alignMultilineAssignment"; //NOI18N
101
    public static final String alignMultilineTryResources = "alignMultilineTryResources"; //NOI18N
102
    public static final String alignMultilineDisjunctiveCatchTypes = "alignMultilineDisjunctiveCatchTypes"; //NOI18N
103
    public static final String alignMultilineFor = "alignMultilineFor"; //NOI18N
104
    public static final String alignMultilineArrayInit = "alignMultilineArrayInit"; //NOI18N
105
    public static final String placeElseOnNewLine = "placeElseOnNewLine"; //NOI18N
106
    public static final String placeWhileOnNewLine = "placeWhileOnNewLine"; //NOI18N
107
    public static final String placeCatchOnNewLine = "placeCatchOnNewLine"; //NOI18N
108
    public static final String placeFinallyOnNewLine = "placeFinallyOnNewLine"; //NOI18N
109
    public static final String placeNewLineAfterModifiers = "placeNewLineAfterModifiers"; //NOI18N
110
    
111
    public static final String wrapExtendsImplementsKeyword = "wrapExtendsImplementsKeyword"; //NOI18N
112
    public static final String wrapExtendsImplementsList = "wrapExtendsImplementsList"; //NOI18N
113
    public static final String wrapMethodParams = "wrapMethodParams"; //NOI18N
114
    public static final String wrapThrowsKeyword = "wrapThrowsKeyword"; //NOI18N
115
    public static final String wrapThrowsList = "wrapThrowsList"; //NOI18N
116
    public static final String wrapMethodCallArgs = "wrapMethodCallArgs"; //NOI18N
117
    public static final String wrapAnnotationArgs = "wrapAnnotationArgs"; //NOI18N
118
    public static final String wrapChainedMethodCalls = "wrapChainedMethodCalls"; //NOI18N
119
    public static final String wrapAfterDotInChainedMethodCalls = "wrapAfterDotInChainedMethodCalls"; //NOI18N
120
    public static final String wrapArrayInit = "wrapArrayInit"; //NOI18N
121
    public static final String wrapTryResources = "wrapTryResources"; //NOI18N
122
    public static final String wrapDisjunctiveCatchTypes = "wrapDisjunctiveCatchTypes"; //NOI18N
123
    public static final String wrapFor = "wrapFor"; //NOI18N
124
    public static final String wrapForStatement = "wrapForStatement"; //NOI18N
125
    public static final String wrapIfStatement = "wrapIfStatement"; //NOI18N
126
    public static final String wrapWhileStatement = "wrapWhileStatement"; //NOI18N
127
    public static final String wrapDoWhileStatement = "wrapDoWhileStatement"; //NOI18N
128
    public static final String wrapAssert = "wrapAssert"; //NOI18N
129
    public static final String wrapEnumConstants = "wrapEnumConstants"; //NOI18N
130
    public static final String wrapAnnotations = "wrapAnnotations"; //NOI18N
131
    public static final String wrapBinaryOps = "wrapBinaryOps"; //NOI18N
132
    public static final String wrapAfterBinaryOps = "wrapAfterBinaryOps"; //NOI18N
133
    public static final String wrapTernaryOps = "wrapTernaryOps"; //NOI18N
134
    public static final String wrapAfterTernaryOps = "wrapAfterTernaryOps"; //NOI18N
135
    public static final String wrapAssignOps = "wrapAssignOps"; //NOI18N
136
    
137
    public static final String blankLinesBeforePackage = "blankLinesBeforePackage"; //NOI18N
138
    public static final String blankLinesAfterPackage = "blankLinesAfterPackage"; //NOI18N
139
    public static final String blankLinesBeforeImports = "blankLinesBeforeImports"; //NOI18N
140
    public static final String blankLinesAfterImports = "blankLinesAfterImports"; //NOI18N
141
    public static final String blankLinesBeforeClass = "blankLinesBeforeClass"; //NOI18N
142
    public static final String blankLinesAfterClass = "blankLinesAfterClass"; //NOI18N
143
    public static final String blankLinesAfterClassHeader = "blankLinesAfterClassHeader"; //NOI18N
144
    public static final String blankLinesAfterAnonymousClassHeader = "blankLinesAfterAnonymousClassHeader"; //NOI18N
145
    public static final String blankLinesBeforeFields = "blankLinesBeforeFields"; //NOI18N
146
    public static final String blankLinesAfterFields = "blankLinesAfterFields"; //NOI18N
147
    public static final String blankLinesBeforeMethods = "blankLinesBeforeMethods"; //NOI18N
148
    public static final String blankLinesAfterMethods = "blankLinesAfterMethods"; //NOI18N
149
    
150
    public static final String spaceBeforeWhile = "spaceBeforeWhile"; //NOI18N
151
    public static final String spaceBeforeElse = "spaceBeforeElse"; //NOI18N
152
    public static final String spaceBeforeCatch = "spaceBeforeCatch"; //NOI18N
153
    public static final String spaceBeforeFinally = "spaceBeforeFinally"; //NOI18N
154
    public static final String spaceBeforeMethodDeclParen = "spaceBeforeMethodDeclParen"; //NOI18N
155
    public static final String spaceBeforeMethodCallParen = "spaceBeforeMethodCallParen"; //NOI18N
156
    public static final String spaceBeforeIfParen = "spaceBeforeIfParen"; //NOI18N
157
    public static final String spaceBeforeForParen = "spaceBeforeForParen"; //NOI18N
158
    public static final String spaceBeforeWhileParen = "spaceBeforeWhileParen"; //NOI18N
159
    public static final String spaceBeforeTryParen = "spaceBeforeTryParen"; //NOI18N
160
    public static final String spaceBeforeCatchParen = "spaceBeforeCatchParen"; //NOI18N
161
    public static final String spaceBeforeSwitchParen = "spaceBeforeSwitchParen"; //NOI18N
162
    public static final String spaceBeforeSynchronizedParen = "spaceBeforeSynchronizedParen"; //NOI18N
163
    public static final String spaceBeforeAnnotationParen = "spaceBeforeAnnotationParen"; //NOI18N    
164
    public static final String spaceAroundUnaryOps = "spaceAroundUnaryOps"; //NOI18N
165
    public static final String spaceAroundBinaryOps = "spaceAroundBinaryOps"; //NOI18N
166
    public static final String spaceAroundTernaryOps = "spaceAroundTernaryOps"; //NOI18N
167
    public static final String spaceAroundAssignOps = "spaceAroundAssignOps"; //NOI18N
168
    public static final String spaceAroundAnnotationValueAssignOps = "spaceAroundAnnotationValueAssignOps"; //NOI18N
169
    public static final String spaceBeforeClassDeclLeftBrace = "spaceBeforeClassDeclLeftBrace"; //NOI18N
170
    public static final String spaceBeforeMethodDeclLeftBrace = "spaceBeforeMethodDeclLeftBrace"; //NOI18N
171
    public static final String spaceBeforeIfLeftBrace = "spaceBeforeIfLeftBrace"; //NOI18N
172
    public static final String spaceBeforeElseLeftBrace = "spaceBeforeElseLeftBrace"; //NOI18N
173
    public static final String spaceBeforeWhileLeftBrace = "spaceBeforeWhileLeftBrace"; //NOI18N
174
    public static final String spaceBeforeForLeftBrace = "spaceBeforeForLeftBrace"; //NOI18N
175
    public static final String spaceBeforeDoLeftBrace = "spaceBeforeDoLeftBrace"; //NOI18N
176
    public static final String spaceBeforeSwitchLeftBrace = "spaceBeforeSwitchLeftBrace"; //NOI18N
177
    public static final String spaceBeforeTryLeftBrace = "spaceBeforeTryLeftBrace"; //NOI18N
178
    public static final String spaceBeforeCatchLeftBrace = "spaceBeforeCatchLeftBrace"; //NOI18N
179
    public static final String spaceBeforeFinallyLeftBrace = "spaceBeforeFinallyLeftBrace"; //NOI18N
180
    public static final String spaceBeforeSynchronizedLeftBrace = "spaceBeforeSynchronizedLeftBrace"; //NOI18N
181
    public static final String spaceBeforeStaticInitLeftBrace = "spaceBeforeStaticInitLeftBrace"; //NOI18N
182
    public static final String spaceBeforeArrayInitLeftBrace = "spaceBeforeArrayInitLeftBrace"; //NOI18N
183
    public static final String spaceWithinParens = "spaceWithinParens"; //NOI18N
184
    public static final String spaceWithinMethodDeclParens = "spaceWithinMethodDeclParens"; //NOI18N
185
    public static final String spaceWithinMethodCallParens = "spaceWithinMethodCallParens"; //NOI18N
186
    public static final String spaceWithinIfParens = "spaceWithinIfParens"; //NOI18N
187
    public static final String spaceWithinForParens = "spaceWithinForParens"; //NOI18N
188
    public static final String spaceWithinWhileParens = "spaceWithinWhileParens"; //NOI18N
189
    public static final String spaceWithinSwitchParens = "spaceWithinSwitchParens"; //NOI18N
190
    public static final String spaceWithinTryParens = "spaceWithinTryParens"; //NOI18N
191
    public static final String spaceWithinCatchParens = "spaceWithinCatchParens"; //NOI18N
192
    public static final String spaceWithinSynchronizedParens = "spaceWithinSynchronizedParens"; //NOI18N
193
    public static final String spaceWithinTypeCastParens = "spaceWithinTypeCastParens"; //NOI18N
194
    public static final String spaceWithinAnnotationParens = "spaceWithinAnnotationParens"; //NOI18N
195
    public static final String spaceWithinBraces = "spaceWithinBraces"; //NOI18N
196
    public static final String spaceWithinArrayInitBrackets = "spaceWithinArrayInitBrackets"; //NOI18N
197
    public static final String spaceBeforeComma = "spaceBeforeComma"; //NOI18N
198
    public static final String spaceAfterComma = "spaceAfterComma"; //NOI18N
199
    public static final String spaceBeforeSemi = "spaceBeforeSemi"; //NOI18N
200
    public static final String spaceAfterSemi = "spaceAfterSemi"; //NOI18N
201
    public static final String spaceBeforeColon = "spaceBeforeColon"; //NOI18N
202
    public static final String spaceAfterColon = "spaceAfterColon"; //NOI18N
203
    public static final String spaceAfterTypeCast = "spaceAfterTypeCast"; //NOI18N
204
    
205
    public static final String useSingleClassImport = "useSingleClassImport"; //NOI18N
206
    public static final String usePackageImport = "usePackageImport"; //NOI18N
207
    public static final String useFQNs = "useFQNs"; //NOI18N
208
    public static final String importInnerClasses = "importInnerClasses"; //NOI18N
209
    public static final String allowConvertToStarImport = "allowConvertToStarImport"; //NOI18N
210
    public static final String countForUsingStarImport = "countForUsingStarImport"; //NOI18N
211
    public static final String allowConvertToStaticStarImport = "allowConvertToStaticStarImport"; //NOI18N
212
    public static final String countForUsingStaticStarImport = "countForUsingStaticStarImport"; //NOI18N
213
    public static final String packagesForStarImport = "packagesForStarImport"; //NOI18N
214
    public static final String separateStaticImports = "separateStaticImports"; //NOI18N
215
    public static final String importGroupsOrder = "importGroupsOrder"; //NOI18N
216
    public static final String separateImportGroups = "separateImportGroups"; //NOI18N
217
    
218
    public static final String enableCommentFormatting = "enableCommentFormatting"; //NOI18N
219
    public static final String enableBlockCommentFormatting = "enableBlockCommentFormatting"; //NOI18N
220
    public static final String wrapCommentText = "wrapCommentText"; //NOI18N
221
    public static final String wrapOneLineComment = "wrapOneLineComment"; //NOI18N
222
    public static final String preserveNewLinesInComments = "preserveNewLinesInComments"; //NOI18N
223
    public static final String blankLineAfterJavadocDescription = "blankLineAfterJavadocDescription"; //NOI18N
224
    public static final String blankLineAfterJavadocParameterDescriptions = "blankLineAfterJavadocParameterDescriptions"; //NOI18N
225
    public static final String blankLineAfterJavadocReturnTag = "blankLineAfterJavadocReturnTag"; //NOI18N
226
    public static final String generateParagraphTagOnBlankLines = "generateParagraphTagOnBlankLines"; //NOI18N
227
    public static final String alignJavadocParameterDescriptions = "alignJavadocParameterDescriptions"; //NOI18N
228
    public static final String alignJavadocReturnDescription = "alignJavadocReturnDescription"; //NOI18N
229
    public static final String alignJavadocExceptionDescriptions = "alignJavadocExceptionDescriptions"; //NOI18N
230
    public static String JAVA_MIME_TYPE = "text/x-java"; // NOI18N
231
232
    public static int getDefaultAsInt(String key) {
233
        return Lookup.getDefault().lookup(FmtConstants.class).defaultAsInt(key);
234
    }
235
236
    public static boolean getDefaultAsBoolean(String key) {
237
        return Lookup.getDefault().lookup(FmtConstants.class).defaultAsBoolean(key);
238
    }
239
240
    public static String getDefaultAsString(String key) {
241
        return Lookup.getDefault().lookup(FmtConstants.class).defaultAsString(key);
242
    }
243
244
    protected abstract int defaultAsInt(String key);
245
    protected abstract boolean defaultAsBoolean(String key);
246
    protected abstract String defaultAsString(String key);
247
    
248
}
(-)a/java.preprocessorbridge/src/org/netbeans/modules/java/preprocessorbridge/spi/TalkToEditor.java (+99 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 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 2012 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.java.preprocessorbridge.spi;
43
44
import java.beans.PropertyChangeListener;
45
import java.util.prefs.Preferences;
46
import javax.swing.text.BadLocationException;
47
import javax.swing.text.Document;
48
import javax.swing.text.JTextComponent;
49
import org.openide.filesystems.FileObject;
50
import org.openide.util.Lookup;
51
52
/**
53
 *
54
 * @author Jaroslav Tulach <jtulach@netbeans.org>
55
 */
56
public abstract class TalkToEditor {
57
    protected TalkToEditor() {
58
    }
59
60
    private static TalkToEditor getDefault() {
61
        return Lookup.getDefault().lookup(TalkToEditor.class);
62
    }
63
64
    public static JTextComponent findFocusedComponent() {
65
        return getDefault().implFocusedComponent();
66
    }
67
68
    
69
    public static Preferences findCodePreferences(FileObject file) {
70
        return getDefault().implCodePreferences(file);
71
    }
72
    public static Preferences findCodePreferences(Document doc) {
73
        return getDefault().implCodePreferences(doc);
74
    }
75
    public static JTextComponent findLastFocusedComponent() {
76
        return getDefault().implLastFocusedComponent();
77
    }
78
    public static void addEditorRegistryListener(PropertyChangeListener propertyChangeListener) {
79
        getDefault().implAddRemoveListener(propertyChangeListener, true);
80
    }
81
    public static void removeEditorRegistryListener(PropertyChangeListener propertyChangeListener) {
82
        getDefault().implAddRemoveListener(propertyChangeListener, false);
83
    }
84
    public static int findOffsetIndent(Document doc, int offset) throws BadLocationException {
85
        return getDefault().implOffsetIndent(doc, offset);
86
    }
87
    public static boolean checkGuarded(Document doc, int pos, long treePos) {
88
        return getDefault().implCheckGuarded(doc, pos, treePos);
89
    }
90
91
92
    protected abstract Preferences implCodePreferences(FileObject file);
93
    protected abstract Preferences implCodePreferences(Document doc);
94
    protected abstract JTextComponent implLastFocusedComponent();
95
    protected abstract JTextComponent implFocusedComponent();
96
    protected abstract void implAddRemoveListener(PropertyChangeListener pcl, boolean toAdd);
97
    protected abstract int implOffsetIndent(Document doc, int offset) throws BadLocationException;
98
    protected abstract boolean implCheckGuarded(Document doc, int pos, long treePos);
99
}
(-)a/java.source/nbproject/project.xml (-56 / +11 lines)
Lines 141-183 Link Here
141
                    <compile-dependency/>
141
                    <compile-dependency/>
142
                    <run-dependency>
142
                    <run-dependency>
143
                        <release-version>1</release-version>
143
                        <release-version>1</release-version>
144
                        <specification-version>1.0</specification-version>
144
                        <specification-version>1.17</specification-version>
145
                    </run-dependency>
146
                </dependency>
147
                <dependency>
148
                    <code-name-base>org.netbeans.modules.editor.indent</code-name-base>
149
                    <build-prerequisite/>
150
                    <compile-dependency/>
151
                    <run-dependency>
152
                        <release-version>2</release-version>
153
                        <specification-version>1.11</specification-version>
154
                    </run-dependency>
155
                </dependency>
156
                <dependency>
157
                    <code-name-base>org.netbeans.modules.editor.indent.project</code-name-base>
158
                    <build-prerequisite/>
159
                    <compile-dependency/>
160
                    <run-dependency>
161
                        <release-version>0-1</release-version>
162
                        <specification-version>1.0</specification-version>
163
                    </run-dependency>
164
                </dependency>
165
                <dependency>
166
                    <code-name-base>org.netbeans.modules.editor.lib</code-name-base>
167
                    <build-prerequisite/>
168
                    <compile-dependency/>
169
                    <run-dependency>
170
                        <release-version>3</release-version>
171
                        <specification-version>3.1</specification-version>
172
                    </run-dependency>
173
                </dependency>
174
                <dependency>
175
                    <code-name-base>org.netbeans.modules.editor.lib2</code-name-base>
176
                    <build-prerequisite/>
177
                    <compile-dependency/>
178
                    <run-dependency>
179
                        <release-version>1</release-version>
180
                        <specification-version>1.11</specification-version>
181
                    </run-dependency>
145
                    </run-dependency>
182
                </dependency>
146
                </dependency>
183
                <dependency>
147
                <dependency>
Lines 190-210 Link Here
190
                    </run-dependency>
154
                    </run-dependency>
191
                </dependency>
155
                </dependency>
192
                <dependency>
156
                <dependency>
193
                    <code-name-base>org.netbeans.modules.editor.settings</code-name-base>
194
                    <build-prerequisite/>
195
                    <compile-dependency/>
196
                    <run-dependency>
197
                        <release-version>1</release-version>
198
                        <specification-version>1.18</specification-version>
199
                    </run-dependency>
200
                </dependency>
201
                <dependency>
202
                    <code-name-base>org.netbeans.modules.editor.util</code-name-base>
157
                    <code-name-base>org.netbeans.modules.editor.util</code-name-base>
203
                    <build-prerequisite/>
158
                    <build-prerequisite/>
204
                    <compile-dependency/>
159
                    <compile-dependency/>
205
                    <run-dependency>
160
                    <run-dependency>
206
                        <release-version>1</release-version>
161
                        <release-version>1</release-version>
207
                        <specification-version>1.22</specification-version>
162
                        <specification-version>1.49</specification-version>
208
                    </run-dependency>
163
                    </run-dependency>
209
                </dependency>
164
                </dependency>
210
                <dependency>
165
                <dependency>
Lines 252-266 Link Here
252
                    </run-dependency>
207
                    </run-dependency>
253
                </dependency>
208
                </dependency>
254
                <dependency>
209
                <dependency>
255
                    <code-name-base>org.netbeans.modules.options.editor</code-name-base>
256
                    <build-prerequisite/>
257
                    <compile-dependency/>
258
                    <run-dependency>
259
                        <release-version>1</release-version>
260
                        <specification-version>1.20</specification-version>
261
                    </run-dependency>
262
                </dependency>
263
                <dependency>
264
                    <code-name-base>org.netbeans.modules.parsing.api</code-name-base>
210
                    <code-name-base>org.netbeans.modules.parsing.api</code-name-base>
265
                    <build-prerequisite/>
211
                    <build-prerequisite/>
266
                    <compile-dependency/>
212
                    <compile-dependency/>
Lines 402-407 Link Here
402
                        <specification-version>6.2</specification-version>
348
                        <specification-version>6.2</specification-version>
403
                    </run-dependency>
349
                    </run-dependency>
404
                </dependency>
350
                </dependency>
351
                <dependency>
352
                    <code-name-base>org.netbeans.modules.editor.settings</code-name-base>
353
                    <build-prerequisite/>
354
                    <compile-dependency/>
355
                    <run-dependency>
356
                        <release-version>1</release-version>
357
                        <specification-version>1.43</specification-version>
358
                    </run-dependency>
359
                </dependency>
405
            </module-dependencies>
360
            </module-dependencies>
406
            <test-dependencies>
361
            <test-dependencies>
407
                <test-type>
362
                <test-type>
(-)a/java.source/src/org/netbeans/api/java/source/CodeStyle.java (-6 / +5 lines)
Lines 62-71 Link Here
62
import com.sun.source.tree.VariableTree;
62
import com.sun.source.tree.VariableTree;
63
63
64
import org.netbeans.api.project.Project;
64
import org.netbeans.api.project.Project;
65
import org.netbeans.modules.editor.indent.spi.CodeStylePreferences;
65
import org.netbeans.modules.java.preprocessorbridge.spi.TalkToEditor;
66
import org.netbeans.modules.java.source.parsing.JavacParser;
66
import org.netbeans.modules.java.uisupport.FmtOptions;
67
import org.netbeans.modules.java.ui.FmtOptions;
67
import static org.netbeans.modules.java.uisupport.FmtOptions.*;
68
import static org.netbeans.modules.java.ui.FmtOptions.*;
69
import org.openide.filesystems.FileObject;
68
import org.openide.filesystems.FileObject;
70
69
71
/** 
70
/** 
Lines 117-123 Link Here
117
     * @since 0.39
116
     * @since 0.39
118
     */
117
     */
119
    public synchronized static CodeStyle getDefault(FileObject file) {
118
    public synchronized static CodeStyle getDefault(FileObject file) {
120
        Preferences prefs = CodeStylePreferences.get(file, JavacParser.MIME_TYPE).getPreferences();
119
        Preferences prefs = TalkToEditor.findCodePreferences(file);
121
        return FmtOptions.codeStyleProducer.create(prefs);
120
        return FmtOptions.codeStyleProducer.create(prefs);
122
    }
121
    }
123
122
Lines 133-139 Link Here
133
     * @since 0.39
132
     * @since 0.39
134
     */
133
     */
135
    public synchronized static CodeStyle getDefault(Document doc) {
134
    public synchronized static CodeStyle getDefault(Document doc) {
136
        Preferences prefs = CodeStylePreferences.get(doc, JavacParser.MIME_TYPE).getPreferences();
135
        Preferences prefs = TalkToEditor.findCodePreferences(doc);
137
        return FmtOptions.codeStyleProducer.create(prefs);
136
        return FmtOptions.codeStyleProducer.create(prefs);
138
    }
137
    }
139
    
138
    
(-)a/java.source/src/org/netbeans/api/java/source/GeneratorUtilities.java (-4 / +4 lines)
Lines 120-126 Link Here
120
120
121
import org.netbeans.api.java.lexer.JavaTokenId;
121
import org.netbeans.api.java.lexer.JavaTokenId;
122
import org.netbeans.api.lexer.TokenSequence;
122
import org.netbeans.api.lexer.TokenSequence;
123
import org.netbeans.editor.GuardedDocument;
123
import org.netbeans.modules.java.preprocessorbridge.spi.TalkToEditor;
124
import org.netbeans.modules.java.source.builder.CommentHandlerService;
124
import org.netbeans.modules.java.source.builder.CommentHandlerService;
125
import org.netbeans.modules.java.source.builder.CommentSetImpl;
125
import org.netbeans.modules.java.source.builder.CommentSetImpl;
126
import org.netbeans.modules.java.source.parsing.FileObjects;
126
import org.netbeans.modules.java.source.parsing.FileObjects;
Lines 215-226 Link Here
215
            if ((path == null || !utils.isSynthetic(path))
215
            if ((path == null || !utils.isSynthetic(path))
216
                    && (codeStyle.getClassMemberInsertionPoint() == CodeStyle.InsertionPoint.FIRST_IN_CATEGORY && comparator.compare(member, tree) <= 0
216
                    && (codeStyle.getClassMemberInsertionPoint() == CodeStyle.InsertionPoint.FIRST_IN_CATEGORY && comparator.compare(member, tree) <= 0
217
                    || comparator.compare(member, tree) < 0)) {
217
                    || comparator.compare(member, tree) < 0)) {
218
                if (doc == null || !(doc instanceof GuardedDocument))
218
                if (doc == null) {
219
                    break;
219
                    break;
220
                }
220
                int pos = (int)(lastMember != null ? sp.getEndPosition(compilationUnit, lastMember) : sp.getStartPosition( compilationUnit,clazz));
221
                int pos = (int)(lastMember != null ? sp.getEndPosition(compilationUnit, lastMember) : sp.getStartPosition( compilationUnit,clazz));
221
                pos = ((GuardedDocument)doc).getGuardedBlockChain().adjustToBlockEnd(pos);
222
                long treePos = sp.getStartPosition(compilationUnit, tree);
222
                long treePos = sp.getStartPosition(compilationUnit, tree);
223
                if (treePos < 0 || pos <= treePos)
223
                if (TalkToEditor.checkGuarded(doc, pos, treePos))
224
                    break;
224
                    break;
225
            }
225
            }
226
            idx++;
226
            idx++;
(-)a/java.source/src/org/netbeans/api/java/source/ModificationResult.java (-2 / +15 lines)
Lines 62-68 Link Here
62
import org.netbeans.api.annotations.common.NullUnknown;
62
import org.netbeans.api.annotations.common.NullUnknown;
63
import org.netbeans.api.java.source.ModificationResult.CreateChange;
63
import org.netbeans.api.java.source.ModificationResult.CreateChange;
64
import org.netbeans.api.queries.FileEncodingQuery;
64
import org.netbeans.api.queries.FileEncodingQuery;
65
import org.netbeans.editor.BaseDocument;
66
import org.netbeans.lib.editor.util.swing.DocumentUtilities;
65
import org.netbeans.lib.editor.util.swing.DocumentUtilities;
67
import org.netbeans.modules.java.preprocessorbridge.spi.JavaFileFilterImplementation;
66
import org.netbeans.modules.java.preprocessorbridge.spi.JavaFileFilterImplementation;
68
import org.netbeans.modules.java.source.JavaFileFilterQuery;
67
import org.netbeans.modules.java.source.JavaFileFilterQuery;
Lines 349-355 Link Here
349
                    // The listener was added while trying to fix #63323
348
                    // The listener was added while trying to fix #63323
350
                    // IMPORTANT: it has to be removed immediatelly after the change to stop marking the events
349
                    // IMPORTANT: it has to be removed immediatelly after the change to stop marking the events
351
                    // as ignoring caret changes
350
                    // as ignoring caret changes
352
                    if (doc instanceof BaseDocument) {
351
                    if (isBaseDocument()) {
353
                        l = new DocumentListener() {
352
                        l = new DocumentListener() {
354
                            @Override
353
                            @Override
355
                            public void insertUpdate(DocumentEvent e) {
354
                            public void insertUpdate(DocumentEvent e) {
Lines 377-382 Link Here
377
                    }
376
                    }
378
                }
377
                }
379
            }
378
            }
379
380
            private boolean isBaseDocument() {
381
                if (doc == null) {
382
                    return false;
383
                }
384
                Class<?> c = doc.getClass();
385
                while (c != null) {
386
                    if ("org.netbeans.editor.BaseDocument".equals(c.getName())) { // NOI18N
387
                        return true;
388
                    }
389
                    c = c.getSuperclass();
390
                }
391
                return false;
392
            }
380
        };
393
        };
381
        if (diff.isCommitToGuards()) {
394
        if (diff.isCommitToGuards()) {
382
            NbDocument.runAtomic(doc, task);
395
            NbDocument.runAtomic(doc, task);
(-)a/java.source/src/org/netbeans/api/java/source/UiUtils.java (-1 / +1 lines)
Lines 63-69 Link Here
63
import javax.swing.text.StyledDocument;
63
import javax.swing.text.StyledDocument;
64
import org.netbeans.modules.java.source.pretty.VeryPretty;
64
import org.netbeans.modules.java.source.pretty.VeryPretty;
65
import org.netbeans.modules.java.source.save.DiffContext;
65
import org.netbeans.modules.java.source.save.DiffContext;
66
import org.netbeans.modules.java.ui.Icons;
66
import org.netbeans.modules.java.uisupport.Icons;
67
import org.openide.DialogDisplayer;
67
import org.openide.DialogDisplayer;
68
import org.openide.NotifyDescriptor;
68
import org.openide.NotifyDescriptor;
69
import org.openide.cookies.EditorCookie;
69
import org.openide.cookies.EditorCookie;
(-)a/java.source/src/org/netbeans/api/java/source/support/OpenedEditors.java (-3 / +3 lines)
Lines 62-69 Link Here
62
import javax.swing.event.ChangeListener;
62
import javax.swing.event.ChangeListener;
63
import javax.swing.text.Document;
63
import javax.swing.text.Document;
64
import javax.swing.text.JTextComponent;
64
import javax.swing.text.JTextComponent;
65
import org.netbeans.api.editor.EditorRegistry;
66
import org.netbeans.api.java.source.JavaSource;
65
import org.netbeans.api.java.source.JavaSource;
66
import org.netbeans.modules.java.preprocessorbridge.spi.TalkToEditor;
67
import org.netbeans.modules.java.source.JavaSourceSupportAccessor;
67
import org.netbeans.modules.java.source.JavaSourceSupportAccessor;
68
import org.openide.filesystems.FileObject;
68
import org.openide.filesystems.FileObject;
69
import org.openide.filesystems.FileUtil;
69
import org.openide.filesystems.FileUtil;
Lines 84-90 Link Here
84
    private static OpenedEditors DEFAULT;
84
    private static OpenedEditors DEFAULT;
85
85
86
    private OpenedEditors() {
86
    private OpenedEditors() {
87
        EditorRegistry.addPropertyChangeListener(new PropertyChangeListener() {
87
        TalkToEditor.addEditorRegistryListener(new PropertyChangeListener() {
88
            public void propertyChange(PropertyChangeEvent evt) {
88
            public void propertyChange(PropertyChangeEvent evt) {
89
                stateChanged();
89
                stateChanged();
90
            }
90
            }
Lines 157-163 Link Here
157
157
158
        visibleEditors.clear();
158
        visibleEditors.clear();
159
159
160
        JTextComponent editor = EditorRegistry.lastFocusedComponent();
160
        JTextComponent editor = TalkToEditor.findLastFocusedComponent();
161
161
162
        DataObject file = editor != null ? getDataObject(editor) : null;
162
        DataObject file = editor != null ? getDataObject(editor) : null;
163
        
163
        
(-)a/java.source/src/org/netbeans/modules/java/classfile/SideBarFactoryImpl.java (-4 / +4 lines)
Lines 41-59 Link Here
41
import javax.swing.JComponent;
41
import javax.swing.JComponent;
42
import javax.swing.text.Document;
42
import javax.swing.text.Document;
43
import javax.swing.text.JTextComponent;
43
import javax.swing.text.JTextComponent;
44
import org.netbeans.editor.SideBarFactory;
44
//import org.netbeans.editor.SideBarFactory;
45
import org.openide.filesystems.FileObject;
45
import org.openide.filesystems.FileObject;
46
import org.openide.filesystems.FileStateInvalidException;
46
import org.openide.filesystems.FileStateInvalidException;
47
import org.openide.loaders.DataObject;
47
import org.openide.loaders.DataObject;
48
import org.openide.util.Exceptions;
48
import org.openide.util.Exceptions;
49
49
50
/**
50
/** XXX: probably move to java.editor (?)
51
 *
51
 *
52
 * @author lahvac
52
 * @author lahvac
53
 */
53
 */
54
public class SideBarFactoryImpl implements SideBarFactory {
54
public class SideBarFactoryImpl /* implements SideBarFactory*/ {
55
55
56
    @Override
56
 //   @Override
57
    public JComponent createSideBar(JTextComponent target) {
57
    public JComponent createSideBar(JTextComponent target) {
58
        Document doc = target.getDocument();
58
        Document doc = target.getDocument();
59
        FileObject originFile;
59
        FileObject originFile;
(-)a/java.source/src/org/netbeans/modules/java/source/parsing/JavacParser.java (-7 / +8 lines)
Lines 100-106 Link Here
100
import javax.tools.JavaFileObject;
100
import javax.tools.JavaFileObject;
101
import org.netbeans.api.annotations.common.NonNull;
101
import org.netbeans.api.annotations.common.NonNull;
102
import org.netbeans.api.annotations.common.NullAllowed;
102
import org.netbeans.api.annotations.common.NullAllowed;
103
import org.netbeans.api.editor.EditorRegistry;
104
import org.netbeans.api.java.classpath.ClassPath;
103
import org.netbeans.api.java.classpath.ClassPath;
105
import org.netbeans.api.java.lexer.JavaTokenId;
104
import org.netbeans.api.java.lexer.JavaTokenId;
106
import org.netbeans.api.java.queries.SourceLevelQuery;
105
import org.netbeans.api.java.queries.SourceLevelQuery;
Lines 137-142 Link Here
137
import org.netbeans.lib.nbjavac.services.NBJavacTrees;
136
import org.netbeans.lib.nbjavac.services.NBJavacTrees;
138
import org.netbeans.lib.nbjavac.services.NBTreeMaker;
137
import org.netbeans.lib.nbjavac.services.NBTreeMaker;
139
import org.netbeans.lib.nbjavac.services.PartialReparser;
138
import org.netbeans.lib.nbjavac.services.PartialReparser;
139
import org.netbeans.modules.java.preprocessorbridge.api.FmtConstants;
140
import org.netbeans.modules.java.preprocessorbridge.spi.TalkToEditor;
140
import org.netbeans.modules.java.source.tasklist.CompilerSettings;
141
import org.netbeans.modules.java.source.tasklist.CompilerSettings;
141
import org.netbeans.modules.java.source.usages.ClassIndexImpl;
142
import org.netbeans.modules.java.source.usages.ClassIndexImpl;
142
import org.netbeans.modules.java.source.usages.ClasspathInfoAccessor;
143
import org.netbeans.modules.java.source.usages.ClasspathInfoAccessor;
Lines 171-177 Link Here
171
    //Debug logger
172
    //Debug logger
172
    private static final Logger LOGGER = Logger.getLogger(JavacParser.class.getName());
173
    private static final Logger LOGGER = Logger.getLogger(JavacParser.class.getName());
173
    //Java Mime Type
174
    //Java Mime Type
174
    public static final String MIME_TYPE = "text/x-java";
175
    public static final String MIME_TYPE = FmtConstants.JAVA_MIME_TYPE;
175
    //JavaFileObjectProvider used by the JavacParser - may be overriden by unit test
176
    //JavaFileObjectProvider used by the JavacParser - may be overriden by unit test
176
    static JavaFileObjectProvider jfoProvider = new DefaultJavaFileObjectProvider ();
177
    static JavaFileObjectProvider jfoProvider = new DefaultJavaFileObjectProvider ();
177
    //No output writer like /dev/null
178
    //No output writer like /dev/null
Lines 1116-1122 Link Here
1116
                th.addTokenHierarchyListener(lexListener = WeakListeners.create(TokenHierarchyListener.class, this,th));
1117
                th.addTokenHierarchyListener(lexListener = WeakListeners.create(TokenHierarchyListener.class, this,th));
1117
                document = doc;
1118
                document = doc;
1118
            }
1119
            }
1119
            EditorRegistry.addPropertyChangeListener(new EditorRegistryWeakListener(this));
1120
            TalkToEditor.addEditorRegistryListener(new EditorRegistryWeakListener(this));
1120
        }
1121
        }
1121
1122
1122
        @Override
1123
        @Override
Lines 1138-1146 Link Here
1138
                    //reset document
1139
                    //reset document
1139
                    this.document = doc;
1140
                    this.document = doc;
1140
                }
1141
                }
1141
            } else if (EditorRegistry.FOCUS_GAINED_PROPERTY.equals(evt.getPropertyName())) {
1142
            } else if ("focusGained".equals(evt.getPropertyName())) {
1142
                final Document doc = document;
1143
                final Document doc = document;
1143
                final JTextComponent focused = EditorRegistry.focusedComponent();
1144
                final JTextComponent focused = TalkToEditor.findFocusedComponent();
1144
                final Document focusedDoc = focused == null ? null : focused.getDocument();
1145
                final Document focusedDoc = focused == null ? null : focused.getDocument();
1145
                if (doc != null && doc == focusedDoc) {
1146
                if (doc != null && doc == focusedDoc) {
1146
                    positions.clear();
1147
                    positions.clear();
Lines 1216-1222 Link Here
1216
        @Override
1217
        @Override
1217
        public void propertyChange(PropertyChangeEvent evt) {
1218
        public void propertyChange(PropertyChangeEvent evt) {
1218
            final PropertyChangeListener delegate = get();
1219
            final PropertyChangeListener delegate = get();
1219
            final JTextComponent lastCandidate = EditorRegistry.focusedComponent();
1220
            final JTextComponent lastCandidate = TalkToEditor.findFocusedComponent();
1220
            if (delegate != null && lastCandidate != null && lastCandidate != getLast()) {
1221
            if (delegate != null && lastCandidate != null && lastCandidate != getLast()) {
1221
                setLast(lastCandidate);
1222
                setLast(lastCandidate);
1222
                delegate.propertyChange(evt);
1223
                delegate.propertyChange(evt);
Lines 1225-1231 Link Here
1225
1226
1226
        @Override
1227
        @Override
1227
        public void run() {
1228
        public void run() {
1228
            EditorRegistry.removePropertyChangeListener(this);
1229
            TalkToEditor.removeEditorRegistryListener(this);
1229
        }
1230
        }
1230
1231
1231
        /**
1232
        /**
(-)a/java.source/src/org/netbeans/modules/java/source/save/CasualDiff.java (-5 / +6 lines)
Lines 76-83 Link Here
76
import javax.swing.text.BadLocationException;
76
import javax.swing.text.BadLocationException;
77
import static org.netbeans.modules.java.source.save.ListMatcher.*;
77
import static org.netbeans.modules.java.source.save.ListMatcher.*;
78
import static com.sun.tools.javac.code.Flags.*;
78
import static com.sun.tools.javac.code.Flags.*;
79
79
import javax.swing.text.Document;
80
import org.netbeans.modules.editor.indent.api.IndentUtils;
80
81
import org.netbeans.modules.java.preprocessorbridge.spi.TalkToEditor;
81
import static org.netbeans.modules.java.source.save.PositionEstimator.*;
82
import static org.netbeans.modules.java.source.save.PositionEstimator.*;
82
83
83
public class CasualDiff {
84
public class CasualDiff {
Lines 290-300 Link Here
290
    }
291
    }
291
    
292
    
292
    private static int getOldIndent(DiffContext diffContext, Tree t) {
293
    private static int getOldIndent(DiffContext diffContext, Tree t) {
293
        if (diffContext.doc != null) {
294
        final Document doc = diffContext.doc;
295
        if (doc != null) {
294
            try {
296
            try {
295
                int offset = (int) diffContext.trees.getSourcePositions().getStartPosition(diffContext.origUnit, t);
297
                int offset = (int) diffContext.trees.getSourcePositions().getStartPosition(diffContext.origUnit, t);
296
                int lineStartOffset = IndentUtils.lineStartOffset(diffContext.doc, offset);
298
                return TalkToEditor.findOffsetIndent(doc, offset);
297
                return IndentUtils.lineIndent(diffContext.doc, lineStartOffset);
298
            } catch (BadLocationException ex) {}
299
            } catch (BadLocationException ex) {}
299
        }
300
        }
300
        return -1;
301
        return -1;
(-)a/java.source/src/org/netbeans/modules/java/source/save/Reformatter.java (-4 / +6 lines)
Lines 58-67 Link Here
58
import org.netbeans.api.lexer.Token;
58
import org.netbeans.api.lexer.Token;
59
import org.netbeans.api.lexer.TokenHierarchy;
59
import org.netbeans.api.lexer.TokenHierarchy;
60
import org.netbeans.api.lexer.TokenSequence;
60
import org.netbeans.api.lexer.TokenSequence;
61
/* XXX: Where to with reformatter?
61
import org.netbeans.editor.GuardedDocument;
62
import org.netbeans.editor.GuardedDocument;
62
import org.netbeans.modules.editor.indent.spi.Context;
63
import org.netbeans.modules.editor.indent.spi.Context;
63
import org.netbeans.modules.editor.indent.spi.ExtraLock;
64
import org.netbeans.modules.editor.indent.spi.ExtraLock;
64
import org.netbeans.modules.editor.indent.spi.ReformatTask;
65
import org.netbeans.modules.editor.indent.spi.ReformatTask;
66
*/
65
import org.netbeans.modules.java.source.JavaSourceAccessor;
67
import org.netbeans.modules.java.source.JavaSourceAccessor;
66
import org.netbeans.modules.java.source.parsing.FileObjects;
68
import org.netbeans.modules.java.source.parsing.FileObjects;
67
import org.netbeans.modules.java.source.parsing.JavacParser;
69
import org.netbeans.modules.java.source.parsing.JavacParser;
Lines 80-86 Link Here
80
 *
82
 *
81
 * @author Dusan Balek
83
 * @author Dusan Balek
82
 */
84
 */
83
public class Reformatter implements ReformatTask {
85
public class Reformatter { /*implements ReformatTask {
84
    
86
    
85
    private static final Object CT_HANDLER_DOC_PROPERTY = "code-template-insert-handler"; // NOI18N
87
    private static final Object CT_HANDLER_DOC_PROPERTY = "code-template-insert-handler"; // NOI18N
86
88
Lines 145-151 Link Here
145
        for (Context.Region region : indentRegions)
147
        for (Context.Region region : indentRegions)
146
            reformatImpl(region, cs);
148
            reformatImpl(region, cs);
147
    }
149
    }
148
    
150
*/    
149
    public static String reformat(String text, CodeStyle style) {
151
    public static String reformat(String text, CodeStyle style) {
150
        return reformat(text, style, style.getRightMargin());
152
        return reformat(text, style, style.getRightMargin());
151
    }
153
    }
Lines 175-181 Link Here
175
        }
177
        }
176
        return sb.toString();
178
        return sb.toString();
177
    }
179
    }
178
    
180
  /*  
179
    private void reformatImpl(Context.Region region, CodeStyle cs) throws BadLocationException {
181
    private void reformatImpl(Context.Region region, CodeStyle cs) throws BadLocationException {
180
        boolean templateEdit = doc.getProperty(CT_HANDLER_DOC_PROPERTY) != null;
182
        boolean templateEdit = doc.getProperty(CT_HANDLER_DOC_PROPERTY) != null;
181
        int startOffset = region.getStartOffset();
183
        int startOffset = region.getStartOffset();
Lines 367-373 Link Here
367
            return source != null ? new Reformatter(source, context) : null;
369
            return source != null ? new Reformatter(source, context) : null;
368
        }        
370
        }        
369
    }
371
    }
370
372
*/
371
    private static class Pretty extends TreePathScanner<Boolean, Void> {
373
    private static class Pretty extends TreePathScanner<Boolean, Void> {
372
374
373
        private static final String OPERATOR = "operator"; //NOI18N
375
        private static final String OPERATOR = "operator"; //NOI18N
(-)a/java.source/src/org/netbeans/modules/java/source/save/Reindenter.java (-2 / +4 lines)
Lines 39-45 Link Here
39
package org.netbeans.modules.java.source.save;
39
package org.netbeans.modules.java.source.save;
40
40
41
import com.sun.source.tree.AnnotationTree;
41
import com.sun.source.tree.AnnotationTree;
42
import com.sun.source.tree.BinaryTree;
43
import com.sun.source.tree.BlockTree;
42
import com.sun.source.tree.BlockTree;
44
import com.sun.source.tree.CaseTree;
43
import com.sun.source.tree.CaseTree;
45
import com.sun.source.tree.ClassTree;
44
import com.sun.source.tree.ClassTree;
Lines 89-98 Link Here
89
import org.netbeans.api.java.source.CodeStyle;
88
import org.netbeans.api.java.source.CodeStyle;
90
import org.netbeans.api.lexer.TokenHierarchy;
89
import org.netbeans.api.lexer.TokenHierarchy;
91
import org.netbeans.api.lexer.TokenSequence;
90
import org.netbeans.api.lexer.TokenSequence;
91
/* XXX: Where to put the Reindenter?
92
import org.netbeans.modules.editor.indent.spi.Context;
92
import org.netbeans.modules.editor.indent.spi.Context;
93
import org.netbeans.modules.editor.indent.spi.Context.Region;
93
import org.netbeans.modules.editor.indent.spi.Context.Region;
94
import org.netbeans.modules.editor.indent.spi.ExtraLock;
94
import org.netbeans.modules.editor.indent.spi.ExtraLock;
95
import org.netbeans.modules.editor.indent.spi.IndentTask;
95
import org.netbeans.modules.editor.indent.spi.IndentTask;
96
*/
96
import org.netbeans.modules.java.source.parsing.FileObjects;
97
import org.netbeans.modules.java.source.parsing.FileObjects;
97
import org.netbeans.modules.java.source.parsing.JavacParser;
98
import org.netbeans.modules.java.source.parsing.JavacParser;
98
99
Lines 100-106 Link Here
100
 *
101
 *
101
 * @author Dusan Balek
102
 * @author Dusan Balek
102
 */
103
 */
103
public class Reindenter implements IndentTask {
104
public class Reindenter { /*implements IndentTask {
104
105
105
    private final Context context;
106
    private final Context context;
106
    private CodeStyle cs;
107
    private CodeStyle cs;
Lines 920-923 Link Here
920
                    ? new Reindenter(context) : null;
921
                    ? new Reindenter(context) : null;
921
        }
922
        }
922
    }
923
    }
924
*/
923
}
925
}
(-)a/java.source/src/org/netbeans/modules/java/ui/Bundle.properties (-5 lines)
Lines 500-508 Link Here
500
500
501
AN_Preview=Preview
501
AN_Preview=Preview
502
AD_Preview=Preview
502
AD_Preview=Preview
503
FmtTabsIndents.absoluteLabelIndentCheckBox.AccessibleContext.accessibleDescription=Indent Labels absolutely
504
FmtTabsIndents.addLeadingStarInCommentCheckBox.AccessibleContext.accessibleDescription=Comment lines starting with leading star
503
FmtTabsIndents.addLeadingStarInCommentCheckBox.AccessibleContext.accessibleDescription=Comment lines starting with leading star
505
FmtTabsIndents.indentCasesFromSwitchCheckBox.AccessibleContext.accessibleDescription=Additional indent for case statements
506
FmtTabsIndents.indentTopLevelClassMembersCheckBox.AccessibleContext.accessibleDescription=Indent for top-level class members
507
FmtTabsIndents.continuationIndentSizeField.AccessibleContext.accessibleDescription=Indent size in spaces
508
FmtTabsIndents.labelIndentField.AccessibleContext.accessibleDescription=Label indentation size in spaces
(-)a/java.source/src/org/netbeans/modules/java/ui/ElementHeaderFormater.java (-1 / +1 lines)
Lines 28-34 Link Here
28
 *
28
 *
29
 * Portions Copyrighted 2007 Sun Microsystems, Inc.
29
 * Portions Copyrighted 2007 Sun Microsystems, Inc.
30
 */
30
 */
31
package org.netbeans.modules.java.ui;
31
package org.netbeans.modules.java.uisupport;
32
32
33
import com.sun.source.tree.ClassTree;
33
import com.sun.source.tree.ClassTree;
34
import com.sun.source.tree.MethodTree;
34
import com.sun.source.tree.MethodTree;
(-)a/java.source/src/org/netbeans/modules/java/ui/FmtOptions.java (-799 / +19 lines)
Lines 41-277 Link Here
41
 * Version 2 license, then the option applies only if the new code is
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
42
 * made subject to such option by the copyright holder.
43
 */
43
 */
44
package org.netbeans.modules.java.ui;
44
package org.netbeans.modules.java.uisupport;
45
45
46
import java.awt.Component;
46
import org.netbeans.modules.java.preprocessorbridge.api.FmtConstants;
47
import java.awt.Container;
48
import java.awt.Rectangle;
49
import java.awt.event.ActionEvent;
50
import java.awt.event.ActionListener;
51
import java.util.Arrays;
52
import java.util.HashMap;
47
import java.util.HashMap;
53
import java.util.HashSet;
54
import java.util.LinkedList;
55
import java.util.List;
56
import java.util.Map;
48
import java.util.Map;
57
import java.util.Set;
58
import java.util.prefs.AbstractPreferences;
59
import java.util.prefs.BackingStoreException;
60
import java.util.prefs.Preferences;
49
import java.util.prefs.Preferences;
61
import javax.swing.ComboBoxModel;
62
import javax.swing.DefaultComboBoxModel;
63
import javax.swing.JComboBox;
64
import javax.swing.JComponent;
65
import javax.swing.JEditorPane;
66
import javax.swing.JList;
67
import javax.swing.JPanel;
68
import javax.swing.JSpinner;
69
import javax.swing.JTable;
70
import javax.swing.JTextField;
71
import javax.swing.JToggleButton;
72
import javax.swing.event.ChangeEvent;
73
import javax.swing.event.ChangeListener;
74
import javax.swing.event.DocumentEvent;
75
import javax.swing.event.DocumentListener;
76
import javax.swing.event.ListDataEvent;
77
import javax.swing.event.ListDataListener;
78
import javax.swing.event.TableModelEvent;
79
import javax.swing.event.TableModelListener;
80
import org.netbeans.api.editor.settings.SimpleValueNames;
81
import org.netbeans.api.java.source.CodeStyle;
50
import org.netbeans.api.java.source.CodeStyle;
82
import static org.netbeans.api.java.source.CodeStyle.*;
51
import org.netbeans.api.java.source.CodeStyle.BracePlacement;
83
import org.netbeans.modules.java.source.save.Reformatter;
52
import org.netbeans.api.java.source.CodeStyle.BracesGenerationStyle;
84
import org.netbeans.modules.options.editor.spi.PreferencesCustomizer;
53
import org.netbeans.api.java.source.CodeStyle.InsertionPoint;
85
import org.netbeans.modules.options.editor.spi.PreviewProvider;
54
import org.netbeans.api.java.source.CodeStyle.WrapStyle;
86
55
import org.openide.util.lookup.ServiceProvider;
87
import org.openide.text.CloneableEditorSupport;
88
import org.openide.util.HelpCtx;
89
import org.openide.util.NbBundle;
90
56
91
/**
57
/**
92
 *
58
 *
93
 * @author phrebejk
59
 * @author phrebejk
94
 */
60
 */
95
public class FmtOptions {
61
@ServiceProvider(service=FmtConstants.class)
96
62
public class FmtOptions extends FmtConstants {
97
    public static final String expandTabToSpaces = SimpleValueNames.EXPAND_TABS;
98
    public static final String tabSize = SimpleValueNames.TAB_SIZE;
99
    public static final String spacesPerTab = SimpleValueNames.SPACES_PER_TAB;
100
    public static final String indentSize = SimpleValueNames.INDENT_SHIFT_WIDTH;
101
    public static final String continuationIndentSize = "continuationIndentSize"; //NOI18N
102
    public static final String labelIndent = "labelIndent"; //NOI18N
103
    public static final String absoluteLabelIndent = "absoluteLabelIndent"; //NOI18N
104
    public static final String indentTopLevelClassMembers = "indentTopLevelClassMembers"; //NOI18N
105
    public static final String indentCasesFromSwitch = "indentCasesFromSwitch"; //NOI18N
106
    public static final String rightMargin = SimpleValueNames.TEXT_LIMIT_WIDTH;
107
    
108
    public static final String addLeadingStarInComment = "addLeadingStarInComment"; //NOI18N
109
110
    public static final String preferLongerNames = "preferLongerNames"; //NOI18N
111
    public static final String fieldNamePrefix = "fieldNamePrefix"; //NOI18N
112
    public static final String fieldNameSuffix = "fieldNameSuffix"; //NOI18N
113
    public static final String staticFieldNamePrefix = "staticFieldNamePrefix"; //NOI18N
114
    public static final String staticFieldNameSuffix = "staticFieldNameSuffix"; //NOI18N
115
    public static final String parameterNamePrefix = "parameterNamePrefix"; //NOI18N
116
    public static final String parameterNameSuffix = "parameterNameSuffix"; //NOI18N
117
    public static final String localVarNamePrefix = "localVarNamePrefix"; //NOI18N
118
    public static final String localVarNameSuffix = "localVarNameSuffix"; //NOI18N
119
    public static final String qualifyFieldAccess = "qualifyFieldAccess"; //NOI18N
120
    public static final String useIsForBooleanGetters = "useIsForBooleanGetters"; //NOI18N
121
    public static final String addOverrideAnnotation = "addOverrideAnnotation"; //NOI18N
122
    public static final String makeLocalVarsFinal = "makeLocalVarsFinal"; //NOI18N
123
    public static final String makeParametersFinal = "makeParametersFinal"; //NOI18N
124
    public static final String classMembersOrder = "classMembersOrder"; //NOI18N
125
    public static final String sortMembersByVisibility = "sortMembersByVisibility"; //NOI18N
126
    public static final String visibilityOrder = "visibilityOrder"; //NOI18N
127
    public static final String classMemberInsertionPoint = "classMemberInsertionPoint"; //NOI18N
128
    
129
    public static final String classDeclBracePlacement = "classDeclBracePlacement"; //NOI18N
130
    public static final String methodDeclBracePlacement = "methodDeclBracePlacement"; //NOI18N
131
    public static final String otherBracePlacement = "otherBracePlacement"; //NOI18N
132
    public static final String specialElseIf = "specialElseIf"; //NOI18N
133
    public static final String redundantIfBraces = "redundantIfBraces"; //NOI18N
134
    public static final String redundantForBraces = "redundantForBraces"; //NOI18N
135
    public static final String redundantWhileBraces = "redundantWhileBraces"; //NOI18N
136
    public static final String redundantDoWhileBraces = "redundantDoWhileBraces"; //NOI18N
137
    public static final String alignMultilineMethodParams = "alignMultilineMethodParams"; //NOI18N
138
    public static final String alignMultilineCallArgs = "alignMultilineCallArgs"; //NOI18N
139
    public static final String alignMultilineAnnotationArgs = "alignMultilineAnnotationArgs"; //NOI18N
140
    public static final String alignMultilineImplements = "alignMultilineImplements"; //NOI18N
141
    public static final String alignMultilineThrows = "alignMultilineThrows"; //NOI18N
142
    public static final String alignMultilineParenthesized = "alignMultilineParenthesized"; //NOI18N
143
    public static final String alignMultilineBinaryOp = "alignMultilineBinaryOp"; //NOI18N
144
    public static final String alignMultilineTernaryOp = "alignMultilineTernaryOp"; //NOI18N
145
    public static final String alignMultilineAssignment = "alignMultilineAssignment"; //NOI18N
146
    public static final String alignMultilineTryResources = "alignMultilineTryResources"; //NOI18N
147
    public static final String alignMultilineDisjunctiveCatchTypes = "alignMultilineDisjunctiveCatchTypes"; //NOI18N
148
    public static final String alignMultilineFor = "alignMultilineFor"; //NOI18N
149
    public static final String alignMultilineArrayInit = "alignMultilineArrayInit"; //NOI18N
150
    public static final String placeElseOnNewLine = "placeElseOnNewLine"; //NOI18N
151
    public static final String placeWhileOnNewLine = "placeWhileOnNewLine"; //NOI18N
152
    public static final String placeCatchOnNewLine = "placeCatchOnNewLine"; //NOI18N
153
    public static final String placeFinallyOnNewLine = "placeFinallyOnNewLine"; //NOI18N
154
    public static final String placeNewLineAfterModifiers = "placeNewLineAfterModifiers"; //NOI18N
155
    
156
    public static final String wrapExtendsImplementsKeyword = "wrapExtendsImplementsKeyword"; //NOI18N
157
    public static final String wrapExtendsImplementsList = "wrapExtendsImplementsList"; //NOI18N
158
    public static final String wrapMethodParams = "wrapMethodParams"; //NOI18N
159
    public static final String wrapThrowsKeyword = "wrapThrowsKeyword"; //NOI18N
160
    public static final String wrapThrowsList = "wrapThrowsList"; //NOI18N
161
    public static final String wrapMethodCallArgs = "wrapMethodCallArgs"; //NOI18N
162
    public static final String wrapAnnotationArgs = "wrapAnnotationArgs"; //NOI18N
163
    public static final String wrapChainedMethodCalls = "wrapChainedMethodCalls"; //NOI18N
164
    public static final String wrapAfterDotInChainedMethodCalls = "wrapAfterDotInChainedMethodCalls"; //NOI18N
165
    public static final String wrapArrayInit = "wrapArrayInit"; //NOI18N
166
    public static final String wrapTryResources = "wrapTryResources"; //NOI18N
167
    public static final String wrapDisjunctiveCatchTypes = "wrapDisjunctiveCatchTypes"; //NOI18N
168
    public static final String wrapFor = "wrapFor"; //NOI18N
169
    public static final String wrapForStatement = "wrapForStatement"; //NOI18N
170
    public static final String wrapIfStatement = "wrapIfStatement"; //NOI18N
171
    public static final String wrapWhileStatement = "wrapWhileStatement"; //NOI18N
172
    public static final String wrapDoWhileStatement = "wrapDoWhileStatement"; //NOI18N
173
    public static final String wrapAssert = "wrapAssert"; //NOI18N
174
    public static final String wrapEnumConstants = "wrapEnumConstants"; //NOI18N
175
    public static final String wrapAnnotations = "wrapAnnotations"; //NOI18N
176
    public static final String wrapBinaryOps = "wrapBinaryOps"; //NOI18N
177
    public static final String wrapAfterBinaryOps = "wrapAfterBinaryOps"; //NOI18N
178
    public static final String wrapTernaryOps = "wrapTernaryOps"; //NOI18N
179
    public static final String wrapAfterTernaryOps = "wrapAfterTernaryOps"; //NOI18N
180
    public static final String wrapAssignOps = "wrapAssignOps"; //NOI18N
181
    
182
    public static final String blankLinesBeforePackage = "blankLinesBeforePackage"; //NOI18N
183
    public static final String blankLinesAfterPackage = "blankLinesAfterPackage"; //NOI18N
184
    public static final String blankLinesBeforeImports = "blankLinesBeforeImports"; //NOI18N
185
    public static final String blankLinesAfterImports = "blankLinesAfterImports"; //NOI18N
186
    public static final String blankLinesBeforeClass = "blankLinesBeforeClass"; //NOI18N
187
    public static final String blankLinesAfterClass = "blankLinesAfterClass"; //NOI18N
188
    public static final String blankLinesAfterClassHeader = "blankLinesAfterClassHeader"; //NOI18N
189
    public static final String blankLinesAfterAnonymousClassHeader = "blankLinesAfterAnonymousClassHeader"; //NOI18N
190
    public static final String blankLinesBeforeFields = "blankLinesBeforeFields"; //NOI18N
191
    public static final String blankLinesAfterFields = "blankLinesAfterFields"; //NOI18N
192
    public static final String blankLinesBeforeMethods = "blankLinesBeforeMethods"; //NOI18N
193
    public static final String blankLinesAfterMethods = "blankLinesAfterMethods"; //NOI18N
194
    
195
    public static final String spaceBeforeWhile = "spaceBeforeWhile"; //NOI18N
196
    public static final String spaceBeforeElse = "spaceBeforeElse"; //NOI18N
197
    public static final String spaceBeforeCatch = "spaceBeforeCatch"; //NOI18N
198
    public static final String spaceBeforeFinally = "spaceBeforeFinally"; //NOI18N
199
    public static final String spaceBeforeMethodDeclParen = "spaceBeforeMethodDeclParen"; //NOI18N
200
    public static final String spaceBeforeMethodCallParen = "spaceBeforeMethodCallParen"; //NOI18N
201
    public static final String spaceBeforeIfParen = "spaceBeforeIfParen"; //NOI18N
202
    public static final String spaceBeforeForParen = "spaceBeforeForParen"; //NOI18N
203
    public static final String spaceBeforeWhileParen = "spaceBeforeWhileParen"; //NOI18N
204
    public static final String spaceBeforeTryParen = "spaceBeforeTryParen"; //NOI18N
205
    public static final String spaceBeforeCatchParen = "spaceBeforeCatchParen"; //NOI18N
206
    public static final String spaceBeforeSwitchParen = "spaceBeforeSwitchParen"; //NOI18N
207
    public static final String spaceBeforeSynchronizedParen = "spaceBeforeSynchronizedParen"; //NOI18N
208
    public static final String spaceBeforeAnnotationParen = "spaceBeforeAnnotationParen"; //NOI18N    
209
    public static final String spaceAroundUnaryOps = "spaceAroundUnaryOps"; //NOI18N
210
    public static final String spaceAroundBinaryOps = "spaceAroundBinaryOps"; //NOI18N
211
    public static final String spaceAroundTernaryOps = "spaceAroundTernaryOps"; //NOI18N
212
    public static final String spaceAroundAssignOps = "spaceAroundAssignOps"; //NOI18N
213
    public static final String spaceAroundAnnotationValueAssignOps = "spaceAroundAnnotationValueAssignOps"; //NOI18N
214
    public static final String spaceBeforeClassDeclLeftBrace = "spaceBeforeClassDeclLeftBrace"; //NOI18N
215
    public static final String spaceBeforeMethodDeclLeftBrace = "spaceBeforeMethodDeclLeftBrace"; //NOI18N
216
    public static final String spaceBeforeIfLeftBrace = "spaceBeforeIfLeftBrace"; //NOI18N
217
    public static final String spaceBeforeElseLeftBrace = "spaceBeforeElseLeftBrace"; //NOI18N
218
    public static final String spaceBeforeWhileLeftBrace = "spaceBeforeWhileLeftBrace"; //NOI18N
219
    public static final String spaceBeforeForLeftBrace = "spaceBeforeForLeftBrace"; //NOI18N
220
    public static final String spaceBeforeDoLeftBrace = "spaceBeforeDoLeftBrace"; //NOI18N
221
    public static final String spaceBeforeSwitchLeftBrace = "spaceBeforeSwitchLeftBrace"; //NOI18N
222
    public static final String spaceBeforeTryLeftBrace = "spaceBeforeTryLeftBrace"; //NOI18N
223
    public static final String spaceBeforeCatchLeftBrace = "spaceBeforeCatchLeftBrace"; //NOI18N
224
    public static final String spaceBeforeFinallyLeftBrace = "spaceBeforeFinallyLeftBrace"; //NOI18N
225
    public static final String spaceBeforeSynchronizedLeftBrace = "spaceBeforeSynchronizedLeftBrace"; //NOI18N
226
    public static final String spaceBeforeStaticInitLeftBrace = "spaceBeforeStaticInitLeftBrace"; //NOI18N
227
    public static final String spaceBeforeArrayInitLeftBrace = "spaceBeforeArrayInitLeftBrace"; //NOI18N
228
    public static final String spaceWithinParens = "spaceWithinParens"; //NOI18N
229
    public static final String spaceWithinMethodDeclParens = "spaceWithinMethodDeclParens"; //NOI18N
230
    public static final String spaceWithinMethodCallParens = "spaceWithinMethodCallParens"; //NOI18N
231
    public static final String spaceWithinIfParens = "spaceWithinIfParens"; //NOI18N
232
    public static final String spaceWithinForParens = "spaceWithinForParens"; //NOI18N
233
    public static final String spaceWithinWhileParens = "spaceWithinWhileParens"; //NOI18N
234
    public static final String spaceWithinSwitchParens = "spaceWithinSwitchParens"; //NOI18N
235
    public static final String spaceWithinTryParens = "spaceWithinTryParens"; //NOI18N
236
    public static final String spaceWithinCatchParens = "spaceWithinCatchParens"; //NOI18N
237
    public static final String spaceWithinSynchronizedParens = "spaceWithinSynchronizedParens"; //NOI18N
238
    public static final String spaceWithinTypeCastParens = "spaceWithinTypeCastParens"; //NOI18N
239
    public static final String spaceWithinAnnotationParens = "spaceWithinAnnotationParens"; //NOI18N
240
    public static final String spaceWithinBraces = "spaceWithinBraces"; //NOI18N
241
    public static final String spaceWithinArrayInitBrackets = "spaceWithinArrayInitBrackets"; //NOI18N
242
    public static final String spaceBeforeComma = "spaceBeforeComma"; //NOI18N
243
    public static final String spaceAfterComma = "spaceAfterComma"; //NOI18N
244
    public static final String spaceBeforeSemi = "spaceBeforeSemi"; //NOI18N
245
    public static final String spaceAfterSemi = "spaceAfterSemi"; //NOI18N
246
    public static final String spaceBeforeColon = "spaceBeforeColon"; //NOI18N
247
    public static final String spaceAfterColon = "spaceAfterColon"; //NOI18N
248
    public static final String spaceAfterTypeCast = "spaceAfterTypeCast"; //NOI18N
249
    
250
    public static final String useSingleClassImport = "useSingleClassImport"; //NOI18N
251
    public static final String usePackageImport = "usePackageImport"; //NOI18N
252
    public static final String useFQNs = "useFQNs"; //NOI18N
253
    public static final String importInnerClasses = "importInnerClasses"; //NOI18N
254
    public static final String allowConvertToStarImport = "allowConvertToStarImport"; //NOI18N
255
    public static final String countForUsingStarImport = "countForUsingStarImport"; //NOI18N
256
    public static final String allowConvertToStaticStarImport = "allowConvertToStaticStarImport"; //NOI18N
257
    public static final String countForUsingStaticStarImport = "countForUsingStaticStarImport"; //NOI18N
258
    public static final String packagesForStarImport = "packagesForStarImport"; //NOI18N
259
    public static final String separateStaticImports = "separateStaticImports"; //NOI18N
260
    public static final String importGroupsOrder = "importGroupsOrder"; //NOI18N
261
    public static final String separateImportGroups = "separateImportGroups"; //NOI18N
262
    
263
    public static final String enableCommentFormatting = "enableCommentFormatting"; //NOI18N
264
    public static final String enableBlockCommentFormatting = "enableBlockCommentFormatting"; //NOI18N
265
    public static final String wrapCommentText = "wrapCommentText"; //NOI18N
266
    public static final String wrapOneLineComment = "wrapOneLineComment"; //NOI18N
267
    public static final String preserveNewLinesInComments = "preserveNewLinesInComments"; //NOI18N
268
    public static final String blankLineAfterJavadocDescription = "blankLineAfterJavadocDescription"; //NOI18N
269
    public static final String blankLineAfterJavadocParameterDescriptions = "blankLineAfterJavadocParameterDescriptions"; //NOI18N
270
    public static final String blankLineAfterJavadocReturnTag = "blankLineAfterJavadocReturnTag"; //NOI18N
271
    public static final String generateParagraphTagOnBlankLines = "generateParagraphTagOnBlankLines"; //NOI18N
272
    public static final String alignJavadocParameterDescriptions = "alignJavadocParameterDescriptions"; //NOI18N
273
    public static final String alignJavadocReturnDescription = "alignJavadocReturnDescription"; //NOI18N
274
    public static final String alignJavadocExceptionDescriptions = "alignJavadocExceptionDescriptions"; //NOI18N
275
63
276
    public static CodeStyleProducer codeStyleProducer;
64
    public static CodeStyleProducer codeStyleProducer;
277
    
65
    
Lines 283-299 Link Here
283
    
71
    
284
    private static final String JAVA = "text/x-java"; //NOI18N
72
    private static final String JAVA = "text/x-java"; //NOI18N
285
    
73
    
286
    private FmtOptions() {}
74
    public FmtOptions() {}
287
75
288
    public static int getDefaultAsInt(String key) {
76
77
    @Override
78
    protected int defaultAsInt(String key) {
289
        return Integer.parseInt(defaults.get(key));
79
        return Integer.parseInt(defaults.get(key));
290
    }
80
    }
291
    
81
292
    public static boolean getDefaultAsBoolean(String key) {
82
    @Override
83
    protected boolean defaultAsBoolean(String key) {
293
        return Boolean.parseBoolean(defaults.get(key));
84
        return Boolean.parseBoolean(defaults.get(key));
294
    }
85
    }
295
        
86
296
    public static String getDefaultAsString(String key) {
87
    @Override
88
    protected String defaultAsString(String key) {
297
        return defaults.get(key);
89
        return defaults.get(key);
298
    }
90
    }
299
    
91
    
Lines 549-1126 Link Here
549
        }
341
        }
550
342
551
    }
343
    }
552
 
553
    
554
    // Support section ---------------------------------------------------------
555
      
556
    public static class CategorySupport implements ActionListener, ChangeListener, ListDataListener, TableModelListener, DocumentListener, PreviewProvider, PreferencesCustomizer {
557
558
        public static final String OPTION_ID = "org.netbeans.modules.java.ui.FormatingOptions.ID";
559
560
        private static final int LOAD = 0;
561
        private static final int STORE = 1;
562
        private static final int ADD_LISTENERS = 2;
563
        
564
        private static final ComboItem  bracePlacement[] = new ComboItem[] {
565
                new ComboItem( BracePlacement.SAME_LINE.name(), "LBL_bp_SAME_LINE" ), // NOI18N
566
                new ComboItem( BracePlacement.NEW_LINE.name(), "LBL_bp_NEW_LINE" ), // NOI18N
567
                new ComboItem( BracePlacement.NEW_LINE_HALF_INDENTED.name(), "LBL_bp_NEW_LINE_HALF_INDENTED" ), // NOI18N
568
                new ComboItem( BracePlacement.NEW_LINE_INDENTED.name(), "LBL_bp_NEW_LINE_INDENTED" ) // NOI18N
569
            };
570
        private static final ComboItem  bracesGeneration[] = new ComboItem[] {
571
                new ComboItem( BracesGenerationStyle.GENERATE.name(), "LBL_bg_GENERATE" ), // NOI18N
572
                new ComboItem( BracesGenerationStyle.LEAVE_ALONE.name(), "LBL_bg_LEAVE_ALONE" ), // NOI18N
573
                new ComboItem( BracesGenerationStyle.ELIMINATE.name(), "LBL_bg_ELIMINATE" ) // NOI18N       
574
            };
575
        
576
        private static final ComboItem  wrap[] = new ComboItem[] {
577
                new ComboItem( WrapStyle.WRAP_ALWAYS.name(), "LBL_wrp_WRAP_ALWAYS" ), // NOI18N
578
                new ComboItem( WrapStyle.WRAP_IF_LONG.name(), "LBL_wrp_WRAP_IF_LONG" ), // NOI18N
579
                new ComboItem( WrapStyle.WRAP_NEVER.name(), "LBL_wrp_WRAP_NEVER" ) // NOI18N
580
            };
581
        
582
        private static final ComboItem  insertionPoint[] = new ComboItem[] {
583
                new ComboItem( InsertionPoint.LAST_IN_CATEGORY.name(), "LBL_ip_LAST_IN_CATEGORY" ), // NOI18N
584
                new ComboItem( InsertionPoint.FIRST_IN_CATEGORY.name(), "LBL_ip_FIRST_IN_CATEGORY" ), // NOI18N
585
                new ComboItem( InsertionPoint.CARET_LOCATION.name(), "LBL_ip_CARET_LOCATION" ) // NOI18N
586
            };
587
        
588
        protected final String previewText;
589
//        private String forcedOptions[][];
590
        
591
//        private boolean changed = false;
592
//        private boolean loaded = false;
593
        private final String id;
594
        protected final JPanel panel;
595
        private final List<JComponent> components = new LinkedList<JComponent>();                
596
        private JEditorPane previewPane;
597
        
598
        protected final Preferences preferences;
599
        protected final Preferences previewPrefs;
600
    
601
        protected CategorySupport(Preferences preferences, String id, JPanel panel, String previewText, String[]... forcedOptions) {
602
            this.preferences = preferences;
603
            this.id = id;
604
            this.panel = panel;
605
            this.previewText = previewText != null ? previewText : NbBundle.getMessage(FmtOptions.class, "SAMPLE_Default"); //NOI18N
606
607
            // Scan the panel for its components
608
            scan(panel, components);
609
610
            // Initialize the preview preferences
611
            Preferences forcedPrefs = new PreviewPreferences();
612
            for (String[] option : forcedOptions) {
613
                forcedPrefs.put( option[0], option[1]);
614
            }
615
            this.previewPrefs = new ProxyPreferences(forcedPrefs, preferences);
616
617
            // Load and hook up all the components
618
            loadFrom(preferences);
619
            addListeners();
620
        }
621
        
622
        protected void addListeners() {
623
            scan(ADD_LISTENERS, null);
624
        }
625
        
626
        protected void loadFrom(Preferences preferences) {
627
//            loaded = true;
628
            scan(LOAD, preferences);
629
//            loaded = false;
630
        }
631
//
632
//        public void applyChanges() {
633
//            storeTo(preferences);
634
//        }
635
//
636
        protected void storeTo(Preferences p) {
637
            scan(STORE, p);
638
        }
639
        
640
        protected void notifyChanged() {
641
//            if (loaded)
642
//                return;
643
            storeTo(preferences);
644
            refreshPreview();
645
        }
646
        
647
        protected void loadListData(final JList list, final String optionID, final Preferences p) {
648
        }
649
650
        protected void storeListData(final JList list, final String optionID, final Preferences node) {            
651
        }
652
653
        protected void loadTableData(final JTable table, final String optionID, final Preferences p) {
654
        }
655
656
        protected void storeTableData(final JTable table, final String optionID, final Preferences node) {            
657
        }
658
659
        // ActionListener implementation ---------------------------------------
660
        
661
        public void actionPerformed(ActionEvent e) {
662
            notifyChanged();
663
        }
664
        
665
        // ChangeListener implementation ---------------------------------------
666
        
667
        @Override
668
        public void stateChanged(ChangeEvent e) {
669
            notifyChanged();
670
        }
671
        
672
        // ListDataListener implementation -----------------------------------
673
674
        @Override
675
        public void contentsChanged(ListDataEvent e) {
676
        }
677
678
        @Override
679
        public void intervalAdded(ListDataEvent e) {
680
            notifyChanged();
681
        }
682
683
        @Override
684
        public void intervalRemoved(ListDataEvent e) {
685
        }
686
        
687
        // TableModelListener implementation -----------------------------------
688
        
689
        @Override
690
        public void tableChanged(TableModelEvent e) {
691
            notifyChanged();
692
        }
693
694
        // DocumentListener implementation -------------------------------------
695
        
696
        public void insertUpdate(DocumentEvent e) {
697
            notifyChanged();
698
        }
699
700
        public void removeUpdate(DocumentEvent e) {
701
            notifyChanged();
702
        }
703
704
        public void changedUpdate(DocumentEvent e) {
705
            notifyChanged();
706
        }
707
708
        // PreviewProvider methods -----------------------------------------------------
709
        
710
        public JComponent getPreviewComponent() {
711
            if (previewPane == null) {
712
                previewPane = new JEditorPane();
713
                previewPane.getAccessibleContext().setAccessibleName(NbBundle.getMessage(FmtOptions.class, "AN_Preview")); //NOI18N
714
                previewPane.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(FmtOptions.class, "AD_Preview")); //NOI18N
715
                previewPane.putClientProperty("HighlightsLayerIncludes", "^org\\.netbeans\\.modules\\.editor\\.lib2\\.highlighting\\.SyntaxHighlighting$"); //NOI18N
716
                previewPane.setEditorKit(CloneableEditorSupport.getEditorKit("text/x-java"));
717
                previewPane.setEditable(false);
718
            }
719
            return previewPane;
720
        }
721
722
        public void refreshPreview() {
723
            JEditorPane jep = (JEditorPane) getPreviewComponent();
724
            try {
725
                int rm = previewPrefs.getInt(rightMargin, getDefaultAsInt(rightMargin));
726
                jep.putClientProperty("TextLimitLine", rm); //NOI18N
727
                jep.getDocument().putProperty(SimpleValueNames.TEXT_LINE_WRAP, ""); //NOI18N
728
                jep.getDocument().putProperty(SimpleValueNames.TAB_SIZE, ""); //NOI18N
729
                jep.getDocument().putProperty(SimpleValueNames.TEXT_LIMIT_WIDTH, ""); //NOI18N
730
            }
731
            catch( NumberFormatException e ) {
732
                // Ignore it
733
            }
734
            try {
735
                Class.forName(CodeStyle.class.getName(), true, CodeStyle.class.getClassLoader());
736
            } catch (ClassNotFoundException cnfe) {
737
                // ignore
738
            }
739
740
            CodeStyle codeStyle = codeStyleProducer.create(previewPrefs);
741
            jep.setIgnoreRepaint(true);
742
            jep.setText(Reformatter.reformat(previewText, codeStyle));
743
            jep.setIgnoreRepaint(false);
744
            jep.scrollRectToVisible(new Rectangle(0,0,10,10) );
745
            jep.repaint(100);
746
        }
747
748
        // PreferencesCustomizer implementation --------------------------------
749
        
750
        public JComponent getComponent() {
751
            return panel;
752
        }
753
754
        public String getDisplayName() {
755
            return panel.getName();
756
        }
757
758
        public String getId() {
759
            return id;
760
        }
761
        
762
        public HelpCtx getHelpCtx() {
763
            return null;
764
        }
765
766
        // PreferencesCustomizer.Factory implementation ------------------------
767
768
        public static final class Factory implements PreferencesCustomizer.Factory {
769
770
            private final String id;
771
            private final Class<? extends JPanel> panelClass;
772
            private final String previewText;
773
            private final String[][] forcedOptions;
774
775
            public Factory(String id, Class<? extends JPanel> panelClass, String previewText, String[]... forcedOptions) {
776
                this.id = id;
777
                this.panelClass = panelClass;
778
                this.previewText = previewText;
779
                this.forcedOptions = forcedOptions;
780
            }
781
782
            public PreferencesCustomizer create(Preferences preferences) {
783
                try {
784
                    CategorySupport categorySupport = new CategorySupport(preferences, id, panelClass.newInstance(), previewText, forcedOptions);
785
                    if (categorySupport.panel instanceof Runnable)
786
                        ((Runnable)categorySupport.panel).run();
787
                    return categorySupport;
788
                } catch (Exception e) {
789
                    return null;
790
                }
791
            }
792
        } // End of CategorySupport.Factory class
793
        
794
        // Private methods -----------------------------------------------------
795
796
        private void performOperation(int operation, JComponent jc, String optionID, Preferences p) {
797
            switch(operation) {
798
            case LOAD:
799
                loadData(jc, optionID, p);
800
                break;
801
            case STORE:
802
                storeData(jc, optionID, p);
803
                break;
804
            case ADD_LISTENERS:
805
                addListener(jc);
806
                break;
807
            }
808
        }
809
810
        private void scan(int what, Preferences p ) {
811
            for (JComponent jc : components) {
812
                Object o = jc.getClientProperty(OPTION_ID);
813
                if (o instanceof String) {
814
                    performOperation(what, jc, (String)o, p);
815
                } else if (o instanceof String[]) {
816
                    for(String oid : (String[])o) {
817
                        performOperation(what, jc, oid, p);
818
                    }
819
                }
820
            }
821
        }
822
823
        private void scan(Container container, List<JComponent> components) {
824
            for (Component c : container.getComponents()) {
825
                if (c instanceof JComponent) {
826
                    JComponent jc = (JComponent)c;
827
                    Object o = jc.getClientProperty(OPTION_ID);
828
                    if (o instanceof String || o instanceof String[])
829
                        components.add(jc);
830
                }                    
831
                if (c instanceof Container)
832
                    scan((Container)c, components);
833
            }
834
        }
835
836
        /** Very smart method which tries to set the values in the components correctly
837
         */ 
838
        private void loadData( JComponent jc, String optionID, Preferences node ) {
839
            
840
            if ( jc instanceof JTextField ) {
841
                JTextField field = (JTextField)jc;                
842
                field.setText( node.get(optionID, getDefaultAsString(optionID)) );
843
            }
844
            else if ( jc instanceof JSpinner ) {
845
                JSpinner js = (JSpinner)jc;
846
                js.setValue(node.getInt(optionID, getDefaultAsInt(optionID)));
847
            }
848
            else if ( jc instanceof JToggleButton ) {
849
                JToggleButton toggle = (JToggleButton)jc;
850
                boolean df = getDefaultAsBoolean(optionID);
851
                toggle.setSelected( node.getBoolean(optionID, df));                
852
            } 
853
            else if ( jc instanceof JComboBox ) {
854
                JComboBox cb  = (JComboBox)jc;
855
                String value = node.get(optionID, getDefaultAsString(optionID) );
856
                ComboBoxModel model = createModel(value);
857
                cb.setModel(model);
858
                ComboItem item = whichItem(value, model);
859
                cb.setSelectedItem(item);
860
            }
861
            else if ( jc instanceof JList ) {
862
                loadListData((JList)jc, optionID, node);
863
            }
864
            else if ( jc instanceof JTable ) {
865
                loadTableData((JTable)jc, optionID, node);
866
            }
867
        }
868
869
        private void storeData( JComponent jc, String optionID, Preferences node ) {
870
            
871
            if ( jc instanceof JTextField ) {
872
                JTextField field = (JTextField)jc;
873
                
874
                String text = field.getText();
875
                
876
                // XXX test for numbers
877
                if ( isInteger(optionID) ) {
878
                    try {
879
                        int i = Integer.parseInt(text);                        
880
                    } catch (NumberFormatException e) {
881
                        return;
882
                    }
883
                }
884
885
                // XXX: watch out, tabSize, spacesPerTab, indentSize and expandTabToSpaces
886
                // fall back on getGlopalXXX() values and not getDefaultAsXXX value,
887
                // which is why we must not remove them. Proper solution would be to
888
                // store formatting preferences to MimeLookup and not use NbPreferences.
889
                // The problem currently is that MimeLookup based Preferences do not support subnodes.
890
                if (!optionID.equals(tabSize) &&
891
                    !optionID.equals(spacesPerTab) && !optionID.equals(indentSize) &&
892
                    getDefaultAsString(optionID).equals(text)
893
                ) {
894
                    node.remove(optionID);
895
                } else {
896
                    node.put(optionID, text);
897
                }
898
            }
899
            else if ( jc instanceof JSpinner ) {
900
                JSpinner js = (JSpinner)jc;
901
                Object value = js.getValue();
902
                if (getDefaultAsInt(optionID) == ((Integer)value).intValue())
903
                    node.remove(optionID);
904
                else
905
                    node.putInt(optionID, ((Integer)value).intValue());
906
            }
907
            else if ( jc instanceof JToggleButton ) {
908
                JToggleButton toggle = (JToggleButton)jc;
909
                if (!optionID.equals(expandTabToSpaces) && getDefaultAsBoolean(optionID) == toggle.isSelected())
910
                    node.remove(optionID);
911
                else
912
                    node.putBoolean(optionID, toggle.isSelected());
913
            }
914
            else if ( jc instanceof JComboBox ) {
915
                JComboBox cb  = (JComboBox)jc;
916
                // Logger.global.info( cb.getSelectedItem() + " " + optionID);
917
                String value = ((ComboItem) cb.getSelectedItem()).value;
918
                if (getDefaultAsString(optionID).equals(value))
919
                    node.remove(optionID);
920
                else
921
                    node.put(optionID,value);
922
            }
923
            else if ( jc instanceof JList ) {
924
                storeListData((JList)jc, optionID, node);
925
            }
926
            else if ( jc instanceof JTable ) {
927
                storeTableData((JTable)jc, optionID, node);
928
            }
929
        }
930
        
931
        private void addListener( JComponent jc ) {
932
            if ( jc instanceof JTextField ) {
933
                JTextField field = (JTextField)jc;
934
                field.addActionListener(this);
935
                field.getDocument().addDocumentListener(this);
936
            }
937
            else if ( jc instanceof JSpinner ) {
938
                JSpinner spinner = (JSpinner)jc;
939
                spinner.addChangeListener(this);
940
            }
941
            else if ( jc instanceof JToggleButton ) {
942
                JToggleButton toggle = (JToggleButton)jc;
943
                toggle.addActionListener(this);
944
            }
945
            else if ( jc instanceof JComboBox) {
946
                JComboBox cb  = (JComboBox)jc;
947
                cb.addActionListener(this);
948
            }
949
            else if ( jc instanceof JList) {
950
                JList jl = (JList)jc;
951
                jl.getModel().addListDataListener(this);
952
            }
953
            else if ( jc instanceof JTable) {
954
                JTable jt = (JTable)jc;
955
                jt.getModel().addTableModelListener(this);
956
            }
957
        }
958
        
959
            
960
        private ComboBoxModel createModel( String value ) {
961
            
962
            // is it braces placement?            
963
            for (ComboItem comboItem : bracePlacement) {
964
                if ( value.equals( comboItem.value) ) {
965
                    return new DefaultComboBoxModel( bracePlacement );
966
                }
967
            }
968
            
969
            // is it braces generation?
970
            for (ComboItem comboItem : bracesGeneration) {
971
                if ( value.equals( comboItem.value) ) {
972
                    return new DefaultComboBoxModel( bracesGeneration );
973
                }
974
            }
975
            
976
            // is it wrap?
977
            for (ComboItem comboItem : wrap) {
978
                if ( value.equals( comboItem.value) ) {
979
                    return new DefaultComboBoxModel( wrap );
980
                }
981
            }
982
            
983
            // is it insertion point?
984
            for (ComboItem comboItem : insertionPoint) {
985
                if ( value.equals( comboItem.value) ) {
986
                    return new DefaultComboBoxModel( insertionPoint );
987
                }
988
            }
989
            
990
            return null;
991
        }
992
        
993
        private static ComboItem whichItem(String value, ComboBoxModel model) {
994
            
995
            for (int i = 0; i < model.getSize(); i++) {
996
                ComboItem item = (ComboItem)model.getElementAt(i);
997
                if ( value.equals(item.value)) {
998
                    return item;
999
                }
1000
            }    
1001
            return null;
1002
        }
1003
        
1004
        private static class ComboItem {
1005
            
1006
            String value;
1007
            String displayName;
1008
1009
            public ComboItem(String value, String key) {
1010
                this.value = value;
1011
                this.displayName = NbBundle.getMessage(FmtOptions.class, key);
1012
            }
1013
1014
            @Override
1015
            public String toString() {
1016
                return displayName;
1017
            }
1018
            
1019
        }
1020
    }
1021
   
1022
    public static class PreviewPreferences extends AbstractPreferences {
1023
        
1024
        private Map<String,Object> map = new HashMap<String, Object>();
1025
1026
        public PreviewPreferences() {
1027
            super(null, ""); // NOI18N
1028
        }
1029
        
1030
        protected void putSpi(String key, String value) {
1031
            map.put(key, value);            
1032
        }
1033
1034
        protected String getSpi(String key) {
1035
            return (String)map.get(key);                    
1036
        }
1037
1038
        protected void removeSpi(String key) {
1039
            map.remove(key);
1040
        }
1041
1042
        protected void removeNodeSpi() throws BackingStoreException {
1043
            throw new UnsupportedOperationException("Not supported yet.");
1044
        }
1045
1046
        protected String[] keysSpi() throws BackingStoreException {
1047
            String array[] = new String[map.keySet().size()];
1048
            return map.keySet().toArray( array );
1049
        }
1050
1051
        protected String[] childrenNamesSpi() throws BackingStoreException {
1052
            throw new UnsupportedOperationException("Not supported yet.");
1053
        }
1054
1055
        protected AbstractPreferences childSpi(String name) {
1056
            throw new UnsupportedOperationException("Not supported yet.");
1057
        }
1058
1059
        protected void syncSpi() throws BackingStoreException {
1060
            throw new UnsupportedOperationException("Not supported yet.");
1061
        }
1062
1063
        protected void flushSpi() throws BackingStoreException {
1064
            throw new UnsupportedOperationException("Not supported yet.");
1065
        }
1066
    }
1067
1068
    // read-only, no subnodes
1069
    public static final class ProxyPreferences extends AbstractPreferences {
1070
        
1071
        private final Preferences[] delegates;
1072
1073
        public ProxyPreferences(Preferences... delegates) {
1074
            super(null, ""); // NOI18N
1075
            this.delegates = delegates;
1076
        }
1077
        
1078
        protected void putSpi(String key, String value) {
1079
            throw new UnsupportedOperationException("Not supported yet.");
1080
        }
1081
1082
        protected String getSpi(String key) {
1083
            for(Preferences p : delegates) {
1084
                String value = p.get(key, null);
1085
                if (value != null) {
1086
                    return value;
1087
                }
1088
            }
1089
            return null;
1090
        }
1091
1092
        protected void removeSpi(String key) {
1093
            throw new UnsupportedOperationException("Not supported yet.");
1094
        }
1095
1096
        protected void removeNodeSpi() throws BackingStoreException {
1097
            throw new UnsupportedOperationException("Not supported yet.");
1098
        }
1099
1100
        protected String[] keysSpi() throws BackingStoreException {
1101
            Set<String> keys = new HashSet<String>();
1102
            for(Preferences p : delegates) {
1103
                keys.addAll(Arrays.asList(p.keys()));
1104
            }
1105
            return keys.toArray(new String[ keys.size() ]);
1106
        }
1107
1108
        protected String[] childrenNamesSpi() throws BackingStoreException {
1109
            throw new UnsupportedOperationException("Not supported yet.");
1110
        }
1111
1112
        protected AbstractPreferences childSpi(String name) {
1113
            throw new UnsupportedOperationException("Not supported yet.");
1114
        }
1115
1116
        protected void syncSpi() throws BackingStoreException {
1117
            throw new UnsupportedOperationException("Not supported yet.");
1118
        }
1119
1120
        protected void flushSpi() throws BackingStoreException {
1121
            throw new UnsupportedOperationException("Not supported yet.");
1122
        }
1123
    } // End of ProxyPreferences class
1124
    
344
    
1125
    public static interface CodeStyleProducer {
345
    public static interface CodeStyleProducer {
1126
        
346
        
(-)a/java.source/src/org/netbeans/modules/java/ui/Icons.java (-1 / +1 lines)
Lines 42-48 Link Here
42
 * made subject to such option by the copyright holder.
42
 * made subject to such option by the copyright holder.
43
 */
43
 */
44
44
45
package org.netbeans.modules.java.ui;
45
package org.netbeans.modules.java.uisupport;
46
46
47
import java.awt.Image;
47
import java.awt.Image;
48
import java.util.Collection;
48
import java.util.Collection;
(-)a/java.source/src/org/netbeans/modules/java/ui/LazyListModel.java (-1 / +1 lines)
Lines 42-48 Link Here
42
 * made subject to such option by the copyright holder.
42
 * made subject to such option by the copyright holder.
43
 */
43
 */
44
44
45
package org.netbeans.modules.java.ui;
45
package org.netbeans.modules.java.uisupport;
46
46
47
import java.util.BitSet;
47
import java.util.BitSet;
48
import javax.swing.*;
48
import javax.swing.*;
(-)a/java.source/src/org/netbeans/modules/java/ui/Renderers.java (-1 / +1 lines)
Lines 42-48 Link Here
42
 * made subject to such option by the copyright holder.
42
 * made subject to such option by the copyright holder.
43
 */
43
 */
44
44
45
package org.netbeans.modules.java.ui;
45
package org.netbeans.modules.java.uisupport;
46
46
47
import java.awt.Component;
47
import java.awt.Component;
48
import javax.lang.model.element.TypeElement;
48
import javax.lang.model.element.TypeElement;
(-)a/java.source/test/unit/src/org/netbeans/api/java/source/gen/AnnotationTest.java (-1 / +1 lines)
Lines 71-77 Link Here
71
import org.netbeans.api.java.source.WorkingCopy;
71
import org.netbeans.api.java.source.WorkingCopy;
72
import org.netbeans.junit.NbTestSuite;
72
import org.netbeans.junit.NbTestSuite;
73
import org.netbeans.modules.java.source.save.Reformatter;
73
import org.netbeans.modules.java.source.save.Reformatter;
74
import org.netbeans.modules.java.ui.FmtOptions;
74
import org.netbeans.modules.java.uisupport.FmtOptions;
75
import org.openide.filesystems.FileUtil;
75
import org.openide.filesystems.FileUtil;
76
import org.openide.util.Exceptions;
76
import org.openide.util.Exceptions;
77
77
(-)a/java.source/test/unit/src/org/netbeans/api/java/source/gen/MoveTreeTest.java (-1 / +1 lines)
Lines 70-76 Link Here
70
import org.netbeans.api.java.source.TreeMaker;
70
import org.netbeans.api.java.source.TreeMaker;
71
import org.netbeans.api.java.source.WorkingCopy;
71
import org.netbeans.api.java.source.WorkingCopy;
72
import org.netbeans.junit.NbTestSuite;
72
import org.netbeans.junit.NbTestSuite;
73
import org.netbeans.modules.java.ui.FmtOptions;
73
import org.netbeans.modules.java.uisupport.FmtOptions;
74
74
75
/**
75
/**
76
 * Tests method type parameters changes.
76
 * Tests method type parameters changes.
(-)a/java.source/test/unit/src/org/netbeans/api/java/source/gen/OperatorsTest.java (-1 / +1 lines)
Lines 54-60 Link Here
54
import org.netbeans.junit.NbTestSuite;
54
import org.netbeans.junit.NbTestSuite;
55
import org.netbeans.modules.editor.indent.spi.CodeStylePreferences;
55
import org.netbeans.modules.editor.indent.spi.CodeStylePreferences;
56
import org.netbeans.modules.java.source.parsing.JavacParser;
56
import org.netbeans.modules.java.source.parsing.JavacParser;
57
import org.netbeans.modules.java.ui.FmtOptions;
57
import org.netbeans.modules.java.uisupport.FmtOptions;
58
import org.openide.filesystems.FileObject;
58
import org.openide.filesystems.FileObject;
59
import org.openide.filesystems.FileUtil;
59
import org.openide.filesystems.FileUtil;
60
60
(-)a/java.source/test/unit/src/org/netbeans/api/java/source/gen/RefactoringRegressionsTest.java (-1 / +1 lines)
Lines 59-65 Link Here
59
import javax.lang.model.type.TypeKind;
59
import javax.lang.model.type.TypeKind;
60
import org.netbeans.api.java.source.*;
60
import org.netbeans.api.java.source.*;
61
import org.netbeans.junit.NbTestSuite;
61
import org.netbeans.junit.NbTestSuite;
62
import org.netbeans.modules.java.ui.FmtOptions;
62
import org.netbeans.modules.java.uisupport.FmtOptions;
63
import static org.netbeans.api.java.source.JavaSource.*;
63
import static org.netbeans.api.java.source.JavaSource.*;
64
64
65
/**
65
/**
(-)a/java.source/test/unit/src/org/netbeans/api/java/source/gen/TryTest.java (-1 / +1 lines)
Lines 65-71 Link Here
65
import org.netbeans.api.java.source.TreeMaker;
65
import org.netbeans.api.java.source.TreeMaker;
66
import org.netbeans.api.java.source.WorkingCopy;
66
import org.netbeans.api.java.source.WorkingCopy;
67
import org.netbeans.junit.NbTestSuite;
67
import org.netbeans.junit.NbTestSuite;
68
import org.netbeans.modules.java.ui.FmtOptions;
68
import org.netbeans.modules.java.uisupport.FmtOptions;
69
import org.openide.filesystems.FileUtil;
69
import org.openide.filesystems.FileUtil;
70
70
71
/**
71
/**
(-)a/nbjunit/src/org/netbeans/junit/NbModuleSuite.java (-1 / +42 lines)
Lines 237-242 Link Here
237
            }
237
            }
238
            arr.add(clusterRegExp);
238
            arr.add(clusterRegExp);
239
            arr.add(moduleRegExp);
239
            arr.add(moduleRegExp);
240
            arr.add("enabled"); // NOI18N
241
            return new Configuration(
242
                this.clusterRegExp, arr, startupArgs, parentClassLoader,
243
                tests, latestTestCaseClass, reuseUserDir, gui,
244
                enableClasspathModules, honorAutoEager, failOnMessage, 
245
                failOnException, hideExtraModules);
246
        }
247
248
        public Configuration autoloadModules(String clusterRegExp, String moduleRegExp) {
249
            List<String> arr = new ArrayList<String>();
250
            if (this.moduleRegExp != null) {
251
                arr.addAll(this.moduleRegExp);
252
            }
253
            arr.add(clusterRegExp);
254
            arr.add(moduleRegExp);
255
            arr.add("autoload"); // NOI18N
240
            return new Configuration(
256
            return new Configuration(
241
                this.clusterRegExp, arr, startupArgs, parentClassLoader,
257
                this.clusterRegExp, arr, startupArgs, parentClassLoader,
242
                tests, latestTestCaseClass, reuseUserDir, gui,
258
                tests, latestTestCaseClass, reuseUserDir, gui,
Lines 1344-1349 Link Here
1344
                }
1360
                }
1345
                String clusterReg = it.next();
1361
                String clusterReg = it.next();
1346
                String moduleReg = it.next();
1362
                String moduleReg = it.next();
1363
                String state = it.next();
1347
                Pattern modPattern = Pattern.compile(moduleReg);
1364
                Pattern modPattern = Pattern.compile(moduleReg);
1348
                for (File c : clusterDirs) {
1365
                for (File c : clusterDirs) {
1349
                    if (!c.getName().matches(clusterReg)) {
1366
                    if (!c.getName().matches(clusterReg)) {
Lines 1371-1377 Link Here
1371
                        if (!contains) {
1388
                        if (!contains) {
1372
                            continue;
1389
                            continue;
1373
                        }
1390
                        }
1374
                        enableModule(xml, autoloads, contains, new File(config, m.getName()));
1391
                        if (state.equals("enabled")) {
1392
                            enableModule(xml, autoloads, contains, new File(config, m.getName()));
1393
                        } else {
1394
                            assert state.equals("autoload");
1395
                            autoloadModule(xml, autoloads, contains, new File(config, m.getName()));
1396
                        }
1375
                    }
1397
                    }
1376
                }
1398
                }
1377
            }
1399
            }
Lines 1423-1428 Link Here
1423
                }
1445
                }
1424
            }
1446
            }
1425
        }
1447
        }
1448
        
1449
        private static void autoloadModule(String xml, boolean autoloads, boolean enable, File target) throws IOException {
1450
            boolean toEnable = false;
1451
            Matcher matcherAuto = AUTO.matcher(xml);
1452
            if (matcherAuto.find()) {
1453
                if ("true".equals(matcherAuto.group(1))) {
1454
                    return;
1455
                }
1456
            }
1457
            int begin = xml.indexOf("<param name=\"autoload");
1458
            int end = xml.indexOf("<param name=\"jar");
1459
            String middle = "<param name=\"autoload\">true</param>\n" + "    <param name=\"eager\">false</param>\n" + "    ";
1460
            String out = xml.substring(0, begin) + middle + xml.substring(end);
1461
            try {
1462
                writeModule(target, out);
1463
            } catch (IllegalStateException ex) {
1464
                throw new IOException("Unparsable:\n" + xml, ex);
1465
            }
1466
        }
1426
1467
1427
        private static void writeModule(File file, String xml) throws IOException {
1468
        private static void writeModule(File file, String xml) throws IOException {
1428
            String previous;
1469
            String previous;

Return to bug 217633