From ddf9d42ea3bb5c6caf19d4527fa0bccba7f92bb6 Mon Sep 17 00:00:00 2001 From: kuangshuai Date: Mon, 25 Oct 2021 19:41:59 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-61521=20=E4=B8=BB=E9=A2=98=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E5=BC=95=E5=AF=BC=E9=A1=B5=E5=8A=A0=E8=BD=BD=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../share/ui/online/OnlineWidgetRepoPane.java | 13 +++++++++- .../share/ui/online/OnlineWidgetTabPane.java | 24 ++++++++++++++++++- .../theme/DownloadComponentPackageGuide.java | 1 + 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetRepoPane.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetRepoPane.java index 2d8bcfdbef..3a1df9f723 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetRepoPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetRepoPane.java @@ -95,7 +95,7 @@ public class OnlineWidgetRepoPane extends BasicPane { setContent(); } - private void setContent() { + public void setContent() { if (sharableWidgets != null) { initContentPane(); addCenterPane(); @@ -144,14 +144,25 @@ public class OnlineWidgetRepoPane extends BasicPane { private boolean initContentPane() { boolean loadWidgetsSuccess = loadWidgets(); if (loadWidgetsSuccess) { + if (componentTabPane != null) { + componentTabPane.removeTabChangeListener(tabChangeListener); + } this.componentTabPane = new OnlineWidgetTabPane(sharableWidgets[0].toArray(new OnlineShareWidget[sharableWidgets[0].size()]), sharableWidgets[1].toArray(new OnlineShareWidget[sharableWidgets[1].size()])); + this.componentTabPane.addTabChangeListener(tabChangeListener); } else { switchPane(Status.DISCONNECTED); } return loadWidgetsSuccess; } + private OnlineWidgetTabPane.TabChangeListener tabChangeListener = new OnlineWidgetTabPane.TabChangeListener() { + @Override + public void tabChange(int selectedIndex) { + setShowPackagePanel(selectedIndex != 0); + } + }; + private void reload() { this.removeAll(); sharableWidgets = null; diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetTabPane.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetTabPane.java index 96837fd3c1..4553f7879c 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetTabPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetTabPane.java @@ -10,6 +10,9 @@ import javax.swing.BorderFactory; import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.CardLayout; +import java.util.ArrayList; +import java.util.EventListener; +import java.util.List; /** * Created by kerry on 2020-10-19 @@ -20,8 +23,10 @@ public class OnlineWidgetTabPane extends JPanel { private CardLayout cardLayout; private JPanel centerPane; private boolean packagePaneCreated = false; + private List tabChangeListeners; public OnlineWidgetTabPane(OnlineShareWidget[] sharableWidgets, OnlineShareWidget[] sharableWidgetPackage) { + tabChangeListeners = new ArrayList<>(); initPane(sharableWidgets, sharableWidgetPackage); } @@ -33,7 +38,9 @@ public class OnlineWidgetTabPane extends JPanel { //延迟组件包面板的初始化,防止组件面板里组件的缩略图和组件包面板里组件的缩略图一起加载 UITabGroup headGroup = new UITabGroup(new String[]{COMPONENT, COMPONENT_PACKAGE}) { public void tabChanged(int newSelectedIndex) { - OnlineWidgetRepoPane.getInstance().setShowPackagePanel(newSelectedIndex != 0); + for (TabChangeListener changeListener : tabChangeListeners) { + changeListener.tabChange(newSelectedIndex); + } if (newSelectedIndex == 0) { cardLayout.show(centerPane, COMPONENT); } else { @@ -45,6 +52,7 @@ public class OnlineWidgetTabPane extends JPanel { } cardLayout.show(centerPane, COMPONENT_PACKAGE); } + } }; headGroup.setSelectedIndex(0); @@ -55,4 +63,18 @@ public class OnlineWidgetTabPane extends JPanel { this.add(jPanel, BorderLayout.NORTH); this.add(centerPane, BorderLayout.CENTER); } + + public void addTabChangeListener(TabChangeListener listener) { + if (!tabChangeListeners.contains(listener)) { + tabChangeListeners.add(listener); + } + } + + public void removeTabChangeListener(TabChangeListener listener) { + tabChangeListeners.remove(listener); + } + + public interface TabChangeListener extends EventListener { + void tabChange(int selectedIndex); + } } 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 f5d8bf57f4..5d878a3c21 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 @@ -102,6 +102,7 @@ public class DownloadComponentPackageGuide { EastRegionContainerPane.getInstance().showContainer(); EastRegionContainerPane.getInstance().switchTabTo(EastRegionContainerPane.KEY_WIDGET_SETTINGS); OnlineWidgetRepoPane onlineWidgetRepoPane = OnlineWidgetRepoPane.getInstance(); + onlineWidgetRepoPane.setContent(); OnlineWidgetTabPane tabPane = (OnlineWidgetTabPane) ComponentUtils.findComponentByClass(onlineWidgetRepoPane, OnlineWidgetTabPane.class); UITabGroup tabGroup = (UITabGroup) ComponentUtils.findComponentByClass(tabPane, UITabGroup.class); JPanel centerPane = (JPanel) tabPane.getComponent(1);