删除无效代码
This commit is contained in:
parent
6acc5024f3
commit
6bd259992a
@ -9,7 +9,6 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 控制器接口类
|
* 控制器接口类
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public interface ControllerInterface {
|
public interface ControllerInterface {
|
||||||
|
|
||||||
@ -110,4 +109,5 @@ public interface ControllerInterface {
|
|||||||
*/
|
*/
|
||||||
void initTabPane();
|
void initTabPane();
|
||||||
|
|
||||||
|
void updateUIWithNewTextArea(TextArea textArea);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -57,20 +57,12 @@ public class LunchApp extends Application {
|
|||||||
threadPool.execute(() -> {
|
threadPool.execute(() -> {
|
||||||
TextArea textArea = controller.openAssociatedFileAndCreateTextArea(rawParameters);
|
TextArea textArea = controller.openAssociatedFileAndCreateTextArea(rawParameters);
|
||||||
if (!Objects.isNull(textArea)) {
|
if (!Objects.isNull(textArea)) {
|
||||||
Platform.runLater(() -> updateUIWithNewTextArea(textArea));
|
Platform.runLater(() -> controller.updateUIWithNewTextArea(textArea));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateUIWithNewTextArea(TextArea textArea) {
|
|
||||||
Tab tab = new Tab("新建文件 " + (++ViewManager.tabIndex));
|
|
||||||
tab.setContent(textArea);
|
|
||||||
ViewManager.tabPane.getTabs().add(tab);
|
|
||||||
ViewManager.tabPane.getSelectionModel().select(tab);
|
|
||||||
controller.updateStatusLabel(textArea);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop() {
|
public void stop() {
|
||||||
// 关闭线程池
|
// 关闭线程池
|
||||||
|
|||||||
@ -30,7 +30,6 @@ public class SaveAsFile implements EventHandler<ActionEvent> {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void handle(ActionEvent event) {
|
public void handle(ActionEvent event) {
|
||||||
Controller controller = new Controller();
|
|
||||||
Tab selectedTab = tabPane.getSelectionModel().getSelectedItem();
|
Tab selectedTab = tabPane.getSelectionModel().getSelectedItem();
|
||||||
if (selectedTab != null) {
|
if (selectedTab != null) {
|
||||||
FileChooser fileChooser = new FileChooser();
|
FileChooser fileChooser = new FileChooser();
|
||||||
@ -41,7 +40,6 @@ public class SaveAsFile implements EventHandler<ActionEvent> {
|
|||||||
try {
|
try {
|
||||||
BufferedWriter writer = new BufferedWriter(new FileWriter(file));
|
BufferedWriter writer = new BufferedWriter(new FileWriter(file));
|
||||||
TextArea textArea = (TextArea) selectedTab.getContent(); // 获取当前Tab页的文本编辑区
|
TextArea textArea = (TextArea) selectedTab.getContent(); // 获取当前Tab页的文本编辑区
|
||||||
controller.autoSave(textArea);// 自动保存
|
|
||||||
String text = textArea.getText();
|
String text = textArea.getText();
|
||||||
writer.write(text); // 写入文件内容
|
writer.write(text); // 写入文件内容
|
||||||
writer.flush();
|
writer.flush();
|
||||||
|
|||||||
@ -89,6 +89,7 @@ public class Controller implements ControllerInterface {
|
|||||||
if (file != null) {
|
if (file != null) {
|
||||||
try (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) {
|
try (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) {
|
||||||
writer.write(newValue);
|
writer.write(newValue);
|
||||||
|
System.out.println("正在自动保存---");
|
||||||
} catch (IOException ignored) {
|
} catch (IOException ignored) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -234,6 +235,15 @@ public class Controller implements ControllerInterface {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateUIWithNewTextArea(TextArea textArea) {
|
||||||
|
Tab tab = new Tab("新建文件 " + (++ViewManager.tabIndex));
|
||||||
|
tab.setContent(textArea);
|
||||||
|
ViewManager.tabPane.getTabs().add(tab);
|
||||||
|
ViewManager.tabPane.getSelectionModel().select(tab);
|
||||||
|
updateStatusLabel(textArea);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 配置文本区域。
|
* 配置文本区域。
|
||||||
*
|
*
|
||||||
|
|||||||
@ -32,7 +32,7 @@ public class EncodingDetector {
|
|||||||
// 尝试常见的编码
|
// 尝试常见的编码
|
||||||
for (Charset charset : commonCharsets()) {
|
for (Charset charset : commonCharsets()) {
|
||||||
if (isValidEncoding(text, charset)) {
|
if (isValidEncoding(text, charset)) {
|
||||||
System.out.println(isValidEncoding(text, charset));
|
System.out.println("编码监测结果:" + isValidEncoding(text, charset));
|
||||||
return charset.name();
|
return charset.name();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user