From 117ec994ef29d54eea42bb7f5b27bfa50a44787b Mon Sep 17 00:00:00 2001 From: Joacim Breiler Date: Mon, 21 Mar 2022 21:11:23 +0100 Subject: [PATCH 1/2] Added tool tip on outline action. --- ugs-core/src/resources/MessagesBundle_en_US.properties | 1 + .../java/com/willwinder/ugs/nbp/core/actions/OutlineAction.java | 1 + .../com/willwinder/ugs/nbp/lib/services/LocalizingService.java | 2 ++ 3 files changed, 4 insertions(+) diff --git a/ugs-core/src/resources/MessagesBundle_en_US.properties b/ugs-core/src/resources/MessagesBundle_en_US.properties index dd472a9b3..cab44bdf1 100644 --- a/ugs-core/src/resources/MessagesBundle_en_US.properties +++ b/ugs-core/src/resources/MessagesBundle_en_US.properties @@ -589,6 +589,7 @@ platform.plugin.jog.stepSmaller = Smaller platform.plugin.jog.stealKeyboardFocus = Making sure that keyboard controls are active platform.window.edit.macros = Edit macros... platform.action.outline = Outline +platform.action.outline.tooltip = Move the machine around the model using the current depth platform.plugin.joystick.activate = Activate joystick platform.plugin.joystick.buttonControls = Button controls: platform.plugin.joystick.analogControls = Analog controls: diff --git a/ugs-platform/ugs-platform-ugscore/src/main/java/com/willwinder/ugs/nbp/core/actions/OutlineAction.java b/ugs-platform/ugs-platform-ugscore/src/main/java/com/willwinder/ugs/nbp/core/actions/OutlineAction.java index 7ed1ddd69..4b5de90cd 100644 --- a/ugs-platform/ugs-platform-ugscore/src/main/java/com/willwinder/ugs/nbp/core/actions/OutlineAction.java +++ b/ugs-platform/ugs-platform-ugscore/src/main/java/com/willwinder/ugs/nbp/core/actions/OutlineAction.java @@ -88,6 +88,7 @@ public OutlineAction() { putValue(SMALL_ICON, ImageUtilities.loadImageIcon(ICON_BASE, false)); putValue("menuText", LocalizingService.OutlineTitle); putValue(NAME, LocalizingService.OutlineTitle); + putValue(Action.SHORT_DESCRIPTION, LocalizingService.OutlineToolTip); setEnabled(isEnabled()); } diff --git a/ugs-platform/ugs-platform-ugslib/src/main/java/com/willwinder/ugs/nbp/lib/services/LocalizingService.java b/ugs-platform/ugs-platform-ugslib/src/main/java/com/willwinder/ugs/nbp/lib/services/LocalizingService.java index ea976fcad..75dda283f 100644 --- a/ugs-platform/ugs-platform-ugslib/src/main/java/com/willwinder/ugs/nbp/lib/services/LocalizingService.java +++ b/ugs-platform/ugs-platform-ugslib/src/main/java/com/willwinder/ugs/nbp/lib/services/LocalizingService.java @@ -233,6 +233,8 @@ public class LocalizingService { public final static String OutlineTitleKey = "platform.action.outline"; public final static String OutlineTitle = Localization.getString(OutlineTitleKey, lang); + public final static String OutlineToolTipKey = "platform.action.outline.tooltip"; + public final static String OutlineToolTip = Localization.getString(OutlineToolTipKey, lang); public final static String OutlineWindowPath = MENU_MACHINE_ACTIONS; public final static String OutlineActionId = "com.willwinder.ugs.nbp.core.actions.OutlineAction"; public final static String OutlineCategory = CATEGORY_PROGRAM; From 5f63bfe5a0c94c6296327aac441c520b7d96fb2b Mon Sep 17 00:00:00 2001 From: Joacim Breiler Date: Mon, 21 Mar 2022 21:11:53 +0100 Subject: [PATCH 2/2] Made the text auto selected when then the popup appears. --- .../uielements/components/PopupEditor.java | 44 +++++++++++-------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/ugs-core/src/com/willwinder/universalgcodesender/uielements/components/PopupEditor.java b/ugs-core/src/com/willwinder/universalgcodesender/uielements/components/PopupEditor.java index f7433e5bd..01ea8c336 100644 --- a/ugs-core/src/com/willwinder/universalgcodesender/uielements/components/PopupEditor.java +++ b/ugs-core/src/com/willwinder/universalgcodesender/uielements/components/PopupEditor.java @@ -47,28 +47,13 @@ public PopupEditor(JComponent parent, String title, String text) { setResizable(false); JPanel panel = new JPanel(new MigLayout("fill, wrap 2, inset 2, gap 6, wmin 200, hmin 48", "[70%][30%]")); textField = new TextField(text); + textField.setSelectionStart(0); + textField.setSelectionEnd(text.length()); textField.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 16)); - textField.addKeyListener(new KeyListener() { - @Override - public void keyTyped(KeyEvent e) { - } - - @Override - public void keyPressed(KeyEvent e) { - if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { - dispose(); - } else if (e.getKeyCode() == KeyEvent.VK_ENTER) { - notifyListenersAndDispose(); - } - } - - @Override - public void keyReleased(KeyEvent e) { - } - }); + textField.addKeyListener(new PopupEditorKeyListener()); JButton button = new JButton("Set"); button.setMinimumSize(new Dimension(10, 10)); - button.addActionListener((event) -> notifyListenersAndDispose()); + button.addActionListener(event -> notifyListenersAndDispose()); panel.add(textField, "grow"); panel.add(button, "grow"); @@ -103,4 +88,25 @@ public void dispose() { public interface PopupEditorListener { void onValue(String value); } + + private class PopupEditorKeyListener implements KeyListener { + @Override + public void keyTyped(KeyEvent e) { + // Not used + } + + @Override + public void keyPressed(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { + dispose(); + } else if (e.getKeyCode() == KeyEvent.VK_ENTER) { + notifyListenersAndDispose(); + } + } + + @Override + public void keyReleased(KeyEvent e) { + // Not used + } + } }