From 233b692e038224475e244d984968766402aba2b1 Mon Sep 17 00:00:00 2001 From: vito Date: Thu, 14 May 2020 15:00:37 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-30068=E3=80=90=E5=9B=BD=E9=99=85?= =?UTF-8?q?=E5=8C=96=E3=80=91=E6=97=A5=E5=BF=97=E7=95=8C=E9=9D=A2=E9=83=A8?= =?UTF-8?q?=E5=88=86=E6=98=BE=E7=A4=BA=E9=81=AE=E6=8C=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../loghandler/DesignerLogHandler.java | 2 +- .../mainframe/loghandler/LogHandlerBar.java | 318 ++++++++---------- .../mainframe/loghandler/LogHandlerBarUI.java | 9 +- 3 files changed, 151 insertions(+), 178 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java index 5937770c4e..b935eb11ea 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java @@ -45,7 +45,7 @@ public class DesignerLogHandler { private final SimpleDateFormat LOG_SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - private static final int GAP_X = -150; + private static final int GAP_X = -75; private static final int INFO_GAP_Y = -60; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBar.java b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBar.java index ddb16de04c..f86cb22ef7 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBar.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBar.java @@ -2,183 +2,161 @@ package com.fr.design.mainframe.loghandler; import com.fr.base.BaseUtils; import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.ui.util.UIUtil; import javax.swing.*; import java.awt.*; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; -import java.util.concurrent.atomic.AtomicBoolean; -public class LogHandlerBar extends JPanel implements ItemSelectable { - - private static final long serialVersionUID = 1L; - private ItemListener listeners; - private UIButton clear; - private UIButton selectedall; - private UIButton set; - - private String text; - private int INFONUM = 0; - private int ERRORNUM = 0; - private int SERVERNUM = 0; - - private boolean isWithSerious; - - public LogHandlerBar() { - this(null); - } - - public LogHandlerBar(String text) { - this.setLayout(new CaptionLayout()); - this.setUI(new LogHandlerBarUI()); - this.text = text; - clear = new UIButton(BaseUtils.readIcon("com/fr/design/images/log/clear.png")); - clear.setMargin(null); - clear.setOpaque(false); - clear.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); - clear.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Clear_All")); - selectedall = new UIButton(BaseUtils.readIcon("com/fr/design/images/log/selectedall.png")); - selectedall.setMargin(null); - selectedall.setOpaque(false); - selectedall.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); - selectedall.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Select_All")); - set = new UIButton(BaseUtils.readIcon("com/fr/design/images/log/setting.png")); - set.setMargin(null); - set.setOpaque(false); - set.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); - set.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set")); - - this.add(clear); - this.add(selectedall); - this.add(set); - } - - public void clearMessage() { - INFONUM = ERRORNUM = SERVERNUM = 0; - repaint(); - } - - public boolean IsWithSerious() { - return isWithSerious; - } - - public void setWithSerious(boolean b) { - this.isWithSerious = b; - } - - public void infoAdd() { - INFONUM++; - repaint(); - } - - public void errorAdd() { - ERRORNUM++; - timerPaint(); - } - - public void serverAdd() { - SERVERNUM++; - timerPaint(); - } - - private AtomicBoolean painting = new AtomicBoolean(false); - - public void timerPaint() { - if(!painting.get()) { - painting.set(true); - repaint(); - painting.set(false); - } - } - - public int getInfo() { - return INFONUM; - } - - public int getError() { - return ERRORNUM; - } - - public int getServer() { - return SERVERNUM; - } - - public void addItemListener(ItemListener l) { - listeners = l; - } - - public void removeItemListener(ItemListener l) { - listeners = null; - } - - protected void fireItemStateChanged(ItemEvent e) { - listeners.itemStateChanged(e); - } - - public Object[] getSelectedObjects() { - return new Object[] { text }; - } - - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - repaint(); - } - - public void addClearListener(ActionListener l) { - clear.addActionListener(l); - } - - public void addSelectedListener(ActionListener l) { - selectedall.addActionListener(l); - } - - public void addSetListener(ActionListener l) { - set.addActionListener(l); - } - - private class CaptionLayout implements LayoutManager { - - @Override - public void addLayoutComponent(String name, Component comp) { - - } - - @Override - public void removeLayoutComponent(Component comp) { - - } - - @Override - public Dimension preferredLayoutSize(Container parent) { - return new Dimension(120, 24); - } +import static com.fr.design.i18n.Toolkit.i18nText; - @Override - public Dimension minimumLayoutSize(Container parent) { - return new Dimension(0, 0); - } - - @Override - public void layoutContainer(Container target) { - Insets insets = target.getInsets(); - int top = insets.top; - int right = target.getWidth() - insets.right; - clear.setBounds(right - CLEAR_OFFSET, top + TOP_OFFSET, clear.getPreferredSize().width, clear.getPreferredSize().height); - selectedall.setBounds(right - SELECT_OFFSET, top + TOP_OFFSET, selectedall.getPreferredSize().width, selectedall.getPreferredSize().height); - set.setBounds(right - SET_OFFSET, top + TOP_OFFSET, set.getPreferredSize().width, set.getPreferredSize().height); - - } - - private static final int CLEAR_OFFSET = 130; - private static final int TOP_OFFSET = 4; - private static final int SELECT_OFFSET = 100; - private static final int SET_OFFSET = 70; - } +public class LogHandlerBar extends JPanel implements ItemSelectable { + private static final long serialVersionUID = 1L; + private ItemListener listeners; + private UIButton clear; + private UIButton selectedall; + private UIButton set; + private UILabel normalLabel; + private UILabel alertLabel; + private UILabel seriouslyLabel; + + private String text; + private int INFONUM = 0; + private int ERRORNUM = 0; + private int SERVERNUM = 0; + private static final int FLOW_LAYOUT_HGAP = 10; + private static final int FLOW_LAYOUT_VGAP = 5; + + private boolean isWithSerious; + + public LogHandlerBar() { + this(null); + } + + public LogHandlerBar(String text) { + this.setLayout(new FlowLayout(FlowLayout.RIGHT, FLOW_LAYOUT_HGAP, FLOW_LAYOUT_VGAP)); + this.setUI(new LogHandlerBarUI()); + this.text = text; + clear = new UIButton(BaseUtils.readIcon("com/fr/design/images/log/clear.png")); + clear.setMargin(null); + clear.setOpaque(false); + clear.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + clear.setToolTipText(i18nText("Fine-Design_Basic_Clear_All")); + selectedall = new UIButton(BaseUtils.readIcon("com/fr/design/images/log/selectedall.png")); + selectedall.setMargin(null); + selectedall.setOpaque(false); + selectedall.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + selectedall.setToolTipText(i18nText("Fine-Design_Basic_Select_All")); + set = new UIButton(BaseUtils.readIcon("com/fr/design/images/log/setting.png")); + set.setMargin(null); + set.setOpaque(false); + set.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + set.setToolTipText(i18nText("Fine-Design_Report_Set")); + normalLabel = new UILabel(i18nText("Fine-Design_Basic_NNormal") + "(0)"); + alertLabel = new UILabel(i18nText("Fine-Design_Basic_Alert") + "(0)"); + seriouslyLabel = new UILabel(i18nText("Fine-Design_Basic_Seriously") + "(0)"); + + this.add(normalLabel); + this.add(alertLabel); + this.add(seriouslyLabel); + this.add(clear); + this.add(selectedall); + this.add(set); + } + + /** + * 更新日志数量统计标签 + */ + private void changeLabel() { + UIUtil.invokeLaterIfNeeded(new Runnable() { + @Override + public void run() { + normalLabel.setText(i18nText("Fine-Design_Basic_NNormal") + '(' + getInfo() + ')'); + alertLabel.setText(i18nText("Fine-Design_Basic_Alert") + '(' + getError() + ')'); + seriouslyLabel.setText(i18nText("Fine-Design_Basic_Seriously") + '(' + getServer() + ')'); + } + }); + } + + public void clearMessage() { + INFONUM = ERRORNUM = SERVERNUM = 0; + changeLabel(); + } + + public boolean IsWithSerious() { + return isWithSerious; + } + + public void setWithSerious(boolean b) { + this.isWithSerious = b; + } + + public void infoAdd() { + INFONUM++; + changeLabel(); + } + + public void errorAdd() { + ERRORNUM++; + changeLabel(); + } + + public void serverAdd() { + SERVERNUM++; + changeLabel(); + } + + public int getInfo() { + return INFONUM; + } + + public int getError() { + return ERRORNUM; + } + + public int getServer() { + return SERVERNUM; + } + + public void addItemListener(ItemListener l) { + listeners = l; + } + + public void removeItemListener(ItemListener l) { + listeners = null; + } + + protected void fireItemStateChanged(ItemEvent e) { + listeners.itemStateChanged(e); + } + + public Object[] getSelectedObjects() { + return new Object[]{text}; + } + + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + repaint(); + } + + public void addClearListener(ActionListener l) { + clear.addActionListener(l); + } + + public void addSelectedListener(ActionListener l) { + selectedall.addActionListener(l); + } + + public void addSetListener(ActionListener l) { + set.addActionListener(l); + } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBarUI.java b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBarUI.java index bbb9eed346..d118817081 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBarUI.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBarUI.java @@ -1,5 +1,7 @@ package com.fr.design.mainframe.loghandler; +import javax.swing.JComponent; +import javax.swing.plaf.ComponentUI; import java.awt.Color; import java.awt.Cursor; import java.awt.FontMetrics; @@ -11,9 +13,6 @@ import java.awt.event.FocusListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; -import javax.swing.JComponent; -import javax.swing.plaf.ComponentUI; - public class LogHandlerBarUI extends ComponentUI implements MouseListener, FocusListener { @@ -99,10 +98,6 @@ public class LogHandlerBarUI extends ComponentUI implements MouseListener, Focus if (button.getText() != null) { g.drawString(button.getText(), textLeadingGap, y); } - - g.drawString(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_NNormal") + '(' + button.getInfo() + ')', button.getWidth() - 310, y); - g.drawString(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert") + '(' + button.getError() + ')', button.getWidth() - 250, y); - g.drawString(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Seriously") + '(' + button.getServer() + ')', button.getWidth() - 190, y); } /**