From 8ae5e092d944d518156f09e13fd68dfd5c341a96 Mon Sep 17 00:00:00 2001 From: richie Date: Fri, 30 Aug 2019 17:57:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fanruan/api/cal/FormulaKit.java | 2 +- .../fanruan/api/conf/BaseConfiguration.java | 2 +- .../com/fanruan/api/data/ConnectionKit.java | 4 +- .../fanruan/api/design/macro/UIConstants.java | 15 ++- .../design/ui/container/BasicBeanPane.java | 2 +- .../api/design/ui/container/BasicDialog.java | 24 +++-- .../api/design/ui/container/BasicPane.java | 93 +++++++++++++++++++ .../fanruan/api/design/util/GUICoreKit.java | 25 ++++- .../com/fanruan/api/err/UtilEvalError.java | 13 ++- src/main/java/com/fanruan/api/xml/XmlKit.java | 23 ++++- 10 files changed, 179 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/fanruan/api/cal/FormulaKit.java b/src/main/java/com/fanruan/api/cal/FormulaKit.java index e863d2c..10bb4fa 100644 --- a/src/main/java/com/fanruan/api/cal/FormulaKit.java +++ b/src/main/java/com/fanruan/api/cal/FormulaKit.java @@ -54,7 +54,7 @@ public class FormulaKit { * @param content 公式的内容 * @return 公式对象 */ - public static @NotNull FormulaProvider newFormula(Object content) { + public static @NotNull BaseFormula newFormula(Object content) { return BaseFormula.createFormulaBuilder().build(content); } diff --git a/src/main/java/com/fanruan/api/conf/BaseConfiguration.java b/src/main/java/com/fanruan/api/conf/BaseConfiguration.java index 29147d6..c6b7066 100644 --- a/src/main/java/com/fanruan/api/conf/BaseConfiguration.java +++ b/src/main/java/com/fanruan/api/conf/BaseConfiguration.java @@ -30,7 +30,7 @@ public abstract class BaseConfiguration extends DefaultConfiguration { * @param 类型 * @return 配置对象 */ - static T getConfigInstance(final Class clazz) { + public static T getConfigInstance(final Class clazz) { return ConfigContext.getConfigInstance(clazz); } } diff --git a/src/main/java/com/fanruan/api/data/ConnectionKit.java b/src/main/java/com/fanruan/api/data/ConnectionKit.java index ed64b99..e22f3e9 100644 --- a/src/main/java/com/fanruan/api/data/ConnectionKit.java +++ b/src/main/java/com/fanruan/api/data/ConnectionKit.java @@ -17,7 +17,7 @@ public class ConnectionKit { * @param name 名字 * @return 数据连接 */ - public @Nullable Connection getConnection(@NotNull String name) { + public static @Nullable Connection getConnection(@NotNull String name) { return ConnectionConfig.getInstance().getConnection(name); } @@ -28,7 +28,7 @@ public class ConnectionKit { * @param type 类型 * @return 数据连接 */ - public @Nullable T getConnection(@NotNull String name, Class type) { + public static @Nullable T getConnection(@NotNull String name, Class type) { Connection connection = getConnection(name); if (TypeKit.objectInstanceOf(connection, type)) { return (T) connection; diff --git a/src/main/java/com/fanruan/api/design/macro/UIConstants.java b/src/main/java/com/fanruan/api/design/macro/UIConstants.java index 613600f..471cae3 100644 --- a/src/main/java/com/fanruan/api/design/macro/UIConstants.java +++ b/src/main/java/com/fanruan/api/design/macro/UIConstants.java @@ -2,7 +2,18 @@ package com.fanruan.api.design.macro; import java.awt.*; -public class UIConstants { - Color UIPOPUPMENU_LINE_COLOR = new Color(13158861); +/** + * 设计器界面使用的一些常量 + */ +public interface UIConstants { + + /** + * 边框线颜色 + */ + Color LINE_COLOR = new Color(153, 153, 153); + + /** + * 圆角弧度 + */ int ARC = 0; } diff --git a/src/main/java/com/fanruan/api/design/ui/container/BasicBeanPane.java b/src/main/java/com/fanruan/api/design/ui/container/BasicBeanPane.java index ec72cbf..2ffc211 100644 --- a/src/main/java/com/fanruan/api/design/ui/container/BasicBeanPane.java +++ b/src/main/java/com/fanruan/api/design/ui/container/BasicBeanPane.java @@ -1,4 +1,4 @@ package com.fanruan.api.design.ui.container; -public abstract class BasicBeanPane extends com.fr.design.beans.BasicBeanPane{ +public abstract class BasicBeanPane extends com.fr.design.beans.BasicBeanPane { } diff --git a/src/main/java/com/fanruan/api/design/ui/container/BasicDialog.java b/src/main/java/com/fanruan/api/design/ui/container/BasicDialog.java index 5a65107..dcea5c2 100644 --- a/src/main/java/com/fanruan/api/design/ui/container/BasicDialog.java +++ b/src/main/java/com/fanruan/api/design/ui/container/BasicDialog.java @@ -1,36 +1,40 @@ package com.fanruan.api.design.ui.container; -import com.fanruan.api.design.ui.container.BasicPane; - import java.awt.*; -public class BasicDialog extends com.fr.design.dialog.BasicDialog{ - public BasicDialog(Dialog parent){ +public class BasicDialog extends com.fr.design.dialog.BasicDialog { + + public BasicDialog(Dialog parent) { super(parent); } - public BasicDialog(Dialog parent, BasicPane pane){ + public BasicDialog(Dialog parent, BasicPane pane) { super(parent, pane); } - public BasicDialog(Dialog parent, BasicPane pane, boolean isNeedButton){ + public BasicDialog(Dialog parent, BasicPane pane, boolean isNeedButton) { super(parent, pane, isNeedButton); } - public BasicDialog(Frame parent){ + public BasicDialog(Frame parent) { super(parent); } - public BasicDialog(Frame parent, BasicPane pane){ + public BasicDialog(Frame parent, BasicPane pane) { super(parent, pane); } - public BasicDialog(Frame parent, BasicPane pane, boolean isNedButtonPane){ + public BasicDialog(Frame parent, BasicPane pane, boolean isNedButtonPane) { super(parent, pane, isNedButtonPane); } @Override - public void checkValid(){ + protected void setBasicDialogSize(Dimension dimension) { + super.setBasicDialogSize(dimension); + } + + @Override + public void checkValid() throws Exception { } } diff --git a/src/main/java/com/fanruan/api/design/ui/container/BasicPane.java b/src/main/java/com/fanruan/api/design/ui/container/BasicPane.java index c089e0c..f3052fe 100644 --- a/src/main/java/com/fanruan/api/design/ui/container/BasicPane.java +++ b/src/main/java/com/fanruan/api/design/ui/container/BasicPane.java @@ -1,5 +1,98 @@ package com.fanruan.api.design.ui.container; + +import com.fanruan.api.design.util.GUICoreKit; +import com.fr.design.dialog.DialogActionListener; +import com.fr.design.dialog.UIDialog; + +import java.awt.*; + public abstract class BasicPane extends com.fr.design.dialog.BasicPane { + /** + * 显示窗口 + * + * @param window 窗口 + * @return 对话框 + */ + public BasicDialog showWindow(Window window) { + return this.showWindow(window, null); + } + + + /** + * 显示窗口 + * + * @param window 窗口 + * @param l 对话框监听器 + * @return 对话框 + */ + public BasicDialog showWindow(Window window, DialogActionListener l) { + return showWindowWithCustomSize(window, l, BasicDialog.DEFAULT); + } + + public BasicDialog showWindowWithCustomSize(Window window, DialogActionListener l, Dimension dimension) { + BasicDialog dg; + if (window instanceof Frame) { + dg = new DIALOG((Frame) window); + } else { + dg = new DIALOG((Dialog) window); + } + + if (l != null) { + dg.addDialogActionListener(l); + } + dg.setBasicDialogSize(dimension); + GUICoreKit.centerWindow(dg); + dg.setResizable(false); + return dg; + } + + private class DIALOG extends BasicDialog { + public DIALOG(Frame parent) { + super(parent, BasicPane.this); + this.setTitle(BasicPane.this.title4PopupWindow()); + } + + public DIALOG(Dialog parent) { + super(parent, BasicPane.this); + this.setTitle(BasicPane.this.title4PopupWindow()); + } + + + public DIALOG(Frame parent, boolean isNeedButtonPane) { + super(parent, BasicPane.this, isNeedButtonPane); + this.setTitle(BasicPane.this.title4PopupWindow()); + } + + + public DIALOG(Dialog parent, boolean isNeedButtonPane) { + super(parent, BasicPane.this, isNeedButtonPane); + this.setTitle(BasicPane.this.title4PopupWindow()); + } + + + public void checkValid() throws Exception { + BasicPane.this.checkValid(); + } + + } + + private class UnsizedDialog extends UIDialog { + + public UnsizedDialog(Frame parent) { + super(parent, BasicPane.this); + this.setTitle(BasicPane.this.title4PopupWindow()); + } + + public UnsizedDialog(Dialog parent) { + super(parent, BasicPane.this); + this.setTitle(BasicPane.this.title4PopupWindow()); + } + + + public void checkValid() throws Exception { + BasicPane.this.checkValid(); + } + } } diff --git a/src/main/java/com/fanruan/api/design/util/GUICoreKit.java b/src/main/java/com/fanruan/api/design/util/GUICoreKit.java index 8446f02..1ff5155 100644 --- a/src/main/java/com/fanruan/api/design/util/GUICoreKit.java +++ b/src/main/java/com/fanruan/api/design/util/GUICoreKit.java @@ -1,7 +1,7 @@ package com.fanruan.api.design.util; -import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.utils.gui.GUICoreUtils; import javax.swing.*; import java.awt.*; @@ -100,20 +100,39 @@ public class GUICoreKit { public static void showPopupMenu(JPopupMenu menu, Component component, int x, int y) { GUICoreUtils.showPopupMenu(menu, component, x, y); } + /** * 创建一个带有左空边框的面板 * * @return 返回一个JPanel对象 */ - public static JPanel createNormalFlowInnerContainerPane(){ + public static JPanel createNormalFlowInnerContainerPane() { return FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); } + /** * 创建一个带有边框面板 * * @return 返回一个JPanel对象 */ - public static JPanel createBorderLayoutPane(){ + public static JPanel createBorderLayoutPane() { return FRGUIPaneFactory.createBorderLayout_S_Pane(); } + + /** + * 设置一个窗口居中 + */ + public static void centerWindow(Window win) { + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + + Dimension winSize = win.getSize(); + + if (winSize.height > screenSize.height) { + winSize.height = screenSize.height; + } + if (winSize.width > screenSize.width) { + winSize.width = screenSize.width; + } + win.setLocation((screenSize.width - winSize.width) / 2, (screenSize.height - winSize.height) / 2 - 20); + } } diff --git a/src/main/java/com/fanruan/api/err/UtilEvalError.java b/src/main/java/com/fanruan/api/err/UtilEvalError.java index fed9c53..db4ef1f 100644 --- a/src/main/java/com/fanruan/api/err/UtilEvalError.java +++ b/src/main/java/com/fanruan/api/err/UtilEvalError.java @@ -1,4 +1,15 @@ package com.fanruan.api.err; -public class UtilEvalError extends com.fr.stable.UtilEvalError{ +/** + * 公式计算异常 + */ +public class UtilEvalError extends com.fr.stable.UtilEvalError { + + public UtilEvalError() { + + } + + public UtilEvalError(String message) { + super(message); + } } diff --git a/src/main/java/com/fanruan/api/xml/XmlKit.java b/src/main/java/com/fanruan/api/xml/XmlKit.java index 921739f..89de42a 100644 --- a/src/main/java/com/fanruan/api/xml/XmlKit.java +++ b/src/main/java/com/fanruan/api/xml/XmlKit.java @@ -1,9 +1,13 @@ package com.fanruan.api.xml; -import com.fr.stable.xml.*; import com.fr.data.core.DataCoreXmlUtils; import com.fr.data.impl.Connection; import com.fr.general.xml.GeneralXMLTools; +import com.fr.stable.xml.XMLPrintWriter; +import com.fr.stable.xml.XMLReadable; +import com.fr.stable.xml.XMLTools; +import com.fr.stable.xml.XMLable; +import com.fr.stable.xml.XMLableReader; import java.io.InputStream; @@ -42,21 +46,34 @@ public class XmlKit { public static void writeXMLable(XMLPrintWriter writer, XMLable xml, String tagName) { GeneralXMLTools.writeXMLable(writer, xml, tagName); } + /** * 读取connection对象 + * * @param reader XMLableReader对象 * @return Connection对象 - * */ public static Connection readXMLConnectionMap(XMLableReader reader) { return DataCoreXmlUtils.readXMLConnectionMap(reader); } + + /** + * 从xml中读取数据连接对象 + * @param reader xml读取器 + * @return 数据连接对象 + */ + public static Connection readXMLConnection(XMLableReader reader) { + return DataCoreXmlUtils.readXMLConnection(reader); + } + /** * 写connection对象 - * @param writer XMLPrintWriter对象 + * + * @param writer XMLPrintWriter对象 * @param connection Connection对象 */ public static void writeXMLConnection(XMLPrintWriter writer, Connection connection) { DataCoreXmlUtils.writeXMLConnection(writer, connection); } + }