Browse Source

Merge branch 'final/10.0' of https://code.fineres.com/scm/~qinghui.liu/design into final/10.0

final/10.0
Qinghui.Liu 4 years ago
parent
commit
9b54229236
  1. 3
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java
  2. 10
      designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java
  3. 2
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  4. 19
      designer-base/src/main/java/com/fr/design/parameter/ParameterArrayPane.java
  5. 27
      designer-base/src/main/java/com/fr/design/utils/DesignUtils.java
  6. 24
      designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java
  7. 11
      designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java
  8. 9
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java
  9. 15
      designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java
  10. 7
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java
  11. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java
  12. 11
      designer-realize/src/test/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRenderTest.java

3
designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java

@ -185,7 +185,8 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
box.setMinimumSize(new Dimension(300, 400)); box.setMinimumSize(new Dimension(300, 400));
// 防止数据连接名过长时影响 split pane 分割效果 // 防止数据连接名过长时影响 split pane 分割效果
connectionTableProcedurePane.setMinimumSize(new Dimension(250, 400)); // 本界面中给MaxMemRowCountPanel留的空间太小,造成MaxMemRowCountPanel显示异常,这边减小一点最小宽度,拉长MaxMemRowCountPanel
connectionTableProcedurePane.setMinimumSize(new Dimension(230, 400));
connectionTableProcedurePane.setMaximumSize(new Dimension(500, 400)); connectionTableProcedurePane.setMaximumSize(new Dimension(500, 400));
// 使用SplitPane // 使用SplitPane
JSplitPane mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, connectionTableProcedurePane, sqlSplitPane); JSplitPane mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, connectionTableProcedurePane, sqlSplitPane);

10
designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java

@ -3,11 +3,12 @@ package com.fr.design.gui.iprogressbar;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.UIDialog; import com.fr.design.dialog.UIDialog;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.stable.os.support.OSBasedAction;
import com.fr.stable.os.support.OSSupportCenter;
import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.os.impl.SupportOSImpl;
import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.FRFont; import com.fr.general.FRFont;
import com.fr.stable.os.support.OSBasedAction;
import com.fr.stable.os.support.OSSupportCenter;
import javax.swing.JDialog; import javax.swing.JDialog;
import javax.swing.JLabel; import javax.swing.JLabel;
@ -57,7 +58,10 @@ public class ProgressDialog extends UIDialog {
progressBar.setMaximum(1000); progressBar.setMaximum(1000);
panel.add(progressBar, BorderLayout.CENTER); panel.add(progressBar, BorderLayout.CENTER);
text = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Loading_Project"), JLabel.CENTER); text = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Loading_Project"), JLabel.CENTER);
FRFont font = FRFont.getInstance().applySize(14).applyForeground(new ColorUIResource(333334)); FRFont font = DesignUtils
.getDefaultGUIFont()
.applySize(14)
.applyForeground(new ColorUIResource(333334));
text.setFont(font); text.setFont(font);
panel.add(text, BorderLayout.SOUTH); panel.add(text, BorderLayout.SOUTH);
panel.setVisible(true); panel.setVisible(true);

2
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java

@ -578,7 +578,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
} }
}); });
nameField.selectAll(); nameField.selectAll();
nameField.setPreferredSize(new Dimension(180, 20)); nameField.setPreferredSize(new Dimension(170, 20));
JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 5)); JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 5));
topPanel.setBorder(BorderFactory.createEmptyBorder(15, 15, 0, 15)); topPanel.setBorder(BorderFactory.createEmptyBorder(15, 15, 0, 15));

19
designer-base/src/main/java/com/fr/design/parameter/ParameterArrayPane.java

@ -7,7 +7,7 @@ import com.fr.design.gui.controlpane.JListControlPane;
import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.gui.controlpane.NameableSelfCreator; import com.fr.design.gui.controlpane.NameableSelfCreator;
import com.fr.design.gui.controlpane.UnrepeatedNameHelper; import com.fr.design.gui.controlpane.UnrepeatedNameHelper;
import com.fr.design.gui.ilist.ModNameActionListener; import com.fr.design.i18n.Toolkit;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.stable.Nameable; import com.fr.stable.Nameable;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -23,17 +23,12 @@ public class ParameterArrayPane extends JListControlPane {
*/ */
public ParameterArrayPane() { public ParameterArrayPane() {
super(); super();
this.addModNameActionListener(new ModNameActionListener() { this.addModNameActionListener((index, oldName, newName) -> populateSelectedValue());
public void nameModed(int index, String oldName, String newName) {
populateSelectedValue();
}
});
this.addEditingListener(new PropertyChangeAdapter() { this.addEditingListener(new PropertyChangeAdapter() {
public void propertyChange() { public void propertyChange() {
Parameter[] parameters = ParameterConfig.getInstance().getGlobalParameters(); Parameter[] parameters = ParameterConfig.getInstance().getGlobalParameters();
String[] allListNames = nameableList.getAllNames(); String[] allListNames = nameableList.getAllNames();
allListNames[nameableList.getSelectedIndex()] = StringUtils.EMPTY; allListNames[editingIndex] = StringUtils.EMPTY;
String tempName = getEditingName(); String tempName = getEditingName();
if (StringUtils.isEmpty(tempName)) { if (StringUtils.isEmpty(tempName)) {
nameableList.stopEditing(); nameableList.stopEditing();
@ -45,7 +40,7 @@ public class ParameterArrayPane extends JListControlPane {
&& isNameRepeated(new List[]{Arrays.asList(parameters), Arrays.asList(allListNames)}, tempName)) { && isNameRepeated(new List[]{Arrays.asList(parameters), Arrays.asList(allListNames)}, tempName)) {
nameableList.stopEditing(); nameableList.stopEditing();
FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ParameterArrayPane.this), FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ParameterArrayPane.this),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Duplicate_Parameter_Name")); Toolkit.i18nText("Fine-Design_Basic_Duplicate_Parameter_Name"));
setIllegalIndex(editingIndex); setIllegalIndex(editingIndex);
} }
} }
@ -55,7 +50,7 @@ public class ParameterArrayPane extends JListControlPane {
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Engine_Schedule_Template_Parameter"); return Toolkit.i18nText("Fine-Design_Basic_Engine_Schedule_Template_Parameter");
} }
/** /**
@ -65,7 +60,7 @@ public class ParameterArrayPane extends JListControlPane {
*/ */
public NameableCreator[] createNameableCreators() { public NameableCreator[] createNameableCreators() {
return new NameableCreator[]{ return new NameableCreator[]{
new NameableSelfCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Engine_Parameter_Name"), Parameter.class, ParameterPane.class) { new NameableSelfCreator(Toolkit.i18nText("Fine-Design_Basic_Engine_Parameter_Name"), Parameter.class, ParameterPane.class) {
public Parameter createNameable(UnrepeatedNameHelper helper) { public Parameter createNameable(UnrepeatedNameHelper helper) {
// 返回参数设置面板. // 返回参数设置面板.
return new Parameter(helper.createUnrepeatedName("p")); return new Parameter(helper.createUnrepeatedName("p"));
@ -89,7 +84,7 @@ public class ParameterArrayPane extends JListControlPane {
// Nameable[]居然不能强转成Parameter[],一定要这么写... // Nameable[]居然不能强转成Parameter[],一定要这么写...
Nameable[] res = this.update(); Nameable[] res = this.update();
Parameter[] res_array = new Parameter[res.length]; Parameter[] res_array = new Parameter[res.length];
java.util.Arrays.asList(res).toArray(res_array); Arrays.asList(res).toArray(res_array);
return res_array; return res_array;
} }

27
designer-base/src/main/java/com/fr/design/utils/DesignUtils.java

@ -8,6 +8,7 @@ import com.fr.design.ExtraDesignClassManager;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.fun.DesignerEnvProcessor; import com.fr.design.fun.DesignerEnvProcessor;
import com.fr.design.gui.UILookAndFeel; import com.fr.design.gui.UILookAndFeel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.exit.DesignerExiter; import com.fr.exit.DesignerExiter;
import com.fr.file.FileFILE; import com.fr.file.FileFILE;
@ -21,7 +22,9 @@ import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.os.OperatingSystem; import com.fr.stable.os.OperatingSystem;
import com.fr.start.ServerStarter; import com.fr.start.ServerStarter;
import com.fr.value.NotNullLazyValue;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import org.jetbrains.annotations.NotNull;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.UIManager; import javax.swing.UIManager;
@ -248,6 +251,7 @@ public class DesignUtils {
// 刷新DesignerFrame里面的面板 // 刷新DesignerFrame里面的面板
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() { public void run() {
if (DesignerContext.getDesignerFrame() == null) { if (DesignerContext.getDesignerFrame() == null) {
return; return;
@ -269,7 +273,7 @@ public class DesignUtils {
FineLoggerFactory.getLogger().error("Substance Raven Graphite failed to initialize"); FineLoggerFactory.getLogger().error("Substance Raven Graphite failed to initialize");
} }
//获取当前系统语言下设计器用的默认字体 //获取当前系统语言下设计器用的默认字体
FRFont guiFRFont = getCurrentLocaleFont(); FRFont guiFRFont = getDefaultGUIFont();
//指定UIManager中字体 //指定UIManager中字体
Enumeration keys = UIManager.getDefaults().keys(); Enumeration keys = UIManager.getDefaults().keys();
while (keys.hasMoreElements()) { while (keys.hasMoreElements()) {
@ -286,11 +290,21 @@ public class DesignUtils {
} }
/** /**
* 获取当前系统语言下设计器用的默认字体 * 获取当前系统语言下设计器界面使用的默认字体
* *
* @return 默认字体 * @return 默认字体
*/ */
private static FRFont getCurrentLocaleFont() { public static FRFont getDefaultGUIFont() {
return CURRENT_LOCALE_FONT.getValue();
}
/**
* 获取当前系统语言下设计器用的默认字体
*/
private static final NotNullLazyValue<FRFont> CURRENT_LOCALE_FONT = new NotNullLazyValue<FRFont>() {
@NotNull
@Override
protected FRFont compute() {
FRFont guiFRFont; FRFont guiFRFont;
Locale defaultLocale = Locale.getDefault(); Locale defaultLocale = Locale.getDefault();
// JDK9 之后宋体在计算label中字母的空间上出现问题,暂时先用雅黑兼容,以后再统一字体 // JDK9 之后宋体在计算label中字母的空间上出现问题,暂时先用雅黑兼容,以后再统一字体
@ -302,9 +316,7 @@ public class DesignUtils {
guiFRFont = getNamedFont("Dialog"); guiFRFont = getNamedFont("Dialog");
} }
//先初始化的设计器locale, 后初始化lookandfeel.如果顺序改了, 这边也要调整. String file = Toolkit.i18nText("Fine-Design_Basic_File");
Locale designerLocale = GeneralContext.getLocale();
String file = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_File");
char displayChar = file.charAt(0); char displayChar = file.charAt(0);
if (!guiFRFont.canDisplay(displayChar)) { if (!guiFRFont.canDisplay(displayChar)) {
//如果不能用默认的语言显示字体, 比如想在英文系统里用中文设计器 //如果不能用默认的语言显示字体, 比如想在英文系统里用中文设计器
@ -314,13 +326,14 @@ public class DesignUtils {
//比如想在中文或英文系统里用韩文设计器 //比如想在中文或英文系统里用韩文设计器
guiFRFont = getNamedFont("Dialog"); guiFRFont = getNamedFont("Dialog");
if (!guiFRFont.canDisplay(displayChar)) { if (!guiFRFont.canDisplay(displayChar)) {
FineLoggerFactory.getLogger().error(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_SimSun_Not_Found")); FineLoggerFactory.getLogger().error(Toolkit.i18nText("Fine-Design_Basic_Base_SimSun_Not_Found"));
} }
} }
} }
return guiFRFont; return guiFRFont;
} }
};
private static FRFont getNamedFont(String name) { private static FRFont getNamedFont(String name) {
return FRFont.getInstance(name, Font.PLAIN, 12); return FRFont.getInstance(name, Font.PLAIN, 12);

24
designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java

@ -30,6 +30,7 @@ import com.fr.design.mainframe.EastRegionContainerPane;
import com.fr.design.mainframe.FormArea; import com.fr.design.mainframe.FormArea;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormDesignerModeForSpecial; import com.fr.design.mainframe.FormDesignerModeForSpecial;
import com.fr.design.mainframe.FormDesignerUI;
import com.fr.design.mainframe.FormParaPane; import com.fr.design.mainframe.FormParaPane;
import com.fr.design.mainframe.FormWidgetDetailPane; import com.fr.design.mainframe.FormWidgetDetailPane;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
@ -58,6 +59,7 @@ import java.awt.Graphics;
import java.awt.Image; import java.awt.Image;
import java.awt.Insets; import java.awt.Insets;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -467,6 +469,21 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
return ((FormParameterUI) getTarget()).getDesignSize(); return ((FormParameterUI) getTarget()).getDesignSize();
} }
/**
* 设置其UI类为DesignerUI负责渲染
*/
@Override
public void updateUI() {
setUI(new FormDesignerUI(){
@Override
protected Rectangle getFitPaintBounds(Component component, Component parent) {
return new Rectangle(0, 0, parent.getSize().width, parent.getSize().height);
}
});
}
/** /**
* 设置高度 * 设置高度
* *
@ -722,4 +739,11 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
return new JComponent[]{new CutAction(this).createToolBarComponent(), new CopyAction(this).createToolBarComponent(), new PasteAction(this).createToolBarComponent(), return new JComponent[]{new CutAction(this).createToolBarComponent(), new CopyAction(this).createToolBarComponent(), new PasteAction(this).createToolBarComponent(),
new FormDeleteAction(this).createToolBarComponent()}; new FormDeleteAction(this).createToolBarComponent()};
} }
@Override
public boolean checkIfBeyondValidArea(MouseEvent e){
return false;
}
} }

11
designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java

@ -166,7 +166,7 @@ public class EditingMouseListener extends MouseInputAdapter {
// 获取焦点,以便获取热键 // 获取焦点,以便获取热键
designer.requestFocus(); designer.requestFocus();
} }
if (e.getButton() == MouseEvent.BUTTON1 && !beyondValidArea(e)) { if (e.getButton() == MouseEvent.BUTTON1 && !designer.checkIfBeyondValidArea(e)) {
Direction dir = selectionModel.getDirectionAt(e); Direction dir = selectionModel.getDirectionAt(e);
if (!DesignerMode.isAuthorityEditing()) { if (!DesignerMode.isAuthorityEditing()) {
@ -194,15 +194,6 @@ public class EditingMouseListener extends MouseInputAdapter {
e.translatePoint(oldX - e.getX(), oldY - e.getY()); e.translatePoint(oldX - e.getX(), oldY - e.getY());
} }
private boolean beyondValidArea(MouseEvent e) {
if (e.getX() < 0 || e.getY() < 0 ||
e.getX() > designer.getRootComponent().getWidth() ||
e.getY() > (designer.getRootComponent().getHeight() + designer.getParaHeight())) {
return true;
}
return false;
}
private void offsetEventPoint(MouseEvent e){ private void offsetEventPoint(MouseEvent e){
int x = designer.getRelativeX(e.getX()); int x = designer.getRelativeX(e.getX());
int y = designer.getRelativeY(e.getY()); int y = designer.getRelativeY(e.getY());

9
designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java

@ -1733,4 +1733,13 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
return (int) (this.getArea().getVerticalValue() / this.scale); return (int) (this.getArea().getVerticalValue() / this.scale);
} }
public boolean checkIfBeyondValidArea(MouseEvent e){
if (e.getX() < 0 || e.getY() < 0 ||
e.getX() > this.getRootComponent().getWidth() ||
e.getY() > (this.getRootComponent().getHeight() + this.getParaHeight())) {
return true;
}
return false;
}
} }

15
designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java

@ -424,12 +424,8 @@ public class FormDesignerUI extends ComponentUI {
// 禁止双缓冲 // 禁止双缓冲
ComponentUtils.disableBuffer(component, dbcomponents); ComponentUtils.disableBuffer(component, dbcomponents);
Graphics clipg; Graphics clipg;
clipg = g.create( Rectangle clipgBounds = getFitPaintBounds(component, parent);
-designer.getHorizontalScaleValue(), clipg = g.create(clipgBounds.x, clipgBounds.y, clipgBounds.width, clipgBounds.height);
-designer.getVerticalScaleValue() + designer.getParaHeight(),
component.getSize().width + designer.getHorizontalScaleValue(),
component.getSize().height + designer.getVerticalScaleValue());
designer.paintContent(clipg); designer.paintContent(clipg);
paintWatermark((Graphics2D) clipg); paintWatermark((Graphics2D) clipg);
clipg.dispose(); clipg.dispose();
@ -439,6 +435,13 @@ public class FormDesignerUI extends ComponentUI {
designer.resetEditorComponentBounds(); designer.resetEditorComponentBounds();
} }
protected Rectangle getFitPaintBounds(Component component, Component parent) {
return new Rectangle(-designer.getHorizontalScaleValue(),
-designer.getVerticalScaleValue() + designer.getParaHeight(),
component.getSize().width + designer.getHorizontalScaleValue(),
component.getSize().height + designer.getVerticalScaleValue());
}
/** /**
* 画参数面板 * 画参数面板
*/ */

7
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java

@ -124,7 +124,10 @@ public class ContentCellRender implements ListCellRenderer<Object> {
private String getReplacedString(String modelName, String string) { private String getReplacedString(String modelName, String string) {
//需要考虑modelName有空格的情况 //需要考虑modelName有空格的情况
//比如现在是work boo k 搜索词是workb,应该要替换的部分是work b //比如现在是work boo k 搜索词是workb,应该要替换的部分是work b
//先去掉空格进行匹配 //先去掉已经匹配替换过的部分,因为考虑到分词的情况,可能会进行多次替换
final String regex = "\\|<font.*?</font>\\|";
modelName = modelName.replaceAll(regex, StringUtils.EMPTY);
//再去掉空格进行匹配
String noBlackName = modelName.replaceAll(StringUtils.BLANK, StringUtils.EMPTY).toLowerCase(); String noBlackName = modelName.replaceAll(StringUtils.BLANK, StringUtils.EMPTY).toLowerCase();
int index = noBlackName.indexOf(string.toLowerCase()); int index = noBlackName.indexOf(string.toLowerCase());
if (index == -1) { if (index == -1) {
@ -139,6 +142,4 @@ public class ContentCellRender implements ListCellRenderer<Object> {
} }
return result.toString(); return result.toString();
} }
} }

2
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java

@ -112,7 +112,7 @@ public class FileSearchManager implements AlphaFineSearchProvider {
name = name.replaceAll(StringUtils.BLANK, StringUtils.EMPTY); name = name.replaceAll(StringUtils.BLANK, StringUtils.EMPTY);
if (name.contains(searchText)) { if (name.contains(searchText)) {
FileModel model = new FileModel(node.getName(), node.getEnvPath()); FileModel model = new FileModel(node.getName(), node.getEnvPath());
if (!AlphaFineHelper.getFilterResult().contains(model)) { if (!AlphaFineHelper.getFilterResult().contains(model) && !filterModelList.contains(model)) {
AlphaFineHelper.checkCancel(); AlphaFineHelper.checkCancel();
filterModelList.add(model); filterModelList.add(model);
} }

11
designer-realize/src/test/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRenderTest.java

@ -1,7 +1,9 @@
package com.fr.design.mainframe.alphafine.cell.render; package com.fr.design.mainframe.alphafine.cell.render;
import com.fr.stable.StringUtils;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.*; import static org.junit.Assert.*;
/** /**
@ -13,11 +15,20 @@ public class ContentCellRenderTest {
@Test @Test
public void highLightModelName() { public void highLightModelName() {
final String regex = "<font.*?</font>";
String searchText = "workb"; String searchText = "workb";
ContentCellRender contentCellRender = new ContentCellRender(searchText,new String[]{searchText}); ContentCellRender contentCellRender = new ContentCellRender(searchText,new String[]{searchText});
String workbook = contentCellRender.highLightModelName("workbook", new String[]{searchText}); String workbook = contentCellRender.highLightModelName("workbook", new String[]{searchText});
assertTrue(workbook.endsWith("workb</font>ook</body></HTML>")); assertTrue(workbook.endsWith("workb</font>ook</body></HTML>"));
workbook = contentCellRender.highLightModelName("work book", new String[]{searchText}); workbook = contentCellRender.highLightModelName("work book", new String[]{searchText});
assertTrue(workbook.endsWith("work b</font>ook</body></HTML>")); assertTrue(workbook.endsWith("work b</font>ook</body></HTML>"));
searchText = "我是空格";
contentCellRender = new ContentCellRender(searchText, new String[]{"我是空格", "我是", "空格"});
workbook = contentCellRender.highLightModelName("我是 空格", new String[]{searchText});
assertEquals(workbook.replaceFirst(regex, StringUtils.EMPTY), workbook.replaceAll(regex, StringUtils.EMPTY));
workbook = contentCellRender.highLightModelName("我是是 空格", new String[]{"我是空格", "我是", "空格"});
assertNotEquals(workbook.replaceFirst(regex, StringUtils.EMPTY), workbook.replaceAll(regex, StringUtils.EMPTY));
} }
} }
Loading…
Cancel
Save