!68 解决冲突

Merge pull request !68 from Luke/release-v1.1.12
This commit is contained in:
Luke 2023-09-02 05:35:14 +00:00 committed by Gitee
commit 4f59dda32e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
18 changed files with 121 additions and 106 deletions

View File

@ -23,11 +23,6 @@ module org.jcnc.jnotepad {
exports org.jcnc.jnotepad.controller.event.handler.menubar; exports org.jcnc.jnotepad.controller.event.handler.menubar;
exports org.jcnc.jnotepad.tool; exports org.jcnc.jnotepad.tool;
exports org.jcnc.jnotepad.interfaces; exports org.jcnc.jnotepad.interfaces;
exports org.jcnc.jnotepad.ui.module;
exports org.jcnc.jnotepad.ui.setstage;
exports org.jcnc.jnotepad.root.center.main.center.tab;
exports org.jcnc.jnotepad.root.top.menu;
exports org.jcnc.jnotepad.view.manager;
opens org.jcnc.jnotepad.app.config; opens org.jcnc.jnotepad.app.config;
exports org.jcnc.jnotepad.root.center.main.bottom.status; exports org.jcnc.jnotepad.root.center.main.bottom.status;

View File

@ -27,10 +27,7 @@ import java.util.concurrent.ExecutorService;
* @author 许轲 * @author 许轲
*/ */
public class LunchApp extends Application { public class LunchApp extends Application {
/**
* 线程池
*/
private final ExecutorService threadPool = ThreadPoolManager.getThreadPool();
private static final Pane ROOT = new Pane(); private static final Pane ROOT = new Pane();
private static final Scene SCENE; private static final Scene SCENE;
@ -40,6 +37,11 @@ public class LunchApp extends Application {
SCENE = new Scene(ROOT, width, length); SCENE = new Scene(ROOT, width, length);
} }
/**
* 线程池
*/
private final ExecutorService threadPool = ThreadPoolManager.getThreadPool();
/** /**
* 应用程序的入口点启动 JavaFX 应用程序 * 应用程序的入口点启动 JavaFX 应用程序
* *

View File

@ -4,9 +4,9 @@ import javafx.event.ActionEvent;
import javafx.event.EventHandler; import javafx.event.EventHandler;
import org.jcnc.jnotepad.app.i18n.UiResourceBundle; import org.jcnc.jnotepad.app.i18n.UiResourceBundle;
import org.jcnc.jnotepad.constants.TextConstants; import org.jcnc.jnotepad.constants.TextConstants;
import org.jcnc.jnotepad.root.center.main.bottom.status.StatusHorizontalBox; import org.jcnc.jnotepad.root.center.main.bottom.status.JNotepadStatusBox;
import org.jcnc.jnotepad.root.center.main.center.tab.MainTab; import org.jcnc.jnotepad.root.center.main.center.tab.JNotepadTab;
import org.jcnc.jnotepad.root.center.main.center.tab.MainTabPane; import org.jcnc.jnotepad.root.center.main.center.tab.JNotepadTabPane;
import org.jcnc.jnotepad.ui.module.LineNumberTextArea; import org.jcnc.jnotepad.ui.module.LineNumberTextArea;
import org.jcnc.jnotepad.view.manager.ViewManager; import org.jcnc.jnotepad.view.manager.ViewManager;
@ -38,15 +38,15 @@ public class NewFile implements EventHandler<ActionEvent> {
// TODO: refactor统一TextArea新建绑定监听器入口 // TODO: refactor统一TextArea新建绑定监听器入口
ViewManager viewManager = ViewManager.getInstance(); ViewManager viewManager = ViewManager.getInstance();
// 创建标签页 // 创建标签页
MainTab mainTab = new MainTab( JNotepadTab JNotepadTab = new JNotepadTab(
UiResourceBundle.getContent(TextConstants.NEW_FILE) UiResourceBundle.getContent(TextConstants.NEW_FILE)
+ viewManager.selfIncreaseAndGetTabIndex(), + viewManager.selfIncreaseAndGetTabIndex(),
textArea); textArea);
// 设置当前标签页与本地文件无关联 // 设置当前标签页与本地文件无关联
mainTab.setRelevance(false); JNotepadTab.setRelevance(false);
// 将Tab页添加到TabPane中 // 将Tab页添加到TabPane中
MainTabPane.getInstance().addNewTab(mainTab); JNotepadTabPane.getInstance().addNewTab(JNotepadTab);
// 更新编码信息 // 更新编码信息
StatusHorizontalBox.getInstance().updateEncodingLabel(); JNotepadStatusBox.getInstance().updateEncodingLabel();
} }
} }

View File

@ -9,8 +9,8 @@ import javafx.stage.FileChooser;
import org.jcnc.jnotepad.app.i18n.UiResourceBundle; import org.jcnc.jnotepad.app.i18n.UiResourceBundle;
import org.jcnc.jnotepad.constants.TextConstants; import org.jcnc.jnotepad.constants.TextConstants;
import org.jcnc.jnotepad.manager.ThreadPoolManager; import org.jcnc.jnotepad.manager.ThreadPoolManager;
import org.jcnc.jnotepad.root.center.main.center.tab.MainTab; import org.jcnc.jnotepad.root.center.main.center.tab.JNotepadTab;
import org.jcnc.jnotepad.root.center.main.center.tab.MainTabPane; import org.jcnc.jnotepad.root.center.main.center.tab.JNotepadTabPane;
import org.jcnc.jnotepad.tool.EncodingDetector; import org.jcnc.jnotepad.tool.EncodingDetector;
import org.jcnc.jnotepad.tool.LogUtil; import org.jcnc.jnotepad.tool.LogUtil;
import org.jcnc.jnotepad.tool.UiUtil; import org.jcnc.jnotepad.tool.UiUtil;
@ -83,9 +83,9 @@ public class OpenFile implements EventHandler<ActionEvent> {
*/ */
public void openFile(File file) { public void openFile(File file) {
// 获取标签页集合 // 获取标签页集合
MainTabPane jnotepadMainTabPane = MainTabPane.getInstance(); JNotepadTabPane jnotepadTabPane = JNotepadTabPane.getInstance();
// 遍历标签页查找匹配的标签页 // 遍历标签页查找匹配的标签页
for (Tab tab : jnotepadMainTabPane.getTabs()) { for (Tab tab : jnotepadTabPane.getTabs()) {
// 获取绑定的文件 // 获取绑定的文件
File tabFile = (File) tab.getUserData(); File tabFile = (File) tab.getUserData();
if (tabFile == null) { if (tabFile == null) {
@ -93,7 +93,7 @@ public class OpenFile implements EventHandler<ActionEvent> {
} }
if (file.getPath().equals((tabFile).getPath())) { if (file.getPath().equals((tabFile).getPath())) {
// 找到匹配的标签页设置为选中状态并跳转 // 找到匹配的标签页设置为选中状态并跳转
jnotepadMainTabPane.getSelectionModel().select(tab); jnotepadTabPane.getSelectionModel().select(tab);
return; return;
} }
} }
@ -119,11 +119,11 @@ public class OpenFile implements EventHandler<ActionEvent> {
LogUtil.getLogger(this.getClass()).info("已调用读取文件功能"); LogUtil.getLogger(this.getClass()).info("已调用读取文件功能");
Platform.runLater(() -> { Platform.runLater(() -> {
textArea.getMainTextArea().setText(text); textArea.getMainTextArea().setText(text);
MainTab tab = createNewTab(file.getName(), textArea, encoding); JNotepadTab tab = createNewTab(file.getName(), textArea, encoding);
// 设置当前标签页关联本地文件 // 设置当前标签页关联本地文件
tab.setRelevance(true); tab.setRelevance(true);
tab.setUserData(file); tab.setUserData(file);
MainTabPane.getInstance().addNewTab(tab); JNotepadTabPane.getInstance().addNewTab(tab);
}); });
} catch (IOException ignored) { } catch (IOException ignored) {
LogUtil.getLogger(this.getClass()).info("已忽视IO异常!"); LogUtil.getLogger(this.getClass()).info("已忽视IO异常!");
@ -146,7 +146,7 @@ public class OpenFile implements EventHandler<ActionEvent> {
* @param textArea 文本区域 * @param textArea 文本区域
* @return 新的标签页 * @return 新的标签页
*/ */
private MainTab createNewTab(String tabName, LineNumberTextArea textArea, Charset charset) { private JNotepadTab createNewTab(String tabName, LineNumberTextArea textArea, Charset charset) {
return new MainTab(tabName, textArea, charset); return new JNotepadTab(tabName, textArea, charset);
} }
} }

View File

@ -7,8 +7,8 @@ import javafx.scene.input.KeyCode;
import javafx.stage.FileChooser; import javafx.stage.FileChooser;
import org.jcnc.jnotepad.app.i18n.UiResourceBundle; import org.jcnc.jnotepad.app.i18n.UiResourceBundle;
import org.jcnc.jnotepad.constants.TextConstants; import org.jcnc.jnotepad.constants.TextConstants;
import org.jcnc.jnotepad.root.center.main.center.tab.MainTab; import org.jcnc.jnotepad.root.center.main.center.tab.JNotepadTab;
import org.jcnc.jnotepad.root.center.main.center.tab.MainTabPane; import org.jcnc.jnotepad.root.center.main.center.tab.JNotepadTabPane;
import org.jcnc.jnotepad.tool.LogUtil; import org.jcnc.jnotepad.tool.LogUtil;
import org.jcnc.jnotepad.tool.UiUtil; import org.jcnc.jnotepad.tool.UiUtil;
import org.jcnc.jnotepad.ui.dialog.factory.impl.TextFileChooserFactory; import org.jcnc.jnotepad.ui.dialog.factory.impl.TextFileChooserFactory;
@ -30,7 +30,7 @@ public class RenameFile implements EventHandler<ActionEvent> {
@Override @Override
public void handle(ActionEvent actionEvent) { public void handle(ActionEvent actionEvent) {
// 获取当前标签页 // 获取当前标签页
MainTab jnotepadtab = MainTabPane.getInstance().getSelected(); JNotepadTab jnotepadtab = JNotepadTabPane.getInstance().getSelected();
if (jnotepadtab == null || jnotepadtab.getText().isEmpty()) { if (jnotepadtab == null || jnotepadtab.getText().isEmpty()) {
return; return;
} }
@ -50,7 +50,7 @@ public class RenameFile implements EventHandler<ActionEvent> {
* *
* @param jnotepadtab 标签页组件 * @param jnotepadtab 标签页组件
*/ */
private void handleRenameTab(MainTab jnotepadtab) { private void handleRenameTab(JNotepadTab jnotepadtab) {
TextField textField = new TextField(jnotepadtab.getText()); TextField textField = new TextField(jnotepadtab.getText());
textField.getStyleClass().add("tab-title-editable"); textField.getStyleClass().add("tab-title-editable");
// 清空标签页名称 // 清空标签页名称
@ -88,7 +88,7 @@ public class RenameFile implements EventHandler<ActionEvent> {
* *
* @param jnotepadtab 标签页组件 * @param jnotepadtab 标签页组件
*/ */
private void handleRenameRelevanceFile(MainTab jnotepadtab) { private void handleRenameRelevanceFile(JNotepadTab jnotepadtab) {
// 获取原始文件对象 // 获取原始文件对象
File file = (File) jnotepadtab.getUserData(); File file = (File) jnotepadtab.getUserData();
// 获取应用窗口并绑定 // 获取应用窗口并绑定

View File

@ -6,8 +6,8 @@ import javafx.stage.FileChooser;
import org.jcnc.jnotepad.app.i18n.UiResourceBundle; import org.jcnc.jnotepad.app.i18n.UiResourceBundle;
import org.jcnc.jnotepad.constants.TextConstants; import org.jcnc.jnotepad.constants.TextConstants;
import org.jcnc.jnotepad.controller.i18n.LocalizationController; import org.jcnc.jnotepad.controller.i18n.LocalizationController;
import org.jcnc.jnotepad.root.center.main.center.tab.MainTab; import org.jcnc.jnotepad.root.center.main.center.tab.JNotepadTab;
import org.jcnc.jnotepad.root.center.main.center.tab.MainTabPane; import org.jcnc.jnotepad.root.center.main.center.tab.JNotepadTabPane;
import org.jcnc.jnotepad.root.top.menu.TopMenuBar; import org.jcnc.jnotepad.root.top.menu.TopMenuBar;
import org.jcnc.jnotepad.tool.LogUtil; import org.jcnc.jnotepad.tool.LogUtil;
import org.jcnc.jnotepad.tool.SingletonUtil; import org.jcnc.jnotepad.tool.SingletonUtil;
@ -40,7 +40,7 @@ public class SaveFile implements EventHandler<ActionEvent> {
@Override @Override
public void handle(ActionEvent actionEvent) { public void handle(ActionEvent actionEvent) {
// 获取当前tab页 // 获取当前tab页
MainTab selectedTab = MainTabPane.getInstance().getSelected(); JNotepadTab selectedTab = JNotepadTabPane.getInstance().getSelected();
if (selectedTab == null) { if (selectedTab == null) {
return; return;
} }
@ -72,7 +72,7 @@ public class SaveFile implements EventHandler<ActionEvent> {
* @see LogUtil * @see LogUtil
*/ */
protected void saveTab(Class<?> currentClass) { protected void saveTab(Class<?> currentClass) {
MainTab selectedTab = MainTabPane.getInstance().getSelected(); JNotepadTab selectedTab = JNotepadTabPane.getInstance().getSelected();
if (selectedTab == null) { if (selectedTab == null) {
return; return;
} }

View File

@ -4,7 +4,6 @@ import javafx.event.ActionEvent;
import javafx.event.EventHandler; import javafx.event.EventHandler;
import org.jcnc.jnotepad.ui.setstage.SetStage; import org.jcnc.jnotepad.ui.setstage.SetStage;
/** /**
* 设置按钮事件的事件处理程序 * 设置按钮事件的事件处理程序
* *

View File

@ -24,6 +24,15 @@ public class RootBorderPane extends AbstractBorderPane {
initRootBorderPane(); initRootBorderPane();
} }
/**
* 获取 RootBorderPane 的单例实例
*
* @return RootBorderPane 的单例实例
*/
public static RootBorderPane getInstance() {
return INSTANCE;
}
/** /**
* 初始化 RootBorderPane * 初始化 RootBorderPane
* *
@ -43,12 +52,5 @@ public class RootBorderPane extends AbstractBorderPane {
setBottomComponent(RootBottomSideBarVerticalBox.getInstance()); setBottomComponent(RootBottomSideBarVerticalBox.getInstance());
} }
/**
* 获取 RootBorderPane 的单例实例
*
* @return RootBorderPane 的单例实例
*/
public static RootBorderPane getInstance() {
return INSTANCE;
}
} }

View File

@ -1,6 +1,6 @@
package org.jcnc.jnotepad.root.bottom; package org.jcnc.jnotepad.root.bottom;
import org.jcnc.jnotepad.root.center.main.bottom.status.StatusHorizontalBox; import org.jcnc.jnotepad.root.center.main.bottom.status.JNotepadStatusBox;
import org.jcnc.jnotepad.ui.module.AbstractVerticalBox; import org.jcnc.jnotepad.ui.module.AbstractVerticalBox;
/** /**
@ -18,10 +18,6 @@ public class RootBottomSideBarVerticalBox extends AbstractVerticalBox {
initSidebarVerticalBox(); initSidebarVerticalBox();
} }
private void initSidebarVerticalBox() {
getChildren().addAll(StatusHorizontalBox.getInstance());
}
/** /**
* 获取 RootBottomSideBarVerticalBox 的唯一实例 * 获取 RootBottomSideBarVerticalBox 的唯一实例
* *
@ -30,4 +26,8 @@ public class RootBottomSideBarVerticalBox extends AbstractVerticalBox {
public static RootBottomSideBarVerticalBox getInstance() { public static RootBottomSideBarVerticalBox getInstance() {
return INSTANCE; return INSTANCE;
} }
private void initSidebarVerticalBox() {
getChildren().addAll(JNotepadStatusBox.getInstance());
}
} }

View File

@ -1,6 +1,6 @@
package org.jcnc.jnotepad.root.center.main; package org.jcnc.jnotepad.root.center.main;
import org.jcnc.jnotepad.root.center.main.center.tab.MainTabPane; import org.jcnc.jnotepad.root.center.main.center.tab.JNotepadTabPane;
import org.jcnc.jnotepad.ui.module.AbstractBorderPane; import org.jcnc.jnotepad.ui.module.AbstractBorderPane;
/** /**
@ -18,11 +18,6 @@ public class MainBorderPane extends AbstractBorderPane {
initRootBorderPane(); initRootBorderPane();
} }
private void initRootBorderPane() {
// 文本框
setCenterComponent(MainTabPane.getInstance());
}
/** /**
* 获取 MainBorderPane 的唯一实例 * 获取 MainBorderPane 的唯一实例
* *
@ -31,4 +26,10 @@ public class MainBorderPane extends AbstractBorderPane {
public static MainBorderPane getInstance() { public static MainBorderPane getInstance() {
return INSTANCE; return INSTANCE;
} }
private void initRootBorderPane() {
// 文本框
setCenterComponent(JNotepadTabPane.getInstance());
}
} }

View File

@ -6,8 +6,8 @@ import javafx.scene.control.Label;
import javafx.scene.control.TextArea; import javafx.scene.control.TextArea;
import org.jcnc.jnotepad.app.i18n.UiResourceBundle; import org.jcnc.jnotepad.app.i18n.UiResourceBundle;
import org.jcnc.jnotepad.constants.TextConstants; import org.jcnc.jnotepad.constants.TextConstants;
import org.jcnc.jnotepad.root.center.main.center.tab.MainTab; import org.jcnc.jnotepad.root.center.main.center.tab.JNotepadTab;
import org.jcnc.jnotepad.root.center.main.center.tab.MainTabPane; import org.jcnc.jnotepad.root.center.main.center.tab.JNotepadTabPane;
import org.jcnc.jnotepad.ui.module.AbstractHorizontalBox; import org.jcnc.jnotepad.ui.module.AbstractHorizontalBox;
import java.nio.charset.Charset; import java.nio.charset.Charset;
@ -19,9 +19,9 @@ import java.nio.charset.Charset;
* *
* @author songdragon * @author songdragon
*/ */
public class StatusHorizontalBox extends AbstractHorizontalBox { public class JNotepadStatusBox extends AbstractHorizontalBox {
private static final StatusHorizontalBox STATUS_BOX = new StatusHorizontalBox(); private static final JNotepadStatusBox STATUS_BOX = new JNotepadStatusBox();
private static final String STATUS_LABEL_FORMAT = "%s : %d \t%s: %d \t%s: %d \t"; private static final String STATUS_LABEL_FORMAT = "%s : %d \t%s: %d \t%s: %d \t";
/** /**
* 字数统计及光标 * 字数统计及光标
@ -33,11 +33,11 @@ public class StatusHorizontalBox extends AbstractHorizontalBox {
private Label encodingLabel; private Label encodingLabel;
private StatusHorizontalBox() { private JNotepadStatusBox() {
initStatusBox(); initStatusBox();
} }
public static StatusHorizontalBox getInstance() { public static JNotepadStatusBox getInstance() {
return STATUS_BOX; return STATUS_BOX;
} }
@ -89,7 +89,7 @@ public class StatusHorizontalBox extends AbstractHorizontalBox {
* 更新字数统计 * 更新字数统计
*/ */
public void updateWordCountStatusLabel() { public void updateWordCountStatusLabel() {
MainTabPane instance = MainTabPane.getInstance(); JNotepadTabPane instance = JNotepadTabPane.getInstance();
if (instance.getSelected() == null) { if (instance.getSelected() == null) {
return; return;
} }
@ -107,12 +107,12 @@ public class StatusHorizontalBox extends AbstractHorizontalBox {
* <br>2. 状态栏更新当前选中tab的字符编码 * <br>2. 状态栏更新当前选中tab的字符编码
*/ */
public void updateWhenTabSelected() { public void updateWhenTabSelected() {
MainTabPane instance = MainTabPane.getInstance(); JNotepadTabPane instance = JNotepadTabPane.getInstance();
if (instance.getSelected() != null) { if (instance.getSelected() != null) {
updateWordCountStatusLabel(); updateWordCountStatusLabel();
MainTab mainTab = instance.getSelected(); JNotepadTab JNotepadTab = instance.getSelected();
if (mainTab != null) { if (JNotepadTab != null) {
updateEncodingLabel(mainTab.getCharset().name()); updateEncodingLabel(JNotepadTab.getCharset().name());
} }
} }
} }

View File

@ -13,7 +13,7 @@ import java.nio.charset.Charset;
* *
* @author songdragon * @author songdragon
*/ */
public class MainTab extends Tab { public class JNotepadTab extends Tab {
private final LineNumberTextArea lineNumberTextArea; private final LineNumberTextArea lineNumberTextArea;
/** /**
@ -26,15 +26,15 @@ public class MainTab extends Tab {
private boolean isRelevance = false; private boolean isRelevance = false;
private Charset charset = Charset.defaultCharset(); private Charset charset = Charset.defaultCharset();
public MainTab(String tabTitle) { public JNotepadTab(String tabTitle) {
this(tabTitle, new LineNumberTextArea()); this(tabTitle, new LineNumberTextArea());
} }
public MainTab(String tabTitle, LineNumberTextArea textArea) { public JNotepadTab(String tabTitle, LineNumberTextArea textArea) {
this(tabTitle, textArea, Charset.defaultCharset()); this(tabTitle, textArea, Charset.defaultCharset());
} }
public MainTab(String tabTitle, LineNumberTextArea textArea, Charset charset) { public JNotepadTab(String tabTitle, LineNumberTextArea textArea, Charset charset) {
super(tabTitle); super(tabTitle);
lineNumberTextArea = textArea; lineNumberTextArea = textArea;
this.setContent(lineNumberTextArea); this.setContent(lineNumberTextArea);

View File

@ -1,7 +1,7 @@
package org.jcnc.jnotepad.root.center.main.center.tab; package org.jcnc.jnotepad.root.center.main.center.tab;
import javafx.scene.control.TabPane; import javafx.scene.control.TabPane;
import org.jcnc.jnotepad.root.center.main.bottom.status.StatusHorizontalBox; import org.jcnc.jnotepad.root.center.main.bottom.status.JNotepadStatusBox;
import org.jcnc.jnotepad.root.top.menu.TopMenuBar; import org.jcnc.jnotepad.root.top.menu.TopMenuBar;
import org.jcnc.jnotepad.tool.SingletonUtil; import org.jcnc.jnotepad.tool.SingletonUtil;
@ -10,15 +10,15 @@ import org.jcnc.jnotepad.tool.SingletonUtil;
* *
* @author songdragon * @author songdragon
*/ */
public class MainTabPane extends TabPane { public class JNotepadTabPane extends TabPane {
private static final MainTabPane TAB_PANE = new MainTabPane(); private static final JNotepadTabPane TAB_PANE = new JNotepadTabPane();
private MainTabPane() { private JNotepadTabPane() {
initListeners(); initListeners();
} }
public static MainTabPane getInstance() { public static JNotepadTabPane getInstance() {
return TAB_PANE; return TAB_PANE;
} }
@ -34,7 +34,7 @@ public class MainTabPane extends TabPane {
TopMenuBar.getInstance().updateMenuStatusBySelectedTab(); TopMenuBar.getInstance().updateMenuStatusBySelectedTab();
} }
// 更新状态标签 // 更新状态标签
StatusHorizontalBox.getInstance().updateWhenTabSelected(); JNotepadStatusBox.getInstance().updateWhenTabSelected();
} }
); );
} }
@ -44,7 +44,7 @@ public class MainTabPane extends TabPane {
* *
* @param tab 新标签页 * @param tab 新标签页
*/ */
public void addNewTab(MainTab tab) { public void addNewTab(JNotepadTab tab) {
if (tab == null) { if (tab == null) {
return; return;
} }
@ -61,8 +61,8 @@ public class MainTabPane extends TabPane {
* *
* @return 当前选中的标签页 * @return 当前选中的标签页
*/ */
public MainTab getSelected() { public JNotepadTab getSelected() {
return (MainTab) this.getSelectionModel().getSelectedItem(); return (JNotepadTab) this.getSelectionModel().getSelectedItem();
} }
/** /**
@ -70,8 +70,8 @@ public class MainTabPane extends TabPane {
* 应用当前菜单上选中的自动换行设置 * 应用当前菜单上选中的自动换行设置
*/ */
public void fireTabSelected() { public void fireTabSelected() {
MainTab selectedTab = getSelected(); JNotepadTab selectedTab = getSelected();
selectedTab.setAutoLine(SingletonUtil.getAppConfigController().getAutoLineConfig()); selectedTab.setAutoLine(SingletonUtil.getAppConfigController().getAutoLineConfig());
StatusHorizontalBox.getInstance().updateWhenTabSelected(); JNotepadStatusBox.getInstance().updateWhenTabSelected();
} }
} }

View File

@ -3,21 +3,36 @@ package org.jcnc.jnotepad.root.right;
import org.jcnc.jnotepad.ui.module.AbstractVerticalBox; import org.jcnc.jnotepad.ui.module.AbstractVerticalBox;
/** /**
* @author 许轲 * 右侧边栏的垂直布局容器类
*
* <p>该类用于管理右侧边栏的布局和内容</p>
*
* @Author 许轲
*/ */
public class RootRightSideBarVerticalBox extends AbstractVerticalBox { public class RootRightSideBarVerticalBox extends AbstractVerticalBox {
/**
* 唯一的 RootRightSideBarVerticalBox 实例使用单例模式
*/
private static final RootRightSideBarVerticalBox INSTANCE = new RootRightSideBarVerticalBox(); private static final RootRightSideBarVerticalBox INSTANCE = new RootRightSideBarVerticalBox();
private RootRightSideBarVerticalBox() { private RootRightSideBarVerticalBox() {
initSidebarVerticalBox(); initSidebarVerticalBox();
} }
private void initSidebarVerticalBox() { /**
* 获取 RootRightSideBarVerticalBox 的唯一实例
} *
* @return RootRightSideBarVerticalBox 的实例
*/
public static RootRightSideBarVerticalBox getInstance() { public static RootRightSideBarVerticalBox getInstance() {
return INSTANCE; return INSTANCE;
} }
/**
* 初始化右侧边栏的垂直布局
*/
private void initSidebarVerticalBox() {
// 在此添加右侧边栏布局和内容的初始化代码
}
} }

View File

@ -20,6 +20,15 @@ public class RootTopBorderPane extends AbstractBorderPane {
initRootBorderPane(); initRootBorderPane();
} }
/**
* 获取 RootTopBorderPane 的单例实例
*
* @return RootTopBorderPane 的单例实例
*/
public static RootTopBorderPane getInstance() {
return INSTANCE;
}
/** /**
* 初始化 RootTopBorderPane * 初始化 RootTopBorderPane
* *
@ -29,13 +38,4 @@ public class RootTopBorderPane extends AbstractBorderPane {
// 在顶部区域添加菜单栏 // 在顶部区域添加菜单栏
setTopComponent(TopMenuBar.getInstance()); setTopComponent(TopMenuBar.getInstance());
} }
/**
* 获取 RootTopBorderPane 的单例实例
*
* @return RootTopBorderPane 的单例实例
*/
public static RootTopBorderPane getInstance() {
return INSTANCE;
}
} }

View File

@ -10,8 +10,8 @@ import org.jcnc.jnotepad.controller.config.AppConfigController;
import org.jcnc.jnotepad.controller.event.handler.menubar.*; import org.jcnc.jnotepad.controller.event.handler.menubar.*;
import org.jcnc.jnotepad.controller.event.handler.tool.SetBtn; import org.jcnc.jnotepad.controller.event.handler.tool.SetBtn;
import org.jcnc.jnotepad.controller.i18n.LocalizationController; import org.jcnc.jnotepad.controller.i18n.LocalizationController;
import org.jcnc.jnotepad.root.center.main.center.tab.MainTab; import org.jcnc.jnotepad.root.center.main.center.tab.JNotepadTab;
import org.jcnc.jnotepad.root.center.main.center.tab.MainTabPane; import org.jcnc.jnotepad.root.center.main.center.tab.JNotepadTabPane;
import org.jcnc.jnotepad.root.left.sidebar.tools.ToolBar; import org.jcnc.jnotepad.root.left.sidebar.tools.ToolBar;
import org.jcnc.jnotepad.tool.LogUtil; import org.jcnc.jnotepad.tool.LogUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -35,7 +35,7 @@ public class TopMenuBar extends MenuBar {
/** /**
* 标签页布局组件封装 * 标签页布局组件封装
*/ */
MainTabPane mainTabPane = MainTabPane.getInstance(); JNotepadTabPane JNotepadTabPane = org.jcnc.jnotepad.root.center.main.center.tab.JNotepadTabPane.getInstance();
AppConfigController appConfigController = AppConfigController.getInstance(); AppConfigController appConfigController = AppConfigController.getInstance();
Logger logger = LogUtil.getLogger(this.getClass()); Logger logger = LogUtil.getLogger(this.getClass());
/** /**
@ -289,7 +289,7 @@ public class TopMenuBar extends MenuBar {
// 1. 更新全局配置 // 1. 更新全局配置
AppConfigController.getInstance().setAutoLineConfig(after); AppConfigController.getInstance().setAutoLineConfig(after);
// 2. 对当前tab生效配置 // 2. 对当前tab生效配置
mainTabPane.fireTabSelected(); JNotepadTabPane.fireTabSelected();
}); });
topItem.selectedProperty().addListener((observableValue, before, after) -> { topItem.selectedProperty().addListener((observableValue, before, after) -> {
// 获取窗口容器 // 获取窗口容器
@ -322,7 +322,7 @@ public class TopMenuBar extends MenuBar {
* 根据当前选中tab更新菜单选项 * 根据当前选中tab更新菜单选项
*/ */
public void updateMenuStatusBySelectedTab() { public void updateMenuStatusBySelectedTab() {
MainTab selectedTab = mainTabPane.getSelected(); JNotepadTab selectedTab = JNotepadTabPane.getSelected();
lineFeedItem.selectedProperty().setValue(selectedTab.isAutoLine()); lineFeedItem.selectedProperty().setValue(selectedTab.isAutoLine());
} }
} }

View File

@ -23,6 +23,7 @@ public class UiUtil {
private UiUtil() { private UiUtil() {
} }
/** /**
* 获取应用程序图标 * 获取应用程序图标
* *

View File

@ -3,9 +3,9 @@ package org.jcnc.jnotepad.ui.module;
import javafx.beans.property.StringProperty; import javafx.beans.property.StringProperty;
import javafx.scene.control.TextArea; import javafx.scene.control.TextArea;
import javafx.scene.layout.BorderPane; import javafx.scene.layout.BorderPane;
import org.jcnc.jnotepad.root.center.main.bottom.status.StatusHorizontalBox; import org.jcnc.jnotepad.root.center.main.bottom.status.JNotepadStatusBox;
import org.jcnc.jnotepad.root.center.main.center.tab.MainTab; import org.jcnc.jnotepad.root.center.main.center.tab.JNotepadTab;
import org.jcnc.jnotepad.root.center.main.center.tab.MainTabPane; import org.jcnc.jnotepad.root.center.main.center.tab.JNotepadTabPane;
import org.jcnc.jnotepad.tool.LogUtil; import org.jcnc.jnotepad.tool.LogUtil;
import org.jcnc.jnotepad.tool.SingletonUtil; import org.jcnc.jnotepad.tool.SingletonUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -24,9 +24,9 @@ import java.io.IOException;
*/ */
public class LineNumberTextArea extends BorderPane { public class LineNumberTextArea extends BorderPane {
private static final Logger logger = LogUtil.getLogger(LineNumberTextArea.class);
static final int[] SIZE_TABLE = {9, 99, 999, 9999, 99999, 999999, 9999999, static final int[] SIZE_TABLE = {9, 99, 999, 9999, 99999, 999999, 9999999,
99999999, 999999999, Integer.MAX_VALUE}; 99999999, 999999999, Integer.MAX_VALUE};
private static final Logger logger = LogUtil.getLogger(LineNumberTextArea.class);
private static final int MIN_LINE_NUMBER_WIDTH = 30; private static final int MIN_LINE_NUMBER_WIDTH = 30;
private final TextArea mainTextArea; private final TextArea mainTextArea;
private final TextArea lineNumberArea; private final TextArea lineNumberArea;
@ -62,12 +62,12 @@ public class LineNumberTextArea extends BorderPane {
lineNumberArea.textProperty().addListener((observable, oldValue, newValue) -> updateLineNumberWidth()); lineNumberArea.textProperty().addListener((observable, oldValue, newValue) -> updateLineNumberWidth());
this.mainTextArea.caretPositionProperty().addListener((caretObservable, oldPosition, newPosition) -> StatusHorizontalBox.getInstance().updateWordCountStatusLabel()); this.mainTextArea.caretPositionProperty().addListener((caretObservable, oldPosition, newPosition) -> JNotepadStatusBox.getInstance().updateWordCountStatusLabel());
this.textProperty().addListener((observable, oldValue, newValue) -> { this.textProperty().addListener((observable, oldValue, newValue) -> {
// 更新行号 // 更新行号
updateLineNumberArea(); updateLineNumberArea();
// 更新状态栏 // 更新状态栏
StatusHorizontalBox.getInstance().updateWordCountStatusLabel(); JNotepadStatusBox.getInstance().updateWordCountStatusLabel();
// 自动保存 // 自动保存
save(); save();
}); });
@ -77,7 +77,7 @@ public class LineNumberTextArea extends BorderPane {
* 以原文件编码格式写回文件 * 以原文件编码格式写回文件
*/ */
public void save() { public void save() {
MainTab tab = MainTabPane.getInstance().getSelected(); JNotepadTab tab = JNotepadTabPane.getInstance().getSelected();
if (tab == null) { if (tab == null) {
return; return;
} }