diff --git a/designer-base/src/main/java/com/fr/design/components/notification/NotificationDialog.java b/designer-base/src/main/java/com/fr/design/components/notification/NotificationDialog.java index f7182ddcaf..42dac12c9f 100644 --- a/designer-base/src/main/java/com/fr/design/components/notification/NotificationDialog.java +++ b/designer-base/src/main/java/com/fr/design/components/notification/NotificationDialog.java @@ -9,6 +9,8 @@ import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.VerticalFlowLayout; +import com.fr.env.detect.base.ExceptionDetectorConfig; import javax.swing.BorderFactory; import javax.swing.Icon; @@ -22,7 +24,6 @@ import java.awt.Color; import java.awt.Container; import java.awt.Desktop; import java.awt.Dimension; -import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; @@ -149,8 +150,7 @@ public class NotificationDialog extends JDialog { .collect(Collectors.toList()); // 竖向排列 - JPanel messageSummaryPanel = new JPanel(); - messageSummaryPanel.setLayout(new GridLayout(messageComponents.size(), 1)); + JPanel messageSummaryPanel = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, VerticalFlowLayout.TOP, 0, 0); messageComponents.forEach(messageSummaryPanel::add); JPanel centerPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); @@ -210,7 +210,8 @@ public class NotificationDialog extends JDialog { notReminder.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { - // todo + // 配置处理 + ExceptionDetectorConfig.getInstance().setOpen(false); // 点击事件 destroy(); } diff --git a/designer-base/src/main/java/com/fr/design/components/notification/NotificationMessage.java b/designer-base/src/main/java/com/fr/design/components/notification/NotificationMessage.java index 26dba1297b..c107a0fb88 100644 --- a/designer-base/src/main/java/com/fr/design/components/notification/NotificationMessage.java +++ b/designer-base/src/main/java/com/fr/design/components/notification/NotificationMessage.java @@ -1,6 +1,6 @@ package com.fr.design.components.notification; -import com.fr.design.utils.LinkStrUtil; +import com.fr.design.utils.LinkStrUtils; /** * created by Harrison on 2022/05/24 @@ -76,7 +76,7 @@ public interface NotificationMessage { @Override public String format() { - return LinkStrUtil.generateHtmlTag(text); + return LinkStrUtils.generateHtmlTag(text); } @Override diff --git a/designer-base/src/main/java/com/fr/design/components/table/TablePanel.java b/designer-base/src/main/java/com/fr/design/components/table/TablePanel.java index a1a9492f84..317a171954 100644 --- a/designer-base/src/main/java/com/fr/design/components/table/TablePanel.java +++ b/designer-base/src/main/java/com/fr/design/components/table/TablePanel.java @@ -2,6 +2,7 @@ package com.fr.design.components.table; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.utils.ColorUtils; import com.fr.third.org.apache.commons.lang3.ArrayUtils; import javax.swing.BorderFactory; @@ -152,6 +153,8 @@ public class TablePanel extends JPanel { int x = row - 1; int y = column - 1; + syncCellColor(row, component); + JPanel cellPanel = this.cellPanels[x][y]; if (ArrayUtils.getLength(cellPanel.getComponents()) == 1) { cellPanel.remove(0); @@ -167,13 +170,14 @@ public class TablePanel extends JPanel { } private void syncHeaderColor(Component component) { - - component.setBackground(DEFAULT_HEADER_COLOR); + + ColorUtils.syncBackground(component, DEFAULT_HEADER_COLOR); } private void syncCellColor(int row, Component component) { Color rowColor = getRowColorByRowNumber(row); + ColorUtils.syncBackground(component, rowColor); component.setBackground(rowColor); } diff --git a/designer-base/src/main/java/com/fr/design/dialog/link/MessageWithLink.java b/designer-base/src/main/java/com/fr/design/dialog/link/MessageWithLink.java index a6746d2273..0d6bd23488 100644 --- a/designer-base/src/main/java/com/fr/design/dialog/link/MessageWithLink.java +++ b/designer-base/src/main/java/com/fr/design/dialog/link/MessageWithLink.java @@ -1,18 +1,18 @@ package com.fr.design.dialog.link; -import com.fr.design.utils.LinkStrUtil; +import com.fr.design.utils.LinkStrUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; import javax.swing.JEditorPane; import javax.swing.event.HyperlinkEvent; -import javax.swing.event.HyperlinkListener; import java.awt.Color; import java.awt.Desktop; import java.awt.Font; import java.net.URI; +import java.net.URL; -import static com.fr.design.utils.LinkStrUtil.LABEL; +import static com.fr.design.utils.LinkStrUtils.LABEL; /** * 用来构建JOptionPane带超链的消息提示 @@ -22,6 +22,14 @@ import static com.fr.design.utils.LinkStrUtil.LABEL; * Created by hades on 2020/10/23 */ public class MessageWithLink extends JEditorPane { + + public MessageWithLink(String htmlText) { + + super("text/html", htmlText); + + setEditable(false); + setBorder(null); + } public MessageWithLink(String htmlText, Runnable action) { @@ -57,20 +65,31 @@ public class MessageWithLink extends JEditorPane { public MessageWithLink(String frontMessage, String linkName, String link, String backMessage, Color backgroundColor, Font font, Color fontColor) { - super("text/html", "
" + frontMessage + "" + linkName + "" + backMessage + ""); + super("text/html", "" + frontMessage + "" + linkName + "" + backMessage + ""); initListener(link); setEditable(false); setBorder(null); } + public void initListener() { + + addHyperlinkListener(hyperlinkEvent -> { + try { + if (hyperlinkEvent.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { + URL url = hyperlinkEvent.getURL(); + Desktop.getDesktop().browse(url.toURI()); + } + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + }); + } + public void initListener(Runnable runnable) { - addHyperlinkListener(new HyperlinkListener() { - @Override - public void hyperlinkUpdate(HyperlinkEvent e) { - if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { - runnable.run(); - } + addHyperlinkListener(e -> { + if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { + runnable.run(); } }); } diff --git a/designer-base/src/main/java/com/fr/design/utils/ColorUtils.java b/designer-base/src/main/java/com/fr/design/utils/ColorUtils.java new file mode 100644 index 0000000000..739d394720 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/utils/ColorUtils.java @@ -0,0 +1,30 @@ +package com.fr.design.utils; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.util.Arrays; + +/** + * created by Harrison on 2022/05/29 + **/ +public class ColorUtils { + + /** + * 递归的同步颜色 + * + * @param color 颜色 + */ + public static void syncBackground(Component component, Color color) { + + component.setBackground(color); + + if (component instanceof Container) { + Container container = (Container) component; + Component[] components = container.getComponents(); + if (components != null) { + Arrays.stream(components).forEach((e) -> syncBackground(e, color)); + } + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/utils/DevUtil.java b/designer-base/src/main/java/com/fr/design/utils/DevUtil.java deleted file mode 100644 index caf6fc9665..0000000000 --- a/designer-base/src/main/java/com/fr/design/utils/DevUtil.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.fr.design.utils; - -import com.fr.design.ui.util.UIUtil; -import com.fr.env.detect.ui.EnvDetectorDialog; - -import javax.swing.JFrame; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.Toolkit; -import java.util.function.Consumer; - -/** - * 设计器的开发时工具 - * 帮助进行 UI 页面的调试 - * - * created by Harrison on 2022/05/23 - **/ -public class DevUtil { - - public static void show(Consumer consumer) { - - DesignUtils.initLookAndFeel(); - - UIUtil.invokeLaterIfNeeded(() -> { - - JFrame frame = new JFrame("dev-util"); - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize(); - frame.setSize(dimension); - - consumer.accept(frame); - - frame.setVisible(true); - }); - - } - - public static void main(String[] args) { - - DevUtil.show(new Consumer() { - @Override - public void accept(Frame frame) { - - EnvDetectorDialog envDetectorDialog = new EnvDetectorDialog(frame); - envDetectorDialog.setVisible(true); - } - }); - } -} diff --git a/designer-base/src/main/java/com/fr/design/utils/DevUtils.java b/designer-base/src/main/java/com/fr/design/utils/DevUtils.java new file mode 100644 index 0000000000..85918f84be --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/utils/DevUtils.java @@ -0,0 +1,73 @@ +package com.fr.design.utils; + +import com.fr.config.dao.DaoContext; +import com.fr.config.dao.impl.LocalClassHelperDao; +import com.fr.config.dao.impl.LocalEntityDao; +import com.fr.config.dao.impl.LocalXmlEntityDao; +import com.fr.design.ui.util.UIUtil; +import com.fr.env.detect.bean.DetectorResult; +import com.fr.env.detect.bean.DetectorType; +import com.fr.env.detect.bean.ExceptionLog; +import com.fr.env.detect.bean.ExceptionSolution; +import com.fr.env.detect.bean.ExceptionTips; +import com.fr.env.detect.ui.DetectorErrorDialog; +import com.fr.third.guava.collect.Lists; +import com.fr.transaction.Configurations; +import com.fr.transaction.LocalConfigurationHelper; + +import javax.swing.JFrame; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Toolkit; +import java.util.function.Consumer; + +/** + * 设计器的开发时工具 + * 帮助进行 UI 页面的调试 + *+ * created by Harrison on 2022/05/23 + **/ +public class DevUtils { + + private static void prepare() { + + DaoContext.setEntityDao(new LocalEntityDao()); + DaoContext.setClassHelperDao(new LocalClassHelperDao()); + DaoContext.setXmlEntityDao(new LocalXmlEntityDao()); + Configurations.setHelper(new LocalConfigurationHelper()); + } + + public static void show(Consumer consumer) { + + DesignUtils.initLookAndFeel(); + + UIUtil.invokeLaterIfNeeded(() -> { + + JFrame frame = new JFrame("dev-util"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize(); + frame.setSize(dimension); + + consumer.accept(frame); + + frame.setVisible(true); + }); + + } + + public static void main(String[] args) { + + DevUtils.prepare(); + DevUtils.show(new Consumer() { + @Override + public void accept(Frame frame) { + + DetectorErrorDialog dialog = new DetectorErrorDialog(frame, Lists.newArrayList(DetectorResult.exception(DetectorType.FINE_DB_PERMISSION, + ExceptionTips.create("test"), + ExceptionSolution.create("111test222", "www.baidu.com", null), + ExceptionLog.create("log")))); + dialog.setVisible(true); + } + }); + } +} diff --git a/designer-base/src/main/java/com/fr/design/utils/LinkStrUtil.java b/designer-base/src/main/java/com/fr/design/utils/LinkStrUtils.java similarity index 98% rename from designer-base/src/main/java/com/fr/design/utils/LinkStrUtil.java rename to designer-base/src/main/java/com/fr/design/utils/LinkStrUtils.java index 08cd2614fe..d02c9abff2 100644 --- a/designer-base/src/main/java/com/fr/design/utils/LinkStrUtil.java +++ b/designer-base/src/main/java/com/fr/design/utils/LinkStrUtils.java @@ -9,7 +9,7 @@ import java.awt.Font; /** * created by Harrison on 2022/05/24 **/ -public class LinkStrUtil { +public class LinkStrUtils { public static final UILabel LABEL = new UILabel();