From cd0e098e4397504c7203575bfed48adc03275132 Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Thu, 1 Jun 2017 21:39:40 +0800 Subject: [PATCH] =?UTF-8?q?alphafine=20=E8=AE=BE=E7=BD=AE=E7=9A=84?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF=E5=86=85=E5=AE=B9=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../report/ReportEngineAttrAction.java | 7 +- .../report/ReportExportAttrAction.java | 5 +- .../report/ReportMobileAttrAction.java | 4 +- .../actions/report/ReportPageAttrAction.java | 4 +- .../actions/report/ReportPageSetupAction.java | 4 +- .../actions/report/ReportWebAttrAction.java | 4 +- .../actions/report/ReportWriteAttrAction.java | 4 +- .../server/ServerConfigManagerAction.java | 4 +- .../actions/server/StyleListAction.java | 4 +- .../com/fr/design/actions/UpdateAction.java | 79 +++++++++++++++++++ .../design/actions/file/PreferenceAction.java | 56 ++++++------- .../fr/design/actions/help/AboutAction.java | 8 ++ .../help/alphafine/AlphafineAction.java | 4 +- .../actions/server/FunctionManagerAction.java | 4 +- .../design/gui/frpane/LoadingBasicPane.java | 7 ++ .../mainframe/toolbar/UpdateActionModel.java | 19 +++++ .../fr/design/module/ChartPreStyleAction.java | 4 +- 17 files changed, 182 insertions(+), 39 deletions(-) diff --git a/designer/src/com/fr/design/actions/report/ReportEngineAttrAction.java b/designer/src/com/fr/design/actions/report/ReportEngineAttrAction.java index 796e3b638e..bb5942bd43 100644 --- a/designer/src/com/fr/design/actions/report/ReportEngineAttrAction.java +++ b/designer/src/com/fr/design/actions/report/ReportEngineAttrAction.java @@ -8,6 +8,7 @@ import com.fr.design.menu.KeySetUtils; import com.fr.design.report.LayerReportPane; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; +import com.fr.general.IOUtils; import com.fr.report.worksheet.WorkSheet; public class ReportEngineAttrAction extends ReportComponentAction { @@ -17,7 +18,11 @@ public class ReportEngineAttrAction extends ReportComponentAction componentMap; + private String searchText = StringUtils.EMPTY; + /** * Constructor */ @@ -426,4 +432,77 @@ public abstract class UpdateAction extends ShortCut implements Action { return menuItem; } + + public void setSearchText(JPanel panel) { + if (panel instanceof LoadingBasicPane) { + ((LoadingBasicPane) panel).initForSearch(); + } + this.searchText = getComponentTexts(panel, new StringBuffer()); + + } + + /** + * 获取搜索匹配字符串 + * @return + */ + public String getSearchText() { + return searchText; + } + + /** + * 遍历面板中所有控件,获取text用于alphafine的action搜索 + * @param panel + * @param stringBuffer + * @return + */ + public String getComponentTexts(JPanel panel, StringBuffer stringBuffer) { + Border border = panel.getBorder(); + if (border instanceof TitledBorder) { + stringBuffer.append(((TitledBorder) border).getTitle()); + } + Component[] components = panel.getComponents(); + for (Component component : components) { + if (component instanceof JPanel) { + getComponentTexts((JPanel) component, stringBuffer); + } else if (component instanceof JScrollPane) { + Component childComponent = ((JScrollPane) component).getViewport().getView(); + if (childComponent instanceof JPanel) { + getComponentTexts((JPanel) childComponent, stringBuffer); + } + } else if (component instanceof JLabel) { + stringBuffer.append(((JLabel) component).getText()); + } else if (component instanceof JCheckBox) { + stringBuffer.append(((JCheckBox) component).getText()); + } else if (component instanceof JButton) { + stringBuffer.append(((JButton) component).getText()); + } else if (component instanceof JRadioButton) { + stringBuffer.append(((JRadioButton) component).getText()); + } else if (component instanceof JComboBox) { + for (int i = 0; i < ((JComboBox) component).getItemCount(); i++) { + stringBuffer.append(((JComboBox) component).getItemAt(i)); + } + } else if (component instanceof JTabbedPane) { + getTabPaneTexts(stringBuffer, (JTabbedPane) component); + } + } + return String.valueOf(stringBuffer); + } + + /** + * 递归遍历tabbedPane + * @param stringBuffer + * @param component + */ + private void getTabPaneTexts(StringBuffer stringBuffer, JTabbedPane component) { + for (int i = 0; i < component.getTabCount(); i++) { + stringBuffer.append(component.getTitleAt(i)); + Component tabComponent = component.getComponentAt(i); + if (tabComponent instanceof JPanel) { + getComponentTexts((JPanel) tabComponent, stringBuffer); + } else if (tabComponent instanceof JTabbedPane) { + getTabPaneTexts(stringBuffer, (JTabbedPane) tabComponent); + } + } + } + } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/actions/file/PreferenceAction.java b/designer_base/src/com/fr/design/actions/file/PreferenceAction.java index 71c25837db..f9f222c1be 100644 --- a/designer_base/src/com/fr/design/actions/file/PreferenceAction.java +++ b/designer_base/src/com/fr/design/actions/file/PreferenceAction.java @@ -1,47 +1,49 @@ package com.fr.design.actions.file; -import java.awt.event.ActionEvent; - import com.fr.design.DesignerEnvManager; import com.fr.design.actions.UpdateAction; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrame; import com.fr.design.mainframe.JTemplate; import com.fr.design.menu.KeySetUtils; -import com.fr.design.dialog.BasicDialog; -import com.fr.design.dialog.DialogActionAdapter; + +import java.awt.event.ActionEvent; public class PreferenceAction extends UpdateAction { - public PreferenceAction() { + public PreferenceAction() { this.setMenuKeySet(KeySetUtils.PREFERENCE); - this.setName(getMenuKeySet().getMenuKeySetName()+"..."); + this.setName(getMenuKeySet().getMenuKeySetName() + "..."); this.setMnemonic(getMenuKeySet().getMnemonic()); - } + this.setSearchText(new PreferencePane()); + } /** * 动作 + * * @param e 事件 */ - public void actionPerformed(ActionEvent e) { - final DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); - - final PreferencePane preferencePane = new PreferencePane(); - preferencePane.populate(DesignerEnvManager.getEnvManager()); - - BasicDialog basicDialog = preferencePane.showWindow(designerFrame); - basicDialog.addDialogActionListener(new DialogActionAdapter() { - public void doOk() { - preferencePane.update(DesignerEnvManager.getEnvManager()); - DesignerEnvManager.loadLogSetting(); - DesignerEnvManager.getEnvManager().saveXMLFile(); - JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - jt.refreshToolArea(); - preferencePane.showRestartDialog(); - } - }); - - basicDialog.setVisible(true); - } + public void actionPerformed(ActionEvent e) { + final DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); + + final PreferencePane preferencePane = new PreferencePane(); + preferencePane.populate(DesignerEnvManager.getEnvManager()); + + BasicDialog basicDialog = preferencePane.showWindow(designerFrame); + basicDialog.addDialogActionListener(new DialogActionAdapter() { + public void doOk() { + preferencePane.update(DesignerEnvManager.getEnvManager()); + DesignerEnvManager.loadLogSetting(); + DesignerEnvManager.getEnvManager().saveXMLFile(); + JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + jt.refreshToolArea(); + preferencePane.showRestartDialog(); + } + }); + + basicDialog.setVisible(true); + } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/actions/help/AboutAction.java b/designer_base/src/com/fr/design/actions/help/AboutAction.java index 1c3c48d0ec..0b7b77571d 100644 --- a/designer_base/src/com/fr/design/actions/help/AboutAction.java +++ b/designer_base/src/com/fr/design/actions/help/AboutAction.java @@ -7,8 +7,12 @@ import com.fr.design.actions.UpdateAction; import com.fr.design.mainframe.DesignerContext; import com.fr.design.menu.MenuKeySet; import com.fr.general.Inter; +import com.fr.stable.StringUtils; +import org.eclipse.swt.internal.ole.win32.COM; +import javax.imageio.plugins.jpeg.JPEGHuffmanTable; import javax.swing.*; +import java.awt.*; import java.awt.event.ActionEvent; /** @@ -19,6 +23,7 @@ public class AboutAction extends UpdateAction { this.setMenuKeySet(ABOUT); this.setName(getMenuKeySet().getMenuKeySetName()+"..."); this.setMnemonic(getMenuKeySet().getMnemonic()); + this.setSearchText(new AboutPane()); } /** @@ -47,4 +52,7 @@ public class AboutAction extends UpdateAction { return null; } }; + + + } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/actions/help/alphafine/AlphafineAction.java b/designer_base/src/com/fr/design/actions/help/alphafine/AlphafineAction.java index fdd6e060e2..23cf7de758 100644 --- a/designer_base/src/com/fr/design/actions/help/alphafine/AlphafineAction.java +++ b/designer_base/src/com/fr/design/actions/help/alphafine/AlphafineAction.java @@ -9,6 +9,7 @@ import com.fr.design.dialog.DialogActionListener; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrame; import com.fr.design.menu.MenuKeySet; +import com.fr.general.IOUtils; import javax.swing.*; import java.awt.event.ActionEvent; @@ -21,7 +22,8 @@ public class AlphafineAction extends UpdateAction { this.setMenuKeySet(ALPHAFINE); this.setName(getMenuKeySet().getMenuName()); this.setMnemonic(getMenuKeySet().getMnemonic()); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/mainframe/alphafine/images/smallsearch.png")); + this.setSmallIcon(IOUtils.readIcon("/com/fr/design/mainframe/alphafine/images/smallsearch.png")); + this.setSearchText(new AlphafineConfigPane()); } public static final MenuKeySet ALPHAFINE = new MenuKeySet() { diff --git a/designer_base/src/com/fr/design/actions/server/FunctionManagerAction.java b/designer_base/src/com/fr/design/actions/server/FunctionManagerAction.java index 664d448622..7467a00eaf 100644 --- a/designer_base/src/com/fr/design/actions/server/FunctionManagerAction.java +++ b/designer_base/src/com/fr/design/actions/server/FunctionManagerAction.java @@ -14,6 +14,7 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.design.menu.MenuKeySet; import com.fr.file.FunctionManager; import com.fr.file.FunctionManagerProvider; +import com.fr.general.IOUtils; import com.fr.general.Inter; import javax.swing.*; @@ -28,7 +29,8 @@ public class FunctionManagerAction extends UpdateAction { this.setMenuKeySet(FUNCTION_MANAGER); this.setName(getMenuKeySet().getMenuKeySetName()+"..."); this.setMnemonic(getMenuKeySet().getMnemonic()); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_web/function.png")); + this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/m_web/function.png")); + this.setSearchText(new FunctionManagerPane()); } /** diff --git a/designer_base/src/com/fr/design/gui/frpane/LoadingBasicPane.java b/designer_base/src/com/fr/design/gui/frpane/LoadingBasicPane.java index 32a2118076..4ca17be09c 100644 --- a/designer_base/src/com/fr/design/gui/frpane/LoadingBasicPane.java +++ b/designer_base/src/com/fr/design/gui/frpane/LoadingBasicPane.java @@ -74,6 +74,13 @@ public abstract class LoadingBasicPane extends BasicPane { } + /** + * 为了alphafine搜索,需要初始化的时候加载一次组件 + */ + public void initForSearch() { + initComponents(new JPanel()); + } + /** * 完成时 */ diff --git a/designer_base/src/com/fr/design/mainframe/toolbar/UpdateActionModel.java b/designer_base/src/com/fr/design/mainframe/toolbar/UpdateActionModel.java index ad3db0348d..4884f0f952 100644 --- a/designer_base/src/com/fr/design/mainframe/toolbar/UpdateActionModel.java +++ b/designer_base/src/com/fr/design/mainframe/toolbar/UpdateActionModel.java @@ -12,12 +12,15 @@ import com.fr.design.actions.UpdateAction; public class UpdateActionModel { private String parentName; private String actionName; + private String relatedKey; + private String searchKey; private UpdateAction action; public UpdateActionModel(String parentName, UpdateAction action) { this.parentName = parentName; this.action = action; this.actionName = action.getName(); + this.searchKey = action.getSearchText(); } /** @@ -55,4 +58,20 @@ public class UpdateActionModel { public void setActionName(String actionName) { this.actionName = actionName; } + + public String getRelatedKey() { + return relatedKey; + } + + public void setRelatedKey(String relatedKey) { + this.relatedKey = relatedKey; + } + + public String getSearchKey() { + return searchKey; + } + + public void setSearchKey(String searchKey) { + this.searchKey = searchKey; + } } diff --git a/designer_chart/src/com/fr/design/module/ChartPreStyleAction.java b/designer_chart/src/com/fr/design/module/ChartPreStyleAction.java index 36909565bf..e93b271e2f 100644 --- a/designer_chart/src/com/fr/design/module/ChartPreStyleAction.java +++ b/designer_chart/src/com/fr/design/module/ChartPreStyleAction.java @@ -9,6 +9,7 @@ import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrame; import com.fr.design.menu.MenuKeySet; +import com.fr.general.IOUtils; import com.fr.general.Inter; import javax.swing.*; @@ -25,7 +26,8 @@ public class ChartPreStyleAction extends UpdateAction { this.setMenuKeySet(CHART_DEFAULT_STYLE); this.setName(getMenuKeySet().getMenuKeySetName()+ "..."); this.setMnemonic(getMenuKeySet().getMnemonic()); - this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/chart/ChartType.png")); + this.setSmallIcon(IOUtils.readIcon("com/fr/design/images/chart/ChartType.png")); + this.setSearchText(new ChartPreStyleManagerPane()); } /**