Skip to content

Commit

Permalink
Extract Strings
Browse files Browse the repository at this point in the history
  • Loading branch information
nroduit committed Jan 31, 2025
1 parent f16af68 commit b7efb24
Show file tree
Hide file tree
Showing 20 changed files with 69 additions and 45 deletions.
3 changes: 3 additions & 0 deletions annotations/idea/java/net/annotations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<item name='java.net.InetAddress java.net.InetAddress getByName(java.lang.String)'>
<annotation name='org.jetbrains.annotations.NonNls'/>
</item>
<item name='java.net.URI URI(java.lang.String) 0'>
<annotation name='org.jetbrains.annotations.NonNls'/>
</item>
<item name='java.net.URI java.lang.String getScheme()'>
<annotation name='org.jetbrains.annotations.NonNls'/>
</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,19 +476,19 @@ public void patient(String[] argv) {
final Option opt = Options.compile(usage).parse(argv);
final List<String> args = opt.args();

if (opt.isSet("help") || args.isEmpty()) {
if (opt.isSet("help") || args.isEmpty()) { // NON-NLS
opt.usage();
return;
}

GuiExecutor.execute(() -> patientCommand(opt, args.get(0)));
GuiExecutor.execute(() -> patientCommand(opt, args.getFirst()));
}

private void patientCommand(Option opt, String arg) {

final Document newPatientContext;

if (opt.isSet("xml")) {
if (opt.isSet("xml")) { // NON-NLS
newPatientContext = getPatientContext(arg, OPT_NONE);
} else if (opt.isSet("inbound")) { // NON-NLS
newPatientContext = getPatientContext(arg, OPT_B64ZIP);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void jbInit() {

List<Object> list = Stream.of(AnatomicModifier.values()).collect(Collectors.toList());
modifierGroup.setModel(list, false, false);
modifiersDropdown.setToolTipText("Select modifiers");
modifiersDropdown.setToolTipText(Messages.getString("select.modifiers"));
add(modifiersDropdown, "cell 1 2, span"); // NON-NLS

add(lblApplyTo, "span, split 3, right, gaptop 20"); // NON-NLS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ WorklistDialog.apply=Apply
WorklistDialog.cancel=Cancel
modifiers=Modifiers
calling.node=Calling Node
select.modifiers=Select modifiers
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static void main(String[] args) {

Option opt = Options.compile(usage).parse(args);

if (opt.isSet("help")) {
if (opt.isSet("help")) { // NON-NLS
opt.usage(); // includes text before Usage:
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public static void applyPreferences(
String componentName,
Type type) {
if (list != null && prefs != null && bundleName != null && componentName != null) {
Preferences prefNode = prefs.node(componentName).node(type.name().toLowerCase() + "s");
Preferences prefNode =
prefs.node(componentName).node(type.name().toLowerCase() + "s"); // NON-NLS
synchronized (list) { // NOSONAR lock object is the list for iterating its elements safely
for (Insertable c : list) {
if (!Type.EMPTY.equals(c.getType())) {
Expand Down Expand Up @@ -92,7 +93,7 @@ public static void applyPreferences(
public static void savePreferences(
List<? extends Insertable> list, Preferences prefs, Type type) {
if (list != null && prefs != null) {
Preferences prefNode = prefs.node(type.name().toLowerCase() + "s");
Preferences prefNode = prefs.node(type.name().toLowerCase() + "s"); // NON-NLS
synchronized (list) { // NOSONAR lock object is the list for iterating its elements safely
for (Insertable c : list) {
if (!Type.EMPTY.equals(c.getType())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ protected static String formatValue(String value, boolean decimal, String format
// If the value ($V) is followed by ':' that means a number formatter is used
if (suffix && format.charAt(index + fmLength) == ':') {
fmLength++;
if (format.charAt(index + fmLength) == 'f' && decimal) {
if (format.charAt(index + fmLength) == 'f' && decimal) { // NON-NLS
fmLength++;
String pattern = getPattern(index + fmLength, format);
if (pattern != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class AuditLog {
public static final String LOG_FILE_PATTERN = "org.apache.sling.commons.log.file.pattern";

public static final String LOG_FOLDER_PATH =
AppProperties.WEASIS_PATH + File.separator + "log" + File.separator;
AppProperties.WEASIS_PATH + File.separator + "log" + File.separator; // NON-NLS

public enum LEVEL {
TRACE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ private static String stringWithEscapeSubstitutions(String s) {
ret.append('\\');
} else if (cn == ' ') {
ret.append(' ');
} else if (cn == 't') {
} else if (cn == 't') { // NON-NLS
ret.append('\t');
} else if (cn == 'n') { // NON-NLS
ret.append('\n');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void get(String[] argv) throws IOException {
final List<String> fargs = opt.getList("file"); // NON-NLS
final List<String> uargs = opt.getList("url"); // NON-NLS

if (opt.isSet("help") || (fargs.isEmpty() && uargs.isEmpty())) {
if (opt.isSet("help") || (fargs.isEmpty() && uargs.isEmpty())) { // NON-NLS
opt.usage();
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ private static Map<Integer, TagD> readTags() {
eventType = xmler.next();
if (eventType == XMLStreamConstants.START_ELEMENT) {
key = xmler.getName().getLocalPart();
if ("el".equals(key)) {
if ("el".equals(key)) { // NON-NLS
readElement(xmler, map);
}
}
Expand Down Expand Up @@ -697,7 +697,7 @@ private static void readElement(XMLStreamReader xmler, Map<Integer, TagD> map)

break;
case XMLStreamConstants.END_ELEMENT:
if ("el".equals(xmler.getName().getLocalPart())) {
if ("el".equals(xmler.getName().getLocalPart())) { // NON-NLS
state = false;
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@ private static void readCorner(ModalityInfoData data, CornerDisplay corner, XMLS
}
break;
case XMLStreamConstants.START_ELEMENT:
if ("p".equals(xmler.getName().getLocalPart()) && xmler.getAttributeCount() >= 1) {
if ("p".equals(xmler.getName().getLocalPart()) // NON-NLS
&& xmler.getAttributeCount() >= 1) {
index = TagUtil.getIntegerTagAttribute(xmler, "index", -1); // NON-NLS
format = xmler.getAttributeValue(null, "format"); // NON-NLS
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ public void get(String[] argv) throws IOException {
final List<String> iargs = opt.getList("iwado"); // NON-NLS
final List<String> wargs = opt.getList("wado"); // NON-NLS

if (opt.isSet("help")
if (opt.isSet("help") // NON-NLS
|| (largs.isEmpty()
&& rargs.isEmpty()
&& iargs.isEmpty()
Expand Down Expand Up @@ -1184,7 +1184,7 @@ public void rs(String[] argv) throws IOException {
final String rsUrl = opt.get("url"); // NON-NLS
final List<String> pargs = opt.getList("request"); // NON-NLS

if (opt.isSet("help") || rsUrl.isEmpty() || (pargs.isEmpty())) {
if (opt.isSet("help") || rsUrl.isEmpty() || (pargs.isEmpty())) { // NON-NLS
opt.usage();
return;
}
Expand Down Expand Up @@ -1261,7 +1261,7 @@ public void close(String[] argv) throws IOException {
final List<String> yargs = opt.getList("study"); // NON-NLS
final List<String> sargs = opt.getList("series"); // NON-NLS

if (opt.isSet("help")
if (opt.isSet("help") // NON-NLS
|| (pargs.isEmpty()
&& yargs.isEmpty()
&& sargs.isEmpty()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1811,7 +1811,7 @@ public void zoom(String[] argv) throws IOException {
final Option opt = Options.compile(usage).parse(argv);
final List<String> args = opt.args();

if (opt.isSet("help")
if (opt.isSet("help") // NON-NLS
|| !opt.isOnlyOneOptionActivate("set", "increase", "decrease")) { // NON-NLS
opt.usage();
return;
Expand All @@ -1834,8 +1834,8 @@ private void zoomCommand(Option opt, List<String> args) {
.get()
.setSliderValue(
zoomAction.get().getSliderValue() - opt.getNumber("decrease")); // NON-NLS
} else if (opt.isSet("set")) {
double val3 = Double.parseDouble(opt.get("set"));
} else if (opt.isSet("set")) { // NON-NLS
double val3 = Double.parseDouble(opt.get("set")); // NON-NLS
if (val3 <= 0.0) {
firePropertyChange(
ActionW.SYNCH.cmd(),
Expand All @@ -1861,7 +1861,7 @@ public void wl(String[] argv) throws IOException {
final Option opt = Options.compile(usage).parse(argv);
final List<String> args = opt.args();

if (opt.isSet("help") || args.size() != 2) {
if (opt.isSet("help") || args.size() != 2) { // NON-NLS
opt.usage();
return;
}
Expand Down Expand Up @@ -1893,7 +1893,7 @@ public void move(String[] argv) throws IOException {
final Option opt = Options.compile(usage).parse(argv);
final List<String> args = opt.args();

if (opt.isSet("help") || args.size() != 2) {
if (opt.isSet("help") || args.size() != 2) { // NON-NLS
opt.usage();
return;
}
Expand Down Expand Up @@ -1923,7 +1923,7 @@ public void scroll(String[] argv) throws IOException {
};
final Option opt = Options.compile(usage).parse(argv);

if (opt.isSet("help")
if (opt.isSet("help") // NON-NLS
|| !opt.isOnlyOneOptionActivate("set", "increase", "decrease")) { // NON-NLS
opt.usage();
return;
Expand All @@ -1941,8 +1941,8 @@ public void scroll(String[] argv) throws IOException {
} else if (opt.isSet("decrease")) { // NON-NLS
moveTroughSliceAction.setSliderValue(
moveTroughSliceAction.getSliderValue() - opt.getNumber("decrease")); // NON-NLS
} else if (opt.isSet("set")) {
moveTroughSliceAction.setSliderValue(opt.getNumber("set"));
} else if (opt.isSet("set")) { // NON-NLS
moveTroughSliceAction.setSliderValue(opt.getNumber("set")); // NON-NLS
}
}
} catch (Exception e) {
Expand Down Expand Up @@ -1999,7 +1999,7 @@ public void mouseLeftAction(String[] argv) throws IOException {
final Option opt = Options.compile(usage).parse(argv);
final List<String> args = opt.args();

if (opt.isSet("help") || args.size() != 1) {
if (opt.isSet("help") || args.size() != 1) { // NON-NLS
opt.usage();
return;
}
Expand Down Expand Up @@ -2055,7 +2055,7 @@ public void synch(String[] argv) throws IOException {
final Option opt = Options.compile(usage).parse(argv);
final List<String> args = opt.args();

if (opt.isSet("help") || args.size() != 1) {
if (opt.isSet("help") || args.size() != 1) { // NON-NLS
opt.usage();
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,16 @@ segmentation=Segmentation
graphic.opacity=Graphic Opacity
list.of.regions=List of regions
oblique.mpr=Oblique MPR
reset.thickness=Reset thickness
custom.thickness=Custom thickness
mip.thickness=MIP thickness
change.mpr.pref=Change MPR preferences
mip.type=MIP type
show.crosshair=Show crosshair
show.center.crosshair=Show center of crosshair
center=Center
all.views=All views
enter.thickness=Enter a thickness value in pixels
axial=Axial
coronal=Coronal
sagittal=Sagittal
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.weasis.core.api.gui.util.GuiUtils;
import org.weasis.core.ui.model.layer.LayerAnnotation.Position;
import org.weasis.dicom.codec.geometry.PatientOrientation.Biped;
import org.weasis.dicom.viewer2d.Messages;
import org.weasis.dicom.viewer2d.mpr.MprView.SliceOrientation;

public class AxisDirection {
Expand All @@ -41,9 +42,9 @@ public AxisDirection(SliceOrientation viewOrientation) {
};
this.name =
switch (viewOrientation) {
case AXIAL -> "Axial";
case CORONAL -> "Coronal";
case SAGITTAL -> "Sagittal";
case AXIAL -> Messages.getString("axial");
case CORONAL -> Messages.getString("coronal");
case SAGITTAL -> Messages.getString("sagittal");
};

switch (viewOrientation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,16 +410,16 @@ public ViewButton buildMprButton() {
new ViewButton(
(invoker, x, y) -> {
JPopupMenu popupMenu = new JPopupMenu();
JMenu menu = new JMenu("All views");
JMenu menu = new JMenu(Messages.getString("all.views"));

if (getCenterMode() != 2) {
JMenuItem item = new JMenuItem("Center");
JMenuItem item = new JMenuItem(Messages.getString("center"));
item.addActionListener(e -> recenterAxis(false));
item.setAccelerator(
KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.ALT_DOWN_MASK));
popupMenu.add(item);

item = new JMenuItem("Center");
item = new JMenuItem(Messages.getString("center"));
item.addActionListener(e -> recenterAxis(true));
item.setAccelerator(
KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.ALT_DOWN_MASK));
Expand All @@ -430,7 +430,7 @@ public ViewButton buildMprButton() {
if (gap > 0) {
boolean showCenter = getViewProperty(this, SHOW_CROSS_CENTER);
JCheckBoxMenuItem boxMenuItem =
new JCheckBoxMenuItem("Show center of crosshair", showCenter);
new JCheckBoxMenuItem(Messages.getString("show.center.crosshair"), showCenter);
boxMenuItem.addActionListener(
e -> showCrossCenter((JCheckBoxMenuItem) e.getSource(), false));
boxMenuItem.setAccelerator(
Expand All @@ -448,7 +448,7 @@ public ViewButton buildMprButton() {

boolean showCrossLines = !getViewProperty(this, HIDE_CROSSLINES);
JCheckBoxMenuItem boxMenuItem =
new JCheckBoxMenuItem("Show crosshair lines", showCrossLines);
new JCheckBoxMenuItem(Messages.getString("show.crosshair"), showCrossLines);
boxMenuItem.addActionListener(
e -> showCrossLines((JCheckBoxMenuItem) e.getSource(), false));
boxMenuItem.setAccelerator(
Expand All @@ -464,7 +464,9 @@ public ViewButton buildMprButton() {
menu.add(boxMenuItem);

JMenu menuItem =
mprController.getMipTypeOption().createUnregisteredRadioMenu("MIP type");
mprController
.getMipTypeOption()
.createUnregisteredRadioMenu(Messages.getString("mip.type"));
menu.add(menuItem);

menuItem = buildMipThicknessMenu(false);
Expand Down Expand Up @@ -503,7 +505,7 @@ public ViewButton buildMprButton() {

private JMenu buildMipThicknessMenu(boolean all) {
MprAxis axis = getMprAxis();
JMenu menu = new JMenu("MIP thickness");
JMenu menu = new JMenu(Messages.getString("mip.thickness"));
DicomImageElement img = axis.getImageElement();
if (img == null) {
return menu;
Expand Down Expand Up @@ -538,7 +540,7 @@ private JMenu buildMipThicknessMenu(boolean all) {
}
menu.add(new JPopupMenu.Separator());

menu.add(new JMenuItem("Reset thickness"))
menu.add(new JMenuItem(Messages.getString("reset.thickness")))
.addActionListener(
e -> {
for (MprAxis mprAxis : mprAxisList) {
Expand All @@ -550,13 +552,15 @@ private JMenu buildMipThicknessMenu(boolean all) {
}
});

menu.add(new JMenuItem("Custom thickness"))
menu.add(new JMenuItem(Messages.getString("custom.thickness")))
.addActionListener(
e -> {
String message = Messages.getString("enter.thickness");
String input =
JOptionPane.showInputDialog(
"Enter a thickness value in pixels"
+ " (1 pix = %s %s)".formatted(DecFormatter.allNumber(minRatio), abbr)
message
+ " (1 pix = %s %s)" // NON-NLS
.formatted(DecFormatter.allNumber(minRatio), abbr)
+ StringUtil.COLON);
try {
int customThickness = Integer.parseInt(input);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ private String setFrameOfReferenceUID(OriginalStack stack) {
private Attributes getCommonTags(OriginalStack stack, SliceOrientation orientation) {
String frUID = setFrameOfReferenceUID(stack);
String desc = TagD.getTagValue(stack.series, Tag.SeriesDescription, String.class);
String mprDesc = "MPR " + orientation;
desc = desc == null ? mprDesc : desc + " [%s]".formatted(mprDesc);
String mprDesc = "MPR " + orientation; // NON-NLS
desc = desc == null ? mprDesc : desc + " [%s]".formatted(mprDesc); // NON-NLS
return stack.getCommonAttributes(frUID, desc, imageTypes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
public class VolImageIO implements DcmMediaReader {
private static final Logger LOGGER = LoggerFactory.getLogger(VolImageIO.class);

private static final String MIME_TYPE = "image/vol";
private static final String MIME_TYPE = "image/vol"; // NON-NLS
private static final SoftHashMap<VolImageIO, DicomMetaData> HEADER_CACHE =
new SoftHashMap<>() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class ConfigData {
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(ConfigData.class);

/** Name of the configuration directory. */
public static final String CONFIG_DIRECTORY = "conf";
public static final String CONFIG_DIRECTORY = "conf"; // NON-NLS

public static final String APP_PROPERTY_FILE = "weasis.properties";
public static final String P_WEASIS_VERSION = "weasis.version";
Expand Down

0 comments on commit b7efb24

Please sign in to comment.