From 5ec25e6264a8e582dffcc36c10fec37ed207a457 Mon Sep 17 00:00:00 2001 From: zack Date: Thu, 22 Sep 2016 20:19:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=A5=E8=A1=A8=E5=9D=97=E5=85=B1=E4=BA=AB?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fun/DesignerFrameUpButtonProvider.java | 24 +++++++++++++++++++ .../AbstractDsinFrameUpButtonProvider.java | 23 ++++++++++++++++++ .../fr/design/mainframe/DesignerFrame.java | 19 +++++++++++++++ .../com/fr/design/mainframe/JTemplate.java | 24 ++++++++++++++++++- 4 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 designer_base/src/com/fr/design/fun/DesignerFrameUpButtonProvider.java create mode 100644 designer_base/src/com/fr/design/fun/impl/AbstractDsinFrameUpButtonProvider.java diff --git a/designer_base/src/com/fr/design/fun/DesignerFrameUpButtonProvider.java b/designer_base/src/com/fr/design/fun/DesignerFrameUpButtonProvider.java new file mode 100644 index 0000000000..b6a86ae81c --- /dev/null +++ b/designer_base/src/com/fr/design/fun/DesignerFrameUpButtonProvider.java @@ -0,0 +1,24 @@ +package com.fr.design.fun; + +import com.fr.design.gui.ibutton.UIButton; +import com.fr.stable.fun.mark.Mutable; + +/** + * 设计器面板最上方的按钮接口(保存,赋值,撤销同级) + * Coder: zack + * Date: 2016/9/22 + * Time: 15:40 + */ +public interface DesignerFrameUpButtonProvider extends Mutable { + + int CURRENT_LEVEL = 1; + + String XML_TAG = "DesignerFrameUpButtonProvider"; + + /** + * 根据当前的设计状态返回最上层工具按钮 + * @param menuState 现在设计器的设计状态 + * @return 按钮 + */ + UIButton[] getUpButtons(int menuState); +} diff --git a/designer_base/src/com/fr/design/fun/impl/AbstractDsinFrameUpButtonProvider.java b/designer_base/src/com/fr/design/fun/impl/AbstractDsinFrameUpButtonProvider.java new file mode 100644 index 0000000000..bd1f70829b --- /dev/null +++ b/designer_base/src/com/fr/design/fun/impl/AbstractDsinFrameUpButtonProvider.java @@ -0,0 +1,23 @@ +package com.fr.design.fun.impl; + +import com.fr.design.fun.DesignerFrameUpButtonProvider; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.stable.fun.mark.API; + +/** + * Coder: zack + * Date: 2016/9/22 + * Time: 15:50 + */ +@API(level = DesignerFrameUpButtonProvider.CURRENT_LEVEL) +public abstract class AbstractDsinFrameUpButtonProvider implements DesignerFrameUpButtonProvider { + @Override + public UIButton[] getUpButtons(int menuState) { + return new UIButton[0]; + } + + @Override + public String mark4Provider() { + return getClass().getName(); + } +} diff --git a/designer_base/src/com/fr/design/mainframe/DesignerFrame.java b/designer_base/src/com/fr/design/mainframe/DesignerFrame.java index a1f5f16a4b..329b631552 100644 --- a/designer_base/src/com/fr/design/mainframe/DesignerFrame.java +++ b/designer_base/src/com/fr/design/mainframe/DesignerFrame.java @@ -464,9 +464,28 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta //添加分享按钮 addShareButton(); + + //添加插件中的按钮 + addExtraButtons(); return combineUp; } + + private void addExtraButtons(){ + JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + if(jt == null){ + return; + } + + + UIButton[] extraButtons = jt.createExtraButtons(); + for (int i = 0; i < extraButtons.length; i++) { + combineUp.add(extraButtons[i]); + } + if (extraButtons.length > 0) { + combineUp.addSeparator(new Dimension(2, 16)); + } + } private void addShareButton(){ JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); diff --git a/designer_base/src/com/fr/design/mainframe/JTemplate.java b/designer_base/src/com/fr/design/mainframe/JTemplate.java index 8478e2500d..58060d91a9 100644 --- a/designer_base/src/com/fr/design/mainframe/JTemplate.java +++ b/designer_base/src/com/fr/design/mainframe/JTemplate.java @@ -8,8 +8,8 @@ import com.fr.base.io.IOFile; import com.fr.design.DesignModelAdapter; import com.fr.design.DesignState; import com.fr.design.DesignerEnvManager; +import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.TableDataSourceAction; -import com.fr.design.actions.core.WorkBookSupportable; import com.fr.design.actions.edit.RedoAction; import com.fr.design.actions.edit.UndoAction; import com.fr.design.actions.file.SaveAsTemplateAction; @@ -19,6 +19,7 @@ import com.fr.design.designer.TargetComponent; import com.fr.design.dialog.InformationWarnPane; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.TemplateTreePane; +import com.fr.design.fun.DesignerFrameUpButtonProvider; import com.fr.design.fun.MenuHandler; import com.fr.design.fun.PreviewProvider; import com.fr.design.gui.frpane.HyperlinkGroupPane; @@ -37,9 +38,12 @@ import com.fr.file.FILE; import com.fr.file.FILEChooserPane; import com.fr.file.FileNodeFILE; import com.fr.file.MemFILE; +import com.fr.form.ui.NoneWidget; +import com.fr.form.ui.Widget; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.general.Inter; +import com.fr.stable.ArrayUtils; import com.fr.stable.ProductConstants; import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; @@ -51,6 +55,7 @@ import java.awt.*; import java.io.File; import java.util.ArrayList; import java.util.Arrays; +import java.util.Set; import java.util.regex.Pattern; /** @@ -505,6 +510,9 @@ public abstract class JTemplate> ex public boolean saveShareFile(){ return true; } + public Widget getSelectElementCase(){ + return new NoneWidget(); + } protected FILEChooserPane getFILEChooserPane(boolean isShowLoc){ return new FILEChooserPane(true, isShowLoc); @@ -957,4 +965,18 @@ public abstract class JTemplate> ex public boolean acceptToolbarItem(Class clazz) { return true; } + + /** + * 加载插件中的按钮 + * @return 按钮组 + */ + public UIButton[] createExtraButtons() { + Set providers = ExtraDesignClassManager.getInstance().getArray(DesignerFrameUpButtonProvider.XML_TAG); + UIButton[] uiButtons = new UIButton[0]; + for (DesignerFrameUpButtonProvider provider : providers) { + uiButtons = ArrayUtils.addAll(uiButtons, provider.getUpButtons(getMenuState())); + } + + return uiButtons; + } } \ No newline at end of file