supplier) {
+ PrintStream oldStream = System.out;
+ try (ByteArrayOutputStream tmpStream = new ByteArrayOutputStream(1024);
+ PrintStream cacheStream = new PrintStream(tmpStream)) {
+ System.setOut(cacheStream);
+ T value = supplier.get();
+ String strMsg = tmpStream.toString();
+ addStr(strMsg);
+ return value;
+ } catch (Exception e) {
+ logException(e);
+ } finally {
+ System.setOut(oldStream);
+ }
+ return null;
+ }
+
+ private void logException(Throwable throwable) {
+ try (StringWriter stringWriter = new StringWriter(); PrintWriter printWriter = new PrintWriter(stringWriter)) {
+ throwable.printStackTrace(printWriter);
+ addStr(stringWriter.toString());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/src/main/java/com/luoboduner/moo/tool/ui/listener/func/QuickNoteListener.java b/src/main/java/com/luoboduner/moo/tool/ui/listener/func/QuickNoteListener.java
index 14b7a5fc..80cd7cf7 100644
--- a/src/main/java/com/luoboduner/moo/tool/ui/listener/func/QuickNoteListener.java
+++ b/src/main/java/com/luoboduner/moo/tool/ui/listener/func/QuickNoteListener.java
@@ -36,6 +36,8 @@
import java.text.DecimalFormat;
import java.util.Date;
import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
/**
*
@@ -52,6 +54,9 @@ public class QuickNoteListener {
public static String selectedName;
+ // 创建一个单线程的ExecutorService
+ public static ExecutorService executorService = Executors.newSingleThreadExecutor();
+
public static void addListeners() {
QuickNoteForm quickNoteForm = QuickNoteForm.getInstance();
QuickNoteSyntaxTextViewerManager quickNoteSyntaxTextViewerManager = QuickNoteForm.quickNoteSyntaxTextViewerManager;
@@ -613,24 +618,28 @@ private static void deleteFiles(QuickNoteForm quickNoteForm) {
* @param refreshModifiedTime
*/
public static void quickSave(boolean refreshModifiedTime, boolean writeLog) {
- String now = SqliteUtil.nowDateForSqlite();
- if (selectedName != null) {
- TQuickNote tQuickNote = new TQuickNote();
- tQuickNote.setName(selectedName);
- String text = QuickNoteForm.quickNoteSyntaxTextViewerManager.getTextByName(selectedName);
- if (writeLog) {
- log.info("save note: " + selectedName + ", content: " + text);
- }
- tQuickNote.setContent(text);
- if (refreshModifiedTime) {
- tQuickNote.setModifiedTime(now);
+ executorService.submit(() -> {
+ String now = SqliteUtil.nowDateForSqlite();
+ if (selectedName != null) {
+ TQuickNote tQuickNote = new TQuickNote();
+ tQuickNote.setName(selectedName);
+
+ String text = QuickNoteForm.quickNoteSyntaxTextViewerManager.getTextByName(selectedName);
+ if (writeLog) {
+ log.info("save note: " + selectedName + ", content: " + text);
+ }
+ tQuickNote.setContent(text);
+ if (refreshModifiedTime) {
+ tQuickNote.setModifiedTime(now);
+ }
+
+ quickNoteMapper.updateByName(tQuickNote);
}
- quickNoteMapper.updateByName(tQuickNote);
- }
+ QuickNoteIndicatorTools.showTips("已保存:" + selectedName, QuickNoteIndicatorTools.TipsLevel.SUCCESS);
+ });
- QuickNoteIndicatorTools.showTips("已保存:" + selectedName, QuickNoteIndicatorTools.TipsLevel.SUCCESS);
}
/**
diff --git a/src/main/resources/icon/java.svg b/src/main/resources/icon/java.svg
new file mode 100755
index 00000000..7e77a1e1
--- /dev/null
+++ b/src/main/resources/icon/java.svg
@@ -0,0 +1 @@
+
\ No newline at end of file