From 78aab5a8781ff246e38bbdb9f3e6d7c4b31fc10f Mon Sep 17 00:00:00 2001 From: kerry Date: Fri, 12 Nov 2021 14:33:20 +0800 Subject: [PATCH 1/3] =?UTF-8?q?REPORT-62400=20&&=20REPORT-62399=20&&=20REP?= =?UTF-8?q?ORT-62547=E3=80=90=E6=8E=A5=E8=A7=A6=E7=82=B9=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E3=80=91=E6=8B=96=E6=8B=BD=E5=8A=A8=E6=95=88=E5=87=BA=E7=8E=B0?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E9=A2=84=E8=A7=88=E5=9B=BE=E4=B8=8D=E6=B6=88?= =?UTF-8?q?=E5=A4=B1=EF=BC=9B=E3=80=90=E6=8E=A5=E8=A7=A6=E7=82=B9=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E3=80=91=E8=BD=AE=E6=92=AD=E7=9A=84=E5=90=8C=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E9=BC=A0=E6=A0=87=E6=82=AC=E6=B5=AE=E5=9C=A8=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E4=B8=8A=EF=BC=8C=E8=BD=AE=E6=92=AD=E5=9B=BE=E4=B8=8D?= =?UTF-8?q?=E6=B6=88=E5=A4=B1=EF=BC=8C=E4=B8=8E=E7=BB=84=E4=BB=B6=E9=A2=84?= =?UTF-8?q?=E8=A7=88=E5=9B=BE=E5=90=8C=E6=97=B6=E5=87=BA=E7=8E=B0=EF=BC=9B?= =?UTF-8?q?=E3=80=90=E6=8E=A5=E8=A7=A6=E7=82=B9=E4=BC=98=E5=8C=96=E3=80=91?= =?UTF-8?q?=E8=BD=AE=E6=92=AD=E7=9A=84=E5=9B=BE=E7=89=87=E5=9B=BA=E5=AE=9A?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=EF=BC=8C=E5=AF=BC=E8=87=B4=E9=A2=84=E8=A7=88?= =?UTF-8?q?=E5=9B=BE=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../embed/OnlineEmbedFilterSelectPane.java | 4 +++- .../share/ui/online/embed/PreviewDialog.java | 18 ++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/OnlineEmbedFilterSelectPane.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/OnlineEmbedFilterSelectPane.java index b7f62e564..0d3a757f3 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/OnlineEmbedFilterSelectPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/OnlineEmbedFilterSelectPane.java @@ -95,7 +95,7 @@ public class OnlineEmbedFilterSelectPane extends AbstractOnlineWidgetSelectPane this.doLayout(); this.validate(); this.repaint(); - previewDialog.setImage(getPreviewImage(shareWidget)); + previewDialog.setImage(getPreviewImage(shareWidget), widgetPane.getLocationOnScreen()); //展示弹出框 service.schedule(new Runnable() { @Override @@ -114,6 +114,7 @@ public class OnlineEmbedFilterSelectPane extends AbstractOnlineWidgetSelectPane if (!CarouselStateManger.getInstance().isSuspend()) { showCurrentLoadBlock(integer, widgetPane); } else { + previewDialog.setVisible(false); pollingCarouselState(integer, widgetPane); } } @@ -130,6 +131,7 @@ public class OnlineEmbedFilterSelectPane extends AbstractOnlineWidgetSelectPane return; } if (!CarouselStateManger.getInstance().isSuspend()) { + previewDialog.setVisible(true); showCurrentLoadBlock(integer, widgetPane); service.shutdown(); } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/PreviewDialog.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/PreviewDialog.java index 086f4d2bd..3ef29c8cb 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/PreviewDialog.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/PreviewDialog.java @@ -6,35 +6,33 @@ import com.fr.design.mainframe.EastRegionContainerPane; import javax.swing.ImageIcon; import javax.swing.JDialog; +import java.awt.Dimension; import java.awt.Image; +import java.awt.Point; /** * Created by kerry on 2021/10/22 */ public class PreviewDialog extends JDialog { + private static final int OFFSET_Y = 9; public PreviewDialog() { super(DesignerContext.getDesignerFrame()); setUndecorated(true); - setSize(300, 300); - adjustLocation(); this.setVisible(false); } - public void setImage(Image image) { + public void setImage(Image image, Point point) { this.getContentPane().removeAll(); this.getContentPane().add(new UILabel(new ImageIcon(image))); + int width = image.getWidth(null); + this.setSize(width, image.getHeight(null)); + this.setLocation(point.x - width, point.y + OFFSET_Y); this.doLayout(); + this.validate(); this.repaint(); } - public void adjustLocation() { - - this.setLocation( - EastRegionContainerPane.getInstance().getX() - 300, - 20 - ); - } } From e7355039d81200f49accf92ff31aea7749ff7d07 Mon Sep 17 00:00:00 2001 From: kerry Date: Mon, 15 Nov 2021 16:22:05 +0800 Subject: [PATCH 2/3] =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/DesignerCloudURLManager.java | 4 +-- .../mainframe/share/ComponentShareUtil.java | 2 +- .../mainframe/FormWidgetDetailPane.java | 33 ++++++++++++------- .../share/ui/block/PreviewWidgetBlock.java | 3 +- .../embed/OnlineEmbedFilterSelectPane.java | 20 +++++++---- 5 files changed, 39 insertions(+), 23 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/DesignerCloudURLManager.java b/designer-base/src/main/java/com/fr/design/DesignerCloudURLManager.java index c6e5e18cf..240733a72 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerCloudURLManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerCloudURLManager.java @@ -63,7 +63,7 @@ public class DesignerCloudURLManager implements XMLable { executorService.submit(() -> { updateURLXMLFile(key, latestUrl); }); - return url; + return latestUrl; } //本地缓存不为空时,直接返回对应 url,同时异步更新 executorService.submit(() -> { @@ -74,7 +74,7 @@ public class DesignerCloudURLManager implements XMLable { } private synchronized void updateURLXMLFile(String key, String url) { - if (!urlMap.containsKey(key) || !url.equals(urlMap.get(key))) { + if (StringUtils.isNotEmpty(url) && (!urlMap.containsKey(key) || !url.equals(urlMap.get(key)))) { urlMap.put(key, url); saveURLXMLFile(); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/share/ComponentShareUtil.java b/designer-base/src/main/java/com/fr/design/mainframe/share/ComponentShareUtil.java index db53be726..dbf983993 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/share/ComponentShareUtil.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/share/ComponentShareUtil.java @@ -66,7 +66,7 @@ public class ComponentShareUtil { * @return boolean */ public static boolean needShowFirstDragAnimate() { - return ComponentReuseNotificationInfo.getInstance().isFirstDrag() && !hasTouched(); + return ComponentReuseNotificationInfo.getInstance().isFirstDrag(); } /** diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java b/designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java index 5bf6a9385..205316cd1 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java @@ -13,7 +13,6 @@ import com.fr.design.mainframe.share.ui.local.LocalWidgetRepoPane; import com.fr.design.mainframe.share.ui.online.OnlineWidgetRepoPane; import com.fr.general.locale.LocaleCenter; import com.fr.general.locale.LocaleMark; - import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JPanel; @@ -33,13 +32,15 @@ import java.util.List; * Date: 14-7-8 * Time: 下午8:18 */ -public class FormWidgetDetailPane extends FormDockView{ +public class FormWidgetDetailPane extends FormDockView { private static final int ONLINE_TAB = 1; private JPanel centerPane; private UIHeadGroup headGroup; private List paneList; private CardLayout cardLayout; + //用来标记当前组件库界面是否处于已触达状态 + private boolean hasTouched = false; private boolean isEmptyPane = false; @@ -50,7 +51,7 @@ public class FormWidgetDetailPane extends FormDockView{ return HOLDER.singleton; } - private FormWidgetDetailPane(){ + private FormWidgetDetailPane() { setLayout(FRGUIPaneFactory.createBorderLayout()); } @@ -77,7 +78,7 @@ public class FormWidgetDetailPane extends FormDockView{ /** * 初始化 */ - public void refreshDockingView(){ + public void refreshDockingView() { if (isEmptyPane) { return; } @@ -87,18 +88,18 @@ public class FormWidgetDetailPane extends FormDockView{ clearDockingView(); return; } - + hasTouched = ComponentShareUtil.hasTouched(); initPaneList(); this.setBorder(null); cardLayout = new CardLayout(); centerPane = new JPanel(cardLayout); String[] paneNames = new String[paneList.size()]; for (int i = 0; i < paneList.size(); i++) { - String title = paneList.get(i).getTitle(); + String title = paneList.get(i).getTitle(); paneNames[i] = title; centerPane.add(paneList.get(i), title); } - headGroup = new UIHeadGroup(paneNames) { + headGroup = new UIHeadGroup(paneNames) { protected void tabChanged(int newSelectedIndex) { //初始化还未展示的时候不需要收集其 marketClick if (this.isShowing() && newSelectedIndex == 1) { @@ -106,20 +107,28 @@ public class FormWidgetDetailPane extends FormDockView{ } cardLayout.show(centerPane, paneList.get(newSelectedIndex).getTitle()); } - }; + }; headGroup.setSelectedIndex(ComponentShareUtil.needSwitch2OnlineTab() ? ONLINE_TAB : 0); this.add(headGroup, BorderLayout.NORTH); this.add(centerPane, BorderLayout.CENTER); } + /** + * 判断是否可触达 + * + * @return boolean + */ + public boolean hasTouched() { + return hasTouched; + } + - public void resetEmptyPane(){ + public void resetEmptyPane() { this.isEmptyPane = false; } - /** * 清除数据 */ @@ -129,7 +138,7 @@ public class FormWidgetDetailPane extends FormDockView{ this.add(psp, BorderLayout.CENTER); } - public void switch2Empty(){ + public void switch2Empty() { isEmptyPane = true; this.removeAll(); JPanel panel = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 5); @@ -162,7 +171,7 @@ public class FormWidgetDetailPane extends FormDockView{ } - public void enterWidgetLib() { + public void enterWidgetLib() { ComponentReuseNotifyUtil.enterWidgetLibExtraAction(); EastRegionContainerPane.getInstance().switchTabTo(EastRegionContainerPane.KEY_WIDGET_LIB); } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/PreviewWidgetBlock.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/PreviewWidgetBlock.java index 949719b85..425e3e1ca 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/PreviewWidgetBlock.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/PreviewWidgetBlock.java @@ -5,6 +5,7 @@ import com.fr.design.DesignerEnvManager; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.EastRegionContainerPane; +import com.fr.design.mainframe.FormWidgetDetailPane; import com.fr.design.mainframe.reuse.ComponentReuseNotificationInfo; import com.fr.design.mainframe.share.ComponentShareUtil; import com.fr.design.mainframe.share.collect.ComponentCollector; @@ -147,7 +148,7 @@ public abstract class PreviewWidgetBlock extends JPanel implements MouseListe @Override public void mouseEntered(MouseEvent e) { hover = true; - if (ComponentShareUtil.needShowFirstDragAnimate() && checkWidget()) { + if (ComponentShareUtil.needShowFirstDragAnimate() && !FormWidgetDetailPane.getInstance().hasTouched() && checkWidget()) { schedule(ANIMATE_START_TIME); awtEventListener = event -> { if (!this.isShowing()) { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/OnlineEmbedFilterSelectPane.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/OnlineEmbedFilterSelectPane.java index 0d3a757f3..6ef729ce3 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/OnlineEmbedFilterSelectPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/OnlineEmbedFilterSelectPane.java @@ -46,13 +46,18 @@ public class OnlineEmbedFilterSelectPane extends AbstractOnlineWidgetSelectPane awtEventListener = event -> { if (event instanceof MouseEvent) { if (((MouseEvent) event).getClickCount() > 0) { - Point selectPanePoint = OnlineEmbedFilterSelectPane.this.getLocationOnScreen(); - Dimension selectPaneDimension = OnlineEmbedFilterSelectPane.this.getSize(); - Rectangle selectPaneRec = new Rectangle(selectPanePoint.x, selectPanePoint.y, selectPaneDimension.width, selectPaneDimension.height); - if (CarouselStateManger.getInstance().running() && - !selectPaneRec.contains(((MouseEvent) event).getLocationOnScreen())) { - CarouselStateManger.getInstance().stop(); + try { + Point selectPanePoint = OnlineEmbedFilterSelectPane.this.getLocationOnScreen(); + Dimension selectPaneDimension = OnlineEmbedFilterSelectPane.this.getSize(); + Rectangle selectPaneRec = new Rectangle(selectPanePoint.x, selectPanePoint.y, selectPaneDimension.width, selectPaneDimension.height); + if (CarouselStateManger.getInstance().running() && + !selectPaneRec.contains(((MouseEvent) event).getLocationOnScreen())) { + CarouselStateManger.getInstance().stop(); + } + } catch (Exception e) { + //忽略 } + } } @@ -82,9 +87,10 @@ public class OnlineEmbedFilterSelectPane extends AbstractOnlineWidgetSelectPane public void animate() throws InterruptedException { CarouselStateManger.getInstance().countDownLatchAwait(); - AtomicInteger integer = new AtomicInteger(showWidgets.length-1); + AtomicInteger integer = new AtomicInteger(showWidgets.length - 1); showCurrentLoadBlock(integer, widgetPane); this.repaint(); + CarouselStateManger.getInstance().start(); previewDialog.setVisible(true); } From fd7a89abd349ebb97eae2bd0067f4a5c5f82b883 Mon Sep 17 00:00:00 2001 From: kerry Date: Mon, 15 Nov 2021 17:38:37 +0800 Subject: [PATCH 3/3] REPORT-62623 && REPORT-62399 && REPORT-62547 && REPORT-62626 && REPORT-62400 && REPORT-62542 && REPORT-62544 --- .../share/ui/online/CarouselStateManger.java | 12 ---- .../embed/OnlineEmbedFilterSelectPane.java | 57 +++++++++++++------ 2 files changed, 39 insertions(+), 30 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/CarouselStateManger.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/CarouselStateManger.java index a0265d536..078fe4110 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/CarouselStateManger.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/CarouselStateManger.java @@ -4,14 +4,11 @@ package com.fr.design.mainframe.share.ui.online; import com.fr.general.ComparatorUtils; import com.fr.stable.StringUtils; -import java.util.concurrent.CountDownLatch; - /** * Created by kerry on 2021/10/22 */ public class CarouselStateManger { - private static final String START_CAROUSEL ="START_CAROUSEL"; public static final String RIGHT_CLICK ="RIGHT_CLICK"; public static final String DOWNLOAD_COMPONENT ="DOWNLOAD_COMPONENT"; public static final String FIRST_DRAG_ANIMATE ="FIRST_DRAG_ANIMATE"; @@ -19,7 +16,6 @@ public class CarouselStateManger { private CarouseState state; - private final CountDownLatch countDownLatch = new CountDownLatch(1); private String suspendEvent; @@ -36,14 +32,6 @@ public class CarouselStateManger { } - public void countDown() { - countDownLatch.countDown(); - } - - public void countDownLatchAwait() throws InterruptedException { - countDownLatch.await(); - } - public void start() { this.state = CarouseState.RUNNING; } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/OnlineEmbedFilterSelectPane.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/OnlineEmbedFilterSelectPane.java index 6ef729ce3..120a396b6 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/OnlineEmbedFilterSelectPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/OnlineEmbedFilterSelectPane.java @@ -7,11 +7,9 @@ import com.fr.design.mainframe.share.ui.online.CarouselStateManger; import com.fr.design.mainframe.share.ui.widgetfilter.FilterPane; import com.fr.form.share.base.DataLoad; import com.fr.form.share.bean.OnlineShareWidget; -import com.fr.form.share.constants.ShareComponentConstants; -import com.fr.log.FineLoggerFactory; +import com.fr.form.share.exception.NetWorkFailedException; +import com.fr.general.http.HttpClient; import com.fr.module.ModuleContext; -import com.fr.stable.EncodeConstants; -import com.fr.third.springframework.web.util.UriUtils; import javax.imageio.ImageIO; import javax.swing.JPanel; @@ -24,7 +22,8 @@ import java.awt.Rectangle; import java.awt.event.AWTEventListener; import java.awt.event.MouseEvent; import java.io.IOException; -import java.net.URL; +import java.net.HttpURLConnection; +import java.util.concurrent.CountDownLatch; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @@ -34,10 +33,12 @@ import java.util.concurrent.atomic.AtomicInteger; */ public class OnlineEmbedFilterSelectPane extends AbstractOnlineWidgetSelectPane { private static final String CAROUSEL_PREVIEW = "carousel_preview"; + private static final int CAROUSE_IMAGE_LOAD_TIMEOUT = 2000; private OnlineShareWidget[] showWidgets; private PreviewDialog previewDialog; private JPanel widgetPane; + private final CountDownLatch countDownLatch = new CountDownLatch(1); private final AWTEventListener awtEventListener; @@ -82,11 +83,11 @@ public class OnlineEmbedFilterSelectPane extends AbstractOnlineWidgetSelectPane protected void fireAfterDataLoad() { super.fireAfterDataLoad(); - CarouselStateManger.getInstance().countDown(); + countDownLatch.countDown(); } public void animate() throws InterruptedException { - CarouselStateManger.getInstance().countDownLatchAwait(); + countDownLatch.await(); AtomicInteger integer = new AtomicInteger(showWidgets.length - 1); showCurrentLoadBlock(integer, widgetPane); this.repaint(); @@ -94,6 +95,22 @@ public class OnlineEmbedFilterSelectPane extends AbstractOnlineWidgetSelectPane previewDialog.setVisible(true); } + private Image getPreviewImage(String url) throws NetWorkFailedException { + HttpClient httpClient = new HttpClient(url); + httpClient.setTimeout(CAROUSE_IMAGE_LOAD_TIMEOUT); + httpClient.asGet(); + int responseCode = httpClient.getResponseCode(); + if (responseCode != HttpURLConnection.HTTP_OK) { + throw new NetWorkFailedException(); + } + try { + return ImageIO.read(httpClient.getResponseStream()); + } catch (IOException e) { + throw new NetWorkFailedException(); + } + + } + private void showCurrentLoadBlock(AtomicInteger integer, JPanel widgetPane) { ScheduledExecutorService service = createToastScheduleExecutorService(); OnlineShareWidget shareWidget = showWidgets[integer.get()]; @@ -101,7 +118,13 @@ public class OnlineEmbedFilterSelectPane extends AbstractOnlineWidgetSelectPane this.doLayout(); this.validate(); this.repaint(); - previewDialog.setImage(getPreviewImage(shareWidget), widgetPane.getLocationOnScreen()); + try { + previewDialog.setImage(getPreviewImage(shareWidget.getPicPath()), widgetPane.getLocationOnScreen()); + } catch (NetWorkFailedException e) { + this.stopCarouse(integer, false); + this.switchPane(PaneStatue.DISCONNECTED); + return; + } //展示弹出框 service.schedule(new Runnable() { @Override @@ -146,11 +169,18 @@ public class OnlineEmbedFilterSelectPane extends AbstractOnlineWidgetSelectPane } private void stopCarouse(AtomicInteger integer) { + this.stopCarouse(integer, true); + } + + private void stopCarouse(AtomicInteger integer, boolean showExtra) { previewDialog.setVisible(false); - loadRestShowWidgets(integer.get() - 1); + if (showExtra) { + loadRestShowWidgets(integer.get() - 1); + } java.awt.Toolkit.getDefaultToolkit().removeAWTEventListener(awtEventListener); } + private void loadRestShowWidgets(int startIndex) { for (int i = startIndex; i >= 0; i--) { OnlineShareWidget shareWidget = showWidgets[i]; @@ -161,15 +191,6 @@ public class OnlineEmbedFilterSelectPane extends AbstractOnlineWidgetSelectPane this.repaint(); } - public Image getPreviewImage(OnlineShareWidget widget) { - try { - return ImageIO.read(new URL(UriUtils.encodePath(widget.getPicPath(), EncodeConstants.ENCODING_UTF_8))); - } catch (IOException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - return ShareComponentConstants.DEFAULT_COVER; - } - } - private ScheduledExecutorService createToastScheduleExecutorService() { return ModuleContext.getExecutor().newSingleThreadScheduledExecutor(new NamedThreadFactory(CAROUSEL_PREVIEW)); }