From e1748fda1b5ab98f888de565f3e6ba1552e620f1 Mon Sep 17 00:00:00 2001 From: Starryi Date: Mon, 15 Nov 2021 10:18:03 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-62573=20=E3=80=90=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E5=8F=AF=E6=9B=B4=E6=96=B0=E6=8F=90=E9=86=92=E3=80=91=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=A4=8D=E7=94=A8-=E5=BA=94=E5=BD=93=E4=BB=85?= =?UTF-8?q?=E6=9C=89=E5=8F=AF=E6=9B=B4=E6=96=B0=E7=BB=84=E4=BB=B6=E7=9A=84?= =?UTF-8?q?=E5=88=86=E7=BB=84=E5=B1=95=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 重新实现组件分组面板可展开的逻辑 【改动思路】 同上 --- .../share/ui/block/LocalWidgetBlock.java | 2 +- .../mainframe/share/ui/local/GroupPane.java | 22 +++++++++++++------ .../share/ui/local/LocalWidgetRepoPane.java | 8 +++---- .../ui/local/LocalWidgetRepoUpdater.java | 8 +++++-- .../mainframe/share/ui/local/ManagePane.java | 2 +- 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java index 6839ee41f..e08c317d8 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java @@ -275,7 +275,7 @@ public class LocalWidgetBlock extends PreviewWidgetBlock if (getUpdater().isUpdating()) { paintLoadingIndicator(g2d, getUpdater().getProcessValue()); - } else if (LocalWidgetRepoUpdater.getInstance().checkUpdate(getWidget()) != null) { + } else if (LocalWidgetRepoUpdater.getInstance().checkUpdatable(getWidget())) { paintUpdatableMarker(g2d); } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/GroupPane.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/GroupPane.java index 905e9d87b..0a4aacfc9 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/GroupPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/GroupPane.java @@ -53,10 +53,6 @@ public class GroupPane extends JPanel { private SharableWidgetProvider[] elCaseBindInfoList; private SortType sortType = WidgetSortType.INSTALL_TIME; - private GroupPane(Group group) { - this(group, DEFAULT_HEIGHT, group.isDefaultExpend()); - } - private GroupPane(Group group, boolean expendStatus) { this(group, DEFAULT_HEIGHT, expendStatus); } @@ -90,7 +86,9 @@ public class GroupPane extends JPanel { //按照筛选条件进行过滤 elCaseBindInfoList = LocalWidgetFilter.getInstance().filter(elCaseBindInfoList); - boolean needExpendGroup = expendStatus || (isFiltering() && elCaseBindInfoList.length > 0); + boolean needExpendGroup = expendStatus + || (isFiltering() && elCaseBindInfoList.length > 0) + || hasUpdatableWidget(); if (elCaseBindInfoList.length == 0 && isFiltering()) { this.setVisible(false); } @@ -107,6 +105,16 @@ public class GroupPane extends JPanel { expendGroup(needExpendGroup); } + private boolean hasUpdatableWidget() { + for (SharableWidgetProvider provider: elCaseBindInfoList) { + boolean updatable = LocalWidgetRepoUpdater.getInstance().checkUpdatable(provider); + if (updatable) { + return true; + } + } + return false; + } + public LocalWidgetSelectPane getWidgetListPane() { return contentPanel; } @@ -375,7 +383,7 @@ public class GroupPane extends JPanel { DEFAULT { @Override public GroupPane creteGroupPane(Group group) { - return new GroupPane(group); + return new GroupPane(group, group.isDefaultExpend()); } }, EXPANDED { @@ -384,7 +392,7 @@ public class GroupPane extends JPanel { return new GroupPane(group, true); } }, - CLOSURE { + COLLAPSED { @Override public GroupPane creteGroupPane(Group group) { return new GroupPane(group, false); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/LocalWidgetRepoPane.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/LocalWidgetRepoPane.java index 522574ce0..d2ad2d6f5 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/LocalWidgetRepoPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/LocalWidgetRepoPane.java @@ -390,7 +390,7 @@ public class LocalWidgetRepoPane extends BasicPane { List updatableWidgetProviders = LocalWidgetRepoUpdater.getInstance().getUpdatableWidgetProviders(); updateTipPane.setVisible(updatableWidgetProviders.size() > 0); if (updatableWidgetProviders.size() > 0) { - refreshAllGroupPane(GroupPane.GroupCreateStrategy.EXPANDED); + refreshAllGroupPane(GroupPane.GroupCreateStrategy.DEFAULT); } } } @@ -413,7 +413,7 @@ public class LocalWidgetRepoPane extends BasicPane { toolbarPane.reset(); managePane.switchPanel(false); switchPane(LocalPaneStatus.NORMAL); - refreshAllGroupPane(GroupPane.GroupCreateStrategy.EXPANDED); + refreshAllGroupPane(GroupPane.GroupCreateStrategy.DEFAULT); List blockList = getUpdatableBlocks(); if (blockList.size() == 0) { @@ -428,7 +428,7 @@ public class LocalWidgetRepoPane extends BasicPane { LocalWidgetRepoUpdater updater = LocalWidgetRepoUpdater.getInstance(); for (LocalWidgetBlock block: blockList) { - OnlineShareWidget remoteLatestWidget = updater.checkUpdate(block.getWidget()); + OnlineShareWidget remoteLatestWidget = updater.findLatestRemoteWidget(block.getWidget()); block.getUpdater().updateWidget(remoteLatestWidget.getId(), new LocalWidgetUpdater.UpdateListener() { @Override public void onUpdated(boolean success, String group, String id) { @@ -505,7 +505,7 @@ public class LocalWidgetRepoPane extends BasicPane { LocalWidgetBlock widgetBlock = (LocalWidgetBlock) component; SharableWidgetProvider localProvider = widgetBlock.getWidget(); - OnlineShareWidget remoteLatestWidget = updater.checkUpdate(localProvider); + OnlineShareWidget remoteLatestWidget = updater.findLatestRemoteWidget(localProvider); if (remoteLatestWidget != null) { blockList.add(widgetBlock); } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/LocalWidgetRepoUpdater.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/LocalWidgetRepoUpdater.java index 03eb751f2..4cf949fad 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/LocalWidgetRepoUpdater.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/LocalWidgetRepoUpdater.java @@ -55,7 +55,11 @@ public class LocalWidgetRepoUpdater { remoteLatestWidgetsBackup.clear(); } - public OnlineShareWidget checkUpdate(SharableWidgetProvider provider) { + public boolean checkUpdatable(SharableWidgetProvider provider) { + return findLatestRemoteWidget(provider) != null; + } + + public OnlineShareWidget findLatestRemoteWidget(SharableWidgetProvider provider) { OnlineShareWidget remoteLatestWidget = remoteLatestWidgetsBackup.get(provider.getId()); if (remoteLatestWidget != null && StringUtils.isNotEmpty(remoteLatestWidget.getVersion())) { Version remoteLatestVersion = Version.create(remoteLatestWidget.getVersion()); @@ -76,7 +80,7 @@ public class LocalWidgetRepoUpdater { for (Group group: groups) { SharableWidgetProvider[] widgetProviders = group.getAllBindInfoList(); for (SharableWidgetProvider widgetProvider: widgetProviders) { - if (checkUpdate(widgetProvider) != null) { + if (checkUpdatable(widgetProvider)) { updatableProviders.add(widgetProvider); } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/ManagePane.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/ManagePane.java index 67e2efe3f..387c1a135 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/ManagePane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/ManagePane.java @@ -135,7 +135,7 @@ class ManagePane extends JPanel implements ShareUIAspect { String userInput = getFileName().replaceAll("[\\\\/:*?\"<>|]", StringUtils.EMPTY); //新建分组,刷新显示 if (DefaultShareGroupManager.getInstance().createGroup(userInput)) { - LocalWidgetRepoPane.getInstance().refreshAllGroupPane(GroupPane.GroupCreateStrategy.CLOSURE); + LocalWidgetRepoPane.getInstance().refreshAllGroupPane(GroupPane.GroupCreateStrategy.COLLAPSED); } else { ShareUIUtils.showErrorMessageDialog(Toolkit.i18nText("Fine-Design_Basic_Make_Failure")); }