commit
32b20809f9
@ -35,12 +35,13 @@ module org.jcnc.jnotepad {
|
||||
opens org.jcnc.jnotepad.app.config;
|
||||
exports org.jcnc.jnotepad.plugin.interfaces;
|
||||
exports org.jcnc.jnotepad.views.root.bottom.function;
|
||||
exports org.jcnc.jnotepad.views.root.bottom.function.interfaces;
|
||||
exports org.jcnc.jnotepad.ui.dialog;
|
||||
exports org.jcnc.jnotepad.ui.dialog.interfaces;
|
||||
exports org.jcnc.jnotepad.ui.module;
|
||||
exports org.jcnc.jnotepad.model.entity;
|
||||
exports org.jcnc.jnotepad.views.root.bottom;
|
||||
exports org.jcnc.jnotepad.views.root.bottom.status;
|
||||
exports org.jcnc.jnotepad.plugin.api.core.views.sidebar.bottom;
|
||||
exports org.jcnc.jnotepad.plugin.api.core.controller.config;
|
||||
|
||||
}
|
||||
@ -36,7 +36,7 @@ public class LunchApp extends Application {
|
||||
// 初始化应用程序
|
||||
APPLICATION_MANAGER.initializeApp();
|
||||
// 初始化默认操作
|
||||
APPLICATION_MANAGER.initializeDefaultAction();
|
||||
APPLICATION_MANAGER.executeDefaultAction();
|
||||
primaryStage.show();
|
||||
}
|
||||
|
||||
|
||||
@ -7,10 +7,12 @@ import javafx.scene.Scene;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.Window;
|
||||
import org.jcnc.jnotepad.LunchApp;
|
||||
import org.jcnc.jnotepad.app.i18n.UiResourceBundle;
|
||||
import org.jcnc.jnotepad.common.constants.AppConstants;
|
||||
import org.jcnc.jnotepad.common.constants.TextConstants;
|
||||
import org.jcnc.jnotepad.common.manager.ThreadPoolManager;
|
||||
import org.jcnc.jnotepad.common.util.LogUtil;
|
||||
import org.jcnc.jnotepad.common.util.UiUtil;
|
||||
import org.jcnc.jnotepad.controller.ResourceController;
|
||||
import org.jcnc.jnotepad.controller.cache.CacheController;
|
||||
@ -20,6 +22,7 @@ import org.jcnc.jnotepad.controller.manager.Controller;
|
||||
import org.jcnc.jnotepad.plugin.manager.PluginManager;
|
||||
import org.jcnc.jnotepad.views.manager.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
@ -77,7 +80,10 @@ public class ApplicationManager {
|
||||
initPrimaryStage();
|
||||
}
|
||||
|
||||
public void initializeDefaultAction() {
|
||||
/**
|
||||
* 执行默认操作
|
||||
*/
|
||||
public void executeDefaultAction() {
|
||||
// 使用加载关联文件并创建文本区域
|
||||
List<String> rawParameters = application.getParameters().getRaw();
|
||||
Controller.getInstance().openAssociatedFileAndCreateTextArea(rawParameters);
|
||||
@ -192,6 +198,25 @@ public class ApplicationManager {
|
||||
|
||||
}
|
||||
|
||||
public void restart() {
|
||||
try {
|
||||
// 获取当前Java应用程序的命令
|
||||
String javaCommand = System.getProperty("java.home") + "/bin/java";
|
||||
String mainClass = LunchApp.class.getName();
|
||||
|
||||
// 构建新进程来重新启动应用程序
|
||||
ProcessBuilder builder = new ProcessBuilder(javaCommand, "-cp", System.getProperty("java.class.path"), mainClass);
|
||||
builder.start();
|
||||
|
||||
// 关闭当前应用程序
|
||||
System.exit(0);
|
||||
} catch (IOException e) {
|
||||
LogUtil.getLogger("正在重启当前应用程序".getClass());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Pane getRoot() {
|
||||
return root;
|
||||
}
|
||||
|
||||
@ -1,32 +0,0 @@
|
||||
package org.jcnc.jnotepad.app.util;
|
||||
|
||||
import org.jcnc.jnotepad.LunchApp;
|
||||
import org.jcnc.jnotepad.common.util.LogUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author luke
|
||||
*/
|
||||
public class ApplicationRestarter {
|
||||
private ApplicationRestarter() {
|
||||
}
|
||||
|
||||
public static void restart() {
|
||||
try {
|
||||
// 获取当前Java应用程序的命令
|
||||
String javaCommand = System.getProperty("java.home") + "/bin/java";
|
||||
String mainClass = LunchApp.class.getName();
|
||||
|
||||
// 构建新进程来重新启动应用程序
|
||||
ProcessBuilder builder = new ProcessBuilder(javaCommand, "-cp", System.getProperty("java.class.path"), mainClass);
|
||||
builder.start();
|
||||
|
||||
// 关闭当前应用程序
|
||||
System.exit(0);
|
||||
} catch (IOException e) {
|
||||
LogUtil.getLogger("正在重启当前应用程序".getClass());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,7 @@
|
||||
package org.jcnc.jnotepad.common.manager;
|
||||
|
||||
import org.jcnc.jnotepad.plugin.api.core.manager.AbstractCacheManager;
|
||||
|
||||
/**
|
||||
* 应用程序缓存管理类
|
||||
*
|
||||
|
||||
@ -3,6 +3,7 @@ package org.jcnc.jnotepad.common.util;
|
||||
import org.jcnc.jnotepad.controller.event.handler.menubar.OpenFile;
|
||||
import org.jcnc.jnotepad.exception.AppException;
|
||||
import org.jcnc.jnotepad.model.entity.DirFileModel;
|
||||
import org.kordamp.ikonli.javafx.FontIcon;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.ByteBuffer;
|
||||
@ -13,6 +14,8 @@ import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static org.kordamp.ikonli.antdesignicons.AntDesignIconsFilled.*;
|
||||
|
||||
/**
|
||||
* 文件工具
|
||||
*
|
||||
@ -140,7 +143,7 @@ public class FileUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
DirFileModel dirFileModel = new DirFileModel(file.getAbsolutePath(), file.getName(), new ArrayList<>());
|
||||
DirFileModel dirFileModel = new DirFileModel(file.getAbsolutePath(), file.getName(), new ArrayList<>(), new FontIcon(FOLDER), new FontIcon(FOLDER_OPEN));
|
||||
|
||||
File[] files = file.listFiles();
|
||||
if (files != null) {
|
||||
@ -149,7 +152,8 @@ public class FileUtil {
|
||||
DirFileModel childDirFileModel = getDirFileModel(f);
|
||||
dirFileModel.getChildFile().add(childDirFileModel);
|
||||
} else {
|
||||
dirFileModel.getChildFile().add(new DirFileModel(f.getAbsolutePath(), f.getName(), null));
|
||||
// todo 在此监测文件后缀,设置对应的图标
|
||||
dirFileModel.getChildFile().add(new DirFileModel(f.getAbsolutePath(), f.getName(), null, new FontIcon(FILE), new FontIcon(FILE)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package org.jcnc.jnotepad.controller.config;
|
||||
|
||||
import org.jcnc.jnotepad.app.config.AppConfig;
|
||||
import org.jcnc.jnotepad.model.entity.ShortcutKey;
|
||||
import org.jcnc.jnotepad.plugin.api.core.controller.config.BaseConfigController;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package org.jcnc.jnotepad.controller.config;
|
||||
|
||||
import org.jcnc.jnotepad.app.config.PluginConfig;
|
||||
import org.jcnc.jnotepad.plugin.api.core.controller.config.BaseConfigController;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package org.jcnc.jnotepad.model.entity;
|
||||
|
||||
import org.kordamp.ikonli.javafx.FontIcon;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@ -14,14 +16,22 @@ public class DirFileModel {
|
||||
private String path;
|
||||
private String name;
|
||||
|
||||
private FontIcon iconIsNotSelected;
|
||||
|
||||
private FontIcon iconIsSelected;
|
||||
|
||||
private List<DirFileModel> childFile;
|
||||
|
||||
public DirFileModel(String path, String name, List<DirFileModel> childFile) {
|
||||
|
||||
public DirFileModel(String path, String name, List<DirFileModel> childFile, FontIcon iconIsNotSelected, FontIcon iconIsSelected) {
|
||||
this.path = path;
|
||||
this.name = name;
|
||||
this.childFile = childFile;
|
||||
this.iconIsNotSelected = iconIsNotSelected;
|
||||
this.iconIsSelected = iconIsSelected;
|
||||
}
|
||||
|
||||
|
||||
public List<DirFileModel> getChildFile() {
|
||||
return childFile;
|
||||
}
|
||||
@ -46,4 +56,24 @@ public class DirFileModel {
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public FontIcon getIconIsNotSelected() {
|
||||
return iconIsNotSelected;
|
||||
}
|
||||
|
||||
public void setIconIsNotSelected(FontIcon iconIsNotSelected) {
|
||||
this.iconIsNotSelected = iconIsNotSelected;
|
||||
}
|
||||
|
||||
public FontIcon getIconIsSelected() {
|
||||
return iconIsSelected;
|
||||
}
|
||||
|
||||
public void setIconIsSelected(FontIcon iconIsSelected) {
|
||||
this.iconIsSelected = iconIsSelected;
|
||||
}
|
||||
|
||||
public void setChildFile(List<DirFileModel> childFile) {
|
||||
this.childFile = childFile;
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package org.jcnc.jnotepad.controller.config;
|
||||
package org.jcnc.jnotepad.plugin.api.core.controller.config;
|
||||
|
||||
import org.jcnc.jnotepad.common.util.JsonUtil;
|
||||
import org.jcnc.jnotepad.common.util.LogUtil;
|
||||
@ -1,4 +1,4 @@
|
||||
package org.jcnc.jnotepad.common.manager;
|
||||
package org.jcnc.jnotepad.plugin.api.core.manager;
|
||||
|
||||
import org.jcnc.jnotepad.model.entity.Cache;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package org.jcnc.jnotepad.ui.setstage;
|
||||
package org.jcnc.jnotepad.plugin.api.core.ui.stage;
|
||||
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.image.Image;
|
||||
@ -1,4 +1,4 @@
|
||||
package org.jcnc.jnotepad.views.manager;
|
||||
package org.jcnc.jnotepad.plugin.api.core.views.manager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package org.jcnc.jnotepad.views.manager.builder;
|
||||
package org.jcnc.jnotepad.plugin.api.core.views.manager.builder;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
@ -1,4 +1,4 @@
|
||||
package org.jcnc.jnotepad.views.root.bottom.function.interfaces;
|
||||
package org.jcnc.jnotepad.plugin.api.core.views.sidebar.bottom;
|
||||
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.Menu;
|
||||
@ -1,6 +1,6 @@
|
||||
package org.jcnc.jnotepad.plugin.manager;
|
||||
|
||||
import org.jcnc.jnotepad.app.util.ApplicationRestarter;
|
||||
import org.jcnc.jnotepad.app.manager.ApplicationManager;
|
||||
import org.jcnc.jnotepad.common.manager.ThreadPoolManager;
|
||||
import org.jcnc.jnotepad.common.util.LogUtil;
|
||||
import org.jcnc.jnotepad.common.util.PopUpUtil;
|
||||
@ -201,7 +201,7 @@ public class PluginManager {
|
||||
appDialog -> {
|
||||
appDialog.close();
|
||||
// 执行重启操作
|
||||
ApplicationRestarter.restart();
|
||||
ApplicationManager.getInstance().restart();
|
||||
}, null, "重启", "以后再说");
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@ import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.Stage;
|
||||
import org.jcnc.jnotepad.app.util.ApplicationRestarter;
|
||||
import org.jcnc.jnotepad.app.manager.ApplicationManager;
|
||||
import org.jcnc.jnotepad.common.util.LogUtil;
|
||||
import org.jcnc.jnotepad.common.util.PopUpUtil;
|
||||
import org.jcnc.jnotepad.common.util.UiUtil;
|
||||
@ -75,7 +75,7 @@ public class DeveloperDebugStage extends Stage {
|
||||
debugButton6.setOnAction(event -> {
|
||||
logger.debug("开发者调试: {}启动!", debugButton6.getText());
|
||||
// 执行重启操作
|
||||
ApplicationRestarter.restart();
|
||||
ApplicationManager.getInstance().restart();
|
||||
});
|
||||
|
||||
alertBox.getChildren().addAll(debugButton1, debugButton2, debugButton3, debugButton4, debugButton5);
|
||||
|
||||
@ -19,6 +19,7 @@ import javafx.scene.layout.VBox;
|
||||
import javafx.stage.Stage;
|
||||
import org.jcnc.jnotepad.common.util.LogUtil;
|
||||
import org.jcnc.jnotepad.common.util.UiUtil;
|
||||
import org.jcnc.jnotepad.plugin.api.core.ui.stage.AbstractPaneStage;
|
||||
import org.jcnc.jnotepad.views.manager.RootManager;
|
||||
|
||||
import static org.jcnc.jnotepad.common.constants.AppConstants.*;
|
||||
|
||||
@ -29,9 +29,9 @@ import org.jcnc.jnotepad.common.util.LogUtil;
|
||||
import org.jcnc.jnotepad.common.util.PopUpUtil;
|
||||
import org.jcnc.jnotepad.common.util.UiUtil;
|
||||
import org.jcnc.jnotepad.model.entity.PluginDescriptor;
|
||||
import org.jcnc.jnotepad.plugin.api.core.ui.stage.AbstractPaneStage;
|
||||
import org.jcnc.jnotepad.plugin.manager.PluginManager;
|
||||
import org.jcnc.jnotepad.ui.module.CustomSetButton;
|
||||
import org.jcnc.jnotepad.ui.setstage.AbstractPaneStage;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package org.jcnc.jnotepad.views.manager;
|
||||
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.scene.control.SplitPane;
|
||||
import javafx.scene.control.TreeItem;
|
||||
import org.jcnc.jnotepad.common.manager.ApplicationCacheManager;
|
||||
@ -41,7 +42,7 @@ public class DirectorySidebarManager {
|
||||
private static final DirectorySidebarPane DIRECTORY_SIDEBAR_PANE = DirectorySidebarPane.getInstance();
|
||||
|
||||
|
||||
private static final double lastDividerPosition = 0.3;
|
||||
private static final double LAST_DIVIDER_POSITION = 0.3;
|
||||
|
||||
/**
|
||||
* 控制文件树显示
|
||||
@ -56,13 +57,13 @@ public class DirectorySidebarManager {
|
||||
double roundedNumber = Double.parseDouble(formattedNumber);
|
||||
|
||||
// 分割条位置不等于 代表展开
|
||||
if (roundedNumber != 0.0) {
|
||||
if (Double.compare(roundedNumber, 0.0) != 0) {
|
||||
// 收缩分割条 收缩文件树
|
||||
center.setDividerPositions(0.0);
|
||||
|
||||
} else {
|
||||
// 展开分割条,文件树
|
||||
center.setDividerPositions(lastDividerPosition);
|
||||
center.setDividerPositions(LAST_DIVIDER_POSITION);
|
||||
|
||||
}
|
||||
}
|
||||
@ -76,8 +77,19 @@ public class DirectorySidebarManager {
|
||||
if (bool) {
|
||||
// 获取分割面板
|
||||
SplitPane center = (SplitPane) MAIN_BORDER_PANE.getCenter();
|
||||
center.setDividerPositions(lastDividerPosition);
|
||||
center.setDividerPositions(LAST_DIVIDER_POSITION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static ChangeListener<Boolean> getTreeItemListener(TreeItem<DirFileModel> item) {
|
||||
return (observable, oldValue, newValue) -> {
|
||||
if (Boolean.TRUE.equals(newValue)) {
|
||||
item.setGraphic(item.getValue().getIconIsSelected());
|
||||
} else {
|
||||
item.setGraphic(item.getValue().getIconIsNotSelected());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@ -86,10 +98,10 @@ public class DirectorySidebarManager {
|
||||
* @param dirFileModel 文件
|
||||
*/
|
||||
public void setTreeView(DirFileModel dirFileModel) {
|
||||
TreeItem<DirFileModel> rootItem = new TreeItem<>(dirFileModel);
|
||||
TreeItem<DirFileModel> rootItem = new TreeItem<>(dirFileModel, dirFileModel.getIconIsNotSelected());
|
||||
|
||||
DIRECTORY_SIDEBAR_PANE.setRoot(rootItem);
|
||||
|
||||
rootItem.expandedProperty().addListener(getTreeItemListener(rootItem));
|
||||
expandFolder(dirFileModel, rootItem);
|
||||
}
|
||||
|
||||
@ -103,7 +115,8 @@ public class DirectorySidebarManager {
|
||||
List<DirFileModel> childFileList = dirFileModel.getChildFile();
|
||||
if (childFileList != null) {
|
||||
for (DirFileModel childFile : childFileList) {
|
||||
TreeItem<DirFileModel> childItem = new TreeItem<>(childFile);
|
||||
TreeItem<DirFileModel> childItem = new TreeItem<>(childFile, childFile.getIconIsNotSelected());
|
||||
childItem.expandedProperty().addListener(getTreeItemListener(childItem));
|
||||
item.getChildren().add(childItem);
|
||||
expandFolder(childFile, childItem);
|
||||
}
|
||||
@ -111,6 +124,11 @@ public class DirectorySidebarManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 展开已打开文件树
|
||||
*
|
||||
* @since 2023/10/2 23:12
|
||||
*/
|
||||
public void expandTheOpenFileTree() {
|
||||
// 获取缓存
|
||||
Object cacheData = CACHE_MANAGER.getCacheData(OpenDirectory.GROUP, "folderThatWasOpened");
|
||||
|
||||
@ -5,7 +5,8 @@ import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import org.jcnc.jnotepad.controller.event.handler.setting.DirTreeBtn;
|
||||
import org.jcnc.jnotepad.controller.event.handler.setting.SetBtn;
|
||||
import org.jcnc.jnotepad.views.manager.builder.SideBarButtonBuilder;
|
||||
import org.jcnc.jnotepad.plugin.api.core.views.manager.AbstractManager;
|
||||
import org.jcnc.jnotepad.plugin.api.core.views.manager.builder.SideBarButtonBuilder;
|
||||
import org.jcnc.jnotepad.views.root.left.sidebar.tools.SidebarToolBar;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@ -15,6 +15,7 @@ import org.jcnc.jnotepad.controller.config.AppConfigController;
|
||||
import org.jcnc.jnotepad.controller.event.handler.menubar.*;
|
||||
import org.jcnc.jnotepad.controller.i18n.LocalizationController;
|
||||
import org.jcnc.jnotepad.model.entity.ShortcutKey;
|
||||
import org.jcnc.jnotepad.plugin.api.core.views.manager.AbstractManager;
|
||||
import org.jcnc.jnotepad.ui.setstage.HelpPaneStage;
|
||||
import org.jcnc.jnotepad.ui.setstage.pluginstage.PluginManagementPane;
|
||||
import org.jcnc.jnotepad.views.root.top.menu.TopMenuBar;
|
||||
@ -23,7 +24,6 @@ import org.slf4j.Logger;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jcnc.jnotepad.common.constants.TextConstants.*;
|
||||
import static org.jcnc.jnotepad.common.constants.TextConstants.OPEN_DIRECTORY;
|
||||
|
||||
/**
|
||||
* 顶部菜单栏管理类
|
||||
|
||||
@ -20,18 +20,21 @@ public class DirectorySidebarPane extends TreeView<DirFileModel> {
|
||||
|
||||
private static final DirectorySidebarPane INSTANCE = new DirectorySidebarPane();
|
||||
|
||||
private static final int CLICK_COUNT = 2;
|
||||
|
||||
private DirectorySidebarPane() {
|
||||
this.setOnMouseClicked(mouseEvent -> {
|
||||
if (mouseEvent.getClickCount() == 2) {
|
||||
if (mouseEvent.getClickCount() == CLICK_COUNT) {
|
||||
TreeItem<DirFileModel> item = DirectorySidebarPane.this.getSelectionModel().getSelectedItem();
|
||||
if (Objects.isNull(item)) return;
|
||||
if (Objects.isNull(item)) {
|
||||
return;
|
||||
}
|
||||
File file = new File(item.getValue().getPath());
|
||||
|
||||
if (!file.isFile()) {
|
||||
return;
|
||||
}
|
||||
OpenFile.openFile(file);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user