2023年6月1日16:35:26 添加文本编辑器
6
pom.xml
|
|
@ -406,7 +406,11 @@
|
||||||
<artifactId>bcprov-jdk16</artifactId>
|
<artifactId>bcprov-jdk16</artifactId>
|
||||||
<version>1.46</version>
|
<version>1.46</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.fxmisc.richtext</groupId>
|
||||||
|
<artifactId>richtextfx</artifactId>
|
||||||
|
<version>0.10.0</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,159 @@
|
||||||
|
package com.zhangmeng.tools.components;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : 芊芊墨客
|
||||||
|
* @version : 1.0
|
||||||
|
* @date : 2023-05-08 11:41
|
||||||
|
*/
|
||||||
|
|
||||||
|
import com.zaxxer.hikari.util.FastList;
|
||||||
|
import javafx.application.Platform;
|
||||||
|
import javafx.beans.property.SimpleIntegerProperty;
|
||||||
|
import javafx.beans.property.SimpleObjectProperty;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.control.TreeCell;
|
||||||
|
import javafx.scene.control.TreeItem;
|
||||||
|
import javafx.scene.control.TreeView;
|
||||||
|
import javafx.scene.image.Image;
|
||||||
|
import javafx.scene.image.ImageView;
|
||||||
|
import javafx.scene.layout.HBox;
|
||||||
|
import javafx.scene.text.Font;
|
||||||
|
import javafx.scene.text.Text;
|
||||||
|
import javafx.util.Callback;
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class RecursiveFileList extends TreeView<File> {
|
||||||
|
|
||||||
|
private final SimpleObjectProperty<File> index_file = new SimpleObjectProperty<>(null);
|
||||||
|
|
||||||
|
private final SimpleIntegerProperty text_size = new SimpleIntegerProperty(15);
|
||||||
|
private final SimpleIntegerProperty icon_size = new SimpleIntegerProperty(15);
|
||||||
|
|
||||||
|
public RecursiveFileList(File root) {
|
||||||
|
super(new TreeItem<>(root));
|
||||||
|
if (root != null){
|
||||||
|
new Thread(()->{
|
||||||
|
Platform.runLater(()->{
|
||||||
|
setRoot(getTreeItem(root));
|
||||||
|
});
|
||||||
|
}).start();
|
||||||
|
}else {
|
||||||
|
setRoot(null);
|
||||||
|
}
|
||||||
|
setShowRoot(true);
|
||||||
|
this.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
|
if (newValue.getValue().isFile()) {
|
||||||
|
index_file.setValue(newValue.getValue());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.setCellFactory(new Callback<TreeView<File>, TreeCell<File>>() {
|
||||||
|
@Override
|
||||||
|
public TreeCell<File> call(TreeView<File> param) {
|
||||||
|
return new TreeCell<File>(){
|
||||||
|
@Override
|
||||||
|
protected void updateItem(File item, boolean empty) {
|
||||||
|
super.updateItem(item, empty);
|
||||||
|
if (!empty){
|
||||||
|
HBox hBox = new HBox(10);
|
||||||
|
ImageView iv = null;
|
||||||
|
if (this.getTreeItem().isExpanded()){
|
||||||
|
iv = new ImageView(new Image("image/向下.png"));
|
||||||
|
}else {
|
||||||
|
iv = new ImageView(new Image("image/向右.png"));
|
||||||
|
}
|
||||||
|
iv.setPreserveRatio(true);
|
||||||
|
iv.setFitWidth(icon_size.get());
|
||||||
|
this.setDisclosureNode(iv);
|
||||||
|
|
||||||
|
Label label = new Label(item.getName());
|
||||||
|
label.setFont(new Font(text_size.get()));
|
||||||
|
|
||||||
|
//判断是否是文件
|
||||||
|
boolean directory = item.isDirectory();
|
||||||
|
if (directory){
|
||||||
|
ImageView dir = new ImageView(new Image("image/dir.png"));
|
||||||
|
dir.setPreserveRatio(true);
|
||||||
|
dir.setFitWidth(icon_size.get());
|
||||||
|
hBox.getChildren().add(dir);
|
||||||
|
}else {
|
||||||
|
if (item.isFile()){
|
||||||
|
ImageView file = null;
|
||||||
|
|
||||||
|
String extension = FilenameUtils.getExtension(item.getName());
|
||||||
|
if (extension.equals("java")){
|
||||||
|
file = new ImageView(new Image("image/java.png"));
|
||||||
|
}
|
||||||
|
if (extension.equals("html")){
|
||||||
|
file = new ImageView(new Image("image/html.png"));
|
||||||
|
}
|
||||||
|
if (extension.equals("jar")){
|
||||||
|
file = new ImageView(new Image("image/jar.png"));
|
||||||
|
}
|
||||||
|
if (extension.equals("json")){
|
||||||
|
file = new ImageView(new Image("image/json.png"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (extension.equals("jpg")){
|
||||||
|
file = new ImageView(new Image("image/jpg.png"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (extension.equals("png")){
|
||||||
|
file = new ImageView(new Image("image/png.png"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file != null){
|
||||||
|
file.setPreserveRatio(true);
|
||||||
|
file.setFitWidth(icon_size.get());
|
||||||
|
hBox.getChildren().add(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hBox.getChildren().add(label);
|
||||||
|
this.setGraphic(hBox);
|
||||||
|
}else {
|
||||||
|
this.setGraphic(null);
|
||||||
|
this.setDisclosureNode(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private TreeItem<File> getTreeItem(File file) {
|
||||||
|
TreeItem<File> item = new TreeItem<>();
|
||||||
|
item.setGraphic(new Text(file.getName()));
|
||||||
|
item.setValue(file);
|
||||||
|
if (file.isDirectory()) {
|
||||||
|
if (file.listFiles()!= null){
|
||||||
|
List<File> fileList = new ArrayList<>();
|
||||||
|
File[] dirs = file.listFiles(File::isDirectory);
|
||||||
|
if (dirs != null){
|
||||||
|
Arrays.sort(dirs, Comparator.comparing(File::getName));
|
||||||
|
fileList.addAll(List.of(dirs));
|
||||||
|
}
|
||||||
|
File[] files = file.listFiles(File::isFile);
|
||||||
|
if (files != null){
|
||||||
|
Arrays.sort(files, Comparator.comparing(File::getName));
|
||||||
|
fileList.addAll(List.of(files));
|
||||||
|
}
|
||||||
|
for (File child : fileList) {
|
||||||
|
item.getChildren().add(getTreeItem(child));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getValue() {
|
||||||
|
if (index_file.getValue() == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return index_file.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,179 @@
|
||||||
|
package com.zhangmeng.tools.controller;
|
||||||
|
|
||||||
|
import com.zhangmeng.tools.components.RecursiveFileList;
|
||||||
|
import com.zhangmeng.tools.languages.ProcessJava;
|
||||||
|
import com.zhangmeng.tools.utils.AlertUtils;
|
||||||
|
import javafx.event.ActionEvent;
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.control.SplitPane;
|
||||||
|
import javafx.scene.image.Image;
|
||||||
|
import javafx.stage.DirectoryChooser;
|
||||||
|
import javafx.stage.FileChooser;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
import org.fxmisc.flowless.VirtualizedScrollPane;
|
||||||
|
import org.fxmisc.richtext.CodeArea;
|
||||||
|
import org.fxmisc.richtext.LineNumberFactory;
|
||||||
|
import org.fxmisc.richtext.model.StyleSpans;
|
||||||
|
import org.fxmisc.richtext.model.StyleSpansBuilder;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : 芊芊墨客
|
||||||
|
* @version : 1.0
|
||||||
|
* @date : 2023-06-01 10:44
|
||||||
|
*
|
||||||
|
* 文本编辑器
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class FileEditController {
|
||||||
|
|
||||||
|
|
||||||
|
public SplitPane splitPane;
|
||||||
|
|
||||||
|
private CodeArea codeArea;
|
||||||
|
private RecursiveFileList recursiveFileList = null;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public void initialize() {
|
||||||
|
recursiveFileList = new RecursiveFileList(null);
|
||||||
|
codeArea = new CodeArea();
|
||||||
|
URL resource = this.getClass().getClassLoader().getResource("css/code.css");
|
||||||
|
codeArea.setParagraphGraphicFactory(LineNumberFactory.get(codeArea));
|
||||||
|
codeArea.textProperty().addListener((obs, oldText, newText) -> {
|
||||||
|
codeArea.setStyleSpans(0, computeHighlighting(newText));
|
||||||
|
});
|
||||||
|
codeArea.getStylesheets().add(resource.toExternalForm());
|
||||||
|
splitPane.getItems().add(0,recursiveFileList);
|
||||||
|
splitPane.getItems().add(1,new VirtualizedScrollPane<>(codeArea));
|
||||||
|
splitPane.setDividerPosition(0,0.20);
|
||||||
|
splitPane.setDividerPosition(1,0.80);
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public void open_file_dir(ActionEvent event) {
|
||||||
|
open_file_dir();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void open_file(File file){
|
||||||
|
byte[] bytes = new byte[0];
|
||||||
|
try {
|
||||||
|
bytes = Files.readAllBytes(file.toPath());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
String file_content = new String(bytes, StandardCharsets.UTF_8);
|
||||||
|
codeArea.clear();
|
||||||
|
codeArea.replaceText(0, 0, file_content);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void open_file_dir(){
|
||||||
|
|
||||||
|
Stage stage = new Stage();
|
||||||
|
DirectoryChooser dc = new DirectoryChooser();
|
||||||
|
dc.setTitle("文件夹选择");
|
||||||
|
File file = dc.showDialog(stage);
|
||||||
|
if (file != null) {
|
||||||
|
if (file.isDirectory()){
|
||||||
|
splitPane.getItems().clear();
|
||||||
|
recursiveFileList = new RecursiveFileList(file) ;
|
||||||
|
recursiveFileList.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
|
if (newValue.getValue().isFile()) {
|
||||||
|
String extension = FilenameUtils.getExtension(newValue.getValue().getName());
|
||||||
|
boolean flag = true;
|
||||||
|
|
||||||
|
if (extension.equals("mp4")){
|
||||||
|
flag = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (extension.equals("jpg")){
|
||||||
|
flag = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (extension.equals("png")){
|
||||||
|
flag = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (extension.equals("avi")){
|
||||||
|
flag = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (extension.equals("zip")){
|
||||||
|
flag = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (extension.equals("ico")){
|
||||||
|
flag = false;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// if (extension.equals("json")){
|
||||||
|
// flag = true;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (extension.equals("go")){
|
||||||
|
// flag = true;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (extension.equals("js")){
|
||||||
|
// flag = true;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (extension.equals("css")){
|
||||||
|
// flag = true;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (extension.equals(".xml")){
|
||||||
|
// flag = true;
|
||||||
|
// }
|
||||||
|
if (flag){
|
||||||
|
open_file(newValue.getValue());
|
||||||
|
}else {
|
||||||
|
AlertUtils.alert_warning("该文件不支持!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
splitPane.getItems().add(0,recursiveFileList);
|
||||||
|
splitPane.getItems().add(1,new VirtualizedScrollPane<>(codeArea));
|
||||||
|
splitPane.setDividerPosition(0,0.20);
|
||||||
|
splitPane.setDividerPosition(1,0.80);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static StyleSpans<Collection<String>> computeHighlighting(String text) {
|
||||||
|
Matcher matcher = ProcessJava.PATTERN.matcher(text);
|
||||||
|
int lastKwEnd = 0;
|
||||||
|
StyleSpansBuilder<Collection<String>> spansBuilder = new StyleSpansBuilder<>();
|
||||||
|
while(matcher.find()) {
|
||||||
|
String styleClass =
|
||||||
|
matcher.group("KEYWORD") != null ? "keyword" :
|
||||||
|
matcher.group("PAREN") != null ? "paren" :
|
||||||
|
matcher.group("BRACE") != null ? "brace" :
|
||||||
|
matcher.group("BRACKET") != null ? "bracket" :
|
||||||
|
matcher.group("SEMICOLON") != null ? "semicolon" :
|
||||||
|
matcher.group("STRING") != null ? "string" :
|
||||||
|
matcher.group("COMMENT") != null ? "comment" :
|
||||||
|
matcher.group("ANNOTATION") != null ? "annotation" :
|
||||||
|
matcher.group("PARAMS") != null ? "parameter" :
|
||||||
|
null; /* never happens */
|
||||||
|
assert styleClass != null;
|
||||||
|
spansBuilder.add(Collections.emptyList(), matcher.start() - lastKwEnd);
|
||||||
|
spansBuilder.add(Collections.singleton(styleClass), matcher.end() - matcher.start());
|
||||||
|
lastKwEnd = matcher.end();
|
||||||
|
}
|
||||||
|
spansBuilder.add(Collections.emptyList(), text.length() - lastKwEnd);
|
||||||
|
return spansBuilder.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -595,4 +595,7 @@ public class HomeController implements Serializable {
|
||||||
listView.getSelectionModel().select(index);
|
listView.getSelectionModel().select(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void file_edit_menu_item(ActionEvent event) {
|
||||||
|
load_small_tools(16);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -83,6 +83,7 @@ public class SmallToolsController {
|
||||||
private AnchorPane pdf_ocr;
|
private AnchorPane pdf_ocr;
|
||||||
private AnchorPane batch_update_file_name;
|
private AnchorPane batch_update_file_name;
|
||||||
private AnchorPane capter_screen;
|
private AnchorPane capter_screen;
|
||||||
|
private AnchorPane file_edit;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private ListView<ResourcesUtils.SmallTools> listView;
|
private ListView<ResourcesUtils.SmallTools> listView;
|
||||||
|
|
@ -409,11 +410,33 @@ public class SmallToolsController {
|
||||||
}
|
}
|
||||||
capter_screen(flag);
|
capter_screen(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (newValue.getIndex() == 16) {
|
||||||
|
if (file_edit != null) {
|
||||||
|
flag = true;
|
||||||
|
}
|
||||||
|
file_edit(flag);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void file_edit(boolean flag) {
|
||||||
|
|
||||||
|
//默认选择第一个
|
||||||
|
listView.getSelectionModel().select(0);
|
||||||
|
if (!flag) {
|
||||||
|
try {
|
||||||
|
root = FXMLLoader.load(ResourcesUtils.getResource("file-edit"));
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
file_edit = root;
|
||||||
|
} else {
|
||||||
|
root = file_edit;
|
||||||
|
}
|
||||||
|
common_method();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Image getImage(ResourcesUtils.SmallTools SmallTools) {
|
public static Image getImage(ResourcesUtils.SmallTools SmallTools) {
|
||||||
|
|
@ -434,6 +457,7 @@ public class SmallToolsController {
|
||||||
case Pdf_Ocr -> new Image(ImagePath.path(ImagePath.ImagePathType.Qr_CODE));
|
case Pdf_Ocr -> new Image(ImagePath.path(ImagePath.ImagePathType.Qr_CODE));
|
||||||
case BatchUpdateFileName -> new Image(ImagePath.path(ImagePath.ImagePathType.Qr_CODE));
|
case BatchUpdateFileName -> new Image(ImagePath.path(ImagePath.ImagePathType.Qr_CODE));
|
||||||
case Capter_Screent -> new Image(ImagePath.path(ImagePath.ImagePathType.Qr_CODE));
|
case Capter_Screent -> new Image(ImagePath.path(ImagePath.ImagePathType.Qr_CODE));
|
||||||
|
case File_Edit -> new Image(ImagePath.path(ImagePath.ImagePathType.Qr_CODE));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -496,7 +520,6 @@ public class SmallToolsController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void hex_16(boolean flag) {
|
private void hex_16(boolean flag) {
|
||||||
//默认选择第一个
|
//默认选择第一个
|
||||||
listView.getSelectionModel().select(0);
|
listView.getSelectionModel().select(0);
|
||||||
|
|
@ -883,10 +906,12 @@ public class SmallToolsController {
|
||||||
ListView<ResourcesUtils.Player> listView = (ListView) fx.lookup("#listView");
|
ListView<ResourcesUtils.Player> listView = (ListView) fx.lookup("#listView");
|
||||||
listView.getSelectionModel().select(index);
|
listView.getSelectionModel().select(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void socket_server_menu_item(ActionEvent event) {
|
public void socket_server_menu_item(ActionEvent event) {
|
||||||
load_server_tools(3);
|
load_server_tools(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void telephone_menu_item(ActionEvent event) {
|
public void telephone_menu_item(ActionEvent event) {
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
|
|
@ -895,11 +920,13 @@ public class SmallToolsController {
|
||||||
}
|
}
|
||||||
telephone(flag);
|
telephone(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void mybatis_plus_gen_menu_item(ActionEvent event) {
|
public void mybatis_plus_gen_menu_item(ActionEvent event) {
|
||||||
|
|
||||||
load_mysql_tools(1);
|
load_mysql_tools(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void JsonView_menu_item(ActionEvent event) {
|
public void JsonView_menu_item(ActionEvent event) {
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
|
|
@ -908,6 +935,7 @@ public class SmallToolsController {
|
||||||
}
|
}
|
||||||
json_view(flag);
|
json_view(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void maven_jar_install_menu_item(ActionEvent event) {
|
public void maven_jar_install_menu_item(ActionEvent event) {
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
|
|
@ -925,6 +953,7 @@ public class SmallToolsController {
|
||||||
}
|
}
|
||||||
word_ocr(flag);
|
word_ocr(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void bar_code_menu_item(ActionEvent event) {
|
public void bar_code_menu_item(ActionEvent event) {
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,127 @@
|
||||||
|
package com.zhangmeng.tools.languages;
|
||||||
|
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : 芊芊墨客
|
||||||
|
* @version : 1.0
|
||||||
|
* @date : 2023-06-01 11:01
|
||||||
|
*/
|
||||||
|
public class ProcessJava {
|
||||||
|
|
||||||
|
public static final String[] KEYWORDS = new String[] {
|
||||||
|
"abstract", "assert", "boolean", "break", "byte",
|
||||||
|
"case", "catch", "char", "class", "const",
|
||||||
|
"continue", "default", "do", "double", "else",
|
||||||
|
"enum", "extends", "final", "finally", "float",
|
||||||
|
"for", "if", "goto", "implements", "import",
|
||||||
|
"instanceof", "int", "interface", "long", "native",
|
||||||
|
"new", "package", "private", "protected", "public",
|
||||||
|
"return", "short", "static", "strictfp", "super",
|
||||||
|
"switch", "synchronized", "this", "throw", "throws",
|
||||||
|
"transient", "try", "void", "volatile", "while"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static final String KEYWORD_PATTERN = "\\b(" + String.join("|", KEYWORDS) + ")\\b";
|
||||||
|
public static final String PAREN_PATTERN = "\\(|\\)";
|
||||||
|
public static final String BRACE_PATTERN = "\\{|\\}";
|
||||||
|
public static final String BRACKET_PATTERN = "\\[|\\]";
|
||||||
|
public static final String SEMICOLON_PATTERN = "\\;";
|
||||||
|
public static final String STRING_PATTERN = "\"([^\"\\\\]|\\\\.)*\"";
|
||||||
|
public static final String COMMENT_PATTERN = "//[^\n]*" + "|" + "/\\*(.|\\R)*?\\*/";
|
||||||
|
public static final String ANNOTATION_PATTERN = "@[a-zA-Z]+";
|
||||||
|
public static final String PARAMS_PATTERN = "\\\\b([a-zA-Z]+)\\\\s*=\\\\s*([a-zA-Z0-9]+)\\\\b";
|
||||||
|
|
||||||
|
public static final Pattern PATTERN = Pattern.compile(
|
||||||
|
"(?<KEYWORD>" + KEYWORD_PATTERN + ")"
|
||||||
|
+ "|(?<PAREN>" + PAREN_PATTERN + ")"
|
||||||
|
+ "|(?<BRACE>" + BRACE_PATTERN + ")"
|
||||||
|
+ "|(?<BRACKET>" + BRACKET_PATTERN + ")"
|
||||||
|
+ "|(?<SEMICOLON>" + SEMICOLON_PATTERN + ")"
|
||||||
|
+ "|(?<STRING>" + STRING_PATTERN + ")"
|
||||||
|
+ "|(?<COMMENT>" + COMMENT_PATTERN + ")"
|
||||||
|
+ "|(?<ANNOTATION>" + ANNOTATION_PATTERN + ")"
|
||||||
|
+ "|(?<PARAMS>" + PARAMS_PATTERN + ")"
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
public static String SAMPLE_CODE = "package com.dashidao.server.model;\n" +
|
||||||
|
"\n" +
|
||||||
|
"import java.util.Date;\n" +
|
||||||
|
"\n" +
|
||||||
|
"public class PosterGroupCouponCode extends BaseEntity<Long> {\n" +
|
||||||
|
"\n" +
|
||||||
|
"\tprivate Date addTime;\n" +
|
||||||
|
"\tprivate Boolean deleteStatus;\n" +
|
||||||
|
"\tprivate String groupCouponCode;\n" +
|
||||||
|
"\tprivate Integer groupCouponStatus;\n" +
|
||||||
|
"\tprivate Date writeOffTime;\n" +
|
||||||
|
"\tprivate Long orderFormId;\n" +
|
||||||
|
"\tprivate Long posterGoodsCartId;\n" +
|
||||||
|
"\tprivate Long tuiKuanShouHouId;\n" +
|
||||||
|
"\tprivate Long orderMealUserId;\n" +
|
||||||
|
"\tprivate String groupSkusJson;\n" +
|
||||||
|
"\n" +
|
||||||
|
"\tpublic Date getAddTime() {\n" +
|
||||||
|
"\t\treturn addTime;\n" +
|
||||||
|
"\t}\n" +
|
||||||
|
"\tpublic void setAddTime(Date addTime) {\n" +
|
||||||
|
"\t\tthis.addTime = addTime;\n" +
|
||||||
|
"\t}\n" +
|
||||||
|
"\tpublic Boolean getDeleteStatus() {\n" +
|
||||||
|
"\t\treturn deleteStatus;\n" +
|
||||||
|
"\t}\n" +
|
||||||
|
"\tpublic void setDeleteStatus(Boolean deleteStatus) {\n" +
|
||||||
|
"\t\tthis.deleteStatus = deleteStatus;\n" +
|
||||||
|
"\t}\n" +
|
||||||
|
"\tpublic String getGroupCouponCode() {\n" +
|
||||||
|
"\t\treturn groupCouponCode;\n" +
|
||||||
|
"\t}\n" +
|
||||||
|
"\tpublic void setGroupCouponCode(String groupCouponCode) {\n" +
|
||||||
|
"\t\tthis.groupCouponCode = groupCouponCode;\n" +
|
||||||
|
"\t}\n" +
|
||||||
|
"\tpublic Integer getGroupCouponStatus() {\n" +
|
||||||
|
"\t\treturn groupCouponStatus;\n" +
|
||||||
|
"\t}\n" +
|
||||||
|
"\tpublic void setGroupCouponStatus(Integer groupCouponStatus) {\n" +
|
||||||
|
"\t\tthis.groupCouponStatus = groupCouponStatus;\n" +
|
||||||
|
"\t}\n" +
|
||||||
|
"\tpublic Date getWriteOffTime() {\n" +
|
||||||
|
"\t\treturn writeOffTime;\n" +
|
||||||
|
"\t}\n" +
|
||||||
|
"\tpublic void setWriteOffTime(Date writeOffTime) {\n" +
|
||||||
|
"\t\tthis.writeOffTime = writeOffTime;\n" +
|
||||||
|
"\t}\n" +
|
||||||
|
"\tpublic Long getOrderFormId() {\n" +
|
||||||
|
"\t\treturn orderFormId;\n" +
|
||||||
|
"\t}\n" +
|
||||||
|
"\tpublic void setOrderFormId(Long orderFormId) {\n" +
|
||||||
|
"\t\tthis.orderFormId = orderFormId;\n" +
|
||||||
|
"\t}\n" +
|
||||||
|
"\tpublic Long getPosterGoodsCartId() {\n" +
|
||||||
|
"\t\treturn posterGoodsCartId;\n" +
|
||||||
|
"\t}\n" +
|
||||||
|
"\tpublic void setPosterGoodsCartId(Long posterGoodsCartId) {\n" +
|
||||||
|
"\t\tthis.posterGoodsCartId = posterGoodsCartId;\n" +
|
||||||
|
"\t}\n" +
|
||||||
|
"\tpublic Long getTuiKuanShouHouId() {\n" +
|
||||||
|
"\t\treturn tuiKuanShouHouId;\n" +
|
||||||
|
"\t}\n" +
|
||||||
|
"\tpublic void setTuiKuanShouHouId(Long tuiKuanShouHouId) {\n" +
|
||||||
|
"\t\tthis.tuiKuanShouHouId = tuiKuanShouHouId;\n" +
|
||||||
|
"\t}\n" +
|
||||||
|
"\tpublic Long getOrderMealUserId() {\n" +
|
||||||
|
"\t\treturn orderMealUserId;\n" +
|
||||||
|
"\t}\n" +
|
||||||
|
"\tpublic void setOrderMealUserId(Long orderMealUserId) {\n" +
|
||||||
|
"\t\tthis.orderMealUserId = orderMealUserId;\n" +
|
||||||
|
"\t}\n" +
|
||||||
|
"\tpublic String getGroupSkusJson() {\n" +
|
||||||
|
"\t\treturn groupSkusJson;\n" +
|
||||||
|
"\t}\n" +
|
||||||
|
"\tpublic void setGroupSkusJson(String groupSkusJson) {\n" +
|
||||||
|
"\t\tthis.groupSkusJson = groupSkusJson;\n" +
|
||||||
|
"\t}\n" +
|
||||||
|
"\n" +
|
||||||
|
"}\n";
|
||||||
|
}
|
||||||
|
|
@ -132,6 +132,7 @@ public class ResourcesUtils {
|
||||||
Pdf_Ocr("pdf识别", 13),
|
Pdf_Ocr("pdf识别", 13),
|
||||||
BatchUpdateFileName("批量修改文件名", 14),
|
BatchUpdateFileName("批量修改文件名", 14),
|
||||||
Capter_Screent("截图", 15),
|
Capter_Screent("截图", 15),
|
||||||
|
File_Edit("文件编辑器", 16),
|
||||||
;
|
;
|
||||||
|
|
||||||
SmallTools(String title, int index) {
|
SmallTools(String title, int index) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,187 @@
|
||||||
|
/*- CodeArea的根节点样式*/
|
||||||
|
.code-area {
|
||||||
|
-fx-font-family: "Consolas";
|
||||||
|
-fx-font-size: 16px;
|
||||||
|
-fx-text-fill: #1d171e;
|
||||||
|
-fx-background-color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** - 行号的样式*/
|
||||||
|
.code-area .line-number {
|
||||||
|
-fx-background-color: #f4f4f4;
|
||||||
|
-fx-text-fill: #999999;
|
||||||
|
-fx-fill: #f4f;
|
||||||
|
-fx-font-size: 18px;
|
||||||
|
-fx-padding: 5 5 5 5px
|
||||||
|
}
|
||||||
|
|
||||||
|
/*- 光标的样式*/
|
||||||
|
.code-area .caret {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.code-area .selection {
|
||||||
|
-fx-fill: #cbcacb;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-*/
|
||||||
|
/*选中文本的样式*/
|
||||||
|
.code-area .highlight {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-*/
|
||||||
|
/*高亮文本的样式*/
|
||||||
|
.code-area .folded {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-*/
|
||||||
|
/*折叠代码的样式*/
|
||||||
|
.code-area .folded-indicator {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-*/
|
||||||
|
/*折叠代码指示器的样式*/
|
||||||
|
.code-area .folded-indicator:hover {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-*/
|
||||||
|
/*折叠代码指示器的鼠标悬停样式*/
|
||||||
|
.code-area .error {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-*/
|
||||||
|
/*错误文本的样式*/
|
||||||
|
.code-area .warning {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-*/
|
||||||
|
/*警告文本的样式*/
|
||||||
|
.code-area .info {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-*/
|
||||||
|
/*信息文本的样式*/
|
||||||
|
.code-area .keyword {
|
||||||
|
-fx-fill: #10ADEBFF
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-*/
|
||||||
|
/*关键字的样式*/
|
||||||
|
.code-area .operator {
|
||||||
|
-fx-fill: #d12746;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-*/
|
||||||
|
/*运算符的样式*/
|
||||||
|
.code-area .number {
|
||||||
|
-fx-fill: #27c5d1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-*/
|
||||||
|
/*数字的样式*/
|
||||||
|
.code-area .string {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-*/
|
||||||
|
/*字符串的样式*/
|
||||||
|
.code-area .comment {
|
||||||
|
-fx-fill: #cbcacb;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-*/
|
||||||
|
/*注释的样式*/
|
||||||
|
.code-area .type {
|
||||||
|
-fx-fill: red;
|
||||||
|
-fx-text-fill: #ffff55;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-*/
|
||||||
|
/*类型的样式*/
|
||||||
|
.code-area .function {
|
||||||
|
-fx-fill: red;
|
||||||
|
-fx-text-fill: #ffff55;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-*/
|
||||||
|
/*函数的样式*/
|
||||||
|
.code-area .parameter {
|
||||||
|
-fx-fill: #d56b6b;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-*/
|
||||||
|
/*参数的样式*/
|
||||||
|
.code-area .annotation {
|
||||||
|
-fx-fill: #eeee07;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-*/
|
||||||
|
/*注解的样式*/
|
||||||
|
.code-area .class {
|
||||||
|
-fx-fill: red;
|
||||||
|
-fx-text-fill: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-*/
|
||||||
|
/*类的样式*/
|
||||||
|
.code-area .interface {
|
||||||
|
-fx-fill: red;
|
||||||
|
-fx-text-fill: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-*/
|
||||||
|
/*接口的样式*/
|
||||||
|
.code-area .enum {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-*/
|
||||||
|
/*枚举的样式*/
|
||||||
|
.code-area .field {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-*/
|
||||||
|
/*字段的样式*/
|
||||||
|
.code-area .method {
|
||||||
|
-fx-fill: red;
|
||||||
|
-fx-text-fill: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-*/
|
||||||
|
/*方法的样式*/
|
||||||
|
.code-area .constructor {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-*/
|
||||||
|
/*构造函数的样式*/
|
||||||
|
.code-area .static {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-*/
|
||||||
|
/*静态的样式*/
|
||||||
|
.code-area .final {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-*/
|
||||||
|
/*最终的样式*/
|
||||||
|
.code-area .abstract {
|
||||||
|
-fx-fill: red;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-*/
|
||||||
|
/*抽象的样式*/
|
||||||
|
.code-area .deprecated {
|
||||||
|
-fx-fill: #d12746;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.scene.control.ListView?>
|
||||||
|
<?import javafx.scene.control.Menu?>
|
||||||
|
<?import javafx.scene.control.MenuBar?>
|
||||||
|
<?import javafx.scene.control.MenuItem?>
|
||||||
|
<?import javafx.scene.control.SplitPane?>
|
||||||
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
|
|
||||||
|
<AnchorPane fx:controller="com.zhangmeng.tools.controller.FileEditController" prefHeight="649.0" prefWidth="1200.0"
|
||||||
|
xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1">
|
||||||
|
<children>
|
||||||
|
<MenuBar AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
|
<menus>
|
||||||
|
<Menu mnemonicParsing="false" text="文件">
|
||||||
|
<items>
|
||||||
|
<MenuItem mnemonicParsing="false" text="打开文件夹" onAction="#open_file_dir" />
|
||||||
|
<MenuItem mnemonicParsing="false" text="保存"/>
|
||||||
|
</items>
|
||||||
|
</Menu>
|
||||||
|
</menus>
|
||||||
|
</MenuBar>
|
||||||
|
<SplitPane fx:id="splitPane" layoutX="122.0" layoutY="239.0" prefHeight="200.0" prefWidth="808.0" AnchorPane.bottomAnchor="0.0"
|
||||||
|
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="25.0">
|
||||||
|
</SplitPane>
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
|
|
@ -49,6 +49,7 @@
|
||||||
<MenuItem mnemonicParsing="false" text="pdf识别" onAction="#pdf_menu_item"/>
|
<MenuItem mnemonicParsing="false" text="pdf识别" onAction="#pdf_menu_item"/>
|
||||||
<MenuItem mnemonicParsing="false" text="批量修改文件名" onAction="#batch_update_file_name_menu_item"/>
|
<MenuItem mnemonicParsing="false" text="批量修改文件名" onAction="#batch_update_file_name_menu_item"/>
|
||||||
<MenuItem mnemonicParsing="false" text="截图工具" onAction="#capter_screen_menu_item"/>
|
<MenuItem mnemonicParsing="false" text="截图工具" onAction="#capter_screen_menu_item"/>
|
||||||
|
<MenuItem mnemonicParsing="false" text="文件编辑器" onAction="#file_edit_menu_item"/>
|
||||||
</items>
|
</items>
|
||||||
</Menu>
|
</Menu>
|
||||||
|
|
||||||
|
|
|
||||||
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 6.0 KiB |
|
After Width: | Height: | Size: 8.3 KiB |
|
After Width: | Height: | Size: 5.4 KiB |
|
After Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 5.3 KiB |
|
After Width: | Height: | Size: 5.7 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 2.8 KiB |