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 c6e5e18cf5..240733a72c 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 db53be7264..dbf9839935 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 5bf6a93855..205316cd17 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/LocalWidgetBlock.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java index e08c317d89..72eb35d000 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 @@ -1,5 +1,6 @@ package com.fr.design.mainframe.share.ui.block; +import com.fr.base.FRContext; import com.fr.base.GraphHelper; import com.fr.base.iofile.attr.SharableAttrMark; import com.fr.design.base.mode.DesignModeContext; @@ -38,8 +39,10 @@ import org.jetbrains.annotations.Nullable; import javax.swing.Action; import javax.swing.Icon; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JPopupMenu; +import javax.swing.UIManager; import java.awt.AlphaComposite; import java.awt.BorderLayout; import java.awt.Color; @@ -57,6 +60,7 @@ import java.awt.dnd.DnDConstants; import java.awt.event.ActionEvent; import java.awt.event.MouseEvent; import java.awt.font.FontRenderContext; +import java.awt.font.LineMetrics; import java.awt.geom.Dimension2D; import java.awt.image.BufferedImage; import java.util.UUID; @@ -224,7 +228,10 @@ public class LocalWidgetBlock extends PreviewWidgetBlock } if (!widget.isCompatibleWithCurrentEnv()) { FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), - Toolkit.i18nText("Fine-Design_Share_Drag_And_Make_Incompatible_Component_Tip") + Toolkit.i18nText("Fine-Design_Share_Drag_And_Make_Incompatible_Component_Tip"), + Toolkit.i18nText("Fine-Design_Basic_Error"), + JOptionPane.ERROR_MESSAGE, + UIManager.getIcon("OptionPane.errorIcon") ); return; } @@ -293,17 +300,17 @@ public class LocalWidgetBlock extends PreviewWidgetBlock double canvasH = coverDim.getHeight(); g2d.setColor(new Color(0.0F, 0.0F, 0.0F, 0.4F)); - GraphHelper.fillRect(g2d, canvasX, canvasY, canvasW, canvasH - 16); + GraphHelper.fillRect(g2d, canvasX, canvasY, canvasW, canvasH); g2d.setColor(new Color(0.0F, 0.0F, 0.0F, 0.5F)); GraphHelper.fillRect(g2d, canvasX, canvasH - 16, canvasW, 16); String tipText = Toolkit.i18nText("Fine-Design_Share_Incompatible_Version_Tip"); - Font tipFont = FRFont.getInstance().deriveFont(8F); + Font tipFont = FRContext.getDefaultValues().getFRFont().deriveFont(8.0F); FontRenderContext frc = g2d.getFontRenderContext(); double tipTextWidth = GraphHelper.stringWidth(tipText, tipFont, frc); - Dimension2D dim = GraphHelper.stringDimensionWithRotation(tipText, tipFont, 0, frc); - double tipTextHeight = dim.getHeight(); + LineMetrics metrics = tipFont.getLineMetrics(tipText, frc); + double tipTextHeight = metrics.getHeight(); g2d.setColor(Color.WHITE); g2d.setFont(tipFont); GraphHelper.drawString(g2d, tipText, canvasX + (canvasW - tipTextWidth) / 2.0F, canvasY + canvasH - (16 - tipTextHeight) / 2.0F); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetUpdater.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetUpdater.java index 083df1b4e7..68a3123f78 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetUpdater.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetUpdater.java @@ -11,6 +11,9 @@ import com.fr.design.mainframe.share.util.ShareComponentUtils; import com.fr.design.ui.util.UIUtil; import com.fr.form.share.DefaultSharableWidget; import com.fr.form.share.Group; +import com.fr.form.share.GroupManege; +import com.fr.form.share.SharableWidgetProvider; +import com.fr.form.share.group.DefaultShareGroupManager; import com.fr.log.FineLoggerFactory; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; @@ -20,7 +23,6 @@ import java.awt.Component; import java.awt.Container; import java.io.File; import java.io.IOException; -import java.util.concurrent.ExecutionException; /** * @author Starryi @@ -103,9 +105,12 @@ public class LocalWidgetUpdater implements Process { boolean success = false; try { success = get(); - } catch (InterruptedException | ExecutionException e) { + } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } + if (success) { + resetWidgetOfBlock(); + } if (updateListener != null) { updateListener.onUpdated(success, getGroup().getGroupName(), widget.getId()); } @@ -115,19 +120,38 @@ public class LocalWidgetUpdater implements Process { worker.execute(); } + private void resetWidgetOfBlock() { + GroupManege groupManege = DefaultShareGroupManager.getInstance(); + Group group = groupManege.getGroup(getGroup().getGroupName()); + if (group != null) { + String id = widgetBlock.getWidgetUuid(); + if (StringUtils.isNotEmpty(id)) { + SharableWidgetProvider localLatestWidget = group.getElCaseBindInfoById(widgetBlock.getWidgetUuid()); + if (localLatestWidget instanceof DefaultSharableWidget) { + widgetBlock.widget = (DefaultSharableWidget) localLatestWidget; + repaintBlockAndOverlay(); + } + } + } + } + public void cancelUpdate() { - if (worker.isDone() || worker.isCancelled()) { - return; + if (worker != null && !worker.isDone()) { + worker.cancel(true); + worker = null; } - worker.cancel(true); + process(-1.0); } @Override public void process(Double processValue) { this.processValue = processValue; + repaintBlockAndOverlay(); + } - UIUtil.invokeAndWaitIfNeeded(new Runnable() { + private void repaintBlockAndOverlay() { + UIUtil.invokeLaterIfNeeded(new Runnable() { @Override public void run() { Container absoluteLayoutParent = getAbsoluteLayoutAncestor(widgetBlock); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/OnlineWidgetBlock.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/OnlineWidgetBlock.java index 9f5873771c..cd4163b4b5 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/OnlineWidgetBlock.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/OnlineWidgetBlock.java @@ -357,6 +357,9 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock { if (isUnusable) { paintUnusableMask((Graphics2D) g); } + if (this.parentPane != null) { + this.parentPane.refreshShowPaneUI(); + } } protected void paintUnusableMask(Graphics2D g2d) { @@ -393,14 +396,12 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock { g2d.setColor(oldColor); g2d.setFont(oldFont); + } @Override public void repaint() { super.repaint(); - if (this.parentPane != null) { - this.parentPane.refreshUI(); - } } class WidgetDownloadProcess implements com.fr.design.extra.Process { 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 949719b852..425e3e1ca3 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/AbstractOnlineWidgetSelectPane.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/AbstractOnlineWidgetSelectPane.java index 4221e4b968..53239700d0 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/AbstractOnlineWidgetSelectPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/AbstractOnlineWidgetSelectPane.java @@ -242,7 +242,7 @@ public abstract class AbstractOnlineWidgetSelectPane extends AbstractWidgetSele return this.getParent(); } - public void refreshUI() { - OnlineWidgetRepoPane.getInstance().repaint(); + public void refreshShowPaneUI() { + OnlineWidgetRepoPane.getInstance().refreshShowPaneUI(); } } 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 a0265d536d..078fe41105 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/OnlineWidgetRepoPane.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetRepoPane.java index fcc59771e6..b9e430fe46 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 @@ -228,6 +228,12 @@ public class OnlineWidgetRepoPane extends BasicPane { } } + public void refreshShowPaneUI(){ + if (componentTabPane != null) { + this.componentTabPane.refreshShowPaneUI(); + } + } + public void completeEmbedFilter(){ if (componentTabPane != 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 96c3e28258..b48b74e67d 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 @@ -87,6 +87,13 @@ public class OnlineWidgetTabPane extends JPanel { this.cardLayout.show(centerPane, ComponentShareUtil.needShowEmbedFilterPane() ? COMPONENT_EMBED : COMPONENT); } + public void refreshShowPaneUI(){ + if (embedFilterShowPane != null) { + this.embedFilterShowPane.refreshUI(); + } + } + + public void removeTabChangeListener(TabChangeListener listener) { tabChangeListeners.remove(listener); } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/EmbedPane.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/EmbedPane.java index 04680753b7..bf535b367f 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/EmbedPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/EmbedPane.java @@ -86,7 +86,7 @@ public class EmbedPane extends JPanel { protected void paintBorder(Graphics g, UIButton b) { Color oldColor = g.getColor(); g.setColor(SEARCH_BUTTON_COLOR); - g.drawRoundRect(0, 0, b.getWidth(), b.getHeight(), 2, 2); + g.drawRoundRect(0, 0, b.getWidth() - 4, b.getHeight() - 4, 2, 2); g.setColor(oldColor); } }); 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 b7f62e5644..120a396b62 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; @@ -46,13 +47,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) { + //忽略 } + } } @@ -77,17 +83,34 @@ public class OnlineEmbedFilterSelectPane extends AbstractOnlineWidgetSelectPane protected void fireAfterDataLoad() { super.fireAfterDataLoad(); - CarouselStateManger.getInstance().countDown(); + countDownLatch.countDown(); } public void animate() throws InterruptedException { - CarouselStateManger.getInstance().countDownLatchAwait(); - AtomicInteger integer = new AtomicInteger(showWidgets.length-1); + countDownLatch.await(); + AtomicInteger integer = new AtomicInteger(showWidgets.length - 1); showCurrentLoadBlock(integer, widgetPane); this.repaint(); + CarouselStateManger.getInstance().start(); 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()]; @@ -95,7 +118,13 @@ public class OnlineEmbedFilterSelectPane extends AbstractOnlineWidgetSelectPane this.doLayout(); this.validate(); this.repaint(); - previewDialog.setImage(getPreviewImage(shareWidget)); + 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 @@ -114,6 +143,7 @@ public class OnlineEmbedFilterSelectPane extends AbstractOnlineWidgetSelectPane if (!CarouselStateManger.getInstance().isSuspend()) { showCurrentLoadBlock(integer, widgetPane); } else { + previewDialog.setVisible(false); pollingCarouselState(integer, widgetPane); } } @@ -130,6 +160,7 @@ public class OnlineEmbedFilterSelectPane extends AbstractOnlineWidgetSelectPane return; } if (!CarouselStateManger.getInstance().isSuspend()) { + previewDialog.setVisible(true); showCurrentLoadBlock(integer, widgetPane); service.shutdown(); } @@ -138,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]; @@ -153,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)); } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/OnlineEmbedFilterShowPane.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/OnlineEmbedFilterShowPane.java index 11e39c923f..9141bf98a0 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/OnlineEmbedFilterShowPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/OnlineEmbedFilterShowPane.java @@ -36,6 +36,12 @@ public class OnlineEmbedFilterShowPane extends JPanel { selectPane.animate(); } + public void refreshUI(){ + if (embedPane != null) { + this.repaint(); + } + } + public void completeEmbedFilter(){ if (embedPane!= null && embedPane.isShowing()){ this.remove(embedPane); 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 086f4d2bd5..3ef29c8cb6 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 - ); - } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/util/OnlineShopUtils.java b/designer-form/src/main/java/com/fr/design/mainframe/share/util/OnlineShopUtils.java index 67326c8536..c8c7b54ea3 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/util/OnlineShopUtils.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/util/OnlineShopUtils.java @@ -46,7 +46,7 @@ public class OnlineShopUtils { } private static String getWidgetReusePath() { - return getReuInfoPath(); + return StableUtils.pathJoin(getReuInfoPath(), "all/detail/"); } private static String getPackageChildrenPath() { diff --git a/designer-realize/src/main/java/com/fr/design/share/effect/EffectItemGroup.java b/designer-realize/src/main/java/com/fr/design/share/effect/EffectItemGroup.java index c04932d0d7..30456128f4 100644 --- a/designer-realize/src/main/java/com/fr/design/share/effect/EffectItemGroup.java +++ b/designer-realize/src/main/java/com/fr/design/share/effect/EffectItemGroup.java @@ -109,34 +109,30 @@ public class EffectItemGroup { Object value = cellElement.getValue(); if (value instanceof ChartCollection) { ChartCollection chartCollection = (ChartCollection) value; - for (int index = 0; index < chartCollection.getChartCount(); index++) { - Chart chart= (Chart) chartCollection.getChart(index, ChartProvider.class); - Plot plot = chart.getPlot(); - if (plot == null) { - continue; - } - SourceNode chartSourceNode = SourceNodeUtils.createSourceNode(plot, chartCollection.getChartName(index), cellSourceNode); - initChartPlot(plot, chartSourceNode, false); - } - + initChartEditorByChartCollection(chartCollection, cellSourceNode); } } - } private void initChartEditor() { ChartEditor editor = (ChartEditor) this.widget; ChartCollection chartCollection = (ChartCollection) editor.getChartCollection(); + initChartEditorByChartCollection(chartCollection, null); + } + + private void initChartEditorByChartCollection(ChartCollection chartCollection, SourceNode sourceNode) { for (int index = 0; index < chartCollection.getChartCount(); index++) { - Chart chart= (Chart) chartCollection.getChart(index, ChartProvider.class); - Plot plot = chart.getPlot(); - if (plot == null) { - continue; + ChartProvider chartProvider = chartCollection.getChart(index, ChartProvider.class); + if (chartProvider instanceof Chart) { + Chart chart= (Chart) chartCollection.getChart(index, ChartProvider.class); + Plot plot = chart.getPlot(); + if (plot == null) { + continue; + } + SourceNode plotSourceNode = SourceNodeUtils.createSourceNode(plot, chartCollection.getChartName(index), sourceNode); + initChartPlot(plot, plotSourceNode, false); } - SourceNode plotSourceNode = SourceNodeUtils.createSourceNode(plot, chartCollection.getChartName(index), null); - initChartPlot(plot, plotSourceNode, false); } - } private void initChartPlot(Plot plot, SourceNode sourceNode, boolean isSubChart) {