Added several improvements

This commit is contained in:
Robert Vokac 2024-03-03 14:19:49 +00:00
parent 4af1ecb4ed
commit b9c5e317b0
No known key found for this signature in database
GPG Key ID: 693D30BEE3329055
3 changed files with 12 additions and 11 deletions

View File

@ -187,8 +187,6 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
ioException.printStackTrace();
}
int profileNumber = 0;
Toaster toaster = new Toaster();
toaster.setDisplayTime(5000);
switch(e.getKeyCode()) {
case KeyEvent.VK_0: profileNumber = 0;break;
case KeyEvent.VK_1: profileNumber = 1;break;
@ -205,25 +203,25 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
if(properties.containsKey(key)) {
String profileName = (String) properties.get(key);
if(profileName.equals( timeCalcConfiguration.profileNameProperty)) {
toaster.showToaster("Profile \"" + profileName + "\" is already active. Nothing to do");
Utils.showNotification("Profile \"" + profileName + "\" is already active. Nothing to do", 5000);
} else {
toaster.showToaster("Info: Changing profile to: " + ((
Utils.showNotification("Info: Changing profile to: " + ((
profileName.isEmpty() ? "{Default profile}" :
profileName)));
profileName)), 5000);
TimeCalcProperties.getInstance().loadProfile(profileName);
timeCalcConfiguration.loadFromTimeCalcProperties(
TimeCalcProperties.getInstance());
}
} else {
JOptionPane.showMessageDialog(null, "Warning: There is no profile assigned to Key " + profileNumber, "Warning", JOptionPane.WARNING_MESSAGE);
Utils.showNotification("Warning: There is no profile assigned to Key " + profileNumber, 5000);
}
}
if (e.getKeyCode() == KeyEvent.VK_F) {
if(FileConstants.TIME_CALC_PROFILES_TXT_FILE.exists()) {
try {
Utils.showNotification(Utils.readTextFromFile(FileConstants.TIME_CALC_PROFILES_TXT_FILE), 200);
Utils.showNotification(Utils.readTextFromFile(FileConstants.TIME_CALC_PROFILES_TXT_FILE), 15000, 200);
} catch (IOException ioException) {
ioException.printStackTrace();
Utils.showNotification("Error: " + ioException.getMessage());

View File

@ -34,8 +34,8 @@ public class HelpWindow extends TWindow {
this.setLayout(null);
JScrollPane scrollPane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane.setBounds(1, 1,
getWidth() - SwingUtils.MARGIN,
getHeight() - SwingUtils.MARGIN);
getWidth() - 2 * SwingUtils.MARGIN,
getHeight() - 4 * SwingUtils.MARGIN);
add(scrollPane);
JEditorPane editor = new JEditorPane();

View File

@ -144,9 +144,12 @@ public class Utils {
public static void showNotification(String message) {
showNotification(message, 0);
}
public static void showNotification(String message, int height) {
public static void showNotification(String message, int displayTime) {
showNotification(message, displayTime, 0);
}
public static void showNotification(String message, int displayTime, int height) {
Toaster toaster = new Toaster();
toaster.setDisplayTime(15000);
toaster.setDisplayTime(displayTime == 0 ? 15000 : displayTime);
if(height != 0) {
toaster.setToasterHeight(height);
}