⚰️ 删除无用代码 🐛 修复 BUG 当无打开文件时打开文件程序抛空指针异常问题
This commit is contained in:
parent
5ad48be1cd
commit
7ab6793179
@ -1,5 +1,6 @@
|
|||||||
package org.jcnc.jnotepad;
|
package org.jcnc.jnotepad;
|
||||||
|
|
||||||
|
|
||||||
import atlantafx.base.theme.PrimerLight;
|
import atlantafx.base.theme.PrimerLight;
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
@ -55,7 +56,6 @@ public class LunchApp extends Application {
|
|||||||
double width = AppConstants.SCREEN_WIDTH;
|
double width = AppConstants.SCREEN_WIDTH;
|
||||||
double length = AppConstants.SCREEN_LENGTH;
|
double length = AppConstants.SCREEN_LENGTH;
|
||||||
String icon = AppConstants.APP_ICON;
|
String icon = AppConstants.APP_ICON;
|
||||||
|
|
||||||
scene = new Scene(root, width, length);
|
scene = new Scene(root, width, length);
|
||||||
Application.setUserAgentStylesheet(new PrimerLight().getUserAgentStylesheet());
|
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());
|
||||||
|
|||||||
@ -1,53 +0,0 @@
|
|||||||
package org.jcnc.jnotepad.app.config;
|
|
||||||
|
|
||||||
|
|
||||||
import org.jcnc.jnotepad.app.entity.ShortcutKey;
|
|
||||||
import org.jcnc.jnotepad.app.entity.Style;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 应用程序配置类
|
|
||||||
*
|
|
||||||
* @author gewuyou 一个大转盘
|
|
||||||
* @see [相关类/方法]
|
|
||||||
*/
|
|
||||||
public class JnotepadConfig {
|
|
||||||
/**
|
|
||||||
* 快捷键列表
|
|
||||||
*/
|
|
||||||
private List<ShortcutKey> shortcutKeyList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 样式列表 TODO
|
|
||||||
*/
|
|
||||||
private List<Style> styleList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 单例模式
|
|
||||||
*/
|
|
||||||
private JnotepadConfig() {
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final JnotepadConfig INSTANCE = new JnotepadConfig();
|
|
||||||
|
|
||||||
public static JnotepadConfig getInstance() {
|
|
||||||
return INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ShortcutKey> getShortcutKeyList() {
|
|
||||||
return shortcutKeyList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setShortcutKeyList(List<ShortcutKey> shortcutKeyList) {
|
|
||||||
this.shortcutKeyList = shortcutKeyList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Style> getStyleList() {
|
|
||||||
return styleList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStyleList(List<Style> styleList) {
|
|
||||||
this.styleList = styleList;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,5 +1,6 @@
|
|||||||
package org.jcnc.jnotepad.app.config;
|
package org.jcnc.jnotepad.app.config;
|
||||||
|
|
||||||
|
import org.jcnc.jnotepad.LunchApp;
|
||||||
import org.jcnc.jnotepad.tool.LogUtil;
|
import org.jcnc.jnotepad.tool.LogUtil;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
@ -11,8 +12,9 @@ import static org.jcnc.jnotepad.constants.AppConstants.APP_NAME;
|
|||||||
import static org.jcnc.jnotepad.constants.TextConstants.*;
|
import static org.jcnc.jnotepad.constants.TextConstants.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 本地化配置文件
|
* 本地化配置文件<br>
|
||||||
*
|
* 注意:该配置文件必须先于快捷键配置文件加载
|
||||||
|
* @see LunchApp
|
||||||
* @author gewuyou
|
* @author gewuyou
|
||||||
*/
|
*/
|
||||||
public class LocalizationConfig {
|
public class LocalizationConfig {
|
||||||
|
|||||||
@ -1,35 +0,0 @@
|
|||||||
package org.jcnc.jnotepad.app.entity;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 快捷键
|
|
||||||
*
|
|
||||||
* @author gewuyou
|
|
||||||
*/
|
|
||||||
public class ShortcutKey {
|
|
||||||
private String buttonName;
|
|
||||||
private String shortcutKeyValue;
|
|
||||||
|
|
||||||
public ShortcutKey() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public ShortcutKey(String buttonName, String shortcutKeyValue) {
|
|
||||||
this.buttonName = buttonName;
|
|
||||||
this.shortcutKeyValue = shortcutKeyValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getButtonName() {
|
|
||||||
return buttonName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setButtonName(String buttonName) {
|
|
||||||
this.buttonName = buttonName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getShortcutKeyValue() {
|
|
||||||
return shortcutKeyValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setShortcutKeyValue(String shortcutKeyValue) {
|
|
||||||
this.shortcutKeyValue = shortcutKeyValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,35 +0,0 @@
|
|||||||
package org.jcnc.jnotepad.app.entity;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 样式
|
|
||||||
*
|
|
||||||
* @author gewuyou
|
|
||||||
*/
|
|
||||||
public class Style {
|
|
||||||
private String styleName;
|
|
||||||
private String styleValue;
|
|
||||||
|
|
||||||
public Style() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public Style(String styleName, String styleValue) {
|
|
||||||
this.styleName = styleName;
|
|
||||||
this.styleValue = styleValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getStyleName() {
|
|
||||||
return styleName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStyleName(String styleName) {
|
|
||||||
this.styleName = styleName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getStyleValue() {
|
|
||||||
return styleValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStyleValue(String styleValue) {
|
|
||||||
this.styleValue = styleValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -74,7 +74,7 @@ public abstract class LoadJnotepadConfig<T> {
|
|||||||
* 解析配置文件
|
* 解析配置文件
|
||||||
*
|
*
|
||||||
* @param inputStream 输入流
|
* @param inputStream 输入流
|
||||||
* @return java.util.List<java.util.LinkedHashMap < java.lang.String, java.lang.String>>
|
* @return T
|
||||||
* @since 2023/8/25 15:18
|
* @since 2023/8/25 15:18
|
||||||
*/
|
*/
|
||||||
protected abstract T parseConfig(InputStream inputStream);
|
protected abstract T parseConfig(InputStream inputStream);
|
||||||
|
|||||||
@ -1,16 +1,10 @@
|
|||||||
package org.jcnc.jnotepad.constants;
|
package org.jcnc.jnotepad.constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 路径常量
|
* 路径常量<br>
|
||||||
*
|
|
||||||
* @author gewuyou
|
* @author gewuyou
|
||||||
*/
|
*/
|
||||||
public class PathConstants {
|
public class PathConstants {
|
||||||
private PathConstants() {
|
private PathConstants() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 配置文件路径
|
|
||||||
*/
|
|
||||||
public static final String CONFIGURATION_FILE_PATH = "../config/";
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,14 +52,10 @@ public class LineNumberTextArea extends BorderPane {
|
|||||||
|
|
||||||
private void initListeners() {
|
private void initListeners() {
|
||||||
// 当主要文本区域的垂直滚动位置发生变化时,使行号文本区域的滚动位置保持一致
|
// 当主要文本区域的垂直滚动位置发生变化时,使行号文本区域的滚动位置保持一致
|
||||||
mainTextArea.scrollTopProperty().addListener((observable, oldValue, newValue) -> {
|
mainTextArea.scrollTopProperty().addListener((observable, oldValue, newValue) -> lineNumberArea.setScrollTop(mainTextArea.getScrollTop()));
|
||||||
lineNumberArea.setScrollTop(mainTextArea.getScrollTop());
|
|
||||||
});
|
|
||||||
|
|
||||||
// 当行号文本区域的垂直滚动位置发生变化时,使主要文本区域的滚动位置保持一致
|
// 当行号文本区域的垂直滚动位置发生变化时,使主要文本区域的滚动位置保持一致
|
||||||
lineNumberArea.scrollTopProperty().addListener((observable, oldValue, newValue) -> {
|
lineNumberArea.scrollTopProperty().addListener((observable, oldValue, newValue) -> mainTextArea.setScrollTop(lineNumberArea.getScrollTop()));
|
||||||
mainTextArea.setScrollTop(lineNumberArea.getScrollTop());
|
|
||||||
});
|
|
||||||
|
|
||||||
lineNumberArea.textProperty().addListener((observable, oldValue, newValue) -> updateLineNumberWidth());
|
lineNumberArea.textProperty().addListener((observable, oldValue, newValue) -> updateLineNumberWidth());
|
||||||
|
|
||||||
@ -79,6 +75,7 @@ public class LineNumberTextArea extends BorderPane {
|
|||||||
*/
|
*/
|
||||||
public void save() {
|
public void save() {
|
||||||
JNotepadTab tab = JNotepadTabPane.getInstance().getSelected();
|
JNotepadTab tab = JNotepadTabPane.getInstance().getSelected();
|
||||||
|
if (tab != null) {
|
||||||
File file = (File) tab.getUserData();
|
File file = (File) tab.getUserData();
|
||||||
String newValue = this.mainTextArea.getText();
|
String newValue = this.mainTextArea.getText();
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
@ -90,6 +87,7 @@ public class LineNumberTextArea extends BorderPane {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isRelevance() {
|
public boolean isRelevance() {
|
||||||
return isRelevance;
|
return isRelevance;
|
||||||
@ -137,7 +135,7 @@ public class LineNumberTextArea extends BorderPane {
|
|||||||
|
|
||||||
// 恢复之前的滚动位置
|
// 恢复之前的滚动位置
|
||||||
mainTextArea.setScrollTop(mainTextAreaScrollTop);
|
mainTextArea.setScrollTop(mainTextAreaScrollTop);
|
||||||
lineNumberArea.setScrollTop(lineNumberAreaScrollTop-8);
|
lineNumberArea.setScrollTop(lineNumberAreaScrollTop - 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextArea getMainTextArea() {
|
public TextArea getMainTextArea() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user