Browse Source

Merging in latest from upstream (DESIGN/design:refs/heads/release/10.0)

* commit '818543e391ada9b5e37d7db4bd509f5e2c926de4':
  REPORT-13902 错误的test依赖, 先移出来.
  切换事件监听优先级
  load 场景下 模板内存优化结果的处理
  REPORT-13202 包含插件控件的模板切换环境后存储出错
  REPORT-12718 设计器漏传了.
  无JIRA任务 去掉httpclient的使用
  REPORT-13802
  REPORT-13802
  REPORT-13810
  REPORT-13303 设计器如果根目录有很多面板, 会卡在白屏很久, 不合理.
  REPORT-13626  先改回去,不在回归里面处理,一直都是这样的逻辑
  REPORT-13074 远程设计向下兼容 1. 将尝试连接和正式连接提示分开。
  CHART-3086 geojson读写移到core。service相关改动较大 下一波处理
  REPORT-13074 远程设计向下兼容 1. 忘了注释掉
  REPORT-13074 远程设计向下兼容 1. 修复一下逻辑。 更方便理解
  REPORT-13074 远程设计向下兼容 1. 补充一些注释。
  REPORT-13074 远程设计向下兼容 1. 加入序列化异常 SerilizationException , WorkspaceNoteHitException 2. 加入切换远程连接的检测,以及测试远程连接的提醒。
bugfix/10.0
abel.chen 6 years ago
parent
commit
8464f8c0ee
  1. 65
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  2. 79
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  3. 5
      designer-base/src/main/java/com/fr/design/gui/itextfield/UIAutoCompletionField.java
  4. 30
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  5. 13
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  6. 34
      designer-base/src/main/java/com/fr/env/RemoteEnvPane.java
  7. 62
      designer-base/src/main/java/com/fr/env/TestConnectionResult.java
  8. 2
      designer-base/src/main/resources/com/fr/design/insert/formula/variable/cn/servletURL.txt
  9. 2
      designer-base/src/main/resources/com/fr/design/insert/formula/variable/en/servletURL.txt
  10. 11
      designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/MapDataTree.java
  11. 10
      designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapSourceChoosePane.java
  12. 4
      designer-form/src/main/java/com/fr/design/designer/creator/ErrorCreator.java
  13. 4
      designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java
  14. 29
      designer-form/src/test/java/com/fr/form/ui/WidgetNameCopyTest.java
  15. 82
      designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java
  16. 46
      designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java

65
designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java

@ -5,6 +5,7 @@ import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.design.env.DesignerWorkspaceGenerator;
import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.TemplateTreePane; import com.fr.design.file.TemplateTreePane;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
@ -15,19 +16,25 @@ import com.fr.env.EnvListPane;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.license.exception.RegistEditionException; import com.fr.license.exception.RegistEditionException;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.AssistUtils;
import com.fr.stable.EnvChangedListener; import com.fr.stable.EnvChangedListener;
import com.fr.start.server.ServerTray; import com.fr.start.server.ServerTray;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.WorkContextCallback; import com.fr.workspace.WorkContextCallback;
import com.fr.workspace.Workspace; import com.fr.workspace.Workspace;
import com.fr.workspace.connect.AuthException; import com.fr.workspace.connect.AuthException;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.engine.channel.http.FunctionalHttpRequest;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.UIManager; import javax.swing.UIManager;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import static javax.swing.JOptionPane.ERROR_MESSAGE; import static javax.swing.JOptionPane.ERROR_MESSAGE;
import static javax.swing.JOptionPane.QUESTION_MESSAGE;
public class EnvChangeEntrance { public class EnvChangeEntrance {
@ -90,15 +97,21 @@ public class EnvChangeEntrance {
}); });
return false; return false;
} }
// 如果版本不一致,且确认 不继续 连接,这里返回 false.
if (!versionCheckAndConfirm(selectedEnv)) {
return false;
}
//REPORT-13810如果只是添加了工作目录,没有切换,这里ToolArea也是要显示新建的工作目录
JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) {
template.refreshToolArea();
}
WorkContext.switchTo(workspace, new WorkContextCallback() { WorkContext.switchTo(workspace, new WorkContextCallback() {
@Override @Override
public void done() { public void done() {
DesignerEnvManager.getEnvManager().setCurEnvName(envName); DesignerEnvManager.getEnvManager().setCurEnvName(envName);
DesignUtils.refreshDesignerFrame(); DesignUtils.refreshDesignerFrame();
JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) {
template.refreshToolArea();
}
DesignTableDataManager.fireDSChanged(new HashMap<String, String>()); DesignTableDataManager.fireDSChanged(new HashMap<String, String>());
if (WorkContext.getCurrent().isLocal()) { if (WorkContext.getCurrent().isLocal()) {
//初始化一下serverTray //初始化一下serverTray
@ -138,6 +151,50 @@ public class EnvChangeEntrance {
return true; return true;
} }
/**
* 切换远程环境之前进行版本检测当版本不一致的时候提示
* 当用户确认选择 ok 才继续
*
* @param selectedEnv 选择的环境
* @return 是否一致
* 1. 非远程环境 返回 true
* 2. 远程环境
* 2.1 不匹配
* 2.1.1 当选择 ok 返回 true
* 2.1.2 当选择 no, 返回 false
* 2.2 匹配 返回 true
* @throws Exception 异常
*/
private boolean versionCheckAndConfirm(DesignerWorkspaceInfo selectedEnv) throws Exception {
if (selectedEnv.getType() == DesignerWorkspaceType.Remote) {
WorkspaceConnectionInfo info = selectedEnv.getConnection();
String serverVersion = new FunctionalHttpRequest(info).getServerVersion();
if (AssistUtils.equals(serverVersion, WorkContext.getVersion())) {
return true;
}
final List<Integer> result = new ArrayList<>(1);
PopTipStrategy.NOW.showTip(new PopTip() {
@Override
public void show() {
String[] option = {Toolkit.i18nText("Fine-Design_Report_Yes"), Toolkit.i18nText("Fine-Design_Report_No")};
int choice = JOptionPane.showOptionDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Version_Inconsistency"),
UIManager.getString("OptionPane.messageDialogTitle"), JOptionPane.YES_NO_OPTION, QUESTION_MESSAGE, UIManager.getIcon("OptionPane.warningIcon"), option, 1);
result.add(choice);
}
});
// 只有选择 yes , 这里的值才为 0, 返回 true
// 否着返回 false, 将不进行下面的连接操作。
return result.size() != 0 && result.get(0) == 0;
}
return true;
}
/** /**
* 编辑items * 编辑items
* *

79
designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java

@ -1,6 +1,8 @@
package com.fr.design.file; package com.fr.design.file;
import com.fr.base.chart.chartdata.CallbackEvent; import com.fr.base.chart.chartdata.CallbackEvent;
import com.fr.base.io.BaseBook;
import com.fr.base.io.IOFile;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.base.mode.DesignModeContext; import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
@ -18,10 +20,14 @@ import com.fr.stable.CoreConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.third.org.apache.commons.io.FilenameUtils; import com.fr.third.org.apache.commons.io.FilenameUtils;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.ListIterator; import java.util.ListIterator;
import java.util.Map;
/** /**
* 历史模板缓存 * 历史模板缓存
@ -305,4 +311,77 @@ public class HistoryTemplateListCache implements CallbackEvent {
} }
return true; return true;
} }
/**
* 切换环境时暂存打开的模板内容key 是在历史中的indexvalue 是模板xml 内容byte[]
*/
private Map<Integer, byte[]> bytesMap;
/**
* 切换环境前将正在编辑的模板暂存起来并且在新环境中重新读取一遍暂存的不是模板文件的内容而是模板对象的内容
* <p>
* 防止新环境加载到的同名 Class 和模板对象中的 Class 不一致在新环境存储失败
*
* @see HistoryTemplateListCache#load()
*/
public void stash() {
FineLoggerFactory.getLogger().info("Env Change Template Stashing...");
if (bytesMap == null) {
bytesMap = new HashMap<Integer, byte[]>();
} else {
bytesMap.clear();
}
int size = historyList.size();
for (int i = 0; i < size; i++) {
JTemplate<?, ?> template = historyList.get(i);
try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
BaseBook target = template.getTarget();
if (target != null) {
target.export(outputStream);
bytesMap.put(i, outputStream.toByteArray());
}
// 如果 target == null 那么这个模板是被模板内存优化功能处理过的,不用处理
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
FineLoggerFactory.getLogger().info("Env Change Template Stashed.");
}
/**
* 切换环境前将正在编辑的模板暂存起来后在新环境重新读取一遍
* <p>
* 防止新环境加载到的同名 Class 和模板对象中的 Class 不一致在新环境存储失败
*
* @see HistoryTemplateListCache#stash()
*/
public void load() {
FineLoggerFactory.getLogger().info("Env Change Template Loading...");
if (bytesMap != null && bytesMap.size() != 0) {
int size = historyList.size();
for (int i = 0; i < size; i++) {
try {
byte[] bytes = bytesMap.get(i);
// 可能有模板 stash 失败的情况,在 load 的时候不更新它
if (bytes == null) {
continue;
}
ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
BaseBook target = historyList.get(i).getTarget();
if (target != null) {
// todo readStream 这个行为应该上升到 BaseBook 上
((IOFile) target).readStream(inputStream);
}
// 如果 target == null 那么这个模板是被模板内存优化功能处理过的,不用处理
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
bytesMap.clear();
MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList);
MutilTempalteTabPane.getInstance().repaint();
}
FineLoggerFactory.getLogger().info("Env Change Template Loaded.");
}
} }

5
designer-base/src/main/java/com/fr/design/gui/itextfield/UIAutoCompletionField.java

@ -2,6 +2,8 @@ package com.fr.design.gui.itextfield;
import com.fr.design.gui.imenu.UIListPopup; import com.fr.design.gui.imenu.UIListPopup;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.stable.OperatingSystem;
import javax.swing.JList; import javax.swing.JList;
import javax.swing.UIManager; import javax.swing.UIManager;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
@ -82,6 +84,9 @@ public class UIAutoCompletionField extends UITextField implements DocumentListen
} }
private void textChanged() { private void textChanged() {
if (OperatingSystem.isMacOS()) {
return;
}
if (!popup.isVisible()) { if (!popup.isVisible()) {
showPopup(); showPopup();
requestFocus(); requestFocus();

30
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java

@ -102,6 +102,8 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class DesignerFrame extends JFrame implements JTemplateActionListener, TargetModifiedListener { public class DesignerFrame extends JFrame implements JTemplateActionListener, TargetModifiedListener {
@ -241,6 +243,9 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
private ProgressDialog progressDialog; private ProgressDialog progressDialog;
private ExecutorService fixedThreadPool = Executors.newFixedThreadPool(1);
public DesignerFrame(ToolBarMenuDock ad) { public DesignerFrame(ToolBarMenuDock ad) {
setName(DESIGNER_FRAME_NAME); setName(DESIGNER_FRAME_NAME);
@ -815,18 +820,21 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* 报表运行环境改变时,需要刷新某些面板 * 报表运行环境改变时,需要刷新某些面板
*/ */
public void refreshEnv() { public void refreshEnv() {
this.setTitle(); this.setTitle();
DesignerFrameFileDealerPane.getInstance().refreshDockingView(); fixedThreadPool.execute(new Runnable() {
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()); @Override
TemplateTreePane.getInstance().refreshDockingView(); public void run() {
DesignTableDataManager.clearGlobalDs(); DesignerFrameFileDealerPane.getInstance().refreshDockingView();
EastRegionContainerPane.getInstance().refreshDownPane(); TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter());
TemplateTreePane.getInstance().refreshDockingView();
JTemplate template = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); DesignTableDataManager.clearGlobalDs();
if (template != null) { EastRegionContainerPane.getInstance().refreshDownPane();
template.refreshToolArea(); JTemplate template = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
} if (template != null) {
template.refreshToolArea();
}
}
});
} }
/** /**

13
designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

@ -522,19 +522,6 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
if (editingFILE == null) { if (editingFILE == null) {
return false; return false;
} }
// //检查一下连接是否成功
// try {
// if (FRContext.getCommonOperator() != null && !FRContext.getCommonOperator().testServerConnectionWithOutShowMessagePane()) {
// //连接不成功,提示
// JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
// com.fr.design.i18n.Toolkit.i18nText(new String[]{"server_disconnected", "template_unsaved"}, new String[]{",", "!"})
// , com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Error"), JOptionPane.ERROR_MESSAGE);
// return false;
// }
// } catch (Exception e) {
// FineLoggerFactory.getLogger().error(e.getMessage(), e);
// }
// 检查一下editingFILE是不是已存在的文件,如果不存在则用saveAs // 检查一下editingFILE是不是已存在的文件,如果不存在则用saveAs
if (!editingFILE.exists()) { if (!editingFILE.exists()) {

34
designer-base/src/main/java/com/fr/env/RemoteEnvPane.java vendored

@ -511,14 +511,14 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
} }
private void tryConnectRemoteEnv() { private void tryConnectRemoteEnv() {
final RemoteDesignerWorkspaceInfo remoteEnv = updateBean();
final WorkspaceConnectionInfo connection = remoteEnv.getConnection();
final SwingWorker<Boolean, Void> worker = new SwingWorker<Boolean, Void>() { final SwingWorker<Boolean, Void> worker = new SwingWorker<Boolean, Void>() {
@Override @Override
protected Boolean doInBackground() throws Exception { protected Boolean doInBackground() throws Exception {
final RemoteDesignerWorkspaceInfo remoteEnv = updateBean();
WorkspaceConnectionInfo connection = remoteEnv.getConnection();
DesignerEnvManager.getEnvManager().setCertificatePath(connection.getCertPath()); DesignerEnvManager.getEnvManager().setCertificatePath(connection.getCertPath());
DesignerEnvManager.getEnvManager().setCertificatePass(connection.getCertSecretKey()); DesignerEnvManager.getEnvManager().setCertificatePass(connection.getCertSecretKey());
try { try {
@ -532,18 +532,26 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
protected void done() { protected void done() {
okButton.setEnabled(true); okButton.setEnabled(true);
try { try {
Boolean result = get();
if (result == null) { TestConnectionResult result = TestConnectionResult.parse(get(), connection);
if (result == TestConnectionResult.Fully_Success) {
message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Successful"));
uiLabel.setIcon(UIManager.getIcon("OptionPane.informationIcon"));
}
if (result == TestConnectionResult.Partly_Sucess) {
message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Version_Inconsistence_Test"));
uiLabel.setIcon(UIManager.getIcon("OptionPane.warningIcon"));
}
if (result == TestConnectionResult.Fully_Failed) {
message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Failed"));
uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon"));
}
if (result == TestConnectionResult.Auth_Failed) {
message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed")); message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed"));
uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon")); uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon"));
} else {
if (result) {
message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Successful"));
uiLabel.setIcon(UIManager.getIcon("OptionPane.informationIcon"));
} else {
message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Failed"));
uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon"));
}
} }
} catch (InterruptedException | ExecutionException e) { } catch (InterruptedException | ExecutionException e) {
FineLoggerFactory.getLogger().error(e, e.getMessage()); FineLoggerFactory.getLogger().error(e, e.getMessage());

62
designer-base/src/main/java/com/fr/env/TestConnectionResult.java vendored

@ -0,0 +1,62 @@
package com.fr.env;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.AssistUtils;
import com.fr.workspace.WorkContext;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.engine.channel.http.FunctionalHttpRequest;
/**
* 测试连接的结果
* 不改变原有逻辑的情况下加入一层转化
* 根据这里的转化结果判断需要提示哪些内容
*
* created by Harrison on 2018/12/20
**/
public enum TestConnectionResult {
/**
* 完全成功, 版本匹配测试连接成功
*/
Fully_Success,
/**
* 不完全成功版本不匹配但测试连接成功
*/
Partly_Sucess,
/**
* 完全失败直接没连上
*/
Fully_Failed,
/**
* 验证 Token 失败
*/
Auth_Failed;
public static TestConnectionResult parse(Boolean value, WorkspaceConnectionInfo info) {
if (value == null) {
return Auth_Failed;
}
if (!value) {
return Fully_Failed;
}
try {
String serverVersion = new FunctionalHttpRequest(info).getServerVersion();
if (AssistUtils.equals(serverVersion, WorkContext.getVersion())) {
return Fully_Success;
}
return Partly_Sucess;
} catch (Exception e) {
// 发生异常,说明没连接上。返回完全失败。
FineLoggerFactory.getLogger().error(e.getMessage());
return Fully_Failed;
}
}
}

2
designer-base/src/main/resources/com/fr/design/insert/formula/variable/cn/servletURL.txt

@ -1 +1 @@
假如访问:http://localhost:8080/WebReport/ReportServer?reportlet=WorkBook1.cpt,servletURL指的是:/WebReport/ReportServer 假如访问的是http://localhost:8075/webroot/decision/view/report?viewlet=workbook1.cpt,servletURL指的是:/webroot/decision/view/report

2
designer-base/src/main/resources/com/fr/design/insert/formula/variable/en/servletURL.txt

@ -1 +1 @@
http://localhost:8080/WebReport/ReportServer?reportlet=WorkBook1.cpt,servletURL is /WebReport/ReportServer http://localhost:8075/webroot/decision/view/report?viewlet=workbook1.cpt,servletURL is /webroot/decision/view/report

11
designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/MapDataTree.java

@ -4,8 +4,9 @@ import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.plugin.chart.map.designer.type.GEOJSONTreeHelper; import com.fr.plugin.chart.map.designer.type.GEOJSONTreeHelper;
import com.fr.plugin.chart.map.server.ChartGEOJSONHelper;
import com.fr.plugin.chart.map.server.CompatibleGEOJSONHelper; import com.fr.plugin.chart.map.server.CompatibleGEOJSONHelper;
import com.fr.plugin.chart.map.server.GEOJSONHelper; import com.fr.geojson.helper.GEOJSONHelper;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.JTree; import javax.swing.JTree;
@ -78,7 +79,7 @@ public class MapDataTree extends JTree {
DefaultMutableTreeNode currentSel = (DefaultMutableTreeNode)this.getLastSelectedPathComponent(); DefaultMutableTreeNode currentSel = (DefaultMutableTreeNode)this.getLastSelectedPathComponent();
return GEOJSONHelper.getInstance().getJsonUrlByPath(currentSel.getUserObject().toString()); return CompatibleGEOJSONHelper.getJsonUrlByPathIncludeParam(currentSel.getUserObject().toString());
} }
//根据路径精确查找 //根据路径精确查找
@ -96,7 +97,7 @@ public class MapDataTree extends JTree {
return null; return null;
} }
String dirPath = el.getUserObject().toString(); String dirPath = el.getUserObject().toString();
String url = GEOJSONHelper.getInstance().getJsonUrlByPath(dirPath); String url = CompatibleGEOJSONHelper.getJsonUrlByPathIncludeParam(dirPath);
if (GEOJSONHelper.getInstance().isValidDirPath(dirPath) && ComparatorUtils.equals(jsonUrl, url)){ if (GEOJSONHelper.getInstance().isValidDirPath(dirPath) && ComparatorUtils.equals(jsonUrl, url)){
selectTreeNode(el, m_model); selectTreeNode(el, m_model);
return el; return el;
@ -133,7 +134,7 @@ public class MapDataTree extends JTree {
if(treeNode == null || treeNode.getUserObject() == null){ if(treeNode == null || treeNode.getUserObject() == null){
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }
return GEOJSONHelper.getPresentNameWithPath(treeNode.getUserObject().toString()); return ChartGEOJSONHelper.getPresentNameWithPath(treeNode.getUserObject().toString());
} }
//模糊搜索 深度优先. //模糊搜索 深度优先.
@ -149,7 +150,7 @@ public class MapDataTree extends JTree {
DefaultMutableTreeNode el = els.nextElement(); DefaultMutableTreeNode el = els.nextElement();
String path = el.getUserObject().toString(); String path = el.getUserObject().toString();
String fileName = GEOJSONHelper.getPresentNameWithPath(path); String fileName = ChartGEOJSONHelper.getPresentNameWithPath(path);
if (GEOJSONHelper.getInstance().isValidDirPath(path) && StringUtils.contains(fileName, text)) { if (GEOJSONHelper.getInstance().isValidDirPath(path) && StringUtils.contains(fileName, text)) {
selectTreeNode(el, m_model); selectTreeNode(el, m_model);
return; return;

10
designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapSourceChoosePane.java

@ -18,15 +18,15 @@ import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.plugin.chart.base.GisLayer; import com.fr.plugin.chart.base.GisLayer;
import com.fr.plugin.chart.base.ViewCenter; import com.fr.plugin.chart.base.ViewCenter;
import com.fr.plugin.chart.map.VanChartMapPlot; import com.fr.plugin.chart.map.VanChartMapPlot;
import com.fr.plugin.chart.map.designer.type.GEOJSONTreeHelper; import com.fr.plugin.chart.map.designer.type.GEOJSONTreeHelper;
import com.fr.plugin.chart.map.layer.WMSLayer; import com.fr.plugin.chart.map.layer.WMSLayer;
import com.fr.plugin.chart.map.server.ChartGEOJSONHelper;
import com.fr.plugin.chart.map.server.CompatibleGEOJSONHelper; import com.fr.plugin.chart.map.server.CompatibleGEOJSONHelper;
import com.fr.plugin.chart.map.server.GEOJSONHelper; import com.fr.geojson.helper.GEOJSONHelper;
import com.fr.plugin.chart.map.server.MapLayerConfigManager; import com.fr.plugin.chart.map.server.MapLayerConfigManager;
import com.fr.plugin.chart.service.WMSFactory; import com.fr.plugin.chart.service.WMSFactory;
import com.fr.plugin.chart.type.GISLayerType; import com.fr.plugin.chart.type.GISLayerType;
@ -201,7 +201,7 @@ public class VanChartMapSourceChoosePane extends JPanel implements UIObserver {
} else if(o instanceof String){//list里面没有 } else if(o instanceof String){//list里面没有
selectTreePath = null; selectTreePath = null;
this.tree.setSelectionPath(null); this.tree.setSelectionPath(null);
this.getModel().setSelectedItem(GEOJSONHelper.getPresentNameWithPath((String) o)); this.getModel().setSelectedItem(ChartGEOJSONHelper.getPresentNameWithPath((String) o));
} }
} }
@ -209,7 +209,7 @@ public class VanChartMapSourceChoosePane extends JPanel implements UIObserver {
protected String pathToString(TreePath path) { protected String pathToString(TreePath path) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
//不显示后缀 //不显示后缀
return GEOJSONHelper.getPresentNameWithPath(node.toString()); return ChartGEOJSONHelper.getPresentNameWithPath(node.toString());
} }
@Override @Override
@ -533,7 +533,7 @@ public class VanChartMapSourceChoosePane extends JPanel implements UIObserver {
GEOJSONTreeHelper.getInstance().updateParamRootNode(VanChartMapSourceChoosePane.this.getParams()); GEOJSONTreeHelper.getInstance().updateParamRootNode(VanChartMapSourceChoosePane.this.getParams());
if(selectTreePath != null){ if(selectTreePath != null){
mapDataTree.setSelectNodePath(GEOJSONHelper.completeJSONName(selectTreePath.getLastPathComponent().toString())); mapDataTree.setSelectNodePath(CompatibleGEOJSONHelper.completeJSONName(selectTreePath.getLastPathComponent().toString()));
selectTreePath = mapDataTree.getSelectionPath(); selectTreePath = mapDataTree.getSelectionPath();
} }

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

@ -1,7 +1,7 @@
package com.fr.design.designer.creator; package com.fr.design.designer.creator;
import com.fr.form.ui.ErrorMarker;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.WidgetErrorMarker;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import java.awt.*; import java.awt.*;
@ -18,7 +18,7 @@ public class ErrorCreator extends NullCreator {
@Override @Override
protected String showText() { protected String showText() {
ErrorMarker marker = (ErrorMarker)toData(); WidgetErrorMarker marker = (WidgetErrorMarker)toData();
String text = marker.getWidgetValue().getDisplayValue(); String text = marker.getWidgetValue().getDisplayValue();
if (StringUtils.isEmpty(text)) { if (StringUtils.isEmpty(text)) {
return super.showText(); return super.showText();

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

@ -26,7 +26,6 @@ import com.fr.form.ui.ComboCheckBox;
import com.fr.form.ui.DateEditor; import com.fr.form.ui.DateEditor;
import com.fr.form.ui.EditorHolder; import com.fr.form.ui.EditorHolder;
import com.fr.form.ui.ElementCaseEditor; import com.fr.form.ui.ElementCaseEditor;
import com.fr.form.ui.ErrorMarker;
import com.fr.form.ui.FileEditor; import com.fr.form.ui.FileEditor;
import com.fr.form.ui.FreeButton; import com.fr.form.ui.FreeButton;
import com.fr.form.ui.IframeEditor; import com.fr.form.ui.IframeEditor;
@ -42,6 +41,7 @@ import com.fr.form.ui.TextEditor;
import com.fr.form.ui.TreeComboBoxEditor; import com.fr.form.ui.TreeComboBoxEditor;
import com.fr.form.ui.TreeEditor; import com.fr.form.ui.TreeEditor;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.WidgetErrorMarker;
import com.fr.form.ui.container.WAbsoluteBodyLayout; import com.fr.form.ui.container.WAbsoluteBodyLayout;
import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WBorderLayout;
@ -160,7 +160,7 @@ public class XCreatorUtils {
objectMap.put(NameWidget.class, XNameWidget.class); objectMap.put(NameWidget.class, XNameWidget.class);
objectMap.put(CardSwitchButton.class, XCardSwitchButton.class); objectMap.put(CardSwitchButton.class, XCardSwitchButton.class);
objectMap.put(CardAddButton.class, XCardAddButton.class); objectMap.put(CardAddButton.class, XCardAddButton.class);
objectMap.put(ErrorMarker.class, ErrorCreator.class); objectMap.put(WidgetErrorMarker.class, ErrorCreator.class);
} }
private static void reInitExtra() { private static void reInitExtra() {

29
designer-form/src/test/java/com/fr/form/ui/WidgetNameCopyTest.java

@ -0,0 +1,29 @@
package com.fr.form.ui;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.mainframe.FormSelectionUtils;
import com.fr.form.main.Form;
import com.fr.general.ComparatorUtils;
import junit.framework.TestCase;
import java.awt.Dimension;
/**
* @author kerry
* @date 2018/7/27
*/
public class WidgetNameCopyTest extends TestCase {
public void testWidgetNameCopy() throws Exception {
Widget button = new FreeButton();
Form form = new Form();
button.setWidgetName("button0");
XCreator xCreator = XCreatorUtils.createXCreator(button, new Dimension(100, 100));
XCreator copyXcreator1 = FormSelectionUtils.copyXcreator(form, xCreator);
XCreator copyXcreator2 = FormSelectionUtils.copyXcreator(form, xCreator);
copyXcreator1.toData().setWidgetName("button_test");
assertTrue(!ComparatorUtils.equals(copyXcreator2.toData().getWidgetName(), copyXcreator1.toData().getWidgetName()));
}
}

82
designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java

@ -3,15 +3,16 @@ package com.fr.design.mainframe.errorinfo;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.mainframe.SiteCenterToken; import com.fr.design.mainframe.SiteCenterToken;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import com.fr.general.ComparatorUtils; import com.fr.general.CommonIOUtils;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpResponseType;
import com.fr.json.JSONException; import com.fr.general.http.HttpToolbox;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.license.function.VT4FR; import com.fr.license.function.VT4FR;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.log.LogHandler; import com.fr.log.LogHandler;
import com.fr.stable.ArrayUtils;
import com.fr.stable.EnvChangedListener; import com.fr.stable.EnvChangedListener;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
@ -93,9 +94,7 @@ public class ErrorInfoUploader {
try { try {
String downloadURL = CloudCenter.getInstance().acquireUrlByKind("solution.download", "http://cloud.fanruan.com/api/solution"); String downloadURL = CloudCenter.getInstance().acquireUrlByKind("solution.download", "http://cloud.fanruan.com/api/solution");
downloadURL = String.format("%s?token=%s", downloadURL, SiteCenterToken.generateToken()); downloadURL = String.format("%s?token=%s", downloadURL, SiteCenterToken.generateToken());
HttpClient hc = new HttpClient(downloadURL); InputStream in = HttpToolbox.post(downloadURL, new HashMap<String, Object>(), HttpResponseType.STREAM);
hc.asGet();
InputStream in = hc.getResponseStream();
StableUtils.makesureFileExist(localCacheZip); StableUtils.makesureFileExist(localCacheZip);
FileOutputStream out = new FileOutputStream(localCacheZip); FileOutputStream out = new FileOutputStream(localCacheZip);
IOUtils.copyBinaryTo(in, out); IOUtils.copyBinaryTo(in, out);
@ -114,15 +113,11 @@ public class ErrorInfoUploader {
// 判断本地文件大小. // 判断本地文件大小.
String checkURL = CloudCenter.getInstance().acquireUrlByKind("solution.check", "http://cloud.fanruan.com/api/solution/cache/check"); String checkURL = CloudCenter.getInstance().acquireUrlByKind("solution.check", "http://cloud.fanruan.com/api/solution/cache/check");
checkURL = String.format("%s?token=%s", checkURL, SiteCenterToken.generateToken()); checkURL = String.format("%s?token=%s", checkURL, SiteCenterToken.generateToken());
HttpClient client = new HttpClient(checkURL); try {
client.asGet(); JSONObject res = new JSONObject(HttpToolbox.get(checkURL));
if (client.isServerAlive()) { // 简单粗暴, 直接判断文件大小.
try { return res.optLong("version") != localCacheZip.length();
JSONObject res = new JSONObject(client.getResponseText()); } catch (Exception ignore) {
// 简单粗暴, 直接判断文件大小.
return res.optLong("version") != localCacheZip.length();
} catch (JSONException ignore) {
}
} }
return false; return false;
} }
@ -140,27 +135,29 @@ public class ErrorInfoUploader {
} }
File[] files = folder.listFiles(); File[] files = folder.listFiles();
if (files.length > MAX_ERROR_SIZE) { if (ArrayUtils.getLength(files) > MAX_ERROR_SIZE) {
StableUtils.deleteFile(folder); CommonIOUtils.deleteFile(folder);
return; return;
} }
try { try {
for (File file : files) { if (ArrayUtils.isNotEmpty(files)) {
String filePath = file.getPath(); for (File file : files) {
String suffix = filePath.substring(filePath.lastIndexOf(".")); String filePath = file.getPath();
String suffix = filePath.substring(filePath.lastIndexOf("."));
if (suffix.endsWith(SUFFIX)) {
Thread.sleep(1000L); if (suffix.endsWith(SUFFIX)) {
String content = IOUtils.inputStream2String(new FileInputStream(file)); Thread.sleep(1000L);
if (content.length() > MAX_ERROR_SIZE) { String content = IOUtils.inputStream2String(new FileInputStream(file));
file.delete(); if (content.length() > MAX_ERROR_SIZE) {
continue; CommonIOUtils.deleteFile(file);
} continue;
}
String url = CloudCenter.getInstance().acquireUrlByKind("design.error");
if (sendErroInfo(url, content)) { String url = CloudCenter.getInstance().acquireUrlByKind("design.error");
file.delete(); if (sendErrorInfo(url, content)) {
CommonIOUtils.deleteFile(file);
}
} }
} }
} }
@ -169,25 +166,18 @@ public class ErrorInfoUploader {
} }
} }
private boolean sendErroInfo(String url, String content) { private boolean sendErrorInfo(String url, String content) {
HashMap<String, String> para = new HashMap<>(); HashMap<String, Object> para = new HashMap<>();
para.put("token", SiteCenterToken.generateToken()); para.put("token", SiteCenterToken.generateToken());
para.put("content", content); para.put("content", content);
HttpClient httpClient = new HttpClient(url, para, true);
httpClient.asGet();
if (!httpClient.isServerAlive()) {
return false;
}
String res = httpClient.getResponseText();
boolean success;
try { try {
success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success"); String responseText = HttpToolbox.post(url, para);
} catch (Exception ex) { return "success".equals(new JSONObject(responseText).get("status"));
success = true; } catch (Exception ignore) {
} }
return success; return false;
} }

46
designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java

@ -1,6 +1,7 @@
package com.fr.start.module; package com.fr.start.module;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.event.Event; import com.fr.event.Event;
import com.fr.event.Listener; import com.fr.event.Listener;
@ -77,32 +78,51 @@ public class DesignerStartup extends Activator {
} }
/** /**
* 切换环境时重新启动所有相关模块 * 注册切换环境前后事件监听
*/ */
private void registerEnvListener() { private void registerEnvListener() {
/*切换环境前,关闭所有相关模块*/
listenEvent(WorkspaceEvent.BeforeSwitch, new Listener<Workspace>() { listenEvent(WorkspaceEvent.BeforeSwitch, new Listener<Workspace>() {
@Override @Override
public void on(Event event, Workspace param) { public void on(Event event, Workspace current) {
getSub(EnvBasedModule.class).stop(); getSub(EnvBasedModule.class).stop();
} }
}); });
/*切换环境后,重新启动所有相关模块*/
listenEvent(WorkspaceEvent.AfterSwitch, new Listener<Workspace>(Integer.MAX_VALUE) { listenEvent(WorkspaceEvent.AfterSwitch, new Listener<Workspace>(Integer.MAX_VALUE) {
@Override @Override
public void on(Event event, Workspace param) { public void on(Event event, Workspace current) {
getSub(EnvBasedModule.class).start(); getSub(EnvBasedModule.class).start();
ExecutorService service = Executors.newSingleThreadExecutor(); // 切换后的环境是本地环境才启动内置服务器
service.submit(new Runnable() { if (current.isLocal()) {
@Override ExecutorService service = Executors.newSingleThreadExecutor();
public void run() { service.submit(new Runnable() {
FineEmbedServer.start(); @Override
} public void run() {
}); FineEmbedServer.start();
service.shutdown(); }
});
service.shutdown();
}
}
});
/*切换环境前,存储一下打开的所有文件对象,优先级高于默认优先级,要先于 关闭相关模块部分 被触发*/
listenEvent(WorkspaceEvent.BeforeSwitch, new Listener<Workspace>(Integer.MAX_VALUE) {
@Override
public void on(Event event, Workspace workspace) {
HistoryTemplateListCache.getInstance().stash();
}
});
/*切换环境后,装载一下打开的所有文件对象,优先级低于默认优先级,要后于 启动相关模块部分 被触发*/
listenEvent(WorkspaceEvent.AfterSwitch, new Listener<Workspace>(Integer.MIN_VALUE) {
@Override
public void on(Event event, Workspace workspace) {
HistoryTemplateListCache.getInstance().load();
} }
}); });
} }

Loading…
Cancel
Save