diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaTag.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaTag.java index ff8755974b..c3f3c83a1d 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaTag.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaTag.java @@ -2,6 +2,7 @@ package com.fr.design.actions.replace.action.content.formula; import com.fr.chart.chartdata.MeterReportDefinition; import com.fr.data.VerifyItem; +import com.fr.data.impl.FormulaDictionary; import com.fr.design.actions.replace.info.DealWithInfoValue; import com.fr.design.actions.replace.info.Info; import com.fr.design.actions.replace.info.base.SearchTag; @@ -133,6 +134,24 @@ public enum FormulaTag implements DealWithInfoValue { attr.setTooltipText(ShowValueUtils.replaceAll(attr.getTooltipText(), findStr, replaceStr)); } } + }, + DICT_EXCUTE(SearchTag.DICT_EXCUTE) { + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + if (info.getContent().getHoldObject() instanceof FormulaDictionary) { + FormulaDictionary dictionary = (FormulaDictionary) info.getContent().getHoldObject(); + dictionary.setExcuteFormula(ShowValueUtils.replaceAll(dictionary.getExcuteFormula(), findStr, replaceStr)); + } + } + }, + DICT_PRODUCE(SearchTag.DICT_PRODUCE) { + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + if (info.getContent().getHoldObject() instanceof FormulaDictionary) { + FormulaDictionary dictionary = (FormulaDictionary) info.getContent().getHoldObject(); + dictionary.setProduceFormula(ShowValueUtils.replaceAll(dictionary.getProduceFormula(), findStr, replaceStr)); + } + } }; int index; diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/DictionaryType.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/DictionaryType.java index 22d4cb3959..6a55aebf9b 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/DictionaryType.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/DictionaryType.java @@ -6,6 +6,7 @@ import com.fr.data.impl.FormulaDictionary; import com.fr.data.impl.TableDataDictionary; import com.fr.design.actions.replace.info.FormulaInfo; import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.actions.replace.info.base.SearchTag; import com.fr.design.i18n.Toolkit; import org.jetbrains.annotations.Nullable; @@ -32,23 +33,27 @@ public enum DictionaryType implements DictionaryAction { //显示值 if (formulaDictionary.getExcuteFormula() != null) { ITContent excuteContent = ITContent.copy(content); - excuteContent.setReplaceObject(dictionary); + excuteContent.setReplaceObject(formulaDictionary.getExcuteFormula()); excuteContent.addOtherPos( Toolkit.i18nText("Fine-Design_Basic_DS_Dictionary"), Toolkit.i18nText("Fine-Design_Basic_Formula"), Toolkit.i18nText("Fine-Design_Basic_Display_Value") ); + excuteContent.setHoldObject(dictionary); + excuteContent.setTag(SearchTag.DICT_EXCUTE); formulaInfos.add(new FormulaInfo(excuteContent)); } //实际值 if (formulaDictionary.getProduceFormula() != null) { ITContent produceContent = ITContent.copy(content); - produceContent.setReplaceObject(dictionary); + produceContent.setReplaceObject(formulaDictionary.getProduceFormula()); produceContent.addOtherPos( Toolkit.i18nText("Fine-Design_Basic_DS_Dictionary"), Toolkit.i18nText("Fine-Design_Basic_Formula"), Toolkit.i18nText("Fine-Design_Basic_Actual_Value") ); + produceContent.setHoldObject(dictionary); + produceContent.setTag(SearchTag.DICT_PRODUCE); formulaInfos.add(new FormulaInfo(produceContent)); } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/FormulaInfo.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/FormulaInfo.java index 73a0750cb8..ce2ecd36c6 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/FormulaInfo.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/FormulaInfo.java @@ -40,14 +40,7 @@ public class FormulaInfo implements Info { @Override public Map getValue(Object... o) { Map map = new HashMap<>(); - //这边比较特殊,存的都是FormulaDictionary ,特殊判断一下 - if (this.content.getOtherPos().contains(DISPLAY)) { - map.put("content", ((FormulaDictionary) this.getContent().getReplaceObject()).getExcuteFormula()); - } else if (this.content.getOtherPos().contains(ACTUAL)) { - map.put("content", ((FormulaDictionary) this.getContent().getReplaceObject()).getProduceFormula()); - } else { - map = getCommonValue(); - } + map = getCommonValue(); return map; } @@ -70,11 +63,8 @@ public class FormulaInfo implements Info { @Override public Boolean checkValid() { - FormulaReplaceObject formulaReplaceObject = FormulaReplaceObject.match(this.content.getReplaceObject().getClass().getSimpleName()); - if (formulaReplaceObject != null) { - return formulaReplaceObject.check(this); - } - return false; + //校验二期才完善,目前都给过 + return true; } private Map getCommonValue() { diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/SearchTag.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/SearchTag.java index 1bbba05b35..956d3ff386 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/SearchTag.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/SearchTag.java @@ -44,6 +44,14 @@ public class SearchTag { * 单元格属性-其他-内容提示 */ public static final int CELL_TOOL_TIP = 8; + /** + * 数据字典-公式-显示值 + */ + public static final int DICT_EXCUTE = 9; + /** + * 数据字典-公式-实际值 + */ + public static final int DICT_PRODUCE = 10; diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java index 96ee17b6cd..4843df57f4 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java @@ -9,6 +9,7 @@ import com.fr.design.actions.replace.utils.ShowValueUtils; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.UIDialog; import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; @@ -22,6 +23,7 @@ import com.fr.stable.StringUtils; import javax.swing.JOptionPane; import javax.swing.JPanel; import java.awt.BorderLayout; +import java.awt.Color; import java.awt.Dimension; import java.awt.Point; import java.awt.event.ActionEvent; @@ -117,8 +119,10 @@ public class ITReplaceMainDialog extends UIDialog { JPanel center = new JPanel(new BorderLayout()); + UIComboBox replaceComboBox = northPane.getReplaceInputCombobox(); northPane.getFindInputCombobox().setEditable(true); - northPane.getReplaceInputCombobox().setEditable(false); + replaceComboBox.setEnabled(false); + replaceComboBox.setEditable(true); northPane.getReplaceButton().setEnabled(false); ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).setPlaceholder(Toolkit.i18nText("Fine-Design_Replace_Search_Input")); @@ -160,7 +164,8 @@ public class ITReplaceMainDialog extends UIDialog { private void replace() { String searchStr = ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).getText(); String replaceStr = ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).getText(); - if (StringUtils.equals(getSearchStr(), searchStr)) { + //替换内容为空需要触发搜索 + if (StringUtils.equals(getSearchStr(), searchStr) && StringUtils.isNotEmpty(replaceStr)) { if (isITReplaceValid() && checkTemplateChanged(searchResultList)) { for (Info info : searchResultList) { if (info.getContent().isSelected()) { @@ -298,7 +303,8 @@ public class ITReplaceMainDialog extends UIDialog { northPane.getResultLabel().setText("" + Toolkit.i18nText("Fine-Design_Replace_Search_Finish") + "" + searchResultList.size() + "" + Toolkit.i18nText("Fine-Design_Replace_Result")); } ITTableEditorPane.ITHeaderRenderer renderer = (ITTableEditorPane.ITHeaderRenderer) getEditTable().getTableHeader().getDefaultRenderer(); - renderer.refreshHeader(getEditTable()); + //刷新表头,并且重新勾选中表头全选框 + renderer.refreshHeader(getEditTable(), true); itTableEditor.fireTableDataChanged(); northPane.refreshFindInputComboBoxItems(); setSearchFlag(true); @@ -306,18 +312,17 @@ public class ITReplaceMainDialog extends UIDialog { //如果有结果,默认选中第一行 if (searchResultList.size() > 0){ getEditTable().addRowSelectionInterval(FIRST_ROW,FIRST_ROW); - northPane.getReplaceButton().setEnabled(true); } - - //设置替换输入框的可用性 - if (StringUtils.isNotEmpty(searchStr)) { - ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).setEditable(true); - northPane.getReplaceInputCombobox().setEditable(true); + //更新替换按钮可用性 + if (StringUtils.isEmpty(searchStr) || searchResultList.size() == 0){ + northPane.getReplaceButton().setEnabled(false); } else { - ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).setEditable(false); - northPane.getReplaceInputCombobox().setEditable(false); + northPane.getReplaceButton().setEnabled(true); } + + //设置替换输入框的可用性 + northPane.getReplaceInputCombobox().setEnabled(StringUtils.isNotEmpty(searchStr)); } else { //todo } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java index 4d2f39718d..0a743d34eb 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java @@ -72,17 +72,8 @@ public class ITTableEditorPane extends BasicPane { int col = ((JTable) e.getSource()).columnAtPoint(e.getPoint()); if (col == ITReplaceSouthPanel.CHECKBOX_INDEX) { ITContent content = (ITContent) editTable.getValueAt(row, ITReplaceSouthPanel.CONTENT_INDEX); - if (content.isSelected()) { - content.setSelected(false); - editTable.setValueAt(content.isSelected(), row, col); - ITReplaceMainDialog.selectCount--; - ITReplaceMainDialog.getInstance().getNorthPane().getReplaceButton().setEnabled(ITReplaceMainDialog.selectCount > 0); - } else { - content.setSelected(true); - editTable.setValueAt(content.isSelected(), row, col); - ITReplaceMainDialog.selectCount++; - ITReplaceMainDialog.getInstance().getNorthPane().getReplaceButton().setEnabled(true); - } + //改变面板的各个状态 + changeComponentStatus(content, row, col); } } @@ -90,10 +81,35 @@ public class ITTableEditorPane extends BasicPane { UIScrollPane scrollPane = new UIScrollPane(editTable); scrollPane.setBorder(new UIRoundedBorder(UIConstants.TITLED_BORDER_COLOR, 1, UIConstants.ARC)); pane.add(scrollPane, BorderLayout.CENTER); + } - + /** + * 改变面板的各个状态(替换按钮、表头勾选框) + * @param content + * @param row + * @param col + */ + public void changeComponentStatus(ITContent content, int row, int col) { + if (content.isSelected()) { + content.setSelected(false); + editTable.setValueAt(content.isSelected(), row, col); + ITReplaceMainDialog.selectCount--; + //如果没有选中,替换按钮需要置灰 + ITReplaceMainDialog.getInstance().getNorthPane().getReplaceButton().setEnabled(ITReplaceMainDialog.selectCount > 0); + } else { + content.setSelected(true); + editTable.setValueAt(content.isSelected(), row, col); + ITReplaceMainDialog.selectCount++; + ITReplaceMainDialog.getInstance().getNorthPane().getReplaceButton().setEnabled(true); + } + //更新表头的勾选框状态 + if (editTable.getTableHeader().getDefaultRenderer() instanceof ITHeaderRenderer) { + ITHeaderRenderer renderer = (ITHeaderRenderer) editTable.getTableHeader().getDefaultRenderer(); + renderer.refreshHeader(editTable, ITReplaceMainDialog.selectCount >= editTable.getRowCount()); + } } + public UITableModelAdapter getTableModel() { return tableModel; } @@ -142,8 +158,8 @@ public class ITTableEditorPane extends BasicPane { * * @param table */ - public void refreshHeader(JTable table) { - selectBox.setSelected(true); + public void refreshHeader(JTable table, boolean value) { + selectBox.setSelected(value); int rowHeight = table.getRowHeight(); table.updateUI(); table.setRowHeight(rowHeight);