Skip to content

Commit

Permalink
Merge pull request #96 from rememberber/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
rememberber committed Oct 30, 2023
2 parents ef6cfbf + 050b7ce commit 719d63d
Show file tree
Hide file tree
Showing 24 changed files with 280 additions and 304 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.uiDesigner.core.Spacer;
import com.luoboduner.moo.tool.ui.component.textviewer.QuickNoteRSyntaxTextViewer;
import com.luoboduner.moo.tool.ui.listener.func.HostListener;
import com.luoboduner.moo.tool.ui.listener.func.JsonBeautyListener;
import lombok.Getter;
Expand Down Expand Up @@ -128,7 +129,7 @@ void markAll() {

private void findOrMarkAll(boolean find) {
try {
QuickNoteSyntaxTextViewer.ignoreQuickSave = true;
QuickNoteRSyntaxTextViewer.ignoreQuickSave = true;
JsonBeautyListener.ignoreQuickSave = true;
HostListener.ignoreQuickSave = true;
// update search context
Expand All @@ -154,7 +155,7 @@ private void findOrMarkAll(boolean find) {
} catch (Exception e) {
log.error(e.toString());
} finally {
QuickNoteSyntaxTextViewer.ignoreQuickSave = false;
QuickNoteRSyntaxTextViewer.ignoreQuickSave = false;
JsonBeautyListener.ignoreQuickSave = false;
HostListener.ignoreQuickSave = false;
}
Expand Down Expand Up @@ -190,7 +191,7 @@ private void replace() {

private void replaceAll() {
try {
QuickNoteSyntaxTextViewer.ignoreQuickSave = true;
QuickNoteRSyntaxTextViewer.ignoreQuickSave = true;
JsonBeautyListener.ignoreQuickSave = true;
HostListener.ignoreQuickSave = true;
// update search context
Expand All @@ -213,7 +214,7 @@ private void replaceAll() {
} catch (Exception e) {
log.error(e.toString());
} finally {
QuickNoteSyntaxTextViewer.ignoreQuickSave = false;
QuickNoteRSyntaxTextViewer.ignoreQuickSave = false;
JsonBeautyListener.ignoreQuickSave = false;
HostListener.ignoreQuickSave = false;
}
Expand Down
21 changes: 16 additions & 5 deletions src/main/java/com/luoboduner/moo/tool/ui/component/TopMenuBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
import com.jthemedetecor.OsThemeDetector;
import com.luoboduner.moo.tool.App;
import com.luoboduner.moo.tool.ui.Init;
import com.luoboduner.moo.tool.ui.component.textviewer.QuickNoteRSyntaxTextViewer;
import com.luoboduner.moo.tool.ui.component.textviewer.QuickNoteRSyntaxTextViewerManager;
import com.luoboduner.moo.tool.ui.dialog.*;
import com.luoboduner.moo.tool.ui.form.MainWindow;
import com.luoboduner.moo.tool.ui.form.func.HostForm;
import com.luoboduner.moo.tool.ui.form.func.JavaConsoleForm;
import com.luoboduner.moo.tool.ui.form.func.JsonBeautyForm;
import com.luoboduner.moo.tool.ui.form.func.RegexForm;
import com.luoboduner.moo.tool.util.SystemUtil;
Expand Down Expand Up @@ -421,20 +424,28 @@ private void changeTheme(String selectedThemeName) {

initThemesMenu();

QuickNoteSyntaxTextViewerManager.viewMap.forEach((name, rTextScrollPane) -> {
((QuickNoteSyntaxTextViewer) rTextScrollPane.getTextArea()).updateTheme();
QuickNoteSyntaxTextViewerManager.updateGutter(rTextScrollPane);
QuickNoteRSyntaxTextViewerManager.viewMap.forEach((name, rTextScrollPane) -> {
((QuickNoteRSyntaxTextViewer) rTextScrollPane.getTextArea()).updateTheme();
QuickNoteRSyntaxTextViewerManager.updateGutter(rTextScrollPane);
rTextScrollPane.updateUI();
});

JsonBeautyForm.getInstance().updateTheme();
JsonBeautyForm.getInstance().getTextArea().updateTheme();
JsonBeautyForm.getInstance().getScrollPane().updateTheme();
JsonBeautyForm.initTextAreaFont();
JsonBeautyForm.getInstance().getScrollPane().updateUI();

HostForm.getInstance().updateTheme();
HostForm.getInstance().getTextArea().updateTheme();
HostForm.getInstance().getScrollPane().updateTheme();
HostForm.getInstance().getScrollPane().updateUI();

RegexForm.getInstance().getTextArea().updateTheme();
RegexForm.getInstance().getScrollPane().updateTheme();
RegexForm.getInstance().getScrollPane().updateUI();

JavaConsoleForm.getInstance().getTextArea().updateTheme();
JavaConsoleForm.getInstance().getScrollPane().updateTheme();
JavaConsoleForm.getInstance().getScrollPane().updateUI();
}

private void keyMapActionPerformed() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.luoboduner.moo.tool.ui.component;
package com.luoboduner.moo.tool.ui.component.textviewer;

import com.formdev.flatlaf.FlatLaf;
import com.luoboduner.moo.tool.App;
import com.luoboduner.moo.tool.ui.form.func.TimeConvertForm;
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
import org.fife.ui.rsyntaxtextarea.Theme;
Expand All @@ -11,18 +10,22 @@
import java.awt.*;
import java.io.IOException;

public class RegexSyntaxTextViewer extends RSyntaxTextArea {
public RegexSyntaxTextViewer() {
public class CommonRSyntaxTextViewer extends RSyntaxTextArea {
public CommonRSyntaxTextViewer() {

setDoubleBuffered(true);

updateTheme();
}

public void updateTheme() {
try {
Theme theme;
if (FlatLaf.isLafDark()) {
theme = Theme.load(RegexSyntaxTextViewer.class.getResourceAsStream(
theme = Theme.load(App.class.getResourceAsStream(
"/org/fife/ui/rsyntaxtextarea/themes/monokai.xml"));
} else {
theme = Theme.load(RegexSyntaxTextViewer.class.getResourceAsStream(
theme = Theme.load(App.class.getResourceAsStream(
"/org/fife/ui/rsyntaxtextarea/themes/idea.xml"));
}
theme.apply(this);
Expand All @@ -38,9 +41,6 @@ public RegexSyntaxTextViewer() {

// 初始化背景色
// Style.blackTextArea(this);
setBackground(TimeConvertForm.getInstance().getTimeHisTextArea().getBackground());
// 初始化边距
setMargin(new Insets(10, 10, 10, 10));

// 初始化字体
String fontName = App.config.getJsonBeautyFontName();
Expand All @@ -53,7 +53,6 @@ public RegexSyntaxTextViewer() {

setHyperlinksEnabled(false);


setBackground(UIManager.getColor("Editor.background"));
setCaretColor(UIManager.getColor("Editor.caretColor"));
setSelectionColor(UIManager.getColor("Editor.selectionBackground"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
package com.luoboduner.moo.tool.ui.component;
package com.luoboduner.moo.tool.ui.component.textviewer;

import com.formdev.flatlaf.FlatLaf;
import com.luoboduner.moo.tool.App;
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
import org.fife.ui.rtextarea.Gutter;
import org.fife.ui.rtextarea.RTextScrollPane;

import javax.swing.*;
import java.awt.*;

public class RegexRTextScrollPane extends RTextScrollPane {
public class CommonRTextScrollPane extends RTextScrollPane {
// constructor
public RegexRTextScrollPane(RegexSyntaxTextViewer textArea) {
public CommonRTextScrollPane(RSyntaxTextArea textArea) {
super(textArea);

updateTheme();
}

public void updateTheme() {
setMaximumSize(new Dimension(-1, -1));
setMinimumSize(new Dimension(-1, -1));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.luoboduner.moo.tool.ui.component;
package com.luoboduner.moo.tool.ui.component.textviewer;

import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;

import javax.swing.event.HyperlinkEvent;
import java.awt.*;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

public class HostSyntaxTextViewer extends RSyntaxTextArea {
public HostSyntaxTextViewer() {
public class HostRSyntaxTextViewer extends CommonRSyntaxTextViewer {
public HostRSyntaxTextViewer() {

addHyperlinkListener(e -> {
if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) {
Expand All @@ -23,5 +23,15 @@ public HostSyntaxTextViewer() {
});

setDoubleBuffered(true);

updateTheme();
}

public void updateTheme() {
super.updateTheme();

setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_HOSTS);

setHyperlinksEnabled(true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.luoboduner.moo.tool.ui.component.textviewer;

public class HostRTextScrollPane extends CommonRTextScrollPane {
// constructor
public HostRTextScrollPane(HostRSyntaxTextViewer textArea) {
super(textArea);

updateTheme();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.luoboduner.moo.tool.ui.component.textviewer;

import com.luoboduner.moo.tool.util.SystemUtil;

import java.awt.*;

public class JavaRSyntaxTextViewer extends CommonRSyntaxTextViewer {
public JavaRSyntaxTextViewer() {

setDoubleBuffered(true);

updateTheme();
}

@Override
public void updateTheme() {
super.updateTheme();
// Consolas is not available on Linux
if (SystemUtil.isLinuxOs()) {
setFont(new Font("Monospaced", Font.PLAIN, 14));
} else {
setFont(new Font("Consolas", Font.PLAIN, 14));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.luoboduner.moo.tool.ui.component.textviewer;

public class JavaRTextScrollPane extends CommonRTextScrollPane {
// constructor
public JavaRTextScrollPane(JavaRSyntaxTextViewer textArea) {
super(textArea);

updateTheme();
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.luoboduner.moo.tool.ui.component;
package com.luoboduner.moo.tool.ui.component.textviewer;

import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;

import javax.swing.event.HyperlinkEvent;
import java.awt.*;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

public class JsonSyntaxTextViewer extends RSyntaxTextArea {
public JsonSyntaxTextViewer() {
public class JsonRSyntaxTextViewer extends CommonRSyntaxTextViewer {
public JsonRSyntaxTextViewer() {

addHyperlinkListener(e -> {
if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) {
Expand All @@ -23,5 +23,14 @@ public JsonSyntaxTextViewer() {
});

setDoubleBuffered(true);

updateTheme();
}

public void updateTheme() {
super.updateTheme();

setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JSON);
setCodeFoldingEnabled(true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.luoboduner.moo.tool.ui.component.textviewer;

public class JsonRTextScrollPane extends CommonRTextScrollPane {
// constructor
public JsonRTextScrollPane(JsonRSyntaxTextViewer textArea) {
super(textArea);

updateTheme();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.luoboduner.moo.tool.ui.component;
package com.luoboduner.moo.tool.ui.component.textviewer;

import com.luoboduner.moo.tool.App;
import com.luoboduner.moo.tool.ui.Style;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.luoboduner.moo.tool.ui.component;
package com.luoboduner.moo.tool.ui.component.textviewer;

import com.formdev.flatlaf.FlatLaf;
import com.formdev.flatlaf.fonts.jetbrains_mono.FlatJetBrainsMonoFont;
Expand All @@ -22,10 +22,10 @@
import java.net.URI;
import java.net.URISyntaxException;

public class QuickNoteSyntaxTextViewer extends RSyntaxTextArea {
public class QuickNoteRSyntaxTextViewer extends RSyntaxTextArea {
public static boolean ignoreQuickSave;

public QuickNoteSyntaxTextViewer() {
public QuickNoteRSyntaxTextViewer() {

// setUseSelectedTextColor(true);
// setSelectedTextColor(new Color(50, 50, 50));
Expand Down Expand Up @@ -113,10 +113,10 @@ public void updateTheme() {
try {
Theme theme;
if (FlatLaf.isLafDark()) {
theme = Theme.load(JsonSyntaxTextViewer.class.getResourceAsStream(
theme = Theme.load(App.class.getResourceAsStream(
"/org/fife/ui/rsyntaxtextarea/themes/monokai.xml"));
} else {
theme = Theme.load(JsonSyntaxTextViewer.class.getResourceAsStream(
theme = Theme.load(App.class.getResourceAsStream(
"/org/fife/ui/rsyntaxtextarea/themes/idea.xml"));
}
theme.apply(this);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.luoboduner.moo.tool.ui.component;
package com.luoboduner.moo.tool.ui.component.textviewer;

import com.formdev.flatlaf.FlatLaf;
import com.formdev.flatlaf.fonts.jetbrains_mono.FlatJetBrainsMonoFont;
Expand All @@ -20,7 +20,7 @@
/**
* 自定义普通纯文本视图管理器
*/
public class QuickNoteSyntaxTextViewerManager {
public class QuickNoteRSyntaxTextViewerManager {

public static Map<String, RTextScrollPane> viewMap = new HashMap<>();

Expand All @@ -36,7 +36,7 @@ public class QuickNoteSyntaxTextViewerManager {
public RTextScrollPane getRTextScrollPane(String name) {
RTextScrollPane rTextScrollPane = viewMap.get(name);
if (rTextScrollPane == null) {
QuickNoteSyntaxTextViewer plainTextViewer = new QuickNoteSyntaxTextViewer();
QuickNoteRSyntaxTextViewer plainTextViewer = new QuickNoteRSyntaxTextViewer();
TQuickNote tQuickNote = quickNoteMapper.selectByName(name);
plainTextViewer.setText(tQuickNote.getContent());
if (StringUtils.isNotEmpty(tQuickNote.getSyntax())) {
Expand Down Expand Up @@ -69,7 +69,7 @@ public RTextScrollPane getRTextScrollPane(String name) {
public void updateFont(String name){
RTextScrollPane rTextScrollPane = viewMap.get(name);
if (rTextScrollPane != null) {
QuickNoteSyntaxTextViewer plainTextViewer = (QuickNoteSyntaxTextViewer) rTextScrollPane.getTextArea();
QuickNoteRSyntaxTextViewer plainTextViewer = (QuickNoteRSyntaxTextViewer) rTextScrollPane.getTextArea();
TQuickNote tQuickNote = quickNoteMapper.selectByName(name);
if (StringUtils.isNotEmpty(tQuickNote.getFontName()) && StringUtils.isNotEmpty(tQuickNote.getFontSize())) {
Font font;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.luoboduner.moo.tool.ui.component.textviewer;

public class RegexRSyntaxTextViewer extends CommonRSyntaxTextViewer {
public RegexRSyntaxTextViewer() {

setDoubleBuffered(true);

updateTheme();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.luoboduner.moo.tool.ui.component.textviewer;

public class RegexRTextScrollPane extends CommonRTextScrollPane {
// constructor
public RegexRTextScrollPane(RegexRSyntaxTextViewer textArea) {
super(textArea);

updateTheme();
}
}
Loading

0 comments on commit 719d63d

Please sign in to comment.