Browse Source

Pull request #10203: REPORT-75998 更改数据字典-公式的处理逻辑、增加勾选框的刷新逻辑、查找框无内容时替换框禁用、增加搜索模板Web属性引用JS

Merge in DESIGN/design from ~DESTINY.LIN/design:feature/x to feature/x

* commit '8548304e6266631af204bc8ff46a68c1fe79f5c3':
  REPORT-75998 修改部分格式
  REPORT-75998 增加搜索模板Web属性引用JS
  REPORT-75998 更改数据字典-公式的处理逻辑、增加勾选框的刷新逻辑、查找框无内容时替换框禁用 REPORT-75998 增加搜索模板Web属性引用JS
  REPORT-75998 更改数据字典-公式的处理逻辑、增加勾选框的刷新逻辑、查找框无内容时替换框禁用
feature/x
Destiny.Lin-林锦龙 2 years ago
parent
commit
04deec7620
  1. 19
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaTag.java
  2. 9
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/DictionaryType.java
  3. 20
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchWebJSAction.java
  4. 14
      designer-realize/src/main/java/com/fr/design/actions/replace/info/FormulaInfo.java
  5. 53
      designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java
  6. 12
      designer-realize/src/main/java/com/fr/design/actions/replace/info/base/SearchTag.java
  7. 27
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java
  8. 34
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java

19
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<Pair<Integer, Integer>> 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<Pair<Integer, Integer>> operatorArray) {
if (info.getContent().getHoldObject() instanceof FormulaDictionary) {
FormulaDictionary dictionary = (FormulaDictionary) info.getContent().getHoldObject();
dictionary.setProduceFormula(ShowValueUtils.replaceAll(dictionary.getProduceFormula(), findStr, replaceStr));
}
}
};
int index;

9
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));
}
}

20
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchWebJSAction.java

@ -4,6 +4,7 @@ import com.fr.design.actions.replace.info.JSInfo;
import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.design.actions.replace.info.base.SearchTag;
import com.fr.design.actions.replace.utils.SearchJSUtils;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.JTemplate;
@ -19,6 +20,7 @@ import com.fr.report.web.util.ReportEngineEventMapping;
import com.fr.web.attr.ReportWebAttr;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -86,12 +88,30 @@ public class SearchWebJSAction implements SearchJS {
content.setTemplateName(jTemplate.getTemplateName());
content.setJumpAble(false);
addWebContent2Array(webAttr);
//处理引用JS
dealImportJS(content,jsInfos,webAttr);
for (int i = 0; i < arrayList.size(); i++) {
addJSInfos2ListFromArray(content, jsInfos, arrayList.get(i));
}
}
}
private void dealImportJS(ITContent content, List<JSInfo> jsInfos, ReportWebAttr webAttr) {
if (webAttr != null){
for (String jsStr : webAttr.getJSImport()){
ITContent jsContent = ITContent.copy(content);
jsContent.addOtherPos(
Toolkit.i18nText("Fine-Design_Basic_Report_Web_Attributes"),
Toolkit.i18nText("Fine-Design_Report_Import_JavaScript")
);
jsContent.setReplaceObject(jsStr);
jsContent.setHoldObject(webAttr);
jsContent.setTag(SearchTag.IMPORT_JS);
jsInfos.add(new JSInfo(jsContent));
}
}
}
private void addJSInfos2ListFromServerWebAttr(ITContent content, List<JSInfo> jsInfos, WebContent webContent) {
ITContent newContent = ITContent.copy(content);
if (SERVER_MAP.containsKey(webContent.getClass().getSimpleName())) {

14
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<String, String> getValue(Object... o) {
Map<String, String> 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();
}
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<String, String> getCommonValue() {

53
designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java

@ -3,13 +3,16 @@ package com.fr.design.actions.replace.info;
import com.fr.data.impl.DBTableData;
import com.fr.design.actions.replace.utils.ShowValueUtils;
import com.fr.form.event.Listener;
import com.fr.general.GeneralUtils;
import com.fr.js.JavaScriptImpl;
import com.fr.js.NameJavaScript;
import com.fr.plugin.chart.base.VanChartHtmlLabel;
import com.fr.stable.StringUtils;
import com.fr.stable.collections.combination.Pair;
import com.fr.web.attr.ReportWebAttr;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -184,33 +187,71 @@ public enum ReplaceObject implements DealWithInfoValue {
return StringUtils.equals(javaScript.getContent(), info.getContent().getOldShowStr());
}
},
/**
* 模板Web属性引用JS
*/
IMPORT_JS("String") {
@Override
public Map<String, String> getValue(Object... o) {
HashMap<String, String> map = new HashMap<>();
addValue2Map(contentKey, GeneralUtils.objectToString(o[0]), map);
return map;
}
@Override
public void setValue(Info info, String findStr, String replaceStr, List<Pair<Integer, Integer>> operatorArray) {
if (info.getContent().getHoldObject() instanceof ReportWebAttr) {
ReportWebAttr attr = (ReportWebAttr) info.getContent().getHoldObject();
List<String> jsImports = Arrays.asList(attr.getJSImport());
String jsName = GeneralUtils.objectToString(info.getContent().getReplaceObject());
for (int i = 0, len = jsImports.size(); i < len; i++) {
if (StringUtils.equals(jsImports.get(i), jsName)) {
jsImports.set(i, ShowValueUtils.replaceAll(jsName, findStr, replaceStr));
}
}
attr.clearJSImportList();
for (int i = 0, len = jsImports.size(); i < len; i++) {
attr.addJSImport(jsImports.get(i));
}
}
}
@Override
public String getInfoShowStr(Info info) {
return GeneralUtils.objectToString(info.getContent().getReplaceObject());
}
@Override
boolean check(Info info) {
return true;
}
},
/**
* DBTableDataSQL
*/
DB_TABLE_DATA("DBTableData") {
@Override
boolean check(Info info) {
boolean check (Info info){
DBTableData dbTableData = (DBTableData) info.getContent().getReplaceObject();
return StringUtils.equals(dbTableData.getQuery(), info.getContent().getOldShowStr());
}
@Override
public Map<String, String> getValue(Object... o) {
public Map<String, String> getValue (Object...o){
HashMap<String, String> map = new HashMap<>();
addValue2Map(contentKey, ((DBTableData) o[0]).getQuery(), map);
return map;
}
@Override
public void setValue(Info info, String findStr, String replaceStr, List<Pair<Integer, Integer>> operatorArray) {
public void setValue (Info info, String findStr, String replaceStr, List < Pair < Integer, Integer >> operatorArray){
DBTableData dbTableData = (DBTableData) info.getContent().getReplaceObject();
info.updateOldStr(dbTableData.getQuery(), findStr);
dbTableData.setQuery(ShowValueUtils.replaceAll(dbTableData.getQuery(), findStr, replaceStr));
//todo DesignTableDataManager
}
@Override
public String getInfoShowStr(Info info) {
public String getInfoShowStr (Info info){
return info.getInfoShowStr(info);
}
};
@ -256,4 +297,4 @@ public enum ReplaceObject implements DealWithInfoValue {
abstract boolean check(Info info);
}
}

12
designer-realize/src/main/java/com/fr/design/actions/replace/info/base/SearchTag.java

@ -44,6 +44,18 @@ 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;
/**
* 引用JS
*/
public static final int IMPORT_JS = 11;

27
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("<html>" + Toolkit.i18nText("Fine-Design_Replace_Search_Finish") + "<font color = 'rgb(61,153,249)'>" + searchResultList.size() + "</font>" + 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
}

34
designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java

@ -72,10 +72,29 @@ public class ITTableEditorPane<T> extends BasicPane {
int col = ((JTable) e.getSource()).columnAtPoint(e.getPoint());
if (col == ITReplaceSouthPanel.CHECKBOX_INDEX) {
ITContent content = (ITContent) editTable.getValueAt(row, ITReplaceSouthPanel.CONTENT_INDEX);
//改变面板的各个状态
changeComponentStatus(content, row, col);
}
}
});
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);
@ -83,16 +102,13 @@ public class ITTableEditorPane<T> extends BasicPane {
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());
}
}
});
UIScrollPane scrollPane = new UIScrollPane(editTable);
scrollPane.setBorder(new UIRoundedBorder(UIConstants.TITLED_BORDER_COLOR, 1, UIConstants.ARC));
pane.add(scrollPane, BorderLayout.CENTER);
}
public UITableModelAdapter<T> getTableModel() {
return tableModel;
@ -142,8 +158,8 @@ public class ITTableEditorPane<T> 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);

Loading…
Cancel
Save