Browse Source

Merge remote-tracking branch 'origin/release/10.0' into release/10.0

feature/big-screen
Yvan 4 years ago
parent
commit
390b007301
  1. 11
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  2. 2
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java
  3. 2
      designer-base/src/main/java/com/fr/design/dialog/ErrorDialog.java
  4. 38
      designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java
  5. 10
      designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java
  6. 24
      designer-base/src/main/java/com/fr/env/EnvListPane.java
  7. 67
      designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java
  8. 7
      designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java
  9. 4
      designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java
  10. 4
      designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java
  11. 7
      designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java
  12. 4
      designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java
  13. 5
      designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java
  14. 6
      designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java
  15. 4
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java
  16. 10
      designer-form/src/main/java/com/fr/design/mainframe/TopXCreators.java
  17. 4
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/BottomModel.java
  18. 24
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java
  19. 168
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  20. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/PluginPreviewPane.java
  21. 4
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/RobotPreviewPane.java
  22. 12
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java
  23. 5
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SegmentationManager.java
  24. 79
      designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/FileSearchManagerTest.java
  25. 23
      designer-realize/src/test/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRenderTest.java

11
designer-base/src/main/java/com/fr/design/DesignerEnvManager.java

@ -218,14 +218,9 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
if (needCheckEnv) { if (needCheckEnv) {
checkNameEnvMap(); checkNameEnvMap();
} }
GeneralContext.addEnvChangedListener(() -> {
GeneralContext.addEnvChangedListener(new EnvChangedListener() { designerEnvManager.setCurrentDirectoryPrefix(FILEFactory.ENV_PREFIX);
@Override designerEnvManager.setDialogCurrentDirectory(ProjectConstants.REPORTLETS_NAME);
public void envChanged() {
designerEnvManager.setCurrentDirectoryPrefix(FILEFactory.ENV_PREFIX);
designerEnvManager.setDialogCurrentDirectory(ProjectConstants.REPORTLETS_NAME);
}
}); });
} }

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

@ -218,7 +218,7 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
paramTexts[0] = SqlUtils.tryPureSqlText(sqlTextPane.getText()); paramTexts[0] = SqlUtils.tryPureSqlText(sqlTextPane.getText());
paramTexts[1] = SqlUtils.tryPureSqlText(pageQuery); paramTexts[1] = SqlUtils.tryPureSqlText(pageQuery);
List<ParameterProvider> existParameterList = editorPane.update(); List<ParameterProvider> existParameterList = editorPane.update();
Parameter[] ps = existParameterList == null ? new Parameter[0] : existParameterList.toArray(new Parameter[existParameterList.size()]); Parameter[] ps = existParameterList == null ? new Parameter[0] : existParameterList.toArray(new Parameter[0]);
editorPane.populate(ParameterUtils.analyzeAndUnionParameters(paramTexts, ps)); editorPane.populate(ParameterUtils.analyzeAndUnionParameters(paramTexts, ps));
} }

2
designer-base/src/main/java/com/fr/design/dialog/ErrorDialog.java

@ -35,7 +35,7 @@ public abstract class ErrorDialog extends JDialog implements ActionListener {
JPanel messagePane = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true); JPanel messagePane = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true);
UILabel boldFontLabel = new UILabel(message); UILabel boldFontLabel = new UILabel(message);
UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Send_Report_To_Us")); UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Send_Report_To_Us"));
Font font = FRFont.getInstance("Dialog", Font.BOLD, 20); Font font = FRFont.getInstance(label.getFont().getFontName(), Font.BOLD, 20);
boldFontLabel.setFont(font); boldFontLabel.setFont(font);
messagePane.add(boldFontLabel); messagePane.add(boldFontLabel);
messagePane.add(label); messagePane.add(label);

38
designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java vendored

@ -40,6 +40,12 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
private WorkspaceConnectionInfo connection; private WorkspaceConnectionInfo connection;
/**
* 标记下新创建的远程工作目录 兼容存留的远程目录客户升级后再回退 读取为密文
* 仅保证当前新增是加密的
*/
private boolean newCreated;
public static RemoteDesignerWorkspaceInfo create(WorkspaceConnectionInfo connection) { public static RemoteDesignerWorkspaceInfo create(WorkspaceConnectionInfo connection) {
RemoteDesignerWorkspaceInfo info = new RemoteDesignerWorkspaceInfo(); RemoteDesignerWorkspaceInfo info = new RemoteDesignerWorkspaceInfo();
info.connection = connection; info.connection = connection;
@ -79,12 +85,21 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
return remindTime; return remindTime;
} }
public boolean isNewCreated() {
return newCreated;
}
public void setNewCreated(boolean newCreated) {
this.newCreated = newCreated;
}
@Override @Override
public void readXML(XMLableReader reader) { public void readXML(XMLableReader reader) {
if (reader.isAttr()) { if (reader.isAttr()) {
this.name = reader.getAttrAsString("name", StringUtils.EMPTY); this.name = reader.getAttrAsString("name", StringUtils.EMPTY);
this.remindTime = reader.getAttrAsString("remindTime", StringUtils.EMPTY); this.remindTime = reader.getAttrAsString("remindTime", StringUtils.EMPTY);
this.newCreated = reader.getAttrAsBoolean("newCreated", false);
} }
if (reader.isChildNode()) { if (reader.isChildNode()) {
String tagName = reader.getTagName(); String tagName = reader.getTagName();
@ -92,32 +107,49 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
String url = reader.getAttrAsString("url", StringUtils.EMPTY); String url = reader.getAttrAsString("url", StringUtils.EMPTY);
String username = reader.getAttrAsString("username", StringUtils.EMPTY); String username = reader.getAttrAsString("username", StringUtils.EMPTY);
//密码解密 //密码解密
String password = SecurityToolbox.defaultDecrypt(reader.getAttrAsString("password", StringUtils.EMPTY).replaceAll(" ", "\r\n")); String password = SecurityToolbox.defaultDecrypt(reader.getAttrAsString("password", StringUtils.EMPTY).replaceAll(StringUtils.BLANK, "\r\n"));
String certPath = reader.getAttrAsString("certPath", StringUtils.EMPTY); String certPath = reader.getAttrAsString("certPath", StringUtils.EMPTY);
String certSecretKey = reader.getAttrAsString("certSecretKey", StringUtils.EMPTY); String certSecretKey = readCertSecretKey(reader);
boolean rememberPwd = reader.getAttrAsBoolean("rememberPwd", true); boolean rememberPwd = reader.getAttrAsBoolean("rememberPwd", true);
this.connection = new WorkspaceConnectionInfo(url, username, password, certPath, certSecretKey, rememberPwd); this.connection = new WorkspaceConnectionInfo(url, username, password, certPath, certSecretKey, rememberPwd);
} }
} }
} }
private String readCertSecretKey(XMLableReader reader) {
if (isNewCreated()) {
return SecurityToolbox.defaultDecrypt(reader.getAttrAsString("certSecretKey", StringUtils.EMPTY).replaceAll(StringUtils.BLANK, "\r\n"));
} else {
return reader.getAttrAsString("certSecretKey", StringUtils.EMPTY);
}
}
@Override @Override
public void writeXML(XMLPrintWriter writer) { public void writeXML(XMLPrintWriter writer) {
writer.attr("name", name); writer.attr("name", name);
writer.attr("remindTime", remindTime); writer.attr("remindTime", remindTime);
writer.attr("newCreated", isNewCreated());
if (this.connection != null) { if (this.connection != null) {
writer.startTAG("Connection"); writer.startTAG("Connection");
writer.attr("url", connection.getUrl()); writer.attr("url", connection.getUrl());
writer.attr("username", connection.getUserName()); writer.attr("username", connection.getUserName());
writer.attr("password", SecurityToolbox.defaultEncrypt(connection.getPassword())); writer.attr("password", SecurityToolbox.defaultEncrypt(connection.getPassword()));
writer.attr("certPath", connection.getCertPath()); writer.attr("certPath", connection.getCertPath());
writer.attr("certSecretKey", connection.getCertSecretKey()); writeCertSecretKey(writer);
writer.attr("rememberPwd", connection.isRememberPwd()); writer.attr("rememberPwd", connection.isRememberPwd());
writer.end(); writer.end();
} }
} }
private void writeCertSecretKey(XMLPrintWriter writer) {
if (isNewCreated()) {
writer.attr("certSecretKey", SecurityToolbox.defaultEncrypt(connection.getCertSecretKey()));
} else {
writer.attr("certSecretKey", connection.getCertSecretKey());
}
}
@Override @Override
@SuppressWarnings("squid:S2975") @SuppressWarnings("squid:S2975")
public Object clone() throws CloneNotSupportedException { public Object clone() throws CloneNotSupportedException {

10
designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java

@ -19,7 +19,7 @@ import java.awt.event.MouseMotionListener;
public class UIEastResizableContainer extends JPanel { public class UIEastResizableContainer extends JPanel {
private static final long serialVersionUID = 1854340560790476907L; private static final long serialVersionUID = 1854340560790476907L;
public static final int MAX_CONTAINER_WIDTH = 500; public static final int MAX_CONTAINER_WIDTH = 340;
public static final int MIN_CONTAINER_WIDTH = 286; public static final int MIN_CONTAINER_WIDTH = 286;
private int containerWidth = 240; private int containerWidth = 240;
@ -266,13 +266,7 @@ public class UIEastResizableContainer extends JPanel {
@Override @Override
public void mouseDragged(MouseEvent e) { public void mouseDragged(MouseEvent e) {
containerWidth = UIEastResizableContainer.this.getWidth() + (UIEastResizableContainer.this.getLocationOnScreen().x - e.getXOnScreen()); // do noting
containerWidth = Math.min(containerWidth, MAX_CONTAINER_WIDTH);
containerWidth = Math.max(containerWidth, MIN_CONTAINER_WIDTH);
refreshContainer();
if ( DesignModeContext.isAuthorityEditing()) {
DesignerContext.getDesignerFrame().doResize();
}
} }
}); });
addMouseListener(new MouseAdapter() { addMouseListener(new MouseAdapter() {

24
designer-base/src/main/java/com/fr/env/EnvListPane.java vendored

@ -3,6 +3,7 @@ package com.fr.env;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.env.LocalDesignerWorkspaceInfo; import com.fr.design.env.LocalDesignerWorkspaceInfo;
import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.JListControlPane;
@ -17,8 +18,10 @@ import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.*; import javax.swing.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set;
/** /**
* @author yaohwu * @author yaohwu
@ -98,11 +101,30 @@ public class EnvListPane extends JListControlPane {
DesignerEnvManager mgr = DesignerEnvManager.getEnvManager(); DesignerEnvManager mgr = DesignerEnvManager.getEnvManager();
//这里代码时序换一下,因为update中需要借助mgr来获取提醒时间,已确认mgr对res无依赖 //这里代码时序换一下,因为update中需要借助mgr来获取提醒时间,已确认mgr对res无依赖
Nameable[] res = this.update(); Nameable[] res = this.update();
Set<Nameable> set = findNewWorkSpaceInfo(res);
mgr.clearAllEnv(); mgr.clearAllEnv();
for (Nameable re : res) { for (Nameable re : res) {
NameObject nameObject = (NameObject) re; NameObject nameObject = (NameObject) re;
mgr.putEnv(nameObject.getName(), (DesignerWorkspaceInfo) nameObject.getObject()); DesignerWorkspaceInfo info = (DesignerWorkspaceInfo) nameObject.getObject();
if (set.contains(re) && info.getType() == DesignerWorkspaceType.Remote) {
RemoteDesignerWorkspaceInfo newInfo = (RemoteDesignerWorkspaceInfo) info;
newInfo.setNewCreated(true);
mgr.putEnv(nameObject.getName(), newInfo);
} else {
mgr.putEnv(nameObject.getName(), info);
}
} }
return this.getSelectedName(); return this.getSelectedName();
} }
private Set<Nameable> findNewWorkSpaceInfo(Nameable[] res) {
Set<Nameable> set = new HashSet<>();
for (Nameable val : res) {
NameObject nameObject = (NameObject) val;
if (DesignerEnvManager.getEnvManager().getWorkspaceInfo(nameObject.getName()) == null) {
set.add(val);
}
}
return set;
}
} }

67
designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java vendored

@ -1,9 +1,16 @@
package com.fr.design.env; package com.fr.design.env;
import com.fr.invoke.Reflect;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLReaderHelper;
import com.fr.stable.xml.XMLableReader;
import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.connect.WorkspaceConnectionInfo;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.junit.Assert; import org.junit.Assert;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
/** /**
* @author hades * @author hades
* @version 10.0 * @version 10.0
@ -22,4 +29,64 @@ public class RemoteDesignerWorkspaceInfoTest extends TestCase {
Assert.assertFalse(workspaceInfo3.checkValid()); Assert.assertFalse(workspaceInfo3.checkValid());
} }
public void testReadXml() {
String xml0 = "<Connection url=\"https://192.168.101.171:8075/webroot/decision\" username=\"1\" password=\"EclFl2zl5ti32lqQIh9r/7iCd0Vmhm5uuLol+zs+oi4JWN8F6JA2Ym4PYeQOAR5cjvIdzhUgwoG/\n" +
"AJF1Ht1CFLfZqrztuJsWpP8GlMvqZb/Gi3TT2idJC/qHU6Am1jFe0qJoytyWUi5zGnZicTfVgDir\n" +
"gE0kuw1ONOzFCkVfNbLrC+DXIIbVa7ramqbsVa6/LDEqOJvfAE36cBYJjWGHjOT91ixldaCyEX8m\n" +
"0xmw5xvEuEiTgRUHufbKCEG0FOR1xvS3D3C9vlauoqDI1INOyUOawQvpuQ552AjZi/FH1v+eNt+q\n" +
"eU7iCzsKb6P5KomaKUTZ8EPlSR/+Ihzg5VjAyg==\" certPath=\"\" certSecretKey=\"bofKLt/G93T2NudGR71Npb1GCPSUVeC34dtFGa+DHRl2GfP3WM4Nitb/LwdA/mml5BNl/S5f4txt\n" +
"0jxK4r08BoWoleKt5r7C0Fapj6Ccm+qVP6ywaxN1PSC0ML8Fowo3VYhv2BVzdodMLLliIVngostk\n" +
"76gqsiatzJb0XiPnzb0UpjWs7lpgCw+XDBk2Qfpv/U8fyPmLkAxA+085w55vzLluu7o2ilaveOUk\n" +
"hmT3NfZinTTZd+dQJxfVfUgjKJdZ9C+EM/IkzY1gVYXYuZ8gl5wd5RkjC3VUOu36akmB09gXJ4S8\n" +
"z8ZdHilA5L9tneuS5C05DMRJ6CdO+avGJgJAtw==\" rememberPwd=\"true\"/>";
String xml1 = "<Connection url=\"https://192.168.101.171:8075/webroot/decision\" username=\"1\" password=\"EclFl2zl5ti32lqQIh9r/7iCd0Vmhm5uuLol+zs+oi4JWN8F6JA2Ym4PYeQOAR5cjvIdzhUgwoG/\n" +
"AJF1Ht1CFLfZqrztuJsWpP8GlMvqZb/Gi3TT2idJC/qHU6Am1jFe0qJoytyWUi5zGnZicTfVgDir\n" +
"gE0kuw1ONOzFCkVfNbLrC+DXIIbVa7ramqbsVa6/LDEqOJvfAE36cBYJjWGHjOT91ixldaCyEX8m\n" +
"0xmw5xvEuEiTgRUHufbKCEG0FOR1xvS3D3C9vlauoqDI1INOyUOawQvpuQ552AjZi/FH1v+eNt+q\n" +
"eU7iCzsKb6P5KomaKUTZ8EPlSR/+Ihzg5VjAyg==\" certPath=\"\" certSecretKey=\"xxxxxxx\" rememberPwd=\"true\"/>";
byte[] bytes0 = xml0.getBytes();
byte[] bytes1 = xml1.getBytes();
RemoteDesignerWorkspaceInfo info = new RemoteDesignerWorkspaceInfo();
ByteArrayInputStream in0 = new ByteArrayInputStream(bytes0);
ByteArrayInputStream in1 = new ByteArrayInputStream(bytes1);
try {
XMLableReader reader0 = XMLReaderHelper.createXMLableReader(in0, XMLPrintWriter.XML_ENCODER);
Reflect.on(reader0).set("state", 1);
info.setNewCreated(true);
info.readXML(reader0);
Assert.assertEquals("xxxxxxx", info.getConnection().getCertSecretKey());
XMLableReader reader1 = XMLReaderHelper.createXMLableReader(in1, XMLPrintWriter.XML_ENCODER);
Reflect.on(reader1).set("state", 1);
info.setNewCreated(false);
info.readXML(reader1);
Assert.assertEquals("xxxxxxx", info.getConnection().getCertSecretKey());
} catch (Exception ignore) {
}
}
public void testWriteXml() {
ByteArrayOutputStream out0 = new ByteArrayOutputStream();
XMLPrintWriter writer0 = XMLPrintWriter.create(out0);
RemoteDesignerWorkspaceInfo info0 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("127.0.0.1", "1", "1", "/xxx", "xxxxx", true));
info0.setNewCreated(true);
info0.writeXML(writer0);
writer0.close();
String result0 = new String(out0.toByteArray());
Assert.assertTrue(result0.contains("certSecretKey"));
Assert.assertFalse(result0.contains("certSecretKey=\"xxxxx\""));
ByteArrayOutputStream out1 = new ByteArrayOutputStream();
XMLPrintWriter writer1 = XMLPrintWriter.create(out1);
RemoteDesignerWorkspaceInfo info1 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("127.0.0.1", "1", "1", "/xxx", "xxxxx", true));
info1.writeXML(writer1);
writer1.close();
String result1 = new String(out1.toByteArray());
Assert.assertTrue(result1.contains("certSecretKey"));
Assert.assertTrue(result1.contains("certSecretKey=\"xxxxx\""));
}
} }

7
designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java

@ -82,6 +82,10 @@ public abstract class AbstractCustomFieldComboBoxPane<T> extends BasicBeanPane<T
return false; return false;
} }
protected boolean seriesComboBoxHasNone() {
return false;
}
public void checkBoxUse(boolean hasUse) { public void checkBoxUse(boolean hasUse) {
nameOrValue.setEnabled(hasUse); nameOrValue.setEnabled(hasUse);
useFieldValuePane.checkBoxUse(hasUse); useFieldValuePane.checkBoxUse(hasUse);
@ -147,8 +151,7 @@ public abstract class AbstractCustomFieldComboBoxPane<T> extends BasicBeanPane<T
private void initComponents() { private void initComponents() {
series = new UIComboBox(); series = seriesComboBoxHasNone() ? new UIComboBoxWithNone() : new UIComboBox();
value = valueComboBoxHasNone() ? new UIComboBoxWithNone() : new UIComboBox(); value = valueComboBoxHasNone() ? new UIComboBoxWithNone() : new UIComboBox();
value.addItemListener(new ItemListener() { value.addItemListener(new ItemListener() {
@Override @Override

4
designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java

@ -22,6 +22,10 @@ public class ExtendedCustomFieldComboBoxPane extends AbstractCustomFieldComboBox
return new ExtendedCustomFieldNamePane(); return new ExtendedCustomFieldNamePane();
} }
@Override
protected boolean seriesComboBoxHasNone() {
return true;
}
@Override @Override
public void populateBean(AbstractDataConfig ob) { public void populateBean(AbstractDataConfig ob) {

4
designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java

@ -41,7 +41,9 @@ public class UIComboBoxWithNone extends UIComboBox {
public void setSelectedItem(Object anObject) { public void setSelectedItem(Object anObject) {
super.setSelectedItem(anObject); super.setSelectedItem(anObject);
if (getSelectedIndex() == -1) {//找不到的都选中无。中文的无 英文下是none。 //找不到的都选中无。中文的无 英文下是none。
//改正:找不到的且anObject不是null的 全部选中无。
if (getSelectedIndex() == -1 && anObject != null) {
super.setSelectedItem(getDefaultLocaleString()); super.setSelectedItem(getDefaultLocaleString());
} }
} }

7
designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java

@ -805,4 +805,11 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
return false; return false;
} }
/**
* 是否支持置顶显示
*/
public boolean isTopable() {
return true;
}
} }

4
designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java

@ -131,4 +131,8 @@ public class XWAbsoluteBodyLayout extends XWAbsoluteLayout {
return false; return false;
} }
@Override
public boolean isTopable() {
return false;
}
} }

5
designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java

@ -1222,6 +1222,11 @@ public class XWFitLayout extends XLayoutContainer {
return false; return false;
} }
@Override
public boolean isTopable() {
return false;
}
public boolean switch2FitBodyLayout(XCreator creator) { public boolean switch2FitBodyLayout(XCreator creator) {
try { try {
XWFitLayout xfl = (XWFitLayout) creator.getBackupParent(); XWFitLayout xfl = (XWFitLayout) creator.getBackupParent();

6
designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java

@ -251,6 +251,8 @@ public class XWParameterLayout extends XWAbsoluteLayout {
return false; return false;
} }
@Override
public boolean isTopable() {
return false;
}
} }

4
designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java

@ -639,4 +639,8 @@ public class XWTabFitLayout extends XWFitLayout {
checkVisible(); checkVisible();
} }
@Override
public boolean isTopable() {
return true;
}
} }

10
designer-form/src/main/java/com/fr/design/mainframe/TopXCreators.java

@ -58,9 +58,15 @@ public class TopXCreators extends JComponent {
SelectionModel selectionModel = designer.getSelectionModel(); SelectionModel selectionModel = designer.getSelectionModel();
XCreator[] xCreators = selectionModel.getSelection().getSelectedCreators(); XCreator[] xCreators = selectionModel.getSelection().getSelectedCreators();
for (XCreator creator : xCreators) { for (XCreator creator : xCreators) {
if (!creator.isTopable()) {
continue;
}
XWCardMainBorderLayout topXMainBorderLayout = XCreatorUtils.getTopXMainBorderLayout(creator); XWCardMainBorderLayout topXMainBorderLayout = XCreatorUtils.getTopXMainBorderLayout(creator);
TopXCreator topXCreator = topXMainBorderLayout == null ? new TopXCreator(designer, creator) : new TopXCreator(designer, topXMainBorderLayout); add(new TopXCreator(designer, creator));
add(topXCreator); if (topXMainBorderLayout != null) {
add(new TopXCreator(designer, topXMainBorderLayout));
}
} }
} }

4
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/BottomModel.java

@ -49,9 +49,7 @@ public class BottomModel extends AlphaCellModel {
public void doAction() { public void doAction() {
try { try {
Desktop.getDesktop().browse(new URI(AlphaFineConstants.ALPHA_GO_TO_FORUM)); Desktop.getDesktop().browse(new URI(AlphaFineConstants.ALPHA_GO_TO_FORUM));
} catch (IOException e) { } catch (IOException | URISyntaxException e) {
FineLoggerFactory.getLogger().error(e.getMessage());
} catch (URISyntaxException e) {
FineLoggerFactory.getLogger().error(e.getMessage()); FineLoggerFactory.getLogger().error(e.getMessage());
} }
} }

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

@ -106,11 +106,10 @@ public class ContentCellRender implements ListCellRenderer<Object> {
if (strings == null) { if (strings == null) {
return modelName; return modelName;
} }
for (int i = 0; i < strings.length; i++) { for (String string : strings) {
String primaryStr = getReplacedString(modelName, strings[i]); String primaryStr = getReplacedString(modelName, string);
modelName = modelName.replaceAll("(?i)" + strings[i], "|<font color=" + AlphaFineConstants.HIGH_LIGHT_COLOR + ">" + strings[i] + "</font>|");
if (StringUtils.isNotEmpty(primaryStr)) { if (StringUtils.isNotEmpty(primaryStr)) {
modelName = modelName.replaceAll(strings[i], primaryStr); modelName = modelName.replaceAll("(?i)" + primaryStr, "|<font color=" + AlphaFineConstants.HIGH_LIGHT_COLOR + ">" + primaryStr + "</font>|");
} }
} }
modelName = "<html><head><style> .style{" + modelName = "<html><head><style> .style{" +
@ -121,13 +120,24 @@ public class ContentCellRender implements ListCellRenderer<Object> {
return modelName; return modelName;
} }
private String getReplacedString(String modelName, String string) { private String getReplacedString(String modelName, String string) {
int index = modelName.toLowerCase().indexOf(string.toLowerCase()); //需要考虑modelName有空格的情况
//比如现在是work boo k 搜索词是workb,应该要替换的部分是work b
//先去掉空格进行匹配
String noBlackName = modelName.replaceAll(StringUtils.BLANK, StringUtils.EMPTY).toLowerCase();
int index = noBlackName.indexOf(string.toLowerCase());
if (index == -1) { if (index == -1) {
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }
return modelName.substring(index, index + string.length()); StringBuilder result = new StringBuilder();
int count = 0;
while (count < string.length()) {
char pos = modelName.charAt(index++);
result.append(pos);
count += pos == ' ' ? 0 : 1;
}
return result.toString();
} }

168
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java

@ -162,19 +162,15 @@ public class AlphaFineDialog extends UIDialog {
* @return * @return
*/ */
public static AWTEventListener listener() { public static AWTEventListener listener() {
return new AWTEventListener() { return event -> {
if (event instanceof KeyEvent) {
@Override KeyEvent e = (KeyEvent) event;
public void eventDispatched(AWTEvent event) { KeyStroke keyStroke = (KeyStroke) KeyStroke.getAWTKeyStrokeForEvent(e);
if (event instanceof KeyEvent) { KeyStroke storeKeyStroke = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().getShortCutKeyStore();
KeyEvent e = (KeyEvent) event; if (ComparatorUtils.equals(keyStroke.toString(), storeKeyStroke.toString()) && AlphaFineConfigManager.isALPHALicAvailable() && AlphaFinePane.getAlphaFinePane().isVisible()) {
KeyStroke keyStroke = (KeyStroke) KeyStroke.getAWTKeyStrokeForEvent(e); doClickAction();
KeyStroke storeKeyStroke = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().getShortCutKeyStore();
if (ComparatorUtils.equals(keyStroke.toString(), storeKeyStroke.toString()) && AlphaFineConfigManager.isALPHALicAvailable() && AlphaFinePane.getAlphaFinePane().isVisible()) {
doClickAction();
}
} }
} }
}; };
} }
@ -300,7 +296,7 @@ public class AlphaFineDialog extends UIDialog {
if (winSize.width > screenSize.width) { if (winSize.width > screenSize.width) {
winSize.width = screenSize.width; winSize.width = screenSize.width;
} }
//这里设置位置:水平居中,竖直偏上 //这里设置位置:水平居中,竖直偏上
win.setLocation((screenSize.width - winSize.width) / 2, (screenSize.height - winSize.height) / AlphaFineConstants.SHOW_SIZE); win.setLocation((screenSize.width - winSize.width) / 2, (screenSize.height - winSize.height) / AlphaFineConstants.SHOW_SIZE);
} }
@ -513,7 +509,8 @@ public class AlphaFineDialog extends UIDialog {
* @return * @return
*/ */
private String getStoreText(String searchText) { private String getStoreText(String searchText) {
setStoreText(searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length())); //这里也需要先做一个去除不需要空格的处理
setStoreText((searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1)).replaceAll(StringUtils.BLANK, StringUtils.EMPTY));
return storeText; return storeText;
} }
@ -616,9 +613,7 @@ public class AlphaFineDialog extends UIDialog {
rightSearchResultPane.removeAll(); rightSearchResultPane.removeAll();
try { try {
rightSearchResultPane.add(new FilePreviewPane(get())); rightSearchResultPane.add(new FilePreviewPane(get()));
} catch (InterruptedException e) { } catch (InterruptedException | ExecutionException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} catch (ExecutionException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
validate(); validate();
@ -651,9 +646,7 @@ public class AlphaFineDialog extends UIDialog {
rightSearchResultPane.add(new FilePreviewPane(get())); rightSearchResultPane.add(new FilePreviewPane(get()));
validate(); validate();
repaint(); repaint();
} catch (InterruptedException e) { } catch (InterruptedException | ExecutionException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} catch (ExecutionException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
} }
@ -819,56 +812,52 @@ public class AlphaFineDialog extends UIDialog {
} }
}); });
Timer timer = new Timer(TIMER_DELAY, new ActionListener() { Timer timer = new Timer(TIMER_DELAY, e -> {
@Override if (!alreadyInitHot && StringUtils.isEmpty(searchTextField.getText())) {
public void actionPerformed(ActionEvent e) { alreadyInitHot = true;
if (!alreadyInitHot && StringUtils.isEmpty(searchTextField.getText())) { removeSearchResult();
alreadyInitHot = true; refreshContainer();
if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isNeedIntelligentCustomerService()) {
initHotPane();
setSize(AlphaFineConstants.FULL_SIZE);
} else {
setSize(AlphaFineConstants.FIELD_SIZE);
}
refreshContainer();
return;
} else if (beforeSearchStr.equals(searchTextField.getText()) && StringUtils.isNotEmpty(beforeSearchStr)) {
if (alreadySearch) {
return;
} else {
removeHotPane();
removeSearchResult(); removeSearchResult();
refreshContainer(); refreshContainer();
if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isNeedIntelligentCustomerService()) { if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isNeedSegmentationCheckbox()) {
initHotPane(); //是高级搜索
setSize(AlphaFineConstants.FULL_SIZE); if (searchTextField.getText().toLowerCase().startsWith(ADVANCED_SEARCH_MARK)) {
} else { segmentationResult = SegmentationManager.getInstance().startSegmentation(getStoreText(searchTextField.getText().toLowerCase()));
setSize(AlphaFineConstants.FIELD_SIZE); }
} //是普通搜索
refreshContainer(); else {
return; segmentationResult = SegmentationManager.getInstance().startSegmentation(searchTextField.getText().toLowerCase());
} else if (beforeSearchStr.equals(searchTextField.getText()) && StringUtils.isNotEmpty(beforeSearchStr)) { }
if (alreadySearch) {
return;
} else { } else {
removeHotPane(); if (StringUtils.isEmpty(getRealSearchText(searchTextField.getText()))) {
removeSearchResult(); segmentationResult = null;
refreshContainer();
if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isNeedSegmentationCheckbox()) {
//是高级搜索
if (searchTextField.getText().toLowerCase().startsWith(ADVANCED_SEARCH_MARK)) {
segmentationResult = SegmentationManager.getInstance().startSegmentation(getStoreText(searchTextField.getText().toLowerCase()));
}
//是普通搜索
else {
segmentationResult = SegmentationManager.getInstance().startSegmentation(searchTextField.getText().toLowerCase());
}
} else { } else {
if (StringUtils.isEmpty(getRealSearchText(searchTextField.getText()))) { segmentationResult = new String[]{getRealSearchText(searchTextField.getText())};
segmentationResult = null;
} else {
segmentationResult = new String[]{getRealSearchText(searchTextField.getText())};
}
} }
doSearch(searchTextField.getText().toLowerCase());
alreadySearch = true;
} }
} else { doSearch(searchTextField.getText().toLowerCase());
beforeSearchStr = searchTextField.getText(); alreadySearch = true;
alreadySearch = false;
}
if (beforeSearchStr.equals(searchTextField.getText()) && beforeSearchStr.length() != 0) {
alreadyInitHot = false;
} }
} else {
beforeSearchStr = searchTextField.getText();
alreadySearch = false;
}
if (beforeSearchStr.equals(searchTextField.getText()) && beforeSearchStr.length() != 0) {
alreadyInitHot = false;
} }
}); });
timer.start(); timer.start();
} }
@ -880,7 +869,7 @@ public class AlphaFineDialog extends UIDialog {
searchText = searchText.toLowerCase(); searchText = searchText.toLowerCase();
Pattern p = Pattern.compile(AlphaFineConstants.SPECIAL_CHARACTER_REGEX); Pattern p = Pattern.compile(AlphaFineConstants.SPECIAL_CHARACTER_REGEX);
Matcher m = p.matcher(searchText); Matcher m = p.matcher(searchText);
searchText = m.replaceAll("").trim().replaceAll(" ", ""); searchText = m.replaceAll(StringUtils.EMPTY).trim().replaceAll(StringUtils.BLANK, StringUtils.EMPTY);
if (searchText.length() == 0) { if (searchText.length() == 0) {
return null; return null;
} }
@ -901,22 +890,19 @@ public class AlphaFineDialog extends UIDialog {
* 当鼠标在搜索界面边界外点击时触发 * 当鼠标在搜索界面边界外点击时触发
*/ */
private void initAWTEventListener() { private void initAWTEventListener() {
Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { Toolkit.getDefaultToolkit().addAWTEventListener(event -> {
@Override if (!AlphaFineDialog.this.isVisible()) {
public void eventDispatched(AWTEvent event) { return;
if (!AlphaFineDialog.this.isVisible()) { }
return; if (event instanceof MouseEvent) {
} MouseEvent k = (MouseEvent) event;
if (event instanceof MouseEvent) { if (SwingUtilities.isLeftMouseButton(k)) {
MouseEvent k = (MouseEvent) event; Point p = k.getLocationOnScreen();
if (SwingUtilities.isLeftMouseButton(k)) { Rectangle dialogRectangle = AlphaFineDialog.this.getBounds();
Point p = k.getLocationOnScreen(); Rectangle paneRectangle = new Rectangle(AlphaFinePane.getAlphaFinePane().getLocationOnScreen(), AlphaFinePane.getAlphaFinePane().getSize());
Rectangle dialogRectangle = AlphaFineDialog.this.getBounds(); if (!dialogRectangle.contains(p) && !paneRectangle.contains(p) && !forceOpen) {
Rectangle paneRectangle = new Rectangle(AlphaFinePane.getAlphaFinePane().getLocationOnScreen(), AlphaFinePane.getAlphaFinePane().getSize()); AlphaFineDialog.this.dispose();
if (!dialogRectangle.contains(p) && !paneRectangle.contains(p) && !forceOpen) { forceOpen = false;
AlphaFineDialog.this.dispose();
forceOpen = false;
}
} }
} }
} }
@ -925,7 +911,7 @@ public class AlphaFineDialog extends UIDialog {
@Override @Override
public void checkValid() throws Exception { public void checkValid() throws Exception {
//不处理 //不处理
} }
/** /**
@ -948,14 +934,11 @@ public class AlphaFineDialog extends UIDialog {
if (cellModel instanceof BottomModel) { if (cellModel instanceof BottomModel) {
return; return;
} }
Thread sendThread = new Thread(new Runnable() { Thread sendThread = new Thread(() -> {
@Override if (StringUtils.isNotEmpty(storeText)) {
public void run() { RecentSearchManager searchManager = RecentSearchManager.getInstance();
if (StringUtils.isNotEmpty(storeText)) { searchManager.addModel(storeText, cellModel);
RecentSearchManager searchManager = RecentSearchManager.getInstance(); sendDataToServer(storeText, cellModel);
searchManager.addModel(storeText, cellModel);
sendDataToServer(storeText, cellModel);
}
} }
}); });
sendThread.start(); sendThread.start();
@ -1182,12 +1165,9 @@ public class AlphaFineDialog extends UIDialog {
} }
}); });
addListSelectionListener(new ListSelectionListener() { addListSelectionListener(e -> {
@Override if (!e.getValueIsAdjusting() && getSelectedValue() != null) {
public void valueChanged(ListSelectionEvent e) { showResult(getSelectedValue());
if (!e.getValueIsAdjusting() && getSelectedValue() != null) {
showResult(getSelectedValue());
}
} }
}); });

2
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/PluginPreviewPane.java

@ -49,7 +49,7 @@ public class PluginPreviewPane extends JPanel {
nameLabel.setBackground(AlphaFineConstants.BLUE); nameLabel.setBackground(AlphaFineConstants.BLUE);
nameLabel.setBorder(BorderFactory.createEmptyBorder(20, 20, 10, 20)); nameLabel.setBorder(BorderFactory.createEmptyBorder(20, 20, 10, 20));
line.setBorder(BorderFactory.createEmptyBorder(20, 0, 10, 0)); line.setBorder(BorderFactory.createEmptyBorder(20, 0, 10, 0));
String price0 = price == 0 ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Collect_Information_free") : "¥" + String.valueOf(price); String price0 = price == 0 ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Collect_Information_free") : "¥" + price;
UILabel priceLabel = new UILabel(price0); UILabel priceLabel = new UILabel(price0);
priceLabel.setForeground(AlphaFineConstants.RED); priceLabel.setForeground(AlphaFineConstants.RED);
priceLabel.setFont(AlphaFineConstants.MEDIUM_FONT); priceLabel.setFont(AlphaFineConstants.MEDIUM_FONT);

4
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/RobotPreviewPane.java

@ -61,9 +61,7 @@ public class RobotPreviewPane extends JPanel {
.replaceAll("'\\)", StringUtils.EMPTY); .replaceAll("'\\)", StringUtils.EMPTY);
try { try {
Desktop.getDesktop().browse(new URI(AlphaFineConstants.ALPHA_PREVIEW + URLEncoder.encode(s, EncodeConstants.ENCODING_UTF_8))); Desktop.getDesktop().browse(new URI(AlphaFineConstants.ALPHA_PREVIEW + URLEncoder.encode(s, EncodeConstants.ENCODING_UTF_8)));
} catch (IOException e1) { } catch (IOException | URISyntaxException e1) {
FineLoggerFactory.getLogger().error(e1.getMessage());
} catch (URISyntaxException e1) {
FineLoggerFactory.getLogger().error(e1.getMessage()); FineLoggerFactory.getLogger().error(e1.getMessage());
} }
} }

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

@ -33,7 +33,7 @@ public class FileSearchManager implements AlphaFineSearchProvider {
private FileNode[] fileNodes = null; private FileNode[] fileNodes = null;
//停止搜索 //停止搜索
//隐藏的搜索功能,可根据特殊的字符标记判断搜索分类 //隐藏的搜索功能,可根据特殊的字符标记判断搜索分类
private boolean isContainCpt = true; private boolean isContainCpt = true;
private boolean isContainFrm = true; private boolean isContainFrm = true;
@ -108,20 +108,22 @@ public class FileSearchManager implements AlphaFineSearchProvider {
private void doSearch(String searchText) { private void doSearch(String searchText) {
if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainTemplate()) { if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainTemplate()) {
for (FileNode node : fileNodes) { for (FileNode node : fileNodes) {
if (node.getName().toLowerCase().contains(searchText)) { String name = node.getName().toLowerCase();
name = name.replaceAll(StringUtils.BLANK, StringUtils.EMPTY);
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)) {
AlphaFineHelper.checkCancel(); AlphaFineHelper.checkCancel();
filterModelList.add(model); filterModelList.add(model);
} }
} }
} }
} }
} }
/** /**
* 搜索模板内容 * 搜索模板内容
*
* @param searchText * @param searchText
*/ */
private void doFileContentSearch(String searchText) { private void doFileContentSearch(String searchText) {
@ -140,10 +142,10 @@ public class FileSearchManager implements AlphaFineSearchProvider {
private String dealWithSearchText(String searchText) { private String dealWithSearchText(String searchText) {
if (searchText.startsWith(FRM_PREFIX)) { if (searchText.startsWith(FRM_PREFIX)) {
isContainCpt = false; isContainCpt = false;
searchText = searchText.substring(MARK_LENGTH, searchText.length()); searchText = searchText.substring(MARK_LENGTH);
} else if (searchText.startsWith(CPT_PREFIX)) { } else if (searchText.startsWith(CPT_PREFIX)) {
isContainFrm = false; isContainFrm = false;
searchText = searchText.substring(MARK_LENGTH, searchText.length()); searchText = searchText.substring(MARK_LENGTH);
} }
return searchText; return searchText;
} }

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

@ -42,10 +42,7 @@ public class SegmentationManager {
count = count + 1; count = count + 1;
} }
} }
if (count >= MAX_CHINESE_CHARACTERS_NUM) { return count >= MAX_CHINESE_CHARACTERS_NUM;
return true;
}
return false;
} }
/** /**

79
designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/FileSearchManagerTest.java

@ -0,0 +1,79 @@
package com.fr.design.mainframe.alphafine.search.manager.impl;
import com.fr.base.FRContext;
import com.fr.base.extension.FileExtension;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.help.alphafine.AlphaFineConfigManager;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.file.filetree.FileNode;
import com.fr.invoke.Reflect;
import com.fr.stable.project.ProjectConstants;
import com.fr.web.core.SessionPoolManager;
import com.fr.web.utils.WebUtils;
import org.easymock.EasyMock;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
import org.powermock.modules.junit4.PowerMockRunner;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.*;
/**
* @author Yyming
* @version 10.0
* Created by Yyming on 2020/9/15
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest({AlphaFineHelper.class,DesignerEnvManager.class})
@SuppressStaticInitializationFor("com.fr.design.mainframe.alphafine.AlphaFineHelper")
public class FileSearchManagerTest {
@Test
public void doSearch() {
String searchText = "workb";
FileSearchManager instance = FileSearchManager.getInstance();
FileNode fileNode1 = EasyMock.createMock(FileNode.class);
FileNode fileNode2 = EasyMock.createMock(FileNode.class);
EasyMock.expect(fileNode1.getName()).andReturn("workbook").anyTimes();
EasyMock.expect(fileNode2.getName()).andReturn("work book").anyTimes();
EasyMock.expect(fileNode1.getEnvPath()).andReturn("").anyTimes();
EasyMock.expect(fileNode2.getEnvPath()).andReturn("").anyTimes();
EasyMock.replay(fileNode1,fileNode2);
FileNode[] fileNodes = { fileNode1, fileNode2 };
Reflect.on(instance).set("fileNodes",fileNodes);
AlphaFineConfigManager configManager = EasyMock.createMock(AlphaFineConfigManager.class);
EasyMock.expect(configManager.isContainTemplate()).andReturn(true).anyTimes();
EasyMock.replay(configManager);
DesignerEnvManager manager = EasyMock.createMock(DesignerEnvManager.class);
EasyMock.expect(manager.getAlphaFineConfigManager()).andReturn(configManager).anyTimes();
EasyMock.replay(manager);
PowerMock.mockStatic(DesignerEnvManager.class);
DesignerEnvManager.getEnvManager();
PowerMock.expectLastCall().andReturn(manager).anyTimes();
PowerMock.replay(DesignerEnvManager.class);
List<AlphaCellModel> list = new ArrayList<>();
PowerMock.mockStatic(AlphaFineHelper.class);
AlphaFineHelper.getFilterResult();
PowerMock.expectLastCall().andReturn(list).anyTimes();
AlphaFineHelper.findFolderName("");
PowerMock.expectLastCall().andReturn("").anyTimes();
AlphaFineHelper.checkCancel();
PowerMock.expectLastCall().andVoid().anyTimes();
PowerMock.replay(AlphaFineHelper.class);
SearchResult alphaCellModels = new SearchResult();
Reflect.on(instance).set("filterModelList",alphaCellModels);
Reflect.on(instance).call("doSearch",searchText);
assertEquals(alphaCellModels.size(),2);
}
}

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

@ -0,0 +1,23 @@
package com.fr.design.mainframe.alphafine.cell.render;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* @author Yyming
* @version 10.0
* Created by Yyming on 2020/9/16
*/
public class ContentCellRenderTest {
@Test
public void highLightModelName() {
String searchText = "workb";
ContentCellRender contentCellRender = new ContentCellRender(searchText,new String[]{searchText});
String workbook = contentCellRender.highLightModelName("workbook", new String[]{searchText});
assertTrue(workbook.endsWith("workb</font>ook</body></HTML>"));
workbook = contentCellRender.highLightModelName("work book", new String[]{searchText});
assertTrue(workbook.endsWith("work b</font>ook</body></HTML>"));
}
}
Loading…
Cancel
Save