diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java index 68bb917114..da2f0e0dc7 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -218,14 +218,9 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { if (needCheckEnv) { checkNameEnvMap(); } - - GeneralContext.addEnvChangedListener(new EnvChangedListener() { - @Override - public void envChanged() { - - designerEnvManager.setCurrentDirectoryPrefix(FILEFactory.ENV_PREFIX); - designerEnvManager.setDialogCurrentDirectory(ProjectConstants.REPORTLETS_NAME); - } + GeneralContext.addEnvChangedListener(() -> { + designerEnvManager.setCurrentDirectoryPrefix(FILEFactory.ENV_PREFIX); + designerEnvManager.setDialogCurrentDirectory(ProjectConstants.REPORTLETS_NAME); }); } diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java index 23e6f46136..d1beacb1d8 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java @@ -218,7 +218,7 @@ public class DBTableDataPane extends AbstractTableDataPane { paramTexts[0] = SqlUtils.tryPureSqlText(sqlTextPane.getText()); paramTexts[1] = SqlUtils.tryPureSqlText(pageQuery); List 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)); } diff --git a/designer-base/src/main/java/com/fr/design/dialog/ErrorDialog.java b/designer-base/src/main/java/com/fr/design/dialog/ErrorDialog.java index 21042a57a9..11a49fafe1 100644 --- a/designer-base/src/main/java/com/fr/design/dialog/ErrorDialog.java +++ b/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); UILabel boldFontLabel = new UILabel(message); 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); messagePane.add(boldFontLabel); messagePane.add(label); diff --git a/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java b/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java index 2f30f70b97..37a671eeb8 100644 --- a/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java +++ b/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java @@ -40,6 +40,12 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { private WorkspaceConnectionInfo connection; + /** + * 标记下新创建的远程工作目录 兼容存留的远程目录客户升级后再回退 读取为密文 + * 仅保证当前新增是加密的 + */ + private boolean newCreated; + public static RemoteDesignerWorkspaceInfo create(WorkspaceConnectionInfo connection) { RemoteDesignerWorkspaceInfo info = new RemoteDesignerWorkspaceInfo(); info.connection = connection; @@ -79,12 +85,21 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { return remindTime; } + public boolean isNewCreated() { + return newCreated; + } + + public void setNewCreated(boolean newCreated) { + this.newCreated = newCreated; + } + @Override public void readXML(XMLableReader reader) { if (reader.isAttr()) { this.name = reader.getAttrAsString("name", StringUtils.EMPTY); this.remindTime = reader.getAttrAsString("remindTime", StringUtils.EMPTY); + this.newCreated = reader.getAttrAsBoolean("newCreated", false); } if (reader.isChildNode()) { String tagName = reader.getTagName(); @@ -92,32 +107,49 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { String url = reader.getAttrAsString("url", 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 certSecretKey = reader.getAttrAsString("certSecretKey", StringUtils.EMPTY); + String certSecretKey = readCertSecretKey(reader); boolean rememberPwd = reader.getAttrAsBoolean("rememberPwd", true); 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 public void writeXML(XMLPrintWriter writer) { writer.attr("name", name); writer.attr("remindTime", remindTime); + writer.attr("newCreated", isNewCreated()); if (this.connection != null) { writer.startTAG("Connection"); writer.attr("url", connection.getUrl()); writer.attr("username", connection.getUserName()); writer.attr("password", SecurityToolbox.defaultEncrypt(connection.getPassword())); writer.attr("certPath", connection.getCertPath()); - writer.attr("certSecretKey", connection.getCertSecretKey()); + writeCertSecretKey(writer); writer.attr("rememberPwd", connection.isRememberPwd()); writer.end(); } } + private void writeCertSecretKey(XMLPrintWriter writer) { + if (isNewCreated()) { + writer.attr("certSecretKey", SecurityToolbox.defaultEncrypt(connection.getCertSecretKey())); + } else { + writer.attr("certSecretKey", connection.getCertSecretKey()); + } + } + @Override @SuppressWarnings("squid:S2975") public Object clone() throws CloneNotSupportedException { diff --git a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java index df07acf1ab..77407a3eda 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java +++ b/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 { 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; private int containerWidth = 240; @@ -266,13 +266,7 @@ public class UIEastResizableContainer extends JPanel { @Override public void mouseDragged(MouseEvent e) { - containerWidth = UIEastResizableContainer.this.getWidth() + (UIEastResizableContainer.this.getLocationOnScreen().x - e.getXOnScreen()); - containerWidth = Math.min(containerWidth, MAX_CONTAINER_WIDTH); - containerWidth = Math.max(containerWidth, MIN_CONTAINER_WIDTH); - refreshContainer(); - if ( DesignModeContext.isAuthorityEditing()) { - DesignerContext.getDesignerFrame().doResize(); - } + // do noting } }); addMouseListener(new MouseAdapter() { diff --git a/designer-base/src/main/java/com/fr/env/EnvListPane.java b/designer-base/src/main/java/com/fr/env/EnvListPane.java index 911a7b22f8..2d875cb458 100644 --- a/designer-base/src/main/java/com/fr/env/EnvListPane.java +++ b/designer-base/src/main/java/com/fr/env/EnvListPane.java @@ -3,6 +3,7 @@ package com.fr.env; import com.fr.design.DesignerEnvManager; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.env.DesignerWorkspaceInfo; +import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.LocalDesignerWorkspaceInfo; import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.gui.controlpane.JListControlPane; @@ -17,8 +18,10 @@ import com.fr.stable.core.PropertyChangeAdapter; import javax.swing.*; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Set; /** * @author yaohwu @@ -98,11 +101,30 @@ public class EnvListPane extends JListControlPane { DesignerEnvManager mgr = DesignerEnvManager.getEnvManager(); //这里代码时序换一下,因为update中需要借助mgr来获取提醒时间,已确认mgr对res无依赖 Nameable[] res = this.update(); + Set set = findNewWorkSpaceInfo(res); mgr.clearAllEnv(); for (Nameable re : res) { 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(); } + + private Set findNewWorkSpaceInfo(Nameable[] res) { + Set set = new HashSet<>(); + for (Nameable val : res) { + NameObject nameObject = (NameObject) val; + if (DesignerEnvManager.getEnvManager().getWorkspaceInfo(nameObject.getName()) == null) { + set.add(val); + } + } + return set; + } } diff --git a/designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java b/designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java index 54dbae3b02..d6e89cd93f 100644 --- a/designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java +++ b/designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java @@ -1,9 +1,16 @@ 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 junit.framework.TestCase; import org.junit.Assert; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; + /** * @author hades * @version 10.0 @@ -22,4 +29,64 @@ public class RemoteDesignerWorkspaceInfoTest extends TestCase { Assert.assertFalse(workspaceInfo3.checkValid()); } + public void testReadXml() { + String xml0 = ""; + String xml1 = ""; + 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\"")); + + } + } diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java index e4e27b7f49..16f983c758 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java @@ -82,6 +82,10 @@ public abstract class AbstractCustomFieldComboBoxPane extends BasicBeanPane extends BasicBeanPane { if (strings == null) { return modelName; } - for (int i = 0; i < strings.length; i++) { - String primaryStr = getReplacedString(modelName, strings[i]); - modelName = modelName.replaceAll("(?i)" + strings[i], "|" + strings[i] + "|"); + for (String string : strings) { + String primaryStr = getReplacedString(modelName, string); if (StringUtils.isNotEmpty(primaryStr)) { - modelName = modelName.replaceAll(strings[i], primaryStr); + modelName = modelName.replaceAll("(?i)" + primaryStr, "|" + primaryStr + "|"); } } modelName = "