Change Controllers.navigate(null) to PageCloseEvent/onEnd

This commit is contained in:
huangyuhui 2018-09-03 21:27:39 +08:00
parent d01c9a425a
commit e4e521c2ef
9 changed files with 27 additions and 26 deletions

View File

@ -25,7 +25,6 @@ import javafx.scene.Node;
import javafx.scene.layout.StackPane;
import org.jackhuang.hmcl.ui.animation.TransitionHandler;
import org.jackhuang.hmcl.ui.construct.PageCloseEvent;
import org.jackhuang.hmcl.ui.construct.TaskExecutorDialogWizardDisplayer;
import org.jackhuang.hmcl.ui.wizard.*;
import java.util.Queue;

View File

@ -79,7 +79,7 @@ public final class ModpackPage extends StackPane implements WizardPage {
chooser.setTitle(i18n("modpack.choose"));
chooser.getExtensionFilters().add(new FileChooser.ExtensionFilter(i18n("modpack"), "*.zip"));
File selectedFile = chooser.showOpenDialog(Controllers.getStage());
if (selectedFile == null) Platform.runLater(() -> Controllers.navigate(null));
if (selectedFile == null) Platform.runLater(controller::onEnd);
else {
controller.getSettings().put(MODPACK_FILE, selectedFile);
lblModpackLocation.setText(selectedFile.getAbsolutePath());

View File

@ -87,7 +87,7 @@ public final class ModpackInfoPage extends StackPane implements WizardPage {
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter(i18n("modpack"), "*.zip"));
File file = fileChooser.showSaveDialog(Controllers.getStage());
if (file == null) {
Controllers.navigate(null);
controller.onEnd();
return;
}
controller.getSettings().put(MODPACK_NAME, txtModpackName.getText());

View File

@ -29,6 +29,7 @@ import org.jackhuang.hmcl.setting.Profiles;
import org.jackhuang.hmcl.ui.Controllers;
import org.jackhuang.hmcl.ui.FXUtils;
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.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
private void onSave() {
if (profile != null) {
@ -103,7 +96,7 @@ public final class ProfilePage extends StackPane implements DecoratorPage {
Profiles.getProfiles().add(newProfile);
}
Controllers.navigate(null);
fireEvent(new PageCloseEvent());
}
public String getTitle() {

View File

@ -56,7 +56,6 @@ public class Versions {
Controllers.confirmDialog(message, i18n("message.confirm"), () -> {
if (profile.getRepository().removeVersionFromDisk(version)) {
profile.getRepository().refreshVersionsAsync().start();
Controllers.navigate(null);
}
}, null);
}
@ -65,7 +64,6 @@ public class Versions {
Controllers.inputDialog(i18n("version.manage.rename.message"), (res, resolve, reject) -> {
if (profile.getRepository().renameVersion(version, res)) {
profile.getRepository().refreshVersionsAsync().start();
Controllers.navigate(null);
resolve.run();
} else {
reject.accept(i18n("version.manage.rename.fail"));

View File

@ -109,7 +109,6 @@ public class DefaultWizardDisplayer extends StackPane implements AbstractWizardD
@FXML
private void close() {
wizardController.onCancel();
Controllers.navigate(null);
}
@FXML

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* 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 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.TaskListener;
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 java.util.Map;
@ -36,7 +38,7 @@ public interface TaskExecutorDialogWizardDisplayer extends AbstractWizardDisplay
default void handleTask(Map<String, Object> settings, Task task) {
TaskExecutorDialogPane pane = new TaskExecutorDialogPane(it -> {
it.fireEvent(new DialogCloseEvent());
Controllers.navigate(null);
onEnd();
});
pane.setTitle(i18n("message.doing"));
@ -65,17 +67,17 @@ public interface TaskExecutorDialogWizardDisplayer extends AbstractWizardDisplay
pane.fireEvent(new DialogCloseEvent());
if (success) {
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"))
Controllers.dialog(i18n("message.success"), null, MessageBox.FINE_MESSAGE, () -> Controllers.navigate(null));
Controllers.dialog(i18n("message.success"), null, MessageBox.FINE_MESSAGE, () -> onEnd());
} else {
if (executor.getLastException() == null)
return;
String appendix = StringUtils.getStackTrace(executor.getLastException());
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"))
Controllers.dialog(appendix, i18n("wizard.failed"), MessageBox.ERROR_MESSAGE, () -> Controllers.navigate(null));
Controllers.dialog(appendix, i18n("wizard.failed"), MessageBox.ERROR_MESSAGE, () -> onEnd());
}
});

View File

@ -59,6 +59,20 @@
-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 *

View File

@ -45,10 +45,6 @@
</VBox>
</ScrollPane>
<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>
<JFXButton BorderPane.alignment="BOTTOM_RIGHT" fx:id="btnSave" onMouseClicked="#onSave" prefWidth="100" prefHeight="40"
buttonType="RAISED" text="%button.save" styleClass="jfx-button-raised"/>