Browse Source

Pull request #10207: REPORT-75998 修复查找完成后打开新模板无查找内容不符的提示,修复输入img返回结果不正确的bug

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

* commit '0afa23c3c33303301601d293090b6e3e9fe38acd':
  REPORT-75998 修复数据集面板不更新的bug、优化魔术数
  REPORT-75998 修复查找完成后打开新模板无查找内容不符的提示,修复输入img返回结果不正确的bug
feature/x
Destiny.Lin-林锦龙 2 years ago
parent
commit
d6cd0d3618
  1. 7
      designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java
  2. 13
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java
  3. 9
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java
  4. 108
      designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java

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

@ -1,7 +1,10 @@
package com.fr.design.actions.replace.info;
import com.fr.data.impl.DBTableData;
import com.fr.design.DesignModelAdapter;
import com.fr.design.actions.replace.utils.ShowValueUtils;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.TableDataTreePane;
import com.fr.form.event.Listener;
import com.fr.general.GeneralUtils;
import com.fr.js.JavaScriptImpl;
@ -248,6 +251,10 @@ public enum ReplaceObject implements DealWithInfoValue {
DBTableData dbTableData = (DBTableData) info.getContent().getReplaceObject();
info.updateOldStr(dbTableData.getQuery(), findStr);
dbTableData.setQuery(ShowValueUtils.replaceAll(dbTableData.getQuery(), findStr, replaceStr));
//清除缓存
DesignTableDataManager.removeSelectedColumnNames(dbTableData.getName());
//收缩菜单
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).refreshDockingView();
}
@Override

13
designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java

@ -48,6 +48,7 @@ public class ITReplaceMainDialog extends UIDialog {
private static boolean matched = false;
private static volatile ITReplaceMainDialog instance = null;
private static String templateID;
private static String templateName;
private ITReplaceNorthPanel northPane;
private ITReplaceSouthPanel southPanel;
private ITReplaceWestPanel westPanel;
@ -165,8 +166,9 @@ public class ITReplaceMainDialog extends UIDialog {
String searchStr = ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).getText();
String replaceStr = ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).getText();
//替换内容为空需要触发搜索
if (StringUtils.equals(getSearchStr(), searchStr) && StringUtils.isNotEmpty(replaceStr)) {
if (isITReplaceValid() && checkTemplateChanged(searchResultList)) {
if (StringUtils.equals(getSearchStr(), searchStr) && StringUtils.isNotEmpty(replaceStr)) {
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(true);
for (Info info : searchResultList) {
if (info.getContent().isSelected()) {
info.setValue(info, searchStr, replaceStr, info.getContent().getOperatorArray());
@ -175,8 +177,8 @@ public class ITReplaceMainDialog extends UIDialog {
southPanel.getTableEditorPane().update();
northPane.refreshReplaceInputComboBoxItems();
ITTableEditorPane.getEditTable().repaint();
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(true);
setSearchFlag(false);
}
search();
} else {
Object[] options = new Object[]{Toolkit.i18nText("Fine-Design_Replace_Search_Again"), Toolkit.i18nText("Fine-Design_Basic_Cancel")};
@ -196,9 +198,6 @@ public class ITReplaceMainDialog extends UIDialog {
search();
}
}
} else {
search();
}
}
@ -220,7 +219,8 @@ public class ITReplaceMainDialog extends UIDialog {
*/
public boolean isITReplaceValid() {
if (JTemplate.isValid(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate())) {
return StringUtils.equals(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget().getTemplateID(), templateID);
return StringUtils.equals(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget().getTemplateID(), templateID)
&& StringUtils.equals(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTemplateName(), templateName);
} else {
return false;
}
@ -288,6 +288,7 @@ public class ITReplaceMainDialog extends UIDialog {
if (JTemplate.isValid(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate())) {
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
templateID = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget().getTemplateID();
templateName = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTemplateName();
itTableEditor.clear();
String searchStr = ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).getText();
//更新搜索内容

9
designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java

@ -6,13 +6,14 @@ import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.ReportComponentComposite;
import com.fr.file.FILEFactory;
import com.fr.general.GeneralUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import javax.swing.AbstractCellEditor;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import java.awt.Component;
@ -42,7 +43,9 @@ public class ITTableButton extends AbstractCellEditor implements TableCellEditor
ITContent content = (ITContent) getEditTable().getValueAt(getEditTable().getEditingRow(), 6);
if (StringUtils.isNotEmpty(GeneralUtils.objectToString(content.getTrlString()))) {
ITReplaceMainDialog.setITReplaceFlag(true);
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().navigate(new TRL(GeneralUtils.objectToString(content.getTrlString())));
TRL trl = new TRL(GeneralUtils.objectToString(content.getTrlString()));
DesignerContext.getDesignerFrame().openTemplate(FILEFactory.createFILE(ProjectConstants.REPORTLETS_NAME + FILEFactory.SEPARATOR + content.getTemplateName()));
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().navigate(trl);
}
ITReplaceMainDialog.setITReplaceFlag(false);
}

108
designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java

@ -28,6 +28,33 @@ public class ShowValueUtils {
public static final String ANY_THING_REGEX = ".";
public static final String NUMBER_REGEX = "[0-9]";
public static final String ENGLISH_REGEX = "[a-zA-Z]";
public static final char LEFT_HTML_CHAR = '<';
public static final char RIGHT_HTML_CHAR = '>';
public static final String HEAD = "<html><nobr>";
public static final String TAIL = "</nobr></html>";
public static final String FONT_HEAD = "<font color = 'rgb(61,153,249)'>";
public static final String FONT_TAIL = "</font>";
public static final String HTML = "<html>";
public static final String NOBR = "<nobr>";
public static final String HTML_TAIL = "</html>";
public static final String NOBR_TAIL = "</nobr>";
public static final int HEAD_LEN = HEAD.length();
public static final int TAIL_LEN = TAIL.length();
public static final int FONT_HEAD_LEN = FONT_HEAD.length();
public static final int FONT_TAIL_LEN = FONT_TAIL.length();
public static final int HTML_LEN = HTML.length();
public static final int HTML_TAIL_LEN = HTML_TAIL.length();
public static final int NOBR_LEN = NOBR.length();
public static final int NOBR_TAIL_LEN = NOBR_TAIL.length();
/**
* <转变为&lt;的长度差
*/
public static final int LEFT_DIFFERENT = 3;
/**
* >转变为&gt的长度差
*/
public static final int RIGHT_DIFFERENT = 2;
public static Pattern containPattern;
private static List<String> specialCharList = new ArrayList<>();
@ -135,26 +162,73 @@ public class ShowValueUtils {
String result = str;
Pattern pattern = containPattern;
Matcher matcher = pattern.matcher(str);
String head = "<font color = 'rgb(61,153,249)'>";
String tail = "</font>";
int size = head.length() + tail.length();
int size = FONT_HEAD.length() + FONT_TAIL.length();
int index = 0;
StringBuilder builder = new StringBuilder(str);
while (matcher.find()) {
builder.replace(matcher.start() + index, matcher.end() + index, head + changeHtmlStr(matcher.group()) + tail);
builder.replace(matcher.start() + index, matcher.end() + index, FONT_HEAD + changeHtmlStr(matcher.group()) + FONT_TAIL);
index += size;
index += getIncreaseCount(matcher.group());
}
return "<html><body><div><nobr>" +
builder.toString() +
"</nobr></div></body></html>";
return changeOriginHtmlStr(HEAD + builder.toString() + TAIL);
} else {
return "<html><body><div><nobr>" +
replaceAll(str, searchStr, "<font color = 'rgb(61,153,249)'>" + changeHtmlStr(searchStr) + "</font>") +
"</nobr></div></body></html>";
String ans = HEAD + replaceAll(str, searchStr, FONT_HEAD + changeHtmlStr(searchStr) + FONT_TAIL) + TAIL;
return changeOriginHtmlStr(ans);
}
}
/**
* 用于处理原字符串中的尖括号
*/
private static String changeOriginHtmlStr(String str) {
int count = 0;
StringBuilder builder = new StringBuilder(str);
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
if (c == LEFT_HTML_CHAR) {
if (!checkValid(str, i)) {
builder.replace(i + count, i + count + 1, "&lt;");
count += LEFT_DIFFERENT;
}
}
}
return builder.toString();
}
private static boolean checkValid(String str, int i) {
int leftLen = str.length() - (i + 1);
return checkStrValid(str, i, leftLen, HTML_LEN, HTML) ||
checkStrValid(str, i, leftLen, HTML_TAIL_LEN, HTML_TAIL) ||
checkStrValid(str, i, leftLen, FONT_HEAD_LEN, FONT_HEAD) ||
checkStrValid(str, i, leftLen, FONT_TAIL_LEN, FONT_TAIL) ||
checkStrValid(str, i, leftLen, NOBR_LEN, NOBR) ||
checkStrValid(str, i, leftLen, NOBR_TAIL_LEN, NOBR_TAIL);
}
/**
* 是否是所指定的字符串
*
* @param str
* @param i
* @param leftLen
* @return
*/
private static boolean checkStrValid(String str, int i, int leftLen, int len, String checkStr) {
if (leftLen < len - 1) {
return false;
} else {
return StringUtils.equals(str.substring(i, i + len), checkStr);
}
}
/**
* 用于处理搜索的字符中的尖括号
*
* @param searchStr
* @return
*/
private static String changeHtmlStr(String searchStr) {
String showStr = searchStr;
showStr = showStr.replace("<", "&lt;");
@ -162,6 +236,19 @@ public class ShowValueUtils {
return showStr;
}
private static int getIncreaseCount(String str) {
int count = 0;
for (int i = 0; i < str.length(); i++) {
if (str.charAt(i) == LEFT_HTML_CHAR) {
count += LEFT_DIFFERENT;
}
if (str.charAt(i) == RIGHT_HTML_CHAR) {
count += RIGHT_DIFFERENT;
}
}
return count;
}
/**
* 集合是否不为空
*
@ -193,6 +280,7 @@ public class ShowValueUtils {
/**
* 支持通配符的contains
*
* @param originStr
* @param matchStr
* @return

Loading…
Cancel
Save