From 3084eef79d91008e5455ff8f1e9927ed48fad5dc Mon Sep 17 00:00:00 2001 From: kerry Date: Thu, 4 Nov 2021 16:17:57 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-60153=20=E5=A4=8D=E7=94=A8=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E6=8E=A5=E8=A7=A6=E7=82=B9=E4=BC=98=E5=8C=96=E4=BA=8C?= =?UTF-8?q?=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reuse/ComponentReuseNotificationInfo.java | 16 ++++++++-- .../mainframe/share/ComponentShareUtil.java | 6 +++- .../java/com/fr/design/mainframe/JForm.java | 6 +++- .../actions/DownloadSuitableThemeAction.java | 2 ++ .../share/ui/actions/Jump2DetailAction.java | 2 ++ .../ui/block/AbstractOnlineWidgetBlock.java | 17 +++++++--- .../share/ui/block/OnlineWidgetBlock.java | 15 +++++++-- .../share/ui/block/PreviewWidgetBlock.java | 12 +++---- .../AbstractOnlineWidgetSelectPane.java | 4 +++ .../share/ui/online/CarouselStateManger.java | 25 +++++++++++++-- .../embed/OnlineEmbedFilterSelectPane.java | 12 +++---- .../resource/OnlineResourceManager.java | 2 +- .../ui/widgetfilter/FilterConfigPane.java | 32 +++++++++++++++---- .../share/ui/widgetfilter/FilterPane.java | 6 +--- .../ui/widgetfilter/FilterPopupPane.java | 5 +-- .../mainframe/share/util/OnlineShopUtils.java | 15 ++++++++- 16 files changed, 136 insertions(+), 41 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/reuse/ComponentReuseNotificationInfo.java b/designer-base/src/main/java/com/fr/design/mainframe/reuse/ComponentReuseNotificationInfo.java index 5011ef2bde..46ccef0990 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/reuse/ComponentReuseNotificationInfo.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/reuse/ComponentReuseNotificationInfo.java @@ -28,6 +28,8 @@ public class ComponentReuseNotificationInfo implements XMLable { private boolean widgetLibHasRefreshed = false; + private boolean completeFirstShowComponentLib = false; + public boolean isClickedWidgetLib() { return clickedWidgetLib; } @@ -68,6 +70,14 @@ public class ComponentReuseNotificationInfo implements XMLable { this.widgetLibHasRefreshed = widgetLibHasRefreshed; } + public boolean isCompleteFirstShowComponentLib() { + return completeFirstShowComponentLib; + } + + public void setCompleteFirstShowComponentLib(boolean completeFirstShowComponentLib) { + this.completeFirstShowComponentLib = completeFirstShowComponentLib; + } + public String getHistoryCreatedReuses() { return historyCreatedReuses; } @@ -79,7 +89,8 @@ public class ComponentReuseNotificationInfo implements XMLable { @Override public void readXML(XMLableReader reader) { this.setClickedWidgetLib(reader.getAttrAsBoolean("clickedWidgetLib", false)); - this.setCompleteEmbedFilter(reader.getAttrAsBoolean("hasCompleteEmbedFilter", false)); + this.setCompleteEmbedFilter(reader.getAttrAsBoolean("completeEmbedFilter", false)); + this.setCompleteFirstShowComponentLib(reader.getAttrAsBoolean("completeFirstShowComponentLib", false)); this.setWidgetLibHasRefreshed(reader.getAttrAsBoolean("widgetLibHasRefreshed", false)); this.setFirstDrag(reader.getAttrAsBoolean("firstDrag", true)); this.setHistoryCreatedReuses(reader.getAttrAsString("historyCreatedReuses", "[]")); @@ -90,7 +101,8 @@ public class ComponentReuseNotificationInfo implements XMLable { public void writeXML(XMLPrintWriter writer) { writer.startTAG("ComponentReuseNotificationInfo"); writer.attr("clickedWidgetLib", this.clickedWidgetLib) - .attr("hasCompleteEmbedFilter", this.completeEmbedFilter) + .attr("completeEmbedFilter", this.completeEmbedFilter) + .attr("completeFirstShowComponentLib", this.completeFirstShowComponentLib) .attr("firstDrag", this.firstDrag) .attr("widgetLibHasRefreshed", this.widgetLibHasRefreshed) .attr("firstDragEndTime", this.firstDragEndTime) 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 8940b6c890..db53be7264 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 @@ -48,7 +48,7 @@ public class ComponentShareUtil { } /** - * 判断是否需要展示嵌入式筛选面板 + * 判断是否在需要展示组件库界面 * * @return boolean */ @@ -56,6 +56,10 @@ public class ComponentShareUtil { return !ComponentReuseNotificationInfo.getInstance().isCompleteEmbedFilter() && !hasTouched() && isCurrentTplNewCreate(); } + public static boolean needShowComponentLib() { + return !ComponentReuseNotificationInfo.getInstance().isCompleteFirstShowComponentLib() && !hasTouched() && isCurrentTplNewCreate(); + } + /** * 判断是否需要展示首次拖拽动效 * diff --git a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java index 6d0147b603..6e16472dfa 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java @@ -13,6 +13,7 @@ import com.fr.base.theme.TemplateThemeConfig; import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignModelAdapter; import com.fr.design.DesignState; +import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.FormMobileAttrAction; import com.fr.design.actions.TemplateParameterAction; @@ -49,6 +50,7 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.form.FormECCompositeProvider; import com.fr.design.mainframe.form.FormECDesignerProvider; +import com.fr.design.mainframe.reuse.ComponentReuseNotificationInfo; import com.fr.design.mainframe.share.collect.ComponentCollector; import com.fr.design.mainframe.share.ComponentShareUtil; import com.fr.design.mainframe.template.info.JFormProcessInfo; @@ -894,8 +896,10 @@ public class JForm extends JTemplate implements BaseJForm implements ResourceLoader { - private final AbstractOnlineWidgetSelectPane parentPane; + protected final AbstractOnlineWidgetSelectPane parentPane; private UILabel coverLabel; + private Image coverImage; public AbstractOnlineWidgetBlock(OnlineShareWidget widget, AbstractOnlineWidgetSelectPane parentPane) { super(widget); @@ -61,8 +63,12 @@ public abstract class AbstractOnlineWidgetBlock extends PreviewWidgetBlock { @Override 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 d55228b192..949719b852 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 @@ -48,7 +48,6 @@ public abstract class PreviewWidgetBlock extends JPanel implements MouseListe private static final int ANIMATE_START_TIME = 1000; private static final int ANIMATE_TIME = 2000; private AnimatePopupDialog animatePopupDialog; - private AWTEventListener awtEventListener; private static final double[] ANIMATE_CONTROL_VALUE = {0.23, 1, 0.32, 1}; @@ -104,7 +103,7 @@ public abstract class PreviewWidgetBlock extends JPanel implements MouseListe private void showPreviewPane() { synchronized (this) { - CarouselStateManger.getInstance().suspend(); + CarouselStateManger.getInstance().suspend(CarouselStateManger.MOUSE_HOVER); if (!showing) { showPreview(widget); showing = true; @@ -119,7 +118,6 @@ public abstract class PreviewWidgetBlock extends JPanel implements MouseListe protected abstract void hidePreview(); private void hidePreviewPane() { - CarouselStateManger.getInstance().start(); if (showing) { hidePreview(); showing = false; @@ -176,7 +174,7 @@ public abstract class PreviewWidgetBlock extends JPanel implements MouseListe private void animate(ScheduledExecutorService service) { - CarouselStateManger.getInstance().suspend(); + CarouselStateManger.getInstance().suspend(CarouselStateManger.FIRST_DRAG_ANIMATE); AtomicInteger atomicInteger = new AtomicInteger(0); BezierCubic cubic = new BezierCubic(ANIMATE_CONTROL_VALUE[0], ANIMATE_CONTROL_VALUE[1], ANIMATE_CONTROL_VALUE[2], ANIMATE_CONTROL_VALUE[3]); Point startPoint = new Point(this.getLocationOnScreen().x - 5, this.getLocationOnScreen().y - 5); @@ -193,7 +191,7 @@ public abstract class PreviewWidgetBlock extends JPanel implements MouseListe ComponentReuseNotificationInfo.getInstance().setFirstDragEndTime(System.currentTimeMillis()); DesignerEnvManager.getEnvManager().saveXMLFile(); java.awt.Toolkit.getDefaultToolkit().removeAWTEventListener(awtEventListener); - CarouselStateManger.getInstance().start(); + CarouselStateManger.getInstance().start(CarouselStateManger.FIRST_DRAG_ANIMATE); return; } double progress = calXProgress(atomicInteger.getAndIncrement() * 20, cubic); @@ -220,7 +218,9 @@ public abstract class PreviewWidgetBlock extends JPanel implements MouseListe public void mouseExited(MouseEvent e) { hover = false; this.hidePreviewPane(); - + if(!FirstDragAnimateStateManager.getInstance().animating()){ + CarouselStateManger.getInstance().start(CarouselStateManger.MOUSE_HOVER); + } } @Override 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 f85f30b623..4221e4b968 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 @@ -241,4 +241,8 @@ public abstract class AbstractOnlineWidgetSelectPane extends AbstractWidgetSele protected Container getParentContainer() { return this.getParent(); } + + public void refreshUI() { + OnlineWidgetRepoPane.getInstance().repaint(); + } } 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 cd818f42e1..a0265d536d 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 @@ -1,6 +1,9 @@ package com.fr.design.mainframe.share.ui.online; +import com.fr.general.ComparatorUtils; +import com.fr.stable.StringUtils; + import java.util.concurrent.CountDownLatch; /** @@ -8,10 +11,18 @@ import java.util.concurrent.CountDownLatch; */ 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"; + public static final String MOUSE_HOVER ="MOUSE_HOVER"; + private CarouseState state; private final CountDownLatch countDownLatch = new CountDownLatch(1); + private String suspendEvent; + public static CarouselStateManger getInstance() { return CarouselStateManger.HOLDER.singleton; @@ -37,12 +48,22 @@ public class CarouselStateManger { this.state = CarouseState.RUNNING; } + public void start(String startEvent) { + if (!this.stopped() && ComparatorUtils.equals(this.suspendEvent, startEvent)){ + this.state = CarouseState.RUNNING; + this.suspendEvent = StringUtils.EMPTY; + } + } + public boolean running() { return this.state == CarouseState.RUNNING; } - public void suspend() { - this.state = CarouseState.SUSPEND; + public void suspend(String externalSuspendEvent) { + if (!this.stopped()) { + this.state = CarouseState.SUSPEND; + this.suspendEvent = externalSuspendEvent; + } } public boolean isSuspend() { 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 f1069ba3fc..b7f62e5644 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 @@ -82,11 +82,10 @@ public class OnlineEmbedFilterSelectPane extends AbstractOnlineWidgetSelectPane public void animate() throws InterruptedException { CarouselStateManger.getInstance().countDownLatchAwait(); - AtomicInteger integer = new AtomicInteger(0); + AtomicInteger integer = new AtomicInteger(showWidgets.length-1); showCurrentLoadBlock(integer, widgetPane); this.repaint(); previewDialog.setVisible(true); - CarouselStateManger.getInstance().start(); } private void showCurrentLoadBlock(AtomicInteger integer, JPanel widgetPane) { @@ -105,12 +104,13 @@ public class OnlineEmbedFilterSelectPane extends AbstractOnlineWidgetSelectPane stopCarouse(integer); return; } - if (integer.get() == showWidgets.length - 1) { + if (integer.get() == 0) { CarouselStateManger.getInstance().stop(); + stopCarouse(integer); previewDialog.setVisible(false); return; } - integer.incrementAndGet(); + integer.decrementAndGet(); if (!CarouselStateManger.getInstance().isSuspend()) { showCurrentLoadBlock(integer, widgetPane); } else { @@ -139,12 +139,12 @@ public class OnlineEmbedFilterSelectPane extends AbstractOnlineWidgetSelectPane private void stopCarouse(AtomicInteger integer) { previewDialog.setVisible(false); - loadRestShowWidgets(integer.get() + 1); + loadRestShowWidgets(integer.get() - 1); java.awt.Toolkit.getDefaultToolkit().removeAWTEventListener(awtEventListener); } private void loadRestShowWidgets(int startIndex) { - for (int i = startIndex; i < showWidgets.length; i++) { + for (int i = startIndex; i >= 0; i--) { OnlineShareWidget shareWidget = showWidgets[i]; widgetPane.add(createWidgetBlock(shareWidget)); } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/resource/OnlineResourceManager.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/resource/OnlineResourceManager.java index 3915a84dd1..4e10ff25bb 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/resource/OnlineResourceManager.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/resource/OnlineResourceManager.java @@ -49,7 +49,7 @@ public class OnlineResourceManager { try { loader = loaderBlockingQueue.take(); } catch (InterruptedException e) { - e.printStackTrace(); + } loader.load(); } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/widgetfilter/FilterConfigPane.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/widgetfilter/FilterConfigPane.java index 31df72f99c..8808a5d754 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/widgetfilter/FilterConfigPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/widgetfilter/FilterConfigPane.java @@ -9,6 +9,7 @@ import com.fr.design.mainframe.share.Bean.WidgetFilterInfo; import com.fr.design.mainframe.share.Bean.WidgetFilterTypeInfo; import com.fr.general.ComparatorUtils; import com.fr.stable.StringUtils; +import com.fr.third.javax.annotation.Nullable; import javax.swing.BorderFactory; import javax.swing.JPanel; @@ -152,7 +153,7 @@ public abstract class FilterConfigPane extends JPanel { checkBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { - if (checkBox.isSelected() && !checkBox.getFilterInfo().hasChildFilter()) { + if (checkBox.isSelected() && (!checkBox.getFilterInfo().hasChildFilter() || !showChildNode)) { filterList.add(filterInfo); } else if (filterList.contains(filterInfo)) { filterList.remove(filterInfo); @@ -222,16 +223,35 @@ public abstract class FilterConfigPane extends JPanel { public abstract String assembleFilter(); - public void setFilters(List selectedFilterNames) { + public void setFilters(List selectedFilters) { reset = true; filterList.clear(); + setFilterList(selectedFilters); + reset = false; + } + + private void setFilterList(List selectedFilters){ for (FilterCheckBox checkBox : checkBoxList) { - if (selectedFilterNames.contains(checkBox.getFilterInfo().getName())) { - checkBox.setSelected(true); - filterList.add(checkBox.getFilterInfo()); + String filterName = checkBox.getFilterInfo().getName(); + WidgetFilterInfo selectFilterInfo = getSelectFilterInfoByName(selectedFilters, filterName); + if (selectFilterInfo == null) { + continue; + } + checkBox.setSelected(true); + if (selectFilterInfo.hasChildFilter()) { + setFilterList(selectFilterInfo.getInnerFilterInfo()); } } - reset = false; + } + + @Nullable + private WidgetFilterInfo getSelectFilterInfoByName(List selectedFilters, String name) { + for (WidgetFilterInfo filterInfo : selectedFilters) { + if (ComparatorUtils.equals(filterInfo.getName(), name)) { + return filterInfo; + } + } + return null; } public void reset() { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/widgetfilter/FilterPane.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/widgetfilter/FilterPane.java index 77e8631779..6713d94e2b 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/widgetfilter/FilterPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/widgetfilter/FilterPane.java @@ -206,11 +206,7 @@ public class FilterPane extends JPanel { } public void setFilter(List selectedFilters){ - List selectedFilterNames = new ArrayList<>(); - for(WidgetFilterInfo filterInfo : selectedFilters){ - selectedFilterNames.add(filterInfo.getName()); - } - filterPopupPane.setFilters(selectedFilterNames); + filterPopupPane.setFilters(selectedFilters); } private void switchToNoFilter() { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/widgetfilter/FilterPopupPane.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/widgetfilter/FilterPopupPane.java index 94a96b4b1e..e0ec375bc9 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/widgetfilter/FilterPopupPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/widgetfilter/FilterPopupPane.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe.share.ui.widgetfilter; import com.fr.design.mainframe.share.Bean.FilterTypeInfo; +import com.fr.design.mainframe.share.Bean.WidgetFilterInfo; import javax.swing.event.ChangeEvent; import java.util.List; @@ -19,8 +20,8 @@ public abstract class FilterPopupPane extends FilterConfigPane { this.filterPane = filterPane; } - public void setFilters(List selectedFilterNames) { - super.setFilters(selectedFilterNames); + public void setFilters(List selectedFilters) { + super.setFilters(selectedFilters); filterPane.changeFilterButtonStatus(hasFilter()); } 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 9405ace596..7db6608c58 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 @@ -172,9 +172,10 @@ public class OnlineShopUtils { } public static String assembleFilter(List filterInfos) { + List allFilterInfos = getAllFilterInfoList(filterInfos); List cidList = new ArrayList<>(); Map queryParaMap = new HashMap<>(); - for (WidgetFilterInfo filterInfo : filterInfos) { + for (WidgetFilterInfo filterInfo : allFilterInfos) { if (ComparatorUtils.equals(CHART, filterInfo.getType()) || ComparatorUtils.equals(REPORT, filterInfo.getType())) { cidList.add(filterInfo.getType() + "-" + filterInfo.getId()); @@ -206,6 +207,18 @@ public class OnlineShopUtils { return StringUtils.join("&", queryCondition.toArray(new String[queryCondition.size()])); } + private static List getAllFilterInfoList(List filterInfos) { + List allFilterList = new ArrayList<>(); + for (WidgetFilterInfo filterInfo : filterInfos) { + if (filterInfo.hasChildFilter()) { + allFilterList.addAll(filterInfo.getInnerFilterInfo()); + } else { + allFilterList.add(filterInfo); + } + } + return allFilterList; + } + public static boolean testConnection() { HttpClient httpClient = new HttpClient(getTestConnectionUrl()); httpClient.asGet();