diff --git a/modules/decima-ui/src/main/java/com/shade/decima/ui/Application.java b/modules/decima-ui/src/main/java/com/shade/decima/ui/Application.java index fe57c6ab..0dc0de40 100644 --- a/modules/decima-ui/src/main/java/com/shade/decima/ui/Application.java +++ b/modules/decima-ui/src/main/java/com/shade/decima/ui/Application.java @@ -371,6 +371,8 @@ private void configureUI() { UIManager.put("Action.splitDownIcon", new FlatSVGIcon("icons/actions/split_down.svg")); UIManager.put("Action.splitRightIcon", new FlatSVGIcon("icons/actions/split_right.svg")); UIManager.put("Action.starIcon", new FlatSVGIcon("icons/actions/star.svg")); + UIManager.put("Action.lowerCaseIcon", new FlatSVGIcon("icons/actions/lowercase.svg")); + UIManager.put("Action.upperCaseIcon", new FlatSVGIcon("icons/actions/uppercase.svg")); UIManager.put("Action.undoIcon", new FlatSVGIcon("icons/actions/undo.svg")); UIManager.put("Action.wireframeIcon", new FlatSVGIcon("icons/actions/wireframe.svg")); UIManager.put("Action.zoomFitIcon", new FlatSVGIcon("icons/actions/zoom_fit.svg")); diff --git a/modules/decima-ui/src/main/java/com/shade/decima/ui/dialogs/HashToolDialog.java b/modules/decima-ui/src/main/java/com/shade/decima/ui/dialogs/HashToolDialog.java index 1ae30e08..a91e8d3f 100644 --- a/modules/decima-ui/src/main/java/com/shade/decima/ui/dialogs/HashToolDialog.java +++ b/modules/decima-ui/src/main/java/com/shade/decima/ui/dialogs/HashToolDialog.java @@ -55,16 +55,35 @@ public void windowDeactivated(WindowEvent e) { private static class ContentPanel extends JPanel { private final List converters = new ArrayList<>(); private final JTextField inputField; + private final JToggleButton upperCaseButton; + private final JToggleButton lowerCaseButton; private final JToggleButton nullTerminatedButton; public ContentPanel() { - setLayout(new MigLayout("ins dialog,wrap 3", "[][grow,fill,150lp]")); + setLayout(new MigLayout("ins dialog,wrap 3", "[][grow,fill,200lp]")); + + upperCaseButton = new JToggleButton(UIManager.getIcon("Action.upperCaseIcon")); + upperCaseButton.setToolTipText("Treat as uppercase"); + + lowerCaseButton = new JToggleButton(UIManager.getIcon("Action.lowerCaseIcon")); + lowerCaseButton.setToolTipText("Treat as lowercase"); nullTerminatedButton = new JToggleButton(UIManager.getIcon("Action.nullTerminatorIcon")); - nullTerminatedButton.setToolTipText("Null-terminated string"); + nullTerminatedButton.setToolTipText("Include null terminator"); + + upperCaseButton.addActionListener(e -> { + lowerCaseButton.setSelected(false); + update(); + }); + lowerCaseButton.addActionListener(e -> { + upperCaseButton.setSelected(false); + update(); + }); nullTerminatedButton.addActionListener(e -> update()); final JToolBar toolBar = new JToolBar(); + toolBar.add(upperCaseButton); + toolBar.add(lowerCaseButton); toolBar.add(nullTerminatedButton); inputField = new JTextField(); @@ -73,6 +92,7 @@ public ContentPanel() { add(new JLabel("Text:")); add(inputField, "span 2"); + add(new JSeparator(), "growx,span 3"); for (Hasher hasher : Hasher.availableHashers()) { final JTextField decField = new JTextField(); @@ -92,7 +112,15 @@ public ContentPanel() { } private void update() { - byte[] data = inputField.getText().getBytes(StandardCharsets.UTF_8); + String text = inputField.getText(); + + if (upperCaseButton.isSelected()) { + text = text.toUpperCase(); + } else if (lowerCaseButton.isSelected()) { + text = text.toLowerCase(); + } + + byte[] data = text.getBytes(StandardCharsets.UTF_8); if (nullTerminatedButton.isSelected()) { data = Arrays.copyOf(data, data.length + 1); diff --git a/modules/decima-ui/src/main/resources/icons/actions/lowercase.svg b/modules/decima-ui/src/main/resources/icons/actions/lowercase.svg new file mode 100644 index 00000000..8f3d80c9 --- /dev/null +++ b/modules/decima-ui/src/main/resources/icons/actions/lowercase.svg @@ -0,0 +1,8 @@ + + actions-lowercase + + + + + + diff --git a/modules/decima-ui/src/main/resources/icons/actions/null_terminator.svg b/modules/decima-ui/src/main/resources/icons/actions/null_terminator.svg index 76f3589e..b15a9376 100644 --- a/modules/decima-ui/src/main/resources/icons/actions/null_terminator.svg +++ b/modules/decima-ui/src/main/resources/icons/actions/null_terminator.svg @@ -1,7 +1,8 @@ actions-null_terminator - - + + + diff --git a/modules/decima-ui/src/main/resources/icons/actions/uppercase.svg b/modules/decima-ui/src/main/resources/icons/actions/uppercase.svg new file mode 100644 index 00000000..46d4d500 --- /dev/null +++ b/modules/decima-ui/src/main/resources/icons/actions/uppercase.svg @@ -0,0 +1,8 @@ + + actions-uppercase + + + + + +