From 9af3093423d54454f167128a0646fb1033c0e6ef Mon Sep 17 00:00:00 2001 From: zack Date: Thu, 3 Nov 2016 15:45:36 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20=20?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=85=B1=E4=BA=AB=E7=9A=84=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E4=BA=A4=E4=BA=92=E6=94=B9=E8=BF=9B=E5=92=8C=E9=AA=8C=E6=94=B6?= =?UTF-8?q?=E7=9A=84bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/mainframe/HelpDialogHandler.java | 13 +++ .../design/mainframe/HelpDialogManager.java | 44 +++++++++ .../fr/design/mainframe/UndoStateEdit.java | 1 + .../design/designer/creator/XChartEditor.java | 7 +- .../design/designer/creator/XElementCase.java | 13 ++- .../com/fr/design/mainframe/CoverPane.java | 97 +++++++++++++++++++ .../fr/design/mainframe/CoverReportPane.java | 54 ++++------- .../mainframe/EditingMouseListener.java | 17 +++- 8 files changed, 195 insertions(+), 51 deletions(-) create mode 100644 designer_base/src/com/fr/design/mainframe/HelpDialogHandler.java create mode 100644 designer_base/src/com/fr/design/mainframe/HelpDialogManager.java create mode 100644 designer_form/src/com/fr/design/mainframe/CoverPane.java diff --git a/designer_base/src/com/fr/design/mainframe/HelpDialogHandler.java b/designer_base/src/com/fr/design/mainframe/HelpDialogHandler.java new file mode 100644 index 000000000..dec93e658 --- /dev/null +++ b/designer_base/src/com/fr/design/mainframe/HelpDialogHandler.java @@ -0,0 +1,13 @@ +package com.fr.design.mainframe; + +/** + * Coder: zack + * Date: 2016/11/3 + * Time: 10:43 + */ +public interface HelpDialogHandler { + /** + * 销毁 + */ + void destroyHelpDialog(); +} diff --git a/designer_base/src/com/fr/design/mainframe/HelpDialogManager.java b/designer_base/src/com/fr/design/mainframe/HelpDialogManager.java new file mode 100644 index 000000000..9cae023ea --- /dev/null +++ b/designer_base/src/com/fr/design/mainframe/HelpDialogManager.java @@ -0,0 +1,44 @@ +package com.fr.design.mainframe; + +/** + * 帮助信息的面板由于需要滚动条所以采用了很挫的dialog做,dialog很多情况下不能主动关闭,这边控制一下 + * Coder: zack + * Date: 2016/11/2 + * Time: 16:34 + */ +public class HelpDialogManager { + private static HelpDialogManager THIS; + private HelpDialogHandler handler; + + private HelpDialogManager() { + + } + + public HelpDialogHandler getPane() { + return handler; + } + + public void setPane(HelpDialogHandler dialog) { + if (dialog == this.handler) { + return; + } + //只允许一个dialog存在 + if (this.handler != null) { + handler.destroyHelpDialog(); + } + this.handler = dialog; + } + + public static HelpDialogManager getInstance() { + if (THIS == null) { + THIS = new HelpDialogManager(); + } + return THIS; + } + + public void destroyDialog() { + if (handler != null) { + handler.destroyHelpDialog(); + } + } +} diff --git a/designer_base/src/com/fr/design/mainframe/UndoStateEdit.java b/designer_base/src/com/fr/design/mainframe/UndoStateEdit.java index 3fc8f0436..f81e2bbd3 100644 --- a/designer_base/src/com/fr/design/mainframe/UndoStateEdit.java +++ b/designer_base/src/com/fr/design/mainframe/UndoStateEdit.java @@ -50,6 +50,7 @@ public class UndoStateEdit extends AbstractUndoableEdit { } } if (this.old != null) { + HelpDialogManager.getInstance().destroyDialog(); this.old.applyState(); } if (BaseUtils.isAuthorityEditing()) { diff --git a/designer_form/src/com/fr/design/designer/creator/XChartEditor.java b/designer_form/src/com/fr/design/designer/creator/XChartEditor.java index 49d193199..28926f6c8 100644 --- a/designer_form/src/com/fr/design/designer/creator/XChartEditor.java +++ b/designer_form/src/com/fr/design/designer/creator/XChartEditor.java @@ -2,26 +2,21 @@ package com.fr.design.designer.creator; import java.awt.*; import java.awt.event.MouseEvent; -import java.awt.image.BufferedImage; import java.beans.IntrospectionException; import javax.swing.*; -import com.fr.base.BaseUtils; -import com.fr.base.chart.BaseChart; import com.fr.base.chart.BaseChartCollection; import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.gui.chart.BaseChartPropertyPane; import com.fr.design.gui.chart.MiddleChartComponent; -import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.*; import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor; import com.fr.design.mainframe.widget.renderer.LayoutBorderStyleRenderer; import com.fr.design.module.DesignModuleFactory; import com.fr.design.designer.beans.events.DesignerEditor; -import com.fr.form.ui.AbstractBorderStyleWidget; import com.fr.form.ui.BaseChartEditor; import com.fr.form.ui.Widget; import com.fr.design.form.util.XCreatorConstants; @@ -237,7 +232,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator { editor.setLayout(null); editor.setOpaque(false); - coverPanel = new CoverReportPane(); + coverPanel = new CoverPane(); coverPanel.setPreferredSize(this.getPreferredSize()); coverPanel.setBounds(this.getBounds()); diff --git a/designer_form/src/com/fr/design/designer/creator/XElementCase.java b/designer_form/src/com/fr/design/designer/creator/XElementCase.java index 39caec435..6ff949dfd 100644 --- a/designer_form/src/com/fr/design/designer/creator/XElementCase.java +++ b/designer_form/src/com/fr/design/designer/creator/XElementCase.java @@ -9,10 +9,7 @@ import com.fr.design.fun.FormElementCaseEditorProvider; import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.fun.impl.AbstractFormElementCaseEditorProvider; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.mainframe.CoverReportPane; -import com.fr.design.mainframe.EditingMouseListener; -import com.fr.design.mainframe.FormDesigner; -import com.fr.design.mainframe.WidgetPropertyPane; +import com.fr.design.mainframe.*; import com.fr.design.mainframe.widget.editors.BooleanEditor; import com.fr.design.mainframe.widget.editors.PaddingMarginEditor; import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor; @@ -201,6 +198,13 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme editor.repaint(); } + /** + * 销毁帮助提示框 + */ + public void destroyHelpDialog(){ + coverPanel.destroyHelpDialog(); + } + public JComponent getCoverPane(){ return coverPanel; } @@ -280,6 +284,7 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme if (this.isHelpBtnOnFocus()) { coverPanel.setMsgDisplay(e); }else { + coverPanel.destroyHelpDialog(); switchTab(e,editingMouseListener); } } diff --git a/designer_form/src/com/fr/design/mainframe/CoverPane.java b/designer_form/src/com/fr/design/mainframe/CoverPane.java new file mode 100644 index 000000000..b6cdd472a --- /dev/null +++ b/designer_form/src/com/fr/design/mainframe/CoverPane.java @@ -0,0 +1,97 @@ +package com.fr.design.mainframe; + +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.icon.IconPathConstants; +import com.fr.general.IOUtils; +import com.fr.general.Inter; + +import javax.swing.*; +import java.awt.*; + +/** + * Created with IntelliJ IDEA. + * User: zx + * Date: 14-7-24 + * Time: 上午9:09 + */ +public class CoverPane extends JPanel { + + private UIButton editButton; + private AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 60 / 100.0F); + + public CoverPane() { + setLayout(getCoverLayout()); + setBackground(null); + setOpaque(false); + + editButton = new UIButton(Inter.getLocText("Edit"), IOUtils.readIcon(IconPathConstants.TD_EDIT_ICON_PATH)) { + @Override + public Dimension getPreferredSize() { + return new Dimension(60, 24); + } + }; + editButton.setBorderPainted(false); + editButton.setExtraPainted(false); + editButton.setBackground(new Color(176, 196, 222)); + add(editButton); + } + + public AlphaComposite getComposite() { + return composite; + } + + public void setComposite(AlphaComposite composite) { + this.composite = composite; + } + + public UIButton getEditButton() { + return editButton; + } + + public void setEditButton(UIButton editButton) { + this.editButton = editButton; + } + + protected LayoutManager getCoverLayout() { + return new LayoutManager() { + + @Override + public void removeLayoutComponent(Component comp) { + } + + @Override + public Dimension preferredLayoutSize(Container parent) { + return parent.getPreferredSize(); + } + + @Override + public Dimension minimumLayoutSize(Container parent) { + return null; + } + + @Override + public void layoutContainer(Container parent) { + int width = parent.getParent().getWidth(); + int height = parent.getParent().getHeight(); + int preferWidth = editButton.getPreferredSize().width; + int preferHeight = editButton.getPreferredSize().height; + editButton.setBounds((width - preferWidth) / 2, (height - preferHeight) / 2, preferWidth, preferHeight); + } + + @Override + public void addLayoutComponent(String name, Component comp) { + } + }; + } + + + public void paint(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + Composite oldComposite = g2d.getComposite(); + g2d.setComposite(composite); + g2d.setColor(Color.white); + g2d.fillRect(0, 0, getWidth(), getHeight()); + g2d.setComposite(oldComposite); + super.paint(g); + } +} \ No newline at end of file diff --git a/designer_form/src/com/fr/design/mainframe/CoverReportPane.java b/designer_form/src/com/fr/design/mainframe/CoverReportPane.java index 63ec66f5a..f99633856 100644 --- a/designer_form/src/com/fr/design/mainframe/CoverReportPane.java +++ b/designer_form/src/com/fr/design/mainframe/CoverReportPane.java @@ -8,7 +8,6 @@ import com.fr.design.icon.IconPathConstants; import com.fr.form.share.ShareConstants; import com.fr.general.FRScreen; import com.fr.general.IOUtils; -import com.fr.general.Inter; import com.fr.stable.StringUtils; import javax.swing.*; @@ -16,15 +15,13 @@ import java.awt.*; import java.awt.event.MouseEvent; /** - * Created with IntelliJ IDEA. - * User: zx - * Date: 14-7-24 - * Time: 上午9:09 + * 报表块的封面(如果后面所有的组件都有帮助信息的话就抽接口吧) + * Coder: zack + * Date: 2016/11/2 + * Time: 11:32 */ -public class CoverReportPane extends JPanel { - - private UIButton editButton; - private Icon controlMode = IOUtils.readIcon(IconPathConstants.TD_EL_SHARE_CLOSE_ICON_PATH); +public class CoverReportPane extends CoverPane implements HelpDialogHandler{ + private Icon controlMode = IOUtils.readIcon(IconPathConstants.TD_EL_SHARE_HELP_ICON_PATH); private JComponent controlButton = new JComponent() { protected void paintComponent(Graphics g) { g.setColor(UIConstants.NORMAL_BACKGROUND); @@ -39,28 +36,13 @@ public class CoverReportPane extends JPanel { private ElementCaseHelpDialog helpDialog = null; - private AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 60 / 100.0F); - public CoverReportPane() { this(StringUtils.EMPTY); } public CoverReportPane(String helpMsg) { + super(); this.helpMsg = helpMsg; - setLayout(getCoverLayout()); - setBackground(null); - setOpaque(false); - - editButton = new UIButton(Inter.getLocText("Edit"), IOUtils.readIcon(IconPathConstants.TD_EDIT_ICON_PATH)) { - @Override - public Dimension getPreferredSize() { - return new Dimension(60, 24); - } - }; - editButton.setBorderPainted(false); - editButton.setExtraPainted(false); - editButton.setBackground(new Color(176, 196, 222)); - add(editButton); add(controlButton); if (WidgetPropertyPane.getInstance().getEditingFormDesigner() != null) { WidgetPropertyPane.getInstance().getEditingFormDesigner().addDesignerEditListener(new DesignerEditListener() { @@ -98,6 +80,7 @@ public class CoverReportPane extends JPanel { int rY = 165 + e.getY();//165是设计器最上面几个面板的高度 helpDialog.setLocationRelativeTo(DesignerContext.getDesignerFrame(), rX, rY); helpDialog.showWindow(); + HelpDialogManager.getInstance().setPane(this); } else { controlMode = IOUtils.readIcon(IconPathConstants.TD_EL_SHARE_HELP_ICON_PATH); controlButton.repaint(); @@ -125,6 +108,7 @@ public class CoverReportPane extends JPanel { @Override public void layoutContainer(Container parent) { + UIButton editButton = getEditButton(); int width = parent.getParent().getWidth(); int height = parent.getParent().getHeight(); int preferWidth = editButton.getPreferredSize().width; @@ -139,17 +123,6 @@ public class CoverReportPane extends JPanel { }; } - - public void paint(Graphics g) { - Graphics2D g2d = (Graphics2D) g; - Composite oldComposite = g2d.getComposite(); - g2d.setComposite(composite); - g2d.setColor(Color.white); - g2d.fillRect(0, 0, getWidth(), getHeight()); - g2d.setComposite(oldComposite); - super.paint(g); - } - public void destroyHelpDialog() { if (helpDialog != null) { controlMode = IOUtils.readIcon(IconPathConstants.TD_EL_SHARE_HELP_ICON_PATH); @@ -159,4 +132,11 @@ public class CoverReportPane extends JPanel { } } -} \ No newline at end of file + @Override + public void setVisible(boolean aFlag) { + super.setVisible(aFlag); + if (aFlag) { + HelpDialogManager.getInstance().setPane(this); + } + } +} diff --git a/designer_form/src/com/fr/design/mainframe/EditingMouseListener.java b/designer_form/src/com/fr/design/mainframe/EditingMouseListener.java index 0aa77281d..869ec2077 100644 --- a/designer_form/src/com/fr/design/mainframe/EditingMouseListener.java +++ b/designer_form/src/com/fr/design/mainframe/EditingMouseListener.java @@ -256,7 +256,7 @@ public class EditingMouseListener extends MouseInputAdapter { public void mouseMoved(MouseEvent e) { XCreator component = designer.getComponentAt(e); - setCoverPaneNotDisplay(); + setCoverPaneNotDisplay(e, false); if(processTopLayoutMouseMove(component, e)){ return; @@ -320,8 +320,17 @@ public class EditingMouseListener extends MouseInputAdapter { designer.repaint(); } - private void setCoverPaneNotDisplay(){ - if (xElementCase != null){ + private void setCoverPaneNotDisplay(MouseEvent e, boolean isLinkedHelpDialog) { + if (xElementCase != null) { + int x = getParentPositionX(xElementCase, 0) - designer.getArea().getHorizontalValue(); + int y = getParentPositionY(xElementCase, 0) - designer.getArea().getVerticalValue(); + Rectangle rect = new Rectangle(x, y, xElementCase.getWidth(), xElementCase.getHeight()); + if (rect.contains(e.getPoint())) { + return; + } + if(isLinkedHelpDialog){ + xElementCase.destroyHelpDialog(); + } xElementCase.displayCoverPane(false); } if (xChartEditor != null){ @@ -525,7 +534,7 @@ public class EditingMouseListener extends MouseInputAdapter { designer.setCursor(Cursor.getDefaultCursor()); } - setCoverPaneNotDisplay(); + setCoverPaneNotDisplay(e, true); cancelPromptWidgetForbidEnter(); } From dc01a3fe223fdf7fa4b813c743cad09338b882d9 Mon Sep 17 00:00:00 2001 From: zack Date: Thu, 3 Nov 2016 19:22:07 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20=20?= =?UTF-8?q?=E4=B8=A5=E6=A0=BC=E9=99=90=E5=88=B6dialog=E7=9A=84=E4=BA=A4?= =?UTF-8?q?=E4=BA=92=E4=B9=8B=E5=90=8Ectrl=20z=E6=92=A4=E9=94=80=E4=B9=8B?= =?UTF-8?q?=E5=89=8D=E5=BF=85=E9=A1=BB=E5=85=88=E5=85=B3=E9=97=AD=E5=B8=AE?= =?UTF-8?q?=E5=8A=A9=E5=BC=B9=E6=A1=86=EF=BC=8C=E8=BF=99=E8=BE=B9=E5=B0=B1?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E5=88=A0=E6=8E=89=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer_base/src/com/fr/design/mainframe/UndoStateEdit.java | 1 - 1 file changed, 1 deletion(-) diff --git a/designer_base/src/com/fr/design/mainframe/UndoStateEdit.java b/designer_base/src/com/fr/design/mainframe/UndoStateEdit.java index f81e2bbd3..3fc8f0436 100644 --- a/designer_base/src/com/fr/design/mainframe/UndoStateEdit.java +++ b/designer_base/src/com/fr/design/mainframe/UndoStateEdit.java @@ -50,7 +50,6 @@ public class UndoStateEdit extends AbstractUndoableEdit { } } if (this.old != null) { - HelpDialogManager.getInstance().destroyDialog(); this.old.applyState(); } if (BaseUtils.isAuthorityEditing()) { From 5ed311f92a8b4ad89d8ebb1dce4abae4db864b4b Mon Sep 17 00:00:00 2001 From: zack Date: Thu, 3 Nov 2016 20:02:54 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=85=B1=E4=BA=AB=E5=BC=82=E6=AD=A5=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/FormWidgetDetailPane.java | 62 +++++++++++-------- 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java b/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java index 6bcc9a266..a1fb5f147 100644 --- a/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java +++ b/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java @@ -1,47 +1,35 @@ package com.fr.design.mainframe; -import java.awt.*; -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.util.*; -import java.util.List; - -import javax.swing.*; -import javax.swing.border.LineBorder; -import javax.swing.filechooser.FileNameExtensionFilter; - import com.fr.base.BaseUtils; -import com.fr.design.actions.file.WebPreviewUtils; -import com.fr.design.constants.UIConstants; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.UIDialog; import com.fr.design.extra.PluginWebBridge; import com.fr.design.extra.ShopDialog; import com.fr.design.extra.WebManagerPaneFactory; -import com.fr.design.file.HistoryTemplateListPane; -import com.fr.design.file.MutilTempalteTabPane; import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.ibutton.UIPreviewButton; 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.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIPopupMenu; -import com.fr.design.gui.itoolbar.UILargeToolbar; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.parameter.ParameterPropertyPane; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.form.share.ShareConstants; import com.fr.form.share.ShareLoader; import com.fr.form.ui.ElCaseBindInfo; -import com.fr.general.IOUtils; import com.fr.general.Inter; +import javax.swing.*; +import javax.swing.filechooser.FileNameExtensionFilter; +import java.awt.*; +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; + /** * Created with IntelliJ IDEA. * User: zx @@ -60,6 +48,7 @@ public class FormWidgetDetailPane extends FormDockView{ private UIButton deleteButton; private static final int OFFSET_X = 140; private static final int OFFSET_Y = 26; + private SwingWorker sw; public static FormWidgetDetailPane getInstance() { if (HOLDER.singleton == null) { @@ -105,7 +94,19 @@ public class FormWidgetDetailPane extends FormDockView{ reuWidgetPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); reuWidgetPanel.setBorder(null); if (elCaseBindInfoList == null) { - elCaseBindInfoList = ShareLoader.getLoader().getAllBindInfoList(); + elCaseBindInfoList = new ElCaseBindInfo[0]; + 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(); createRefreshButton(); @@ -178,8 +179,19 @@ public class FormWidgetDetailPane extends FormDockView{ refreshButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - refreshShareMoudule(); - refreshDownPanel(false); + if (sw != null) { + sw.cancel(true); + } + sw = new SwingWorker() { + @Override + protected Object doInBackground() throws Exception { + ShareLoader.getLoader().refreshModule(); + elCaseBindInfoList = ShareLoader.getLoader().getAllBindInfoList(); + refreshDownPanel(false); + return null; + } + }; + sw.execute(); } });