From 87cc9fea7b6e8bd0960134ad0252f09969398a64 Mon Sep 17 00:00:00 2001 From: mine_ Date: Tue, 16 Sep 2025 00:34:57 +0800 Subject: [PATCH 01/12] =?UTF-8?q?feat:=20=E5=AF=B9mainWindow.java=E5=8A=A0?= =?UTF-8?q?=E8=BD=BDPanel=E5=81=9A=E4=BA=86=E4=BA=9B=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vortex/ui/controller/MainWindow.java | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/main/java/tech/minediamond/vortex/ui/controller/MainWindow.java b/src/main/java/tech/minediamond/vortex/ui/controller/MainWindow.java index 40e98e0..f598242 100644 --- a/src/main/java/tech/minediamond/vortex/ui/controller/MainWindow.java +++ b/src/main/java/tech/minediamond/vortex/ui/controller/MainWindow.java @@ -25,6 +25,8 @@ import com.google.inject.Injector; import javafx.application.Platform; import javafx.beans.binding.Bindings; +import javafx.beans.property.ObjectProperty; +import javafx.beans.property.SimpleObjectProperty; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; @@ -47,19 +49,14 @@ import tech.minediamond.vortex.model.appConfig.AppConfig; import tech.minediamond.vortex.model.ui.ContentPanel; import tech.minediamond.vortex.model.ui.Theme; -import tech.minediamond.vortex.service.ui.ShowStageListenerFactory; import tech.minediamond.vortex.service.i18n.I18nService; -import tech.minediamond.vortex.service.ui.AutoOperateService; -import tech.minediamond.vortex.service.ui.ShowStageListener; -import tech.minediamond.vortex.service.ui.StageProvider; -import tech.minediamond.vortex.service.ui.WindowAnimator; +import tech.minediamond.vortex.service.ui.*; import tech.minediamond.vortex.ui.component.SimpleHoverTooltip; import tech.minediamond.vortex.util.BindingUtils; import java.io.IOException; import java.util.HashMap; import java.util.Map; -import java.util.Optional; import static tech.minediamond.vortex.model.ui.Theme.*; @@ -71,8 +68,6 @@ public class MainWindow { private final I18nService i18n; private final AutoOperateService autoOperateService; - private static ContentPanel currentContentPanel; - @FXML private AnchorPane mainWindow; @FXML @@ -84,11 +79,14 @@ public class MainWindow { @FXML private ToggleButton quickEditBtn; @FXML + private ToggleButton settingBtn; + @FXML private Button themeSwitchBtn; @FXML private Button hideWindowBtn; //缓存已经加载的视图 private final Map viewCache = new HashMap<>(); + private final ObjectProperty currentContentPanelProperty = new SimpleObjectProperty<>(ContentPanel.EDITORPANEL); private double xOffset = 0; private double yOffset = 0; @@ -122,7 +120,7 @@ public void initialize() { handleDragWindow(); initUIComponent(); - loadOrGetView(ContentPanel.EDITORPANEL); + loadOrGetView(currentContentPanelProperty.get()); mainToggleGroup.selectToggle(quickEditBtn); } @@ -183,8 +181,17 @@ public void initUIComponent() { mainToggleGroup.selectToggle(oldValue); } }); + + currentContentPanelProperty.addListener((observable, oldValue, newValue) -> { + loadOrGetView(newValue); + switch (newValue) { + case EDITORPANEL -> mainToggleGroup.selectToggle(quickEditBtn); + case SETTINGPANEL -> mainToggleGroup.selectToggle(settingBtn); + } + }); } + /** * 设置主窗口的属性 */ @@ -246,10 +253,6 @@ public void setupWindowListeners() { * @param fxmlFileName 文件名 */ private void loadOrGetView(ContentPanel fxmlFileName) { - if (fxmlFileName == currentContentPanel) { - log.info("原页面:{},新页面:{},页面一致", fxmlFileName.getFileName(), currentContentPanel.getFileName()); - return; - } String fileName = fxmlFileName.getFileName(); Parent view = viewCache.get(fileName); @@ -266,25 +269,24 @@ private void loadOrGetView(ContentPanel fxmlFileName) { AnchorPane.setBottomAnchor(view, 0.0); AnchorPane.setLeftAnchor(view, 0.0); AnchorPane.setRightAnchor(view, 0.0); - log.info("原页面:{},新页面:{},从文件加载新页面", Optional.ofNullable(currentContentPanel).map(ContentPanel::getFileName).orElse("无"), fxmlFileName.getFileName()); + log.info("加载新页面:{},从文件加载新页面", fxmlFileName.getFileName()); } catch (IOException e) { log.error("加载 {} 页面出现错误: ", fileName, e); return; } } else { - log.info("原页面:{},新页面:{},从缓存加载新页面", Optional.ofNullable(currentContentPanel).map(ContentPanel::getFileName).orElse("无"), fxmlFileName.getFileName()); + log.info("加载新页面:{},从缓存加载新页面", fxmlFileName.getFileName()); } - currentContentPanel = fxmlFileName; //更新tabWindow tabWindow.getChildren().setAll(view); } public void showEditorPanel(ActionEvent actionEvent) { - loadOrGetView(ContentPanel.EDITORPANEL); + currentContentPanelProperty.set(ContentPanel.EDITORPANEL); } public void showSettingPanel(ActionEvent actionEvent) { - loadOrGetView(ContentPanel.SETTINGPANEL); + currentContentPanelProperty.set(ContentPanel.SETTINGPANEL); } } From 0b73c87a417dc4a981e746c94c7d030ec4795241 Mon Sep 17 00:00:00 2001 From: mine_ Date: Tue, 16 Sep 2025 10:43:22 +0800 Subject: [PATCH 02/12] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E7=95=8C=E9=9D=A2=EF=BC=88=E7=9B=AE=E5=89=8D=E6=98=AF?= =?UTF-8?q?=E7=A9=BA=E5=A3=B3=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vortex/model/ui/ContentPanel.java | 5 +-- .../vortex/ui/controller/MainWindow.java | 16 ++++++--- .../vortex/ui/controller/SearchPanel.java | 24 +++++++++++++ .../minediamond/vortex/ui/main-window.fxml | 2 +- .../minediamond/vortex/ui/searchPanel.fxml | 34 +++++++++++++++++++ 5 files changed, 73 insertions(+), 8 deletions(-) create mode 100644 src/main/java/tech/minediamond/vortex/ui/controller/SearchPanel.java create mode 100644 src/main/resources/tech/minediamond/vortex/ui/searchPanel.fxml diff --git a/src/main/java/tech/minediamond/vortex/model/ui/ContentPanel.java b/src/main/java/tech/minediamond/vortex/model/ui/ContentPanel.java index deff287..bad95ef 100644 --- a/src/main/java/tech/minediamond/vortex/model/ui/ContentPanel.java +++ b/src/main/java/tech/minediamond/vortex/model/ui/ContentPanel.java @@ -20,8 +20,9 @@ package tech.minediamond.vortex.model.ui; public enum ContentPanel { - EDITORPANEL("editorPanel.fxml"), - SETTINGPANEL("settingPanel.fxml"); + EDITOR_PANEL("editorPanel.fxml"), + SETTING_PANEL("settingPanel.fxml"), + SEARCH_PANEL("searchPanel.fxml"); private final String fileName; diff --git a/src/main/java/tech/minediamond/vortex/ui/controller/MainWindow.java b/src/main/java/tech/minediamond/vortex/ui/controller/MainWindow.java index f598242..090377d 100644 --- a/src/main/java/tech/minediamond/vortex/ui/controller/MainWindow.java +++ b/src/main/java/tech/minediamond/vortex/ui/controller/MainWindow.java @@ -79,6 +79,8 @@ public class MainWindow { @FXML private ToggleButton quickEditBtn; @FXML + private ToggleButton searchBtn; + @FXML private ToggleButton settingBtn; @FXML private Button themeSwitchBtn; @@ -86,7 +88,7 @@ public class MainWindow { private Button hideWindowBtn; //缓存已经加载的视图 private final Map viewCache = new HashMap<>(); - private final ObjectProperty currentContentPanelProperty = new SimpleObjectProperty<>(ContentPanel.EDITORPANEL); + private final ObjectProperty currentContentPanelProperty = new SimpleObjectProperty<>(ContentPanel.EDITOR_PANEL); private double xOffset = 0; private double yOffset = 0; @@ -185,8 +187,9 @@ public void initUIComponent() { currentContentPanelProperty.addListener((observable, oldValue, newValue) -> { loadOrGetView(newValue); switch (newValue) { - case EDITORPANEL -> mainToggleGroup.selectToggle(quickEditBtn); - case SETTINGPANEL -> mainToggleGroup.selectToggle(settingBtn); + case EDITOR_PANEL -> mainToggleGroup.selectToggle(quickEditBtn); + case SETTING_PANEL -> mainToggleGroup.selectToggle(settingBtn); + case SEARCH_PANEL -> mainToggleGroup.selectToggle(searchBtn); } }); } @@ -282,11 +285,14 @@ private void loadOrGetView(ContentPanel fxmlFileName) { } public void showEditorPanel(ActionEvent actionEvent) { - currentContentPanelProperty.set(ContentPanel.EDITORPANEL); + currentContentPanelProperty.set(ContentPanel.EDITOR_PANEL); } public void showSettingPanel(ActionEvent actionEvent) { - currentContentPanelProperty.set(ContentPanel.SETTINGPANEL); + currentContentPanelProperty.set(ContentPanel.SETTING_PANEL); } + public void showSearchPanel(ActionEvent actionEvent) { + currentContentPanelProperty.set(ContentPanel.SEARCH_PANEL); + } } diff --git a/src/main/java/tech/minediamond/vortex/ui/controller/SearchPanel.java b/src/main/java/tech/minediamond/vortex/ui/controller/SearchPanel.java new file mode 100644 index 0000000..d92bf7e --- /dev/null +++ b/src/main/java/tech/minediamond/vortex/ui/controller/SearchPanel.java @@ -0,0 +1,24 @@ +/* + * Vortex + * Copyright (C) 2025 Mine-diamond + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package tech.minediamond.vortex.ui.controller; + +public class SearchPanel { + +} diff --git a/src/main/resources/tech/minediamond/vortex/ui/main-window.fxml b/src/main/resources/tech/minediamond/vortex/ui/main-window.fxml index e9ea5ce..1ee3379 100644 --- a/src/main/resources/tech/minediamond/vortex/ui/main-window.fxml +++ b/src/main/resources/tech/minediamond/vortex/ui/main-window.fxml @@ -42,7 +42,7 @@ - + diff --git a/src/main/resources/tech/minediamond/vortex/ui/searchPanel.fxml b/src/main/resources/tech/minediamond/vortex/ui/searchPanel.fxml new file mode 100644 index 0000000..d5fe0a2 --- /dev/null +++ b/src/main/resources/tech/minediamond/vortex/ui/searchPanel.fxml @@ -0,0 +1,34 @@ + + + + + + + + + + + +