⚡️ 优化代码逻辑
This commit is contained in:
parent
5b5fdaadd7
commit
e1a058d891
@ -1,7 +1,6 @@
|
|||||||
package org.jcnc.jnotepad.Interface;
|
package org.jcnc.jnotepad.Interface;
|
||||||
|
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
import javafx.scene.layout.HBox;
|
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
|
|
||||||
public interface VBoxAble {
|
public interface VBoxAble {
|
||||||
|
|||||||
@ -4,7 +4,6 @@ package org.jcnc.jnotepad;
|
|||||||
import atlantafx.base.theme.PrimerLight;
|
import atlantafx.base.theme.PrimerLight;
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.image.Image;
|
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import org.jcnc.jnotepad.app.i18n.UIResourceBundle;
|
import org.jcnc.jnotepad.app.i18n.UIResourceBundle;
|
||||||
@ -13,6 +12,7 @@ import org.jcnc.jnotepad.constants.TextConstants;
|
|||||||
import org.jcnc.jnotepad.controller.i18n.LocalizationController;
|
import org.jcnc.jnotepad.controller.i18n.LocalizationController;
|
||||||
import org.jcnc.jnotepad.controller.manager.Controller;
|
import org.jcnc.jnotepad.controller.manager.Controller;
|
||||||
import org.jcnc.jnotepad.manager.ThreadPoolManager;
|
import org.jcnc.jnotepad.manager.ThreadPoolManager;
|
||||||
|
import org.jcnc.jnotepad.tool.UiUtil;
|
||||||
import org.jcnc.jnotepad.view.manager.ViewManager;
|
import org.jcnc.jnotepad.view.manager.ViewManager;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -38,7 +38,6 @@ public class LunchApp extends Application {
|
|||||||
Pane root = new Pane();
|
Pane root = new Pane();
|
||||||
double width = AppConstants.SCREEN_WIDTH;
|
double width = AppConstants.SCREEN_WIDTH;
|
||||||
double length = AppConstants.SCREEN_LENGTH;
|
double length = AppConstants.SCREEN_LENGTH;
|
||||||
String icon = AppConstants.APP_ICON;
|
|
||||||
scene = new Scene(root, width, length);
|
scene = new Scene(root, width, length);
|
||||||
Application.setUserAgentStylesheet(new PrimerLight().getUserAgentStylesheet());
|
Application.setUserAgentStylesheet(new PrimerLight().getUserAgentStylesheet());
|
||||||
scene.getStylesheets().add(Objects.requireNonNull(getClass().getResource("/css/styles.css")).toExternalForm());
|
scene.getStylesheets().add(Objects.requireNonNull(getClass().getResource("/css/styles.css")).toExternalForm());
|
||||||
@ -47,7 +46,7 @@ public class LunchApp extends Application {
|
|||||||
primaryStage.setWidth(width);
|
primaryStage.setWidth(width);
|
||||||
primaryStage.setHeight(length);
|
primaryStage.setHeight(length);
|
||||||
primaryStage.setScene(scene);
|
primaryStage.setScene(scene);
|
||||||
primaryStage.getIcons().add(new Image(Objects.requireNonNull(getClass().getResource(icon)).toString()));
|
primaryStage.getIcons().add(UiUtil.getIcon());
|
||||||
primaryStage.show();
|
primaryStage.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,17 +2,7 @@ package org.jcnc.jnotepad.controller.event.handler.tool;
|
|||||||
|
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
import javafx.scene.Scene;
|
|
||||||
import javafx.scene.control.Label;
|
|
||||||
import javafx.scene.layout.VBox;
|
|
||||||
import javafx.stage.Stage;
|
|
||||||
import org.jcnc.jnotepad.app.i18n.UIResourceBundle;
|
|
||||||
import org.jcnc.jnotepad.constants.TextConstants;
|
|
||||||
import org.jcnc.jnotepad.tool.UiUtil;
|
|
||||||
import org.jcnc.jnotepad.ui.module.LineNumberTextArea;
|
|
||||||
import org.jcnc.jnotepad.ui.root.center.tab.JNotepadTab;
|
|
||||||
import org.jcnc.jnotepad.ui.setStage.SetStage;
|
import org.jcnc.jnotepad.ui.setStage.SetStage;
|
||||||
import org.jcnc.jnotepad.view.manager.ViewManager;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,12 +1,16 @@
|
|||||||
package org.jcnc.jnotepad.tool;
|
package org.jcnc.jnotepad.tool;
|
||||||
|
|
||||||
|
import javafx.scene.image.Image;
|
||||||
import javafx.stage.Window;
|
import javafx.stage.Window;
|
||||||
import org.jcnc.jnotepad.ui.root.top.menu.JNotepadMenuBar;
|
import org.jcnc.jnotepad.constants.AppConstants;
|
||||||
import org.jcnc.jnotepad.ui.root.bottom.status.JNotepadStatusBox;
|
import org.jcnc.jnotepad.ui.root.bottom.status.JNotepadStatusBox;
|
||||||
import org.jcnc.jnotepad.ui.root.center.tab.JNotepadTab;
|
import org.jcnc.jnotepad.ui.root.center.tab.JNotepadTab;
|
||||||
import org.jcnc.jnotepad.ui.root.center.tab.JNotepadTabPane;
|
import org.jcnc.jnotepad.ui.root.center.tab.JNotepadTabPane;
|
||||||
|
import org.jcnc.jnotepad.ui.root.top.menu.JNotepadMenuBar;
|
||||||
import org.jcnc.jnotepad.view.manager.ViewManager;
|
import org.jcnc.jnotepad.view.manager.ViewManager;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UI工具<br>
|
* UI工具<br>
|
||||||
* 封装了项目所有的UI组件,以减少组件单例模式造成代码的复杂性
|
* 封装了项目所有的UI组件,以减少组件单例模式造成代码的复杂性
|
||||||
@ -33,6 +37,20 @@ public class UiUtil {
|
|||||||
* 菜单栏组件
|
* 菜单栏组件
|
||||||
*/
|
*/
|
||||||
private static final JNotepadMenuBar MENU_BAR = JNotepadMenuBar.getInstance();
|
private static final JNotepadMenuBar MENU_BAR = JNotepadMenuBar.getInstance();
|
||||||
|
/**
|
||||||
|
* 应用程序图标
|
||||||
|
*/
|
||||||
|
private static final Image ICON = new Image(Objects.requireNonNull(UiUtil.class.getResource(AppConstants.APP_ICON)).toString());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取应用程序图标
|
||||||
|
*
|
||||||
|
* @return javafx.scene.image.Image
|
||||||
|
* @since 2023/8/30 11:03
|
||||||
|
*/
|
||||||
|
public static Image getIcon() {
|
||||||
|
return ICON;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取标签页布局组件
|
* 获取标签页布局组件
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
package org.jcnc.jnotepad.ui.root.top.tools;
|
package org.jcnc.jnotepad.ui.root.top.tools;
|
||||||
|
|
||||||
import javafx.geometry.Pos;
|
|
||||||
import javafx.scene.control.Button;
|
|
||||||
import javafx.scene.layout.HBox;
|
import javafx.scene.layout.HBox;
|
||||||
import javafx.scene.layout.Priority;
|
import javafx.scene.layout.Priority;
|
||||||
|
|
||||||
|
|||||||
@ -1,18 +1,25 @@
|
|||||||
package org.jcnc.jnotepad.ui.setStage;
|
package org.jcnc.jnotepad.ui.setStage;
|
||||||
|
|
||||||
import javafx.geometry.Insets;
|
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.layout.GridPane;
|
import javafx.scene.control.ListView;
|
||||||
import javafx.scene.layout.HBox;
|
import javafx.scene.control.SplitPane;
|
||||||
|
import javafx.scene.control.TitledPane;
|
||||||
import javafx.scene.layout.StackPane;
|
import javafx.scene.layout.StackPane;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
import org.jcnc.jnotepad.tool.UiUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 许轲
|
||||||
|
*/
|
||||||
public class SetStage {
|
public class SetStage {
|
||||||
|
|
||||||
private static final SetStage SET_STAGE = new SetStage();
|
private static final SetStage SET_STAGE = new SetStage();
|
||||||
private StackPane contentDisplay; // Declare contentDisplay as a class member
|
/**
|
||||||
|
* Declare contentDisplay as a class member
|
||||||
|
*/
|
||||||
|
private StackPane contentDisplay;
|
||||||
|
|
||||||
public static SetStage getInstance() {
|
public static SetStage getInstance() {
|
||||||
return SET_STAGE;
|
return SET_STAGE;
|
||||||
@ -57,16 +64,17 @@ public class SetStage {
|
|||||||
titledPaneContainer.getChildren().addAll(generalPane, appearancePane, securityPane);
|
titledPaneContainer.getChildren().addAll(generalPane, appearancePane, securityPane);
|
||||||
|
|
||||||
// 创建一个占位符,用于显示右侧内容区域
|
// 创建一个占位符,用于显示右侧内容区域
|
||||||
StackPane contentDisplay = new StackPane(new Label("从左侧选择设置以显示内容"));
|
StackPane stackPane = new StackPane(new Label("从左侧选择设置以显示内容"));
|
||||||
|
|
||||||
// 设置 TitledPanes 的点击事件监听器
|
// 设置 TitledPanes 的点击事件监听器
|
||||||
generalPane.setOnMouseClicked(event -> contentDisplay.getChildren().setAll(new Label("常规设置内容")));
|
generalPane.setOnMouseClicked(event -> stackPane.getChildren().setAll(new Label("常规设置内容")));
|
||||||
appearancePane.setOnMouseClicked(event -> contentDisplay.getChildren().setAll(new Label("外观设置内容")));
|
appearancePane.setOnMouseClicked(event -> stackPane.getChildren().setAll(new Label("外观设置内容")));
|
||||||
securityPane.setOnMouseClicked(event -> contentDisplay.getChildren().setAll(new Label("安全设置内容")));
|
securityPane.setOnMouseClicked(event -> stackPane.getChildren().setAll(new Label("安全设置内容")));
|
||||||
|
|
||||||
// 创建一个水平分割面板来容纳整个布局
|
// 创建一个水平分割面板来容纳整个布局
|
||||||
SplitPane splitPane = new SplitPane(titledPaneContainer, contentDisplay);
|
SplitPane splitPane = new SplitPane(titledPaneContainer, stackPane);
|
||||||
splitPane.setDividerPositions(0.3); // 设置分隔条位置
|
// 设置分隔条位置
|
||||||
|
splitPane.setDividerPositions(0.3);
|
||||||
|
|
||||||
// 创建场景
|
// 创建场景
|
||||||
Scene scene = new Scene(splitPane, 800, 600);
|
Scene scene = new Scene(splitPane, 800, 600);
|
||||||
@ -74,6 +82,7 @@ public class SetStage {
|
|||||||
// 设置场景并显示窗口
|
// 设置场景并显示窗口
|
||||||
setStage.setScene(scene);
|
setStage.setScene(scene);
|
||||||
setStage.setTitle("设置窗口");
|
setStage.setTitle("设置窗口");
|
||||||
|
setStage.getIcons().add(UiUtil.getIcon());
|
||||||
setStage.show();
|
setStage.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,10 +96,8 @@ public class SetStage {
|
|||||||
contentDisplay.getChildren().setAll(new Label(selectedItem + " 的设置内容"));
|
contentDisplay.getChildren().setAll(new Label(selectedItem + " 的设置内容"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return listView;
|
return listView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,9 +3,9 @@ package org.jcnc.jnotepad.view.manager;
|
|||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.layout.BorderPane;
|
import javafx.scene.layout.BorderPane;
|
||||||
import org.jcnc.jnotepad.exception.AppException;
|
import org.jcnc.jnotepad.exception.AppException;
|
||||||
import org.jcnc.jnotepad.ui.root.top.RootTopVBox;
|
|
||||||
import org.jcnc.jnotepad.ui.root.bottom.status.JNotepadStatusBox;
|
import org.jcnc.jnotepad.ui.root.bottom.status.JNotepadStatusBox;
|
||||||
import org.jcnc.jnotepad.ui.root.center.tab.JNotepadTabPane;
|
import org.jcnc.jnotepad.ui.root.center.tab.JNotepadTabPane;
|
||||||
|
import org.jcnc.jnotepad.ui.root.top.RootTopVBox;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user