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 2, 2024
1 parent dae750c commit 9c0b777
Show file tree
Hide file tree
Showing 26 changed files with 165 additions and 118 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package mara.mybox.controller;

import mara.mybox.dev.MyBoxLog;

/**
* @Author Mara
* @CreateDate 2021-12-25
* @License Apache License Version 2.0
*/
public abstract class BaseBranchController extends BaseFileController {

@Override
public void initValues() {
try {
super.initValues();

stageType = StageType.Branch;

} catch (Exception e) {
MyBoxLog.error(e);
}
}

}
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
package mara.mybox.controller;

import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML;
import javafx.scene.control.CheckBox;
import mara.mybox.dev.MyBoxLog;
import static mara.mybox.value.Languages.message;
import mara.mybox.value.UserConfig;

/**
* @Author Mara
* @CreateDate 2021-12-25
* @License Apache License Version 2.0
*/
public abstract class BaseChildController extends BaseController {

@FXML
protected CheckBox onTopCheck, closeAfterCheck;
public abstract class BaseChildController extends BaseFileController {

@Override
public void initValues() {
Expand All @@ -30,51 +21,4 @@ public void initValues() {
}
}

@Override
public void initControls() {
try {
super.initControls();

if (onTopCheck != null) {
if (getMyStage() != null) {
onTopCheck.setSelected(getMyStage().isAlwaysOnTop());
}
onTopCheck.selectedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> v, Boolean ov, Boolean nv) {
if (getMyStage() == null) {
return;
}
myStage.setAlwaysOnTop(onTopCheck.isSelected());
popInformation(myStage.isAlwaysOnTop() ? message("AlwayOnTop") : message("DisableAlwayOnTop"));
}
});
}
if (closeAfterCheck != null) {
closeAfterCheck.setSelected(UserConfig.getBoolean(interfaceName + "SaveClose", false));
closeAfterCheck.selectedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> v, Boolean ov, Boolean nv) {
UserConfig.setBoolean(interfaceName + "SaveClose", closeAfterCheck.isSelected());
}
});
}

} catch (Exception e) {
MyBoxLog.error(e);
}
}

@FXML
@Override
public void cancelAction() {
close();
}

@Override
public boolean keyESC() {
close();
return false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ public void handle(WindowEvent event) {
}
});
parent.getMyStage().setFullScreen(false);
myStage.setAlwaysOnTop(true);
setAlwaysTop(true, false);
break;
}
case Pop: {
myStage.setAlwaysOnTop(true);
setAlwaysTop(true, false);
if (parent != null) {
parent.getMyStage().setFullScreen(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,7 @@ public void systemMethod() {

@FXML
public void setAlwaysOnTop() {
if (getMyStage() == null) {
return;
}
myStage.setAlwaysOnTop(true);
setAlwaysTop(true, true);
}

public void clearUserSettings() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public static enum SaveAsType {
@FXML
protected ImageView tipsView, rightTipsView, linksView, leftPaneControl, rightPaneControl;
@FXML
protected CheckBox rightPaneCheck, leftPaneCheck, toolbarCheck;
protected CheckBox rightPaneCheck, leftPaneCheck, toolbarCheck, onTopCheck, closeAfterCheck;
@FXML
protected ToggleGroup saveAsGroup, fileTypeGroup;
@FXML
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,27 @@ public void changed(ObservableValue ov, Toggle oldValue, Toggle newValue) {

initMainArea();

if (onTopCheck != null) {
onTopCheck.selectedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> v, Boolean ov, Boolean nv) {
if (isSettingValues || myStage == null) {
return;
}
setAlwaysTop(onTopCheck.isSelected(), true);
}
});
}
if (closeAfterCheck != null) {
closeAfterCheck.setSelected(UserConfig.getBoolean(interfaceName + "SaveClose", false));
closeAfterCheck.selectedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> v, Boolean ov, Boolean nv) {
UserConfig.setBoolean(interfaceName + "SaveClose", closeAfterCheck.isSelected());
}
});
}

if (tipsView != null) {
tipsView.setPickOnBounds(true);
tipsView.setOnMouseClicked(new EventHandler<MouseEvent>() {
Expand Down Expand Up @@ -436,6 +457,11 @@ public void run() {
}
}, 1000);
}

if (onTopCheck != null) {
onTopCheck.setSelected(myStage.isAlwaysOnTop());
}

} catch (Exception e) {
MyBoxLog.error(e);
}
Expand Down Expand Up @@ -565,6 +591,26 @@ public void run() {
}
}

public void setAlwaysTop(boolean onTop, boolean info) {
try {
myStage = getMyStage();
if (myStage == null || !myStage.isShowing()) {
return;
}
myStage.setAlwaysOnTop(onTop);
if (info) {
popInformation(onTop ? message("AlwayOnTop") : message("DisableAlwayOnTop"));
}
if (onTopCheck != null) {
isSettingValues = true;
onTopCheck.setSelected(onTop);
isSettingValues = false;
}
} catch (Exception e) {
MyBoxLog.error(e);
}
}

public void iconified() {
try {
getMyStage().setIconified(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import mara.mybox.fxml.NodeTools;
import mara.mybox.fxml.WindowTools;
import mara.mybox.value.AppVariables;
import static mara.mybox.value.Languages.message;

/**
* @Author Mara
Expand Down Expand Up @@ -566,8 +565,7 @@ public boolean controlAlt0() {
}
myStage = getMyStage();
if (myStage != null && myStage.isShowing()) {
myStage.setAlwaysOnTop(!myStage.isAlwaysOnTop());
popInformation(myStage.isAlwaysOnTop() ? message("AlwayOnTop") : message("DisableAlwayOnTop"));
setAlwaysTop(!myStage.isAlwaysOnTop(), true);
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* @CreateDate 2021-9-4
* @License Apache License Version 2.0
*/
public abstract class BaseData2DTaskController extends BaseTaskController {
public abstract class BaseData2DTaskController extends BaseBranchController {

protected BaseData2DLoadController dataController;
protected Data2D data2D;
Expand Down Expand Up @@ -345,11 +345,13 @@ public boolean checkOptions() {
if (!sourceController.allPagesRadio.isSelected()
&& sourceController.selectedRowsIndices.isEmpty()) {
popError(message("SelectToHandle") + ": " + message("Rows"));
tabPane.getSelectionModel().select(sourceTab);
return false;
}

if (columnsPane != null && checkedColsIndices.isEmpty()) {
popError(message("SelectToHandle") + ": " + message("Columns"));
tabPane.getSelectionModel().select(optionsTab);
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML;
import javafx.scene.control.CheckBox;
import javafx.scene.image.Image;
import mara.mybox.bufferedimage.ImageScope;
import mara.mybox.dev.MyBoxLog;
import mara.mybox.fximage.ScaleTools;
import mara.mybox.fxml.FxSingletonTask;
import mara.mybox.fxml.FxTask;
import static mara.mybox.value.Languages.message;
import mara.mybox.value.UserConfig;

/**
* @Author Mara
Expand All @@ -30,9 +27,6 @@ public class BaseImageEditController extends BaseShapeController {
protected boolean needFixSize;
protected FxTask demoTask;

@FXML
protected CheckBox closeAfterCheck, onTopCheck;

protected void setParameters(BaseImageController parent) {
try {
if (parent == null) {
Expand All @@ -51,23 +45,6 @@ public void changed(ObservableValue<? extends Boolean> v, Boolean ov, Boolean nv
});
}

closeAfterCheck.setSelected(UserConfig.getBoolean(baseName + "CloseAfterHandle", false));
closeAfterCheck.selectedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> v, Boolean ov, Boolean nv) {
UserConfig.setBoolean(baseName + "CloseAfterHandle", closeAfterCheck.isSelected());
}
});

onTopCheck.setSelected(getMyStage().isAlwaysOnTop());
onTopCheck.selectedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> v, Boolean ov, Boolean nv) {
myStage.setAlwaysOnTop(onTopCheck.isSelected());
popInformation(myStage.isAlwaysOnTop() ? message("AlwayOnTop") : message("DisableAlwayOnTop"));
}
});

if (undoButton != null) {
undoButton.disableProperty().bind(imageController.undoButton.disableProperty());
}
Expand Down Expand Up @@ -153,6 +130,7 @@ public void fitView() {
}
}

@Override
public boolean checkOptions() {
if (imageController == null || !imageController.isShowing()) {
close();
Expand Down Expand Up @@ -304,18 +282,6 @@ public void saveAction() {
imageController.saveAction();
}

@FXML
@Override
public void cancelAction() {
close();
}

@Override
public boolean keyESC() {
close();
return false;
}

@Override
public boolean controlAltS() {
saveAction();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ public void afterTask() {
if (openCheck != null && openCheck.isSelected()) {
openTarget();
}
if (closeAfterCheck != null) {
close();
}
}

public void cancelTask() {
Expand All @@ -202,7 +205,8 @@ public void cancelAction() {

protected void taskCanceled() {
cancelled = true;
showLogs(message("Cancel"));
showLogs(message("Cancelled"));
MyBoxLog.debug(getClass());
}

@FXML
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ public void setParameters(Connection conn, BaseController parent) {

baseAboveCheck.setSelected(UserConfig.getBoolean(conn, baseName + "BaseAbove", false));

String v = UserConfig.getString(conn, baseName + "BaseTransparentAs", "Transparent");
if ("Another".equals(v)) {
baseAsOverlayRadio.setSelected(true);
baseTransparentAs = TransparentAs.Another;
String v = UserConfig.getString(conn, baseName + "BaseTransparentAs", "Another");
if ("Transparent".equals(v)) {
baseAsTransparentRadio.setSelected(true);
baseTransparentAs = TransparentAs.Transparent;
} else if ("Blend".equals(v)) {
baseBlendRadio.setSelected(true);
baseTransparentAs = TransparentAs.Blend;
} else {
baseAsTransparentRadio.setSelected(true);
baseTransparentAs = TransparentAs.Transparent;
baseAsOverlayRadio.setSelected(true);
baseTransparentAs = TransparentAs.Another;
}

v = UserConfig.getString(conn, baseName + "OverlayTransparentAs", "Another");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void set(File file) {

getMyStage().setWidth(file.getAbsolutePath().length() * AppVariables.sceneFontSize + 40);
myStage.setHeight(AppVariables.sceneFontSize * 14 + 80);
myStage.setAlwaysOnTop(true);
setAlwaysTop(true, false);

} catch (Exception e) {
MyBoxLog.error(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void okAction() {
@FXML
public void dataAction() {
InfoTreeManageController c = InfoNode.openManager(handlerController.category);
c.getMyStage().setAlwaysOnTop(true);
c.setAlwaysTop(true, false);
}

public SimpleBooleanProperty getNotify() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public void AlwayOnTop() {
if (getMyStage() == null) {
return;
}
myStage.setAlwaysOnTop(alwayOnTopCheck.isSelected());
setAlwaysTop(alwayOnTopCheck.isSelected(), true);
}

@FXML
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void closeWriter() {
printer.close();
printer = null;
if (isFailed() || tmpFile == null || !tmpFile.exists()
|| !FileTools.override(tmpFile, targetFile, true)) {
|| !FileTools.override(tmpFile, targetFile)) {
FileDeleteTools.delete(tmpFile);
showInfo(message("Failed") + ": " + targetFile);
return;
Expand Down
Loading

0 comments on commit 9c0b777

Please sign in to comment.