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

(-)a/apisupport.refactoring/src/org/netbeans/modules/apisupport/hints/UseNbBundleMessages.java (-4 / +16 lines)
Lines 87-95 Link Here
87
import com.sun.source.tree.NewArrayTree;
87
import com.sun.source.tree.NewArrayTree;
88
import com.sun.source.tree.Tree;
88
import com.sun.source.tree.Tree;
89
import com.sun.source.tree.Tree.Kind;
89
import com.sun.source.tree.Tree.Kind;
90
import com.sun.source.tree.VariableTree;
90
import com.sun.source.util.SourcePositions;
91
import com.sun.source.util.SourcePositions;
91
import com.sun.source.util.TreePath;
92
import com.sun.source.util.TreePath;
92
import org.netbeans.api.actions.Savable;
93
import org.netbeans.api.actions.Savable;
94
import org.netbeans.api.java.source.TreeUtilities;
93
95
94
public class UseNbBundleMessages extends AbstractHint {
96
public class UseNbBundleMessages extends AbstractHint {
95
97
Lines 264-274 Link Here
264
                        if (!isAlreadyRegistered) {
266
                        if (!isAlreadyRegistered) {
265
                            Tree enclosing = findEnclosingElement(wc, treePath);
267
                            Tree enclosing = findEnclosingElement(wc, treePath);
266
                            Tree modifiers;
268
                            Tree modifiers;
267
                            if (enclosing.getKind() == Kind.METHOD) {
269
                            switch (enclosing.getKind()) {
270
                            case METHOD:
268
                                modifiers = ((MethodTree) enclosing).getModifiers();
271
                                modifiers = ((MethodTree) enclosing).getModifiers();
269
                            } else if (enclosing.getKind() == Kind.COMPILATION_UNIT) {
272
                                break;
273
                            case VARIABLE:
274
                                modifiers = ((VariableTree) enclosing).getModifiers();
275
                                break;
276
                            case COMPILATION_UNIT:
270
                                modifiers = enclosing;
277
                                modifiers = enclosing;
271
                            } else {
278
                                break;
279
                            default:
272
                                modifiers = ((ClassTree) enclosing).getModifiers();
280
                                modifiers = ((ClassTree) enclosing).getModifiers();
273
                            }
281
                            }
274
                            List<ExpressionTree> lines = new ArrayList<ExpressionTree>();
282
                            List<ExpressionTree> lines = new ArrayList<ExpressionTree>();
Lines 354-362 Link Here
354
                        case INTERFACE:
362
                        case INTERFACE:
355
                        case ANNOTATION_TYPE:
363
                        case ANNOTATION_TYPE:
356
                        case METHOD: // (or constructor)
364
                        case METHOD: // (or constructor)
365
                        case VARIABLE:
357
                            Element e = wc.getTrees().getElement(treePath);
366
                            Element e = wc.getTrees().getElement(treePath);
358
                            if (e != null) {
367
                            if (e != null) {
359
                                TypeElement type = kind == Kind.METHOD ? wc.getElementUtilities().enclosingTypeElement(e) : (TypeElement) e;
368
                                TypeElement type = TreeUtilities.CLASS_TREE_KINDS.contains(kind) ? (TypeElement) e : wc.getElementUtilities().enclosingTypeElement(e);
360
                                if (type == null || !wc.getElementUtilities().isLocal(type)) {
369
                                if (type == null || !wc.getElementUtilities().isLocal(type)) {
361
                                    return leaf;
370
                                    return leaf;
362
                                } // else part of an inner class
371
                                } // else part of an inner class
Lines 420-425 Link Here
420
        case METHOD:
429
        case METHOD:
421
            modifiers = ((MethodTree) tree).getModifiers();
430
            modifiers = ((MethodTree) tree).getModifiers();
422
            break;
431
            break;
432
        case VARIABLE:
433
            modifiers = ((VariableTree) tree).getModifiers();
434
            break;
423
        case CLASS:
435
        case CLASS:
424
        case ENUM:
436
        case ENUM:
425
        case INTERFACE:
437
        case INTERFACE:
(-)a/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardPanelVisual.java (-1 / +1 lines)
Lines 68-78 Link Here
68
 *
68
 *
69
 * @author mkleint
69
 * @author mkleint
70
 */
70
 */
71
@Messages("NbmWizardPanelVisual.wait=Searching...")
72
public class NbmWizardPanelVisual extends javax.swing.JPanel {
71
public class NbmWizardPanelVisual extends javax.swing.JPanel {
73
72
74
    private static final RequestProcessor RP = new RequestProcessor(NbmWizardPanelVisual.class);
73
    private static final RequestProcessor RP = new RequestProcessor(NbmWizardPanelVisual.class);
75
74
75
    @Messages("NbmWizardPanelVisual.wait=Searching...")
76
    private static final String SEARCHING = NbmWizardPanelVisual_wait();
76
    private static final String SEARCHING = NbmWizardPanelVisual_wait();
77
    private final NbmWizardPanel panel;
77
    private final NbmWizardPanel panel;
78
    private ValidationGroup vg = ValidationGroup.create();
78
    private ValidationGroup vg = ValidationGroup.create();
(-)a/maven/src/org/netbeans/modules/maven/nodes/MavenProjectNode.java (-1 / +1 lines)
Lines 73-81 Link Here
73
 *
73
 *
74
 * @author Milos Kleint
74
 * @author Milos Kleint
75
 */
75
 */
76
@Messages("ICON_BrokenProjectBadge=Project loading failed or was not complete")
77
public class MavenProjectNode extends AbstractNode {
76
public class MavenProjectNode extends AbstractNode {
78
    static final String BADGE_ICON = "org/netbeans/modules/maven/brokenProjectBadge.png";//NOI18N
77
    static final String BADGE_ICON = "org/netbeans/modules/maven/brokenProjectBadge.png";//NOI18N
78
    @Messages("ICON_BrokenProjectBadge=Project loading failed or was not complete")
79
    private static final String toolTipBroken = "<img src=\"" + MavenProjectNode.class.getClassLoader().getResource(BADGE_ICON) + "\">&nbsp;" + ICON_BrokenProjectBadge();
79
    private static final String toolTipBroken = "<img src=\"" + MavenProjectNode.class.getClassLoader().getResource(BADGE_ICON) + "\">&nbsp;" + ICON_BrokenProjectBadge();
80
80
81
     private NbMavenProjectImpl project;
81
     private NbMavenProjectImpl project;
(-)a/openide.util/apichanges.xml (+24 lines)
Lines 51-56 Link Here
51
    <apidef name="actions">Actions API</apidef>
51
    <apidef name="actions">Actions API</apidef>
52
</apidefs>
52
</apidefs>
53
<changes>
53
<changes>
54
    <change id="Messages.fields">
55
        <api name="util"/>
56
        <summary><code>@NbBundle.Messages</code> available on fields</summary>
57
        <version major="8" minor="22"/>
58
        <date year="2012" month="1" day="3"/>
59
        <author login="jglick"/>
60
        <compatibility addition="yes">
61
            <p>
62
                Existing annotations made on classes but only used from a field
63
                within that class will continue to work, but for clarity should
64
                be moved onto the field.
65
            </p>
66
        </compatibility>
67
        <description>
68
            <p>
69
                <code>@NbBundle.Messages</code> may now be used on fields, useful
70
                in case the field initializer involves some complex construction
71
                requiring a localized message. (Merely storing a localized message
72
                in a String constant is poor practice; inline the field instead.)
73
            </p>
74
        </description>
75
        <class package="org.openide.util" name="NbBundle"/>
76
        <issue number="206543"/>
77
    </change>
54
    <change id="HelpCtx.display">
78
    <change id="HelpCtx.display">
55
        <api name="util"/>
79
        <api name="util"/>
56
        <summary><code>HelpCtx.display</code> added</summary>
80
        <summary><code>HelpCtx.display</code> added</summary>
(-)a/openide.util/manifest.mf (-1 / +1 lines)
Lines 1-5 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.openide.util
2
OpenIDE-Module: org.openide.util
3
OpenIDE-Module-Localizing-Bundle: org/openide/util/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/openide/util/Bundle.properties
4
OpenIDE-Module-Specification-Version: 8.21
4
OpenIDE-Module-Specification-Version: 8.22
5
5
(-)a/openide.util/src/org/openide/util/NbBundle.java (-2 / +2 lines)
Lines 820-829 Link Here
820
     * # {0} - file path
820
     * # {0} - file path
821
     * dialog.message=The file {0} was invalid.
821
     * dialog.message=The file {0} was invalid.
822
     * </pre>
822
     * </pre>
823
     * @since org.openide.util 8.10
823
     * @since org.openide.util 8.10 (available also on fields since 8.22)
824
     */
824
     */
825
    @Retention(RetentionPolicy.SOURCE)
825
    @Retention(RetentionPolicy.SOURCE)
826
    @Target({ElementType.PACKAGE, ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR})
826
    @Target({ElementType.PACKAGE, ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.FIELD})
827
    public @interface Messages {
827
    public @interface Messages {
828
        /**
828
        /**
829
         * List of key/value pairs.
829
         * List of key/value pairs.
(-)a/openide.util/test/unit/src/org/netbeans/modules/openide/util/NbBundleProcessorTest.java (+11 lines)
Lines 96-101 Link Here
96
        assertEquals("&Build 2 Projects", LBL_BuildMainProjectAction_Name(2, "whatever"));
96
        assertEquals("&Build 2 Projects", LBL_BuildMainProjectAction_Name(2, "whatever"));
97
    }
97
    }
98
98
99
    public void testFieldUsage() throws Exception {
100
        AnnotationProcessorTestUtils.makeSource(src, "p.C",
101
                "public class C {",
102
                "@org.openide.util.NbBundle.Messages(\"k=v\")",
103
                "public static final Object X = new Object() {public String toString() {return Bundle.k();}};",
104
                "}");
105
        assertTrue(AnnotationProcessorTestUtils.runJavac(src, null, dest, null, null));
106
        ClassLoader l = new URLClassLoader(new URL[] {dest.toURI().toURL()});
107
        assertEquals("v", l.loadClass("p.C").getField("X").get(null).toString());
108
    }
109
99
    @Messages({
110
    @Messages({
100
        "s1=Don't worry",
111
        "s1=Don't worry",
101
        "s2=Don''t worry about {0}",
112
        "s2=Don''t worry about {0}",
(-)a/projectui/src/org/netbeans/modules/project/ui/groups/GroupOptionProcessor.java (-6 / +6 lines)
Lines 56-79 Link Here
56
import org.openide.util.lookup.ServiceProvider;
56
import org.openide.util.lookup.ServiceProvider;
57
57
58
@ServiceProvider(service=OptionProcessor.class)
58
@ServiceProvider(service=OptionProcessor.class)
59
@Messages({
60
    "GroupOptionProcessor.open.name=--open-group NAME",
61
    "GroupOptionProcessor.open.desc=open a project group by name",
62
    "GroupOptionProcessor.close.desc=close any open project group",
63
    "GroupOptionProcessor.list.desc=list available project groups"
64
})
65
public class GroupOptionProcessor extends OptionProcessor {
59
public class GroupOptionProcessor extends OptionProcessor {
66
60
61
    @Messages({
62
        "GroupOptionProcessor.open.name=--open-group NAME",
63
        "GroupOptionProcessor.open.desc=open a project group by name",
64
    })
67
    private static final Option OPEN_OPTION =
65
    private static final Option OPEN_OPTION =
68
            Option.shortDescription(
66
            Option.shortDescription(
69
            Option.displayName(
67
            Option.displayName(
70
            Option.requiredArgument(Option.NO_SHORT_NAME, "open-group"),
68
            Option.requiredArgument(Option.NO_SHORT_NAME, "open-group"),
71
            Bundle.class.getName(), "GroupOptionProcessor.open.name"),
69
            Bundle.class.getName(), "GroupOptionProcessor.open.name"),
72
            Bundle.class.getName(), "GroupOptionProcessor.open.desc");
70
            Bundle.class.getName(), "GroupOptionProcessor.open.desc");
71
    @Messages("GroupOptionProcessor.close.desc=close any open project group")
73
    private static final Option CLOSE_OPTION =
72
    private static final Option CLOSE_OPTION =
74
            Option.shortDescription(
73
            Option.shortDescription(
75
            Option.withoutArgument(Option.NO_SHORT_NAME, "close-group"),
74
            Option.withoutArgument(Option.NO_SHORT_NAME, "close-group"),
76
            Bundle.class.getName(), "GroupOptionProcessor.close.desc");
75
            Bundle.class.getName(), "GroupOptionProcessor.close.desc");
76
    @Messages("GroupOptionProcessor.list.desc=list available project groups")
77
    private static final Option LIST_OPTION =
77
    private static final Option LIST_OPTION =
78
            Option.shortDescription(
78
            Option.shortDescription(
79
            Option.withoutArgument(Option.NO_SHORT_NAME, "list-groups"),
79
            Option.withoutArgument(Option.NO_SHORT_NAME, "list-groups"),

Return to bug 206543