Browse Source

Merge remote-tracking branch 'origin/feature/x' into feature/x

feature/x
Hoky 3 years ago
parent
commit
f242234050
  1. 11
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  2. 42
      designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java
  3. 2
      designer-base/src/main/java/com/fr/design/mainframe/ComponentReuseNotifyUtil.java
  4. 18
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  5. 17
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  6. 14
      designer-base/src/main/java/com/fr/design/mainframe/reuse/ComponentReuseNotificationInfo.java
  7. 14
      designer-base/src/main/java/com/fr/design/utils/gui/AdjustWorkBookDefaultStyleUtils.java
  8. 1
      designer-form/src/main/java/com/fr/design/designer/beans/LayoutAdapter.java
  9. 4
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/AbstractLayoutAdapter.java
  10. 1
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRBorderLayoutAdapter.java
  11. 21
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRCardMainBorderLayoutAdapter.java
  12. 2
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java
  13. 8
      designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java
  14. 1
      designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java
  15. 16
      designer-form/src/main/java/com/fr/design/mainframe/DesignerTransferHandler.java
  16. 5
      designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java
  17. 9
      designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java
  18. 2
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/PreviewWidgetBlock.java
  19. 1
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/LocalWidgetRepoPane.java
  20. 14
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/AbstractOnlineWidgetShowPane.java
  21. 34
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetPopupPreviewPane.java
  22. 41
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/PreviewImagePane.java
  23. 59
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/EmbedPane.java
  24. 11
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/OnlineEmbedFilterSelectPane.java
  25. 13
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/OnlineEmbedFilterShowPane.java
  26. 15
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/embed/PreviewDialog.java
  27. 2
      designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java
  28. 2
      designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/layout/UseLayoutAndComponentGuide.java
  29. 29
      designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/theme/DownloadComponentPackageGuide.java
  30. 2
      designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/theme/ThemeToggleGuide.java
  31. 7
      designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java

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

@ -19,6 +19,7 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.locale.impl.ProductImproveMark;
import com.fr.design.login.DesignerLoginType;
import com.fr.design.login.config.DesignerLoginConfigManager;
import com.fr.design.mainframe.ComponentReuseNotifyUtil;
import com.fr.design.mainframe.reuse.ComponentReuseNotificationInfo;
import com.fr.design.mainframe.vcs.VcsConfigManager;
import com.fr.design.notification.SnapChatConfig;
@ -415,6 +416,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private void compatibilityPrevVersion(File prevEnvFile) {
try {
XMLTools.readFileXML(designerEnvManager, prevEnvFile);
clearOldVersionDesignerEnvProperties();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
@ -424,6 +426,11 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
designerEnvManager.saveXMLFile();
}
private void clearOldVersionDesignerEnvProperties() {
SnapChatConfig snapChatConfig = designerEnvManager.getSnapChatConfig();
snapChatConfig.resetRead(ComponentReuseNotifyUtil.COMPONENT_SNAP_CHAT_KEY);
}
public static void setEnvFile(File envFile) {
DesignerEnvManager.envFile = envFile;
}
@ -2332,4 +2339,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
DesignerExiter.getInstance().execute();
}
}
public SnapChatConfig getSnapChatConfig() {
return snapChatConfig;
}
}

42
designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java

@ -25,6 +25,8 @@ import com.fr.plugin.manage.control.PluginTask;
import com.fr.plugin.manage.control.PluginTaskCallback;
import com.fr.plugin.manage.control.PluginTaskResult;
import com.fr.plugin.view.PluginView;
import com.fr.plugin.xml.PluginElementName;
import com.fr.plugin.xml.PluginXmlElement;
import com.fr.stable.StringUtils;
import javax.swing.JOptionPane;
@ -91,15 +93,37 @@ public class PluginOperateUtils {
public static void setPluginActive(String pluginInfo, JSCallback jsCallback) {
PluginMarker pluginMarker = PluginUtils.createPluginMarker(pluginInfo);
PluginContext plugin = PluginManager.getContext(pluginMarker);
boolean active = plugin.isActive();
PluginTaskCallback modifyStatusCallback = new ModifyStatusCallback(active, jsCallback);
if (active) {
PluginManager.getController().forbid(pluginMarker, modifyStatusCallback);
} else {
PluginManager.getController().enable(pluginMarker, modifyStatusCallback);
}
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
PluginMarker pluginMarker = PluginUtils.createPluginMarker(pluginInfo);
PluginContext plugin = PluginManager.getContext(pluginMarker);
boolean active = plugin.isActive();
PluginTaskCallback modifyStatusCallback = new ModifyStatusCallback(active, jsCallback);
if (active) {
PluginXmlElement forbidReminder = plugin.getXml().getElement(PluginElementName.ForbidReminder);
if (forbidReminder != null && forbidReminder.getContent() != null) {
// 禁用前提示
int rv = FineJOptionPane.showConfirmDialog(
null,
forbidReminder.getContent(),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"),
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.WARNING_MESSAGE
);
if (rv == JOptionPane.OK_OPTION) {
PluginManager.getController().forbid(pluginMarker, modifyStatusCallback);
}
} else {
// 正常禁用
PluginManager.getController().forbid(pluginMarker, modifyStatusCallback);
}
} else {
PluginManager.getController().enable(pluginMarker, modifyStatusCallback);
}
}
});
}
public static void uninstallPlugin(final String pluginInfo, final boolean isForce, final JSCallback jsCallback) {

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

@ -12,7 +12,7 @@ import com.fr.design.notification.SnapChatKey;
* Created by kerry on 5/8/21
*/
public class ComponentReuseNotifyUtil {
private static final String COMPONENT_SNAP_CHAT_KEY = "com.fr.component.share-components";
public static final String COMPONENT_SNAP_CHAT_KEY = "com.fr.component.share-components";
private ComponentReuseNotifyUtil() {

18
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java

@ -34,6 +34,7 @@ import com.fr.design.menu.KeySetUtils;
import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef;
import com.fr.design.roleAuthority.RolesAlreadyEditedPane;
import com.fr.design.ui.util.UIUtil;
import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.event.Event;
@ -101,6 +102,23 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
return context.contain(PluginModule.ExtraDesign, ShortCut.TEMPLATE_TREE);
}
});
GeneralContext.listenPluginRunningChanged(new PluginEventListener() {
@Override
public void on(PluginEvent event) {
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
DesignerFrameFileDealerPane.getInstance().refresh();
DesignerFrameFileDealerPane.getInstance().stateChange();
}
});
}
}, new PluginFilter() {
@Override
public boolean accept(PluginContext context) {
return context.contain(PluginModule.ExtraDesign, App.MARK_STRING);
}
});
}
private List<FileToolbarStateChangeListener> otherToolbarStateChangeListeners = new ArrayList<>();

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

@ -7,11 +7,11 @@ import com.fr.base.io.BaseBook;
import com.fr.base.iofile.attr.DesignBanCopyAttrMark;
import com.fr.base.iofile.attr.TemplateIdAttrMark;
import com.fr.base.iofile.attr.TemplateThemeAttrMark;
import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.TemplateThemeCompatible;
import com.fr.base.theme.TemplateThemeConfig;
import com.fr.base.theme.ThemedTemplate;
import com.fr.base.vcs.DesignerMode;
import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.TemplateThemeConfig;
import com.fr.decision.config.FSConfig;
import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignState;
@ -70,14 +70,13 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory;
import com.fr.nx.app.designer.toolbar.TemplateTransformer;
import com.fr.nx.app.designer.utils.CptAndCptxCompatibilityUtil;
import com.fr.nx.app.designer.utils.CptCompileUtil;
import com.fr.nx.cptx.entry.metadata.CptxMetadata;
import com.fr.nx.cptx.utils.CptxFileUtils;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.context.PluginRuntime;
import com.fr.nx.app.designer.toolbar.CompileAction;
import com.fr.nx.app.designer.toolbar.TemplateTransformer;
import com.fr.plugin.injectable.PluginModule;
import com.fr.plugin.manage.PluginFilter;
import com.fr.plugin.observer.PluginEvent;
@ -644,6 +643,16 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
fireSuperTargetModified();
}
public void undoToCurrent() {
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
BaseUndoState current = JTemplate.this.getUndoState();
current.applyState();
}
});
}
/**
* 模板更新
*/

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

@ -9,6 +9,7 @@ import com.fr.stable.xml.XMLableReader;
*/
public class ComponentReuseNotificationInfo implements XMLable {
public static final String XML_TAG = "ComponentReuseNotificationInfo";
private static final int INVALID_NUM = -1;
private static final ComponentReuseNotificationInfo INSTANCE = new ComponentReuseNotificationInfo();
@ -86,6 +87,19 @@ public class ComponentReuseNotificationInfo implements XMLable {
this.historyCreatedReuses = historyCreatedReuses;
}
//兼容老版本云端埋点的记录
public long getLastNotifyTime() {
return INVALID_NUM;
}
public int getNotifiedNumber() {
return INVALID_NUM;
}
public long getLastGuidePopUpTime() {
return INVALID_NUM;
}
@Override
public void readXML(XMLableReader reader) {
this.setClickedWidgetLib(reader.getAttrAsBoolean("clickedWidgetLib", false));

14
designer-base/src/main/java/com/fr/design/utils/gui/AdjustWorkBookDefaultStyleUtils.java

@ -18,6 +18,16 @@ public class AdjustWorkBookDefaultStyleUtils {
private static final Color TEMPLATE_BACKGROUND = new Color(16, 11, 43);
private static final Color CELL_ELEMENT_BORDER = new Color(110, 110, 110);
private static Color currentStoryBack = null;
public static void setCurrentStoryBack(Color color) {
currentStoryBack = color;
}
private static Color getCurrentStoryBack() {
return currentStoryBack == null ? TEMPLATE_BACKGROUND : currentStoryBack;
}
public static void adjustCellElement(CellElement cellElement) {
if (DesignModeContext.isDuchampMode()) {
Style style = cellElement.getStyle();
@ -33,14 +43,14 @@ public class AdjustWorkBookDefaultStyleUtils {
public static void adjustFloatElement(FloatElement floatElement) {
if (DesignModeContext.isDuchampMode()) {
Style style = floatElement.getStyle();
style = style.deriveBackground(ColorBackground.getInstance(TEMPLATE_BACKGROUND));
style = style.deriveBackground(ColorBackground.getInstance(getCurrentStoryBack()));
style = style.deriveFRFont(style.getFRFont().applyForeground(Color.WHITE));
floatElement.setStyle(style);
}
}
public static Color adjustBack(Color color) {
return DesignModeContext.isDuchampMode() ? TEMPLATE_BACKGROUND : color;
return DesignModeContext.isDuchampMode() ? getCurrentStoryBack() : color;
}
/**

1
designer-form/src/main/java/com/fr/design/designer/beans/LayoutAdapter.java

@ -140,5 +140,4 @@ public interface LayoutAdapter {
default void dragOver(XCreator xCreator, SelectionModel selectionModel, int x, int y) {
};
}

4
designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/AbstractLayoutAdapter.java

@ -13,7 +13,7 @@ import com.fr.design.utils.ComponentUtils;
import com.fr.design.utils.gui.LayoutUtils;
import com.fr.general.ComparatorUtils;
import java.awt.*;
import java.awt.LayoutManager;
public abstract class AbstractLayoutAdapter implements LayoutAdapter {
@ -209,6 +209,4 @@ public abstract class AbstractLayoutAdapter implements LayoutAdapter {
selectionModel.removeCreator(xCreator, xCreator.getWidth(), xCreator.getHeight());
selectionModel.setSelectedCreator(container);
}
}

1
designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRBorderLayoutAdapter.java

@ -184,5 +184,4 @@ public class FRBorderLayoutAdapter extends AbstractLayoutAdapter {
public ConstraintsGroupModel getLayoutConstraints(XCreator creator) {
return new FRBorderLayoutConstraints(container, creator);
}
}

21
designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRCardMainBorderLayoutAdapter.java

@ -1,13 +1,15 @@
package com.fr.design.designer.beans.adapters.layout;
import com.fr.design.designer.beans.models.AddingModel;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.cardlayout.XWCardTagLayout;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.form.layout.FRBorderLayout;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.ui.util.UIUtil;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.general.ComparatorUtils;
import java.awt.BorderLayout;
@ -65,18 +67,13 @@ public class FRCardMainBorderLayoutAdapter extends FRBorderLayoutAdapter {
if (minConstraint > value) {
FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Beyond_Tablayout_Bounds"));
JTemplate<?, ?> jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (jt != null && jt.getUndoManager().canUndo()) {
// 自适应布局平分高度导致变矮的场景,优先做撤销
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
jt.undo();
}
});
} else if (container.getBackupBound() != null) {
// 手动拖动导致变矮的场景
container.setSize(container.getBackupBound().getSize());
if (jt != null) {
jt.undoToCurrent();
}
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
AddingModel model = formDesigner.getAddingModel();
model.setAddedIllegal(true);
return true;
} else {
return false;

2
designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java

@ -1243,5 +1243,5 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
public void dragOver(XCreator xCreator, SelectionModel selectionModel,int x, int y) {
frLayoutState.dragOver(xCreator, selectionModel,x,y);
};
}
}

8
designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java

@ -24,6 +24,7 @@ public class AddingModel {
private int currentX;
private int currentY;
private boolean added;
private boolean addedIllegal = false; // 有时候是添加完成了,但是添加会造成某些控件size不合法,例如tab
public AddingModel(FormDesigner designer, XCreator xCreator) {
this.creator = xCreator;
@ -141,4 +142,11 @@ public class AddingModel {
return added;
}
public boolean isAddedIllegal() {
return addedIllegal;
}
public void setAddedIllegal(boolean addedIllegal) {
this.addedIllegal = addedIllegal;
}
}

1
designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java

@ -25,7 +25,6 @@ import com.fr.design.fun.FormWidgetOptionProvider;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelection;
import com.fr.design.mainframe.FormSelectionUtils;
import com.fr.design.mainframe.share.encrypt.clipboard.impl.EncryptSelectionClipboardHandler;
import com.fr.design.utils.ComponentUtils;
import com.fr.design.utils.gui.LayoutUtils;
import com.fr.general.ComparatorUtils;

16
designer-form/src/main/java/com/fr/design/mainframe/DesignerTransferHandler.java

@ -1,12 +1,11 @@
package com.fr.design.mainframe;
import java.awt.datatransfer.Transferable;
import com.fr.design.designer.beans.models.AddingModel;
import com.fr.design.file.HistoryTemplateListPane;
import javax.swing.JComponent;
import javax.swing.TransferHandler;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.beans.models.AddingModel;
import java.awt.datatransfer.Transferable;
public class DesignerTransferHandler extends TransferHandler {
@ -21,7 +20,14 @@ public class DesignerTransferHandler extends TransferHandler {
protected void exportDone(JComponent source, Transferable data, int action) {
if (!addingModel.isCreatorAdded()) {
designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_CUTED);
undoWhenAddingFailed();
}
}
private void undoWhenAddingFailed() {
JTemplate<?, ?> jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (jt != null) {
jt.undoToCurrent();
}
}
}

5
designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java

@ -144,7 +144,10 @@ public class FormCreatorDropTarget extends DropTarget {
designer.getSelectionModel().setSelectedCreators(
FormSelectionUtils.rebuildSelection(xCreator, new Widget[]{widget}));
designer.getEditListenerTable().fireCreatorModified(addingModel.getXCreator(), DesignerEvent.CREATOR_ADDED);
if (!addingModel.isAddedIllegal()) {
designer.getEditListenerTable().fireCreatorModified(addingModel.getXCreator(), DesignerEvent.CREATOR_ADDED);
}
tabDragInner.tryDragIn();
} else {
Toolkit.getDefaultToolkit().beep();
// 拖入失败 取消选中

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

@ -33,6 +33,7 @@ import java.util.List;
* Time: 下午8:18
*/
public class FormWidgetDetailPane extends FormDockView {
private static final int LOCAL_TAB = 0;
private static final int ONLINE_TAB = 1;
private JPanel centerPane;
@ -108,7 +109,7 @@ public class FormWidgetDetailPane extends FormDockView {
cardLayout.show(centerPane, paneList.get(newSelectedIndex).getTitle());
}
};
headGroup.setSelectedIndex(ComponentShareUtil.needSwitch2OnlineTab() ? ONLINE_TAB : 0);
headGroup.setSelectedIndex(ComponentShareUtil.needSwitch2OnlineTab() ? ONLINE_TAB : LOCAL_TAB);
this.add(headGroup, BorderLayout.NORTH);
this.add(centerPane, BorderLayout.CENTER);
}
@ -155,11 +156,11 @@ public class FormWidgetDetailPane extends FormDockView {
}
public void switch2Local() {
cardLayout.show(centerPane, paneList.get(0).getTitle());
headGroup.setSelectedIndex(LOCAL_TAB);
}
public void swich2Online() {
cardLayout.show(centerPane, paneList.get(1).getTitle());
public void switch2Online() {
headGroup.setSelectedIndex(ONLINE_TAB);
}
private UILabel tipLabel(String text) {

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

@ -237,7 +237,7 @@ public abstract class PreviewWidgetBlock<T> extends JPanel implements MouseListe
lastStallTime = System.currentTimeMillis();
Dimension dimension = getCoverDimension();
Rectangle containerRec = new Rectangle(0, 0, dimension.width, dimension.height);
if (!isRightClickPopupMenuVisible()) {
if (!isRightClickPopupMenuVisible() && !FirstDragAnimateStateManager.getInstance().animating()) {
if (containerRec.contains(e.getX(), e.getY())) {
this.showPreviewPane();
} else {

1
designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/LocalWidgetRepoPane.java

@ -92,6 +92,7 @@ public class LocalWidgetRepoPane extends BasicPane {
container.setLayout(new BorderLayout());
updateTipPane = createUpdateTipPane();
updateTipPane.setVisible(false);
container.add(updateTipPane, BorderLayout.NORTH);
updateProgressPane = createUpdateMaskPane();

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

@ -43,6 +43,7 @@ public abstract class AbstractOnlineWidgetShowPane extends JPanel {
protected FilterPane filterPane;
private JPanel centerPane;
private SortTabPane sortTabPane;
private JPanel toolBarPane;
private final JPanel loadingPane = new LoadingPane();
@ -77,10 +78,10 @@ public abstract class AbstractOnlineWidgetShowPane extends JPanel {
FlexSearchFieldPane flexSearchPane = new FlexSearchFieldPane(filterPane);
initSearchTextFieldPaneListener(flexSearchPane);
JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
northPane.add(flexSearchPane, BorderLayout.CENTER);
northPane.add(sortTabPane, BorderLayout.SOUTH);
initNorthPane(jPanel, northPane);
toolBarPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
toolBarPane.add(flexSearchPane, BorderLayout.CENTER);
toolBarPane.add(sortTabPane, BorderLayout.SOUTH);
initNorthPane(jPanel, toolBarPane);
this.searchResultShowPane = initSearchResultShowPane(sharableWidgetProviders);
mainCardLayout = new CardLayout();
@ -93,10 +94,15 @@ public abstract class AbstractOnlineWidgetShowPane extends JPanel {
return jPanel;
}
protected void initNorthPane(JPanel jPanel, JPanel northPane) {
jPanel.add(northPane, BorderLayout.NORTH);
}
public void setToolBarPaneVisible(boolean flag){
this.toolBarPane.setVisible(flag);
}
protected AbstractOnlineWidgetSelectPane createOnlineWidgetSelectPane(OnlineShareWidget[] sharableWidgetProviders) {
return new OnlineWidgetSelectPane(sharableWidgetProviders, filterPane, 50);

34
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetPopupPreviewPane.java

@ -23,11 +23,8 @@ import javax.swing.plaf.basic.BasicLabelUI;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Image;
import java.awt.Toolkit;
/**
* @author Starryi
@ -35,7 +32,7 @@ import java.awt.Toolkit;
* Created by Starryi on 2021/9/14
*/
public class OnlineWidgetPopupPreviewPane extends AbstractWidgetPopupPreviewPane<OnlineShareWidget> {
private static final int POPUP_WIDTH = 412;
public static final int POPUP_WIDTH = 412;
private static final int POPUP_TOP_HEIGHT = 28;
private static final int POPUP_BOTTOM_HEIGHT = 54;
@ -221,33 +218,4 @@ public class OnlineWidgetPopupPreviewPane extends AbstractWidgetPopupPreviewPane
compatibleEnVersionLabel.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Share_Compatible_Designer_Version") + ": " + compatibleEnVersion);
}
private static class PreviewImagePane extends JPanel {
private static final Image DEFAULT_IMAGE = IOUtils.readImage("com/fr/base/images/share/component_error.png");
private static final int PREVIEW_IMAGE_WIDTH = POPUP_WIDTH - 20;
private static final int STANDARD_DPI = 128;
private Image previewImage;
public void setPreviewImage(Image previewImage) {
this.previewImage = previewImage;
if (this.previewImage == null) {
this.previewImage = DEFAULT_IMAGE;
}
int dpi = Toolkit.getDefaultToolkit().getScreenResolution();
int imageWidth = this.previewImage.getWidth(null);
int imageHeight = this.previewImage.getHeight(null);
double imageAspectRatio = (double) imageWidth / imageHeight;
int width = (PREVIEW_IMAGE_WIDTH * dpi) / STANDARD_DPI;
int height = (int) (width / imageAspectRatio);
setPreferredSize(new Dimension(width, height));
}
@Override
public void paint(Graphics g) {
g.drawImage(this.previewImage, 0, 0, getWidth(), getHeight(), null);
}
}
}

41
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/PreviewImagePane.java

@ -0,0 +1,41 @@
package com.fr.design.mainframe.share.ui.online;
import com.fr.general.IOUtils;
import javax.swing.JPanel;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
/**
* Created by kerry on 2021/11/19
*/
public class PreviewImagePane extends JPanel {
private static final Image DEFAULT_IMAGE = IOUtils.readImage("com/fr/base/images/share/component_error.png");
private static final int PREVIEW_IMAGE_WIDTH = OnlineWidgetPopupPreviewPane.POPUP_WIDTH - 20;
private static final int STANDARD_DPI = 128;
private Image previewImage;
public void setPreviewImage(Image previewImage) {
this.previewImage = previewImage;
if (this.previewImage == null) {
this.previewImage = DEFAULT_IMAGE;
}
int dpi = Toolkit.getDefaultToolkit().getScreenResolution();
int imageWidth = this.previewImage.getWidth(null);
int imageHeight = this.previewImage.getHeight(null);
double imageAspectRatio = (double) imageWidth / imageHeight;
int width = (PREVIEW_IMAGE_WIDTH * dpi) / STANDARD_DPI;
int height = (int) (width / imageAspectRatio);
setPreferredSize(new Dimension(width, height));
}
@Override
public void paint(Graphics g) {
g.drawImage(this.previewImage, 0, 0, getWidth(), getHeight(), null);
}
}

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

@ -7,6 +7,7 @@ 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.DesignerContext;
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;
@ -18,10 +19,13 @@ import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.UIManager;
import java.awt.AlphaComposite;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Point;
import java.awt.event.ActionEvent;
@ -41,7 +45,9 @@ 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 static final float DELTA_ALPHA = 0.13F;
private Image image;
private float alpha = 1.0F;
public EmbedPane(OnlineEmbedFilterShowPane showPane) {
this.addMouseListener(new MouseAdapter() {
@ -54,8 +60,7 @@ public class EmbedPane extends JPanel {
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));
jPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 0));
FilterConfigPane filterConfigPane = new FilterConfigPane(OnlineShopUtils.getEmbPaneShowFilterTypeInfos(), false) {
@Override
@ -65,9 +70,9 @@ public class EmbedPane extends JPanel {
};
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 tipPane = getFilterTipPane();
tipPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
jPanel.add(tipPane, BorderLayout.NORTH);
jPanel.add(filterConfigPane, BorderLayout.CENTER);
JPanel southPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
southPane.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 8));
@ -79,6 +84,43 @@ public class EmbedPane extends JPanel {
return jPanel;
}
private JPanel getFilterTipPane() {
String remark = Toolkit.i18nText("Fine-Design_Share_Online_Embed_Filter_Tip");
UILabel label = new UILabel();
label.setSize(new Dimension(212, 30));
//用THML标签进行拼接,以实现自动换行
StringBuilder builder = new StringBuilder("<html>");
char[] chars = remark.toCharArray();
//获取字体计算大小
FontMetrics fontMetrics = label.getFontMetrics(label.getFont());
int start = 0;
int len = 0;
while (start + len < remark.length()) {
while (true) {
len++;
if (start + len > remark.length())
break;
if (fontMetrics.charsWidth(chars, start, len)
> label.getWidth()) {
break;
}
}
builder.append(chars, start, len - 1).append("<br/>");
start = start + len - 1;
len = 0;
}
//拼接剩余部分
builder.append(chars, start, remark.length() - start);
builder.append("</html>");
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
label.setText(builder.toString());
jPanel.add(label);
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() {
@ -86,7 +128,7 @@ public class EmbedPane extends JPanel {
protected void paintBorder(Graphics g, UIButton b) {
Color oldColor = g.getColor();
g.setColor(SEARCH_BUTTON_COLOR);
g.drawRoundRect(0, 0, b.getWidth() - 4, b.getHeight() - 4, 2, 2);
g.drawRoundRect(2, 2, b.getWidth() - 4, b.getHeight() - 4, 2, 2);
g.setColor(oldColor);
}
});
@ -96,7 +138,7 @@ public class EmbedPane extends JPanel {
public void actionPerformed(ActionEvent e) {
String filterStr = filterConfigPane.assembleFilter();
if (StringUtils.isEmpty(filterStr)) {
FineJOptionPane.showMessageDialog(EmbedPane.this,
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Share_Online_Embed_Filter_Warning_Tip"),
Toolkit.i18nText("Fine-Design_Basic_Message"), WARNING_MESSAGE,
UIManager.getIcon("OptionPane.warningIcon"));
@ -134,6 +176,7 @@ public class EmbedPane extends JPanel {
Dimension newDimension = new Dimension(dimension.width - 25, dimension.height - 30);
EmbedPane.this.setSize(newDimension);
EmbedPane.this.setLocation(point.x + 25, 0);
alpha -= DELTA_ALPHA;
});
}, 0, 60, TimeUnit.MILLISECONDS);
@ -141,6 +184,8 @@ public class EmbedPane extends JPanel {
@Override
public void paint(Graphics g) {
AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, Math.max(0, alpha));
((Graphics2D) g).setComposite(composite);
super.paint(g);
if (image != null) {
g.drawImage(image, 0, 0, EmbedPane.this.getWidth(), EmbedPane.this.getHeight(), null);

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

@ -7,9 +7,13 @@ 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.form.share.exception.NetWorkFailedException;
import com.fr.general.http.HttpClient;
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;
@ -22,6 +26,7 @@ import java.awt.Rectangle;
import java.awt.event.AWTEventListener;
import java.awt.event.MouseEvent;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ScheduledExecutorService;
@ -96,6 +101,12 @@ public class OnlineEmbedFilterSelectPane extends AbstractOnlineWidgetSelectPane
}
private Image getPreviewImage(String url) throws NetWorkFailedException {
try {
url = UriUtils.encodePath(url, EncodeConstants.ENCODING_UTF_8);
} catch (UnsupportedEncodingException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return ShareComponentConstants.DEFAULT_COVER;
}
HttpClient httpClient = new HttpClient(url);
httpClient.setTimeout(CAROUSE_IMAGE_LOAD_TIMEOUT);
httpClient.asGet();

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

@ -21,14 +21,23 @@ public class OnlineEmbedFilterShowPane extends JPanel {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
embedPane = new EmbedPane(this);
embedPane.setLocation(10, 0);
embedPane.setSize(228, 273);
this.add(embedPane);
embedPane.setSize(228, embedPane.getPreferredSize().height);
this.add(embedPane, BorderLayout.NORTH);
this.onlineWidgetShowPane = onlineWidgetShowPane;
this.onlineWidgetShowPane.setToolBarPaneVisible(false);
this.add(onlineWidgetShowPane, BorderLayout.CENTER);
}
public void filterStateChanged(String filterStr) {
this.removeAll();
this.add(embedPane);
this.add(onlineWidgetShowPane, BorderLayout.CENTER);
this.validate();
this.doLayout();
this.repaint();
onlineWidgetShowPane.setToolBarPaneVisible(true);
selectPane = onlineWidgetShowPane.animate(filterStr);
}
public void animate(List<WidgetFilterInfo> selectedFilters) throws InterruptedException {

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

@ -1,10 +1,8 @@
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 com.fr.design.mainframe.share.ui.online.PreviewImagePane;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import java.awt.Dimension;
import java.awt.Image;
@ -25,12 +23,13 @@ public class PreviewDialog extends JDialog {
public void setImage(Image image, Point point) {
this.getContentPane().removeAll();
this.getContentPane().add(new UILabel(new ImageIcon(image)));
int width = image.getWidth(null);
this.setSize(width, image.getHeight(null));
this.setLocation(point.x - width, point.y + OFFSET_Y);
PreviewImagePane previewImagePane = new PreviewImagePane();
previewImagePane.setPreviewImage(image);
Dimension dimension = previewImagePane.getPreferredSize();
this.getContentPane().add(previewImagePane);
setSize(new Dimension(dimension.width, dimension.height));
this.setLocation(point.x - dimension.width, point.y + OFFSET_Y);
this.doLayout();
this.validate();
this.repaint();
}

2
designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java

@ -82,7 +82,7 @@ class FormApp extends AbstractAppProvider {
OpenResult<Form, Parameter[]> result = worker.getResult();
if (result != null) {
return (JTemplate<Form, ?>) StableFactory.getMarkedInstanceObjectFromClass(BaseJForm.XML_TAG,
new Object[]{result.getBaseBook(), tplFile, new Parameter[0]}, classType, BaseJForm.class);
new Object[]{result.getBaseBook(), tplFile, result.getRef()}, classType, BaseJForm.class);
}
return emptyForm;
}

2
designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/layout/UseLayoutAndComponentGuide.java

@ -191,7 +191,7 @@ public class UseLayoutAndComponentGuide {
Component component = ComponentUtils.findComponentByName(newFormPane.getWindow().getContentPane(), UIDialog.OK_BUTTON);
if (component != null) {
scene.addClickTarget(component, ClickScene.ClickType.LEFT);
scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_Base_Tip_Click_Confirm"), GuideTip.Direction.TOP);
scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_Base_Tip_Click", Toolkit.i18nText("Fine-Design_Report_OK")), GuideTip.Direction.TOP);
}
return super.prepared();
}

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

@ -29,6 +29,7 @@ import com.fr.design.mainframe.guide.tip.GuideTip;
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.ui.online.widgetpackage.OnlineWidgetPackagesShowPane;
import com.fr.design.mainframe.share.util.DownloadUtils;
import com.fr.design.mainframe.share.util.OnlineShopUtils;
import com.fr.design.utils.ComponentUtils;
@ -102,22 +103,23 @@ public class DownloadComponentPackageGuide {
EastRegionContainerPane.getInstance().showContainer();
EastRegionContainerPane.getInstance().switchTabTo(EastRegionContainerPane.KEY_WIDGET_SETTINGS);
OnlineWidgetRepoPane onlineWidgetRepoPane = OnlineWidgetRepoPane.getInstance();
onlineWidgetRepoPane.setContent();
OnlineWidgetTabPane tabPane = (OnlineWidgetTabPane) ComponentUtils.findComponentByClass(onlineWidgetRepoPane, OnlineWidgetTabPane.class);
UITabGroup tabGroup = (UITabGroup) ComponentUtils.findComponentByClass(tabPane, UITabGroup.class);
JPanel centerPane = (JPanel) tabPane.getComponent(1);
if (centerPane.getComponentCount() > 0) {
Component onlineWidgetPackagesShowPane = ComponentUtils.findComponentByClass(onlineWidgetRepoPane, OnlineWidgetPackagesShowPane.class);
if (onlineWidgetPackagesShowPane != null) {
GuideManager.getInstance().getCurrentGuide().start();
} else {
onlineWidgetRepoPane.setContent();
OnlineWidgetTabPane tabPane = (OnlineWidgetTabPane) ComponentUtils.findComponentByClass(onlineWidgetRepoPane, OnlineWidgetTabPane.class);
JPanel centerPane = (JPanel) tabPane.getComponent(1);
centerPane.addContainerListener(new ContainerAdapter() {
@Override
public void componentAdded(ContainerEvent e) {
GuideManager.getInstance().getCurrentGuide().start();
if (e.getChild() instanceof OnlineWidgetPackagesShowPane) {
GuideManager.getInstance().getCurrentGuide().start();
}
}
});
}
tabGroup.setSelectedIndex(1);
tabGroup.tabChanged(1);
switch2OnlinePackageBlock();
} else {
GuideCreateUtils.showNoNetworkAlert();
GuideManager.getInstance().getCurrentGuide().terminate();
@ -168,7 +170,7 @@ public class DownloadComponentPackageGuide {
@Override
public boolean onComplete() {
FormWidgetDetailPane.getInstance().swich2Online();
FormWidgetDetailPane.getInstance().switch2Online();
return true;
}
});
@ -270,7 +272,7 @@ public class DownloadComponentPackageGuide {
public boolean prepared() {
Component target = ComponentUtils.findComponentByClass(themeConfirmDialog.getContentPane(), UIButton.class);
scene.addClickTarget(target, ClickScene.ClickType.LEFT);
scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_Base_Tip_Click_Confirm"), GuideTip.Direction.BOTTOM);
scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_Base_Tip_Click_Confirm", Toolkit.i18nText("Fine-Design_Basic_Confirm")), GuideTip.Direction.BOTTOM);
return super.prepared();
}
@ -298,4 +300,11 @@ public class DownloadComponentPackageGuide {
themeConfirmDialog.dispose();
}
}
private static void switch2OnlinePackageBlock() {
OnlineWidgetTabPane tabPane = (OnlineWidgetTabPane) ComponentUtils.findComponentByClass(OnlineWidgetRepoPane.getInstance(), OnlineWidgetTabPane.class);
UITabGroup tabGroup = (UITabGroup) ComponentUtils.findComponentByClass(tabPane, UITabGroup.class);
tabGroup.setSelectedIndex(1);
tabGroup.tabChanged(1);
}
}

2
designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/theme/ThemeToggleGuide.java

@ -173,7 +173,7 @@ public class ThemeToggleGuide {
@Override
public boolean prepared() {
scene.addClickTarget(ComponentUtils.findComponentByName(themeDialog, TemplateThemeGridPagesPane.COMPLETE_BUTTON), ClickScene.ClickType.LEFT, true);
scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_Base_Tip_Click_Complete"), BubbleTip.Direction.TOP);
scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_Base_Tip_Click", Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Dialog_Close")), BubbleTip.Direction.TOP);
return true;
}

7
designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java

@ -879,12 +879,7 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
* @param e
*/
public void mouseWheelMoved(MouseWheelEvent e) {
if (!InputEventBaseOnOS.isControlDown(e)) {
ElementCasePane reportPane = grid.getElementCasePane();
if (reportPane.isHorizontalScrollBarVisible()) {
reportPane.getVerticalScrollBar().setValue(reportPane.getVerticalScrollBar().getValue() + e.getWheelRotation() * 3);
}
}
}
/**

Loading…
Cancel
Save