commit
6a856a7a6d
@ -25,6 +25,8 @@ module org.jcnc.jnotepad {
|
||||
exports org.jcnc.jnotepad.Interface;
|
||||
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;
|
||||
exports org.jcnc.jnotepad.root.center.main.bottom.status;
|
||||
|
||||
@ -6,6 +6,7 @@ import javafx.application.Application;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.Window;
|
||||
import org.jcnc.jnotepad.app.i18n.UiResourceBundle;
|
||||
import org.jcnc.jnotepad.constants.AppConstants;
|
||||
import org.jcnc.jnotepad.constants.TextConstants;
|
||||
@ -30,21 +31,27 @@ public class LunchApp extends Application {
|
||||
* 线程池
|
||||
*/
|
||||
private final ExecutorService threadPool = ThreadPoolManager.getThreadPool();
|
||||
Scene scene;
|
||||
private static final Pane ROOT = new Pane();
|
||||
private static final Scene SCENE;
|
||||
|
||||
static {
|
||||
double width = AppConstants.SCREEN_WIDTH;
|
||||
double length = AppConstants.SCREEN_LENGTH;
|
||||
SCENE = new Scene(ROOT, width, length);
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
|
||||
public static Window getWindow() {
|
||||
return SCENE.getWindow();
|
||||
}
|
||||
@Override
|
||||
public void start(Stage primaryStage) {
|
||||
|
||||
Pane root = new Pane();
|
||||
double width = AppConstants.SCREEN_WIDTH;
|
||||
double length = AppConstants.SCREEN_LENGTH;
|
||||
scene = new Scene(root, width, length);
|
||||
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());
|
||||
initUiComponents();
|
||||
UiResourceBundle.bindStringProperty(primaryStage.titleProperty(), TextConstants.TITLE);
|
||||
|
||||
@ -53,11 +60,10 @@ public class LunchApp extends Application {
|
||||
// 使自定义标题栏可拖动
|
||||
customTitleBar.makeDraggable(primaryStage);*/
|
||||
// primaryStage.initStyle(StageStyle.UNDECORATED); // 移除默认窗口装饰
|
||||
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.setWidth(width);
|
||||
primaryStage.setHeight(length);
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.setScene(SCENE);
|
||||
primaryStage.setWidth(SCENE.getWidth());
|
||||
primaryStage.setHeight(SCENE.getHeight());
|
||||
primaryStage.setScene(SCENE);
|
||||
primaryStage.getIcons().add(UiUtil.getIcon());
|
||||
primaryStage.show();
|
||||
}
|
||||
@ -68,8 +74,8 @@ public class LunchApp extends Application {
|
||||
LocalizationController.initLocal();
|
||||
|
||||
//2. 加载组件
|
||||
ViewManager viewManager = ViewManager.getInstance(scene);
|
||||
viewManager.initScreen(scene);
|
||||
ViewManager viewManager = ViewManager.getInstance(SCENE);
|
||||
viewManager.initScreen(SCENE);
|
||||
|
||||
// 使用线程池加载关联文件并创建文本区域
|
||||
List<String> rawParameters = getParameters().getRaw();
|
||||
|
||||
@ -4,15 +4,16 @@ import javafx.application.Platform;
|
||||
import javafx.concurrent.Task;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.stage.FileChooser;
|
||||
import org.jcnc.jnotepad.app.i18n.UiResourceBundle;
|
||||
import org.jcnc.jnotepad.constants.TextConstants;
|
||||
import org.jcnc.jnotepad.manager.ThreadPoolManager;
|
||||
import org.jcnc.jnotepad.root.center.main.center.tab.JNotepadTab;
|
||||
import org.jcnc.jnotepad.root.center.main.center.tab.JNotepadTabPane;
|
||||
import org.jcnc.jnotepad.tool.EncodingDetector;
|
||||
import org.jcnc.jnotepad.tool.LogUtil;
|
||||
import org.jcnc.jnotepad.tool.UiUtil;
|
||||
import org.jcnc.jnotepad.ui.dialog.factory.FileChooserFactory;
|
||||
import org.jcnc.jnotepad.ui.dialog.factory.impl.TextFileChooserFactory;
|
||||
import org.jcnc.jnotepad.ui.module.LineNumberTextArea;
|
||||
|
||||
@ -47,9 +48,10 @@ public class OpenFile implements EventHandler<ActionEvent> {
|
||||
null,
|
||||
new FileChooser.ExtensionFilter("All types", "*.*"))
|
||||
.showOpenDialog(UiUtil.getAppWindow());
|
||||
if (file != null) {
|
||||
openFile(file);
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
openFile(file);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -81,6 +83,21 @@ public class OpenFile implements EventHandler<ActionEvent> {
|
||||
* @param file 文件对象
|
||||
*/
|
||||
public void openFile(File file) {
|
||||
// 获取标签页集合
|
||||
JNotepadTabPane jnotepadTabPane = UiUtil.getJnotepadTabPane();
|
||||
// 遍历标签页,查找匹配的标签页
|
||||
for (Tab tab : jnotepadTabPane.getTabs()) {
|
||||
// 获取绑定的文件
|
||||
File tabFile = (File) tab.getUserData();
|
||||
if (tabFile == null) {
|
||||
continue;
|
||||
}
|
||||
if (file.getPath().equals((tabFile).getPath())) {
|
||||
// 找到匹配的标签页,设置为选中状态并跳转
|
||||
jnotepadTabPane.getSelectionModel().select(tab);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ThreadPoolManager.getThreadPool().submit(createOpenFileTask(file));
|
||||
}
|
||||
|
||||
|
||||
@ -10,7 +10,6 @@ import org.jcnc.jnotepad.constants.TextConstants;
|
||||
import org.jcnc.jnotepad.root.center.main.center.tab.JNotepadTab;
|
||||
import org.jcnc.jnotepad.tool.LogUtil;
|
||||
import org.jcnc.jnotepad.tool.UiUtil;
|
||||
import org.jcnc.jnotepad.ui.dialog.factory.FileChooserFactory;
|
||||
import org.jcnc.jnotepad.ui.dialog.factory.impl.TextFileChooserFactory;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
|
||||
@ -10,7 +10,6 @@ import org.jcnc.jnotepad.root.center.main.center.tab.JNotepadTab;
|
||||
import org.jcnc.jnotepad.tool.LogUtil;
|
||||
import org.jcnc.jnotepad.tool.SingletonUtil;
|
||||
import org.jcnc.jnotepad.tool.UiUtil;
|
||||
import org.jcnc.jnotepad.ui.dialog.factory.FileChooserFactory;
|
||||
import org.jcnc.jnotepad.ui.dialog.factory.impl.TextFileChooserFactory;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
|
||||
@ -7,9 +7,10 @@ import org.jcnc.jnotepad.root.right.RootRightSideBarVBox;
|
||||
import org.jcnc.jnotepad.root.top.RootTopBorderPane;
|
||||
import org.jcnc.jnotepad.ui.module.AbstractBorderPane;
|
||||
|
||||
/*
|
||||
/**
|
||||
* 根舞台下的Root主布局
|
||||
* */
|
||||
* @author 许轲
|
||||
*/
|
||||
public class RootBorderPane extends AbstractBorderPane {
|
||||
|
||||
private static final RootBorderPane INSTANCE = new RootBorderPane();
|
||||
@ -19,11 +20,16 @@ public class RootBorderPane extends AbstractBorderPane {
|
||||
}
|
||||
|
||||
private void initRootBorderPane() {
|
||||
setCenterComponent(MainBorderPane.getInstance()); //中间,用于显示Main主布局
|
||||
setLeftComponent(ToolHBox.getInstance()); //主布局的左边
|
||||
setRightComponent(RootRightSideBarVBox.getInstance()); //主布局的右边
|
||||
setTopComponent(RootTopBorderPane.getInstance()); //主布局的上面
|
||||
setBottomComponent(RootBottomSideBarVBox.getInstance());//主布局的下面
|
||||
//中间,用于显示Main主布局
|
||||
setCenterComponent(MainBorderPane.getInstance());
|
||||
//主布局的左边
|
||||
setLeftComponent(ToolHBox.getInstance());
|
||||
//主布局的右边
|
||||
setRightComponent(RootRightSideBarVBox.getInstance());
|
||||
//主布局的上面
|
||||
setTopComponent(RootTopBorderPane.getInstance());
|
||||
//主布局的下面
|
||||
setBottomComponent(RootBottomSideBarVBox.getInstance());
|
||||
}
|
||||
|
||||
public static RootBorderPane getInstance() {
|
||||
|
||||
@ -3,9 +3,11 @@ package org.jcnc.jnotepad.root.center.main;
|
||||
import org.jcnc.jnotepad.root.center.main.center.tab.JNotepadTabPane;
|
||||
import org.jcnc.jnotepad.ui.module.AbstractBorderPane;
|
||||
|
||||
/*
|
||||
* MainBorderPane区域,用于显示文本框以及文本框周边
|
||||
* */
|
||||
/**
|
||||
* MainBorderPane区域,用于显示文本框以及文本框周边
|
||||
*
|
||||
* @author 许轲
|
||||
*/
|
||||
public class MainBorderPane extends AbstractBorderPane {
|
||||
|
||||
private static final MainBorderPane INSTANCE = new MainBorderPane();
|
||||
@ -15,8 +17,8 @@ public class MainBorderPane extends AbstractBorderPane {
|
||||
}
|
||||
|
||||
private void initRootBorderPane() {
|
||||
|
||||
setCenterComponent(JNotepadTabPane.getInstance()); //文本框
|
||||
//文本框
|
||||
setCenterComponent(JNotepadTabPane.getInstance());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package org.jcnc.jnotepad.root.center.main.center.tab;
|
||||
|
||||
import javafx.scene.control.TabPane;
|
||||
import org.jcnc.jnotepad.controller.config.AppConfigController;
|
||||
import org.jcnc.jnotepad.tool.SingletonUtil;
|
||||
import org.jcnc.jnotepad.tool.UiUtil;
|
||||
|
||||
/**
|
||||
@ -47,8 +47,11 @@ public class JNotepadTabPane extends TabPane {
|
||||
if (tab == null) {
|
||||
return;
|
||||
}
|
||||
// 将标签页加入标签页列表
|
||||
this.getTabs().add(tab);
|
||||
// 设置索引
|
||||
this.getSelectionModel().select(tab);
|
||||
// 将标签页设置为选中状态
|
||||
fireTabSelected();
|
||||
}
|
||||
|
||||
@ -67,7 +70,7 @@ public class JNotepadTabPane extends TabPane {
|
||||
*/
|
||||
public void fireTabSelected() {
|
||||
JNotepadTab selectedTab = getSelected();
|
||||
selectedTab.setAutoLine(AppConfigController.getInstance().getAutoLineConfig());
|
||||
selectedTab.setAutoLine(SingletonUtil.getAppConfigController().getAutoLineConfig());
|
||||
UiUtil.getStatusBox().updateWhenTabSelected();
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,9 +3,12 @@ package org.jcnc.jnotepad.root.top;
|
||||
import org.jcnc.jnotepad.root.top.menu.JNotepadMenuBar;
|
||||
import org.jcnc.jnotepad.ui.module.AbstractBorderPane;
|
||||
|
||||
/*
|
||||
* MainBorderPane区域,用于显示文本框以及文本框周边
|
||||
* */
|
||||
|
||||
/**
|
||||
* MainBorderPane区域,用于显示文本框以及文本框周边
|
||||
*
|
||||
* @author 许轲
|
||||
*/
|
||||
public class RootTopBorderPane extends AbstractBorderPane {
|
||||
|
||||
private static final RootTopBorderPane INSTANCE = new RootTopBorderPane();
|
||||
@ -15,7 +18,8 @@ public class RootTopBorderPane extends AbstractBorderPane {
|
||||
}
|
||||
|
||||
private void initRootBorderPane() {
|
||||
setTopComponent(JNotepadMenuBar.getInstance()); //文本框上面
|
||||
//文本框上面
|
||||
setTopComponent(JNotepadMenuBar.getInstance());
|
||||
}
|
||||
|
||||
public static RootTopBorderPane getInstance() {
|
||||
|
||||
@ -28,6 +28,9 @@ import static org.jcnc.jnotepad.constants.TextConstants.*;
|
||||
public class JNotepadMenuBar extends MenuBar {
|
||||
|
||||
private static final JNotepadMenuBar MENU_BAR = new JNotepadMenuBar();
|
||||
/**
|
||||
* 按钮集合
|
||||
*/
|
||||
private final Map<String, MenuItem> itemMap = new HashMap<>();
|
||||
/**
|
||||
* 标签页布局组件封装。
|
||||
@ -39,7 +42,9 @@ public class JNotepadMenuBar extends MenuBar {
|
||||
* 工具栏
|
||||
*/
|
||||
JNotepadToolBar toolBar = JNotepadToolBar.getInstance();
|
||||
// 获取工具栏中的setButton
|
||||
/**
|
||||
* 获取工具栏中的setButton
|
||||
*/
|
||||
Button setButton = toolBar.getSetButton();
|
||||
/**
|
||||
* 文件菜单
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user