From d2f600dabd2bb1fedac40551be0918c350ca51fc Mon Sep 17 00:00:00 2001 From: Yvan Date: Wed, 29 Jul 2020 13:36:12 +0800 Subject: [PATCH 01/12] =?UTF-8?q?=E4=B8=BB=E8=A6=81=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=EF=BC=9A=201.=E5=B0=86MacOS=E7=B3=BB=E7=BB=9F=E4=B8=8B?= =?UTF-8?q?=E7=9A=84=E7=B2=98=E8=B4=B4=E9=94=AE=E6=B7=BB=E5=8A=A0=E5=88=B0?= =?UTF-8?q?UIPasswordField=E7=9A=84InputMap=E4=B8=AD=EF=BC=8C=E4=BD=BF?= =?UTF-8?q?=E5=85=B6=E6=94=AF=E6=8C=81command+v=E4=B8=BA=E7=B2=98=E8=B4=B4?= =?UTF-8?q?=E9=94=AE=202.=E4=BF=AE=E6=94=B9=E5=AF=BC=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/gui/ipasswordfield/UIPassWordField.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/ipasswordfield/UIPassWordField.java b/designer-base/src/main/java/com/fr/design/gui/ipasswordfield/UIPassWordField.java index 0aad7ee91..2d2f1864d 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ipasswordfield/UIPassWordField.java +++ b/designer-base/src/main/java/com/fr/design/gui/ipasswordfield/UIPassWordField.java @@ -1,11 +1,12 @@ package com.fr.design.gui.ipasswordfield; +import com.fr.common.inputevent.InputEventBaseOnOS; import com.fr.design.constants.UIConstants; -import javax.swing.*; +import javax.swing.JPasswordField; import javax.swing.text.Document; -import java.awt.*; +import java.awt.Graphics; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -21,26 +22,31 @@ public class UIPassWordField extends JPasswordField { public UIPassWordField() { super(); + InputEventBaseOnOS.addBasicEditInputMap(this); addRollOverListener(); } public UIPassWordField(String text) { super(text); + InputEventBaseOnOS.addBasicEditInputMap(this); addRollOverListener(); } public UIPassWordField(int columns) { super(columns); + InputEventBaseOnOS.addBasicEditInputMap(this); addRollOverListener(); } public UIPassWordField(String text, int columns) { super(text, columns); + InputEventBaseOnOS.addBasicEditInputMap(this); addRollOverListener(); } public UIPassWordField(Document doc, String txt, int columns) { super(doc, txt, columns); + InputEventBaseOnOS.addBasicEditInputMap(this); addRollOverListener(); } @@ -69,4 +75,4 @@ public class UIPassWordField extends JPasswordField { super.paintBorder(g); } } -} \ No newline at end of file +} From b0fe3f124300f345323d2332a484c8a8073422ea Mon Sep 17 00:00:00 2001 From: Yvan Date: Wed, 29 Jul 2020 13:49:07 +0800 Subject: [PATCH 02/12] =?UTF-8?q?=E4=B8=BB=E8=A6=81=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=EF=BC=9A=201.=E5=B0=86MacOS=E7=B3=BB=E7=BB=9F=E4=B8=8B?= =?UTF-8?q?=E7=9A=84=E7=B2=98=E8=B4=B4=E9=94=AE=E6=B7=BB=E5=8A=A0=E5=88=B0?= =?UTF-8?q?UIPasswordField=E7=9A=84InputMap=E4=B8=AD=EF=BC=8C=E4=BD=BF?= =?UTF-8?q?=E5=85=B6=E6=94=AF=E6=8C=81command+v=E4=B8=BA=E7=B2=98=E8=B4=B4?= =?UTF-8?q?=E9=94=AE=202.=E4=BF=AE=E6=94=B9=E5=AF=BC=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/gui/ipasswordfield/UIPassWordField.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/ipasswordfield/UIPassWordField.java b/designer-base/src/main/java/com/fr/design/gui/ipasswordfield/UIPassWordField.java index 2d2f1864d..ba05141c9 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ipasswordfield/UIPassWordField.java +++ b/designer-base/src/main/java/com/fr/design/gui/ipasswordfield/UIPassWordField.java @@ -22,35 +22,31 @@ public class UIPassWordField extends JPasswordField { public UIPassWordField() { super(); - InputEventBaseOnOS.addBasicEditInputMap(this); addRollOverListener(); } public UIPassWordField(String text) { super(text); - InputEventBaseOnOS.addBasicEditInputMap(this); addRollOverListener(); } public UIPassWordField(int columns) { super(columns); - InputEventBaseOnOS.addBasicEditInputMap(this); addRollOverListener(); } public UIPassWordField(String text, int columns) { super(text, columns); - InputEventBaseOnOS.addBasicEditInputMap(this); addRollOverListener(); } public UIPassWordField(Document doc, String txt, int columns) { super(doc, txt, columns); - InputEventBaseOnOS.addBasicEditInputMap(this); addRollOverListener(); } private void addRollOverListener() { + InputEventBaseOnOS.addBasicEditInputMap(this); this.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { From a069f6ca9b0543ac647fbaccfcec9da88f58a18e Mon Sep 17 00:00:00 2001 From: Yvan Date: Wed, 29 Jul 2020 13:52:55 +0800 Subject: [PATCH 03/12] =?UTF-8?q?=E4=B8=BB=E8=A6=81=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=EF=BC=9A=201.=E5=B0=86MacOS=E7=B3=BB=E7=BB=9F=E4=B8=8B?= =?UTF-8?q?=E7=9A=84=E7=B2=98=E8=B4=B4=E9=94=AE=E6=B7=BB=E5=8A=A0=E5=88=B0?= =?UTF-8?q?UIPasswordField=E7=9A=84InputMap=E4=B8=AD=EF=BC=8C=E4=BD=BF?= =?UTF-8?q?=E5=85=B6=E6=94=AF=E6=8C=81command+v=E4=B8=BA=E7=B2=98=E8=B4=B4?= =?UTF-8?q?=E9=94=AE=202.=E4=BF=AE=E6=94=B9=E5=AF=BC=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/gui/itextfield/UITextField.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/itextfield/UITextField.java b/designer-base/src/main/java/com/fr/design/gui/itextfield/UITextField.java index 98823bee9..3f8b18908 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itextfield/UITextField.java +++ b/designer-base/src/main/java/com/fr/design/gui/itextfield/UITextField.java @@ -251,4 +251,4 @@ public class UITextField extends JTextField implements UIObserver, GlobalNameObs this.isBorderPainted = isBorderPainted; } -} \ No newline at end of file +} From 8f360741e38ca85f29b7181b9e50d162b30c08bc Mon Sep 17 00:00:00 2001 From: Yvan Date: Wed, 29 Jul 2020 14:05:01 +0800 Subject: [PATCH 04/12] =?UTF-8?q?=E4=B8=BB=E8=A6=81=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=EF=BC=9A=201.=E5=B0=86MacOS=E7=B3=BB=E7=BB=9F=E4=B8=8B?= =?UTF-8?q?=E7=9A=84=E7=B2=98=E8=B4=B4=E9=94=AE=E6=B7=BB=E5=8A=A0=E5=88=B0?= =?UTF-8?q?UIPasswordField=E7=9A=84InputMap=E4=B8=AD=EF=BC=8C=E4=BD=BF?= =?UTF-8?q?=E5=85=B6=E6=94=AF=E6=8C=81command+v=E4=B8=BA=E7=B2=98=E8=B4=B4?= =?UTF-8?q?=E9=94=AE=202.=E4=BF=AE=E6=94=B9=E5=AF=BC=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/gui/itextfield/UITextField.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/itextfield/UITextField.java b/designer-base/src/main/java/com/fr/design/gui/itextfield/UITextField.java index 3f8b18908..fd77b6f4d 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itextfield/UITextField.java +++ b/designer-base/src/main/java/com/fr/design/gui/itextfield/UITextField.java @@ -9,11 +9,20 @@ import com.fr.design.utils.gui.GUICoreUtils; import com.fr.stable.Constants; import com.fr.stable.StringUtils; -import javax.swing.*; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JTextField; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.text.Document; -import java.awt.*; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Insets; +import java.awt.LayoutManager; +import java.awt.RenderingHints; + /** * @author Jerry @@ -33,36 +42,31 @@ public class UITextField extends JTextField implements UIObserver, GlobalNameObs public UITextField() { super(); - InputEventBaseOnOS.addBasicEditInputMap(this); initListener(); } public UITextField(int columns) { super(columns); - InputEventBaseOnOS.addBasicEditInputMap(this); initListener(); } public UITextField(String text, int columns) { super(text, columns); - InputEventBaseOnOS.addBasicEditInputMap(this); initListener(); } public UITextField(String text) { super(text); - InputEventBaseOnOS.addBasicEditInputMap(this); - initListener(); } public UITextField(Document doc, String text, int columns) { super(doc, text, columns); - InputEventBaseOnOS.addBasicEditInputMap(this); initListener(); } protected void initListener() { + InputEventBaseOnOS.addBasicEditInputMap(this); if (shouldResponseChangeListener()) { getDocument().addDocumentListener(new DocumentListener() { @Override From eef74f18a39c2b927fdd27c9c554b9e962682565 Mon Sep 17 00:00:00 2001 From: Yvan Date: Wed, 29 Jul 2020 15:12:13 +0800 Subject: [PATCH 05/12] =?UTF-8?q?=E4=B8=BB=E8=A6=81=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=EF=BC=9A=201.=E5=B0=86MacOS=E7=B3=BB=E7=BB=9F=E4=B8=8B?= =?UTF-8?q?=E7=9A=84=E7=B2=98=E8=B4=B4=E9=94=AE=E6=B7=BB=E5=8A=A0=E5=88=B0?= =?UTF-8?q?UIPasswordField=E7=9A=84InputMap=E4=B8=AD=EF=BC=8C=E4=BD=BF?= =?UTF-8?q?=E5=85=B6=E6=94=AF=E6=8C=81command+v=E4=B8=BA=E7=B2=98=E8=B4=B4?= =?UTF-8?q?=E9=94=AE=202.=E4=BF=AE=E6=94=B9=E5=AF=BC=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/gui/ipasswordfield/UIPassWordField.java | 6 +++++- .../main/java/com/fr/design/gui/itextfield/UITextField.java | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/ipasswordfield/UIPassWordField.java b/designer-base/src/main/java/com/fr/design/gui/ipasswordfield/UIPassWordField.java index ba05141c9..2d2f1864d 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ipasswordfield/UIPassWordField.java +++ b/designer-base/src/main/java/com/fr/design/gui/ipasswordfield/UIPassWordField.java @@ -22,31 +22,35 @@ public class UIPassWordField extends JPasswordField { public UIPassWordField() { super(); + InputEventBaseOnOS.addBasicEditInputMap(this); addRollOverListener(); } public UIPassWordField(String text) { super(text); + InputEventBaseOnOS.addBasicEditInputMap(this); addRollOverListener(); } public UIPassWordField(int columns) { super(columns); + InputEventBaseOnOS.addBasicEditInputMap(this); addRollOverListener(); } public UIPassWordField(String text, int columns) { super(text, columns); + InputEventBaseOnOS.addBasicEditInputMap(this); addRollOverListener(); } public UIPassWordField(Document doc, String txt, int columns) { super(doc, txt, columns); + InputEventBaseOnOS.addBasicEditInputMap(this); addRollOverListener(); } private void addRollOverListener() { - InputEventBaseOnOS.addBasicEditInputMap(this); this.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { diff --git a/designer-base/src/main/java/com/fr/design/gui/itextfield/UITextField.java b/designer-base/src/main/java/com/fr/design/gui/itextfield/UITextField.java index fd77b6f4d..09db8974e 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itextfield/UITextField.java +++ b/designer-base/src/main/java/com/fr/design/gui/itextfield/UITextField.java @@ -42,31 +42,35 @@ public class UITextField extends JTextField implements UIObserver, GlobalNameObs public UITextField() { super(); + InputEventBaseOnOS.addBasicEditInputMap(this); initListener(); } public UITextField(int columns) { super(columns); + InputEventBaseOnOS.addBasicEditInputMap(this); initListener(); } public UITextField(String text, int columns) { super(text, columns); + InputEventBaseOnOS.addBasicEditInputMap(this); initListener(); } public UITextField(String text) { super(text); + InputEventBaseOnOS.addBasicEditInputMap(this); initListener(); } public UITextField(Document doc, String text, int columns) { super(doc, text, columns); + InputEventBaseOnOS.addBasicEditInputMap(this); initListener(); } protected void initListener() { - InputEventBaseOnOS.addBasicEditInputMap(this); if (shouldResponseChangeListener()) { getDocument().addDocumentListener(new DocumentListener() { @Override From a965e07ff90e52597b37d4b605a84de1ed084ae3 Mon Sep 17 00:00:00 2001 From: Yvan Date: Wed, 29 Jul 2020 17:46:59 +0800 Subject: [PATCH 06/12] =?UTF-8?q?=E4=B8=BB=E8=A6=81=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=EF=BC=9A=201.=E5=B0=86MacOS=E7=B3=BB=E7=BB=9F=E4=B8=8B?= =?UTF-8?q?=E7=9A=84=E7=B2=98=E8=B4=B4=E9=94=AE=E6=B7=BB=E5=8A=A0=E5=88=B0?= =?UTF-8?q?UIPasswordField=E7=9A=84InputMap=E4=B8=AD=EF=BC=8C=E4=BD=BF?= =?UTF-8?q?=E5=85=B6=E6=94=AF=E6=8C=81command+v=E4=B8=BA=E7=B2=98=E8=B4=B4?= =?UTF-8?q?=E9=94=AE=202.=E4=BF=AE=E6=94=B9=E5=AF=BC=E5=8C=85=203.?= =?UTF-8?q?=E5=B0=86=E6=9E=84=E9=80=A0=E6=96=B9=E6=B3=95=E9=87=8C=E7=9A=84?= =?UTF-8?q?=E5=85=AC=E7=94=A8=E6=93=8D=E4=BD=9C=E6=8A=BD=E5=8F=96=E5=87=BA?= =?UTF-8?q?=E6=9D=A5=E6=94=BE=E5=9C=A8init()=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/ipasswordfield/UIPassWordField.java | 19 +++++++++++-------- .../fr/design/gui/itextfield/UITextField.java | 19 +++++++++++-------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/ipasswordfield/UIPassWordField.java b/designer-base/src/main/java/com/fr/design/gui/ipasswordfield/UIPassWordField.java index 2d2f1864d..5e595643c 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ipasswordfield/UIPassWordField.java +++ b/designer-base/src/main/java/com/fr/design/gui/ipasswordfield/UIPassWordField.java @@ -22,30 +22,33 @@ public class UIPassWordField extends JPasswordField { public UIPassWordField() { super(); - InputEventBaseOnOS.addBasicEditInputMap(this); - addRollOverListener(); + init(); } public UIPassWordField(String text) { super(text); - InputEventBaseOnOS.addBasicEditInputMap(this); - addRollOverListener(); + init(); } public UIPassWordField(int columns) { super(columns); - InputEventBaseOnOS.addBasicEditInputMap(this); - addRollOverListener(); + init(); } public UIPassWordField(String text, int columns) { super(text, columns); - InputEventBaseOnOS.addBasicEditInputMap(this); - addRollOverListener(); + init(); } public UIPassWordField(Document doc, String txt, int columns) { super(doc, txt, columns); + init(); + } + + /** + * 每个构造方法里都需要做的一些操作 + */ + public void init() { InputEventBaseOnOS.addBasicEditInputMap(this); addRollOverListener(); } diff --git a/designer-base/src/main/java/com/fr/design/gui/itextfield/UITextField.java b/designer-base/src/main/java/com/fr/design/gui/itextfield/UITextField.java index 09db8974e..10edf9fe0 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itextfield/UITextField.java +++ b/designer-base/src/main/java/com/fr/design/gui/itextfield/UITextField.java @@ -42,30 +42,33 @@ public class UITextField extends JTextField implements UIObserver, GlobalNameObs public UITextField() { super(); - InputEventBaseOnOS.addBasicEditInputMap(this); - initListener(); + init(); } public UITextField(int columns) { super(columns); - InputEventBaseOnOS.addBasicEditInputMap(this); - initListener(); + init(); } public UITextField(String text, int columns) { super(text, columns); - InputEventBaseOnOS.addBasicEditInputMap(this); - initListener(); + init(); } public UITextField(String text) { super(text); - InputEventBaseOnOS.addBasicEditInputMap(this); - initListener(); + init(); } public UITextField(Document doc, String text, int columns) { super(doc, text, columns); + init(); + } + + /** + * 每个构造方法里都需要做的一些操作 + */ + public void init() { InputEventBaseOnOS.addBasicEditInputMap(this); initListener(); } From b8f22b901def58d22a472f38ada25b663afcc3b8 Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Wed, 29 Jul 2020 18:32:43 +0800 Subject: [PATCH 07/12] =?UTF-8?q?REPORT-29562=20=E3=80=90=E5=9B=BD?= =?UTF-8?q?=E9=99=85=E5=8C=96=E3=80=91=E6=9D=A1=E4=BB=B6=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E4=B8=AD=E8=B6=85=E7=BA=A7=E9=93=BE=E6=8E=A5=E5=92=8C=E6=8E=A7?= =?UTF-8?q?=E4=BB=B6=E4=BA=8B=E4=BB=B6=E6=96=87=E5=AD=97=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E4=B8=8D=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/condition/HyperlinkPane.java | 4 +++- .../java/com/fr/design/condition/WidgetHighlightPane.java | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/condition/HyperlinkPane.java b/designer-realize/src/main/java/com/fr/design/condition/HyperlinkPane.java index 643ad7890..594d2ed9c 100644 --- a/designer-realize/src/main/java/com/fr/design/condition/HyperlinkPane.java +++ b/designer-realize/src/main/java/com/fr/design/condition/HyperlinkPane.java @@ -15,6 +15,7 @@ import com.fr.report.cell.cellattr.highlight.HighlightAction; import com.fr.report.cell.cellattr.highlight.HyperlinkHighlightAction; import javax.swing.*; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -30,6 +31,7 @@ public class HyperlinkPane extends ConditionAttrSingleConditionPane { private static final int DIALOG_WIDTH = 700; private static final int DIALOG_HEIGHT = 400; + private static final Dimension WINDOW_CUSTOM_SIZE = new Dimension(720, 600); private Widget widget; private UIComboBox box; @@ -45,8 +48,7 @@ public class WidgetHighlightPane extends ConditionAttrSingleConditionPane Date: Wed, 29 Jul 2020 19:24:19 +0800 Subject: [PATCH 08/12] =?UTF-8?q?REPORT-29562=20=E3=80=90=E5=9B=BD?= =?UTF-8?q?=E9=99=85=E5=8C=96=E3=80=91=E6=9D=A1=E4=BB=B6=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E4=B8=AD=E8=B6=85=E7=BA=A7=E9=93=BE=E6=8E=A5=E5=92=8C=E6=8E=A7?= =?UTF-8?q?=E4=BB=B6=E4=BA=8B=E4=BB=B6=E6=96=87=E5=AD=97=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E4=B8=8D=E5=85=A8=20=E4=BF=AE=E6=94=B9import?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/condition/HyperlinkPane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-realize/src/main/java/com/fr/design/condition/HyperlinkPane.java b/designer-realize/src/main/java/com/fr/design/condition/HyperlinkPane.java index 594d2ed9c..1df652a84 100644 --- a/designer-realize/src/main/java/com/fr/design/condition/HyperlinkPane.java +++ b/designer-realize/src/main/java/com/fr/design/condition/HyperlinkPane.java @@ -15,7 +15,7 @@ import com.fr.report.cell.cellattr.highlight.HighlightAction; import com.fr.report.cell.cellattr.highlight.HyperlinkHighlightAction; import javax.swing.*; -import java.awt.*; +import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; From 383d6fc2316e5bcce2cac1f5e6f5126683433e97 Mon Sep 17 00:00:00 2001 From: "Yuan.Wang" <1536296691@qq.com> Date: Thu, 30 Jul 2020 10:14:28 +0800 Subject: [PATCH 09/12] =?UTF-8?q?REPORT-23260=20=E5=B0=86=E5=8E=9F?= =?UTF-8?q?=E6=9C=AC=E7=9A=84=E5=85=A8=E9=80=89=E6=A1=86=E6=9B=BF=E6=8D=A2?= =?UTF-8?q?=E4=B8=BA=E4=B8=89=E6=80=81=E7=9A=84CheckBox,=E5=B9=B6=E5=9C=A8?= =?UTF-8?q?=E4=B8=89=E6=80=81=E7=9A=84CheckBox=E4=B8=AD=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E7=9B=91=E5=90=AC=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/event/StateChangeListener.java | 9 +++++++++ .../fr/design/file/SaveSomeTemplatePane.java | 2 +- .../itree/checkboxtree/TristateCheckBox.java | 20 +++++++++++++++++-- 3 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/event/StateChangeListener.java diff --git a/designer-base/src/main/java/com/fr/design/event/StateChangeListener.java b/designer-base/src/main/java/com/fr/design/event/StateChangeListener.java new file mode 100644 index 000000000..9e4e655f3 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/event/StateChangeListener.java @@ -0,0 +1,9 @@ +package com.fr.design.event; + +/** + * @Author: Yuan.Wang + * @Date: 2020/7/29 + */ +public interface StateChangeListener { + public void stateChange(); +} diff --git a/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java b/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java index f271f23c0..be92b0473 100644 --- a/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java +++ b/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java @@ -1 +1 @@ -package com.fr.design.file; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilist.UIList; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.ProductConstants; import javax.swing.*; import java.awt.*; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.ArrayList; /** * Author : daisy * Date: 13-8-9 * Time: 下午3:41 */ public class SaveSomeTemplatePane extends BasicPane { private UICheckBox[] templateCheckBoxes = null; private BasicDialog dialog; private JPanel templatesChoosePane; private UIScrollPane scrollPane; private java.util.List> unSavedTemplate = new ArrayList>(); private boolean isAllSaved = false; //该变量用来判断是在关闭其他模板或是关闭设计器的时候,是否需要判断当前模板有没有保存 private boolean isJudgeCurrentEditingTemplate = true; public SaveSomeTemplatePane(boolean isNeedTojudgeCurrent) { this.setLayout(FRGUIPaneFactory.createBorderLayout()); if (this.dialog == null) { this.dialog = this.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { @Override public void doOk() { for (int i = 0; i < templateCheckBoxes.length; i++) { if (templateCheckBoxes[i].isSelected()) { saveSelectedTemplate(unSavedTemplate.get(i)); } } isAllSaved = true; } public void doCancel() { isAllSaved = false; } }); } UILabel tip = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Select_The_Source_To_Save")); this.add(tip, BorderLayout.NORTH); templatesChoosePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); UIScrollPane scrollPane = new UIScrollPane(templatesChoosePane); this.add(scrollPane, BorderLayout.CENTER); this.isJudgeCurrentEditingTemplate = isNeedTojudgeCurrent; } private void initTemplatesChoosePane() { templatesChoosePane.setBorder(BorderFactory.createTitledBorder("")); for (int i = 0; i < unSavedTemplate.size(); i++) { templateCheckBoxes[i] = new UICheckBox(unSavedTemplate.get(i).getEditingFILE().getName()); templateCheckBoxes[i].setSelected(true); } final UIList templatesList = new UIList(templateCheckBoxes); templatesList.setModel(new UnSeletedTemplateListDataMode()); templatesList.setCellRenderer(new UnSelectedListCellRender()); templatesList.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { super.mousePressed(e); int index = templatesList.getSelectedIndex(); if (index < 0) { return; } UICheckBox checkBox = (UICheckBox) templatesList.getModel().getElementAt(index); checkBox.setSelected(!checkBox.isSelected()); templatesList.repaint(); } }); final UICheckBox filenameCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Choose_All")); filenameCheckBox.setSelected(true); filenameCheckBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { boolean isSelected = filenameCheckBox.isSelected(); for (int i = 0; i < templatesList.getModel().getSize(); i++) { UICheckBox checkBox = (UICheckBox) templatesList.getModel().getElementAt(i); checkBox.setSelected(isSelected); } templatesList.repaint(); } }); templatesChoosePane.add(filenameCheckBox, BorderLayout.NORTH); templatesChoosePane.add(templatesList, BorderLayout.CENTER); } public boolean showSavePane() { populate(); //如果有未保存的文件 ,则跳出保存对话框,选择要存储的项目 if (!unSavedTemplate.isEmpty()) { dialog.setVisible(true); } else { isAllSaved = true; } return isAllSaved; } public void populate() { java.util.List> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); JTemplate currentTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); for (int i = 0; i < opendedTemplate.size(); i++) { if (isneedToAdd(opendedTemplate.get(i), currentTemplate)) { unSavedTemplate.add(opendedTemplate.get(i)); } } templateCheckBoxes = new UICheckBox[unSavedTemplate.size()]; initTemplatesChoosePane(); } private boolean isneedToAdd(JTemplate template, JTemplate currentTemplate) { //所有模板都判断是不是保存 if (isJudgeCurrentEditingTemplate) { return !template.isALLSaved(); } //当前编辑的模板不判断是否已经保存 if (ComparatorUtils.equals(template, currentTemplate)) { return false; } else { return !template.isALLSaved(); } } private void saveSelectedTemplate(JTemplate specifiedTemplate) { if (!specifiedTemplate.isSaved()) { specifiedTemplate.stopEditing(); specifiedTemplate.saveTemplate(); } FineLoggerFactory.getLogger().info( com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); } public int saveLastOneTemplate() { JTemplate specifiedTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); if (!specifiedTemplate.isALLSaved()) { specifiedTemplate.stopEditing(); int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (returnVal == JOptionPane.YES_OPTION && specifiedTemplate.saveTemplate()) { specifiedTemplate.saveTemplate(); FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); } return returnVal; } return JOptionPane.YES_OPTION; } protected String title4PopupWindow() { return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Save"); } private class UnSelectedListCellRender extends DefaultListCellRenderer { @Override public Component getListCellRendererComponent(JList list, Object value, int index, final boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); templateCheckBoxes[index] = (UICheckBox) value; templateCheckBoxes[index].setBackground(list.getBackground()); return templateCheckBoxes[index]; } } private class UnSeletedTemplateListDataMode extends AbstractListModel { @Override public int getSize() { return templateCheckBoxes.length; } @Override public UICheckBox getElementAt(int index) { if (index > getSize() - 1 || index < 0) { return null; } return templateCheckBoxes[index]; } } } \ No newline at end of file +package com.fr.design.file; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.event.StateChangeListener; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilist.UIList; import com.fr.design.gui.itree.checkboxtree.NullTristateCheckBox; import com.fr.design.gui.itree.checkboxtree.TristateCheckBox; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.ProductConstants; import javax.swing.*; import javax.swing.border.EmptyBorder; import java.awt.*; import java.awt.event.*; import java.util.ArrayList; /** * Author : daisy * Date: 13-8-9 * Time: 下午3:41 */ public class SaveSomeTemplatePane extends BasicPane { private UICheckBox[] templateCheckBoxes = null; private BasicDialog dialog; private JPanel templatesChoosePane; private UIScrollPane scrollPane; private java.util.List> unSavedTemplate = new ArrayList>(); private boolean isAllSaved = false; //该变量用来判断是在关闭其他模板或是关闭设计器的时候,是否需要判断当前模板有没有保存 private boolean isJudgeCurrentEditingTemplate = true; public SaveSomeTemplatePane(boolean isNeedTojudgeCurrent) { this.setLayout(FRGUIPaneFactory.createBorderLayout()); if (this.dialog == null) { this.dialog = this.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { @Override public void doOk() { for (int i = 0; i < templateCheckBoxes.length; i++) { if (templateCheckBoxes[i].isSelected()) { saveSelectedTemplate(unSavedTemplate.get(i)); } } isAllSaved = true; } public void doCancel() { isAllSaved = false; } }); } UILabel tip = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Select_The_Source_To_Save")); this.add(tip, BorderLayout.NORTH); templatesChoosePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); UIScrollPane scrollPane = new UIScrollPane(templatesChoosePane); this.add(scrollPane, BorderLayout.CENTER); this.isJudgeCurrentEditingTemplate = isNeedTojudgeCurrent; } private void initTemplatesChoosePane() { templatesChoosePane.setBorder(BorderFactory.createTitledBorder("")); for (int i = 0; i < unSavedTemplate.size(); i++) { templateCheckBoxes[i] = new UICheckBox(unSavedTemplate.get(i).getEditingFILE().getName()); templateCheckBoxes[i].setSelected(true); } final UIList templatesList = new UIList(templateCheckBoxes); templatesList.setModel(new UnSeletedTemplateListDataMode()); templatesList.setCellRenderer(new UnSelectedListCellRender()); final TristateCheckBox chooseAllCheckBox = new NullTristateCheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Choose_All")); chooseAllCheckBox.setState(TristateCheckBox.SELECTED); //取消chooseAllCheckBox的焦点事件监听,因为默认的焦点事件监听中失焦时会改变chooseAllCheckBox的状态 chooseAllCheckBox.setFocusable(false); chooseAllCheckBox.addStateChangeListener(new StateChangeListener() { @Override public void stateChange() { if (chooseAllCheckBox.getState() == TristateCheckBox.DO_NOT_CARE) { return; } boolean isSelected = chooseAllCheckBox.isSelected(); for (int i = 0; i < templatesList.getModel().getSize(); i++) { UICheckBox checkBox = (UICheckBox) templatesList.getModel().getElementAt(i); checkBox.setSelected(isSelected); } templatesList.repaint(); } }); templatesList.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { super.mousePressed(e); int index = templatesList.getSelectedIndex(); if (index < 0) { return; } UICheckBox checkBox = (UICheckBox) templatesList.getModel().getElementAt(index); checkBox.setSelected(!checkBox.isSelected()); //根据templateCheckBoxes中的选择情况来更新全选框的状态 int selectedCount = calculateSelectedNum(); if (selectedCount == 0) { chooseAllCheckBox.setState(TristateCheckBox.NOT_SELECTED); } else if (selectedCount == templateCheckBoxes.length) { chooseAllCheckBox.setState(TristateCheckBox.SELECTED); } else { chooseAllCheckBox.setState(TristateCheckBox.DO_NOT_CARE); } templatesList.repaint(); } }); templatesChoosePane.add(chooseAllCheckBox, BorderLayout.NORTH); templatesChoosePane.add(templatesList, BorderLayout.CENTER); } /** * 获取templateCheckBoxes中状态为选中状态的CheckBox数量 * */ private int calculateSelectedNum() { int count = 0; for (UICheckBox checkBox : templateCheckBoxes) { if (checkBox.isSelected()) { count++; } } return count; } public boolean showSavePane() { populate(); //如果有未保存的文件 ,则跳出保存对话框,选择要存储的项目 if (!unSavedTemplate.isEmpty()) { dialog.setVisible(true); } else { isAllSaved = true; } return isAllSaved; } public void populate() { java.util.List> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); JTemplate currentTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); for (int i = 0; i < opendedTemplate.size(); i++) { if (isneedToAdd(opendedTemplate.get(i), currentTemplate)) { unSavedTemplate.add(opendedTemplate.get(i)); } } templateCheckBoxes = new UICheckBox[unSavedTemplate.size()]; initTemplatesChoosePane(); } private boolean isneedToAdd(JTemplate template, JTemplate currentTemplate) { //所有模板都判断是不是保存 if (isJudgeCurrentEditingTemplate) { return !template.isALLSaved(); } //当前编辑的模板不判断是否已经保存 if (ComparatorUtils.equals(template, currentTemplate)) { return false; } else { return !template.isALLSaved(); } } private void saveSelectedTemplate(JTemplate specifiedTemplate) { if (!specifiedTemplate.isSaved()) { specifiedTemplate.stopEditing(); specifiedTemplate.saveTemplate(); } FineLoggerFactory.getLogger().info( com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); } public int saveLastOneTemplate() { JTemplate specifiedTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); if (!specifiedTemplate.isALLSaved()) { specifiedTemplate.stopEditing(); int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (returnVal == JOptionPane.YES_OPTION && specifiedTemplate.saveTemplate()) { specifiedTemplate.saveTemplate(); FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); } return returnVal; } return JOptionPane.YES_OPTION; } protected String title4PopupWindow() { return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Save"); } private class UnSelectedListCellRender extends DefaultListCellRenderer { @Override public Component getListCellRendererComponent(JList list, Object value, int index, final boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); templateCheckBoxes[index] = (UICheckBox) value; templateCheckBoxes[index].setBackground(list.getBackground()); return templateCheckBoxes[index]; } } private class UnSeletedTemplateListDataMode extends AbstractListModel { @Override public int getSize() { return templateCheckBoxes.length; } @Override public UICheckBox getElementAt(int index) { if (index > getSize() - 1 || index < 0) { return null; } return templateCheckBoxes[index]; } } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/checkboxtree/TristateCheckBox.java b/designer-base/src/main/java/com/fr/design/gui/itree/checkboxtree/TristateCheckBox.java index a4a59ade2..b821b0731 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itree/checkboxtree/TristateCheckBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/itree/checkboxtree/TristateCheckBox.java @@ -1,6 +1,7 @@ package com.fr.design.gui.itree.checkboxtree; import com.fr.design.constants.UIConstants; +import com.fr.design.event.StateChangeListener; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.stable.Constants; @@ -75,6 +76,8 @@ public class TristateCheckBox extends UICheckBox { private final TristateDecorator model; + public StateChangeListener stateChangeListener; + public TristateCheckBox(String text, Icon icon, State initial) { super(text, icon); setUI(new TristateCheckBoxUI()); @@ -83,7 +86,7 @@ public class TristateCheckBox extends UICheckBox { @Override public void mousePressed(MouseEvent e) { grabFocus(); - model.setState(getNextState(model.getState())); + setState(getNextState(model.getState())); } }); // Reset the keyboard action map @@ -92,7 +95,7 @@ public class TristateCheckBox extends UICheckBox { @Override public void actionPerformed(ActionEvent e) { grabFocus(); - model.setState(getNextState(model.getState())); + setState(getNextState(model.getState())); } }); map.put("released", null); @@ -125,12 +128,20 @@ public class TristateCheckBox extends UICheckBox { public void addMouseListener(MouseListener l) { } + public void addStateChangeListener(StateChangeListener stateChangeListener) { + this.stateChangeListener=stateChangeListener; + } + /** * Set the new state to either SELECTED, NOT_SELECTED or * DO_NOT_CARE. If state == null, it is treated as DO_NOT_CARE. */ public void setState(State state) { + State old = getState(); model.setState(state); + if (old != state) { + fireBoxStateChanged(); + } } /** @@ -141,6 +152,11 @@ public class TristateCheckBox extends UICheckBox { return model.getState(); } + public void fireBoxStateChanged() { + if (stateChangeListener != null) { + stateChangeListener.stateChange(); + } + } /** * Exactly which Design Pattern is this? Is it an Adapter, From e33af330cafa8096e1e726fceaa7fa3c33b49fe4 Mon Sep 17 00:00:00 2001 From: "Yuan.Wang" <1536296691@qq.com> Date: Thu, 30 Jul 2020 10:35:45 +0800 Subject: [PATCH 10/12] =?UTF-8?q?REPORT-35463=20=E6=B7=BB=E5=8A=A0BUG?= =?UTF-8?q?=E9=9C=80=E6=B1=82=E5=8F=8D=E9=A6=88=E3=80=81=E6=8A=80=E6=9C=AF?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=8F=9C=E5=8D=95=E9=A1=B9=EF=BC=8C=E8=8B=B1?= =?UTF-8?q?=E6=96=87=E5=B8=AE=E5=8A=A9=E8=8F=9C=E5=8D=95=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=8A=80=E6=9C=AF=E6=94=AF=E6=8C=81=EF=BC=8C=E9=9F=A9=E6=96=87?= =?UTF-8?q?=E3=80=81=E6=97=A5=E6=96=87=E5=B8=AE=E5=8A=A9=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=B8=AE=E5=8A=A9=E6=96=87=E6=A1=A3=EF=BC=8C?= =?UTF-8?q?=E5=8F=B0=E6=B9=BE=E7=A4=BE=E5=8C=BA=E8=8F=9C=E5=8D=95BUG=20?= =?UTF-8?q?=E4=B8=8E=E9=9C=80=E6=B1=82=E5=8F=8D=E9=A6=88=E5=90=88=E4=B8=BA?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=EF=BC=8C=E6=96=B0=E5=A2=9E=E6=8A=80=E6=9C=AF?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=8F=9C=E5=8D=95=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions/community/BugNeedAction.java | 48 +++++++++++++++++ .../actions/community/TechSupportAction.java | 49 ++++++++++++++++++ .../fr/design/locale/impl/BugNeedMark.java | 29 +++++++++++ .../design/locale/impl/TechSupportMark.java | 30 +++++++++++ .../mainframe/toolbar/ToolBarMenuDock.java | 32 +++++++----- .../com/fr/design/images/bbs/support.png | Bin 0 -> 385 bytes 6 files changed, 174 insertions(+), 14 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/actions/community/BugNeedAction.java create mode 100644 designer-base/src/main/java/com/fr/design/actions/community/TechSupportAction.java create mode 100644 designer-base/src/main/java/com/fr/design/locale/impl/BugNeedMark.java create mode 100644 designer-base/src/main/java/com/fr/design/locale/impl/TechSupportMark.java create mode 100644 designer-base/src/main/resources/com/fr/design/images/bbs/support.png diff --git a/designer-base/src/main/java/com/fr/design/actions/community/BugNeedAction.java b/designer-base/src/main/java/com/fr/design/actions/community/BugNeedAction.java new file mode 100644 index 000000000..17ee23b53 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/actions/community/BugNeedAction.java @@ -0,0 +1,48 @@ +package com.fr.design.actions.community; + +import com.fr.base.BaseUtils; +import com.fr.design.actions.UpdateAction; +import com.fr.design.locale.impl.BugNeedMark; +import com.fr.design.menu.MenuKeySet; +import com.fr.design.utils.BrowseUtils; +import com.fr.general.locale.LocaleCenter; +import com.fr.general.locale.LocaleMark; + +import javax.swing.*; +import java.awt.event.ActionEvent; + +/** + * @Author: Yuan.Wang + * @Date: 2020/7/28 + */ +public class BugNeedAction extends UpdateAction { + public BugNeedAction() { + this.setMenuKeySet(BugAndNeed); + this.setName(getMenuKeySet().getMenuName()); + this.setMnemonic(getMenuKeySet().getMnemonic()); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/bbs/need.png")); + } + + @Override + public void actionPerformed(ActionEvent e) { + LocaleMark localeMark = LocaleCenter.getMark(BugNeedMark.class); + BrowseUtils.browser(localeMark.getValue()); + } + + public static final MenuKeySet BugAndNeed = new MenuKeySet() { + @Override + public char getMnemonic() { + return 0; + } + + @Override + public String getMenuName() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Community_BugAndNeed"); + } + + @Override + public KeyStroke getKeyStroke() { + return null; + } + }; +} diff --git a/designer-base/src/main/java/com/fr/design/actions/community/TechSupportAction.java b/designer-base/src/main/java/com/fr/design/actions/community/TechSupportAction.java new file mode 100644 index 000000000..9c8067138 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/actions/community/TechSupportAction.java @@ -0,0 +1,49 @@ +package com.fr.design.actions.community; + +import com.fr.base.BaseUtils; +import com.fr.design.actions.UpdateAction; +import com.fr.design.locale.impl.TechSupportMark; +import com.fr.design.menu.MenuKeySet; +import com.fr.design.utils.BrowseUtils; +import com.fr.general.locale.LocaleCenter; +import com.fr.general.locale.LocaleMark; + +import javax.swing.*; +import java.awt.event.ActionEvent; + +/** + * @Author: Yuan.Wang + * @Date: 2020/7/28 + */ +public class TechSupportAction extends UpdateAction { + public TechSupportAction() { + this.setMenuKeySet(TechSupport); + this.setName(getMenuKeySet().getMenuName()); + this.setMnemonic(getMenuKeySet().getMnemonic()); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/bbs/support.png")); + } + + @Override + public void actionPerformed(ActionEvent e) { + LocaleMark localeMark = LocaleCenter.getMark(TechSupportMark.class); + String str=localeMark.getValue(); + BrowseUtils.browser(localeMark.getValue()); + } + + public static final MenuKeySet TechSupport = new MenuKeySet() { + @Override + public char getMnemonic() { + return 0; + } + + @Override + public String getMenuName() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Community_TechSupport"); + } + + @Override + public KeyStroke getKeyStroke() { + return null; + } + }; +} diff --git a/designer-base/src/main/java/com/fr/design/locale/impl/BugNeedMark.java b/designer-base/src/main/java/com/fr/design/locale/impl/BugNeedMark.java new file mode 100644 index 000000000..41822d19c --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/locale/impl/BugNeedMark.java @@ -0,0 +1,29 @@ +package com.fr.design.locale.impl; + +import com.fr.general.CloudCenter; +import com.fr.general.GeneralContext; +import com.fr.general.locale.LocaleMark; + +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +/** + * @Author: Yuan.Wang + * @Date: 2020/7/29 + */ +public class BugNeedMark implements LocaleMark { + private Map map = new HashMap<>(); + private static final String TW_BUG_AND_NEEDS = CloudCenter.getInstance().acquireUrlByKind("bbs.bug.needs.zh_TW"); + + public BugNeedMark() { + map.put(Locale.TAIWAN, TW_BUG_AND_NEEDS); + } + + @Override + public String getValue() { + String result = map.get(GeneralContext.getLocale()); + return result == null ? TW_BUG_AND_NEEDS : result; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/locale/impl/TechSupportMark.java b/designer-base/src/main/java/com/fr/design/locale/impl/TechSupportMark.java new file mode 100644 index 000000000..6d15764b5 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/locale/impl/TechSupportMark.java @@ -0,0 +1,30 @@ +package com.fr.design.locale.impl; + +import com.fr.general.CloudCenter; +import com.fr.general.GeneralContext; +import com.fr.general.locale.LocaleMark; + +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +/** + * @Author: Yuan.Wang + * @Date: 2020/7/29 + */ +public class TechSupportMark implements LocaleMark { + private Map map = new HashMap<>(); + private static final String EN_TECH_SUPPORT = CloudCenter.getInstance().acquireUrlByKind("bbs.tech.support.en_US"); + private static final String TW_TECH_SUPPORT = CloudCenter.getInstance().acquireUrlByKind("bbs.tech.support.zh_TW"); + + public TechSupportMark() { + map.put(Locale.US, EN_TECH_SUPPORT); + map.put(Locale.TAIWAN, TW_TECH_SUPPORT); + } + + @Override + public String getValue() { + String result = map.get(GeneralContext.getLocale()); + return result == null ? EN_TECH_SUPPORT : result; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index bc4b85ced..cc6e0fc48 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -9,15 +9,7 @@ import com.fr.design.DesignState; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.UpdateAction; -import com.fr.design.actions.community.BBSAction; -import com.fr.design.actions.community.BugAction; -import com.fr.design.actions.community.CenterAction; -import com.fr.design.actions.community.FacebookFansAction; -import com.fr.design.actions.community.NeedAction; -import com.fr.design.actions.community.QuestionAction; -import com.fr.design.actions.community.SignAction; -import com.fr.design.actions.community.TechSolutionAction; -import com.fr.design.actions.community.VideoAction; +import com.fr.design.actions.community.*; import com.fr.design.actions.file.CloseCurrentTemplateAction; import com.fr.design.actions.file.ExitDesignerAction; import com.fr.design.actions.file.OpenRecentReportMenuDef; @@ -529,9 +521,15 @@ public abstract class ToolBarMenuDock { */ public ShortCut[] createHelpShortCuts() { final java.util.List shortCuts = new ArrayList(); - // 英文,把 video 和帮助文档放到 Help 下面 - if (GeneralContext.getLocale().equals(Locale.US)) { + + Locale locale = GeneralContext.getLocale(); + // 英文,把Video和技术支持放到 Help 下面 + if (locale.equals(Locale.US)) { shortCuts.add(new VideoAction()); + shortCuts.add(new TechSupportAction()); + } + // 英文、韩文、日文,把帮助文档放到 Help 下面 + if (locale.equals(Locale.US) || locale.equals(Locale.KOREA) || locale.equals(Locale.JAPAN)) { shortCuts.add(new TutorialAction()); } //远程不使用更新升级,产品演示 @@ -576,9 +574,15 @@ public abstract class ToolBarMenuDock { shortCuts.add(new TechSolutionAction()); shortCuts.add(SeparatorDef.DEFAULT); - - shortCuts.add(new BugAction()); - shortCuts.add(new NeedAction()); + + //台湾,将BUG和需求合并成一个,同时新增技术支持 + if (GeneralContext.getLocale().equals(Locale.TAIWAN)) { + shortCuts.add(new TechSupportAction()); + shortCuts.add(new BugNeedAction()); + } else { + shortCuts.add(new BugAction()); + shortCuts.add(new NeedAction()); + } shortCuts.add(SeparatorDef.DEFAULT); diff --git a/designer-base/src/main/resources/com/fr/design/images/bbs/support.png b/designer-base/src/main/resources/com/fr/design/images/bbs/support.png new file mode 100644 index 0000000000000000000000000000000000000000..a19c313c676f90bf185735978443d6b19c2f95c0 GIT binary patch literal 385 zcmV-{0e=38P)F?|{7< z3nD5>GcfQI2!4PzXY8w-UPBYHaZ+OYy=R}#cL=o=MbWV(8WX_@QwRKgBEqvloMc({ zR+EEKAW0Gvgu_W`X-bGM2H|3VZ?`X2V!?$Mo#u!|4T3PdMS@df@RE1>Qd})}*0+`( z3E`>8^E<^|fnYQmVp%@y^m>CdO+S>Z+c=I7zZZ)+bvjqYZ1yU=YX_J1h5+u{l0_`M z=vaR(v8>g3kj}csOjl6*-|3LfRn--TCw{an?Rzi?9bU}yYBnlljyDHjokDA?q#(Y( zR&3(FX5&iygunX#U%(Af+V#)X)PAF;k!Y&q;Z+A7=3Kw%wrf>=RlrYBQWCe}%8UK= fV3hO|+dB9GN6&QJ`0wdo00000NkvXXu0mjf(9x$| literal 0 HcmV?d00001 From 9f8e753b186af15aaacc472f180e3514195646a2 Mon Sep 17 00:00:00 2001 From: "Yuan.Wang" <1536296691@qq.com> Date: Thu, 30 Jul 2020 14:27:52 +0800 Subject: [PATCH 11/12] =?UTF-8?q?REPORT-35463=20=E4=BD=BF=E7=94=A8LocaleAc?= =?UTF-8?q?tion=E5=8C=85=E8=A3=85action?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/locale/impl/SupportLocaleImpl.java | 107 ++++++++++++++++++ .../mainframe/toolbar/ToolBarMenuDock.java | 85 +++++++++++--- 2 files changed, 174 insertions(+), 18 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/locale/impl/SupportLocaleImpl.java b/designer-base/src/main/java/com/fr/design/locale/impl/SupportLocaleImpl.java index c6c1b1f28..e192336d6 100644 --- a/designer-base/src/main/java/com/fr/design/locale/impl/SupportLocaleImpl.java +++ b/designer-base/src/main/java/com/fr/design/locale/impl/SupportLocaleImpl.java @@ -10,6 +10,7 @@ import java.util.Set; * 某些国际化环境支持的操作 * 需要增加/删除支持的语言 统一在这里修改 无须改动业务代码 * 后续有新的不同语言下的差异操作 添加新的枚举 + * * @author Hades * @date 2019/6/24 */ @@ -50,6 +51,112 @@ public enum SupportLocaleImpl implements SupportLocale { set.add(Locale.KOREA); return set; } + }, + + /** + * BUG反馈 + */ + BUG { + @Override + public Set support() { + Set set = new HashSet(); + set.add(Locale.CHINA); + set.add(Locale.US); + set.add(Locale.JAPAN); + set.add(Locale.KOREA); + return set; + } + }, + + /** + * 需求反馈 + */ + NEED { + @Override + public Set support() { + Set set = new HashSet(); + set.add(Locale.CHINA); + set.add(Locale.US); + set.add(Locale.JAPAN); + set.add(Locale.KOREA); + return set; + } + }, + + /** + * BUG需求反馈 + */ + BUG_AND_NEED { + @Override + public Set support() { + Set set = new HashSet(); + set.add(Locale.TAIWAN); + return set; + } + }, + + /** + * 视频 + */ + VIDEO { + @Override + public Set support() { + Set set = new HashSet(); + set.add(Locale.US); + return set; + } + }, + + /** + * 技术支持-帮助菜单下 + */ + TECH_SUPPORT_HELP { + @Override + public Set support() { + Set set = new HashSet(); + set.add(Locale.US); + return set; + } + }, + + /** + * 技术支持-社区菜单下 + */ + TECH_SUPPORT_COMMUNITY { + @Override + public Set support() { + Set set = new HashSet(); + set.add(Locale.TAIWAN); + return set; + } + }, + + /** + * 帮助文档-帮助菜单下 + */ + TUTORIAL_HELP { + @Override + public Set support() { + Set set = new HashSet(); + set.add(Locale.CHINA); + set.add(Locale.TAIWAN); + return set; + } + }, + + /** + * 帮助文档-社区菜单下 + */ + TUTORIAL_COMMUNITY { + @Override + public Set support() { + Set set = new HashSet(); + set.add(Locale.US); + set.add(Locale.KOREA); + set.add(Locale.JAPAN); + return set; + } } + } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index cc6e0fc48..775b03747 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -9,7 +9,17 @@ import com.fr.design.DesignState; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.UpdateAction; -import com.fr.design.actions.community.*; +import com.fr.design.actions.community.BBSAction; +import com.fr.design.actions.community.BugAction; +import com.fr.design.actions.community.BugNeedAction; +import com.fr.design.actions.community.CenterAction; +import com.fr.design.actions.community.FacebookFansAction; +import com.fr.design.actions.community.NeedAction; +import com.fr.design.actions.community.QuestionAction; +import com.fr.design.actions.community.SignAction; +import com.fr.design.actions.community.TechSolutionAction; +import com.fr.design.actions.community.TechSupportAction; +import com.fr.design.actions.community.VideoAction; import com.fr.design.actions.file.CloseCurrentTemplateAction; import com.fr.design.actions.file.ExitDesignerAction; import com.fr.design.actions.file.OpenRecentReportMenuDef; @@ -523,15 +533,28 @@ public abstract class ToolBarMenuDock { final java.util.List shortCuts = new ArrayList(); Locale locale = GeneralContext.getLocale(); - // 英文,把Video和技术支持放到 Help 下面 - if (locale.equals(Locale.US)) { - shortCuts.add(new VideoAction()); - shortCuts.add(new TechSupportAction()); - } - // 英文、韩文、日文,把帮助文档放到 Help 下面 - if (locale.equals(Locale.US) || locale.equals(Locale.KOREA) || locale.equals(Locale.JAPAN)) { - shortCuts.add(new TutorialAction()); - } + + LocaleCenter.buildAction(new LocaleAction() { + @Override + public void execute() { + shortCuts.add(new VideoAction()); + } + }, SupportLocaleImpl.VIDEO); + + LocaleCenter.buildAction(new LocaleAction() { + @Override + public void execute() { + shortCuts.add(new TutorialAction()); + } + }, SupportLocaleImpl.TUTORIAL_HELP); + + LocaleCenter.buildAction(new LocaleAction() { + @Override + public void execute() { + shortCuts.add(new TechSupportAction()); + } + }, SupportLocaleImpl.TECH_SUPPORT_HELP); + //远程不使用更新升级,产品演示 if (WorkContext.getCurrent().isLocal()) { shortCuts.add(new WebDemoAction()); @@ -575,14 +598,40 @@ public abstract class ToolBarMenuDock { shortCuts.add(SeparatorDef.DEFAULT); - //台湾,将BUG和需求合并成一个,同时新增技术支持 - if (GeneralContext.getLocale().equals(Locale.TAIWAN)) { - shortCuts.add(new TechSupportAction()); - shortCuts.add(new BugNeedAction()); - } else { - shortCuts.add(new BugAction()); - shortCuts.add(new NeedAction()); - } + LocaleCenter.buildAction(new LocaleAction() { + @Override + public void execute() { + shortCuts.add(new BugAction()); + } + }, SupportLocaleImpl.BUG); + + LocaleCenter.buildAction(new LocaleAction() { + @Override + public void execute() { + shortCuts.add(new NeedAction()); + } + }, SupportLocaleImpl.NEED); + + LocaleCenter.buildAction(new LocaleAction() { + @Override + public void execute() { + shortCuts.add(new BugNeedAction()); + } + }, SupportLocaleImpl.BUG_AND_NEED); + + LocaleCenter.buildAction(new LocaleAction() { + @Override + public void execute() { + shortCuts.add(new TechSupportAction()); + } + }, SupportLocaleImpl.TECH_SUPPORT_COMMUNITY); + + LocaleCenter.buildAction(new LocaleAction() { + @Override + public void execute() { + shortCuts.add(new TutorialAction()); + } + }, SupportLocaleImpl.TUTORIAL_COMMUNITY); shortCuts.add(SeparatorDef.DEFAULT); From cc9878b8ff5f92054dad3b9a9f8bcfa90ff884e4 Mon Sep 17 00:00:00 2001 From: "Yuan.Wang" <1536296691@qq.com> Date: Thu, 30 Jul 2020 14:39:23 +0800 Subject: [PATCH 12/12] =?UTF-8?q?REPORT-35463=20=E4=BF=AE=E6=94=B9SaveSome?= =?UTF-8?q?TemplatePane=E7=9A=84=E6=8D=A2=E8=A1=8C=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/file/SaveSomeTemplatePane.java | 245 +++++++++++++++++- 1 file changed, 244 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java b/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java index be92b0473..e331d296e 100644 --- a/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java +++ b/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java @@ -1 +1,244 @@ -package com.fr.design.file; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.event.StateChangeListener; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilist.UIList; import com.fr.design.gui.itree.checkboxtree.NullTristateCheckBox; import com.fr.design.gui.itree.checkboxtree.TristateCheckBox; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.ProductConstants; import javax.swing.*; import javax.swing.border.EmptyBorder; import java.awt.*; import java.awt.event.*; import java.util.ArrayList; /** * Author : daisy * Date: 13-8-9 * Time: 下午3:41 */ public class SaveSomeTemplatePane extends BasicPane { private UICheckBox[] templateCheckBoxes = null; private BasicDialog dialog; private JPanel templatesChoosePane; private UIScrollPane scrollPane; private java.util.List> unSavedTemplate = new ArrayList>(); private boolean isAllSaved = false; //该变量用来判断是在关闭其他模板或是关闭设计器的时候,是否需要判断当前模板有没有保存 private boolean isJudgeCurrentEditingTemplate = true; public SaveSomeTemplatePane(boolean isNeedTojudgeCurrent) { this.setLayout(FRGUIPaneFactory.createBorderLayout()); if (this.dialog == null) { this.dialog = this.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { @Override public void doOk() { for (int i = 0; i < templateCheckBoxes.length; i++) { if (templateCheckBoxes[i].isSelected()) { saveSelectedTemplate(unSavedTemplate.get(i)); } } isAllSaved = true; } public void doCancel() { isAllSaved = false; } }); } UILabel tip = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Select_The_Source_To_Save")); this.add(tip, BorderLayout.NORTH); templatesChoosePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); UIScrollPane scrollPane = new UIScrollPane(templatesChoosePane); this.add(scrollPane, BorderLayout.CENTER); this.isJudgeCurrentEditingTemplate = isNeedTojudgeCurrent; } private void initTemplatesChoosePane() { templatesChoosePane.setBorder(BorderFactory.createTitledBorder("")); for (int i = 0; i < unSavedTemplate.size(); i++) { templateCheckBoxes[i] = new UICheckBox(unSavedTemplate.get(i).getEditingFILE().getName()); templateCheckBoxes[i].setSelected(true); } final UIList templatesList = new UIList(templateCheckBoxes); templatesList.setModel(new UnSeletedTemplateListDataMode()); templatesList.setCellRenderer(new UnSelectedListCellRender()); final TristateCheckBox chooseAllCheckBox = new NullTristateCheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Choose_All")); chooseAllCheckBox.setState(TristateCheckBox.SELECTED); //取消chooseAllCheckBox的焦点事件监听,因为默认的焦点事件监听中失焦时会改变chooseAllCheckBox的状态 chooseAllCheckBox.setFocusable(false); chooseAllCheckBox.addStateChangeListener(new StateChangeListener() { @Override public void stateChange() { if (chooseAllCheckBox.getState() == TristateCheckBox.DO_NOT_CARE) { return; } boolean isSelected = chooseAllCheckBox.isSelected(); for (int i = 0; i < templatesList.getModel().getSize(); i++) { UICheckBox checkBox = (UICheckBox) templatesList.getModel().getElementAt(i); checkBox.setSelected(isSelected); } templatesList.repaint(); } }); templatesList.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { super.mousePressed(e); int index = templatesList.getSelectedIndex(); if (index < 0) { return; } UICheckBox checkBox = (UICheckBox) templatesList.getModel().getElementAt(index); checkBox.setSelected(!checkBox.isSelected()); //根据templateCheckBoxes中的选择情况来更新全选框的状态 int selectedCount = calculateSelectedNum(); if (selectedCount == 0) { chooseAllCheckBox.setState(TristateCheckBox.NOT_SELECTED); } else if (selectedCount == templateCheckBoxes.length) { chooseAllCheckBox.setState(TristateCheckBox.SELECTED); } else { chooseAllCheckBox.setState(TristateCheckBox.DO_NOT_CARE); } templatesList.repaint(); } }); templatesChoosePane.add(chooseAllCheckBox, BorderLayout.NORTH); templatesChoosePane.add(templatesList, BorderLayout.CENTER); } /** * 获取templateCheckBoxes中状态为选中状态的CheckBox数量 * */ private int calculateSelectedNum() { int count = 0; for (UICheckBox checkBox : templateCheckBoxes) { if (checkBox.isSelected()) { count++; } } return count; } public boolean showSavePane() { populate(); //如果有未保存的文件 ,则跳出保存对话框,选择要存储的项目 if (!unSavedTemplate.isEmpty()) { dialog.setVisible(true); } else { isAllSaved = true; } return isAllSaved; } public void populate() { java.util.List> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); JTemplate currentTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); for (int i = 0; i < opendedTemplate.size(); i++) { if (isneedToAdd(opendedTemplate.get(i), currentTemplate)) { unSavedTemplate.add(opendedTemplate.get(i)); } } templateCheckBoxes = new UICheckBox[unSavedTemplate.size()]; initTemplatesChoosePane(); } private boolean isneedToAdd(JTemplate template, JTemplate currentTemplate) { //所有模板都判断是不是保存 if (isJudgeCurrentEditingTemplate) { return !template.isALLSaved(); } //当前编辑的模板不判断是否已经保存 if (ComparatorUtils.equals(template, currentTemplate)) { return false; } else { return !template.isALLSaved(); } } private void saveSelectedTemplate(JTemplate specifiedTemplate) { if (!specifiedTemplate.isSaved()) { specifiedTemplate.stopEditing(); specifiedTemplate.saveTemplate(); } FineLoggerFactory.getLogger().info( com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); } public int saveLastOneTemplate() { JTemplate specifiedTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); if (!specifiedTemplate.isALLSaved()) { specifiedTemplate.stopEditing(); int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (returnVal == JOptionPane.YES_OPTION && specifiedTemplate.saveTemplate()) { specifiedTemplate.saveTemplate(); FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); } return returnVal; } return JOptionPane.YES_OPTION; } protected String title4PopupWindow() { return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Save"); } private class UnSelectedListCellRender extends DefaultListCellRenderer { @Override public Component getListCellRendererComponent(JList list, Object value, int index, final boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); templateCheckBoxes[index] = (UICheckBox) value; templateCheckBoxes[index].setBackground(list.getBackground()); return templateCheckBoxes[index]; } } private class UnSeletedTemplateListDataMode extends AbstractListModel { @Override public int getSize() { return templateCheckBoxes.length; } @Override public UICheckBox getElementAt(int index) { if (index > getSize() - 1 || index < 0) { return null; } return templateCheckBoxes[index]; } } } \ No newline at end of file +package com.fr.design.file; + +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.event.StateChangeListener; +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ilist.UIList; +import com.fr.design.gui.itree.checkboxtree.NullTristateCheckBox; +import com.fr.design.gui.itree.checkboxtree.TristateCheckBox; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.JTemplate; +import com.fr.general.ComparatorUtils; + +import com.fr.log.FineLoggerFactory; +import com.fr.stable.ProductConstants; + +import javax.swing.*; +import javax.swing.border.EmptyBorder; +import java.awt.*; +import java.awt.event.*; +import java.util.ArrayList; + +/** + * Author : daisy + * Date: 13-8-9 + * Time: 下午3:41 + */ +public class SaveSomeTemplatePane extends BasicPane { + + private UICheckBox[] templateCheckBoxes = null; + private BasicDialog dialog; + private JPanel templatesChoosePane; + private UIScrollPane scrollPane; + private java.util.List> unSavedTemplate = new ArrayList>(); + private boolean isAllSaved = false; + + //该变量用来判断是在关闭其他模板或是关闭设计器的时候,是否需要判断当前模板有没有保存 + private boolean isJudgeCurrentEditingTemplate = true; + + public SaveSomeTemplatePane(boolean isNeedTojudgeCurrent) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + if (this.dialog == null) { + this.dialog = this.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + @Override + public void doOk() { + for (int i = 0; i < templateCheckBoxes.length; i++) { + if (templateCheckBoxes[i].isSelected()) { + saveSelectedTemplate(unSavedTemplate.get(i)); + } + } + isAllSaved = true; + } + + public void doCancel() { + isAllSaved = false; + } + + }); + } + UILabel tip = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Select_The_Source_To_Save")); + this.add(tip, BorderLayout.NORTH); + templatesChoosePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + UIScrollPane scrollPane = new UIScrollPane(templatesChoosePane); + this.add(scrollPane, BorderLayout.CENTER); + this.isJudgeCurrentEditingTemplate = isNeedTojudgeCurrent; + } + + private void initTemplatesChoosePane() { + templatesChoosePane.setBorder(BorderFactory.createTitledBorder("")); + for (int i = 0; i < unSavedTemplate.size(); i++) { + templateCheckBoxes[i] = new UICheckBox(unSavedTemplate.get(i).getEditingFILE().getName()); + templateCheckBoxes[i].setSelected(true); + } + + final UIList templatesList = new UIList(templateCheckBoxes); + templatesList.setModel(new UnSeletedTemplateListDataMode()); + templatesList.setCellRenderer(new UnSelectedListCellRender()); + + final TristateCheckBox chooseAllCheckBox = new NullTristateCheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Choose_All")); + chooseAllCheckBox.setState(TristateCheckBox.SELECTED); + //取消chooseAllCheckBox的焦点事件监听,因为默认的焦点事件监听中失焦时会改变chooseAllCheckBox的状态 + chooseAllCheckBox.setFocusable(false); + chooseAllCheckBox.addStateChangeListener(new StateChangeListener() { + @Override + public void stateChange() { + if (chooseAllCheckBox.getState() == TristateCheckBox.DO_NOT_CARE) { + return; + } + boolean isSelected = chooseAllCheckBox.isSelected(); + for (int i = 0; i < templatesList.getModel().getSize(); i++) { + UICheckBox checkBox = (UICheckBox) templatesList.getModel().getElementAt(i); + checkBox.setSelected(isSelected); + } + templatesList.repaint(); + } + }); + + templatesList.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent e) { + super.mousePressed(e); + int index = templatesList.getSelectedIndex(); + if (index < 0) { + return; + } + UICheckBox checkBox = (UICheckBox) templatesList.getModel().getElementAt(index); + checkBox.setSelected(!checkBox.isSelected()); + + //根据templateCheckBoxes中的选择情况来更新全选框的状态 + int selectedCount = calculateSelectedNum(); + if (selectedCount == 0) { + chooseAllCheckBox.setState(TristateCheckBox.NOT_SELECTED); + } else if (selectedCount == templateCheckBoxes.length) { + chooseAllCheckBox.setState(TristateCheckBox.SELECTED); + } else { + chooseAllCheckBox.setState(TristateCheckBox.DO_NOT_CARE); + } + templatesList.repaint(); + } + }); + + templatesChoosePane.add(chooseAllCheckBox, BorderLayout.NORTH); + templatesChoosePane.add(templatesList, BorderLayout.CENTER); + + } + + /** + * 获取templateCheckBoxes中状态为选中状态的CheckBox数量 + * */ + private int calculateSelectedNum() { + int count = 0; + for (UICheckBox checkBox : templateCheckBoxes) { + if (checkBox.isSelected()) { + count++; + } + } + return count; + } + + + public boolean showSavePane() { + populate(); + //如果有未保存的文件 ,则跳出保存对话框,选择要存储的项目 + if (!unSavedTemplate.isEmpty()) { + dialog.setVisible(true); + } else { + isAllSaved = true; + } + return isAllSaved; + } + + public void populate() { + java.util.List> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); + JTemplate currentTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + for (int i = 0; i < opendedTemplate.size(); i++) { + if (isneedToAdd(opendedTemplate.get(i), currentTemplate)) { + unSavedTemplate.add(opendedTemplate.get(i)); + } + } + templateCheckBoxes = new UICheckBox[unSavedTemplate.size()]; + initTemplatesChoosePane(); + } + + private boolean isneedToAdd(JTemplate template, JTemplate currentTemplate) { + //所有模板都判断是不是保存 + if (isJudgeCurrentEditingTemplate) { + return !template.isALLSaved(); + } + + //当前编辑的模板不判断是否已经保存 + if (ComparatorUtils.equals(template, currentTemplate)) { + return false; + } else { + return !template.isALLSaved(); + } + } + + + private void saveSelectedTemplate(JTemplate specifiedTemplate) { + if (!specifiedTemplate.isSaved()) { + specifiedTemplate.stopEditing(); + specifiedTemplate.saveTemplate(); + } + FineLoggerFactory.getLogger().info( com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); + } + + + public int saveLastOneTemplate() { + JTemplate specifiedTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + if (!specifiedTemplate.isALLSaved()) { + specifiedTemplate.stopEditing(); + int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?", + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); + if (returnVal == JOptionPane.YES_OPTION && specifiedTemplate.saveTemplate()) { + specifiedTemplate.saveTemplate(); + FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); + } + return returnVal; + } + return JOptionPane.YES_OPTION; + } + + + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Save"); + } + + + private class UnSelectedListCellRender extends DefaultListCellRenderer { + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, final boolean isSelected, boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + templateCheckBoxes[index] = (UICheckBox) value; + templateCheckBoxes[index].setBackground(list.getBackground()); + return templateCheckBoxes[index]; + } + + } + + + private class UnSeletedTemplateListDataMode extends AbstractListModel { + + @Override + public int getSize() { + return templateCheckBoxes.length; + } + + @Override + public UICheckBox getElementAt(int index) { + if (index > getSize() - 1 || index < 0) { + return null; + } + return templateCheckBoxes[index]; + } + + } + + +}