From b1a3ee6f1f725c6dfd9329e48fbf32a2d2aed801 Mon Sep 17 00:00:00 2001 From: Harrison Date: Mon, 23 Mar 2020 10:59:47 +0800 Subject: [PATCH 1/7] =?UTF-8?q?REPORT-27647=20=E6=A8=A1=E6=9D=BF=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E7=9A=84=E5=AE=89=E8=A3=85=E4=B8=8B=E8=BD=BD-?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E7=BB=84=E4=BB=B6=E5=A4=8D=E7=94=A8=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=20ui=20=E7=95=8C=E9=9D=A2=201=E3=80=81=20=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E7=BB=84=E4=BB=B6=E5=BA=93=E7=95=8C=E9=9D=A2=202?= =?UTF-8?q?=E3=80=81=20=E5=B0=8F=E5=9C=86=E7=82=B9=E8=AE=BE=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/DesignerEnvManager.java | 25 +- .../fun/ComponentLibraryPaneProcessor.java | 31 ++ ...AbstractComponentLibraryPaneProcessor.java | 25 ++ .../com/fr/design/gui/imenu/UIMenuItem.java | 75 +--- .../com/fr/design/gui/imenu/UIMenuItemUI.java | 81 ++++ .../mainframe/toolbar/ToolBarMenuDock.java | 20 +- .../main/java/com/fr/design/menu/MenuDef.java | 35 +- .../com/fr/design/menu/SnapChatMenuDef.java | 161 +++++++ .../fr/design/menu/SnapChatMenuItemUI.java | 31 ++ .../com/fr/design/menu/SnapChatMenuUI.java | 29 ++ .../fr/design/menu/SnapChatUpdateAction.java | 74 ++++ .../java/com/fr/design/menu/SnapChatUtil.java | 33 ++ .../com/fr/design/notification/SnapChat.java | 28 ++ .../design/notification/SnapChatAllTypes.java | 38 ++ .../design/notification/SnapChatConfig.java | 88 ++++ .../fr/design/notification/SnapChatKey.java | 9 + .../mainframe/FormWidgetDetailPane.java | 391 ++--------------- .../component/ComponentLibraryManager.java | 23 + .../pane/ComponentLibraryPaneCreator.java | 68 +++ .../ComponentLibraryPaneProcessorImpl.java | 412 ++++++++++++++++++ 20 files changed, 1230 insertions(+), 447 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/fun/ComponentLibraryPaneProcessor.java create mode 100644 designer-base/src/main/java/com/fr/design/fun/impl/AbstractComponentLibraryPaneProcessor.java create mode 100644 designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuItemUI.java create mode 100644 designer-base/src/main/java/com/fr/design/menu/SnapChatMenuDef.java create mode 100644 designer-base/src/main/java/com/fr/design/menu/SnapChatMenuItemUI.java create mode 100644 designer-base/src/main/java/com/fr/design/menu/SnapChatMenuUI.java create mode 100644 designer-base/src/main/java/com/fr/design/menu/SnapChatUpdateAction.java create mode 100644 designer-base/src/main/java/com/fr/design/menu/SnapChatUtil.java create mode 100644 designer-base/src/main/java/com/fr/design/notification/SnapChat.java create mode 100644 designer-base/src/main/java/com/fr/design/notification/SnapChatAllTypes.java create mode 100644 designer-base/src/main/java/com/fr/design/notification/SnapChatConfig.java create mode 100644 designer-base/src/main/java/com/fr/design/notification/SnapChatKey.java create mode 100644 designer-form/src/main/java/com/fr/design/mainframe/component/ComponentLibraryManager.java create mode 100644 designer-form/src/main/java/com/fr/design/mainframe/component/pane/ComponentLibraryPaneCreator.java create mode 100644 designer-form/src/main/java/com/fr/design/mainframe/component/pane/ComponentLibraryPaneProcessorImpl.java diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java index cb8634c002..661b4fa5c8 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -16,6 +16,7 @@ import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.locale.impl.ProductImproveMark; import com.fr.design.mainframe.vcs.VcsConfigManager; +import com.fr.design.notification.SnapChatConfig; import com.fr.design.update.push.DesignerPushUpdateConfigManager; import com.fr.design.style.color.ColorSelectConfigManager; import com.fr.design.utils.DesignUtils; @@ -154,6 +155,11 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { * alphafine */ private AlphaFineConfigManager alphaFineConfigManager = AlphaFineConfigManager.getInstance(); + + /** + * 阅后即焚的配置项 + */ + private SnapChatConfig snapChatConfig = SnapChatConfig.getInstance(); private DesignerPushUpdateConfigManager designerPushUpdateConfigManager = DesignerPushUpdateConfigManager.getInstance(); @@ -1548,12 +1554,17 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { readVcsAttr(reader); } else if (DesignerPort.XML_TAG.equals(name)) { readDesignerPort(reader); - } - else { + } else if (name.equals(SnapChatConfig.XML_TAG)) { + readSnapChatConfig(reader); + } else { readLayout(reader, name); } } } + + private void readSnapChatConfig(XMLableReader reader) { + reader.readXMLObject(this.snapChatConfig = SnapChatConfig.getInstance()); + } private void readAlphaFineAttr(XMLableReader reader) { reader.readXMLObject(this.alphaFineConfigManager = AlphaFineConfigManager.getInstance()); @@ -1770,9 +1781,17 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { writeDesignerPushUpdateAttr(writer); writeVcsAttr(writer); writeDesignerPort(writer); + writeSnapChatConfig(writer); writer.end(); } - + + private void writeSnapChatConfig(XMLPrintWriter writer) { + + if (this.snapChatConfig != null) { + this.snapChatConfig.writeXML(writer); + } + } + private void writeAlphaFineAttr(XMLPrintWriter writer) { if (this.alphaFineConfigManager != null) { this.alphaFineConfigManager.writeXML(writer); diff --git a/designer-base/src/main/java/com/fr/design/fun/ComponentLibraryPaneProcessor.java b/designer-base/src/main/java/com/fr/design/fun/ComponentLibraryPaneProcessor.java new file mode 100644 index 0000000000..88385a11b1 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/ComponentLibraryPaneProcessor.java @@ -0,0 +1,31 @@ +package com.fr.design.fun; + +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.mainframe.DockingView; +import com.fr.stable.fun.mark.Immutable; + +import javax.swing.JPanel; + +/** + * created by Harrison on 2020/03/16 + **/ +public interface ComponentLibraryPaneProcessor extends Immutable { + + String XML_TAG = "ParameterExpandablePaneUIProvider"; + + int CURRENT_LEVEL = 1; + + UIScrollPane createShowPanel(boolean isEdit); + + JPanel createMenuNorthPane(); + + UIComboBox createMenuComBox(); + + void parentView(DockingView dockingView); + + void parentPane(JPanel panel); + + void complete(); + +} diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractComponentLibraryPaneProcessor.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractComponentLibraryPaneProcessor.java new file mode 100644 index 0000000000..f376ad7887 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractComponentLibraryPaneProcessor.java @@ -0,0 +1,25 @@ +package com.fr.design.fun.impl; + +import com.fr.design.fun.ComponentLibraryPaneProcessor; +import com.fr.stable.fun.impl.AbstractProvider; +import com.fr.stable.fun.mark.API; +import com.fr.stable.fun.mark.Layer; + +/** + * created by Harrison on 2020/03/16 + **/ +@API(level = ComponentLibraryPaneProcessor.CURRENT_LEVEL) +public abstract class AbstractComponentLibraryPaneProcessor extends AbstractProvider implements ComponentLibraryPaneProcessor { + + @Override + public int currentAPILevel() { + + return ComponentLibraryPaneProcessor.CURRENT_LEVEL; + } + + @Override + public int layerIndex() { + + return Layer.DEFAULT_LAYER_INDEX; + } +} diff --git a/designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuItem.java b/designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuItem.java index 37f1fe0528..3230dbda21 100644 --- a/designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuItem.java +++ b/designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuItem.java @@ -1,15 +1,11 @@ package com.fr.design.gui.imenu; -import java.awt.*; - -import javax.swing.*; -import javax.swing.plaf.basic.BasicMenuItemUI; - import com.fr.design.constants.UIConstants; -import com.fr.stable.Constants; import com.fr.stable.StringUtils; -import com.fr.design.utils.gui.GUIPaintUtils; -import sun.swing.SwingUtilities2; + +import javax.swing.Action; +import javax.swing.Icon; +import javax.swing.JMenuItem; public class UIMenuItem extends JMenuItem{ public UIMenuItem() { @@ -42,66 +38,5 @@ public class UIMenuItem extends JMenuItem{ public String getText() { return StringUtils.BLANK + super.getText(); } - - private class UIMenuItemUI extends BasicMenuItemUI { - @Override - protected void paintBackground(Graphics g, JMenuItem menuItem,Color bgColor) { - if(menuItem.getIcon() == null) { - super.paintBackground(g, menuItem, bgColor); - return; - } - ButtonModel model = menuItem.getModel(); - Color oldColor = g.getColor(); - int menuWidth = menuItem.getWidth(); - int menuHeight = menuItem.getHeight(); - - g.setColor(UIConstants.NORMAL_BACKGROUND); - g.fillRect(0, 0, menuWidth, menuHeight); - if(menuItem.isOpaque()) { - if (model.isArmed()|| (menuItem instanceof JMenu && model.isSelected())) { - GUIPaintUtils.fillPaint((Graphics2D)g, 30, 0, menuWidth - 30, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7); - } else { - GUIPaintUtils.fillPaint((Graphics2D)g, 30, 0, menuWidth - 30, menuHeight, true, Constants.NULL, menuItem.getBackground(), 7); - } - g.setColor(oldColor); - } - else if (model.isArmed() || (menuItem instanceof JMenu && - model.isSelected())) { - GUIPaintUtils.fillPaint((Graphics2D)g, 30, 0, menuWidth - 30, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7); - g.setColor(oldColor); - } - } - - protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { - ButtonModel model = menuItem.getModel(); - FontMetrics fm = SwingUtilities2.getFontMetrics(menuItem, g); - int mnemIndex = menuItem.getDisplayedMnemonicIndex(); - - if(!model.isEnabled()) { - // *** paint the text disabled - if ( UIManager.get("MenuItem.disabledForeground") instanceof Color ) { - g.setColor( UIManager.getColor("MenuItem.disabledForeground") ); - SwingUtilities2.drawStringUnderlineCharAt(menuItem, g,text, - -1, textRect.x, textRect.y + fm.getAscent()); - } else { - g.setColor(menuItem.getBackground().brighter()); - SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, text, - -1, textRect.x, textRect.y + fm.getAscent()); - g.setColor(menuItem.getBackground().darker()); - SwingUtilities2.drawStringUnderlineCharAt(menuItem, g,text, - -1, textRect.x - 1, textRect.y + - fm.getAscent() - 1); - } - } else { - // *** paint the text normally - if (model.isArmed()|| (menuItem instanceof JMenu && model.isSelected())) { - g.setColor(Color.WHITE); // Uses protected field. - } - SwingUtilities2.drawStringUnderlineCharAt(menuItem, g,text, - -1, textRect.x, textRect.y + fm.getAscent()); - } - } - - } - + } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuItemUI.java b/designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuItemUI.java new file mode 100644 index 0000000000..0d883abfbf --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuItemUI.java @@ -0,0 +1,81 @@ +package com.fr.design.gui.imenu; + +import com.fr.design.constants.UIConstants; +import com.fr.design.utils.gui.GUIPaintUtils; +import com.fr.stable.Constants; +import sun.swing.SwingUtilities2; + +import javax.swing.ButtonModel; +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import javax.swing.UIManager; +import javax.swing.plaf.basic.BasicMenuItemUI; +import java.awt.Color; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Rectangle; + +/** + * created by Harrison on 2020/03/22 + **/ +public class UIMenuItemUI extends BasicMenuItemUI { + + @Override + protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) { + if (menuItem.getIcon() == null) { + super.paintBackground(g, menuItem, bgColor); + return; + } + ButtonModel model = menuItem.getModel(); + Color oldColor = g.getColor(); + int menuWidth = menuItem.getWidth(); + int menuHeight = menuItem.getHeight(); + + g.setColor(UIConstants.NORMAL_BACKGROUND); + g.fillRect(0, 0, menuWidth, menuHeight); + if (menuItem.isOpaque()) { + if (model.isArmed() || (menuItem instanceof JMenu && model.isSelected())) { + GUIPaintUtils.fillPaint((Graphics2D) g, 30, 0, menuWidth - 30, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7); + } else { + GUIPaintUtils.fillPaint((Graphics2D) g, 30, 0, menuWidth - 30, menuHeight, true, Constants.NULL, menuItem.getBackground(), 7); + } + g.setColor(oldColor); + } else if (model.isArmed() || (menuItem instanceof JMenu && + model.isSelected())) { + GUIPaintUtils.fillPaint((Graphics2D) g, 30, 0, menuWidth - 30, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7); + g.setColor(oldColor); + } + } + + protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { + ButtonModel model = menuItem.getModel(); + FontMetrics fm = SwingUtilities2.getFontMetrics(menuItem, g); + int mnemIndex = menuItem.getDisplayedMnemonicIndex(); + + if (!model.isEnabled()) { + // *** paint the text disabled + if (UIManager.get("MenuItem.disabledForeground") instanceof Color) { + g.setColor(UIManager.getColor("MenuItem.disabledForeground")); + SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, text, + -1, textRect.x, textRect.y + fm.getAscent()); + } else { + g.setColor(menuItem.getBackground().brighter()); + SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, text, + -1, textRect.x, textRect.y + fm.getAscent()); + g.setColor(menuItem.getBackground().darker()); + SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, text, + -1, textRect.x - 1, textRect.y + + fm.getAscent() - 1); + } + } else { + // *** paint the text normally + if (model.isArmed() || (menuItem instanceof JMenu && model.isSelected())) { + g.setColor(Color.WHITE); // Uses protected field. + } + SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, text, + -1, textRect.x, textRect.y + fm.getAscent()); + } + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index cdafa8c410..bc4b85ced8 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -12,7 +12,6 @@ import com.fr.design.actions.UpdateAction; import com.fr.design.actions.community.BBSAction; import com.fr.design.actions.community.BugAction; import com.fr.design.actions.community.CenterAction; -import com.fr.design.actions.community.CusDemandAction; import com.fr.design.actions.community.FacebookFansAction; import com.fr.design.actions.community.NeedAction; import com.fr.design.actions.community.QuestionAction; @@ -53,7 +52,9 @@ import com.fr.design.mainframe.ToolBarNewTemplatePane; import com.fr.design.menu.MenuDef; import com.fr.design.menu.SeparatorDef; import com.fr.design.menu.ShortCut; +import com.fr.design.menu.SnapChatMenuDef; import com.fr.design.menu.ToolBarDef; +import com.fr.design.notification.SnapChatAllTypes; import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.remote.action.RemoteDesignAuthManagerAction; import com.fr.design.update.actions.SoftwareUpdateAction; @@ -563,15 +564,24 @@ public abstract class ToolBarMenuDock { * @return 社区菜单的子菜单 */ public ShortCut[] createCommunityShortCuts() { + final java.util.List shortCuts = new ArrayList(); shortCuts.add(new BBSAction()); + + shortCuts.add(SeparatorDef.DEFAULT); + shortCuts.add(new VideoAction()); shortCuts.add(new TutorialAction()); shortCuts.add(new QuestionAction()); shortCuts.add(new TechSolutionAction()); + + shortCuts.add(SeparatorDef.DEFAULT); + shortCuts.add(new BugAction()); shortCuts.add(new NeedAction()); - shortCuts.add(new CusDemandAction()); + + shortCuts.add(SeparatorDef.DEFAULT); + shortCuts.add(new CenterAction()); shortCuts.add(new SignAction()); LocaleCenter.buildAction(new LocaleAction() { @@ -594,7 +604,11 @@ public abstract class ToolBarMenuDock { } public MenuDef createCommunityMenuDef() { - MenuDef menuDef = new MenuDef(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Community"), 'C'); + + MenuDef menuDef = new SnapChatMenuDef( + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Community"), + 'C', + SnapChatAllTypes.Menu.BBS); ShortCut[] otherCommunityShortCuts = createCommunityShortCuts(); for (ShortCut shortCut : otherCommunityShortCuts) { menuDef.addShortCut(shortCut); diff --git a/designer-base/src/main/java/com/fr/design/menu/MenuDef.java b/designer-base/src/main/java/com/fr/design/menu/MenuDef.java index c18749c12c..f495e03f13 100644 --- a/designer-base/src/main/java/com/fr/design/menu/MenuDef.java +++ b/designer-base/src/main/java/com/fr/design/menu/MenuDef.java @@ -38,8 +38,8 @@ public class MenuDef extends ShortCut { protected UIMenu createdJMenu; protected UIButton createdButton; protected JPopupMenu popupMenu; - private boolean hasScrollSubMenu; - private boolean isHeadMenu; + protected boolean hasScrollSubMenu; + protected boolean isHeadMenu; private String anchor; @@ -187,18 +187,13 @@ public class MenuDef extends ShortCut { */ public UIMenu createJMenu() { if (createdJMenu == null) { - if (hasScrollSubMenu) { - createdJMenu = new UIScrollMenu(this.getName()); - } else if (isHeadMenu){ - createdJMenu = new UIHeadMenu(this.getName()); - } else { - createdJMenu = new UIMenu(this.getName()); - } + createdJMenu = createJMenu0(); createdJMenu.setMnemonic(this.getMnemonic()); if (this.iconPath != null) { createdJMenu.setIcon(BaseUtils.readIcon(this.iconPath)); } - createdJMenu.addMenuListener(menuDefListener); + MenuListener menuListener = createMenuListener(); + createdJMenu.addMenuListener(menuListener); ContainerListener listener = getContainerListener(); if (listener != null) { createdJMenu.getPopupMenu().addContainerListener(listener); @@ -207,7 +202,20 @@ public class MenuDef extends ShortCut { return createdJMenu; } - + + protected UIMenu createJMenu0() { + + UIMenu createdJMenu; + if (hasScrollSubMenu) { + createdJMenu = new UIScrollMenu(this.getName()); + } else if (isHeadMenu){ + createdJMenu = new UIHeadMenu(this.getName()); + } else { + createdJMenu = new UIMenu(this.getName()); + } + return createdJMenu; + } + protected ContainerListener getContainerListener() { return null; } @@ -377,6 +385,11 @@ public class MenuDef extends ShortCut { public void intoJToolBar(JToolBar toolBar) { toolBar.add(this.createUIButton()); } + + protected MenuListener createMenuListener() { + + return menuDefListener; + } private MenuListener menuDefListener = new MenuListener() { diff --git a/designer-base/src/main/java/com/fr/design/menu/SnapChatMenuDef.java b/designer-base/src/main/java/com/fr/design/menu/SnapChatMenuDef.java new file mode 100644 index 0000000000..473c17f251 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/menu/SnapChatMenuDef.java @@ -0,0 +1,161 @@ +package com.fr.design.menu; + +import com.fr.design.gui.imenu.UIMenu; +import com.fr.design.gui.imenu.UIScrollMenu; +import com.fr.design.notification.SnapChat; +import com.fr.design.notification.SnapChatConfig; +import com.fr.design.notification.SnapChatKey; + +import javax.swing.JMenu; +import javax.swing.event.MenuEvent; +import javax.swing.event.MenuListener; +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.geom.Ellipse2D; +import java.awt.image.BufferedImage; + +/** + * created by Harrison on 2020/03/16 + **/ +public class SnapChatMenuDef extends MenuDef implements SnapChat { + + private SnapChatKey uniqueKey; + private SnapChatMenuUI menuUI = new SnapChatMenuUI(this); + + public SnapChatMenuDef(String name, SnapChatKey uniqueKey) { + super(name); + this.uniqueKey = uniqueKey; + } + + public SnapChatMenuDef(Boolean rePaint, SnapChatKey uniqueKey) { + super(rePaint); + this.uniqueKey = uniqueKey; + } + + public SnapChatMenuDef(String name, char mnemonic, SnapChatKey uniqueKey) { + super(name, mnemonic); + this.uniqueKey = uniqueKey; + } + + @Override + public boolean hasRead() { + + String calcKey = calcKey(); + return SnapChatConfig.getInstance().hasRead(calcKey); + } + + @Override + public void markRead() { + + String calcKey = calcKey(); + SnapChatConfig.getInstance().markRead(calcKey); + } + + @Override + public SnapChatKey key() { + + return this.uniqueKey; + } + + @Override + protected MenuListener createMenuListener() { + + return new SnapChatMenuListener(); + } + + private String calcKey() { + + return key().calc(); + } + + @Override + protected UIMenu createJMenu0() { + + UIMenu createdJMenu; + if (hasScrollSubMenu) { + createdJMenu = new SnapChatUIScrollMenu(this.getName()); + } else if (isHeadMenu){ + createdJMenu = new SnapChatUIHeadMenu(this.getName()); + } else { + createdJMenu = new SnapChatUIMenu(this.getName()); + } + return createdJMenu; + } + + private class SnapChatMenuListener implements MenuListener { + + @Override + public void menuSelected(MenuEvent e) { + + markRead(); + Object source = e.getSource(); + if (!(source instanceof JMenu)) { + return; + } + updateMenu(); + } + + @Override + public void menuDeselected(MenuEvent e) { + + } + + @Override + public void menuCanceled(MenuEvent e) { + + } + } + + private class SnapChatUIScrollMenu extends UIScrollMenu { + + public SnapChatUIScrollMenu(String s) { + super(s); + } + + @Override + public void updateUI() { + setUI(menuUI); + } + } + + private class SnapChatUIMenu extends UIMenu { + + public SnapChatUIMenu(String name) { + + super(name); + } + + @Override + public void updateUI() { + + setUI(menuUI); + } + } + + private class SnapChatUIHeadMenu extends UIMenu { + + public SnapChatUIHeadMenu(String name) { + + super(name); + } + + @Override + public void updateUI() { + + setUI(menuUI); + } + } + + public static void main(String[] args) { + + BufferedImage image = new BufferedImage(16, 16, Image.SCALE_DEFAULT); + Graphics2D g2d = image.createGraphics(); + g2d.setColor(Color.green); + Ellipse2D.Double shape = + new Ellipse2D.Double(2, 2, 1, 1); + g2d.fill(shape); + g2d.draw(shape); + System.out.println(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/menu/SnapChatMenuItemUI.java b/designer-base/src/main/java/com/fr/design/menu/SnapChatMenuItemUI.java new file mode 100644 index 0000000000..c9ab8532d2 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/menu/SnapChatMenuItemUI.java @@ -0,0 +1,31 @@ +package com.fr.design.menu; + +import com.fr.design.gui.imenu.UIMenuItemUI; + +import javax.swing.JMenuItem; +import java.awt.Graphics; +import java.awt.Rectangle; + +/** + * created by Harrison on 2020/03/22 + **/ +class SnapChatMenuItemUI extends UIMenuItemUI { + + private final SnapChatUpdateAction snapChatUpdateAction; + + public SnapChatMenuItemUI(SnapChatUpdateAction snapChatUpdateAction) { + + this.snapChatUpdateAction = snapChatUpdateAction; + } + + @Override + protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { + + super.paintText(g, menuItem, textRect, text); + + if (!snapChatUpdateAction.hasRead()) { + SnapChatUtil.paintSnapChat(g, textRect); + } + } + +} diff --git a/designer-base/src/main/java/com/fr/design/menu/SnapChatMenuUI.java b/designer-base/src/main/java/com/fr/design/menu/SnapChatMenuUI.java new file mode 100644 index 0000000000..47bc3c6634 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/menu/SnapChatMenuUI.java @@ -0,0 +1,29 @@ +package com.fr.design.menu; + +import com.fr.design.gui.imenu.UIMenuUI; + +import javax.swing.JMenuItem; +import java.awt.Graphics; +import java.awt.Rectangle; + +/** + * created by Harrison on 2020/03/22 + **/ +public class SnapChatMenuUI extends UIMenuUI { + + private SnapChatMenuDef menuDef; + + public SnapChatMenuUI(SnapChatMenuDef menuDef) { + this.menuDef = menuDef; + } + + @Override + protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { + + super.paintText(g, menuItem, textRect, text); + + if (!menuDef.hasRead()) { + SnapChatUtil.paintSnapChat(g, textRect); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/menu/SnapChatUpdateAction.java b/designer-base/src/main/java/com/fr/design/menu/SnapChatUpdateAction.java new file mode 100644 index 0000000000..fe1088ea82 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/menu/SnapChatUpdateAction.java @@ -0,0 +1,74 @@ +package com.fr.design.menu; + +import com.fr.design.actions.UpdateAction; +import com.fr.design.gui.imenu.UIMenuItem; +import com.fr.design.notification.SnapChat; +import com.fr.design.notification.SnapChatConfig; +import com.fr.design.notification.SnapChatKey; + +import java.awt.event.ActionEvent; + +/** + * created by Harrison on 2020/03/22 + **/ +public class SnapChatUpdateAction extends UpdateAction implements SnapChat { + + private SnapChatKey uniqueKey; + + public SnapChatUpdateAction(SnapChatKey uniqueKey) { + this.uniqueKey = uniqueKey; + } + + @Override + public void actionPerformed(ActionEvent e) { + + markRead(); + actionPerformed0(e); + } + + protected void actionPerformed0(ActionEvent e) { + + } + + @Override + public boolean hasRead() { + + String calcKey = calcKey(); + return SnapChatConfig.getInstance().hasRead(calcKey); + } + + @Override + public void markRead() { + + String calcKey = calcKey(); + SnapChatConfig.getInstance().markRead(calcKey); + } + + @Override + public SnapChatKey key() { + + return this.uniqueKey; + } + + private String calcKey() { + + return key().calc(); + } + + @Override + public UIMenuItem createMenuItem() { + + Object object = this.getValue(UIMenuItem.class.getName()); + if (object == null && !(object instanceof UIMenuItem)) { + UIMenuItem menuItem = new UIMenuItem(this); + // 设置名字用作单元测 + menuItem.setName(getName()); + menuItem.setUI(new SnapChatMenuItemUI(this)); + object = menuItem; + + this.putValue(UIMenuItem.class.getName(), object); + } + return (UIMenuItem) object; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/menu/SnapChatUtil.java b/designer-base/src/main/java/com/fr/design/menu/SnapChatUtil.java new file mode 100644 index 0000000000..6eb648055a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/menu/SnapChatUtil.java @@ -0,0 +1,33 @@ +package com.fr.design.menu; + +import java.awt.Color; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Rectangle; +import java.awt.geom.Ellipse2D; + +/** + * created by Harrison on 2020/03/22 + **/ +public class SnapChatUtil { + + public static void paintSnapChat(Graphics g, Rectangle textRect) { + + Color oldColor = g.getColor(); + + double x = textRect.getWidth(); + x += textRect.getX(); + x += 2; + + double y = textRect.getY(); + + Graphics2D g2d = (Graphics2D) g; + g2d.setColor(Color.red); + Ellipse2D.Double shape = + new Ellipse2D.Double(x, y, 4, 4); + g2d.fill(shape); + g2d.draw(shape); + + g2d.setColor(oldColor); + } +} diff --git a/designer-base/src/main/java/com/fr/design/notification/SnapChat.java b/designer-base/src/main/java/com/fr/design/notification/SnapChat.java new file mode 100644 index 0000000000..8dd6f8aa28 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/notification/SnapChat.java @@ -0,0 +1,28 @@ +package com.fr.design.notification; + +/** + * 阅后即焚的消息提醒 + * + * created by Harrison on 2020/03/16 + **/ +public interface SnapChat { + + /** + * 已读 + * + * @return 是否为已读 + */ + boolean hasRead(); + + /** + * 标记为已读 + */ + void markRead(); + + /** + * 独一无二的标志 + * + * @return 字符标志 + */ + SnapChatKey key(); +} diff --git a/designer-base/src/main/java/com/fr/design/notification/SnapChatAllTypes.java b/designer-base/src/main/java/com/fr/design/notification/SnapChatAllTypes.java new file mode 100644 index 0000000000..6aeb384df5 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/notification/SnapChatAllTypes.java @@ -0,0 +1,38 @@ +package com.fr.design.notification; + +import com.fr.stable.CommonUtils; + +/** + * created by Harrison on 2020/03/16 + **/ +public abstract class SnapChatAllTypes { + + public enum Menu implements SnapChatKey { + + /** + * 社区按钮 + */ + BBS("BBS"); + + private static final String SIGN = "0001"; + + private String key; + + Menu(String key) { + this.key = key; + } + + public String getKey() { + return key; + } + + @Override + public String calc() { + + return CommonUtils.join( + new String[]{SIGN, getKey()}, "-" + ); + } + } + +} diff --git a/designer-base/src/main/java/com/fr/design/notification/SnapChatConfig.java b/designer-base/src/main/java/com/fr/design/notification/SnapChatConfig.java new file mode 100644 index 0000000000..c9cc177640 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/notification/SnapChatConfig.java @@ -0,0 +1,88 @@ +package com.fr.design.notification; + +import com.fr.stable.xml.XMLPrintWriter; +import com.fr.stable.xml.XMLReadable; +import com.fr.stable.xml.XMLable; +import com.fr.stable.xml.XMLableReader; + +import java.util.HashMap; +import java.util.Map; + +/** + * created by Harrison on 2020/03/16 + **/ +@SuppressWarnings("unchecked") +public class SnapChatConfig implements XMLable { + + public static final String XML_TAG = "SnapChatConfig"; + + /** + * 已经阅读过的属性 + */ + private Map markReadMap = new HashMap<>(8); + + private static final SnapChatConfig INSTANCE = new SnapChatConfig(); + + public static SnapChatConfig getInstance() { + return INSTANCE; + } + + public Boolean hasRead(String key) { + + Map map = markReadMap; + Boolean val = map.get(key); + return val == null ? Boolean.FALSE : val; + } + + public void markRead(String key) { + + markReadMap.put(key, Boolean.TRUE); + } + + @Override + public void readXML(XMLableReader reader) { + + String tagName = reader.getTagName(); + if ("MarkReadMap".equals(tagName)) { + readMarkReadMapXML(reader); + } + } + + @Override + public void writeXML(XMLPrintWriter writer) { + + writer.startTAG(XML_TAG); + writeMarkReadMapXML(writer); + writer.end(); + } + + private void readMarkReadMapXML(XMLableReader reader) { + + reader.readXMLObject(new XMLReadable() { + @Override + public void readXML(XMLableReader reader) { + String tmpVal = reader.getElementValue(); + Boolean markRead = Boolean.valueOf(tmpVal); + markReadMap.put(reader.getAttrAsString("key", ""), markRead); + } + }); + } + + /** + * 写入map + */ + private void writeMarkReadMapXML(XMLPrintWriter writer) { + + writer.startTAG("MarkReadMap"); + for (Map.Entry item : markReadMap.entrySet()) { + writer.startTAG("item").attr("key", item.getKey()).textNode(item.getValue().toString()).end(); + } + writer.end(); + } + + @Override + public Object clone() throws CloneNotSupportedException { + + return null; + } +} diff --git a/designer-base/src/main/java/com/fr/design/notification/SnapChatKey.java b/designer-base/src/main/java/com/fr/design/notification/SnapChatKey.java new file mode 100644 index 0000000000..fa316db350 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/notification/SnapChatKey.java @@ -0,0 +1,9 @@ +package com.fr.design.notification; + +/** + * created by Harrison on 2020/03/16 + **/ +public interface SnapChatKey { + + String calc(); +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java b/designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java index c32abb2ffc..7d00e367c1 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java @@ -1,42 +1,19 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; -import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.icombobox.UIComboBox; -import com.fr.design.gui.icontainer.UIScrollPane; -import com.fr.design.gui.ilable.UILabel; +import com.fr.design.fun.ComponentLibraryPaneProcessor; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.widget.FRWidgetFactory; -import com.fr.form.share.ShareLoader; -import com.fr.form.ui.SharableWidgetBindInfo; -import com.fr.general.CloudCenter; -import com.fr.log.FineLoggerFactory; -import com.fr.share.ShareConstants; -import com.fr.stable.ArrayUtils; -import com.fr.stable.StringUtils; +import com.fr.design.mainframe.component.pane.ComponentLibraryPaneCreator; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.manage.PluginFilter; +import com.fr.plugin.observer.PluginEvent; +import com.fr.plugin.observer.PluginEventListener; +import com.fr.plugin.observer.PluginListenerRegistration; -import javax.swing.BorderFactory; -import javax.swing.DefaultComboBoxModel; import javax.swing.Icon; -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; -import javax.swing.SwingWorker; -import javax.swing.filechooser.FileNameExtensionFilter; import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Desktop; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.io.File; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; /** * Created with IntelliJ IDEA. @@ -45,19 +22,6 @@ import java.net.URISyntaxException; * Time: 下午8:18 */ public class FormWidgetDetailPane extends FormDockView{ - private static final int LOCAL_WIDGET_LABEL_WIDTH = 90; - - private UIScrollPane downPane; - private JPanel reuWidgetPanel; - private UIComboBox comboBox; - private SharableWidgetBindInfo[] elCaseBindInfoList; - private UIButton deleteButton; - private JPanel editPanel; - private JPanel resetPanel; - private JPanel menutPanelNorthPane; - private SwingWorker sw; - //组件面板是否可以编辑 - private boolean isEdit; public static FormWidgetDetailPane getInstance() { if (HOLDER.singleton == null) { @@ -68,6 +32,7 @@ public class FormWidgetDetailPane extends FormDockView{ private FormWidgetDetailPane(){ setLayout(FRGUIPaneFactory.createBorderLayout()); + listenPluginComponentPane(); } @@ -89,350 +54,56 @@ public class FormWidgetDetailPane extends FormDockView{ public Icon getViewIcon() { return BaseUtils.readIcon("/com/fr/design/images/m_report/attributes.png"); } - + /** * 初始化 */ + @Override public void refreshDockingView(){ + FormDesigner designer = this.getEditingFormDesigner(); removeAll(); if(designer == null){ clearDockingView(); return; } - reuWidgetPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); - reuWidgetPanel.setBorder(null); - if (elCaseBindInfoList == null) { - if (sw != null) { - sw.cancel(true); - } - sw = new SwingWorker() { - @Override - protected Object doInBackground() throws Exception { - elCaseBindInfoList = ShareLoader.getLoader().getAllBindInfoList(); - refreshDownPanel(false); - return null; - } - }; - sw.execute(); - } - initReuWidgetPanel(); - initMenuPanel(); - - add(reuWidgetPanel, BorderLayout.CENTER); - - } - - /** - * 初始化组件共享和复用面板 - */ - private void initReuWidgetPanel() { - elCaseBindInfoList = ShareLoader.getLoader().getAllBindInfoList(); - downPane = new UIScrollPane(new ShareWidgetPane(elCaseBindInfoList, false)); - downPane.setBorder(null); - reuWidgetPanel.add(downPane); - } - - /** - * 初始化菜单栏面板 - */ - private void initMenuPanel() { - JPanel menutPanel = new JPanel(); - menutPanel.setLayout(FRGUIPaneFactory.createBorderLayout()); - menutPanel.setBorder(BorderFactory.createEmptyBorder(3, 10, 10, 15)); - - menutPanelNorthPane = new JPanel(new BorderLayout()); - UILabel localWidgetLabel = FRWidgetFactory.createLineWrapLabel( - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Local_Widget"), - LOCAL_WIDGET_LABEL_WIDTH); - menutPanelNorthPane.add(localWidgetLabel, BorderLayout.WEST); - menutPanelNorthPane.add(initEditButtonPane(), BorderLayout.EAST); - menutPanelNorthPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0)); - - menutPanel.add(menutPanelNorthPane, BorderLayout.NORTH); - comboBox = new UIComboBox(getFormCategories()); - comboBox.setPreferredSize(new Dimension(240, comboBox.getPreferredSize().height)); - initComboBoxSelectedListener(); - menutPanel.add(comboBox, BorderLayout.CENTER); - reuWidgetPanel.add(menutPanel, BorderLayout.NORTH); - - } - - /** - * 创建菜单栏按钮面板 - */ - private JPanel initEditButtonPane() { - editPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0)); - - editPanel.add(createRefreshButton()); - editPanel.add(createDownloadButton()); - editPanel.add(createInstallButton()); - editPanel.add(createDeleteButton()); - - return editPanel; + + initComponentPane(); } - - /** - * 创建取消删除面板 - */ - private JPanel initResetButtonPane() { - resetPanel = new JPanel(); - UIButton resetButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Reset")); - resetPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); - resetButton.setBackground(Color.white); - resetButton.setForeground(new Color(0x333334)); - resetButton.addActionListener(new ActionListener() { + + private void listenPluginComponentPane() { + + PluginFilter filter = new PluginFilter() { @Override - public void actionPerformed(ActionEvent e) { - refreshDownPanel(false); - replaceButtonPanel(false); - reuWidgetPanel.remove(deleteButton); + public boolean accept(PluginContext context) { + return context.contain(ComponentLibraryPaneProcessor.XML_TAG); } - }); - - deleteButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Remove_Item")); - deleteButton.setBackground(Color.white); - deleteButton.setForeground(new Color(0xeb1d1f)); - deleteButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - if (ShareLoader.getLoader().removeModulesFromList()) { - refreshShareMoudule(); - reuWidgetPanel.remove(deleteButton); - elCaseBindInfoList = ShareLoader.getLoader().getAllBindInfoList(); - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Share_Module_Removed_Successful")); - refreshDownPanel(false); - replaceButtonPanel(false); - refreshComboxData(); - } else { - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Share_Module_Removed_Failed")); - } - - } - }); - JPanel deletePane = new JPanel(new BorderLayout()); - deletePane.add(deleteButton, BorderLayout.CENTER); - deletePane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); - - resetPanel.setLayout(FRGUIPaneFactory.createBorderLayout()); - resetPanel.add(resetButton, BorderLayout.CENTER); - resetPanel.add(deletePane, BorderLayout.WEST); - - refreshDownPanel(true); - - return resetPanel; - - } - - - private void initComboBoxSelectedListener() { - comboBox.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - ShareLoader.getLoader().resetRemovedModuleList(); - int filterIndex = comboBox.getSelectedIndex(); - if (filterIndex == 0) { - elCaseBindInfoList = ShareLoader.getLoader().getAllBindInfoList(); - } else { - String filterName = comboBox.getSelectedItem().toString(); - elCaseBindInfoList = ShareLoader.getLoader().getFilterBindInfoList(filterName); - } - refreshDownPanel(isEdit); - - } - }); - } - - /** - * 创建工具条按钮 - */ - private UIButton createToolButton(Icon icon, String toolTip, ActionListener actionListener) { - UIButton toolButton = new UIButton(); - toolButton.setIcon(icon); - toolButton.setToolTipText(toolTip); - toolButton.set4ToolbarButton(); - toolButton.addActionListener(actionListener); - return toolButton; - - } - - /** - * 创建刷新按钮 - */ - private UIButton createRefreshButton() { - return createToolButton( - BaseUtils.readIcon("/com/fr/design/form/images/refresh.png"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Refresh"), - new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - if (sw != null) { - sw.cancel(true); - } - sw = new SwingWorker() { - @Override - protected Object doInBackground() throws Exception { - ShareLoader.getLoader().refreshModule(); - elCaseBindInfoList = ShareLoader.getLoader().getAllBindInfoList(); - refreshComboxData(); - refreshDownPanel(false); - return null; - } - }; - sw.execute(); - } - } - ); - } - - private void refreshComboxData() { - comboBox.setSelectedIndex(0); - comboBox.setModel(new DefaultComboBoxModel(getFormCategories())); - } - - /** - * 创建下载模板的按钮 - */ - private UIButton createDownloadButton() { - UIButton downloadButton = new UIButton(); - downloadButton.setIcon(BaseUtils.readIcon("/com/fr/design/form/images/download icon.png")); - downloadButton.set4ToolbarButton(); - downloadButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Download_Template")); - downloadButton.addActionListener(new ActionListener() { + }; + PluginListenerRegistration.getInstance().listenRunningChanged(new PluginEventListener() { @Override - public void actionPerformed(ActionEvent e) { - String url = CloudCenter.getInstance().acquireUrlByKind("reuse.url"); - if (StringUtils.isEmpty(url)) { - FineLoggerFactory.getLogger().info("The URL is empty!"); - return; - } - try { - Desktop.getDesktop().browse(new URI(url)); - } catch (IOException exp) { - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Default_Browser_Duplicate")); - FineLoggerFactory.getLogger().error(exp.getMessage(), exp); - } catch (URISyntaxException exp) { - FineLoggerFactory.getLogger().error(exp.getMessage(), exp); - } catch (Exception exp) { - FineLoggerFactory.getLogger().error(exp.getMessage(), exp); - FineLoggerFactory.getLogger().error("Can not open the browser for URL: " + url); - } - } - }); - return downloadButton; - } - - /** - * 创建安装模板的按钮 - */ - private UIButton createInstallButton() { - return createToolButton( - BaseUtils.readIcon("/com/fr/design/form/images/install icon.png"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Install_Template"), - new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - JFileChooser fileChooser = new JFileChooser(); - fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); - fileChooser.setFileFilter(new FileNameExtensionFilter(".reu", "reu")); - int returnValue = fileChooser.showDialog(new UILabel(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Select")); - if (returnValue == JFileChooser.APPROVE_OPTION) { - final File chosenFile = fileChooser.getSelectedFile(); - installFromDiskZipFile(chosenFile); - } - } - } - ); - } - - /** - * 创建删除模板的按钮 - */ - private UIButton createDeleteButton() { - return createToolButton( - BaseUtils.readIcon("/com/fr/design/form/images/delete icon.png"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Delete_Template"), - new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - replaceButtonPanel(true); - } - } - ); - } - - private void replaceButtonPanel(boolean isEdit) { - this.isEdit = isEdit; - if (isEdit) { - menutPanelNorthPane.remove(editPanel); - menutPanelNorthPane.add(initResetButtonPane(), BorderLayout.EAST); - } else { - menutPanelNorthPane.remove(resetPanel); - menutPanelNorthPane.add(initEditButtonPane(), BorderLayout.EAST); - ShareLoader.getLoader().resetRemovedModuleList(); - } - } - - private void installFromDiskZipFile(File chosenFile) { - if (chosenFile != null && chosenFile.getName().endsWith(ShareConstants.SUFFIX_MODULE)) { - try { - if (ShareLoader.getLoader().installModuleFromDiskZipFile(chosenFile)) { - refreshShareMoudule(); - elCaseBindInfoList = ShareLoader.getLoader().getAllBindInfoList(); - refreshDownPanel(false); - refreshComboxData(); - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Share_Module_OK")); - } else { - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Share_Module_Error")); - } - } catch (IOException e) { - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Share_Module_Error")); - FineLoggerFactory.getLogger().error(e.getMessage(), e); + public void on(PluginEvent event) { + refreshDockingView(); } - } + }, filter); } - - private void refreshShareMoudule() { - try { - ShareLoader.getLoader().refreshModule(); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } - - /** - * 获取报表块组件分类 - */ - public String[] getFormCategories() { - return ArrayUtils.addAll(new String[] {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_AllCategories")}, ShareLoader.getLoader().getModuleCategory()); - } - - public void refreshDownPanel(boolean isEdit) { - reuWidgetPanel.remove(downPane); - downPane = new UIScrollPane(new ShareWidgetPane(elCaseBindInfoList, isEdit)); - downPane.setBorder(null); - reuWidgetPanel.add(downPane); - repaintContainer(); - - } - - public void repaintContainer() { - validate(); - repaint(); - revalidate(); + + private void initComponentPane() { + + ComponentLibraryPaneCreator creator = ComponentLibraryPaneCreator.getNew(); + JPanel componentLibraryPane = creator.create(this); + add(componentLibraryPane, BorderLayout.CENTER); } /** * 清除数据 */ public void clearDockingView() { + JScrollPane psp = new JScrollPane(); psp.setBorder(null); this.add(psp, BorderLayout.CENTER); } - - /** * 定位 * @return 位置 diff --git a/designer-form/src/main/java/com/fr/design/mainframe/component/ComponentLibraryManager.java b/designer-form/src/main/java/com/fr/design/mainframe/component/ComponentLibraryManager.java new file mode 100644 index 0000000000..7cd5e6e825 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/component/ComponentLibraryManager.java @@ -0,0 +1,23 @@ +package com.fr.design.mainframe.component; + +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.fun.ComponentLibraryPaneProcessor; +import com.fr.design.mainframe.component.pane.ComponentLibraryPaneProcessorImpl; + +/** + * created by Harrison on 2020/03/16 + **/ +public class ComponentLibraryManager { + + private static ComponentLibraryPaneProcessor DEFAULT = new ComponentLibraryPaneProcessorImpl(); + + public static ComponentLibraryPaneProcessor selectPaneProcessor() { + + ComponentLibraryPaneProcessor right = ExtraDesignClassManager.getInstance().getSingle(ComponentLibraryPaneProcessor.XML_TAG); + + if (right == null || DEFAULT.layerIndex() > right.layerIndex()) { + right = DEFAULT; + } + return right; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/component/pane/ComponentLibraryPaneCreator.java b/designer-form/src/main/java/com/fr/design/mainframe/component/pane/ComponentLibraryPaneCreator.java new file mode 100644 index 0000000000..97425fdb4f --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/component/pane/ComponentLibraryPaneCreator.java @@ -0,0 +1,68 @@ +package com.fr.design.mainframe.component.pane; + +import com.fr.design.fun.ComponentLibraryPaneProcessor; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.DockingView; +import com.fr.design.mainframe.component.ComponentLibraryManager; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; + +/** + * created by Harrison on 2020/03/22 + **/ +public class ComponentLibraryPaneCreator { + + private ComponentLibraryPaneProcessor processor; + + public ComponentLibraryPaneCreator() { + + processor = ComponentLibraryManager.selectPaneProcessor(); + } + + public static ComponentLibraryPaneCreator getNew() { + + return new ComponentLibraryPaneCreator(); + } + + public JPanel create(DockingView dockingView) { + + JPanel componentLibPanel = createComponentLibPanel(); + processor.parentView(dockingView); + processor.parentPane(componentLibPanel); + + JPanel menuPanel = createMenuPanel(); + componentLibPanel.add(menuPanel, BorderLayout.NORTH); + + UIScrollPane showPane = processor.createShowPanel(false); + componentLibPanel.add(showPane); + return componentLibPanel; + } + + private JPanel createComponentLibPanel() { + + JPanel reuWidgetPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + reuWidgetPanel.setBorder(null); + return reuWidgetPanel; + } + + /** + * 初始化菜单栏面板 + */ + private JPanel createMenuPanel() { + + JPanel menuPanel = new JPanel(); + menuPanel.setLayout(FRGUIPaneFactory.createBorderLayout()); + menuPanel.setBorder(BorderFactory.createEmptyBorder(3, 10, 10, 15)); + + JPanel menuPanelNorthPane = processor.createMenuNorthPane(); + menuPanel.add(menuPanelNorthPane, BorderLayout.NORTH); + + UIComboBox menuPanelComboBox = processor.createMenuComBox(); + menuPanel.add(menuPanelComboBox, BorderLayout.CENTER); + return menuPanel; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/component/pane/ComponentLibraryPaneProcessorImpl.java b/designer-form/src/main/java/com/fr/design/mainframe/component/pane/ComponentLibraryPaneProcessorImpl.java new file mode 100644 index 0000000000..18148ce0d6 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/component/pane/ComponentLibraryPaneProcessorImpl.java @@ -0,0 +1,412 @@ +package com.fr.design.mainframe.component.pane; + +import com.fr.base.BaseUtils; +import com.fr.design.fun.impl.AbstractComponentLibraryPaneProcessor; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.DockingView; +import com.fr.design.mainframe.ShareWidgetPane; +import com.fr.design.widget.FRWidgetFactory; +import com.fr.form.share.ShareLoader; +import com.fr.form.ui.SharableWidgetBindInfo; +import com.fr.general.CloudCenter; +import com.fr.log.FineLoggerFactory; +import com.fr.share.ShareConstants; +import com.fr.stable.ArrayUtils; +import com.fr.stable.StringUtils; + +import javax.swing.BorderFactory; +import javax.swing.DefaultComboBoxModel; +import javax.swing.Icon; +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.SwingWorker; +import javax.swing.filechooser.FileNameExtensionFilter; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Desktop; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; + +/** + * created by Harrison on 2020/03/16 + **/ +public class ComponentLibraryPaneProcessorImpl extends AbstractComponentLibraryPaneProcessor { + + private static final int LOCAL_WIDGET_LABEL_WIDTH = 90; + + private DockingView parentView; + + private SwingWorker sw; + + private JPanel componentLibPane; + private UIScrollPane showPane; + + private UIComboBox menuPanelComboBox; + private JPanel menuPanelNorthPane; + private SharableWidgetBindInfo[] bindInfoArray; + + private UIButton deleteButton; + private JPanel editPanel; + private JPanel resetPanel; + /** + * 组件面板是否可以编辑 + */ + private boolean isEdit; + + public ComponentLibraryPaneProcessorImpl() { + + } + + @Override + public void parentView(DockingView dockingView) { + + parentView = dockingView; + if (bindInfoArray == null) { + if (sw != null) { + sw.cancel(true); + } + sw = new SwingWorker() { + @Override + protected Object doInBackground() throws Exception { + bindInfoArray = ShareLoader.getLoader().getAllBindInfoList(); + refreshShowPanel(false); + return null; + } + }; + sw.execute(); + } + } + + @Override + public void parentPane(JPanel panel) { + this.componentLibPane = panel; + } + + @Override + public void complete() { + + } + + /** + * 初始化组件共享和复用面板 + */ + @Override + public UIScrollPane createShowPanel(boolean isEdit) { + + showPane = new UIScrollPane( + new ShareWidgetPane(bindInfoArray, isEdit) + ); + showPane.setBorder(null); + return showPane; + } + + + @Override + public UIComboBox createMenuComBox() { + + menuPanelComboBox = new UIComboBox(getFormCategories()); + menuPanelComboBox.setPreferredSize(new Dimension(240, menuPanelComboBox.getPreferredSize().height)); + addComboBoxListener(); + return menuPanelComboBox; + } + + private void addComboBoxListener() { + + menuPanelComboBox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + ShareLoader.getLoader().resetRemovedModuleList(); + int filterIndex = menuPanelComboBox.getSelectedIndex(); + if (filterIndex == 0) { + bindInfoArray = ShareLoader.getLoader().getAllBindInfoList(); + } else { + String filterName = menuPanelComboBox.getSelectedItem().toString(); + bindInfoArray = ShareLoader.getLoader().getFilterBindInfoList(filterName); + } + refreshShowPanel(isEdit); + } + }); + } + + @Override + public JPanel createMenuNorthPane() { + + menuPanelNorthPane = new JPanel(new BorderLayout()); + UILabel localWidgetLabel = FRWidgetFactory.createLineWrapLabel( + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Local_Widget"), + LOCAL_WIDGET_LABEL_WIDTH); + menuPanelNorthPane.add(localWidgetLabel, BorderLayout.WEST); + menuPanelNorthPane.add(initEditButtonPane(), BorderLayout.EAST); + menuPanelNorthPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0)); + return menuPanelNorthPane; + + } + + /** + * 创建菜单栏按钮面板 + */ + protected JPanel initEditButtonPane() { + + editPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0)); + + editPanel.add(createRefreshButton()); + editPanel.add(createDownloadButton()); + editPanel.add(createInstallButton()); + editPanel.add(createDeleteButton()); + + return editPanel; + } + + /** + * 创建取消删除面板 + */ + protected JPanel initResetButtonPane() { + + resetPanel = new JPanel(); + UIButton resetButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Reset")); + resetPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); + resetButton.setBackground(Color.white); + resetButton.setForeground(new Color(0x333334)); + resetButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + refreshShowPanel(false); + replaceButtonPanel(false); + componentLibPane.remove(deleteButton); + } + }); + + deleteButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Remove_Item")); + deleteButton.setBackground(Color.white); + deleteButton.setForeground(new Color(0xeb1d1f)); + deleteButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (ShareLoader.getLoader().removeModulesFromList()) { + refreshShareModule(); + componentLibPane.remove(deleteButton); + bindInfoArray = ShareLoader.getLoader().getAllBindInfoList(); + JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Share_Module_Removed_Successful")); + refreshShowPanel(false); + replaceButtonPanel(false); + refreshComboBoxData(); + } else { + JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Share_Module_Removed_Failed")); + } + + } + }); + JPanel deletePane = new JPanel(new BorderLayout()); + deletePane.add(deleteButton, BorderLayout.CENTER); + deletePane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); + + resetPanel.setLayout(FRGUIPaneFactory.createBorderLayout()); + resetPanel.add(resetButton, BorderLayout.CENTER); + resetPanel.add(deletePane, BorderLayout.WEST); + + refreshShowPanel(true); + + return resetPanel; + + } + + + /** + * 创建工具条按钮 + */ + protected UIButton createToolButton(Icon icon, String toolTip, ActionListener actionListener) { + + UIButton toolButton = new UIButton(); + toolButton.setIcon(icon); + toolButton.setToolTipText(toolTip); + toolButton.set4ToolbarButton(); + toolButton.addActionListener(actionListener); + return toolButton; + + } + + /** + * 创建刷新按钮 + */ + protected UIButton createRefreshButton() { + + return createToolButton( + BaseUtils.readIcon("/com/fr/design/form/images/refresh.png"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Refresh"), + new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (sw != null) { + sw.cancel(true); + } + sw = new SwingWorker() { + @Override + protected Object doInBackground() throws Exception { + ShareLoader.getLoader().refreshModule(); + bindInfoArray = ShareLoader.getLoader().getAllBindInfoList(); + refreshComboBoxData(); + refreshShowPanel(false); + return null; + } + }; + sw.execute(); + } + } + ); + } + + /** + * 创建下载模板的按钮 + */ + protected UIButton createDownloadButton() { + UIButton downloadButton = new UIButton(); + downloadButton.setIcon(BaseUtils.readIcon("/com/fr/design/form/images/download icon.png")); + downloadButton.set4ToolbarButton(); + downloadButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Download_Template")); + downloadButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + String url = CloudCenter.getInstance().acquireUrlByKind("reuse.url"); + if (StringUtils.isEmpty(url)) { + FineLoggerFactory.getLogger().info("The URL is empty!"); + return; + } + try { + Desktop.getDesktop().browse(new URI(url)); + } catch (IOException exp) { + JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Default_Browser_Duplicate")); + FineLoggerFactory.getLogger().error(exp.getMessage(), exp); + } catch (URISyntaxException exp) { + FineLoggerFactory.getLogger().error(exp.getMessage(), exp); + } catch (Exception exp) { + FineLoggerFactory.getLogger().error(exp.getMessage(), exp); + FineLoggerFactory.getLogger().error("Can not open the browser for URL: " + url); + } + } + }); + return downloadButton; + } + + /** + * 创建安装模板的按钮 + */ + protected UIButton createInstallButton() { + return createToolButton( + BaseUtils.readIcon("/com/fr/design/form/images/install icon.png"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Install_Template"), + new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); + fileChooser.setFileFilter(new FileNameExtensionFilter(".reu", "reu")); + int returnValue = fileChooser.showDialog(new UILabel(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Select")); + if (returnValue == JFileChooser.APPROVE_OPTION) { + final File chosenFile = fileChooser.getSelectedFile(); + installFromDiskZipFile(chosenFile); + } + } + } + ); + } + + /** + * 创建删除模板的按钮 + */ + protected UIButton createDeleteButton() { + return createToolButton( + BaseUtils.readIcon("/com/fr/design/form/images/delete icon.png"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Delete_Template"), + new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + replaceButtonPanel(true); + } + } + ); + } + + /** + * 获取报表块组件分类 + */ + protected String[] getFormCategories() { + + return ArrayUtils.addAll(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_AllCategories")}, ShareLoader.getLoader().getModuleCategory()); + } + + protected void refreshShowPanel(boolean isEdit) { + + componentLibPane.remove(showPane); + showPane = createShowPanel(isEdit); + componentLibPane.add(showPane); + repaint(); + } + + private void refreshComboBoxData() { + + menuPanelComboBox.setSelectedIndex(0); + menuPanelComboBox.setModel(new DefaultComboBoxModel(getFormCategories())); + } + + private void replaceButtonPanel(boolean isEdit) { + + this.isEdit = isEdit; + if (isEdit) { + menuPanelNorthPane.remove(editPanel); + menuPanelNorthPane.add(initResetButtonPane(), BorderLayout.EAST); + } else { + menuPanelNorthPane.remove(resetPanel); + menuPanelNorthPane.add(initEditButtonPane(), BorderLayout.EAST); + ShareLoader.getLoader().resetRemovedModuleList(); + } + } + + private void installFromDiskZipFile(File chosenFile) { + + if (chosenFile != null && chosenFile.getName().endsWith(ShareConstants.SUFFIX_MODULE)) { + try { + if (ShareLoader.getLoader().installModuleFromDiskZipFile(chosenFile)) { + refreshShareModule(); + bindInfoArray = ShareLoader.getLoader().getAllBindInfoList(); + refreshShowPanel(false); + refreshComboBoxData(); + JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Share_Module_OK")); + } else { + JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Share_Module_Error")); + } + } catch (IOException e) { + JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Share_Module_Error")); + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + } + + private void refreshShareModule() { + try { + ShareLoader.getLoader().refreshModule(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + + public void repaint() { + + parentView.validate(); + parentView.repaint(); + parentView.revalidate(); + } + +} From 1807f814ef3249652778872aa8ee02905d3b92de Mon Sep 17 00:00:00 2001 From: Harrison Date: Mon, 23 Mar 2020 11:06:14 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E5=8E=BB=E6=8E=89=20main=20=E5=87=BD?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/menu/SnapChatMenuDef.java | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/menu/SnapChatMenuDef.java b/designer-base/src/main/java/com/fr/design/menu/SnapChatMenuDef.java index 473c17f251..f3c5735f01 100644 --- a/designer-base/src/main/java/com/fr/design/menu/SnapChatMenuDef.java +++ b/designer-base/src/main/java/com/fr/design/menu/SnapChatMenuDef.java @@ -9,11 +9,6 @@ import com.fr.design.notification.SnapChatKey; import javax.swing.JMenu; import javax.swing.event.MenuEvent; import javax.swing.event.MenuListener; -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.geom.Ellipse2D; -import java.awt.image.BufferedImage; /** * created by Harrison on 2020/03/16 @@ -146,16 +141,4 @@ public class SnapChatMenuDef extends MenuDef implements SnapChat { setUI(menuUI); } } - - public static void main(String[] args) { - - BufferedImage image = new BufferedImage(16, 16, Image.SCALE_DEFAULT); - Graphics2D g2d = image.createGraphics(); - g2d.setColor(Color.green); - Ellipse2D.Double shape = - new Ellipse2D.Double(2, 2, 1, 1); - g2d.fill(shape); - g2d.draw(shape); - System.out.println(); - } } From f279194bba6b963ca30facc4e4c479efca434d83 Mon Sep 17 00:00:00 2001 From: Harrison Date: Mon, 23 Mar 2020 14:12:58 +0800 Subject: [PATCH 3/7] =?UTF-8?q?REPORT-27647=20=E6=A8=A1=E6=9D=BF=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E7=9A=84=E5=AE=89=E8=A3=85=E4=B8=8B=E8=BD=BD-?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E7=BB=84=E4=BB=B6=E5=A4=8D=E7=94=A8=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=201=E3=80=81=E7=A9=BA=E5=AD=97=E7=AC=A6=E4=B8=B2=202?= =?UTF-8?q?=E3=80=81=E5=88=A4=E7=A9=BA=203=E3=80=81=E6=8E=A5=E5=8F=A3=20xm?= =?UTF-8?q?l?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fun/ComponentLibraryPaneProcessor.java | 28 ++++++++++++++++++- .../design/notification/SnapChatConfig.java | 7 +++-- .../pane/ComponentLibraryPaneCreator.java | 8 ++++-- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/fun/ComponentLibraryPaneProcessor.java b/designer-base/src/main/java/com/fr/design/fun/ComponentLibraryPaneProcessor.java index 88385a11b1..7b484b156d 100644 --- a/designer-base/src/main/java/com/fr/design/fun/ComponentLibraryPaneProcessor.java +++ b/designer-base/src/main/java/com/fr/design/fun/ComponentLibraryPaneProcessor.java @@ -8,24 +8,50 @@ import com.fr.stable.fun.mark.Immutable; import javax.swing.JPanel; /** + * 组件库面板处理器 + * * created by Harrison on 2020/03/16 **/ public interface ComponentLibraryPaneProcessor extends Immutable { - String XML_TAG = "ParameterExpandablePaneUIProvider"; + String XML_TAG = "ComponentLibraryPaneProcessor"; int CURRENT_LEVEL = 1; + /** + * 创建展示面板 + * + * @param isEdit 是否可以编辑 + * @return 展示面板 + */ UIScrollPane createShowPanel(boolean isEdit); + /** + * 创建菜单的上部面板 + * + * @return 面板 + */ JPanel createMenuNorthPane(); + /** + * 创建复选框 + * + * @return 复选框 + */ UIComboBox createMenuComBox(); void parentView(DockingView dockingView); + /** + * 父面板 + * + * @param panel 面板 + */ void parentPane(JPanel panel); + /** + * 创建完成 + */ void complete(); } diff --git a/designer-base/src/main/java/com/fr/design/notification/SnapChatConfig.java b/designer-base/src/main/java/com/fr/design/notification/SnapChatConfig.java index c9cc177640..04170e3be8 100644 --- a/designer-base/src/main/java/com/fr/design/notification/SnapChatConfig.java +++ b/designer-base/src/main/java/com/fr/design/notification/SnapChatConfig.java @@ -1,5 +1,6 @@ package com.fr.design.notification; +import com.fr.stable.StringUtils; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLReadable; import com.fr.stable.xml.XMLable; @@ -63,7 +64,7 @@ public class SnapChatConfig implements XMLable { public void readXML(XMLableReader reader) { String tmpVal = reader.getElementValue(); Boolean markRead = Boolean.valueOf(tmpVal); - markReadMap.put(reader.getAttrAsString("key", ""), markRead); + markReadMap.put(reader.getAttrAsString("key", StringUtils.EMPTY), markRead); } }); } @@ -82,7 +83,7 @@ public class SnapChatConfig implements XMLable { @Override public Object clone() throws CloneNotSupportedException { - - return null; + + return super.clone(); } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/component/pane/ComponentLibraryPaneCreator.java b/designer-form/src/main/java/com/fr/design/mainframe/component/pane/ComponentLibraryPaneCreator.java index 97425fdb4f..8cb5d15334 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/component/pane/ComponentLibraryPaneCreator.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/component/pane/ComponentLibraryPaneCreator.java @@ -59,10 +59,14 @@ public class ComponentLibraryPaneCreator { menuPanel.setBorder(BorderFactory.createEmptyBorder(3, 10, 10, 15)); JPanel menuPanelNorthPane = processor.createMenuNorthPane(); - menuPanel.add(menuPanelNorthPane, BorderLayout.NORTH); + if (menuPanelNorthPane != null) { + menuPanel.add(menuPanelNorthPane, BorderLayout.NORTH); + } UIComboBox menuPanelComboBox = processor.createMenuComBox(); - menuPanel.add(menuPanelComboBox, BorderLayout.CENTER); + if (menuPanelComboBox != null) { + menuPanel.add(menuPanelComboBox, BorderLayout.CENTER); + } return menuPanel; } } From 5b0c5dc2998ac3ad2e69bb6a3ee9a0146cab7658 Mon Sep 17 00:00:00 2001 From: Harrison Date: Tue, 24 Mar 2020 14:23:15 +0800 Subject: [PATCH 4/7] =?UTF-8?q?REPORT-27647=20=E6=A8=A1=E6=9D=BF=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E7=9A=84=E5=AE=89=E8=A3=85=E4=B8=8B=E8=BD=BD-?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E7=BB=84=E4=BB=B6=E5=A4=8D=E7=94=A8=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=201=E3=80=81=E6=8A=BD=E5=87=BA=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E6=9B=B4=E9=80=9A=E7=94=A8=E7=9A=84=E6=8E=A5=E5=8F=A3=E6=9D=A5?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=9D=A2=E6=9D=BF=202=E3=80=81=E4=B8=BA?= =?UTF-8?q?=E5=85=B1=E4=BA=AB=E5=8A=A0=E8=BD=BD=E5=99=A8=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/fun/PropertyItemPaneProvider.java | 25 ++ .../AbstractPropertyItemPaneProvider.java | 31 ++ .../mainframe/EastRegionContainerPane.java | 139 +++++- .../com/fr/design/mainframe/PaneHolder.java | 17 + .../fr/design/mainframe/PropertyItemBean.java | 68 +++ .../fr/design/menu/SnapChatUpdateAction.java | 8 +- .../mainframe/FormWidgetDetailPane.java | 392 +++++++++++++++-- .../java/com/fr/design/mainframe/JForm.java | 61 ++- .../component/ComponentLibraryManager.java | 23 - .../pane/ComponentLibraryPaneCreator.java | 72 --- .../ComponentLibraryPaneProcessorImpl.java | 412 ------------------ 11 files changed, 697 insertions(+), 551 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/fun/PropertyItemPaneProvider.java create mode 100644 designer-base/src/main/java/com/fr/design/fun/impl/AbstractPropertyItemPaneProvider.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/PaneHolder.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/PropertyItemBean.java delete mode 100644 designer-form/src/main/java/com/fr/design/mainframe/component/ComponentLibraryManager.java delete mode 100644 designer-form/src/main/java/com/fr/design/mainframe/component/pane/ComponentLibraryPaneCreator.java delete mode 100644 designer-form/src/main/java/com/fr/design/mainframe/component/pane/ComponentLibraryPaneProcessorImpl.java diff --git a/designer-base/src/main/java/com/fr/design/fun/PropertyItemPaneProvider.java b/designer-base/src/main/java/com/fr/design/fun/PropertyItemPaneProvider.java new file mode 100644 index 0000000000..2dbead9ed6 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/PropertyItemPaneProvider.java @@ -0,0 +1,25 @@ +package com.fr.design.fun; + +import com.fr.design.mainframe.PaneHolder; +import com.fr.design.mainframe.PropertyItemBean; +import com.fr.stable.fun.mark.Mutable; +import org.jetbrains.annotations.Nullable; + +/** + * created by Harrison on 2020/03/23 + **/ +public interface PropertyItemPaneProvider extends Mutable { + + int CURRENT_LEVEL = 1; + + String XML_TAG = "PropertyItemPaneProvider"; + + String key(); + + PropertyItemBean getItem(); + + @Nullable + PaneHolder getPaneHolder(Class clazz); + + String replaceKey(); +} diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractPropertyItemPaneProvider.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractPropertyItemPaneProvider.java new file mode 100644 index 0000000000..44e4abd4d1 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractPropertyItemPaneProvider.java @@ -0,0 +1,31 @@ +package com.fr.design.fun.impl; + +import com.fr.design.fun.PropertyItemPaneProvider; +import com.fr.design.mainframe.PaneHolder; +import com.fr.stable.fun.impl.AbstractProvider; +import com.fr.stable.fun.mark.API; + +/** + * created by Harrison on 2020/03/23 + **/ +@API(level = PropertyItemPaneProvider.CURRENT_LEVEL) +public abstract class AbstractPropertyItemPaneProvider extends AbstractProvider implements PropertyItemPaneProvider { + + @Override + public PaneHolder getPaneHolder(Class clazz) { + + if (sign().equals(clazz)) { + return getPathHolder0(); + } + return null; + } + + protected abstract PaneHolder getPathHolder0(); + + protected abstract Class sign(); + + @Override + public int currentAPILevel() { + return PropertyItemPaneProvider.CURRENT_LEVEL; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java index 07191d536d..790c0eb39f 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java @@ -3,7 +3,9 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignerEnvManager; +import com.fr.design.ExtraDesignClassManager; import com.fr.design.constants.UIConstants; +import com.fr.design.fun.PropertyItemPaneProvider; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButtonUI; import com.fr.design.gui.icontainer.UIEastResizableContainer; @@ -12,12 +14,38 @@ import com.fr.design.layout.VerticalFlowLayout; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.general.FRFont; - +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.context.PluginRuntime; +import com.fr.plugin.injectable.PluginModule; +import com.fr.plugin.manage.PluginFilter; +import com.fr.plugin.observer.PluginEvent; +import com.fr.plugin.observer.PluginEventListener; +import com.fr.plugin.observer.PluginEventType; +import com.fr.plugin.observer.PluginListenerRegistration; import com.fr.stable.StringUtils; -import javax.swing.*; +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.SwingConstants; +import javax.swing.SwingUtilities; import javax.swing.border.EmptyBorder; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Color; +import java.awt.Container; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.GraphicsEnvironment; +import java.awt.Image; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; @@ -26,6 +54,7 @@ import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import java.util.HashSet; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import java.util.Set; @@ -101,9 +130,95 @@ public class EastRegionContainerPane extends UIEastResizableContainer { defaultAuthorityPane = getDefaultPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Not_Support_Authority_Edit")); switchMode(PropertyMode.REPORT); setContainerWidth(CONTAINER_WIDTH); + + initPluginPane(); + listenPlugin(); } - + + private void listenPlugin() { + + PluginFilter filter = new PluginFilter() { + @Override + public boolean accept(PluginContext context) { + return context.contain(PropertyItemPaneProvider.XML_TAG); + } + }; + PluginListenerRegistration.getInstance().listen( + PluginEventType.AfterRun, + new PluginEventListener() { + @Override + public void on(PluginEvent event) { + PluginContext context = event.getContext(); + PluginRuntime runtime = context.getRuntime(); + Set providers = runtime.get(PropertyItemPaneProvider.XML_TAG); + for (PropertyItemPaneProvider provider : providers) { + addPropertyItem(provider); + } + updateAllPropertyPane(); + } + }, filter); + PluginListenerRegistration.getInstance().listen( + PluginEventType.BeforeStop, + new PluginEventListener(10) { + @Override + public void on(PluginEvent event) { + PluginContext context = event.getContext(); + PluginRuntime runtime = context.getRuntime(); + Set providers = runtime.get(PropertyItemPaneProvider.XML_TAG); + for (PropertyItemPaneProvider provider : providers) { + removePropertyItem(provider); + + } + updateAllPropertyPane(); + } + }, filter); + } + + private void removePropertyItem(PropertyItemPaneProvider provider) { + + propertyItemMap.remove(provider.key()); + String replaceKey = provider.replaceKey(); + PropertyItem replaceItem = propertyItemMap.get(replaceKey); + if (replaceItem != null) { + replaceItem.setReplace(false); + } + } + + private void initPluginPane() { + + ExtraDesignClassManager classManager = PluginModule.getAgent(PluginModule.ExtraDesign); + Set providers = classManager.getArray(PropertyItemPaneProvider.XML_TAG); + for (PropertyItemPaneProvider provider : providers) { + addPropertyItem(provider); + } + } + + private void addPropertyItem(PropertyItemPaneProvider provider) { + + String key = provider.key(); + PropertyItemBean itemBean = provider.getItem(); + PropertyItem propertyItem = new PropertyItem(itemBean.getName(), + itemBean.getTitle(), + itemBean.getBtnIconName(), + itemBean.getVisibleModes(), + itemBean.getEnableModes()); + UIButton button = propertyItem.getButton(); + List buttonListeners = itemBean.getButtonListeners(); + for (ActionListener buttonListener : buttonListeners) { + button.addActionListener(buttonListener); + } + propertyItemMap.put(key, propertyItem); + + String replaceKey = provider.replaceKey(); + PropertyItem replaceItem = propertyItemMap.get(replaceKey); + if (replaceItem != null) { + replaceItem.setReplace(true); + } + + } + private void initPropertyItemList() { + propertyItemMap = new LinkedHashMap<>(); // 有序map // 单元格元素 PropertyItem cellElement = new PropertyItem(KEY_CELL_ELEMENT, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cell_Element"), @@ -360,6 +475,11 @@ public class EastRegionContainerPane extends UIEastResizableContainer { public void replaceConfiguredRolesPane(JComponent pane) { propertyItemMap.get(KEY_CONFIGURED_ROLES).replaceContentPane(pane); } + + public void replaceKeyPane(String key, JComponent pane) { + + propertyItemMap.get(key).replaceContentPane(pane); + } public JComponent getConfiguredRolesPane() { return propertyItemMap.get(KEY_CONFIGURED_ROLES).getContentPane(); @@ -511,6 +631,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer { private PopupDialog popupDialog; // 弹出框 private boolean isPoppedOut = false; // 是否弹出 private boolean isVisible = true; // 是否可见 + private boolean replace = false; // 是否被替代 private boolean isEnabled = true; // 是否可用 private Set visibleModes; private Set enableModes; @@ -563,13 +684,19 @@ public class EastRegionContainerPane extends UIEastResizableContainer { } public boolean isVisible() { - return isVisible; + // 取决于可见且未替代 + return isVisible && !replace; } public void setVisible(boolean isVisible) { this.isVisible = isVisible; } - + + public void setReplace(boolean replace) { + + this.replace = replace; + } + public boolean isEnabled() { return isEnabled; } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/PaneHolder.java b/designer-base/src/main/java/com/fr/design/mainframe/PaneHolder.java new file mode 100644 index 0000000000..aef5e0b137 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/PaneHolder.java @@ -0,0 +1,17 @@ +package com.fr.design.mainframe; + +import javax.swing.JPanel; + +/** + * created by Harrison on 2020/03/23 + **/ +public interface PaneHolder { + + /** + * 得到 Pane + * + * @param arg 参数 + * @return 面板 + */ + JPanel getInstance(T arg); +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/PropertyItemBean.java b/designer-base/src/main/java/com/fr/design/mainframe/PropertyItemBean.java new file mode 100644 index 0000000000..f6a250defc --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/PropertyItemBean.java @@ -0,0 +1,68 @@ +package com.fr.design.mainframe; + +import java.awt.event.ActionListener; +import java.util.List; + +/** + * created by Harrison on 2020/03/23 + **/ +public class PropertyItemBean { + + private String name; + private String title; + private String btnIconName; + private EastRegionContainerPane.PropertyMode[] visibleModes; + private EastRegionContainerPane.PropertyMode[] enableModes; + private List buttonListeners; + + public PropertyItemBean() { + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getBtnIconName() { + return btnIconName; + } + + public void setBtnIconName(String btnIconName) { + this.btnIconName = btnIconName; + } + + public EastRegionContainerPane.PropertyMode[] getVisibleModes() { + return visibleModes; + } + + public void setVisibleModes(EastRegionContainerPane.PropertyMode[] visibleModes) { + this.visibleModes = visibleModes; + } + + public EastRegionContainerPane.PropertyMode[] getEnableModes() { + return enableModes; + } + + public void setEnableModes(EastRegionContainerPane.PropertyMode[] enableModes) { + this.enableModes = enableModes; + } + + public List getButtonListeners() { + return buttonListeners; + } + + public void setButtonListeners(List buttonListeners) { + this.buttonListeners = buttonListeners; + } +} diff --git a/designer-base/src/main/java/com/fr/design/menu/SnapChatUpdateAction.java b/designer-base/src/main/java/com/fr/design/menu/SnapChatUpdateAction.java index fe1088ea82..4829545468 100644 --- a/designer-base/src/main/java/com/fr/design/menu/SnapChatUpdateAction.java +++ b/designer-base/src/main/java/com/fr/design/menu/SnapChatUpdateAction.java @@ -11,7 +11,7 @@ import java.awt.event.ActionEvent; /** * created by Harrison on 2020/03/22 **/ -public class SnapChatUpdateAction extends UpdateAction implements SnapChat { +public abstract class SnapChatUpdateAction extends UpdateAction implements SnapChat { private SnapChatKey uniqueKey; @@ -20,15 +20,13 @@ public class SnapChatUpdateAction extends UpdateAction implements SnapChat { } @Override - public void actionPerformed(ActionEvent e) { + public final void actionPerformed(ActionEvent e) { markRead(); actionPerformed0(e); } - protected void actionPerformed0(ActionEvent e) { - - } + protected abstract void actionPerformed0(ActionEvent e); @Override public boolean hasRead() { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java b/designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java index 7d00e367c1..f49f2859b2 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java @@ -1,19 +1,43 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; -import com.fr.design.fun.ComponentLibraryPaneProcessor; +import com.fr.base.FRContext; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.mainframe.component.pane.ComponentLibraryPaneCreator; -import com.fr.plugin.context.PluginContext; -import com.fr.plugin.manage.PluginFilter; -import com.fr.plugin.observer.PluginEvent; -import com.fr.plugin.observer.PluginEventListener; -import com.fr.plugin.observer.PluginListenerRegistration; +import com.fr.design.widget.FRWidgetFactory; +import com.fr.form.share.ShareLoader; +import com.fr.form.ui.SharableWidgetBindInfo; +import com.fr.general.CloudCenter; +import com.fr.log.FineLoggerFactory; +import com.fr.share.ShareConstants; +import com.fr.stable.ArrayUtils; +import com.fr.stable.StringUtils; +import javax.swing.BorderFactory; +import javax.swing.DefaultComboBoxModel; import javax.swing.Icon; +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; +import javax.swing.SwingWorker; +import javax.swing.filechooser.FileNameExtensionFilter; import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Desktop; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; /** * Created with IntelliJ IDEA. @@ -22,6 +46,19 @@ import java.awt.BorderLayout; * Time: 下午8:18 */ public class FormWidgetDetailPane extends FormDockView{ + private static final int LOCAL_WIDGET_LABEL_WIDTH = 90; + + private UIScrollPane downPane; + private JPanel reuWidgetPanel; + private UIComboBox comboBox; + private SharableWidgetBindInfo[] elCaseBindInfoList; + private UIButton deleteButton; + private JPanel editPanel; + private JPanel resetPanel; + private JPanel menutPanelNorthPane; + private SwingWorker sw; + //组件面板是否可以编辑 + private boolean isEdit; public static FormWidgetDetailPane getInstance() { if (HOLDER.singleton == null) { @@ -32,7 +69,6 @@ public class FormWidgetDetailPane extends FormDockView{ private FormWidgetDetailPane(){ setLayout(FRGUIPaneFactory.createBorderLayout()); - listenPluginComponentPane(); } @@ -54,56 +90,350 @@ public class FormWidgetDetailPane extends FormDockView{ public Icon getViewIcon() { return BaseUtils.readIcon("/com/fr/design/images/m_report/attributes.png"); } - + /** * 初始化 */ - @Override public void refreshDockingView(){ - FormDesigner designer = this.getEditingFormDesigner(); removeAll(); if(designer == null){ clearDockingView(); return; } - - initComponentPane(); + reuWidgetPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + reuWidgetPanel.setBorder(null); + if (elCaseBindInfoList == null) { + if (sw != null) { + sw.cancel(true); + } + sw = new SwingWorker() { + @Override + protected Object doInBackground() throws Exception { + elCaseBindInfoList = ShareLoader.getLoader().getAllBindInfoList(); + refreshDownPanel(false); + return null; + } + }; + sw.execute(); + } + initReuWidgetPanel(); + initMenuPanel(); + + add(reuWidgetPanel, BorderLayout.CENTER); + + } + + /** + * 初始化组件共享和复用面板 + */ + private void initReuWidgetPanel() { + elCaseBindInfoList = ShareLoader.getLoader().getAllBindInfoList(); + downPane = new UIScrollPane(new ShareWidgetPane(elCaseBindInfoList, false)); + downPane.setBorder(null); + reuWidgetPanel.add(downPane); + } + + /** + * 初始化菜单栏面板 + */ + private void initMenuPanel() { + JPanel menutPanel = new JPanel(); + menutPanel.setLayout(FRGUIPaneFactory.createBorderLayout()); + menutPanel.setBorder(BorderFactory.createEmptyBorder(3, 10, 10, 15)); + + menutPanelNorthPane = new JPanel(new BorderLayout()); + UILabel localWidgetLabel = FRWidgetFactory.createLineWrapLabel( + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Local_Widget"), + LOCAL_WIDGET_LABEL_WIDTH); + menutPanelNorthPane.add(localWidgetLabel, BorderLayout.WEST); + menutPanelNorthPane.add(initEditButtonPane(), BorderLayout.EAST); + menutPanelNorthPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0)); + + menutPanel.add(menutPanelNorthPane, BorderLayout.NORTH); + comboBox = new UIComboBox(getFormCategories()); + comboBox.setPreferredSize(new Dimension(240, comboBox.getPreferredSize().height)); + initComboBoxSelectedListener(); + menutPanel.add(comboBox, BorderLayout.CENTER); + reuWidgetPanel.add(menutPanel, BorderLayout.NORTH); + + } + + /** + * 创建菜单栏按钮面板 + */ + private JPanel initEditButtonPane() { + editPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0)); + + editPanel.add(createRefreshButton()); + editPanel.add(createDownloadButton()); + editPanel.add(createInstallButton()); + editPanel.add(createDeleteButton()); + + return editPanel; } - - private void listenPluginComponentPane() { - - PluginFilter filter = new PluginFilter() { + + /** + * 创建取消删除面板 + */ + private JPanel initResetButtonPane() { + resetPanel = new JPanel(); + UIButton resetButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Reset")); + resetPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); + resetButton.setBackground(Color.white); + resetButton.setForeground(new Color(0x333334)); + resetButton.addActionListener(new ActionListener() { @Override - public boolean accept(PluginContext context) { - return context.contain(ComponentLibraryPaneProcessor.XML_TAG); + public void actionPerformed(ActionEvent e) { + refreshDownPanel(false); + replaceButtonPanel(false); + reuWidgetPanel.remove(deleteButton); } - }; - PluginListenerRegistration.getInstance().listenRunningChanged(new PluginEventListener() { + }); + + deleteButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Remove_Item")); + deleteButton.setBackground(Color.white); + deleteButton.setForeground(new Color(0xeb1d1f)); + deleteButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (ShareLoader.getLoader().removeModulesFromList()) { + refreshShareMoudule(); + reuWidgetPanel.remove(deleteButton); + elCaseBindInfoList = ShareLoader.getLoader().getAllBindInfoList(); + JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Share_Module_Removed_Successful")); + refreshDownPanel(false); + replaceButtonPanel(false); + refreshComboxData(); + } else { + JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Share_Module_Removed_Failed")); + } + + } + }); + JPanel deletePane = new JPanel(new BorderLayout()); + deletePane.add(deleteButton, BorderLayout.CENTER); + deletePane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); + + resetPanel.setLayout(FRGUIPaneFactory.createBorderLayout()); + resetPanel.add(resetButton, BorderLayout.CENTER); + resetPanel.add(deletePane, BorderLayout.WEST); + + refreshDownPanel(true); + + return resetPanel; + + } + + + private void initComboBoxSelectedListener() { + comboBox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + ShareLoader.getLoader().resetRemovedModuleList(); + int filterIndex = comboBox.getSelectedIndex(); + if (filterIndex == 0) { + elCaseBindInfoList = ShareLoader.getLoader().getAllBindInfoList(); + } else { + String filterName = comboBox.getSelectedItem().toString(); + elCaseBindInfoList = ShareLoader.getLoader().getFilterBindInfoList(filterName); + } + refreshDownPanel(isEdit); + + } + }); + } + + /** + * 创建工具条按钮 + */ + private UIButton createToolButton(Icon icon, String toolTip, ActionListener actionListener) { + UIButton toolButton = new UIButton(); + toolButton.setIcon(icon); + toolButton.setToolTipText(toolTip); + toolButton.set4ToolbarButton(); + toolButton.addActionListener(actionListener); + return toolButton; + + } + + /** + * 创建刷新按钮 + */ + private UIButton createRefreshButton() { + return createToolButton( + BaseUtils.readIcon("/com/fr/design/form/images/refresh.png"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Refresh"), + new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (sw != null) { + sw.cancel(true); + } + sw = new SwingWorker() { + @Override + protected Object doInBackground() throws Exception { + ShareLoader.getLoader().refreshModule(); + elCaseBindInfoList = ShareLoader.getLoader().getAllBindInfoList(); + refreshComboxData(); + refreshDownPanel(false); + return null; + } + }; + sw.execute(); + } + } + ); + } + + private void refreshComboxData() { + comboBox.setSelectedIndex(0); + comboBox.setModel(new DefaultComboBoxModel(getFormCategories())); + } + + /** + * 创建下载模板的按钮 + */ + private UIButton createDownloadButton() { + UIButton downloadButton = new UIButton(); + downloadButton.setIcon(BaseUtils.readIcon("/com/fr/design/form/images/download icon.png")); + downloadButton.set4ToolbarButton(); + downloadButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Download_Template")); + downloadButton.addActionListener(new ActionListener() { @Override - public void on(PluginEvent event) { - refreshDockingView(); + public void actionPerformed(ActionEvent e) { + String url = CloudCenter.getInstance().acquireUrlByKind("reuse.url"); + if (StringUtils.isEmpty(url)) { + FRContext.getLogger().info("The URL is empty!"); + return; + } + try { + Desktop.getDesktop().browse(new URI(url)); + } catch (IOException exp) { + JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Default_Browser_Duplicate")); + FineLoggerFactory.getLogger().error(exp.getMessage(), exp); + } catch (URISyntaxException exp) { + FineLoggerFactory.getLogger().error(exp.getMessage(), exp); + } catch (Exception exp) { + FineLoggerFactory.getLogger().error(exp.getMessage(), exp); + FineLoggerFactory.getLogger().error("Can not open the browser for URL: " + url); + } + } + }); + return downloadButton; + } + + /** + * 创建安装模板的按钮 + */ + private UIButton createInstallButton() { + return createToolButton( + BaseUtils.readIcon("/com/fr/design/form/images/install icon.png"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Install_Template"), + new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); + fileChooser.setFileFilter(new FileNameExtensionFilter(".reu", "reu")); + int returnValue = fileChooser.showDialog(new UILabel(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Select")); + if (returnValue == JFileChooser.APPROVE_OPTION) { + final File chosenFile = fileChooser.getSelectedFile(); + installFromDiskZipFile(chosenFile); + } + } + } + ); + } + + /** + * 创建删除模板的按钮 + */ + private UIButton createDeleteButton() { + return createToolButton( + BaseUtils.readIcon("/com/fr/design/form/images/delete icon.png"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Delete_Template"), + new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + replaceButtonPanel(true); + } + } + ); + } + + private void replaceButtonPanel(boolean isEdit) { + this.isEdit = isEdit; + if (isEdit) { + menutPanelNorthPane.remove(editPanel); + menutPanelNorthPane.add(initResetButtonPane(), BorderLayout.EAST); + } else { + menutPanelNorthPane.remove(resetPanel); + menutPanelNorthPane.add(initEditButtonPane(), BorderLayout.EAST); + ShareLoader.getLoader().resetRemovedModuleList(); + } + } + + private void installFromDiskZipFile(File chosenFile) { + if (chosenFile != null && chosenFile.getName().endsWith(ShareConstants.SUFFIX_MODULE)) { + try { + if (ShareLoader.getLoader().installModuleFromDiskZipFile(chosenFile)) { + refreshShareMoudule(); + elCaseBindInfoList = ShareLoader.getLoader().getAllBindInfoList(); + refreshDownPanel(false); + refreshComboxData(); + JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Share_Module_OK")); + } else { + JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Share_Module_Error")); + } + } catch (IOException e) { + JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Share_Module_Error")); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } - }, filter); + } } - - private void initComponentPane() { - - ComponentLibraryPaneCreator creator = ComponentLibraryPaneCreator.getNew(); - JPanel componentLibraryPane = creator.create(this); - add(componentLibraryPane, BorderLayout.CENTER); + + private void refreshShareMoudule() { + try { + ShareLoader.getLoader().refreshModule(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + + /** + * 获取报表块组件分类 + */ + public String[] getFormCategories() { + return ArrayUtils.addAll(new String[] {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_AllCategories")}, ShareLoader.getLoader().getModuleCategory()); + } + + public void refreshDownPanel(boolean isEdit) { + reuWidgetPanel.remove(downPane); + downPane = new UIScrollPane(new ShareWidgetPane(elCaseBindInfoList, isEdit)); + downPane.setBorder(null); + reuWidgetPanel.add(downPane); + repaintContainer(); + + } + + public void repaintContainer() { + validate(); + repaint(); + revalidate(); } /** * 清除数据 */ public void clearDockingView() { - JScrollPane psp = new JScrollPane(); psp.setBorder(null); this.add(psp, BorderLayout.CENTER); } + + /** * 定位 * @return 位置 diff --git a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java index ab19002c18..74c14a6046 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java @@ -6,6 +6,7 @@ import com.fr.base.Parameter; import com.fr.base.extension.FileExtension; import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignState; +import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.FormMobileAttrAction; import com.fr.design.actions.TemplateParameterAction; import com.fr.design.actions.core.WorkBookSupportable; @@ -29,6 +30,7 @@ import com.fr.design.designer.properties.FormWidgetAuthorityEditPane; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; import com.fr.design.fun.PreviewProvider; +import com.fr.design.fun.PropertyItemPaneProvider; import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; import com.fr.design.gui.ilable.UILabel; @@ -65,6 +67,14 @@ import com.fr.form.ui.container.WLayout; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; import com.fr.page.PaperSettingProvider; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.context.PluginRuntime; +import com.fr.plugin.injectable.PluginModule; +import com.fr.plugin.manage.PluginFilter; +import com.fr.plugin.observer.PluginEvent; +import com.fr.plugin.observer.PluginEventListener; +import com.fr.plugin.observer.PluginEventType; +import com.fr.plugin.observer.PluginListenerRegistration; import com.fr.report.cell.Elem; import com.fr.report.cell.cellattr.CellImage; import com.fr.report.worksheet.FormElementCase; @@ -91,6 +101,7 @@ import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Set; public class JForm extends JTemplate implements BaseJForm
{ private static final String FORM_CARD = "FORM"; @@ -116,12 +127,58 @@ public class JForm extends JTemplate implements BaseJForm providers = runtime.get(PropertyItemPaneProvider.XML_TAG); + for (PropertyItemPaneProvider provider : providers) { + addPane(provider); + } + } + }, filter); + } + + private void initPluginPane() { + + ExtraDesignClassManager classManager = PluginModule.getAgent(PluginModule.ExtraDesign); + Set providers = classManager.getArray(PropertyItemPaneProvider.XML_TAG); + for (PropertyItemPaneProvider provider : providers) { + addPane(provider); + } } - + + private void addPane(PropertyItemPaneProvider provider) { + + PaneHolder holder = provider.getPaneHolder(FormDesigner.class); + if (holder != null) { + JPanel panel = holder.getInstance(formDesign); + EastRegionContainerPane.getInstance().replaceKeyPane(provider.key(), panel); + } + } + @Override public void refreshEastPropertiesPane() { // 暂时用不到,遇到的时候再加刷新右侧tab面板的代码 @@ -765,7 +822,7 @@ public class JForm extends JTemplate implements BaseJForm right.layerIndex()) { - right = DEFAULT; - } - return right; - } -} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/component/pane/ComponentLibraryPaneCreator.java b/designer-form/src/main/java/com/fr/design/mainframe/component/pane/ComponentLibraryPaneCreator.java deleted file mode 100644 index 8cb5d15334..0000000000 --- a/designer-form/src/main/java/com/fr/design/mainframe/component/pane/ComponentLibraryPaneCreator.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.fr.design.mainframe.component.pane; - -import com.fr.design.fun.ComponentLibraryPaneProcessor; -import com.fr.design.gui.icombobox.UIComboBox; -import com.fr.design.gui.icontainer.UIScrollPane; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.mainframe.DockingView; -import com.fr.design.mainframe.component.ComponentLibraryManager; - -import javax.swing.BorderFactory; -import javax.swing.JPanel; -import java.awt.BorderLayout; - -/** - * created by Harrison on 2020/03/22 - **/ -public class ComponentLibraryPaneCreator { - - private ComponentLibraryPaneProcessor processor; - - public ComponentLibraryPaneCreator() { - - processor = ComponentLibraryManager.selectPaneProcessor(); - } - - public static ComponentLibraryPaneCreator getNew() { - - return new ComponentLibraryPaneCreator(); - } - - public JPanel create(DockingView dockingView) { - - JPanel componentLibPanel = createComponentLibPanel(); - processor.parentView(dockingView); - processor.parentPane(componentLibPanel); - - JPanel menuPanel = createMenuPanel(); - componentLibPanel.add(menuPanel, BorderLayout.NORTH); - - UIScrollPane showPane = processor.createShowPanel(false); - componentLibPanel.add(showPane); - return componentLibPanel; - } - - private JPanel createComponentLibPanel() { - - JPanel reuWidgetPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); - reuWidgetPanel.setBorder(null); - return reuWidgetPanel; - } - - /** - * 初始化菜单栏面板 - */ - private JPanel createMenuPanel() { - - JPanel menuPanel = new JPanel(); - menuPanel.setLayout(FRGUIPaneFactory.createBorderLayout()); - menuPanel.setBorder(BorderFactory.createEmptyBorder(3, 10, 10, 15)); - - JPanel menuPanelNorthPane = processor.createMenuNorthPane(); - if (menuPanelNorthPane != null) { - menuPanel.add(menuPanelNorthPane, BorderLayout.NORTH); - } - - UIComboBox menuPanelComboBox = processor.createMenuComBox(); - if (menuPanelComboBox != null) { - menuPanel.add(menuPanelComboBox, BorderLayout.CENTER); - } - return menuPanel; - } -} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/component/pane/ComponentLibraryPaneProcessorImpl.java b/designer-form/src/main/java/com/fr/design/mainframe/component/pane/ComponentLibraryPaneProcessorImpl.java deleted file mode 100644 index 18148ce0d6..0000000000 --- a/designer-form/src/main/java/com/fr/design/mainframe/component/pane/ComponentLibraryPaneProcessorImpl.java +++ /dev/null @@ -1,412 +0,0 @@ -package com.fr.design.mainframe.component.pane; - -import com.fr.base.BaseUtils; -import com.fr.design.fun.impl.AbstractComponentLibraryPaneProcessor; -import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.icombobox.UIComboBox; -import com.fr.design.gui.icontainer.UIScrollPane; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.mainframe.DockingView; -import com.fr.design.mainframe.ShareWidgetPane; -import com.fr.design.widget.FRWidgetFactory; -import com.fr.form.share.ShareLoader; -import com.fr.form.ui.SharableWidgetBindInfo; -import com.fr.general.CloudCenter; -import com.fr.log.FineLoggerFactory; -import com.fr.share.ShareConstants; -import com.fr.stable.ArrayUtils; -import com.fr.stable.StringUtils; - -import javax.swing.BorderFactory; -import javax.swing.DefaultComboBoxModel; -import javax.swing.Icon; -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.SwingWorker; -import javax.swing.filechooser.FileNameExtensionFilter; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Desktop; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.io.File; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; - -/** - * created by Harrison on 2020/03/16 - **/ -public class ComponentLibraryPaneProcessorImpl extends AbstractComponentLibraryPaneProcessor { - - private static final int LOCAL_WIDGET_LABEL_WIDTH = 90; - - private DockingView parentView; - - private SwingWorker sw; - - private JPanel componentLibPane; - private UIScrollPane showPane; - - private UIComboBox menuPanelComboBox; - private JPanel menuPanelNorthPane; - private SharableWidgetBindInfo[] bindInfoArray; - - private UIButton deleteButton; - private JPanel editPanel; - private JPanel resetPanel; - /** - * 组件面板是否可以编辑 - */ - private boolean isEdit; - - public ComponentLibraryPaneProcessorImpl() { - - } - - @Override - public void parentView(DockingView dockingView) { - - parentView = dockingView; - if (bindInfoArray == null) { - if (sw != null) { - sw.cancel(true); - } - sw = new SwingWorker() { - @Override - protected Object doInBackground() throws Exception { - bindInfoArray = ShareLoader.getLoader().getAllBindInfoList(); - refreshShowPanel(false); - return null; - } - }; - sw.execute(); - } - } - - @Override - public void parentPane(JPanel panel) { - this.componentLibPane = panel; - } - - @Override - public void complete() { - - } - - /** - * 初始化组件共享和复用面板 - */ - @Override - public UIScrollPane createShowPanel(boolean isEdit) { - - showPane = new UIScrollPane( - new ShareWidgetPane(bindInfoArray, isEdit) - ); - showPane.setBorder(null); - return showPane; - } - - - @Override - public UIComboBox createMenuComBox() { - - menuPanelComboBox = new UIComboBox(getFormCategories()); - menuPanelComboBox.setPreferredSize(new Dimension(240, menuPanelComboBox.getPreferredSize().height)); - addComboBoxListener(); - return menuPanelComboBox; - } - - private void addComboBoxListener() { - - menuPanelComboBox.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - ShareLoader.getLoader().resetRemovedModuleList(); - int filterIndex = menuPanelComboBox.getSelectedIndex(); - if (filterIndex == 0) { - bindInfoArray = ShareLoader.getLoader().getAllBindInfoList(); - } else { - String filterName = menuPanelComboBox.getSelectedItem().toString(); - bindInfoArray = ShareLoader.getLoader().getFilterBindInfoList(filterName); - } - refreshShowPanel(isEdit); - } - }); - } - - @Override - public JPanel createMenuNorthPane() { - - menuPanelNorthPane = new JPanel(new BorderLayout()); - UILabel localWidgetLabel = FRWidgetFactory.createLineWrapLabel( - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Local_Widget"), - LOCAL_WIDGET_LABEL_WIDTH); - menuPanelNorthPane.add(localWidgetLabel, BorderLayout.WEST); - menuPanelNorthPane.add(initEditButtonPane(), BorderLayout.EAST); - menuPanelNorthPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0)); - return menuPanelNorthPane; - - } - - /** - * 创建菜单栏按钮面板 - */ - protected JPanel initEditButtonPane() { - - editPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0)); - - editPanel.add(createRefreshButton()); - editPanel.add(createDownloadButton()); - editPanel.add(createInstallButton()); - editPanel.add(createDeleteButton()); - - return editPanel; - } - - /** - * 创建取消删除面板 - */ - protected JPanel initResetButtonPane() { - - resetPanel = new JPanel(); - UIButton resetButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Reset")); - resetPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); - resetButton.setBackground(Color.white); - resetButton.setForeground(new Color(0x333334)); - resetButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - refreshShowPanel(false); - replaceButtonPanel(false); - componentLibPane.remove(deleteButton); - } - }); - - deleteButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Remove_Item")); - deleteButton.setBackground(Color.white); - deleteButton.setForeground(new Color(0xeb1d1f)); - deleteButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - if (ShareLoader.getLoader().removeModulesFromList()) { - refreshShareModule(); - componentLibPane.remove(deleteButton); - bindInfoArray = ShareLoader.getLoader().getAllBindInfoList(); - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Share_Module_Removed_Successful")); - refreshShowPanel(false); - replaceButtonPanel(false); - refreshComboBoxData(); - } else { - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Share_Module_Removed_Failed")); - } - - } - }); - JPanel deletePane = new JPanel(new BorderLayout()); - deletePane.add(deleteButton, BorderLayout.CENTER); - deletePane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); - - resetPanel.setLayout(FRGUIPaneFactory.createBorderLayout()); - resetPanel.add(resetButton, BorderLayout.CENTER); - resetPanel.add(deletePane, BorderLayout.WEST); - - refreshShowPanel(true); - - return resetPanel; - - } - - - /** - * 创建工具条按钮 - */ - protected UIButton createToolButton(Icon icon, String toolTip, ActionListener actionListener) { - - UIButton toolButton = new UIButton(); - toolButton.setIcon(icon); - toolButton.setToolTipText(toolTip); - toolButton.set4ToolbarButton(); - toolButton.addActionListener(actionListener); - return toolButton; - - } - - /** - * 创建刷新按钮 - */ - protected UIButton createRefreshButton() { - - return createToolButton( - BaseUtils.readIcon("/com/fr/design/form/images/refresh.png"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Refresh"), - new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - if (sw != null) { - sw.cancel(true); - } - sw = new SwingWorker() { - @Override - protected Object doInBackground() throws Exception { - ShareLoader.getLoader().refreshModule(); - bindInfoArray = ShareLoader.getLoader().getAllBindInfoList(); - refreshComboBoxData(); - refreshShowPanel(false); - return null; - } - }; - sw.execute(); - } - } - ); - } - - /** - * 创建下载模板的按钮 - */ - protected UIButton createDownloadButton() { - UIButton downloadButton = new UIButton(); - downloadButton.setIcon(BaseUtils.readIcon("/com/fr/design/form/images/download icon.png")); - downloadButton.set4ToolbarButton(); - downloadButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Download_Template")); - downloadButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - String url = CloudCenter.getInstance().acquireUrlByKind("reuse.url"); - if (StringUtils.isEmpty(url)) { - FineLoggerFactory.getLogger().info("The URL is empty!"); - return; - } - try { - Desktop.getDesktop().browse(new URI(url)); - } catch (IOException exp) { - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Default_Browser_Duplicate")); - FineLoggerFactory.getLogger().error(exp.getMessage(), exp); - } catch (URISyntaxException exp) { - FineLoggerFactory.getLogger().error(exp.getMessage(), exp); - } catch (Exception exp) { - FineLoggerFactory.getLogger().error(exp.getMessage(), exp); - FineLoggerFactory.getLogger().error("Can not open the browser for URL: " + url); - } - } - }); - return downloadButton; - } - - /** - * 创建安装模板的按钮 - */ - protected UIButton createInstallButton() { - return createToolButton( - BaseUtils.readIcon("/com/fr/design/form/images/install icon.png"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Install_Template"), - new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - JFileChooser fileChooser = new JFileChooser(); - fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); - fileChooser.setFileFilter(new FileNameExtensionFilter(".reu", "reu")); - int returnValue = fileChooser.showDialog(new UILabel(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Select")); - if (returnValue == JFileChooser.APPROVE_OPTION) { - final File chosenFile = fileChooser.getSelectedFile(); - installFromDiskZipFile(chosenFile); - } - } - } - ); - } - - /** - * 创建删除模板的按钮 - */ - protected UIButton createDeleteButton() { - return createToolButton( - BaseUtils.readIcon("/com/fr/design/form/images/delete icon.png"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Delete_Template"), - new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - replaceButtonPanel(true); - } - } - ); - } - - /** - * 获取报表块组件分类 - */ - protected String[] getFormCategories() { - - return ArrayUtils.addAll(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_AllCategories")}, ShareLoader.getLoader().getModuleCategory()); - } - - protected void refreshShowPanel(boolean isEdit) { - - componentLibPane.remove(showPane); - showPane = createShowPanel(isEdit); - componentLibPane.add(showPane); - repaint(); - } - - private void refreshComboBoxData() { - - menuPanelComboBox.setSelectedIndex(0); - menuPanelComboBox.setModel(new DefaultComboBoxModel(getFormCategories())); - } - - private void replaceButtonPanel(boolean isEdit) { - - this.isEdit = isEdit; - if (isEdit) { - menuPanelNorthPane.remove(editPanel); - menuPanelNorthPane.add(initResetButtonPane(), BorderLayout.EAST); - } else { - menuPanelNorthPane.remove(resetPanel); - menuPanelNorthPane.add(initEditButtonPane(), BorderLayout.EAST); - ShareLoader.getLoader().resetRemovedModuleList(); - } - } - - private void installFromDiskZipFile(File chosenFile) { - - if (chosenFile != null && chosenFile.getName().endsWith(ShareConstants.SUFFIX_MODULE)) { - try { - if (ShareLoader.getLoader().installModuleFromDiskZipFile(chosenFile)) { - refreshShareModule(); - bindInfoArray = ShareLoader.getLoader().getAllBindInfoList(); - refreshShowPanel(false); - refreshComboBoxData(); - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Share_Module_OK")); - } else { - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Share_Module_Error")); - } - } catch (IOException e) { - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Share_Module_Error")); - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } - } - - private void refreshShareModule() { - try { - ShareLoader.getLoader().refreshModule(); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } - - public void repaint() { - - parentView.validate(); - parentView.repaint(); - parentView.revalidate(); - } - -} From f89a5d3171f9de2a09101f06650e7155b4363a9b Mon Sep 17 00:00:00 2001 From: Harrison Date: Tue, 24 Mar 2020 14:38:48 +0800 Subject: [PATCH 5/7] =?UTF-8?q?REPORT-27647=20=E6=A8=A1=E6=9D=BF=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E7=9A=84=E5=AE=89=E8=A3=85=E4=B8=8B=E8=BD=BD-?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E7=BB=84=E4=BB=B6=E5=A4=8D=E7=94=A8=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=20=E5=88=A0=E6=8E=89=E5=A4=9A=E4=BD=99=E7=9A=84?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/fun/PropertyItemPaneProvider.java | 21 ++++++++++++++++ ...AbstractComponentLibraryPaneProcessor.java | 25 ------------------- .../mainframe/EastRegionContainerPane.java | 6 +++++ 3 files changed, 27 insertions(+), 25 deletions(-) delete mode 100644 designer-base/src/main/java/com/fr/design/fun/impl/AbstractComponentLibraryPaneProcessor.java diff --git a/designer-base/src/main/java/com/fr/design/fun/PropertyItemPaneProvider.java b/designer-base/src/main/java/com/fr/design/fun/PropertyItemPaneProvider.java index 2dbead9ed6..2c5c3f2d48 100644 --- a/designer-base/src/main/java/com/fr/design/fun/PropertyItemPaneProvider.java +++ b/designer-base/src/main/java/com/fr/design/fun/PropertyItemPaneProvider.java @@ -14,12 +14,33 @@ public interface PropertyItemPaneProvider extends Mutable { String XML_TAG = "PropertyItemPaneProvider"; + /** + * 独一无二的标志 + * + * @return 标志 + */ String key(); + /** + * 配置属性 + * + * @return 熟悉 + */ PropertyItemBean getItem(); + /** + * 面板持有者 + * + * @param clazz 类型 + * @return 持有者 + */ @Nullable PaneHolder getPaneHolder(Class clazz); + /** + * 想要替代的类型 + * + * @return 替代类型 + */ String replaceKey(); } diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractComponentLibraryPaneProcessor.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractComponentLibraryPaneProcessor.java deleted file mode 100644 index f376ad7887..0000000000 --- a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractComponentLibraryPaneProcessor.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.fr.design.fun.impl; - -import com.fr.design.fun.ComponentLibraryPaneProcessor; -import com.fr.stable.fun.impl.AbstractProvider; -import com.fr.stable.fun.mark.API; -import com.fr.stable.fun.mark.Layer; - -/** - * created by Harrison on 2020/03/16 - **/ -@API(level = ComponentLibraryPaneProcessor.CURRENT_LEVEL) -public abstract class AbstractComponentLibraryPaneProcessor extends AbstractProvider implements ComponentLibraryPaneProcessor { - - @Override - public int currentAPILevel() { - - return ComponentLibraryPaneProcessor.CURRENT_LEVEL; - } - - @Override - public int layerIndex() { - - return Layer.DEFAULT_LAYER_INDEX; - } -} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java index 790c0eb39f..0c23e8658f 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java @@ -178,6 +178,9 @@ public class EastRegionContainerPane extends UIEastResizableContainer { propertyItemMap.remove(provider.key()); String replaceKey = provider.replaceKey(); + if (replaceKey == null) { + return; + } PropertyItem replaceItem = propertyItemMap.get(replaceKey); if (replaceItem != null) { replaceItem.setReplace(false); @@ -210,6 +213,9 @@ public class EastRegionContainerPane extends UIEastResizableContainer { propertyItemMap.put(key, propertyItem); String replaceKey = provider.replaceKey(); + if (replaceKey == null) { + return; + } PropertyItem replaceItem = propertyItemMap.get(replaceKey); if (replaceItem != null) { replaceItem.setReplace(true); From 2a0bbc69bc773513d92b25dbb03b50fc1b4db77d Mon Sep 17 00:00:00 2001 From: Harrison Date: Tue, 24 Mar 2020 14:46:47 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fun/ComponentLibraryPaneProcessor.java | 57 ------------------- 1 file changed, 57 deletions(-) delete mode 100644 designer-base/src/main/java/com/fr/design/fun/ComponentLibraryPaneProcessor.java diff --git a/designer-base/src/main/java/com/fr/design/fun/ComponentLibraryPaneProcessor.java b/designer-base/src/main/java/com/fr/design/fun/ComponentLibraryPaneProcessor.java deleted file mode 100644 index 7b484b156d..0000000000 --- a/designer-base/src/main/java/com/fr/design/fun/ComponentLibraryPaneProcessor.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.fr.design.fun; - -import com.fr.design.gui.icombobox.UIComboBox; -import com.fr.design.gui.icontainer.UIScrollPane; -import com.fr.design.mainframe.DockingView; -import com.fr.stable.fun.mark.Immutable; - -import javax.swing.JPanel; - -/** - * 组件库面板处理器 - * - * created by Harrison on 2020/03/16 - **/ -public interface ComponentLibraryPaneProcessor extends Immutable { - - String XML_TAG = "ComponentLibraryPaneProcessor"; - - int CURRENT_LEVEL = 1; - - /** - * 创建展示面板 - * - * @param isEdit 是否可以编辑 - * @return 展示面板 - */ - UIScrollPane createShowPanel(boolean isEdit); - - /** - * 创建菜单的上部面板 - * - * @return 面板 - */ - JPanel createMenuNorthPane(); - - /** - * 创建复选框 - * - * @return 复选框 - */ - UIComboBox createMenuComBox(); - - void parentView(DockingView dockingView); - - /** - * 父面板 - * - * @param panel 面板 - */ - void parentPane(JPanel panel); - - /** - * 创建完成 - */ - void complete(); - -} From 713b72cded5d886b417e5d696f1fe3c3c24aeb6f Mon Sep 17 00:00:00 2001 From: Harrison Date: Tue, 24 Mar 2020 18:08:10 +0800 Subject: [PATCH 7/7] =?UTF-8?q?REPORT-27647=20=E6=A8=A1=E6=9D=BF=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E7=9A=84=E5=AE=89=E8=A3=85=E4=B8=8B=E8=BD=BD-?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E7=BB=84=E4=BB=B6=E5=A4=8D=E7=94=A8=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=20=E8=B0=83=E6=95=B4=E6=9A=B4=E9=9C=B2=E7=9A=84?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=EF=BC=8C=E8=BF=94=E5=9B=9E=E5=90=88=E9=80=82?= =?UTF-8?q?=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/FormCreatorDropTarget.java | 6 +++--- .../fr/design/mainframe/FormWidgetDetailPane.java | 4 ++-- .../com/fr/design/mainframe/ShareWidgetButton.java | 12 ++++++------ .../com/fr/design/mainframe/ShareWidgetPane.java | 7 ++++--- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java b/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java index 756a89f564..0a6e692f49 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java @@ -22,15 +22,14 @@ import com.fr.design.icon.IconPathConstants; import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.design.utils.ComponentUtils; import com.fr.form.share.SharableEditorProvider; +import com.fr.form.share.SharableWidgetProvider; import com.fr.form.share.ShareLoader; import com.fr.form.ui.ChartEditor; -import com.fr.form.ui.SharableWidgetBindInfo; import com.fr.form.ui.Widget; import com.fr.stable.Constants; import javax.swing.BorderFactory; import javax.swing.JWindow; -import java.util.Map; import java.awt.Color; import java.awt.Component; import java.awt.Point; @@ -40,6 +39,7 @@ import java.awt.dnd.DropTarget; import java.awt.dnd.DropTargetDragEvent; import java.awt.dnd.DropTargetDropEvent; import java.awt.dnd.DropTargetEvent; +import java.util.Map; /** * 添加模式下鼠标事件处理器。 @@ -99,7 +99,7 @@ public class FormCreatorDropTarget extends DropTarget { if (addingXCreator.isShared()) { String shareId = addingXCreator.getShareId(); SharableEditorProvider sharableEditor = ShareLoader.getLoader().getSharedElCaseEditorById(shareId); - SharableWidgetBindInfo bindInfo = ShareLoader.getLoader().getElCaseBindInfoById(shareId); + SharableWidgetProvider bindInfo = ShareLoader.getLoader().getElCaseBindInfoById(shareId); if (sharableEditor != null && bindInfo != null) { Map tdNameMap = TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).addTableData(bindInfo.getName(), sharableEditor.getTableDataSource()); //合并数据集之后,可能会有数据集名称变化,做一下联动 diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java b/designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java index f49f2859b2..ecb3faa706 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java @@ -8,8 +8,8 @@ import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.widget.FRWidgetFactory; +import com.fr.form.share.SharableWidgetProvider; import com.fr.form.share.ShareLoader; -import com.fr.form.ui.SharableWidgetBindInfo; import com.fr.general.CloudCenter; import com.fr.log.FineLoggerFactory; import com.fr.share.ShareConstants; @@ -51,7 +51,7 @@ public class FormWidgetDetailPane extends FormDockView{ private UIScrollPane downPane; private JPanel reuWidgetPanel; private UIComboBox comboBox; - private SharableWidgetBindInfo[] elCaseBindInfoList; + private SharableWidgetProvider[] elCaseBindInfoList; private UIButton deleteButton; private JPanel editPanel; private JPanel resetPanel; diff --git a/designer-form/src/main/java/com/fr/design/mainframe/ShareWidgetButton.java b/designer-form/src/main/java/com/fr/design/mainframe/ShareWidgetButton.java index a79ac17a5c..7e7d76d896 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/ShareWidgetButton.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/ShareWidgetButton.java @@ -1,14 +1,13 @@ package com.fr.design.mainframe; -import com.fr.base.BaseUtils; import com.fr.base.iofile.attr.SharableAttrMark; import com.fr.base.vcs.DesignerMode; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.gui.ilable.UILabel; +import com.fr.form.share.SharableWidgetProvider; import com.fr.form.share.ShareLoader; import com.fr.form.ui.AbstractBorderStyleWidget; -import com.fr.form.ui.SharableWidgetBindInfo; import com.fr.form.ui.Widget; import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; import com.fr.general.ComparatorUtils; @@ -52,8 +51,9 @@ import java.io.Serializable; * Time: 16:14 */ public class ShareWidgetButton extends JPanel implements MouseListener, MouseMotionListener, Serializable { + private static final Dimension TAB_DEFAULT_SIZE = new Dimension(500, 300); - private SharableWidgetBindInfo bindInfo; + private SharableWidgetProvider bindInfo; private MouseEvent lastPressEvent; private JPanel reportPane; private boolean isEdit; @@ -72,7 +72,7 @@ public class ShareWidgetButton extends JPanel implements MouseListener, MouseMot } }; - public ShareWidgetButton(SharableWidgetBindInfo bindInfo) { + public ShareWidgetButton(SharableWidgetProvider bindInfo) { this.bindInfo = bindInfo; this.setPreferredSize(new Dimension(108, 68)); initUI(); @@ -149,11 +149,11 @@ public class ShareWidgetButton extends JPanel implements MouseListener, MouseMot }; } - public SharableWidgetBindInfo getBindInfo() { + public SharableWidgetProvider getBindInfo() { return bindInfo; } - public void setBindInfo(SharableWidgetBindInfo bindInfo) { + public void setBindInfo(SharableWidgetProvider bindInfo) { this.bindInfo = bindInfo; } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/ShareWidgetPane.java b/designer-form/src/main/java/com/fr/design/mainframe/ShareWidgetPane.java index 32ce586c72..549a4b174e 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/ShareWidgetPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/ShareWidgetPane.java @@ -1,7 +1,8 @@ package com.fr.design.mainframe; -import com.fr.form.ui.SharableWidgetBindInfo; + +import com.fr.form.share.SharableWidgetProvider; import javax.swing.*; import java.awt.*; @@ -12,12 +13,12 @@ import java.awt.*; */ public class ShareWidgetPane extends JPanel { - public ShareWidgetPane(SharableWidgetBindInfo[] elCaseBindInfoList, boolean isEdit) { + public ShareWidgetPane(SharableWidgetProvider[] elCaseBindInfoList, boolean isEdit) { this.setBorder(BorderFactory.createEmptyBorder(10, 3, 0, 0));// 设置面板的边框 ,距离上、左、下、右 的距离 if (elCaseBindInfoList != null) { int rowCount = (elCaseBindInfoList.length + 1) / 2; this.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 10)); - for (SharableWidgetBindInfo rbModuleInfo : elCaseBindInfoList) { + for (SharableWidgetProvider rbModuleInfo : elCaseBindInfoList) { ShareWidgetButton widgetButton = new ShareWidgetButton(rbModuleInfo); widgetButton.setElementCaseEdit(isEdit); this.add(widgetButton);