Browse Source

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

* commit '411037b1d384a401b3dae93c2f900e3742767960': (33 commits)
  配色
  CORE-116 进一步整理Session管理问题&单元测试失败
  设计器启动捕获LifecycleFatalError,进程退出
  CORE-113 提供自定义AOP注解的接口,可以在各个模块自行定义方便日志记录,文档稍后补充
  REPORT-9388 远程设计重构-设计器目录树-工具栏-10.0远程下比9.0多出两个工具栏按钮
  rtREPORT-9747 【10.0二轮回归】修改以前的模板无法更改
  REPORT-9619
  REPORT-9619
  REPORT-9619
  REPORT-9706 在远程环境下,切换成本地的时候弹出一个错误提示框呢
  REPORT-9741【10.0二轮回归】设计器菜单栏-文件-切换至远程服务器
  CORE-116 删除LogRecordTime等无用的对象
  .
  无
  CORE-116 fr_username->fine_username等对应的修改,KMS上补充文档,老的保持兼容
  REPORT-9246 设计器中有好多配置修改操作 中夹杂了很多的业务逻辑,将业务逻辑和配置修改剥离出来,Configurations.update操作中尽量只包含修改配置的步骤
  rt
  rtREPORT-9747 【10.0二轮回归】修改以前的模板无法更改
  .
  REPORT-9747 【10.0二轮回归】修改以前的模板无法更改
  ...
master
yaoh.wu 6 years ago
parent
commit
bc3a625133
  1. 61
      designer-base/src/main/java/com/fr/design/actions/file/LocalePane.java
  2. 17
      designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java
  3. 36
      designer-base/src/main/java/com/fr/design/actions/server/ConnectionListAction.java
  4. 20
      designer-base/src/main/java/com/fr/design/actions/server/GlobalParameterAction.java
  5. 42
      designer-base/src/main/java/com/fr/design/actions/server/GlobalTableDataAction.java
  6. 18
      designer-base/src/main/java/com/fr/design/actions/server/ProcedureListAction.java
  7. 29
      designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java
  8. 132
      designer-base/src/main/java/com/fr/design/formula/VariableResolverAdapter.java
  9. 11
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  10. 262
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  11. 143
      designer-base/src/main/java/com/fr/design/mainframe/TemplatePane.java
  12. 1
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogAppender.java
  13. 84
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java
  14. 46
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogImpl.java
  15. 12
      designer-base/src/main/java/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java
  16. 2
      designer-base/src/main/java/com/fr/design/remote/ui/AuthorityListControlPane.java
  17. 4
      designer-base/src/main/java/com/fr/design/remote/ui/UserManagerPane.java
  18. 24
      designer-base/src/main/java/com/fr/file/FileFILE.java
  19. 9
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartFillStylePane.java
  20. 97
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartPreFillStylePane.java
  21. 5
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java
  22. 165
      designer-chart/src/main/java/com/fr/design/module/ChartPreFillStylePane.java
  23. 4
      designer-chart/src/main/java/com/fr/design/module/ChartPreStyleAction.java
  24. 52
      designer-chart/src/main/java/com/fr/design/module/ChartPreStyleManagerPane.java
  25. 29
      designer-chart/src/main/java/com/fr/design/module/ChartPreStylePane.java
  26. 16
      designer-realize/src/main/java/com/fr/design/actions/report/ReportWebAttrAction.java
  27. 20
      designer-realize/src/main/java/com/fr/design/actions/server/WidgetManagerAction.java
  28. 3
      designer-realize/src/main/java/com/fr/design/dscolumn/SelectedDataColumnPane.java
  29. 4
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/FileModel.java
  30. 14
      designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java
  31. 41
      designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java
  32. 2
      designer-realize/src/main/java/com/fr/design/webattr/WebCssPane.java
  33. 2
      designer-realize/src/main/java/com/fr/design/webattr/WebJsPane.java
  34. 2
      designer-realize/src/main/java/com/fr/design/webattr/WriteToolBarPane.java
  35. 2
      designer-realize/src/main/java/com/fr/design/webattr/WriteWebSettingPane.java
  36. 21
      designer-realize/src/main/java/com/fr/start/Designer.java
  37. 5
      designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java
  38. 18
      designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java
  39. 21
      designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java

61
designer-base/src/main/java/com/fr/design/actions/file/LocalePane.java

@ -12,10 +12,10 @@ import com.fr.design.gui.itextfield.UITextField;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.bridge.StableFactory;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.resource.WorkResourceOutputStream; import com.fr.workspace.resource.WorkResourceOutputStream;
@ -37,7 +37,6 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.ResourceBundle;
import java.util.Set; import java.util.Set;
import java.util.Vector; import java.util.Vector;
@ -121,43 +120,26 @@ public class LocalePane extends BasicPane {
} }
private void initPredefinedProperties() { private void initPredefinedProperties() {
Map<Locale, String> supportLocaleMap = Inter.getSupportLocaleMap(); Map<Locale, String> supportLocaleMap = InterProviderFactory.getProvider().getSupportLocaleMap();
String[] localeFiles = StableFactory.getLocaleFiles(); Map<String, String> map;
List<String> sortKeys = new ArrayList<String>(); List<String> sortKeys = new ArrayList<String>();
for (String path : localeFiles) { map = InterProviderFactory.getProvider().getLocalBundle(Locale.SIMPLIFIED_CHINESE).getMap();
ResourceBundle chineseBundle = loadResourceBundle(path, Locale.SIMPLIFIED_CHINESE); sortKeys.addAll(map.keySet());
sortKeys.addAll(chineseBundle.keySet());
}
Collections.sort(sortKeys); Collections.sort(sortKeys);
Map<Locale, List<ResourceBundle>> localeResourceBundleMap = new HashMap<Locale, List<ResourceBundle>>();
for (Map.Entry<Locale, String> entry : supportLocaleMap.entrySet()) {
Locale locale = entry.getKey();
List<ResourceBundle> list = new ArrayList<>();
for (String path : localeFiles) {
ResourceBundle chineseBundle = loadResourceBundle(path, locale);
list.add(chineseBundle);
}
localeResourceBundleMap.put(locale, list);
}
Map<Locale, Vector<String>> data = new HashMap<Locale, Vector<String>>(); Map<Locale, Vector<String>> data = new HashMap<Locale, Vector<String>>();
for (Map.Entry<Locale, List<ResourceBundle>> entry : localeResourceBundleMap.entrySet()) { for (Locale locale : supportLocaleMap.keySet()) {
Vector<String> column = new Vector<String>(); Vector<String> column = new Vector<String>();
List<ResourceBundle> rbs = entry.getValue();
for (String key : sortKeys) { for (String key : sortKeys) {
column.add(readText(rbs, key)); column.add(InterProviderFactory.getProvider().getLocText(key));
} }
data.put(entry.getKey(), column); data.put(locale, column);
} }
Vector<String> keyVector = new Vector<String>(); Vector<String> keyVector = new Vector<String>();
keyVector.addAll(sortKeys); keyVector.addAll(sortKeys);
@ -167,20 +149,7 @@ public class LocalePane extends BasicPane {
predefineTableModel.addColumn(entry.getKey().getDisplayName(), entry.getValue()); predefineTableModel.addColumn(entry.getKey().getDisplayName(), entry.getValue());
} }
} }
private String readText(List<ResourceBundle> rbs, String key) {
for (ResourceBundle rb : rbs) {
if (rb.containsKey(key)) {
return rb.getString(key);
}
}
return null;
}
private ResourceBundle loadResourceBundle(String dir, Locale locale) {
return ResourceBundle.getBundle(dir, locale, Inter.class.getClassLoader());
}
private void initCustomProperties() throws Exception { private void initCustomProperties() throws Exception {
FileNode[] fileNodes = FRContext.getFileNodes().list(ProjectConstants.LOCALE_NAME); FileNode[] fileNodes = FRContext.getFileNodes().list(ProjectConstants.LOCALE_NAME);

17
designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java

@ -22,7 +22,8 @@ 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 javax.swing.*; import javax.swing.JOptionPane;
import javax.swing.UIManager;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
@ -108,16 +109,15 @@ public class SwitchExistEnv extends MenuDef {
try { try {
workspace = DesignerWorkspaceGenerator.generate(selectedEnv); workspace = DesignerWorkspaceGenerator.generate(selectedEnv);
if (workspace == null) { if (workspace == null) {
JOptionPane.showMessageDialog( JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"FR-Designer_M-SwitchWorkspace", "Failed"}),
DesignerContext.getDesignerFrame(), null, 0, UIManager.getIcon("OptionPane.errorIcon"));
Inter.getLocText(new String[]{"FR-Designer_M-SwitchWorkspace", "Failed"}));
return; return;
} }
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();
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshToolArea(); HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshToolArea();
@ -125,9 +125,8 @@ public class SwitchExistEnv extends MenuDef {
} }
}); });
} catch (AuthException exception) { } catch (AuthException exception) {
JOptionPane.showMessageDialog( JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"Fine-Designer_Basic_Remote_Connect_Auth_Failed", "Failed"}),
DesignerContext.getDesignerFrame(), null, 0, UIManager.getIcon("OptionPane.errorIcon"));
Inter.getLocText(new String[]{"Fine-Designer_Basic_Remote_Connect_Auth_Failed"}));
} }
} }
} }

36
designer-base/src/main/java/com/fr/design/actions/server/ConnectionListAction.java

@ -1,7 +1,6 @@
package com.fr.design.actions.server; package com.fr.design.actions.server;
import com.fr.config.Configuration;
import com.fr.data.impl.Connection; import com.fr.data.impl.Connection;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.data.datapane.connect.ConnectionManagerPane; import com.fr.design.data.datapane.connect.ConnectionManagerPane;
@ -16,10 +15,11 @@ import com.fr.file.ConnectionConfig;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.locale.InterProviderFactory; import com.fr.locale.InterProviderFactory;
import com.fr.transaction.CallBackAdaptor;
import com.fr.transaction.Configurations; import com.fr.transaction.Configurations;
import com.fr.transaction.Worker; import com.fr.transaction.WorkerFacade;
import javax.swing.*; import javax.swing.KeyStroke;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.util.Map; import java.util.Map;
@ -74,26 +74,27 @@ public class ConnectionListAction extends UpdateAction {
final BasicDialog databaseListDialog = databaseManagerPane.showLargeWindow(designerFrame, null); final BasicDialog databaseListDialog = databaseManagerPane.showLargeWindow(designerFrame, null);
databaseListDialog.addDialogActionListener(new DialogActionAdapter() { databaseListDialog.addDialogActionListener(new DialogActionAdapter() {
public void doOk() { public void doOk() {
Configurations.update(new Worker() { if (!databaseManagerPane.isNamePermitted()) {
databaseListDialog.setDoOKSucceed(false);
return;
}
Configurations.modify(new WorkerFacade(ConnectionConfig.class) {
@Override @Override
public void run() { public void run() {
if (!databaseManagerPane.isNamePermitted()) { databaseManagerPane.update(datasourceManager);
databaseListDialog.setDoOKSucceed(false);
return;
}
if (!doWithDatasourceManager(datasourceManager, databaseManagerPane, databaseListDialog)) {
//如果更新失败,则不关闭对话框,也不写xml文件,并且将对话框定位在请重命名的那个对象页面
return;
}
DesignerContext.getDesignerBean("databasename").refreshBeanElement();
} }
}.addCallBack(new CallBackAdaptor() {
@Override @Override
public Class<? extends Configuration>[] targets() { public boolean beforeCommit() {
return new Class[]{ConnectionConfig.class}; //如果更新失败,则不关闭对话框,也不写xml文件,并且将对话框定位在请重命名的那个对象页面
return doWithDatasourceManager(datasourceManager, databaseManagerPane, databaseListDialog);
} }
});
@Override
public void afterCommit() {
DesignerContext.getDesignerBean("databasename").refreshBeanElement();
}
}));
} }
}); });
databaseListDialog.setVisible(true); databaseListDialog.setVisible(true);
@ -109,7 +110,6 @@ public class ConnectionListAction extends UpdateAction {
* @return boolean 是否更新成功 * @return boolean 是否更新成功
*/ */
public static boolean doWithDatasourceManager(ConnectionConfig datasourceManager, ConnectionShowPane connectionShowPane, BasicDialog databaseListDialog) { public static boolean doWithDatasourceManager(ConnectionConfig datasourceManager, ConnectionShowPane connectionShowPane, BasicDialog databaseListDialog) {
connectionShowPane.update(datasourceManager);
boolean isFailed = false; boolean isFailed = false;
//存在请重命名则不能更新 //存在请重命名则不能更新
int index = isConnectionMapContainsRename(datasourceManager); int index = isConnectionMapContainsRename(datasourceManager);

20
designer-base/src/main/java/com/fr/design/actions/server/GlobalParameterAction.java

@ -5,7 +5,6 @@ package com.fr.design.actions.server;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.ParameterConfig; import com.fr.base.ParameterConfig;
import com.fr.config.Configuration;
import com.fr.config.ServerPreferenceConfig; import com.fr.config.ServerPreferenceConfig;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
@ -16,10 +15,11 @@ import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.menu.MenuKeySet; import com.fr.design.menu.MenuKeySet;
import com.fr.design.parameter.ParameterManagerPane; import com.fr.design.parameter.ParameterManagerPane;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.transaction.CallBackAdaptor;
import com.fr.transaction.Configurations; import com.fr.transaction.Configurations;
import com.fr.transaction.Worker; import com.fr.transaction.WorkerFacade;
import javax.swing.*; import javax.swing.KeyStroke;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
@ -49,23 +49,21 @@ public class GlobalParameterAction extends UpdateAction {
parameterManagerPane.populate(ParameterConfig.getInstance().getGlobalParameters()); parameterManagerPane.populate(ParameterConfig.getInstance().getGlobalParameters());
parameterManagerDialog.addDialogActionListener(new DialogActionAdapter() { parameterManagerDialog.addDialogActionListener(new DialogActionAdapter() {
public void doOk() { public void doOk() {
Configurations.update(new Worker() { Configurations.modify(new WorkerFacade(ServerPreferenceConfig.class) {
@Override @Override
public void run() { public void run() {
//apply new parameter list.
parameterManagerPane.update(); parameterManagerPane.update();
}
}.addCallBack(new CallBackAdaptor() {
@Override
public void afterCommit() {
DesignModelAdapter<?, ?> model = DesignModelAdapter.getCurrentModelAdapter(); DesignModelAdapter<?, ?> model = DesignModelAdapter.getCurrentModelAdapter();
if (model != null) { if (model != null) {
model.parameterChanged(); model.parameterChanged();
} }
parameterManagerDialog.setDoOKSucceed(!parameterManagerPane.isContainsRename()); parameterManagerDialog.setDoOKSucceed(!parameterManagerPane.isContainsRename());
} }
}));
@Override
public Class<? extends Configuration>[] targets() {
return new Class[]{ServerPreferenceConfig.class};
}
});
} }
}); });

42
designer-base/src/main/java/com/fr/design/actions/server/GlobalTableDataAction.java

@ -21,10 +21,12 @@ import com.fr.file.ProcedureConfig;
import com.fr.file.TableDataConfig; import com.fr.file.TableDataConfig;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.locale.InterProviderFactory; import com.fr.locale.InterProviderFactory;
import com.fr.transaction.CallBackAdaptor;
import com.fr.transaction.Configurations; import com.fr.transaction.Configurations;
import com.fr.transaction.Worker; import com.fr.transaction.Worker;
import com.fr.transaction.WorkerFacade;
import javax.swing.*; import javax.swing.KeyStroke;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -92,33 +94,35 @@ public class GlobalTableDataAction extends UpdateAction implements ResponseDataS
globalTableDataDialog.addDialogActionListener(new DialogActionAdapter() { globalTableDataDialog.addDialogActionListener(new DialogActionAdapter() {
@Override @Override
public void doOk() { public void doOk() {
Configurations.update(new Worker() { if (!globalTableDataPane.isNamePermitted()) {
globalTableDataDialog.setDoOKSucceed(false);
return;
}
DesignTableDataManager.clearGlobalDs();
Configurations.modify(new WorkerFacade(TableDataConfig.class) {
@Override @Override
public void run() { public void run() {
if (!globalTableDataPane.isNamePermitted()) {
globalTableDataDialog.setDoOKSucceed(false);
return;
}
DesignTableDataManager.clearGlobalDs();
globalTableDataPane.update(tableDataConfig); globalTableDataPane.update(tableDataConfig);
if (!doWithDatasourceManager(tableDataConfig, globalTableDataPane, globalTableDataDialog)) {
//如果更新失败,则不关闭对话框,也不写xml文件,并且将对话框定位在请重命名的那个对象页面
return;
}
// 刷新共有数据集
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter());
fireDSChanged(globalTableDataPane.getDsChangedNameMap());
} }
}.addCallBack(new CallBackAdaptor() {
@Override @Override
public Class<? extends Configuration>[] targets() { public boolean beforeCommit() {
return new Class[]{TableDataConfig.class}; //如果更新失败,则不关闭对话框,也不写xml文件,并且将对话框定位在请重命名的那个对象页面
return doWithDatasourceManager(tableDataConfig, globalTableDataPane, globalTableDataDialog);
} }
});
@Override
public void afterCommit() {
// 刷新共有数据集
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter());
fireDSChanged(globalTableDataPane.getDsChangedNameMap());
}
}));
} }
}); });
globalTableDataDialog.setVisible(true); globalTableDataDialog.setVisible(true);

18
designer-base/src/main/java/com/fr/design/actions/server/ProcedureListAction.java

@ -1,7 +1,6 @@
package com.fr.design.actions.server; package com.fr.design.actions.server;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.config.Configuration;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
@ -13,8 +12,9 @@ import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame; import com.fr.design.mainframe.DesignerFrame;
import com.fr.file.ProcedureConfig; import com.fr.file.ProcedureConfig;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.transaction.CallBackAdaptor;
import com.fr.transaction.Configurations; import com.fr.transaction.Configurations;
import com.fr.transaction.Worker; import com.fr.transaction.WorkerFacade;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
@ -44,20 +44,18 @@ public class ProcedureListAction extends UpdateAction {
BasicDialog databaseListDialog = databaseManagerPane.showLargeWindow(designerFrame, null); BasicDialog databaseListDialog = databaseManagerPane.showLargeWindow(designerFrame, null);
databaseListDialog.addDialogActionListener(new DialogActionAdapter() { databaseListDialog.addDialogActionListener(new DialogActionAdapter() {
public void doOk() { public void doOk() {
Configurations.update(new Worker() { DesignTableDataManager.clearGlobalDs();
Configurations.modify(new WorkerFacade(ProcedureConfig.class) {
@Override @Override
public void run() { public void run() {
DesignTableDataManager.clearGlobalDs();
databaseManagerPane.update(procedureConfig); databaseManagerPane.update(procedureConfig);
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter());
} }
}.addCallBack(new CallBackAdaptor() {
@Override @Override
public Class<? extends Configuration>[] targets() { public void afterCommit() {
return new Class[]{ProcedureConfig.class}; TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter());
} }
}); }));
} }
}); });
databaseListDialog.setVisible(true); databaseListDialog.setVisible(true);

29
designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java

@ -1,7 +1,5 @@
package com.fr.design.data.datapane.connect; package com.fr.design.data.datapane.connect;
import com.fr.base.FRContext;
import com.fr.config.Configuration;
import com.fr.data.impl.AbstractDatabaseConnection; import com.fr.data.impl.AbstractDatabaseConnection;
import com.fr.data.impl.Connection; import com.fr.data.impl.Connection;
import com.fr.data.impl.NameDatabaseConnection; import com.fr.data.impl.NameDatabaseConnection;
@ -13,11 +11,12 @@ import com.fr.design.mainframe.DesignerContext;
import com.fr.file.ConnectionConfig; import com.fr.file.ConnectionConfig;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.transaction.CallBackAdaptor;
import com.fr.transaction.Configurations; import com.fr.transaction.Configurations;
import com.fr.transaction.Worker; import com.fr.transaction.WorkerFacade;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import javax.swing.*; import javax.swing.SwingUtilities;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
import java.util.ArrayList; import java.util.ArrayList;
@ -100,22 +99,24 @@ public class ConnectionComboBoxPanel extends ItemEditableComboBoxPanel {
connectionListDialog.setDoOKSucceed(false); connectionListDialog.setDoOKSucceed(false);
return; return;
} }
Configurations.update(new Worker() {
Configurations.modify(new WorkerFacade(ConnectionConfig.class) {
@Override @Override
public void run() { public void run() {
if (!ConnectionListAction.doWithDatasourceManager(connectionConfig, connectionListPane, connectionListPane.update(connectionConfig);
connectionListDialog)) { }
//如果更新失败,则不关闭对话框,也不写xml文件,并且将对话框定位在请重命名的那个对象页面 }.addCallBack(new CallBackAdaptor() {
return; @Override
} public boolean beforeCommit() {
DesignerContext.getDesignerBean("databasename").refreshBeanElement(); //如果更新失败,则不关闭对话框,也不写xml文件,并且将对话框定位在请重命名的那个对象页面
return ConnectionListAction.doWithDatasourceManager(connectionConfig, connectionListPane, connectionListDialog);
} }
@Override @Override
public Class<? extends Configuration>[] targets() { public void afterCommit() {
return new Class[]{ConnectionConfig.class}; DesignerContext.getDesignerBean("databasename").refreshBeanElement();
} }
}); }));
} }
}); });

132
designer-base/src/main/java/com/fr/design/formula/VariableResolverAdapter.java

@ -3,10 +3,10 @@ package com.fr.design.formula;
import com.fr.base.Parameter; import com.fr.base.Parameter;
import com.fr.base.ParameterConfig; import com.fr.base.ParameterConfig;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.general.web.ParameterConstants;
import com.fr.plugin.ExtraClassManager; import com.fr.plugin.ExtraClassManager;
import com.fr.script.ScriptConstants; import com.fr.script.ScriptConstants;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.Constants;
import com.fr.stable.fun.BuiltInParametersProvider; import com.fr.stable.fun.BuiltInParametersProvider;
import com.fr.stable.script.CalculatorProvider; import com.fr.stable.script.CalculatorProvider;
@ -15,91 +15,93 @@ import java.util.List;
import java.util.Set; import java.util.Set;
public abstract class VariableResolverAdapter implements VariableResolver { public abstract class VariableResolverAdapter implements VariableResolver {
private static final int TABLE_DATA_PARA = 0; private static final int TABLE_DATA_PARA = 0;
private static final int REPORT_DATA_PARA = 1; private static final int REPORT_DATA_PARA = 1;
/** /**
* 获取模板内置的一些参数 * 获取模板内置的一些参数
* *
* @return 内置参数 * @return 内置参数
*/ */
public String[] resolveCurReportVariables() { public String[] resolveCurReportVariables() {
String [] variables = new String[] { ScriptConstants.SUMMARY_TAG + "page_number", String[] variables = new String[]{
ScriptConstants.SUMMARY_TAG + "totalPage_number", ScriptConstants.SUMMARY_TAG + "page_number",
// 下面是权限相关的参数 ScriptConstants.SUMMARY_TAG + "totalPage_number",
ScriptConstants.DETAIL_TAG + Constants.P.PRIVILEGE_USERNAME, ScriptConstants.DETAIL_TAG + Constants.P.PRIVILEGE_AUTHORITY, // 下面是权限相关的参数
ScriptConstants.DETAIL_TAG + Constants.P.PRIVILEGE_DEPARTMETN_AND_POST, ScriptConstants.DETAIL_TAG + ParameterConstants.FINE_USERNAME,
// 空值参数 ScriptConstants.DETAIL_TAG + ParameterConstants.FINE_ROLE,
"NULL", "NOFILTER", ScriptConstants.DETAIL_TAG + ParameterConstants.FINE_POSITION,
// request变量 // 空值参数
CalculatorProvider.REPORT_NAME, CalculatorProvider.FORMLET_NAME, CalculatorProvider.SERVLET_URL, CalculatorProvider.SERVER_SCHEMA, CalculatorProvider.SERVER_NAME, "NULL", "NOFILTER",
CalculatorProvider.SERVER_PORT, CalculatorProvider.SERVER_URL, CalculatorProvider.CONTEXT_PATH, CalculatorProvider.SESSION_ID // request变量
}; CalculatorProvider.REPORT_NAME, CalculatorProvider.FORMLET_NAME, CalculatorProvider.SERVLET_URL, CalculatorProvider.SERVER_SCHEMA, CalculatorProvider.SERVER_NAME,
Set<BuiltInParametersProvider> set = ExtraClassManager.getInstance().getArray(BuiltInParametersProvider.XML_TAG); CalculatorProvider.SERVER_PORT, CalculatorProvider.SERVER_URL, CalculatorProvider.CONTEXT_PATH, CalculatorProvider.SESSION_ID
for (BuiltInParametersProvider provider : set) { };
return (String[]) ArrayUtils.addAll(variables, new String []{ Set<BuiltInParametersProvider> set = ExtraClassManager.getInstance().getArray(BuiltInParametersProvider.XML_TAG);
ScriptConstants.DETAIL_TAG + provider.getParametersName() for (BuiltInParametersProvider provider : set) {
}); return (String[]) ArrayUtils.addAll(variables, new String[]{
} ScriptConstants.DETAIL_TAG + provider.getParametersName()
return variables; });
} }
return variables;
private Parameter[] getCurrentModeParameters(int type) { }
Parameter[] parameters = null;
if(DesignModelAdapter.getCurrentModelAdapter() == null) { private Parameter[] getCurrentModeParameters(int type) {
parameters = new Parameter[0]; Parameter[] parameters = null;
} else { if (DesignModelAdapter.getCurrentModelAdapter() == null) {
if(type == TABLE_DATA_PARA) { parameters = new Parameter[0];
parameters = DesignModelAdapter.getCurrentModelAdapter().getTableDataParameters(); } else {
} else if(type == REPORT_DATA_PARA){ if (type == TABLE_DATA_PARA) {
parameters = DesignModelAdapter.getCurrentModelAdapter().getReportParameters(); parameters = DesignModelAdapter.getCurrentModelAdapter().getTableDataParameters();
} } else if (type == REPORT_DATA_PARA) {
} parameters = DesignModelAdapter.getCurrentModelAdapter().getReportParameters();
return parameters; }
} }
return parameters;
}
/** /**
* 获取数据集参数 * 获取数据集参数
* *
* @return 所有参数 * @return 所有参数
*/ */
public String[] resolveTableDataParameterVariables() { public String[] resolveTableDataParameterVariables() {
Parameter[] parameters = getCurrentModeParameters(TABLE_DATA_PARA); Parameter[] parameters = getCurrentModeParameters(TABLE_DATA_PARA);
String[] parameterNames = new String[parameters.length]; String[] parameterNames = new String[parameters.length];
for (int i = 0; i < parameters.length; i++) { for (int i = 0; i < parameters.length; i++) {
parameterNames[i] = ScriptConstants.DETAIL_TAG + parameters[i].getName(); parameterNames[i] = ScriptConstants.DETAIL_TAG + parameters[i].getName();
} }
return parameterNames; return parameterNames;
} }
/** /**
* 获取模板参数 * 获取模板参数
* *
* @return 所有参数 * @return 所有参数
*/ */
public String[] resolveReportParameterVariables() { public String[] resolveReportParameterVariables() {
Parameter[] parameters = getCurrentModeParameters(REPORT_DATA_PARA); Parameter[] parameters = getCurrentModeParameters(REPORT_DATA_PARA);
String[] parameterNames = new String[parameters.length]; String[] parameterNames = new String[parameters.length];
for (int i = 0; i < parameters.length; i++) { for (int i = 0; i < parameters.length; i++) {
parameterNames[i] = ScriptConstants.DETAIL_TAG + parameters[i].getName(); parameterNames[i] = ScriptConstants.DETAIL_TAG + parameters[i].getName();
} }
return parameterNames; return parameterNames;
} }
/** /**
* 获取全局参数 * 获取全局参数
* *
* @return 所有参数 * @return 所有参数
*/ */
public String[] resolveGlobalParameterVariables() { public String[] resolveGlobalParameterVariables() {
// 加上全局的参数 // 加上全局的参数
Parameter[] globalParameters = ParameterConfig.getInstance().getGlobalParameters(); Parameter[] globalParameters = ParameterConfig.getInstance().getGlobalParameters();
List<String> variablesList = new ArrayList<String>(); List<String> variablesList = new ArrayList<String>();
for (int i = 0; i < (globalParameters == null ? 0 : globalParameters.length); i++) { for (int i = 0; i < (globalParameters == null ? 0 : globalParameters.length); i++) {
variablesList.add(ScriptConstants.DETAIL_TAG + (globalParameters[i]).getName()); variablesList.add(ScriptConstants.DETAIL_TAG + (globalParameters[i]).getName());
} }
return variablesList.toArray(new String[variablesList.size()]); return variablesList.toArray(new String[variablesList.size()]);
} }
} }

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

@ -1009,16 +1009,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*/ */
private void activeTemplate(FILE tplFile, JTemplate jt) { private void activeTemplate(FILE tplFile, JTemplate jt) {
// 如果该模板已经打开,则进行激活就可以了 // 如果该模板已经打开,则进行激活就可以了
String fullName = StableUtils.pathJoin(new String[]{ProjectConstants.REPORTLETS_NAME, tplFile.getName()}); int index = HistoryTemplateListPane.getInstance().contains(tplFile.getPath());
if (tplFile instanceof FileNodeFILE) {
fullName = ((FileNodeFILE) tplFile).getEnvPath() + "/" + tplFile.getPath();
}
// 如果是从文件夹打开的文件,不是从设计器文件树打开的文件,则直接取path就行
if (tplFile instanceof FileFILE) {
fullName = tplFile.getPath();
}
fullName = OperatingSystem.isWindows() ? fullName.replaceAll("/", "\\\\") : fullName.replaceAll("\\\\", "/");
int index = HistoryTemplateListPane.getInstance().contains(fullName);
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);

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

@ -36,6 +36,7 @@ import com.fr.io.utils.ResourceIOUtils;
import com.fr.stable.CoreConstants; import com.fr.stable.CoreConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
@ -50,35 +51,35 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarStateChangeListener, ResponseDataSourceChange { public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarStateChangeListener, ResponseDataSourceChange {
private static final String FILE = "file"; private static final String FILE = "file";
private static volatile DesignerFrameFileDealerPane THIS; private static volatile DesignerFrameFileDealerPane THIS;
private CardLayout card; private CardLayout card;
private JPanel cardPane; private JPanel cardPane;
private FileOperations selectedOperation; private FileOperations selectedOperation;
private UIToolbar toolBar; private UIToolbar toolBar;
private OpenReportAction openReportAction = new OpenReportAction(); private OpenReportAction openReportAction = new OpenReportAction();
private RefreshTreeAction refreshTreeAction = new RefreshTreeAction(); private RefreshTreeAction refreshTreeAction = new RefreshTreeAction();
private OpenFolderAction openFolderAction = new OpenFolderAction(); private OpenFolderAction openFolderAction = new OpenFolderAction();
private RenameAction renameAction = new RenameAction(); private RenameAction renameAction = new RenameAction();
private DelFileAction delFileAction = new DelFileAction(); private DelFileAction delFileAction = new DelFileAction();
/** /**
* 刷新 * 刷新
*/ */
public void refresh() { public void refresh() {
selectedOperation.refresh(); selectedOperation.refresh();
} }
@ -93,9 +94,9 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
} }
return THIS; return THIS;
} }
private DesignerFrameFileDealerPane() { private DesignerFrameFileDealerPane() {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
toolBar = ToolBarDef.createJToolBar(); toolBar = ToolBarDef.createJToolBar();
toolBar.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIConstants.TOOLBAR_BORDER_COLOR)); toolBar.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIConstants.TOOLBAR_BORDER_COLOR));
@ -106,23 +107,23 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
parent.setBorder(BorderFactory.createEmptyBorder(3, 0, 4, 0)); parent.setBorder(BorderFactory.createEmptyBorder(3, 0, 4, 0));
tooBarPane.add(parent, BorderLayout.CENTER); tooBarPane.add(parent, BorderLayout.CENTER);
tooBarPane.add(new UIMenuHighLight(), BorderLayout.SOUTH); tooBarPane.add(new UIMenuHighLight(), BorderLayout.SOUTH);
add(tooBarPane, BorderLayout.NORTH); add(tooBarPane, BorderLayout.NORTH);
cardPane = new JPanel(card = new CardLayout()); cardPane = new JPanel(card = new CardLayout());
cardPane.add(TemplateTreePane.getInstance(), FILE); cardPane.add(TemplateTreePane.getInstance(), FILE);
selectedOperation = TemplateTreePane.getInstance(); selectedOperation = TemplateTreePane.getInstance();
card.show(cardPane, FILE); card.show(cardPane, FILE);
TemplateTreePane.getInstance().setToobarStateChangeListener(this); TemplateTreePane.getInstance().setToobarStateChangeListener(this);
add(cardPane, BorderLayout.CENTER); add(cardPane, BorderLayout.CENTER);
stateChange(); stateChange();
} }
public final void setCurrentEditingTemplate(JTemplate<?, ?> jt) { public final void setCurrentEditingTemplate(JTemplate<?, ?> jt) {
DesignModelAdapter.setCurrentModelAdapter(jt == null ? null : jt.getModel()); DesignModelAdapter.setCurrentModelAdapter(jt == null ? null : jt.getModel());
fireDSChanged(); fireDSChanged();
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()); TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter());
@ -132,37 +133,40 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
if (BaseUtils.isAuthorityEditing()) { if (BaseUtils.isAuthorityEditing()) {
RolesAlreadyEditedPane.getInstance().refreshDockingView(); RolesAlreadyEditedPane.getInstance().refreshDockingView();
} }
jt.setComposite(); jt.setComposite();
jt.refreshToolArea(); jt.refreshToolArea();
jt.fireJTemplateOpened(); jt.fireJTemplateOpened();
jt.requestFocus(); jt.requestFocus();
jt.revert(); jt.revert();
FRContext.getLogger().info("\"" + jt.getEditingFILE().getName() + "\"" + Inter.getLocText("LOG-Has_Been_Openned") + "!"); FRContext.getLogger().info("\"" + jt.getEditingFILE().getName() + "\"" + Inter.getLocText("LOG-Has_Been_Openned") + "!");
} }
/** /**
* 刷新菜单 * 刷新菜单
*/ */
public void refreshDockingView() { public void refreshDockingView() {
ToolBarDef toolbarDef = new ToolBarDef(); ToolBarDef toolbarDef = new ToolBarDef();
toolbarDef.addShortCut(openReportAction, refreshTreeAction); toolbarDef.addShortCut(openReportAction, refreshTreeAction);
toolbarDef.addShortCut(openFolderAction, renameAction); if (WorkContext.getCurrent().isLocal()) {
toolbarDef.addShortCut(openFolderAction, renameAction);
}
toolbarDef.addShortCut(delFileAction); toolbarDef.addShortCut(delFileAction);
Set<ShortCut> extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts(); Set<ShortCut> extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts();
for (ShortCut shortCut : extraShortCuts) { for (ShortCut shortCut : extraShortCuts) {
toolbarDef.addShortCut(shortCut); toolbarDef.addShortCut(shortCut);
} }
toolbarDef.updateToolBar(toolBar); toolbarDef.updateToolBar(toolBar);
refreshActions(); refreshActions();
refresh();
} }
private void refreshActions() { private void refreshActions() {
openReportAction.setEnabled(false); openReportAction.setEnabled(false);
refreshTreeAction.setEnabled(true); refreshTreeAction.setEnabled(true);
openFolderAction.setEnabled(false); openFolderAction.setEnabled(false);
@ -170,123 +174,123 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
delFileAction.setEnabled(false); delFileAction.setEnabled(false);
this.repaint(); this.repaint();
} }
/** /**
* 响应数据集改变 * 响应数据集改变
*/ */
public void fireDSChanged() { public void fireDSChanged() {
fireDSChanged(new HashMap<String, String>()); fireDSChanged(new HashMap<String, String>());
} }
/** /**
* 响应数据集改变 * 响应数据集改变
* *
* @param map 改变名字的数据集 * @param map 改变名字的数据集
*/ */
public void fireDSChanged(Map<String, String> map) { public void fireDSChanged(Map<String, String> map) {
DesignTableDataManager.fireDSChanged(map); DesignTableDataManager.fireDSChanged(map);
} }
/* /*
* Open Report Action * Open Report Action
*/ */
private class OpenReportAction extends UpdateAction { private class OpenReportAction extends UpdateAction {
public OpenReportAction() { public OpenReportAction() {
this.setName(KeySetUtils.OPEN_TEMPLATE.getMenuKeySetName()); this.setName(KeySetUtils.OPEN_TEMPLATE.getMenuKeySetName());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/buttonicon/open.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/buttonicon/open.png"));
} }
@Override @Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
selectedOperation.openSelectedReport(); selectedOperation.openSelectedReport();
} }
} }
private class OpenFolderAction extends UpdateAction { private class OpenFolderAction extends UpdateAction {
public OpenFolderAction() { public OpenFolderAction() {
this.setName(Inter.getLocText("FR-Designer_Show_in_Containing_Folder")); this.setName(Inter.getLocText("FR-Designer_Show_in_Containing_Folder"));
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/view_folder.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/view_folder.png"));
} }
@Override @Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
selectedOperation.openContainerFolder(); selectedOperation.openContainerFolder();
} }
} }
/* /*
* 刷新ReportletsTree * 刷新ReportletsTree
*/ */
private class RefreshTreeAction extends UpdateAction { private class RefreshTreeAction extends UpdateAction {
public RefreshTreeAction() { public RefreshTreeAction() {
this.setName(Inter.getLocText("FR-Designer_Refresh")); this.setName(Inter.getLocText("FR-Designer_Refresh"));
this.setSmallIcon(UIConstants.REFRESH_ICON); this.setSmallIcon(UIConstants.REFRESH_ICON);
} }
@Override @Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
selectedOperation.refresh(); selectedOperation.refresh();
stateChange(); stateChange();
} }
} }
/* /*
* 重命名文件 * 重命名文件
*/ */
private class RenameAction extends UpdateAction { private class RenameAction extends UpdateAction {
public RenameAction() { public RenameAction() {
this.setName(Inter.getLocText("FR-Designer_Rename")); this.setName(Inter.getLocText("FR-Designer_Rename"));
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/data/source/rename.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/data/source/rename.png"));
} }
@Override @Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
new RenameDialog(); new RenameDialog();
MutilTempalteTabPane.getInstance().repaint(); MutilTempalteTabPane.getInstance().repaint();
} }
} }
/* /*
* 删除指定文件 * 删除指定文件
*/ */
private class DelFileAction extends UpdateAction { private class DelFileAction extends UpdateAction {
public DelFileAction() { public DelFileAction() {
this.setName(Inter.getLocText("FR-Designer_Remove")); this.setName(Inter.getLocText("FR-Designer_Remove"));
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/data/source/delete.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/data/source/delete.png"));
} }
@Override @Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
selectedOperation.deleteFile(); selectedOperation.deleteFile();
} }
} }
/** /**
* 按钮状态改变 * 按钮状态改变
*/ */
@Override @Override
public void stateChange() { public void stateChange() {
if (selectedOperation.getSelectedTemplatePath() != null) { if (selectedOperation.getSelectedTemplatePath() != null) {
openReportAction.setEnabled(true); openReportAction.setEnabled(true);
renameAction.setEnabled(true); renameAction.setEnabled(true);
@ -297,7 +301,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
delFileAction.setEnabled(false); delFileAction.setEnabled(false);
} }
openFolderAction.setEnabled(containsFolderNums() + seletedTemplateNums() != 0); openFolderAction.setEnabled(containsFolderNums() + seletedTemplateNums() != 0);
refreshTreeAction.setEnabled(true); refreshTreeAction.setEnabled(true);
if (containsFolderNums() > 0 && (containsFolderNums() + seletedTemplateNums() > 1)) { if (containsFolderNums() > 0 && (containsFolderNums() + seletedTemplateNums() > 1)) {
refreshActions(); refreshActions();
@ -308,22 +312,22 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
renameAction.setEnabled(false); renameAction.setEnabled(false);
delFileAction.setEnabled(true); delFileAction.setEnabled(true);
} }
} }
/** /**
* 是否包含文件夹 * 是否包含文件夹
* *
* @return * @return
*/ */
private int containsFolderNums() { private int containsFolderNums() {
TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree(); TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree();
if (fileTree.getSelectionPaths() == null) { if (fileTree.getSelectionPaths() == null) {
return 0; return 0;
} }
//选择的包含文件和文件夹的数目 //选择的包含文件和文件夹的数目
if (fileTree.getSelectionPaths().length == 0) { if (fileTree.getSelectionPaths().length == 0) {
return 0; return 0;
@ -331,53 +335,53 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
//所有的num减去模板的num,得到文件夹的num //所有的num减去模板的num,得到文件夹的num
return fileTree.getSelectionPaths().length - fileTree.getSelectedTemplatePaths().length; return fileTree.getSelectionPaths().length - fileTree.getSelectedTemplatePaths().length;
} }
/** /**
* 是否选择了多个模板 * 是否选择了多个模板
* *
* @return * @return
*/ */
private int seletedTemplateNums() { private int seletedTemplateNums() {
TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree(); TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree();
if (fileTree.getSelectionPaths() == null) { if (fileTree.getSelectionPaths() == null) {
return 0; return 0;
} }
return fileTree.getSelectedTemplatePaths().length; return fileTree.getSelectedTemplatePaths().length;
} }
// js: 重命名对话框,模仿Eclipse的重命名,支持快捷键F2,Enter,ESC // js: 重命名对话框,模仿Eclipse的重命名,支持快捷键F2,Enter,ESC
private class RenameDialog { private class RenameDialog {
private UITextField jt; private UITextField jt;
private String userInput; private String userInput;
private String oldName; private String oldName;
private UILabel hintsLabel; private UILabel hintsLabel;
private UIButton confirmButton; private UIButton confirmButton;
private JDialog jd; private JDialog jd;
private String suffix; private String suffix;
public RenameDialog() { public RenameDialog() {
final String reportPath = selectedOperation.getSelectedTemplatePath(); final String reportPath = selectedOperation.getSelectedTemplatePath();
if (reportPath == null) { if (reportPath == null) {
return; return;
} }
final FileNodeFILE nodeFile = new FileNodeFILE(new FileNode(StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath), false)); final FileNodeFILE nodeFile = new FileNodeFILE(new FileNode(StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath), false));
final String path = nodeFile.getPath(); final String path = nodeFile.getPath();
oldName = nodeFile.getName(); oldName = nodeFile.getName();
suffix = oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length()); suffix = oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length());
oldName = oldName.replaceAll(suffix, ""); oldName = oldName.replaceAll(suffix, "");
jd = new JDialog(); jd = new JDialog();
jd.setLayout(new GridLayout(2, 2)); jd.setLayout(new GridLayout(2, 2));
jd.setModal(true); jd.setModal(true);
@ -388,14 +392,14 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
jt.getDocument().addDocumentListener(getdoDocumentListener()); jt.getDocument().addDocumentListener(getdoDocumentListener());
jt.selectAll(); jt.selectAll();
jt.setPreferredSize(new Dimension(150, 20)); jt.setPreferredSize(new Dimension(150, 20));
JPanel newNamePanel = new JPanel(); JPanel newNamePanel = new JPanel();
newNamePanel.setLayout(new BoxLayout(newNamePanel, BoxLayout.X_AXIS)); newNamePanel.setLayout(new BoxLayout(newNamePanel, BoxLayout.X_AXIS));
newNamePanel.add(Box.createHorizontalGlue()); newNamePanel.add(Box.createHorizontalGlue());
newNamePanel.add(newNameLabel); newNamePanel.add(newNameLabel);
newNamePanel.add(Box.createHorizontalStrut(5)); newNamePanel.add(Box.createHorizontalStrut(5));
jd.add(newNamePanel); jd.add(newNamePanel);
JPanel jtPanel = new JPanel(); JPanel jtPanel = new JPanel();
jtPanel.setLayout(new BoxLayout(jtPanel, BoxLayout.Y_AXIS)); jtPanel.setLayout(new BoxLayout(jtPanel, BoxLayout.Y_AXIS));
JPanel containJt = new JPanel(new BorderLayout()); JPanel containJt = new JPanel(new BorderLayout());
@ -405,46 +409,46 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
jtPanel.add(containJt); jtPanel.add(containJt);
jtPanel.add(Box.createVerticalGlue()); jtPanel.add(Box.createVerticalGlue());
jd.add(jtPanel); jd.add(jtPanel);
addUITextFieldListener(nodeFile, path); addUITextFieldListener(nodeFile, path);
hintsLabel = new UILabel(); hintsLabel = new UILabel();
hintsLabel.setBounds(20, 50, 250, 30); hintsLabel.setBounds(20, 50, 250, 30);
hintsLabel.setMaximumSize(new Dimension(200, 30)); hintsLabel.setMaximumSize(new Dimension(200, 30));
hintsLabel.setHorizontalAlignment(SwingConstants.RIGHT); hintsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
hintsLabel.setForeground(Color.RED); hintsLabel.setForeground(Color.RED);
hintsLabel.setVisible(false); hintsLabel.setVisible(false);
confirmButton = new UIButton(Inter.getLocText("FR-Designer_Confirm")); confirmButton = new UIButton(Inter.getLocText("FR-Designer_Confirm"));
confirmButton.setPreferredSize(new Dimension(80, 25)); confirmButton.setPreferredSize(new Dimension(80, 25));
confirmButton.setMinimumSize(new Dimension(80, 25)); confirmButton.setMinimumSize(new Dimension(80, 25));
confirmButton.setMaximumSize(new Dimension(80, 25)); confirmButton.setMaximumSize(new Dimension(80, 25));
confirmButton.addActionListener(new ActionListener() { confirmButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
confirmClose(nodeFile, path); confirmClose(nodeFile, path);
} }
}); });
UIButton cancelButton = new UIButton(Inter.getLocText("FR-Designer_Cancel")); UIButton cancelButton = new UIButton(Inter.getLocText("FR-Designer_Cancel"));
cancelButton.setPreferredSize(new Dimension(80, 25)); cancelButton.setPreferredSize(new Dimension(80, 25));
cancelButton.setMinimumSize(new Dimension(80, 25)); cancelButton.setMinimumSize(new Dimension(80, 25));
cancelButton.setMaximumSize(new Dimension(80, 25)); cancelButton.setMaximumSize(new Dimension(80, 25));
cancelButton.addActionListener(new ActionListener() { cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
jd.dispose(); jd.dispose();
} }
}); });
JPanel hintsPanel = new JPanel(); JPanel hintsPanel = new JPanel();
hintsPanel.setLayout(new BorderLayout()); hintsPanel.setLayout(new BorderLayout());
hintsPanel.add(hintsLabel, BorderLayout.EAST); hintsPanel.add(hintsLabel, BorderLayout.EAST);
jd.add(hintsLabel); jd.add(hintsLabel);
JPanel btPanel = new JPanel(new BorderLayout()); JPanel btPanel = new JPanel(new BorderLayout());
btPanel.setLayout(new BoxLayout(btPanel, BoxLayout.X_AXIS)); btPanel.setLayout(new BoxLayout(btPanel, BoxLayout.X_AXIS));
btPanel.add(Box.createHorizontalGlue()); btPanel.add(Box.createHorizontalGlue());
@ -453,7 +457,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
btPanel.add(cancelButton); btPanel.add(cancelButton);
btPanel.add(Box.createHorizontalStrut(20)); btPanel.add(Box.createHorizontalStrut(20));
jd.add(btPanel); jd.add(btPanel);
jd.setSize(380, 200); jd.setSize(380, 200);
jd.setTitle(Inter.getLocText("FR-Designer_Rename")); jd.setTitle(Inter.getLocText("FR-Designer_Rename"));
jd.setResizable(false); jd.setResizable(false);
@ -463,24 +467,24 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
GUICoreUtils.centerWindow(jd); GUICoreUtils.centerWindow(jd);
jd.setVisible(true); jd.setVisible(true);
} }
public void confirmClose(FileNodeFILE nodeFile, String path) { public void confirmClose(FileNodeFILE nodeFile, String path) {
userInput = userInput == null ? oldName : userInput; userInput = userInput == null ? oldName : userInput;
String oldPath = path.replaceAll("/", "\\\\"); String oldPath = path.replaceAll("/", "\\\\");
String newPath = path.replace(nodeFile.getName(), userInput + suffix); String newPath = path.replace(nodeFile.getName(), userInput + suffix);
renameTemplateInMemory(nodeFile, userInput + suffix, oldName + suffix); renameTemplateInMemory(nodeFile, userInput + suffix, oldName + suffix);
DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(oldPath, newPath.replaceAll("/", "\\\\")); DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(oldPath, newPath.replaceAll("/", "\\\\"));
//模版重命名 //模版重命名
ResourceIOUtils.renameTo(path, newPath); ResourceIOUtils.renameTo(path, newPath);
selectedOperation.refresh(); selectedOperation.refresh();
DesignerContext.getDesignerFrame().setTitle(); DesignerContext.getDesignerFrame().setTitle();
jd.dispose(); jd.dispose();
} }
private void renameTemplateInMemory(FILE tplFile, String newName, String oldName) { private void renameTemplateInMemory(FILE tplFile, String newName, String oldName) {
JTemplate<?, ?> dPane = getSpecialTemplateByFILE(tplFile); JTemplate<?, ?> dPane = getSpecialTemplateByFILE(tplFile);
if (dPane == null) { if (dPane == null) {
return; return;
@ -488,24 +492,24 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
FILE renameFile = dPane.getEditingFILE(); FILE renameFile = dPane.getEditingFILE();
renameFile.setPath(renameFile.getPath().replace(oldName, newName)); renameFile.setPath(renameFile.getPath().replace(oldName, newName));
} }
// 增加enter以及esc快捷键的支持 // 增加enter以及esc快捷键的支持
public void addUITextFieldListener(final FileNodeFILE nodeFile, final String path) { public void addUITextFieldListener(final FileNodeFILE nodeFile, final String path) {
jt.addKeyListener(new KeyAdapter() { jt.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) { public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
jd.dispose(); jd.dispose();
} }
} }
}); });
jt.addKeyListener(new KeyAdapter() { jt.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) { public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) { if (e.getKeyCode() == KeyEvent.VK_ENTER) {
if (confirmButton.isEnabled()) { if (confirmButton.isEnabled()) {
confirmClose(nodeFile, path); confirmClose(nodeFile, path);
@ -513,35 +517,35 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
} }
} }
}); });
} }
// UITextField的输入监听 // UITextField的输入监听
public DocumentListener getdoDocumentListener() { public DocumentListener getdoDocumentListener() {
DocumentListener dl = new DocumentListener() { DocumentListener dl = new DocumentListener() {
public void changedUpdate(DocumentEvent e) { public void changedUpdate(DocumentEvent e) {
isNameAlreadyExist(); isNameAlreadyExist();
} }
public void insertUpdate(DocumentEvent e) { public void insertUpdate(DocumentEvent e) {
isNameAlreadyExist(); isNameAlreadyExist();
} }
public void removeUpdate(DocumentEvent e) { public void removeUpdate(DocumentEvent e) {
isNameAlreadyExist(); isNameAlreadyExist();
} }
}; };
return dl; return dl;
} }
private void isNameAlreadyExist() { private void isNameAlreadyExist() {
userInput = jt.getText().trim(); userInput = jt.getText().trim();
if (selectedOperation.isNameAlreadyExist(userInput, oldName, suffix)) { if (selectedOperation.isNameAlreadyExist(userInput, oldName, suffix)) {
jt.selectAll(); jt.selectAll();
@ -555,13 +559,13 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
} }
} }
} }
/** /**
* @param tplFile * @param tplFile
* @return 内存中的template重命名一下 * @return 内存中的template重命名一下
*/ */
private JTemplate<?, ?> getSpecialTemplateByFILE(FILE tplFile) { private JTemplate<?, ?> getSpecialTemplateByFILE(FILE tplFile) {
HistoryTemplateListPane historyHandle = HistoryTemplateListPane.getInstance(); HistoryTemplateListPane historyHandle = HistoryTemplateListPane.getInstance();
if (ComparatorUtils.equals(historyHandle.getCurrentEditingTemplate().getEditingFILE(), tplFile)) { if (ComparatorUtils.equals(historyHandle.getCurrentEditingTemplate().getEditingFILE(), tplFile)) {
return historyHandle.getCurrentEditingTemplate(); return historyHandle.getCurrentEditingTemplate();
@ -573,5 +577,5 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
} }
return null; return null;
} }
} }

143
designer-base/src/main/java/com/fr/design/mainframe/TemplatePane.java

@ -20,6 +20,7 @@ import com.fr.stable.EnvChangedListener;
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 javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -30,37 +31,37 @@ import java.awt.event.MouseListener;
//TODO: august TemplatePane和TemplateTreePane最好合并成一个类 //TODO: august TemplatePane和TemplateTreePane最好合并成一个类
public class TemplatePane extends JPanel implements MouseListener { public class TemplatePane extends JPanel implements MouseListener {
private static final long NUM = 1L; private static final long NUM = 1L;
private static int NUM200 = 200; private static int NUM200 = 200;
public static TemplatePane getInstance() { public static TemplatePane getInstance() {
return HOLDER.singleton; return HOLDER.singleton;
} }
private static class HOLDER { private static class HOLDER {
private static TemplatePane singleton = new TemplatePane(); private static TemplatePane singleton = new TemplatePane();
} }
private static final long serialVersionUID = 2108412478281713143L; private static final long serialVersionUID = 2108412478281713143L;
public static final int HEIGHT = 23;// 最好和日志的高度统一 用同一个变量 public static final int HEIGHT = 23;// 最好和日志的高度统一 用同一个变量
private static javax.swing.Icon leftIcon = BaseUtils.readIcon("/com/fr/design/images/docking/left.png"); private static javax.swing.Icon leftIcon = BaseUtils.readIcon("/com/fr/design/images/docking/left.png");
private static javax.swing.Icon rightIcon = BaseUtils.readIcon("/com/fr/design/images/docking/right.png"); private static javax.swing.Icon rightIcon = BaseUtils.readIcon("/com/fr/design/images/docking/right.png");
private boolean isExpanded = false; private boolean isExpanded = false;
private UIButton editButton; private UIButton editButton;
private UILabel envLabel; private UILabel envLabel;
private TemplatePane() { private TemplatePane() {
super(); super();
this.initComponents(); this.initComponents();
this.setFocusable(true); this.setFocusable(true);
@ -69,24 +70,24 @@ public class TemplatePane extends JPanel implements MouseListener {
TemplateTreePane.getInstance().setVisible(isExpanded); TemplateTreePane.getInstance().setVisible(isExpanded);
TemplateTreePane.getInstance().setVisible(true); TemplateTreePane.getInstance().setVisible(true);
} }
private void initComponents() { private void initComponents() {
GeneralContext.addEnvChangedListener(new EnvChangedListener() { GeneralContext.addEnvChangedListener(new EnvChangedListener() {
public void envChanged() { public void envChanged() {
setJLabel(DesignerEnvManager.getEnvManager().getCurEnvName()); setJLabel(DesignerEnvManager.getEnvManager().getCurEnvName());
} }
}); });
this.setLayout(new BorderLayout(25, 0)); this.setLayout(new BorderLayout(25, 0));
editButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/control/control-center2.png")) { editButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/control/control-center2.png")) {
private static final long serialVersionUID = NUM; private static final long serialVersionUID = NUM;
@Override @Override
public Point getToolTipLocation(MouseEvent event) { public Point getToolTipLocation(MouseEvent event) {
return new Point(25, 2); return new Point(25, 2);
} }
}; };
@ -98,9 +99,9 @@ public class TemplatePane extends JPanel implements MouseListener {
this.add(new UILabel(" "), BorderLayout.WEST); this.add(new UILabel(" "), BorderLayout.WEST);
this.add(editButton, BorderLayout.EAST); this.add(editButton, BorderLayout.EAST);
editButton.addActionListener(new ActionListener() { editButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
editItems(); editItems();
} }
}); });
@ -109,25 +110,25 @@ public class TemplatePane extends JPanel implements MouseListener {
setJLabel(DesignerEnvManager.getEnvManager().getCurEnvName()); setJLabel(DesignerEnvManager.getEnvManager().getCurEnvName());
this.add(envLabel, BorderLayout.CENTER); this.add(envLabel, BorderLayout.CENTER);
} }
/** /**
* 是否可扩展 * 是否可扩展
* *
* @return 同上 * @return 同上
*/ */
public boolean IsExpanded() { public boolean IsExpanded() {
return this.isExpanded; return this.isExpanded;
} }
public void setExpand(boolean b) { public void setExpand(boolean b) {
this.isExpanded = b; this.isExpanded = b;
this.repaint(); this.repaint();
} }
private boolean envListOkAction(EnvListPane envListPane) { private boolean envListOkAction(EnvListPane envListPane) {
final String selectedName = envListPane.updateEnvManager(); final String selectedName = envListPane.updateEnvManager();
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(selectedName); DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(selectedName);
@ -135,13 +136,11 @@ public class TemplatePane extends JPanel implements MouseListener {
try { try {
Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv); Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv);
if (workspace == null) { if (workspace == null) {
JOptionPane.showMessageDialog( JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"FR-Designer_M-SwitchWorkspace", "Failed"}),
DesignerContext.getDesignerFrame(), null, 0, UIManager.getIcon("OptionPane.errorIcon"));
Inter.getLocText(new String[]{"FR-Designer_M-SwitchWorkspace", "Failed"}));
return false; return false;
} }
WorkContext.switchTo(workspace, new WorkContextCallback() { WorkContext.switchTo(workspace, new WorkContextCallback() {
@Override @Override
public void done() { public void done() {
DesignerEnvManager.getEnvManager().setCurEnvName(selectedName); DesignerEnvManager.getEnvManager().setCurEnvName(selectedName);
@ -153,8 +152,8 @@ public class TemplatePane extends JPanel implements MouseListener {
template.refreshToolArea(); template.refreshToolArea();
} }
setJLabel(selectedName); setJLabel(selectedName);
} catch (Exception e) { } catch (AuthException e) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"}), JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"Fine-Designer_Basic_Remote_Connect_Auth_Failed", "Failed"}),
null, 0, UIManager.getIcon("OptionPane.errorIcon")); null, 0, UIManager.getIcon("OptionPane.errorIcon"));
return false; return false;
} }
@ -165,33 +164,33 @@ public class TemplatePane extends JPanel implements MouseListener {
} }
return true; return true;
} }
/** /**
* 编辑items * 编辑items
*/ */
public void editItems() { public void editItems() {
final EnvListPane envListPane = new EnvListPane(); final EnvListPane envListPane = new EnvListPane();
final BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame())); final BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame()));
envListPane.populateEnvManager(envLabel.getText()); envListPane.populateEnvManager(envLabel.getText());
envListDialog.addDialogActionListener(new DialogActionAdapter() { envListDialog.addDialogActionListener(new DialogActionAdapter() {
public void doOk() { public void doOk() {
envListOkAction(envListPane); envListOkAction(envListPane);
} }
public void doCancel() { public void doCancel() {
envListDialog.setVisible(false); envListDialog.setVisible(false);
} }
}); });
envListDialog.setVisible(true); envListDialog.setVisible(true);
} }
private void setJLabel(String name) { private void setJLabel(String name) {
DesignerWorkspaceInfo config = DesignerEnvManager.getEnvManager().getWorkspaceInfo(name); DesignerWorkspaceInfo config = DesignerEnvManager.getEnvManager().getWorkspaceInfo(name);
if (config != null) { if (config != null) {
switch (config.getType()) { switch (config.getType()) {
@ -205,26 +204,26 @@ public class TemplatePane extends JPanel implements MouseListener {
} }
} }
} }
envLabel.setText(name); envLabel.setText(name);
envLabel.repaint(); envLabel.repaint();
} }
@Override @Override
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
return new Dimension(250, HEIGHT); return new Dimension(250, HEIGHT);
} }
@Override @Override
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
super.paintComponent(g); super.paintComponent(g);
paintBackgroundIcon(g); paintBackgroundIcon(g);
} }
private void paintBackgroundIcon(Graphics g) { private void paintBackgroundIcon(Graphics g) {
int w = this.getWidth(); int w = this.getWidth();
int h = this.getHeight(); int h = this.getHeight();
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
@ -239,9 +238,9 @@ public class TemplatePane extends JPanel implements MouseListener {
g2d.drawLine(w - 1, 2, w - 1, h - 1); g2d.drawLine(w - 1, 2, w - 1, h - 1);
Icon icon = !isExpanded ? leftIcon : rightIcon; Icon icon = !isExpanded ? leftIcon : rightIcon;
icon.paintIcon(this, g2d, 4, 4); icon.paintIcon(this, g2d, 4, 4);
} }
/** /**
* 鼠标点击 * 鼠标点击
* *
@ -249,9 +248,9 @@ public class TemplatePane extends JPanel implements MouseListener {
*/ */
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
} }
/** /**
* 鼠标按下 * 鼠标按下
* *
@ -259,7 +258,7 @@ public class TemplatePane extends JPanel implements MouseListener {
*/ */
@Override @Override
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
if (e.getX() < NUM200) { if (e.getX() < NUM200) {
isExpanded = !isExpanded; isExpanded = !isExpanded;
TemplateTreePane.getInstance().setVisible(isExpanded); TemplateTreePane.getInstance().setVisible(isExpanded);
@ -267,7 +266,7 @@ public class TemplatePane extends JPanel implements MouseListener {
DesignerEnvManager.getEnvManager().setTemplateTreePaneExpanded(isExpanded); DesignerEnvManager.getEnvManager().setTemplateTreePaneExpanded(isExpanded);
} }
} }
/** /**
* 鼠标放开 * 鼠标放开
* *
@ -275,9 +274,9 @@ public class TemplatePane extends JPanel implements MouseListener {
*/ */
@Override @Override
public void mouseReleased(MouseEvent e) { public void mouseReleased(MouseEvent e) {
} }
/** /**
* 鼠标进入 * 鼠标进入
* *
@ -285,9 +284,9 @@ public class TemplatePane extends JPanel implements MouseListener {
*/ */
@Override @Override
public void mouseEntered(MouseEvent e) { public void mouseEntered(MouseEvent e) {
} }
/** /**
* 鼠标离开 * 鼠标离开
* *
@ -295,33 +294,33 @@ public class TemplatePane extends JPanel implements MouseListener {
*/ */
@Override @Override
public void mouseExited(MouseEvent e) { public void mouseExited(MouseEvent e) {
} }
/** /**
* 处理异常 * 处理异常
*/ */
public void dealEvnExceptionWhenStartDesigner() { public void dealEvnExceptionWhenStartDesigner() {
final EnvListPane envListPane = new EnvListPane(); final EnvListPane envListPane = new EnvListPane();
envListPane.populateEnvManager(envLabel.getText()); envListPane.populateEnvManager(envLabel.getText());
BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame())); BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame()));
envListDialog.addDialogActionListener(new DialogActionAdapter() { envListDialog.addDialogActionListener(new DialogActionAdapter() {
public void doOk() { public void doOk() {
if (!envListOkAction(envListPane)) { if (!envListOkAction(envListPane)) {
System.exit(0); System.exit(0);
} }
} }
public void doCancel() { public void doCancel() {
System.exit(0); System.exit(0);
} }
}); });
envListDialog.setVisible(true); envListDialog.setVisible(true);
} }
} }

1
designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogAppender.java

@ -1,7 +1,6 @@
package com.fr.design.mainframe.loghandler; package com.fr.design.mainframe.loghandler;
import com.fr.general.FRLogLevel;
import com.fr.third.apache.log4j.AppenderSkeleton; import com.fr.third.apache.log4j.AppenderSkeleton;
import com.fr.third.apache.log4j.Level; import com.fr.third.apache.log4j.Level;
import com.fr.third.apache.log4j.spi.LoggingEvent; import com.fr.third.apache.log4j.spi.LoggingEvent;

84
designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java

@ -1,17 +1,16 @@
package com.fr.design.mainframe.loghandler; package com.fr.design.mainframe.loghandler;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogLevel;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.general.LogRecordTime;
import com.fr.general.log.Log4jConfig; import com.fr.general.log.Log4jConfig;
import com.fr.stable.xml.LogRecordTimeProvider; import com.fr.log.FineLoggerFactory;
import com.fr.third.apache.log4j.Level; import com.fr.third.apache.log4j.Level;
import com.fr.third.apache.log4j.spi.LoggingEvent;
import com.fr.third.apache.log4j.spi.ThrowableInformation;
import javax.swing.*; import javax.swing.*;
import javax.swing.text.BadLocationException; import javax.swing.text.BadLocationException;
@ -29,11 +28,13 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.logging.LogRecord;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
public class DesignerLogHandler { public class DesignerLogHandler {
private static final SimpleDateFormat LOG_SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
protected static final int INFO_INT = Level.INFO.toInt(); protected static final int INFO_INT = Level.INFO.toInt();
protected static final int ERROR_INT = Level.ERROR.toInt(); protected static final int ERROR_INT = Level.ERROR.toInt();
protected static final int WARN_INT = Level.WARN.toInt(); protected static final int WARN_INT = Level.WARN.toInt();
@ -67,7 +68,6 @@ public class DesignerLogHandler {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
logHandlerArea.jTextArea.setText(""); logHandlerArea.jTextArea.setText("");
caption.clearMessage(); caption.clearMessage();
DesignerLogImpl.getInstance().clear();
} }
}); });
caption.addSelectedListener(new ActionListener() { caption.addSelectedListener(new ActionListener() {
@ -84,10 +84,6 @@ public class DesignerLogHandler {
public void itemStateChanged(ItemEvent e) { public void itemStateChanged(ItemEvent e) {
logHandlerArea.jTextArea.setText(""); logHandlerArea.jTextArea.setText("");
caption.clearMessage(); caption.clearMessage();
LogRecordTimeProvider[] recorders = DesignerLogImpl.getInstance().getRecorders();
for (LogRecordTimeProvider logRecordTime : recorders) {
logHandlerArea.printStackTrace(logRecordTime);
}
} }
}; };
showInfo = new JCheckBoxMenuItem(Inter.getLocText(new String[]{"Display", "Normal", "Info"}), true); showInfo = new JCheckBoxMenuItem(Inter.getLocText(new String[]{"Display", "Normal", "Info"}), true);
@ -101,7 +97,7 @@ public class DesignerLogHandler {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
JPopupMenu jPopupMenu = new JPopupMenu(); JPopupMenu jPopupMenu = new JPopupMenu();
int logLevelInt = Log4jConfig.getInstance().getRootLevel().toInt(); int logLevelInt = Log4jConfig.getInstance().getRootLevel().toInt();
if (logLevelInt <= INFO_INT) { if (logLevelInt <= INFO_INT) {
jPopupMenu.add(showInfo); jPopupMenu.add(showInfo);
@ -193,55 +189,52 @@ public class DesignerLogHandler {
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
resultPane.setText(""); resultPane.setText("");
caption.clearMessage(); caption.clearMessage();
DesignerLogImpl.getInstance().clear();
} }
}); });
return resultPane; return resultPane;
} }
public void printStackTrace(LogRecordTimeProvider logRecordTime) { public void printStackTrace(LoggingEvent event) {
LogRecord logRecord = logRecordTime.getLogRecord(); int intLevel = event.getLevel().toInt();
Date date = logRecordTime.getDate(); Date date = new Date(event.getTimeStamp());
int logLevelvalue = logRecord.getLevel().intValue(); ThrowableInformation information = event.getThrowableInformation();
if (logLevelvalue == INFO_INT && showInfo.isSelected()) { if (intLevel == INFO_INT && showInfo.isSelected()) {
printMessage(logRecord.getMessage(), logLevelvalue, date, logRecord.getThrown()); printMessage(event.getRenderedMessage(), intLevel, date, information == null ? null : information.getThrowable());
} else if (logLevelvalue == ERROR_INT && showError.isSelected()) { } else if (intLevel == ERROR_INT && showError.isSelected()) {
printMessage(logRecord.getMessage(), logLevelvalue, date, logRecord.getThrown()); printMessage(event.getRenderedMessage(), intLevel, date, information == null ? null : information.getThrowable());
} else if (logLevelvalue == WARN_INT && showServer.isSelected()) { } else if (intLevel == WARN_INT && showServer.isSelected()) {
printMessage(logRecord.getMessage(), logLevelvalue, date, logRecord.getThrown()); printMessage(event.getRenderedMessage(), intLevel, date, information == null ? null : information.getThrowable());
} }
} }
public void printStackTrace(String message, Level level, Date date) { public void printStackTrace(String message, Level level, Date date) {
int logLevelvalue = level.toInt(); int intLevel = level.toInt();
if (logLevelvalue == INFO_INT && showInfo.isSelected()) { if (intLevel == INFO_INT && showInfo.isSelected()) {
printMessage(message, logLevelvalue, date); printMessage(message, intLevel, date);
} else if (logLevelvalue == ERROR_INT && showError.isSelected()) { } else if (intLevel == ERROR_INT && showError.isSelected()) {
printMessage(message, logLevelvalue, date); printMessage(message, intLevel, date);
} else if (logLevelvalue == WARN_INT && showServer.isSelected()) { } else if (intLevel == WARN_INT && showServer.isSelected()) {
printMessage(message, logLevelvalue, date); printMessage(message, intLevel, date);
} }
} }
private void printMessage(String message, int logLevelvalue, Date date) { private void printMessage(String message, int intLevel, Date date) {
printMessage(message, logLevelvalue, date, null); printMessage(message, intLevel, date, null);
} }
private void printMessage(String messange, int logLevelvalue, Date date, Throwable e) { private void printMessage(String msg, int intLevel, Date date, Throwable e) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.log(LOG_SIMPLE_DATE_FORMAT.format(date) + "\n", 0);
this.log(simpleDateFormat.format(date) + "\n", 0); String message = appendLocaleMark(msg, intLevel);
String message = swithInter(messange, logLevelvalue); this.log(message, intLevel);
this.log(message, logLevelvalue); setMessage(message, intLevel);
setMessage(message, logLevelvalue);
if (e == null) { if (e == null) {
return; return;
} }
StackTraceElement[] stacktraceelement = e.getStackTrace(); StackTraceElement[] traceElements = e.getStackTrace();
for (int i = 0; i < stacktraceelement.length; i++) { for (int i = 0; i < traceElements.length; i++) {
this.log("\t" + "at " + stacktraceelement[i].toString() + "\n", 0); this.log("\t" + "at " + traceElements[i].toString() + "\n", 0);
} }
} }
@ -264,11 +257,11 @@ public class DesignerLogHandler {
try { try {
doc.insertString(doc.getLength(), str, attrSet); doc.insertString(doc.getLength(), str, attrSet);
} catch (BadLocationException e) { } catch (BadLocationException e) {
FRContext.getLogger().error(e.getMessage()); FineLoggerFactory.getLogger().error(e.getMessage());
} }
} }
private String swithInter(String str, int style) { private String appendLocaleMark(String str, int style) {
if (style == ERROR_INT) { if (style == ERROR_INT) {
str = Inter.getLocText("FR-Designer_Alert") + ":" + str + "\n"; str = Inter.getLocText("FR-Designer_Alert") + ":" + str + "\n";
} else if (style == WARN_INT) { } else if (style == WARN_INT) {
@ -318,14 +311,13 @@ public class DesignerLogHandler {
} else if (ComparatorUtils.equals(evt.getActionCommand(), LogHandlerArea.this.clear.getText())) { } else if (ComparatorUtils.equals(evt.getActionCommand(), LogHandlerArea.this.clear.getText())) {
LogHandlerArea.this.jTextArea.setText(""); LogHandlerArea.this.jTextArea.setText("");
caption.clearMessage(); caption.clearMessage();
DesignerLogImpl.getInstance().clear();
} }
} }
}; };
} }
public void printRemoteLog(LogRecordTime logRecordTime) { public void printLoggingEvent(LoggingEvent event) {
logHandlerArea.printStackTrace(logRecordTime); logHandlerArea.printStackTrace(event);
} }
} }

46
designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogImpl.java

@ -1,46 +0,0 @@
package com.fr.design.mainframe.loghandler;
import com.fr.stable.fun.impl.AbstractLogProvider;
import com.fr.stable.xml.LogRecordTimeProvider;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Administrator on 2016/1/11 0011.
*/
public class DesignerLogImpl extends AbstractLogProvider{
private static DesignerLogImpl instance = new DesignerLogImpl();
public static DesignerLogImpl getInstance(){
return instance;
}
private DesignerLogImpl(){
}
private List<LogRecordTimeProvider> records = new ArrayList<LogRecordTimeProvider>();
/**
* 清除内存中的日志记录
*/
public void clear(){
records.clear();
}
/**
* 获取所有日志信息
*
* @return 日志信息
*/
public LogRecordTimeProvider[] getRecorders(){
return records.toArray(new LogRecordTimeProvider[records.size()]);
}
@Override
public void record(LogRecordTimeProvider logRecordTime) {
records.add(logRecordTime);
}
}

12
designer-base/src/main/java/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java

@ -32,7 +32,7 @@ public class RemoteDesignAuthorityManagerAction extends UpdateAction {
final AuthorityManagerPane managerPane = new AuthorityManagerPane(); final AuthorityManagerPane managerPane = new AuthorityManagerPane();
BasicDialog dialog = managerPane.showWindow(DesignerContext.getDesignerFrame()); BasicDialog dialog = managerPane.showWindow(DesignerContext.getDesignerFrame());
if (!WorkContext.getCurrent().isLocal()) { if (!WorkContext.getCurrent().isLocal()) {
try { try {
// 远程设计获取全部设计成员的权限列表 // 远程设计获取全部设计成员的权限列表
@ -44,12 +44,12 @@ public class RemoteDesignAuthorityManagerAction extends UpdateAction {
FineLoggerFactory.getLogger().error(exception.getMessage(), exception); FineLoggerFactory.getLogger().error(exception.getMessage(), exception);
} }
} }
dialog.addDialogActionListener(new DialogActionAdapter() { dialog.addDialogActionListener(new DialogActionAdapter() {
@Override @Override
public void doOk() { public void doOk() {
DesignAuthority[] authorities = managerPane.update(); DesignAuthority[] authorities = managerPane.update();
if (!WorkContext.getCurrent().isLocal()) { if (!WorkContext.getCurrent().isLocal()) {
boolean success = false; boolean success = false;
@ -61,10 +61,10 @@ public class RemoteDesignAuthorityManagerAction extends UpdateAction {
FineLoggerFactory.getLogger().info("update remote design authority: " + success); FineLoggerFactory.getLogger().info("update remote design authority: " + success);
} }
} }
@Override @Override
public void doCancel() { public void doCancel() {
super.doCancel(); super.doCancel();
} }
}); });

2
designer-base/src/main/java/com/fr/design/remote/ui/AuthorityListControlPane.java

@ -18,12 +18,12 @@ import com.fr.design.remote.RemoteDesignAuthorityCreator;
import com.fr.design.remote.ui.list.AuthorityList; import com.fr.design.remote.ui.list.AuthorityList;
import com.fr.design.remote.ui.list.AuthorityListCellRenderer; import com.fr.design.remote.ui.list.AuthorityListCellRenderer;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.workspace.server.authority.RemoteDesignMember;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.report.DesignAuthority; import com.fr.report.DesignAuthority;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.workspace.server.authority.RemoteDesignMember;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.DefaultListModel; import javax.swing.DefaultListModel;

4
designer-base/src/main/java/com/fr/design/remote/ui/UserManagerPane.java

@ -13,12 +13,12 @@ import com.fr.design.remote.ui.list.AddedMemberListCellRender;
import com.fr.design.remote.ui.list.AddingMemberList; import com.fr.design.remote.ui.list.AddingMemberList;
import com.fr.design.remote.ui.list.AddingMemberListCellRender; import com.fr.design.remote.ui.list.AddingMemberListCellRender;
import com.fr.design.remote.ui.list.MemberListSelectedChangeListener; import com.fr.design.remote.ui.list.MemberListSelectedChangeListener;
import com.fr.workspace.server.authority.RemoteDesignMember;
import com.fr.workspace.server.authority.decision.DecisionOperator;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.third.guava.collect.ImmutableList; import com.fr.third.guava.collect.ImmutableList;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.server.authority.RemoteDesignMember;
import com.fr.workspace.server.authority.decision.DecisionOperator;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.DefaultListModel; import javax.swing.DefaultListModel;

24
designer-base/src/main/java/com/fr/file/FileFILE.java

@ -1,23 +1,22 @@
package com.fr.file; package com.fr.file;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import javax.swing.Icon;
import javax.swing.filechooser.FileSystemView;
import com.fr.base.io.XMLEncryptUtils; import com.fr.base.io.XMLEncryptUtils;
import com.fr.design.gui.itree.filetree.FileComparator; import com.fr.design.gui.itree.filetree.FileComparator;
import com.fr.design.gui.itree.filetree.FileTreeIcon; import com.fr.design.gui.itree.filetree.FileTreeIcon;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogManager; import com.fr.general.SessionLocalManager;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import javax.swing.*;
import javax.swing.filechooser.FileSystemView;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
public class FileFILE implements FILE { public class FileFILE implements FILE {
private File file; private File file;
@ -199,12 +198,11 @@ public class FileFILE implements FILE {
if (file == null || !file.exists()) { if (file == null || !file.exists()) {
return null; return null;
} }
FRLogManager.declareResourceWriteStart(file.getAbsolutePath());
java.io.OutputStream out = null; java.io.OutputStream out = null;
try { try {
out = new FileOutputStream(file); out = new FileOutputStream(file);
} catch (Exception e) { } catch (Exception e) {
throw FRLogManager.createLogPackedException(e); throw SessionLocalManager.createLogPackedException(e);
} }
return out; return out;
} }

9
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartFillStylePane.java

@ -1,10 +1,11 @@
package com.fr.design.mainframe.chart.gui.style; package com.fr.design.mainframe.chart.gui.style;
import com.fr.base.ChartColorMatching;
import com.fr.base.ChartPreStyleConfig; import com.fr.base.ChartPreStyleConfig;
import com.fr.base.Utils; import com.fr.base.Utils;
import com.fr.chart.base.AttrFillStyle; import com.fr.chart.base.AttrFillStyle;
import com.fr.chart.base.ChartConstants; import com.fr.chart.base.ChartConstants;
import com.fr.chart.base.ChartPreStyle; import com.fr.chart.base.ChartUtils;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
@ -199,9 +200,9 @@ public class ChartFillStylePane extends BasicBeanPane<AttrFillStyle>{
} else if(styleSelectBox.getSelectedIndex() < styleSelectBox.getItemCount() - 1){ } else if(styleSelectBox.getSelectedIndex() < styleSelectBox.getItemCount() - 1){
ChartPreStyleConfig manager = ChartPreStyleConfig.getInstance(); ChartPreStyleConfig manager = ChartPreStyleConfig.getInstance();
Object preStyle = manager.getPreStyle(styleSelectBox.getSelectedItem()); Object preStyle = manager.getPreStyle(styleSelectBox.getSelectedItem());
if(preStyle instanceof ChartPreStyle) { if (preStyle instanceof ChartColorMatching) {
AttrFillStyle def = ((ChartPreStyle) preStyle).getAttrFillStyle(); AttrFillStyle def = ChartUtils.chartColorMatching2AttrFillStyle((ChartColorMatching) preStyle);
def.setFillStyleName(Utils.objectToString(styleSelectBox.getSelectedItem())); def.setFillStyleName(Utils.objectToString(styleSelectBox.getSelectedItem()));
return def; return def;
}else{ }else{
condition.setColorStyle(ChartConstants.COLOR_DEFAULT); condition.setColorStyle(ChartConstants.COLOR_DEFAULT);

97
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartPreFillStylePane.java

@ -1,97 +0,0 @@
package com.fr.design.mainframe.chart.gui.style;
import java.awt.*;
import com.fr.chart.base.AttrFillStyle;
import com.fr.chart.base.ChartConstants;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.general.Inter;
/**
* 预定义的图表配色界面, 其中和属性表中ChartFillStylePane 主要的不同就是标签的位置.
* @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2013-8-21 下午03:16:27
*/
public class ChartPreFillStylePane extends ChartFillStylePane {
public ChartPreFillStylePane() {
}
protected void initLayout() {// 仅仅是服务器预定 风格界面布局, 和属性表 有所不同.
customPane.setPreferredSize(new Dimension(200, 200));
colorGradient.setPreferredSize(new Dimension(120, 30));
double p = TableLayout.PREFERRED;
double[] columnSize = {p, p };
double[] rowSize = { p, p, p};
Component[][] components = new Component[][]{
new Component[]{new UILabel(" " + Inter.getLocText("ColorMatch")), null},
new Component[]{null, customPane},
};
this.add(TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize), BorderLayout.WEST);
}
public void populateBean(AttrFillStyle condition) {
styleSelectBox.setSelectedIndex(styleSelectBox.getItemCount()-1);
if(condition == null || condition.getColorStyle() == ChartConstants.COLOR_DEFAULT) {
colorAcc.populateBean(ChartConstants.CHART_COLOR_ARRAY);// 新建时 保持默认样式
accButton.setSelected(true);
gradientButton.setSelected(false);
cardLayout.show(changeColorSetPane, "acc");
colorGradient.getSelectColorPointBtnP1().setColorInner(Color.WHITE);
colorGradient.getSelectColorPointBtnP2().setColorInner(Color.black);// 控件中的位置无效.
} else {
int colorStyle = condition.getColorStyle();
gradientButton.setSelected(colorStyle == ChartConstants.COLOR_GRADIENT);
accButton.setSelected(colorStyle == ChartConstants.COLOR_ACC);
int colorSize = condition.getColorSize();
if(colorSize == 2 && gradientButton.isSelected() ) {
cardLayout.show(changeColorSetPane, "gradient");
Color endColor = condition.getColorIndex(1);
Color startColor = condition.getColorIndex(0);
colorGradient.getSelectColorPointBtnP1().setColorInner(startColor);
colorGradient.getSelectColorPointBtnP2().setColorInner(endColor);
colorGradient.repaint();
} else if(colorSize > 2 && accButton.isSelected()){
cardLayout.show(changeColorSetPane, "acc");
Color[] colors = new Color[colorSize];
for(int i = 0; i < colorSize; i++) {
colors[i] = condition.getColorIndex(i);
}
colorAcc.populateBean(colors);
}
}
}
@Override
public AttrFillStyle updateBean() {
AttrFillStyle condition = new AttrFillStyle();
condition.clearColors();
if(gradientButton.isSelected()) {
condition.setColorStyle(ChartConstants.COLOR_GRADIENT);
Color start = colorGradient.getSelectColorPointBtnP1().getColorInner();
Color end = colorGradient.getSelectColorPointBtnP2().getColorInner();
condition.addFillColor(start);
condition.addFillColor(end);
} else {
condition.setColorStyle(ChartConstants.COLOR_ACC);
Color[] colors = colorAcc.updateBean();
for(int i = 0, length = colors.length; i < length; i++) {
condition.addFillColor(colors[i]);
}
}
return condition;
}
}

5
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java

@ -1,12 +1,13 @@
package com.fr.design.mainframe.chart.gui.type; package com.fr.design.mainframe.chart.gui.type;
import com.fr.base.ChartColorMatching;
import com.fr.base.ChartPreStyleConfig; import com.fr.base.ChartPreStyleConfig;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.background.ColorBackground; import com.fr.base.background.ColorBackground;
import com.fr.chart.base.AttrContents; import com.fr.chart.base.AttrContents;
import com.fr.chart.base.AttrFillStyle; import com.fr.chart.base.AttrFillStyle;
import com.fr.chart.base.ChartConstants; import com.fr.chart.base.ChartConstants;
import com.fr.chart.base.ChartPreStyle; import com.fr.chart.base.ChartUtils;
import com.fr.chart.base.DataSeriesCondition; import com.fr.chart.base.DataSeriesCondition;
import com.fr.chart.base.TextAttr; import com.fr.chart.base.TextAttr;
import com.fr.chart.chartattr.Axis; import com.fr.chart.chartattr.Axis;
@ -243,7 +244,7 @@ public abstract class AbstractChartTypePane extends FurtherBasicBeanPane<Chart>{
if(preStyle == null){ if(preStyle == null){
plot.getPlotFillStyle().setColorStyle(ChartConstants.COLOR_DEFAULT); plot.getPlotFillStyle().setColorStyle(ChartConstants.COLOR_DEFAULT);
}else{ }else{
AttrFillStyle fillStyle = ((ChartPreStyle)preStyle).getAttrFillStyle(); AttrFillStyle fillStyle = ChartUtils.chartColorMatching2AttrFillStyle((ChartColorMatching) preStyle);
fillStyle.setFillStyleName(name); fillStyle.setFillStyleName(name);
plot.setPlotFillStyle(fillStyle); plot.setPlotFillStyle(fillStyle);
} }

165
designer-chart/src/main/java/com/fr/design/module/ChartPreFillStylePane.java

@ -0,0 +1,165 @@
package com.fr.design.module;
import com.fr.base.ChartColorMatching;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.style.ChartAccColorPane;
import com.fr.design.style.background.gradient.FixedGradientBar;
import com.fr.general.Inter;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
/**
* 预定义的图表配色界面.
* @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2013-8-21 下午03:16:27
*/
public class ChartPreFillStylePane extends BasicBeanPane<ChartColorMatching> {
private JPanel changeColorSetPane;
private CardLayout cardLayout;
private UIButton accButton;
private UIButton gradientButton;
private ChartAccColorPane colorAcc;
private FixedGradientBar colorGradient;
public ChartPreFillStylePane() {
initComponents();
initListener();
}
private void initComponents() {
JPanel customPane = new JPanel(FRGUIPaneFactory.createBorderLayout());
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new FlowLayout(FlowLayout.LEFT));
buttonPane.add(accButton = new UIButton(Inter.getLocText("FR-Designer_Chart_Acc_Set")));
buttonPane.add(gradientButton = new UIButton(Inter.getLocText("FR-Designer_Gradient-Color")));
customPane.add(buttonPane, BorderLayout.NORTH);
changeColorSetPane = new JPanel(cardLayout = new CardLayout());
changeColorSetPane.add(colorGradient = new FixedGradientBar(4, 130), "gradient");
changeColorSetPane.add(colorAcc = new ChartAccColorPane(), "acc");
cardLayout.show(changeColorSetPane, "acc");
customPane.add(changeColorSetPane, BorderLayout.CENTER);
accButton.setSelected(true);
customPane.setPreferredSize(new Dimension(200, 200));
colorGradient.setPreferredSize(new Dimension(120, 30));
colorGradient.getSelectColorPointBtnP1().setColorInner(Color.WHITE);
colorGradient.getSelectColorPointBtnP2().setColorInner(Color.black);
double p = TableLayout.PREFERRED;
double[] columnSize = {p, p};
double[] rowSize = {p, p, p};
Component[][] components = new Component[][]{
new Component[]{new UILabel(" " + Inter.getLocText("ColorMatch")), null},
new Component[]{null, customPane},
};
this.setLayout(new BorderLayout());
this.add(TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize), BorderLayout.WEST);
}
private void initListener() {
accButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
accButton.setSelected(true);
gradientButton.setSelected(false);
cardLayout.show(changeColorSetPane, "acc");
}
});
gradientButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gradientButton.setSelected(true);
accButton.setSelected(false);
cardLayout.show(changeColorSetPane, "gradient");
}
});
}
@Override
protected String title4PopupWindow() {
return Inter.getLocText("ServerM-Predefined_Styles");
}
public void populateBean(ChartColorMatching condition) {
if (condition == null) {
return;
}
boolean isGradient = condition.getGradient();
List<Color> colorList = condition.getColorList();
if (isGradient) {
gradientButton.setSelected(true);
accButton.setSelected(false);
cardLayout.show(changeColorSetPane, "gradient");
if (colorList.size() == 2) {
colorGradient.getSelectColorPointBtnP1().setColorInner(colorList.get(0));
colorGradient.getSelectColorPointBtnP2().setColorInner(colorList.get(1));
colorGradient.repaint();
}
} else {
accButton.setSelected(true);
gradientButton.setSelected(false);
cardLayout.show(changeColorSetPane, "acc");
if (colorList.size() > 0) {
colorAcc.populateBean(colorList.toArray(new Color[colorList.size()]));
}
}
}
@Override
public ChartColorMatching updateBean() {
ChartColorMatching chartColorMatching = new ChartColorMatching();
List<Color> colorList = new ArrayList<Color>();
if(gradientButton.isSelected()) {
chartColorMatching.setGradient(true);
Color start = colorGradient.getSelectColorPointBtnP1().getColorInner();
Color end = colorGradient.getSelectColorPointBtnP2().getColorInner();
colorList.add(start);
colorList.add(end);
} else {
chartColorMatching.setGradient(false);
Color[] colors = colorAcc.updateBean();
for(Color color : colors) {
colorList.add(color);
}
}
chartColorMatching.setColorList(colorList);
return chartColorMatching;
}
}

4
designer-chart/src/main/java/com/fr/design/module/ChartPreStyleAction.java

@ -39,14 +39,10 @@ public class ChartPreStyleAction extends UpdateAction {
@Override @Override
public void doOk() { public void doOk() {
pane.updateBean(); pane.updateBean();
// ChartPreStyleManagerProvider manager = ChartPreStyleServerManager.getProviderInstance();
// manager.setStyleEditing(null);
} }
@Override @Override
public void doCancel() { public void doCancel() {
// ChartPreStyleManagerProvider manager = ChartPreStyleServerManager.getProviderInstance();
// manager.setStyleEditing(null);
} }
}); });

52
designer-chart/src/main/java/com/fr/design/module/ChartPreStyleManagerPane.java

@ -1,8 +1,9 @@
package com.fr.design.module; package com.fr.design.module;
import com.fr.base.ChartColorMatching;
import com.fr.base.ChartPreStyleConfig; import com.fr.base.ChartPreStyleConfig;
import com.fr.base.Utils; import com.fr.base.Utils;
import com.fr.chart.base.ChartPreStyle; import com.fr.config.Configuration;
import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.JListControlPane;
import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameObjectCreator;
import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.NameableCreator;
@ -10,8 +11,9 @@ import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame; import com.fr.design.mainframe.DesignerFrame;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.general.NameObject; import com.fr.general.NameObject;
import com.fr.stable.ListMap;
import com.fr.stable.Nameable; import com.fr.stable.Nameable;
import com.fr.transaction.Configurations;
import com.fr.transaction.Worker;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
@ -32,7 +34,7 @@ public class ChartPreStyleManagerPane extends JListControlPane {
public NameableCreator[] createNameableCreators() { public NameableCreator[] createNameableCreators() {
return new NameableCreator[]{ return new NameableCreator[]{
new NameObjectCreator(Inter.getLocText("FR-Designer_PreStyle"), new NameObjectCreator(Inter.getLocText("FR-Designer_PreStyle"),
ChartPreStyle.class, ChartPreStylePane.class) ChartColorMatching.class, ChartPreStylePane.class)
}; };
} }
@ -42,15 +44,14 @@ public class ChartPreStyleManagerPane extends JListControlPane {
} }
public void populateBean() { public void populateBean() {
ChartPreStyleConfig config = ChartPreStyleConfig.getInstance(); ChartPreStyleConfig config = ChartPreStyleConfig.getInstance().mirror();
ArrayList list = new ArrayList(); ArrayList list = new ArrayList();
Iterator keys = config.names(); Iterator keys = config.names();
while(keys.hasNext()) { while(keys.hasNext()) {
Object key = keys.next(); Object key = keys.next();
ChartPreStyle value = (ChartPreStyle)config.getPreStyle(key); ChartColorMatching value = (ChartColorMatching) config.getPreStyle(key);
list.add(new NameObject(Utils.objectToString(key), value)); list.add(new NameObject(Utils.objectToString(key), value));
} }
@ -63,24 +64,33 @@ public class ChartPreStyleManagerPane extends JListControlPane {
} }
public void updateBean() { public void updateBean() {
ChartPreStyleConfig config = ChartPreStyleConfig.getInstance(); Configurations.update(new Worker() {
@Override
public void run() {
ChartPreStyleConfig config = ChartPreStyleConfig.getInstance();
config.setPreStyleMap(new ListMap()); config.setCurrentStyle(getSelectedName());
Nameable[] values = this.update(); Nameable[] values = update();
config.clearAllPreStyle();
config.setCurrentStyle(getSelectedName()); for(Nameable value : values) {
config.putPreStyle(value.getName(), ((NameObject) value).getObject());
for(int i = 0; i < values.length; i++) { }
Nameable value = values[i];
config.putPreStyle(value.getName(), ((NameObject)value).getObject()); // 通知报表整个刷新.
} DesignerFrame frame = DesignerContext.getDesignerFrame();
if(frame != null) {
frame.repaint();
}
}
@Override
public Class<? extends Configuration>[] targets() {
return new Class[]{ChartPreStyleConfig.class};
}
});
// 通知报表整个刷新.
DesignerFrame frame = DesignerContext.getDesignerFrame();
if(frame != null) {
frame.repaint();
}
} }
} }

29
designer-chart/src/main/java/com/fr/design/module/ChartPreStylePane.java

@ -1,16 +1,17 @@
package com.fr.design.module; package com.fr.design.module;
import com.fr.chart.base.ChartPreStyle; import com.fr.base.ChartColorMatching;
import com.fr.chart.base.ChartUtils;
import com.fr.chart.chartattr.Bar2DPlot; import com.fr.chart.chartattr.Bar2DPlot;
import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.Plot;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.chart.gui.ChartComponent; import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener; import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.ilable.BoldFontTextLabel; import com.fr.design.gui.ilable.BoldFontTextLabel;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.chart.gui.style.ChartPreFillStylePane;
import com.fr.general.Inter; import com.fr.general.Inter;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -25,8 +26,8 @@ import java.awt.FlowLayout;
* @author kunsnat E-mail:kunsnat@gmail.com * @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2013-8-20 下午05:02:00 * @version 创建时间2013-8-20 下午05:02:00
*/ */
public class ChartPreStylePane extends BasicBeanPane<ChartPreStyle>{ public class ChartPreStylePane extends BasicBeanPane<ChartColorMatching> {
private ChartPreFillStylePane fillStylePane; private ChartPreFillStylePane fillStylePane;
private ChartComponent chartComponent; private ChartComponent chartComponent;
@ -78,28 +79,26 @@ public class ChartPreStylePane extends BasicBeanPane<ChartPreStyle>{
} }
} }
} }
private void refreshWhenStyleChange(ChartPreStyle preStyle) { private void refreshWhenStyleChange(ChartColorMatching preStyle) {
// ChartPreStyleManagerProvider manager = ChartPreStyleServerManager.getProviderInstance();
// manager.setStyleEditing(preStyle);
if(chartComponent != null) { if(chartComponent != null) {
Plot plot = (Plot) chartComponent.getEditingChart().getBasePlot();
plot.setPlotFillStyle(ChartUtils.chartColorMatching2AttrFillStyle(preStyle));
chartComponent.reset(); chartComponent.reset();
} }
} }
@Override @Override
public void populateBean(ChartPreStyle preStyle) { public void populateBean(ChartColorMatching preStyle) {
fillStylePane.populateBean(preStyle);
fillStylePane.populateBean(preStyle.getAttrFillStyle());
refreshWhenStyleChange(preStyle); refreshWhenStyleChange(preStyle);
} }
@Override @Override
public ChartPreStyle updateBean() { public ChartColorMatching updateBean() {
ChartPreStyle preStyle = new ChartPreStyle(); return fillStylePane.updateBean();
preStyle.setAttrFillStyle(fillStylePane.updateBean());
return preStyle;
} }
@Override @Override

16
designer-realize/src/main/java/com/fr/design/actions/report/ReportWebAttrAction.java

@ -3,7 +3,6 @@
*/ */
package com.fr.design.actions.report; package com.fr.design.actions.report;
import com.fr.config.Configuration;
import com.fr.design.actions.JWorkBookAction; import com.fr.design.actions.JWorkBookAction;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
@ -13,8 +12,9 @@ import com.fr.design.menu.KeySetUtils;
import com.fr.design.webattr.ReportWebAttrPane; import com.fr.design.webattr.ReportWebAttrPane;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.main.TemplateWorkBook; import com.fr.main.TemplateWorkBook;
import com.fr.transaction.CallBackAdaptor;
import com.fr.transaction.Configurations; import com.fr.transaction.Configurations;
import com.fr.transaction.Worker; import com.fr.transaction.WorkerFacade;
import com.fr.web.attr.ReportWebAttr; import com.fr.web.attr.ReportWebAttr;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
@ -56,19 +56,17 @@ public class ReportWebAttrAction extends JWorkBookAction {
dialog.addDialogActionListener(new DialogActionAdapter() { dialog.addDialogActionListener(new DialogActionAdapter() {
@Override @Override
public void doOk() { public void doOk() {
Configurations.update(new Worker() { Configurations.modify(new WorkerFacade(ReportWebAttr.class) {
@Override @Override
public void run() { public void run() {
wbTpl.setReportWebAttr(reportWebAttrPane.update()); wbTpl.setReportWebAttr(reportWebAttrPane.update());
jwb.fireTargetModified();
} }
}.addCallBack(new CallBackAdaptor() {
@Override @Override
public Class<? extends Configuration>[] targets() { public void afterCommit() {
return new Class[]{ReportWebAttr.class}; jwb.fireTargetModified();
} }
}); }));
} }
}); });

20
designer-realize/src/main/java/com/fr/design/actions/server/WidgetManagerAction.java

@ -1,7 +1,6 @@
package com.fr.design.actions.server; package com.fr.design.actions.server;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.config.Configuration;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
@ -12,10 +11,11 @@ import com.fr.design.menu.MenuKeySet;
import com.fr.design.webattr.WidgetManagerPane; import com.fr.design.webattr.WidgetManagerPane;
import com.fr.form.ui.WidgetInfoConfig; import com.fr.form.ui.WidgetInfoConfig;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.transaction.CallBackAdaptor;
import com.fr.transaction.Configurations; import com.fr.transaction.Configurations;
import com.fr.transaction.Worker; import com.fr.transaction.WorkerFacade;
import javax.swing.*; import javax.swing.KeyStroke;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
public class WidgetManagerAction extends UpdateAction { public class WidgetManagerAction extends UpdateAction {
@ -45,22 +45,22 @@ public class WidgetManagerAction extends UpdateAction {
BasicDialog widgetConfigDialog = widgetManagerPane.showLargeWindow(designerFrame, new DialogActionAdapter() { BasicDialog widgetConfigDialog = widgetManagerPane.showLargeWindow(designerFrame, new DialogActionAdapter() {
@Override @Override
public void doOk() { public void doOk() {
Configurations.update(new Worker() {
Configurations.modify(new WorkerFacade(WidgetInfoConfig.class) {
@Override @Override
public void run() { public void run() {
widgetManagerPane.update(widgetManager); widgetManagerPane.update(widgetManager);
}
}.addCallBack(new CallBackAdaptor() {
@Override
public void afterCommit() {
DesignModelAdapter model = DesignModelAdapter.getCurrentModelAdapter(); DesignModelAdapter model = DesignModelAdapter.getCurrentModelAdapter();
if (model != null) { if (model != null) {
model.widgetConfigChanged(); model.widgetConfigChanged();
} }
designerFrame.getSelectedJTemplate().refreshToolArea(); designerFrame.getSelectedJTemplate().refreshToolArea();
} }
}));
@Override
public Class<? extends Configuration>[] targets() {
return new Class[]{WidgetInfoConfig.class};
}
});
} }
}); });

3
designer-realize/src/main/java/com/fr/design/dscolumn/SelectedDataColumnPane.java

@ -88,6 +88,7 @@ public class SelectedDataColumnPane extends BasicPane {
private static final Pattern COLUMN_NAME_PATTERN = Pattern.compile("[^\\d]"); private static final Pattern COLUMN_NAME_PATTERN = Pattern.compile("[^\\d]");
/** /**
* 数据集下拉框变动后修改数据列下拉框加载状态的监听器 * 数据集下拉框变动后修改数据列下拉框加载状态的监听器
*/ */
@ -236,6 +237,8 @@ public class SelectedDataColumnPane extends BasicPane {
ps = dsColumn.getParameters(); ps = dsColumn.getParameters();
addListener(); addListener();
//重新设置需要加载
columnNameComboBox.setLoaded(false);
} }
/** /**

4
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/FileModel.java

@ -22,8 +22,8 @@ public class FileModel extends AlphaCellModel {
public FileModel(String name, String filePath) { public FileModel(String name, String filePath) {
super(name, null, CellType.FILE); super(name, null, CellType.FILE);
this.filePath = filePath; this.filePath = filePath.replaceAll("\\\\", "/");
setDescription(AlphaFineHelper.findFolderName(filePath)); setDescription(AlphaFineHelper.findFolderName(this.filePath));
} }
public String getFilePath() { public String getFilePath() {

14
designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java

@ -4,19 +4,19 @@ import com.fr.base.io.IOFile;
import com.fr.base.io.XMLReadHelper; import com.fr.base.io.XMLReadHelper;
import com.fr.config.MarketConfig; import com.fr.config.MarketConfig;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.general.FRLogManager; import com.fr.general.SessionLocalManager;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.general.LogDuration;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import com.fr.stable.web.SessionProvider;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import com.fr.third.apache.log4j.AppenderSkeleton; import com.fr.third.apache.log4j.AppenderSkeleton;
import com.fr.third.apache.log4j.Level; import com.fr.third.apache.log4j.Level;
import com.fr.third.apache.log4j.spi.LoggingEvent; import com.fr.third.apache.log4j.spi.LoggingEvent;
import com.fr.web.core.SessionDealWith; import com.fr.web.core.SessionPoolManager;
import com.fr.web.core.SessionIDInfor; import com.fr.web.core.TemplateSessionIDInfo;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@ -96,18 +96,18 @@ public class ErrorInfoLogAppender extends AppenderSkeleton {
} }
private String readTemplateID() { private String readTemplateID() {
LogDuration logDuration = FRLogManager.getSession(); SessionProvider logDuration = SessionLocalManager.getSession();
if (logDuration == null) { if (logDuration == null) {
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }
String sessionID = logDuration.getSessionID(); String sessionID = logDuration.getSessionID();
SessionIDInfor infor = SessionDealWith.getSessionIDInfor(sessionID); TemplateSessionIDInfo infor = SessionPoolManager.getSessionIDInfor(sessionID, TemplateSessionIDInfo.class);
if (infor == null) { if (infor == null) {
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }
String bookPath = infor.getBookPath(); String bookPath = infor.getRelativePath();
// 这个iofile只读一个templateid, 其他以后有需要再读. // 这个iofile只读一个templateid, 其他以后有需要再读.
IOFile file = new IOFile() { IOFile file = new IOFile() {
@Override @Override

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

@ -4,48 +4,55 @@ import com.fr.config.RemoteConfigEvent;
import com.fr.decision.webservice.utils.DecisionServiceConstants; import com.fr.decision.webservice.utils.DecisionServiceConstants;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.loghandler.DesignerLogHandler; import com.fr.design.mainframe.loghandler.DesignerLogHandler;
import com.fr.workspace.server.socket.SocketInfoOperator;
import com.fr.event.EventDispatcher; import com.fr.event.EventDispatcher;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.general.LogRecordTime;
import com.fr.general.LogUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.serialization.SerializerHelper;
import com.fr.stable.ArrayUtils;
import com.fr.third.apache.log4j.spi.LoggingEvent;
import com.fr.third.guava.base.Optional; import com.fr.third.guava.base.Optional;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace; import com.fr.workspace.Workspace;
import com.fr.workspace.base.WorkspaceConstants; import com.fr.workspace.base.WorkspaceConstants;
import com.fr.workspace.engine.server.rpc.netty.RemoteCallClient; import com.fr.workspace.engine.server.rpc.netty.RemoteCallClient;
import com.fr.workspace.server.socket.SocketInfoOperator;
import io.socket.client.IO; import io.socket.client.IO;
import io.socket.client.Socket; import io.socket.client.Socket;
import io.socket.emitter.Emitter; import io.socket.emitter.Emitter;
import javax.swing.JOptionPane; import javax.swing.*;
import javax.swing.UIManager;
import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.net.URL; import java.net.URL;
public class DesignerSocketIO { public class DesignerSocketIO {
enum Status {
Connected,
Disconnected,
Disconnecting
}
private static Optional<Socket> socketIO = Optional.absent(); private static Optional<Socket> socketIO = Optional.absent();
public static Status status = Status.Disconnected;
private static final Emitter.Listener printLog = new Emitter.Listener() { private static final Emitter.Listener printLog = new Emitter.Listener() {
@Override @Override
public void call(Object... objects) { public void call(Object... objects) {
try { if (ArrayUtils.isNotEmpty(objects)) {
LogRecordTime[] logRecordTimes = LogUtils.readXMLLogRecords(new ByteArrayInputStream((byte[]) objects[0])); try {
for (LogRecordTime logRecordTime : logRecordTimes) { LoggingEvent event = SerializerHelper.deserialize((byte[]) objects[0]);
DesignerLogHandler.getInstance().printRemoteLog(logRecordTime); DesignerLogHandler.getInstance().printLoggingEvent(event);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
} }
}; };
public static void close() { public static void close() {
if (socketIO.isPresent()) { if (socketIO.isPresent()) {
status = Status.Disconnecting;
socketIO.get().close(); socketIO.get().close();
socketIO = Optional.absent(); socketIO = Optional.absent();
} }
@ -71,11 +78,15 @@ public class DesignerSocketIO {
socketIO.get().on(Socket.EVENT_DISCONNECT, new Emitter.Listener() { socketIO.get().on(Socket.EVENT_DISCONNECT, new Emitter.Listener() {
@Override @Override
public void call(Object... objects) { public void call(Object... objects) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"Fine-Designer_Basic_Remote_Disconnected"}), if (status != Status.Disconnecting) {
null, 0, UIManager.getIcon("OptionPane.errorIcon")); JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"Fine-Designer_Basic_Remote_Disconnected"}),
null, 0, UIManager.getIcon("OptionPane.errorIcon"));
}
status = Status.Disconnected;
} }
}); });
socketIO.get().connect(); socketIO.get().connect();
status = Status.Connected;
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
@ -92,4 +103,4 @@ public class DesignerSocketIO {
DecisionServiceConstants.WEB_SOCKET_TOKEN_NAME, DecisionServiceConstants.WEB_SOCKET_TOKEN_NAME,
RemoteCallClient.getInstance().getToken()); RemoteCallClient.getInstance().getToken());
} }
} }

2
designer-realize/src/main/java/com/fr/design/webattr/WebCssPane.java

@ -85,7 +85,7 @@ public class WebCssPane extends BasicPane {
if (!"css".equalsIgnoreCase(fileType)) { if (!"css".equalsIgnoreCase(fileType)) {
return; return;
} }
localText.setText(file.getPath().substring(1)); localText.setText(file.getPath());
centerPane.setAddEnabled(true); centerPane.setAddEnabled(true);
} }

2
designer-realize/src/main/java/com/fr/design/webattr/WebJsPane.java

@ -173,7 +173,7 @@ public class WebJsPane extends BasicPane {
if (!"js".equalsIgnoreCase(fileType)) { if (!"js".equalsIgnoreCase(fileType)) {
return; return;
} }
localText.setText(file.getPath().substring(1)); localText.setText(file.getPath());
editingPane.setAddEnabled(true); editingPane.setAddEnabled(true);
} }

2
designer-realize/src/main/java/com/fr/design/webattr/WriteToolBarPane.java

@ -41,7 +41,7 @@ public class WriteToolBarPane extends AbstractEditToolBarPane {
private DragToolBarPane dragToolbarPane; private DragToolBarPane dragToolbarPane;
private UIRadioButton topRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer_Top")); private UIRadioButton topRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer_Top"));
private UIRadioButton bottomRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer_Bottom")); private UIRadioButton bottomRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer_Bottom"));
private UILabel sheetShowLocationLabel = new UILabel("sheet" + Inter.getLocText(new String[]{"Label", "Page_Number", "Display position"}) + ":"); private UILabel sheetShowLocationLabel = new UILabel(Inter.getLocText("Fine-Designer_Sheet_Label_Page_Display_Position"));
private UIRadioButton centerRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer_Center_Display")); private UIRadioButton centerRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer_Center_Display"));
private UIRadioButton leftRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer_Left_Display")); private UIRadioButton leftRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer_Left_Display"));
private UILabel rptShowLocationLabel = new UILabel(Inter.getLocText("FR-Designer_Report_Show_Location") + ":", UILabel.LEFT); private UILabel rptShowLocationLabel = new UILabel(Inter.getLocText("FR-Designer_Report_Show_Location") + ":", UILabel.LEFT);

2
designer-realize/src/main/java/com/fr/design/webattr/WriteWebSettingPane.java

@ -56,7 +56,7 @@ public class WriteWebSettingPane extends WebSettingPane<WebWrite> {
//sheet标签页显示位置 //sheet标签页显示位置
topRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer_Top")); topRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer_Top"));
bottomRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer_Bottom")); bottomRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer_Bottom"));
sheetShowLocationLabel = new UILabel("sheet" + Inter.getLocText(new String[]{"Label", "Page_Number", "Display position"}) + ":", UILabel.LEFT); sheetShowLocationLabel = new UILabel(Inter.getLocText("Fine-Designer_Sheet_Label_Page_Display_Position"), UILabel.LEFT);
ButtonGroup buttonGroup = new ButtonGroup(); ButtonGroup buttonGroup = new ButtonGroup();
bottomRadioButton.setSelected(true); bottomRadioButton.setSelected(true);
buttonGroup.add(topRadioButton); buttonGroup.add(topRadioButton);

21
designer-realize/src/main/java/com/fr/start/Designer.java

@ -42,12 +42,12 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.module.Module; import com.fr.module.Module;
import com.fr.module.ModuleContext; import com.fr.module.ModuleContext;
import com.fr.record.analyzer.FineAnalyzer;
import com.fr.stable.BuildContext; import com.fr.stable.BuildContext;
import com.fr.stable.OperatingSystem; import com.fr.stable.OperatingSystem;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.lifecycle.LifecycleFatalError;
import com.fr.stable.xml.XMLTools; import com.fr.stable.xml.XMLTools;
import com.fr.start.fx.SplashFx; import com.fr.start.fx.SplashFx;
import com.fr.start.jni.SplashMac; import com.fr.start.jni.SplashMac;
@ -56,14 +56,9 @@ import com.fr.start.preload.ImagePreLoader;
import com.fr.start.server.ServerTray; import com.fr.start.server.ServerTray;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import javax.swing.JComponent; import javax.swing.*;
import javax.swing.JPanel;
import javax.swing.border.MatteBorder; import javax.swing.border.MatteBorder;
import java.awt.Component; import java.awt.*;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.io.File; import java.io.File;
@ -96,8 +91,6 @@ public class Designer extends BaseDesigner {
*/ */
public static void main(String[] args) { public static void main(String[] args) {
FineAnalyzer.init();
BuildContext.setBuildFilePath("/com/fr/stable/build.properties"); BuildContext.setBuildFilePath("/com/fr/stable/build.properties");
@ -115,7 +108,11 @@ public class Designer extends BaseDesigner {
Module designerRoot = ModuleContext.parseRoot("designer-startup.xml"); Module designerRoot = ModuleContext.parseRoot("designer-startup.xml");
//传递启动参数 //传递启动参数
designerRoot.setSingleton(StartupArgs.class, new StartupArgs(args)); designerRoot.setSingleton(StartupArgs.class, new StartupArgs(args));
designerRoot.start(); try {
designerRoot.start();
} catch (LifecycleFatalError fatal) {
System.exit(0);
}
if (WorkContext.getCurrent().isLocal()) { if (WorkContext.getCurrent().isLocal()) {
//初始化一下serverTray //初始化一下serverTray
@ -197,7 +194,7 @@ public class Designer extends BaseDesigner {
if (!BaseUtils.isAuthorityEditing()) { if (!BaseUtils.isAuthorityEditing()) {
menuDef.addShortCut(SeparatorDef.DEFAULT); menuDef.addShortCut(SeparatorDef.DEFAULT);
if (WorkContext.getCurrent().isRoot()) { if (WorkContext.getCurrent().isRoot()) {
menuDef.addShortCut(new ServerConfigManagerAction(), new StyleListAction(), new WidgetManagerAction()); menuDef.addShortCut(new ServerConfigManagerAction(), new StyleListAction(), new WidgetManagerAction());
if (ActionFactory.getChartPreStyleAction() != null) { if (ActionFactory.getChartPreStyleAction() != null) {

5
designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

@ -48,7 +48,6 @@ import com.fr.design.mainframe.form.FormECDesignerProvider;
import com.fr.design.mainframe.form.FormElementCaseDesigner; import com.fr.design.mainframe.form.FormElementCaseDesigner;
import com.fr.design.mainframe.form.FormReportComponentComposite; import com.fr.design.mainframe.form.FormReportComponentComposite;
import com.fr.design.mainframe.loghandler.DesignerLogAppender; import com.fr.design.mainframe.loghandler.DesignerLogAppender;
import com.fr.design.mainframe.loghandler.DesignerLogImpl;
import com.fr.design.mainframe.loghandler.LogMessageBar; import com.fr.design.mainframe.loghandler.LogMessageBar;
import com.fr.design.mainframe.socketio.DesignerSocketIO; import com.fr.design.mainframe.socketio.DesignerSocketIO;
import com.fr.design.module.DesignModuleFactory; import com.fr.design.module.DesignModuleFactory;
@ -91,7 +90,6 @@ import com.fr.report.cell.painter.CellImagePainter;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.ParameterProvider; import com.fr.stable.ParameterProvider;
import com.fr.stable.bridge.StableFactory; import com.fr.stable.bridge.StableFactory;
import com.fr.stable.fun.LogProvider;
import com.fr.stable.plugin.ExtraDesignClassManagerProvider; import com.fr.stable.plugin.ExtraDesignClassManagerProvider;
import com.fr.stable.script.CalculatorProviderContext; import com.fr.stable.script.CalculatorProviderContext;
import com.fr.stable.script.ValueConverter; import com.fr.stable.script.ValueConverter;
@ -100,7 +98,7 @@ import com.fr.stable.xml.ObjectXMLWriterFinder;
import com.fr.start.BBSGuestPaneProvider; import com.fr.start.BBSGuestPaneProvider;
import com.fr.xml.ReportXMLUtils; import com.fr.xml.ReportXMLUtils;
import java.awt.Image; import java.awt.*;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -165,7 +163,6 @@ public class DesignerActivator extends Activator implements Prepare {
InformationCollector.getInstance().collectStartTime(); InformationCollector.getInstance().collectStartTime();
ExtraDesignClassManager.getInstance().getFeedback().didFeedback(); ExtraDesignClassManager.getInstance().getFeedback().didFeedback();
StableFactory.registerMarkedObject(LogProvider.MARK_STRING, DesignerLogImpl.getInstance());
} }
private static void preLoadPane() { private static void preLoadPane() {

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

@ -1,14 +1,16 @@
package com.fr.start.module; package com.fr.start.module;
import com.fr.design.DesignerEnvManager;
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;
import com.fr.general.ComparatorUtils;
import com.fr.module.Activator; import com.fr.module.Activator;
import com.fr.record.analyzer.EnableMetrics; import com.fr.record.analyzer.EnableMetrics;
import com.fr.record.analyzer.Metrics; import com.fr.record.analyzer.Metrics;
import com.fr.start.Designer; import com.fr.start.Designer;
import com.fr.start.EnvSwitcher; import com.fr.start.ServerStarter;
import com.fr.start.SplashContext; import com.fr.start.SplashContext;
import com.fr.startup.activators.BasicActivator; import com.fr.startup.activators.BasicActivator;
import com.fr.workspace.Workspace; import com.fr.workspace.Workspace;
@ -31,10 +33,20 @@ public class DesignerStartup extends Activator {
startSub(BasicActivator.class); startSub(BasicActivator.class);
final String[] args = getModule().upFindSingleton(StartupArgs.class).get(); final String[] args = getModule().upFindSingleton(StartupArgs.class).get();
final Designer designer = new Designer(args); final Designer designer = new Designer(args);
//启动env
startSub(DesignerWorkspaceProvider.class); startSub(DesignerWorkspaceProvider.class);
//启动env
startSub(EnvBasedModule.class); startSub(EnvBasedModule.class);
getRoot().getSingleton(EnvSwitcher.class).switch2LastEnv();
if (args != null) {
for (String arg : args) {
if (ComparatorUtils.equals(arg, "demo")) {
DesignerEnvManager.getEnvManager().setCurrentEnv2Default();
ServerStarter.browserDemoURL();
break;
}
}
}
ExecutorService service = Executors.newSingleThreadExecutor(); ExecutorService service = Executors.newSingleThreadExecutor();
registerEnvListener(); registerEnvListener();
service.submit(new Runnable() { service.submit(new Runnable() {

21
designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java

@ -1,10 +1,9 @@
package com.fr.start.module; package com.fr.start.module;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.general.ComparatorUtils;
import com.fr.module.Activator; import com.fr.module.Activator;
import com.fr.start.EnvSwitcher; import com.fr.start.EnvSwitcher;
import com.fr.start.ServerStarter;
/** /**
* Created by juhaoyu on 2018/1/8. * Created by juhaoyu on 2018/1/8.
@ -16,21 +15,11 @@ public class DesignerWorkspaceProvider extends Activator {
public void start() { public void start() {
//检查环境 //检查环境
DesignerEnvManager.checkNameEnvMap(); DesignerEnvManager.checkNameEnvMap();
String[] args = getModule().upFindSingleton(StartupArgs.class).get(); EnvSwitcher switcher = new EnvSwitcher();
if (args != null) {
for (String arg : args) {
if (ComparatorUtils.equals(arg, "demo")) {
DesignerEnvManager.getEnvManager().setCurrentEnv2Default();
ServerStarter.browserDemoURL();
break;
}
}
}
getRoot().setSingleton(EnvSwitcher.class, new EnvSwitcher());
//设置好环境即可,具体跟环境有关的模块会自动调用 //设置好环境即可,具体跟环境有关的模块会自动调用
getRoot().getSingleton(EnvSwitcher.class).switch2LastEnv(); switcher.switch2LastEnv();
getRoot().setSingleton(EnvSwitcher.class, switcher);
} }

Loading…
Cancel
Save