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