mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-19 08:46:09 -04:00
Change Controllers.navigate(null) to PageCloseEvent/onEnd
This commit is contained in:
parent
d01c9a425a
commit
e4e521c2ef
@ -25,7 +25,6 @@ import javafx.scene.Node;
|
|||||||
import javafx.scene.layout.StackPane;
|
import javafx.scene.layout.StackPane;
|
||||||
import org.jackhuang.hmcl.ui.animation.TransitionHandler;
|
import org.jackhuang.hmcl.ui.animation.TransitionHandler;
|
||||||
import org.jackhuang.hmcl.ui.construct.PageCloseEvent;
|
import org.jackhuang.hmcl.ui.construct.PageCloseEvent;
|
||||||
import org.jackhuang.hmcl.ui.construct.TaskExecutorDialogWizardDisplayer;
|
|
||||||
import org.jackhuang.hmcl.ui.wizard.*;
|
import org.jackhuang.hmcl.ui.wizard.*;
|
||||||
|
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
@ -79,7 +79,7 @@ public final class ModpackPage extends StackPane implements WizardPage {
|
|||||||
chooser.setTitle(i18n("modpack.choose"));
|
chooser.setTitle(i18n("modpack.choose"));
|
||||||
chooser.getExtensionFilters().add(new FileChooser.ExtensionFilter(i18n("modpack"), "*.zip"));
|
chooser.getExtensionFilters().add(new FileChooser.ExtensionFilter(i18n("modpack"), "*.zip"));
|
||||||
File selectedFile = chooser.showOpenDialog(Controllers.getStage());
|
File selectedFile = chooser.showOpenDialog(Controllers.getStage());
|
||||||
if (selectedFile == null) Platform.runLater(() -> Controllers.navigate(null));
|
if (selectedFile == null) Platform.runLater(controller::onEnd);
|
||||||
else {
|
else {
|
||||||
controller.getSettings().put(MODPACK_FILE, selectedFile);
|
controller.getSettings().put(MODPACK_FILE, selectedFile);
|
||||||
lblModpackLocation.setText(selectedFile.getAbsolutePath());
|
lblModpackLocation.setText(selectedFile.getAbsolutePath());
|
||||||
|
@ -87,7 +87,7 @@ public final class ModpackInfoPage extends StackPane implements WizardPage {
|
|||||||
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter(i18n("modpack"), "*.zip"));
|
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter(i18n("modpack"), "*.zip"));
|
||||||
File file = fileChooser.showSaveDialog(Controllers.getStage());
|
File file = fileChooser.showSaveDialog(Controllers.getStage());
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
Controllers.navigate(null);
|
controller.onEnd();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
controller.getSettings().put(MODPACK_NAME, txtModpackName.getText());
|
controller.getSettings().put(MODPACK_NAME, txtModpackName.getText());
|
||||||
|
@ -29,6 +29,7 @@ import org.jackhuang.hmcl.setting.Profiles;
|
|||||||
import org.jackhuang.hmcl.ui.Controllers;
|
import org.jackhuang.hmcl.ui.Controllers;
|
||||||
import org.jackhuang.hmcl.ui.FXUtils;
|
import org.jackhuang.hmcl.ui.FXUtils;
|
||||||
import org.jackhuang.hmcl.ui.construct.FileItem;
|
import org.jackhuang.hmcl.ui.construct.FileItem;
|
||||||
|
import org.jackhuang.hmcl.ui.construct.PageCloseEvent;
|
||||||
import org.jackhuang.hmcl.ui.decorator.DecoratorPage;
|
import org.jackhuang.hmcl.ui.decorator.DecoratorPage;
|
||||||
import org.jackhuang.hmcl.util.StringUtils;
|
import org.jackhuang.hmcl.util.StringUtils;
|
||||||
|
|
||||||
@ -78,14 +79,6 @@ public final class ProfilePage extends StackPane implements DecoratorPage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
|
||||||
private void onDelete() {
|
|
||||||
if (profile != null) {
|
|
||||||
Profiles.getProfiles().remove(profile);
|
|
||||||
Controllers.navigate(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void onSave() {
|
private void onSave() {
|
||||||
if (profile != null) {
|
if (profile != null) {
|
||||||
@ -103,7 +96,7 @@ public final class ProfilePage extends StackPane implements DecoratorPage {
|
|||||||
Profiles.getProfiles().add(newProfile);
|
Profiles.getProfiles().add(newProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
Controllers.navigate(null);
|
fireEvent(new PageCloseEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
|
@ -56,7 +56,6 @@ public class Versions {
|
|||||||
Controllers.confirmDialog(message, i18n("message.confirm"), () -> {
|
Controllers.confirmDialog(message, i18n("message.confirm"), () -> {
|
||||||
if (profile.getRepository().removeVersionFromDisk(version)) {
|
if (profile.getRepository().removeVersionFromDisk(version)) {
|
||||||
profile.getRepository().refreshVersionsAsync().start();
|
profile.getRepository().refreshVersionsAsync().start();
|
||||||
Controllers.navigate(null);
|
|
||||||
}
|
}
|
||||||
}, null);
|
}, null);
|
||||||
}
|
}
|
||||||
@ -65,7 +64,6 @@ public class Versions {
|
|||||||
Controllers.inputDialog(i18n("version.manage.rename.message"), (res, resolve, reject) -> {
|
Controllers.inputDialog(i18n("version.manage.rename.message"), (res, resolve, reject) -> {
|
||||||
if (profile.getRepository().renameVersion(version, res)) {
|
if (profile.getRepository().renameVersion(version, res)) {
|
||||||
profile.getRepository().refreshVersionsAsync().start();
|
profile.getRepository().refreshVersionsAsync().start();
|
||||||
Controllers.navigate(null);
|
|
||||||
resolve.run();
|
resolve.run();
|
||||||
} else {
|
} else {
|
||||||
reject.accept(i18n("version.manage.rename.fail"));
|
reject.accept(i18n("version.manage.rename.fail"));
|
||||||
|
@ -109,7 +109,6 @@ public class DefaultWizardDisplayer extends StackPane implements AbstractWizardD
|
|||||||
@FXML
|
@FXML
|
||||||
private void close() {
|
private void close() {
|
||||||
wizardController.onCancel();
|
wizardController.onCancel();
|
||||||
Controllers.navigate(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see {http://www.gnu.org/licenses/}.
|
* along with this program. If not, see {http://www.gnu.org/licenses/}.
|
||||||
*/
|
*/
|
||||||
package org.jackhuang.hmcl.ui.construct;
|
package org.jackhuang.hmcl.ui.wizard;
|
||||||
|
|
||||||
import com.jfoenix.concurrency.JFXUtilities;
|
import com.jfoenix.concurrency.JFXUtilities;
|
||||||
import javafx.beans.property.StringProperty;
|
import javafx.beans.property.StringProperty;
|
||||||
@ -23,7 +23,9 @@ import org.jackhuang.hmcl.task.Task;
|
|||||||
import org.jackhuang.hmcl.task.TaskExecutor;
|
import org.jackhuang.hmcl.task.TaskExecutor;
|
||||||
import org.jackhuang.hmcl.task.TaskListener;
|
import org.jackhuang.hmcl.task.TaskListener;
|
||||||
import org.jackhuang.hmcl.ui.Controllers;
|
import org.jackhuang.hmcl.ui.Controllers;
|
||||||
import org.jackhuang.hmcl.ui.wizard.AbstractWizardDisplayer;
|
import org.jackhuang.hmcl.ui.construct.DialogCloseEvent;
|
||||||
|
import org.jackhuang.hmcl.ui.construct.MessageBox;
|
||||||
|
import org.jackhuang.hmcl.ui.construct.TaskExecutorDialogPane;
|
||||||
import org.jackhuang.hmcl.util.StringUtils;
|
import org.jackhuang.hmcl.util.StringUtils;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -36,7 +38,7 @@ public interface TaskExecutorDialogWizardDisplayer extends AbstractWizardDisplay
|
|||||||
default void handleTask(Map<String, Object> settings, Task task) {
|
default void handleTask(Map<String, Object> settings, Task task) {
|
||||||
TaskExecutorDialogPane pane = new TaskExecutorDialogPane(it -> {
|
TaskExecutorDialogPane pane = new TaskExecutorDialogPane(it -> {
|
||||||
it.fireEvent(new DialogCloseEvent());
|
it.fireEvent(new DialogCloseEvent());
|
||||||
Controllers.navigate(null);
|
onEnd();
|
||||||
});
|
});
|
||||||
|
|
||||||
pane.setTitle(i18n("message.doing"));
|
pane.setTitle(i18n("message.doing"));
|
||||||
@ -65,17 +67,17 @@ public interface TaskExecutorDialogWizardDisplayer extends AbstractWizardDisplay
|
|||||||
pane.fireEvent(new DialogCloseEvent());
|
pane.fireEvent(new DialogCloseEvent());
|
||||||
if (success) {
|
if (success) {
|
||||||
if (settings.containsKey("success_message") && settings.get("success_message") instanceof String)
|
if (settings.containsKey("success_message") && settings.get("success_message") instanceof String)
|
||||||
Controllers.dialog((String) settings.get("success_message"), null, MessageBox.FINE_MESSAGE, () -> Controllers.navigate(null));
|
Controllers.dialog((String) settings.get("success_message"), null, MessageBox.FINE_MESSAGE, () -> onEnd());
|
||||||
else if (!settings.containsKey("forbid_success_message"))
|
else if (!settings.containsKey("forbid_success_message"))
|
||||||
Controllers.dialog(i18n("message.success"), null, MessageBox.FINE_MESSAGE, () -> Controllers.navigate(null));
|
Controllers.dialog(i18n("message.success"), null, MessageBox.FINE_MESSAGE, () -> onEnd());
|
||||||
} else {
|
} else {
|
||||||
if (executor.getLastException() == null)
|
if (executor.getLastException() == null)
|
||||||
return;
|
return;
|
||||||
String appendix = StringUtils.getStackTrace(executor.getLastException());
|
String appendix = StringUtils.getStackTrace(executor.getLastException());
|
||||||
if (settings.containsKey("failure_message") && settings.get("failure_message") instanceof String)
|
if (settings.containsKey("failure_message") && settings.get("failure_message") instanceof String)
|
||||||
Controllers.dialog(appendix, (String) settings.get("failure_message"), MessageBox.ERROR_MESSAGE, () -> Controllers.navigate(null));
|
Controllers.dialog(appendix, (String) settings.get("failure_message"), MessageBox.ERROR_MESSAGE, () -> onEnd());
|
||||||
else if (!settings.containsKey("forbid_failure_message"))
|
else if (!settings.containsKey("forbid_failure_message"))
|
||||||
Controllers.dialog(appendix, i18n("wizard.failed"), MessageBox.ERROR_MESSAGE, () -> Controllers.navigate(null));
|
Controllers.dialog(appendix, i18n("wizard.failed"), MessageBox.ERROR_MESSAGE, () -> onEnd());
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -59,6 +59,20 @@
|
|||||||
-fx-padding: 20 0 20 0;
|
-fx-padding: 20 0 20 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.iconed-item {
|
||||||
|
-fx-padding: 10 16 10 16;
|
||||||
|
-fx-spacing: 10;
|
||||||
|
-fx-font-size: 14;
|
||||||
|
-fx-alignment: CENTER_LEFT;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-iconed-item {
|
||||||
|
-fx-padding: 10 16 10 16;
|
||||||
|
-fx-spacing: 10;
|
||||||
|
-fx-font-size: 12;
|
||||||
|
-fx-alignment: CENTER_LEFT;
|
||||||
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* *
|
* *
|
||||||
* JFX Tab Pane *
|
* JFX Tab Pane *
|
||||||
|
@ -45,10 +45,6 @@
|
|||||||
</VBox>
|
</VBox>
|
||||||
</ScrollPane>
|
</ScrollPane>
|
||||||
<BorderPane pickOnBounds="false" style="-fx-padding: 20;">
|
<BorderPane pickOnBounds="false" style="-fx-padding: 20;">
|
||||||
<left>
|
|
||||||
<JFXButton BorderPane.alignment="BOTTOM_LEFT" fx:id="btnDelete" onMouseClicked="#onDelete" prefWidth="100" prefHeight="40"
|
|
||||||
buttonType="RAISED" text="%button.delete" styleClass="jfx-button-raised" />
|
|
||||||
</left>
|
|
||||||
<right>
|
<right>
|
||||||
<JFXButton BorderPane.alignment="BOTTOM_RIGHT" fx:id="btnSave" onMouseClicked="#onSave" prefWidth="100" prefHeight="40"
|
<JFXButton BorderPane.alignment="BOTTOM_RIGHT" fx:id="btnSave" onMouseClicked="#onSave" prefWidth="100" prefHeight="40"
|
||||||
buttonType="RAISED" text="%button.save" styleClass="jfx-button-raised"/>
|
buttonType="RAISED" text="%button.save" styleClass="jfx-button-raised"/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user