Skip to content

Commit

Permalink
a6.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Mararsh committed Apr 26, 2024
1 parent d78e100 commit 02dd909
Show file tree
Hide file tree
Showing 33 changed files with 291 additions and 319 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import mara.mybox.data.FileInformation.FileSelectorType;
import mara.mybox.data.ImageItem;
import mara.mybox.data.ProcessParameters;
import mara.mybox.db.data.VisitHistory;
import mara.mybox.dev.MyBoxLog;
import mara.mybox.fxml.FxSingletonTask;
import mara.mybox.fxml.FxTask;
Expand Down Expand Up @@ -55,7 +56,7 @@ public abstract class BaseBatchController<T> extends BaseTaskController {
protected TableView<T> tableView;
protected List<File> sourceFiles;
protected List<String> filesPassword;
protected boolean sourceCheckSubdir, createDirectories, allowPaused, browseTargets, viewTargetPath;
protected boolean sourceCheckSubdir, createDirectories, allowPaused, viewTargetPath;
protected boolean isPreview, paused;
protected long dirFilesNumber, dirFilesHandled, totalFilesHandled = 0, totalItemsHandled = 0;
protected long fileSelectorSize, fileSelectorTime;
Expand Down Expand Up @@ -84,7 +85,7 @@ public abstract class BaseBatchController<T> extends BaseTaskController {

public BaseBatchController() {
targetSubdirKey = "targetSubdirKey";
browseTargets = viewTargetPath = false;
viewTargetPath = false;
allowPaused = false;

sourceExtensionFilter = FileFilters.AllExtensionFilter;
Expand Down Expand Up @@ -121,7 +122,7 @@ public void afterTask(boolean ok) {
if (!isPreview && openCheck != null && !openCheck.isSelected()) {
return;
}
if (targetFilesCount > 0 && viewTargetPath) {
if (viewTargetPath && targetFilesCount > 0) {
openTarget();
} else if (targetFiles == null || targetFilesCount == 1) {
if (lastTargetName == null || !new File(lastTargetName).exists()) {
Expand All @@ -130,7 +131,7 @@ public void afterTask(boolean ok) {
viewTarget(new File(lastTargetName));
}
} else if (targetFilesCount > 0) {
if (browseTargets) {
if (VisitHistory.isImageType(TargetFileType)) {
browseAction();
} else {
openTarget();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public abstract class BaseBatchImageController extends BaseBatchFileController {

public BaseBatchImageController() {
targetSubdirKey = "ImageCreatSubdir";
browseTargets = true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import mara.mybox.fxml.FxTask;
import mara.mybox.tools.FileNameTools;
import mara.mybox.value.AppVariables;
import mara.mybox.value.Languages;
import static mara.mybox.value.Languages.message;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException;

Expand Down Expand Up @@ -50,7 +50,7 @@ public void setFileType() {
@Override
public boolean makePreviewParameters() {
if (!makeActualParameters()) {
popError(Languages.message("Invalid"));
popError(message("Invalid"));
actualParameters = null;
return false;
}
Expand Down Expand Up @@ -128,13 +128,15 @@ public String handleFile(FxTask currentTask, File srcFile, File targetPath) {
}
currentParameters.startPage = 1;
} catch (InvalidPasswordException e) {
return Languages.message("PasswordIncorrect");
return message("PasswordIncorrect");
} catch (Exception e) {
return e.toString();
showLogs(e.toString());
return message("Failed");
}
updateInterface("CompleteFile");
return MessageFormat.format(Languages.message("HandlePagesGenerateNumber"),
currentParameters.currentPage - currentParameters.fromPage, generated);
showLogs(MessageFormat.format(message("HandlePagesGenerateNumber"),
currentParameters.currentPage - currentParameters.fromPage, generated));
return message("Successful");
}

public boolean preHandlePages(FxTask currentTask) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,11 @@ public void openSourcePath() {

@FXML
public void openBackups() {
FileBackupController.load((BaseController) this);
openBackups(baseName + "BackupWhenSave");
}

public void openBackups(String name) {
FileBackupController.load((BaseController) this, name);
}

public FileBackup addBackup(FxTask inTask, File file) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ public void handle(ActionEvent event) {

menu = new MenuItem(message("FileBackups"), StyleTools.getIconImageView("iconBackup.png"));
menu.setOnAction((ActionEvent menuItemEvent) -> {
openBackups();
openBackups(baseName + "BackupWhenSave");
});
items.add(menu);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public void handle(ActionEvent event) {

menu = new MenuItem(message("FileBackups"), StyleTools.getIconImageView("iconBackup.png"));
menu.setOnAction((ActionEvent menuItemEvent) -> {
openBackups();
openBackups(baseName + "BackupWhenSave");
});
items.add(menu);
}
Expand Down
121 changes: 0 additions & 121 deletions alpha/MyBox/src/main/java/mara/mybox/controller/ControlFileBackup.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,7 @@ public void handleMutiplePages(Data2D attributes) {
@Override
protected boolean handle() {
try {
needBackup = sourceData.isDataFile() && !sourceData.isTmpData()
&& UserConfig.getBoolean(baseName + "BackupWhenSave", true);
needBackup = sourceData.needBackup();
if (needBackup) {
backup = addBackup(this, sourceFile);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import mara.mybox.fxml.WindowTools;
import mara.mybox.value.Fxmls;
import static mara.mybox.value.Languages.message;
import mara.mybox.value.UserConfig;

/**
* @Author Mara
Expand Down Expand Up @@ -134,8 +133,7 @@ public void handleAllTask() {
@Override
protected boolean handle() {
try {
needBackup = data2D.isDataFile() && !data2D.isTmpData()
&& UserConfig.getBoolean(baseName + "BackupWhenSave", true);
needBackup = data2D.needBackup();
if (needBackup) {
addBackup(this, data2D.getFile());
}
Expand Down
Loading

0 comments on commit 02dd909

Please sign in to comment.