Added support for profiles II
This commit is contained in:
parent
b7ef2119f3
commit
3b9805abed
@ -219,18 +219,16 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
||||
}
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_F) {
|
||||
Toaster toaster = new Toaster();
|
||||
|
||||
if(timeCalcProfilesTxtFile.exists()) {
|
||||
toaster.setDisplayTime(15000);
|
||||
try {
|
||||
toaster.showToaster(Utils.readTextFromFile(timeCalcProfilesTxtFile));
|
||||
Utils.showNotification(Utils.readTextFromFile(timeCalcProfilesTxtFile), 200);
|
||||
} catch (IOException ioException) {
|
||||
ioException.printStackTrace();
|
||||
toaster.showToaster("Error: " + ioException.getMessage());
|
||||
Utils.showNotification("Error: " + ioException.getMessage());
|
||||
}
|
||||
} else {
|
||||
toaster.setDisplayTime(15000);
|
||||
toaster.showToaster("Warning: There are no numbers assigned to profiles. Update file: " + timeCalcProfilesTxtFile.getAbsolutePath() + ".");
|
||||
Utils.showNotification("Warning: There are no numbers assigned to profiles. Update file: " + timeCalcProfilesTxtFile.getAbsolutePath() + ".");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -162,8 +162,13 @@ public class TimeCalcProperties {
|
||||
}
|
||||
|
||||
public void loadProfile(String profileName) {
|
||||
File file = getFile(profileName);
|
||||
if(!file.exists()) {
|
||||
Utils.showNotification("There is no profile with name: " + profileName);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
this.properties.load( new FileInputStream(getFile(profileName)));
|
||||
this.properties.load( new FileInputStream(file));
|
||||
} catch (IOException e) {
|
||||
System.err.println(e);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.nanoboot.utils.timecalc.utils.common;
|
||||
|
||||
import org.nanoboot.utils.timecalc.app.Main;
|
||||
import org.nanoboot.utils.timecalc.swing.common.Toaster;
|
||||
import org.nanoboot.utils.timecalc.utils.property.BooleanProperty;
|
||||
|
||||
import java.awt.Color;
|
||||
@ -140,4 +141,15 @@ public class Utils {
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
public static void showNotification(String message) {
|
||||
showNotification(message, 0);
|
||||
}
|
||||
public static void showNotification(String message, int height) {
|
||||
Toaster toaster = new Toaster();
|
||||
toaster.setDisplayTime(15000);
|
||||
if(height != 0) {
|
||||
toaster.setToasterHeight(height);
|
||||
}
|
||||
toaster.showToaster(message);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user