Skip to content

Commit

Permalink
Usability fixes (winder#2362)
Browse files Browse the repository at this point in the history
* Add placeholder to better indicate that you can type commands in the command box

* Added error message when the GLPanel couldn't be loaded and added possibility to open log directory

* Fixed problem when user chooses a new file that exists and decides not to overwrite the file.

* Displays a warning message when the user must save gcode file befor it can be sent.

* Added more descriptive tooltips

* Updated library versions

* Added action for creating shortcuts

* Added windows icons

* Fixed icon for MacOSX and in the settings panel

* Delete key can now remove objects in the designer
  • Loading branch information
breiler authored Nov 8, 2023
1 parent d6ef44c commit ff90545
Show file tree
Hide file tree
Showing 40 changed files with 755 additions and 86 deletions.
11 changes: 5 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jetty.version>9.4.41.v20210516</jetty.version>
<jersey.version>2.29.1</jersey.version>
<gluegen.version>2.5.0-rc-20230523</gluegen.version>
<jogl.version>2.5.0-rc-20230523</jogl.version>
<gluegen.version>2.5.0</gluegen.version>
<jogl.version>2.5.0</jogl.version>
<miglayout.version>3.7.4</miglayout.version>
<guava.version>28.1-jre</guava.version>
<jssc.version>2.8.0</jssc.version>
<jserialcomm.version>2.9.2</jserialcomm.version>
<commons-lang3.version>3.12.0</commons-lang3.version>
<commons-io.version>2.11.0</commons-io.version>
<commons-io.version>2.14.0</commons-io.version>
<commons-csv.version>1.9.0</commons-csv.version>
<gson.version>2.10</gson.version>
<gson.version>2.10.1</gson.version>
<jmf.version>2.1.1e</jmf.version>
<zxing.version>3.4.0</zxing.version>
<qrgen.version>1.4</qrgen.version>
Expand All @@ -68,8 +68,7 @@
<ugs.surefire.version>3.0.0-M5</ugs.surefire.version>
<download-maven-plugin.version>1.3.0</download-maven-plugin.version>
<mockito.version>3.2.4</mockito.version>
<batik.version>1.16</batik.version>
<jxmodem.version>0.1a</jxmodem.version>
<batik.version>1.17</batik.version>
<jts.version>1.19.0</jts.version>
<ugs.maven-resources-plugin.version>3.1.0</ugs.maven-resources-plugin.version>
<ugs.maven-jar-plugin.version>3.2.0</ugs.maven-jar-plugin.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ This file is part of Universal Gcode Sender (UGS).
* @author wwinder
*/
public class CommandTextArea extends JTextField implements KeyEventDispatcher, UGSEventListener {
public static final String PLACEHOLDER_TEXT = " >\t";
private final transient CommandHistory commandHistory = new CommandHistory();
// This is needed for unit testing.
protected boolean focusNotNeeded = false;
Expand All @@ -58,6 +59,7 @@ public CommandTextArea(BackendAPI backend) {

// Make it possible to send multiple lines
getDocument().putProperty("filterNewlines", Boolean.FALSE);
addFocusListener(new TextFieldPlaceholderFocusListener(this, PLACEHOLDER_TEXT));
}

public final void init(BackendAPI backend) {
Expand Down Expand Up @@ -118,13 +120,10 @@ private void sendCommands(String[] commands) throws Exception {
}

private boolean isArrowKey(KeyEvent e) {
switch (e.getKeyCode()) {
case KeyEvent.VK_UP:
case KeyEvent.VK_DOWN:
return true;
default:
return false;
}
return switch (e.getKeyCode()) {
case KeyEvent.VK_UP, KeyEvent.VK_DOWN -> true;
default -> false;
};
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.willwinder.universalgcodesender.uielements.components;

import javax.swing.*;
import java.awt.*;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;

/**
* Register this as a listener to a text field and it will show a placeholder
*/
public class TextFieldPlaceholderFocusListener implements FocusListener {

private final JTextField textField;
private final Color textColor;
private final Color placeholderColor;
private final String placeholderText;

public TextFieldPlaceholderFocusListener(JTextField textArea, String placeholderText) {
this.textField = textArea;
textColor = textArea.getForeground();
placeholderColor = textArea.getDisabledTextColor();
this.placeholderText = placeholderText;
focusLost(null);
}

@Override
public void focusGained(FocusEvent e) {
if (textField.getText().equals(placeholderText)) {
textField.setText("");
textField.setForeground(textColor);
}
}

@Override
public void focusLost(FocusEvent e) {
if (textField.getText().isEmpty()) {
textField.setForeground(placeholderColor);
textField.setText(placeholderText);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,18 @@ This file is part of Universal Gcode Sender (UGS).

import com.willwinder.universalgcodesender.i18n.Localization;
import com.willwinder.universalgcodesender.model.BackendAPI;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;

import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import java.awt.Component;
import java.awt.EventQueue;
import java.awt.Window;
import java.io.File;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;

/**
*
Expand Down Expand Up @@ -63,28 +69,36 @@ public static void displayErrorDialog(final String errorMessage, boolean modal)
LOGGER.warning("Something tried to display an error message with an empty message: " + ExceptionUtils.getStackTrace(new Throwable()));
return;
}
String title = Localization.getString("error");
displayMessageDialog(new JPanel(), title, errorMessage, JOptionPane.ERROR_MESSAGE, modal);
}

Runnable r = () -> {
//JOptionPane.showMessageDialog(new JFrame(), errorMessage,
// Localization.getString("error"), JOptionPane.ERROR_MESSAGE);
NarrowOptionPane.showNarrowDialog(250, errorMessage.replaceAll("\\.\\.", "\\."),
Localization.getString("error"),
JOptionPane.ERROR_MESSAGE);
};
/**
* Displays a message dialog
*
* @param parent the parent component
* @param title the title string for the dialog
* @param message the Object to display
* @param messageType the type of message to be displayed: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
* @param modal toggle whether the message should block or fire and forget.
*/
public static void displayMessageDialog(Component parent, String title, String message, int messageType, boolean modal) {
Window windowAncestor = SwingUtilities.getWindowAncestor(parent == null ? new JPanel() : parent);
Runnable r = () -> NarrowOptionPane.showNarrowDialog(windowAncestor, 250, StringUtils.defaultString(message).replaceAll("\\.\\.", "\\."),
title,
messageType);

if (modal) {
r.run();
} else {
java.awt.EventQueue.invokeLater(r);
EventQueue.invokeLater(r);
}
}

public static void displayHelpDialog(final String helpMessage) {
java.awt.EventQueue.invokeLater(() -> {
NarrowOptionPane.showNarrowConfirmDialog(250, helpMessage, Localization.getString("help"),
JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE);
//JOptionPane.showMessageDialog(new JFrame(), helpMessage,
// Localization.getString("help"), JOptionPane.INFORMATION_MESSAGE);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ This file is part of Universal Gcode Sender (UGS).
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import java.awt.Component;

/**
* @author wwinder
Expand All @@ -33,10 +33,10 @@ public class NarrowOptionPane extends JOptionPane {
public static String pattern =
"<html><body><p style='width: %dpx;'>%s</p></body></html>";

public static void showNarrowDialog(int textWidthInPixels,
public static void showNarrowDialog(Component parentComponent, int textWidthInPixels,
String message, String title, int messageType)
throws HeadlessException {
JOptionPane.showMessageDialog(new JFrame(),
JOptionPane.showMessageDialog(parentComponent,
String.format(pattern, textWidthInPixels, message.replaceAll("\n", "<br>")),
title, messageType);
}
Expand Down
2 changes: 1 addition & 1 deletion ugs-core/src/resources/MessagesBundle_cs_CZ.properties
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ autoleveler.option.offset-y = Posun měřící sondy Y
autoleveler.option.offset-z = Posun měřící sondy Z
experimental.feature = Toto je experimentální funkce. Prosím buďte opatrní a nahlaste všechny chyby, které najdete na GitHubu.
# Window title for platform GUI
platform-title = Universal Gcode Platform\n
platform-title = Universal Gcode Sender\n
mainWindow.swing.alarmLock = Odemnout
mainWindow.swing.checkMode = Režim kontroly
mainWindow.swing.getState = Stav
Expand Down
9 changes: 8 additions & 1 deletion ugs-core/src/resources/MessagesBundle_en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,12 @@ platform.menu.jog.feed = Feed rate
platform.menu.actions = Actions
platform.menu.macros = Macros
platform.menu.machine = Machine
platform.actions.program.not.saved.message = You must save the file first
platform.actions.program.not.saved.title = Not saved
platform.actions.homing.enabled.tooltip = Use this to perform a homing operation to find the machine zero position
platform.actions.homing.disabled.tooltip = Homing needs to be enabled in the firmware settings
platform.actions.unlock.tooltip = Clear the alarm state and unlock the machine
platform.actions.softreset.tooltip = Reboot the controller
incomplete.localization.title = Not fully translated
incomplete.localization = Universal Gcode Sender is not fully localized for this language. \nPlease visit https://translate.universalgcodesender.com to see how you can help.
incomplete.localization.doNotShowAgain = Do not show this message again
Expand Down Expand Up @@ -498,7 +503,7 @@ autoleveler.probe-failed = Probe failed
autoleveler.panel.clear = Clear scan
experimental.feature = This is an experimental feature. Please use caution and report any bugs you find on GitHub.
# Window title for platform GUI
platform-title = Universal Gcode Platform
platform-title = Universal Gcode Sender
mainWindow.swing.alarmLock = Unlock
mainWindow.swing.checkMode = Check Mode
mainWindow.swing.getState = Get State
Expand Down Expand Up @@ -660,6 +665,8 @@ platform.plugin.jog.stealKeyboardFocus = Making sure that keyboard controls are
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.action.openLogDirectory = Open log directory
platform.action.createShortcut = Create shortcut
platform.plugin.joystick.activate = Activate joystick
platform.plugin.joystick.buttonControls = Button controls:
platform.plugin.joystick.analogControls = Analog controls:
Expand Down
23 changes: 23 additions & 0 deletions ugs-platform/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,16 @@
<property name="bundle.jvm.path" refid="jre_name" />
<basename property="bundle.jvm.name" file="${bundle.jvm.path}"/>

<!-- Delete windows binaries -->
<delete file="${project.build.directory}/${brandingToken}-win/bin/ugsplatform64.exe" failonerror="false"/>
<delete file="${project.build.directory}/${brandingToken}-win/bin/ugsplatform" failonerror="false"/>

<!-- Configure relative JRE path into ugsplatform.conf -->
<replace file="${project.build.directory}/${brandingToken}-win/etc/${brandingToken}.conf" token="#jdkhome=&quot;/path/to/jdk&quot;" value="jdkhome=&quot;jdk/${bundle.jvm.name}&quot;"/>

<!-- Copy icon -->
<copy todir="${project.build.directory}/${brandingToken}-win/bin" file="src/main/app-resources/icon.ico" />

<!-- Create Archive -->
<exec dir="${project.build.directory}" executable="zip" failonerror="true">
<arg value="-r"/>
Expand Down Expand Up @@ -382,9 +389,16 @@
<property name="bundle.jvm.path" refid="jre_name" />
<basename property="bundle.jvm.name" file="${bundle.jvm.path}"/>

<!-- Delete windows binaries -->
<delete file="${project.build.directory}/${brandingToken}-win/bin/ugsplatform.exe" failonerror="false"/>
<delete file="${project.build.directory}/${brandingToken}-win/bin/ugsplatform" failonerror="false"/>

<!-- Configure relative JRE path into ugsplatform.conf -->
<replace file="${project.build.directory}/${brandingToken}-win/etc/${brandingToken}.conf" token="#jdkhome=&quot;/path/to/jdk&quot;" value="jdkhome=&quot;jdk/${bundle.jvm.name}&quot;"/>

<!-- Copy icon -->
<copy todir="${project.build.directory}/${brandingToken}-win/bin" file="src/main/app-resources/icon.ico" />

<!-- Create Archive -->
<exec dir="${project.build.directory}" executable="zip" failonerror="true">
<arg value="-r"/>
Expand Down Expand Up @@ -686,6 +700,9 @@
<fileset dir="${project.build.directory}/${brandingToken}"/>
</copy>

<!-- Copy icon -->
<copy todir="${project.build.directory}/${brandingToken}-linux-x64/bin" file="src/main/app-resources/icon.svg" />

<!-- Delete windows binaries -->
<delete file="${project.build.directory}/${brandingToken}-linux-x64/bin/ugsplatform.exe" failonerror="false"/>
<delete file="${project.build.directory}/${brandingToken}-linux-x64/bin/ugsplatform64.exe" failonerror="false"/>
Expand Down Expand Up @@ -766,6 +783,9 @@
<fileset dir="${project.build.directory}/${brandingToken}"/>
</copy>

<!-- Copy icon -->
<copy todir="${project.build.directory}/${brandingToken}-linux-arm/bin" file="src/main/app-resources/icon.svg" />

<!-- Delete windows binaries -->
<delete file="${project.build.directory}/${brandingToken}-linux-arm/bin/ugsplatform.exe" failonerror="false"/>
<delete file="${project.build.directory}/${brandingToken}-linux-arm/bin/ugsplatform64.exe" failonerror="false"/>
Expand Down Expand Up @@ -846,6 +866,9 @@
<fileset dir="${project.build.directory}/${brandingToken}"/>
</copy>

<!-- Copy icon -->
<copy todir="${project.build.directory}/${brandingToken}-linux-aarch64/bin" file="src/main/app-resources/icon.svg" />

<!-- Delete windows binaries -->
<delete file="${project.build.directory}/${brandingToken}-linux-aarch64/bin/ugsplatform.exe" failonerror="false"/>
<delete file="${project.build.directory}/${brandingToken}-linux-aarch64/bin/ugsplatform64.exe" failonerror="false"/>
Expand Down
Binary file not shown.
Loading

0 comments on commit ff90545

Please sign in to comment.