Browse Source

Merge branch 'release/10.0' of http://cloud.finedevelop.com:2015/scm/~alex.sung/design into release/10.0

bugfix/10.0
alex.sung 6 years ago
parent
commit
855acfa587
  1. 65
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  2. 3
      designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java
  3. 82
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  4. 43
      designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java
  5. 18
      designer-base/src/main/java/com/fr/design/formula/FunctionConstants.java
  6. 5
      designer-base/src/main/java/com/fr/design/gui/itextfield/UIAutoCompletionField.java
  7. 53
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  8. 24
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  9. 13
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  10. 5
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogMessageBar.java
  11. 30
      designer-base/src/main/java/com/fr/env/RemoteEnvPane.java
  12. 62
      designer-base/src/main/java/com/fr/env/TestConnectionResult.java
  13. 2
      designer-base/src/main/resources/com/fr/design/insert/formula/variable/cn/servletURL.txt
  14. 2
      designer-base/src/main/resources/com/fr/design/insert/formula/variable/en/servletURL.txt
  15. 11
      designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/MapDataTree.java
  16. 10
      designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapSourceChoosePane.java
  17. 4
      designer-form/src/main/java/com/fr/design/designer/creator/ErrorCreator.java
  18. 4
      designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java
  19. 29
      designer-form/src/test/java/com/fr/form/ui/WidgetNameCopyTest.java
  20. 52
      designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java
  21. 30
      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
* *

3
designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java

@ -4,6 +4,7 @@ import com.fr.base.FRContext;
import com.fr.base.StoreProcedureParameter; import com.fr.base.StoreProcedureParameter;
import com.fr.base.TableData; import com.fr.base.TableData;
import com.fr.data.TableDataSource; import com.fr.data.TableDataSource;
import com.fr.data.TableDataSourceTailor;
import com.fr.data.core.DataCoreXmlUtils; import com.fr.data.core.DataCoreXmlUtils;
import com.fr.data.impl.EmbeddedTableData; import com.fr.data.impl.EmbeddedTableData;
import com.fr.data.impl.storeproc.ProcedureDataModel; import com.fr.data.impl.storeproc.ProcedureDataModel;
@ -444,7 +445,7 @@ public abstract class DesignTableDataManager {
parameter.setValue(parameterMap.get(parameter.getName())); parameter.setValue(parameterMap.get(parameter.getName()));
} }
} }
return DataOperator.getInstance().previewTableData(tableDataSource, tabledata, parameterMap, rowCount); return DataOperator.getInstance().previewTableData(TableDataSourceTailor.extractTableData(tableDataSource), tabledata, parameterMap, rowCount);
} catch (Exception e) { } catch (Exception e) {
throw new TableDataException(e.getMessage(), e); throw new TableDataException(e.getMessage(), e);
} finally { } finally {

82
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;
/** /**
* 历史模板缓存 * 历史模板缓存
@ -188,10 +194,13 @@ public class HistoryTemplateListCache implements CallbackEvent {
/** /**
* 判断是否打开过该模板 * 判断是否打开过该模板
* 由于切换环境不会关闭模板可能存在同名的模板所以该方法不能准确找到所选的模板
* *
* @param filename 文件名 * @param filename 文件名
* @return 文件位置 * @return 文件位置
* @deprecated use HistoryTemplateListCache#contains(com.fr.design.mainframe.JTemplate) instead
*/ */
@Deprecated
public int contains(String filename) { public int contains(String filename) {
for (int i = 0; i < historyList.size(); i++) { for (int i = 0; i < historyList.size(); i++) {
String historyPath = historyList.get(i).getPath(); String historyPath = historyList.get(i).getPath();
@ -302,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.");
}
} }

43
designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java

@ -18,7 +18,6 @@ import com.fr.log.FineLoggerFactory;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.third.javax.annotation.Nonnull; import com.fr.third.javax.annotation.Nonnull;
import com.fr.third.org.apache.commons.io.FilenameUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.server.lock.TplOperator; import com.fr.workspace.server.lock.TplOperator;
@ -674,9 +673,6 @@ public class MutilTempalteTabPane extends JComponent {
return; return;
} }
//当前激活的模板
String filename = openedTemplate.get(selectedIndex).getPath();
filename = FilenameUtils.standard(filename);
if (!specifiedTemplate.isALLSaved() && !DesignerMode.isVcsMode()) { if (!specifiedTemplate.isALLSaved() && !DesignerMode.isVcsMode()) {
specifiedTemplate.stopEditing(); specifiedTemplate.stopEditing();
int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?", int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?",
@ -684,20 +680,20 @@ public class MutilTempalteTabPane extends JComponent {
if (returnVal == JOptionPane.YES_OPTION) { if (returnVal == JOptionPane.YES_OPTION) {
specifiedTemplate.saveTemplate(); specifiedTemplate.saveTemplate();
FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName()));
closeTpl(specifiedTemplate, filename); closeTpl(specifiedTemplate);
} else if (returnVal == JOptionPane.NO_OPTION) { } else if (returnVal == JOptionPane.NO_OPTION) {
closeTpl(specifiedTemplate, filename); closeTpl(specifiedTemplate);
} }
} else { } else {
closeTpl(specifiedTemplate, filename); closeTpl(specifiedTemplate);
} }
} }
private void closeTpl(@Nonnull JTemplate<?, ?> specifiedTemplate, @Nonnull String fileName) { private void closeTpl(@Nonnull JTemplate<?, ?> specifiedTemplate) {
HistoryTemplateListCache.getInstance().closeSelectedReport(specifiedTemplate); HistoryTemplateListCache.getInstance().closeSelectedReport(specifiedTemplate);
closeAndFreeLock(specifiedTemplate); closeAndFreeLock(specifiedTemplate);
activeTemplate(fileName); activePrevTemplateAfterClose();
} }
private void closeAndFreeLock(@Nonnull JTemplate<?, ?> template) { private void closeAndFreeLock(@Nonnull JTemplate<?, ?> template) {
@ -729,11 +725,9 @@ public class MutilTempalteTabPane extends JComponent {
} }
/** /**
* 关闭掉一个模板之后该激活的Tab * 关闭掉一个模板之后激活新的待显示模板
*
* @param fileName 关闭掉一个模板之后该激活的Tab的文件名绝对路径
*/ */
private void activeTemplate(String fileName) { private void activePrevTemplateAfterClose() {
if (openedTemplate.isEmpty()) { if (openedTemplate.isEmpty()) {
//新建并激活模板 //新建并激活模板
DesignerContext.getDesignerFrame().addAndActivateJTemplate(); DesignerContext.getDesignerFrame().addAndActivateJTemplate();
@ -742,23 +736,20 @@ public class MutilTempalteTabPane extends JComponent {
temTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); temTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
} else { } else {
//如果关闭的模板是当前选中的模板,则重新激活 // 如果关闭的模板是当前选中的模板,则重新激活当前 selectIndex 的模板;
if (closeIconIndex == selectedIndex) { // selectIndex 没有变化,但是对应的模板已经变成了前一张模板
if (closeIconIndex == maxPaintIndex) { if (closeIconIndex == selectedIndex || isCloseCurrent) {
// 如果 closeIconIndex 是最后一个被渲染画出的,那么预览上一个,防止数组越界
if (closeIconIndex >= maxPaintIndex) {
// selectIndex 不会 <0 因为如果关闭的是打开的最后一个模板,那么关闭之后 openedTemplate.isEmpty() = true
selectedIndex--; selectedIndex--;
} }
} else if (isCloseCurrent) {
//不是通过关闭按钮,而是通过文件关闭菜单关闭的当前模板的,也重新激活
if (selectedIndex > openedTemplate.size() - 1) {
selectedIndex -= 1;
if (selectedIndex < 0) {
selectedIndex = 0;
}
isCloseCurrent = false; isCloseCurrent = false;
} }
} else { // 如果关闭的模板不是当前选中的模板,那么重新获取一下当前模板的 index,激活该 index
//如果关闭的模板不是当前选中的模板,则激活的模板不变 else {
selectedIndex = HistoryTemplateListCache.getInstance().contains(fileName); JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
selectedIndex = HistoryTemplateListCache.getInstance().contains(template);
} }
//如果是已后台关闭的模板,则重新打开文件 //如果是已后台关闭的模板,则重新打开文件
openedTemplate.get(selectedIndex).activeOldJTemplate(); openedTemplate.get(selectedIndex).activeOldJTemplate();

18
designer-base/src/main/java/com/fr/design/formula/FunctionConstants.java

@ -12,7 +12,6 @@ import com.fr.function.RANGE;
import com.fr.function.SUM; import com.fr.function.SUM;
import com.fr.function.TIME; import com.fr.function.TIME;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.plugin.ExtraClassManager; import com.fr.plugin.ExtraClassManager;
@ -25,23 +24,28 @@ import com.fr.stable.fun.mark.Mutable;
import com.fr.stable.script.Function; import com.fr.stable.script.Function;
import com.fr.stable.script.FunctionDef; import com.fr.stable.script.FunctionDef;
import javax.swing.DefaultListModel;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URL; import java.net.URL;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.util.*; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Enumeration;
import java.util.List;
import java.util.Set;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
import javax.swing.DefaultListModel;
public final class FunctionConstants { public final class FunctionConstants {
public static FunctionGroup PLUGIN = getPluginFunctionGroup(); public static FunctionGroup PLUGIN = getPluginFunctionGroup();
public static FunctionGroup CUSTOM = getCustomFunctionGroup(); public static FunctionGroup CUSTOM = getCustomFunctionGroup();
static NameAndFunctionList COMMON = getCommonFunctionList(); public static NameAndFunctionList COMMON = getCommonFunctionList();
static NameAndTypeAndFunctionList[] EMBFUNCTIONS = getEmbededFunctionListArray(); public static NameAndTypeAndFunctionList[] EMBFUNCTIONS = getEmbededFunctionListArray();
public static FunctionGroup ALL = getAllFunctionGroup(); public static FunctionGroup ALL = getAllFunctionGroup();
static { static {
@ -117,7 +121,7 @@ public final class FunctionConstants {
* 将函数分组插件中的函数添加到对应的列表中 * 将函数分组插件中的函数添加到对应的列表中
* @param listModel * @param listModel
*/ */
static void addFunctionGroupFromPlugins(DefaultListModel listModel){ public static void addFunctionGroupFromPlugins(DefaultListModel listModel){
//hugh:自定义函数分组 //hugh:自定义函数分组
Set<Mutable> containers = ExtraClassManager.getInstance().getArray(FunctionDefContainer.MARK_STRING); Set<Mutable> containers = ExtraClassManager.getInstance().getArray(FunctionDefContainer.MARK_STRING);
if(!containers.isEmpty()){ if(!containers.isEmpty()){

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();

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

@ -31,13 +31,13 @@ import com.fr.design.gui.imenu.UIMenuHighLight;
import com.fr.design.gui.iprogressbar.ProgressDialog; import com.fr.design.gui.iprogressbar.ProgressDialog;
import com.fr.design.gui.iscrollbar.UIScrollBar; import com.fr.design.gui.iscrollbar.UIScrollBar;
import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.loghandler.LogMessageBar; import com.fr.design.mainframe.loghandler.LogMessageBar;
import com.fr.design.mainframe.toolbar.ToolBarMenuDock; import com.fr.design.mainframe.toolbar.ToolBarMenuDock;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.menu.MenuManager; import com.fr.design.menu.MenuManager;
import com.fr.design.menu.ShortCut; import com.fr.design.menu.ShortCut;
import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.exception.DecryptTemplateException; import com.fr.exception.DecryptTemplateException;
import com.fr.file.FILE; import com.fr.file.FILE;
@ -68,6 +68,7 @@ import javax.swing.JLayeredPane;
import javax.swing.JMenuBar; import javax.swing.JMenuBar;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager; import javax.swing.UIManager;
import javax.swing.WindowConstants; import javax.swing.WindowConstants;
import javax.swing.border.MatteBorder; import javax.swing.border.MatteBorder;
@ -78,7 +79,6 @@ import java.awt.Graphics;
import java.awt.Insets; import java.awt.Insets;
import java.awt.Point; import java.awt.Point;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable; import java.awt.datatransfer.Transferable;
import java.awt.dnd.DnDConstants; import java.awt.dnd.DnDConstants;
@ -162,9 +162,9 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
//用于判断设计器是否打开了 //用于判断设计器是否打开了
private boolean designerOpened = false; private boolean designerOpened = false;
private int contentWidth = (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth()); private int contentWidth = (int) (java.awt.Toolkit.getDefaultToolkit().getScreenSize().getWidth());
private int contentHeight = (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight()); private int contentHeight = (int) (java.awt.Toolkit.getDefaultToolkit().getScreenSize().getHeight());
private WindowAdapter windowAdapter = new WindowAdapter() { private WindowAdapter windowAdapter = new WindowAdapter() {
@ -413,7 +413,16 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
public void on(PluginEvent event) { public void on(PluginEvent event) {
refreshNorthEastPane(northEastPane, ad); refreshNorthEastPane(northEastPane, ad);
DesignUtils.refreshDesignerFrame(); SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (DesignerContext.getDesignerFrame() == null) {
return;
}
DesignerContext.getDesignerFrame().refresh();
DesignerContext.getDesignerFrame().repaint();
}
});
} }
}, new PluginFilter() { }, new PluginFilter() {
@ -815,14 +824,19 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* 报表运行环境改变时,需要刷新某些面板 * 报表运行环境改变时,需要刷新某些面板
*/ */
public void refreshEnv() { public void refreshEnv() {
refresh();
DesignerFrameFileDealerPane.getInstance().refreshDockingView();
TemplateTreePane.getInstance().refreshDockingView();
}
/**
* 安装设计器相关插件时的刷新
*/
public void refresh() {
this.setTitle(); this.setTitle();
DesignerFrameFileDealerPane.getInstance().refreshDockingView();
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()); TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter());
TemplateTreePane.getInstance().refreshDockingView();
DesignTableDataManager.clearGlobalDs(); DesignTableDataManager.clearGlobalDs();
EastRegionContainerPane.getInstance().refreshDownPane(); EastRegionContainerPane.getInstance().refreshDownPane();
JTemplate template = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); JTemplate template = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (template != null) { if (template != null) {
template.refreshToolArea(); template.refreshToolArea();
@ -855,18 +869,18 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
editingTemplate.stopEditing(); editingTemplate.stopEditing();
if (!editingTemplate.getEditingFILE().exists()) { if (!editingTemplate.getEditingFILE().exists()) {
int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + editingTemplate.getEditingFILE() Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + editingTemplate.getEditingFILE()
+ "\" ?", ProductConstants.PRODUCT_NAME, JOptionPane.YES_NO_OPTION, + "\" ?", ProductConstants.PRODUCT_NAME, JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE); JOptionPane.QUESTION_MESSAGE);
if (returnVal == JOptionPane.YES_OPTION && editingTemplate.saveTemplate()) { if (returnVal == JOptionPane.YES_OPTION && editingTemplate.saveTemplate()) {
editingTemplate.saveTemplate(); editingTemplate.saveTemplate();
FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved",
editingTemplate.getEditingFILE().getName())); editingTemplate.getEditingFILE().getName()));
} }
} else { } else {
if (editingTemplate.saveTemplate()) { if (editingTemplate.saveTemplate()) {
editingTemplate.saveTemplate(); editingTemplate.saveTemplate();
FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved",
editingTemplate.getEditingFILE().getName())); editingTemplate.getEditingFILE().getName()));
} }
} }
@ -963,8 +977,12 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
// p:判断一下,如何文件为空或者文件不存在,直接返回. // p:判断一下,如何文件为空或者文件不存在,直接返回.
if (tplFile == null || !tplFile.exists()) { if (tplFile == null || !tplFile.exists()) {
JOptionPane.showMessageDialog(this, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Warning_Template_Do_Not_Exsit"), JOptionPane.showMessageDialog(
ProductConstants.PRODUCT_NAME, JOptionPane.INFORMATION_MESSAGE); this,
Toolkit.i18nText("Fine-Design_Basic_Warning_Template_Do_Not_Exsit"),
ProductConstants.PRODUCT_NAME,
JOptionPane.INFORMATION_MESSAGE
);
DesignerFrameFileDealerPane.getInstance().refresh(); DesignerFrameFileDealerPane.getInstance().refresh();
return; return;
} }
@ -974,7 +992,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} catch (DecryptTemplateException e) { } catch (DecryptTemplateException e) {
JOptionPane.showMessageDialog( JOptionPane.showMessageDialog(
this, this,
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Encrypt_Decrypt_Exception"), Toolkit.i18nText("Fine-Design_Encrypt_Decrypt_Exception"),
UIManager.getString("OptionPane.messageDialogTitle"), UIManager.getString("OptionPane.messageDialogTitle"),
JOptionPane.WARNING_MESSAGE, JOptionPane.WARNING_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon") UIManager.getIcon("OptionPane.errorIcon")
@ -1033,7 +1051,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
MutilTempalteTabPane.getInstance().setTemTemplate( MutilTempalteTabPane.getInstance().setTemTemplate(
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); HistoryTemplateListPane.getInstance().getCurrentEditingTemplate());
} else { } else {
activeTemplate(tplFile, jt); activeTemplate(jt);
} }
opened = true; opened = true;
break; break;
@ -1048,13 +1066,12 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
/** /**
* 激活指定的模板 * 激活指定的模板
* *
* @param tplFile 模板文件
* @param jt 当前报表 * @param jt 当前报表
* @date 2014-10-14-下午6:31:23 * @date 2014-10-14-下午6:31:23
*/ */
private void activeTemplate(FILE tplFile, JTemplate jt) { private void activeTemplate(JTemplate jt) {
// 如果该模板已经打开,则进行激活就可以了 // 如果该模板已经打开,则进行激活就可以了
int index = HistoryTemplateListPane.getInstance().contains(tplFile.getPath()); int index = HistoryTemplateListPane.getInstance().contains(jt);
List<JTemplate<?, ?>> historyList = HistoryTemplateListPane.getInstance().getHistoryList(); List<JTemplate<?, ?>> historyList = HistoryTemplateListPane.getInstance().getHistoryList();
if (index != -1) { if (index != -1) {
historyList.get(index).activeJTemplate(index, jt); historyList.get(index).activeJTemplate(index, jt);

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

@ -30,11 +30,18 @@ import com.fr.design.menu.KeySetUtils;
import com.fr.design.menu.ShortCut; import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef; import com.fr.design.menu.ToolBarDef;
import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.roleAuthority.RolesAlreadyEditedPane;
import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.file.FileNodeFILE; import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.injectable.PluginModule;
import com.fr.plugin.manage.PluginFilter;
import com.fr.plugin.observer.PluginEvent;
import com.fr.plugin.observer.PluginEventListener;
import com.fr.stable.CoreConstants; 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;
@ -68,6 +75,22 @@ import static javax.swing.JOptionPane.WARNING_MESSAGE;
public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarStateChangeListener, ResponseDataSourceChange { public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarStateChangeListener, ResponseDataSourceChange {
static {
GeneralContext.listenPluginRunningChanged(new PluginEventListener() {
@Override
public void on(PluginEvent event) {
DesignUtils.refreshDesignerFrame();
}
}, new PluginFilter() {
@Override
public boolean accept(PluginContext context) {
return context.contain(PluginModule.ExtraDesign, ShortCut.TEMPLATE_TREE);
}
});
}
private static final String FILE = "file"; private static final String FILE = "file";
private static volatile DesignerFrameFileDealerPane THIS; private static volatile DesignerFrameFileDealerPane THIS;
@ -163,7 +186,6 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
* 刷新菜单 * 刷新菜单
*/ */
public void refreshDockingView() { public void refreshDockingView() {
ToolBarDef toolbarDef = new ToolBarDef(); ToolBarDef toolbarDef = new ToolBarDef();
toolbarDef.addShortCut(newFolderAction, refreshTreeAction); toolbarDef.addShortCut(newFolderAction, refreshTreeAction);
if (WorkContext.getCurrent().isLocal()) { if (WorkContext.getCurrent().isLocal()) {

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()) {

5
designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogMessageBar.java

@ -69,8 +69,11 @@ public class LogMessageBar extends JPanel {
return new Dimension(width, 24); return new Dimension(width, 24);
} }
/**
* 销毁内置的日志面板,外部插件会用到
*/
public void disposeLogDialog() { public void disposeLogDialog() {
if (dlg != null) { if (dlg != null && dlg.isShowing()) {
dlg.dispose(); dlg.dispose();
} }
THIS = null; THIS = null;

30
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);
message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed")); if (result == TestConnectionResult.Fully_Success) {
uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon"));
} else {
if (result) {
message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Successful")); message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Successful"));
uiLabel.setIcon(UIManager.getIcon("OptionPane.informationIcon")); uiLabel.setIcon(UIManager.getIcon("OptionPane.informationIcon"));
} else { }
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")); message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Failed"));
uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon")); uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon"));
} }
if (result == TestConnectionResult.Auth_Failed) {
message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_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());
@ -589,7 +597,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
dialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(RemoteEnvPane.this), UIManager.getString("OptionPane.messageDialogTitle"), true); dialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(RemoteEnvPane.this), UIManager.getString("OptionPane.messageDialogTitle"), true);
dialog.setSize(new Dimension(268, 118)); dialog.setSize(new Dimension(308, 132));
okButton.setEnabled(false); okButton.setEnabled(false);
JPanel jp = new JPanel(); JPanel jp = new JPanel();
JPanel upPane = new JPanel(); JPanel upPane = new JPanel();

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()));
}
}

52
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);
client.asGet();
if (client.isServerAlive()) {
try { try {
JSONObject res = new JSONObject(client.getResponseText()); JSONObject res = new JSONObject(HttpToolbox.get(checkURL));
// 简单粗暴, 直接判断文件大小. // 简单粗暴, 直接判断文件大小.
return res.optLong("version") != localCacheZip.length(); return res.optLong("version") != localCacheZip.length();
} catch (JSONException ignore) { } catch (Exception ignore) {
}
} }
return false; return false;
} }
@ -140,12 +135,13 @@ 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 {
if (ArrayUtils.isNotEmpty(files)) {
for (File file : files) { for (File file : files) {
String filePath = file.getPath(); String filePath = file.getPath();
String suffix = filePath.substring(filePath.lastIndexOf(".")); String suffix = filePath.substring(filePath.lastIndexOf("."));
@ -154,13 +150,14 @@ public class ErrorInfoUploader {
Thread.sleep(1000L); Thread.sleep(1000L);
String content = IOUtils.inputStream2String(new FileInputStream(file)); String content = IOUtils.inputStream2String(new FileInputStream(file));
if (content.length() > MAX_ERROR_SIZE) { if (content.length() > MAX_ERROR_SIZE) {
file.delete(); CommonIOUtils.deleteFile(file);
continue; continue;
} }
String url = CloudCenter.getInstance().acquireUrlByKind("design.error"); String url = CloudCenter.getInstance().acquireUrlByKind("design.error");
if (sendErroInfo(url, content)) { if (sendErrorInfo(url, content)) {
file.delete(); 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;
} }

30
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,24 +78,27 @@ 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();
// 切换后的环境是本地环境才启动内置服务器
if (current.isLocal()) {
ExecutorService service = Executors.newSingleThreadExecutor(); ExecutorService service = Executors.newSingleThreadExecutor();
service.submit(new Runnable() { service.submit(new Runnable() {
@Override @Override
@ -104,6 +108,22 @@ public class DesignerStartup extends Activator {
}); });
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