diff --git a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java index 9ad3b4ab1..76ae52894 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -16,6 +16,7 @@ import com.fr.general.GeneralContext; import com.fr.license.exception.RegistEditionException; import com.fr.log.FineLoggerFactory; import com.fr.stable.EnvChangedListener; +import com.fr.start.server.ServerTray; import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContextCallback; import com.fr.workspace.Workspace; @@ -51,19 +52,28 @@ public class EnvChangeEntrance { }); } - private boolean envListOkAction(EnvListPane envListPane) { + private boolean envListOkAction(EnvListPane envListPane, PopTipStrategy strategy) { final String selectedName = envListPane.updateEnvManager(); - return switch2Env(selectedName); + return switch2Env(selectedName, strategy); } + /** + * 切换到指定名称的工作目录 + * + * @param envName 目标工作目录名称 + */ + public void switch2Env(final String envName) { + switch2Env(envName, PopTipStrategy.LATER); + } + /** * 切换到新环境 * * @param envName 新工作环境名称 * @return 是否成功 */ - public boolean switch2Env(final String envName) { + private boolean switch2Env(final String envName, PopTipStrategy strategy) { DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName); @@ -71,8 +81,13 @@ public class EnvChangeEntrance { Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv); boolean checkValid = workspace != null && selectedEnv.checkValid(); if (!checkValid) { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), - UIManager.getString("OptionPane.messageDialogTitle"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); + strategy.showTip(new PopTip() { + @Override + public void show() { + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), + UIManager.getString("OptionPane.messageDialogTitle"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); + } + }); return false; } WorkContext.switchTo(workspace, new WorkContextCallback() { @@ -85,19 +100,34 @@ public class EnvChangeEntrance { template.refreshToolArea(); } DesignTableDataManager.fireDSChanged(new HashMap()); + if (WorkContext.getCurrent().isLocal()) { + //初始化一下serverTray + ServerTray.init(); + } } }); } catch (AuthException | RegistEditionException e) { // String title = Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed"); // String title = Toolkit.i18nText("Fine-Design_Basic_Lic_Does_Not_Support_Remote"); - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), - UIManager.getString("OptionPane.messageDialogTitle"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); + strategy.showTip(new PopTip() { + @Override + public void show() { + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), + UIManager.getString("OptionPane.messageDialogTitle"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); + } + }); return false; } catch (Exception exception) { FineLoggerFactory.getLogger().error(exception.getMessage(), exception); - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), - UIManager.getString("OptionPane.messageDialogTitle"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); + strategy.showTip(new PopTip() { + @Override + public void show() { + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), + UIManager.getString("OptionPane.messageDialogTitle"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); + } + }); + return false; } TemplateTreePane.getInstance().refreshDockingView(); @@ -131,13 +161,11 @@ public class EnvChangeEntrance { @Override public void doOk() { - envListDialog.dispose(); - envListOkAction(envListPane); + envListOkAction(envListPane, PopTipStrategy.LATER); } @Override public void doCancel() { - envListDialog.dispose(); } }); @@ -155,11 +183,9 @@ public class EnvChangeEntrance { @Override public void doOk() { - - if (!envListOkAction(envListPane)) { + if (!envListOkAction(envListPane, PopTipStrategy.NOW)) { System.exit(0); } - } @Override @@ -170,4 +196,40 @@ public class EnvChangeEntrance { envListDialog.setVisible(true); } + + /** + * 提示显示策略 + */ + enum PopTipStrategy { + + /** + * 切换失败,就马上提示失败,不关闭选择列表对话框 + */ + NOW { + @Override + void showTip(PopTip tip) { + tip.show(); + } + }, + /** + * 切换失败,自动关闭选择列表对话框,然后提示切换失败 + */ + LATER { + @Override + void showTip(final PopTip tip) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + tip.show(); + } + }); + } + }; + + abstract void showTip(PopTip tip); + } + + interface PopTip { + void show(); + } } diff --git a/designer-base/src/main/java/com/fr/design/gui/HyperlinkFilterHelper.java b/designer-base/src/main/java/com/fr/design/gui/HyperlinkFilterHelper.java deleted file mode 100644 index bc2cbdbf9..000000000 --- a/designer-base/src/main/java/com/fr/design/gui/HyperlinkFilterHelper.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.fr.design.gui; - -import com.fr.design.file.HistoryTemplateListPane; -import com.fr.design.mainframe.BaseJForm; -import com.fr.design.mainframe.JTemplate; -import com.fr.general.ComparatorUtils; - - -/** - * Created by mengao on 2017/9/22. - * 单元格超链、图表超链在不同类型模版中,下拉选项不同 - */ -public class HyperlinkFilterHelper { - - public static boolean whetherAddHyperlink4cell(String itemName) { - JTemplate jTemplate = getCurrentEditingTemplate(); - if (jTemplate == null) { - return false; - } - //先屏蔽掉这个,之后还有别的 - String[] names = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_ Hyperlink_Chart_Float")}; - for (String name : names) { - if (!jTemplate.isJWorkBook() && ComparatorUtils.equals(itemName, name)) { - return false; - } - } - return whetherAddFormLink(jTemplate, itemName); - } - - public static boolean whetherAddHyperlink4Chart(String itemName) { - JTemplate jTemplate = getCurrentEditingTemplate(); - if (jTemplate == null) { - return false; - } - //先屏蔽掉这个,之后还有别的 - String[] names = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_ Hyperlink_Chart_Float"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Chart_Cell")}; - for (String name : names) { - if (!jTemplate.isJWorkBook() && ComparatorUtils.equals(itemName, name)) { - if (jTemplate.getEditingReportIndex() == BaseJForm.ELEMENTCASE_TAB && ComparatorUtils.equals(itemName, names[0])) { - //表单报表块中图表悬浮元素超链,只屏蔽联动悬浮元素 - return false; - } else if (jTemplate.getEditingReportIndex() == BaseJForm.FORM_TAB) { - //表单图表超链屏蔽掉联动悬浮元素和联动单元格 - return false; - } - } - } - return whetherAddFormLink(jTemplate, itemName); - } - - private static JTemplate getCurrentEditingTemplate() { - return HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - } - - private static boolean whetherAddFormLink(JTemplate jTemplate, String itemName) { - String formName = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Form_Link"); - return !(jTemplate.isJWorkBook() && ComparatorUtils.equals(itemName, formName)); - } -} diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/NameableCreator.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/NameableCreator.java index e667675ec..97fadec00 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/NameableCreator.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/NameableCreator.java @@ -5,25 +5,25 @@ import com.fr.design.gui.ilist.ListModelElement; import com.fr.js.JavaScript; import com.fr.stable.Nameable; -import javax.swing.*; +import javax.swing.Icon; public interface NameableCreator { - public String menuName(); - - public Icon menuIcon(); - - public String createTooltip(); - - public Nameable createNameable(UnrepeatedNameHelper helper); - - public Class getUpdatePane(); - - public Object acceptObject2Populate(Object ob); - - public void saveUpdatedBean(ListModelElement wrapper, Object bean); - - public Class getHyperlink(); - - - public boolean isNeedParameterWhenPopulateJControlPane(); + String menuName(); + + Icon menuIcon(); + + String createTooltip(); + + Nameable createNameable(UnrepeatedNameHelper helper); + + Class getUpdatePane(); + + Object acceptObject2Populate(Object ob); + + void saveUpdatedBean(ListModelElement wrapper, Object bean); + + Class getHyperlink(); + + + boolean isNeedParameterWhenPopulateJControlPane(); } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/shortcutfactory/OldShortCutFactory.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/shortcutfactory/OldShortCutFactory.java index a7608e2bd..d0cf10f7e 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/shortcutfactory/OldShortCutFactory.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/shortcutfactory/OldShortCutFactory.java @@ -2,15 +2,17 @@ package com.fr.design.gui.controlpane.shortcutfactory; import com.fr.base.BaseUtils; import com.fr.design.actions.UpdateAction; -import com.fr.design.gui.HyperlinkFilterHelper; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.ShortCut4JControlPane; import com.fr.design.gui.controlpane.ShortCutListenerProvider; import com.fr.design.menu.LineSeparator; import com.fr.design.menu.MenuDef; import com.fr.design.menu.ShortCut; +import com.fr.design.module.DesignModuleFactory; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; +import com.fr.js.JavaScript; +import com.fr.stable.Filter; import javax.swing.Icon; import java.awt.event.ActionEvent; @@ -83,7 +85,8 @@ public class OldShortCutFactory extends AbstractShortCutFactory { private void wrapActionListener(NameableCreator[] creators) { for (final NameableCreator creator : creators) { - if (!HyperlinkFilterHelper.whetherAddHyperlink4cell(creator.menuName())) { + Filter> filter = DesignModuleFactory.getHyperlinkGroupType().getFilter(); + if (!filter.accept(creator.getHyperlink())) { continue; } boolean isTrue = ComparatorUtils.equals(creator.menuName(), Inter.getLocText("Datasource-Stored_Procedure")) || diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/shortcutfactory/ShortCutFactory.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/shortcutfactory/ShortCutFactory.java index b561c28ba..7d1699543 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/shortcutfactory/ShortCutFactory.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/shortcutfactory/ShortCutFactory.java @@ -3,7 +3,6 @@ package com.fr.design.gui.controlpane.shortcutfactory; import com.fr.base.BaseUtils; import com.fr.design.actions.UpdateAction; import com.fr.design.actions.core.ActionFactory; -import com.fr.design.gui.HyperlinkFilterHelper; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.ShortCut4JControlPane; import com.fr.design.gui.controlpane.ShortCutListenerProvider; @@ -11,7 +10,10 @@ import com.fr.design.gui.ibutton.UIButton; import com.fr.design.menu.LineSeparator; import com.fr.design.menu.MenuDef; import com.fr.design.menu.ShortCut; +import com.fr.design.module.DesignModuleFactory; import com.fr.general.ComparatorUtils; +import com.fr.js.JavaScript; +import com.fr.stable.Filter; import com.fr.stable.StringUtils; import javax.swing.AbstractButton; @@ -36,11 +38,11 @@ public class ShortCutFactory extends AbstractShortCutFactory { @Override public ShortCut4JControlPane[] createShortCuts() { return new ShortCut4JControlPane[]{ - copyItemShortCut(), - moveUpItemShortCut(), - moveDownItemShortCut(), - sortItemShortCut(), - removeItemShortCut() + copyItemShortCut(), + moveUpItemShortCut(), + moveDownItemShortCut(), + sortItemShortCut(), + removeItemShortCut() }; } @@ -77,7 +79,7 @@ public class ShortCutFactory extends AbstractShortCutFactory { Object object = this.getValue(UIButton.class.getName()); if (!(object instanceof AbstractButton)) { // 直接使用默认UI - UIButton button = new UIButton(); + UIButton button = new UIButton(); // 添加一个名字作为自动化测试用 button.setName(getName()); @@ -124,7 +126,8 @@ public class ShortCutFactory extends AbstractShortCutFactory { /** * 生成UIButton - * @return 菜单按钮 + * + * @return 菜单按钮 */ public UIButton createUIButton() { createdButton = super.createUIButton(); @@ -139,7 +142,8 @@ public class ShortCutFactory extends AbstractShortCutFactory { private void wrapActionListener(NameableCreator[] creators) { for (final NameableCreator creator : creators) { - if (!whetherAdd(creator.menuName())) { + Filter> filter = DesignModuleFactory.getHyperlinkGroupType().getFilter(); + if (!filter.accept(creator.getHyperlink())) { continue; } boolean isTrue = ComparatorUtils.equals(creator.menuName(), com.fr.design.i18n.Toolkit.i18nText("Datasource-Stored_Procedure")) || @@ -163,9 +167,5 @@ public class ShortCutFactory extends AbstractShortCutFactory { }); } } - - protected boolean whetherAdd(String itemName){ - return HyperlinkFilterHelper.whetherAddHyperlink4cell(itemName); - } } } diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/BaseHyperlinkGroup.java b/designer-base/src/main/java/com/fr/design/gui/frpane/BaseHyperlinkGroup.java index fbc9678d5..898101698 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/BaseHyperlinkGroup.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/BaseHyperlinkGroup.java @@ -2,6 +2,8 @@ package com.fr.design.gui.frpane; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.module.DesignModuleFactory; +import com.fr.js.JavaScript; +import com.fr.stable.Filter; /** * 基础的超级链接类型, 不包括图表相关超链. @@ -11,13 +13,34 @@ import com.fr.design.module.DesignModuleFactory; */ public class BaseHyperlinkGroup implements HyperlinkGroupType { - /** - * 返回支持的超级链接类型 - * - * @return - */ - public NameableCreator[] getHyperlinkCreators() { - return DesignModuleFactory.getCreators4Hyperlink(); - } + /** + * 返回支持的超级链接类型 + * + * @return NameableCreator[] + */ + public NameableCreator[] getHyperlinkCreators() { + return DesignModuleFactory.getCreators4Hyperlink(); + } + + @Override + public Filter> getFilter() { + return new Filter>() { + @Override + public boolean accept(Class aClass) { + return true; + } + }; + } + + @Override + public Filter getOldFilter() { + return new Filter() { + @Override + public boolean accept(Object object) { + return true; + } + }; + } + } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupType.java b/designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupType.java index 37a64a290..8db0b9b94 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupType.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupType.java @@ -1,18 +1,37 @@ package com.fr.design.gui.frpane; import com.fr.design.gui.controlpane.NameableCreator; +import com.fr.js.JavaScript; +import com.fr.stable.Filter; /** - * 超级链接 支持的类型 种类. + * 超级链接 支持的类型 种类. + * * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2013-6-26 下午04:41:55 */ public interface HyperlinkGroupType { - - /** - * 返回支持的超级链接类型 - * @return NameableCreator[] - */ - public NameableCreator[] getHyperlinkCreators(); + + /** + * 返回支持的超级链接类型 + * + * @return NameableCreator[] + */ + NameableCreator[] getHyperlinkCreators(); + + + /** + * 图表超链过滤 + * + * @return 图表超链过滤 + */ + Filter> getFilter(); + + /** + * 老图表超链的过滤 + * + * @return 老图表超链的过滤 + */ + Filter getOldFilter(); } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/UICorrelationComboBoxPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/UICorrelationComboBoxPane.java index a1f92ddd0..79dece505 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/UICorrelationComboBoxPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/UICorrelationComboBoxPane.java @@ -8,7 +8,6 @@ import com.fr.design.dialog.DialogActionListener; import com.fr.design.dialog.UIDialog; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; -import com.fr.design.gui.HyperlinkFilterHelper; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenutable.UIMenuNameableCreator; @@ -16,20 +15,28 @@ import com.fr.design.gui.imenutable.UIMenuTable; import com.fr.design.hyperlink.ReportletHyperlinkPane; import com.fr.design.hyperlink.WebHyperlinkPane; import com.fr.design.javascript.EmailPane; +import com.fr.design.module.DesignModuleFactory; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; - import com.fr.js.AbstractJavaScript; import com.fr.js.EmailJavaScript; import com.fr.js.ReportletHyperlink; import com.fr.js.WebHyperlink; import com.fr.stable.ArrayUtils; +import com.fr.stable.Filter; import com.fr.stable.StringUtils; -import javax.swing.*; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.SwingUtilities; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.LayoutManager; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; @@ -76,6 +83,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver { /** * 刷新下拉列表和按钮 + * * @param values 下拉列表里的值 */ public void refreshMenuAndAddMenuAction(List values) { @@ -88,7 +96,8 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver { if (values.size() > 1) { for (UIMenuNameableCreator value : values) { final String itemName = value.getName(); - if(!HyperlinkFilterHelper.whetherAddHyperlink4Chart(itemName)){ + Filter filter = DesignModuleFactory.getHyperlinkGroupType().getOldFilter(); + if (!filter.accept(value.getObj())) { continue; } UIMenuItem item = new UIMenuItem(itemName); @@ -238,6 +247,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver { /** * 增加布局 + * * @param name 名字 * @param comp 组件 */ @@ -247,6 +257,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver { /** * 删除组件 + * * @param comp 组件 */ public void removeLayoutComponent(Component comp) { @@ -255,6 +266,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver { /** * 获得组件的大小 + * * @param parent 上层容器 * @return 组件的大小 */ @@ -265,6 +277,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver { /** * 最小的布局大小 + * * @param parent 上层容器 * @return 最小的大小 */ @@ -274,6 +287,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver { /** * 布局容器 + * * @param parent 上层容器 */ public void layoutContainer(Container parent) { @@ -287,6 +301,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver { /** * 增加监听事件 + * * @param l 监听的对象 */ public void addChangeListener(ChangeListener l) { @@ -296,6 +311,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver { /** * 删除监听事件 + * * @param l 需要删除的事件 */ public void removeChangeListener(ChangeListener l) { @@ -337,6 +353,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver { /** * 更新并且重载 当前列表的值 + * * @param list 更新的列表 */ public void populateBean(List list) { @@ -353,14 +370,14 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver { /** * 重置每个条目的名字 */ - public void resetItemName(){ - for(int i = 0; i < tablePane.getRowCount(); i++){ + public void resetItemName() { + for (int i = 0; i < tablePane.getRowCount(); i++) { UIMenuNameableCreator line = tablePane.getLine(i); Object obj = line.getObj(); - if(obj instanceof AbstractJavaScript){ - AbstractJavaScript script = (AbstractJavaScript)obj; + if (obj instanceof AbstractJavaScript) { + AbstractJavaScript script = (AbstractJavaScript) obj; String itemName = script.getItemName(); - if(!StringUtils.isBlank(itemName)){ + if (!StringUtils.isBlank(itemName)) { line.setName(itemName); } } @@ -369,6 +386,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver { /** * 测试例子界面 + * * @param args 参数向量 */ public static void main(String... args) { @@ -397,6 +415,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver { /** * 注册观察者监听事件 + * * @param listener 观察者监听事件 */ public void registerChangeListener(UIObserverListener listener) { @@ -406,6 +425,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver { /** * 是否需要响应事件 + * * @return 需要相应 */ public boolean shouldResponseChangeListener() { diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBox.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBox.java index 14a90da7b..e6130ca3d 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBox.java @@ -15,6 +15,7 @@ import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.util.List; import java.util.Vector; /** @@ -131,6 +132,21 @@ public class UIComboBox extends JComboBox implements UIObserver, GlobalNameObser return new Dimension(super.getPreferredSize().width + SIZE5, SIZE); } + public void refreshBoxItems(List list) { + Object ob = getSelectedItem(); + + removeAllItems(); + for (Object o : list) { + addItem(o); + } + + getModel().setSelectedItem(ob); + } + + public void clearBoxItems() { + removeAllItems(); + } + /** * 鼠标进入事件 */ diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/DataPaneHelper.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/DataPaneHelper.java index 3fb9d6a63..69cf88286 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/DataPaneHelper.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/DataPaneHelper.java @@ -21,15 +21,7 @@ public class DataPaneHelper { return; } - Object ob = box.getSelectedItem(); - box.removeAllItems(); - - int length = list.size(); - for (int i = 0; i < length; i++) { - box.addItem(list.get(i)); - } - - box.getModel().setSelectedItem(ob); + box.refreshBoxItems(list); } /** @@ -39,7 +31,7 @@ public class DataPaneHelper { */ public static void clearBoxItems(UIComboBox box) { if (box != null) { - box.removeAllItems(); + box.clearBoxItems(); } } diff --git a/designer-chart/src/main/java/com/fr/design/module/ChartHyperlinkGroup.java b/designer-chart/src/main/java/com/fr/design/module/ChartHyperlinkGroup.java index 583a669ef..4e5037109 100644 --- a/designer-chart/src/main/java/com/fr/design/module/ChartHyperlinkGroup.java +++ b/designer-chart/src/main/java/com/fr/design/module/ChartHyperlinkGroup.java @@ -7,12 +7,17 @@ import com.fr.design.chart.series.SeriesCondition.impl.ChartHyperPoplinkPane; import com.fr.design.chart.series.SeriesCondition.impl.ChartHyperRelateCellLinkPane; import com.fr.design.chart.series.SeriesCondition.impl.ChartHyperRelateFloatLinkPane; import com.fr.design.chart.series.SeriesCondition.impl.FormHyperlinkPane; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.frpane.BaseHyperlinkGroup; - +import com.fr.design.mainframe.BaseJForm; +import com.fr.design.mainframe.JTemplate; +import com.fr.general.ComparatorUtils; import com.fr.js.FormHyperlinkProvider; +import com.fr.js.JavaScript; import com.fr.stable.ArrayUtils; +import com.fr.stable.Filter; import com.fr.stable.bridge.StableFactory; /** @@ -31,12 +36,82 @@ public class ChartHyperlinkGroup extends BaseHyperlinkGroup { public NameableCreator[] getHyperlinkCreators() { FormHyperlinkProvider formHyperlink = StableFactory.getMarkedInstanceObjectFromClass(FormHyperlinkProvider.XML_TAG, FormHyperlinkProvider.class); - NameableCreator[] realted4CharthyperUse = { + NameableCreator[] related4ChartHyper = { new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Float_Chart"), ChartHyperPoplink.class, ChartHyperPoplinkPane.ChartNoRename.class), new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Cell"), ChartHyperRelateCellLink.class, ChartHyperRelateCellLinkPane.ChartNoRename.class), new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Float"), ChartHyperRelateFloatLink.class, ChartHyperRelateFloatLinkPane.ChartNoRename.class), new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Hyperlink_Form_Link"), formHyperlink.getClass(), FormHyperlinkPane.class)}; - return (NameableCreator[]) ArrayUtils.addAll(super.getHyperlinkCreators(), realted4CharthyperUse); + return ArrayUtils.addAll(super.getHyperlinkCreators(), related4ChartHyper); + + } + + @Override + public Filter> getFilter() { + return new Filter>() { + @Override + public boolean accept(Class clazz) { + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (template == null) { + return false; + } + + if (template.isJWorkBook()) { + // 如果是普通报表单元格,那么没有 FormHyperlink 选项 + FormHyperlinkProvider formHyperlink = StableFactory.getMarkedInstanceObjectFromClass(FormHyperlinkProvider.XML_TAG, FormHyperlinkProvider.class); + //返回true表示可用,返回false表示不可用 + return !ComparatorUtils.equals(clazz, formHyperlink.getClass()); + + } else { + // 如果是决策报表 + Class[] classes = new Class[]{ChartHyperRelateCellLink.class, ChartHyperRelateFloatLink.class}; + for (Class aClass : classes) { + if (template.getEditingReportIndex() == BaseJForm.FORM_TAB) { + // 编辑的是决策报表中的图表,那么没有ChartHyperRelateFloatLink 和 ChartHyperRelateCellLink 选项,有FormHyperlink 选项 + if (ComparatorUtils.equals(aClass, clazz)) { + return false; + } + } else if (template.getEditingReportIndex() == BaseJForm.ELEMENTCASE_TAB) { + // 编辑的是决策报表中的报表块,那么没有 ChartHyperRelateFloatLink,有ChartHyperRelateCellLink 和 FormHyperlink 选项 + return !ComparatorUtils.equals(clazz, ChartHyperRelateFloatLink.class); + } + } + } + return true; + } + }; + } + @Override + public Filter getOldFilter() { + return new Filter() { + @Override + public boolean accept(Object object) { + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (template == null) { + return false; + } + if (template.isJWorkBook()) { + // 如果是普通报表单元格,那么没有 FormHyperlink 选项 + FormHyperlinkProvider formHyperlink = StableFactory.getMarkedInstanceObjectFromClass(FormHyperlinkProvider.XML_TAG, FormHyperlinkProvider.class); + //返回true表示可用,返回false表示不可用 + return !ComparatorUtils.equals(object.getClass(), formHyperlink.getClass()); + } else { + // 如果是决策报表 + Class[] classes = new Class[]{ChartHyperRelateCellLink.class, ChartHyperRelateFloatLink.class}; + for (Class aClass : classes) { + if (template.getEditingReportIndex() == BaseJForm.FORM_TAB) { + // 编辑的是决策报表中的图表,那么没有ChartHyperRelateFloatLink 和 ChartHyperRelateCellLink 选项,有FormHyperlink 选项 + if (ComparatorUtils.equals(aClass, object.getClass())) { + return false; + } + } else if (template.getEditingReportIndex() == BaseJForm.ELEMENTCASE_TAB) { + // 编辑的是决策报表中的报表块,那么没有 ChartHyperRelateFloatLink,有ChartHyperRelateCellLink 和 FormHyperlink 选项 + return !ComparatorUtils.equals(object.getClass(), ChartHyperRelateFloatLink.class); + } + } + } + return true; + } + }; } } diff --git a/designer-chart/src/main/java/com/fr/design/module/FormHyperlinkGroup.java b/designer-chart/src/main/java/com/fr/design/module/FormHyperlinkGroup.java index 473d55a40..f10964d4c 100644 --- a/designer-chart/src/main/java/com/fr/design/module/FormHyperlinkGroup.java +++ b/designer-chart/src/main/java/com/fr/design/module/FormHyperlinkGroup.java @@ -8,7 +8,6 @@ import com.fr.design.chart.series.SeriesCondition.impl.FormHyperlinkPane; import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.frpane.BaseHyperlinkGroup; - import com.fr.js.FormHyperlinkProvider; import com.fr.stable.ArrayUtils; import com.fr.stable.bridge.StableFactory; @@ -23,15 +22,16 @@ public class FormHyperlinkGroup extends BaseHyperlinkGroup { /** * 返回支持的超级链接类型 + * * @return NameableCreator[] */ public NameableCreator[] getHyperlinkCreators() { - FormHyperlinkProvider formHyperlink = StableFactory.getMarkedInstanceObjectFromClass(FormHyperlinkProvider.XML_TAG, FormHyperlinkProvider.class); - NameableCreator[] realted4CharthyperUse = { + FormHyperlinkProvider formHyperlink = StableFactory.getMarkedInstanceObjectFromClass(FormHyperlinkProvider.XML_TAG, FormHyperlinkProvider.class); + NameableCreator[] related4ChartHyper = { new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Float_Chart"), ChartHyperPoplink.class, ChartHyperPoplinkPane.ChartNoRename.class), new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Cell"), ChartHyperRelateCellLink.class, ChartHyperRelateCellLinkPane.ChartNoRename.class), new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Hyperlink_Form_Link"), formHyperlink.getClass(), FormHyperlinkPane.class)}; - return (NameableCreator[]) ArrayUtils.addAll(super.getHyperlinkCreators(), realted4CharthyperUse); + return ArrayUtils.addAll(super.getHyperlinkCreators(), related4ChartHyper); } } diff --git a/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartTableDataPane.java b/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartTableDataPane.java index 0ac454634..e0bf8de70 100644 --- a/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartTableDataPane.java +++ b/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartTableDataPane.java @@ -10,13 +10,14 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.data.CalculateComboBox; import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.general.GeneralUtils; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.SwingConstants; import java.awt.BorderLayout; import java.awt.Component; import java.util.Arrays; import java.util.List; -import javax.swing.BorderFactory; -import javax.swing.JPanel; -import javax.swing.SwingConstants; /** * Created by shine on 2018/3/2. @@ -52,8 +53,8 @@ public abstract class AbstractExtendedChartTableDataPane fieldList = new ArrayList(); - public ExtendedCustomFieldComboBoxPane(boolean hasNoneItem) { - this.hasNoneItem = hasNoneItem; - } - @Override protected void initLayout() { this.setLayout(new BorderLayout(0, 6)); @@ -76,6 +70,10 @@ public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane