Browse Source

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

* commit 'c935d7d5ad4b0f923881bd6f729a031540818982':
  在上层统一处理 swing 线程同步问题
  line separator
  REPORT-13870 远程设计问题以及环境切换问题
  无JIRA任务,公式编辑器显示报表参数异常
  REPORT-14361 部分操作可能导致AWT EDT线程同步异常
  REPORT-13202 包含插件控件的模板切换环境后存储出错
bugfix/10.0
abel.chen 6 years ago
parent
commit
f235d54c3a
  1. 2
      designer-base/src/main/java/com/fr/design/DesignModelAdapter.java
  2. 1
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  3. 33
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  4. 4
      designer-base/src/main/java/com/fr/design/mainframe/AbstractAppProvider.java
  5. 50
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  6. 2
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  7. 63
      designer-base/src/main/java/com/fr/design/mainframe/JTemplateFactory.java
  8. 25
      designer-base/src/main/java/com/fr/design/parameter/ParaDefinitePane.java
  9. 106
      designer-base/src/main/java/com/fr/file/StashedFILE.java
  10. 14
      designer-form/src/main/java/com/fr/design/designer/beans/events/CreatorEventListenerTable.java
  11. 3
      designer-form/src/main/java/com/fr/design/designer/beans/events/DesignerEditListener.java
  12. 44
      designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java
  13. 1
      designer-form/src/main/java/com/fr/design/mainframe/FormHierarchyTreePane.java
  14. 6
      designer-realize/src/main/java/com/fr/design/mainframe/app/DesignerAppActivator.java
  15. 4
      designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java
  16. 9
      designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java

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

@ -134,7 +134,7 @@ public abstract class DesignModelAdapter<T extends BaseBook, S extends JTemplate
*/
@Deprecated
public Parameter[] getReportParameters() {
return getTableDataParameters();
return getTemplateParameters();
}
/**

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

@ -224,6 +224,7 @@ public class EnvChangeEntrance {
@Override
public void doCancel() {
envListDialog.dispose();
// todo 断开了但是没选择新的环境,那么尝试重连旧环境,等接口
}
});
envListDialog.setVisible(true);

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

@ -2,7 +2,6 @@ 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;
@ -10,17 +9,18 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JTemplateFactory;
import com.fr.design.mainframe.JVirtualTemplate;
import com.fr.design.module.DesignModuleFactory;
import com.fr.file.FILE;
import com.fr.file.FileNodeFILE;
import com.fr.file.StashedFILE;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
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;
@ -315,7 +315,7 @@ public class HistoryTemplateListCache implements CallbackEvent {
/**
* 切换环境时暂存打开的模板内容key 是在历史中的indexvalue 是模板xml 内容byte[]
*/
private Map<Integer, byte[]> bytesMap;
private Map<Integer, FILE> stashFILEMap;
/**
* 切换环境前将正在编辑的模板暂存起来并且在新环境中重新读取一遍暂存的不是模板文件的内容而是模板对象的内容
@ -326,20 +326,21 @@ public class HistoryTemplateListCache implements CallbackEvent {
*/
public void stash() {
FineLoggerFactory.getLogger().info("Env Change Template Stashing...");
if (bytesMap == null) {
bytesMap = new HashMap<Integer, byte[]>();
if (stashFILEMap == null) {
stashFILEMap = new HashMap<Integer, FILE>();
} else {
bytesMap.clear();
stashFILEMap.clear();
}
int size = historyList.size();
for (int i = 0; i < size; i++) {
JTemplate<?, ?> template = historyList.get(i);
FILE file = template.getEditingFILE();
try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
BaseBook target = template.getTarget();
if (target != null) {
target.export(outputStream);
bytesMap.put(i, outputStream.toByteArray());
stashFILEMap.put(i, new StashedFILE(file, outputStream.toByteArray()));
}
// 如果 target == null 那么这个模板是被模板内存优化功能处理过的,不用处理
} catch (Exception e) {
@ -358,27 +359,25 @@ public class HistoryTemplateListCache implements CallbackEvent {
*/
public void load() {
FineLoggerFactory.getLogger().info("Env Change Template Loading...");
if (bytesMap != null && bytesMap.size() != 0) {
if (stashFILEMap != null && stashFILEMap.size() != 0) {
int size = historyList.size();
for (int i = 0; i < size; i++) {
try {
byte[] bytes = bytesMap.get(i);
FILE stashedFile = stashFILEMap.get(i);
// 可能有模板 stash 失败的情况,在 load 的时候不更新它
if (bytes == null) {
// 或者这个模板是被模板内存优化功能处理过的,不用处理
if (stashedFile == null) {
continue;
}
ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
BaseBook target = historyList.get(i).getTarget();
if (target != null) {
// todo readStream 这个行为应该上升到 BaseBook 上
((IOFile) target).readStream(inputStream);
JTemplate<?, ?> template = JTemplateFactory.createJTemplate(stashedFile);
if (template != null) {
historyList.set(i, template);
}
// 如果 target == null 那么这个模板是被模板内存优化功能处理过的,不用处理
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
bytesMap.clear();
stashFILEMap.clear();
MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList);
MutilTempalteTabPane.getInstance().repaint();
}

4
designer-base/src/main/java/com/fr/design/mainframe/AbstractAppProvider.java

@ -21,12 +21,12 @@ public abstract class AbstractAppProvider<T extends IOFile> extends AbstractProv
@Override
public void process() {
DesignerFrame.registApp(this);
JTemplateFactory.register(this);
}
@Override
public void undo() {
DesignerFrame.removeApp(this);
JTemplateFactory.remove(this);
}
}

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

@ -51,7 +51,6 @@ 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.OperatingSystem;
import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils;
@ -115,11 +114,9 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
private static final int MENU_HEIGHT = 26;
private static final Integer SECOND_LAYER = new Integer(100);
private static final Integer SECOND_LAYER = 100;
private static final Integer TOP_LAYER = new Integer((200));
private static java.util.List<App<?>> appList = new java.util.ArrayList<App<?>>();
private static final Integer TOP_LAYER = 200;
private List<DesignerOpenedListener> designerOpenedListenerList = new ArrayList<>();
@ -342,19 +339,22 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* 注册app.
*
* @param app 注册app.
* @deprecated use {@link JTemplateFactory#register(App)} instead
*/
@Deprecated
public static void registApp(App<?> app) {
if (app != null) {
appList.add(app);
}
JTemplateFactory.register(app);
}
/**
* 移除app
*
* @param app app
* @deprecated use {@link JTemplateFactory#remove(App)} instead
*/
@Deprecated
public static void removeApp(App<?> app) {
if (app != null) {
appList.remove(app);
}
JTemplateFactory.remove(app);
}
/**
@ -1027,21 +1027,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*/
private void openFile(FILE tplFile) {
String fileName = tplFile.getName();
int indexOfLastDot = fileName.lastIndexOf(CoreConstants.DOT);
if (indexOfLastDot < 0) {
return;
}
String fileExtention = fileName.substring(indexOfLastDot + 1);
for (int i = 0, len = appList.size(); i < len; i++) {
App<?> app = appList.get(i);
String[] defaultAppExtentions = app.defaultExtensions();
boolean opened = false;
for (int j = 0; j < defaultAppExtentions.length; j++) {
if (defaultAppExtentions[j].equalsIgnoreCase(fileExtention)) {
// 不要catch
JTemplate jt = app.openTemplate(tplFile);
JTemplate jt = JTemplateFactory.createJTemplate(tplFile);
if (jt == null) {
return;
}
@ -1053,14 +1039,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} else {
activeTemplate(jt);
}
opened = true;
break;
}
}
if (opened) {
break;
}
}
}
/**

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

@ -610,7 +610,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
} else {
JOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked"),
Toolkit.i18nText("Fine-Design-Basic_Save_Failure"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Message"),
JOptionPane.WARNING_MESSAGE);
return false;

63
designer-base/src/main/java/com/fr/design/mainframe/JTemplateFactory.java

@ -0,0 +1,63 @@
package com.fr.design.mainframe;
import com.fr.file.FILE;
import com.fr.stable.CoreConstants;
import com.fr.third.javax.annotation.Nonnull;
import com.fr.third.javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
public final class JTemplateFactory {
private static final List<App<?>> ALL_APP = new ArrayList<App<?>>();
private JTemplateFactory() {
}
/**
* 生成设计器编辑模板对象
*
* @param file 包含了模板名称类型以及内容的文件
* @return 设计器编辑的模板对象
*/
@Nullable
public static JTemplate<?, ?> createJTemplate(@Nonnull FILE file) {
String fileName = file.getName();
int indexOfLastDot = fileName.lastIndexOf(CoreConstants.DOT);
if (indexOfLastDot < 0) {
return null;
}
String fileExtension = fileName.substring(indexOfLastDot + 1);
for (App<?> app : ALL_APP) {
String[] defaultAppExtensions = app.defaultExtensions();
for (String defaultAppExtension : defaultAppExtensions) {
if (defaultAppExtension.equalsIgnoreCase(fileExtension)) {
JTemplate<?, ?> jt = app.openTemplate(file);
if (jt != null) {
return jt;
}
}
}
}
return null;
}
/**
* 注册app.
*
* @param app 注册app.
*/
public static void register(App<?> app) {
if (app != null) {
ALL_APP.add(app);
}
}
public static void remove(App<?> app) {
if (app != null) {
ALL_APP.remove(app);
}
}
}

25
designer-base/src/main/java/com/fr/design/parameter/ParaDefinitePane.java

@ -1 +1,24 @@
package com.fr.design.parameter; import com.fr.base.Parameter; public interface ParaDefinitePane { public Parameter[] getNoRepeatParas(Parameter[] paras); public void setParameterArray(Parameter[] ps); public Parameter[] getParameterArray(); public void refreshParameter(); public boolean isWithQueryButton(); public void addingParameter2Editor(Parameter p); public void addingParameter2EditorWithQueryButton(Parameter p); public void addingAllParameter2Editor(); }
package com.fr.design.parameter;
import com.fr.base.Parameter;
public interface ParaDefinitePane {
Parameter[] getNoRepeatParas(Parameter[] paras);
void setParameterArray(Parameter[] ps);
Parameter[] getParameterArray();
void refreshParameter();
boolean isWithQueryButton();
void addingParameter2Editor(Parameter p);
void addingParameter2EditorWithQueryButton(Parameter p);
void addingAllParameter2Editor();
}

106
designer-base/src/main/java/com/fr/file/StashedFILE.java

@ -0,0 +1,106 @@
package com.fr.file;
import javax.swing.Icon;
import javax.transaction.NotSupportedException;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.OutputStream;
/**
* 切换环境用于暂存的文件类型
*/
public class StashedFILE implements FILE {
private FILE file;
private byte[] content;
public StashedFILE(FILE file, byte[] content) {
this.file = file;
this.content = content;
}
@Override
public String prefix() {
return file.prefix();
}
@Override
public boolean isDirectory() {
return file.isDirectory();
}
@Override
public String getName() {
return file.getName();
}
@Override
public Icon getIcon() {
return file.getIcon();
}
@Override
public String getPath() {
return file.getPath();
}
@Override
public void setPath(String path) {
throw new UnsupportedOperationException();
}
@Override
public FILE getParent() {
throw new UnsupportedOperationException();
}
@Override
public FILE[] listFiles() {
throw new UnsupportedOperationException();
}
@Override
public boolean createFolder(String name) {
throw new UnsupportedOperationException();
}
@Override
public boolean mkfile() throws Exception {
throw new UnsupportedOperationException();
}
@Override
public boolean exists() {
return false;
}
@Override
public void closeTemplate() throws Exception {
// do nothing
}
@Override
public InputStream asInputStream() throws Exception {
return new ByteArrayInputStream(content);
}
@Override
public OutputStream asOutputStream() throws Exception {
throw new NotSupportedException();
}
@Override
public String getEnvFullName() {
return file.getEnvFullName();
}
@Override
public boolean isMemFile() {
return true;
}
@Override
public boolean isEnvFile() {
return false;
}
}

14
designer-form/src/main/java/com/fr/design/designer/beans/events/CreatorEventListenerTable.java

@ -1,10 +1,11 @@
package com.fr.design.designer.beans.events;
import java.util.ArrayList;
import com.fr.design.designer.creator.XComponent;
import com.fr.general.ComparatorUtils;
import javax.swing.SwingUtilities;
import java.util.ArrayList;
public class CreatorEventListenerTable {
protected ArrayList<DesignerEditListener> listeners;
@ -26,11 +27,16 @@ public class CreatorEventListenerTable {
listeners.add(listener);
}
private void fireCreatorModified(DesignerEvent evt) {
private void fireCreatorModified(final DesignerEvent evt) {
for (int i = 0; i < listeners.size(); i++) {
DesignerEditListener listener = listeners.get(i);
final DesignerEditListener listener = listeners.get(i);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
listener.fireCreatorModified(evt);
}
});
}
}
public void fireCreatorModified(XComponent creator, int eventID) {

3
designer-form/src/main/java/com/fr/design/designer/beans/events/DesignerEditListener.java

@ -4,8 +4,9 @@ import java.util.EventListener;
/**
* 界面设计组件触发的编辑处理器接口
* @since 6.5.4
*
* @author richer
* @since 6.5.4
*/
public interface DesignerEditListener extends EventListener {

44
designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java

@ -3,21 +3,6 @@
*/
package com.fr.design.form.parameter;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Insets;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import com.fr.base.BaseUtils;
import com.fr.base.Parameter;
import com.fr.base.parameter.ParameterUI;
@ -39,7 +24,17 @@ import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.designer.properties.FormWidgetAuthorityEditPane;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.mainframe.*;
import com.fr.design.mainframe.AuthorityEditPane;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.EastRegionContainerPane;
import com.fr.design.mainframe.FormArea;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormDesignerModeForSpecial;
import com.fr.design.mainframe.FormParaPane;
import com.fr.design.mainframe.FormWidgetDetailPane;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.WidgetToolBarPane;
import com.fr.design.parameter.ParaDefinitePane;
import com.fr.design.parameter.ParameterDesignerProvider;
import com.fr.design.parameter.ParameterPropertyPane;
@ -51,9 +46,22 @@ import com.fr.form.ui.WidgetValue;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WLayout;
import com.fr.form.ui.container.WParameterLayout;
import com.fr.stable.ArrayUtils;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Insets;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* Created by IntelliJ IDEA.
* User : Richer
@ -169,7 +177,7 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
this.getEditListenerTable().addListener(new DesignerEditListener() {
@Override
public void fireCreatorModified(DesignerEvent evt) {
public void fireCreatorModified(final DesignerEvent evt) {
if (evt.getCreatorEventID() != DesignerEvent.CREATOR_SELECTED) {
paraDefinitePane.setParameterArray(
paraDefinitePane.getNoRepeatParas(DesignModelAdapter.getCurrentModelAdapter().getParameters()));

1
designer-form/src/main/java/com/fr/design/mainframe/FormHierarchyTreePane.java

@ -18,7 +18,6 @@ import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef;
import com.fr.design.parameter.HierarchyTreePane;
import javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.Icon;

6
designer-realize/src/main/java/com/fr/design/mainframe/app/DesignerAppActivator.java

@ -1,7 +1,7 @@
package com.fr.design.mainframe.app;
import com.fr.design.mainframe.App;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.mainframe.JTemplateFactory;
import com.fr.module.Activator;
import com.fr.module.extension.Prepare;
@ -17,7 +17,7 @@ public class DesignerAppActivator extends Activator implements Prepare {
List<App> appList = rightCollectMutable(App.KEY);
for (App app : appList) {
DesignerFrame.registApp(app);
JTemplateFactory.register(app);
}
}
@ -26,7 +26,7 @@ public class DesignerAppActivator extends Activator implements Prepare {
List<App> appList = rightCollectMutable(App.KEY);
for (App app : appList) {
DesignerFrame.removeApp(app);
JTemplateFactory.remove(app);
}
}

4
designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java

@ -82,6 +82,10 @@ public class DesignerSocketIO {
socketIO.get().on(Socket.EVENT_DISCONNECT, new Emitter.Listener() {
@Override
public void call(Object... objects) {
/*
* todo 远程心跳断开不一定 socketio 断开 和远程紧密相关的业务都绑定在心跳上切换成心跳断开之后进行提醒
* socketio 只用推日志和通知配置变更
*/
if (status != Status.Disconnecting) {
try {
SwingUtilities.invokeAndWait(new Runnable() {

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

@ -82,16 +82,15 @@ public class DesignerStartup extends Activator {
*/
private void registerEnvListener() {
/*切换环境前,关闭所有相关模块*/
listenEvent(WorkspaceEvent.BeforeSwitch, new Listener<Workspace>() {
/*切换环境前,关闭所有相关模块,最后执行*/
listenEvent(WorkspaceEvent.BeforeSwitch, new Listener<Workspace>(Integer.MIN_VALUE) {
@Override
public void on(Event event, Workspace current) {
getSub(EnvBasedModule.class).stop();
}
});
/*切换环境后,重新启动所有相关模块*/
/*切换环境后,重新启动所有相关模块,最先执行*/
listenEvent(WorkspaceEvent.AfterSwitch, new Listener<Workspace>(Integer.MAX_VALUE) {
@Override
@ -110,7 +109,7 @@ public class DesignerStartup extends Activator {
}
}
});
/*切换环境前,存储一下打开的所有文件对象,优先级高于默认优先级,要先于 关闭相关模块部分 被触发*/
/*切换环境前,存储一下打开的所有文件对象,要先于 关闭相关模块部分 被触发*/
listenEvent(WorkspaceEvent.BeforeSwitch, new Listener<Workspace>(Integer.MAX_VALUE) {
@Override
public void on(Event event, Workspace workspace) {

Loading…
Cancel
Save