Skip to content

Commit

Permalink
v4.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Mararsh committed Feb 20, 2019
1 parent b679c8f commit b979d95
Show file tree
Hide file tree
Showing 259 changed files with 12,123 additions and 8,878 deletions.
2 changes: 1 addition & 1 deletion MyBox/pom.xml
Expand Up @@ -4,7 +4,7 @@

<groupId>mara</groupId>
<artifactId>MyBox</artifactId>
<version>4.8</version>
<version>4.9</version>
<packaging>jar</packaging>

<name>MyBox</name>
Expand Down
45 changes: 26 additions & 19 deletions MyBox/src/main/java/mara/mybox/MainApp.java
Expand Up @@ -6,13 +6,14 @@
import javafx.application.Platform;
import javafx.stage.Stage;
import javax.imageio.ImageIO;
import mara.mybox.controller.OpenFile;
import mara.mybox.controller.BaseController;
import mara.mybox.fxml.FxmlStage;
import mara.mybox.db.DerbyBase;
import mara.mybox.objects.AppVaribles;
import mara.mybox.objects.CommonValues;
import mara.mybox.image.ImageValueTools;
import mara.mybox.value.AppVaribles;
import mara.mybox.value.CommonValues;
import mara.mybox.image.ImageValue;
import mara.mybox.tools.FileTools;
import static mara.mybox.objects.AppVaribles.logger;
import static mara.mybox.value.AppVaribles.logger;

/**
* @Author Mara
Expand All @@ -30,24 +31,29 @@ public void start(Stage stage) throws Exception {
System.setProperty("sun.java2d.cmm", "sun.java2d.cmm.kcms.KcmsServiceProvider");
System.setProperty("org.apache.pdfbox.rendering.UsePureJavaCMYKConversion", "true");

ImageValueTools.registrySupportedImageFormats();

File userPath = new File(CommonValues.UserFilePath);
File userPath = new File(CommonValues.AppDataRoot);
if (!userPath.exists()) {
userPath.mkdirs();
if (!userPath.mkdirs()) {
FxmlStage.alertError(stage, "Can not find or make user path:\n" + CommonValues.AppDataRoot);
return;
}
}
if (CommonValues.AppTempPath.exists()) {
FileTools.deleteDir(CommonValues.AppTempPath);
}
if (!CommonValues.AppTempPath.mkdirs()) {
FxmlStage.alertError(stage, "Can not find or make user path:\n" + CommonValues.AppTempPath);
return;
}

// The following 3 statements should be done in this order
DerbyBase.initTables();
AppVaribles.initAppVaribles();
DerbyBase.checkUpdates();

File tempPath = new File(CommonValues.TempPath);
if (tempPath.exists()) {
FileTools.deleteDir(tempPath);
}
tempPath.mkdirs();

ImageValue.registrySupportedImageFormats();
ImageIO.setUseCache(true);
ImageIO.setCacheDirectory(new File(CommonValues.TempPath));
ImageIO.setCacheDirectory(CommonValues.AppTempPath);

String inFile = null;
List<String> paremeters = getParameters().getUnnamed();
Expand All @@ -57,11 +63,12 @@ public void start(Stage stage) throws Exception {
}
}
if (inFile != null) {
if (!OpenFile.openTarget(getClass(), stage, inFile)) {
OpenFile.openMyBox(getClass(), stage);
BaseController controller = FxmlStage.openTarget(getClass(), stage, inFile, false);
if (controller == null) {
FxmlStage.openMyBox(getClass(), stage);
}
} else {
OpenFile.openMyBox(getClass(), stage);
FxmlStage.openMyBox(getClass(), stage);
}

// https://stackoverflow.com/questions/23527679/trying-to-open-a-javafx-stage-after-calling-platform-exit
Expand Down
Expand Up @@ -5,10 +5,10 @@
import javafx.fxml.FXML;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.Label;
import mara.mybox.objects.AppVaribles;
import mara.mybox.objects.CommonValues;
import mara.mybox.value.AppVaribles;
import mara.mybox.value.CommonValues;
import mara.mybox.fxml.FxmlTools;
import static mara.mybox.objects.AppVaribles.logger;
import static mara.mybox.value.AppVaribles.logger;

/**
* @Author Mara
Expand Down
29 changes: 17 additions & 12 deletions MyBox/src/main/java/mara/mybox/controller/AlarmClockController.java
Expand Up @@ -26,12 +26,12 @@
import javax.sound.sampled.FloatControl;
import javax.sound.sampled.LineEvent;
import javax.sound.sampled.LineListener;
import static mara.mybox.objects.AppVaribles.logger;
import mara.mybox.objects.AlarmClock;
import mara.mybox.objects.AppVaribles;
import mara.mybox.objects.CommonValues;
import static mara.mybox.value.AppVaribles.logger;
import mara.mybox.data.AlarmClock;
import mara.mybox.value.AppVaribles;
import mara.mybox.value.CommonValues;
import mara.mybox.tools.SoundTools;
import static mara.mybox.objects.AppVaribles.getMessage;
import static mara.mybox.value.AppVaribles.getMessage;
import mara.mybox.tools.DateTools;
import mara.mybox.fxml.FxmlTools;
import static mara.mybox.fxml.FxmlTools.badStyle;
Expand All @@ -53,7 +53,7 @@ public class AlarmClockController extends BaseController {
@FXML
private CheckBox activeCheck, loopCheck;
@FXML
private Button playButton, pauseButton, saveButton;
private Button playButton, pauseButton;
@FXML
protected Pane alertClockTable;
@FXML
Expand Down Expand Up @@ -474,12 +474,14 @@ public void handle(ActionEvent event) {
private void selectSound(ActionEvent event) {
try {
final FileChooser fileChooser = new FileChooser();
String defaultPath = CommonValues.UserFilePath;
String defaultPath = CommonValues.AppDataRoot;
if (System.getProperty("os.name").toLowerCase().contains("windows")) {
defaultPath = "C:\\Windows\\media";
}
File path = new File(AppVaribles.getUserConfigPath(SystemMediaPathKey, defaultPath));
fileChooser.setInitialDirectory(path);
File path = AppVaribles.getUserConfigPath(SystemMediaPathKey, defaultPath);
if (path.exists()) {
fileChooser.setInitialDirectory(path);
}
fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("wav", "*.wav"));
final File file = fileChooser.showOpenDialog(getMyStage());
if (file == null) {
Expand All @@ -500,8 +502,10 @@ private void selectSound(ActionEvent event) {
private void selectMusic(ActionEvent event) {
try {
final FileChooser fileChooser = new FileChooser();
File path = new File(AppVaribles.getUserConfigPath(MusicPathKey, CommonValues.UserFilePath));
fileChooser.setInitialDirectory(path);
File path = AppVaribles.getUserConfigPath(MusicPathKey);
if (path.exists()) {
fileChooser.setInitialDirectory(path);
}
fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("mp3", "*.mp3"));
final File file = fileChooser.showOpenDialog(getMyStage());
if (file == null) {
Expand All @@ -519,7 +523,8 @@ private void selectMusic(ActionEvent event) {
}

@FXML
private void saveAlarm(ActionEvent event) {
@Override
public void saveAction() {
if (currentAlarm == null || !isEdit) {
currentAlarm = new AlarmClock();
currentAlarm.setKey(new Date().getTime());
Expand Down
Expand Up @@ -6,12 +6,12 @@
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javax.sound.sampled.Clip;
import mara.mybox.objects.AlarmClock;
import static mara.mybox.objects.AlarmClock.getTypeString;
import mara.mybox.objects.AppVaribles;
import mara.mybox.objects.CommonValues;
import mara.mybox.data.AlarmClock;
import static mara.mybox.data.AlarmClock.getTypeString;
import mara.mybox.value.AppVaribles;
import mara.mybox.value.CommonValues;
import mara.mybox.fxml.FxmlTools;
import static mara.mybox.objects.AppVaribles.logger;
import static mara.mybox.value.AppVaribles.logger;
import mara.mybox.tools.SoundTools;

/**
Expand Down
Expand Up @@ -18,9 +18,10 @@
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.HBox;
import mara.mybox.objects.AlarmClock;
import mara.mybox.objects.AppVaribles;
import static mara.mybox.objects.AppVaribles.logger;
import javafx.scene.layout.Region;
import mara.mybox.data.AlarmClock;
import mara.mybox.value.AppVaribles;
import static mara.mybox.value.AppVaribles.logger;
import mara.mybox.tools.DateTools;

/**
Expand Down Expand Up @@ -124,6 +125,7 @@ private void clearAction(ActionEvent event) {
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
alert.setTitle(getBaseTitle());
alert.setContentText(AppVaribles.getMessage("SureClearAlarmClocks"));
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
Optional<ButtonType> result = alert.showAndWait();
if (result.get() != ButtonType.OK) {
return;
Expand All @@ -138,7 +140,8 @@ private void clearAction(ActionEvent event) {
}

@FXML
private void deleteAction(ActionEvent event) {
@Override
public void deleteAction() {
ObservableList<AlarmClock> selected = alarmClocksView.getSelectionModel().getSelectedItems();
if (selected == null || selected.isEmpty()) {
return;
Expand Down

0 comments on commit b979d95

Please sign in to comment.