Skip to content

Commit

Permalink
Merge pull request #95 from rememberber/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
rememberber authored Oct 30, 2023
2 parents 0a92d28 + fcba251 commit ef6cfbf
Show file tree
Hide file tree
Showing 12 changed files with 506 additions and 99 deletions.
13 changes: 10 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
<guava.version>32.1.2-jre</guava.version>
<okhttp.version>4.11.0</okhttp.version>
<google.zxing.core.version>3.5.1</google.zxing.core.version>
<flatlaf.version>3.2.1</flatlaf.version>
<flatlaf-extras.version>3.2.1</flatlaf-extras.version>
<flatlaf-intellij-themes.version>3.2.1</flatlaf-intellij-themes.version>
<flatlaf.version>3.2.5</flatlaf.version>
<flatlaf-extras.version>3.2.5</flatlaf-extras.version>
<flatlaf-intellij-themes.version>3.2.5</flatlaf-intellij-themes.version>
<flatlaf-fonts-jetbrains-mono.version>2.242</flatlaf-fonts-jetbrains-mono.version>
<rsyntaxtextarea.version>3.3.4</rsyntaxtextarea.version>
<sql-formatter.version>2.0.4</sql-formatter.version>
Expand All @@ -45,6 +45,7 @@
<oshi-core.version>6.4.6</oshi-core.version>
<jfa.version>1.2.0</jfa.version>
<versioncompare.version>1.5.0</versioncompare.version>
<groovy.version>4.0.15</groovy.version>
</properties>

<repositories>
Expand Down Expand Up @@ -260,6 +261,12 @@
<artifactId>versioncompare</artifactId>
<version>${versioncompare.version}</version>
</dependency>

<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy</artifactId>
<version>${groovy.version}</version>
</dependency>

</dependencies>

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

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

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

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

setMaximumSize(new Dimension(-1, -1));
setMinimumSize(new Dimension(-1, -1));

Color defaultBackground = App.mainFrame.getBackground();

Gutter gutter = getGutter();
if (FlatLaf.isLafDark()) {
gutter.setBorderColor(gutter.getLineNumberColor().darker());
} else {
gutter.setBorderColor(gutter.getLineNumberColor().brighter());
}
gutter.setBackground(defaultBackground);
Font font2 = new Font(App.config.getFont(), Font.PLAIN, App.config.getFontSize());
gutter.setLineNumberFont(font2);
gutter.setBackground(UIManager.getColor("Editor.gutter.background"));
gutter.setBorderColor(UIManager.getColor("Editor.gutter.borderColor"));
gutter.setLineNumberColor(UIManager.getColor("Editor.gutter.lineNumberColor"));
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,68 @@
package com.luoboduner.moo.tool.ui.component;

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;

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

public class RegexSyntaxTextViewer extends RSyntaxTextArea {
public RegexSyntaxTextViewer() {

setDoubleBuffered(true);

try {
Theme theme;
if (FlatLaf.isLafDark()) {
theme = Theme.load(RegexSyntaxTextViewer.class.getResourceAsStream(
"/org/fife/ui/rsyntaxtextarea/themes/monokai.xml"));
} else {
theme = Theme.load(RegexSyntaxTextViewer.class.getResourceAsStream(
"/org/fife/ui/rsyntaxtextarea/themes/idea.xml"));
}
theme.apply(this);
} catch (IOException ioe) { // Never happens
ioe.printStackTrace();
}

setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_NONE);
setCodeFoldingEnabled(true);
// setCurrentLineHighlightColor(new Color(52, 52, 52));
// setUseSelectedTextColor(true);
// setSelectedTextColor(new Color(50, 50, 50));

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

// 初始化字体
String fontName = App.config.getJsonBeautyFontName();
int fontSize = App.config.getJsonBeautyFontSize();
if (fontSize == 0) {
fontSize = getFont().getSize() + 2;
}
Font font = new Font(fontName, Font.PLAIN, fontSize);
setFont(font);

setHyperlinksEnabled(false);


setBackground(UIManager.getColor("Editor.background"));
setCaretColor(UIManager.getColor("Editor.caretColor"));
setSelectionColor(UIManager.getColor("Editor.selectionBackground"));
setCurrentLineHighlightColor(UIManager.getColor("Editor.currentLineHighlight"));
setMarkAllHighlightColor(UIManager.getColor("Editor.markAllHighlightColor"));
setMarkOccurrencesColor(UIManager.getColor("Editor.markOccurrencesColor"));
setMatchedBracketBGColor(UIManager.getColor("Editor.matchedBracketBackground"));
setMatchedBracketBorderColor(UIManager.getColor("Editor.matchedBracketBorderColor"));
setPaintMatchedBracketPair(true);
setAnimateBracketMatching(false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@ private void changeTheme(String selectedThemeName) {
HostForm.getInstance().updateTheme();
HostForm.getInstance().getScrollPane().updateUI();

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

Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/luoboduner/moo/tool/ui/form/MainWindow.form
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,15 @@
<border type="none"/>
<children/>
</grid>
<grid id="679bb" binding="javaConsolePanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<tabbedpane title="Java"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
</children>
</tabbedpane>
</children>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class MainWindow {
private JPanel cronPanel;
private JPanel regexPanel;
private JPanel imagePanel;
private JPanel javaConsolePanel;

private static MainWindow mainWindow;

Expand Down Expand Up @@ -76,7 +77,7 @@ public void init() {
mainWindow.getTabbedPane().setIconAt(12, new FlatSVGIcon("icon/translate.svg"));
mainWindow.getTabbedPane().setIconAt(13, new FlatSVGIcon("icon/schedule.svg", 15, 15));
mainWindow.getTabbedPane().setIconAt(14, new FlatSVGIcon("icon/reg.svg"));

mainWindow.getTabbedPane().setIconAt(15, new FlatSVGIcon("icon/java.svg"));

mainWindow.getQuickNotePanel().add(QuickNoteForm.getInstance().getQuickNotePanel(), gridConstraints);
mainWindow.getJsonBeautyPanel().add(JsonBeautyForm.getInstance().getJsonBeautyPanel(), gridConstraints);
Expand All @@ -93,6 +94,7 @@ public void init() {
mainWindow.getCronPanel().add(CronForm.getInstance().getCronPanel(), gridConstraints);
mainWindow.getRegexPanel().add(RegexForm.getInstance().getRegexPanel(), gridConstraints);
mainWindow.getImagePanel().add(ImageForm.getInstance().getImagePanel(), gridConstraints);
mainWindow.getJavaConsolePanel().add(JavaConsoleForm.getInstance().getJavaConsolePanel(), gridConstraints);
mainWindow.getMainPanel().updateUI();

TabListener.addListeners();
Expand Down Expand Up @@ -163,6 +165,9 @@ public void init() {
regexPanel = new JPanel();
regexPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
tabbedPane.addTab("正则", new ImageIcon(getClass().getResource("/icon/reg.png")), regexPanel);
javaConsolePanel = new JPanel();
javaConsolePanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
tabbedPane.addTab("Java", javaConsolePanel);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.luoboduner.moo.tool.ui.form.func.JavaConsoleForm">
<grid id="27dc6" binding="javaConsolePanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="12" left="12" bottom="12" right="12"/>
<constraints>
<xy x="26" y="46" width="494" height="567"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="5956" layout-manager="GridLayoutManager" row-count="1" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="10" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="1" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="804be" class="javax.swing.JButton" binding="clean">
<constraints>
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="清除"/>
</properties>
</component>
<component id="54894" class="javax.swing.JButton" binding="run">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="执行"/>
</properties>
</component>
<component id="8d9f4" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font size="14"/>
<text value="输入Java或groovy代码点击执行即可"/>
</properties>
</component>
<hspacer id="73c3d">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
</children>
</grid>
<splitpane id="76c59">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<preferred-size width="200" height="200"/>
</grid>
</constraints>
<properties>
<continuousLayout value="true"/>
<dividerLocation value="463"/>
<dividerSize value="3"/>
</properties>
<border type="none"/>
<children>
<scrollpane id="7a589">
<constraints>
<splitpane position="left"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="61044" class="javax.swing.JTextArea" binding="codeArea">
<constraints/>
<properties>
<background color="-13947600"/>
<font name="Consolas" size="16"/>
<text value=""/>
</properties>
</component>
</children>
</scrollpane>
<scrollpane id="8cb4d">
<constraints>
<splitpane position="right"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="286fe" class="javax.swing.JTextArea" binding="resultArea">
<constraints/>
<properties>
<background color="-13947600"/>
<editable value="false"/>
<font name="Consolas" size="16"/>
</properties>
</component>
</children>
</scrollpane>
</children>
</splitpane>
</children>
</grid>
</form>
Loading

0 comments on commit ef6cfbf

Please sign in to comment.