From e9e70d28a9354ab1337503e9654cdf196f5e3214 Mon Sep 17 00:00:00 2001 From: richie Date: Wed, 28 Aug 2019 16:33:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=BC=96=E8=BE=91=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/component/code/SyntaxConstants.java | 20 ++++++++++ .../ui/component/code/UISyntaxTextArea.java | 37 +++++++++++++++++++ .../code/UISyntaxTextScrollPane.java | 30 +++++++++++++++ .../api/design/ui/container/UIScrollPane.java | 16 ++++++++ 4 files changed, 103 insertions(+) create mode 100644 src/main/java/com/fanruan/api/design/ui/component/code/SyntaxConstants.java create mode 100644 src/main/java/com/fanruan/api/design/ui/component/code/UISyntaxTextArea.java create mode 100644 src/main/java/com/fanruan/api/design/ui/component/code/UISyntaxTextScrollPane.java create mode 100644 src/main/java/com/fanruan/api/design/ui/container/UIScrollPane.java diff --git a/src/main/java/com/fanruan/api/design/ui/component/code/SyntaxConstants.java b/src/main/java/com/fanruan/api/design/ui/component/code/SyntaxConstants.java new file mode 100644 index 0000000..f2a5756 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/component/code/SyntaxConstants.java @@ -0,0 +1,20 @@ +package com.fanruan.api.design.ui.component.code; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-08-28 + * 代码编辑器用到的常量 + */ +public interface SyntaxConstants { + + String SYNTAX_STYLE_NONE = "text/plain"; + + String SYNTAX_STYLE_JAVA = "text/java"; + + String SYNTAX_STYLE_JAVASCRIPT = "text/javascript"; + + String SYNTAX_STYLE_SQL = "text/sql"; + + String SYNTAX_STYLE_FORMULA = "text/formula"; +} diff --git a/src/main/java/com/fanruan/api/design/ui/component/code/UISyntaxTextArea.java b/src/main/java/com/fanruan/api/design/ui/component/code/UISyntaxTextArea.java new file mode 100644 index 0000000..bd1ea0f --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/component/code/UISyntaxTextArea.java @@ -0,0 +1,37 @@ +package com.fanruan.api.design.ui.component.code; + +import com.fr.design.gui.syntax.ui.rsyntaxtextarea.RSyntaxTextArea; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-08-28 + * 代码编辑器,支持javascript、sql、java、公式和普通文本 + * @see com.fanruan.api.design.ui.component.code.SyntaxConstants + *

+ * UISyntaxTextArea contentTextArea = new UISyntaxTextArea(); + * contentTextArea.setCloseCurlyBraces(true); + * contentTextArea.setLineWrap(true); + * contentTextArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT); + * contentTextArea.setCodeFoldingEnabled(true); + * contentTextArea.setAntiAliasingEnabled(true); + *

+ */ +public class UISyntaxTextArea extends RSyntaxTextArea { + + public UISyntaxTextArea() { + super(); + } + + public UISyntaxTextArea(String text) { + super(text); + } + + public UISyntaxTextArea(int rows, int cols) { + super(rows, cols); + } + + public UISyntaxTextArea(String text, int rows, int cols) { + super(text, rows, cols); + } +} diff --git a/src/main/java/com/fanruan/api/design/ui/component/code/UISyntaxTextScrollPane.java b/src/main/java/com/fanruan/api/design/ui/component/code/UISyntaxTextScrollPane.java new file mode 100644 index 0000000..4b38e45 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/component/code/UISyntaxTextScrollPane.java @@ -0,0 +1,30 @@ +package com.fanruan.api.design.ui.component.code; + +import com.fr.design.gui.syntax.ui.rtextarea.RTextScrollPane; + +import java.awt.*; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-08-28 + * 可滚动的代码编辑器容器 + */ +public class UISyntaxTextScrollPane extends RTextScrollPane { + + public UISyntaxTextScrollPane() { + + } + + public UISyntaxTextScrollPane(Component component) { + super(component); + } + + public UISyntaxTextScrollPane(Component component, boolean lineNumbers) { + super(component, lineNumbers); + } + + public UISyntaxTextScrollPane(Component component, boolean lineNumbers, Color lineNumberColor) { + super(component, lineNumbers, lineNumberColor); + } +} diff --git a/src/main/java/com/fanruan/api/design/ui/container/UIScrollPane.java b/src/main/java/com/fanruan/api/design/ui/container/UIScrollPane.java new file mode 100644 index 0000000..681e193 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/container/UIScrollPane.java @@ -0,0 +1,16 @@ +package com.fanruan.api.design.ui.container; + +import java.awt.*; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-08-28 + * 可滚动容器 + */ +public class UIScrollPane extends com.fr.design.gui.icontainer.UIScrollPane { + + public UIScrollPane(Component component) { + super(component); + } +}