# HG changeset patch # Parent eec381a17245c703727aa1f5b67e70d0673e4030 Sample usage of @NbBundle.Messages. diff --git a/hudson/src/org/netbeans/modules/hudson/ui/actions/Bundle.properties b/hudson/src/org/netbeans/modules/hudson/ui/actions/Bundle.properties --- a/hudson/src/org/netbeans/modules/hudson/ui/actions/Bundle.properties +++ b/hudson/src/org/netbeans/modules/hudson/ui/actions/Bundle.properties @@ -55,27 +55,16 @@ LBL_SynchronizeAction=&Synchronize -CTL_CreateJob=Create Build Job... CreateJobPanel.projectLabel.text=&Project to Build: CreateJobPanel.nameLabel.text=Build &Name: CreateJobPanel.browse.text=&Browse... CreateJobPanel.serverLabel.text=Build &Server: CreateJobPanel.addServer.text=&Add... CreateJobPanel.explanationLabel.text=Build Server will automatically get the sources and libraries from the same\n
source code repository and run the same build targets as your local project. -CreateJob.new_build=New Build... -CreateJob.title=New Continuous Build -CreateJob.create=Create -CreateJob.failure=Could not create job. Please check your server's log for details. ShowChanges.label=Show Changes ShowChanges.no_changes=No changes. # {0} - job #build ShowChanges.title={0} changes -ShowFailures.label=Show Test Failures -# {0} - job #build -ShowFailures.title={0} Test Failures -# {0} - class & method name of failed test -# {1} - suite name of failed test -ShowFailures.from_suite={0} (from {1}) # {0} - file path in workspace Hyperlinker.looking_for=Looking for {0}... # {0} - file path in workspace diff --git a/hudson/src/org/netbeans/modules/hudson/ui/actions/CreateJob.java b/hudson/src/org/netbeans/modules/hudson/ui/actions/CreateJob.java --- a/hudson/src/org/netbeans/modules/hudson/ui/actions/CreateJob.java +++ b/hudson/src/org/netbeans/modules/hudson/ui/actions/CreateJob.java @@ -74,7 +74,8 @@ import org.openide.awt.ActionRegistration; import org.openide.awt.HtmlBrowser.URLDisplayer; import org.openide.util.Exceptions; -import org.openide.util.NbBundle; +import org.openide.util.NbBundle.Messages; +import static org.netbeans.modules.hudson.ui.actions.Bundle.*; import org.openide.util.RequestProcessor; import org.openide.xml.XMLUtil; import org.w3c.dom.Document; @@ -85,25 +86,31 @@ @ActionID(category="Team", id="org.netbeans.modules.hudson.ui.actions.CreateJob") @ActionRegistration(displayName="#CTL_CreateJob", iconInMenu=false) @ActionReference(path="Menu/Versioning", position=400) +@Messages("CTL_CreateJob=Create Build Job...") public class CreateJob extends AbstractAction { private final HudsonInstance instance; public CreateJob() { - super(NbBundle.getMessage(CreateJob.class, "CTL_CreateJob")); + super(CTL_CreateJob()); this.instance = null; } + @Messages("CreateJob.new_build=New Build...") public CreateJob(HudsonInstance instance) { - super(NbBundle.getMessage(CreateJob.class, "CreateJob.new_build")); + super(CreateJob_new_build()); this.instance = instance; } + @Messages({ + "CreateJob.title=New Continuous Build", + "CreateJob.create=Create" + }) public void actionPerformed(ActionEvent e) { final CreateJobPanel panel = new CreateJobPanel(); - final DialogDescriptor dd = new DialogDescriptor(panel, NbBundle.getMessage(CreateJob.class, "CreateJob.title")); + final DialogDescriptor dd = new DialogDescriptor(panel, CreateJob_title()); final AtomicReference dialog = new AtomicReference(); - final JButton createButton = new JButton(NbBundle.getMessage(CreateJob.class, "CreateJob.create")); + final JButton createButton = new JButton(CreateJob_create()); createButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { RequestProcessor.getDefault().post(new Runnable() { @@ -135,6 +142,7 @@ dialog.get().setVisible(true); } + @Messages("CreateJob.failure=Could not create job. Please check your server's log for details.") private void finalizeJob(HudsonInstance instance, ProjectHudsonJobCreator creator, String name, Project project) { try { Document doc = creator.configure(); @@ -152,7 +160,7 @@ OpenProjects.getDefault().open(new Project[] {project}, false); UI.selectNode(instance.getUrl(), name); } catch (IOException x) { - Exceptions.attachLocalizedMessage(x, NbBundle.getMessage(CreateJob.class, "CreateJob.failure")); + Exceptions.attachLocalizedMessage(x, CreateJob_failure()); Logger.getLogger(CreateJob.class.getName()).log(Level.WARNING, null, x); } } diff --git a/hudson/src/org/netbeans/modules/hudson/ui/actions/ShowFailures.java b/hudson/src/org/netbeans/modules/hudson/ui/actions/ShowFailures.java --- a/hudson/src/org/netbeans/modules/hudson/ui/actions/ShowFailures.java +++ b/hudson/src/org/netbeans/modules/hudson/ui/actions/ShowFailures.java @@ -60,7 +60,8 @@ import org.netbeans.modules.hudson.api.HudsonJobBuild; import org.netbeans.modules.hudson.api.HudsonMavenModuleBuild; import org.openide.awt.HtmlBrowser.URLDisplayer; -import org.openide.util.NbBundle; +import org.openide.util.NbBundle.Messages; +import static org.netbeans.modules.hudson.ui.actions.Bundle.*; import org.openide.util.RequestProcessor; import org.openide.windows.IOProvider; import org.openide.windows.InputOutput; @@ -93,17 +94,20 @@ this(module.getBuild().getJob(), module.getUrl(), module.getBuildDisplayName()); } + @Messages("ShowFailures.label=Show Test Failures") private ShowFailures(HudsonJob job, String url, String displayName) { this.job = job; this.url = url; this.displayName = displayName; - putValue(NAME, NbBundle.getMessage(ShowFailures.class, "ShowFailures.label")); + putValue(NAME, ShowFailures_label()); } public void actionPerformed(ActionEvent e) { new RequestProcessor(url + "testReport").post(this); // NOI18N } + @Messages({"# {0} - job #build", "ShowFailures.title={0} Test Failures", + "# {0} - class & method name of failed test", "# {1} - suite name of failed test", "ShowFailures.from_suite={0} (from {1})"}) public void run() { try { XMLReader parser = XMLUtil.createXMLReader(); @@ -113,7 +117,7 @@ Hyperlinker hyperlinker = new Hyperlinker(job); private void prepareOutput() { if (io == null) { - String title = NbBundle.getMessage(ShowFailures.class, "ShowFailures.title", displayName); + String title = ShowFailures_title(displayName); io = IOProvider.getDefault().getIO(title, new Action[0]); io.select(); } @@ -191,7 +195,7 @@ } String name = c.className + "." + c.name; if (s.name != null && !s.name.equals(c.className)) { - name = NbBundle.getMessage(ShowFailures.class, "ShowFailures.from_suite", name, s.name); + name = ShowFailures_from_suite(name, s.name); } println(); out.println(name, new OutputListener() { diff --git a/hudson/src/org/netbeans/modules/hudson/ui/notification/Bundle.properties b/hudson/src/org/netbeans/modules/hudson/ui/notification/Bundle.properties --- a/hudson/src/org/netbeans/modules/hudson/ui/notification/Bundle.properties +++ b/hudson/src/org/netbeans/modules/hudson/ui/notification/Bundle.properties @@ -38,19 +38,4 @@ # # Portions Copyrighted 2009 Sun Microsystems, Inc. -# {0} - job name -# {1} - build number -ProblemNotification.title.failed={0} #{1,number,#} failed -# {0} - job name -# {1} - build number -ProblemNotification.title.unstable={0} #{1,number,#} is unstable -ProblemNotification.description.failed=The build failed. -ProblemNotification.description.unstable=Some tests failed. ProblemPanel.ignore.text=Ignore -# {0} - job name -ProblemNotification.ignore.title=Ignore Failures in {0} -# {0} - job name -# {1} - server name -ProblemNotification.ignore.question=\ - Do you wish to cease to receive notifications of failures in {0}? \ - If you change your mind, use Services > Hudson Builders > {1} > {0} > Properties > Watched. diff --git a/hudson/src/org/netbeans/modules/hudson/ui/notification/ProblemNotification.java b/hudson/src/org/netbeans/modules/hudson/ui/notification/ProblemNotification.java --- a/hudson/src/org/netbeans/modules/hudson/ui/notification/ProblemNotification.java +++ b/hudson/src/org/netbeans/modules/hudson/ui/notification/ProblemNotification.java @@ -55,8 +55,9 @@ import org.openide.awt.NotificationDisplayer; import org.openide.awt.NotificationDisplayer.Priority; import org.openide.util.ImageUtilities; -import org.openide.util.NbBundle; +import org.openide.util.NbBundle.Messages; import org.openide.util.RequestProcessor; +import static org.netbeans.modules.hudson.ui.notification.Bundle.*; /** * Build failed or was unstable. @@ -76,14 +77,25 @@ this.failed = failed; } + @Messages({ + "# {0} - job name", + "# {1} - build number", + "ProblemNotification.title.failed={0} #{1,number,#} failed", + "# {0} - job name", + "# {1} - build number", + "ProblemNotification.title.unstable={0} #{1,number,#} is unstable" + }) private String getTitle() { // XXX use HudsonJobBuild.getDisplayName - return NbBundle.getMessage(ProblemNotification.class, failed ? "ProblemNotification.title.failed" : "ProblemNotification.title.unstable", - job.getDisplayName(), build); + return failed ? ProblemNotification_title_failed(job.getDisplayName(), build) : ProblemNotification_title_unstable(job.getDisplayName(), build); } + @Messages({ + "ProblemNotification.description.failed=The build failed.", + "ProblemNotification.description.unstable=Some tests failed." + }) String showFailureText() { - return NbBundle.getMessage(ProblemNotification.class, failed ? "ProblemNotification.description.failed" : "ProblemNotification.description.unstable"); + return failed ? ProblemNotification_description_failed() : ProblemNotification_description_unstable(); } void showFailure() { @@ -113,10 +125,17 @@ }); } + @Messages({ + "# {0} - job name", + "# {1} - server name", + "ProblemNotification.ignore.question=Do you wish to cease to receive notifications of failures in {0}? If you change your mind, use Services > Hudson Builders > {1} > {0} > Properties > Watched.", + "# {0} - job name", + "ProblemNotification.ignore.title=Ignore Failures in {0}" + }) void ignore() { // #161601 if (DialogDisplayer.getDefault().notify(new NotifyDescriptor.Confirmation( - NbBundle.getMessage(ProblemNotification.class, "ProblemNotification.ignore.question", job.getDisplayName(), job.getInstance().getName()), - NbBundle.getMessage(ProblemNotification.class, "ProblemNotification.ignore.title", job.getDisplayName()), + ProblemNotification_ignore_question(job.getDisplayName(), job.getInstance().getName()), + ProblemNotification_ignore_title(job.getDisplayName()), NotifyDescriptor.OK_CANCEL_OPTION)) == NotifyDescriptor.OK_OPTION) { job.setSalient(false); }