Browse Source

REPORT-75998 决策报表组件JS判断、部分通配符逻辑、左侧面板界面优化

feature/x
Destiny.Lin 2 years ago
parent
commit
cc48a7b29a
  1. 2
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchDSColumnFormulaAction.java
  2. 14
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchCellJSAction.java
  3. 87
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchComponentJSAction.java
  4. 2
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchJSManager.java
  5. 1
      designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java
  6. 6
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java
  7. 13
      designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java
  8. 47
      designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java

2
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchDSColumnFormulaAction.java

@ -59,7 +59,7 @@ public class SearchDSColumnFormulaAction implements SearchCellFormula {
private void addFormulaInfos2ArrayFromResult(ITContent content, DSColumn dsColumn, List<FormulaInfo> formulaInfos) { private void addFormulaInfos2ArrayFromResult(ITContent content, DSColumn dsColumn, List<FormulaInfo> formulaInfos) {
char formulaLabel = '='; char formulaLabel = '=';
if (dsColumn.getResult().length() > 0 && dsColumn.getResult().charAt(0) == formulaLabel) { if (dsColumn.getResult() != null && dsColumn.getResult().length() > 0 && dsColumn.getResult().charAt(0) == formulaLabel) {
ITContent newContent = ITContent.copy(content); ITContent newContent = ITContent.copy(content);
newContent.setReplaceObject(dsColumn); newContent.setReplaceObject(dsColumn);
//高级-显示值 //高级-显示值

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

@ -61,20 +61,6 @@ public class SearchCellJSAction implements SearchJS {
//单元格如果是图表还需要额外处理 //单元格如果是图表还需要额外处理
if (cell.getValue() instanceof ChartCollection) { if (cell.getValue() instanceof ChartCollection) {
SearchChartJSAction.getInstance().searchChartJS((ChartCollection) cell.getValue(), ITContent.copy(cellInfo.getContent()), jsInfos); SearchChartJSAction.getInstance().searchChartJS((ChartCollection) cell.getValue(), ITContent.copy(cellInfo.getContent()), jsInfos);
//List<Pair<VanChartHtmlLabel, String>> htmlLabels = SearchJSUtils.getHtmlLabel((ChartCollection) cell.getValue());
//List<NameJavaScript> nameJavaScripts = SearchJSUtils.getNameJavaScript((ChartCollection) cell.getValue());
////图表-样式-标签以及图表-特效-条件显示
//ITContent htmlITContent = ITContent.copy(cellInfo.getContent());
//htmlITContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Chart"));
//SearchJSUtils.addJSInfosFromHtmlLabel(htmlITContent, htmlLabels, jsInfos);
////图表-特效-交互属性
//ITContent conditionContent = ITContent.copy(cellInfo.getContent());
//conditionContent.addOtherPos(
// Toolkit.i18nText("Fine-Design_Chart_Chart"),
// Toolkit.i18nText("Fine-Design_Chart_Animation_Special"),
// Toolkit.i18nText("Fine-Design_Chart_Interactive")
//);
//SearchJSUtils.addJSInfosFromNameJS(conditionContent, nameJavaScripts, jsInfos);
} }
} }
} }

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

@ -0,0 +1,87 @@
package com.fr.design.actions.replace.action.content.js;
import com.fr.base.chart.BaseChartCollection;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.design.actions.replace.action.content.component.SearchComponentAction;
import com.fr.design.actions.replace.info.ComponentInfo;
import com.fr.design.actions.replace.info.JSInfo;
import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.design.mainframe.JTemplate;
import com.fr.form.ui.ChartEditor;
import com.fr.form.ui.container.WTitleLayout;
import java.util.ArrayList;
import java.util.List;
/**
* 决策报表的图表组件中特殊存在的JS
*
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-09-20
*/
public class SearchComponentJSAction implements SearchJS {
private SearchComponentJSAction() {
}
@Override
public void searchJSFromObject(JTemplate jTemplate, List<JSInfo> jsInfos) {
List<JSInfo> componentJSInfos = new ArrayList<>();
addJSInfos2ListFromComponent(jTemplate, componentJSInfos);
jsInfos.addAll(componentJSInfos);
}
private void addJSInfos2ListFromComponent(JTemplate jTemplate, List<JSInfo> componentJSInfos) {
SearchComponentAction searchComponentAction = SearchComponentAction.getInstance();
searchComponentAction.search4Infos(jTemplate);
List<ComponentInfo> componentInfoList = searchComponentAction.getComponentInfos();
for (ComponentInfo componentInfo : componentInfoList) {
Object o = componentInfo.getContent().getReplaceObject();
if (o instanceof WTitleLayout) {
if (((WTitleLayout) o).getBodyBoundsWidget().getWidget() instanceof ChartEditor) {
ChartEditor chartEditor = (ChartEditor) ((WTitleLayout) o).getBodyBoundsWidget().getWidget();
SearchChartJSAction searchChartJSAction = SearchChartJSAction.getInstance();
for (BaseChartCollection chartCollection : chartEditor.getChartCollections()) {
if (chartCollection instanceof ChartCollection) {
searchChartJSAction.searchChartJS((ChartCollection) chartCollection, ITContent.copy(componentInfo.getContent()), componentJSInfos);
}
}
}
}
}
}
/**
* 对外开放获取对象的方法
*
* @return
*/
public static SearchComponentJSAction getInstance() {
return SearchComponentJSActionEnum.SINGLETON.getInstance();
}
/**
* 枚举实现单例
*/
private enum SearchComponentJSActionEnum {
/**
* 单例
*/
SINGLETON;
private SearchComponentJSAction instance;
SearchComponentJSActionEnum() {
instance = new SearchComponentJSAction();
}
/**
* 获取单例的方法
*
* @return
*/
public SearchComponentJSAction getInstance() {
return instance;
}
}
}

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

@ -32,6 +32,8 @@ public class SearchJSManager implements SearchAction, SearchManager {
register(SearchWebJSAction.getInstance()); register(SearchWebJSAction.getInstance());
//从悬浮元素 //从悬浮元素
register(SearchFloatJSAction.getInstance()); register(SearchFloatJSAction.getInstance());
//从决策报表图表组件
register(SearchComponentJSAction.getInstance());
} }
@Override @Override

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

@ -93,6 +93,7 @@ public enum ReplaceObject implements DealWithInfoValue {
} }
} else { } else {
Listener listener = ((Listener) ((info.getContent().getReplaceObject()))); Listener listener = ((Listener) ((info.getContent().getReplaceObject())));
info.updateOldStr(listener.getName(), findStr);
listener.setName(listener.getName().replaceAll(findStr, replaceStr)); listener.setName(listener.getName().replaceAll(findStr, replaceStr));
} }
} }

6
designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java

@ -25,13 +25,9 @@ public class ITReplaceWestPanel {
UIToggleButton contentButton = new UIToggleButton(Toolkit.i18nText("Fine-Design_Basic_Templates_Content")); UIToggleButton contentButton = new UIToggleButton(Toolkit.i18nText("Fine-Design_Basic_Templates_Content"));
contentButton.setSelected(true); contentButton.setSelected(true);
contentButton.setBorderPainted(false); contentButton.setBorderPainted(false);
UIToggleButton settingButton = new UIToggleButton("//");
settingButton.setBorderPainted(false);
leftJpanel.add(contentButton); leftJpanel.add(contentButton);
leftJpanel.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, new Color(218, 218, 221))); leftJpanel.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, new Color(218, 218, 221)));
leftJpanel.add(settingButton); int labelNum = 14;
//由于要砍掉设置项这部分,这边先暂时填充一下
int labelNum = 13;
for (int i = 0; i < labelNum; i++) { for (int i = 0; i < labelNum; i++) {
leftJpanel.add(new UILabel("")); leftJpanel.add(new UILabel(""));
} }

13
designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java

@ -38,11 +38,14 @@ public class SearchJSUtils {
* 从Listener中获取JS * 从Listener中获取JS
*/ */
public static void searchJSFromListener(List<JSInfo> jsInfos, ITContent content) { public static void searchJSFromListener(List<JSInfo> jsInfos, ITContent content) {
JavaScript javaScript = ((Listener) (content.getReplaceObject())).getAction(); if (content.getReplaceObject() instanceof Listener){
if (javaScript instanceof JavaScriptImpl) { Listener listener = (Listener) (content.getReplaceObject());
ITContent newContent = ITContent.copy(content); JavaScript javaScript = listener.getAction();
newContent.setReplaceObject(javaScript); if (javaScript instanceof JavaScriptImpl) {
SearchJSUtils.addJSInfos(jsInfos, new JSInfo(newContent)); ITContent newContent = ITContent.copy(content);
newContent.setReplaceObject(listener);
SearchJSUtils.addJSInfos(jsInfos, new JSInfo(newContent));
}
} }
} }

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

@ -11,8 +11,10 @@ import com.fr.stable.collections.combination.Pair;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
/** /**
* 用来处理展示内容的工具类截取高亮 * 用来处理展示内容的工具类截取高亮
* *
@ -22,6 +24,12 @@ import java.util.regex.Pattern;
*/ */
public class ShowValueUtils { public class ShowValueUtils {
public static final String ANY_THING = "?";
public static final String NUMBER = "#";
public static final String ENGLISH = "$";
public static final String ANY_THING_REGEX = ".";
public static final String NUMBER_REGEX = "[0-9]";
public static final String ENGLISH_REGEX = "[\u4e00-\u9fa5a-zA-Z]";
/** /**
* 获取除内容外其他一次性展示所有的内容名称水印... * 获取除内容外其他一次性展示所有的内容名称水印...
* *
@ -48,14 +56,20 @@ public class ShowValueUtils {
* @return 替换后的字符串 * @return 替换后的字符串
*/ */
public static String replaceAll(String str, String regex, String replacement) { public static String replaceAll(String str, String regex, String replacement) {
if (ITReplaceMainDialog.isMatched()){ return str.replace(regex, replacement);
return str.replaceAll(Pattern.quote(regex), replacement);
}else {
return str.replace(regex, replacement);
}
} }
/**
* 转换正则表达式
* @param regex
* @return
*/
public static String changeRegex(String regex){
regex = regex.replace(NUMBER,NUMBER_REGEX);
regex = regex.replace(ENGLISH, ENGLISH_REGEX);
regex = regex.replace(ANY_THING,ANY_THING_REGEX);
return regex;
}
/** /**
* 获取匹配的字符串的位置开始位置结束位置 * 获取匹配的字符串的位置开始位置结束位置
@ -93,7 +107,7 @@ public class ShowValueUtils {
*/ */
public static void updateHighlight(Info info, String replaceStr) { public static void updateHighlight(Info info, String replaceStr) {
String s = info.getInfoShowStr(info); String s = info.getInfoShowStr(info);
s = ShowValueUtils.replaceAll(s, info.getContent().getLastSearchStr(), "<font color = 'rgb(61,153,249)'>" + replaceStr + "</font>"); s = s.replace(info.getContent().getLastSearchStr(), "<font color = 'rgb(61,153,249)'>" + replaceStr + "</font>");
info.getContent().setShowStr( info.getContent().setShowStr(
"<html><body><div><nobr>" + s + "</nobr></div></body></html>" "<html><body><div><nobr>" + s + "</nobr></div></body></html>"
); );
@ -110,4 +124,23 @@ public class ShowValueUtils {
public static boolean isNotEmpty(Collection collection) { public static boolean isNotEmpty(Collection collection) {
return collection != null && collection.size() > 0; return collection != null && collection.size() > 0;
} }
/**
* 支持正则表达式的indexOf
* @param str
* @param regex
* @return
*/
public static int indexOf(String str, String regex){
CharSequence inputStr = str;
int failReturn = -1;
String patternStr = changeRegex(regex);
Pattern pattern = Pattern.compile(patternStr);
Matcher matcher = pattern.matcher(inputStr);
if(matcher.find()){
return matcher.start();
}
return failReturn;
}
} }

Loading…
Cancel
Save