mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-25 07:27:49 +01:00
Added several improvements
This commit is contained in:
parent
4af1ecb4ed
commit
b9c5e317b0
@ -187,8 +187,6 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
|||||||
ioException.printStackTrace();
|
ioException.printStackTrace();
|
||||||
}
|
}
|
||||||
int profileNumber = 0;
|
int profileNumber = 0;
|
||||||
Toaster toaster = new Toaster();
|
|
||||||
toaster.setDisplayTime(5000);
|
|
||||||
switch(e.getKeyCode()) {
|
switch(e.getKeyCode()) {
|
||||||
case KeyEvent.VK_0: profileNumber = 0;break;
|
case KeyEvent.VK_0: profileNumber = 0;break;
|
||||||
case KeyEvent.VK_1: profileNumber = 1;break;
|
case KeyEvent.VK_1: profileNumber = 1;break;
|
||||||
@ -205,25 +203,25 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
|||||||
if(properties.containsKey(key)) {
|
if(properties.containsKey(key)) {
|
||||||
String profileName = (String) properties.get(key);
|
String profileName = (String) properties.get(key);
|
||||||
if(profileName.equals( timeCalcConfiguration.profileNameProperty)) {
|
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 {
|
} else {
|
||||||
toaster.showToaster("Info: Changing profile to: " + ((
|
Utils.showNotification("Info: Changing profile to: " + ((
|
||||||
profileName.isEmpty() ? "{Default profile}" :
|
profileName.isEmpty() ? "{Default profile}" :
|
||||||
profileName)));
|
profileName)), 5000);
|
||||||
TimeCalcProperties.getInstance().loadProfile(profileName);
|
TimeCalcProperties.getInstance().loadProfile(profileName);
|
||||||
timeCalcConfiguration.loadFromTimeCalcProperties(
|
timeCalcConfiguration.loadFromTimeCalcProperties(
|
||||||
TimeCalcProperties.getInstance());
|
TimeCalcProperties.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} 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 (e.getKeyCode() == KeyEvent.VK_F) {
|
||||||
|
|
||||||
if(FileConstants.TIME_CALC_PROFILES_TXT_FILE.exists()) {
|
if(FileConstants.TIME_CALC_PROFILES_TXT_FILE.exists()) {
|
||||||
try {
|
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) {
|
} catch (IOException ioException) {
|
||||||
ioException.printStackTrace();
|
ioException.printStackTrace();
|
||||||
Utils.showNotification("Error: " + ioException.getMessage());
|
Utils.showNotification("Error: " + ioException.getMessage());
|
||||||
|
@ -34,8 +34,8 @@ public class HelpWindow extends TWindow {
|
|||||||
this.setLayout(null);
|
this.setLayout(null);
|
||||||
JScrollPane scrollPane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
JScrollPane scrollPane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
||||||
scrollPane.setBounds(1, 1,
|
scrollPane.setBounds(1, 1,
|
||||||
getWidth() - SwingUtils.MARGIN,
|
getWidth() - 2 * SwingUtils.MARGIN,
|
||||||
getHeight() - SwingUtils.MARGIN);
|
getHeight() - 4 * SwingUtils.MARGIN);
|
||||||
add(scrollPane);
|
add(scrollPane);
|
||||||
|
|
||||||
JEditorPane editor = new JEditorPane();
|
JEditorPane editor = new JEditorPane();
|
||||||
|
@ -144,9 +144,12 @@ public class Utils {
|
|||||||
public static void showNotification(String message) {
|
public static void showNotification(String message) {
|
||||||
showNotification(message, 0);
|
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 toaster = new Toaster();
|
||||||
toaster.setDisplayTime(15000);
|
toaster.setDisplayTime(displayTime == 0 ? 15000 : displayTime);
|
||||||
if(height != 0) {
|
if(height != 0) {
|
||||||
toaster.setToasterHeight(height);
|
toaster.setToasterHeight(height);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user