Skip to content

Commit

Permalink
Add indexed access operator overload for ResourceBundle.getString
Browse files Browse the repository at this point in the history
Closes #418
  • Loading branch information
kirill-grouchnikov committed Oct 24, 2022
1 parent 87f91f9 commit 9b9cd3c
Show file tree
Hide file tree
Showing 10 changed files with 197 additions and 152 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import org.pushingpixels.radiance.demo.component.ktx.svg.Help_browser
import org.pushingpixels.radiance.demo.component.ktx.svg.Image_x_generic
import org.pushingpixels.radiance.component.api.common.CommandButtonPresentationState
import org.pushingpixels.radiance.component.ktx.commandButton
import org.pushingpixels.radiance.swing.ktx.util.get
import org.pushingpixels.radiance.theming.api.RadianceThemingCortex
import org.pushingpixels.radiance.theming.api.RadianceThemingSlices
import org.pushingpixels.radiance.theming.api.skin.BusinessSkin
Expand All @@ -61,18 +62,18 @@ fun main() {

val commandButton = commandButton {
command {
title = resourceBundle.getString("Paste.text")
title = resourceBundle["Paste.text"]
iconFactory = Help_browser.factory()
extraText = resourceBundle.getString("Paste.textExtra")
extraText = resourceBundle["Paste.textExtra"]
action = { println("Activated at " + System.currentTimeMillis() + "!") }
actionRichTooltip {
title = resourceBundle.getString("Tooltip.textActionTitle")
title = resourceBundle["Tooltip.textActionTitle"]
mainIconFactory = Image_x_generic.factory()
description {
+resourceBundle.getString("Tooltip.textParagraph1")
+resourceBundle.getString("Tooltip.textParagraph2")
}
footer = resourceBundle.getString("Tooltip.textFooterParagraph1")
footer = resourceBundle["Tooltip.textFooterParagraph1"]
}
}
presentation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import org.pushingpixels.radiance.demo.component.ktx.svg.Format_text_underline
import org.pushingpixels.radiance.component.api.common.CommandButtonPresentationState
import org.pushingpixels.radiance.component.ktx.commandButton
import org.pushingpixels.radiance.component.ktx.commandPopupMenu
import org.pushingpixels.radiance.swing.ktx.util.get
import org.pushingpixels.radiance.theming.api.RadianceThemingCortex
import org.pushingpixels.radiance.theming.api.RadianceThemingSlices
import org.pushingpixels.radiance.theming.api.skin.BusinessSkin
Expand Down Expand Up @@ -72,7 +73,7 @@ fun main() {
title = "multi"
menu = commandPopupMenu {
command {
title = resourceBundle.getString("FontBold.tooltip.textActionTitle")
title = resourceBundle["FontBold.tooltip.textActionTitle"]
iconFactory = Format_text_bold.factory()
action = {
println("Toggle bold")
Expand All @@ -82,7 +83,7 @@ fun main() {
isToggleSelected = isBold
}
command {
title = resourceBundle.getString("FontItalic.tooltip.textActionTitle")
title = resourceBundle["FontItalic.tooltip.textActionTitle"]
iconFactory = Format_text_italic.factory()
action = {
println("Toggle italic")
Expand All @@ -92,7 +93,7 @@ fun main() {
isToggleSelected = isItalic
}
command {
title = resourceBundle.getString("FontUnderline.tooltip.textActionTitle")
title = resourceBundle["FontUnderline.tooltip.textActionTitle"]
iconFactory = Format_text_underline.factory()
action = {
println("Toggle underline")
Expand All @@ -102,7 +103,7 @@ fun main() {
isToggleSelected = isUnderline
}
command {
title = resourceBundle.getString("FontStrikethrough.tooltip.textActionTitle")
title = resourceBundle["FontStrikethrough.tooltip.textActionTitle"]
iconFactory = Format_text_strikethrough.factory()
action = {
println("Toggle strikethrough")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import org.pushingpixels.radiance.swing.ktx.swing.hasStyleInSelection
import org.pushingpixels.radiance.swing.ktx.swing.toggleStyleInSelection
import org.pushingpixels.radiance.component.ktx.command
import org.pushingpixels.radiance.component.ktx.commandButtonStrip
import org.pushingpixels.radiance.swing.ktx.util.get
import org.pushingpixels.radiance.theming.api.RadianceThemingCortex
import org.pushingpixels.radiance.theming.api.skin.GeminiSkin
import java.awt.BorderLayout
Expand Down Expand Up @@ -96,8 +97,8 @@ fun main() {
isToggle = true
isActionEnabled = false
actionRichTooltip {
title = resourceBundle.getString("FontBold.tooltip.textActionTitle")
description = resourceBundle.getString("FontBold.tooltip.textActionParagraph1")
title = resourceBundle["FontBold.tooltip.textActionTitle"]
description = resourceBundle["FontBold.tooltip.textActionParagraph1"]
}
}

Expand All @@ -110,8 +111,8 @@ fun main() {
isToggle = true
isActionEnabled = false
actionRichTooltip {
title = resourceBundle.getString("FontItalic.tooltip.textActionTitle")
description = resourceBundle.getString("FontItalic.tooltip.textActionParagraph1")
title = resourceBundle["FontItalic.tooltip.textActionTitle"]
description = resourceBundle["FontItalic.tooltip.textActionParagraph1"]
}
}

Expand All @@ -124,8 +125,8 @@ fun main() {
isToggle = true
isActionEnabled = false
actionRichTooltip {
title = resourceBundle.getString("FontUnderline.tooltip.textActionTitle")
description = resourceBundle.getString("FontUnderline.tooltip.textActionParagraph1")
title = resourceBundle["FontUnderline.tooltip.textActionTitle"]
description = resourceBundle["FontUnderline.tooltip.textActionParagraph1"]
}
}

Expand All @@ -138,8 +139,8 @@ fun main() {
isToggle = true
isActionEnabled = false
actionRichTooltip {
title = resourceBundle.getString("FontStrikethrough.tooltip.textActionTitle")
description = resourceBundle.getString("FontStrikethrough.tooltip.textActionParagraph1")
title = resourceBundle["FontStrikethrough.tooltip.textActionTitle"]
description = resourceBundle["FontStrikethrough.tooltip.textActionParagraph1"]
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import org.pushingpixels.radiance.component.ktx.DelayedCommandListener
import org.pushingpixels.radiance.component.ktx.KColorSelectorCommand
import org.pushingpixels.radiance.component.ktx.colorSelectorCommandButton
import org.pushingpixels.radiance.component.ktx.colorSelectorPopupMenu
import org.pushingpixels.radiance.swing.ktx.util.get
import org.pushingpixels.radiance.theming.api.RadianceThemingCortex
import org.pushingpixels.radiance.theming.api.RadianceThemingSlices
import org.pushingpixels.radiance.theming.api.skin.BusinessSkin
Expand Down Expand Up @@ -154,7 +155,7 @@ fun main() {
onColorPreviewCanceled = onColorPreviewCanceledListener

command {
title = resourceBundle.getString("ColorSelector.textAutomatic")
title = resourceBundle["ColorSelector.textAutomatic"]
iconFactory = ColorIcon.factory(defaultPanelColor)
action = {
onColorActivatedListener.invoke(defaultPanelColor)
Expand All @@ -174,7 +175,7 @@ fun main() {
}

colorSectionWithDerived {
title = resourceBundle.getString("ColorSelector.textThemeCaption")
title = resourceBundle["ColorSelector.textThemeCaption"]
colors {
+Color(255, 255, 255)
+Color(0, 0, 0)
Expand All @@ -190,7 +191,7 @@ fun main() {
}

colorSection {
title = resourceBundle.getString("ColorSelector.textStandardCaption")
title = resourceBundle["ColorSelector.textStandardCaption"]
colors {
+Color(140, 0, 0)
+Color(253, 0, 0)
Expand All @@ -206,11 +207,11 @@ fun main() {
}

recentSection {
title = resourceBundle.getString("ColorSelector.textRecentCaption")
title = resourceBundle["ColorSelector.textRecentCaption"]
}

command {
title = resourceBundle.getString("ColorSelector.textMoreColor")
title = resourceBundle["ColorSelector.textMoreColor"]
action = DelayedCommandListener {
val color = JColorChooser.showDialog(it.buttonSource,
"Color chooser", backgroundColor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import org.pushingpixels.radiance.component.api.common.icon.DecoratedRadianceIco
import org.pushingpixels.radiance.swing.ktx.awt.render
import org.pushingpixels.radiance.component.ktx.commandButton
import org.pushingpixels.radiance.component.ktx.commandPopupMenu
import org.pushingpixels.radiance.swing.ktx.util.get
import org.pushingpixels.radiance.theming.api.RadianceThemingCortex
import org.pushingpixels.radiance.theming.api.RadianceThemingSlices
import org.pushingpixels.radiance.theming.api.skin.BusinessSkin
Expand Down Expand Up @@ -66,9 +67,9 @@ fun main() {
val mf = MessageFormat(resourceBundle.getString("TestMenuItem.text"))
val commandButton = commandButton {
command {
title = resourceBundle.getString("Paste.text")
title = resourceBundle["Paste.text"]
iconFactory = Help_browser.factory()
extraText = resourceBundle.getString("Paste.textExtra")
extraText = resourceBundle["Paste.textExtra"]
menu = commandPopupMenu {
commandPanel {
presentation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import org.pushingpixels.radiance.demo.component.ktx.svg.Text_x_generic
import org.pushingpixels.radiance.component.api.common.CommandButtonPresentationState
import org.pushingpixels.radiance.component.ktx.commandButton
import org.pushingpixels.radiance.component.ktx.commandPopupMenu
import org.pushingpixels.radiance.swing.ktx.util.get
import org.pushingpixels.radiance.theming.api.RadianceThemingCortex
import org.pushingpixels.radiance.theming.api.RadianceThemingSlices
import org.pushingpixels.radiance.theming.api.skin.BusinessSkin
Expand All @@ -63,9 +64,9 @@ fun main() {

val commandButton = commandButton {
command {
title = resourceBundle.getString("Paste.text")
title = resourceBundle["Paste.text"]
iconFactory = Help_browser.factory()
extraText = resourceBundle.getString("Paste.textExtra")
extraText = resourceBundle["Paste.textExtra"]
menu = commandPopupMenu {
val mf = MessageFormat(resourceBundle.getString("TestMenuItem.text"))
for (i in 0 until 20) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import org.pushingpixels.radiance.component.api.common.CommandButtonPresentation
import org.pushingpixels.radiance.component.api.common.model.CommandButtonPresentationModel
import org.pushingpixels.radiance.component.ktx.commandButton
import org.pushingpixels.radiance.component.ktx.commandPopupMenu
import org.pushingpixels.radiance.swing.ktx.util.get
import org.pushingpixels.radiance.theming.api.RadianceThemingCortex
import org.pushingpixels.radiance.theming.api.RadianceThemingSlices
import org.pushingpixels.radiance.theming.api.skin.BusinessSkin
Expand All @@ -63,17 +64,17 @@ fun main() {

val commandButton = commandButton {
command {
title = resourceBundle.getString("Paste.text")
title = resourceBundle["Paste.text"]
iconFactory = Help_browser.factory()
extraText = resourceBundle.getString("Paste.textExtra")
extraText = resourceBundle["Paste.textExtra"]
secondaryRichTooltip {
title = resourceBundle.getString("Tooltip.textActionTitle")
title = resourceBundle["Tooltip.textActionTitle"]
mainIconFactory = Image_x_generic.factory()
description {
+resourceBundle.getString("Tooltip.textParagraph1")
+resourceBundle.getString("Tooltip.textParagraph2")
}
footer = resourceBundle.getString("Tooltip.textFooterParagraph1")
footer = resourceBundle["Tooltip.textFooterParagraph1"]
}
menu = commandPopupMenu {
val mf = MessageFormat(resourceBundle.getString("TestMenuItem.text"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import org.pushingpixels.radiance.demo.component.ktx.svg.*
import org.pushingpixels.radiance.component.api.common.CommandButtonPresentationState
import org.pushingpixels.radiance.component.ktx.commandButton
import org.pushingpixels.radiance.component.ktx.commandPopupMenu
import org.pushingpixels.radiance.swing.ktx.util.get
import org.pushingpixels.radiance.theming.api.RadianceThemingCortex
import org.pushingpixels.radiance.theming.api.RadianceThemingSlices
import org.pushingpixels.radiance.theming.api.skin.BusinessSkin
Expand All @@ -62,9 +63,9 @@ fun main() {

val commandButton = commandButton {
command {
title = resourceBundle.getString("Paste.text")
title = resourceBundle["Paste.text"]
iconFactory = Help_browser.factory()
extraText = resourceBundle.getString("Paste.textExtra")
extraText = resourceBundle["Paste.textExtra"]
menu = commandPopupMenu {
val mf = MessageFormat(resourceBundle.getString("TestMenuItem.text"))
group {
Expand Down
Loading

0 comments on commit 9b9cd3c

Please sign in to comment.