Browse Source

Pull request #6685: REPORT-62623 && REPORT-62399 && REPORT-62547 && REPORT-62626 && REPORT-62400 && REPORT-62542 && REPORT-62544 bug 修复

Merge in DESIGN/design from ~KERRY/design_10.0:feature/x to feature/x

* commit 'fd7a89abd349ebb97eae2bd0067f4a5c5f82b883':
  REPORT-62623 && REPORT-62399 && REPORT-62547 && REPORT-62626 && REPORT-62400 && REPORT-62542 && REPORT-62544
  bug修复
  REPORT-62400 && REPORT-62399 && REPORT-62547【接触点优化】拖拽动效出现时,预览图不消失;【接触点优化】轮播的同时,鼠标悬浮在组件上,轮播图不消失,与组件预览图同时出现;【接触点优化】轮播的图片固定大小,导致预览图显示不全
feature/x
kerry 3 years ago
parent
commit
86ebd5ee74
  1. 4
      designer-base/src/main/java/com/fr/design/DesignerCloudURLManager.java
  2. 2
      designer-base/src/main/java/com/fr/design/mainframe/share/ComponentShareUtil.java
  3. 33
      designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java
  4. 3
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/PreviewWidgetBlock.java
  5. 12
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/CarouselStateManger.java
  6. 79
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/OnlineEmbedFilterSelectPane.java
  7. 18
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/PreviewDialog.java

4
designer-base/src/main/java/com/fr/design/DesignerCloudURLManager.java

@ -63,7 +63,7 @@ public class DesignerCloudURLManager implements XMLable {
executorService.submit(() -> { executorService.submit(() -> {
updateURLXMLFile(key, latestUrl); updateURLXMLFile(key, latestUrl);
}); });
return url; return latestUrl;
} }
//本地缓存不为空时,直接返回对应 url,同时异步更新 //本地缓存不为空时,直接返回对应 url,同时异步更新
executorService.submit(() -> { executorService.submit(() -> {
@ -74,7 +74,7 @@ public class DesignerCloudURLManager implements XMLable {
} }
private synchronized void updateURLXMLFile(String key, String url) { 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); urlMap.put(key, url);
saveURLXMLFile(); saveURLXMLFile();
} }

2
designer-base/src/main/java/com/fr/design/mainframe/share/ComponentShareUtil.java

@ -66,7 +66,7 @@ public class ComponentShareUtil {
* @return boolean * @return boolean
*/ */
public static boolean needShowFirstDragAnimate() { public static boolean needShowFirstDragAnimate() {
return ComponentReuseNotificationInfo.getInstance().isFirstDrag() && !hasTouched(); return ComponentReuseNotificationInfo.getInstance().isFirstDrag();
} }
/** /**

33
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.design.mainframe.share.ui.online.OnlineWidgetRepoPane;
import com.fr.general.locale.LocaleCenter; import com.fr.general.locale.LocaleCenter;
import com.fr.general.locale.LocaleMark; import com.fr.general.locale.LocaleMark;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -33,13 +32,15 @@ import java.util.List;
* Date: 14-7-8 * Date: 14-7-8
* Time: 下午8:18 * Time: 下午8:18
*/ */
public class FormWidgetDetailPane extends FormDockView{ public class FormWidgetDetailPane extends FormDockView {
private static final int ONLINE_TAB = 1; private static final int ONLINE_TAB = 1;
private JPanel centerPane; private JPanel centerPane;
private UIHeadGroup headGroup; private UIHeadGroup headGroup;
private List<BasicPane> paneList; private List<BasicPane> paneList;
private CardLayout cardLayout; private CardLayout cardLayout;
//用来标记当前组件库界面是否处于已触达状态
private boolean hasTouched = false;
private boolean isEmptyPane = false; private boolean isEmptyPane = false;
@ -50,7 +51,7 @@ public class FormWidgetDetailPane extends FormDockView{
return HOLDER.singleton; return HOLDER.singleton;
} }
private FormWidgetDetailPane(){ private FormWidgetDetailPane() {
setLayout(FRGUIPaneFactory.createBorderLayout()); setLayout(FRGUIPaneFactory.createBorderLayout());
} }
@ -77,7 +78,7 @@ public class FormWidgetDetailPane extends FormDockView{
/** /**
* 初始化 * 初始化
*/ */
public void refreshDockingView(){ public void refreshDockingView() {
if (isEmptyPane) { if (isEmptyPane) {
return; return;
} }
@ -87,18 +88,18 @@ public class FormWidgetDetailPane extends FormDockView{
clearDockingView(); clearDockingView();
return; return;
} }
hasTouched = ComponentShareUtil.hasTouched();
initPaneList(); initPaneList();
this.setBorder(null); this.setBorder(null);
cardLayout = new CardLayout(); cardLayout = new CardLayout();
centerPane = new JPanel(cardLayout); centerPane = new JPanel(cardLayout);
String[] paneNames = new String[paneList.size()]; String[] paneNames = new String[paneList.size()];
for (int i = 0; i < paneList.size(); i++) { for (int i = 0; i < paneList.size(); i++) {
String title = paneList.get(i).getTitle(); String title = paneList.get(i).getTitle();
paneNames[i] = title; paneNames[i] = title;
centerPane.add(paneList.get(i), title); centerPane.add(paneList.get(i), title);
} }
headGroup = new UIHeadGroup(paneNames) { headGroup = new UIHeadGroup(paneNames) {
protected void tabChanged(int newSelectedIndex) { protected void tabChanged(int newSelectedIndex) {
//初始化还未展示的时候不需要收集其 marketClick //初始化还未展示的时候不需要收集其 marketClick
if (this.isShowing() && newSelectedIndex == 1) { if (this.isShowing() && newSelectedIndex == 1) {
@ -106,20 +107,28 @@ public class FormWidgetDetailPane extends FormDockView{
} }
cardLayout.show(centerPane, paneList.get(newSelectedIndex).getTitle()); cardLayout.show(centerPane, paneList.get(newSelectedIndex).getTitle());
} }
}; };
headGroup.setSelectedIndex(ComponentShareUtil.needSwitch2OnlineTab() ? ONLINE_TAB : 0); headGroup.setSelectedIndex(ComponentShareUtil.needSwitch2OnlineTab() ? ONLINE_TAB : 0);
this.add(headGroup, BorderLayout.NORTH); this.add(headGroup, BorderLayout.NORTH);
this.add(centerPane, BorderLayout.CENTER); this.add(centerPane, BorderLayout.CENTER);
} }
/**
* 判断是否可触达
*
* @return boolean
*/
public boolean hasTouched() {
return hasTouched;
}
public void resetEmptyPane(){ public void resetEmptyPane() {
this.isEmptyPane = false; this.isEmptyPane = false;
} }
/** /**
* 清除数据 * 清除数据
*/ */
@ -129,7 +138,7 @@ public class FormWidgetDetailPane extends FormDockView{
this.add(psp, BorderLayout.CENTER); this.add(psp, BorderLayout.CENTER);
} }
public void switch2Empty(){ public void switch2Empty() {
isEmptyPane = true; isEmptyPane = true;
this.removeAll(); this.removeAll();
JPanel panel = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 5); 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(); ComponentReuseNotifyUtil.enterWidgetLibExtraAction();
EastRegionContainerPane.getInstance().switchTabTo(EastRegionContainerPane.KEY_WIDGET_LIB); EastRegionContainerPane.getInstance().switchTabTo(EastRegionContainerPane.KEY_WIDGET_LIB);
} }

3
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.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.design.mainframe.EastRegionContainerPane;
import com.fr.design.mainframe.FormWidgetDetailPane;
import com.fr.design.mainframe.reuse.ComponentReuseNotificationInfo; import com.fr.design.mainframe.reuse.ComponentReuseNotificationInfo;
import com.fr.design.mainframe.share.ComponentShareUtil; import com.fr.design.mainframe.share.ComponentShareUtil;
import com.fr.design.mainframe.share.collect.ComponentCollector; import com.fr.design.mainframe.share.collect.ComponentCollector;
@ -147,7 +148,7 @@ public abstract class PreviewWidgetBlock<T> extends JPanel implements MouseListe
@Override @Override
public void mouseEntered(MouseEvent e) { public void mouseEntered(MouseEvent e) {
hover = true; hover = true;
if (ComponentShareUtil.needShowFirstDragAnimate() && checkWidget()) { if (ComponentShareUtil.needShowFirstDragAnimate() && !FormWidgetDetailPane.getInstance().hasTouched() && checkWidget()) {
schedule(ANIMATE_START_TIME); schedule(ANIMATE_START_TIME);
awtEventListener = event -> { awtEventListener = event -> {
if (!this.isShowing()) { if (!this.isShowing()) {

12
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.general.ComparatorUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import java.util.concurrent.CountDownLatch;
/** /**
* Created by kerry on 2021/10/22 * Created by kerry on 2021/10/22
*/ */
public class CarouselStateManger { public class CarouselStateManger {
private static final String START_CAROUSEL ="START_CAROUSEL";
public static final String RIGHT_CLICK ="RIGHT_CLICK"; public static final String RIGHT_CLICK ="RIGHT_CLICK";
public static final String DOWNLOAD_COMPONENT ="DOWNLOAD_COMPONENT"; public static final String DOWNLOAD_COMPONENT ="DOWNLOAD_COMPONENT";
public static final String FIRST_DRAG_ANIMATE ="FIRST_DRAG_ANIMATE"; public static final String FIRST_DRAG_ANIMATE ="FIRST_DRAG_ANIMATE";
@ -19,7 +16,6 @@ public class CarouselStateManger {
private CarouseState state; private CarouseState state;
private final CountDownLatch countDownLatch = new CountDownLatch(1);
private String suspendEvent; 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() { public void start() {
this.state = CarouseState.RUNNING; this.state = CarouseState.RUNNING;
} }

79
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.design.mainframe.share.ui.widgetfilter.FilterPane;
import com.fr.form.share.base.DataLoad; import com.fr.form.share.base.DataLoad;
import com.fr.form.share.bean.OnlineShareWidget; import com.fr.form.share.bean.OnlineShareWidget;
import com.fr.form.share.constants.ShareComponentConstants; import com.fr.form.share.exception.NetWorkFailedException;
import com.fr.log.FineLoggerFactory; import com.fr.general.http.HttpClient;
import com.fr.module.ModuleContext; import com.fr.module.ModuleContext;
import com.fr.stable.EncodeConstants;
import com.fr.third.springframework.web.util.UriUtils;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -24,7 +22,8 @@ import java.awt.Rectangle;
import java.awt.event.AWTEventListener; import java.awt.event.AWTEventListener;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.io.IOException; 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.ScheduledExecutorService;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
@ -34,10 +33,12 @@ import java.util.concurrent.atomic.AtomicInteger;
*/ */
public class OnlineEmbedFilterSelectPane extends AbstractOnlineWidgetSelectPane { public class OnlineEmbedFilterSelectPane extends AbstractOnlineWidgetSelectPane {
private static final String CAROUSEL_PREVIEW = "carousel_preview"; private static final String CAROUSEL_PREVIEW = "carousel_preview";
private static final int CAROUSE_IMAGE_LOAD_TIMEOUT = 2000;
private OnlineShareWidget[] showWidgets; private OnlineShareWidget[] showWidgets;
private PreviewDialog previewDialog; private PreviewDialog previewDialog;
private JPanel widgetPane; private JPanel widgetPane;
private final CountDownLatch countDownLatch = new CountDownLatch(1);
private final AWTEventListener awtEventListener; private final AWTEventListener awtEventListener;
@ -46,13 +47,18 @@ public class OnlineEmbedFilterSelectPane extends AbstractOnlineWidgetSelectPane
awtEventListener = event -> { awtEventListener = event -> {
if (event instanceof MouseEvent) { if (event instanceof MouseEvent) {
if (((MouseEvent) event).getClickCount() > 0) { if (((MouseEvent) event).getClickCount() > 0) {
Point selectPanePoint = OnlineEmbedFilterSelectPane.this.getLocationOnScreen(); try {
Dimension selectPaneDimension = OnlineEmbedFilterSelectPane.this.getSize(); Point selectPanePoint = OnlineEmbedFilterSelectPane.this.getLocationOnScreen();
Rectangle selectPaneRec = new Rectangle(selectPanePoint.x, selectPanePoint.y, selectPaneDimension.width, selectPaneDimension.height); Dimension selectPaneDimension = OnlineEmbedFilterSelectPane.this.getSize();
if (CarouselStateManger.getInstance().running() && Rectangle selectPaneRec = new Rectangle(selectPanePoint.x, selectPanePoint.y, selectPaneDimension.width, selectPaneDimension.height);
!selectPaneRec.contains(((MouseEvent) event).getLocationOnScreen())) { if (CarouselStateManger.getInstance().running() &&
CarouselStateManger.getInstance().stop(); !selectPaneRec.contains(((MouseEvent) event).getLocationOnScreen())) {
CarouselStateManger.getInstance().stop();
}
} catch (Exception e) {
//忽略
} }
} }
} }
@ -77,17 +83,34 @@ public class OnlineEmbedFilterSelectPane extends AbstractOnlineWidgetSelectPane
protected void fireAfterDataLoad() { protected void fireAfterDataLoad() {
super.fireAfterDataLoad(); super.fireAfterDataLoad();
CarouselStateManger.getInstance().countDown(); countDownLatch.countDown();
} }
public void animate() throws InterruptedException { public void animate() throws InterruptedException {
CarouselStateManger.getInstance().countDownLatchAwait(); countDownLatch.await();
AtomicInteger integer = new AtomicInteger(showWidgets.length-1); AtomicInteger integer = new AtomicInteger(showWidgets.length - 1);
showCurrentLoadBlock(integer, widgetPane); showCurrentLoadBlock(integer, widgetPane);
this.repaint(); this.repaint();
CarouselStateManger.getInstance().start();
previewDialog.setVisible(true); 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) { private void showCurrentLoadBlock(AtomicInteger integer, JPanel widgetPane) {
ScheduledExecutorService service = createToastScheduleExecutorService(); ScheduledExecutorService service = createToastScheduleExecutorService();
OnlineShareWidget shareWidget = showWidgets[integer.get()]; OnlineShareWidget shareWidget = showWidgets[integer.get()];
@ -95,7 +118,13 @@ public class OnlineEmbedFilterSelectPane extends AbstractOnlineWidgetSelectPane
this.doLayout(); this.doLayout();
this.validate(); this.validate();
this.repaint(); 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() { service.schedule(new Runnable() {
@Override @Override
@ -114,6 +143,7 @@ public class OnlineEmbedFilterSelectPane extends AbstractOnlineWidgetSelectPane
if (!CarouselStateManger.getInstance().isSuspend()) { if (!CarouselStateManger.getInstance().isSuspend()) {
showCurrentLoadBlock(integer, widgetPane); showCurrentLoadBlock(integer, widgetPane);
} else { } else {
previewDialog.setVisible(false);
pollingCarouselState(integer, widgetPane); pollingCarouselState(integer, widgetPane);
} }
} }
@ -130,6 +160,7 @@ public class OnlineEmbedFilterSelectPane extends AbstractOnlineWidgetSelectPane
return; return;
} }
if (!CarouselStateManger.getInstance().isSuspend()) { if (!CarouselStateManger.getInstance().isSuspend()) {
previewDialog.setVisible(true);
showCurrentLoadBlock(integer, widgetPane); showCurrentLoadBlock(integer, widgetPane);
service.shutdown(); service.shutdown();
} }
@ -138,11 +169,18 @@ public class OnlineEmbedFilterSelectPane extends AbstractOnlineWidgetSelectPane
} }
private void stopCarouse(AtomicInteger integer) { private void stopCarouse(AtomicInteger integer) {
this.stopCarouse(integer, true);
}
private void stopCarouse(AtomicInteger integer, boolean showExtra) {
previewDialog.setVisible(false); previewDialog.setVisible(false);
loadRestShowWidgets(integer.get() - 1); if (showExtra) {
loadRestShowWidgets(integer.get() - 1);
}
java.awt.Toolkit.getDefaultToolkit().removeAWTEventListener(awtEventListener); java.awt.Toolkit.getDefaultToolkit().removeAWTEventListener(awtEventListener);
} }
private void loadRestShowWidgets(int startIndex) { private void loadRestShowWidgets(int startIndex) {
for (int i = startIndex; i >= 0; i--) { for (int i = startIndex; i >= 0; i--) {
OnlineShareWidget shareWidget = showWidgets[i]; OnlineShareWidget shareWidget = showWidgets[i];
@ -153,15 +191,6 @@ public class OnlineEmbedFilterSelectPane extends AbstractOnlineWidgetSelectPane
this.repaint(); 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() { private ScheduledExecutorService createToastScheduleExecutorService() {
return ModuleContext.getExecutor().newSingleThreadScheduledExecutor(new NamedThreadFactory(CAROUSEL_PREVIEW)); return ModuleContext.getExecutor().newSingleThreadScheduledExecutor(new NamedThreadFactory(CAROUSEL_PREVIEW));
} }

18
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.ImageIcon;
import javax.swing.JDialog; import javax.swing.JDialog;
import java.awt.Dimension;
import java.awt.Image; import java.awt.Image;
import java.awt.Point;
/** /**
* Created by kerry on 2021/10/22 * Created by kerry on 2021/10/22
*/ */
public class PreviewDialog extends JDialog { public class PreviewDialog extends JDialog {
private static final int OFFSET_Y = 9;
public PreviewDialog() { public PreviewDialog() {
super(DesignerContext.getDesignerFrame()); super(DesignerContext.getDesignerFrame());
setUndecorated(true); setUndecorated(true);
setSize(300, 300);
adjustLocation();
this.setVisible(false); this.setVisible(false);
} }
public void setImage(Image image) { public void setImage(Image image, Point point) {
this.getContentPane().removeAll(); this.getContentPane().removeAll();
this.getContentPane().add(new UILabel(new ImageIcon(image))); 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.doLayout();
this.validate(); this.validate();
this.repaint(); this.repaint();
} }
public void adjustLocation() {
this.setLocation(
EastRegionContainerPane.getInstance().getX() - 300,
20
);
}
} }

Loading…
Cancel
Save