From 2d4fab1398b3cb6ea7f2cea1db29f1953f8ed5c1 Mon Sep 17 00:00:00 2001 From: Starryi Date: Mon, 18 Oct 2021 14:40:13 +0800 Subject: [PATCH 1/9] =?UTF-8?q?REPORT-58744=20=E3=80=90=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E3=80=91=E6=92=A4=E9=94=80=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E6=A0=B7=E5=BC=8F=E8=AE=BE=E7=BD=AE=E4=B8=8D?= =?UTF-8?q?=E7=AC=A6=E5=90=88=E9=A2=84=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 1. 修改UIButtonGroup及UIToggleButton的setSelected方法 接口 2. JList仅在选中项改变时触犯stateChanged 【改动思路】 同上 --- .../fr/design/gui/ibutton/UIButtonGroup.java | 32 +++++++++++-------- .../com/fr/design/gui/ibutton/UITabGroup.java | 9 ++---- .../fr/design/gui/ibutton/UIToggleButton.java | 8 +++-- .../design/gui/style/FollowingThemePane.java | 1 + .../chart/gui/ChartTypeButtonPane.java | 2 +- .../component/VanChartAxisButtonPane.java | 2 +- .../cell/settingpane/style/StylePane.java | 1 + .../style/ThemedCellStyleListPane.java | 2 +- .../com/fr/design/report/ReportStylePane.java | 1 + 9 files changed, 31 insertions(+), 27 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButtonGroup.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButtonGroup.java index 624e2e8ee..34a7a0012 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButtonGroup.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButtonGroup.java @@ -37,6 +37,8 @@ public class UIButtonGroup extends JPanel implements GlobalNameObserver { private boolean isToolBarComponent = false; private boolean isClick; + private boolean autoFireStateChanged = true; + public UIButtonGroup(String[] textArray) { this(textArray, null); } @@ -72,7 +74,7 @@ public class UIButtonGroup extends JPanel implements GlobalNameObserver { if (globalNameListener != null) { globalNameListener.setGlobalName(buttonGroupName); } - setSelectedWithFireChanged(index); + setSelectedIndex(index, autoFireStateChanged); } }; } @@ -108,7 +110,7 @@ public class UIButtonGroup extends JPanel implements GlobalNameObserver { if (globalNameListener != null) { globalNameListener.setGlobalName(buttonGroupName); } - setSelectedWithFireChanged(index); + setSelectedIndex(index, autoFireStateChanged); } }; } @@ -175,7 +177,7 @@ public class UIButtonGroup extends JPanel implements GlobalNameObserver { if (globalNameListener != null) { globalNameListener.setGlobalName(buttonGroupName); } - setSelectedWithFireChanged(index); + setSelectedIndex(index, autoFireStateChanged); } }; } @@ -253,6 +255,10 @@ public class UIButtonGroup extends JPanel implements GlobalNameObserver { g2d.setClip(oldClip); } + public void setAutoFireStateChanged(boolean autoFireStateChanged) { + this.autoFireStateChanged = autoFireStateChanged; + } + /** * setSelectedItem * @@ -287,13 +293,14 @@ public class UIButtonGroup extends JPanel implements GlobalNameObserver { return selectedIndex; } - protected void setSelectedWithFireChanged(int newSelectedIndex) { - selectedIndex = newSelectedIndex; - for (int i = 0; i < labelButtonList.size(); i++) { - if (i == selectedIndex) { - labelButtonList.get(i).setSelectedWithFireListener(true); - } else { - labelButtonList.get(i).setSelected(false); + protected void setSelectedIndex(int newSelectedIndex, boolean fireChanged) { + if (selectedIndex != newSelectedIndex) { + selectedIndex = newSelectedIndex; + for (int i = 0; i < labelButtonList.size(); i++) { + labelButtonList.get(i).setSelected(i == selectedIndex, false); + } + if (fireChanged) { + fireStateChanged(); } } } @@ -304,10 +311,7 @@ public class UIButtonGroup extends JPanel implements GlobalNameObserver { * @param newSelectedIndex */ public void setSelectedIndex(int newSelectedIndex) { - selectedIndex = newSelectedIndex; - for (int i = 0; i < labelButtonList.size(); i++) { - labelButtonList.get(i).setSelected(i == selectedIndex); - } + setSelectedIndex(newSelectedIndex, true); } private void fireStateChanged() { diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UITabGroup.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UITabGroup.java index 69f5845f1..1d74d2e1d 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UITabGroup.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UITabGroup.java @@ -63,13 +63,8 @@ public class UITabGroup extends UIButtonGroup { } @Override - protected void setSelectedWithFireChanged(int newSelectedIndex) { - if (selectedIndex != newSelectedIndex) { - selectedIndex = newSelectedIndex; - for (int i = 0; i < labelButtonList.size(); i++) { - labelButtonList.get(i).setSelected(i == selectedIndex); - } - } + protected void setSelectedIndex(int newSelectedIndex, boolean fireChanged) { + super.setSelectedIndex(newSelectedIndex, fireChanged); tabChanged(newSelectedIndex); } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIToggleButton.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIToggleButton.java index dc380c0c9..18764e911 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIToggleButton.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIToggleButton.java @@ -142,10 +142,12 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{ } } - public void setSelectedWithFireListener(boolean isSelected) { + public void setSelected(boolean isSelected, boolean fireChanged) { if (this.isSelected != isSelected) { this.isSelected = isSelected; - fireSelectedChanged(); + if (fireChanged) { + fireSelectedChanged(); + } refresh(isSelected); } } @@ -175,7 +177,7 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{ @Override public void mouseClicked(MouseEvent e) { if (isEnabled() && !isEventBannded) { - setSelectedWithFireListener(!isSelected()); + setSelected(!isSelected(), true); } } }; diff --git a/designer-base/src/main/java/com/fr/design/gui/style/FollowingThemePane.java b/designer-base/src/main/java/com/fr/design/gui/style/FollowingThemePane.java index f9f556b3d..2d596d612 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/FollowingThemePane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/FollowingThemePane.java @@ -47,6 +47,7 @@ public class FollowingThemePane extends BasicPane implements UIObserver { this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS); + followingThemeButtonGroup.setAutoFireStateChanged(false); followingThemeButtonGroup.setSelectedIndex(1); followingThemeButtonGroup.addActionListener(new ActionListener() { @Override diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java index 1fdd6e9fd..7260fe581 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java @@ -660,7 +660,7 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen //记录改变前的plotID String lastPlotID = editingCollection == null ? StringUtils.EMPTY : editingCollection.getSelectedChartProvider(ChartProvider.class).getID(); changeCollectionSelected(getButtonName()); - setSelectedWithFireListener(true); + setSelected(true, true); fireSelectedChanged(); //需要先更新,最后重构面板 diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/component/VanChartAxisButtonPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/component/VanChartAxisButtonPane.java index d5f866c81..302009327 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/component/VanChartAxisButtonPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/component/VanChartAxisButtonPane.java @@ -356,7 +356,7 @@ public class VanChartAxisButtonPane extends BasicBeanPane { if (isEnabled()) { noSelected(); changeAxisSelected(getButtonName()); - setSelectedWithFireListener(true); + setSelected(true, true); fireSelectedChanged(); } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java index b72f6bd87..d5019310a 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java @@ -50,6 +50,7 @@ public class StylePane extends BasicPane implements UIObserver { public StylePane() { followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS); + followingThemeButtonGroup.setAutoFireStateChanged(false); customStylePane = new CustomStylePane(); themedCellStyleListPane = new ThemedCellStyleListPane(); panes[0] = createThemedStylePane(); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/ThemedCellStyleListPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/ThemedCellStyleListPane.java index 5843ea587..78369ba13 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/ThemedCellStyleListPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/ThemedCellStyleListPane.java @@ -47,7 +47,7 @@ public class ThemedCellStyleListPane extends FurtherBasicBeanPane imp styleList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { - if (changeListener != null) { + if (e.getValueIsAdjusting() && changeListener != null) { changeListener.stateChanged(new ChangeEvent(styleList)); } } diff --git a/designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java b/designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java index 1a483d832..fc4b5a116 100644 --- a/designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java +++ b/designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java @@ -78,6 +78,7 @@ public class ReportStylePane extends BasicPane { previewArea = new CellStylePreviewPane(); followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS); + followingThemeButtonGroup.setAutoFireStateChanged(false); customStylePane = new CustomFloatStyleSettingPane(); themedFloatStyleSettingPane = new ThemedFloatStyleSettingPane(); panes[0] = createThemedStylePane(); From fcaf293f105fdf6efcf3686549fd33ec0a311c34 Mon Sep 17 00:00:00 2001 From: Starryi Date: Mon, 18 Oct 2021 14:47:52 +0800 Subject: [PATCH 2/9] =?UTF-8?q?REPORT-58744=20=E3=80=90=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E3=80=91=E6=92=A4=E9=94=80=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E6=A0=B7=E5=BC=8F=E8=AE=BE=E7=BD=AE=E4=B8=8D?= =?UTF-8?q?=E7=AC=A6=E5=90=88=E9=A2=84=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 目前的撤销回退机制是基于AbstractNoScrollPane的自动注册 回调来完成的,灵活性较低,且存在重复注册监听器的问题, 导致一个交互操作会产生多个撤销回退,不适用于日趋复杂的 交互逻辑,后面需要想办法重新设计下。 针对主题的撤销回退,主要原因是跟随主题切换到自定义时,需要将 自定义样式面板设置为跟随主题时一样的配置,但因为上述自动发送 属性更新的逻辑,导致中间产生了大量无效的撤销回退状态。因此 需要临时禁止AbstractAttrNoScrollPane的自动发送属性变化 事件的行为,待面板内容更新完毕后,再恢复自动发送. 【改动思路】 同上 --- .../gui/frpane/AbstractAttrNoScrollPane.java | 14 +++++- .../gui/frpane/AttributeChangeUtils.java | 47 ++++++++++++++++++ .../design/gui/style/FollowingThemePane.java | 16 +++--- .../cell/settingpane/style/StylePane.java | 49 +++++++++++-------- 4 files changed, 99 insertions(+), 27 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/gui/frpane/AttributeChangeUtils.java diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/AbstractAttrNoScrollPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/AbstractAttrNoScrollPane.java index 381a9cd76..a9321879c 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/AbstractAttrNoScrollPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/AbstractAttrNoScrollPane.java @@ -24,6 +24,16 @@ public abstract class AbstractAttrNoScrollPane extends BasicPane { private AttributeChangeListener listener; private String globalName = ""; + private boolean autoFireAttributesChanged = true; + + public boolean isAutoFireAttributesChanged() { + return this.autoFireAttributesChanged; + } + + public void setAutoFireAttributesChanged(boolean autoFireAttributesChanged) { + this.autoFireAttributesChanged = autoFireAttributesChanged; + } + protected AbstractAttrNoScrollPane() { initAll(); } @@ -127,7 +137,9 @@ public abstract class AbstractAttrNoScrollPane extends BasicPane { public void attributeChanged() { synchronized (this) { if (listener != null) { - listener.attributeChange(); + if (autoFireAttributesChanged) { + listener.attributeChange(); + } } } } diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/AttributeChangeUtils.java b/designer-base/src/main/java/com/fr/design/gui/frpane/AttributeChangeUtils.java new file mode 100644 index 000000000..bfc1ff9d4 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/AttributeChangeUtils.java @@ -0,0 +1,47 @@ +package com.fr.design.gui.frpane; + +import java.awt.Component; +import java.awt.Container; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/9/17 + */ +public class AttributeChangeUtils { + private static AbstractAttrNoScrollPane findNearestAttrNoScrollPaneAncestor(Component c) { + for(Container p = c.getParent(); p != null; p = p.getParent()) { + if (p instanceof AbstractAttrNoScrollPane) { + return (AbstractAttrNoScrollPane) p; + } + } + return null; + } + + public static void changeComposedUI(Component composedComponent, boolean fireMiddleStateChanged, UIChangeAction action) { + AbstractAttrNoScrollPane attrPane = findNearestAttrNoScrollPaneAncestor(composedComponent); + boolean oldAutoFire = true; + + if (!fireMiddleStateChanged) { + // 禁止属性面板自动处理属性更新 + if (attrPane != null) { + oldAutoFire = attrPane.isAutoFireAttributesChanged(); + attrPane.setAutoFireAttributesChanged(false); + } + } + + // 更新UI + action.changeComposedUI(); + + if (!fireMiddleStateChanged) { + // 恢复属性面板自动处理属性更新 + if (attrPane != null) { + attrPane.setAutoFireAttributesChanged(oldAutoFire); + } + } + } + + public interface UIChangeAction { + void changeComposedUI(); + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/style/FollowingThemePane.java b/designer-base/src/main/java/com/fr/design/gui/style/FollowingThemePane.java index 2d596d612..bf06aa2fd 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/FollowingThemePane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/FollowingThemePane.java @@ -5,6 +5,7 @@ import com.fr.design.dialog.BasicPane; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.gui.frpane.AttributeChangeUtils; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; @@ -52,12 +53,15 @@ public class FollowingThemePane extends BasicPane implements UIObserver { followingThemeButtonGroup.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - for (FollowingThemeActionChangeListener changeListener : changeListeners) { - changeListener.onFollowingTheme(isFollowingTheme()); - } - invalidate(); - - // 与主题相关的属性面板更新完毕后,再通知外层更新数据 + AttributeChangeUtils.changeComposedUI(FollowingThemePane.this, false, new AttributeChangeUtils.UIChangeAction() { + @Override + public void changeComposedUI() { + for (FollowingThemeActionChangeListener changeListener : changeListeners) { + changeListener.onFollowingTheme(isFollowingTheme()); + } + invalidate(); + } + }); if (uiObserverListener != null) { uiObserverListener.doChange(); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java index d5019310a..bfd335f39 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java @@ -6,6 +6,7 @@ import com.fr.design.designer.IntervalConstants; import com.fr.design.dialog.BasicPane; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.frpane.AttributeChangeUtils; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; @@ -73,27 +74,13 @@ public class StylePane extends BasicPane implements UIObserver { followingThemeButtonGroup.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - int selectedIndex = followingThemeButtonGroup.getSelectedIndex(); - cardLayout.show(contentPane, FOLLOWING_THEME_STRING_ARRAYS[selectedIndex]); - if (selectedIndex == 1) { - // 对于同一个单元格,跟随主题切换到自定义,自定义中的配置与其保持一致 - NameStyle lastSelectedNameStyle = themedCellStyleListPane.updateBean(); - if (lastSelectedNameStyle != null) { - Style lastSelectedRealStyle = lastSelectedNameStyle.getRealStyle(); - try { - lastSelectedRealStyle = (Style) lastSelectedRealStyle.clone(); - if (lastSelectedRealStyle != null) { - customStylePane.populateBean(lastSelectedRealStyle); - } - } catch (CloneNotSupportedException ex) { - FineLoggerFactory.getLogger().error(ex.getMessage(), ex); - } + AttributeChangeUtils.changeComposedUI(StylePane.this, false, new AttributeChangeUtils.UIChangeAction() { + @Override + public void changeComposedUI() { + int selectedIndex = followingThemeButtonGroup.getSelectedIndex(); + onFollowingThemeSettingChanged(selectedIndex, selectedIndex == 0); } - } else { - // 对于同一个单元格,自定义切换到跟随主题,跟随主题选中"默认"样式,并使用默认样式设置选中的单元格 - themedCellStyleListPane.reset(); - } - + }); fireStateChanged(); } }); @@ -109,6 +96,28 @@ public class StylePane extends BasicPane implements UIObserver { IntervalConstants.INTERVAL_L1, 0); } + private void onFollowingThemeSettingChanged(int selectedIndex, boolean isFollowingTheme) { + cardLayout.show(contentPane, FOLLOWING_THEME_STRING_ARRAYS[selectedIndex]); + if (!isFollowingTheme) { + // 对于同一个单元格,跟随主题切换到自定义,自定义中的配置与其保持一致 + NameStyle lastSelectedNameStyle = themedCellStyleListPane.updateBean(); + if (lastSelectedNameStyle != null) { + Style lastSelectedRealStyle = lastSelectedNameStyle.getRealStyle(); + try { + lastSelectedRealStyle = (Style) lastSelectedRealStyle.clone(); + if (lastSelectedRealStyle != null) { + customStylePane.populateBean(lastSelectedRealStyle); + } + } catch (CloneNotSupportedException ex) { + FineLoggerFactory.getLogger().error(ex.getMessage(), ex); + } + } + } else { + // 对于同一个单元格,自定义切换到跟随主题,跟随主题选中"默认"样式,并使用默认样式设置选中的单元格 + themedCellStyleListPane.reset(); + } + } + protected JPanel createTabbedContentPane() { JPanel contentPane = new JPanel(cardLayout) { @Override From d23697e9e7a33656d4793f7225097c005cce3bad Mon Sep 17 00:00:00 2001 From: kuangshuai Date: Mon, 18 Oct 2021 15:39:43 +0800 Subject: [PATCH 3/9] =?UTF-8?q?REPORT-61034=20mac=20=E5=85=A8=E5=B1=8F?= =?UTF-8?q?=E6=97=B6=E5=BC=95=E5=AF=BC=E7=AA=97=E5=8F=A3=E6=9C=AA=E8=A6=86?= =?UTF-8?q?=E7=9B=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/mainframe/guide/base/GuideView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideView.java b/designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideView.java index aa277adbb..7e141d7d5 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideView.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideView.java @@ -124,6 +124,6 @@ public class GuideView extends JDialog { private void updateGuideViewLocation() { GUICoreUtils.centerWindow(window, this); - this.setSize(getSize()); + this.setBounds(window.getBounds()); } } From 5ba9e909284454358da45d68e40be536a76cee9f Mon Sep 17 00:00:00 2001 From: kuangshuai Date: Mon, 18 Oct 2021 20:59:57 +0800 Subject: [PATCH 4/9] =?UTF-8?q?REPORT-60942=20=E6=B0=94=E6=B3=A1=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E4=BA=A4=E4=BA=92=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/mainframe/guide/tip/BubbleTip.java | 8 +- .../guide/ui/bubble/BubbleWithClose.java | 133 +++++++++++------- .../layout/UseLayoutAndComponentGuide.java | 2 +- 3 files changed, 86 insertions(+), 57 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/guide/tip/BubbleTip.java b/designer-base/src/main/java/com/fr/design/mainframe/guide/tip/BubbleTip.java index d3d1c040d..13e5dc28f 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/guide/tip/BubbleTip.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/guide/tip/BubbleTip.java @@ -2,8 +2,6 @@ package com.fr.design.mainframe.guide.tip; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.i18n.Toolkit; -import com.fr.design.mainframe.DesignerContext; -import com.fr.design.mainframe.DesignerFrame; import com.fr.design.mainframe.guide.base.Guide; import com.fr.design.mainframe.guide.base.GuideManager; import com.fr.design.mainframe.guide.ui.bubble.Bubble; @@ -16,9 +14,11 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class BubbleTip implements GuideTip { + private static final int GAP = 5; private BubbleWithClose bubbleBox; private Point anchor; + /** * * @param title 标题 @@ -70,12 +70,12 @@ public class BubbleTip implements GuideTip { int bubbleW = bubbleBox.getPreferredSize().width; int bubbleH = bubbleBox.getPreferredSize().height; if (bubbleBox.isTailHorizontal()) { - int x = bubbleBox.isTailLeft() ? anchor.x : anchor.x - bubbleW; + int x = bubbleBox.isTailLeft() ? anchor.x + GAP : anchor.x - bubbleW - GAP; int y = anchor.y - (int) (bubbleH * bubbleBox.getTailStart()); bubbleBox.setBounds(x, y, bubbleW, bubbleH); } else if (bubbleBox.isTailVertical()) { int x = anchor.x - (int) (bubbleW * bubbleBox.getTailStart()); - int y = bubbleBox.isTailTop() ? anchor.y : anchor.y - bubbleH; + int y = bubbleBox.isTailTop() ? anchor.y + GAP : anchor.y - bubbleH - GAP; bubbleBox.setBounds(x, y, bubbleW, bubbleH); } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/bubble/BubbleWithClose.java b/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/bubble/BubbleWithClose.java index ba8f3da05..904185ccb 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/bubble/BubbleWithClose.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/bubble/BubbleWithClose.java @@ -9,6 +9,7 @@ import com.fr.stable.StringUtils; import javax.swing.Icon; import javax.swing.JTextPane; +import javax.swing.text.MutableAttributeSet; import javax.swing.text.SimpleAttributeSet; import javax.swing.text.StyleConstants; import javax.swing.text.StyledDocument; @@ -18,7 +19,6 @@ import java.awt.Container; import java.awt.Dimension; import java.awt.Font; import java.awt.FontMetrics; -import java.awt.Graphics2D; import java.awt.Insets; import java.awt.LayoutManager; import java.awt.Rectangle; @@ -32,13 +32,21 @@ import java.text.AttributedCharacterIterator; import java.text.AttributedString; public class BubbleWithClose extends Bubble { - private static final Font FONT = new Font(Font.SANS_SERIF, Font.PLAIN, 14); + private static final Font TITLE_FONT = new Font(Font.SANS_SERIF, Font.PLAIN, 14); + private static final Font CONTENT_FONT = new Font(Font.SANS_SERIF, Font.PLAIN, 12); + private static final int TITLE_LINE_HEIGHT = 22; + private static final int CONTENT_LINE_HEIGHT = 18; + private static final Icon ICON = IOUtils.readIcon("/com/fr/design/mainframe/guide/close.png"); - private static final int HEADER_HEIGHT = 24; - private static final Color HEADER_COLOR = new Color(245, 245, 246); private static final Color TITLE_COLOR = new Color(51, 51, 52); private static final Color CONTENT_COLOR = new Color(51,51,52,128); - private static final Insets DEFAULT_INSET = new Insets(10, 15, 10, 15); + private static final Color HIGHLIGHT_COLOR = new Color(65, 155, 249); + private static final Insets DEFAULT_INSET = new Insets(15, 15, 15, 15); + private static final int MIN_WIDTH = 140; + private static final int MAX_WIDTH = 275; + private static final int ICON_GAP = 10; + private static final int ICON_SIZE = 10; + private static final int TEXT_GAP = 5; private String title; @@ -46,6 +54,8 @@ public class BubbleWithClose extends Bubble { private UITextPane titleTextArea; private UITextPane contentTextArea; private UIButton closeButton; + private Dimension titleSize; + private Dimension contentSize; public BubbleWithClose(String title, String content) { this(title, content, TailDirection.LEFT, 0.5f); @@ -87,23 +97,17 @@ public class BubbleWithClose extends Bubble { @Override public void componentResized(ComponentEvent e) { Rectangle rectBounds = getRectBounds(); - Dimension buttonSize = closeButton.getPreferredSize(); - - closeButton.setBounds(getWidth() - 10 - buttonSize.width, rectBounds.y + (HEADER_HEIGHT - buttonSize.height) / 2, buttonSize.width, buttonSize.height); - Dimension titleSize = new Dimension(0,0); - Dimension contentSize = new Dimension(0, 0); + closeButton.setBounds(rectBounds.x + rectBounds.width - DEFAULT_INSET.right - ICON_SIZE, rectBounds.y + 21, ICON_SIZE, ICON_SIZE); if (titleTextArea != null) { - titleSize = calTextSize(titleTextArea, getTextAreaMaxWidth()); - int x = rectBounds.x + (rectBounds.width - getHorizontalInsets() - titleSize.width) / 2 + DEFAULT_INSET.left; - int y = rectBounds.y + HEADER_HEIGHT + DEFAULT_INSET.top; + int x = rectBounds.x + DEFAULT_INSET.left; + int y = rectBounds.y + DEFAULT_INSET.top; titleTextArea.setBounds(x, y, titleSize.width, titleSize.height); } if (contentTextArea != null) { - contentSize = calTextSize(contentTextArea, getTextAreaMaxWidth()); - int x = rectBounds.x + (rectBounds.width - getHorizontalInsets() - contentSize.width) / 2 + DEFAULT_INSET.left; - int y = rectBounds.y = HEADER_HEIGHT + DEFAULT_INSET.top + (titleSize.height == 0 ? 0 : titleSize.height + 10); + int x = rectBounds.x + DEFAULT_INSET.left; + int y = rectBounds.y + DEFAULT_INSET.top + (titleSize.height == 0 ? 0 : titleSize.height + getTextGap()); contentTextArea.setBounds(x,y, contentSize.width, contentSize.height); } setSize(getPreferredSize().width, getPreferredSize().height); @@ -116,7 +120,7 @@ public class BubbleWithClose extends Bubble { closeButton = new UIButton(); closeButton.setIcon(ICON); closeButton.set4ToolbarButton(); - closeButton.setPreferredSize(new Dimension(12, 12)); + closeButton.setPreferredSize(new Dimension(ICON_SIZE, ICON_SIZE)); closeButton.setRolloverEnabled(false); closeButton.setPressedPainted(false); this.add(closeButton); @@ -138,44 +142,83 @@ public class BubbleWithClose extends Bubble { private void createTitleTextArea() { if (StringUtils.isNotEmpty(title)) { - titleTextArea = createTextArea(title, FONT, TITLE_COLOR); + titleTextArea = createTextArea(title, TITLE_FONT, TITLE_LINE_HEIGHT, TITLE_COLOR); this.add(titleTextArea); } - + titleSize = calTextSize(titleTextArea, TITLE_LINE_HEIGHT, getTextAreaWidth(MAX_WIDTH), getTextAreaWidth(MIN_WIDTH)); } private void createContentTextArea() { if (StringUtils.isNotEmpty(content)) { - contentTextArea = createTextArea(content, FONT, CONTENT_COLOR); + contentTextArea = createTextArea(content, CONTENT_FONT, CONTENT_LINE_HEIGHT, CONTENT_COLOR); this.add(contentTextArea); } + contentSize = calTextSize(contentTextArea, CONTENT_LINE_HEIGHT, getTextAreaWidth(MAX_WIDTH), getTextAreaWidth(MIN_WIDTH)); } - private UITextPane createTextArea(String str, Font font, Color foreground) { + private UITextPane createTextArea(String str, Font font, int lineHeight, Color foreground) { + int lineSpace = lineHeight - font.getSize(); UITextPane textArea= new UITextPane(){ @Override public Insets getInsets() { - return new Insets(0, 0, 0, 0); + return new Insets(lineSpace / 2 - 1, 0, lineSpace / 2, 0); } }; + changeLineSpacing(textArea, (float) lineSpace / 2 / lineHeight, true); textArea.setText(str); - textArea.setEnabled(false); + textArea.setEditable(false); + textArea.setForeground(foreground); textArea.setDisabledTextColor(foreground); textArea.setBorder(null); textArea.setFont(font); textArea.setOpaque(false); - textArea.setForeground(foreground); - StyledDocument doc = textArea.getStyledDocument(); - SimpleAttributeSet center = new SimpleAttributeSet(); - StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER); - doc.setParagraphAttributes(0, doc.getLength(), center, false); + highlightText(textArea); return textArea; } + private void changeLineSpacing(JTextPane pane, float factor, boolean replace) { + pane.selectAll(); + MutableAttributeSet set = new SimpleAttributeSet(pane.getParagraphAttributes()); + StyleConstants.setLineSpacing(set, factor); + pane.setParagraphAttributes(set, replace); + } + + private void highlightText(JTextPane textArea) { + SimpleAttributeSet sas = new SimpleAttributeSet(); + StyleConstants.setForeground(sas, HIGHLIGHT_COLOR); + StyledDocument doc = textArea.getStyledDocument(); + String text = textArea.getText(); + int startPos = -1; + for (int i = 0; i < text.length(); i ++) { + char ch = text.charAt(i); + if (ch == '【') { + startPos = i; + } + if (ch == '】') { + if (startPos > 0) { + try { + doc.setCharacterAttributes(startPos, (i - startPos + 1), sas, false); + startPos = -1; + } catch (Exception e) { + } + } + } + } + + } + + @Override + protected int getDefaultWidth() { + return Math.max(titleSize.width, contentSize.width) + getHorizontalInsets() + ICON_GAP + ICON_SIZE + (isTailHorizontal() ? TAIL_HEIGHT : 0) ; + } + + @Override protected int getDefaultHeight() { - Dimension titleSize = calTextSize(titleTextArea, getDefaultTextAreaMaxWidth()); - Dimension contentSize = calTextSize(contentTextArea, getDefaultTextAreaMaxWidth()); - return (isTailVertical() ? TAIL_HEIGHT : 0) + HEADER_HEIGHT + titleSize.height + (titleSize.height == 0 ? 0 : 5) + contentSize.height + getVerticalInsets(); + return titleSize.height + contentSize.height + getTextGap() + getVerticalInsets() + (isTailVertical() ? TAIL_HEIGHT : 0); + } + + private int getTextGap() { + return (titleSize.height != 0 && contentSize.height != 0) ? TEXT_GAP : 0; } private LayoutManager getLayoutManager() { @@ -206,18 +249,6 @@ public class BubbleWithClose extends Bubble { }; } - @Override - protected void paintBubbleBg(Graphics2D g2) { - super.paintBubbleBg(g2); - paintHeaderBg(g2); - } - - private void paintHeaderBg(Graphics2D g2) { - g2.setColor(HEADER_COLOR); - Rectangle bounds = getRectBounds(); - g2.fillRoundRect(bounds.x, bounds.y, bounds.width, HEADER_HEIGHT, 10, 10); - } - private int countLines(JTextPane textArea, int max_width) { AttributedString text = new AttributedString(textArea.getText()); text.addAttribute(TextAttribute.FONT, textArea.getFont()); @@ -234,28 +265,26 @@ public class BubbleWithClose extends Bubble { return lines; } - private Dimension calTextSize(JTextPane textArea, int maxWidth) { + private Dimension calTextSize(JTextPane textArea, int lineHeight, int maxWidth, int minWidth) { if (textArea == null) { - return new Dimension(0, 0); + return new Dimension(minWidth, 0); } FontMetrics fontMetrics = GraphHelper.getFontMetrics(textArea.getFont()); int line = countLines(textArea, maxWidth); int width = maxWidth; if (line == 1) { - width = fontMetrics.stringWidth(textArea.getText()); + width = Math.max(fontMetrics.stringWidth(textArea.getText()), minWidth); } - int height = fontMetrics.getHeight() * line; + int height = lineHeight * line; return new Dimension(width, height); } - private int getTextAreaMaxWidth() { - return getWidth() - (isTailHorizontal() ? TAIL_HEIGHT : 0) -getHorizontalInsets(); - } - private int getDefaultTextAreaMaxWidth() { - return BUBBLE_WIDTH - getHorizontalInsets(); + private int getTextAreaWidth(int bubbleWidth) { + return bubbleWidth - getHorizontalInsets() - ICON_SIZE - ICON_GAP; } + private int getHorizontalInsets() { return DEFAULT_INSET.left + DEFAULT_INSET.right; } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/layout/UseLayoutAndComponentGuide.java b/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/layout/UseLayoutAndComponentGuide.java index 54fc5577b..6d67f3b93 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/layout/UseLayoutAndComponentGuide.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/layout/UseLayoutAndComponentGuide.java @@ -105,7 +105,7 @@ public class UseLayoutAndComponentGuide { ClickScene.ClickType.LEFT ); - scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_F001001_Tip_New_Form") + "测试文本测试文本测试文本测试文本测试文本", GuideTip.Direction.BOTTOM); + scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_F001001_Tip_New_Form"), GuideTip.Direction.RIGHT); scene.showScene(); return true; } From 324db838df68403975d48b7dcc26b51b58053ee0 Mon Sep 17 00:00:00 2001 From: kuangshuai Date: Mon, 18 Oct 2021 21:32:06 +0800 Subject: [PATCH 5/9] =?UTF-8?q?REPORT-61048=20=E8=BF=9C=E7=A8=8B=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=99=A8=E6=96=87=E4=BB=B6=E6=B2=A1=E6=9C=89=E6=9D=83?= =?UTF-8?q?=E9=99=90=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/guide/creator/GuideCreateUtils.java | 15 ++++++++++++++- .../layout/ChangeLayoutComponentGuide.java | 7 ++++++- .../theme/DownloadComponentPackageGuide.java | 5 +++++ .../guide/creator/theme/ThemeToggleGuide.java | 11 ++++++++--- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/GuideCreateUtils.java b/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/GuideCreateUtils.java index 7850e2f64..2e25eaac7 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/GuideCreateUtils.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/GuideCreateUtils.java @@ -163,7 +163,11 @@ public class GuideCreateUtils { InputStream inputStream = GuideCreateUtils.class.getResourceAsStream(StableUtils.pathJoin(sourcePath, fileName + suffix)); byte[] data = ResourceIOUtils.inputStream2Bytes(inputStream); WorkContext.getWorkResource().write(fileWorkPath, data); - DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(fileWorkPath, false))); + FileNodeFILE fileNodeFILE= new FileNodeFILE(new FileNode(fileWorkPath, false)); + if (!fileNodeFILE.exists()) { + return null; + } + DesignerContext.getDesignerFrame().openTemplate(fileNodeFILE); return fileWorkPath; } @@ -200,6 +204,15 @@ public class GuideCreateUtils { JOptionPane.WARNING_MESSAGE); } + public static void showNoFileAuthAlert() { + FineJOptionPane.showMessageDialog( + DesignerContext.getDesignerFrame(), + Toolkit.i18nText("Fine-Design_Basic_Warning_Template_Do_Not_Exsit"), + Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), + JOptionPane.INFORMATION_MESSAGE + ); + } + public static JDialog showConfirmDialog(Window parent, Object message, String title, int optionType) { JOptionPane pane = new JOptionPane(message, JOptionPane.QUESTION_MESSAGE, optionType, null, FineJOptionPane.OPTION_OK_CANCEL, FineJOptionPane.OPTION_OK_CANCEL[0]); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/layout/ChangeLayoutComponentGuide.java b/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/layout/ChangeLayoutComponentGuide.java index a9b7f56c8..6bf82065f 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/layout/ChangeLayoutComponentGuide.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/layout/ChangeLayoutComponentGuide.java @@ -11,6 +11,7 @@ import com.fr.design.mainframe.guide.GuideIds; import com.fr.design.mainframe.guide.base.Guide; import com.fr.design.mainframe.guide.base.GuideBuilder; import com.fr.design.mainframe.guide.base.GuideLifecycleAdaptor; +import com.fr.design.mainframe.guide.base.GuideManager; import com.fr.design.mainframe.guide.creator.GuideCreateUtils; import com.fr.design.mainframe.guide.creator.GuideSceneHelper; import com.fr.design.mainframe.guide.scene.ClickScene; @@ -21,7 +22,6 @@ import com.fr.design.mainframe.guide.scene.GuideSceneLifecycleAdaptor; import com.fr.design.mainframe.guide.tip.GuideTip; import com.fr.design.utils.ComponentUtils; -import javax.swing.SwingUtilities; import java.awt.Point; import java.awt.Rectangle; @@ -50,6 +50,11 @@ public class ChangeLayoutComponentGuide { @Override public boolean prepared() { filePath = GuideCreateUtils.openGuideFile("/com/fr/report/guide/template", "layout_recommend", ".frm"); + if (filePath == null) { + GuideCreateUtils.showNoFileAuthAlert(); + GuideManager.getInstance().getCurrentGuide().terminate(); + return false; + } return true; } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/theme/DownloadComponentPackageGuide.java b/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/theme/DownloadComponentPackageGuide.java index fe5b0cb03..68de9ef8f 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/theme/DownloadComponentPackageGuide.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/theme/DownloadComponentPackageGuide.java @@ -94,6 +94,11 @@ public class DownloadComponentPackageGuide { boolean loadWidgetSuccess = OnlineWidgetRepoPane.loadWidgets(); if (loadWidgetSuccess) { filePath = GuideCreateUtils.openGuideFile("/com/fr/report/guide/template", "layout_recommend", ".frm"); + if (filePath == null) { + GuideCreateUtils.showNoFileAuthAlert(); + GuideManager.getInstance().getCurrentGuide().terminate(); + return false; + } EastRegionContainerPane.getInstance().switchTabTo(EastRegionContainerPane.KEY_WIDGET_SETTINGS); OnlineWidgetRepoPane onlineWidgetRepoPane = OnlineWidgetRepoPane.getInstance(); OnlineWidgetTabPane tabPane = (OnlineWidgetTabPane) ComponentUtils.findComponentByClass(onlineWidgetRepoPane, OnlineWidgetTabPane.class); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/theme/ThemeToggleGuide.java b/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/theme/ThemeToggleGuide.java index 5b7892eb8..07fb60041 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/theme/ThemeToggleGuide.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/theme/ThemeToggleGuide.java @@ -78,9 +78,14 @@ public class ThemeToggleGuide { themeLoadCount--; if (themeLoadCount == 0) { filePath = GuideCreateUtils.openGuideFile("/com/fr/report/guide/template", "toggle_theme", ".frm"); - EastRegionContainerPane.getInstance().switchTabTo(EastRegionContainerPane.KEY_WIDGET_SETTINGS); - asyncThemeFetcher.shutdown(); - GuideManager.getInstance().getCurrentGuide().start(); + if (filePath == null) { + GuideCreateUtils.showNoFileAuthAlert(); + GuideManager.getInstance().getCurrentGuide().terminate(); + } else { + EastRegionContainerPane.getInstance().switchTabTo(EastRegionContainerPane.KEY_WIDGET_SETTINGS); + asyncThemeFetcher.shutdown(); + GuideManager.getInstance().getCurrentGuide().start(); + } } } }); From 7c26de2df73d9961d3cd2a8f7999f99133f0305d Mon Sep 17 00:00:00 2001 From: kuangshuai Date: Mon, 18 Oct 2021 22:40:47 +0800 Subject: [PATCH 6/9] =?UTF-8?q?REPORT-60942=20=E8=A7=86=E8=A7=89=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/mainframe/guide/ui/BubbleHint.java | 28 +++++++++++++------ .../design/mainframe/guide/ui/ExpandPane.java | 4 +-- .../guide/ui/GuideCompleteDialog.java | 23 +++++++++++++-- .../mainframe/guide/ui/GuideManageDialog.java | 2 +- .../guide/ui/bubble/BubbleWithClose.java | 11 ++++---- 5 files changed, 48 insertions(+), 20 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/BubbleHint.java b/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/BubbleHint.java index 56f978731..79d49d192 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/BubbleHint.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/BubbleHint.java @@ -17,6 +17,7 @@ import java.awt.event.ActionListener; public class BubbleHint extends Bubble { private UIButton confirmButton; + private static final Color CONTENT_TEXT_COLOR = new Color(51, 51, 52); public BubbleHint() { super(TailDirection.TOP, 0.9f); @@ -38,21 +39,21 @@ public class BubbleHint extends Bubble { title.setHorizontalAlignment(SwingConstants.CENTER); title.setBorder(BorderFactory.createEmptyBorder(0,0,5,0)); - UILabel content1 = new UILabel(Toolkit.i18nText("Fine-Design_Guide_Tips_Content1")); - content1.setPreferredSize(new Dimension(190,20)); - content1.setHorizontalAlignment(SwingConstants.CENTER); + UILabel content1 = createContentLabel(Toolkit.i18nText("Fine-Design_Guide_Tips_Content1")); - UILabel content2 = new UILabel(Toolkit.i18nText("Fine-Design_Guide_Tips_Content2")); - content2.setPreferredSize(new Dimension(190,20)); - content2.setHorizontalAlignment(SwingConstants.CENTER); + UILabel content2 = createContentLabel(Toolkit.i18nText("Fine-Design_Guide_Tips_Content2")); JPanel buttonContainer= FRGUIPaneFactory.createCenterFlowZeroGapBorderPane(); - buttonContainer.setBorder(BorderFactory.createEmptyBorder(20, 0, 0, 0)); + buttonContainer.setBorder(BorderFactory.createEmptyBorder(15, 0, 0, 0)); buttonContainer.setPreferredSize(new Dimension(190,40)); buttonContainer.setOpaque(false); - confirmButton = new UIButton(Toolkit.i18nText("Fine-Design_Guide_Tips_Know")); - confirmButton.setPreferredSize(new Dimension(78, 24)); + confirmButton = new UIButton(Toolkit.i18nText("Fine-Design_Guide_Tips_Know")) { + public Dimension getPreferredSize() { + return new Dimension(78, 24); + } + }; + buttonContainer.add(confirmButton); contentPane.add(title); @@ -71,4 +72,13 @@ public class BubbleHint extends Bubble { confirmButton.removeActionListener(listener); } + private UILabel createContentLabel(String text) { + UILabel content = new UILabel(text); + content.setPreferredSize(new Dimension(190,20)); + content.setHorizontalAlignment(SwingConstants.CENTER); + content.setFont(content.getFont().deriveFont(14.0f)); + content.setForeground(CONTENT_TEXT_COLOR); + return content; + } + } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/ExpandPane.java b/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/ExpandPane.java index c71a15ea7..c4e6e0160 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/ExpandPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/ExpandPane.java @@ -30,7 +30,7 @@ public class ExpandPane extends JPanel { } private void initComponent() { - VerticalFlowLayout layout = new VerticalFlowLayout(VerticalFlowLayout.TOP, 10, 5); + VerticalFlowLayout layout = new VerticalFlowLayout(VerticalFlowLayout.TOP, 10, 0); layout.setAlignLeft(true); this.setLayout(layout); @@ -47,7 +47,7 @@ public class ExpandPane extends JPanel { private JPanel createHeader() { headerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - headerPane.setPreferredSize(new Dimension(200, 24)); + headerPane.setPreferredSize(new Dimension(200, 16)); UILabel headerTitle = new UILabel(this.title); headerTitle.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); arrow = new UILabel(downIcon); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/GuideCompleteDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/GuideCompleteDialog.java index 29316652d..af1854d7a 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/GuideCompleteDialog.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/GuideCompleteDialog.java @@ -14,7 +14,9 @@ import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JDialog; import javax.swing.JPanel; +import javax.swing.JTextPane; import javax.swing.SwingConstants; +import javax.swing.text.MutableAttributeSet; import javax.swing.text.SimpleAttributeSet; import javax.swing.text.StyleConstants; import javax.swing.text.StyledDocument; @@ -22,6 +24,7 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import java.awt.Dimension; +import java.awt.Font; import java.awt.Graphics2D; import java.awt.Window; import java.awt.event.ActionEvent; @@ -34,12 +37,16 @@ public class GuideCompleteDialog extends JDialog { private static final int ICON_HEIGHT = 182; private static final Color FONT_COLOR = new Color(51, 51, 52); private static final Color BUTTON_BG_COLOR = new Color(65, 155,249); + private static final Font TITLE_FONT = new Font(Font.SANS_SERIF, Font.BOLD, 22); + private static final Font CONTENT_FONT = new Font(Font.SANS_SERIF, Font.PLAIN, 18); + private static final Font BUTTON_FONT = new Font(Font.SANS_SERIF, Font.BOLD, 14); private static GuideCompleteDialog dialog; public static GuideCompleteDialog getInstance() { if (dialog == null) { dialog = new GuideCompleteDialog(DesignerContext.getDesignerFrame()); } + dialog = new GuideCompleteDialog(DesignerContext.getDesignerFrame()); return dialog; } @@ -65,15 +72,16 @@ public class GuideCompleteDialog extends JDialog { container.setBorder(BorderFactory.createEmptyBorder(15, 52, 25, 52)); UILabel title = new UILabel(Toolkit.i18nText("Fine-Design_Guide_Complete_Confirm")); - title.setFont(title.getFont().deriveFont(22.0f)); + title.setFont(TITLE_FONT); title.setPreferredSize(new Dimension(190, 30)); title.setHorizontalAlignment(SwingConstants.CENTER); title.setForeground(FONT_COLOR); textArea = new UITextPane(); + changeLineSpacing(textArea, 0.19f,false); textArea.setEnabled(false); textArea.setOpaque(false); - textArea.setFont(textArea.getFont().deriveFont(18.0f)); + textArea.setFont(CONTENT_FONT); textArea.setPreferredSize(new Dimension(236, 52)); textArea.setBorder(null); textArea.setDisabledTextColor(FONT_COLOR); @@ -83,7 +91,8 @@ public class GuideCompleteDialog extends JDialog { doc.setParagraphAttributes(0, doc.getLength(), center, false); JPanel buttonContainer= FRGUIPaneFactory.createCenterFlowZeroGapBorderPane(); - buttonContainer.setPreferredSize(new Dimension(190,38)); + buttonContainer.setPreferredSize(new Dimension(190,43)); + buttonContainer.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); buttonContainer.setOpaque(false); UIButton button = new UIButton(Toolkit.i18nText("Fine-Design_Guide_Complete_End")){ @@ -92,6 +101,7 @@ public class GuideCompleteDialog extends JDialog { return new Dimension(122, 38); } }; + button.setFont(BUTTON_FONT); button.setUI(confirmButtonUI); button.setRoundBorder(true); button.setForeground(Color.WHITE); @@ -131,4 +141,11 @@ public class GuideCompleteDialog extends JDialog { } } }; + + private void changeLineSpacing(JTextPane pane, float factor, boolean replace) { + pane.selectAll(); + MutableAttributeSet set = new SimpleAttributeSet(pane.getParagraphAttributes()); + StyleConstants.setLineSpacing(set, factor); + pane.setParagraphAttributes(set, replace); + } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/GuideManageDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/GuideManageDialog.java index 07059ad05..98ea4c3c6 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/GuideManageDialog.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/GuideManageDialog.java @@ -74,7 +74,7 @@ public class GuideManageDialog extends JDialog { } private JPanel createGuideVersionPane(GuideVersion guideVersion) { - JPanel expandContent = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, VerticalFlowLayout.TOP, 0, 5); + JPanel expandContent = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, VerticalFlowLayout.TOP, 0, 10); for (GuideGroup guideGroup : guideVersion.getGuideGroupList()) { JPanel guideGroupCard = createGuideGroupCard(guideGroup); expandContent.add(guideGroupCard); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/bubble/BubbleWithClose.java b/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/bubble/BubbleWithClose.java index 904185ccb..62e0ed65d 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/bubble/BubbleWithClose.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/bubble/BubbleWithClose.java @@ -164,22 +164,23 @@ public class BubbleWithClose extends Bubble { return new Insets(lineSpace / 2 - 1, 0, lineSpace / 2, 0); } }; - changeLineSpacing(textArea, (float) lineSpace / 2 / lineHeight, true); - textArea.setText(str); + textArea.setFont(font); + changeLineSpacing(textArea, lineHeight, true); textArea.setEditable(false); textArea.setForeground(foreground); textArea.setDisabledTextColor(foreground); textArea.setBorder(null); - textArea.setFont(font); textArea.setOpaque(false); + textArea.setText(str); highlightText(textArea); return textArea; } - private void changeLineSpacing(JTextPane pane, float factor, boolean replace) { + private void changeLineSpacing(JTextPane pane, int lineHeight, boolean replace) { pane.selectAll(); MutableAttributeSet set = new SimpleAttributeSet(pane.getParagraphAttributes()); - StyleConstants.setLineSpacing(set, factor); + FontMetrics fontMetrics = GraphHelper.getFontMetrics(pane.getFont()); + StyleConstants.setLineSpacing(set, (float)(lineHeight - fontMetrics.getHeight()) / fontMetrics.getHeight()); pane.setParagraphAttributes(set, replace); } From 7c88137c5bf4ecc37bae5c85823021d204f09118 Mon Sep 17 00:00:00 2001 From: kuangshuai Date: Tue, 19 Oct 2021 00:48:10 +0800 Subject: [PATCH 7/9] =?UTF-8?q?REPORT-60942=20=E8=A7=86=E8=A7=89=E4=BC=98?= =?UTF-8?q?=E5=8C=96--=E9=AB=98=E4=BA=AE=E5=8C=BA=E5=9F=9F=E5=8A=A0?= =?UTF-8?q?=E4=B8=AA5=E5=83=8F=E7=B4=A0=E7=9A=84=E8=BE=B9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../guide/scene/AbstractGuideScene.java | 20 ++++++++- .../guide/creator/GuideCreateUtils.java | 43 +++++++++++++++++++ 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/guide/scene/AbstractGuideScene.java b/designer-base/src/main/java/com/fr/design/mainframe/guide/scene/AbstractGuideScene.java index 240244fff..95c7c24a4 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/guide/scene/AbstractGuideScene.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/guide/scene/AbstractGuideScene.java @@ -9,6 +9,7 @@ import com.fr.design.mainframe.guide.tip.BubbleTip; import com.fr.design.mainframe.guide.tip.GuideTip; import com.fr.stable.StringUtils; +import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JComponent; import javax.swing.JPanel; @@ -21,6 +22,7 @@ import java.awt.Composite; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; +import java.awt.Insets; import java.awt.Point; import java.awt.Rectangle; import java.awt.Window; @@ -33,6 +35,7 @@ import java.util.List; public abstract class AbstractGuideScene extends JPanel implements GuideScene { private static final int DEFAULT_ARROW_HEIGHT = 12; private static final int DEFAULT_ARROW_WIDTH = 18; + public static final Insets DEFAULT_HIGHLIGHT_INSETS = new Insets(5, 5, 5, 5); private GuideScene nextScene; private SceneFilter sceneFilter; @@ -169,9 +172,22 @@ public abstract class AbstractGuideScene extends JPanel implements GuideScene { private UILabel getTargetComponentWithImage(BufferedImage image, Rectangle rectangle) { ImageIcon ic = new ImageIcon(image); - UILabel label = new UILabel(ic); + UILabel label = new UILabel(ic){ + @Override + public Insets getInsets() { + return DEFAULT_HIGHLIGHT_INSETS; + } + }; + + label.setBorder(BorderFactory.createMatteBorder(DEFAULT_HIGHLIGHT_INSETS.top, DEFAULT_HIGHLIGHT_INSETS.left, DEFAULT_HIGHLIGHT_INSETS.bottom, DEFAULT_HIGHLIGHT_INSETS.right, Color.WHITE)); + label.setOpaque(true); - label.setBounds(rectangle); + label.setBounds(new Rectangle( + rectangle.x - DEFAULT_HIGHLIGHT_INSETS.left, + rectangle.y - DEFAULT_HIGHLIGHT_INSETS.top, + rectangle.width + DEFAULT_HIGHLIGHT_INSETS.left + DEFAULT_HIGHLIGHT_INSETS.right, + rectangle.height + DEFAULT_HIGHLIGHT_INSETS.top + DEFAULT_HIGHLIGHT_INSETS.bottom + )); return label; } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/GuideCreateUtils.java b/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/GuideCreateUtils.java index 2e25eaac7..864459276 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/GuideCreateUtils.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/GuideCreateUtils.java @@ -14,6 +14,7 @@ import com.fr.design.mainframe.FormCreatorDropTarget; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.JForm; import com.fr.design.mainframe.guide.base.GuideManager; +import com.fr.design.mainframe.guide.scene.AbstractGuideScene; import com.fr.design.mainframe.guide.utils.ScreenImage; import com.fr.design.utils.ComponentUtils; import com.fr.file.FileNodeFILE; @@ -24,6 +25,7 @@ import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; import com.fr.workspace.WorkContext; +import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JComponent; import javax.swing.JDialog; @@ -32,8 +34,10 @@ import javax.swing.JRootPane; import javax.swing.SwingUtilities; import javax.swing.UIManager; import java.awt.BorderLayout; +import java.awt.Color; import java.awt.Component; import java.awt.Container; +import java.awt.Insets; import java.awt.Point; import java.awt.Rectangle; import java.awt.Window; @@ -153,11 +157,50 @@ public class GuideCreateUtils { return new UILabel(ic); } + public static UILabel createTarget(JComponent component, boolean isModal, boolean withBorder) { + ImageIcon ic; + if (isModal) { + ic = new ImageIcon(ScreenImage.createImageWithModal(component)); + } else { + ic = new ImageIcon(ScreenImage.createImage(component)); + } + return createImageTarget(ic, withBorder); + } + + private static UILabel createImageTarget(ImageIcon ic, boolean withBorder) { + if (withBorder) { + Insets insets = AbstractGuideScene.DEFAULT_HIGHLIGHT_INSETS; + UILabel label = new UILabel(ic){ + @Override + public Insets getInsets() { + return insets; + } + }; + + label.setBorder(BorderFactory.createMatteBorder(insets.top, insets.left, insets.bottom, insets.right, Color.WHITE)); + label.setOpaque(true); + return label; + } else { + return new UILabel(ic); + } + } + public static Rectangle getRelativeBounds(Component component, Component parent, int x, int y) { Point point = SwingUtilities.convertPoint(parent,0,0, GuideManager.getInstance().getCurrentGuide().getGuideView().getRootPane()); return new Rectangle(point.x + x, point.y + y, component.getWidth(), component.getHeight()); } + public static Rectangle getRelativeBoundsWithBorder(Component component, Component parent, int x, int y) { + Rectangle rectangle = getRelativeBounds(component, parent, x, y); + Insets insets = AbstractGuideScene.DEFAULT_HIGHLIGHT_INSETS; + return new Rectangle( + rectangle.x - insets.left, + rectangle.y - insets.top, + rectangle.width + insets.left + insets.right, + rectangle.height + insets.top + insets.bottom + ); + } + public static String openGuideFile(String sourcePath, String fileName, String suffix) { String fileWorkPath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, FILE_PREFIX + UUID.randomUUID().toString() + suffix); InputStream inputStream = GuideCreateUtils.class.getResourceAsStream(StableUtils.pathJoin(sourcePath, fileName + suffix)); From 047317700841bf79520ff3bdb2b2b29cbb3a31fd Mon Sep 17 00:00:00 2001 From: vito Date: Tue, 19 Oct 2021 09:47:57 +0800 Subject: [PATCH 8/9] =?UTF-8?q?REPORT-60991=20=E5=AF=BC=E5=87=BA-=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E4=BA=8B=E4=BB=B6-=E5=85=B6=E5=AE=83=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF-=E5=8F=82=E6=95=B0=E8=AE=BE=E7=BD=AE=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=97=B6=E6=97=A0=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../javascript/ExportJavaScriptPane.java | 86 +++++++++++-------- 1 file changed, 50 insertions(+), 36 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java b/designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java index ba64b4d4d..8918ed961 100644 --- a/designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java +++ b/designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java @@ -50,9 +50,9 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; import java.awt.BorderLayout; import java.awt.CardLayout; -import java.awt.Color; import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -86,6 +86,7 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane { + if (e.getStateChange() == ItemEvent.SELECTED) { + final int row = table.getSelectedRow(); + if (row == -1) { return; } - SingleJavaScript js = getList().get(table.getSelectedRow()); + SingleJavaScript js = getList().get(row); Object ob = parameterSetting.getSelectedItem(); if (ob != null) { String value = ob.toString(); js.setExtendParameters(StringUtils.equals(value, DEFAULT)); } - fireTableDataChanged(); + table.repaint(); } }); } @@ -567,7 +566,7 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane(Arrays.asList((ParameterProvider[]) value))); + if (getList().get(row) == null || getList().get(row).isExtendParameters()) { + return EMPTY_LABEL; + } + ParameterProvider[] providers = (ParameterProvider[]) value; + if (providers != null) { + paraSettingPane.refresh(Arrays.asList(providers)); + } return paraButton; } @@ -624,6 +628,14 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane parameterList = this.parameterViewPane.update(); - parameterList.clear(); - ParameterProvider[] parameters = js.getParameters(); - this.parameterViewPane.populate(parameters); + if (this.parameterViewPane != null) { + List parameterList = this.parameterViewPane.update(); + parameterList.clear(); + ParameterProvider[] parameters = js.getParameters(); + this.parameterViewPane.populate(parameters); + } } } else { OtherTemplatePane pane = (OtherTemplatePane) this.templatePanel.getComponent(1); From 7e78ffd7e327118f2fd27fa4e284f542fdd7202a Mon Sep 17 00:00:00 2001 From: vito Date: Tue, 19 Oct 2021 09:56:16 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E6=97=A0jira=E4=BB=BB=E5=8A=A1=20=E6=BC=8F?= =?UTF-8?q?=E4=BA=86=E7=BC=96=E8=BE=91=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/javascript/ExportJavaScriptPane.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java b/designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java index 8918ed961..b559c22e6 100644 --- a/designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java +++ b/designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java @@ -548,9 +548,23 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane