!52 feature-I7WZJW 增加设置按钮和增加设置页面,修改UI代码结构
Merge pull request !52 from Luke/release-v1.1.12
This commit is contained in:
commit
5b5fdaadd7
@ -16,14 +16,16 @@ module org.jcnc.jnotepad {
|
||||
exports org.jcnc.jnotepad;
|
||||
exports org.jcnc.jnotepad.tool;
|
||||
exports org.jcnc.jnotepad.Interface;
|
||||
exports org.jcnc.jnotepad.controller.event.handler;
|
||||
exports org.jcnc.jnotepad.controller.manager;
|
||||
exports org.jcnc.jnotepad.view.manager;
|
||||
exports org.jcnc.jnotepad.constants;
|
||||
exports org.jcnc.jnotepad.ui;
|
||||
exports org.jcnc.jnotepad.controller.i18n;
|
||||
exports org.jcnc.jnotepad.ui.tab;
|
||||
exports org.jcnc.jnotepad.ui.status;
|
||||
exports org.jcnc.jnotepad.ui.menu;
|
||||
exports org.jcnc.jnotepad.ui.root.center.tab;
|
||||
exports org.jcnc.jnotepad.ui.root.bottom.status;
|
||||
exports org.jcnc.jnotepad.ui.root.top.menu;
|
||||
opens org.jcnc.jnotepad.app.config;
|
||||
exports org.jcnc.jnotepad.ui.module;
|
||||
exports org.jcnc.jnotepad.ui.root.top.tools;
|
||||
exports org.jcnc.jnotepad.controller.event.handler.tool;
|
||||
exports org.jcnc.jnotepad.controller.event.handler.menuBar;
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package org.jcnc.jnotepad.Interface;
|
||||
|
||||
import javafx.scene.Node;
|
||||
|
||||
|
||||
public interface BorderPaneAble {
|
||||
|
||||
void setTopComponent(Node node);
|
||||
|
||||
void setBottomComponent(Node node);
|
||||
|
||||
void setLeftComponent(Node node);
|
||||
|
||||
void setRightComponent(Node node);
|
||||
|
||||
void setCenterComponent(Node node);
|
||||
|
||||
|
||||
}
|
||||
@ -7,7 +7,7 @@ import java.util.List;
|
||||
*
|
||||
* @author 许轲
|
||||
*/
|
||||
public interface ControllerInterface {
|
||||
public interface ControllerAble {
|
||||
|
||||
/**
|
||||
* 打开关联文件并创建 TextArea
|
||||
12
src/main/java/org/jcnc/jnotepad/Interface/HBoxAble.java
Normal file
12
src/main/java/org/jcnc/jnotepad/Interface/HBoxAble.java
Normal file
@ -0,0 +1,12 @@
|
||||
package org.jcnc.jnotepad.Interface;
|
||||
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.layout.HBox;
|
||||
|
||||
public interface HBoxAble {
|
||||
|
||||
void addChild(Node node);
|
||||
|
||||
void addChild(Node... nodes);
|
||||
HBox getHBox();
|
||||
}
|
||||
13
src/main/java/org/jcnc/jnotepad/Interface/VBoxAble.java
Normal file
13
src/main/java/org/jcnc/jnotepad/Interface/VBoxAble.java
Normal file
@ -0,0 +1,13 @@
|
||||
package org.jcnc.jnotepad.Interface;
|
||||
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.VBox;
|
||||
|
||||
public interface VBoxAble {
|
||||
void addChild(Node node);
|
||||
|
||||
void addChild(Node... nodes);
|
||||
|
||||
VBox getVBox();
|
||||
}
|
||||
@ -1,12 +1,12 @@
|
||||
package org.jcnc.jnotepad.controller.event.handler;
|
||||
package org.jcnc.jnotepad.controller.event.handler.menuBar;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import org.jcnc.jnotepad.app.i18n.UIResourceBundle;
|
||||
import org.jcnc.jnotepad.constants.TextConstants;
|
||||
import org.jcnc.jnotepad.tool.UiUtil;
|
||||
import org.jcnc.jnotepad.ui.LineNumberTextArea;
|
||||
import org.jcnc.jnotepad.ui.tab.JNotepadTab;
|
||||
import org.jcnc.jnotepad.ui.module.LineNumberTextArea;
|
||||
import org.jcnc.jnotepad.ui.root.center.tab.JNotepadTab;
|
||||
import org.jcnc.jnotepad.view.manager.ViewManager;
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package org.jcnc.jnotepad.controller.event.handler;
|
||||
package org.jcnc.jnotepad.controller.event.handler.menuBar;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import org.jcnc.jnotepad.controller.config.AppConfigController;
|
||||
@ -1,4 +1,4 @@
|
||||
package org.jcnc.jnotepad.controller.event.handler;
|
||||
package org.jcnc.jnotepad.controller.event.handler.menuBar;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.concurrent.Task;
|
||||
@ -9,8 +9,8 @@ import org.jcnc.jnotepad.manager.ThreadPoolManager;
|
||||
import org.jcnc.jnotepad.tool.EncodingDetector;
|
||||
import org.jcnc.jnotepad.tool.LogUtil;
|
||||
import org.jcnc.jnotepad.tool.UiUtil;
|
||||
import org.jcnc.jnotepad.ui.LineNumberTextArea;
|
||||
import org.jcnc.jnotepad.ui.tab.JNotepadTab;
|
||||
import org.jcnc.jnotepad.ui.module.LineNumberTextArea;
|
||||
import org.jcnc.jnotepad.ui.root.center.tab.JNotepadTab;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
@ -1,4 +1,4 @@
|
||||
package org.jcnc.jnotepad.controller.event.handler;
|
||||
package org.jcnc.jnotepad.controller.event.handler.menuBar;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
@ -7,7 +7,7 @@ import javafx.scene.input.KeyCode;
|
||||
import javafx.stage.FileChooser;
|
||||
import org.jcnc.jnotepad.tool.LogUtil;
|
||||
import org.jcnc.jnotepad.tool.UiUtil;
|
||||
import org.jcnc.jnotepad.ui.tab.JNotepadTab;
|
||||
import org.jcnc.jnotepad.ui.root.center.tab.JNotepadTab;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
@ -1,4 +1,4 @@
|
||||
package org.jcnc.jnotepad.controller.event.handler;
|
||||
package org.jcnc.jnotepad.controller.event.handler.menuBar;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import org.jcnc.jnotepad.tool.LogUtil;
|
||||
@ -1,4 +1,4 @@
|
||||
package org.jcnc.jnotepad.controller.event.handler;
|
||||
package org.jcnc.jnotepad.controller.event.handler.menuBar;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
@ -7,7 +7,7 @@ import org.jcnc.jnotepad.controller.config.AppConfigController;
|
||||
import org.jcnc.jnotepad.controller.i18n.LocalizationController;
|
||||
import org.jcnc.jnotepad.tool.LogUtil;
|
||||
import org.jcnc.jnotepad.tool.UiUtil;
|
||||
import org.jcnc.jnotepad.ui.tab.JNotepadTab;
|
||||
import org.jcnc.jnotepad.ui.root.center.tab.JNotepadTab;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
@ -0,0 +1,38 @@
|
||||
package org.jcnc.jnotepad.controller.event.handler.tool;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
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.view.manager.ViewManager;
|
||||
|
||||
|
||||
/**
|
||||
* 设置按钮事件的事件处理程序。
|
||||
* <p>
|
||||
* 当用户点击设置的时候,将打开设置窗口。
|
||||
*
|
||||
* @author 许轲
|
||||
*/
|
||||
public class SetBtn implements EventHandler<ActionEvent> {
|
||||
|
||||
/**
|
||||
* 打开设置窗口处理事件
|
||||
*
|
||||
* @param event 事件对象
|
||||
*/
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
SetStage.getInstance();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,8 +1,8 @@
|
||||
package org.jcnc.jnotepad.controller.manager;
|
||||
|
||||
import org.jcnc.jnotepad.Interface.ControllerInterface;
|
||||
import org.jcnc.jnotepad.controller.event.handler.NewFile;
|
||||
import org.jcnc.jnotepad.controller.event.handler.OpenFile;
|
||||
import org.jcnc.jnotepad.Interface.ControllerAble;
|
||||
import org.jcnc.jnotepad.controller.event.handler.menuBar.NewFile;
|
||||
import org.jcnc.jnotepad.controller.event.handler.menuBar.OpenFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
@ -13,7 +13,7 @@ import java.util.List;
|
||||
*
|
||||
* @author 许轲
|
||||
*/
|
||||
public class Controller implements ControllerInterface {
|
||||
public class Controller implements ControllerAble {
|
||||
|
||||
private static final Controller INSTANCE = new Controller();
|
||||
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
package org.jcnc.jnotepad.tool;
|
||||
|
||||
import javafx.stage.Window;
|
||||
import org.jcnc.jnotepad.ui.menu.JNotepadMenuBar;
|
||||
import org.jcnc.jnotepad.ui.status.JNotepadStatusBox;
|
||||
import org.jcnc.jnotepad.ui.tab.JNotepadTab;
|
||||
import org.jcnc.jnotepad.ui.tab.JNotepadTabPane;
|
||||
import org.jcnc.jnotepad.ui.root.top.menu.JNotepadMenuBar;
|
||||
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.JNotepadTabPane;
|
||||
import org.jcnc.jnotepad.view.manager.ViewManager;
|
||||
|
||||
/**
|
||||
@ -32,12 +32,12 @@ public class UiUtil {
|
||||
/**
|
||||
* 菜单栏组件
|
||||
*/
|
||||
private static final JNotepadMenuBar MENU_BAR = JNotepadMenuBar.getMenuBar();
|
||||
private static final JNotepadMenuBar MENU_BAR = JNotepadMenuBar.getInstance();
|
||||
|
||||
/**
|
||||
* 获取标签页布局组件
|
||||
*
|
||||
* @return org.jcnc.jnotepad.ui.tab.JNotepadTabPane
|
||||
* @return org.jcnc.jnotepad.ui.root.center.tab.JNotepadTabPane
|
||||
* @apiNote JNotepadTabPane.getInstance()
|
||||
* @see JNotepadTabPane
|
||||
*/
|
||||
@ -49,7 +49,7 @@ public class UiUtil {
|
||||
/**
|
||||
* 获取标签页组件
|
||||
*
|
||||
* @return org.jcnc.jnotepad.ui.tab.JNotepadTab
|
||||
* @return org.jcnc.jnotepad.ui.root.center.tab.JNotepadTab
|
||||
* @apiNote JNotepadTabPane.getInstance().getSelected()<br>获取当前选中的标签页
|
||||
* @see JNotepadTabPane
|
||||
*/
|
||||
@ -83,7 +83,7 @@ public class UiUtil {
|
||||
/**
|
||||
* 获取状态栏组件
|
||||
*
|
||||
* @return org.jcnc.jnotepad.ui.status.JNotepadStatusBox
|
||||
* @return org.jcnc.jnotepad.ui.root.bottom.status.JNotepadStatusBox
|
||||
* @since 2023/8/29 14:14
|
||||
*/
|
||||
public static JNotepadStatusBox getStatusBox() {
|
||||
@ -93,7 +93,7 @@ public class UiUtil {
|
||||
/**
|
||||
* 获取菜单栏组件
|
||||
*
|
||||
* @return org.jcnc.jnotepad.ui.menu.JNotepadMenuBar
|
||||
* @return org.jcnc.jnotepad.ui.root.top.menu.JNotepadMenuBar
|
||||
* @since 2023/8/29 14:15
|
||||
*/
|
||||
public static JNotepadMenuBar getMenuBar() {
|
||||
|
||||
@ -0,0 +1,34 @@
|
||||
package org.jcnc.jnotepad.ui.module;
|
||||
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import org.jcnc.jnotepad.Interface.BorderPaneAble;
|
||||
|
||||
public abstract class AbstractBorderPane extends BorderPane implements BorderPaneAble {
|
||||
|
||||
@Override
|
||||
public void setTopComponent(Node node) {
|
||||
setTop(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBottomComponent(Node node) {
|
||||
setBottom(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLeftComponent(Node node) {
|
||||
setLeft(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRightComponent(Node node) {
|
||||
setRight(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCenterComponent(Node node) {
|
||||
setCenter(node);
|
||||
}
|
||||
|
||||
}
|
||||
28
src/main/java/org/jcnc/jnotepad/ui/module/AbstractHBox.java
Normal file
28
src/main/java/org/jcnc/jnotepad/ui/module/AbstractHBox.java
Normal file
@ -0,0 +1,28 @@
|
||||
package org.jcnc.jnotepad.ui.module;
|
||||
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.layout.HBox;
|
||||
import org.jcnc.jnotepad.Interface.HBoxAble;
|
||||
|
||||
public abstract class AbstractHBox extends HBox implements HBoxAble {
|
||||
private final HBox hBox;
|
||||
|
||||
public AbstractHBox() {
|
||||
hBox = new HBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChild(Node node) {
|
||||
hBox.getChildren().add(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChild(Node... nodes) {
|
||||
hBox.getChildren().addAll(nodes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HBox getHBox() {
|
||||
return hBox;
|
||||
}
|
||||
}
|
||||
29
src/main/java/org/jcnc/jnotepad/ui/module/AbstractVBox.java
Normal file
29
src/main/java/org/jcnc/jnotepad/ui/module/AbstractVBox.java
Normal file
@ -0,0 +1,29 @@
|
||||
package org.jcnc.jnotepad.ui.module;
|
||||
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.layout.VBox;
|
||||
import org.jcnc.jnotepad.Interface.VBoxAble;
|
||||
|
||||
public abstract class AbstractVBox extends VBox implements VBoxAble {
|
||||
|
||||
private final VBox vBox;
|
||||
|
||||
public AbstractVBox() {
|
||||
vBox = new VBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChild(Node node) {
|
||||
vBox.getChildren().add(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChild(Node... nodes) {
|
||||
vBox.getChildren().addAll(nodes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VBox getVBox() {
|
||||
return vBox;
|
||||
}
|
||||
}
|
||||
@ -1,13 +1,13 @@
|
||||
package org.jcnc.jnotepad.ui;
|
||||
package org.jcnc.jnotepad.ui.module;
|
||||
|
||||
import javafx.beans.property.StringProperty;
|
||||
import javafx.scene.control.TextArea;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import org.jcnc.jnotepad.controller.config.AppConfigController;
|
||||
import org.jcnc.jnotepad.tool.LogUtil;
|
||||
import org.jcnc.jnotepad.ui.status.JNotepadStatusBox;
|
||||
import org.jcnc.jnotepad.ui.tab.JNotepadTab;
|
||||
import org.jcnc.jnotepad.ui.tab.JNotepadTabPane;
|
||||
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.JNotepadTabPane;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
@ -1,13 +1,13 @@
|
||||
package org.jcnc.jnotepad.ui.status;
|
||||
package org.jcnc.jnotepad.ui.root.bottom.status;
|
||||
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TextArea;
|
||||
import javafx.scene.layout.HBox;
|
||||
import org.jcnc.jnotepad.app.i18n.UIResourceBundle;
|
||||
import org.jcnc.jnotepad.constants.TextConstants;
|
||||
import org.jcnc.jnotepad.ui.tab.JNotepadTab;
|
||||
import org.jcnc.jnotepad.ui.tab.JNotepadTabPane;
|
||||
import org.jcnc.jnotepad.ui.module.AbstractHBox;
|
||||
import org.jcnc.jnotepad.ui.root.center.tab.JNotepadTab;
|
||||
import org.jcnc.jnotepad.ui.root.center.tab.JNotepadTabPane;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
@ -18,7 +18,7 @@ import java.nio.charset.Charset;
|
||||
*
|
||||
* @author songdragon
|
||||
*/
|
||||
public class JNotepadStatusBox extends HBox {
|
||||
public class JNotepadStatusBox extends AbstractHBox {
|
||||
|
||||
private static final JNotepadStatusBox STATUS_BOX = new JNotepadStatusBox();
|
||||
/**
|
||||
@ -1,8 +1,8 @@
|
||||
package org.jcnc.jnotepad.ui.tab;
|
||||
package org.jcnc.jnotepad.ui.root.center.tab;
|
||||
|
||||
import javafx.scene.control.Tab;
|
||||
import org.jcnc.jnotepad.controller.config.AppConfigController;
|
||||
import org.jcnc.jnotepad.ui.LineNumberTextArea;
|
||||
import org.jcnc.jnotepad.ui.module.LineNumberTextArea;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package org.jcnc.jnotepad.ui.tab;
|
||||
package org.jcnc.jnotepad.ui.root.center.tab;
|
||||
|
||||
import javafx.scene.control.TabPane;
|
||||
import org.jcnc.jnotepad.controller.config.AppConfigController;
|
||||
20
src/main/java/org/jcnc/jnotepad/ui/root/top/RootTopVBox.java
Normal file
20
src/main/java/org/jcnc/jnotepad/ui/root/top/RootTopVBox.java
Normal file
@ -0,0 +1,20 @@
|
||||
package org.jcnc.jnotepad.ui.root.top;
|
||||
|
||||
import javafx.scene.layout.VBox;
|
||||
import org.jcnc.jnotepad.ui.root.top.menu.JNotepadMenuBar;
|
||||
import org.jcnc.jnotepad.ui.root.top.tools.ToolHBox;
|
||||
|
||||
public class RootTopVBox extends VBox {
|
||||
private static final RootTopVBox INSTANCE = new RootTopVBox();
|
||||
|
||||
private RootTopVBox() {
|
||||
// 在构造函数中初始化
|
||||
getChildren().add(JNotepadMenuBar.getInstance());
|
||||
getChildren().add(ToolHBox.getInstance());
|
||||
}
|
||||
|
||||
public static RootTopVBox getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package org.jcnc.jnotepad.ui.menu;
|
||||
package org.jcnc.jnotepad.ui.root.top.menu;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.scene.control.*;
|
||||
@ -7,11 +7,13 @@ import javafx.stage.Stage;
|
||||
import org.jcnc.jnotepad.app.config.AppConfig;
|
||||
import org.jcnc.jnotepad.app.i18n.UIResourceBundle;
|
||||
import org.jcnc.jnotepad.controller.config.AppConfigController;
|
||||
import org.jcnc.jnotepad.controller.event.handler.*;
|
||||
import org.jcnc.jnotepad.controller.event.handler.menuBar.*;
|
||||
import org.jcnc.jnotepad.controller.event.handler.tool.SetBtn;
|
||||
import org.jcnc.jnotepad.controller.i18n.LocalizationController;
|
||||
import org.jcnc.jnotepad.tool.LogUtil;
|
||||
import org.jcnc.jnotepad.ui.tab.JNotepadTab;
|
||||
import org.jcnc.jnotepad.ui.tab.JNotepadTabPane;
|
||||
import org.jcnc.jnotepad.ui.root.center.tab.JNotepadTab;
|
||||
import org.jcnc.jnotepad.ui.root.center.tab.JNotepadTabPane;
|
||||
import org.jcnc.jnotepad.ui.root.top.tools.JNotepadToolBar;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.util.*;
|
||||
@ -110,6 +112,14 @@ public class JNotepadMenuBar extends MenuBar {
|
||||
private RadioMenuItem englishItem;
|
||||
private final Map<String, MenuItem> itemMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 工具栏
|
||||
*/
|
||||
JNotepadToolBar toolBar = JNotepadToolBar.getInstance();
|
||||
|
||||
// 获取工具栏中的setButton
|
||||
Button setButton = toolBar.getSetButton();
|
||||
|
||||
/**
|
||||
* 设置当前语言选中状态
|
||||
*
|
||||
@ -264,7 +274,7 @@ public class JNotepadMenuBar extends MenuBar {
|
||||
pluginMenu.getItems().addAll(addItem, countItem);
|
||||
}
|
||||
|
||||
public static JNotepadMenuBar getMenuBar() {
|
||||
public static JNotepadMenuBar getInstance() {
|
||||
return MENU_BAR;
|
||||
}
|
||||
|
||||
@ -278,6 +288,7 @@ public class JNotepadMenuBar extends MenuBar {
|
||||
saveAsItem.setOnAction(new SaveAsFile());
|
||||
openConfigItem.setOnAction(new OpenConfig());
|
||||
renameItem.setOnAction(new RenameFile());
|
||||
setButton.setOnAction(new SetBtn());
|
||||
lineFeedItem.selectedProperty().addListener((observableValue, before, after) -> {
|
||||
// 1. 更新全局配置
|
||||
AppConfigController.getInstance().setAutoLineConfig(after);
|
||||
@ -0,0 +1,36 @@
|
||||
package org.jcnc.jnotepad.ui.root.top.tools;
|
||||
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToolBar;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
|
||||
public class JNotepadToolBar extends ToolBar {
|
||||
private static final JNotepadToolBar INSTANCE = new JNotepadToolBar();
|
||||
|
||||
Button setButton = new Button();
|
||||
|
||||
private JNotepadToolBar() {
|
||||
// 创建工具栏上的按钮
|
||||
Image image = new Image("tools.png"); // 替换为你的图片文件路径
|
||||
ImageView imageView = new ImageView(image);
|
||||
imageView.setFitWidth(10);
|
||||
imageView.setFitHeight(10);
|
||||
imageView.setScaleX(2.5); // 设置水平缩放比例
|
||||
imageView.setScaleY(2.5); // 设置垂直缩放比例
|
||||
// 设置缩放比例
|
||||
setButton.setGraphic(imageView);
|
||||
|
||||
// 将按钮添加到工具栏
|
||||
getItems().addAll(setButton);
|
||||
|
||||
}
|
||||
|
||||
public Button getSetButton() {
|
||||
return setButton;
|
||||
}
|
||||
|
||||
public static JNotepadToolBar getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
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.Priority;
|
||||
|
||||
public class ToolHBox extends HBox {
|
||||
private static final ToolHBox INSTANCE = new ToolHBox();
|
||||
|
||||
private ToolHBox() {
|
||||
|
||||
HBox.setHgrow(JNotepadToolBar.getInstance(), Priority.ALWAYS); // 设置子节点水平拉伸
|
||||
|
||||
getChildren().add(JNotepadToolBar.getInstance());
|
||||
}
|
||||
|
||||
public static ToolHBox getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
96
src/main/java/org/jcnc/jnotepad/ui/setStage/SetStage.java
Normal file
96
src/main/java/org/jcnc/jnotepad/ui/setStage/SetStage.java
Normal file
@ -0,0 +1,96 @@
|
||||
package org.jcnc.jnotepad.ui.setStage;
|
||||
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
public class SetStage {
|
||||
|
||||
private static final SetStage SET_STAGE = new SetStage();
|
||||
private StackPane contentDisplay; // Declare contentDisplay as a class member
|
||||
|
||||
public static SetStage getInstance() {
|
||||
return SET_STAGE;
|
||||
}
|
||||
|
||||
private SetStage() {
|
||||
openSetStage(new Stage());
|
||||
}
|
||||
|
||||
public void openSetStage(Stage setStage) {
|
||||
|
||||
contentDisplay = new StackPane(new Label("从左侧选择设置以显示内容"));
|
||||
|
||||
// 创建 TitledPane 组件
|
||||
TitledPane generalPane = new TitledPane("常规设置", createListView("常规设置项1", "常规设置项2"));
|
||||
TitledPane appearancePane = new TitledPane("外观设置", createListView("外观设置项1", "外观设置项2"));
|
||||
TitledPane securityPane = new TitledPane("安全设置", createListView("安全设置项1", "安全设置项2"));
|
||||
|
||||
generalPane.setOnMouseClicked(event -> {
|
||||
ListView<String> listView = (ListView<String>) generalPane.getContent();
|
||||
if (listView.getSelectionModel().getSelectedItem() != null) {
|
||||
contentDisplay.getChildren().setAll(new Label(listView.getSelectionModel().getSelectedItem() + " 的设置内容"));
|
||||
}
|
||||
});
|
||||
|
||||
appearancePane.setOnMouseClicked(event -> {
|
||||
ListView<String> listView = (ListView<String>) appearancePane.getContent();
|
||||
if (listView.getSelectionModel().getSelectedItem() != null) {
|
||||
contentDisplay.getChildren().setAll(new Label(listView.getSelectionModel().getSelectedItem() + " 的设置内容"));
|
||||
}
|
||||
});
|
||||
|
||||
securityPane.setOnMouseClicked(event -> {
|
||||
ListView<String> listView = (ListView<String>) securityPane.getContent();
|
||||
if (listView.getSelectionModel().getSelectedItem() != null) {
|
||||
contentDisplay.getChildren().setAll(new Label(listView.getSelectionModel().getSelectedItem() + " 的设置内容"));
|
||||
}
|
||||
});
|
||||
|
||||
// 创建一个 VBox 来容纳 TitledPanes
|
||||
VBox titledPaneContainer = new VBox(10);
|
||||
titledPaneContainer.getChildren().addAll(generalPane, appearancePane, securityPane);
|
||||
|
||||
// 创建一个占位符,用于显示右侧内容区域
|
||||
StackPane contentDisplay = new StackPane(new Label("从左侧选择设置以显示内容"));
|
||||
|
||||
// 设置 TitledPanes 的点击事件监听器
|
||||
generalPane.setOnMouseClicked(event -> contentDisplay.getChildren().setAll(new Label("常规设置内容")));
|
||||
appearancePane.setOnMouseClicked(event -> contentDisplay.getChildren().setAll(new Label("外观设置内容")));
|
||||
securityPane.setOnMouseClicked(event -> contentDisplay.getChildren().setAll(new Label("安全设置内容")));
|
||||
|
||||
// 创建一个水平分割面板来容纳整个布局
|
||||
SplitPane splitPane = new SplitPane(titledPaneContainer, contentDisplay);
|
||||
splitPane.setDividerPositions(0.3); // 设置分隔条位置
|
||||
|
||||
// 创建场景
|
||||
Scene scene = new Scene(splitPane, 800, 600);
|
||||
|
||||
// 设置场景并显示窗口
|
||||
setStage.setScene(scene);
|
||||
setStage.setTitle("设置窗口");
|
||||
setStage.show();
|
||||
}
|
||||
|
||||
private ListView<String> createListView(String... items) {
|
||||
ListView<String> listView = new ListView<>();
|
||||
listView.getItems().addAll(items);
|
||||
|
||||
listView.setOnMouseClicked(event -> {
|
||||
String selectedItem = listView.getSelectionModel().getSelectedItem();
|
||||
if (selectedItem != null) {
|
||||
contentDisplay.getChildren().setAll(new Label(selectedItem + " 的设置内容"));
|
||||
}
|
||||
});
|
||||
|
||||
return listView;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -3,9 +3,9 @@ package org.jcnc.jnotepad.view.manager;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import org.jcnc.jnotepad.exception.AppException;
|
||||
import org.jcnc.jnotepad.ui.menu.JNotepadMenuBar;
|
||||
import org.jcnc.jnotepad.ui.status.JNotepadStatusBox;
|
||||
import org.jcnc.jnotepad.ui.tab.JNotepadTabPane;
|
||||
import org.jcnc.jnotepad.ui.root.top.RootTopVBox;
|
||||
import org.jcnc.jnotepad.ui.root.bottom.status.JNotepadStatusBox;
|
||||
import org.jcnc.jnotepad.ui.root.center.tab.JNotepadTabPane;
|
||||
|
||||
|
||||
/**
|
||||
@ -78,7 +78,8 @@ public class ViewManager {
|
||||
|
||||
// 创建主界面布局
|
||||
root = new BorderPane();
|
||||
root.setTop(JNotepadMenuBar.getMenuBar());
|
||||
|
||||
root.setTop(RootTopVBox.getInstance());
|
||||
|
||||
// 创建标签页和文本编辑区域
|
||||
root.setCenter(JNotepadTabPane.getInstance());
|
||||
|
||||
BIN
src/main/resources/tools.gif
Normal file
BIN
src/main/resources/tools.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.7 KiB |
BIN
src/main/resources/tools.png
Normal file
BIN
src/main/resources/tools.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
Loading…
x
Reference in New Issue
Block a user