⚡️ 优化代码 🗑️ 清理无效的代码
This commit is contained in:
parent
2eb71bece8
commit
a9dd2e21c5
@ -23,6 +23,8 @@ module org.jcnc.jnotepad {
|
|||||||
exports org.jcnc.jnotepad.constants;
|
exports org.jcnc.jnotepad.constants;
|
||||||
exports org.jcnc.jnotepad.ui;
|
exports org.jcnc.jnotepad.ui;
|
||||||
exports org.jcnc.jnotepad.app.init;
|
exports org.jcnc.jnotepad.app.init;
|
||||||
exports org.jcnc.jnotepad.json; // 导出 JSON 相关的包,以便 Jackson 库可以访问
|
// 导出 JSON 相关的包,以便 Jackson 库可以访问
|
||||||
opens org.jcnc.jnotepad.json; // 打开 JSON 相关的包,以便 Jackson 库可以使用反射
|
exports org.jcnc.jnotepad.json;
|
||||||
|
// 打开 JSON 相关的包,以便 Jackson 库可以使用反射
|
||||||
|
opens org.jcnc.jnotepad.json;
|
||||||
}
|
}
|
||||||
@ -8,7 +8,6 @@ import javafx.scene.Scene;
|
|||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import org.jcnc.jnotepad.app.config.LocalizationConfig;
|
|
||||||
import org.jcnc.jnotepad.app.i18n.UIResourceBundle;
|
import org.jcnc.jnotepad.app.i18n.UIResourceBundle;
|
||||||
import org.jcnc.jnotepad.app.init.LoadJnotepadConfig;
|
import org.jcnc.jnotepad.app.init.LoadJnotepadConfig;
|
||||||
import org.jcnc.jnotepad.app.init.LoadLanguageConfig;
|
import org.jcnc.jnotepad.app.init.LoadLanguageConfig;
|
||||||
@ -37,8 +36,6 @@ public class LunchApp extends Application {
|
|||||||
* 线程池
|
* 线程池
|
||||||
*/
|
*/
|
||||||
private final ExecutorService threadPool = ThreadPoolManager.getThreadPool();
|
private final ExecutorService threadPool = ThreadPoolManager.getThreadPool();
|
||||||
|
|
||||||
LocalizationConfig localizationConfig = LocalizationConfig.getLocalizationConfig();
|
|
||||||
Controller controller = Controller.getInstance();
|
Controller controller = Controller.getInstance();
|
||||||
Scene scene;
|
Scene scene;
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -2,15 +2,14 @@ package org.jcnc.jnotepad.app.config;
|
|||||||
|
|
||||||
import org.jcnc.jnotepad.LunchApp;
|
import org.jcnc.jnotepad.LunchApp;
|
||||||
import org.jcnc.jnotepad.app.i18n.UIResourceBundle;
|
import org.jcnc.jnotepad.app.i18n.UIResourceBundle;
|
||||||
import org.jcnc.jnotepad.tool.LogUtil;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.util.HashMap;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.*;
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.jcnc.jnotepad.constants.AppConstants.APP_NAME;
|
import static org.jcnc.jnotepad.constants.TextConstants.CHINESE;
|
||||||
import static org.jcnc.jnotepad.constants.TextConstants.*;
|
import static org.jcnc.jnotepad.constants.TextConstants.ENGLISH;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 本地化配置文件<br>
|
* 本地化配置文件<br>
|
||||||
@ -21,10 +20,7 @@ import static org.jcnc.jnotepad.constants.TextConstants.*;
|
|||||||
*/
|
*/
|
||||||
public class LocalizationConfig {
|
public class LocalizationConfig {
|
||||||
private static final LocalizationConfig LOCALIZATION_CONFIG = new LocalizationConfig();
|
private static final LocalizationConfig LOCALIZATION_CONFIG = new LocalizationConfig();
|
||||||
private final Properties properties = new Properties();
|
|
||||||
|
|
||||||
private String language;
|
private String language;
|
||||||
|
|
||||||
private static final Map<String, Locale> SUPPORT_LOCALES;
|
private static final Map<String, Locale> SUPPORT_LOCALES;
|
||||||
private static final Map<Locale, String> SUPPORT_LANGUAGES;
|
private static final Map<Locale, String> SUPPORT_LANGUAGES;
|
||||||
|
|
||||||
@ -39,17 +35,17 @@ public class LocalizationConfig {
|
|||||||
SUPPORT_LANGUAGES.put(Locale.ENGLISH, ENGLISH);
|
SUPPORT_LANGUAGES.put(Locale.ENGLISH, ENGLISH);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Locale getCurrentLocal() {
|
public static Locale getCurrentLocal() {
|
||||||
return Locale.getDefault();
|
return Locale.getDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final void setCurrentLocal(Locale locale) {
|
public static void setCurrentLocal(Locale locale) {
|
||||||
Locale.setDefault(locale);
|
Locale.setDefault(locale);
|
||||||
UIResourceBundle.getInstance().resetLocal();
|
UIResourceBundle.getInstance().resetLocal();
|
||||||
LOCALIZATION_CONFIG.setLanguage(SUPPORT_LANGUAGES.get(locale));
|
LOCALIZATION_CONFIG.setLanguage(SUPPORT_LANGUAGES.get(locale));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final void setCurrentLocal(String language) {
|
public static void setCurrentLocal(String language) {
|
||||||
Locale locale = SUPPORT_LOCALES.get(language);
|
Locale locale = SUPPORT_LOCALES.get(language);
|
||||||
if (locale != null) {
|
if (locale != null) {
|
||||||
setCurrentLocal(locale);
|
setCurrentLocal(locale);
|
||||||
@ -74,7 +70,6 @@ public class LocalizationConfig {
|
|||||||
|
|
||||||
public void setTextWrap(String textWrap) {
|
public void setTextWrap(String textWrap) {
|
||||||
this.textWrap = textWrap;
|
this.textWrap = textWrap;
|
||||||
properties.setProperty(TEXT_WRAP, textWrap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setLanguage(String language) {
|
private void setLanguage(String language) {
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package org.jcnc.jnotepad.app.i18n;
|
package org.jcnc.jnotepad.app.i18n;
|
||||||
|
|
||||||
|
import javafx.beans.binding.Bindings;
|
||||||
import javafx.beans.binding.StringBinding;
|
import javafx.beans.binding.StringBinding;
|
||||||
import javafx.beans.property.ObjectProperty;
|
import javafx.beans.property.ObjectProperty;
|
||||||
import javafx.beans.property.SimpleObjectProperty;
|
import javafx.beans.property.SimpleObjectProperty;
|
||||||
@ -28,7 +29,7 @@ public class UIResourceBundle {
|
|||||||
*/
|
*/
|
||||||
private Locale currentLocale;
|
private Locale currentLocale;
|
||||||
|
|
||||||
public static final UIResourceBundle getInstance() {
|
public static UIResourceBundle getInstance() {
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,11 +40,12 @@ public class UIResourceBundle {
|
|||||||
/**
|
/**
|
||||||
* 资源文件的观察者绑定。
|
* 资源文件的观察者绑定。
|
||||||
*/
|
*/
|
||||||
private ObjectProperty<ResourceBundle> resources = new SimpleObjectProperty<>();
|
private final ObjectProperty<ResourceBundle> resources = new SimpleObjectProperty<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前资源文件
|
* 获取当前资源文件
|
||||||
* @return
|
*
|
||||||
|
* @return 资源文件
|
||||||
*/
|
*/
|
||||||
public ObjectProperty<ResourceBundle> resourcesProperty() {
|
public ObjectProperty<ResourceBundle> resourcesProperty() {
|
||||||
return resources;
|
return resources;
|
||||||
@ -72,26 +74,19 @@ public class UIResourceBundle {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取key对应的绑定属性内容
|
* 获取key对应的绑定属性内容
|
||||||
|
*
|
||||||
* @param key key
|
* @param key key
|
||||||
* @return key对应的内容
|
* @return key对应的内容
|
||||||
*/
|
*/
|
||||||
public StringBinding getStringBinding(String key) {
|
public StringBinding getStringBinding(String key) {
|
||||||
return new StringBinding() {
|
return Bindings.createStringBinding(() -> getResources().getString(key), resourcesProperty());
|
||||||
{
|
|
||||||
bind(resourcesProperty());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String computeValue() {
|
|
||||||
return getResources().getString(key);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 工具方法:绑定StringProperty和Key对应的内容
|
* 工具方法:绑定StringProperty和Key对应的内容
|
||||||
* @param stringProperty
|
*
|
||||||
* @param key
|
* @param stringProperty 字符串属性
|
||||||
|
* @param key 键值
|
||||||
*/
|
*/
|
||||||
public static void bindStringProperty(StringProperty stringProperty, String key) {
|
public static void bindStringProperty(StringProperty stringProperty, String key) {
|
||||||
if (stringProperty == null) {
|
if (stringProperty == null) {
|
||||||
@ -102,16 +97,18 @@ public class UIResourceBundle {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前资源中的key值
|
* 获取当前资源中的key值
|
||||||
* @param key
|
*
|
||||||
* @return
|
* @param key 资源所对应键
|
||||||
|
* @return 当前键所对应的值
|
||||||
*/
|
*/
|
||||||
public static String getContent(String key) {
|
public static String getContent(String key) {
|
||||||
return getInstance().getResources().getString(key);
|
return INSTANCE.getResources().getString(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册资源变更监听器
|
* 注册资源变更监听器
|
||||||
* @param listener
|
*
|
||||||
|
* @param listener 变更监听器
|
||||||
*/
|
*/
|
||||||
public void addListener(ChangeListener<? super ResourceBundle> listener) {
|
public void addListener(ChangeListener<? super ResourceBundle> listener) {
|
||||||
this.resources.addListener(listener);
|
this.resources.addListener(listener);
|
||||||
|
|||||||
@ -3,7 +3,6 @@ package org.jcnc.jnotepad.app.init;
|
|||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.jcnc.jnotepad.app.config.LocalizationConfig;
|
|
||||||
import org.jcnc.jnotepad.exception.AppException;
|
import org.jcnc.jnotepad.exception.AppException;
|
||||||
import org.jcnc.jnotepad.tool.LogUtil;
|
import org.jcnc.jnotepad.tool.LogUtil;
|
||||||
import org.jcnc.jnotepad.tool.PopUpUtil;
|
import org.jcnc.jnotepad.tool.PopUpUtil;
|
||||||
|
|||||||
@ -16,8 +16,6 @@ import java.io.InputStream;
|
|||||||
public class LoadLanguageConfig extends LoadJnotepadConfig<String> {
|
public class LoadLanguageConfig extends LoadJnotepadConfig<String> {
|
||||||
Logger log = LogUtil.getLogger(this.getClass());
|
Logger log = LogUtil.getLogger(this.getClass());
|
||||||
|
|
||||||
LocalizationConfig localizationConfig = LocalizationConfig.getLocalizationConfig();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String parseConfig(InputStream inputStream) {
|
protected String parseConfig(InputStream inputStream) {
|
||||||
return getConfigJson(inputStream).get("language").asText();
|
return getConfigJson(inputStream).get("language").asText();
|
||||||
@ -30,7 +28,7 @@ public class LoadLanguageConfig extends LoadJnotepadConfig<String> {
|
|||||||
if (!"".equals(language) && language != null) {
|
if (!"".equals(language) && language != null) {
|
||||||
log.info("正在加载语言包:{}", language);
|
log.info("正在加载语言包:{}", language);
|
||||||
// 刷新语言包
|
// 刷新语言包
|
||||||
localizationConfig.setCurrentLocal(language);
|
LocalizationConfig.setCurrentLocal(language);
|
||||||
JNotepadMenuBar jNotepadMenuBar = JNotepadMenuBar.getMenuBar();
|
JNotepadMenuBar jNotepadMenuBar = JNotepadMenuBar.getMenuBar();
|
||||||
// 刷新菜单栏
|
// 刷新菜单栏
|
||||||
jNotepadMenuBar.toggleLanguageCheck(language);
|
jNotepadMenuBar.toggleLanguageCheck(language);
|
||||||
|
|||||||
@ -18,7 +18,6 @@ public class AppConstants {
|
|||||||
* 初始高度
|
* 初始高度
|
||||||
*/
|
*/
|
||||||
public static final double SCREEN_LENGTH = 600;
|
public static final double SCREEN_LENGTH = 600;
|
||||||
public static final String APP_NAME = "JNotepad";
|
|
||||||
/**
|
/**
|
||||||
* logo地址
|
* logo地址
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -22,10 +22,6 @@ public class TextConstants {
|
|||||||
|
|
||||||
|
|
||||||
/// GlobalConfig文本常量
|
/// GlobalConfig文本常量
|
||||||
/**
|
|
||||||
* 自动换行配置key
|
|
||||||
*/
|
|
||||||
public static final String TEXT_WRAP = "text.wrap";
|
|
||||||
|
|
||||||
public static final String TITLE = "title";
|
public static final String TITLE = "title";
|
||||||
public static final String SAVE = "SAVE";
|
public static final String SAVE = "SAVE";
|
||||||
@ -44,7 +40,6 @@ public class TextConstants {
|
|||||||
public static final String UPPER_CHINESE = "CHINESE";
|
public static final String UPPER_CHINESE = "CHINESE";
|
||||||
public static final String UPPER_ENGLISH = "ENGLISH";
|
public static final String UPPER_ENGLISH = "ENGLISH";
|
||||||
public static final String NEW_FILE = "NEW_FILE";
|
public static final String NEW_FILE = "NEW_FILE";
|
||||||
public static final String UNKNOWN = "UNKNOWN";
|
|
||||||
public static final String ROW = "ROW";
|
public static final String ROW = "ROW";
|
||||||
public static final String COLUMN = "COLUMN";
|
public static final String COLUMN = "COLUMN";
|
||||||
public static final String WORD_COUNT = "WORD_COUNT";
|
public static final String WORD_COUNT = "WORD_COUNT";
|
||||||
|
|||||||
@ -2,7 +2,6 @@ package org.jcnc.jnotepad.controller.event.handler;
|
|||||||
|
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
import org.jcnc.jnotepad.app.config.LocalizationConfig;
|
|
||||||
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.ui.LineNumberTextArea;
|
import org.jcnc.jnotepad.ui.LineNumberTextArea;
|
||||||
|
|||||||
@ -3,7 +3,6 @@ package org.jcnc.jnotepad.controller.manager;
|
|||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.concurrent.Task;
|
import javafx.concurrent.Task;
|
||||||
import org.jcnc.jnotepad.Interface.ControllerInterface;
|
import org.jcnc.jnotepad.Interface.ControllerInterface;
|
||||||
import org.jcnc.jnotepad.app.config.LocalizationConfig;
|
|
||||||
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;
|
||||||
|
|||||||
@ -42,12 +42,12 @@ public class ThreadPoolManager {
|
|||||||
*/
|
*/
|
||||||
private static final BlockingQueue<Runnable> BLOCKING_QUEUE = new LinkedBlockingQueue<>(4);
|
private static final BlockingQueue<Runnable> BLOCKING_QUEUE = new LinkedBlockingQueue<>(4);
|
||||||
/**
|
/**
|
||||||
* 当前线程数
|
* 当前运行线程数
|
||||||
*/
|
*/
|
||||||
private static final AtomicInteger THREAD_COUNT = new AtomicInteger(1);
|
private static final AtomicInteger THREAD_COUNT = new AtomicInteger(1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 线程数自减
|
* 当前运行线程数自减
|
||||||
*
|
*
|
||||||
* @apiNote 当你创建任务时,务必在最后执行一次该方法
|
* @apiNote 当你创建任务时,务必在最后执行一次该方法
|
||||||
* @see ThreadPoolManager
|
* @see ThreadPoolManager
|
||||||
|
|||||||
@ -3,7 +3,6 @@ package org.jcnc.jnotepad.tool;
|
|||||||
|
|
||||||
import com.ibm.icu.text.CharsetDetector;
|
import com.ibm.icu.text.CharsetDetector;
|
||||||
import com.ibm.icu.text.CharsetMatch;
|
import com.ibm.icu.text.CharsetMatch;
|
||||||
import org.jcnc.jnotepad.app.config.LocalizationConfig;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
@ -18,7 +17,6 @@ import java.nio.charset.Charset;
|
|||||||
* @author 许轲
|
* @author 许轲
|
||||||
*/
|
*/
|
||||||
public class EncodingDetector {
|
public class EncodingDetector {
|
||||||
static LocalizationConfig localizationConfig = LocalizationConfig.getLocalizationConfig();
|
|
||||||
private static final Logger LOG = LogUtil.getLogger(EncodingDetector.class);
|
private static final Logger LOG = LogUtil.getLogger(EncodingDetector.class);
|
||||||
/**
|
/**
|
||||||
* 编码侦测概率,阈值:50%
|
* 编码侦测概率,阈值:50%
|
||||||
@ -71,6 +69,8 @@ public class EncodingDetector {
|
|||||||
public static Charset detectEncodingCharset(File file) {
|
public static Charset detectEncodingCharset(File file) {
|
||||||
String charset = detectEncoding(file);
|
String charset = detectEncoding(file);
|
||||||
try {
|
try {
|
||||||
|
// 断言charset != null
|
||||||
|
assert charset != null;
|
||||||
return Charset.forName(charset);
|
return Charset.forName(charset);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return Charset.defaultCharset();
|
return Charset.defaultCharset();
|
||||||
|
|||||||
@ -9,7 +9,6 @@ import org.jcnc.jnotepad.LunchApp;
|
|||||||
import org.jcnc.jnotepad.app.config.GlobalConfig;
|
import org.jcnc.jnotepad.app.config.GlobalConfig;
|
||||||
import org.jcnc.jnotepad.app.config.LocalizationConfig;
|
import org.jcnc.jnotepad.app.config.LocalizationConfig;
|
||||||
import org.jcnc.jnotepad.app.i18n.UIResourceBundle;
|
import org.jcnc.jnotepad.app.i18n.UIResourceBundle;
|
||||||
import org.jcnc.jnotepad.constants.TextConstants;
|
|
||||||
import org.jcnc.jnotepad.controller.event.handler.*;
|
import org.jcnc.jnotepad.controller.event.handler.*;
|
||||||
import org.jcnc.jnotepad.exception.AppException;
|
import org.jcnc.jnotepad.exception.AppException;
|
||||||
import org.jcnc.jnotepad.tool.JsonUtil;
|
import org.jcnc.jnotepad.tool.JsonUtil;
|
||||||
@ -127,9 +126,7 @@ public class JNotepadMenuBar extends MenuBar {
|
|||||||
switch (language) {
|
switch (language) {
|
||||||
case CHINESE -> chineseItem.setSelected(true);
|
case CHINESE -> chineseItem.setSelected(true);
|
||||||
case ENGLISH -> englishItem.setSelected(true);
|
case ENGLISH -> englishItem.setSelected(true);
|
||||||
default -> {
|
default -> logger.error("未知语言:{}", language);
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +148,7 @@ public class JNotepadMenuBar extends MenuBar {
|
|||||||
* 初始化语言菜单
|
* 初始化语言菜单
|
||||||
*/
|
*/
|
||||||
private void initLanguageMenu() {
|
private void initLanguageMenu() {
|
||||||
logger.info("初始化语言菜单:{}", UIResourceBundle.getContent(LANGUAGE));
|
logger.info("初始化语言菜单!");
|
||||||
// 语言菜单
|
// 语言菜单
|
||||||
languageMenu = new Menu();
|
languageMenu = new Menu();
|
||||||
UIResourceBundle.bindStringProperty(languageMenu.textProperty(), LANGUAGE);
|
UIResourceBundle.bindStringProperty(languageMenu.textProperty(), LANGUAGE);
|
||||||
@ -177,7 +174,7 @@ public class JNotepadMenuBar extends MenuBar {
|
|||||||
* 初始化文件菜单
|
* 初始化文件菜单
|
||||||
*/
|
*/
|
||||||
private void initFileMenu() {
|
private void initFileMenu() {
|
||||||
logger.info("初始化文件菜单:{}", UIResourceBundle.getContent(FILE));
|
logger.info("初始化文件菜单!");
|
||||||
// 文件菜单
|
// 文件菜单
|
||||||
fileMenu = new Menu();
|
fileMenu = new Menu();
|
||||||
UIResourceBundle.bindStringProperty(fileMenu.textProperty(), FILE);
|
UIResourceBundle.bindStringProperty(fileMenu.textProperty(), FILE);
|
||||||
@ -206,7 +203,7 @@ public class JNotepadMenuBar extends MenuBar {
|
|||||||
* 初始化设置菜单
|
* 初始化设置菜单
|
||||||
*/
|
*/
|
||||||
private void initSettingMenu() {
|
private void initSettingMenu() {
|
||||||
logger.info("初始化设置菜单:{}", UIResourceBundle.getContent(SET));
|
logger.info("初始化设置菜单");
|
||||||
// 设置菜单
|
// 设置菜单
|
||||||
setMenu = new Menu();
|
setMenu = new Menu();
|
||||||
UIResourceBundle.bindStringProperty(setMenu.textProperty(), SET);
|
UIResourceBundle.bindStringProperty(setMenu.textProperty(), SET);
|
||||||
@ -232,7 +229,7 @@ public class JNotepadMenuBar extends MenuBar {
|
|||||||
* 初始化插件菜单
|
* 初始化插件菜单
|
||||||
*/
|
*/
|
||||||
private void initPluginMenu() {
|
private void initPluginMenu() {
|
||||||
logger.info("初始化插件菜单:{}", UIResourceBundle.getContent(PLUGIN));
|
logger.info("初始化插件菜单!");
|
||||||
// 插件菜单
|
// 插件菜单
|
||||||
pluginMenu = new Menu();
|
pluginMenu = new Menu();
|
||||||
UIResourceBundle.bindStringProperty(pluginMenu.textProperty(), PLUGIN);
|
UIResourceBundle.bindStringProperty(pluginMenu.textProperty(), PLUGIN);
|
||||||
@ -276,7 +273,6 @@ public class JNotepadMenuBar extends MenuBar {
|
|||||||
englishItem.setOnAction(new LocalizationHandler() {
|
englishItem.setOnAction(new LocalizationHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(ActionEvent actionEvent) {
|
public void handle(ActionEvent actionEvent) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setCurrentLanguage(ENGLISH);
|
setCurrentLanguage(ENGLISH);
|
||||||
toggleLanguage(actionEvent);
|
toggleLanguage(actionEvent);
|
||||||
@ -350,7 +346,7 @@ public class JNotepadMenuBar extends MenuBar {
|
|||||||
writer.write(JsonUtil.toJsonString(json));
|
writer.write(JsonUtil.toJsonString(json));
|
||||||
// 刷新文件
|
// 刷新文件
|
||||||
writer.flush();
|
writer.flush();
|
||||||
// 重新加载快捷键
|
// 重新加载快捷键与语言包
|
||||||
View.getInstance().initJnotepadConfigs(LunchApp.getLocalizationConfigs());
|
View.getInstance().initJnotepadConfigs(LunchApp.getLocalizationConfigs());
|
||||||
logger.info("已刷新语言包!");
|
logger.info("已刷新语言包!");
|
||||||
logger.info("已刷新快捷键!");
|
logger.info("已刷新快捷键!");
|
||||||
|
|||||||
@ -1,19 +1,15 @@
|
|||||||
package org.jcnc.jnotepad.ui.status;
|
package org.jcnc.jnotepad.ui.status;
|
||||||
|
|
||||||
import javafx.beans.value.ChangeListener;
|
|
||||||
import javafx.beans.value.ObservableValue;
|
|
||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.TextArea;
|
import javafx.scene.control.TextArea;
|
||||||
import javafx.scene.layout.HBox;
|
import javafx.scene.layout.HBox;
|
||||||
import org.jcnc.jnotepad.app.config.LocalizationConfig;
|
|
||||||
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.ui.tab.JNotepadTab;
|
import org.jcnc.jnotepad.ui.tab.JNotepadTab;
|
||||||
import org.jcnc.jnotepad.ui.tab.JNotepadTabPane;
|
import org.jcnc.jnotepad.ui.tab.JNotepadTabPane;
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.ResourceBundle;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 状态栏组件封装。
|
* 状态栏组件封装。
|
||||||
@ -36,7 +32,6 @@ public class JNotepadStatusBox extends HBox {
|
|||||||
* 显示文本编码
|
* 显示文本编码
|
||||||
*/
|
*/
|
||||||
private Label encodingLabel;
|
private Label encodingLabel;
|
||||||
private final String ENCODING_LABEL_FORMAT = "\t%s : %s";
|
|
||||||
|
|
||||||
|
|
||||||
private JNotepadStatusBox() {
|
private JNotepadStatusBox() {
|
||||||
@ -61,12 +56,7 @@ public class JNotepadStatusBox extends HBox {
|
|||||||
this.getChildren().add(encodingLabel);
|
this.getChildren().add(encodingLabel);
|
||||||
this.getProperties().put("borderpane-margin", new Insets(5, 10, 5, 10));
|
this.getProperties().put("borderpane-margin", new Insets(5, 10, 5, 10));
|
||||||
|
|
||||||
UIResourceBundle.getInstance().addListener(new ChangeListener<ResourceBundle>() {
|
UIResourceBundle.getInstance().addListener((observable, oldValue, newValue) -> updateWhenTabSelected());
|
||||||
@Override
|
|
||||||
public void changed(ObservableValue<? extends ResourceBundle> observable, ResourceBundle oldValue, ResourceBundle newValue) {
|
|
||||||
updateWhenTabSelected();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,6 +157,7 @@ public class JNotepadStatusBox extends HBox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected String getEncodingFormattedText(String encoding) {
|
protected String getEncodingFormattedText(String encoding) {
|
||||||
return String.format(ENCODING_LABEL_FORMAT, UIResourceBundle.getContent(TextConstants.ENCODE), encoding);
|
String encodingLabelFormat = "\t%s : %s";
|
||||||
|
return String.format(encodingLabelFormat, UIResourceBundle.getContent(TextConstants.ENCODE), encoding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,9 +17,6 @@ public class ViewManager {
|
|||||||
|
|
||||||
private int tabIndex = 0;
|
private int tabIndex = 0;
|
||||||
|
|
||||||
private Boolean line = true;
|
|
||||||
|
|
||||||
|
|
||||||
// 主界面布局
|
// 主界面布局
|
||||||
/**
|
/**
|
||||||
* 主布局
|
* 主布局
|
||||||
@ -39,15 +36,6 @@ public class ViewManager {
|
|||||||
return ++tabIndex;
|
return ++tabIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getLine() {
|
|
||||||
return line;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public BorderPane getRoot() {
|
|
||||||
return root;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取ViewManager的实例。如果实例不存在,则创建一个新实例。
|
* 获取ViewManager的实例。如果实例不存在,则创建一个新实例。
|
||||||
|
|||||||
@ -9,9 +9,9 @@
|
|||||||
<!-- 文件保留时间 -->
|
<!-- 文件保留时间 -->
|
||||||
<property name="log.maxHistory" value="30"/>
|
<property name="log.maxHistory" value="30"/>
|
||||||
<!-- 日志存储路径 -->
|
<!-- 日志存储路径 -->
|
||||||
<property name="log.filePath" value="${user.home}/.jnotepad/logs"/>
|
<property name="log.filePath" value="logs"/>
|
||||||
<!--打包时,请使用下方的路径-->
|
<!--发布0时,请使用下方的路径-->
|
||||||
<!--<property name="log.filePath" value="../logs"/>-->
|
<!--<property name="log.filePath" value="${user.home}/.jnotepad/logs"/>-->
|
||||||
<!-- 日志的显式格式 -->
|
<!-- 日志的显式格式 -->
|
||||||
<property name="log.pattern"
|
<property name="log.pattern"
|
||||||
value="时间:[%d{yyyy-MM-dd HH:mm:ss.SSS}] 线程:[%thread] 日志级别:[%-5level] 调用位置:[%logger{50} 参见:[\(%F:%L\)]] - 日志信息:[%msg]%n">
|
value="时间:[%d{yyyy-MM-dd HH:mm:ss.SSS}] 线程:[%thread] 日志级别:[%-5level] 调用位置:[%logger{50} 参见:[\(%F:%L\)]] - 日志信息:[%msg]%n">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user