🚩 为文件树添加图标,修改项目结构
This commit is contained in:
parent
8a3404b5d7
commit
8a94fb67ec
@ -35,12 +35,13 @@ module org.jcnc.jnotepad {
|
|||||||
opens org.jcnc.jnotepad.app.config;
|
opens org.jcnc.jnotepad.app.config;
|
||||||
exports org.jcnc.jnotepad.plugin.interfaces;
|
exports org.jcnc.jnotepad.plugin.interfaces;
|
||||||
exports org.jcnc.jnotepad.views.root.bottom.function;
|
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;
|
||||||
exports org.jcnc.jnotepad.ui.dialog.interfaces;
|
exports org.jcnc.jnotepad.ui.dialog.interfaces;
|
||||||
exports org.jcnc.jnotepad.ui.module;
|
exports org.jcnc.jnotepad.ui.module;
|
||||||
exports org.jcnc.jnotepad.model.entity;
|
exports org.jcnc.jnotepad.model.entity;
|
||||||
exports org.jcnc.jnotepad.views.root.bottom;
|
exports org.jcnc.jnotepad.views.root.bottom;
|
||||||
exports org.jcnc.jnotepad.views.root.bottom.status;
|
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.initializeApp();
|
||||||
// 初始化默认操作
|
// 初始化默认操作
|
||||||
APPLICATION_MANAGER.initializeDefaultAction();
|
APPLICATION_MANAGER.executeDefaultAction();
|
||||||
primaryStage.show();
|
primaryStage.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -7,10 +7,12 @@ import javafx.scene.Scene;
|
|||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import javafx.stage.Window;
|
import javafx.stage.Window;
|
||||||
|
import org.jcnc.jnotepad.LunchApp;
|
||||||
import org.jcnc.jnotepad.app.i18n.UiResourceBundle;
|
import org.jcnc.jnotepad.app.i18n.UiResourceBundle;
|
||||||
import org.jcnc.jnotepad.common.constants.AppConstants;
|
import org.jcnc.jnotepad.common.constants.AppConstants;
|
||||||
import org.jcnc.jnotepad.common.constants.TextConstants;
|
import org.jcnc.jnotepad.common.constants.TextConstants;
|
||||||
import org.jcnc.jnotepad.common.manager.ThreadPoolManager;
|
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.common.util.UiUtil;
|
||||||
import org.jcnc.jnotepad.controller.ResourceController;
|
import org.jcnc.jnotepad.controller.ResourceController;
|
||||||
import org.jcnc.jnotepad.controller.cache.CacheController;
|
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.plugin.manager.PluginManager;
|
||||||
import org.jcnc.jnotepad.views.manager.*;
|
import org.jcnc.jnotepad.views.manager.*;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
@ -77,7 +80,10 @@ public class ApplicationManager {
|
|||||||
initPrimaryStage();
|
initPrimaryStage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initializeDefaultAction() {
|
/**
|
||||||
|
* 执行默认操作
|
||||||
|
*/
|
||||||
|
public void executeDefaultAction() {
|
||||||
// 使用加载关联文件并创建文本区域
|
// 使用加载关联文件并创建文本区域
|
||||||
List<String> rawParameters = application.getParameters().getRaw();
|
List<String> rawParameters = application.getParameters().getRaw();
|
||||||
Controller.getInstance().openAssociatedFileAndCreateTextArea(rawParameters);
|
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() {
|
public Pane getRoot() {
|
||||||
return root;
|
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;
|
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.controller.event.handler.menubar.OpenFile;
|
||||||
import org.jcnc.jnotepad.exception.AppException;
|
import org.jcnc.jnotepad.exception.AppException;
|
||||||
import org.jcnc.jnotepad.model.entity.DirFileModel;
|
import org.jcnc.jnotepad.model.entity.DirFileModel;
|
||||||
|
import org.kordamp.ikonli.javafx.FontIcon;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
@ -13,6 +14,8 @@ import java.security.MessageDigest;
|
|||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import static org.kordamp.ikonli.antdesignicons.AntDesignIconsFilled.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件工具
|
* 文件工具
|
||||||
*
|
*
|
||||||
@ -140,7 +143,7 @@ public class FileUtil {
|
|||||||
return null;
|
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();
|
File[] files = file.listFiles();
|
||||||
if (files != null) {
|
if (files != null) {
|
||||||
@ -149,7 +152,7 @@ public class FileUtil {
|
|||||||
DirFileModel childDirFileModel = getDirFileModel(f);
|
DirFileModel childDirFileModel = getDirFileModel(f);
|
||||||
dirFileModel.getChildFile().add(childDirFileModel);
|
dirFileModel.getChildFile().add(childDirFileModel);
|
||||||
} else {
|
} else {
|
||||||
dirFileModel.getChildFile().add(new DirFileModel(f.getAbsolutePath(), f.getName(), null));
|
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.app.config.AppConfig;
|
||||||
import org.jcnc.jnotepad.model.entity.ShortcutKey;
|
import org.jcnc.jnotepad.model.entity.ShortcutKey;
|
||||||
|
import org.jcnc.jnotepad.plugin.api.core.controller.config.BaseConfigController;
|
||||||
|
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package org.jcnc.jnotepad.controller.config;
|
package org.jcnc.jnotepad.controller.config;
|
||||||
|
|
||||||
import org.jcnc.jnotepad.app.config.PluginConfig;
|
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.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
package org.jcnc.jnotepad.model.entity;
|
package org.jcnc.jnotepad.model.entity;
|
||||||
|
|
||||||
|
import org.kordamp.ikonli.javafx.FontIcon;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -11,14 +13,22 @@ public class DirFileModel {
|
|||||||
private String path;
|
private String path;
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
private FontIcon iconIsNotSelected;
|
||||||
|
|
||||||
|
private FontIcon iconIsSelected;
|
||||||
|
|
||||||
private List<DirFileModel> childFile;
|
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.path = path;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.childFile = childFile;
|
this.childFile = childFile;
|
||||||
|
this.iconIsNotSelected = iconIsNotSelected;
|
||||||
|
this.iconIsSelected = iconIsSelected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<DirFileModel> getChildFile() {
|
public List<DirFileModel> getChildFile() {
|
||||||
return childFile;
|
return childFile;
|
||||||
}
|
}
|
||||||
@ -47,4 +57,20 @@ public class DirFileModel {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return name;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -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.JsonUtil;
|
||||||
import org.jcnc.jnotepad.common.util.LogUtil;
|
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;
|
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.Scene;
|
||||||
import javafx.scene.image.Image;
|
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;
|
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.ActionEvent;
|
||||||
import javafx.event.EventHandler;
|
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.Label;
|
||||||
import javafx.scene.control.Menu;
|
import javafx.scene.control.Menu;
|
||||||
@ -1,6 +1,6 @@
|
|||||||
package org.jcnc.jnotepad.plugin.manager;
|
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.manager.ThreadPoolManager;
|
||||||
import org.jcnc.jnotepad.common.util.LogUtil;
|
import org.jcnc.jnotepad.common.util.LogUtil;
|
||||||
import org.jcnc.jnotepad.common.util.PopUpUtil;
|
import org.jcnc.jnotepad.common.util.PopUpUtil;
|
||||||
@ -201,7 +201,7 @@ public class PluginManager {
|
|||||||
appDialog -> {
|
appDialog -> {
|
||||||
appDialog.close();
|
appDialog.close();
|
||||||
// 执行重启操作
|
// 执行重启操作
|
||||||
ApplicationRestarter.restart();
|
ApplicationManager.getInstance().restart();
|
||||||
}, null, "重启", "以后再说");
|
}, null, "重启", "以后再说");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import javafx.scene.control.Label;
|
|||||||
import javafx.scene.layout.HBox;
|
import javafx.scene.layout.HBox;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.stage.Stage;
|
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.LogUtil;
|
||||||
import org.jcnc.jnotepad.common.util.PopUpUtil;
|
import org.jcnc.jnotepad.common.util.PopUpUtil;
|
||||||
import org.jcnc.jnotepad.common.util.UiUtil;
|
import org.jcnc.jnotepad.common.util.UiUtil;
|
||||||
@ -75,7 +75,7 @@ public class DeveloperDebugStage extends Stage {
|
|||||||
debugButton6.setOnAction(event -> {
|
debugButton6.setOnAction(event -> {
|
||||||
logger.debug("开发者调试: {}启动!", debugButton6.getText());
|
logger.debug("开发者调试: {}启动!", debugButton6.getText());
|
||||||
// 执行重启操作
|
// 执行重启操作
|
||||||
ApplicationRestarter.restart();
|
ApplicationManager.getInstance().restart();
|
||||||
});
|
});
|
||||||
|
|
||||||
alertBox.getChildren().addAll(debugButton1, debugButton2, debugButton3, debugButton4, debugButton5);
|
alertBox.getChildren().addAll(debugButton1, debugButton2, debugButton3, debugButton4, debugButton5);
|
||||||
|
|||||||
@ -19,6 +19,7 @@ import javafx.scene.layout.VBox;
|
|||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import org.jcnc.jnotepad.common.util.LogUtil;
|
import org.jcnc.jnotepad.common.util.LogUtil;
|
||||||
import org.jcnc.jnotepad.common.util.UiUtil;
|
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 org.jcnc.jnotepad.views.manager.RootManager;
|
||||||
|
|
||||||
import static org.jcnc.jnotepad.common.constants.AppConstants.*;
|
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.PopUpUtil;
|
||||||
import org.jcnc.jnotepad.common.util.UiUtil;
|
import org.jcnc.jnotepad.common.util.UiUtil;
|
||||||
import org.jcnc.jnotepad.model.entity.PluginDescriptor;
|
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.plugin.manager.PluginManager;
|
||||||
import org.jcnc.jnotepad.ui.module.CustomSetButton;
|
import org.jcnc.jnotepad.ui.module.CustomSetButton;
|
||||||
import org.jcnc.jnotepad.ui.setstage.AbstractPaneStage;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package org.jcnc.jnotepad.views.manager;
|
package org.jcnc.jnotepad.views.manager;
|
||||||
|
|
||||||
|
import javafx.beans.value.ChangeListener;
|
||||||
import javafx.scene.control.TreeItem;
|
import javafx.scene.control.TreeItem;
|
||||||
import org.jcnc.jnotepad.common.manager.ApplicationCacheManager;
|
import org.jcnc.jnotepad.common.manager.ApplicationCacheManager;
|
||||||
import org.jcnc.jnotepad.common.util.FileUtil;
|
import org.jcnc.jnotepad.common.util.FileUtil;
|
||||||
@ -12,9 +13,9 @@ import java.io.File;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 文件树管理类
|
||||||
|
*
|
||||||
* @author : cccqyu
|
* @author : cccqyu
|
||||||
* @createTime 2023/10/2 20:33
|
|
||||||
* @description 文件树管理类
|
|
||||||
*/
|
*/
|
||||||
public class DirectorySidebarManager {
|
public class DirectorySidebarManager {
|
||||||
|
|
||||||
@ -67,16 +68,26 @@ public class DirectorySidebarManager {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置文件树内容
|
* 设置文件树内容
|
||||||
*
|
*
|
||||||
* @param dirFileModel 文件
|
* @param dirFileModel 文件
|
||||||
*/
|
*/
|
||||||
public void setTreeView(DirFileModel 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);
|
DIRECTORY_SIDEBAR_PANE.setRoot(rootItem);
|
||||||
|
rootItem.expandedProperty().addListener(getTreeItemListener(rootItem));
|
||||||
expandFolder(dirFileModel, rootItem);
|
expandFolder(dirFileModel, rootItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +101,8 @@ public class DirectorySidebarManager {
|
|||||||
List<DirFileModel> childFileList = dirFileModel.getChildFile();
|
List<DirFileModel> childFileList = dirFileModel.getChildFile();
|
||||||
if (childFileList != null) {
|
if (childFileList != null) {
|
||||||
for (DirFileModel childFile : childFileList) {
|
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);
|
item.getChildren().add(childItem);
|
||||||
expandFolder(childFile, childItem);
|
expandFolder(childFile, childItem);
|
||||||
}
|
}
|
||||||
@ -98,6 +110,11 @@ public class DirectorySidebarManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 展开已打开文件树
|
||||||
|
*
|
||||||
|
* @since 2023/10/2 23:12
|
||||||
|
*/
|
||||||
public void expandTheOpenFileTree() {
|
public void expandTheOpenFileTree() {
|
||||||
// 获取缓存
|
// 获取缓存
|
||||||
Object cacheData = CACHE_MANAGER.getCacheData(OpenDirectory.GROUP, "folderThatWasOpened");
|
Object cacheData = CACHE_MANAGER.getCacheData(OpenDirectory.GROUP, "folderThatWasOpened");
|
||||||
|
|||||||
@ -5,7 +5,8 @@ import javafx.scene.image.Image;
|
|||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import org.jcnc.jnotepad.controller.event.handler.setting.DirTreeBtn;
|
import org.jcnc.jnotepad.controller.event.handler.setting.DirTreeBtn;
|
||||||
import org.jcnc.jnotepad.controller.event.handler.setting.SetBtn;
|
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 org.jcnc.jnotepad.views.root.left.sidebar.tools.SidebarToolBar;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
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.event.handler.menubar.*;
|
||||||
import org.jcnc.jnotepad.controller.i18n.LocalizationController;
|
import org.jcnc.jnotepad.controller.i18n.LocalizationController;
|
||||||
import org.jcnc.jnotepad.model.entity.ShortcutKey;
|
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.HelpPaneStage;
|
||||||
import org.jcnc.jnotepad.ui.setstage.pluginstage.PluginManagementPane;
|
import org.jcnc.jnotepad.ui.setstage.pluginstage.PluginManagementPane;
|
||||||
import org.jcnc.jnotepad.views.root.top.menu.TopMenuBar;
|
import org.jcnc.jnotepad.views.root.top.menu.TopMenuBar;
|
||||||
@ -23,7 +24,6 @@ import org.slf4j.Logger;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static org.jcnc.jnotepad.common.constants.TextConstants.*;
|
import static org.jcnc.jnotepad.common.constants.TextConstants.*;
|
||||||
import static org.jcnc.jnotepad.common.constants.TextConstants.OPEN_DIRECTORY;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 顶部菜单栏管理类
|
* 顶部菜单栏管理类
|
||||||
|
|||||||
@ -1,9 +1,7 @@
|
|||||||
package org.jcnc.jnotepad.views.root.center.main.center.directory;
|
package org.jcnc.jnotepad.views.root.center.main.center.directory;
|
||||||
|
|
||||||
import javafx.event.EventHandler;
|
|
||||||
import javafx.scene.control.TreeItem;
|
import javafx.scene.control.TreeItem;
|
||||||
import javafx.scene.control.TreeView;
|
import javafx.scene.control.TreeView;
|
||||||
import javafx.scene.input.MouseEvent;
|
|
||||||
import org.jcnc.jnotepad.controller.event.handler.menubar.OpenFile;
|
import org.jcnc.jnotepad.controller.event.handler.menubar.OpenFile;
|
||||||
import org.jcnc.jnotepad.model.entity.DirFileModel;
|
import org.jcnc.jnotepad.model.entity.DirFileModel;
|
||||||
|
|
||||||
@ -20,23 +18,24 @@ public class DirectorySidebarPane extends TreeView<DirFileModel> {
|
|||||||
|
|
||||||
private static final DirectorySidebarPane INSTANCE = new DirectorySidebarPane();
|
private static final DirectorySidebarPane INSTANCE = new DirectorySidebarPane();
|
||||||
|
|
||||||
|
private static final int CLICK_COUNT = 2;
|
||||||
|
|
||||||
private DirectorySidebarPane() {
|
private DirectorySidebarPane() {
|
||||||
this.setVisible(false);
|
this.setVisible(false);
|
||||||
|
|
||||||
this.setOnMouseClicked(new EventHandler<MouseEvent>() {
|
this.setOnMouseClicked(mouseEvent -> {
|
||||||
@Override
|
if (mouseEvent.getClickCount() == CLICK_COUNT) {
|
||||||
public void handle(MouseEvent mouseEvent) {
|
TreeItem<DirFileModel> item = DirectorySidebarPane.this.getSelectionModel().getSelectedItem();
|
||||||
if (mouseEvent.getClickCount() == 2) {
|
if (Objects.isNull(item)) {
|
||||||
TreeItem<DirFileModel> item = DirectorySidebarPane.this.getSelectionModel().getSelectedItem();
|
return;
|
||||||
if (Objects.isNull(item)) return;
|
|
||||||
File file = new File(item.getValue().getPath());
|
|
||||||
|
|
||||||
if(!file.isFile()){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
new OpenFile().openFile(file);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
File file = new File(item.getValue().getPath());
|
||||||
|
|
||||||
|
if (!file.isFile()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
OpenFile.openFile(file);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user