Browse Source

REPORT-51678 组件复用插件代码合并--补充SnapChat相关逻辑

feature/10.0
kuangshuai 4 years ago
parent
commit
53388c1024
  1. 41
      designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java
  2. 167
      designer-base/src/main/java/com/fr/design/mainframe/reuse/ReuseGuideDialog.java
  3. 2
      designer-base/src/main/java/com/fr/design/mainframe/reuse/SnapChatKeys.java
  4. 2
      designer-form/src/main/java/com/fr/design/mainframe/share/util/InstallComponentHelper.java

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

@ -13,8 +13,11 @@ 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.menu.SnapChatUtil;
import com.fr.design.notification.SnapChat;
import com.fr.design.notification.SnapChatFactory;
import com.fr.design.ui.util.UIUtil;
import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.gui.GUICoreUtils;
@ -297,14 +300,20 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
"hyperlink", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_PARA_WIDGET, PropertyMode.REPORT_FLOAT, PropertyMode.POLY, PropertyMode.POLY_CHART},
new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_FLOAT, PropertyMode.FORM_REPORT, PropertyMode.POLY_REPORT});
// 组件库
PropertyItem widgetLib = new PropertyItem(KEY_WIDGET_LIB, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Library"),
"widgetlib", new PropertyMode[]{PropertyMode.FORM},
new PropertyMode[]{PropertyMode.FORM}, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ComponentReuseNotifyUtil.enterWidgetLibExtraAction();
}
});
PropertyItem widgetLib = new PropertyItem(
KEY_WIDGET_LIB,
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Library"),
"widgetlib",
new PropertyMode[]{PropertyMode.FORM},
new PropertyMode[]{PropertyMode.FORM},
getWidgetLibSnapChat(),
getWidgetLibPromptWindow(),
new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ComponentReuseNotifyUtil.enterWidgetLibExtraAction();
}
});
// 权限编辑
PropertyItem authorityEdition = new PropertyItem(KEY_AUTHORITY_EDITION, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Permissions_Edition"),
"authorityedit", new PropertyMode[]{PropertyMode.AUTHORITY_EDITION_DISABLED},
@ -519,6 +528,17 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
propertyItemMap.get(KEY_WIDGET_LIB).replaceContentPane(pane);
}
public SnapChat getWidgetLibSnapChat() {
return SnapChatFactory.createSnapChat(false, SnapChatKeys.COMPONENT);
}
public PromptWindow getWidgetLibPromptWindow() {
if (getWidgetLibSnapChat().hasRead()) {
return new ReuseGuideDialog(DesignerContext.getDesignerFrame());
}
return null;
}
public JComponent getWidgetLibPane() {
return propertyItemMap.get(KEY_WIDGET_LIB).getContentPane();
}
@ -726,11 +746,14 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
this(name, title, btnIconName, ICON_BASE_DIR, visibleModes, enableModes, null, null);
}
public PropertyItem(String name, String title, String btnIconName, PropertyMode[] visibleModes, PropertyMode[] enableModes, SnapChat snapChat, PromptWindow promptWindow, ActionListener actionListener) {
this(name, title, btnIconName, ICON_BASE_DIR, visibleModes, enableModes, snapChat, promptWindow, actionListener);
}
public PropertyItem(String name, String title, String btnIconName, PropertyMode[] visibleModes, PropertyMode[] enableModes, ActionListener actionListener) {
this(name, title, btnIconName, ICON_BASE_DIR, visibleModes, enableModes, null, null, actionListener);
}
public PropertyItem(String name, String title, String btnIconName, String iconBaseDir, PropertyMode[] visibleModes, PropertyMode[] enableModes, SnapChat snapChat, PromptWindow promptWindow) {
this(name, title, btnIconName, iconBaseDir, visibleModes, enableModes, snapChat, promptWindow, null);
}

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

@ -0,0 +1,167 @@
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.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/plugin/form/images/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() {
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/plugin/form/images/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-Plugin_Component_Drag_And_Make_Component"));
UILabel imageLabel = new UILabel(new ImageIcon(IOUtils.readImage("com/fr/plugin/form/images/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-Plugin_Component_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() {
}
}
}

2
designer-form/src/main/java/com/fr/design/mainframe/share/ui/menu/SnapChatKeys.java → designer-base/src/main/java/com/fr/design/mainframe/reuse/SnapChatKeys.java

@ -1,4 +1,4 @@
package com.fr.design.mainframe.share.ui.menu;
package com.fr.design.mainframe.reuse;
import com.fr.design.notification.SnapChatKey;

2
designer-form/src/main/java/com/fr/design/mainframe/share/util/InstallComponentHelper.java

@ -1,6 +1,6 @@
package com.fr.design.mainframe.share.util;
import com.fr.design.mainframe.share.ui.menu.SnapChatKeys;
import com.fr.design.mainframe.reuse.SnapChatKeys;
import com.fr.design.notification.SnapChat;
import com.fr.design.notification.SnapChatFactory;
import com.fr.form.share.constants.ComponentPath;

Loading…
Cancel
Save