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. 47
      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. 55
      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. 36
      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. 82
      designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java
  21. 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.env.DesignerWorkspaceGenerator;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.TemplateTreePane;
import com.fr.design.i18n.Toolkit;
@ -15,19 +16,25 @@ import com.fr.env.EnvListPane;
import com.fr.general.GeneralContext;
import com.fr.license.exception.RegistEditionException;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.AssistUtils;
import com.fr.stable.EnvChangedListener;
import com.fr.start.server.ServerTray;
import com.fr.workspace.WorkContext;
import com.fr.workspace.WorkContextCallback;
import com.fr.workspace.Workspace;
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.SwingUtilities;
import javax.swing.UIManager;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import static javax.swing.JOptionPane.ERROR_MESSAGE;
import static javax.swing.JOptionPane.QUESTION_MESSAGE;
public class EnvChangeEntrance {
@ -90,15 +97,21 @@ public class EnvChangeEntrance {
});
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() {
@Override
public void done() {
DesignerEnvManager.getEnvManager().setCurEnvName(envName);
DesignUtils.refreshDesignerFrame();
JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) {
template.refreshToolArea();
}
DesignTableDataManager.fireDSChanged(new HashMap<String, String>());
if (WorkContext.getCurrent().isLocal()) {
//初始化一下serverTray
@ -138,6 +151,50 @@ public class EnvChangeEntrance {
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
*

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.TableData;
import com.fr.data.TableDataSource;
import com.fr.data.TableDataSourceTailor;
import com.fr.data.core.DataCoreXmlUtils;
import com.fr.data.impl.EmbeddedTableData;
import com.fr.data.impl.storeproc.ProcedureDataModel;
@ -444,7 +445,7 @@ public abstract class DesignTableDataManager {
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) {
throw new TableDataException(e.getMessage(), e);
} finally {

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

@ -1,6 +1,8 @@
package com.fr.design.file;
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.base.mode.DesignModeContext;
import com.fr.design.data.DesignTableDataManager;
@ -18,10 +20,14 @@ import com.fr.stable.CoreConstants;
import com.fr.stable.StringUtils;
import com.fr.third.org.apache.commons.io.FilenameUtils;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
/**
* 历史模板缓存
@ -188,10 +194,13 @@ public class HistoryTemplateListCache implements CallbackEvent {
/**
* 判断是否打开过该模板
* 由于切换环境不会关闭模板可能存在同名的模板所以该方法不能准确找到所选的模板
*
* @param filename 文件名
* @return 文件位置
* @deprecated use HistoryTemplateListCache#contains(com.fr.design.mainframe.JTemplate) instead
*/
@Deprecated
public int contains(String filename) {
for (int i = 0; i < historyList.size(); i++) {
String historyPath = historyList.get(i).getPath();
@ -302,4 +311,77 @@ public class HistoryTemplateListCache implements CallbackEvent {
}
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.");
}
}

47
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.ProductConstants;
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.server.lock.TplOperator;
@ -674,9 +673,6 @@ public class MutilTempalteTabPane extends JComponent {
return;
}
//当前激活的模板
String filename = openedTemplate.get(selectedIndex).getPath();
filename = FilenameUtils.standard(filename);
if (!specifiedTemplate.isALLSaved() && !DesignerMode.isVcsMode()) {
specifiedTemplate.stopEditing();
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) {
specifiedTemplate.saveTemplate();
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) {
closeTpl(specifiedTemplate, filename);
closeTpl(specifiedTemplate);
}
} 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);
closeAndFreeLock(specifiedTemplate);
activeTemplate(fileName);
activePrevTemplateAfterClose();
}
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()) {
//新建并激活模板
DesignerContext.getDesignerFrame().addAndActivateJTemplate();
@ -742,23 +736,20 @@ public class MutilTempalteTabPane extends JComponent {
temTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
} else {
//如果关闭的模板是当前选中的模板,则重新激活
if (closeIconIndex == selectedIndex) {
if (closeIconIndex == maxPaintIndex) {
// 如果关闭的模板是当前选中的模板,则重新激活当前 selectIndex 的模板;
// selectIndex 没有变化,但是对应的模板已经变成了前一张模板
if (closeIconIndex == selectedIndex || isCloseCurrent) {
// 如果 closeIconIndex 是最后一个被渲染画出的,那么预览上一个,防止数组越界
if (closeIconIndex >= maxPaintIndex) {
// selectIndex 不会 <0 因为如果关闭的是打开的最后一个模板,那么关闭之后 openedTemplate.isEmpty() = true
selectedIndex--;
}
} else if (isCloseCurrent) {
//不是通过关闭按钮,而是通过文件关闭菜单关闭的当前模板的,也重新激活
if (selectedIndex > openedTemplate.size() - 1) {
selectedIndex -= 1;
if (selectedIndex < 0) {
selectedIndex = 0;
}
isCloseCurrent = false;
}
} else {
//如果关闭的模板不是当前选中的模板,则激活的模板不变
selectedIndex = HistoryTemplateListCache.getInstance().contains(fileName);
isCloseCurrent = false;
}
// 如果关闭的模板不是当前选中的模板,那么重新获取一下当前模板的 index,激活该 index
else {
JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
selectedIndex = HistoryTemplateListCache.getInstance().contains(template);
}
//如果是已后台关闭的模板,则重新打开文件
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.TIME;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils;
import com.fr.log.FineLoggerFactory;
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.FunctionDef;
import javax.swing.DefaultListModel;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URL;
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.ZipFile;
import javax.swing.DefaultListModel;
public final class FunctionConstants {
public static FunctionGroup PLUGIN = getPluginFunctionGroup();
public static FunctionGroup CUSTOM = getCustomFunctionGroup();
static NameAndFunctionList COMMON = getCommonFunctionList();
static NameAndTypeAndFunctionList[] EMBFUNCTIONS = getEmbededFunctionListArray();
public static NameAndFunctionList COMMON = getCommonFunctionList();
public static NameAndTypeAndFunctionList[] EMBFUNCTIONS = getEmbededFunctionListArray();
public static FunctionGroup ALL = getAllFunctionGroup();
static {
@ -117,7 +121,7 @@ public final class FunctionConstants {
* 将函数分组插件中的函数添加到对应的列表中
* @param listModel
*/
static void addFunctionGroupFromPlugins(DefaultListModel listModel){
public static void addFunctionGroupFromPlugins(DefaultListModel listModel){
//hugh:自定义函数分组
Set<Mutable> containers = ExtraClassManager.getInstance().getArray(FunctionDefContainer.MARK_STRING);
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.general.ComparatorUtils;
import com.fr.stable.OperatingSystem;
import javax.swing.JList;
import javax.swing.UIManager;
import javax.swing.event.DocumentEvent;
@ -82,6 +84,9 @@ public class UIAutoCompletionField extends UITextField implements DocumentListen
}
private void textChanged() {
if (OperatingSystem.isMacOS()) {
return;
}
if (!popup.isVisible()) {
showPopup();
requestFocus();

55
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.iscrollbar.UIScrollBar;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.loghandler.LogMessageBar;
import com.fr.design.mainframe.toolbar.ToolBarMenuDock;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.menu.MenuManager;
import com.fr.design.menu.ShortCut;
import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.exception.DecryptTemplateException;
import com.fr.file.FILE;
@ -68,6 +68,7 @@ import javax.swing.JLayeredPane;
import javax.swing.JMenuBar;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.WindowConstants;
import javax.swing.border.MatteBorder;
@ -78,7 +79,6 @@ import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.dnd.DnDConstants;
@ -162,9 +162,9 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
//用于判断设计器是否打开了
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() {
@ -413,7 +413,16 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
public void on(PluginEvent event) {
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() {
@ -815,14 +824,19 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* 报表运行环境改变时,需要刷新某些面板
*/
public void refreshEnv() {
refresh();
DesignerFrameFileDealerPane.getInstance().refreshDockingView();
TemplateTreePane.getInstance().refreshDockingView();
}
/**
* 安装设计器相关插件时的刷新
*/
public void refresh() {
this.setTitle();
DesignerFrameFileDealerPane.getInstance().refreshDockingView();
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter());
TemplateTreePane.getInstance().refreshDockingView();
DesignTableDataManager.clearGlobalDs();
EastRegionContainerPane.getInstance().refreshDownPane();
JTemplate template = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (template != null) {
template.refreshToolArea();
@ -855,18 +869,18 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
editingTemplate.stopEditing();
if (!editingTemplate.getEditingFILE().exists()) {
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,
JOptionPane.QUESTION_MESSAGE);
if (returnVal == JOptionPane.YES_OPTION && 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()));
}
} else {
if (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()));
}
}
@ -963,8 +977,12 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
// p:判断一下,如何文件为空或者文件不存在,直接返回.
if (tplFile == null || !tplFile.exists()) {
JOptionPane.showMessageDialog(this, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Warning_Template_Do_Not_Exsit"),
ProductConstants.PRODUCT_NAME, JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(
this,
Toolkit.i18nText("Fine-Design_Basic_Warning_Template_Do_Not_Exsit"),
ProductConstants.PRODUCT_NAME,
JOptionPane.INFORMATION_MESSAGE
);
DesignerFrameFileDealerPane.getInstance().refresh();
return;
}
@ -974,7 +992,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} catch (DecryptTemplateException e) {
JOptionPane.showMessageDialog(
this,
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Encrypt_Decrypt_Exception"),
Toolkit.i18nText("Fine-Design_Encrypt_Decrypt_Exception"),
UIManager.getString("OptionPane.messageDialogTitle"),
JOptionPane.WARNING_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon")
@ -1033,7 +1051,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
MutilTempalteTabPane.getInstance().setTemTemplate(
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate());
} else {
activeTemplate(tplFile, jt);
activeTemplate(jt);
}
opened = true;
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
*/
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();
if (index != -1) {
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.ToolBarDef;
import com.fr.design.roleAuthority.RolesAlreadyEditedPane;
import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext;
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.StringUtils;
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 {
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 volatile DesignerFrameFileDealerPane THIS;
@ -163,7 +186,6 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
* 刷新菜单
*/
public void refreshDockingView() {
ToolBarDef toolbarDef = new ToolBarDef();
toolbarDef.addShortCut(newFolderAction, refreshTreeAction);
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) {
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
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);
}
/**
* 销毁内置的日志面板,外部插件会用到
*/
public void disposeLogDialog() {
if (dlg != null) {
if (dlg != null && dlg.isShowing()) {
dlg.dispose();
}
THIS = null;

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

@ -511,14 +511,14 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
}
private void tryConnectRemoteEnv() {
final RemoteDesignerWorkspaceInfo remoteEnv = updateBean();
final WorkspaceConnectionInfo connection = remoteEnv.getConnection();
final SwingWorker<Boolean, Void> worker = new SwingWorker<Boolean, Void>() {
@Override
protected Boolean doInBackground() throws Exception {
final RemoteDesignerWorkspaceInfo remoteEnv = updateBean();
WorkspaceConnectionInfo connection = remoteEnv.getConnection();
DesignerEnvManager.getEnvManager().setCertificatePath(connection.getCertPath());
DesignerEnvManager.getEnvManager().setCertificatePass(connection.getCertSecretKey());
try {
@ -532,18 +532,26 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
protected void done() {
okButton.setEnabled(true);
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"));
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) {
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.setSize(new Dimension(268, 118));
dialog.setSize(new Dimension(308, 132));
okButton.setEnabled(false);
JPanel jp = 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.general.ComparatorUtils;
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.GEOJSONHelper;
import com.fr.geojson.helper.GEOJSONHelper;
import com.fr.stable.StringUtils;
import javax.swing.JTree;
@ -78,7 +79,7 @@ public class MapDataTree extends JTree {
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;
}
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)){
selectTreeNode(el, m_model);
return el;
@ -133,7 +134,7 @@ public class MapDataTree extends JTree {
if(treeNode == null || treeNode.getUserObject() == null){
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();
String path = el.getUserObject().toString();
String fileName = GEOJSONHelper.getPresentNameWithPath(path);
String fileName = ChartGEOJSONHelper.getPresentNameWithPath(path);
if (GEOJSONHelper.getInstance().isValidDirPath(path) && StringUtils.contains(fileName, text)) {
selectTreeNode(el, m_model);
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.mainframe.JTemplate;
import com.fr.general.ComparatorUtils;
import com.fr.general.http.HttpClient;
import com.fr.plugin.chart.base.GisLayer;
import com.fr.plugin.chart.base.ViewCenter;
import com.fr.plugin.chart.map.VanChartMapPlot;
import com.fr.plugin.chart.map.designer.type.GEOJSONTreeHelper;
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.GEOJSONHelper;
import com.fr.geojson.helper.GEOJSONHelper;
import com.fr.plugin.chart.map.server.MapLayerConfigManager;
import com.fr.plugin.chart.service.WMSFactory;
import com.fr.plugin.chart.type.GISLayerType;
@ -201,7 +201,7 @@ public class VanChartMapSourceChoosePane extends JPanel implements UIObserver {
} else if(o instanceof String){//list里面没有
selectTreePath = 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) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
//不显示后缀
return GEOJSONHelper.getPresentNameWithPath(node.toString());
return ChartGEOJSONHelper.getPresentNameWithPath(node.toString());
}
@Override
@ -533,7 +533,7 @@ public class VanChartMapSourceChoosePane extends JPanel implements UIObserver {
GEOJSONTreeHelper.getInstance().updateParamRootNode(VanChartMapSourceChoosePane.this.getParams());
if(selectTreePath != null){
mapDataTree.setSelectNodePath(GEOJSONHelper.completeJSONName(selectTreePath.getLastPathComponent().toString()));
mapDataTree.setSelectNodePath(CompatibleGEOJSONHelper.completeJSONName(selectTreePath.getLastPathComponent().toString()));
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;
import com.fr.form.ui.ErrorMarker;
import com.fr.form.ui.Widget;
import com.fr.form.ui.WidgetErrorMarker;
import com.fr.stable.StringUtils;
import java.awt.*;
@ -18,7 +18,7 @@ public class ErrorCreator extends NullCreator {
@Override
protected String showText() {
ErrorMarker marker = (ErrorMarker)toData();
WidgetErrorMarker marker = (WidgetErrorMarker)toData();
String text = marker.getWidgetValue().getDisplayValue();
if (StringUtils.isEmpty(text)) {
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.EditorHolder;
import com.fr.form.ui.ElementCaseEditor;
import com.fr.form.ui.ErrorMarker;
import com.fr.form.ui.FileEditor;
import com.fr.form.ui.FreeButton;
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.TreeEditor;
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.WAbsoluteLayout;
import com.fr.form.ui.container.WBorderLayout;
@ -160,7 +160,7 @@ public class XCreatorUtils {
objectMap.put(NameWidget.class, XNameWidget.class);
objectMap.put(CardSwitchButton.class, XCardSwitchButton.class);
objectMap.put(CardAddButton.class, XCardAddButton.class);
objectMap.put(ErrorMarker.class, ErrorCreator.class);
objectMap.put(WidgetErrorMarker.class, ErrorCreator.class);
}
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.design.mainframe.SiteCenterToken;
import com.fr.general.CloudCenter;
import com.fr.general.ComparatorUtils;
import com.fr.general.CommonIOUtils;
import com.fr.general.GeneralContext;
import com.fr.general.IOUtils;
import com.fr.general.http.HttpClient;
import com.fr.json.JSONException;
import com.fr.general.http.HttpResponseType;
import com.fr.general.http.HttpToolbox;
import com.fr.json.JSONObject;
import com.fr.license.function.VT4FR;
import com.fr.log.FineLoggerFactory;
import com.fr.log.LogHandler;
import com.fr.stable.ArrayUtils;
import com.fr.stable.EnvChangedListener;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
@ -93,9 +94,7 @@ public class ErrorInfoUploader {
try {
String downloadURL = CloudCenter.getInstance().acquireUrlByKind("solution.download", "http://cloud.fanruan.com/api/solution");
downloadURL = String.format("%s?token=%s", downloadURL, SiteCenterToken.generateToken());
HttpClient hc = new HttpClient(downloadURL);
hc.asGet();
InputStream in = hc.getResponseStream();
InputStream in = HttpToolbox.post(downloadURL, new HashMap<String, Object>(), HttpResponseType.STREAM);
StableUtils.makesureFileExist(localCacheZip);
FileOutputStream out = new FileOutputStream(localCacheZip);
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");
checkURL = String.format("%s?token=%s", checkURL, SiteCenterToken.generateToken());
HttpClient client = new HttpClient(checkURL);
client.asGet();
if (client.isServerAlive()) {
try {
JSONObject res = new JSONObject(client.getResponseText());
// 简单粗暴, 直接判断文件大小.
return res.optLong("version") != localCacheZip.length();
} catch (JSONException ignore) {
}
try {
JSONObject res = new JSONObject(HttpToolbox.get(checkURL));
// 简单粗暴, 直接判断文件大小.
return res.optLong("version") != localCacheZip.length();
} catch (Exception ignore) {
}
return false;
}
@ -140,27 +135,29 @@ public class ErrorInfoUploader {
}
File[] files = folder.listFiles();
if (files.length > MAX_ERROR_SIZE) {
StableUtils.deleteFile(folder);
if (ArrayUtils.getLength(files) > MAX_ERROR_SIZE) {
CommonIOUtils.deleteFile(folder);
return;
}
try {
for (File file : files) {
String filePath = file.getPath();
String suffix = filePath.substring(filePath.lastIndexOf("."));
if (suffix.endsWith(SUFFIX)) {
Thread.sleep(1000L);
String content = IOUtils.inputStream2String(new FileInputStream(file));
if (content.length() > MAX_ERROR_SIZE) {
file.delete();
continue;
}
String url = CloudCenter.getInstance().acquireUrlByKind("design.error");
if (sendErroInfo(url, content)) {
file.delete();
if (ArrayUtils.isNotEmpty(files)) {
for (File file : files) {
String filePath = file.getPath();
String suffix = filePath.substring(filePath.lastIndexOf("."));
if (suffix.endsWith(SUFFIX)) {
Thread.sleep(1000L);
String content = IOUtils.inputStream2String(new FileInputStream(file));
if (content.length() > MAX_ERROR_SIZE) {
CommonIOUtils.deleteFile(file);
continue;
}
String url = CloudCenter.getInstance().acquireUrlByKind("design.error");
if (sendErrorInfo(url, content)) {
CommonIOUtils.deleteFile(file);
}
}
}
}
@ -169,25 +166,18 @@ public class ErrorInfoUploader {
}
}
private boolean sendErroInfo(String url, String content) {
HashMap<String, String> para = new HashMap<>();
private boolean sendErrorInfo(String url, String content) {
HashMap<String, Object> para = new HashMap<>();
para.put("token", SiteCenterToken.generateToken());
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 {
success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success");
} catch (Exception ex) {
success = true;
String responseText = HttpToolbox.post(url, para);
return "success".equals(new JSONObject(responseText).get("status"));
} 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;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.mainframe.DesignerContext;
import com.fr.event.Event;
import com.fr.event.Listener;
@ -77,32 +78,51 @@ public class DesignerStartup extends Activator {
}
/**
* 切换环境时重新启动所有相关模块
* 注册切换环境前后事件监听
*/
private void registerEnvListener() {
/*切换环境前,关闭所有相关模块*/
listenEvent(WorkspaceEvent.BeforeSwitch, new Listener<Workspace>() {
@Override
public void on(Event event, Workspace param) {
public void on(Event event, Workspace current) {
getSub(EnvBasedModule.class).stop();
}
});
/*切换环境后,重新启动所有相关模块*/
listenEvent(WorkspaceEvent.AfterSwitch, new Listener<Workspace>(Integer.MAX_VALUE) {
@Override
public void on(Event event, Workspace param) {
public void on(Event event, Workspace current) {
getSub(EnvBasedModule.class).start();
ExecutorService service = Executors.newSingleThreadExecutor();
service.submit(new Runnable() {
@Override
public void run() {
FineEmbedServer.start();
}
});
service.shutdown();
// 切换后的环境是本地环境才启动内置服务器
if (current.isLocal()) {
ExecutorService service = Executors.newSingleThreadExecutor();
service.submit(new Runnable() {
@Override
public void run() {
FineEmbedServer.start();
}
});
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