Browse Source

REPORT-60153 复用组件接触点优化二期

feature/x
kerry 3 years ago
parent
commit
40ed97e4df
  1. 180
      designer-base/src/main/java/com/fr/design/DesignerCloudURLManager.java
  2. 11
      designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java
  3. 8
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  4. 71
      designer-base/src/main/java/com/fr/design/mainframe/reuse/ComponentReuseNotificationInfo.java
  5. 169
      designer-base/src/main/java/com/fr/design/mainframe/reuse/ReuseGuideDialog.java
  6. 95
      designer-base/src/main/java/com/fr/design/mainframe/share/ComponentShareUtil.java
  7. 102
      designer-base/src/main/java/com/fr/design/mainframe/share/collect/ComponentCollector.java
  8. 7
      designer-base/src/test/java/com/fr/design/mainframe/reuse/ComponentReuseNotificationInfoTest.java
  9. 2
      designer-form/src/main/java/com/fr/design/mainframe/FormParaWidgetPane.java
  10. 10
      designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java
  11. 15
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  12. 217
      designer-form/src/main/java/com/fr/design/mainframe/ReuseTriggerPointManager.java
  13. 30
      designer-form/src/main/java/com/fr/design/mainframe/adaptve/config/ReuseNotifyInfo.java
  14. 20
      designer-form/src/main/java/com/fr/design/mainframe/adaptve/config/TriggerPointProvider.java
  15. 28
      designer-form/src/main/java/com/fr/design/mainframe/adaptve/config/impl/CellStyleTriggerPoint.java
  16. 27
      designer-form/src/main/java/com/fr/design/mainframe/adaptve/config/impl/CellValueImageChangeTriggerPoint.java
  17. 3
      designer-form/src/main/java/com/fr/design/mainframe/share/AbstractWidgetSelectPane.java
  18. 44
      designer-form/src/main/java/com/fr/design/mainframe/share/Bean/FilterTypeInfo.java
  19. 60
      designer-form/src/main/java/com/fr/design/mainframe/share/Bean/WidgetFilterInfo.java
  20. 93
      designer-form/src/main/java/com/fr/design/mainframe/share/Bean/WidgetFilterTypeInfo.java
  21. 82
      designer-form/src/main/java/com/fr/design/mainframe/share/config/ComponentReuseConfigManager.java
  22. 14
      designer-form/src/main/java/com/fr/design/mainframe/share/constants/StyleTheme.java
  23. 2
      designer-form/src/main/java/com/fr/design/mainframe/share/generate/task/ComponentUploader.java
  24. 4
      designer-form/src/main/java/com/fr/design/mainframe/share/sort/OnlineWidgetSortType.java
  25. 11
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/AbstractOnlineWidgetBlock.java
  26. 53
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/BezierCubic.java
  27. 14
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java
  28. 10
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/OnlineWidgetBlock.java
  29. 131
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/PreviewWidgetBlock.java
  30. 2
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/ToolbarPane.java
  31. 244
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/AbstractOnlineWidgetSelectPane.java
  32. 78
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/AbstractOnlineWidgetShowPane.java
  33. 65
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/CarouselStateManger.java
  34. 53
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineResourceManager.java
  35. 16
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetRepoPane.java
  36. 212
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetSelectPane.java
  37. 30
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetShowPane.java
  38. 20
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetTabPane.java
  39. 46
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/AnimatePopupDialog.java
  40. 156
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/EmbedPane.java
  41. 44
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/FirstDragAnimateStateManager.java
  42. 169
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/OnlineEmbedFilterSelectPane.java
  43. 47
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/OnlineEmbedFilterShowPane.java
  44. 40
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/PreviewDialog.java
  45. 64
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/resource/OnlineResourceManager.java
  46. 2
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/resource/ResourceLoader.java
  47. 12
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/widgetpackage/OnlineWidgetPackagesShowPane.java
  48. 265
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/widgetfilter/FilterConfigPane.java
  49. 29
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/widgetfilter/FilterPane.java
  50. 191
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/widgetfilter/FilterPopupPane.java
  51. 6
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/widgetfilter/LocalFilterPopupPane.java
  52. 2
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/widgetfilter/LocalWidgetFilter.java
  53. 50
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/widgetfilter/LocalWidgetFilterCategory.java
  54. 10
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/widgetfilter/OnlineFilterPopupPane.java
  55. 17
      designer-form/src/main/java/com/fr/design/mainframe/share/util/DownloadUtils.java
  56. 293
      designer-form/src/main/java/com/fr/design/mainframe/share/util/OnlineShopUtils.java
  57. 17
      designer-form/src/main/java/com/fr/design/mainframe/share/util/ShareFilterConstants.java
  58. 3
      designer-form/src/main/java/com/fr/design/widget/ui/designer/NewFormPane.java
  59. BIN
      designer-form/src/main/resources/com/fr/design/form/images/drag_hand.png
  60. 45
      designer-form/src/test/java/com/fr/design/mainframe/ReuseTriggerPointManagerTest.java
  61. 4
      designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/theme/DownloadComponentPackageGuide.java
  62. 2
      designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareGeneratePane.java

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

@ -0,0 +1,180 @@
package com.fr.design;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.general.CloudCenter;
import com.fr.general.CloudCenterConfig;
import com.fr.general.http.HttpToolbox;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLReaderHelper;
import com.fr.stable.xml.XMLTools;
import com.fr.stable.xml.XMLable;
import com.fr.stable.xml.XMLableReader;
import com.fr.third.javax.xml.stream.XMLStreamException;
import com.fr.third.org.apache.commons.io.FileUtils;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* Created by kerry on 2021/10/22
*/
public class DesignerCloudURLManager implements XMLable {
private static final String CLOUD_URL_INFO = "cloudUrl.info";
private static final String ROOT_XML_TAG = "CloudUrlInfoList";
private static final String CHILD_XML_TAG = "CloudUrlInfo";
private final Map<String, String> urlMap = new HashMap<>();
public static DesignerCloudURLManager getInstance() {
return DesignerCloudURLManager.HOLDER.singleton;
}
private final ExecutorService executorService = Executors.newSingleThreadExecutor(new NamedThreadFactory("TestCloudConnectThread"));
private volatile boolean testResult;
private static class HOLDER {
private static final DesignerCloudURLManager singleton = new DesignerCloudURLManager();
}
private DesignerCloudURLManager() {
loadURLXMLFile();
}
public String acquireUrlByKind(String key) {
String url = CloudCenter.getInstance().acquireConf(key, StringUtils.EMPTY);
if (StringUtils.isEmpty(url)) {
return urlMap.getOrDefault(key, StringUtils.EMPTY);
}
if (!urlMap.containsKey(key) || !url.equals(urlMap.get(key))) {
urlMap.put(key, url);
saveURLXMLFile();
}
return url;
}
public void testConnect() {
executorService.submit(() -> {
testResult = isOnline();
});
}
public boolean isConnected() {
return testResult;
}
public boolean isOnline() {
if (CloudCenterConfig.getInstance().isOnline()) {
String ping = acquireUrlByKind("ping");
if (StringUtils.isNotEmpty(ping)) {
try {
return StringUtils.isEmpty(HttpToolbox.get(ping));
} catch (Exception ignore) {
}
}
}
return false;
}
/**
* 加载本地 url 管理文件
*/
private void loadURLXMLFile() {
if (!getInfoFile().exists()) {
return;
}
XMLableReader reader = null;
try (InputStream in = new FileInputStream(getInfoFile())) {
// XMLableReader 还是应该考虑实现 Closable 接口的,这样就能使用 try-with 语句了
reader = XMLReaderHelper.createXMLableReader(in, XMLPrintWriter.XML_ENCODER);
if (reader == null) {
return;
}
reader.readXMLObject(this);
} catch (FileNotFoundException e) {
// do nothing
} catch (XMLStreamException | IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} finally {
try {
if (reader != null) {
reader.close();
}
} catch (XMLStreamException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}
private File getInfoFile() {
File file = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), CLOUD_URL_INFO));
try {
if (!file.exists()) {
file.createNewFile();
}
} catch (Exception ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
}
return file;
}
/**
* 保存到本地 URL 管理文件中存放在 .Finereport110
*/
void saveURLXMLFile() {
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
XMLTools.writeOutputStreamXML(this, out);
out.flush();
out.close();
String fileContent = new String(out.toByteArray(), StandardCharsets.UTF_8);
FileUtils.writeStringToFile(getInfoFile(), fileContent, StandardCharsets.UTF_8);
} catch (Exception ex) {
FineLoggerFactory.getLogger().error(ex.getMessage());
}
}
@Override
public void readXML(XMLableReader reader) {
String tagName = reader.getTagName();
if (tagName.equals(CHILD_XML_TAG)) {
String key = reader.getAttrAsString("key", StringUtils.EMPTY);
String value = reader.getAttrAsString("url", StringUtils.EMPTY);
this.urlMap.put(key, value);
}
}
@Override
public void writeXML(XMLPrintWriter xmlPrintWriter) {
xmlPrintWriter.startTAG(ROOT_XML_TAG);
Iterator<Map.Entry<String, String>> iterable = urlMap.entrySet().iterator();
while (iterable.hasNext()) {
Map.Entry<String, String> entry = iterable.next();
xmlPrintWriter.startTAG(CHILD_XML_TAG).attr("key", entry.getKey()).attr("url", entry.getValue()).end();
}
xmlPrintWriter.end();
}
@Override
public Object clone() throws CloneNotSupportedException {
return null;
}
}

11
designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java

@ -13,7 +13,6 @@ import com.fr.design.gui.ibutton.UIButtonUI;
import com.fr.design.gui.icontainer.UIEastResizableContainer;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.VerticalFlowLayout;
import com.fr.design.mainframe.reuse.ReuseGuideDialog;
import com.fr.design.mainframe.reuse.SnapChatKeys;
import com.fr.design.mainframe.share.collect.ComponentCollector;
import com.fr.design.notification.SnapChat;
@ -292,7 +291,12 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
// 控件设置
PropertyItem widgetSettings = new PropertyItem(KEY_WIDGET_SETTINGS, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Settings"),
"widgetsettings", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_PARA_WIDGET, PropertyMode.REPORT_FLOAT, PropertyMode.FORM, PropertyMode.POLY},
new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_PARA_WIDGET, PropertyMode.FORM, PropertyMode.POLY_REPORT, PropertyMode.POLY_CHART});
new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_PARA_WIDGET, PropertyMode.FORM, PropertyMode.POLY_REPORT, PropertyMode.POLY_CHART}, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ComponentCollector.getInstance().clickComponentSetting();
}
});
// 条件属性
PropertyItem conditionAttr = new PropertyItem(KEY_CONDITION_ATTR, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Condition_Attributes"),
"conditionattr", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_PARA_WIDGET, PropertyMode.REPORT_FLOAT, PropertyMode.POLY, PropertyMode.POLY_CHART},
@ -538,9 +542,6 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
}
public PromptWindow getWidgetLibPromptWindow() {
if (!getWidgetLibSnapChat().hasRead()) {
return new ReuseGuideDialog(DesignerContext.getDesignerFrame());
}
return null;
}

8
designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

@ -124,6 +124,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
protected U undoState;
protected U authorityUndoState = null;
protected T template; // 当前模板
private boolean isNewCreateTpl = false; //当前模板是否为新建模板
/**
* 模板过程的相关信息
*
@ -198,7 +199,8 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
designModel = createDesignModel(parameters);
}
addCenterPane();
if (isNewFile) {
isNewCreateTpl = isNewFile;
if (isNewCreateTpl) {
// REPORT-58486: 必须在初始的UndoState创建前设置主题,使得初始的UndoState就包含了主题效果
setUpTheme4NewTemplate();
}
@ -959,6 +961,10 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
return true;
}
public boolean isNewCreateTpl(){
return isNewCreateTpl;
}
protected boolean export() throws Exception {
return this.getTarget().export(TemplateResourceManager.getResource().saveTemplate(getEditingFILE()));

71
designer-base/src/main/java/com/fr/design/mainframe/reuse/ComponentReuseNotificationInfo.java

@ -1,6 +1,5 @@
package com.fr.design.mainframe.reuse;
import com.fr.design.DesignerEnvManager;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLable;
import com.fr.stable.xml.XMLableReader;
@ -17,51 +16,56 @@ public class ComponentReuseNotificationInfo implements XMLable {
return INSTANCE;
}
private long lastNotifyTime = 0;
private boolean clickedWidgetLib = false;
private int notifiedNumber = 0;
private long firstDragEndTime = 0L;
private boolean clickedWidgetLib = false;
private boolean completeEmbedFilter = false;
private long lastGuidePopUpTime = 0;
private boolean firstDrag = true;
private String historyCreatedReuses = "[]";
public long getLastNotifyTime() {
return lastNotifyTime;
private boolean widgetLibHasRefreshed = false;
public boolean isClickedWidgetLib() {
return clickedWidgetLib;
}
public void setLastNotifyTime(long lastNotifyTime) {
this.lastNotifyTime = lastNotifyTime;
public void setClickedWidgetLib(boolean clickedWidgetLib) {
this.clickedWidgetLib = clickedWidgetLib;
}
public int getNotifiedNumber() {
return notifiedNumber;
public boolean isCompleteEmbedFilter() {
return completeEmbedFilter;
}
public void setNotifiedNumber(int notifiedNumber) {
this.notifiedNumber = notifiedNumber;
public void setCompleteEmbedFilter(boolean completeEmbedFilter) {
this.completeEmbedFilter = completeEmbedFilter;
}
public boolean isClickedWidgetLib() {
return clickedWidgetLib;
public long getFirstDragEndTime() {
return firstDragEndTime;
}
public void setClickedWidgetLib(boolean clickedWidgetLib) {
this.clickedWidgetLib = clickedWidgetLib;
public void setFirstDragEndTime(long firstDragEndTime) {
this.firstDragEndTime = firstDragEndTime;
}
public boolean isFirstDrag() {
return firstDrag;
}
public long getLastGuidePopUpTime() {
return lastGuidePopUpTime;
public void setFirstDrag(boolean firstDrag) {
this.firstDrag = firstDrag;
}
public void setLastGuidePopUpTime(long lastGuidePopUpTime) {
this.lastGuidePopUpTime = lastGuidePopUpTime;
public boolean isWidgetLibHasRefreshed() {
return widgetLibHasRefreshed;
}
public void updateLastGuidePopUpTime() {
this.setLastGuidePopUpTime(System.currentTimeMillis());
DesignerEnvManager.getEnvManager().saveXMLFile();
public void setWidgetLibHasRefreshed(boolean widgetLibHasRefreshed) {
this.widgetLibHasRefreshed = widgetLibHasRefreshed;
}
public String getHistoryCreatedReuses() {
@ -74,21 +78,24 @@ public class ComponentReuseNotificationInfo implements XMLable {
@Override
public void readXML(XMLableReader reader) {
this.setLastNotifyTime(reader.getAttrAsLong("lastNotifyTime", 0L));
this.setNotifiedNumber(reader.getAttrAsInt("notifiedNumber", 0));
this.setClickedWidgetLib(reader.getAttrAsBoolean("clickedWidgetLib", false));
this.setLastGuidePopUpTime(reader.getAttrAsLong("lastGuidePopUpTime", 0L));
this.setCompleteEmbedFilter(reader.getAttrAsBoolean("hasCompleteEmbedFilter", false));
this.setWidgetLibHasRefreshed(reader.getAttrAsBoolean("widgetLibHasRefreshed", false));
this.setFirstDrag(reader.getAttrAsBoolean("firstDrag", true));
this.setHistoryCreatedReuses(reader.getAttrAsString("historyCreatedReuses", "[]"));
this.setFirstDragEndTime(reader.getAttrAsLong("firstDragEndTime", 0L));
}
@Override
public void writeXML(XMLPrintWriter writer) {
writer.startTAG("ComponentReuseNotificationInfo");
writer.attr("lastNotifyTime", this.lastNotifyTime)
.attr("notifiedNumber", this.notifiedNumber)
.attr("clickedWidgetLib", this.clickedWidgetLib)
.attr("lastGuidePopUpTime", this.lastGuidePopUpTime)
.attr("historyCreatedReuses", this.historyCreatedReuses);;
writer.attr("clickedWidgetLib", this.clickedWidgetLib)
.attr("hasCompleteEmbedFilter", this.completeEmbedFilter)
.attr("firstDrag", this.firstDrag)
.attr("widgetLibHasRefreshed", this.widgetLibHasRefreshed)
.attr("firstDragEndTime", this.firstDragEndTime)
.attr("historyCreatedReuses", this.historyCreatedReuses);
;
writer.end();
}

169
designer-base/src/main/java/com/fr/design/mainframe/reuse/ReuseGuideDialog.java

@ -1,169 +0,0 @@
package com.fr.design.mainframe.reuse;
import com.fr.base.background.ColorBackground;
import com.fr.design.dialog.UIDialog;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.PromptWindow;
import com.fr.design.mainframe.share.collect.ComponentCollector;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.IOUtils;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.geom.RoundRectangle2D;
public class ReuseGuideDialog extends UIDialog implements PromptWindow {
InnerDialog innerDialog;
private static final Dimension DEFAULT = new Dimension(735, 510);
public ReuseGuideDialog(Frame parent) {
super(parent);
}
@Override
public void showWindow() {
innerDialog = new InnerDialog(this);
JPanel backGroundPane = new JPanel() {
@Override
protected void paintComponent(Graphics g) {
Image icon = IOUtils.readImage("com/fr/base/images/share/background.png");// 003.jpg是测试图片在项目的根目录下
g.drawImage(icon, 0, 0, getSize().width, getSize().height, this);// 图片会自动缩放
}
};
add(backGroundPane, BorderLayout.CENTER);
initStyle();
innerDialog.showWindow();
}
private void initStyle() {
setSize(DEFAULT);
setUndecorated(true);
setBackground(new Color(0, 0, 0, 0));
GUICoreUtils.centerWindow(this);
}
@Override
public void hideWindow() {
ComponentReuseNotificationInfo.getInstance().updateLastGuidePopUpTime();
this.setVisible(false);
if (innerDialog != null) {
innerDialog.setVisible(false);
innerDialog.dispose();
innerDialog = null;
}
this.dispose();
}
@Override
public void checkValid() {
}
class InnerDialog extends UIDialog {
private final Dimension DEFAULT = new Dimension(700, 475);
private static final int TITLE_FONT_SIZE = 20;
public InnerDialog(Dialog dialog) {
super(dialog);
}
public void showWindow() {
add(createCenterPanel(), BorderLayout.CENTER);
add(createSouthPanel(), BorderLayout.SOUTH);
add(createNorthPanel(), BorderLayout.NORTH);
showDialog();
}
private JPanel createNorthPanel() {
JPanel northPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
//右上角关闭按钮
JButton button = new JButton(new ImageIcon(IOUtils.readImage("/com/fr/base/images/share/close.png").getScaledInstance(15, 15, Image.SCALE_SMOOTH)));
button.setBorder(null);
button.setOpaque(false);
button.addActionListener(e -> ReuseGuideDialog.this.hideWindow());
northPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 15));
northPanel.setOpaque(false);
northPanel.add(button);
return northPanel;
}
private JPanel createCenterPanel() {
JPanel centerPanel = new JPanel(new BorderLayout());
UILabel titleLabel = new UILabel(Toolkit.i18nText("Fine-Design_Share_Drag_And_Make_Component"));
UILabel imageLabel = new UILabel(new ImageIcon(IOUtils.readImage("com/fr/design/images/dashboard/guide.png").getScaledInstance(DEFAULT.width, DEFAULT.height, Image.SCALE_SMOOTH)));
titleLabel.setFont(new Font(titleLabel.getFont().getName(), Font.BOLD, TITLE_FONT_SIZE));
titleLabel.setBorder(BorderFactory.createEmptyBorder());
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
panel.setOpaque(false);
panel.add(titleLabel);
centerPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
centerPanel.setOpaque(false);
centerPanel.add(imageLabel, BorderLayout.CENTER);
centerPanel.add(panel, BorderLayout.NORTH);
return centerPanel;
}
private JPanel createSouthPanel() {
JPanel southPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
JButton button = new JButton(Toolkit.i18nText("Fine-Design_Share_Try_Drag")) {
@Override
public void paint(Graphics g) {
ColorBackground buttonBackground = ColorBackground.getInstance(Color.decode("#419BF9"));
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
buttonBackground.paint(g2d, new RoundRectangle2D.Double(0, 0, getWidth(), getHeight(), 8, 8));
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
super.paint(g);
}
};
button.setBorder(null);
button.setForeground(Color.WHITE);
button.setOpaque(false);
button.addActionListener(e -> ReuseGuideDialog.this.hideWindow());
southPanel.setBorder(BorderFactory.createEmptyBorder(0, 290, 19, 290));
southPanel.setPreferredSize(new Dimension(DEFAULT.width, 51));
southPanel.setOpaque(false);
southPanel.add(button);
return southPanel;
}
/**
* 显示窗口
*/
private void showDialog() {
setSize(DEFAULT);
setUndecorated(true);
GUICoreUtils.centerWindow(this);
setModalityType(ModalityType.APPLICATION_MODAL);
ReuseGuideDialog.this.setVisible(true);
setVisible(true);
}
@Override
public void checkValid() {
}
}
}

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

@ -0,0 +1,95 @@
package com.fr.design.mainframe.share;
import com.fr.design.DesignerEnvManager;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.reuse.ComponentReuseNotificationInfo;
import com.fr.form.share.constants.ComponentPath;
import com.fr.form.share.group.filter.ReuFilter;
import com.fr.design.DesignerCloudURLManager;
import com.fr.workspace.WorkContext;
/**
* Created by kerry on 2021/10/27
*/
public class ComponentShareUtil {
private ComponentShareUtil() {
}
/**
* 判断是否需要切换到在线组件库
*
* @return
*/
public static boolean needSwitch2OnlineTab() {
return DesignerCloudURLManager.getInstance().isConnected() && !hasTouched() && isCurrentTplNewCreate();
}
/**
* 判断是否可触达
*
* @return boolean
*/
public static boolean hasTouched() {
String sharePath = ComponentPath.SHARE_PATH.path();
String[] components = WorkContext.getWorkResource().list(sharePath, new ReuFilter());
return components != null && components.length > 6;
}
/**
* 判断当前模板是否是新建模板
*
* @return boolean
*/
public static boolean isCurrentTplNewCreate() {
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
return jTemplate.isNewCreateTpl();
}
/**
* 判断是否需要展示嵌入式筛选面板
*
* @return boolean
*/
public static boolean needShowEmbedFilterPane() {
return !ComponentReuseNotificationInfo.getInstance().isCompleteEmbedFilter() && !hasTouched() && isCurrentTplNewCreate();
}
/**
* 判断是否需要展示首次拖拽动效
*
* @return boolean
*/
public static boolean needShowFirstDragAnimate() {
return ComponentReuseNotificationInfo.getInstance().isFirstDrag() && !hasTouched();
}
/**
* 完成嵌入式筛选
*/
public static void completeEmbedFilter() {
boolean changed = false;
if (!ComponentReuseNotificationInfo.getInstance().isWidgetLibHasRefreshed()) {
ComponentReuseNotificationInfo.getInstance().setWidgetLibHasRefreshed(true);
changed = true;
}
if (!ComponentReuseNotificationInfo.getInstance().isCompleteEmbedFilter()) {
ComponentReuseNotificationInfo.getInstance().setCompleteEmbedFilter(true);
changed = true;
}
if (changed) {
DesignerEnvManager.getEnvManager().saveXMLFile();
}
}
/**
* 记录组件库刷新
*/
public static void recordWidgetLibHasRefreshed() {
if (!ComponentReuseNotificationInfo.getInstance().isWidgetLibHasRefreshed()) {
ComponentReuseNotificationInfo.getInstance().setWidgetLibHasRefreshed(true);
DesignerEnvManager.getEnvManager().saveXMLFile();
}
}
}

102
designer-base/src/main/java/com/fr/design/mainframe/share/collect/ComponentCollector.java

@ -4,6 +4,7 @@ import com.fr.base.io.XMLReadHelper;
import com.fr.config.MarketConfig;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.reuse.ComponentReuseNotificationInfo;
import com.fr.design.mainframe.share.ComponentShareUtil;
import com.fr.form.share.DefaultSharableWidget;
import com.fr.form.share.SharableWidgetProvider;
import com.fr.form.share.constants.ComponentPath;
@ -19,7 +20,6 @@ import com.fr.json.JSONException;
import com.fr.json.JSONFactory;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginContexts;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
@ -48,10 +48,6 @@ import java.util.Iterator;
public class ComponentCollector implements XMLable {
private static final long ONE_MINUTE = 60 * 1000L;
private static final int REUSE_INFO_FIRST_POPUP = 1;
private static final int REUSE_INFO_SECOND_POPUP = 2;
private static final String SIMPLE_DATE_PATTERN = "yyyy-MM-dd";
private static final String XML = "ComponentCollector";
@ -98,11 +94,11 @@ public class ComponentCollector implements XMLable {
private static final String MARKET_CLICK = "marketClick";
private static final String PROMPT_JUMP = "promptJump";
private static final String FIRST_SHOW_REACT = "firstShowReact";
private static final String TOOLBAR_JUMP = "toolbarJump";
private static final String EMBEDED_FILTER_REACT = "embededFilterReact";
private static final String POPUP_JUMP = "popupJump";
private static final String DYNAMIC_EFFECT_REACT = "dynamicEffectReact";
private static final String uuid = DesignerEnvManager.getEnvManager().getUUID();
@ -116,11 +112,11 @@ public class ComponentCollector implements XMLable {
private int cmpBoardClick = 0;
private int promptJump = 0;
private int firstShowReact = 0;
private int toolbarJump = 0;
private int embededFilterReact = 0;
private int popupJump = 0;
private int dynamicEffectReact = 0;
private JSONArray activateRecord = JSONFactory.createJSON(JSON.ARRAY);
@ -291,7 +287,7 @@ public class ComponentCollector implements XMLable {
try {
DefaultShareGroupManager.getInstance().refresh();
Group[] groups = DefaultShareGroupManager.getInstance().getAllGroup();
for(Group group : groups) {
for (Group group : groups) {
JSONObject jo = JSONFactory.createJSON(JSON.OBJECT);
jo.put(GROUP_NAME, group.getGroupName());
jo.put(CONTAIN_AMOUNT, group.getAllBindInfoList().length);
@ -338,37 +334,47 @@ public class ComponentCollector implements XMLable {
saveInfo();
}
public void collectPromptJumpWhenJump(){
if (ComponentReuseNotificationInfo.getInstance().getNotifiedNumber() == REUSE_INFO_FIRST_POPUP) {
this.promptJump = 1;
saveInfo();
}else if(ComponentReuseNotificationInfo.getInstance().getNotifiedNumber() == REUSE_INFO_SECOND_POPUP){
this.promptJump = 2;
saveInfo();
public void collectFirstShowReact(int flag) {
if (this.firstShowReact == flag) {
return;
}
this.firstShowReact = flag;
saveInfo();
}
public void collectPromptJumpWhenShow() {
if (ComponentReuseNotificationInfo.getInstance().getNotifiedNumber() == REUSE_INFO_SECOND_POPUP) {
this.promptJump = -1;
public void clickComponentSetting() {
if (!ComponentShareUtil.needShowEmbedFilterPane()) {
return;
}
boolean changed = false;
int firstShowReact = ComponentReuseNotificationInfo.getInstance().isWidgetLibHasRefreshed() ? 2 : -1;
if (this.firstShowReact != firstShowReact) {
this.firstShowReact = firstShowReact;
changed = true;
}
if (this.embededFilterReact == 0 && ComponentReuseNotificationInfo.getInstance().isWidgetLibHasRefreshed()) {
this.embededFilterReact = -1;
changed = true;
}
if (changed) {
saveInfo();
}
}
public void collectToolbarJump() {
if (this.toolbarJump == 0) {
this.toolbarJump = 1;
saveInfo();
public void collectEmbededFilterReact(int flag) {
if (this.embededFilterReact == flag) {
return;
}
this.embededFilterReact = flag;
saveInfo();
}
public void collectPopupJump() {
long currentTime = System.currentTimeMillis();
long lastGuidePopUpTime = ComponentReuseNotificationInfo.getInstance().getLastGuidePopUpTime();
if (currentTime - lastGuidePopUpTime <= ONE_MINUTE && this.popupJump == 0) {
this.popupJump = 1;
public void collectDynamicEffectReact() {
if (this.dynamicEffectReact == 1) {
return;
}
if (System.currentTimeMillis() - ComponentReuseNotificationInfo.getInstance().getFirstDragEndTime() <= ONE_MINUTE) {
this.dynamicEffectReact = 1;
saveInfo();
}
}
@ -468,6 +474,10 @@ public class ComponentCollector implements XMLable {
this.generateCmpNumber = reader.getAttrAsInt("generateCmpNumber", 0);
this.uploadCmpNumber = reader.getAttrAsInt("uploadCmpNumber", 0);
this.firstShowReact = reader.getAttrAsInt(FIRST_SHOW_REACT, 0);
this.embededFilterReact = reader.getAttrAsInt(EMBEDED_FILTER_REACT, 0);
this.dynamicEffectReact = reader.getAttrAsInt(DYNAMIC_EFFECT_REACT, 0);
String activateRecordStr = reader.getAttrAsString("activateRecord", StringUtils.EMPTY);
activateRecord = parseJSONArray(activateRecordStr);
String generateCmpRecordStr = reader.getAttrAsString("generateCmpRecord", StringUtils.EMPTY);
@ -475,13 +485,9 @@ public class ComponentCollector implements XMLable {
this.helpConfigInfo = parseJSONArray(reader.getAttrAsString(HELP_CONFIG_INFO, StringUtils.EMPTY));
this.helpConfigUseInfo = parseJSONArray(reader.getAttrAsString(HELP_CONFIG_USE_INFO, StringUtils.EMPTY));
this.searchContent = parseJSONArray(reader.getAttrAsString(SEARCH_CONTENT,StringUtils.EMPTY));
this.searchContent = parseJSONArray(reader.getAttrAsString(SEARCH_CONTENT, StringUtils.EMPTY));
this.filterContent = parseJSONArray(reader.getAttrAsString(FILTER_CONTENT, StringUtils.EMPTY));
this.sortType = parseJSONArray(reader.getAttrAsString(SORT_TYPE, StringUtils.EMPTY));
this.promptJump = reader.getAttrAsInt(PROMPT_JUMP, 0);
this.toolbarJump = reader.getAttrAsInt(TOOLBAR_JUMP, 0);
this.popupJump = reader.getAttrAsInt(POPUP_JUMP, 0);
}
}
@ -515,9 +521,9 @@ public class ComponentCollector implements XMLable {
.attr(SEARCH_CONTENT, searchContent.toString())
.attr(FILTER_CONTENT, filterContent.toString())
.attr(SORT_TYPE, sortType.toString())
.attr(PROMPT_JUMP, promptJump)
.attr(TOOLBAR_JUMP, toolbarJump)
.attr(POPUP_JUMP, popupJump)
.attr(FIRST_SHOW_REACT, firstShowReact)
.attr(EMBEDED_FILTER_REACT, embededFilterReact)
.attr(DYNAMIC_EFFECT_REACT, dynamicEffectReact)
.end();
}
@ -542,15 +548,9 @@ public class ComponentCollector implements XMLable {
jo.put(SEARCH_CONTENT, searchContent.toString());
jo.put(FILTER_CONTENT, filterContent.toString());
jo.put(SORT_TYPE, sortType.toString());
jo.put("guideInfo", assembleGuideInfo());
return jo.toString();
}
private String assembleGuideInfo() {
JSONObject jo = JSONFactory.createJSON(JSON.OBJECT);
jo.put(PROMPT_JUMP, promptJump)
.put(TOOLBAR_JUMP, toolbarJump)
.put(POPUP_JUMP, popupJump);
jo.put(FIRST_SHOW_REACT, firstShowReact);
jo.put(EMBEDED_FILTER_REACT, embededFilterReact);
jo.put(DYNAMIC_EFFECT_REACT, dynamicEffectReact);
return jo.toString();
}
@ -603,7 +603,7 @@ public class ComponentCollector implements XMLable {
return JSONFactory.createJSON(JSON.ARRAY);
}
public void clear(){
public void clear() {
clearActiveRecord();
clearGenerateCmpRecord();
clearFilterContent();

7
designer-base/src/test/java/com/fr/design/mainframe/reuse/ComponentReuseNotificationInfoTest.java

@ -18,13 +18,11 @@ public class ComponentReuseNotificationInfoTest {
@Test
public void testReadXML() {
try {
XMLableReader xmlReader = XMLableReader.createXMLableReader(new StringReader("<ComponentReuseNotificationInfo lastNotifyTime=\"1620612153215\" notifiedNumber=\"2\" clickedWidgetLib=\"true\"/>\n"));
XMLableReader xmlReader = XMLableReader.createXMLableReader(new StringReader("<ComponentReuseNotificationInfo lastNotifyTime=\"1620612153215\" clickedWidgetLib=\"true\"/>\n"));
ComponentReuseNotificationInfo notificationInfo = ComponentReuseNotificationInfo.getInstance();
notificationInfo.readXML(xmlReader);
xmlReader.close();
Assert.assertEquals(2, notificationInfo.getNotifiedNumber());
Assert.assertEquals(true, notificationInfo.isClickedWidgetLib());
Assert.assertEquals(1620612153215L, notificationInfo.getLastNotifyTime());
} catch (XMLStreamException e) {
Assert.fail(e.getMessage());
}
@ -35,12 +33,11 @@ public class ComponentReuseNotificationInfoTest {
StringWriter sw = new StringWriter();
XMLPrintWriter writer = XMLPrintWriter.create(new PrintWriter(sw));
ComponentReuseNotificationInfo notificationInfo = ComponentReuseNotificationInfo.getInstance();
notificationInfo.setNotifiedNumber(1);
notificationInfo.writeXML(writer);
writer.flush();
writer.close();
Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<ComponentReuseNotificationInfo xmlVersion=\"20170720\" releaseVersion=\"\" lastNotifyTime=\"0\" notifiedNumber=\"1\" clickedWidgetLib=\"false\"/>\n", sw.toString());
"<ComponentReuseNotificationInfo xmlVersion=\"20170720\" releaseVersion=\"\" clickedWidgetLib=\"false\" hasCompleteEmbedFilter=\"false\" firstDrag=\"true\" widgetLibHasRefreshed=\"false\" firstDragEndTime=\"0\" historyCreatedReuses=\"[]\"/>\n", sw.toString());
}
}

2
designer-form/src/main/java/com/fr/design/mainframe/FormParaWidgetPane.java

@ -17,7 +17,6 @@ import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.share.collect.ComponentCollector;
import com.fr.design.module.DesignModuleFactory;
import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.UserDefinedWidgetConfig;
@ -253,7 +252,6 @@ public class FormParaWidgetPane extends JPanel {
@Override
public void mouseClicked(MouseEvent e) {
FormWidgetDetailPane.getInstance().enterWidgetLib();
ComponentCollector.getInstance().collectToolbarJump();
}
@Override

10
designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java

@ -7,8 +7,8 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.locale.impl.ShowOnlineWidgetMark;
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.share.ui.local.LocalWidgetRepoPane;
import com.fr.design.mainframe.share.ui.online.OnlineWidgetRepoPane;
import com.fr.general.locale.LocaleCenter;
@ -106,17 +106,20 @@ public class FormWidgetDetailPane extends FormDockView{
}
cardLayout.show(centerPane, paneList.get(newSelectedIndex).getTitle());
}
};
headGroup.setSelectedIndex(ComponentReuseNotificationInfo.getInstance().isClickedWidgetLib() ? 0 : ONLINE_TAB);
};
headGroup.setSelectedIndex(ComponentShareUtil.needSwitch2OnlineTab() ? ONLINE_TAB : 0);
this.add(headGroup, BorderLayout.NORTH);
this.add(centerPane, BorderLayout.CENTER);
}
public void resetEmptyPane(){
this.isEmptyPane = false;
}
/**
* 清除数据
*/
@ -178,6 +181,7 @@ public class FormWidgetDetailPane extends FormDockView{
paneList = new ArrayList<>();
paneList.add(LocalWidgetRepoPane.getInstance());
if (isShowOnlineWidgetRepoPane()) {
OnlineWidgetRepoPane.getInstance().refresh();
paneList.add(OnlineWidgetRepoPane.getInstance());
}
}

15
designer-form/src/main/java/com/fr/design/mainframe/JForm.java

@ -7,7 +7,6 @@ import com.fr.base.Releasable;
import com.fr.base.extension.FileExtension;
import com.fr.base.iofile.attr.ExtendSharableAttrMark;
import com.fr.base.theme.FormTheme;
import com.fr.base.theme.FormThemeConfig;
import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.TemplateThemeCompatible;
import com.fr.base.theme.TemplateThemeConfig;
@ -50,6 +49,8 @@ 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.share.collect.ComponentCollector;
import com.fr.design.mainframe.share.ComponentShareUtil;
import com.fr.design.mainframe.template.info.JFormProcessInfo;
import com.fr.design.mainframe.template.info.TemplateProcessInfo;
import com.fr.design.mainframe.theme.dialog.TemplateThemeUsingDialog;
@ -350,13 +351,6 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
}
String key = jt.getEditingFILE().getPath() + "-" + jt.getTarget().getTemplateID();
FormHierarchyTreePane.getInstance().removeTreePath(key);
ReuseTriggerPointManager.getInstance().removeJForm(JForm.this);
}
@Override
public void templateOpened(JTemplate<?, ?> jt) {
ReuseTriggerPointManager.getInstance().registerJForm(JForm.this);
}
@Override
@ -900,9 +894,14 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
pane.setLayout(new BorderLayout());
pane.add(FormWidgetDetailPane.getInstance(formDesign), BorderLayout.CENTER);
EastRegionContainerPane.getInstance().replaceWidgetLibPane(pane);
if (!ComponentShareUtil.hasTouched() && this.isNewCreateTpl()) {
ComponentCollector.getInstance().collectFirstShowReact(1);
EastRegionContainerPane.getInstance().switchTabTo(EastRegionContainerPane.KEY_WIDGET_LIB);
}
}
}
public String getEditingCreatorName() {
return formDesign.getSelectionModel().getSelection().getSelectedCreator().toData().getWidgetName();
}

217
designer-form/src/main/java/com/fr/design/mainframe/ReuseTriggerPointManager.java

@ -1,217 +0,0 @@
package com.fr.design.mainframe;
import com.fr.base.iofile.attr.ExtendSharableAttrMark;
import com.fr.design.DesignerEnvManager;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.adaptve.config.TriggerPointProvider;
import com.fr.design.mainframe.adaptve.config.impl.CellStyleTriggerPoint;
import com.fr.design.mainframe.adaptve.config.impl.CellValueImageChangeTriggerPoint;
import com.fr.design.mainframe.adaptve.config.ReuseNotifyInfo;
import com.fr.design.mainframe.reuse.ComponentReuseNotificationInfo;
import com.fr.design.mainframe.share.collect.ComponentCollector;
import com.fr.design.mainframe.toast.DesignerToastMsgUtil;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
import com.fr.event.Null;
import com.fr.form.main.Form;
import com.fr.form.main.WidgetGather;
import com.fr.form.ui.AbstractBorderStyleWidget;
import com.fr.form.ui.Widget;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* Created by kerry on 4/28/21
*/
public class ReuseTriggerPointManager {
private static final long ONE_WEEK_TIME = 7 * 24 * 3600 * 1000L;
private static class Holder {
private static final ReuseTriggerPointManager HOLDER = new ReuseTriggerPointManager();
}
public static ReuseTriggerPointManager getInstance() {
return Holder.HOLDER;
}
private Map<JForm, ReuseNotifyInfo> map = new HashMap<>();
private List<Listener> listeners = new ArrayList<>();
private ReuseTriggerPointManager() {
if (!hasNotifiedTwice()) {
List<TriggerPointProvider> list = getTriggerPoints();
for (TriggerPointProvider triggerPoint : list) {
Listener listener = new Listener<Null>() {
@Override
public void on(Event event, Null o) {
triggerPoint.triggerAction();
}
};
EventDispatcher.listen(triggerPoint.triggerEvent(), listener);
listeners.add(listener);
}
}
}
private List<TriggerPointProvider> getTriggerPoints() {
List<TriggerPointProvider> list = new ArrayList<>();
list.add(new CellStyleTriggerPoint());
list.add(new CellValueImageChangeTriggerPoint());
return list;
}
public boolean hasNotifiedTwice() {
return ComponentReuseNotificationInfo.getInstance().getNotifiedNumber() >= 2;
}
private void reCount() {
//重新计次数
Iterator<Map.Entry<JForm, ReuseNotifyInfo>> iterator = map.entrySet().iterator();
while (iterator.hasNext()) {
iterator.next().getValue().reset();
}
}
private void writeTriggerInfo2xml() {
int number = ComponentReuseNotificationInfo.getInstance().getNotifiedNumber() + 1;
ComponentReuseNotificationInfo.getInstance().setNotifiedNumber(number);
ComponentReuseNotificationInfo.getInstance().setLastNotifyTime(System.currentTimeMillis());
DesignerEnvManager.getEnvManager().saveXMLFile();
//如果已经提示过两次了
if (hasNotifiedTwice()) {
for (Listener listener : listeners) {
EventDispatcher.stopListen(listener);
}
this.map.clear();
}
}
public boolean needTrigger() {
boolean result = true;
if (ComponentReuseNotificationInfo.getInstance().getLastNotifyTime() > 0L) {
result = System.currentTimeMillis() - ComponentReuseNotificationInfo.getInstance().getLastNotifyTime() > ONE_WEEK_TIME;
}
return !hasNotifiedTwice() && result;
}
public void registerJForm(JForm jForm) {
if (!hasNotifiedTwice()) {
this.map.put(jForm, new ReuseNotifyInfo());
}
}
public void removeJForm(JForm jForm) {
if (!hasNotifiedTwice()) {
this.map.remove(jForm);
}
}
public ReuseNotifyInfo getReuseNotifyInfo() {
JTemplate currentJTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (!(currentJTemplate instanceof JForm && hasUseReuseComponent((JForm) currentJTemplate))
&& !ReuseTriggerPointManager.getInstance().needTrigger()) {
return null;
}
return map.get(currentJTemplate);
}
public void reuseNotify(ReuseNotifyInfo notifyInfo) {
if (notifyInfo.matchCondition()) {
ReuseTriggerPointManager.getInstance().reCount();
//弹出提示框
JTemplate currentJTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
DesignerToastMsgUtil.toastPrompt(createReusePrompt((JForm) currentJTemplate));
ReuseTriggerPointManager.getInstance().writeTriggerInfo2xml();
ComponentCollector.getInstance().collectPromptJumpWhenShow();
}
}
private boolean hasUseReuseComponent(JForm jForm) {
Form form = jForm.getTarget();
List<Widget> extendSharableWidgetList = new ArrayList<>();
Form.traversalWidget(form.getContainer(), new WidgetGather() {
@Override
public void dealWith(Widget widget) {
ExtendSharableAttrMark attrMark = ((AbstractBorderStyleWidget) widget).getWidgetAttrMark(ExtendSharableAttrMark.XML_TAG);
if (attrMark != null && StringUtils.isNotEmpty(attrMark.getShareId())) {
extendSharableWidgetList.add(widget);
}
}
@Override
public boolean dealWithAllCards() {
return true;
}
}, AbstractBorderStyleWidget.class);
return extendSharableWidgetList.size() > 0;
}
private JPanel createReusePrompt(JForm jForm) {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
jPanel.add(new UILabel(Toolkit.i18nText("Fine-Design_Component_Reuse_Try_Prompt")), BorderLayout.WEST);
UILabel reuseLabel = new UILabel(Toolkit.i18nText("Fine-Design_Share_Component"));
reuseLabel.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
jForm.tabChanged(0);
FormWidgetDetailPane.getInstance().enterWidgetLib();
ComponentCollector.getInstance().collectPromptJumpWhenJump();
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
});
reuseLabel.setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 0));
reuseLabel.setForeground(Color.BLUE);
reuseLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
jPanel.add(reuseLabel, BorderLayout.CENTER);
return jPanel;
}
}

30
designer-form/src/main/java/com/fr/design/mainframe/adaptve/config/ReuseNotifyInfo.java

@ -1,30 +0,0 @@
package com.fr.design.mainframe.adaptve.config;
/**
* Created by kerry on 5/7/21
*/
public class ReuseNotifyInfo {
private static final int CELL_STYLE_MODIFY_MAX_NUMBER = 3;
private static final int CELL_IMAGE_VALUE_MODIFY_MAX_NUMBER = 1;
private int cellStyleModifiedNumber = 0;
private int cellImageValueNumber = 0;
public void addCellStyleModify() {
cellStyleModifiedNumber++;
}
public void addCellImageValueModify() {
cellImageValueNumber++;
}
public boolean matchCondition() {
return cellStyleModifiedNumber >= CELL_STYLE_MODIFY_MAX_NUMBER
|| cellImageValueNumber >= CELL_IMAGE_VALUE_MODIFY_MAX_NUMBER;
}
public void reset() {
this.cellImageValueNumber = 0;
this.cellStyleModifiedNumber = 0;
}
}

20
designer-form/src/main/java/com/fr/design/mainframe/adaptve/config/TriggerPointProvider.java

@ -1,20 +0,0 @@
package com.fr.design.mainframe.adaptve.config;
import com.fr.event.Event;
/**
* Created by kerry on 4/29/21
*/
public interface TriggerPointProvider {
/**
* 触发后的操作
*/
void triggerAction();
/**
* 触发事件
* @return
*/
Event triggerEvent();
}

28
designer-form/src/main/java/com/fr/design/mainframe/adaptve/config/impl/CellStyleTriggerPoint.java

@ -1,28 +0,0 @@
package com.fr.design.mainframe.adaptve.config.impl;
import com.fr.design.mainframe.DesignOperationEvent;
import com.fr.design.mainframe.ReuseTriggerPointManager;
import com.fr.design.mainframe.adaptve.config.ReuseNotifyInfo;
import com.fr.design.mainframe.adaptve.config.TriggerPointProvider;
import com.fr.event.Event;
/**
* Created by kerry on 5/7/21
*/
public class CellStyleTriggerPoint implements TriggerPointProvider {
@Override
public void triggerAction() {
ReuseNotifyInfo notifyInfo = ReuseTriggerPointManager.getInstance().getReuseNotifyInfo();
if (notifyInfo == null) {
return;
}
notifyInfo.addCellStyleModify();
ReuseTriggerPointManager.getInstance().reuseNotify(notifyInfo);
}
@Override
public Event triggerEvent() {
return DesignOperationEvent.CELL_STYLE_MODIFY;
}
}

27
designer-form/src/main/java/com/fr/design/mainframe/adaptve/config/impl/CellValueImageChangeTriggerPoint.java

@ -1,27 +0,0 @@
package com.fr.design.mainframe.adaptve.config.impl;
import com.fr.design.mainframe.DesignOperationEvent;
import com.fr.design.mainframe.ReuseTriggerPointManager;
import com.fr.design.mainframe.adaptve.config.ReuseNotifyInfo;
import com.fr.design.mainframe.adaptve.config.TriggerPointProvider;
import com.fr.event.Event;
/**
* Created by kerry on 5/7/21
*/
public class CellValueImageChangeTriggerPoint implements TriggerPointProvider {
@Override
public void triggerAction() {
ReuseNotifyInfo notifyInfo = ReuseTriggerPointManager.getInstance().getReuseNotifyInfo();
if (notifyInfo == null) {
return;
}
notifyInfo.addCellImageValueModify();
ReuseTriggerPointManager.getInstance().reuseNotify(notifyInfo);
}
@Override
public Event triggerEvent() {
return DesignOperationEvent.CELL_IMAGE_VALUE_MODIFY;
}
}

3
designer-form/src/main/java/com/fr/design/mainframe/share/AbstractWidgetSelectPane.java

@ -1,7 +1,6 @@
package com.fr.design.mainframe.share;
import com.fr.design.mainframe.share.ui.base.AbstractWidgetPopupPreviewPane;
import com.fr.design.mainframe.share.ui.base.LocalWidgetPopupPreviewPane;
import com.fr.design.mainframe.share.ui.block.PreviewWidgetBlock;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;
@ -44,7 +43,7 @@ public abstract class AbstractWidgetSelectPane<T> extends JPanel {
if (!previewPane.isVisible() && comp.getWidth() != 0 && comp.getHeight() != 0) {
//父容器是GroupPane,要获得的是GroupPane的父容器
Container parentContainer =getParentContainer();
Container parentContainer = getParentContainer();
previewPane.populateBean(comp);
int popupPosY = comp.getLocationOnScreen().y - parentContainer.getLocationOnScreen().y;
if (previewPane.getHeight() + popupPosY > parentContainer.getHeight() + SCROLL_BAR_HEIGHT) {

44
designer-form/src/main/java/com/fr/design/mainframe/share/Bean/FilterTypeInfo.java

@ -0,0 +1,44 @@
package com.fr.design.mainframe.share.Bean;
import java.util.ArrayList;
import java.util.List;
/**
* Created by kerry on 2021/11/1
*/
public class FilterTypeInfo {
private String title;
private String key;
private final List<WidgetFilterTypeInfo> filterTypeInfos = new ArrayList<>();
public FilterTypeInfo(String title, String key){
this.title = title;
this.key = key;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public void addFilterType(WidgetFilterTypeInfo info){
this.filterTypeInfos.add(info);
}
public List<WidgetFilterTypeInfo> getFilterTypeInfos(){
return filterTypeInfos;
}
}

60
designer-form/src/main/java/com/fr/design/mainframe/share/Bean/WidgetFilterInfo.java

@ -0,0 +1,60 @@
package com.fr.design.mainframe.share.Bean;
import java.util.ArrayList;
import java.util.List;
/**
* Created by kerry on 2020-10-23
*/
public class WidgetFilterInfo {
private String name;
private String id;
private String type;
private List<WidgetFilterInfo> childFilterInfo = new ArrayList<>();
public WidgetFilterInfo(String name, String id, String type) {
this.name = name;
this.id = id;
this.type = type;
}
public WidgetFilterInfo() {
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public void addChildFilterInfo(WidgetFilterInfo filterInfo) {
this.childFilterInfo.add(filterInfo);
}
public List<WidgetFilterInfo> getInnerFilterInfo() {
return childFilterInfo;
}
public boolean hasChildFilter() {
return childFilterInfo.size() > 0;
}
}

93
designer-form/src/main/java/com/fr/design/mainframe/share/Bean/WidgetFilterTypeInfo.java

@ -0,0 +1,93 @@
package com.fr.design.mainframe.share.Bean;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.share.util.ShareFilterConstants;
import com.fr.general.ComparatorUtils;
import com.fr.json.JSONArray;
import com.fr.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
/**
* Created by kerry on 2020-10-21
*/
public class WidgetFilterTypeInfo {
private static final String KEY_SPLIT_CHAR = "@";
private String title;
private String key;
private List<WidgetFilterInfo> filterItems = new ArrayList<>();
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public List<WidgetFilterInfo> getFilterItems() {
return filterItems;
}
public void addFilterItem(WidgetFilterInfo filterInfo) {
this.filterItems.add(filterInfo);
}
public static WidgetFilterTypeInfo parseFromJSONObject(JSONObject jsonObject) {
WidgetFilterTypeInfo typeInfo = new WidgetFilterTypeInfo();
typeInfo.setTitle(jsonObject.getString("title"));
typeInfo.setKey(jsonObject.getString("key"));
JSONArray ja = jsonObject.getJSONArray("items");
if (ComparatorUtils.equals(typeInfo.getKey(), ShareFilterConstants.STYLE_FILTER_KEY)) {
createStyleFilterType(ja, typeInfo);
} else {
for (int i = 0; i < ja.size(); i++) {
JSONObject jo = ja.getJSONObject(i);
WidgetFilterInfo info = new WidgetFilterInfo();
info.setId(jo.getString("id"));
info.setName(jo.optString("name"));
info.setType(parseType(typeInfo.getKey()));
typeInfo.addFilterItem(info);
}
}
return typeInfo;
}
private static void createStyleFilterType(JSONArray ja, WidgetFilterTypeInfo typeInfo) {
WidgetFilterInfo dark = new WidgetFilterInfo();
dark.setName(Toolkit.i18nText("Fine-Design_Share_Local_Filter_Dark_Style"));
WidgetFilterInfo light = new WidgetFilterInfo();
light.setName(Toolkit.i18nText("Fine-Design_Share_Local_Filter_Light_Style"));
typeInfo.addFilterItem(dark);
typeInfo.addFilterItem(light);
for (int i = 0; i < ja.size(); i++) {
JSONObject jo = ja.getJSONObject(i);
WidgetFilterInfo info = new WidgetFilterInfo();
info.setId(jo.getString("id"));
info.setName(jo.optString("name"));
info.setType(parseType(typeInfo.getKey()));
if (ComparatorUtils.equals(jo.getInt("themeColor"), 0)) {
dark.addChildFilterInfo(info);
} else {
light.addChildFilterInfo(info);
}
}
}
private static String parseType(String text) {
return text.split(KEY_SPLIT_CHAR)[1];
}
}

82
designer-form/src/main/java/com/fr/design/mainframe/share/config/ComponentReuseConfigManager.java

@ -0,0 +1,82 @@
package com.fr.design.mainframe.share.config;
import com.fr.design.DesignerCloudURLManager;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Properties;
/**
* Created by kerry on 2020-12-14
*/
public class ComponentReuseConfigManager {
private static class Holder {
private static final ComponentReuseConfigManager HOLDER = new ComponentReuseConfigManager();
}
private static final String PROPERTIES_FILE_NAME = "reuse.properties";
private static final String MINI_SHOP_URL = "MINI_SHOP_URL";
private static final String COMPONENT_UPLOAD_URL = "COMPONENT_UPLOAD_URL";
private static final String MARKET_LOGIN_URL = "MARKET_LOGIN_URL";
private static final String UPLOAD_REU_SUPPORT = "UPLOAD_REU_SUPPORT";
public static ComponentReuseConfigManager getInstance() {
return ComponentReuseConfigManager.Holder.HOLDER;
}
private Properties properties;
private ComponentReuseConfigManager() {
}
private File getReusePropertyFile() {
File file = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), PROPERTIES_FILE_NAME));
return file;
}
private String loadAttribute(String key, String defaultValue) {
if (properties == null) {
properties = new Properties();
File file = getReusePropertyFile();
if (!file.exists()) {
return defaultValue;
}
try {
InputStream in = new FileInputStream(file);
properties.load(in);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
String p = properties.getProperty(key);
if (StringUtils.isEmpty(p)) {
p = defaultValue;
}
return p;
}
public String getMiniShopUrl() {
return loadAttribute(MINI_SHOP_URL, DesignerCloudURLManager.getInstance().acquireUrlByKind("af.reuseInfo"));
}
public String getComponentUploadUrl() {
//云中心暂时没有上传网址,这边默认值为空,后续再添加
return loadAttribute(COMPONENT_UPLOAD_URL, StringUtils.EMPTY);
}
public String getMarketLoginUrl() {
return loadAttribute(MARKET_LOGIN_URL, DesignerCloudURLManager.getInstance().acquireUrlByKind("market.login"));
}
public boolean supportUploadReu() {
String uploadReuSupport = loadAttribute(UPLOAD_REU_SUPPORT, "false");
return Boolean.valueOf(uploadReuSupport);
}
}

14
designer-form/src/main/java/com/fr/design/mainframe/share/constants/StyleTheme.java

@ -1,11 +1,11 @@
package com.fr.design.mainframe.share.constants;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.share.util.OnlineShopUtils;
import com.fr.design.mainframe.share.util.ShareFilterConstants;
import com.fr.form.share.bean.StyleThemeBean;
import com.fr.form.share.bean.WidgetFilterInfo;
import com.fr.form.share.bean.WidgetFilterTypeInfo;
import com.fr.form.share.constants.ShareComponentConstants;
import com.fr.form.share.utils.ShareUtils;
import com.fr.design.mainframe.share.Bean.WidgetFilterInfo;
import com.fr.design.mainframe.share.Bean.WidgetFilterTypeInfo;
import com.fr.general.ComparatorUtils;
import java.util.ArrayList;
@ -54,13 +54,13 @@ public enum StyleTheme {
* @return List
*/
public static List<StyleThemeBean> getStyleThemeTypeInfo() {
List<WidgetFilterTypeInfo> widgetFilterTypeInfos = ShareUtils.getWidgetFilterTypeInfos();
List<WidgetFilterTypeInfo> widgetFilterTypeInfos = OnlineShopUtils.getWidgetFilterTypeInfos();
if (widgetFilterTypeInfos.isEmpty()) {
return types();
}
WidgetFilterTypeInfo styleThemeFilterInfo = new WidgetFilterTypeInfo();
for (WidgetFilterTypeInfo typeInfo : widgetFilterTypeInfos) {
if (ComparatorUtils.equals(ShareComponentConstants.STYLE_THEME_KEY, typeInfo.getKey())) {
if (ComparatorUtils.equals(ShareFilterConstants.STYLE_FILTER_KEY, typeInfo.getKey())) {
styleThemeFilterInfo = typeInfo;
break;
}
@ -70,7 +70,7 @@ public enum StyleTheme {
Iterator<WidgetFilterInfo> infoIterator = filterInfoList.iterator();
while (infoIterator.hasNext()) {
WidgetFilterInfo filterInfo = infoIterator.next();
if (!ComparatorUtils.equals(ShareComponentConstants.ALL_STYLE_THEME, filterInfo.getId())) {
if (!ComparatorUtils.equals(ShareFilterConstants.ALL_STYLE_THEME, filterInfo.getId())) {
resultList.add(new StyleThemeBean(filterInfo.getId(), filterInfo.getName()));
}
}

2
designer-form/src/main/java/com/fr/design/mainframe/share/generate/task/ComponentUploader.java

@ -2,7 +2,7 @@ package com.fr.design.mainframe.share.generate.task;
import com.fr.config.MarketConfig;
import com.fr.design.i18n.Toolkit;
import com.fr.form.share.config.ComponentReuseConfigManager;
import com.fr.design.mainframe.share.config.ComponentReuseConfigManager;
import com.fr.design.mainframe.share.generate.ComponentBanner;
import com.fr.io.utils.ResourceIOUtils;
import com.fr.log.FineLoggerFactory;

4
designer-form/src/main/java/com/fr/design/mainframe/share/sort/OnlineWidgetSortType.java

@ -1,9 +1,9 @@
package com.fr.design.mainframe.share.sort;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.share.util.OnlineShopUtils;
import com.fr.form.share.bean.OnlineShareWidget;
import com.fr.form.share.bean.SortParameter;
import com.fr.form.share.utils.ShareUtils;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext;
@ -21,7 +21,7 @@ public enum OnlineWidgetSortType implements SortType<OnlineShareWidget> {
COMPOSITE {
@Override
public void sort(OnlineShareWidget[] widgetProviders) {
Map<String, SortParameter> parameterMap = ShareUtils.getCompositeSortPara();
Map<String, SortParameter> parameterMap = OnlineShopUtils.getCompositeSortPara();
Arrays.sort(widgetProviders, new Comparator<OnlineShareWidget>() {
@Override
public int compare(OnlineShareWidget o1, OnlineShareWidget o2) {

11
designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/AbstractOnlineWidgetBlock.java

@ -4,9 +4,9 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.share.ui.actions.DownloadSuitableThemeAction;
import com.fr.design.mainframe.share.ui.actions.Jump2DetailAction;
import com.fr.design.mainframe.share.ui.actions.SharedComponentPopupMenu;
import com.fr.design.mainframe.share.ui.online.OnlineResourceManager;
import com.fr.design.mainframe.share.ui.online.OnlineWidgetSelectPane;
import com.fr.design.mainframe.share.ui.online.ResourceLoader;
import com.fr.design.mainframe.share.ui.online.AbstractOnlineWidgetSelectPane;
import com.fr.design.mainframe.share.ui.online.resource.OnlineResourceManager;
import com.fr.design.mainframe.share.ui.online.resource.ResourceLoader;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.form.share.bean.OnlineShareWidget;
import com.fr.form.share.constants.ShareComponentConstants;
@ -30,10 +30,10 @@ import java.net.URL;
*/
public abstract class AbstractOnlineWidgetBlock extends PreviewWidgetBlock<OnlineShareWidget> implements ResourceLoader {
private final OnlineWidgetSelectPane parentPane;
private final AbstractOnlineWidgetSelectPane parentPane;
private UILabel coverLabel;
public AbstractOnlineWidgetBlock(OnlineShareWidget widget, OnlineWidgetSelectPane parentPane) {
public AbstractOnlineWidgetBlock(OnlineShareWidget widget, AbstractOnlineWidgetSelectPane parentPane) {
super(widget);
this.parentPane = parentPane;
}
@ -78,7 +78,6 @@ public abstract class AbstractOnlineWidgetBlock extends PreviewWidgetBlock<Onlin
public void load() {
Image image;
try {
Dimension coverDimension = getCoverDimension();
String previewURI = UriUtils.encodePath(widget.getPicPath(), EncodeConstants.ENCODING_UTF_8) + "?x-oss-process=image/resize,m_fixed," + "w_" + coverDimension.width +
",h_" + coverDimension.height;

53
designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/BezierCubic.java

@ -0,0 +1,53 @@
package com.fr.design.mainframe.share.ui.block;
/**
* Created by kerry on 2021/10/29
* 贝塞尔缓动函数实现 https://www.xuanfengge.com/easeing/easeing/
*/
public class BezierCubic {
private final double px1;
private final double px2;
private final double px3;
private final double py1;
private final double py2;
private final double py3;
private final double epsilon;
public BezierCubic(double a, double b, double c, double d) {
this.px3 = 3 * a;
this.px2 = 3 * (c - a) - this.px3;
this.px1 = 1 - this.px3 - this.px2;
this.py3 = 3 * b;
this.py2 = 3 * (d - b) - this.py3;
this.py1 = 1 - this.py3 - this.py2;
this.epsilon = 1e-7; // 目标精度
}
public double getX(double t) {
return ((this.px1 * t + this.px2) * t + this.px3) * t;
}
public double getY(double t) {
return ((this.py1 * t + this.py2) * t + this.py3) * t;
}
public double solve(double x) {
if (x == 0 || x == 1) { // 对 0 和 1 两个特殊 t 不做计算
return this.getY(x);
}
double t = x;
for (int i = 0; i < 8; i++) { // 进行 8 次迭代
double g = this.getX(t) - x;
if (Math.abs(g) < this.epsilon) { // 检测误差到可以接受的范围
return this.getY(t);
}
double d = (3 * this.px1 * t + 2 * this.px2) * t + this.px3; // 对 x 求导
if (Math.abs(d) < 1e-6) { // 如果梯度过低,说明牛顿迭代法无法达到更高精度
break;
}
t = t - g / d;
}
return this.getY(t); // 对得到的近似 t 求 y
}
}

14
designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java

@ -2,20 +2,17 @@ package com.fr.design.mainframe.share.ui.block;
import com.fr.base.GraphHelper;
import com.fr.base.iofile.attr.SharableAttrMark;
import com.fr.design.actions.UpdateAction;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.WidgetToolBarPane;
import com.fr.design.mainframe.share.collect.ComponentCollector;
import com.fr.design.mainframe.share.group.ui.GroupMoveDialog;
import com.fr.design.mainframe.share.ui.actions.SharedComponentMenuItemUI;
import com.fr.design.mainframe.share.ui.actions.SharedComponentPopupAction;
import com.fr.design.mainframe.share.ui.actions.SharedComponentPopupMenu;
import com.fr.design.mainframe.share.ui.constants.ColorConstants;
@ -37,7 +34,6 @@ import com.fr.general.IOUtils;
import com.fr.stable.Constants;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.JPanel;
@ -68,7 +64,7 @@ public class LocalWidgetBlock extends PreviewWidgetBlock<DefaultSharableWidget>
private boolean isEdit;
private boolean isMarked;
private boolean pressed;
private boolean hover;
private final Icon markedMode = IOUtils.readIcon("/com/fr/base/images/share/marked.png");
private final Icon unMarkedMode = IOUtils.readIcon("/com/fr/base/images/share/unmarked.png");
@ -152,6 +148,7 @@ public class LocalWidgetBlock extends PreviewWidgetBlock<DefaultSharableWidget>
pressed = true;
}
@Override
public void mouseReleased(MouseEvent e) {
super.mouseReleased(e);
@ -174,7 +171,7 @@ public class LocalWidgetBlock extends PreviewWidgetBlock<DefaultSharableWidget>
@Override
public void mouseEntered(MouseEvent e) {
super.mouseEntered(e);
hover = true;
}
@Override
@ -182,25 +179,24 @@ public class LocalWidgetBlock extends PreviewWidgetBlock<DefaultSharableWidget>
super.mouseExited(e);
this.mouseHover = false;
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
hover = false;
this.repaint();
}
@Override
public void mouseDragged(MouseEvent e) {
super.mouseDragged(e);
if (DesignModeContext.isAuthorityEditing() || lastPressEvent == null || isEdit) {
return;
}
hidePreview();
ComponentCollector.getInstance().collectPopupJump();
Object source = e.getSource();
if (source instanceof LocalWidgetBlock) {
LocalWidgetBlock no = (LocalWidgetBlock) e.getSource();
if (no == null) {
return;
}
XCreator xCreator= transformXCreator(no);
XCreator xCreator = transformXCreator(no);
if (xCreator == null) {
return;
}

10
designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/OnlineWidgetBlock.java

@ -12,6 +12,7 @@ import com.fr.design.login.DesignerLoginHelper;
import com.fr.design.login.DesignerLoginSource;
import com.fr.design.mainframe.WidgetToolBarPane;
import com.fr.design.mainframe.share.collect.ComponentCollector;
import com.fr.design.mainframe.share.ui.online.AbstractOnlineWidgetSelectPane;
import com.fr.form.share.DefaultSharableWidget;
import com.fr.form.share.group.DefaultShareGroup;
import com.fr.design.mainframe.share.ui.local.LocalWidgetRepoPane;
@ -73,7 +74,7 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock {
private static final BufferedImage WIDGET_DOWNLOAD_ICON = IOUtils.readImage("/com/fr/base/images/share/download.png");
private static final BufferedImage WIDGET_DOWNLOADING_ICON = IOUtils.readImage("/com/fr/base/images/share/downloading.png");
public OnlineWidgetBlock(OnlineShareWidget widget, OnlineWidgetSelectPane parentPane) {
public OnlineWidgetBlock(OnlineShareWidget widget, AbstractOnlineWidgetSelectPane parentPane) {
super(widget, parentPane);
this.add(createSouthPane(widget), BorderLayout.SOUTH);
new DragAndDropDragGestureListener(this, DnDConstants.ACTION_COPY_OR_MOVE);
@ -145,13 +146,13 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock {
@Override
public void mouseDragged(MouseEvent e) {
super.mouseDragged(e);
if (DesignModeContext.isAuthorityEditing() || !checkWidgetInstalled()) {
return;
}
if (lastPressEvent == null) {
return;
}
ComponentCollector.getInstance().collectPopupJump();
Object source = e.getSource();
Widget creatorSource;
String shareId;
@ -269,6 +270,11 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock {
return ShareUtils.getElCaseBindInfoById(widget.getUuid()) != null;
}
protected boolean checkWidget(){
return checkWidgetInstalled();
}
private Group getDefaultGroup() {
return DefaultShareGroupManager.getInstance().getGroup(DefaultShareGroup.GROUP_NAME);
}

131
designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/PreviewWidgetBlock.java

@ -1,24 +1,40 @@
package com.fr.design.mainframe.share.ui.block;
import com.fr.concurrent.NamedThreadFactory;
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.reuse.ComponentReuseNotificationInfo;
import com.fr.design.mainframe.share.ComponentShareUtil;
import com.fr.design.mainframe.share.collect.ComponentCollector;
import com.fr.design.mainframe.share.ui.online.CarouselStateManger;
import com.fr.design.mainframe.share.ui.online.embed.AnimatePopupDialog;
import com.fr.design.mainframe.share.ui.online.embed.FirstDragAnimateStateManager;
import com.fr.form.share.constants.ShareComponentConstants;
import com.fr.module.ModuleContext;
import org.jetbrains.annotations.NotNull;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
import java.awt.AWTEvent;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.AWTEventListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.io.Serializable;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Created by kerry on 2020-10-21
@ -27,6 +43,18 @@ public abstract class PreviewWidgetBlock<T> extends JPanel implements MouseListe
protected T widget;
private boolean showing = false;
private final JPopupMenu rightClickPopupMenu;
private long lastStallTime = 0;
protected boolean hover;
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};
private static final String FIRST_DRAG_ANIMATE = "first_drag_animate";
private final ScheduledExecutorService firstDragCheckService = ModuleContext.getExecutor().newSingleThreadScheduledExecutor(new NamedThreadFactory("first_drag_check"));
public PreviewWidgetBlock(T widget) {
this.widget = widget;
@ -76,12 +104,14 @@ public abstract class PreviewWidgetBlock<T> extends JPanel implements MouseListe
private void showPreviewPane() {
synchronized (this) {
CarouselStateManger.getInstance().suspend();
if (!showing) {
showPreview(widget);
showing = true;
}
}
}
protected abstract String getWidgetUuid();
protected abstract void showPreview(T widget);
@ -89,6 +119,7 @@ public abstract class PreviewWidgetBlock<T> extends JPanel implements MouseListe
protected abstract void hidePreview();
private void hidePreviewPane() {
CarouselStateManger.getInstance().start();
if (showing) {
hidePreview();
showing = false;
@ -99,6 +130,9 @@ public abstract class PreviewWidgetBlock<T> extends JPanel implements MouseListe
@Override
public void mouseClicked(MouseEvent e) {
if (SwingUtilities.isRightMouseButton(e) && FirstDragAnimateStateManager.getInstance().animating()) {
FirstDragAnimateStateManager.getInstance().stopAnimate();
}
this.hidePreviewPane();
}
@ -114,21 +148,92 @@ public abstract class PreviewWidgetBlock<T> extends JPanel implements MouseListe
@Override
public void mouseEntered(MouseEvent e) {
hover = true;
if (ComponentShareUtil.needShowFirstDragAnimate() && checkWidget()) {
schedule(ANIMATE_START_TIME);
awtEventListener = event -> {
if (!this.isShowing()) {
return;
}
if (event instanceof MouseEvent) {
Point selectPanePoint = this.getLocationOnScreen();
Dimension selectPaneDimension = this.getSize();
Rectangle selectPaneRec = new Rectangle(selectPanePoint.x, selectPanePoint.y, selectPaneDimension.width, selectPaneDimension.height);
if (FirstDragAnimateStateManager.getInstance().animating() &&
!selectPaneRec.contains(((MouseEvent) event).getLocationOnScreen())) {
FirstDragAnimateStateManager.getInstance().stopAnimate();
}
}
};
java.awt.Toolkit.getDefaultToolkit().addAWTEventListener(awtEventListener, AWTEvent.MOUSE_EVENT_MASK);
}
}
protected boolean checkWidget() {
return true;
}
private void animate(ScheduledExecutorService service) {
CarouselStateManger.getInstance().suspend();
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);
Point endPoint = calculateEndPoint();
ComponentReuseNotificationInfo.getInstance().setFirstDrag(false);
DesignerEnvManager.getEnvManager().saveXMLFile();
FirstDragAnimateStateManager.getInstance().startAnimate();
service.scheduleAtFixedRate(() -> {
if (FirstDragAnimateStateManager.getInstance().isStop()) {
service.shutdown();
if (animatePopupDialog != null) {
animatePopupDialog.setVisible(false);
}
ComponentReuseNotificationInfo.getInstance().setFirstDragEndTime(System.currentTimeMillis());
DesignerEnvManager.getEnvManager().saveXMLFile();
java.awt.Toolkit.getDefaultToolkit().removeAWTEventListener(awtEventListener);
CarouselStateManger.getInstance().start();
return;
}
double progress = calXProgress(atomicInteger.getAndIncrement() * 20, cubic);
if (progress >= 1) {
atomicInteger.set(0);
}
double x = startPoint.x * 1D + (endPoint.x - startPoint.x) * progress;
double y = ((endPoint.y - startPoint.y) * 1D / (endPoint.x - startPoint.x)) * ((int) x - startPoint.x) + startPoint.y;
animatePopupDialog.setLocation((int) x, (int) y);
}, 0, 20, TimeUnit.MILLISECONDS);
}
private Point calculateEndPoint() {
Point basePoint = EastRegionContainerPane.getInstance().getLocationOnScreen();
Dimension dimension = EastRegionContainerPane.getInstance().getSize();
return new Point(basePoint.x + 20 - this.getWidth() / 2, basePoint.y + dimension.height / 3 - this.getHeight() / 2);
}
public double calXProgress(int time, BezierCubic cubic) {
return cubic.solve(time * 1D / ANIMATE_TIME);
}
@Override
public void mouseExited(MouseEvent e) {
hover = false;
this.hidePreviewPane();
}
@Override
public void mouseDragged(MouseEvent e) {
ComponentCollector.getInstance().collectDynamicEffectReact();
if (FirstDragAnimateStateManager.getInstance().animating()) {
FirstDragAnimateStateManager.getInstance().stopAnimate();
}
}
@Override
public void mouseMoved(MouseEvent e) {
lastStallTime = System.currentTimeMillis();
Dimension dimension = getCoverDimension();
Rectangle containerRec = new Rectangle(0, 0, dimension.width, dimension.height);
if (!isRightClickPopupMenuVisible()) {
@ -140,6 +245,26 @@ public abstract class PreviewWidgetBlock<T> extends JPanel implements MouseListe
}
}
private void schedule(long timeOut) {
firstDragCheckService.schedule(new Runnable() {
@Override
public void run() {
if (!hover) {
return;
}
long interval = System.currentTimeMillis() - lastStallTime;
if (interval < timeOut) {
schedule(ANIMATE_START_TIME - interval);
return;
}
animatePopupDialog = new AnimatePopupDialog(getCoverImage(), new Point(PreviewWidgetBlock.this.getLocationOnScreen().x, PreviewWidgetBlock.this.getLocationOnScreen().y));
ScheduledExecutorService service = ModuleContext.getExecutor().newSingleThreadScheduledExecutor(new NamedThreadFactory(FIRST_DRAG_ANIMATE));
animate(service);
}
}, timeOut, TimeUnit.MILLISECONDS);
}
@Override
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
@ -152,4 +277,6 @@ public abstract class PreviewWidgetBlock<T> extends JPanel implements MouseListe
this.removeMouseListener(this);
this.removeMouseMotionListener(this);
}
}

2
designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/ToolbarPane.java

@ -9,6 +9,7 @@ import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.share.ComponentShareUtil;
import com.fr.design.mainframe.share.sort.WidgetSortType;
import com.fr.design.mainframe.share.ui.base.MouseClickListener;
import com.fr.design.mainframe.share.ui.base.SortPopupMenuItem;
@ -112,6 +113,7 @@ class ToolbarPane extends JPanel {
e -> {
filterPanel.reset();
LocalWidgetRepoPane.getInstance().refreshPane();
ComponentShareUtil.recordWidgetLibHasRefreshed();
}
);
}

244
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/AbstractOnlineWidgetSelectPane.java

@ -0,0 +1,244 @@
package com.fr.design.mainframe.share.ui.online;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.share.AbstractWidgetSelectPane;
import com.fr.design.mainframe.share.ui.base.AbstractWidgetPopupPreviewPane;
import com.fr.design.mainframe.share.ui.base.LoadingPane;
import com.fr.design.mainframe.share.ui.base.NoMatchPane;
import com.fr.design.mainframe.share.ui.base.PagingFiledPane;
import com.fr.design.mainframe.share.ui.block.OnlineWidgetBlock;
import com.fr.design.mainframe.share.ui.block.PreviewWidgetBlock;
import com.fr.design.mainframe.share.ui.online.resource.OnlineResourceManager;
import com.fr.design.mainframe.share.ui.widgetfilter.FilterPane;
import com.fr.design.mainframe.share.util.OnlineShopUtils;
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.stable.ArrayUtils;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingWorker;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.util.concurrent.ExecutionException;
/**
* Created by kerry on 2021/10/22
*/
public abstract class AbstractOnlineWidgetSelectPane extends AbstractWidgetSelectPane<OnlineShareWidget> {
protected static final int H_GAP = 5;
protected static final int V_GAP = 10;
protected enum PaneStatue {NORMAL, NO_MATCH, LOADING, DISCONNECTED}
private OnlineShareWidget[] sharableWidgetProviders;
private PagingFiledPane pagingFiledPane;
private JPanel contentPane;
private UIScrollPane scrollPane;
private FilterPane filterPane;
private final int widgetsPerNum;
private CardLayout cardLayout;
public AbstractOnlineWidgetSelectPane(OnlineShareWidget[] providers, FilterPane filterPane, int widgetsPerNum) {
this(providers, widgetsPerNum);
this.filterPane = filterPane;
}
public AbstractOnlineWidgetSelectPane(final DataLoad<OnlineShareWidget> dataLoad, FilterPane filterPane, final int widgetsPerNum) {
this(dataLoad, widgetsPerNum);
this.filterPane = filterPane;
}
public AbstractOnlineWidgetSelectPane(OnlineShareWidget[] providers, int widgetsPerNum) {
this.widgetsPerNum = widgetsPerNum;
sharableWidgetProviders = providers;
init();
initPagingPane();
switchPane(createComponents());
}
public AbstractOnlineWidgetSelectPane(final DataLoad<OnlineShareWidget> dataLoad, final int widgetsPerNum) {
this.widgetsPerNum = widgetsPerNum;
init();
//异步获取组件信息
new SwingWorker<OnlineWidgetSelectPane.PaneStatue, Void>() {
@Override
protected OnlineWidgetSelectPane.PaneStatue doInBackground() {
sharableWidgetProviders = dataLoad.load();
initPagingPane();
return createComponents();
}
@Override
protected void done() {
try {
switchPane(get());
fireAfterDataLoad();
} catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
Thread.currentThread().interrupt();
} catch (ExecutionException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}.execute();
}
private void init() {
cardLayout = new CardLayout();
this.setLayout(cardLayout);
// 设置面板的边框 ,距离上、左、下、右 的距离
this.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
contentPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.add(new LoadingPane(), OnlineWidgetSelectPane.PaneStatue.LOADING.name());
this.add(new NoMatchPane(), OnlineWidgetSelectPane.PaneStatue.NO_MATCH.name());
this.add(contentPane, OnlineWidgetSelectPane.PaneStatue.NORMAL.name());
switchPane(OnlineWidgetSelectPane.PaneStatue.LOADING);
}
public int getSharableWidgetNum() {
return sharableWidgetProviders == null ? 0 : sharableWidgetProviders.length;
}
public OnlineShareWidget[] getSharableWidgetProviders() {
return sharableWidgetProviders;
}
/**
* 切换需要显示的面板
*/
protected void switchPane(OnlineWidgetSelectPane.PaneStatue statue) {
if (statue == OnlineWidgetSelectPane.PaneStatue.DISCONNECTED) {
OnlineWidgetRepoPane.getInstance().switch2InternetErrorPane();
return;
}
cardLayout.show(this, statue.name());
if (statue == OnlineWidgetSelectPane.PaneStatue.NORMAL) {
//异步加载组件缩略图
OnlineResourceManager.getInstance().loadImage();
}
}
protected void fireAfterDataLoad(){
}
private void synchronizedLoadingContent() {
new SwingWorker<OnlineWidgetSelectPane.PaneStatue, Void>() {
@Override
protected OnlineWidgetSelectPane.PaneStatue doInBackground() {
return createComponents();
}
@Override
protected void done() {
try {
switchPane(get());
//加载之后设置下标记符
} catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
Thread.currentThread().interrupt();
} catch (ExecutionException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}.execute();
}
private void initPagingPane() {
this.pagingFiledPane = new PagingFiledPane(sharableWidgetProviders.length, widgetsPerNum);
this.pagingFiledPane.registerChangeListener(event -> {
AbstractOnlineWidgetSelectPane.this.switchPane(OnlineWidgetSelectPane.PaneStatue.LOADING);
synchronizedLoadingContent();
OnlineWidgetRepoPane.getInstance().completeEmbedFilter();
});
pagingFiledPane.setEnable(pagePaneEnable());
}
protected OnlineWidgetSelectPane.PaneStatue createComponents() {
if (ArrayUtils.isEmpty(sharableWidgetProviders)) {
return OnlineWidgetSelectPane.PaneStatue.NO_MATCH;
}
if (!OnlineShopUtils.testConnection()) {
return OnlineWidgetSelectPane.PaneStatue.DISCONNECTED;
}
OnlineResourceManager.getInstance().cancelLoad();
contentPane.removeAll();
scrollPane = createScrollPane();
contentPane.add(scrollPane, BorderLayout.CENTER);
contentPane.add(this.pagingFiledPane, BorderLayout.SOUTH);
return OnlineWidgetSelectPane.PaneStatue.NORMAL;
}
protected UIScrollPane createScrollPane() {
OnlineShareWidget[] showWidgets = getShowWidgets();
JPanel widgetPane = createWidgetPane();
widgetPane.setLayout(new FlowLayout(FlowLayout.LEFT, H_GAP, V_GAP));
for (OnlineShareWidget provider : showWidgets) {
PreviewWidgetBlock<OnlineShareWidget> widgetButton = createWidgetBlock(provider);
widgetPane.add(widgetButton);
}
widgetPane.setPreferredSize(new Dimension(240, getPaneHeight(showWidgets.length)));
UIScrollPane scrollPane = new UIScrollPane(createContentPane(widgetPane));
setScrollPaneStyle(scrollPane);
return scrollPane;
}
protected OnlineShareWidget[] getShowWidgets(){
return this.pagingFiledPane.getShowItems(this.sharableWidgetProviders);
}
protected JPanel createWidgetPane() {
return new JPanel();
}
protected JPanel createContentPane(JPanel widgetPane) {
JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane();
panel.add(widgetPane, BorderLayout.CENTER);
return panel;
}
protected boolean pagePaneEnable() {
return true;
}
protected void setScrollPaneStyle(UIScrollPane scrollPane) {
scrollPane.setBorder(null);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane.setWheelScrollingEnabled(filterPane == null || !filterPane.isShowPopup());
}
protected PreviewWidgetBlock<OnlineShareWidget> createWidgetBlock(OnlineShareWidget provider) {
return new OnlineWidgetBlock(provider, this);
}
protected int getPaneHeight(int count) {
return (count + 1) / 2 * (ShareComponentConstants.SHARE_BLOCK_HEIGHT + V_GAP);
}
public void setWidgetPaneScrollEnable(boolean enable) {
if (scrollPane != null) {
scrollPane.setWheelScrollingEnabled(enable);
}
}
@Override
protected AbstractWidgetPopupPreviewPane<OnlineShareWidget> createPopupPreviewPane() {
return new OnlineWidgetPopupPreviewPane();
}
protected Container getParentContainer() {
return this.getParent();
}
}

78
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/AbstractOnlineWidgetShowPane.java

@ -3,15 +3,16 @@ package com.fr.design.mainframe.share.ui.online;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.share.sort.OnlineWidgetSortType;
import com.fr.design.mainframe.share.ComponentShareUtil;
import com.fr.design.mainframe.share.ui.base.FlexSearchFieldPane;
import com.fr.design.mainframe.share.ui.base.LoadingPane;
import com.fr.design.mainframe.share.ui.widgetfilter.FilterPane;
import com.fr.design.mainframe.share.util.OnlineShopUtils;
import com.fr.form.share.base.DataLoad;
import com.fr.form.share.bean.OnlineShareWidget;
import com.fr.form.share.utils.ShareUtils;
import com.fr.design.mainframe.share.Bean.WidgetFilterInfo;
import com.fr.general.IOUtils;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.SwingWorker;
@ -39,28 +40,31 @@ public abstract class AbstractOnlineWidgetShowPane extends JPanel {
private JPanel componentSelectPane;
private JPanel searchResultShowPane;
private JPanel mainCenterPane;
private FilterPane filterPane;
protected FilterPane filterPane;
private JPanel centerPane;
private SortTabPane sortTabPane;
private final JPanel loadingPane = new LoadingPane();
private OnlineShareWidget[] sharableWidgetProviders;
protected OnlineShareWidget[] sharableWidgetProviders;
//主面板和搜索面板的cardLayout
private CardLayout mainCardLayout;
public AbstractOnlineWidgetShowPane(OnlineShareWidget[] sharableWidgetProviders) {
this(sharableWidgetProviders, OnlineWidgetSortType.COMPOSITE);
}
public AbstractOnlineWidgetShowPane(OnlineShareWidget[] sharableWidgetProviders, OnlineWidgetSortType sortType) {
this.sharableWidgetProviders = sharableWidgetProviders;
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel contentPane = initContentPane();
JPanel contentPane = initContentPane(sortType);
this.add(contentPane, BorderLayout.CENTER);
}
protected JPanel initContentPane() {
protected JPanel initContentPane(OnlineWidgetSortType sortType) {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
OnlineWidgetSortType.COMPOSITE.sort(sharableWidgetProviders);
sortType.sort(sharableWidgetProviders);
componentSelectPane = createOnlineWidgetSelectPane(sharableWidgetProviders);
centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
centerPane.add(componentSelectPane, BorderLayout.CENTER);
@ -68,6 +72,7 @@ public abstract class AbstractOnlineWidgetShowPane extends JPanel {
filterPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 8));
initFilterPaneListener(filterPane);
sortTabPane = new SortTabPane();
this.sortTabPane.setIndex(sortType.ordinal());
initSortTabPane(sortTabPane);
FlexSearchFieldPane flexSearchPane = new FlexSearchFieldPane(filterPane);
initSearchTextFieldPaneListener(flexSearchPane);
@ -77,7 +82,7 @@ public abstract class AbstractOnlineWidgetShowPane extends JPanel {
northPane.add(sortTabPane, BorderLayout.SOUTH);
initNorthPane(jPanel, northPane);
searchResultShowPane = createOnlineWidgetSelectPane(new OnlineShareWidget[]{});
this.searchResultShowPane = initSearchResultShowPane(sharableWidgetProviders);
mainCardLayout = new CardLayout();
mainCenterPane = new JPanel(mainCardLayout);
mainCenterPane.add(centerPane, MAIN_FILTER_TAB_PANE);
@ -93,7 +98,7 @@ public abstract class AbstractOnlineWidgetShowPane extends JPanel {
}
protected OnlineWidgetSelectPane createOnlineWidgetSelectPane(OnlineShareWidget[] sharableWidgetProviders) {
protected AbstractOnlineWidgetSelectPane createOnlineWidgetSelectPane(OnlineShareWidget[] sharableWidgetProviders) {
return new OnlineWidgetSelectPane(sharableWidgetProviders, filterPane, 50);
}
@ -101,6 +106,17 @@ public abstract class AbstractOnlineWidgetShowPane extends JPanel {
return new OnlineWidgetSelectPane(dataLoad, filterPane, 50);
}
protected AbstractOnlineWidgetSelectPane manualCreateOnlineWidgetSelectPane(OnlineShareWidget[] sharableWidgetProviders) {
ComponentShareUtil.completeEmbedFilter();
return createOnlineWidgetSelectPane(sharableWidgetProviders);
}
protected OnlineWidgetSelectPane manualCreateOnlineWidgetSelectPane(DataLoad<OnlineShareWidget> dataLoad) {
ComponentShareUtil.completeEmbedFilter();
return createOnlineWidgetSelectPane(dataLoad);
}
protected FilterPane createFilterPane() {
return FilterPane.createOnlineFilterPane();
}
@ -126,12 +142,15 @@ public abstract class AbstractOnlineWidgetShowPane extends JPanel {
if (searchResultShowPane != null) {
mainCenterPane.remove(searchResultShowPane);
}
this.searchResultShowPane = createOnlineWidgetSelectPane(widgets.toArray(new OnlineShareWidget[widgets.size()]));
searchResultShowPane = manualCreateOnlineWidgetSelectPane(sharableWidgetProviders);
this.mainCenterPane.add(searchResultShowPane, SEARCH_RESULT_PANE);
this.mainCardLayout.show(mainCenterPane, SEARCH_RESULT_PANE);
this.validate();
this.repaint();
}
protected JPanel initSearchResultShowPane(OnlineShareWidget[] widgets) {
return new JPanel();
}
public void initFilterPaneListener(FilterPane filterPane) {
@ -139,21 +158,30 @@ public abstract class AbstractOnlineWidgetShowPane extends JPanel {
@Override
public void stateChanged(final ChangeEvent e) {
String filterStr = e.getSource().toString();
centerPane.remove(componentSelectPane);
componentSelectPane = createOnlineWidgetSelectPane(() -> {
sharableWidgetProviders = new OnlineShareWidget[0];
sharableWidgetProviders = getSharableWidgetArr(filterStr);
return sharableWidgetProviders;
});
centerPane.add(componentSelectPane, BorderLayout.CENTER);
AbstractOnlineWidgetShowPane.this.validate();
AbstractOnlineWidgetShowPane.this.repaint();
filterStateChanged(filterStr);
}
});
}
protected OnlineShareWidget[] getSharableWidgetArr( String filterStr){
return ShareUtils.getFilterWidgets(filterStr);
public void filterStateChanged(String filterStr) {
replaceSelectPane(manualCreateOnlineWidgetSelectPane(() -> {
sharableWidgetProviders = new OnlineShareWidget[0];
sharableWidgetProviders = getSharableWidgetArr(filterStr);
return sharableWidgetProviders;
}));
}
protected void replaceSelectPane(AbstractOnlineWidgetSelectPane selectPane) {
centerPane.remove(componentSelectPane);
componentSelectPane = selectPane;
centerPane.add(componentSelectPane, BorderLayout.CENTER);
AbstractOnlineWidgetShowPane.this.validate();
AbstractOnlineWidgetShowPane.this.repaint();
}
protected OnlineShareWidget[] getSharableWidgetArr(String filterStr) {
return OnlineShopUtils.getFilterWidgets(filterStr);
}
public void initSearchTextFieldPaneListener(FlexSearchFieldPane searchFieldPane) {
@ -167,6 +195,10 @@ public abstract class AbstractOnlineWidgetShowPane extends JPanel {
});
}
public void setFilterItems(List<WidgetFilterInfo> selectedFilters) {
this.filterPane.setFilter(selectedFilters);
}
public void initSortTabPane(SortTabPane sortTabPane) {
}
@ -236,7 +268,7 @@ public abstract class AbstractOnlineWidgetShowPane extends JPanel {
@Override
protected Boolean doInBackground() {
sortType.sort(sharableWidgetProviders);
componentSelectPane = createOnlineWidgetSelectPane(sharableWidgetProviders);
componentSelectPane = manualCreateOnlineWidgetSelectPane(sharableWidgetProviders);
return true;
}

65
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/CarouselStateManger.java

@ -0,0 +1,65 @@
package com.fr.design.mainframe.share.ui.online;
import java.util.concurrent.CountDownLatch;
/**
* Created by kerry on 2021/10/22
*/
public class CarouselStateManger {
private CarouseState state;
private final CountDownLatch countDownLatch = new CountDownLatch(1);
public static CarouselStateManger getInstance() {
return CarouselStateManger.HOLDER.singleton;
}
private static class HOLDER {
private static CarouselStateManger singleton = new CarouselStateManger();
}
private CarouselStateManger() {
}
public void countDown() {
countDownLatch.countDown();
}
public void countDownLatchAwait() throws InterruptedException {
countDownLatch.await();
}
public void start() {
this.state = CarouseState.RUNNING;
}
public boolean running() {
return this.state == CarouseState.RUNNING;
}
public void suspend() {
this.state = CarouseState.SUSPEND;
}
public boolean isSuspend() {
return this.state == CarouseState.SUSPEND;
}
public void stop() {
this.state = CarouseState.STOP;
}
public boolean stopped() {
return this.state == CarouseState.STOP;
}
enum CarouseState {
RUNNING,
SUSPEND,
STOP
}
}

53
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineResourceManager.java

@ -1,53 +0,0 @@
package com.fr.design.mainframe.share.ui.online;
import javax.swing.SwingWorker;
import java.util.ArrayList;
import java.util.List;
/**
* Created by kerry on 2020-12-10
*/
public class OnlineResourceManager {
private static class HOLDER {
private static final OnlineResourceManager singleton = new OnlineResourceManager();
}
private OnlineResourceManager(){
}
public static OnlineResourceManager getInstance() {
return HOLDER.singleton;
}
private SwingWorker<Boolean,Void> swingWorker;
private final List<ResourceLoader> loaderList = new ArrayList<>();
public void cancelLoad() {
if (swingWorker != null) {
swingWorker.cancel(true);
}
this.loaderList.clear();
}
public void addLoader(ResourceLoader loader) {
this.loaderList.add(loader);
}
public void loadImage() {
swingWorker = new SwingWorker<Boolean, Void>() {
@Override
protected Boolean doInBackground() {
for (ResourceLoader loader : loaderList) {
loader.load();
}
return true;
}
};
swingWorker.execute();
}
}

16
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetRepoPane.java

@ -7,8 +7,8 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.share.ui.base.LoadingPane;
import com.fr.design.mainframe.share.ui.base.MouseClickListener;
import com.fr.design.mainframe.share.util.OnlineShopUtils;
import com.fr.form.share.bean.OnlineShareWidget;
import com.fr.form.share.utils.ShareUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
@ -48,7 +48,7 @@ public class OnlineWidgetRepoPane extends BasicPane {
return true;
}
try{
sharableWidgets = ShareUtils.getAllSharableWidgetsFromShop();
sharableWidgets = OnlineShopUtils.getAllSharableWidgetsFromShop();
return true;
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
@ -222,4 +222,16 @@ public class OnlineWidgetRepoPane extends BasicPane {
return tipLabel;
}
public void refresh() {
if (componentTabPane != null) {
this.componentTabPane.refreshPane();
}
}
public void completeEmbedFilter(){
if (componentTabPane != null) {
this.componentTabPane.completeEmbedFilter();
}
}
}

212
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetSelectPane.java

@ -1,231 +1,29 @@
package com.fr.design.mainframe.share.ui.online;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.share.AbstractWidgetSelectPane;
import com.fr.design.mainframe.share.ui.base.AbstractWidgetPopupPreviewPane;
import com.fr.design.mainframe.share.ui.base.LoadingPane;
import com.fr.design.mainframe.share.ui.base.NoMatchPane;
import com.fr.design.mainframe.share.ui.base.PagingFiledPane;
import com.fr.design.mainframe.share.ui.block.OnlineWidgetBlock;
import com.fr.design.mainframe.share.ui.block.PreviewWidgetBlock;
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.form.share.utils.ShareUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingWorker;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.util.concurrent.ExecutionException;
/**
* Created by kerry on 2020-10-19
*/
public class OnlineWidgetSelectPane extends AbstractWidgetSelectPane<OnlineShareWidget> {
protected static final int H_GAP = 5;
protected static final int V_GAP = 10;
enum PaneStatue {NORMAL, NO_MATCH, LOADING, DISCONNECTED}
private OnlineShareWidget[] sharableWidgetProviders;
private PagingFiledPane pagingFiledPane;
private JPanel contentPane;
private UIScrollPane scrollPane;
private FilterPane filterPane;
private final int widgetsPerNum;
private CardLayout cardLayout;
public class OnlineWidgetSelectPane extends AbstractOnlineWidgetSelectPane {
public OnlineWidgetSelectPane(OnlineShareWidget[] providers, FilterPane filterPane, int widgetsPerNum) {
this(providers, widgetsPerNum);
this.filterPane = filterPane;
super(providers, filterPane, widgetsPerNum);
}
public OnlineWidgetSelectPane(final DataLoad<OnlineShareWidget> dataLoad, FilterPane filterPane, final int widgetsPerNum) {
this(dataLoad, widgetsPerNum);
this.filterPane = filterPane;
super(dataLoad, filterPane, widgetsPerNum);
}
public OnlineWidgetSelectPane(OnlineShareWidget[] providers, int widgetsPerNum) {
this.widgetsPerNum = widgetsPerNum;
sharableWidgetProviders = providers;
init();
initPagingPane();
switchPane(createComponents());
super(providers, widgetsPerNum);
}
public OnlineWidgetSelectPane(final DataLoad<OnlineShareWidget> dataLoad, final int widgetsPerNum) {
this.widgetsPerNum = widgetsPerNum;
init();
//异步获取组件信息
new SwingWorker<PaneStatue, Void>() {
@Override
protected PaneStatue doInBackground() {
sharableWidgetProviders = dataLoad.load();
initPagingPane();
return createComponents();
}
@Override
protected void done() {
try {
switchPane(get());
} catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
Thread.currentThread().interrupt();
} catch (ExecutionException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}.execute();
}
private void init() {
cardLayout = new CardLayout();
this.setLayout(cardLayout);
// 设置面板的边框 ,距离上、左、下、右 的距离
this.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
contentPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.add(new LoadingPane(), PaneStatue.LOADING.name());
this.add(new NoMatchPane(), PaneStatue.NO_MATCH.name());
this.add(contentPane, PaneStatue.NORMAL.name());
switchPane(PaneStatue.LOADING);
}
public int getSharableWidgetNum() {
return sharableWidgetProviders == null ? 0 : sharableWidgetProviders.length;
}
public OnlineShareWidget[] getSharableWidgetProviders() {
return sharableWidgetProviders;
}
/**
* 切换需要显示的面板
*/
private void switchPane(PaneStatue statue) {
if (statue == PaneStatue.DISCONNECTED) {
OnlineWidgetRepoPane.getInstance().switch2InternetErrorPane();
return;
}
cardLayout.show(this, statue.name());
if (statue == PaneStatue.NORMAL) {
//异步加载组件缩略图
OnlineResourceManager.getInstance().loadImage();
}
}
private void synchronizedLoadingContent() {
new SwingWorker<PaneStatue, Void>() {
@Override
protected PaneStatue doInBackground() {
return createComponents();
}
@Override
protected void done() {
try {
switchPane(get());
} catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
Thread.currentThread().interrupt();
} catch (ExecutionException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}.execute();
}
private void initPagingPane() {
this.pagingFiledPane = new PagingFiledPane(sharableWidgetProviders.length, widgetsPerNum);
this.pagingFiledPane.registerChangeListener(event -> {
OnlineWidgetSelectPane.this.switchPane(PaneStatue.LOADING);
synchronizedLoadingContent();
});
pagingFiledPane.setEnable(pagePaneEnable());
}
private PaneStatue createComponents() {
if (ArrayUtils.isEmpty(sharableWidgetProviders)) {
return PaneStatue.NO_MATCH;
}
if (!ShareUtils.testConnection()) {
return PaneStatue.DISCONNECTED;
}
OnlineResourceManager.getInstance().cancelLoad();
contentPane.removeAll();
scrollPane = createScrollPane();
contentPane.add(scrollPane, BorderLayout.CENTER);
contentPane.add(this.pagingFiledPane, BorderLayout.SOUTH);
return PaneStatue.NORMAL;
super(dataLoad, widgetsPerNum);
}
private UIScrollPane createScrollPane() {
OnlineShareWidget[] showWidgets = this.pagingFiledPane.getShowItems(this.sharableWidgetProviders);
JPanel widgetPane = createWidgetPane();
widgetPane.setLayout(new FlowLayout(FlowLayout.LEFT, H_GAP, V_GAP));
for (OnlineShareWidget provider : showWidgets) {
PreviewWidgetBlock<OnlineShareWidget> widgetButton = createWidgetBlock(provider);
widgetPane.add(widgetButton);
}
widgetPane.setPreferredSize(new Dimension(240, getPaneHeight(showWidgets.length)));
UIScrollPane scrollPane = new UIScrollPane(createContentPane(widgetPane));
setScrollPaneStyle(scrollPane);
return scrollPane;
}
protected JPanel createWidgetPane() {
return new JPanel();
}
protected JPanel createContentPane(JPanel widgetPane) {
JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane();
panel.add(widgetPane, BorderLayout.CENTER);
return panel;
}
protected boolean pagePaneEnable() {
return true;
}
protected void setScrollPaneStyle(UIScrollPane scrollPane) {
scrollPane.setBorder(null);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane.setWheelScrollingEnabled(filterPane == null || !filterPane.isShowPopup());
}
protected PreviewWidgetBlock<OnlineShareWidget> createWidgetBlock(OnlineShareWidget provider) {
return new OnlineWidgetBlock(provider, this);
}
protected int getPaneHeight(int count) {
return (count + 1) / 2 * (ShareComponentConstants.SHARE_BLOCK_HEIGHT + V_GAP);
}
public void setWidgetPaneScrollEnable(boolean enable) {
if (scrollPane != null) {
scrollPane.setWheelScrollingEnabled(enable);
}
}
@Override
protected AbstractWidgetPopupPreviewPane<OnlineShareWidget> createPopupPreviewPane() {
return new OnlineWidgetPopupPreviewPane();
}
protected Container getParentContainer() {
return this.getParent();
}
}

30
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetShowPane.java

@ -4,9 +4,11 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.share.collect.ComponentCollector;
import com.fr.design.mainframe.share.sort.OnlineWidgetSortType;
import com.fr.design.mainframe.share.ui.base.FlexSearchFieldPane;
import com.fr.design.mainframe.share.ui.online.embed.OnlineEmbedFilterSelectPane;
import com.fr.design.mainframe.share.ui.widgetfilter.FilterPane;
import com.fr.design.mainframe.share.util.OnlineShopUtils;
import com.fr.form.share.base.DataLoad;
import com.fr.form.share.bean.OnlineShareWidget;
import com.fr.form.share.utils.ShareUtils;
import com.fr.stable.StringUtils;
import javax.swing.event.ChangeEvent;
@ -31,8 +33,13 @@ public class OnlineWidgetShowPane extends AbstractOnlineWidgetShowPane {
private String lastFilter = StringUtils.EMPTY;
private int lastSortTabSelectedIndex = 0;
public OnlineWidgetShowPane(OnlineShareWidget[] sharableWidgetProviders) {
super(sharableWidgetProviders);
public OnlineWidgetShowPane(OnlineShareWidget[] sharableWidgetProviders, OnlineWidgetSortType sortType) {
super(sharableWidgetProviders, sortType);
lastSortTabSelectedIndex = sortType.ordinal();
}
public OnlineWidgetShowPane(OnlineShareWidget[] sharableWidgetProvider) {
super(sharableWidgetProvider);
}
@Override
@ -109,7 +116,7 @@ public class OnlineWidgetShowPane extends AbstractOnlineWidgetShowPane {
}
protected OnlineShareWidget[] getSharableWidgetArr( String filterStr){
OnlineShareWidget[] onlineShareWidgets = ShareUtils.getFilterWidgets(filterStr);
OnlineShareWidget[] onlineShareWidgets = OnlineShopUtils.getFilterWidgets(filterStr);
OnlineWidgetSortType.values()[lastSortTabSelectedIndex].sort(onlineShareWidgets);
return onlineShareWidgets;
}
@ -117,7 +124,6 @@ public class OnlineWidgetShowPane extends AbstractOnlineWidgetShowPane {
@Override
public void initSortTabPane(SortTabPane sortTabPane) {
super.initSortTabPane(sortTabPane);
lastSortTabSelectedIndex = sortTabPane.getIndex();
sortTabPane.registerSortTabMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
@ -149,4 +155,18 @@ public class OnlineWidgetShowPane extends AbstractOnlineWidgetShowPane {
private void collectSortType(String sortType) {
ComponentCollector.getInstance().collectSortType(sortType);
}
public OnlineEmbedFilterSelectPane animate(String filterStr) {
OnlineEmbedFilterSelectPane pane = new OnlineEmbedFilterSelectPane(new DataLoad<OnlineShareWidget>() {
@Override
public OnlineShareWidget[] load() {
sharableWidgetProviders = getSharableWidgetArr(filterStr);
return sharableWidgetProviders;
}
}, filterPane, 50);
replaceSelectPane(pane);
return pane;
}
}

20
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetTabPane.java

@ -3,6 +3,9 @@ package com.fr.design.mainframe.share.ui.online;
import com.fr.design.gui.ibutton.UITabGroup;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.share.collect.ComponentCollector;
import com.fr.design.mainframe.share.sort.OnlineWidgetSortType;
import com.fr.design.mainframe.share.ComponentShareUtil;
import com.fr.design.mainframe.share.ui.online.embed.OnlineEmbedFilterShowPane;
import com.fr.design.mainframe.share.ui.online.widgetpackage.OnlineWidgetPackagesShowPane;
import com.fr.form.share.bean.OnlineShareWidget;
@ -20,10 +23,12 @@ import java.util.List;
public class OnlineWidgetTabPane extends JPanel {
private static final String COMPONENT = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Share");
private static final String COMPONENT_PACKAGE = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Share_Package");
private static final String COMPONENT_EMBED = "COMPONENT_EMBED";
private CardLayout cardLayout;
private JPanel centerPane;
private boolean packagePaneCreated = false;
private List<TabChangeListener> tabChangeListeners;
private OnlineEmbedFilterShowPane embedFilterShowPane;
public OnlineWidgetTabPane(OnlineShareWidget[] sharableWidgets, OnlineShareWidget[] sharableWidgetPackage) {
tabChangeListeners = new ArrayList<>();
@ -34,7 +39,9 @@ public class OnlineWidgetTabPane extends JPanel {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.cardLayout = new CardLayout();
this.centerPane = new JPanel(cardLayout);
this.centerPane.add(new OnlineWidgetShowPane(sharableWidgets), COMPONENT);
this.centerPane.add( embedFilterShowPane = new OnlineEmbedFilterShowPane(new OnlineWidgetShowPane(sharableWidgets, OnlineWidgetSortType.SALES)), COMPONENT_EMBED);
//延迟组件包面板的初始化,防止组件面板里组件的缩略图和组件包面板里组件的缩略图一起加载
UITabGroup headGroup = new UITabGroup(new String[]{COMPONENT, COMPONENT_PACKAGE}) {
public void tabChanged(int newSelectedIndex) {
@ -42,8 +49,9 @@ public class OnlineWidgetTabPane extends JPanel {
changeListener.tabChange(newSelectedIndex);
}
if (newSelectedIndex == 0) {
cardLayout.show(centerPane, COMPONENT);
cardLayout.show(centerPane, ComponentShareUtil.needShowEmbedFilterPane() ? COMPONENT_EMBED : COMPONENT);
} else {
ComponentShareUtil.completeEmbedFilter();
ComponentCollector.getInstance().collectCmpPktClick();
//延迟组件包面板的初始化,防止组件面板里组件和缩略图和组件包面板里组件的缩略图一起加载
if (!packagePaneCreated) {
@ -64,11 +72,20 @@ public class OnlineWidgetTabPane extends JPanel {
this.add(centerPane, BorderLayout.CENTER);
}
public void completeEmbedFilter(){
if (embedFilterShowPane!= null){
embedFilterShowPane.completeEmbedFilter();
}
}
public void addTabChangeListener(TabChangeListener listener) {
if (!tabChangeListeners.contains(listener)) {
tabChangeListeners.add(listener);
}
}
public void refreshPane() {
this.cardLayout.show(centerPane, ComponentShareUtil.needShowEmbedFilterPane() ? COMPONENT_EMBED : COMPONENT);
}
public void removeTabChangeListener(TabChangeListener listener) {
tabChangeListeners.remove(listener);
@ -77,4 +94,5 @@ public class OnlineWidgetTabPane extends JPanel {
public interface TabChangeListener extends EventListener {
void tabChange(int selectedIndex);
}
}

46
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/AnimatePopupDialog.java

@ -0,0 +1,46 @@
package com.fr.design.mainframe.share.ui.online.embed;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.general.IOUtils;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Point;
/**
* Created by kerry on 2021/10/22
*/
public class AnimatePopupDialog extends JDialog {
private static final Icon DRAG_HAND = IOUtils.readIcon("/com/fr/design/form/images/drag_hand.png");
public AnimatePopupDialog(Image image, Point initialPosition) {
super(DesignerContext.getDesignerFrame());
Container container = getContentPane();
setUndecorated(true);
JPanel jPanel = new JPanel() {
@Override
public void paint(Graphics g) {
super.paint(g);
DRAG_HAND.paintIcon(this, g, (this.getWidth() - 20) / 2, (this.getHeight() - 20) / 2);
}
};
jPanel.setLayout(FRGUIPaneFactory.createBorderLayout());
jPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
jPanel.add(new UILabel(new ImageIcon(image)), BorderLayout.CENTER);
container.add(jPanel, BorderLayout.CENTER);
setSize(123, 70);
this.setLocation(initialPosition);
this.setVisible(true);
}
}

156
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/EmbedPane.java

@ -0,0 +1,156 @@
package com.fr.design.mainframe.share.ui.online.embed;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIButtonUI;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.share.collect.ComponentCollector;
import com.fr.design.mainframe.share.ui.widgetfilter.FilterConfigPane;
import com.fr.design.mainframe.share.util.OnlineShopUtils;
import com.fr.design.ui.util.UIUtil;
import com.fr.design.mainframe.share.Bean.WidgetFilterInfo;
import com.fr.module.ModuleContext;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.UIManager;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.image.BufferedImage;
import java.util.List;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import static javax.swing.JOptionPane.WARNING_MESSAGE;
/**
* Created by kerry on 2021/10/21
*/
public class EmbedPane extends JPanel {
private static final String EMBED_PANE_TIMER = "EMBED_PANE_TIMER";
private static final Color BORDER_COLOR = Color.decode("#D9DADD");
private static final Color SEARCH_BUTTON_COLOR = Color.decode("#419BF9");
private Image image;
public EmbedPane(OnlineEmbedFilterShowPane showPane) {
this.addMouseListener(new MouseAdapter() {
});
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createLineBorder(BORDER_COLOR));
this.add(initCenterPane(showPane), BorderLayout.CENTER);
}
private JPanel initCenterPane(OnlineEmbedFilterShowPane showPane) {
JPanel jPanel = new JPanel(FRGUIPaneFactory.createBorderLayout());
jPanel.setBackground(Color.WHITE);
jPanel.setPreferredSize(new Dimension(200, 200));
jPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
FilterConfigPane filterConfigPane = new FilterConfigPane(OnlineShopUtils.getEmbPaneShowFilterTypeInfos(), false) {
@Override
public String assembleFilter() {
return OnlineShopUtils.assembleFilter(getFilterList());
}
};
UIButton searchBtn = initSearchBtn(filterConfigPane, showPane);
filterConfigPane.setBorder(null);
UILabel tipLabel = new UILabel(Toolkit.i18nText("Fine-Design_Share_Online_Embed_Filter_Tip"));
tipLabel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
jPanel.add(tipLabel, BorderLayout.NORTH);
jPanel.add(filterConfigPane, BorderLayout.CENTER);
JPanel southPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
southPane.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 8));
southPane.setBackground(Color.WHITE);
southPane.add(searchBtn, BorderLayout.CENTER);
southPane.setPreferredSize(new Dimension(212, 24));
jPanel.add(southPane, BorderLayout.SOUTH);
return jPanel;
}
private UIButton initSearchBtn(FilterConfigPane filterConfigPane, OnlineEmbedFilterShowPane showPane) {
UIButton searchBtn = new UIButton(Toolkit.i18nText("Fine-Design_Share_Online_Query_Recommend_Component"));
searchBtn.setUI(new UIButtonUI() {
@Override
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.setColor(oldColor);
}
});
searchBtn.setForeground(SEARCH_BUTTON_COLOR);
searchBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String filterStr = filterConfigPane.assembleFilter();
if (StringUtils.isEmpty(filterStr)) {
FineJOptionPane.showMessageDialog(EmbedPane.this,
Toolkit.i18nText("Fine-Design_Share_Online_Embed_Filter_Warning_Tip"),
Toolkit.i18nText("Fine-Design_Basic_Message"), WARNING_MESSAGE,
UIManager.getIcon("OptionPane.warningIcon"));
ComponentCollector.getInstance().collectEmbededFilterReact(2);
return;
}
showPane.filterStateChanged(filterStr);
animateHide(showPane, filterConfigPane.getFilterList());
ComponentCollector.getInstance().collectEmbededFilterReact(1);
}
});
return searchBtn;
}
public void animateHide(OnlineEmbedFilterShowPane showPane, List<WidgetFilterInfo> selectedFilters) {
//先生成图片
image = new BufferedImage(this.getWidth(), this.getHeight(), BufferedImage.TYPE_INT_ARGB);
this.paint(image.getGraphics());
ScheduledExecutorService service = createToastScheduleExecutorService();
this.removeAll();
service.scheduleAtFixedRate(() -> {
Dimension dimension = EmbedPane.this.getSize();
Point point = EmbedPane.this.getLocation();
if (dimension.width <= 0 || dimension.height <= 0) {
EmbedPane.this.setVisible(false);
service.shutdown();
try {
showPane.animate(selectedFilters);
} catch (InterruptedException e) {
}
}
UIUtil.invokeAndWaitIfNeeded(() -> {
Dimension newDimension = new Dimension(dimension.width - 25, dimension.height - 30);
EmbedPane.this.setSize(newDimension);
EmbedPane.this.setLocation(point.x + 25, 0);
});
}, 0, 60, TimeUnit.MILLISECONDS);
}
@Override
public void paint(Graphics g) {
super.paint(g);
if (image != null) {
g.drawImage(image, 0, 0, EmbedPane.this.getWidth(), EmbedPane.this.getHeight(), null);
}
}
private ScheduledExecutorService createToastScheduleExecutorService() {
return ModuleContext.getExecutor().newSingleThreadScheduledExecutor(new NamedThreadFactory(EMBED_PANE_TIMER));
}
}

44
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/FirstDragAnimateStateManager.java

@ -0,0 +1,44 @@
package com.fr.design.mainframe.share.ui.online.embed;
/**
* Created by kerry on 2021/10/29
*/
public class FirstDragAnimateStateManager {
public static FirstDragAnimateStateManager getInstance() {
return FirstDragAnimateStateManager.HOLDER.singleton;
}
private static class HOLDER {
private static final FirstDragAnimateStateManager singleton = new FirstDragAnimateStateManager();
}
private FirstDragAnimateStateManager() {
}
private STATE state;
public void startAnimate() {
this.state = STATE.ANIMATING;
}
public boolean animating() {
return this.state == STATE.ANIMATING;
}
public void stopAnimate() {
this.state = STATE.STOP;
}
public boolean isStop() {
return this.state == STATE.STOP;
}
enum STATE {
ANIMATING,
STOP
}
}

169
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/OnlineEmbedFilterSelectPane.java

@ -0,0 +1,169 @@
package com.fr.design.mainframe.share.ui.online.embed;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.mainframe.share.ui.online.AbstractOnlineWidgetSelectPane;
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.module.ModuleContext;
import com.fr.stable.EncodeConstants;
import com.fr.third.springframework.web.util.UriUtils;
import javax.imageio.ImageIO;
import javax.swing.JPanel;
import java.awt.AWTEvent;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Image;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.AWTEventListener;
import java.awt.event.MouseEvent;
import java.io.IOException;
import java.net.URL;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Created by kerry on 2021/10/22
*/
public class OnlineEmbedFilterSelectPane extends AbstractOnlineWidgetSelectPane {
private static final String CAROUSEL_PREVIEW = "carousel_preview";
private OnlineShareWidget[] showWidgets;
private PreviewDialog previewDialog;
private JPanel widgetPane;
private final AWTEventListener awtEventListener;
public OnlineEmbedFilterSelectPane(final DataLoad<OnlineShareWidget> dataLoad, FilterPane filterPane, int widgetsPerNum) {
super(dataLoad, filterPane, widgetsPerNum);
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();
}
}
}
};
java.awt.Toolkit.getDefaultToolkit().addAWTEventListener(awtEventListener, AWTEvent.MOUSE_EVENT_MASK);
}
protected UIScrollPane createScrollPane() {
showWidgets = getShowWidgets();
widgetPane = createWidgetPane();
widgetPane.setLayout(new FlowLayout(FlowLayout.LEFT, H_GAP, V_GAP));
previewDialog = new PreviewDialog();
widgetPane.setPreferredSize(new Dimension(240, getPaneHeight(showWidgets.length)));
UIScrollPane scrollPane = new UIScrollPane(createContentPane(widgetPane));
setScrollPaneStyle(scrollPane);
return scrollPane;
}
protected void fireAfterDataLoad() {
super.fireAfterDataLoad();
CarouselStateManger.getInstance().countDown();
}
public void animate() throws InterruptedException {
CarouselStateManger.getInstance().countDownLatchAwait();
AtomicInteger integer = new AtomicInteger(0);
showCurrentLoadBlock(integer, widgetPane);
this.repaint();
previewDialog.setVisible(true);
CarouselStateManger.getInstance().start();
}
private void showCurrentLoadBlock(AtomicInteger integer, JPanel widgetPane) {
ScheduledExecutorService service = createToastScheduleExecutorService();
OnlineShareWidget shareWidget = showWidgets[integer.get()];
widgetPane.add(createWidgetBlock(shareWidget), 0);
this.doLayout();
this.validate();
this.repaint();
previewDialog.setImage(getPreviewImage(shareWidget));
//展示弹出框
service.schedule(new Runnable() {
@Override
public void run() {
if (CarouselStateManger.getInstance().stopped()) {
stopCarouse(integer);
return;
}
if (integer.get() == showWidgets.length - 1) {
CarouselStateManger.getInstance().stop();
previewDialog.setVisible(false);
return;
}
integer.incrementAndGet();
if (!CarouselStateManger.getInstance().isSuspend()) {
showCurrentLoadBlock(integer, widgetPane);
} else {
pollingCarouselState(integer, widgetPane);
}
}
}, 500, TimeUnit.MILLISECONDS);
}
private void pollingCarouselState(AtomicInteger integer, JPanel widgetPane) {
ScheduledExecutorService service = createToastScheduleExecutorService();
service.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
if (CarouselStateManger.getInstance().stopped()) {
stopCarouse(integer);
return;
}
if (!CarouselStateManger.getInstance().isSuspend()) {
showCurrentLoadBlock(integer, widgetPane);
service.shutdown();
}
}
}, 0, 500, TimeUnit.MILLISECONDS);
}
private void stopCarouse(AtomicInteger integer) {
previewDialog.setVisible(false);
loadRestShowWidgets(integer.get() + 1);
java.awt.Toolkit.getDefaultToolkit().removeAWTEventListener(awtEventListener);
}
private void loadRestShowWidgets(int startIndex) {
for (int i = startIndex; i < showWidgets.length; i++) {
OnlineShareWidget shareWidget = showWidgets[i];
widgetPane.add(createWidgetBlock(shareWidget));
}
this.doLayout();
this.validate();
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));
}
}

47
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/OnlineEmbedFilterShowPane.java

@ -0,0 +1,47 @@
package com.fr.design.mainframe.share.ui.online.embed;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.share.ComponentShareUtil;
import com.fr.design.mainframe.share.ui.online.OnlineWidgetShowPane;
import com.fr.design.mainframe.share.Bean.WidgetFilterInfo;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.util.List;
/**
* Created by kerry on 2021/10/22
*/
public class OnlineEmbedFilterShowPane extends JPanel {
private final OnlineWidgetShowPane onlineWidgetShowPane;
private final EmbedPane embedPane;
private OnlineEmbedFilterSelectPane selectPane;
public OnlineEmbedFilterShowPane(OnlineWidgetShowPane onlineWidgetShowPane) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
embedPane = new EmbedPane(this);
embedPane.setLocation(10, 0);
embedPane.setSize(228, 273);
this.add(embedPane);
this.onlineWidgetShowPane = onlineWidgetShowPane;
this.add(onlineWidgetShowPane, BorderLayout.CENTER);
}
public void filterStateChanged(String filterStr) {
selectPane = onlineWidgetShowPane.animate(filterStr);
}
public void animate(List<WidgetFilterInfo> selectedFilters) throws InterruptedException {
onlineWidgetShowPane.setFilterItems(selectedFilters);
selectPane.animate();
}
public void completeEmbedFilter(){
if (embedPane!= null && embedPane.isShowing()){
this.remove(embedPane);
ComponentShareUtil.completeEmbedFilter();
this.doLayout();
this.repaint();
}
}
}

40
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/PreviewDialog.java

@ -0,0 +1,40 @@
package com.fr.design.mainframe.share.ui.online.embed;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.EastRegionContainerPane;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import java.awt.Image;
/**
* Created by kerry on 2021/10/22
*/
public class PreviewDialog extends JDialog {
public PreviewDialog() {
super(DesignerContext.getDesignerFrame());
setUndecorated(true);
setSize(300, 300);
adjustLocation();
this.setVisible(false);
}
public void setImage(Image image) {
this.getContentPane().removeAll();
this.getContentPane().add(new UILabel(new ImageIcon(image)));
this.doLayout();
this.validate();
this.repaint();
}
public void adjustLocation() {
this.setLocation(
EastRegionContainerPane.getInstance().getX() - 300,
20
);
}
}

64
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/resource/OnlineResourceManager.java

@ -0,0 +1,64 @@
package com.fr.design.mainframe.share.ui.online.resource;
import javax.swing.SwingWorker;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
/**
* Created by kerry on 2020-12-10
*/
public class OnlineResourceManager {
private static class HOLDER {
private static final OnlineResourceManager singleton = new OnlineResourceManager();
}
private OnlineResourceManager() {
}
public static OnlineResourceManager getInstance() {
return HOLDER.singleton;
}
private SwingWorker<Boolean, Void> swingWorker;
private final BlockingQueue<ResourceLoader> loaderBlockingQueue = new ArrayBlockingQueue<ResourceLoader>(100);
public void cancelLoad() {
if (swingWorker != null) {
swingWorker.cancel(true);
}
this.loaderBlockingQueue.clear();
}
public void addLoader(ResourceLoader loader) {
try {
this.loaderBlockingQueue.put(loader);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
public void loadImage() {
swingWorker = new SwingWorker<Boolean, Void>() {
@Override
protected Boolean doInBackground() {
while (!swingWorker.isCancelled()) {
ResourceLoader loader = null;
try {
loader = loaderBlockingQueue.take();
} catch (InterruptedException e) {
e.printStackTrace();
}
loader.load();
}
return true;
}
};
swingWorker.execute();
}
}

2
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/ResourceLoader.java → designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/resource/ResourceLoader.java

@ -1,4 +1,4 @@
package com.fr.design.mainframe.share.ui.online;
package com.fr.design.mainframe.share.ui.online.resource;
/**
* Created by kerry on 2020-12-10

12
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/widgetpackage/OnlineWidgetPackagesShowPane.java

@ -9,11 +9,15 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.login.DesignerLoginHelper;
import com.fr.design.login.DesignerLoginSource;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.share.sort.OnlineWidgetSortType;
import com.fr.design.mainframe.share.ui.base.MouseClickListener;
import com.fr.design.mainframe.share.ui.online.AbstractOnlineWidgetSelectPane;
import com.fr.design.mainframe.share.ui.online.AbstractOnlineWidgetShowPane;
import com.fr.design.mainframe.share.ui.online.OnlineDownloadPackagePane;
import com.fr.design.mainframe.share.ui.online.OnlineWidgetSelectPane;
import com.fr.design.mainframe.share.ui.widgetfilter.FilterPane;
import com.fr.design.mainframe.share.util.OnlineShopUtils;
import com.fr.design.mainframe.share.util.ShareUIUtils;
import com.fr.form.share.base.DataLoad;
import com.fr.form.share.bean.OnlineShareWidget;
import com.fr.form.share.utils.ShareUtils;
@ -51,8 +55,8 @@ public class OnlineWidgetPackagesShowPane extends AbstractOnlineWidgetShowPane {
super(sharableWidgetProviders);
}
protected JPanel initContentPane() {
JPanel firstPane = super.initContentPane();
protected JPanel initContentPane(OnlineWidgetSortType sortType) {
JPanel firstPane = super.initContentPane(sortType);
cardLayout = new CardLayout();
centerPane = new JPanel(cardLayout);
centerPane.add(firstPane, WIDGETS_INFO);
@ -132,7 +136,7 @@ public class OnlineWidgetPackagesShowPane extends AbstractOnlineWidgetShowPane {
}
protected OnlineWidgetSelectPane createOnlineWidgetSelectPane(OnlineShareWidget[] sharableWidgetProviders) {
protected AbstractOnlineWidgetSelectPane createOnlineWidgetSelectPane(OnlineShareWidget[] sharableWidgetProviders) {
return new OnlineWidgetPackageSelectPane(filterPackageWidget(sharableWidgetProviders), 10, this);
}
@ -154,7 +158,7 @@ public class OnlineWidgetPackagesShowPane extends AbstractOnlineWidgetShowPane {
String id = widgetPackage.getId();
currentPackageId = id;
boolean containsCache = cachePanelMap.containsKey(id);
onlineWidgetSelectPane = containsCache ? cachePanelMap.get(id) : new OnlineWidgetSelectPane(() -> ShareUtils.getPackageWidgets(widgetPackage), 50);
onlineWidgetSelectPane = containsCache ? cachePanelMap.get(id) : new OnlineWidgetSelectPane(() -> OnlineShopUtils.getPackageWidgets(widgetPackage), 50);
downloadLabel.setVisible(!containsCache);
showWidgetDetailPane(onlineWidgetSelectPane);
}

265
designer-form/src/main/java/com/fr/design/mainframe/share/ui/widgetfilter/FilterConfigPane.java

@ -0,0 +1,265 @@
package com.fr.design.mainframe.share.ui.widgetfilter;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.VerticalFlowLayout;
import com.fr.design.mainframe.share.Bean.FilterTypeInfo;
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 javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.List;
/**
* Created by kerry on 2021/11/1
*/
public abstract class FilterConfigPane extends JPanel {
private static final Color BORDER_COLOR = Color.decode("#D9DADD");
private static final String FILTER_ALL_ID = "0";
public static final int CONTENT_WIDTH = 225;
private final List<WidgetFilterInfo> filterList = new ArrayList<>();
private final List<FilterCheckBox> checkBoxList = new ArrayList<>();
private boolean reset = false;
private boolean showChildNode;
public FilterConfigPane(List<FilterTypeInfo> widgetFilterCategories, boolean showChildNode) {
this.showChildNode = showChildNode;
initPane(widgetFilterCategories);
}
public FilterConfigPane(List<FilterTypeInfo> widgetFilterCategories) {
this(widgetFilterCategories, true);
}
private void initPane(List<FilterTypeInfo> widgetFilterCategories) {
this.setBackground(Color.WHITE);
this.setBorder(BorderFactory.createLineBorder(BORDER_COLOR));
this.setForeground(Color.decode("#FFFFFF"));
this.setLayout(new BorderLayout());
this.add(createVerticalFlowPane(widgetFilterCategories), BorderLayout.CENTER);
}
public boolean hasFilter() {
return filterList.size() > 0;
}
public List<WidgetFilterInfo> getFilterList() {
return filterList;
}
private JPanel createVerticalFlowPane(List<FilterTypeInfo> widgetFilterCategories) {
JPanel verticalFlowPane = new JPanel();
verticalFlowPane.setBackground(Color.WHITE);
VerticalFlowLayout layout = new VerticalFlowLayout(FlowLayout.LEADING, 0, 10);
layout.setAlignLeft(true);
verticalFlowPane.setLayout(layout);
verticalFlowPane.setBackground(Color.WHITE);
verticalFlowPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
for (FilterTypeInfo filterTypeInfo : widgetFilterCategories) {
verticalFlowPane.add(createCategoryPane(filterTypeInfo));
}
return verticalFlowPane;
}
private JPanel createTypeFilterPane(WidgetFilterTypeInfo widgetFilterTypeInfo) {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
jPanel.setBackground(Color.WHITE);
UILabel titleLabel = new UILabel(widgetFilterTypeInfo.getTitle() + ":");
titleLabel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
titleLabel.setFont(new Font(titleLabel.getFont().getName(), Font.BOLD, titleLabel.getFont().getSize()));
jPanel.add(titleLabel, BorderLayout.NORTH);
jPanel.add(createCategoryDetailPane(widgetFilterTypeInfo), BorderLayout.CENTER);
return jPanel;
}
private JPanel createCategoryPane(FilterTypeInfo filterTypeInfo) {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
jPanel.setBackground(Color.WHITE);
UILabel titleLabel = new UILabel(filterTypeInfo.getTitle());
titleLabel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
titleLabel.setPreferredSize(new Dimension(CONTENT_WIDTH - 2, 20));
titleLabel.setOpaque(true);
titleLabel.setBackground(Color.decode("#EDEDEE"));
jPanel.add(titleLabel, BorderLayout.NORTH);
jPanel.add(createCategoryDetailPane(filterTypeInfo.getFilterTypeInfos()), BorderLayout.CENTER);
return jPanel;
}
private JPanel createCategoryDetailPane(List<WidgetFilterTypeInfo> filterTypeInfoList) {
if (filterTypeInfoList.size() == 1) {
return createCategoryDetailPane(filterTypeInfoList.get(0));
}
JPanel contentPane = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10);
contentPane.setBackground(Color.WHITE);
for (WidgetFilterTypeInfo info : filterTypeInfoList) {
contentPane.add(createTypeFilterPane(info));
}
return contentPane;
}
private JPanel createCategoryDetailPane(WidgetFilterTypeInfo filterTypeInfo) {
JPanel contentPane = FRGUIPaneFactory.createNColumnGridInnerContainer_S_Pane(2);
contentPane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
contentPane.setBackground(Color.WHITE);
contentPane.setPreferredSize(new Dimension(CONTENT_WIDTH, calculateDetailPaneHeight(filterTypeInfo)));
for (final WidgetFilterInfo filterInfo : filterTypeInfo.getFilterItems()) {
if (ComparatorUtils.equals(FILTER_ALL_ID, filterInfo.getId())) {
continue;
}
FilterCheckBox checkBox = createCheckBox(filterInfo);
contentPane.add(checkBox);
if (showChildNode && filterInfo.hasChildFilter()) {
alignmentFilling(contentPane);
createChildPane(filterInfo.getInnerFilterInfo(), contentPane, checkBox);
alignmentFilling(contentPane);
}
}
return contentPane;
}
private void alignmentFilling(JPanel contentPane) {
if (contentPane.getComponentCount() % 2 == 1) {
contentPane.add(new UILabel(""));
}
}
private FilterCheckBox createCheckBox(WidgetFilterInfo filterInfo) {
final FilterCheckBox checkBox = new FilterCheckBox(filterInfo.getName(), filterInfo);
checkBox.setBackground(Color.WHITE);
checkBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (checkBox.isSelected() && !checkBox.getFilterInfo().hasChildFilter()) {
filterList.add(filterInfo);
} else if (filterList.contains(filterInfo)) {
filterList.remove(filterInfo);
}
if (reset) {
return;
}
fireSelectedChanged(new ChangeEvent(assembleFilter()));
}
});
checkBoxList.add(checkBox);
return checkBox;
}
private void createChildPane(List<WidgetFilterInfo> childFilterInfo, JPanel contentPane, FilterCheckBox parentCheckBox) {
List<FilterCheckBox> childCheckboxList = new ArrayList<>();
for (WidgetFilterInfo filterInfo : childFilterInfo) {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
jPanel.setBackground(Color.WHITE);
jPanel.setBorder(BorderFactory.createEmptyBorder(0, 16, 0, 0));
FilterCheckBox checkBox = createCheckBox(filterInfo);
checkBox.addItemListener(e -> {
if (this.reset) {
return;
}
this.reset = true;
parentCheckBox.setSelected(allChildSelected(childCheckboxList));
this.reset = false;
});
childCheckboxList.add(checkBox);
jPanel.add(checkBox, BorderLayout.CENTER);
contentPane.add(jPanel);
}
parentCheckBox.addItemListener(e -> {
if (this.reset) {
return;
}
this.reset = true;
for (FilterCheckBox checkBox : childCheckboxList) {
checkBox.setSelected(parentCheckBox.isSelected());
}
this.reset = false;
});
}
private boolean allChildSelected(List<FilterCheckBox> childCheckboxList) {
boolean flag = true;
for (FilterCheckBox checkBox : childCheckboxList) {
flag &= checkBox.isSelected();
}
return flag;
}
private int calculateDetailPaneHeight(WidgetFilterTypeInfo filterTypeInfo) {
int displayCount = 0;
for (final WidgetFilterInfo filterInfo : filterTypeInfo.getFilterItems()) {
if (!ComparatorUtils.equals(FILTER_ALL_ID, filterInfo.getId())) {
displayCount++;
}
if (filterInfo.getInnerFilterInfo().size() > 0 && showChildNode) {
displayCount += (1 + filterInfo.getInnerFilterInfo().size());
}
}
return ((displayCount + 1) / 2) * 27;
}
public abstract String assembleFilter();
public void setFilters(List<String> selectedFilterNames) {
reset = true;
filterList.clear();
for (FilterCheckBox checkBox : checkBoxList) {
if (selectedFilterNames.contains(checkBox.getFilterInfo().getName())) {
checkBox.setSelected(true);
filterList.add(checkBox.getFilterInfo());
}
}
reset = false;
}
public void reset() {
reset = true;
for (FilterCheckBox checkBox : checkBoxList) {
checkBox.setSelected(false);
}
filterList.clear();
fireSelectedChanged(new ChangeEvent(StringUtils.EMPTY));
reset = false;
}
protected void fireSelectedChanged(ChangeEvent changeEvent) {
}
private class FilterCheckBox extends UICheckBox {
private WidgetFilterInfo filterInfo;
public FilterCheckBox(String string, WidgetFilterInfo filterInfo) {
super(string);
this.filterInfo = filterInfo;
}
public WidgetFilterInfo getFilterInfo() {
return this.filterInfo;
}
}
}

29
designer-form/src/main/java/com/fr/design/mainframe/share/ui/widgetfilter/FilterPane.java

@ -5,8 +5,10 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.share.ui.base.MouseClickListener;
import com.fr.form.share.bean.WidgetFilterTypeInfo;
import com.fr.form.share.utils.ShareUtils;
import com.fr.design.mainframe.share.util.OnlineShopUtils;
import com.fr.design.mainframe.share.Bean.FilterTypeInfo;
import com.fr.design.mainframe.share.Bean.WidgetFilterInfo;
import com.fr.design.mainframe.share.util.ShareFilterConstants;
import com.fr.general.ComparatorUtils;
import com.fr.invoke.Reflect;
@ -35,10 +37,6 @@ import java.util.List;
* Created by kerry on 2020-10-21
*/
public class FilterPane extends JPanel {
public static final String SOURCE_FILTER_KEY = "2@source";
public static final String CHART_FILTER_KEY = "3@chart";
public static final String REPORT_FILTER_KEY = "4@report";
private static final Icon FILTER_COMBO = BaseUtils.readIcon("/com/fr/base/images/share/filter_combo.png");
private static final Icon FILTER_COMBO_UP = BaseUtils.readIcon("/com/fr/base/images/share/filter_combo_up.png");
private final UILabel filterLabel;
@ -115,10 +113,9 @@ public class FilterPane extends JPanel {
public static FilterPane createOnlinePackageFilterPane() {
FilterPane pane = new FilterPane() {
@Override
protected List<WidgetFilterTypeInfo> loadFilterCategories() {
List<WidgetFilterTypeInfo> filterTypeInfos = super.loadFilterCategories();
filterTypeInfos.removeIf(info -> ComparatorUtils.equals(FilterPane.CHART_FILTER_KEY, info.getKey())
|| ComparatorUtils.equals(FilterPane.REPORT_FILTER_KEY, info.getKey()));
protected List<FilterTypeInfo> loadFilterCategories() {
List<FilterTypeInfo> filterTypeInfos = super.loadFilterCategories();
filterTypeInfos.removeIf(info -> ComparatorUtils.equals(ShareFilterConstants.WIDGET_TYPE_FILTER_KEY, info.getKey()));
return filterTypeInfos;
}
};
@ -166,8 +163,8 @@ public class FilterPane extends JPanel {
java.awt.Toolkit.getDefaultToolkit().removeAWTEventListener(awtEventListener);
}
protected List<WidgetFilterTypeInfo> loadFilterCategories() {
return ShareUtils.getWidgetFilterTypeInfos();
protected List<FilterTypeInfo> loadFilterCategories() {
return OnlineShopUtils.getShowFilterTypeInfos();
}
private boolean isCanHide(MouseEvent mv, JPanel jPanel) {
@ -208,6 +205,14 @@ public class FilterPane extends JPanel {
switchToNoFilter();
}
public void setFilter(List<WidgetFilterInfo> selectedFilters){
List<String> selectedFilterNames = new ArrayList<>();
for(WidgetFilterInfo filterInfo : selectedFilters){
selectedFilterNames.add(filterInfo.getName());
}
filterPopupPane.setFilters(selectedFilterNames);
}
private void switchToNoFilter() {
filterLabel.setText(Toolkit.i18nText("Fine-Design_Share_Online_No_Filter"));
filterLabel.setForeground(Color.decode("#8F8F92"));

191
designer-form/src/main/java/com/fr/design/mainframe/share/ui/widgetfilter/FilterPopupPane.java

@ -1,203 +1,32 @@
package com.fr.design.mainframe.share.ui.widgetfilter;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.VerticalFlowLayout;
import com.fr.form.share.bean.WidgetFilterInfo;
import com.fr.form.share.bean.WidgetFilterTypeInfo;
import com.fr.general.ComparatorUtils;
import com.fr.stable.StringUtils;
import com.fr.design.mainframe.share.Bean.FilterTypeInfo;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.List;
/**
* @Author: Yuan.Wang
* @Date: 2020/11/11
*/
public abstract class FilterPopupPane extends JPanel {
private static final Color BORDER_COLOR = Color.decode("#D9DADD");
private static final String FILTER_ALL_ID = "0";
public abstract class FilterPopupPane extends FilterConfigPane {
public static final int CONTENT_WIDTH = 225;
private final FilterPane filterPane;
FilterPane filterPane;
private List<WidgetFilterInfo> filterList = new ArrayList<>();
private final List<UICheckBox> checkBoxList = new ArrayList<>();
private boolean reset = false;
public FilterPopupPane(FilterPane filterPane, List<WidgetFilterTypeInfo> widgetFilterCategories) {
public FilterPopupPane(FilterPane filterPane, List<FilterTypeInfo> widgetFilterCategories) {
super(widgetFilterCategories);
this.filterPane = filterPane;
initPane(widgetFilterCategories);
}
private void initPane(List<WidgetFilterTypeInfo> widgetFilterCategories) {
this.setBackground(Color.WHITE);
this.setBorder(BorderFactory.createLineBorder(BORDER_COLOR));
this.setForeground(Color.decode("#FFFFFF"));
this.setLayout(new BorderLayout());
this.add(createVerticalFlowPane(widgetFilterCategories), BorderLayout.CENTER);
}
public boolean hasFilter() {
return filterList.size() > 0;
}
protected List<WidgetFilterInfo> getFilterList() {
return filterList;
}
private JPanel createVerticalFlowPane(List<WidgetFilterTypeInfo> widgetFilterCategories) {
List<WidgetFilterTypeInfo> topWidgetTypeFilter = new ArrayList<>();
List<WidgetFilterTypeInfo> widgetTypeFilter = new ArrayList<>();
List<WidgetFilterTypeInfo> otherWidgetTypeFilter = new ArrayList<>();
for (WidgetFilterTypeInfo info : widgetFilterCategories) {
if (ComparatorUtils.equals(FilterPane.CHART_FILTER_KEY, info.getKey())
|| ComparatorUtils.equals(FilterPane.REPORT_FILTER_KEY, info.getKey())) {
widgetTypeFilter.add(info);
} else if (ComparatorUtils.equals(FilterPane.SOURCE_FILTER_KEY, info.getKey())) {
topWidgetTypeFilter.add(info);
} else {
otherWidgetTypeFilter.add(info);
}
}
JPanel verticalFlowPane = new JPanel();
verticalFlowPane.setBackground(Color.WHITE);
VerticalFlowLayout layout = new VerticalFlowLayout(FlowLayout.LEADING, 0, 10);
layout.setAlignLeft(true);
verticalFlowPane.setLayout(layout);
verticalFlowPane.setBackground(Color.WHITE);
verticalFlowPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
for (WidgetFilterTypeInfo info : topWidgetTypeFilter) {
verticalFlowPane.add(createOtherCategoryPane(info));
}
if (widgetTypeFilter.size() > 0) {
verticalFlowPane.add(createWidgetTypeFilterPane(widgetTypeFilter));
}
for (WidgetFilterTypeInfo info : otherWidgetTypeFilter) {
verticalFlowPane.add(createOtherCategoryPane(info));
}
return verticalFlowPane;
public void setFilters(List<String> selectedFilterNames) {
super.setFilters(selectedFilterNames);
filterPane.changeFilterButtonStatus(hasFilter());
}
private JPanel createWidgetTypeFilterPane(List<WidgetFilterTypeInfo> widgetTypeFilter) {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
jPanel.setBackground(Color.WHITE);
UILabel titleLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Type"));
titleLabel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
titleLabel.setPreferredSize(new Dimension(CONTENT_WIDTH - 2, 20));
titleLabel.setOpaque(true);
titleLabel.setBackground(Color.decode("#EDEDEE"));
jPanel.add(titleLabel, BorderLayout.NORTH);
JPanel contentPane = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10);
contentPane.setBackground(Color.WHITE);
for (WidgetFilterTypeInfo info : widgetTypeFilter) {
contentPane.add(createTypeFilterPane(info));
}
jPanel.add(contentPane, BorderLayout.CENTER);
return jPanel;
}
private JPanel createTypeFilterPane(WidgetFilterTypeInfo widgetFilterTypeInfo) {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
jPanel.setBackground(Color.WHITE);
UILabel titleLabel = new UILabel(widgetFilterTypeInfo.getTitle() + ":");
titleLabel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
titleLabel.setFont(new Font(titleLabel.getFont().getName(), Font.BOLD, titleLabel.getFont().getSize()));
jPanel.add(titleLabel, BorderLayout.NORTH);
jPanel.add(createCategoryDetailPane(widgetFilterTypeInfo), BorderLayout.CENTER);
return jPanel;
}
private JPanel createOtherCategoryPane(WidgetFilterTypeInfo filterTypeInfo) {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
jPanel.setBackground(Color.WHITE);
UILabel titleLabel = new UILabel(filterTypeInfo.getTitle());
titleLabel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
titleLabel.setPreferredSize(new Dimension(CONTENT_WIDTH - 2, 20));
titleLabel.setOpaque(true);
titleLabel.setBackground(Color.decode("#EDEDEE"));
jPanel.add(titleLabel, BorderLayout.NORTH);
jPanel.add(createCategoryDetailPane(filterTypeInfo), BorderLayout.CENTER);
return jPanel;
}
private JPanel createCategoryDetailPane(WidgetFilterTypeInfo filterTypeInfo) {
JPanel contentPane = FRGUIPaneFactory.createNColumnGridInnerContainer_S_Pane(2);
contentPane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
contentPane.setBackground(Color.WHITE);
int displayCount = 0;
for (final WidgetFilterInfo filterInfo : filterTypeInfo.getFilterItems()) {
if (!ComparatorUtils.equals(FILTER_ALL_ID, filterInfo.getId())) {
displayCount++;
}
}
int contentPaneHeight = ((displayCount + 1) / 2) * 27;
contentPane.setPreferredSize(new Dimension(CONTENT_WIDTH, contentPaneHeight));
for (final WidgetFilterInfo filterInfo : filterTypeInfo.getFilterItems()) {
if (ComparatorUtils.equals(FILTER_ALL_ID, filterInfo.getId())) {
continue;
}
final UICheckBox checkBox = new UICheckBox(filterInfo.getName());
checkBox.setBackground(Color.WHITE);
checkBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (reset) {
return;
}
if (checkBox.isSelected()) {
filterList.add(filterInfo);
} else if (filterList.contains(filterInfo)) {
filterList.remove(filterInfo);
}
checkFilterButtonStatus();
filterPane.fireChangeListener(new ChangeEvent(assembleFilter()));
}
});
checkBoxList.add(checkBox);
contentPane.add(checkBox);
}
return contentPane;
}
protected abstract String assembleFilter();
private void checkFilterButtonStatus() {
protected void fireSelectedChanged(ChangeEvent changeEvent){
filterPane.changeFilterButtonStatus(hasFilter());
filterPane.fireChangeListener(changeEvent);
}
public void reset() {
reset = true;
for (UICheckBox checkBox : checkBoxList) {
checkBox.setSelected(false);
}
filterList.clear();
checkFilterButtonStatus();
filterPane.fireChangeListener(new ChangeEvent(StringUtils.EMPTY));
reset = false;
}
}

6
designer-form/src/main/java/com/fr/design/mainframe/share/ui/widgetfilter/LocalFilterPopupPane.java

@ -1,6 +1,6 @@
package com.fr.design.mainframe.share.ui.widgetfilter;
import com.fr.form.share.bean.WidgetFilterTypeInfo;
import com.fr.design.mainframe.share.Bean.FilterTypeInfo;
import com.fr.stable.StringUtils;
import java.util.ArrayList;
@ -11,12 +11,12 @@ import java.util.List;
* @Date: 2020/11/11
*/
public class LocalFilterPopupPane extends FilterPopupPane {
public LocalFilterPopupPane(FilterPane pane, List<WidgetFilterTypeInfo> loadFilterCategories) {
public LocalFilterPopupPane(FilterPane pane, List<FilterTypeInfo> loadFilterCategories) {
super(pane, loadFilterCategories);
}
@Override
protected String assembleFilter() {
public String assembleFilter() {
LocalWidgetFilter.getInstance().setFilterList(getFilterList() == null ? new ArrayList<>() : getFilterList());
return StringUtils.EMPTY;
}

2
designer-form/src/main/java/com/fr/design/mainframe/share/ui/widgetfilter/LocalWidgetFilter.java

@ -3,7 +3,7 @@ package com.fr.design.mainframe.share.ui.widgetfilter;
import com.fr.design.i18n.Toolkit;
import com.fr.form.share.DefaultSharableWidget;
import com.fr.form.share.SharableWidgetProvider;
import com.fr.form.share.bean.WidgetFilterInfo;
import com.fr.design.mainframe.share.Bean.WidgetFilterInfo;
import com.fr.design.mainframe.share.constants.DisplayDevice;
import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils;

50
designer-form/src/main/java/com/fr/design/mainframe/share/ui/widgetfilter/LocalWidgetFilterCategory.java

@ -1,7 +1,10 @@
package com.fr.design.mainframe.share.ui.widgetfilter;
import com.fr.form.share.bean.WidgetFilterInfo;
import com.fr.form.share.bean.WidgetFilterTypeInfo;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.share.Bean.FilterTypeInfo;
import com.fr.design.mainframe.share.Bean.WidgetFilterInfo;
import com.fr.design.mainframe.share.Bean.WidgetFilterTypeInfo;
import com.fr.design.mainframe.share.util.ShareFilterConstants;
import java.util.ArrayList;
import java.util.List;
@ -12,33 +15,39 @@ import java.util.List;
*/
public class LocalWidgetFilterCategory {
public static List<WidgetFilterTypeInfo> getLocalCategory() {
List<WidgetFilterTypeInfo> category = new ArrayList<>();
public static List<FilterTypeInfo> getLocalCategory() {
List<FilterTypeInfo> category = new ArrayList<>();
WidgetFilterTypeInfo source = new WidgetFilterTypeInfo();
source.setTitle("来源");
source.setKey("2@source");
source.setTitle(Toolkit.i18nText("Fine-Design_Share_Local_Filter_Source"));
source.setKey(ShareFilterConstants.SOURCE_TYPE_FILTER_KEY);
source.addFilterItem(new WidgetFilterInfo("本地", "1", "source"));
source.addFilterItem(new WidgetFilterInfo("商城", "2", "source"));
source.addFilterItem(new WidgetFilterInfo("全部", "0", "source"));
FilterTypeInfo sourceTypeInfo = new FilterTypeInfo(source.getTitle(), source.getKey());
sourceTypeInfo.addFilterType(source);
WidgetFilterTypeInfo displayDevice = new WidgetFilterTypeInfo();
displayDevice.setTitle("展示终端");
displayDevice.setKey("1@displayDevice");
displayDevice.setTitle(Toolkit.i18nText("Fine-Design_Share_Local_Filter_Show_Device"));
displayDevice.setKey(ShareFilterConstants.SHOW_TERMINAL_FILTER_KEY);
displayDevice.addFilterItem(new WidgetFilterInfo("PC端", "1", "displayDevice"));
displayDevice.addFilterItem(new WidgetFilterInfo("移动端", "2", "displayDevice"));
displayDevice.addFilterItem(new WidgetFilterInfo("全部", "0", "displayDevice"));
FilterTypeInfo showDeviceTypeInfo = new FilterTypeInfo(displayDevice.getTitle(), displayDevice.getKey());
showDeviceTypeInfo.addFilterType(displayDevice);
WidgetFilterTypeInfo fee = new WidgetFilterTypeInfo();
fee.setTitle("价格");
fee.setKey("2@fee");
fee.setTitle(Toolkit.i18nText("Fine-Design_Share_Local_Filter_Price"));
fee.setKey(ShareFilterConstants.FEE_FILTER_KEY);
fee.addFilterItem(new WidgetFilterInfo("付费", "2", "fee"));
fee.addFilterItem(new WidgetFilterInfo("免费", "1", "fee"));
fee.addFilterItem(new WidgetFilterInfo("全部", "0", "fee"));
FilterTypeInfo feeTypeInfo = new FilterTypeInfo(fee.getTitle(), fee.getKey());
feeTypeInfo.addFilterType(fee);
WidgetFilterTypeInfo chart = new WidgetFilterTypeInfo();
chart.setTitle("基础元素");
chart.setKey("3@chart");
chart.setKey(ShareFilterConstants.CHART_FILTER_KEY);
chart.addFilterItem(new WidgetFilterInfo("柱形图/条形图", "1", "chart"));
chart.addFilterItem(new WidgetFilterInfo("折线图", "3", "chart"));
chart.addFilterItem(new WidgetFilterInfo("组合图", "4", "chart"));
@ -52,7 +61,7 @@ public class LocalWidgetFilterCategory {
WidgetFilterTypeInfo report = new WidgetFilterTypeInfo();
report.setTitle("综合应用");
report.setKey("4@report");
report.setKey(ShareFilterConstants.REPORT_FILTER_KEY);
report.addFilterItem(new WidgetFilterInfo("指标卡", "1", "report"));
report.addFilterItem(new WidgetFilterInfo("标题头", "2", "report"));
report.addFilterItem(new WidgetFilterInfo("特殊功能卡", "4", "report"));
@ -60,21 +69,24 @@ public class LocalWidgetFilterCategory {
report.addFilterItem(new WidgetFilterInfo("移动目录导航", "6", "report"));
report.addFilterItem(new WidgetFilterInfo("填报", "8", "report"));
report.addFilterItem(new WidgetFilterInfo("全部", "0", "report"));
FilterTypeInfo widgetTypeInfo = new FilterTypeInfo(Toolkit.i18nText("Fine-Design_Share_Filter_Widget_Type"), ShareFilterConstants.WIDGET_TYPE_FILTER_KEY);
widgetTypeInfo.addFilterType(chart);
widgetTypeInfo.addFilterType(report);
WidgetFilterTypeInfo style = new WidgetFilterTypeInfo();
style.setTitle("风格");
style.setKey("5@style");
style.setTitle(Toolkit.i18nText("Fine-Design_Share_Filter_Style"));
style.setKey(ShareFilterConstants.STYLE_FILTER_KEY);
style.addFilterItem(new WidgetFilterInfo("简约清新", "1", "style"));
style.addFilterItem(new WidgetFilterInfo("商务稳重", "2", "style"));
style.addFilterItem(new WidgetFilterInfo("活泼绚丽", "3", "style"));
style.addFilterItem(new WidgetFilterInfo("酷炫科技", "4", "style"));
style.addFilterItem(new WidgetFilterInfo("其他风格", "5", "style"));
style.addFilterItem(new WidgetFilterInfo("全部", "0", "style"));
category.add(displayDevice);
category.add(source);
category.add(chart);
category.add(report);
FilterTypeInfo styleTypeInfo = new FilterTypeInfo(style.getTitle(), style.getKey());
styleTypeInfo.addFilterType(style);
category.add(sourceTypeInfo);
category.add(widgetTypeInfo);
category.add(showDeviceTypeInfo);
return category;
}

10
designer-form/src/main/java/com/fr/design/mainframe/share/ui/widgetfilter/OnlineFilterPopupPane.java

@ -1,7 +1,7 @@
package com.fr.design.mainframe.share.ui.widgetfilter;
import com.fr.form.share.bean.WidgetFilterTypeInfo;
import com.fr.form.share.utils.ShareUtils;
import com.fr.design.mainframe.share.util.OnlineShopUtils;
import com.fr.design.mainframe.share.Bean.FilterTypeInfo;
import java.util.List;
@ -11,12 +11,12 @@ import java.util.List;
*/
public class OnlineFilterPopupPane extends FilterPopupPane {
public OnlineFilterPopupPane(FilterPane filterPane, List<WidgetFilterTypeInfo> widgetFilterCategories) {
public OnlineFilterPopupPane(FilterPane filterPane, List<FilterTypeInfo> widgetFilterCategories) {
super(filterPane, widgetFilterCategories);
}
protected String assembleFilter() {
return ShareUtils.assembleFilter(getFilterList());
public String assembleFilter() {
return OnlineShopUtils.assembleFilter(getFilterList());
}

17
designer-form/src/main/java/com/fr/design/mainframe/share/util/DownloadUtils.java

@ -6,7 +6,6 @@ import com.fr.design.extra.PluginConstants;
import com.fr.form.share.base.CancelCheck;
import com.fr.form.share.constants.ShareComponentConstants;
import com.fr.ftp.util.Base64;
import com.fr.general.CloudCenter;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
@ -39,19 +38,23 @@ import java.security.KeyFactory;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.X509EncodedKeySpec;
import static com.fr.form.share.constants.ShareComponentConstants.REU_INFO_PATH;
/**
* created by Harrison on 2020/05/27
**/
public class DownloadUtils {
private static final String REUSES_URL = StableUtils.pathJoin(ShareComponentConstants.REU_INFO_PATH, "file/download");
private static final String PACKAGE_REUSES_URL = StableUtils.pathJoin(ShareComponentConstants.REU_INFO_PATH, "package/download/");
private static final String CERTIFICATE_PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCtsz62CPSWXZE/IYZRiAuTSZkw\n" +
"1WOwer8+JFktK0uKLAUuQoBr+UjAMFtRA8W7JgKMDwZy/2liEAiXEOSPU/hrdV8D\n" +
"tT541LnGi1X/hXiRwuttPWYN3L2GYm/d5blU+FBNwghBIrdAxXTzYBc6P4KL/oYX\n" +
"nMdTIrkz8tYkG3QoFQIDAQAB";
private static String getReusesUrl() {
return StableUtils.pathJoin(OnlineShopUtils.getReuInfoPath(), "file/download");
}
private static String getPackageReusesUrl() {
return StableUtils.pathJoin(OnlineShopUtils.getReuInfoPath(), "package/download/");
}
private static CloseableHttpClient createClient() {
@ -65,7 +68,7 @@ public class DownloadUtils {
@NotNull
public static String download(String id, String fileName, com.fr.design.extra.Process<Double> process) throws Exception {
CloseableHttpResponse fileRes = getHttpResponse(REUSES_URL, id);
CloseableHttpResponse fileRes = getHttpResponse(getReusesUrl(), id);
if (fileRes.getStatusLine().getStatusCode() == HttpStatus.SC_MOVED_TEMPORARILY) {
fileRes = getHttpResponse(fileRes.getHeaders("Location")[0].getValue());
}
@ -103,7 +106,7 @@ public class DownloadUtils {
public static String downloadPackage(String id, String fileName, CancelCheck cancelCheck) throws Exception {
CloseableHttpResponse fileRes = getHttpResponse(PACKAGE_REUSES_URL, id);
CloseableHttpResponse fileRes = getHttpResponse(getPackageReusesUrl(), id);
if (fileRes.getStatusLine().getStatusCode() == HttpStatus.SC_MOVED_TEMPORARILY) {
fileRes = getHttpResponse(fileRes.getHeaders("Location")[0].getValue());
}

293
designer-form/src/main/java/com/fr/design/mainframe/share/util/OnlineShopUtils.java

@ -0,0 +1,293 @@
package com.fr.design.mainframe.share.util;
import com.fr.design.DesignerCloudURLManager;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.share.Bean.FilterTypeInfo;
import com.fr.form.share.bean.OnlineShareWidget;
import com.fr.form.share.bean.SortParameter;
import com.fr.design.mainframe.share.Bean.WidgetFilterInfo;
import com.fr.design.mainframe.share.Bean.WidgetFilterTypeInfo;
import com.fr.design.mainframe.share.config.ComponentReuseConfigManager;
import com.fr.general.ComparatorUtils;
import com.fr.general.http.HttpClient;
import com.fr.json.JSONArray;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import java.net.HttpURLConnection;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* Created by kerry on 2021/11/3
*/
public class OnlineShopUtils {
private static final String CHART = "chart";
private static final String REPORT = "report";
private static final String CID_PREFIX = "cid";
private static final String CHART_IDS = "123457";
private OnlineShopUtils() {
}
public static String getReuInfoPath() {
return ComponentReuseConfigManager.getInstance().getMiniShopUrl();
}
private static String getWidgetReusePath() {
return getReuInfoPath();
}
private static String getPackageChildrenPath() {
return StableUtils.pathJoin(getReuInfoPath(), "children/");
}
private static String getWidgetFilterPath() {
// return StableUtils.pathJoin(getReuInfoPath(), "filter");
return "http://192.168.5.83:3008/reuses/filter";
}
private static String getGetCompositeSortParaPath() {
return StableUtils.pathJoin(getReuInfoPath(), "sort_parameter");
}
private static String getTestConnectionUrl() {
return DesignerCloudURLManager.getInstance().acquireUrlByKind("ping");
}
public static List<FilterTypeInfo> getShowFilterTypeInfos() {
List<FilterTypeInfo> filterTypeInfos = new ArrayList<>();
List<WidgetFilterTypeInfo> widgetFilterTypeInfos = getWidgetFilterTypeInfos();
FilterTypeInfo widgetTypeInfo =
new FilterTypeInfo(Toolkit.i18nText("Fine-Design_Share_Filter_Widget_Type"), ShareFilterConstants.WIDGET_TYPE_FILTER_KEY);
for (WidgetFilterTypeInfo info : widgetFilterTypeInfos) {
if (ComparatorUtils.equals(ShareFilterConstants.CHART_FILTER_KEY, info.getKey())
|| ComparatorUtils.equals(ShareFilterConstants.REPORT_FILTER_KEY, info.getKey())) {
widgetTypeInfo.addFilterType(info);
if (!filterTypeInfos.contains(widgetTypeInfo)) {
filterTypeInfos.add(widgetTypeInfo);
}
} else {
FilterTypeInfo typeInfo = new FilterTypeInfo(info.getTitle(), info.getKey());
typeInfo.addFilterType(info);
filterTypeInfos.add(typeInfo);
}
}
filterTypeInfos.sort(Comparator.comparingInt(o -> OnlineFilterType.parse(o.getKey()).ordinal()));
return filterTypeInfos;
}
enum OnlineFilterType {
SHOW_DEVICE(ShareFilterConstants.SHOW_TERMINAL_FILTER_KEY),
STYLE(ShareFilterConstants.STYLE_FILTER_KEY),
WIDGET_TYPE(ShareFilterConstants.WIDGET_TYPE_FILTER_KEY),
FEE(ShareFilterConstants.FEE_FILTER_KEY),
VERSION(ShareFilterConstants.VERSION_FILTER_KEY);
private String flag;
private OnlineFilterType(String flag) {
this.flag = flag;
}
public static OnlineFilterType parse(String flag) {
for (OnlineFilterType filterType : values()) {
if (ComparatorUtils.equals(filterType.flag, flag)) {
return filterType;
}
}
return SHOW_DEVICE;
}
}
public static List<FilterTypeInfo> getEmbPaneShowFilterTypeInfos() {
List<FilterTypeInfo> filterTypeInfos = new ArrayList<>();
List<WidgetFilterTypeInfo> widgetFilterTypeInfos = getWidgetFilterTypeInfos();
WidgetFilterTypeInfo widgetTypeFilterInfo = new WidgetFilterTypeInfo();
widgetTypeFilterInfo.setTitle(Toolkit.i18nText("Fine-Design_Share_Filter_Widget_Type"));
FilterTypeInfo widgetType = new FilterTypeInfo(widgetTypeFilterInfo.getTitle(), ShareFilterConstants.WIDGET_TYPE_FILTER_KEY);
widgetType.addFilterType(widgetTypeFilterInfo);
WidgetFilterInfo reportCard = new WidgetFilterInfo();
reportCard.setName(Toolkit.i18nText("Fine-Design_Share_Online_Filter_Indicator_Card"));
WidgetFilterInfo chartType = new WidgetFilterInfo();
chartType.setName(Toolkit.i18nText("Fine-Design_Share_Online_Filter_Chart"));
WidgetFilterInfo otherType = new WidgetFilterInfo();
otherType.setName(Toolkit.i18nText("Fine-Design_Share_Online_Filter_Other_Type"));
widgetTypeFilterInfo.addFilterItem(reportCard);
widgetTypeFilterInfo.addFilterItem(chartType);
widgetTypeFilterInfo.addFilterItem(otherType);
for (WidgetFilterTypeInfo info : widgetFilterTypeInfos) {
if (ComparatorUtils.equals(ShareFilterConstants.SHOW_TERMINAL_FILTER_KEY, info.getKey())) {
FilterTypeInfo showTerminalInfo = new FilterTypeInfo(info.getTitle(), info.getKey());
showTerminalInfo.addFilterType(info);
filterTypeInfos.add(showTerminalInfo);
} else if (ComparatorUtils.equals(ShareFilterConstants.STYLE_FILTER_KEY, info.getKey())) {
FilterTypeInfo styleTypeInfo = new FilterTypeInfo(info.getTitle(), info.getKey());
styleTypeInfo.addFilterType(info);
filterTypeInfos.add(styleTypeInfo);
} else if (ComparatorUtils.equals(ShareFilterConstants.REPORT_FILTER_KEY, info.getKey())) {
for (WidgetFilterInfo filterInfo : info.getFilterItems()) {
if (ComparatorUtils.equals(filterInfo.getId(), "1")) {
reportCard.addChildFilterInfo(filterInfo);
} else {
otherType.addChildFilterInfo(filterInfo);
}
}
} else if (ComparatorUtils.equals(ShareFilterConstants.CHART_FILTER_KEY, info.getKey())) {
for (WidgetFilterInfo filterInfo : info.getFilterItems()) {
if (filterInfo.getId() != null && CHART_IDS.contains(filterInfo.getId())) {
chartType.addChildFilterInfo(filterInfo);
} else {
otherType.addChildFilterInfo(filterInfo);
}
}
}
}
filterTypeInfos.add(widgetType);
return filterTypeInfos;
}
public static Map<String, SortParameter> getCompositeSortPara() {
Map<String, SortParameter> para = new HashMap<>();
try {
JSONArray resultArr = getResultAttrFromUrl(getGetCompositeSortParaPath());
int size = resultArr.size();
for (int i = 0; i < size; i++) {
JSONObject jo = resultArr.getJSONObject(i);
SortParameter sortParameter = SortParameter.parseFromJSONObject(jo);
para.put(sortParameter.getParameter(), sortParameter);
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return para;
}
public static String assembleFilter(List<WidgetFilterInfo> filterInfos) {
List<String> cidList = new ArrayList<>();
Map<String, String> queryParaMap = new HashMap<>();
for (WidgetFilterInfo filterInfo : filterInfos) {
if (ComparatorUtils.equals(CHART, filterInfo.getType())
|| ComparatorUtils.equals(REPORT, filterInfo.getType())) {
cidList.add(filterInfo.getType() + "-" + filterInfo.getId());
continue;
}
String queryValue = queryParaMap.get(filterInfo.getType());
if (StringUtils.isNotEmpty(queryValue)) {
queryValue += "," + filterInfo.getId();
} else {
queryValue = filterInfo.getId();
}
queryParaMap.put(filterInfo.getType(), queryValue);
}
StringBuffer sb;
List<String> queryCondition = new ArrayList<>();
if (!cidList.isEmpty()) {
sb = new StringBuffer();
sb.append(CID_PREFIX).append("=").append(StringUtils.join(",", cidList.toArray(new String[cidList.size()])));
queryCondition.add(sb.toString());
}
Iterator<Map.Entry<String, String>> iterator = queryParaMap.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, String> entry = iterator.next();
sb = new StringBuffer();
sb.append(entry.getKey()).append("=").append(entry.getValue());
queryCondition.add(sb.toString());
}
return StringUtils.join("&", queryCondition.toArray(new String[queryCondition.size()]));
}
public static boolean testConnection() {
HttpClient httpClient = new HttpClient(getTestConnectionUrl());
httpClient.asGet();
int responseCode = httpClient.getResponseCode();
return responseCode == HttpURLConnection.HTTP_OK;
}
public static List<OnlineShareWidget>[] getAllSharableWidgetsFromShop() throws Exception {
List<OnlineShareWidget>[] sharableWidgetsArray = new List[]{new ArrayList<>(), new ArrayList<>()};
JSONArray resultArr = getResultAttrFromUrl(getWidgetReusePath());
int size = resultArr.size();
for (int i = 0; i < size; i++) {
JSONObject jo = resultArr.getJSONObject(i);
OnlineShareWidget temp = OnlineShareWidget.parseFromJSONObject(jo);
if (temp.isWidgetPackage()) {
sharableWidgetsArray[1].add(temp);
} else {
sharableWidgetsArray[0].add(temp);
}
}
return sharableWidgetsArray;
}
public static OnlineShareWidget[] getPackageWidgets(OnlineShareWidget widgetPackage) {
String plistUrl = getPackageChildrenPath() + widgetPackage.getId();
OnlineShareWidget[] widgets = getOnlineShareWidgets(plistUrl);
for (OnlineShareWidget widget : widgets) {
widget.setParentPackage(widgetPackage);
}
return widgets;
}
public static List<WidgetFilterTypeInfo> getWidgetFilterTypeInfos() {
List<WidgetFilterTypeInfo> result = new ArrayList<>();
try {
JSONArray resultArr = getResultAttrFromUrl(getWidgetFilterPath());
int size = resultArr.size();
for (int i = 0; i < size; i++) {
JSONObject jo = resultArr.getJSONObject(i);
result.add(WidgetFilterTypeInfo.parseFromJSONObject(jo));
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return result;
}
private static OnlineShareWidget[] getOnlineShareWidgets(String url) {
if (StringUtils.isNotBlank(url)) {
try {
JSONArray resultArr = getResultAttrFromUrl(url);
int size = resultArr.size();
List<OnlineShareWidget> onlineShareWidgets = new ArrayList<>();
for (int i = 0; i < size; i++) {
JSONObject jo = resultArr.getJSONObject(i);
OnlineShareWidget widget = OnlineShareWidget.parseFromJSONObject(jo);
if (!widget.isWidgetPackage()) {
onlineShareWidgets.add(widget);
}
}
return onlineShareWidgets.toArray(new OnlineShareWidget[onlineShareWidgets.size()]);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
return new OnlineShareWidget[]{};
}
public static OnlineShareWidget[] getFilterWidgets(String filterStr) {
String plistUrl = getWidgetReusePath() + "?" + filterStr;
return getOnlineShareWidgets(plistUrl);
}
private static JSONArray getResultAttrFromUrl(String url) {
HttpClient httpClient = new HttpClient(url);
httpClient.asGet();
String responseText = httpClient.getResponseText();
JSONObject resultJSONObject = new JSONObject(responseText);
return resultJSONObject.getJSONArray("result");
}
}

17
designer-form/src/main/java/com/fr/design/mainframe/share/util/ShareFilterConstants.java

@ -0,0 +1,17 @@
package com.fr.design.mainframe.share.util;
/**
* Created by kerry on 2021/11/3
*/
public class ShareFilterConstants {
public static final String CHART_FILTER_KEY = "3@chart";
public static final String REPORT_FILTER_KEY = "4@report";
public static final String SHOW_TERMINAL_FILTER_KEY = "4@displayDevice";
public static final String STYLE_FILTER_KEY = "5@style";
public static final String FEE_FILTER_KEY = "2@fee";
public static final String VERSION_FILTER_KEY = "6@version";
public static final String WIDGET_TYPE_FILTER_KEY = "1@widgetType";
public static final String SOURCE_TYPE_FILTER_KEY = "2@source";
public static final String ALL_STYLE_THEME = "0";
}

3
designer-form/src/main/java/com/fr/design/widget/ui/designer/NewFormPane.java

@ -17,10 +17,10 @@ import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.form.main.Form;
import com.fr.design.DesignerCloudURLManager;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.OccupiedLayout;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.form.ui.container.WBorderLayout;
import com.fr.form.ui.container.WFitLayout;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
@ -65,6 +65,7 @@ public class NewFormPane extends BasicPane {
this.add(createModuleListPane(), BorderLayout.WEST);
this.add(createTemplateManagePane(), BorderLayout.CENTER);
initWindow();
DesignerCloudURLManager.getInstance().testConnect();
}
private void initWindow() {

BIN
designer-form/src/main/resources/com/fr/design/form/images/drag_hand.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 967 B

45
designer-form/src/test/java/com/fr/design/mainframe/ReuseTriggerPointManagerTest.java

@ -1,45 +0,0 @@
package com.fr.design.mainframe;
import com.fr.design.mainframe.reuse.ComponentReuseNotificationInfo;
import org.junit.Assert;
import org.junit.Test;
/**
* Created by kerry on 5/10/21
*/
public class ReuseTriggerPointManagerTest {
private static final long ONE_WEEK_TIME = 7 * 24 * 3600 * 1000L;
@Test
public void testNeedTrigger() {
ComponentReuseNotificationInfo notificationInfo = ComponentReuseNotificationInfo.getInstance();
notificationInfo.setNotifiedNumber(0);
Assert.assertTrue(ReuseTriggerPointManager.getInstance().needTrigger());
notificationInfo.setNotifiedNumber(1);
Assert.assertTrue(ReuseTriggerPointManager.getInstance().needTrigger());
notificationInfo.setNotifiedNumber(2);
Assert.assertFalse(ReuseTriggerPointManager.getInstance().needTrigger());
notificationInfo.setNotifiedNumber(0);
notificationInfo.setLastNotifyTime(System.currentTimeMillis());
Assert.assertFalse(ReuseTriggerPointManager.getInstance().needTrigger());
notificationInfo.setNotifiedNumber(1);
notificationInfo.setLastNotifyTime(System.currentTimeMillis());
Assert.assertFalse(ReuseTriggerPointManager.getInstance().needTrigger());
notificationInfo.setNotifiedNumber(1);
notificationInfo.setLastNotifyTime(System.currentTimeMillis() - ONE_WEEK_TIME - 1);
Assert.assertTrue(ReuseTriggerPointManager.getInstance().needTrigger());
notificationInfo.setNotifiedNumber(2);
notificationInfo.setLastNotifyTime(System.currentTimeMillis());
Assert.assertFalse(ReuseTriggerPointManager.getInstance().needTrigger());
}
}

4
designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/theme/DownloadComponentPackageGuide.java

@ -30,8 +30,8 @@ import com.fr.design.mainframe.share.ui.block.OnlineWidgetPackageBlock;
import com.fr.design.mainframe.share.ui.online.OnlineWidgetRepoPane;
import com.fr.design.mainframe.share.ui.online.OnlineWidgetTabPane;
import com.fr.design.mainframe.share.util.DownloadUtils;
import com.fr.design.mainframe.share.util.OnlineShopUtils;
import com.fr.design.utils.ComponentUtils;
import com.fr.form.share.utils.ShareUtils;
import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext;
@ -86,7 +86,7 @@ public class DownloadComponentPackageGuide {
GuideCreateUtils.showUnLoginAlert();
GuideManager.getInstance().getCurrentGuide().terminate();
return false;
} else if (!ShareUtils.testConnection()) {
} else if (!OnlineShopUtils.testConnection()) {
GuideCreateUtils.showNoNetworkAlert();
GuideManager.getInstance().getCurrentGuide().terminate();
return false;

2
designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareGeneratePane.java

@ -26,7 +26,7 @@ import com.fr.design.share.utils.EffectItemUtils;
import com.fr.design.share.utils.ShareDialogUtils;
import com.fr.form.share.DefaultSharableWidget;
import com.fr.form.share.Group;
import com.fr.form.share.config.ComponentReuseConfigManager;
import com.fr.design.mainframe.share.config.ComponentReuseConfigManager;
import com.fr.form.share.exception.NetWorkFailedException;
import com.fr.form.share.group.DefaultShareGroup;
import com.fr.form.share.group.DefaultShareGroupManager;

Loading…
Cancel
Save