Browse Source

移动到8.0

master
svnadmin 8 years ago
parent
commit
57ad5b119d
  1. 2196
      .gitattributes
  2. 1
      .gitignore
  3. 33
      designer_base/.classpath
  4. 1
      designer_base/.project
  5. 19
      designer_base/designer_base.iml
  6. 141
      designer_base/src/com/fr/design/DesignModelAdapter.java
  7. 73
      designer_base/src/com/fr/design/DesignState.java
  8. 1795
      designer_base/src/com/fr/design/DesignerEnvManager.java
  9. 11
      designer_base/src/com/fr/design/Exception/ValidationException.java
  10. 827
      designer_base/src/com/fr/design/ExtraDesignClassManager.java
  11. 191
      designer_base/src/com/fr/design/RestartHelper.java
  12. 1
      designer_base/src/com/fr/design/actions/AllowAuthorityEditAction.java
  13. 41
      designer_base/src/com/fr/design/actions/CheckBoxAction.java
  14. 1
      designer_base/src/com/fr/design/actions/ExitAuthorityEditAction.java
  15. 57
      designer_base/src/com/fr/design/actions/HyperlinkPluginAction.java
  16. 16
      designer_base/src/com/fr/design/actions/JTemplateAction.java
  17. 46
      designer_base/src/com/fr/design/actions/MenuAction.java
  18. 84
      designer_base/src/com/fr/design/actions/TableDataSourceAction.java
  19. 40
      designer_base/src/com/fr/design/actions/TemplateComponentAction.java
  20. 7
      designer_base/src/com/fr/design/actions/TemplateComponentActionInterface.java
  21. 15
      designer_base/src/com/fr/design/actions/ToggleButtonUpdateAction.java
  22. 52
      designer_base/src/com/fr/design/actions/ToolbarActionManager.java
  23. 21
      designer_base/src/com/fr/design/actions/UndoableAction.java
  24. 402
      designer_base/src/com/fr/design/actions/UpdateAction.java
  25. 202
      designer_base/src/com/fr/design/actions/core/ActionUtils.java
  26. 37
      designer_base/src/com/fr/design/actions/edit/CopyAction.java
  27. 39
      designer_base/src/com/fr/design/actions/edit/CutAction.java
  28. 39
      designer_base/src/com/fr/design/actions/edit/PasteAction.java
  29. 59
      designer_base/src/com/fr/design/actions/edit/RedoAction.java
  30. 60
      designer_base/src/com/fr/design/actions/edit/UndoAction.java
  31. 1
      designer_base/src/com/fr/design/actions/file/CloseCurrentTemplateAction.java
  32. 29
      designer_base/src/com/fr/design/actions/file/CloseTemplateAction.java
  33. 22
      designer_base/src/com/fr/design/actions/file/EditEnvAction.java
  34. 32
      designer_base/src/com/fr/design/actions/file/ExitDesignerAction.java
  35. 243
      designer_base/src/com/fr/design/actions/file/LocalePane.java
  36. 78
      designer_base/src/com/fr/design/actions/file/OpenRecentReportMenuDef.java
  37. 45
      designer_base/src/com/fr/design/actions/file/OpenTemplateAction.java
  38. 46
      designer_base/src/com/fr/design/actions/file/PreferenceAction.java
  39. 633
      designer_base/src/com/fr/design/actions/file/PreferencePane.java
  40. 48
      designer_base/src/com/fr/design/actions/file/SaveAsTemplateAction.java
  41. 45
      designer_base/src/com/fr/design/actions/file/SaveTemplateAction.java
  42. 127
      designer_base/src/com/fr/design/actions/file/SwitchExistEnv.java
  43. 95
      designer_base/src/com/fr/design/actions/file/WebPreviewUtils.java
  44. 50
      designer_base/src/com/fr/design/actions/help/AboutAction.java
  45. 100
      designer_base/src/com/fr/design/actions/help/AboutDialog.java
  46. 238
      designer_base/src/com/fr/design/actions/help/AboutPane.java
  47. 57
      designer_base/src/com/fr/design/actions/help/FeedBackAction.java
  48. 350
      designer_base/src/com/fr/design/actions/help/FeedBackPane.java
  49. 75
      designer_base/src/com/fr/design/actions/help/ForumAction.java
  50. 63
      designer_base/src/com/fr/design/actions/help/SupportQQAction.java
  51. 69
      designer_base/src/com/fr/design/actions/help/SystemInfoPane.java
  52. 98
      designer_base/src/com/fr/design/actions/help/TutorialAction.java
  53. 46
      designer_base/src/com/fr/design/actions/help/WebDemoAction.java
  54. 171
      designer_base/src/com/fr/design/actions/server/ConnectionListAction.java
  55. 79
      designer_base/src/com/fr/design/actions/server/FunctionManagerAction.java
  56. 93
      designer_base/src/com/fr/design/actions/server/GlobalParameterAction.java
  57. 197
      designer_base/src/com/fr/design/actions/server/GlobalTableDataAction.java
  58. 48
      designer_base/src/com/fr/design/actions/server/PlatformManagerAction.java
  59. 52
      designer_base/src/com/fr/design/actions/server/PluginManagerAction.java
  60. 63
      designer_base/src/com/fr/design/actions/server/ProcedureListAction.java
  61. 97
      designer_base/src/com/fr/design/actions/tabledata/TableDataAction.java
  62. 39
      designer_base/src/com/fr/design/beans/BasicBeanPane.java
  63. 28
      designer_base/src/com/fr/design/beans/FurtherBasicBeanPane.java
  64. 56
      designer_base/src/com/fr/design/beans/GroupModel.java
  65. 190
      designer_base/src/com/fr/design/beans/location/Absorptionline.java
  66. 332
      designer_base/src/com/fr/design/beans/location/MoveUtils.java
  67. 50
      designer_base/src/com/fr/design/border/UIRoundedBorder.java
  68. 28
      designer_base/src/com/fr/design/border/UITitledBorder.java
  69. 17
      designer_base/src/com/fr/design/bridge/DesignToolbarProvider.java
  70. 15
      designer_base/src/com/fr/design/cell/FloatElementsProvider.java
  71. 66
      designer_base/src/com/fr/design/condition/CellHighlightAddMenuDef.java
  72. 52
      designer_base/src/com/fr/design/condition/ConditionAttrSingleConditionPane.java
  73. 133
      designer_base/src/com/fr/design/condition/ConditionAttributesPane.java
  74. 128
      designer_base/src/com/fr/design/condition/ContinuousTreeSelectionModel.java
  75. 200
      designer_base/src/com/fr/design/condition/DSColumnLiteConditionPane.java
  76. 21
      designer_base/src/com/fr/design/condition/DSColumnSimpleLiteConditionPane.java
  77. 36
      designer_base/src/com/fr/design/condition/HighLightConditionAction.java
  78. 950
      designer_base/src/com/fr/design/condition/LiteConditionPane.java
  79. 103
      designer_base/src/com/fr/design/condition/ObjectLiteConditionPane.java
  80. 54
      designer_base/src/com/fr/design/condition/SingleConditionPane.java
  81. 206
      designer_base/src/com/fr/design/constants/KeyWords.java
  82. 1
      designer_base/src/com/fr/design/constants/LayoutConstants.java
  83. 172
      designer_base/src/com/fr/design/constants/UIConstants.java
  84. 12
      designer_base/src/com/fr/design/data/DataCreatorUI.java
  85. 468
      designer_base/src/com/fr/design/data/DesignTableDataManager.java
  86. 602
      designer_base/src/com/fr/design/data/datapane/ChoosePane.java
  87. 1
      designer_base/src/com/fr/design/data/datapane/ChoosePaneSupportFormula.java
  88. 48
      designer_base/src/com/fr/design/data/datapane/DSButtonGroup.java
  89. 49
      designer_base/src/com/fr/design/data/datapane/DataBaseItems.java
  90. 34
      designer_base/src/com/fr/design/data/datapane/EditOrNewLabel.java
  91. 57
      designer_base/src/com/fr/design/data/datapane/FlashLookLabelMouseAdapter.java
  92. 22
      designer_base/src/com/fr/design/data/datapane/GlobalTableDataComboBox.java
  93. 21
      designer_base/src/com/fr/design/data/datapane/GlobalTreeTableDataDictPane.java
  94. 37
      designer_base/src/com/fr/design/data/datapane/RefreshLabel.java
  95. 62
      designer_base/src/com/fr/design/data/datapane/ReportTableDataPane.java
  96. 149
      designer_base/src/com/fr/design/data/datapane/TableDataComboBox.java
  97. 134
      designer_base/src/com/fr/design/data/datapane/TableDataCreatorProducer.java
  98. 261
      designer_base/src/com/fr/design/data/datapane/TableDataListPane.java
  99. 178
      designer_base/src/com/fr/design/data/datapane/TableDataNameObjectCreator.java
  100. 236
      designer_base/src/com/fr/design/data/datapane/TableDataSourceOP.java
  101. Some files were not shown because too many files have changed in this diff Show More

2196
.gitattributes vendored

File diff suppressed because it is too large Load Diff

1
.gitignore vendored

@ -1,3 +1,4 @@
designer/bin
designer_base/bin
designer_chart/bin
designer_form/bin

33
designer_base/.classpath

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.6u35"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/lib"/>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/base"/>
<classpathentry combineaccessrules="false" kind="src" path="/base-stable"/>
<classpathentry combineaccessrules="false" kind="src" path="/base-basic"/>
<classpathentry kind="lib" path="/lib/jetty/activation.jar"/>
<classpathentry kind="lib" path="/lib/jetty/commons-el.jar"/>
<classpathentry kind="lib" path="/lib/jetty/commons-logging.jar"/>
<classpathentry kind="lib" path="/lib/jetty/jasper-compiler.jar"/>
<classpathentry kind="lib" path="/lib/jetty/jasper-runtime.jar"/>
<classpathentry kind="lib" path="/lib/jetty/javax.servlet.jar"/>
<classpathentry kind="lib" path="/lib/jetty/jaxrpc.jar"/>
<classpathentry kind="lib" path="/lib/jetty/mail.jar"/>
<classpathentry kind="lib" path="/lib/jetty/mx4j-remote.jar"/>
<classpathentry kind="lib" path="/lib/jetty/mx4j-tools.jar"/>
<classpathentry kind="lib" path="/lib/jetty/mx4j.jar"/>
<classpathentry kind="lib" path="/lib/jetty/org.mortbay.jetty.jar"/>
<classpathentry kind="lib" path="/lib/jetty/org.mortbay.jmx.jar"/>
<classpathentry kind="lib" path="/lib/jetty/saaj.jar"/>
<classpathentry kind="lib" path="/lib/jetty/xercesImpl.jar"/>
<classpathentry kind="lib" path="/lib/jetty/xml-apis.jar"/>
<classpathentry kind="lib" path="/lib/jetty/xmlParserAPIs.jar"/>
<classpathentry kind="lib" path="/lib/3rd.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/base-calculate"/>
<classpathentry kind="lib" path="/lib/junit.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/base-data"/>
<classpathentry kind="lib" path="/lib/olap4j-1.1.0.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/base-file"/>
<classpathentry kind="output" path="bin"/>
</classpath>

1
designer_base/.project

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?> <projectDescription> <name>designer_base</name> <comment/> <projects/> <buildSpec> <buildCommand> <name>org.eclipse.jdt.core.javabuilder</name> <arguments/> </buildCommand> </buildSpec> <natures> <nature>org.eclipse.jdt.core.javanature</nature> </natures> </projectDescription>

19
designer_base/designer_base.iml

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/../../../env/8.0/WebReport/WEB-INF/classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="jdk" jdkName="jdk1.8" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="base" />
<orderEntry type="module" module-name="base-basic" />
<orderEntry type="module" module-name="base-calculate" />
<orderEntry type="module" module-name="base-data" />
<orderEntry type="module" module-name="base-file" />
<orderEntry type="module" module-name="base-performance" />
<orderEntry type="module" module-name="base-stable" />
<orderEntry type="library" name="lib" level="project" />
</component>
</module>

141
designer_base/src/com/fr/design/DesignModelAdapter.java

@ -0,0 +1,141 @@
package com.fr.design;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import com.fr.base.Parameter;
import com.fr.base.io.IOFile;
import com.fr.data.TableDataSource;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JTemplateProvider;
import com.fr.form.ui.Widget;
import com.fr.general.ComparatorUtils;
import com.fr.stable.js.WidgetName;
/**
* 当前的设计器模式
*
* @author zhou
* @since 2012-7-26上午11:24:54
*/
public abstract class DesignModelAdapter<T extends IOFile, S extends JTemplateProvider> {
private static DesignModelAdapter<?, ?> currentModelAdapter;
protected S jTemplate;
public DesignModelAdapter(S jTemplate) {
this.jTemplate = jTemplate;
setCurrentModelAdapter(this);
}
public T getBook() {
return (T) ((JTemplate) jTemplate).getTarget();
}
public static void setCurrentModelAdapter(DesignModelAdapter<?, ?> model) {
currentModelAdapter = model;
}
public static DesignModelAdapter<?, ?> getCurrentModelAdapter() {
return currentModelAdapter;
}
/**
* 响应目标改变事件.
*/
public void fireTargetModified() {
((JTemplate) this.jTemplate).fireTargetModified();
}
public String[] getFloatNames() {
return new String[0];
}
public Parameter[] getParameters() {
return new Parameter[0];
}
// 报表参数
public Parameter[] getReportParameters() {
return new Parameter[0];
}
/**
* 数据源参数
*
* @return
*/
public Parameter[] getTableDataParameters() {
return new Parameter[0];
}
/**
* 重命名数据集
*
* @param oldName 旧名字
* @param newName 新名字
* @param isNeedFireModified 是否需要触发保存
* @return 重命名成功返回True
*/
public boolean renameTableData(String oldName, String newName, boolean isNeedFireModified) {
if (!ComparatorUtils.equals(oldName, newName)) {
TableDataSource tds = getBook();
boolean b;
b = tds.renameTableData(oldName, newName);
if (!b) {
return b;
}
if (isNeedFireModified) {
fireTargetModified();
}
}
return true;
}
/**
* 重命名TableData后的一些操作
*
* @param oldName 旧名字
* @param newName 新名字.
* @return 返回是否名字一样.
*/
public boolean renameTableData(String oldName, String newName) {
return renameTableData(oldName, newName, true);
}
/**
* 重命名tabledata
*
* @param map 新名字
*/
public void renameTableData(Map<String, String> map) {
if (map.isEmpty()) {
return;
}
Iterator<String> iterator = map.keySet().iterator();
while (iterator.hasNext()) {
String key = iterator.next();
renameTableData(key, map.get(key));
}
}
public abstract Widget[] getLinkableWidgets() ;
public abstract List<WidgetName> getWidgetsName();
/**
* 环境改变.
*/
public abstract void envChanged();
/**
* 参数改变.
*/
public abstract void parameterChanged();
/**
* 控件配置改变.
*/
public abstract void widgetConfigChanged();
}

73
designer_base/src/com/fr/design/DesignState.java

@ -0,0 +1,73 @@
package com.fr.design;
import com.fr.base.BaseUtils;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.env.RemoteEnv;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 13-12-24
* Time: 上午9:36
* 记录现在设计器的设计状态
*/
public class DesignState {
//菜单的几种情况
//Jwrok
//worksheet
public static final int WORK_SHEET = 0;
//polyDesogner
public static final int POLY_SHEET = 1;
//参数面板
public static final int PARAMETER_PANE = 2;
//From
public static final int JFORM = 4;
//是不是在远程
public static final int REMOTE = 8;
//设计状态
private int designState = -1;
private boolean isRoot = true;//默认是管理员登陆
private boolean isAuthority = false;
public DesignState(ToolBarMenuDockPlus plus) {
designState = plus.getMenuState();
Env env = FRContext.getCurrentEnv();
if (env != null && env instanceof RemoteEnv) {
designState += REMOTE;
}
isRoot = env != null && env.isRoot();
isAuthority = BaseUtils.isAuthorityEditing();
}
public int getDesignState() {
return designState;
}
/**
* 是否是管理员
* @return 是管理员返回true
*/
public boolean isRoot() {
return this.isRoot;
}
/**
* 是否处于权限编辑状态
* @return 是则返回true
*/
public boolean isAuthority() {
return isAuthority;
}
}

1795
designer_base/src/com/fr/design/DesignerEnvManager.java

File diff suppressed because it is too large Load Diff

11
designer_base/src/com/fr/design/Exception/ValidationException.java

@ -0,0 +1,11 @@
package com.fr.design.Exception;
public class ValidationException extends Exception {
public ValidationException() {
}
public ValidationException(String msg) {
super(msg);
}
}

827
designer_base/src/com/fr/design/ExtraDesignClassManager.java

@ -0,0 +1,827 @@
/*
* Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved.
*/
package com.fr.design;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.design.data.datapane.TableDataNameObjectCreator;
import com.fr.design.data.tabledata.wrapper.TableDataFactory;
import com.fr.design.fun.*;
import com.fr.design.gui.controlpane.NameObjectCreator;
import com.fr.design.gui.core.WidgetOption;
import com.fr.design.gui.core.WidgetOptionFactory;
import com.fr.design.mainframe.App;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.menu.ShortCut;
import com.fr.design.widget.Appearance;
import com.fr.file.XMLFileManager;
import com.fr.form.ui.Widget;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.general.GeneralContext;
import com.fr.general.GeneralUtils;
import com.fr.plugin.PluginCollector;
import com.fr.plugin.PluginInvalidLevelException;
import com.fr.plugin.PluginLicenseManager;
import com.fr.plugin.PluginMessage;
import com.fr.stable.EnvChangedListener;
import com.fr.stable.StringUtils;
import com.fr.stable.fun.Authorize;
import com.fr.stable.fun.Level;
import com.fr.stable.plugin.ExtraDesignClassManagerProvider;
import com.fr.stable.plugin.PluginSimplify;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @author : richie
* @since : 8.0
* 用于设计器扩展的管理类
*/
public class ExtraDesignClassManager extends XMLFileManager implements ExtraDesignClassManagerProvider {
private static final String XML_TAG = "ExtraDesignClassManager";
private static final String TEMPLATE_TREE_TAG = "TemplateTreeShortCut";
private static ClassLoader loader = Thread.currentThread().getContextClassLoader();
private static ExtraDesignClassManager classManager;
public synchronized static ExtraDesignClassManager getInstance() {
if (classManager == null) {
classManager = new ExtraDesignClassManager();
classManager.readXMLFile();
}
return classManager;
}
static {
GeneralContext.addEnvChangedListener(new EnvChangedListener() {
public void envChanged() {
ExtraDesignClassManager.envChanged();
}
});
}
private synchronized static void envChanged() {
classManager = null;
}
private List<TableDataNameObjectCreator> reportTDCreators;
private List<TableDataNameObjectCreator> serverTDCreators;
private List<WidgetOption> parameterWidgetOptions;
private Map<Class<? extends Widget>, Class<?>> parameterWidgetOptionsMap;
private List<WidgetOption> webWidgetOptions;
private List<WidgetOption> formWidgetOptions;
private List<WidgetOption> formWidgetContainerOptions;
private Map<Class<? extends Widget>, Class<?>> formWidgetOptionsMap;
private List<WidgetOption> cellWidgetOptions;
private Map<Class<? extends Widget>, Appearance> cellWidgetOptionMap;
private List<NameObjectCreator> connectionCreators;
private Set<PreviewProvider> previewProviders;
private Set<HighlightProvider> highlightProviders;
private TableDataCreatorProvider tableDataCreatorProvider;
private List<MenuHandler> menuHandlers;
private UIFormulaProcessor uiFormulaProcessor;
private List<PresentKindProvider> presentKindProviders;
private List<ExportToolBarProvider> exportToolBarProviders;
private Set<ShortCut> templateTreeShortCutProviders;
private List<SubmitProvider> submitProviders;
private List<GlobalListenerProvider> globalListenerProviders;
private List<JavaScriptActionProvider> javaScriptActionProviders;
private TitlePlaceProcessor titlePlaceProcessor;
private FormElementCaseEditorProcessor formElementCaseEditorProcessor;
private IndentationUnitProcessor indentationUnitProcessor;
private CellAttributeProvider cellAttributeProvider;
private Set<HyperlinkProvider> hyperlinkGroupProviders;
public void addSupportDesignApps(Level level, PluginSimplify simplify) throws Exception {
validAPILevel(level, App.CURRENT_LEVEL, simplify.getPluginName());
App provider = (App) level;
DesignerFrame.registApp(provider);
}
private void validAPILevel(Level level, int targetLevel, String pluginName) {
if (PluginCollector.getCollector().isError(level, targetLevel, pluginName)) {
throw new PluginInvalidLevelException(pluginName, level.currentAPILevel());
}
}
public HyperlinkProvider[] getHyperlinkProvider() {
if (hyperlinkGroupProviders == null) {
return new HyperlinkProvider[0];
}
return hyperlinkGroupProviders.toArray(new HyperlinkProvider[hyperlinkGroupProviders.size()]);
}
public void addHyperlinkProvider(Level level, PluginSimplify simplify) throws Exception {
if (hyperlinkGroupProviders == null) {
hyperlinkGroupProviders = new HashSet<HyperlinkProvider>();
}
validAPILevel(level, HyperlinkProvider.CURRENT_LEVEL, simplify.getPluginName());
HyperlinkProvider provider = (HyperlinkProvider) level;
hyperlinkGroupProviders.add(provider);
}
public GlobalListenerProvider[] getGlobalListenerProvider() {
if (globalListenerProviders == null) {
return new GlobalListenerProvider[0];
}
return globalListenerProviders.toArray(new GlobalListenerProvider[globalListenerProviders.size()]);
}
/**
* 获取javaScriptPane
*
* @return javaScriptPane集合
*/
public List<JavaScriptActionProvider> getJavaScriptActionProvider() {
return javaScriptActionProviders;
}
/**
* 添加一个javaScriptPane
*/
public void addJavaScriptActionProvider(Level level, PluginSimplify simplify) throws Exception {
if (javaScriptActionProviders == null) {
javaScriptActionProviders = new ArrayList<JavaScriptActionProvider>();
}
validAPILevel(level, JavaScriptActionProvider.CURRENT_LEVEL, simplify.getPluginName());
JavaScriptActionProvider provider = (JavaScriptActionProvider) level;
if (!javaScriptActionProviders.contains(provider)) {
javaScriptActionProviders.add(provider);
}
}
/**
* 添加全局监听
*/
public void addGlobalListenerProvider(Level level, PluginSimplify simplify) throws Exception {
if (globalListenerProviders == null) {
globalListenerProviders = new ArrayList<GlobalListenerProvider>();
}
validAPILevel(level, GlobalListenerProvider.CURRENT_LEVEL, simplify.getPluginName());
GlobalListenerProvider provider = (GlobalListenerProvider) level;
if (!globalListenerProviders.contains(provider)) {
globalListenerProviders.add(provider);
}
}
public TableDataCreatorProvider getTableDataCreatorProvider() {
return tableDataCreatorProvider;
}
public void setTableDataCreatorProvider(String className) {
if (StringUtils.isNotBlank(className)) {
try {
Class clazz = Class.forName(className);
tableDataCreatorProvider = (TableDataCreatorProvider) clazz.newInstance();
} catch (Exception e) {
FRLogger.getLogger().error(e.getMessage(), e);
}
}
}
public SubmitProvider[] getSubmitProviders() {
if (submitProviders == null) {
return new SubmitProvider[0];
}
return submitProviders.toArray(new SubmitProvider[submitProviders.size()]);
}
/**
* 添加提交接口
*/
public void addSubmitProvider(Level level, PluginSimplify simplify) throws Exception {
if (submitProviders == null) {
submitProviders = new ArrayList<SubmitProvider>();
}
validAPILevel(level, SubmitProvider.CURRENT_LEVEL, simplify.getPluginName());
SubmitProvider provider = (SubmitProvider) level;
if (!submitProviders.contains(provider)) {
submitProviders.add(provider);
}
}
public TableDataNameObjectCreator[] getReportTableDataCreators() {
if (reportTDCreators == null) {
return new TableDataNameObjectCreator[0];
} else {
return reportTDCreators.toArray(new TableDataNameObjectCreator[reportTDCreators.size()]);
}
}
/**
* 添加reportTDCreators
*
* @param className 类名
*/
public void addTableDataNameObjectCreator(String className, PluginSimplify simplify) {
if (StringUtils.isNotBlank(className)) {
try {
if (reportTDCreators == null) {
reportTDCreators = new ArrayList<TableDataNameObjectCreator>();
}
TableDataNameObjectCreator creator = createTableDataNameObjectCreator(className, simplify);
if (!reportTDCreators.contains(creator)) {
reportTDCreators.add(creator);
}
} catch (Exception e) {
PluginMessage.remindUpdate(className + e.getMessage());
}
}
}
/**
* 添加serverTDCreators
*
* @return 类名
*/
public TableDataNameObjectCreator[] getServerTableDataCreators() {
if (serverTDCreators == null) {
return new TableDataNameObjectCreator[0];
} else {
return serverTDCreators.toArray(new TableDataNameObjectCreator[serverTDCreators.size()]);
}
}
/**
* 添加serverTDCreators
*
* @param className 类名
*/
public void addServerTableDataNameObjectCreator(String className, PluginSimplify simplify) {
if (StringUtils.isNotBlank(className)) {
try {
if (serverTDCreators == null) {
serverTDCreators = new ArrayList<TableDataNameObjectCreator>();
}
TableDataNameObjectCreator creator = createTableDataNameObjectCreator(className, simplify);
if (!serverTDCreators.contains(creator)) {
serverTDCreators.add(creator);
}
} catch (Exception e) {
PluginMessage.remindUpdate(className + e.getMessage());
}
}
}
private TableDataNameObjectCreator createTableDataNameObjectCreator(String className, PluginSimplify simplify) throws Exception {
Class clazz = loader.loadClass(className);
TableDataDefineProvider provider = (TableDataDefineProvider) clazz.newInstance();
validAPILevel(provider, TableDataDefineProvider.CURRENT_LEVEL, simplify.getPluginName());
TableDataNameObjectCreator creator = new TableDataNameObjectCreator(
provider.nameForTableData(),
provider.prefixForTableData(),
provider.iconPathForTableData(),
provider.classForTableData(),
provider.classForInitTableData(),
provider.appearanceForTableData()
);
TableDataFactory.register(provider.classForTableData(), creator);
return creator;
}
public Map<Class<? extends Widget>, Class<?>> getParameterWidgetOptionsMap() {
if (parameterWidgetOptionsMap == null) {
return new HashMap<Class<? extends Widget>, Class<?>>();
} else {
return parameterWidgetOptionsMap;
}
}
public WidgetOption[] getParameterWidgetOptions() {
if (parameterWidgetOptions == null) {
return new WidgetOption[0];
} else {
return parameterWidgetOptions.toArray(new WidgetOption[parameterWidgetOptions.size()]);
}
}
/**
* 添加parameterWidgetOptionsMap
*/
public void addParameterWidgetOption(Level level, PluginSimplify simplify) throws Exception {
if (parameterWidgetOptions == null) {
parameterWidgetOptions = new ArrayList<WidgetOption>();
}
if (parameterWidgetOptionsMap == null) {
parameterWidgetOptionsMap = new HashMap<Class<? extends Widget>, Class<?>>();
}
validAPILevel(level, ParameterWidgetOptionProvider.CURRENT_LEVEL, simplify.getPluginName());
ParameterWidgetOptionProvider provider = (ParameterWidgetOptionProvider) level;
WidgetOption option = WidgetOptionFactory.createByWidgetClass(
provider.nameForWidget(),
BaseUtils.readIcon(provider.iconPathForWidget()),
provider.classForWidget()
);
parameterWidgetOptionsMap.put(provider.classForWidget(), provider.appearanceForWidget());
parameterWidgetOptions.add(option);
}
/**
* 添加 webWidgetOptions
*
* @return 返回 webWidgetOptions
*/
public void addWebWidgetOption(Level level, PluginSimplify simplify) throws Exception {
if (webWidgetOptions == null) {
webWidgetOptions = new ArrayList<WidgetOption>();
}
validAPILevel(level, ToolbarItemProvider.CURRENT_LEVEL, simplify.getPluginName());
ToolbarItemProvider provider = (ToolbarItemProvider) level;
WidgetOption option = WidgetOptionFactory.createByWidgetClass(
provider.nameForWidget(),
BaseUtils.readIcon(provider.iconPathForWidget()),
provider.classForWidget()
);
if (!webWidgetOptions.contains(option)) {
webWidgetOptions.add(option);
}
}
public Map<Class<? extends Widget>, Class<?>> getFormWidgetOptionsMap() {
if (formWidgetOptionsMap == null) {
return new HashMap<Class<? extends Widget>, Class<?>>();
} else {
return formWidgetOptionsMap;
}
}
public WidgetOption[] getFormWidgetOptions() {
if (formWidgetOptions == null) {
return new WidgetOption[0];
} else {
return formWidgetOptions.toArray(new WidgetOption[formWidgetOptions.size()]);
}
}
public WidgetOption[] getWebWidgetOptions() {
if (webWidgetOptions == null) {
return new WidgetOption[0];
} else {
return webWidgetOptions.toArray(new WidgetOption[webWidgetOptions.size()]);
}
}
public WidgetOption[] getFormWidgetContainerOptions() {
if (formWidgetContainerOptions == null) {
return new WidgetOption[0];
} else {
return formWidgetContainerOptions.toArray(new WidgetOption[formWidgetContainerOptions.size()]);
}
}
/**
* 添加 formWidgetContainerOptions
*/
public void addFormWidgetOption(Level level, PluginSimplify simplify) throws Exception {
if (formWidgetOptions == null) {
formWidgetOptions = new ArrayList<WidgetOption>();
}
if (formWidgetContainerOptions == null) {
formWidgetContainerOptions = new ArrayList<WidgetOption>();
}
if (formWidgetOptionsMap == null) {
formWidgetOptionsMap = new HashMap<Class<? extends Widget>, Class<?>>();
}
validAPILevel(level, FormWidgetOptionProvider.CURRENT_LEVEL, simplify.getPluginName());
FormWidgetOptionProvider provider = (FormWidgetOptionProvider) level;
WidgetOption option = WidgetOptionFactory.createByWidgetClass(
provider.nameForWidget(),
BaseUtils.readIcon(provider.iconPathForWidget()),
provider.classForWidget()
);
formWidgetOptionsMap.put(provider.classForWidget(), provider.appearanceForWidget());
if (provider.isContainer()) {
formWidgetContainerOptions.add(option);
} else {
formWidgetOptions.add(option);
}
}
public Map<Class<? extends Widget>, Appearance> getCellWidgetOptionsMap() {
if (cellWidgetOptionMap == null) {
return new HashMap<Class<? extends Widget>, Appearance>();
} else {
return cellWidgetOptionMap;
}
}
public WidgetOption[] getCellWidgetOptions() {
if (cellWidgetOptions == null) {
return new WidgetOption[0];
} else {
return cellWidgetOptions.toArray(new WidgetOption[cellWidgetOptions.size()]);
}
}
/**
* 添加cellWidgetOptionMap
*/
public void addCellWidgetOption(Level level, PluginSimplify simplify) throws Exception {
if (cellWidgetOptions == null) {
cellWidgetOptions = new ArrayList<WidgetOption>();
}
if (cellWidgetOptionMap == null) {
cellWidgetOptionMap = new HashMap<Class<? extends Widget>, Appearance>();
}
validAPILevel(level, CellWidgetOptionProvider.CURRENT_LEVEL, simplify.getPluginName());
CellWidgetOptionProvider provider = (CellWidgetOptionProvider) level;
WidgetOption option = WidgetOptionFactory.createByWidgetClass(
provider.nameForWidget(),
BaseUtils.readIcon(provider.iconPathForWidget()),
provider.classForWidget()
);
if (cellWidgetOptions.contains(option)) {
return;
}
cellWidgetOptionMap.put(provider.classForWidget(), new Appearance(provider.appearanceForWidget(), Appearance.P_MARK + cellWidgetOptionMap.size()));
cellWidgetOptions.add(option);
}
/**
* 添加 connectionCreators
*
* @param className 类名
*/
public void addConnection(String className, PluginSimplify simplify) {
if (StringUtils.isNotBlank(className)) {
try {
Class clazz = Class.forName(className);
if (connectionCreators == null) {
connectionCreators = new ArrayList<NameObjectCreator>();
}
ConnectionProvider provider = (ConnectionProvider) clazz.newInstance();
validAPILevel(provider, ConnectionProvider.CURRENT_LEVEL, simplify.getPluginName());
NameObjectCreator creator = new NameObjectCreator(
provider.nameForConnection(),
provider.iconPathForConnection(),
provider.classForConnection(),
provider.appearanceForConnection()
);
if (!connectionCreators.contains(creator)) {
connectionCreators.add(creator);
}
} catch (Exception e) {
PluginMessage.remindUpdate(className + e.getMessage());
}
}
}
public NameObjectCreator[] getConnections() {
if (connectionCreators == null) {
return new NameObjectCreator[0];
} else {
return connectionCreators.toArray(new NameObjectCreator[connectionCreators.size()]);
}
}
public PreviewProvider[] getPreviewProviders() {
if (previewProviders == null) {
return new PreviewProvider[0];
}
return previewProviders.toArray(new PreviewProvider[previewProviders.size()]);
}
/**
* 添加previewProviders
*/
public void addPreviewProvider(Level level, PluginSimplify simplify) throws Exception {
if (previewProviders == null) {
previewProviders = new HashSet<PreviewProvider>();
}
validAPILevel(level, PreviewProvider.CURRENT_LEVEL, simplify.getPluginName());
PreviewProvider provider = (PreviewProvider) level;
if (!previewProviders.contains(provider)) {
previewProviders.add(provider);
}
}
public HighlightProvider[] getHighlightProviders() {
if (highlightProviders == null) {
return new HighlightProvider[0];
}
return highlightProviders.toArray(new HighlightProvider[highlightProviders.size()]);
}
/**
* 添加 highlightProviders
*/
public void addTemplateTreeShortCutProvider(Level level, PluginSimplify simplify) throws Exception {
if (templateTreeShortCutProviders == null) {
templateTreeShortCutProviders = new HashSet<ShortCut>();
}
validAPILevel(level, ShortCut.CURRENT_LEVEL, simplify.getPluginName());
ShortCut provider = (ShortCut) level;
templateTreeShortCutProviders.add(provider);
}
public ShortCut[] getTemplateTreeShortCutProviders() {
if (templateTreeShortCutProviders == null) {
return new ShortCut[0];
}
return templateTreeShortCutProviders.toArray(new ShortCut[templateTreeShortCutProviders.size()]);
}
/**
* 添加 highlightProviders
*/
public void addConditionProvider(Level level, PluginSimplify simplify) throws Exception {
if (highlightProviders == null) {
highlightProviders = new HashSet<HighlightProvider>();
}
validAPILevel(level, HighlightProvider.CURRENT_LEVEL, simplify.getPluginName());
HighlightProvider provider = (HighlightProvider) level;
highlightProviders.add(provider);
}
public Feedback getFeedback() {
try {
Class clazz = GeneralUtils.classForName("com.fr.design.feedback.CurrentFeedback");
if (clazz != null) {
return (Feedback) clazz.newInstance();
}
} catch (Exception e) {
FRLogger.getLogger().info("no feed back support");
}
return Feedback.EMPTY;
}
public MenuHandler[] getMenuHandlers(String category) {
if (menuHandlers == null) {
return new MenuHandler[0];
}
List<MenuHandler> handlers = new ArrayList<MenuHandler>();
for (MenuHandler handler : menuHandlers) {
if (ComparatorUtils.equals(category, handler.category())) {
handlers.add(handler);
}
}
return handlers.toArray(new MenuHandler[handlers.size()]);
}
/**
* 添加menuHandlers
*/
public void addMenuHandler(Level level, PluginSimplify simplify) throws Exception {
if (menuHandlers == null) {
menuHandlers = new ArrayList<MenuHandler>();
}
validAPILevel(level, MenuHandler.CURRENT_LEVEL, simplify.getPluginName());
MenuHandler handler = (MenuHandler) level;
if (!menuHandlers.contains(handler)) {
menuHandlers.add(handler);
}
}
public UIFormulaProcessor getUIFormulaProcessor() {
return uiFormulaProcessor;
}
public void setUIFormulaProcessor(Level level, PluginSimplify simplify) throws Exception {
validAPILevel(level, UIFormulaProcessor.CURRENT_LEVEL, simplify.getPluginName());
uiFormulaProcessor = (UIFormulaProcessor) level;
}
public PresentKindProvider[] getPresentKindProviders() {
if (presentKindProviders == null) {
return new PresentKindProvider[0];
}
return presentKindProviders.toArray(new PresentKindProvider[presentKindProviders.size()]);
}
/**
* 添加presentKindProviders
*/
public void addPresentKindProvider(Level level, PluginSimplify simplify) throws Exception {
if (presentKindProviders == null) {
presentKindProviders = new ArrayList<PresentKindProvider>();
}
validAPILevel(level, PresentKindProvider.CURRENT_LEVEL, simplify.getPluginName());
PresentKindProvider provider = (PresentKindProvider) level;
presentKindProviders.add(provider);
}
public ExportToolBarProvider[] getExportToolBarProviders() {
if (exportToolBarProviders == null) {
return new ExportToolBarProvider[0];
}
return exportToolBarProviders.toArray(new ExportToolBarProvider[exportToolBarProviders.size()]);
}
/**
* 添加exportToolBarProviders
*/
public void addExportToolBarProvider(Level level, PluginSimplify simplify) throws Exception {
if (exportToolBarProviders == null) {
exportToolBarProviders = new ArrayList<ExportToolBarProvider>();
}
validAPILevel(level, ExportToolBarProvider.CURRENT_LEVEL, simplify.getPluginName());
ExportToolBarProvider provider = (ExportToolBarProvider) level;
if (!exportToolBarProviders.contains(provider)) {
exportToolBarProviders.add(provider);
}
}
public TitlePlaceProcessor getTitlePlaceProcessor() {
return titlePlaceProcessor;
}
public void setTitlePlaceProcessor(Level level, PluginSimplify simplify) throws Exception {
validAPILevel(level, TitlePlaceProcessor.CURRENT_LEVEL, simplify.getPluginName());
titlePlaceProcessor = (TitlePlaceProcessor) level;
}
public FormElementCaseEditorProcessor getPropertyTableEditor() {
return formElementCaseEditorProcessor;
}
public void setPropertyTableEditor(Level level, PluginSimplify simplify) throws Exception {
validAPILevel(level, FormElementCaseEditorProcessor.CURRENT_LEVEL, simplify.getPluginName());
formElementCaseEditorProcessor = (FormElementCaseEditorProcessor) level;
}
public IndentationUnitProcessor getIndentationUnitEditor() {
return indentationUnitProcessor;
}
public void setIndentationUnitEditor(Level level, PluginSimplify simplify) throws Exception {
validAPILevel(level, IndentationUnitProcessor.CURRENT_LEVEL, simplify.getPluginName());
indentationUnitProcessor = (IndentationUnitProcessor) level;
}
public CellAttributeProvider getCelllAttributeProvider() {
return cellAttributeProvider;
}
public void setCellAttributeProvider(Level level, PluginSimplify simplify) throws Exception {
validAPILevel(level, CellAttributeProvider.CURRENT_LEVEL, simplify.getPluginName());
cellAttributeProvider = (CellAttributeProvider) level;
}
/**
* 文件名
*
* @return 文件名
*/
@Override
public String fileName() {
return "designer.xml";
}
/**
* 读xml
*
* @param reader xml对象
*/
public void readXML(XMLableReader reader) {
readXML(reader, null, PluginSimplify.NULL);
}
/**
* 读xml
*
* @param reader xml对象
* @param extraDesignInterfaceList 接口列表
*/
@Override
public void readXML(XMLableReader reader, List<String> extraDesignInterfaceList, PluginSimplify simplify) {
if (reader.isChildNode()) {
String tagName = reader.getTagName();
if (extraDesignInterfaceList != null) {
extraDesignInterfaceList.add(tagName);
}
String className = reader.getAttrAsString("class", "");
if (StringUtils.isEmpty(className)) {
return;
}
readLevelTag(tagName, className, simplify);
}
}
private void readLevelTag(String tagName, String className, PluginSimplify simplify) {
try {
//实现了Level接口的, 可以直接newInstance子类的
Class<?> clazz = loader.loadClass(className);
Authorize authorize = clazz.getAnnotation(Authorize.class);
if (authorize != null) {
PluginLicenseManager.getInstance().registerPaid(authorize, simplify);
}
Level impl = (Level) clazz.newInstance();
//控件
readWidgetRelated(tagName, impl, simplify);
//数据集, 数据连接
readTableDataRelated(tagName, className, simplify);
if (tagName.equals(ParameterWidgetOptionProvider.XML_TAG)) {
addParameterWidgetOption(impl, simplify);
} else if (tagName.equals(PreviewProvider.MARK_STRING)) {
addPreviewProvider(impl, simplify);
} else if (tagName.equals(HighlightProvider.MARK_STRING)) {
addConditionProvider(impl, simplify);
} else if (tagName.equals(MenuHandler.MARK_STRING)) {
addMenuHandler(impl, simplify);
} else if (tagName.equals(UIFormulaProcessor.MARK_STRING)) {
setUIFormulaProcessor(impl, simplify);
} else if (tagName.equals(PresentKindProvider.MARK_STRING)) {
addPresentKindProvider(impl, simplify);
} else if (tagName.equals(TEMPLATE_TREE_TAG)) {
addTemplateTreeShortCutProvider(impl, simplify);
} else if (tagName.equals(SubmitProvider.MARK_STRING)) {
addSubmitProvider(impl, simplify);
} else if (tagName.equals(GlobalListenerProvider.XML_TAG)) {
addGlobalListenerProvider(impl, simplify);
} else if (tagName.equals(JavaScriptActionProvider.XML_TAG)) {
addJavaScriptActionProvider(impl, simplify);
} else if (tagName.equals(TitlePlaceProcessor.MARK_STRING)) {
setTitlePlaceProcessor(impl, simplify);
} else if (tagName.equals(FormElementCaseEditorProcessor.MARK_STRING)) {
setPropertyTableEditor(impl, simplify);
} else if (tagName.equals(IndentationUnitProcessor.MARK_STRING)) {
setIndentationUnitEditor(impl, simplify);
} else if (tagName.equals(CellAttributeProvider.MARK_STRING)) {
setCellAttributeProvider(impl, simplify);
} else if (tagName.equals(HyperlinkProvider.XML_TAG)) {
addHyperlinkProvider(impl, simplify);
} else if (tagName.equals(App.MARK_STRING)) {
addSupportDesignApps(impl, simplify);
}
} catch (PluginInvalidLevelException e) {
PluginMessage.remindUpdate(e.getMessage());
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage());
}
}
private void readTableDataRelated(String tagName, String className, PluginSimplify simplify) {
if (tagName.equals(TableDataCreatorProvider.XML_TAG)) {
setTableDataCreatorProvider(className);
} else if (tagName.equals(TableDataDefineProvider.XML_TAG)) {
addTableDataNameObjectCreator(className, simplify);
} else if (tagName.equals(ServerTableDataDefineProvider.XML_TAG)) {
addServerTableDataNameObjectCreator(className, simplify);
} else if (tagName.equals(ConnectionProvider.XML_TAG)) {
addConnection(className, simplify);
}
}
private void readWidgetRelated(String tagName, Level impl, PluginSimplify simplify) throws Exception {
if (tagName.equals(FormWidgetOptionProvider.XML_TAG)) {
addFormWidgetOption(impl, simplify);
} else if (tagName.equals(ToolbarItemProvider.XML_TAG)) {
addWebWidgetOption(impl, simplify);
} else if (tagName.equals(ExportToolBarProvider.XML_TAG)) {
addExportToolBarProvider(impl, simplify);
} else if (tagName.equals(CellWidgetOptionProvider.XML_TAG)) {
addCellWidgetOption(impl, simplify);
}
}
/**
* 写xml
*
* @param writer xml对象
*/
public void writeXML(XMLPrintWriter writer) {
writer.startTAG(XML_TAG);
writer.end();
}
}

191
designer_base/src/com/fr/design/RestartHelper.java

@ -0,0 +1,191 @@
package com.fr.design;
import com.fr.design.mainframe.DesignerContext;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.general.GeneralUtils;
import com.fr.stable.ArrayUtils;
import com.fr.stable.OperatingSystem;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
/**
* @author richie
* @date 2015-03-26
* @since 8.0
*/
public class RestartHelper {
public static final String RECORD_FILE = StableUtils.pathJoin(StableUtils.getInstallHome(), "delete.properties");
public static final String MOVE_FILE = StableUtils.pathJoin(StableUtils.getInstallHome(), "move.properties");
/**
* 把要删除的文件都记录到delete.properties中
*
* @param files 要删除的文件
*/
public static void saveFilesWhichToDelete(String[] files) {
Properties properties = new Properties();
File file = new File(RECORD_FILE);
if (file.exists()) {
try {
FileInputStream file2DeleteInputStream = new FileInputStream(file);
properties.load(file2DeleteInputStream);
file2DeleteInputStream.close();
} catch (IOException e) {
FRLogger.getLogger().error(e.getMessage(), e);
}
}
if (ArrayUtils.getLength(files) != 0) {
int size = properties.values().size();
for (int i = 0, len = files.length; i < len; i++) {
properties.setProperty((i + size) + "", files[i]);
}
}
try {
FileOutputStream file2DeleteOutputStream = new FileOutputStream(file);
properties.store(file2DeleteOutputStream, "save");
file2DeleteOutputStream.close();
} catch (IOException e) {
FRLogger.getLogger().error(e.getMessage(), e);
}
}
/**
* 把要移动的文件都记录到move.properties中
*
* @param map 移动的文件
*/
public static void saveFilesWhichToMove(Map<String, String> map) {
Properties properties = new Properties();
File file = new File(MOVE_FILE);
if (file.exists()) {
try {
FileInputStream file2MoveInputStream = new FileInputStream(file);
properties.load(file2MoveInputStream);
file2MoveInputStream.close();
} catch (IOException e) {
FRLogger.getLogger().error(e.getMessage(), e);
}
}
if (!map.isEmpty()) {
for (String key : map.keySet()) {
properties.setProperty(key, map.get(key));
}
}
try {
FileOutputStream file2MoveOutputStream = new FileOutputStream(file);
properties.store(file2MoveOutputStream, "save");
file2MoveOutputStream.close();
} catch (IOException e) {
FRLogger.getLogger().error(e.getMessage(), e);
}
}
/**
* 需要重启启动器用于删除文件
*/
public static void deleteRecordFilesWhenStart() {
File ff = new File(RECORD_FILE);
// 如果文件不存在就直接返回了
if (!ff.exists()) {
return;
}
restart();
}
private static boolean deleteWhenDebug() {
File ff = new File(RECORD_FILE);
Properties properties = new Properties();
try {
properties.load(new FileInputStream(ff));
} catch (IOException ignore) {
return true;
}
for (Map.Entry<Object, Object> entry : properties.entrySet()) {
String filePath = GeneralUtils.objectToString(entry.getValue());
File file = new File(filePath);
if (file.isDirectory()) {
File[] files = file.listFiles();
if (files != null) {
for (File f : files) {
deleteFile(f);
}
}
}
deleteFile(file);
}
return ff.delete();
}
private static boolean deleteFile(File f) {
return StableUtils.deleteFile(f);
}
/**
* 重启设计器
*/
public static void restart() {
restart(ArrayUtils.EMPTY_STRING_ARRAY);
}
/**
* 重启设计器并删除某些特定的文件
*
* @param filesToBeDelete 要删除的文件集合
*/
public static void restart(String[] filesToBeDelete) {
String installHome = StableUtils.getInstallHome();
if (StringUtils.isEmpty(installHome) || ComparatorUtils.equals(".", installHome)) {
deleteWhenDebug();
return;
}
try {
if (OperatingSystem.isMacOS()) {
restartInMacOS(installHome, filesToBeDelete);
} else {
restartInWindows(installHome, filesToBeDelete);
}
} catch (Exception e) {
FRLogger.getLogger().error(e.getMessage());
} finally {
DesignerContext.getDesignerFrame().exit();
}
}
private static void restartInMacOS(String installHome, String[] filesToBeDelete) throws Exception {
ProcessBuilder builder = new ProcessBuilder();
List<String> commands = new ArrayList<String>();
commands.add("open");
commands.add(installHome + File.separator + "bin" + File.separator + "restart.app");
if (ArrayUtils.isNotEmpty(filesToBeDelete)) {
commands.add("--args");
commands.add(StableUtils.join(filesToBeDelete, "+"));
}
builder.command(commands);
builder.start();
}
private static void restartInWindows(String installHome, String[] filesToBeDelete) throws Exception {
ProcessBuilder builder = new ProcessBuilder();
List<String> commands = new ArrayList<String>();
commands.add(installHome + File.separator + "bin" + File.separator + "restart.exe");
if (ArrayUtils.isNotEmpty(filesToBeDelete)) {
commands.add(StableUtils.join(filesToBeDelete, "+"));
}
builder.command(commands);
builder.start();
}
}

1
designer_base/src/com/fr/design/actions/AllowAuthorityEditAction.java

@ -0,0 +1 @@
package com.fr.design.actions; import com.fr.base.BaseUtils; import com.fr.design.constants.UIConstants; import com.fr.design.menu.KeySetUtils; import com.fr.design.roleAuthority.ReportAndFSManagePane; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.designer.TargetComponent; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.mainframe.*; /** * Author : daisy * Date: 13-8-30 * Time: 上午10:12 */ public class AllowAuthorityEditAction extends TemplateComponentAction { public AllowAuthorityEditAction(TargetComponent t) { super(t); this.setMenuKeySet(KeySetUtils.ALLOW_AUTHORITY_EDIT); this.setName(getMenuKeySet().getMenuName()); this.setMnemonic(getMenuKeySet().getMnemonic()); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/allow_authority_edit.png")); } /** * 撤销 */ public void prepare4Undo() { HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().iniAuthorityUndoState(); } /** * 执行动作 * * @return 是否执行成功 */ public boolean executeActionReturnUndoRecordNeeded() { TargetComponent tc = getEditingComponent(); if (tc == null) { return false; } cleanAuthorityCondition(); //进入时是格式刷则取消格式刷 if (DesignerContext.getFormatState() != DesignerContext.FORMAT_STATE_NULL) { tc.cancelFormat(); } BaseUtils.setAuthorityEditing(true); ReportAndFSManagePane.getInstance().refreshDockingView(); RolesAlreadyEditedPane.getInstance().refreshDockingView(); WestRegionContainerPane.getInstance().replaceDownPane(ReportAndFSManagePane.getInstance()); DesignerContext.getDesignerFrame().setCloseMode(UIConstants.CLOSE_OF_AUTHORITY); DesignerContext.getDesignerFrame().resetToolkitByPlus(tc.getToolBarMenuDockPlus()); DesignerContext.getDesignerFrame().needToAddAuhtorityPaint(); EastRegionContainerPane.getInstance().replaceUpPane(tc.getEastUpPane()); DesignerContext.getDesignerFrame().refreshDottedLine(); EastRegionContainerPane.getInstance().replaceDownPane(RolesAlreadyEditedPane.getInstance()); //画虚线 return true; } /** * 进入权限编辑之前将权限编辑界面重置一下工具栏 */ private void cleanAuthorityCondition() { java.util.List<JTemplate<?, ?>> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); for (int i = 0; i < opendedTemplate.size(); i++) { opendedTemplate.get(i).cleanAuthorityUndo(); } } }

41
designer_base/src/com/fr/design/actions/CheckBoxAction.java

@ -0,0 +1,41 @@
/*
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved.
*/
package com.fr.design.actions;
import javax.swing.JCheckBoxMenuItem;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.imenu.UICheckBoxMenuItem;
/**
* check box
*/
public abstract class CheckBoxAction extends UpdateAction {
public UICheckBoxMenuItem createMenuItem() {
Object object = this.getValue(UICheckBoxMenuItem.class.getName());
if (object == null) {
object = createCheckBoxMenuItem(this);
this.putValue(UICheckBoxMenuItem.class.getName(), object);
}
// isSelected.
((JCheckBoxMenuItem) object).setSelected(this.isSelected());
return (UICheckBoxMenuItem) object;
}
public abstract boolean isSelected();
public boolean isRadioSelect() {
return false;
}
public void setSelected(boolean isSelected) {
UIButton button = (UIButton) this.createToolBarComponent();
button.setSelected(isSelected);
}
}

1
designer_base/src/com/fr/design/actions/ExitAuthorityEditAction.java

@ -0,0 +1 @@
package com.fr.design.actions; import com.fr.base.BaseUtils; import com.fr.design.data.datapane.TableDataTreePane; import com.fr.design.DesignModelAdapter; import com.fr.design.designer.TargetComponent; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.mainframe.*; import com.fr.general.Inter; /** * Author : daisy * Date: 13-9-2 * Time: 下午3:36 */ public class ExitAuthorityEditAction extends TemplateComponentAction { public ExitAuthorityEditAction(TargetComponent t) { super(t); this.setName(Inter.getLocText(new String[]{"Exit", "DashBoard-Potence", "Edit"})); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/exit_authority_edit.png")); } public void prepare4Undo() { } public boolean executeActionReturnUndoRecordNeeded() { TargetComponent tc = getEditingComponent(); if (tc == null) { return false; } if (BaseUtils.isAuthorityEditing()) { BaseUtils.setAuthorityEditing(false); WestRegionContainerPane.getInstance().replaceDownPane(TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter())); EastRegionContainerPane.getInstance().replaceDownPane(tc.getEastDownPane()); EastRegionContainerPane.getInstance().replaceUpPane(tc.getEastUpPane()); DesignerContext.getDesignerFrame().resetToolkitByPlus(tc.getToolBarMenuDockPlus()); DesignerContext.getDesignerFrame().needToAddAuhtorityPaint(); DesignerContext.getDesignerFrame().refreshDottedLine(); fireAuthorityStateToNomal(); } return true; } /** * 退出权限编辑时,将所有的做过权限编辑的状态,作为一个状态赋给报、报表主体 */ private void fireAuthorityStateToNomal() { java.util.List<JTemplate<?, ?>> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); for (int i = 0; i < opendedTemplate.size(); i++) { //如果在权限编辑时做过操作,则将做过的操作作为一个整体状态赋给正在报表 if (opendedTemplate.get(i).isDoSomethingInAuthority()) { opendedTemplate.get(i).fireAuthorityStateToNomal(); } } } }

57
designer_base/src/com/fr/design/actions/HyperlinkPluginAction.java

@ -0,0 +1,57 @@
/*
* Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved.
*/
package com.fr.design.actions;
import com.fr.design.gui.controlpane.NameObjectCreator;
import java.awt.event.ActionEvent;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-2-26
* Time: 上午10:47
*/
public abstract class HyperlinkPluginAction extends UpdateAction {
public static final String XML_TAG = "hyperlinkType";
public HyperlinkPluginAction() {
this.setName(this.getDisplayName());
}
/**
* 名字
*
* @return
*/
public abstract String getDisplayName();
/**
* 得到超级链接的声明类
*
* @return
*/
public abstract Class getHyperlinkClass();
/**
* 得到相应面板的类
*
* @return
*/
public abstract Class getUpdateHyperlinkPaneClass();
public NameObjectCreator getHyperlinkCreator() {
return new NameObjectCreator(getDisplayName(), getHyperlinkClass(), getUpdateHyperlinkPaneClass());
}
/**
* 动作
* @param e 动作
*/
public void actionPerformed(ActionEvent e) {
}
}

16
designer_base/src/com/fr/design/actions/JTemplateAction.java

@ -0,0 +1,16 @@
package com.fr.design.actions;
import com.fr.design.mainframe.JTemplate;
public abstract class JTemplateAction<T extends JTemplate<?, ?>> extends UpdateAction implements TemplateComponentActionInterface<T> {
private T t;
public JTemplateAction(T t) {
this.t = t;
}
@Override
public T getEditingComponent() {
return t;
}
}

46
designer_base/src/com/fr/design/actions/MenuAction.java

@ -0,0 +1,46 @@
/*
* Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved.
*/
package com.fr.design.actions;
import com.fr.base.BaseUtils;
import com.fr.stable.StringUtils;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-2-28
* Time: 上午9:44
*/
public abstract class MenuAction extends UpdateAction {
public MenuAction() {
this.setName(getDisplayName());
this.setMnemonic(getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/bindColumn.png"));
}
/**
* 名字
*
* @return
*/
public abstract String getDisplayName();
public char getMnemonic() {
return '\0';
}
/**
* 图标
*
* @return
*/
public String getIconPath() {
return StringUtils.EMPTY;
}
}

84
designer_base/src/com/fr/design/actions/TableDataSourceAction.java

@ -0,0 +1,84 @@
package com.fr.design.actions;
import javax.swing.SwingUtilities;
import com.fr.base.BaseUtils;
import com.fr.design.data.DesignTableDataManager;
import com.fr.data.TableDataSource;
import com.fr.design.data.datapane.ReportTableDataPane;
import com.fr.design.data.datapane.TableDataTreePane;
import com.fr.design.data.tabledata.ResponseDataSourceChange;
import com.fr.design.DesignModelAdapter;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.menu.KeySetUtils;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import java.util.HashMap;
import java.util.Map;
/*
* richer:包括报表和表单的数据集 && 图表的数据集
*/
public class TableDataSourceAction extends TemplateComponentAction<JTemplate<?, ?>> implements ResponseDataSourceChange {
public TableDataSourceAction(JTemplate<?, ?> t) {
super(t);
this.setMenuKeySet(KeySetUtils.TEMPLATE_TABLE_DATA_SOURCE);
this.setName(getMenuKeySet().getMenuKeySetName() + "...");
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_web/datasource.png"));
}
/**
* 执行动作
*
* @return 是否执行成功
*/
public boolean executeActionReturnUndoRecordNeeded() {
final TableDataSource tds = this.getEditingComponent().getTarget();
final ReportTableDataPane tableDataPane = new ReportTableDataPane() {
public void complete() {
populate(tds);
}
};
BasicDialog reportTableDataDialog = tableDataPane.showLargeWindow(SwingUtilities.getWindowAncestor(this.getEditingComponent()), null);
reportTableDataDialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
DesignModelAdapter.getCurrentModelAdapter().renameTableData(tableDataPane.getDsNameChangedMap());
tableDataPane.update(tds);
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter());
TableDataSourceAction.this.getEditingComponent().fireTargetModified();
fireDSChanged(tableDataPane.getDsNameChangedMap());
}
});
reportTableDataDialog.setVisible(true);
return false;
}
// TODO ALEX_SEP 同JWorkBookAction,也不知道这个undo该如何处理
/**
* 撤销
*/
public void prepare4Undo() {
}
/**
* 响应数据集改变
*/
public void fireDSChanged() {
fireDSChanged(new HashMap<String, String>());
}
/**
* 响应数据集改变
*
* @param map 地图
*/
public void fireDSChanged(Map<String, String> map) {
DesignTableDataManager.fireDSChanged(map);
}
}

40
designer_base/src/com/fr/design/actions/TemplateComponentAction.java

@ -0,0 +1,40 @@
package com.fr.design.actions;
import com.fr.design.designer.TargetComponent;
public abstract class TemplateComponentAction<T extends TargetComponent> extends UndoableAction implements TemplateComponentActionInterface<T> {
private T t;
protected TemplateComponentAction(T t) {
this.t = t;
}
protected void setEditingComponent(T t) {
this.t = t;
}
@Override
public T getEditingComponent() {
return t;
}
@Override
public void prepare4Undo() {
this.getEditingComponent().fireTargetModified();
T component = getEditingComponent();
if (component == null) {
return;
}
component.requestFocus();
}
/**
* update enable
* TODO ALEX_SEP 这个方法的名字只是简单的叫update,太不明了了
*/
@Override
public void update() {
this.setEnabled(this.getEditingComponent() != null);
}
}

7
designer_base/src/com/fr/design/actions/TemplateComponentActionInterface.java

@ -0,0 +1,7 @@
package com.fr.design.actions;
import com.fr.design.designer.TargetComponent;
public interface TemplateComponentActionInterface<T extends TargetComponent> {
public T getEditingComponent();
}

15
designer_base/src/com/fr/design/actions/ToggleButtonUpdateAction.java

@ -0,0 +1,15 @@
package com.fr.design.actions;
import com.fr.design.gui.ibutton.UIToggleButton;
/**
* 具有ToggleButton属性的action,继承这个类的action就会有
*
* @author zhou
*
*/
public interface ToggleButtonUpdateAction {
public abstract UIToggleButton createToolBarComponent();
}

52
designer_base/src/com/fr/design/actions/ToolbarActionManager.java

@ -0,0 +1,52 @@
/*
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved.
*/
package com.fr.design.actions;
import java.util.ArrayList;
import java.util.List;
import com.fr.design.menu.MenuDef;
public class ToolbarActionManager {
private static ToolbarActionManager toolbarActionManager = null; //key map
//所有的Action Map.
private List<UpdateAction> actionList = new ArrayList<UpdateAction>();
private List<MenuDef> menuList=new ArrayList<MenuDef>();
private ToolbarActionManager() {
}
public static ToolbarActionManager createToolbarActionManager() {
if (toolbarActionManager == null) {
toolbarActionManager = new ToolbarActionManager();
}
return toolbarActionManager;
}
public void registerAction(UpdateAction updateAction) {
actionList.add(updateAction);
}
public void registerAction(MenuDef menuDef) {
menuList.add(menuDef);
}
public void update() {
int actionCount = actionList.size();
for (int i = 0; i < actionCount; i++) {
UpdateAction action = actionList.get(i);
if (action != null) {
action.update();
}
}
actionCount=menuList.size();
for(int i=0;i<actionCount;i++){
MenuDef menuDef=menuList.get(i);
if(menuDef!=null){
menuDef.updateMenu();
}
}
}
}

21
designer_base/src/com/fr/design/actions/UndoableAction.java

@ -0,0 +1,21 @@
package com.fr.design.actions;
import java.awt.event.ActionEvent;
public abstract class UndoableAction extends UpdateAction {
@Override
public void actionPerformed(ActionEvent evt) {
actionPerformedUndoable();
}
protected void actionPerformedUndoable() {
boolean executeValue = this.executeActionReturnUndoRecordNeeded();
if (executeValue) {
prepare4Undo();
}
}
public abstract boolean executeActionReturnUndoRecordNeeded();
public abstract void prepare4Undo();
}

402
designer_base/src/com/fr/design/actions/UpdateAction.java

@ -0,0 +1,402 @@
/*
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved.
*/
package com.fr.design.actions;
import com.fr.base.NameStyle;
import com.fr.base.ScreenResolution;
import com.fr.base.Style;
import com.fr.design.constants.UIConstants;
import com.fr.design.actions.core.ActionUtils;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.imenu.UICheckBoxMenuItem;
import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.menu.ShortCut;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.*;
import java.beans.PropertyChangeListener;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
/**
* An UpdateAction functions allows actions to have an efficient transient state,
* it's update method is called every time the action is about to be displayed
* in UI - allowing the action to poll whatever information it wishes to update its state
* before being displayed
* As a regular Swing Action object - it stores the name, icon, and enabled state for a single action.
* <p/>
* For example, a 'cut' action my be enabled or disabled based on the state of the selection
* in a text component. Just before the edit menu is displayed, the cut action is given the
* opportunity to update itself, and will appear in the menu with the correct state.
* august:不需要考虑UpdateAction的持久化难道需要持久化吗 又不像以前那样保存docking的大小布局
* 如果是ToggleButton就额外继承ToggleButtonUpdateAction接口
*/
public abstract class UpdateAction extends ShortCut implements Action {
/**
* Specifies whether action is enabled; the default is true.
*/
private boolean enabled = true;
/**
* Contains the array of key bindings.
* august:关键词key是Action里面的final常量Action.NAMEAction.SMALL_ICON等等
*/
private Map<String, Object> componentMap;
/**
* Constructor
*/
public UpdateAction() {
//设置默认的small icon,必须有一个默认的图片,这样菜单整体美观.
this.putValue(Action.SMALL_ICON, UIConstants.BLACK_ICON);
}
/**
* Returns true if the action is enabled.
*
* @return true if the action is enabled, false otherwise
* @see Action#isEnabled
*/
@Override
public boolean isEnabled() {
return enabled;
}
/**
* Enables or disables the action.
*
* @param newValue true to enable the action, false to
* disable it
* @see Action#setEnabled
*/
@Override
public void setEnabled(boolean newValue) {
boolean oldValue = this.enabled;
if (oldValue != newValue) {
this.enabled = newValue;
//循环遍历所有的Enable属性.
Iterator<Object> valueIt = this.componentMap.values().iterator();
while (valueIt.hasNext()) {
Object valueObject = valueIt.next();
if (valueObject instanceof JComponent) {
((JComponent) valueObject).setEnabled(this.enabled);
}
}
}
}
/**
* Returns the name for the action, used for a menu or button.
*
* @return the name for the action.
*/
public String getName() {
return (String) this.getValue(Action.NAME);
}
/**
* Sets the name for the action, used for a menu or button.
*
* @param name the name for the action.
*/
public void setName(String name) {
this.putValue(Action.NAME, name);
}
/**
* Returns the smallIcon property setting.
*
* @return The small icon for the action.
*/
public Icon getSmallIcon() {
return (Icon) this.getValue(Action.SMALL_ICON);
}
/**
* Sets the smallIcon property. The smallIcon may be displayed as a menu item's icon or
* possibly as the icon for a button. This icon should be 16x16 pixels in size.
*
* @param smallIcon The small icon for the action.
*/
public void setSmallIcon(Icon smallIcon) {
this.putValue(Action.SMALL_ICON, smallIcon);
}
/**
* Returns the mnemonic property setting.
*
* @return The mnemonic character for the action.
*/
public char getMnemonic() {
Integer n = (Integer) this.getValue(Action.MNEMONIC_KEY);
return n == null ? '\0' : (char) n.intValue();
}
/**
* Sets the mnemonic property. The mnemonic character is the 'hotkey' for the menu item
* or button displaying the action. This *must* be a character in the 'name' property,
* or it will have no effect.
*
* @param mnemonic The mnemonic character for the action
*/
public void setMnemonic(char mnemonic) {
this.putValue(Action.MNEMONIC_KEY, new Integer(mnemonic));
}
/**
* Returns the key used for storing a <code>KeyStroke</code> to be used as the
* accelerator for the action.
*
* @return the key as the accelerator for the action.
*/
public KeyStroke getAccelerator() {
return (KeyStroke) this.getValue(Action.ACCELERATOR_KEY);
}
/**
* Sets the key used for storing a <code>KeyStroke</code> to be used as the
* accelerator for the action.
*
* @param accelerator the key as the accelerator for the action.
*/
public void setAccelerator(KeyStroke accelerator) {
this.putValue(Action.ACCELERATOR_KEY, accelerator);
}
/**
* update enable
*/
public void update() {
}
/**
* Gets the <code>Object</code> associated with the specified key.
*
* @param key a string containing the specified <code>key</code>
* @return the binding <code>Object</code> stored with this key; if there
* are no keys, it will return <code>null</code>
* @see Action#getValue
*/
@Override
public Object getValue(String key) {
if (componentMap == null) {
return null;
}
return componentMap.get(key);
}
/**
* Sets the <code>Value</code> associated with the specified key.
*
* @param key the <code>String</code> that identifies the stored object
* @param newValue the <code>Object</code> to store using this key
* @see Action#putValue
*/
@Override
public void putValue(String key, Object newValue) {
if (componentMap == null) {
componentMap = new HashMap<String, Object>();
}
if (newValue == null) {
componentMap.remove(key);
} else {
componentMap.put(key, newValue);
}
}
@Override
public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
}
@Override
public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
}
/**
* Gets menu item.
*
* @return the created menu item.
*/
public UIMenuItem createMenuItem() {
Object object = this.getValue(UIMenuItem.class.getName());
if (object == null && !(object instanceof UIMenuItem)) {
UIMenuItem menuItem = new UIMenuItem(this);
// 设置名字用作单元测
menuItem.setName(getName());
object = menuItem;
this.putValue(UIMenuItem.class.getName(), object);
}
return (UIMenuItem) object;
}
/**
* Gets component on toolbar.
*
* @return the created components on toolbar.
*/
public JComponent createToolBarComponent() {
Object object = this.getValue(UIButton.class.getName());
if (!(object instanceof AbstractButton)) {
UIButton button = null;
button = new UIButton();
// 添加一个名字作为自动化测试用
button.setName(getName());
button.set4ToolbarButton();
//设置属性.
Integer mnemonicInteger = (Integer) this.getValue(Action.MNEMONIC_KEY);
if (mnemonicInteger != null) {
button.setMnemonic((char) mnemonicInteger.intValue());
}
button.setIcon((Icon) this.getValue(Action.SMALL_ICON));
button.addActionListener(this);
button.registerKeyboardAction(this, this.getAccelerator(), JComponent.WHEN_IN_FOCUSED_WINDOW);
this.putValue(UIButton.class.getName(), button);
button.setText(StringUtils.EMPTY);
button.setEnabled(this.isEnabled());
//peter:产生tooltip
button.setToolTipText(ActionUtils.createButtonToolTipText(this));
object = button;
}
return (JComponent) object;
}
/**
* Equals
*/
@Override
public boolean equals(Object object) {
if (object == this) {
return true;
}
if (!(object instanceof UpdateAction)) {
return false;
}
return ((UpdateAction) object).getName().equals(this.getName());
}
@Override
public int hashCode() {
int hash = 5;
hash = 59 * hash + (this.enabled ? 1 : 0);
return hash;
}
/*
* Add this ShortCut into JPopupMenu
*/
@Override
public void intoJPopupMenu(JPopupMenu menu) {
update();
menu.add(this.createMenuItem());
}
/*
* Add this ShortCut into JToolBar
*/
@Override
public void intoJToolBar(JToolBar toolBar) {
update();
toolBar.add(this.createToolBarComponent());
}
/**
* 全局style的菜单
*/
public static class UseMenuItem extends UIMenuItem {
private NameStyle nameStyle;
public UseMenuItem(Action action) {
super(action);
setPreferredSize(new Dimension(80, 20));
}
public UseMenuItem(String text, Icon icon) {
super(text, icon);
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
if (nameStyle == null) {
return;
}
Style.paintBackground((Graphics2D) g, nameStyle, getWidth() - 1, getHeight() - 1);
Style.paintContent((Graphics2D) g, nameStyle.getName(), nameStyle, getWidth() - 1, getHeight() - 1, ScreenResolution.getScreenResolution());
Style.paintBorder((Graphics2D) g, nameStyle, getWidth() - 1, getHeight() - 1);
}
public NameStyle getNameStyle() {
return this.nameStyle;
}
public void setNameStyle(NameStyle nameStyle) {
this.nameStyle = nameStyle;
}
@Override
public Dimension getMinimumSize() {
return getPreferredSize();
}
}
/**
* Gets menu item.
*
* @return the created menu item.
*/
public UseMenuItem createUseMenuItem() {
Object object = this.getValue(UseMenuItem.class.getName());
if (object == null && !(object instanceof UseMenuItem)) {
object = new UseMenuItem(this);
this.putValue(UseMenuItem.class.getName(), object);
}
return (UseMenuItem) object;
}
public static UICheckBoxMenuItem createCheckBoxMenuItem(UpdateAction action) {
UICheckBoxMenuItem menuItem = new UICheckBoxMenuItem(action.getName());
// 设置属性.
Integer mnemonicInteger = (Integer) action
.getValue(Action.MNEMONIC_KEY);
if (mnemonicInteger != null) {
menuItem.setMnemonic((char) mnemonicInteger.intValue());
}
menuItem.setIcon((Icon) action.getValue(Action.SMALL_ICON));
// if(menuItem.isSelected()){
// menuItem.setIcon(FRSwingConstants.YES_ICON);
// }
menuItem.addActionListener(action);
menuItem.setToolTipText((String) action.getValue(Action.LONG_DESCRIPTION));
menuItem.setAccelerator((KeyStroke) action.getValue(Action.ACCELERATOR_KEY));
return menuItem;
}
}

202
designer_base/src/com/fr/design/actions/core/ActionUtils.java

@ -0,0 +1,202 @@
package com.fr.design.actions.core;
import java.awt.event.KeyEvent;
import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.Map;
import javax.swing.Action;
import javax.swing.KeyStroke;
import com.fr.base.FRContext;
import com.fr.base.Utils;
import com.fr.design.actions.UpdateAction;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.selection.QuickEditor;
/**
* 一些ActionUtils
*/
public class ActionUtils {
private static Class<UpdateAction>[] actionClasses;
private static Class<UpdateAction>[] floatActionClasses;
private ActionUtils() {
}
private static Map<Class, QuickEditor> floatEditor = new HashMap<Class, QuickEditor>();
private static Class chartCollectionClass = null;
private static Map<Class, QuickEditor> cellEditor = new HashMap<Class, QuickEditor>();
private static UpdateAction chartPreStyleAction = null;
/**
* 待说明
* @param clzz 待说明
* @param editor 待说明
*/
public static void registerCellEditor(Class clzz, QuickEditor editor) {
cellEditor.put(clzz, editor);
}
/**
* 待说明
* @param clzz 待说明
* @param editor 待说明
*/
public static void registerFloatEditor(Class clzz, QuickEditor editor) {
floatEditor.put(clzz, editor);
}
/**
* 注册图表的 预定义样式.
* @param action 注册的图表预定义样式action
*/
public static void registerChartPreStyleAction(UpdateAction action) {
chartPreStyleAction = action;
}
/**
* 返回 图表预定义样式Action
*/
public static UpdateAction getChartPreStyleAction() {
return chartPreStyleAction;
}
/**
* kunsnat: 图表注册 悬浮元素编辑器 , 因为ChartCollecion和ChartQuickEditor一个在Chart,一个在Designer, 所以分开注册.
* @param clzz 待说明
*/
public static void registerChartCollection(Class clzz) {
chartCollectionClass = clzz;
}
public static Class getChartCollectionClass() {
return chartCollectionClass;
}
/**
* kunsnat: 图表注册 悬浮元素编辑器 , 因为ChartCollecion和ChartQuickEditor一个在Chart,一个在Designer, 所以分开注册.
* @param editor 待说明
*/
public static void registerChartFloatEditorInEditor(QuickEditor editor) {
if(chartCollectionClass != null) {
floatEditor.put(chartCollectionClass, editor);
}
}
/**
* kunsnat: 图表注册 悬浮元素编辑器 , 因为ChartCollecion和ChartQuickEditor一个在Chart,一个在Designer, 所以分开注册.
* @param editor 待说明
*/
public static void registerChartCellEditorInEditor(QuickEditor editor) {
if(chartCollectionClass != null) {
cellEditor.put(chartCollectionClass, editor);
}
}
/**
* 返回 悬浮元素选中的Editor
*/
public static QuickEditor getFloatEditor(Class clazz) {
return floatEditor.get(clazz);
}
public static QuickEditor getCellEditor(Class clazz) {
return cellEditor.get(clazz);
}
/**
* peter:从Action来产生ToolTipText.
* @param action 动作
* @return 字符
*/
public static String createButtonToolTipText(Action action) {
StringBuffer buttonToolTipTextBuf = new StringBuffer();
//peter:把中文后面的(U),alt 快捷键的括号去掉,这个方法是临时的做法.
String actionName = (String) action.getValue(Action.NAME);
if (actionName.lastIndexOf("(") != -1) {
buttonToolTipTextBuf.append(actionName.substring(0, actionName.lastIndexOf("(")));
} else {
buttonToolTipTextBuf.append(actionName);
}
//peter:产生快捷键的ToolTip.
KeyStroke keyStroke = (KeyStroke) action.getValue(Action.ACCELERATOR_KEY);
if (keyStroke != null) {
buttonToolTipTextBuf.append(" (");
buttonToolTipTextBuf.append(KeyEvent.getKeyModifiersText(keyStroke.getModifiers()));
buttonToolTipTextBuf.append('+');
buttonToolTipTextBuf.append(KeyEvent.getKeyText(keyStroke.getKeyCode()));
buttonToolTipTextBuf.append(')');
}
return Utils.objectToString(buttonToolTipTextBuf);
}
/**
* 纪录插入元素的种类
*
* @param cls 类型数组
*/
public static void registerCellInsertActionClass(Class<UpdateAction>[] cls) {
actionClasses = cls;
}
/**
* 生成单元格插入相关的Action
*
* @param cls 构造函数参数类型
* @param obj 构造函数参数值
* @return 相关Action组成的一个数组
*/
public static UpdateAction[] createCellInsertAction(Class cls, Object obj) {
int length = 0;
JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
//表单中报表块编辑屏蔽掉 插入子报表
length = jTemplate.isJWorkBook()? actionClasses.length : actionClasses.length - 1;
UpdateAction[] actions = new UpdateAction[length];
for (int i = 0; i < length; i++) {
try {
Constructor<UpdateAction> c = actionClasses[i].getConstructor(cls);
actions[i] = c.newInstance(obj);
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
return actions;
}
/**
* 登记悬浮元素插入类型
*
* @param cls 插入类型数组
*/
public static void registerFloatInsertActionClass(Class<UpdateAction>[] cls) {
floatActionClasses = cls;
}
/**
* 生成悬浮元素插入相关的Action
*
* @param cls 构造函数参数类型
* @param obj 构造函数参数值
* @return 相关Action组成的一个数组
*/
public static UpdateAction[] createFloatInsertAction(Class cls, Object obj) {
UpdateAction[] actions = new UpdateAction[floatActionClasses.length];
for (int i = 0; i < floatActionClasses.length; i++) {
try {
Constructor<UpdateAction> c = floatActionClasses[i].getConstructor(cls);
actions[i] = c.newInstance(obj);
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
return actions;
}
}

37
designer_base/src/com/fr/design/actions/edit/CopyAction.java

@ -0,0 +1,37 @@
/*
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved.
*/
package com.fr.design.actions.edit;
import java.awt.event.KeyEvent;
import javax.swing.KeyStroke;
import com.fr.base.BaseUtils;
import com.fr.design.actions.TemplateComponentAction;
import com.fr.design.designer.TargetComponent;
import com.fr.general.Inter;
/**
* Copy.
*/
public class CopyAction extends TemplateComponentAction {
public CopyAction(TargetComponent t) {
super(t);
this.setName(Inter.getLocText("M_Edit-Copy"));
this.setMnemonic('C');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/copy.png"));
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_MASK));
}
@Override
public boolean executeActionReturnUndoRecordNeeded() {
TargetComponent tc = getEditingComponent();
if (tc != null) {
tc.copy();
}
return false;
}
}

39
designer_base/src/com/fr/design/actions/edit/CutAction.java

@ -0,0 +1,39 @@
/*
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved.
*/
package com.fr.design.actions.edit;
import java.awt.event.KeyEvent;
import javax.swing.KeyStroke;
import com.fr.base.BaseUtils;
import com.fr.design.actions.TemplateComponentAction;
import com.fr.design.designer.TargetComponent;
import com.fr.general.Inter;
/**
* Cut.
*/
public class CutAction extends TemplateComponentAction {
/**
* Constructor
*/
public CutAction(TargetComponent t) {
super(t);
this.setName(Inter.getLocText("M_Edit-Cut"));
this.setMnemonic('T');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/cut.png"));
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, KeyEvent.CTRL_MASK));
}
@Override
public boolean executeActionReturnUndoRecordNeeded() {
TargetComponent editPane = getEditingComponent();
if (editPane == null) {
return false;
}
return editPane.cut();
}
}

39
designer_base/src/com/fr/design/actions/edit/PasteAction.java

@ -0,0 +1,39 @@
/*
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved.
*/
package com.fr.design.actions.edit;
import java.awt.event.KeyEvent;
import javax.swing.KeyStroke;
import com.fr.base.BaseUtils;
import com.fr.design.actions.TemplateComponentAction;
import com.fr.design.designer.TargetComponent;
import com.fr.general.Inter;
/**
* Paste.
*/
public class PasteAction extends TemplateComponentAction {
/**
* Constructor
*/
public PasteAction(TargetComponent t) {
super(t);
this.setName(Inter.getLocText("M_Edit-Paste"));
this.setMnemonic('P');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/paste.png"));
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.CTRL_MASK));
}
@Override
public boolean executeActionReturnUndoRecordNeeded() {
TargetComponent tc = getEditingComponent();
if (tc == null) {
return false;
}
return tc.paste();
}
}

59
designer_base/src/com/fr/design/actions/edit/RedoAction.java

@ -0,0 +1,59 @@
/*
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved.
*/
package com.fr.design.actions.edit;
import java.awt.event.ActionEvent;
import com.fr.base.BaseUtils;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.TemplateComponentActionInterface;
import com.fr.design.actions.UpdateAction;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.menu.KeySetUtils;
/**
* Redo.
*/
public class RedoAction extends UpdateAction implements TemplateComponentActionInterface<JTemplate<?, ?>> {
private JTemplate<?, ?> t;
public RedoAction(JTemplate<?, ?> t) {
this.t = t;
this.setMenuKeySet(KeySetUtils.REDO);
this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/redo.png"));
this.setAccelerator(getMenuKeySet().getKeyStroke());
}
@Override
public JTemplate<?, ?> getEditingComponent() {
return t;
}
/**
* 动作
* @param e 事件
*/
public void actionPerformed(ActionEvent e) {
JTemplate<?, ?> uncComponent = getEditingComponent();
if (uncComponent != null) {
uncComponent.redo();
}
}
/**
* update enable
*/
@Override
public void update() {
JTemplate<?, ?> undoComponent = getEditingComponent();
if (DesignerEnvManager.getEnvManager().isSupportUndo()) {
this.setEnabled(undoComponent != null && undoComponent.canRedo());
} else {
this.setEnabled(false);
}
}
}

60
designer_base/src/com/fr/design/actions/edit/UndoAction.java

@ -0,0 +1,60 @@
/*
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved.
*/
package com.fr.design.actions.edit;
import java.awt.event.ActionEvent;
import com.fr.base.BaseUtils;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.TemplateComponentActionInterface;
import com.fr.design.actions.UpdateAction;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.menu.KeySetUtils;
/**
* Undo.
*/
public class UndoAction extends UpdateAction implements TemplateComponentActionInterface<JTemplate<?,?>> {
private JTemplate<?, ?> t;
public UndoAction(JTemplate<?, ?> t) {
this.t = t;
this.setMenuKeySet(KeySetUtils.UNDO);
this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/undo.png"));
this.setAccelerator(getMenuKeySet().getKeyStroke());
}
@Override
public JTemplate<?, ?> getEditingComponent() {
return t;
}
/**
* 动作
* @param e 事件
*/
public void actionPerformed(ActionEvent e) {
JTemplate<?, ?> undoComponent = getEditingComponent();
if (undoComponent != null) {
undoComponent.undo();
}
}
/**
* update enable
*/
@Override
public void update() {
JTemplate<?, ?> undoComponent = getEditingComponent();
if (DesignerEnvManager.getEnvManager().isSupportUndo()) {
this.setEnabled(undoComponent != null && undoComponent.canUndo());
} else {
this.setEnabled(false);
}
}
}

1
designer_base/src/com/fr/design/actions/file/CloseCurrentTemplateAction.java

@ -0,0 +1 @@
package com.fr.design.actions.file; import com.fr.design.actions.UpdateAction; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.MutilTempalteTabPane; import com.fr.design.menu.KeySetUtils; import java.awt.event.ActionEvent; /** * Author : daisy * Date: 13-8-16 * Time: 下午3:23 */ public class CloseCurrentTemplateAction extends UpdateAction { public CloseCurrentTemplateAction() { this.setMenuKeySet(KeySetUtils.CLOSE_CURRENT_TEMPLATE); this.setName(getMenuKeySet().getMenuKeySetName()); this.setMnemonic(getMenuKeySet().getMnemonic()); this.setAccelerator(getMenuKeySet().getKeyStroke()); } /** * 动作 * @param e 事件 */ public void actionPerformed(ActionEvent e) { MutilTempalteTabPane.getInstance().setIsCloseCurrent(true); MutilTempalteTabPane.getInstance().closeFormat(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); MutilTempalteTabPane.getInstance().closeSpecifiedTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); } }

29
designer_base/src/com/fr/design/actions/file/CloseTemplateAction.java

@ -0,0 +1,29 @@
/*
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved.
*/
package com.fr.design.actions.file;
import java.awt.event.ActionEvent;
import com.fr.design.actions.JTemplateAction;
import com.fr.design.mainframe.JTemplate;
import com.fr.general.Inter;
/**
* Close Report.
*/
public class CloseTemplateAction extends JTemplateAction<JTemplate<?, ?>> {
/**
* Constructor
*/
public CloseTemplateAction(JTemplate<?, ?> jt) {
super(jt);
this.setName(Inter.getLocText("M-Close_Template"));
this.setMnemonic('C');
}
public void actionPerformed(ActionEvent evt) {
// this.getEditingComponent().unlockTemplate();
}
}

22
designer_base/src/com/fr/design/actions/file/EditEnvAction.java

@ -0,0 +1,22 @@
package com.fr.design.actions.file;
import java.awt.event.ActionEvent;
import com.fr.design.actions.UpdateAction;
import com.fr.design.mainframe.TemplatePane;
import com.fr.general.Inter;
public class EditEnvAction extends UpdateAction {
public EditEnvAction() {
this.setName(Inter.getLocText("M-Others") + "...");
}
@Override
public void actionPerformed(ActionEvent e) {
TemplatePane.getInstance().editItems();
}
}

32
designer_base/src/com/fr/design/actions/file/ExitDesignerAction.java

@ -0,0 +1,32 @@
/*
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved.
*/
package com.fr.design.actions.file;
import java.awt.event.ActionEvent;
import com.fr.design.actions.UpdateAction;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.menu.KeySetUtils;
/**
* Exit.
*/
public class ExitDesignerAction extends UpdateAction {
/**
* Constructor
*/
public ExitDesignerAction() {
this.setMenuKeySet(KeySetUtils.EXIT_DESIGNER);
this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic());
}
/**
* 动作
* @param e 事件
*/
public void actionPerformed(ActionEvent e) {
DesignerContext.getDesignerFrame().exit();
}
}

243
designer_base/src/com/fr/design/actions/file/LocalePane.java

@ -0,0 +1,243 @@
/*
* Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved.
*/
package com.fr.design.actions.file;
import java.awt.BorderLayout;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import java.util.Vector;
import javax.swing.JTable;
import javax.swing.RowFilter;
import javax.swing.SwingWorker;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableRowSorter;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.dialog.BasicPane;
import com.fr.file.filetree.FileNode;
import com.fr.general.FRLogger;
import com.fr.general.GeneralUtils;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
import com.fr.stable.ArrayUtils;
import com.fr.stable.project.ProjectConstants;
/**
* @author : richie
* @since : 8.0
*/
public class LocalePane extends BasicPane {
private static final String FR = "fr.properties";
private static final String US = "fr_en_US.properties";
private static final String CN = "fr_zh_CN.properties";
private static final String JP = "fr_ja_JP.properties";
private static final String TW = "fr_zh_TW.properties";
private static final String PREFIX = "fr_";
private static final int LOCALE_NAME_LEN = 5;
private UITabbedPane tabbedPane;
private JTable predefinedTable;
private JTable customTable;
private DefaultTableModel predefineTableModel;
private DefaultTableModel customTableModel;
public LocalePane() {
tabbedPane = new UITabbedPane();
setLayout(new BorderLayout());
final UITextField searchTextField = new UITextField();
add(searchTextField, BorderLayout.NORTH);
add(tabbedPane, BorderLayout.CENTER);
predefineTableModel = new DefaultTableModel() {
public boolean isCellEditable(int col, int row) {
return false;
}
};
predefinedTable = new JTable(predefineTableModel);
final TableRowSorter sorter = new TableRowSorter(predefineTableModel);
predefinedTable.setRowSorter(sorter);
customTableModel = new DefaultTableModel();
customTable = new JTable(customTableModel);
final TableRowSorter customSorter = new TableRowSorter(customTableModel);
customTable.setRowSorter(customSorter);
searchTextField.getDocument().addDocumentListener(new DocumentListener() {
public void insertUpdate(DocumentEvent e) {
customSorter.setRowFilter(RowFilter.regexFilter(searchTextField.getText()));
sorter.setRowFilter(RowFilter.regexFilter(searchTextField.getText()));
}
public void removeUpdate(DocumentEvent e) {
customSorter.setRowFilter(RowFilter.regexFilter(searchTextField.getText()));
sorter.setRowFilter(RowFilter.regexFilter(searchTextField.getText()));
}
public void changedUpdate(DocumentEvent e) {
customSorter.setRowFilter(RowFilter.regexFilter(searchTextField.getText()));
sorter.setRowFilter(RowFilter.regexFilter(searchTextField.getText()));
}
});
tabbedPane.addTab(Inter.getLocText("Preference-Predefined"), new UIScrollPane(predefinedTable));
tabbedPane.addTab(Inter.getLocText("Preference-Custom"), new UIScrollPane(customTable));
loadData();
}
private void loadData() {
new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
initPredefinedProperties();
initCustomProperties();
return null;
}
public void done() {
predefineTableModel.fireTableDataChanged();
customTableModel.fireTableDataChanged();
}
}.execute();
}
private void initPredefinedProperties() {
Properties fr = loadLocaleProperties(FR);
Properties us = loadLocaleProperties(US);
Properties cn = loadLocaleProperties(CN);
Properties jp = loadLocaleProperties(JP);
Properties tw = loadLocaleProperties(TW);
Set<String> keys = fr.stringPropertyNames();
List<String> sortKeys = new ArrayList<String>(keys);
Collections.sort(sortKeys);
Vector<String> keyVector = new Vector<String>();
Vector<String> valueVector = new Vector<String>();
Vector<String> usVector = new Vector<String>();
Vector<String> cnVector = new Vector<String>();
Vector<String> jpVector = new Vector<String>();
Vector<String> twVector = new Vector<String>();
for (String key : sortKeys) {
keyVector.add(key);
valueVector.add(fr.getProperty(key));
usVector.add(us.getProperty(key));
cnVector.add(cn.getProperty(key));
jpVector.add(jp.getProperty(key));
twVector.add(tw.getProperty(key));
}
predefineTableModel.addColumn(Inter.getLocText("Key"), keyVector);
predefineTableModel.addColumn(Inter.getLocText("Value"), valueVector);
predefineTableModel.addColumn("en_US", usVector);
predefineTableModel.addColumn("zh_CN", cnVector);
predefineTableModel.addColumn("ja_JP", jpVector);
predefineTableModel.addColumn("zh_TW", twVector);
}
private void initCustomProperties() throws Exception {
Env env = FRContext.getCurrentEnv();
if (env == null) {
return;
}
FileNode[] fileNodes = env.listFile(ProjectConstants.LOCALE_NAME);
if (ArrayUtils.getLength(fileNodes) == 0) {
return;
}
List<Properties> list = new ArrayList<Properties>();
Set<String> keys = new HashSet<String>();
customTableModel.addColumn(Inter.getLocText("Key"));
for (FileNode fileNode : fileNodes) {
String fileName = fileNode.getName();
if (fileName.endsWith(".properties")) {
InputStream in = env.readBean(fileName, ProjectConstants.LOCALE_NAME);
Properties properties = new Properties();
properties.load(in);
keys.addAll(properties.stringPropertyNames());
list.add(properties);
customTableModel.addColumn(fileName.substring(PREFIX.length(), LOCALE_NAME_LEN + PREFIX.length()));
}
}
List<String> sortKeys = new ArrayList<String>(keys);
Collections.sort(sortKeys);
for (String key : sortKeys) {
Vector<String> vector = new Vector<String>();
vector.add(key);
for (int i = 0; i < list.size(); i ++) {
vector.add(list.get(i).getProperty(key));
}
customTableModel.addRow(vector);
}
}
private Properties loadLocaleProperties(String name) {
Properties properties = new Properties();
InputStream inputStream = IOUtils.readResource("/com/fr/general/locale/" + name);
try {
properties.load(inputStream);
} catch (IOException e) {
FRLogger.getLogger().error(e.getMessage());
}
return properties;
}
/**
* 保存当前编辑的国际化
*
*
* @date 2014-9-30-下午3:10:30
*/
public void save() {
Env env = FRContext.getCurrentEnv();
if (env == null) {
return;
}
if (customTable.getCellEditor() == null) {
return;
}
customTable.getCellEditor().stopCellEditing();
for (int i = 1, columnCount = customTableModel.getColumnCount(); i < columnCount; i ++) {
String fileName = customTableModel.getColumnName(i);
Properties properties = new Properties();
for (int j = 0, rowCount = customTableModel.getRowCount(); j < rowCount; j ++) {
properties.setProperty(GeneralUtils.objectToString(customTableModel.getValueAt(j, 0)), GeneralUtils.objectToString(customTableModel.getValueAt(j, i)));
}
OutputStream out = null;
try {
out = env.writeBean(PREFIX + fileName + ".properties", ProjectConstants.LOCALE_NAME);
properties.store(out, null);
out.flush();
out.close();
} catch (Exception e) {
FRLogger.getLogger().info(e.getMessage());
}
}
}
@Override
protected String title4PopupWindow() {
return Inter.getLocText("Preference-Locale");
}
}

78
designer_base/src/com/fr/design/actions/file/OpenRecentReportMenuDef.java

@ -0,0 +1,78 @@
package com.fr.design.actions.file;
import java.awt.event.ActionEvent;
import java.util.List;
import com.fr.base.BaseUtils;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.UpdateAction;
import com.fr.design.gui.imenu.UIMenu;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.menu.KeySetUtils;
import com.fr.design.menu.MenuDef;
import com.fr.file.FILEFactory;
/**
* Open Resent MenuDef.
*/
public class OpenRecentReportMenuDef extends MenuDef {
public OpenRecentReportMenuDef() {
this.setMenuKeySet(KeySetUtils.RECENT_OPEN);
this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setIconPath("/com/fr/base/images/cell/blank.gif");
initMenuDef();
}
private void initMenuDef() {
DesignerEnvManager designerEnvManager = DesignerEnvManager.getEnvManager();
List<String> list = designerEnvManager.getRecentOpenedFilePathList();
for (int i = 0; i < list.size(); i++) {
this.addShortCut(new OpenRecentReportAction(list.get(i)));
}
}
/**
* 更新菜单
*/
public void updateMenu() {
UIMenu createdMenu = this.createJMenu();
createdMenu.removeAll();
this.clearShortCuts();
initMenuDef();
int menuCount = this.getShortCutCount();
for (int i = 0; i < menuCount; i++) {
Object object = this.getShortCut(i);
if (!(object instanceof OpenRecentReportAction)) {
return;
}
OpenRecentReportAction openResentReportAction = (OpenRecentReportAction) object;
openResentReportAction.update();
if (openResentReportAction.isEnabled()) {
createdMenu.add(openResentReportAction.createMenuItem());
}
}
}
public static class OpenRecentReportAction extends UpdateAction {
public OpenRecentReportAction() {
}
public OpenRecentReportAction(String cptName) {
this.setName(cptName);
this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/oem/logo.png"));
}
/**
* 动作
* @param e 事件
*/
public void actionPerformed(ActionEvent e) {
DesignerContext.getDesignerFrame().openTemplate(FILEFactory.createFILE(this.getPath()));
}
public String getPath() {
return this.getName();
}
}
}

45
designer_base/src/com/fr/design/actions/file/OpenTemplateAction.java

@ -0,0 +1,45 @@
/*
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved.
*/
package com.fr.design.actions.file;
import java.awt.event.ActionEvent;
import com.fr.base.BaseUtils;
import com.fr.design.actions.UpdateAction;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.menu.KeySetUtils;
import com.fr.file.FILE;
import com.fr.file.FILEChooserPane;
/**
* Open Template.
*/
public class OpenTemplateAction extends UpdateAction {
public OpenTemplateAction() {
this.setMenuKeySet(KeySetUtils.OPEN_TEMPLATE);
this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/open.png"));
this.setAccelerator(getMenuKeySet().getKeyStroke());
}
/**
* 动作
* @param evt 事件
*/
public void actionPerformed(ActionEvent evt) {
FILEChooserPane fileChooser = FILEChooserPane.getInstance(true, true);
if (fileChooser.showOpenDialog(DesignerContext.getDesignerFrame())
== FILEChooserPane.OK_OPTION) {
final FILE file = fileChooser.getSelectedFILE();
if (file == null) {//选择的文件不能是 null
return;
}
DesignerContext.getDesignerFrame().openTemplate(file);
}
}
}

46
designer_base/src/com/fr/design/actions/file/PreferenceAction.java

@ -0,0 +1,46 @@
package com.fr.design.actions.file;
import java.awt.event.ActionEvent;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.UpdateAction;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.menu.KeySetUtils;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
public class PreferenceAction extends UpdateAction {
public PreferenceAction() {
this.setMenuKeySet(KeySetUtils.PREFERENCE);
this.setName(getMenuKeySet().getMenuKeySetName()+"...");
this.setMnemonic(getMenuKeySet().getMnemonic());
}
/**
* 动作
* @param e 事件
*/
public void actionPerformed(ActionEvent e) {
final DesignerFrame designerFrame = DesignerContext.getDesignerFrame();
final PreferencePane preferencePane = new PreferencePane();
preferencePane.populate(DesignerEnvManager.getEnvManager());
BasicDialog basicDialog = preferencePane.showWindow(designerFrame);
basicDialog.addDialogActionListener(new DialogActionAdapter() {
public void doOk() {
preferencePane.update(DesignerEnvManager.getEnvManager());
DesignerEnvManager.loadLogSetting();
DesignerEnvManager.getEnvManager().saveXMLFile();
JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
jt.refreshToolArea();
}
});
basicDialog.setVisible(true);
}
}

633
designer_base/src/com/fr/design/actions/file/PreferencePane.java

@ -0,0 +1,633 @@
package com.fr.design.actions.file;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.util.Locale;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import com.fr.base.BaseUtils;
import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.editor.editor.IntegerEditor;
import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.ActionLabel;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLevel;
import com.fr.general.Inter;
/**
* 选项对话框
*
* @editor zhou
* @since 2012-3-28下午3:39:48
*/
public class PreferencePane extends BasicPane {
private static final int MAX_UNDO_LIMIT_5 = 5;
private static final int MAX_UNDO_LIMIT_10 = 10;
private static final int MAX_UNDO_LIMIT_15 = 15;
private static final int MAX_UNDO_LIMIT_20 = 20;
private static final int MAX_UNDO_LIMIT_50 = 50;
private static final int SELECTED_INDEX_4 = 4;
private static final int SELECTED_INDEX_5 = 5;
private static final String TYPE = "pressed";
private static final String DISPLAY_TYPE = "+";
private static final String BACK_SLASH = "BACK_SLASH";
private static final String DISPLAY_BACK_SLASH = "\\";
private static final String SLASH = "SLASH";
private static final String DISPLAY_SLASH = "/";
private static final String CONTROL = "CONTROL";
private static final String DISPLAY_CONTROL = "ctrl";
private static final String OPEN_BRACKET = "OPEN_BRACKET";
private static final String DISPLAY_OPEN_BRACKET = "{";
private static final String CLOSE_BRACKET = "CLOSE_BRACKET";
private static final String DISPLAY_CLOSE_BRACKET = "}";
private static final String COMMA = "COMMA";
private static final String DISPLAY_COMMA = ",";
private static final String PERIOD = "PERIOD";
private static final String DISPLAY_PERIOD = ".";
private static final String SEMICOLON = "SEMICOLON";
private static final String DISPLAY_SEMICOLON = ";";
private static final String QUOTE = "QUOTE";
private static final String DISPLAY_QUOTE = "'";
private static final String EQUALS = "EQUALS";
private static final String DISPLAY_EQUALS = "+";
private static final String MINUS = "MINUS";
private static final String DISPLAY_MINUS = "-";
private static final FRLevel[] LOG = {FRLevel.SEVERE, FRLevel.WARNING, FRLevel.INFO, FRLevel.DEBUG};
private static final String[] LANGUAGE = {Inter.getLocText("FR-Designer_Language_Default"),
getLocaledLanguage("Simplified_Chinese_Language", Locale.SIMPLIFIED_CHINESE),
getLocaledLanguage("English_Language", Locale.ENGLISH),
getLocaledLanguage("Japanese_Language", Locale.JAPAN),
getLocaledLanguage("Traditional_Chinese_Language", Locale.TRADITIONAL_CHINESE)};
//设置是否支持undo
private UICheckBox supportUndoCheckBox;
//设置最大撤销次数
private UIComboBox maxUndoLimit;
//是非支持自动计算父格
private UICheckBox supportDefaultParentCalculateCheckBox;
//是否自动转化为公式
private UICheckBox supportStringToFormulaBox;
private UICheckBox defaultStringToFormulaBox;
private UILabel shortCutLabel;
private KeyStroke shortCutKeyStore = null;
private UIColorButton gridLineColorTBButton;
private UIColorButton paginationLineColorTBButton;
private UICheckBox supportCellEditorDefCheckBox;
private UICheckBox isDragPermitedCheckBox;
private UITextField logExportDirectoryField;
private UIComboBox logLevelComboBox, languageComboBox, pageLengthComboBox, reportLengthComboBox;
private IntegerEditor portEditor;
private UITextField jdkHomeTextField;
private UICheckBox oracleSpace;
private UICheckBox joinProductImprove;
public PreferencePane() {
this.initComponents();
}
protected void initComponents() {
JPanel contentPane = this;
contentPane.setLayout(FRGUIPaneFactory.createBorderLayout());
UITabbedPane jtabPane = new UITabbedPane();
JPanel generalPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
jtabPane.addTab(Inter.getLocText("FR-Designer_General"), generalPane);
JPanel advancePane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
jtabPane.addTab(Inter.getLocText("FR-Designer_Advanced"), advancePane);
contentPane.add(jtabPane, BorderLayout.NORTH);
createFunctionPane(generalPane);
createEditPane(generalPane);
createGuiOfGridPane(generalPane);
createColorSettingPane(generalPane);
// ConfPane
JPanel confLocationPane = FRGUIPaneFactory.createX_AXISBoxInnerContainer_S_Pane();
advancePane.add(confLocationPane);
createLogPane(advancePane);
createLanPane(generalPane);
createLengthPane(advancePane);
createServerPane(advancePane);
createJdkHomePane(advancePane);
String[] message = new String[]{"Display", "Oracle_All_Tables"};
String[] sign = new String[]{"Oracle"};
JPanel oraclePane = FRGUIPaneFactory.createTitledBorderPane("Oracle" + Inter.getLocText("FR-Designer_Oracle_All_Tables"));
oracleSpace = new UICheckBox(Inter.getLocText(message, sign));
oraclePane.add(oracleSpace);
JPanel improvePane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("FR-Designer_Product_improve"));
joinProductImprove = new UICheckBox(Inter.getLocText("FR-Designer_Join_Product_improve"));
improvePane.add(joinProductImprove);
JPanel spaceUpPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
spaceUpPane.add(oraclePane, BorderLayout.NORTH);
spaceUpPane.add(improvePane, BorderLayout.SOUTH);
advancePane.add(spaceUpPane);
}
private static String getLocaledLanguage(String key, Locale locale){
StringBuilder sb = new StringBuilder();
sb.append(Inter.getLocText(key)).append("(");
sb.append(Inter.getLocText(key, locale)).append(")");
return sb.toString();
}
private void createFunctionPane(JPanel generalPane) {
JPanel functionPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("FR-Designer_Preference-Function"));
generalPane.add(functionPane);
//添加supportUndo选择项
supportUndoCheckBox = new UICheckBox(Inter.getLocText("Preference-Support_Undo"));
functionPane.add(supportUndoCheckBox);
//添加maxUndoLimit
//String[] undoTimes = {"最大撤销次数","5次","10次","15次","20次","50次"};
String[] undoTimes = {Inter.getLocText("FR-Designer_max_undo_limit"), MAX_UNDO_LIMIT_5 + Inter.getLocText("FR-Designer_time(s)"), MAX_UNDO_LIMIT_10 + Inter.getLocText("FR-Designer_time(s)")
, MAX_UNDO_LIMIT_15 + Inter.getLocText("FR-Designer_time(s)"), MAX_UNDO_LIMIT_20 + Inter.getLocText("FR-Designer_time(s)"), MAX_UNDO_LIMIT_50 + Inter.getLocText("FR-Designer_time(s)")};
maxUndoLimit = new UIComboBox(undoTimes);
functionPane.add(maxUndoLimit);
//不支持撤销则不能选择撤销可缓存,也不能设置最大撤销次数
supportUndoCheckBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
maxUndoLimit.setEnabled(supportUndoCheckBox.isSelected());
}
});
//添加supportDefaultParentCalculate选择项
supportDefaultParentCalculateCheckBox = new UICheckBox(
Inter.getLocText("Preference-Support_Default_Parent_Calculate"));
functionPane.add(supportDefaultParentCalculateCheckBox);
}
private void createEditPane(JPanel generalPane) {
//samuel:编辑器设置
JPanel editPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText(new String[]{"Editor", "Set"}));
generalPane.add(editPane);
//设置是否支持将字符串编辑为公式
supportStringToFormulaBox = new UICheckBox(Inter.getLocText("FR-Designer_Surport_String_To_Formula"));
editPane.add(supportStringToFormulaBox);
//是否默认转化
defaultStringToFormulaBox = new UICheckBox(Inter.getLocText("FR-Designer_Always"));
editPane.add(defaultStringToFormulaBox);
//不支持转化则不能默认执行
supportStringToFormulaBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
defaultStringToFormulaBox.setEnabled(supportStringToFormulaBox.isSelected());
}
});
JPanel keyStrokePane = new JPanel(new BorderLayout());
keyStrokePane.add(new UILabel(Inter.getLocText("Support-Auto_Complete_Shortcut") + ":"), BorderLayout.WEST);
shortCutLabel = new UILabel();
keyStrokePane.add(shortCutLabel, BorderLayout.CENTER);
editPane.add(keyStrokePane);
shortCutLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() > 1) {
final KeyStrokePane basicPane = new KeyStrokePane(shortCutLabel.getText());
BasicDialog dlg = basicPane.showSmallWindow(SwingUtilities.getWindowAncestor(PreferencePane.this), new DialogActionAdapter() {
@Override
public void doOk() {
shortCutLabel.setText(basicPane.getText());
}
});
dlg.setVisible(true);
}
}
});
}
private class KeyStrokePane extends BasicPane {
private UILabel label;
public KeyStrokePane(String text) {
setLayout(new BorderLayout());
setFocusable(true);
requestFocusInWindow();
label = new UILabel(text);
add(GUICoreUtils.createBorderLayoutPane(
new UILabel(Inter.getLocText("Support-Current_Auto_Complete_Shortcut") + ":"),
BorderLayout.WEST,
label,
BorderLayout.CENTER),
BorderLayout.NORTH);
addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
int modifier = e.getModifiers();
if (modifier == 0) {
return;
}
int keyCode = e.getKeyCode();
shortCutKeyStore = KeyStroke.getKeyStroke(keyCode, modifier);
String str = shortCutKeyStore.toString();
label.setText(getDisplayShortCut(str));
}
});
}
public String getText() {
return label.getText();
}
@Override
protected String title4PopupWindow() {
return "KeyStroke";
}
}
private void createGuiOfGridPane(JPanel generalPane) {
// GridPane
JPanel guiOfGridPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("Preference-Setting_Grid"));
generalPane.add(guiOfGridPane);
supportCellEditorDefCheckBox = new UICheckBox(Inter.getLocText("Preference-Support_Cell_Editor_Definition"));
guiOfGridPane.add(supportCellEditorDefCheckBox);
isDragPermitedCheckBox = new UICheckBox(Inter.getLocText("Preference-Is_Drag_Permited"));
guiOfGridPane.add(isDragPermitedCheckBox);
}
private void createColorSettingPane(JPanel generalPane) {
// Color Setting Pane
JPanel colorSettingPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("Preference-Setting_Colors"));
generalPane.add(colorSettingPane);
new UILabel(Inter.getLocText("Preference-Grid_Line_Color"));
new UILabel(Inter.getLocText("Preference-Pagination_Line_Color"));
gridLineColorTBButton = new UIColorButton(BaseUtils.readIcon("/com/fr/design/images/gui/color/foreground.png"));
gridLineColorTBButton.setEnabled(this.isEnabled());
paginationLineColorTBButton = new UIColorButton(BaseUtils.readIcon("/com/fr/design/images/gui/color/foreground.png"));
paginationLineColorTBButton.setEnabled(this.isEnabled());
JPanel leftPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
leftPane.add(new UILabel(Inter.getLocText("Preference-Grid_Line_Color") + ":"));
leftPane.add(gridLineColorTBButton);
JPanel rightPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
rightPane.add(new UILabel(Inter.getLocText("Preference-Pagination_Line_Color") + ":"));
rightPane.add(paginationLineColorTBButton);
colorSettingPane.add(leftPane);
colorSettingPane.add(rightPane);
}
private void createLogPane(JPanel advancePane) {
//richer:选择导出log文件的目录.
JPanel logPane = FRGUIPaneFactory.createX_AXISBoxInnerContainer_S_Pane();
advancePane.add(logPane);
JPanel logExportPane = FRGUIPaneFactory.createTitledBorderPane("log" + Inter.getLocText("FR-Designer_Export_Setting"));
logPane.add(logExportPane);
UILabel logLabel = new UILabel(Inter.getLocText("FR-Designer_Select_Export_Log_Directory") + ":");
logExportPane.add(logLabel, BorderLayout.WEST);
logExportDirectoryField = new UITextField(24);
logExportPane.add(logExportDirectoryField, BorderLayout.CENTER);
UIButton chooseDirBtn = new UIButton("...");
logExportPane.add(chooseDirBtn, BorderLayout.EAST);
chooseDirBtn.setPreferredSize(new Dimension(25, 25));
chooseDirBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int saveValue = fileChooser.showOpenDialog(DesignerContext.getDesignerFrame());
if (saveValue == JFileChooser.APPROVE_OPTION) {
File selectedFile = fileChooser.getSelectedFile();
logExportDirectoryField.setText(selectedFile.getAbsolutePath());
}
}
});
JPanel logLevelPane = FRGUIPaneFactory.createTitledBorderPane("log" + Inter.getLocText("FR-Designer_Level_Setting"));
logPane.add(logLevelPane);
logLevelComboBox = new UIComboBox(LOG);
logLevelPane.add(logLevelComboBox);
logLevelComboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
DesignerEnvManager.getEnvManager().setLogLevel(((FRLevel) logLevelComboBox.getSelectedItem()).getLevel());
}
});
}
private void createLanPane(JPanel generalPane) {
// ben:选择版本语言;
JPanel languageAndDashBoard_pane = FRGUIPaneFactory.createX_AXISBoxInnerContainer_S_Pane();
JPanel LanguagePane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("FR-Designer_Choose_Language"));
generalPane.add(languageAndDashBoard_pane);
languageAndDashBoard_pane.add(LanguagePane);
languageComboBox = new UIComboBox(LANGUAGE);
ActionLabel languageLabel = new ActionLabel(Inter.getLocText("FR-Designer_Designer_Language"));
languageLabel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final LocalePane localePane = new LocalePane();
BasicDialog dlg = localePane.showLargeWindow(SwingUtilities.getWindowAncestor(PreferencePane.this), new DialogActionAdapter() {
@Override
public void doOk() {
localePane.save();
}
});
dlg.setVisible(true);
}
});
UILabel noticeLabel = new UILabel(Inter.getLocText("FR-Designer_Work_After_Restart_Designer"));//sail:提示重启后生效
double p = TableLayout.PREFERRED;
double rowSize[] = {p};
double columnSize[] = {p, p, p};
Component[][] components = {
{languageLabel, languageComboBox, noticeLabel},
};
languageComboBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
//Inter.fr = ResourceBundle.getBundle("com/fr/general/locale/fr", Locale.US);
}
});
JPanel choosePane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
LanguagePane.add(choosePane);
}
private String getDisplayShortCut(String shotrCut) {
return shotrCut.replace(TYPE, DISPLAY_TYPE).replace(BACK_SLASH, DISPLAY_BACK_SLASH).replace(SLASH, DISPLAY_SLASH)
.replace(CONTROL, DISPLAY_CONTROL).replace(OPEN_BRACKET, DISPLAY_OPEN_BRACKET).replace(CLOSE_BRACKET, DISPLAY_CLOSE_BRACKET)
.replace(COMMA, DISPLAY_COMMA).replace(PERIOD, DISPLAY_PERIOD).replace(SEMICOLON, DISPLAY_SEMICOLON).replace(QUOTE, DISPLAY_QUOTE)
.replace(EQUALS, DISPLAY_EQUALS).replace(MINUS, DISPLAY_MINUS);
}
private KeyStroke convert2KeyStroke(String ks) {
return KeyStroke.getKeyStroke(ks.replace(DISPLAY_TYPE, TYPE));
}
private void createLengthPane(JPanel advancePane) {
double p = TableLayout.PREFERRED;
double rowSize[] = {p};
// 长度单位选择
JPanel lengthPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("FR-Designer_Setting-Ruler-Units"));
advancePane.add(lengthPane);
pageLengthComboBox = new UIComboBox(new String[]{Inter.getLocText("FR-Designer_PageSetup-mm"), Inter.getLocText("FR-Designer_Unit_CM"), Inter.getLocText("FR-Designer_Unit_INCH")});
pageLengthComboBox.setPreferredSize(new Dimension(80, 20));
pageLengthComboBox.setMinimumSize(new Dimension(80, 20));
reportLengthComboBox = new UIComboBox(new String[]{Inter.getLocText("FR-Designer_PageSetup-mm"), Inter.getLocText("FR-Designer_Unit_CM"), Inter.getLocText("FR-Designer_Unit_INCH"), Inter.getLocText("FR-Designer_Unit_PT")});
reportLengthComboBox.setPreferredSize(new Dimension(80, 20));
reportLengthComboBox.setMinimumSize(new Dimension(80, 20));
UILabel pagelengthLabel = new UILabel(Inter.getLocText("FR-Designer_Page-Setup-Scale-Units") + ":");
UILabel reportLengthLabel = new UILabel(Inter.getLocText("FR-Designer_Report-Design-Ruler-Units") + ":");
Component[][] lengthComponents = {
{pagelengthLabel, pageLengthComboBox, reportLengthLabel, reportLengthComboBox},
};
JPanel chooseLengthPane = TableLayoutHelper.createTableLayoutPane(lengthComponents, rowSize, new double[]{p, p, p, p});
lengthPane.add(chooseLengthPane);
}
private void createServerPane(JPanel advancePane) {
double p = TableLayout.PREFERRED;
double rowSize[] = {p};
double columnSize[] = {p, p, p};
JPanel serverPortPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("FR-Designer_Web_Preview_Port_Setting"));
advancePane.add(serverPortPane);
portEditor = new IntegerEditor();
portEditor.setPreferredSize(new Dimension(80, 20));
portEditor.setMinimumSize(new Dimension(80, 20));
UILabel notiJlabel = new UILabel(Inter.getLocText("FR-Designer_Work_After_Restart_Designer"));
UILabel serverPortLabel = new UILabel(Inter.getLocText("FR-Designer_Web_Preview_Port") + ":");
Component[][] portComponents = {
{serverPortLabel, portEditor, notiJlabel},
};
JPanel choosePortPane = TableLayoutHelper.createTableLayoutPane(portComponents, rowSize, columnSize);
serverPortPane.add(choosePortPane, BorderLayout.CENTER);
}
private void createJdkHomePane(JPanel advancePane) {
double p = TableLayout.PREFERRED;
double rowSize[] = {p};
double columnSize[] = {p, p, p};
JPanel serverPortPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("Preference-JDK_Home"));
advancePane.add(serverPortPane);
jdkHomeTextField = new UITextField();
UIButton chooseBtn = new UIButton("...");
chooseBtn.setPreferredSize(new Dimension(20, 20));
JPanel panel = GUICoreUtils.createBorderLayoutPane(
jdkHomeTextField, BorderLayout.CENTER,
chooseBtn, BorderLayout.EAST
);
chooseBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int returnValue = fileChooser.showOpenDialog(PreferencePane.this);
if (returnValue == JFileChooser.APPROVE_OPTION) {
File file = fileChooser.getSelectedFile();
jdkHomeTextField.setText(file.getAbsolutePath());
}
}
});
panel.setPreferredSize(new Dimension(300, 20));
UILabel notiJlabel = new UILabel(Inter.getLocText("FR-Designer_Work_After_Restart_Designer"));
UILabel serverPortLabel = new UILabel(Inter.getLocText("Preference-JDK_Home") + ":");
Component[][] portComponents = {
{serverPortLabel, panel, notiJlabel},
};
JPanel choosePortPane = TableLayoutHelper.createTableLayoutPane(portComponents, rowSize, columnSize);
serverPortPane.add(choosePortPane, BorderLayout.CENTER);
}
@Override
protected String title4PopupWindow() {
return Inter.getLocText("M_Window-Preference");
}
/**
* The method of populate.
*
* @param designerEnvManager
*/
public void populate(DesignerEnvManager designerEnvManager) {
if (designerEnvManager == null) {
return;
}
supportUndoCheckBox.setSelected(designerEnvManager.isSupportUndo());
if (designerEnvManager.isSupportUndo()) {
maxUndoLimit.setSelectedIndex(chooseCase(designerEnvManager.getUndoLimit()));
} else {
maxUndoLimit.setEnabled(false);
}
supportDefaultParentCalculateCheckBox.setSelected(designerEnvManager.isSupportDefaultParentCalculate());
supportStringToFormulaBox.setSelected(designerEnvManager.isSupportStringToFormula());
shortCutLabel.setText(getDisplayShortCut(designerEnvManager.getAutoCompleteShortcuts()));
shortCutKeyStore = convert2KeyStroke(designerEnvManager.getAutoCompleteShortcuts());
if (supportStringToFormulaBox.isSelected()) {
defaultStringToFormulaBox.setEnabled(true);
defaultStringToFormulaBox.setSelected(designerEnvManager.isDefaultStringToFormula());
} else {
defaultStringToFormulaBox.setEnabled(false);
defaultStringToFormulaBox.setSelected(false);
}
supportCellEditorDefCheckBox.setSelected(designerEnvManager.isSupportCellEditorDef());
isDragPermitedCheckBox.setSelected(designerEnvManager.isDragPermited());
gridLineColorTBButton.setColor(designerEnvManager.getGridLineColor());
paginationLineColorTBButton.setColor(designerEnvManager.getPaginationLineColor());
this.logExportDirectoryField.setText(designerEnvManager.getLogLocation());
this.logLevelComboBox.setSelectedItem(FRLevel.getByLevel(designerEnvManager.getLogLevel()));
this.languageComboBox.setSelectedItem(LANGUAGE[designerEnvManager.getLanguage()]);
this.pageLengthComboBox.setSelectedIndex(designerEnvManager.getPageLengthUnit());
this.reportLengthComboBox.setSelectedIndex(designerEnvManager.getReportLengthUnit());
this.portEditor.setValue(new Integer(designerEnvManager.getJettyServerPort()));
this.jdkHomeTextField.setText(designerEnvManager.getJdkHome());
this.oracleSpace.setSelected(designerEnvManager.isOracleSystemSpace());
this.joinProductImprove.setSelected(designerEnvManager.isJoinProductImprove());
}
private int chooseCase(int sign) {
switch (sign) {
case 0:
return 0;
case MAX_UNDO_LIMIT_5:
return 1;
case MAX_UNDO_LIMIT_10:
return 2;
case MAX_UNDO_LIMIT_15:
return 3;
case MAX_UNDO_LIMIT_20:
return SELECTED_INDEX_4;
case MAX_UNDO_LIMIT_50:
return SELECTED_INDEX_5;
default:
return 1;
}
}
/**
* The method of update.
*/
public void update(DesignerEnvManager designerEnvManager) {
if (designerEnvManager == null) {
return;
}
designerEnvManager.setLogLocation(this.logExportDirectoryField.getText());
designerEnvManager.setLogLevel(((FRLevel) logLevelComboBox.getSelectedItem()).getLevel());
designerEnvManager.setSupportUndo(supportUndoCheckBox.isSelected());
designerEnvManager.setSupportDefaultParentCalculate(supportDefaultParentCalculateCheckBox.isSelected());
designerEnvManager.setSupportStringToFormula(supportStringToFormulaBox.isSelected());
designerEnvManager.setDefaultStringToFormula(defaultStringToFormulaBox.isSelected());
designerEnvManager.setSupportCellEditorDef(supportCellEditorDefCheckBox.isSelected());
designerEnvManager.setAutoCompleteShortcuts(shortCutKeyStore != null ? shortCutKeyStore.toString().replace(TYPE, DISPLAY_TYPE) : shortCutLabel.getText());
designerEnvManager.setDragPermited(isDragPermitedCheckBox.isSelected());
designerEnvManager.setGridLineColor(gridLineColorTBButton.getColor());
designerEnvManager.setPaginationLineColor(paginationLineColorTBButton.getColor());
designerEnvManager.setLanguage(getLanguageInt());
designerEnvManager.setPageLengthUnit((short) pageLengthComboBox.getSelectedIndex());
designerEnvManager.setReportLengthUnit((short) reportLengthComboBox.getSelectedIndex());
designerEnvManager.setJettyServerPort(portEditor.getValue().intValue());
designerEnvManager.setJdkHome(jdkHomeTextField.getText());
designerEnvManager.setOracleSystemSpace(this.oracleSpace.isSelected());
designerEnvManager.setJoinProductImprove(this.joinProductImprove.isSelected());
// designerEnvManager.setAutoBackUp(this.autoBackUp.isSelected());
designerEnvManager.setUndoLimit(maxUndoLimit.getSelectedIndex() * SELECTED_INDEX_5);
if (maxUndoLimit.getSelectedIndex() == SELECTED_INDEX_5) {
designerEnvManager.setUndoLimit(MAX_UNDO_LIMIT_50);
}
}
/*
* 得到所选语言的int值
*/
private int getLanguageInt() {
int l = 0;
String lang = (String) this.languageComboBox.getSelectedItem();
for (int i = 0; i < LANGUAGE.length; i++) {
if (ComparatorUtils.equals(lang, LANGUAGE[i])) {
l = i;
break;
}
}
return l;
}
}

48
designer_base/src/com/fr/design/actions/file/SaveAsTemplateAction.java

@ -0,0 +1,48 @@
/*
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved.
*/
package com.fr.design.actions.file;
import java.awt.event.ActionEvent;
import com.fr.base.BaseUtils;
import com.fr.design.actions.JTemplateAction;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.menu.KeySetUtils;
/**
* Save as file
*/
public class SaveAsTemplateAction extends JTemplateAction<JTemplate<?, ?>> {
public SaveAsTemplateAction(JTemplate<?, ?> dPane) {
super(dPane);
this.setMenuKeySet(KeySetUtils.SAVE_AS_TEMPLATE);
this.setName(getMenuKeySet().getMenuKeySetName() + "...");
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/saveAs.png"));
}
/**
* 动作
* @param e 事件
*/
public void actionPerformed(ActionEvent e) {
JTemplate<?, ?> jt = this.getEditingComponent();
// kunsnat: 保存前停止编辑状态,保存属性.
jt.stopEditing();
jt.saveAsTemplate();
this.setEnabled(true);
jt.requestFocus();
}
@Override
public void update() {
super.update();
// this.setEnabled(!this.getEditingComponent().isSaved());
// 另存为按钮应该一直可用使用
this.setEnabled(true);
}
}

45
designer_base/src/com/fr/design/actions/file/SaveTemplateAction.java

@ -0,0 +1,45 @@
/*
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved.
*/
package com.fr.design.actions.file;
import java.awt.event.ActionEvent;
import com.fr.base.BaseUtils;
import com.fr.design.actions.JTemplateAction;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.menu.KeySetUtils;
/**
* @author richer
* @since 6.5.3
*/
public class SaveTemplateAction extends JTemplateAction<JTemplate<?, ?>> {
public SaveTemplateAction(JTemplate<?, ?> jt) {
super(jt);
this.setMenuKeySet(KeySetUtils.SAVE_TEMPLATE);
this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/save.png"));
this.setAccelerator(getMenuKeySet().getKeyStroke());
}
/**
* 动作
* @param e 事件
*/
public void actionPerformed(ActionEvent e) {
JTemplate<?, ?> jt = this.getEditingComponent();
jt.stopEditing();
jt.saveTemplate();
jt.requestFocus();
}
@Override
public void update() {
super.update();
this.setEnabled(!this.getEditingComponent().isSaved());
}
}

127
designer_base/src/com/fr/design/actions/file/SwitchExistEnv.java

@ -0,0 +1,127 @@
package com.fr.design.actions.file;
import com.fr.base.BaseUtils;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.tabledata.ResponseDataSourceChange;
import com.fr.dav.LocalEnv;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.UpdateAction;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.TemplatePane;
import com.fr.design.menu.KeySetUtils;
import com.fr.design.menu.MenuDef;
import com.fr.design.menu.SeparatorDef;
import com.fr.design.dialog.InformationWarnPane;
import com.fr.env.RemoteEnv;
import com.fr.env.SignIn;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.general.GeneralContext;
import com.fr.general.Inter;
import com.fr.stable.LicUtils;
import com.fr.stable.ProductConstants;
import com.fr.stable.EnvChangedListener;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.logging.Level;
public class SwitchExistEnv extends MenuDef {
public SwitchExistEnv() {
this.setMenuKeySet(KeySetUtils.SWITCH_ENV);
this.setName(getMenuKeySet().getMenuName());
this.setHasScrollSubMenu(true);
initMenuDef();
GeneralContext.addEnvWillChangedListener(new EnvChangedListener() {
public void envChanged() {
SwitchExistEnv.this.clearShortCuts();
initMenuDef();
}
});
}
private void initMenuDef() {
//ButtonGroup group = new ButtonGroup();
Iterator<String> nameIt = DesignerEnvManager.getEnvManager().getEnvNameIterator();
while (nameIt.hasNext()) {
String name = nameIt.next();
this.setIconPath("com/fr/design/images/m_file/switch.png");
this.addShortCut(new GetExistEnvAction(name));
}
this.addShortCut(SeparatorDef.DEFAULT);
this.addShortCut(new EditEnvAction());
}
public static class GetExistEnvAction extends UpdateAction implements ResponseDataSourceChange {
public GetExistEnvAction() {
}
public GetExistEnvAction(String envName) {
this.setName(envName);
Env env = DesignerEnvManager.getEnvManager().getEnv(envName);
if (env instanceof LocalEnv) {
this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/data/bind/localconnect.png"));
} else if (env instanceof RemoteEnv) {
this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/data/bind/distanceconnect.png"));
}
}
/**
* 响应数据集改变
*/
public void fireDSChanged() {
fireDSChanged(new HashMap<String, String>());
}
/**
* 响应数据集改变
*
* @param map 数据集
*/
public void fireDSChanged(Map<String, String> map) {
DesignTableDataManager.fireDSChanged(map);
}
/**
* 动作
*
* @param e 事件
*/
public void actionPerformed(ActionEvent e) {
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
Env selectedEnv = envManager.getEnv(this.getName());
try {
if (selectedEnv instanceof RemoteEnv && !((RemoteEnv) selectedEnv).testServerConnection()) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"}));
return;
}
String remoteVersion = selectedEnv.getDesignerVersion();
if (StringUtils.isBlank(remoteVersion) || ComparatorUtils.compare(remoteVersion, ProductConstants.DESIGNER_VERSION) < 0) {
String infor = Inter.getLocText("Server-version-tip");
String moreInfo = Inter.getLocText("Server-version-tip-moreInfo");
FRLogger.getLogger().log(Level.WARNING, infor);
new InformationWarnPane(infor, moreInfo, Inter.getLocText("Tooltips")).show();
return;
}
SignIn.signIn(selectedEnv);
LicUtils.resetBytes();
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshToolArea();
fireDSChanged();
} catch (Exception em) {
FRContext.getLogger().error(em.getMessage(), em);
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"}));
TemplatePane.getInstance().editItems();
}
}
}
}

95
designer_base/src/com/fr/design/actions/file/WebPreviewUtils.java

@ -0,0 +1,95 @@
package com.fr.design.actions.file;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.utils.DesignUtils;
import com.fr.file.FILE;
import com.fr.file.FileNodeFILE;
import com.fr.general.GeneralUtils;
import com.fr.general.Inter;
import com.fr.general.web.ParameterConsts;
import com.fr.stable.project.ProjectConstants;
import javax.swing.*;
import java.util.Map;
public final class WebPreviewUtils {
public static void onWorkbookPreview(JTemplate<?, ?> jt) {
actionPerformed(jt, jt.getPreviewType().parametersForPreview(), ParameterConsts.REPORTLET);
}
public static void onFormPreview(JTemplate<?, ?> jt) {
actionPerformed(jt, null, ParameterConsts.FORMLET);
}
public static void actionPerformed(JTemplate<?, ?> jt, Map<String, Object> map, String actionType) {
if (jt == null) {
return;
}
DesignerContext.getDesignerFrame().refreshToolbar();
jt.stopEditing();
/*
* alex:如果没有保存,先保存到Env
*
* 如果保存失败,不执行下面的WebPreview
*/
if (!jt.isSaved() && !jt.saveTemplate2Env()) {
return;
}
FILE currentTemplate = jt.getEditingFILE();
// carl:是否是保存在运行环境下的模板,不是就不能被预览
if (currentTemplate instanceof FileNodeFILE) {
browseUrl(currentTemplate, map, actionType, jt);
} else {
// 说明模板没有保存在报表运行环境下面,提示用户
int selVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Web_Preview_Message"),
Inter.getLocText("Preview_ToolTips"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
if (JOptionPane.OK_OPTION == selVal) {
if (!jt.saveAsTemplate2Env()) {
return;
}
currentTemplate = jt.getEditingFILE();
browseUrl(currentTemplate, map, actionType, jt);
}
}
}
private static void browseUrl(FILE currentTemplate, Map<String, Object> map, String actionType, JTemplate<?, ?> jt) {
if (!(currentTemplate instanceof FileNodeFILE)) {
return;
}
if (currentTemplate.exists()) {
String path = currentTemplate.getPath();
if (path.startsWith(ProjectConstants.REPORTLETS_NAME)) {
path = path.substring(ProjectConstants.REPORTLETS_NAME.length() + 1);
java.util.List<String> parameterNameList = new java.util.ArrayList<String>();
java.util.List<String> parameterValueList = new java.util.ArrayList<String>();
parameterNameList.add(actionType);
parameterValueList.add(path);
if (map != null) {
for (String key : map.keySet()) {
parameterNameList.add(key);
parameterValueList.add(GeneralUtils.objectToString(map.get(key)));
}
}
DesignUtils.visitEnvServerByParameters(parameterNameList.toArray(new String[parameterNameList.size()]), parameterValueList.toArray(new String[parameterValueList.size()]));
}
} else {
int selVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Web_Preview_Message"),
Inter.getLocText("Preview_ToolTips"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
if (JOptionPane.OK_OPTION == selVal) {
if (!jt.saveAsTemplate()) {
return;
}
}
}
}
}

50
designer_base/src/com/fr/design/actions/help/AboutAction.java

@ -0,0 +1,50 @@
/*
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved.
*/
package com.fr.design.actions.help;
import com.fr.design.actions.UpdateAction;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.menu.MenuKeySet;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.event.ActionEvent;
/**
* help about.
*/
public class AboutAction extends UpdateAction {
public AboutAction() {
this.setMenuKeySet(ABOUT);
this.setName(getMenuKeySet().getMenuKeySetName()+"...");
this.setMnemonic(getMenuKeySet().getMnemonic());
}
/**
* 动作
* @param evt 事件
*/
public void actionPerformed(ActionEvent evt) {
AboutPane aboutPane = new AboutPane();
AboutDialog aboutDailog = new AboutDialog(DesignerContext.getDesignerFrame(), aboutPane);
aboutDailog.setVisible(true);
}
public static final MenuKeySet ABOUT = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'S';
}
@Override
public String getMenuName() {
return Inter.getLocText("M_Help-About_Software");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
}

100
designer_base/src/com/fr/design/actions/help/AboutDialog.java

@ -0,0 +1,100 @@
package com.fr.design.actions.help;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.AbstractAction;
import javax.swing.ActionMap;
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.KeyStroke;
import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.Inter;
import com.fr.stable.ProductConstants;
import com.fr.design.utils.gui.GUICoreUtils;
/**
* Dialog displaying information about the application.
*/
public class AboutDialog extends JDialog implements ActionListener {
/**
* Construct a new AboutDialog.
*/
public AboutDialog() {
}
public AboutDialog(Frame parent, JPanel aboutPanel) {
super(parent, true);
this.setTitle(ProductConstants.PRODUCT_NAME);
this.setResizable(false);
JPanel defaultPane=FRGUIPaneFactory.createBorderLayout_L_Pane();
this.setContentPane(defaultPane);
okButton = new UIButton(Inter.getLocText("OK"));
okButton.addActionListener(this);
tabbedPane = new UITabbedPane();
sysPane = new SystemInfoPane();
tabbedPane.addTab(Inter.getLocText("About"), aboutPanel);
tabbedPane.addTab(Inter.getLocText("System"), sysPane);
buttonPanel = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
buttonPanel.add(okButton);
defaultPane.add(tabbedPane, BorderLayout.CENTER);
defaultPane.add(buttonPanel, BorderLayout.SOUTH);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
dialogExit();
}
});
//esp.
InputMap inputMapAncestor = defaultPane.getInputMap(
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
ActionMap actionMap = defaultPane.getActionMap();
//transfer focus to CurrentEditor
inputMapAncestor.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "dialogExit");
actionMap.put("dialogExit", new AbstractAction() {
public void actionPerformed(ActionEvent evt) {
dialogExit();
}
});
this.getRootPane().setDefaultButton(okButton);
this.setSize(new Dimension(660, 600));
GUICoreUtils.centerWindow(this);
}
public void dialogExit() {
this.dispose();
}
/**
* Called when the ok button is clicked.
*/
public void actionPerformed(ActionEvent e) {
this.dialogExit();
}
private SystemInfoPane sysPane;
private JPanel buttonPanel;
private UITabbedPane tabbedPane;
private UIButton okButton;
}

238
designer_base/src/com/fr/design/actions/help/AboutPane.java

@ -0,0 +1,238 @@
/*
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved.
*/
package com.fr.design.actions.help;
import com.fr.design.DesignerEnvManager;
import com.fr.design.gui.ilable.ActionLabel;
import com.fr.design.gui.ilable.BoldFontTextLabel;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils;
import com.fr.general.Inter;
import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils;
import com.fr.stable.bridge.StableFactory;
import com.fr.start.BBSGuestPaneProvider;
import javax.swing.*;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.net.URI;
public class AboutPane extends JPanel {
private static final String FINEREPORT = "FineReport";
private static final int DEFAULT_GAP = 12;
private static final String COPYRIGHT_LABEL = "\u00A9 ";
private static final String BUILD_PREFIX = " Build #";
public AboutPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
//center panel
JPanel centerPane=FRGUIPaneFactory.createBorderLayout_L_Pane();
this.add(centerPane, BorderLayout.CENTER);
JPanel contentPane=FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
centerPane.add(contentPane, BorderLayout.NORTH);
BoxCenterAlignmentCopyablePane buildCopyPane = new BoxCenterAlignmentCopyablePane(
getBuildTitle(),
GeneralUtils.readBuildNO(),
new String[]{
Inter.getLocText("FR-Designer-Basic_Copy_Build_NO"),
Inter.getLocText("FR-Designer-Basic_Copy_Build_NO_OK")
});
contentPane.add(buildCopyPane);
BoxCenterAligmentPane boxCenterAlignmentPane = new BoxCenterAligmentPane(getCopyRight());
contentPane.add(boxCenterAlignmentPane);
boxCenterAlignmentPane = new BoxCenterAligmentPane(Inter.getLocText("About-All_Rights_Reserved"));
contentPane.add(boxCenterAlignmentPane);
contentPane.add(new BoxCenterAlignmentCopyablePane(
Inter.getLocText("FR-Designer-Basic_Activation_Key"),
DesignerEnvManager.getEnvManager().getActivationKey(),
new String[]{
Inter.getLocText("FR-Designer-Basic_Copy_Activation_Key"),
Inter.getLocText("FR-Designer-Basic_Activation_Key_Copy_OK")
}));
if(ComparatorUtils.equals(ProductConstants.APP_NAME,FINEREPORT)){
boxCenterAlignmentPane = new BoxCenterAligmentPane(Inter.getLocText("Service_Phone") + ProductConstants.COMPARE_TELEPHONE);
contentPane.add(boxCenterAlignmentPane);
}
BoxCenterAligmentPane actionLabel = getURLActionLabel(ProductConstants.WEBSITE_URL);
BoxCenterAligmentPane emailLabel = getEmailActionLabel(ProductConstants.SUPPORT_EMAIL);
contentPane.add(actionLabel);
contentPane.add(emailLabel);
addThankPane(contentPane);
}
//添加鸣谢面板
private void addThankPane(JPanel contentPane){
BBSGuestPaneProvider pane = StableFactory.getMarkedInstanceObjectFromClass(BBSGuestPaneProvider.XML_TAG, BBSGuestPaneProvider.class);
if(pane == null){
return;
}
contentPane.add(Box.createVerticalStrut(DEFAULT_GAP));
contentPane.add((Component) pane);
}
private String append(String...strs){
StringBuilder sb = new StringBuilder();
for(String str : strs){
sb.append(str);
}
return sb.toString();
}
private String getCopyRight(){
return append(Inter.getLocText("About-CopyRight"), COPYRIGHT_LABEL,
ProductConstants.HISTORY, StringUtils.BLANK, ProductConstants.COMPANY_NAME);
}
private String getBuildTitle() {
return append(ProductConstants.APP_NAME, Inter.getLocText("About-Version"),
StringUtils.BLANK, ProductConstants.RELEASE_VERSION, BUILD_PREFIX);
}
private BoxCenterAligmentPane getEmailActionLabel(final String mailTo){
ActionLabel emailLabel = new ActionLabel(mailTo);
emailLabel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
Desktop.getDesktop().mail(new URI(mailTo));
} catch (Exception ignore) {
}
}
});
return new BoxCenterAligmentPane(emailLabel);
}
private BoxCenterAligmentPane getURLActionLabel(final String url){
ActionLabel actionLabel = new ActionLabel(url);
actionLabel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
Desktop.getDesktop().browse(new URI(url));
} catch (Exception exp) {
}
}
});
return new BoxCenterAligmentPane(actionLabel);
}
class UserLabel extends BoldFontTextLabel {
public UserLabel(String text) {
super(text);
if (text != null && text.length() > 30) {
ToolTipManager manager = ToolTipManager.sharedInstance();
manager.registerComponent(this);
}
}
public String getToolTipText(MouseEvent e) {
return this.getText();
}
public Point getToolTipLocation(MouseEvent e) {
return new Point(0, 0);
}
}
class BoxCenterAligmentPane extends JPanel {
private UILabel textLabel;
public BoxCenterAligmentPane(String text) {
this(new UILabel(text));
}
public BoxCenterAligmentPane(UILabel label) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel centerPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
this.add(centerPane, BorderLayout.CENTER);
this.textLabel = label;
centerPane.add(textLabel);
}
public void setFont(Font font) {
super.setFont(font);
if (textLabel != null) {
textLabel.setFont(font);
}
}
}
class BoxCenterAlignmentCopyablePane extends JPanel {
private UILabel label;
private UILabel textField;
private UILabel lastLabel;
public BoxCenterAlignmentCopyablePane(String title, String copyText, final String[] descriptions) {
setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel centerPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
this.label = new UILabel(title);
this.textField = new UILabel(copyText);
textField.setBackground(null);
textField.setBorder(null);
centerPane.add(label);
centerPane.add(textField);
textField.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
StringSelection selection = new StringSelection(textField.getText());
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(selection, selection);
lastLabel.setText(descriptions[1]);
lastLabel.setForeground(Color.RED);
}
}
});
this.lastLabel = new UILabel(descriptions[0]);
lastLabel.setForeground(Color.lightGray);
centerPane.add(lastLabel);
add(centerPane, BorderLayout.CENTER);
}
public void setFont(Font font) {
super.setFont(font);
if (textField != null) {
textField.setFont(font);
}
if (label != null) {
label.setFont(font);
}
}
}
}

57
designer_base/src/com/fr/design/actions/help/FeedBackAction.java

@ -0,0 +1,57 @@
package com.fr.design.actions.help;
import com.fr.base.BaseUtils;
import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.menu.MenuKeySet;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.event.ActionEvent;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-3-18
* Time: 上午9:09
*/
public class FeedBackAction extends UpdateAction {
public FeedBackAction() {
this.setMenuKeySet(FEED_BACK);
this.setName(getMenuKeySet().getMenuName());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_help/feedback.png"));
}
/**
* 动作
* @param e 事件
*/
public void actionPerformed(ActionEvent e) {
final DesignerFrame designerFrame = DesignerContext.getDesignerFrame();
FeedBackPane feedBackPane = new FeedBackPane();
BasicDialog basicDialog =feedBackPane.showWindow(designerFrame,false);
feedBackPane.setFeedbackDialog(basicDialog);
basicDialog.setVisible(true);
}
public static final MenuKeySet FEED_BACK = new MenuKeySet() {
@Override
public char getMnemonic() {
return 0;
}
@Override
public String getMenuName() {
return Inter.getLocText("product_feedback");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
}

350
designer_base/src/com/fr/design/actions/help/FeedBackPane.java

@ -0,0 +1,350 @@
/*
* Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved.
*/
package com.fr.design.actions.help;
import com.fr.base.FRContext;
import com.fr.base.FeedBackInfo;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextarea.UITextArea;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import com.fr.stable.StringUtils;
import com.fr.design.utils.DesignUtils;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import javax.swing.border.MatteBorder;
import javax.swing.plaf.ColorUIResource;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;
import java.awt.*;
import java.awt.event.*;
import java.util.Date;
import java.util.concurrent.CancellationException;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-3-18
* Time: 上午9:50
*/
public class FeedBackPane extends BasicPane {
private static final Dimension DIALOG_SIZE = new Dimension(660, 600);
private static final Dimension TEXT_AREA_SIZE = new Dimension(585, 180);
private static final int TEXT_FIELD_WIDTH = 160;
private static final int TEXT_FIELD_HEIGHT = 21;
private static final int GAP = 5;
private static final ColorUIResource BORDER_COLOR = new ColorUIResource(168, 172, 180);
private static final Border TIP_BORDER = BorderFactory.createEmptyBorder(10, 4, 4, 4);
private static final Border DIALOG_BORDER = BorderFactory.createEmptyBorder(0, 6, 4, 6);
private static final Border INNER_LEFT_BORDER = BorderFactory.createEmptyBorder(15, 18, 0, 0);
private static final Border TEXT_AREA_BORDER = BorderFactory.createEmptyBorder(0, 13, 0, 15);
private static final Border SEND_BORDER = BorderFactory.createEmptyBorder(10, 0, 10, 0);
private static final int DETAIL_TEXT_MAX_LENGTH = 400;
private static final int QQ_MAX_LENGTH = 15;
private static final int EMAIL_MAX_LENGTH = 40;
private static final int TEL_MAX_LENGTH = 11;
private static final String ALLOWED_INTEGER_TYPE = "0123456789";
private SwingWorker worker;
private JDialog dlg = new JDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Send"), true);
private UIButton ok = new UIButton(Inter.getLocText("OK"));
private UIButton cancle = new UIButton(Inter.getLocText("Cancel"));
private int ifHasBeenWriten = 0;
private UITextArea detailField;
private boolean isSendSuccessful = false;
private UITextField qq = new UITextField() {
public Dimension getPreferredSize() {
return new Dimension(TEXT_FIELD_WIDTH, TEXT_FIELD_HEIGHT);
}
};
protected UITextField email = new UITextField() {
public Dimension getPreferredSize() {
return new Dimension(TEXT_FIELD_WIDTH, TEXT_FIELD_HEIGHT);
}
};
protected UITextField phone = new UITextField() {
public Dimension getPreferredSize() {
return new Dimension(TEXT_FIELD_WIDTH, TEXT_FIELD_HEIGHT);
}
};
private UIButton sendButton = null;
private BasicDialog feedbackDialog = null;
private JOptionPane send = null;
public FeedBackPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
initDetailArea();
UILabel tip = new UILabel(Inter.getLocText("feedback_info"));
tip.setBorder(TIP_BORDER);
this.add(tip, BorderLayout.NORTH);
UIScrollPane scrollPane = new UIScrollPane(initDetailPane());
scrollPane.setBorder(new MatteBorder(1, 1, 1, 1, BORDER_COLOR));
this.add(scrollPane, BorderLayout.CENTER);
this.add(getSendButton(), BorderLayout.SOUTH);
sendButton.setEnabled(false);
this.setBorder(DIALOG_BORDER);
initDocument();
}
public void setFeedbackDialog(BasicDialog dialog) {
feedbackDialog = dialog;
}
public Dimension getPreferredSize() {
return DIALOG_SIZE;
}
private void initDocument() {
LimitedDocument qqLimited = new LimitedDocument(QQ_MAX_LENGTH);
qqLimited.setAllowChar(ALLOWED_INTEGER_TYPE);
qq.setDocument(qqLimited);
email.setDocument(new LimitedDocument(EMAIL_MAX_LENGTH));
LimitedDocument phoneLimited = new LimitedDocument(TEL_MAX_LENGTH);
phoneLimited.setAllowChar(ALLOWED_INTEGER_TYPE);
phone.setDocument(phoneLimited);
}
private void initDetailArea() {
detailField = new UITextArea() {
public Dimension getPreferredSize() {
return TEXT_AREA_SIZE;
}
};
this.detailField.setForeground(Color.gray);
this.detailField.setText(Inter.getLocText("feedback_tip"));
detailField.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (ifHasBeenWriten == 0) {
detailField.setText(StringUtils.EMPTY);
detailField.setDocument(new LimitedDocument(DETAIL_TEXT_MAX_LENGTH));
ifHasBeenWriten = 1;
}
}
public void keyReleased(KeyEvent e) {
if (ifHasBeenWriten == 0) {
detailField.setText(StringUtils.EMPTY);
detailField.setDocument(new LimitedDocument(DETAIL_TEXT_MAX_LENGTH));
ifHasBeenWriten = 1;
}
detailField.setForeground(Color.black);
String text = detailField.getText();
// 判断在中文输入状态是否还包含提示符 要删掉
String tip = Inter.getLocText("feedback_tip");
if (text.contains(tip)) {
text = text.substring(0, text.indexOf(tip));
detailField.setText(text);
}
sendButton.setEnabled(!(ifHasBeenWriten == 0 || ComparatorUtils.equals(detailField.getText().trim(), StringUtils.EMPTY)));
}
});
detailField.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
if (ifHasBeenWriten == 0) {
detailField.setText(StringUtils.EMPTY);
detailField.setDocument(new LimitedDocument(DETAIL_TEXT_MAX_LENGTH));
ifHasBeenWriten = 1;
}
}
});
}
private JPanel initDetailPane() {
double p = TableLayout.PREFERRED;
UILabel info = new UILabel(Inter.getLocText("detail_description") + ":");
info.setBorder(INNER_LEFT_BORDER);
JPanel contactPane = getContactPane();
contactPane.setBorder(INNER_LEFT_BORDER);
UILabel contact = new UILabel(Inter.getLocText("contact_info") + ":");
contact.setBorder(INNER_LEFT_BORDER);
JPanel jPanel = new JPanel();
jPanel.add(detailField);
jPanel.setBorder(TEXT_AREA_BORDER);
Component[][] components = new Component[][]{
new Component[]{info},
new Component[]{jPanel},
new Component[]{contact},
new Component[]{contactPane},
};
double[] rowSize = {p, p, p, p};
double[] columnSize = {p};
int[][] rowCount = {{1}, {1}, {1}, {1}};
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM);
}
protected JPanel getContactPane() {
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
Component[][] components = new Component[][]{
new Component[]{new UILabel("QQ:", SwingConstants.RIGHT), qq},
new Component[]{new UILabel(Inter.getLocText("email") + ":", SwingConstants.RIGHT), email},
new Component[]{new UILabel(Inter.getLocText("mobile_number") + ":", SwingConstants.RIGHT), phone}
};
double[] rowSize = {p, p, p};
double[] columnSize = {p, p};
int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}};
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM);
}
private JPanel getSendButton() {
JPanel controlPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel buttonsPane = new JPanel(new FlowLayout(FlowLayout.LEFT, GAP, 0));
controlPane.add(buttonsPane, BorderLayout.EAST);
sendButton = new UIButton(Inter.getLocText("Send"));
buttonsPane.add(sendButton);
buttonsPane.setBorder(SEND_BORDER);
sendButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
doWithSendPane();
}
});
controlPane.setBorder(new EmptyBorder(0, 0, GAP, 0));
return controlPane;
}
private void doWithSendPane() {
Object[] options = new Object[]{ok, cancle};
send = new JOptionPane(Inter.getLocText("sending"),
JOptionPane.INFORMATION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, options, options[0]);
ok.setEnabled(false);
ok.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (isSendSuccessful) {
dlg.dispose();
feedbackDialog.dispose();
} else {
ok.setEnabled(false);
send.setMessage(Inter.getLocText("sending"));
setWorker(send);
worker.execute();
}
}
});
cancle.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
worker.cancel(true);
dlg.dispose();
}
});
dlg.setContentPane(send);
dlg.pack();
dlg.setLocationRelativeTo(DesignerContext.getDesignerFrame());
setWorker(send);
worker.execute();
dlg.setVisible(true);
}
private void setWorker(final JOptionPane send) {
worker = new SwingWorker<Boolean, Void>() {
@Override
protected Boolean doInBackground() throws Exception {
FeedBackInfo feedBackInfo = new FeedBackInfo(new Date(), qq.getText(), email.getText(), phone.getText(), detailField.getText());
try {
return DesignUtils.sendFeedBack(feedBackInfo);
} catch (Exception e) {
FRLogger.getLogger().error(e.getMessage());
return false;
}
}
public void done() {
try {
boolean model = get();
ok.setEnabled(true);
cancle.setEnabled(!model);
if (model) {
//发送成功
isSendSuccessful = true;
send.setMessage(Inter.getLocText("HJS-Send_Successfully") + "!");
} else {
isSendSuccessful = false;
String[] message = new String[]{"HJS-Send_Failed", "try_resending"};
String[] operator = new String[]{",", ""};
send.setMessage(Inter.getLocText(message, operator));
}
} catch (Exception e) {
isSendSuccessful = false;
if (!(e instanceof CancellationException)) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
}
};
}
@Override
protected String title4PopupWindow() {
return Inter.getLocText("product_feedback");
}
private class LimitedDocument extends PlainDocument {
private static final long serialVersionUID = 1L;
private int maxLength = -1;// 允许的最大长度
private String allowCharAsString = null;// 允许的字符串格式(0123456789)
public LimitedDocument(int maxLength) {
super();
this.maxLength = maxLength;
}
public void insertString(int offset, String str, AttributeSet attrSet) throws BadLocationException {
if (str == null) {
return;
}
if (allowCharAsString != null && str.length() == 1) {
if (allowCharAsString.indexOf(str) == -1) {
Toolkit.getDefaultToolkit().beep();// 发出一个警告声
return;// 不是所要求的字符格式,就直接返回,不进行下面的添加
}
}
char[] charVal = str.toCharArray();
String strOldValue = getText(0, getLength());
char[] tmp = strOldValue.toCharArray();
if (maxLength != -1 && (tmp.length + charVal.length > maxLength)) {
Toolkit.getDefaultToolkit().beep();// 发出一个警告声
return;// 长度大于指定的长度maxLength,也直接返回,不进行下面的添加
}
super.insertString(offset, str, attrSet);
}
public void setAllowChar(String str) {
allowCharAsString = str;
}
}
}

75
designer_base/src/com/fr/design/actions/help/ForumAction.java

@ -0,0 +1,75 @@
/*
* Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved.
*/
package com.fr.design.actions.help;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.design.actions.UpdateAction;
import com.fr.design.menu.MenuKeySet;
import com.fr.general.Inter;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-3-18
* Time: 上午9:21
*/
public class ForumAction extends UpdateAction {
public ForumAction() {
this.setMenuKeySet(FORUM);
this.setName(getMenuKeySet().getMenuName());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_help/product_forum.png"));
}
/**
* 动作
* @param e 事件
*/
public void actionPerformed(ActionEvent e) {
String url = "http://bbs.finereport.com/";
if (StringUtils.isEmpty(url)) {
FRContext.getLogger().info("The URL is empty!");
return;
}
try {
Desktop.getDesktop().browse(new URI(url));
} catch (IOException exp) {
JOptionPane.showMessageDialog(null, Inter.getLocText("Set_default_browser"));
FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp);
} catch (URISyntaxException exp) {
FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp);
} catch (Exception exp) {
FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp);
FRContext.getLogger().error("Can not open the browser for URL: " + url);
}
}
public static final MenuKeySet FORUM = new MenuKeySet() {
@Override
public char getMnemonic() {
return 0;
}
@Override
public String getMenuName() {
return Inter.getLocText("Forum");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
}

63
designer_base/src/com/fr/design/actions/help/SupportQQAction.java

@ -0,0 +1,63 @@
/*
* Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved.
*/
package com.fr.design.actions.help;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.design.actions.UpdateAction;
import com.fr.design.menu.MenuKeySet;
import com.fr.general.Inter;
import com.fr.stable.ProductConstants;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
/**
* Created with IntelliJ IDEA.
* User: wikky
* Date: 14-6-20
* Time: 上午10:01
* To change this template use File | Settings | File Templates.
*/
public class SupportQQAction extends UpdateAction {
public SupportQQAction(){
this.setMenuKeySet(SUPPORT_QQ);
this.setName(getMenuKeySet().getMenuName());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_help/support_qq.png"));
}
@Override
public void actionPerformed(ActionEvent e) {
try {
Desktop.getDesktop().browse(new URI(ProductConstants.SUPPORT_QQ));
} catch (IOException exp) {
JOptionPane.showMessageDialog(null, Inter.getLocText("Set_default_browser"));
FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp);
} catch (URISyntaxException exp) {
FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp);
}
}
public static final MenuKeySet SUPPORT_QQ = new MenuKeySet() {
@Override
public char getMnemonic() {
return 0;
}
@Override
public String getMenuName() {
return Inter.getLocText("Support_QQ");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
}

69
designer_base/src/com/fr/design/actions/help/SystemInfoPane.java

@ -0,0 +1,69 @@
package com.fr.design.actions.help;
import java.awt.BorderLayout;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Properties;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumnModel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.Inter;
import com.fr.stable.ProductConstants;
public class SystemInfoPane extends JPanel {
public SystemInfoPane() {
super(FRGUIPaneFactory.createBorderLayout());
DefaultTableModel tableModel = new DefaultTableModel();
JTable table = new JTable(tableModel) {
public boolean isCellEditable(int row, int column) {
return false;
}
};
tableModel.addColumn(Inter.getLocText("Property"));
tableModel.addColumn(Inter.getLocText("Value"));
Properties properties = System.getProperties();
Object[] keys = new Object[properties.size()];
int index = 0;
Enumeration enumeration = properties.propertyNames();
while (enumeration.hasMoreElements()) {
keys[index++] = enumeration.nextElement();
}
Arrays.sort(keys);
for (int i = 0; i < keys.length; i++) {
Object[] tableRowData = new Object[2];
String keyValue = keys[i].toString();
// james:屏蔽掉exe4j的内容
if (keyValue.indexOf("exe4j") != -1) {
continue;
}
// james:这个也是exe4j的东东
if ("install4j.exeDir".equals(keyValue)) {
continue;
}
if(keyValue.indexOf("FineReport") != -1){
keys[i] = keyValue.replaceAll("FineReport", ProductConstants.APP_NAME);
}
tableRowData[0] = keys[i];
tableRowData[1] = properties.getProperty((String) keys[i]);
tableModel.addRow(tableRowData);
}
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
TableColumnModel columnModel = table.getColumnModel();
columnModel.getColumn(0).setPreferredWidth(160);
columnModel.getColumn(1).setPreferredWidth(240);
add(new JScrollPane(table), BorderLayout.CENTER);
}
}

98
designer_base/src/com/fr/design/actions/help/TutorialAction.java

@ -0,0 +1,98 @@
package com.fr.design.actions.help;
import java.awt.Desktop;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.util.Locale;
import javax.swing.KeyStroke;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.base.Utils;
import com.fr.design.actions.UpdateAction;
import com.fr.design.menu.MenuKeySet;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import com.fr.general.http.HttpClient;
import com.fr.stable.OperatingSystem;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
public class TutorialAction extends UpdateAction {
public TutorialAction() {
this.setMenuKeySet(HELP_TUTORIAL);
this.setName(getMenuKeySet().getMenuName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_help/help.png"));
this.setAccelerator(getMenuKeySet().getKeyStroke());
}
private void nativeExcuteMacInstallHomePrograms(String appName) {
String installHome = StableUtils.getInstallHome();
if(installHome == null) {
FRContext.getLogger().error("Can not find the install home, please check it.");
} else {
String appPath = StableUtils.pathJoin(new String[]{installHome, "bin", appName});
if(!(new File(appPath)).exists()) {
FRContext.getLogger().error(appPath + " can not be found.");
}
String cmd = "open " + appPath;
Runtime runtime = Runtime.getRuntime();
try {
runtime.exec(cmd);
} catch (IOException e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
}
/**
* 动作
* @param evt 事件
*/
public void actionPerformed(ActionEvent evt) {
Locale locale = FRContext.getLocale();
if (ComparatorUtils.equals(locale, Locale.CHINA) || ComparatorUtils.equals(locale, Locale.TAIWAN)){
HttpClient client = new HttpClient(ProductConstants.HELP_URL);
if(client.getResponseCode() != -1) {
try {
Desktop.getDesktop().browse(new URI(ProductConstants.HELP_URL));
return;
} catch (Exception e) {
//出了异常的话, 依然打开本地教程
}
}
}
if (OperatingSystem.isMacOS()) {
nativeExcuteMacInstallHomePrograms("helptutorial.app");
}
else {
Utils.nativeExcuteInstallHomePrograms("helptutorial.exe");
}
}
public static final MenuKeySet HELP_TUTORIAL = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'T';
}
@Override
public String getMenuName() {
return Inter.getLocText("M_Help-Tutorial");
}
@Override
public KeyStroke getKeyStroke() {
return KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0);
}
};
}

46
designer_base/src/com/fr/design/actions/help/WebDemoAction.java

@ -0,0 +1,46 @@
package com.fr.design.actions.help;
import com.fr.base.BaseUtils;
import com.fr.design.actions.UpdateAction;
import com.fr.design.menu.MenuKeySet;
import com.fr.general.Inter;
import com.fr.start.StartServer;
import javax.swing.*;
import java.awt.event.ActionEvent;
public class WebDemoAction extends UpdateAction {
public WebDemoAction() {
this.setMenuKeySet(PRODUCT_DEMO);
this.setName(getMenuKeySet().getMenuName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_help/demo.png"));
}
/**
* 动作
* @param evt 事件
*/
public void actionPerformed(ActionEvent evt) {
StartServer.browerDemoURL();
}
public static final MenuKeySet PRODUCT_DEMO = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'D';
}
@Override
public String getMenuName() {
return Inter.getLocText("Product_Demo");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
}

171
designer_base/src/com/fr/design/actions/server/ConnectionListAction.java

@ -0,0 +1,171 @@
package com.fr.design.actions.server;
import com.fr.base.BaseUtils;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.base.ModifiedTable;
import com.fr.data.impl.Connection;
import com.fr.dav.LocalEnv;
import com.fr.design.actions.UpdateAction;
import com.fr.design.data.datapane.connect.ConnectionManagerPane;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.menu.MenuKeySet;
import com.fr.file.DatasourceManager;
import com.fr.file.DatasourceManagerProvider;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.util.HashMap;
/**
* DatasourceList Action
*/
public class ConnectionListAction extends UpdateAction {
private static final int BYTENUM = 1444;
public ConnectionListAction() {
this.setMenuKeySet(DEFINE_DATA_CONNECTION);
this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_web/connection.png"));
}
public static final MenuKeySet DEFINE_DATA_CONNECTION = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'D';
}
@Override
public String getMenuName() {
return Inter.getLocText("Server-Define_Data_Connection");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
/**
* 执行动作
*
* @param evt 事件
*/
public void actionPerformed(ActionEvent evt) {
DesignerFrame designerFrame = DesignerContext.getDesignerFrame();
final DatasourceManagerProvider datasourceManager = DatasourceManager.getProviderInstance();
final DatasourceManager backupManager = datasourceManager.getBackUpManager();
final ConnectionManagerPane databaseManagerPane = new ConnectionManagerPane() {
public void complete() {
populate(datasourceManager);
}
protected void renameConnection(String oldName, String newName) {
datasourceManager.getConnectionLocalModifyTable().rename(oldName, newName);
}
};
final BasicDialog databaseListDialog = databaseManagerPane.showLargeWindow(designerFrame, null);
databaseListDialog.addDialogActionListener(new DialogActionAdapter() {
public void doOk() {
if (!databaseManagerPane.isNamePermitted()) {
databaseListDialog.setDoOKSucceed(false);
return;
}
if (!doWithDatasourceManager(datasourceManager, backupManager, databaseManagerPane, databaseListDialog)) {
//如果更新失败,则不关闭对话框,也不写xml文件,并且将对话框定位在请重命名的那个对象页面
return;
}
// marks:保存数据
writeFile(datasourceManager);
}
public void doCancel() {
datasourceManager.synchronizedWithServer();
}
});
databaseListDialog.setVisible(true);
}
private void writeFile(DatasourceManagerProvider datasourceManager) {
Env currentEnv = FRContext.getCurrentEnv();
try {
boolean isSuccess = currentEnv.writeResource(datasourceManager);
if (!isSuccess) {
throw new RuntimeException(Inter.getLocText("FR-Designer_Already_exist"));
}
} catch (Exception e) {
throw new RuntimeException(Inter.getLocText("FR-Designer_Already_exist"));
}
DesignerContext.getDesignerBean("databasename").refreshBeanElement();
}
/**
* 是否正常更新完datasourceManager
*
* @param datasourceManager
* @param databaseManagerPane
* @return
*/
private boolean doWithDatasourceManager(DatasourceManagerProvider datasourceManager, DatasourceManager backupManager,
ConnectionManagerPane databaseManagerPane, BasicDialog databaseListDialog) {
databaseManagerPane.update(datasourceManager);
HashMap<String, Connection> modifyDetails = datasourceManager.getConnectionModifyDetails();
modifyDetails.clear();
Env currentEnv = FRContext.getCurrentEnv();
ModifiedTable localModifiedTable = datasourceManager.checkConnectionModifyTable(backupManager, currentEnv.getUserID());
boolean isFailed = false;
if (currentEnv.isSupportLocalFileOperate() && !((LocalEnv) currentEnv).isNoRemoteUser()) {
//如果是本地,并且有远程用户时则更新自己的修改表
datasourceManager.updateSelfConnectionTotalModifiedTable(localModifiedTable, ModifiedTable.LOCAL_MODIFIER);
} else {
if (!currentEnv.isSupportLocalFileOperate()) {
//如果是远程,则去取服务器的最新的修改表,检查有没有冲突
ModifiedTable currentServerModifyTable = currentEnv.getDataSourceModifiedTables(DatasourceManager.CONNECTION);
if (localModifiedTable.checkModifiedTableConflictWithServer(currentServerModifyTable, currentEnv.getUserID())) {
//有冲突,进行提示
String title = Inter.getLocText(new String[]{"Select", "Single", "Setting"});
int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), localModifiedTable.getWaringMessage(), title, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (returnVal == JOptionPane.YES_OPTION) {
//点击是,进行相应刷新去冲突
datasourceManager.synchronizedWithServer(backupManager, DatasourceManager.CONNECTION);
//要是有重命名冲突的,则对详细的修改表先进行修改
datasourceManager.doWithConnectionConflict(localModifiedTable);
localModifiedTable.removeConfilct();
modifyDetails.clear();
//更新面板
databaseManagerPane.populate(datasourceManager);
} else {
//更新失败,继续停留页面
isFailed = true;
}
}
}
}
//存在请重命名则不能更新
int index = datasourceManager.isConnectionMapContainsRename();
if (index != -1) {
isFailed = true;
databaseManagerPane.setSelectedIndex(index);
}
databaseListDialog.setDoOKSucceed(!isFailed);
//如果修改成功,则去远程端增量修改修改表
if (!isFailed && !currentEnv.isSupportLocalFileOperate()) {
currentEnv.writeDataSourceModifiedTables(localModifiedTable, DatasourceManager.CONNECTION);
localModifiedTable.clear();
modifyDetails.clear();
}
return !isFailed;
}
public void update() {
this.setEnabled(true);
}
}

79
designer_base/src/com/fr/design/actions/server/FunctionManagerAction.java

@ -0,0 +1,79 @@
/*
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved.
*/
package com.fr.design.actions.server;
import com.fr.base.BaseUtils;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.formula.FunctionManagerPane;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.menu.MenuKeySet;
import com.fr.file.FunctionManager;
import com.fr.file.FunctionManagerProvider;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.event.ActionEvent;
/**
* FunctionManager.
*/
public class FunctionManagerAction extends UpdateAction {
public FunctionManagerAction() {
this.setMenuKeySet(FUNCTION_MANAGER);
this.setName(getMenuKeySet().getMenuKeySetName()+"...");
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_web/function.png"));
}
/**
* 动作
* @param evt 事件
*/
public void actionPerformed(ActionEvent evt) {
final FunctionManagerPane functionManagerPane = new FunctionManagerPane();
BasicDialog functionManagerDialog =
functionManagerPane.showWindow(
DesignerContext.getDesignerFrame(),null);
final FunctionManagerProvider functionManager = FunctionManager.getProviderInstance();
functionManagerDialog.addDialogActionListener(new DialogActionAdapter() {
public void doOk() {
functionManagerPane.update(functionManager);
Env currentEnv = FRContext.getCurrentEnv();
try {
currentEnv.writeResource(functionManager);
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
});
functionManagerPane.populate(functionManager);
functionManagerDialog.setVisible(true);
}
public void update() {
this.setEnabled(true);
}
public static final MenuKeySet FUNCTION_MANAGER = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'F';
}
@Override
public String getMenuName() {
return Inter.getLocText("M_Server-Function_Manager");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
}

93
designer_base/src/com/fr/design/actions/server/GlobalParameterAction.java

@ -0,0 +1,93 @@
/*
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved.
*/
package com.fr.design.actions.server;
import com.fr.base.BaseUtils;
import com.fr.base.ConfigManager;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.design.DesignModelAdapter;
import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.menu.MenuKeySet;
import com.fr.design.parameter.ParameterManagerPane;
import com.fr.general.Inter;
import com.fr.base.ConfigManagerProvider;
import javax.swing.*;
import java.awt.event.ActionEvent;
/**
* Parameter dialog
*/
public class GlobalParameterAction extends UpdateAction {
public GlobalParameterAction() {
this.setMenuKeySet(GLOBAL_PARAMETER);
this.setName(getMenuKeySet().getMenuKeySetName() + "...");
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/p.png"));
}
/**
* 动作
*
* @param e 事件
*/
public void actionPerformed(ActionEvent e) {
final DesignerFrame designerFrame = DesignerContext.getDesignerFrame();
final ParameterManagerPane parameterManagerPane = new ParameterManagerPane();
final BasicDialog parameterManagerDialog = parameterManagerPane.showWindow(designerFrame);
//marks:读取服务器配置信息
final ConfigManagerProvider configManager = ConfigManager.getProviderInstance();
parameterManagerPane.populate(configManager);
parameterManagerDialog.addDialogActionListener(new DialogActionAdapter() {
public void doOk() {
//apply new parameter list.
parameterManagerPane.update(configManager);
//marks:保存数据
Env currentEnv = FRContext.getCurrentEnv();
try {
currentEnv.writeResource(configManager);
} catch (Exception ex) {
FRContext.getLogger().error(ex.getMessage(), ex);
}
DesignModelAdapter<?, ?> model = DesignModelAdapter.getCurrentModelAdapter();
if (model != null) {
model.parameterChanged();
}
parameterManagerDialog.setDoOKSucceed(!parameterManagerPane.isContainsRename());
}
});
parameterManagerDialog.setModal(true);
parameterManagerDialog.setVisible(true);
}
public void update() {
this.setEnabled(true);
}
public static final MenuKeySet GLOBAL_PARAMETER = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'G';
}
@Override
public String getMenuName() {
return Inter.getLocText("M_Server-Global_Parameters");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
}

197
designer_base/src/com/fr/design/actions/server/GlobalTableDataAction.java

@ -0,0 +1,197 @@
/*
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved.
*/
package com.fr.design.actions.server;
import com.fr.base.*;
import com.fr.dav.LocalEnv;
import com.fr.design.DesignModelAdapter;
import com.fr.design.actions.UpdateAction;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.TableDataTreePane;
import com.fr.design.data.tabledata.ResponseDataSourceChange;
import com.fr.design.data.tabledata.tabledatapane.TableDataManagerPane;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.menu.MenuKeySet;
import com.fr.file.DatasourceManager;
import com.fr.file.DatasourceManagerProvider;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.util.HashMap;
import java.util.Map;
/**
* Global TableData.
*/
public class GlobalTableDataAction extends UpdateAction implements ResponseDataSourceChange {
//private static TableDataManagerPane globalTableDataPane = new TableDataManagerPane();
public GlobalTableDataAction() {
this.setMenuKeySet(SERVER_TABLEDATA);
this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/data/dock/serverdatabase.png"));
}
public static final MenuKeySet SERVER_TABLEDATA = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'S';
}
@Override
public String getMenuName() {
return Inter.getLocText("DS-Server_TableData");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
/**
* 动作
* @param evt 事件
*/
public void actionPerformed(ActionEvent evt) {
final DesignerFrame designerFrame = DesignerContext.getDesignerFrame();
final DatasourceManagerProvider datasourceManager = DatasourceManager.getProviderInstance();
final DatasourceManager backupManager = datasourceManager.getBackUpManager();
final TableDataManagerPane globalTableDataPane = new TableDataManagerPane() {
public void complete() {
populate(datasourceManager);
}
protected void renameConnection(String oldName, String newName) {
datasourceManager.getConnectionLocalModifyTable().rename(oldName, newName);
}
};
final BasicDialog globalTableDataDialog = globalTableDataPane.showLargeWindow(designerFrame, null);
globalTableDataDialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
if (!globalTableDataPane.isNamePermitted()) {
globalTableDataDialog.setDoOKSucceed(false);
return;
}
DesignTableDataManager.clearGlobalDs();
globalTableDataPane.update(datasourceManager);
if (!doWithDatasourceManager(datasourceManager, backupManager, globalTableDataPane, globalTableDataDialog)) {
//如果更新失败,则不关闭对话框,也不写xml文件,并且将对话框定位在请重命名的那个对象页面
return;
}
writeFile(datasourceManager);
// 刷新共有数据集
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter());
fireDSChanged(globalTableDataPane.getDsChangedNameMap());
}
public void doCancel() {
datasourceManager.synchronizedWithServer();
}
});
globalTableDataDialog.setVisible(true);
}
private void writeFile(DatasourceManagerProvider datasourceManager) {
Env currentEnv = FRContext.getCurrentEnv();
try {
boolean isSuccess = currentEnv.writeResource(datasourceManager);
if (!isSuccess) {
throw new RuntimeException(Inter.getLocText("FR-Designer_Already_exist"));
}
} catch (Exception e) {
throw new RuntimeException(Inter.getLocText("FR-Designer_Already_exist"));
}
}
/**
* 是否正常更新完datasourceManager
*
* @param datasourceManager
* @param databaseManagerPane
* @return
*/
private boolean doWithDatasourceManager(DatasourceManagerProvider datasourceManager, DatasourceManager backupManager,
TableDataManagerPane tableDataManagerPane, BasicDialog databaseListDialog) {
HashMap<String, TableData> modifyDetails = datasourceManager.getTableDataModifyDetails();
modifyDetails.clear();
Env currentEnv = FRContext.getCurrentEnv();
ModifiedTable localModifiedTable = datasourceManager.checkTableDataModifyTable(backupManager, currentEnv.getUserID());
boolean isFailed = false;
if (currentEnv.isSupportLocalFileOperate() && !((LocalEnv) currentEnv).isNoRemoteUser()) {
//如果是本地,并且有远程用户时则更新自己的修改表
datasourceManager.updateSelfTableDataTotalModifiedTable(localModifiedTable, ModifiedTable.LOCAL_MODIFIER);
} else {
if (!currentEnv.isSupportLocalFileOperate()) {
//如果是远程,则去取服务器的最新的修改表,检查有没有冲突
ModifiedTable currentServerModifyTable = currentEnv.getDataSourceModifiedTables(DatasourceManager.TABLEDATA);
if (localModifiedTable.checkModifiedTableConflictWithServer(currentServerModifyTable, currentEnv.getUserID())) {
//有冲突,进行提示
String title = Inter.getLocText(new String[]{"Select", "Single", "Setting"});
int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), localModifiedTable.getWaringMessage(), title, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (returnVal == JOptionPane.YES_OPTION) {
//点击是,进行相应刷新去冲突
datasourceManager.synchronizedWithServer(backupManager, DatasourceManager.TABLEDATA);
//要是有重命名冲突的,则对详细的修改表先进行修改
datasourceManager.doWithTableDataConfilct(localModifiedTable);
localModifiedTable.removeConfilct();
modifyDetails.clear();
//更新面板
tableDataManagerPane.populate(datasourceManager);
} else {
//更新失败,继续停留页面
isFailed = true;
}
}
}
}
//存在请重命名则不能更新
int index = datasourceManager.isTableDataMapContainsRename();
if (index != -1) {
isFailed = true;
tableDataManagerPane.setSelectedIndex(index);
}
databaseListDialog.setDoOKSucceed(!isFailed);
//如果修改成功,则去远程端增量修改修改表
if (!isFailed && !currentEnv.isSupportLocalFileOperate()) {
currentEnv.writeDataSourceModifiedTables(localModifiedTable, DatasourceManager.TABLEDATA);
localModifiedTable.clear();
modifyDetails.clear();
}
return !isFailed;
}
public void update() {
this.setEnabled(true);
}
/**
* 响应数据集改变
*/
public void fireDSChanged() {
fireDSChanged(new HashMap<String, String>());
}
/**
* 响应数据集改变
*
* @param map 对应集
*/
public void fireDSChanged(Map<String, String> map) {
DesignTableDataManager.fireDSChanged(map);
}
}

48
designer_base/src/com/fr/design/actions/server/PlatformManagerAction.java

@ -0,0 +1,48 @@
package com.fr.design.actions.server;
import com.fr.base.BaseUtils;
import com.fr.design.actions.UpdateAction;
import com.fr.design.menu.MenuKeySet;
import com.fr.design.utils.DesignUtils;
import com.fr.general.Inter;
import com.fr.general.web.ParameterConsts;
import javax.swing.*;
import java.awt.event.ActionEvent;
public class PlatformManagerAction extends UpdateAction {
public PlatformManagerAction() {
this.setMenuKeySet(PLATEFORM_MANAGER);
this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/web/images/platform/platform_16_16.png"));
}
/**
* 动作
* @param evt 事件
*/
public void actionPerformed(ActionEvent evt) {
DesignUtils.visitEnvServerByParameters(
new String[] {ParameterConsts.OP},
new String[] {"fr_platform"}
);
}
public static final MenuKeySet PLATEFORM_MANAGER = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'P';
}
@Override
public String getMenuName() {
return Inter.getLocText("M_Server-Platform_Manager");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
}

52
designer_base/src/com/fr/design/actions/server/PluginManagerAction.java

@ -0,0 +1,52 @@
package com.fr.design.actions.server;
import com.fr.base.BaseUtils;
import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.extra.PluginManagerPane;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.menu.MenuKeySet;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.event.ActionEvent;
/**
* @author richie
* @date 2015-03-09
* @since 8.0
*/
public class PluginManagerAction extends UpdateAction {
public PluginManagerAction() {
this.setMenuKeySet(PLUGIN_MANAGER);
this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/server/plugin.png"));
}
@Override
public void actionPerformed(ActionEvent e) {
final PluginManagerPane managerPane = new PluginManagerPane();
BasicDialog dlg = managerPane.showLargeWindow(DesignerContext.getDesignerFrame(),null);
dlg.setVisible(true);
}
public static final MenuKeySet PLUGIN_MANAGER = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'I';
}
@Override
public String getMenuName() {
return Inter.getLocText("FR-Designer-Plugin_Manager");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
}

63
designer_base/src/com/fr/design/actions/server/ProcedureListAction.java

@ -0,0 +1,63 @@
package com.fr.design.actions.server;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.design.DesignModelAdapter;
import com.fr.design.actions.UpdateAction;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.TableDataTreePane;
import com.fr.design.data.tabledata.tabledatapane.ProcedureManagerPane;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.file.DatasourceManager;
import com.fr.file.DatasourceManagerProvider;
import com.fr.general.Inter;
import java.awt.event.ActionEvent;
public class ProcedureListAction extends UpdateAction {
public ProcedureListAction() {
this.setName(Inter.getLocText("Datasource-Stored_Procedure") + "(P)" + "...");
this.setMnemonic('P');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/data/store_procedure.png"));
}
/**
* 事件触发操作
*
* @param evt 事件
*
*/
public void actionPerformed(ActionEvent evt) {
DesignerFrame designerFrame = DesignerContext.getDesignerFrame();
final DatasourceManagerProvider datasourceManager = DatasourceManager.getProviderInstance();
final ProcedureManagerPane databaseManagerPane = new ProcedureManagerPane() {
public void complete() {
populate(datasourceManager);
}
};
BasicDialog databaseListDialog = databaseManagerPane.showLargeWindow(designerFrame,null);
databaseListDialog.addDialogActionListener(new DialogActionAdapter() {
public void doOk() {
DesignTableDataManager.clearGlobalDs();
databaseManagerPane.update(datasourceManager);
// marks:保存数据
try {
FRContext.getCurrentEnv().writeResource(datasourceManager);
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage());
}
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter());
}
});
databaseListDialog.setVisible(true);
}
public void update() {
this.setEnabled(true);
}
}

97
designer_base/src/com/fr/design/actions/tabledata/TableDataAction.java

@ -0,0 +1,97 @@
package com.fr.design.actions.tabledata;
import com.fr.base.BaseUtils;
import com.fr.design.data.datapane.TableDataNameObjectCreator;
import com.fr.design.actions.UpdateAction;
import java.awt.event.ActionEvent;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 13-12-19
* Time: 下午5:21
*/
public abstract class TableDataAction extends UpdateAction {
public static final String XML_TAG_TEMPLATE = "template_tabledata_Type";
public static final String XML_TAG_SERVER = "server_tabledata_Type";
public TableDataAction() {
this.setName(this.getDisplayName());
this.setSmallIcon(BaseUtils.readIcon(this.getIconPath()));
}
/**
* 名字
*
* @return
*/
public abstract String getDisplayName();
/**
* 图标
*
* @return
*/
public abstract String getIconPath();
/**
* 后缀
*
* @return
*/
public abstract String getPrefix();
/**
* 得到TableData的声明类
*
* @return
*/
public abstract Class getTableDataClass();
/**
* 得到相应面板的类
*
* @return
*/
public abstract Class getUpdateTableDataPaneClass();
/**
* 用于初始化的类诺是不需要初始化则不需要实现
*
* @return
*/
public Class getClass4Init() {
return null;
}
/**
* 该菜单后面是否需要插入分割符
*
* @return 是则返回true
*/
public boolean isNeedInsertSeparator() {
return false;
}
public TableDataNameObjectCreator getTableDataCreator() {
if (this.getClass4Init() == null) {
return new TableDataNameObjectCreator(this);
} else {
return new TableDataNameObjectCreator(this, getClass4Init());
}
}
/**
* 动作
* @param e 动作
*/
public void actionPerformed(ActionEvent e) {
}
}

39
designer_base/src/com/fr/design/beans/BasicBeanPane.java

@ -0,0 +1,39 @@
package com.fr.design.beans;
import com.fr.design.dialog.BasicPane;
/**
* Update Pane
*/
public abstract class BasicBeanPane<T> extends BasicPane {
/**
* Populate.
*/
public abstract void populateBean(T ob);
/**
* Update.
*/
public abstract T updateBean();
public void updateBean(T ob) {
}
/**
* 更新权限工具栏面板
*/
public void populateAuthority() {
}
/**
* 仅用来处理图表设计器的地图面板
* @param mapType 地图类型
*/
public void dealWidthMap(String mapType){
}
}

28
designer_base/src/com/fr/design/beans/FurtherBasicBeanPane.java

@ -0,0 +1,28 @@
package com.fr.design.beans;
/**
*
* @author zhou
* @since 2012-5-30下午12:12:42
*/
public abstract class FurtherBasicBeanPane<T> extends BasicBeanPane<T> {
/**
* 是否是指定类型
* @param ob 对象
* @return 是否是指定类型
*/
public abstract boolean accept(Object ob);
/**
* title应该是一个属性不只是对话框的标题时用到与其他组件结合时也会用得到
* @return 绥化狂标题
*/
@Override
public abstract String title4PopupWindow();
/**
* 重置
*/
public abstract void reset();
}

56
designer_base/src/com/fr/design/beans/GroupModel.java

@ -0,0 +1,56 @@
package com.fr.design.beans;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
/**
* richer:属性和事件分组
* @since 6.5.3
*/
public interface GroupModel {
/**
* 该属性所属的分类,普通属性分为基本属性和其它,事件属性根据事件名称不同进行分类
*/
String getGroupName();
/**
* 总共的属性行数
*/
int getRowCount();
/**
* 获取属性表中第row行的渲染器
* @param row
*/
TableCellRenderer getRenderer(int row);
/**
* 获取属性表中第row行的编辑器
* @param row
*/
TableCellEditor getEditor(int row);
/**
* 获取属性表中第row行第column列的值
* @param row
* @param column
* @return 表格中的值
*/
Object getValue(int row, int column);
/**
* 设置属性表中第row行第column列的值为value
* @param value
* @param row
* @param column
* @return 设置成功则返回true否则返回false
*/
boolean setValue(Object value, int row, int column);
/**
* 改行是否可编辑
* @param row
* @return 第row行可编辑返回true否则返回false
*/
boolean isEditable(int row);
}

190
designer_base/src/com/fr/design/beans/location/Absorptionline.java

@ -0,0 +1,190 @@
package com.fr.design.beans.location;
import java.awt.Color;
import java.awt.Graphics;
import com.fr.base.GraphHelper;
import com.fr.design.scrollruler.ScrollRulerComponent;
import com.fr.stable.ArrayUtils;
public class Absorptionline {
private static Absorptionline lineInX = new Absorptionline(null, null, null, true);
private static Absorptionline lineInY = new Absorptionline(null, null, null, false);
private Color lineColor = new Color(228, 225, 199);
private Color midLineColor = new Color(196, 227, 237);
private Integer x1;
private Integer x2;
private Integer middle;
private int[] verticalLines;
private int[] horizontalLines;
private boolean trans;
/**
* 创建X轴连接线
*
* @param x x坐标
*
* @return X轴的连接线
*
* @date 2015-2-12-下午2:45:49
*
*/
public static Absorptionline createXAbsorptionline(int x) {
lineInX.x1 = x;
lineInX.x2 = lineInX.middle = null;
lineInX.horizontalLines = lineInX.verticalLines = null;
return lineInX;
}
/**
* 创建X中轴连接线
*
* @param x x坐标
*
* @return X中轴的连接线
*
* @date 2015-2-12-下午2:45:49
*
*/
public static Absorptionline createXMidAbsorptionline(int x) {
lineInX.middle = x;
lineInX.x1 = lineInX.x2 = null;
lineInX.horizontalLines = lineInX.verticalLines = null;
return lineInX;
}
/**
* 创建Y轴连接线
*
* @param y y坐标
*
* @return Y轴的连接线
*
* @date 2015-2-12-下午2:45:49
*
*/
public static Absorptionline createYAbsorptionline(int y) {
lineInY.x1 = y;
lineInY.x2 = lineInY.middle = null;
lineInY.horizontalLines = lineInY.verticalLines = null;
return lineInY;
}
/**
* 创建Y中轴连接线
*
* @param y y坐标
*
* @return Y中轴的连接线
*
* @date 2015-2-12-下午2:45:49
*
*/
public static Absorptionline createYMidAbsorptionline(int y) {
lineInY.middle = y;
lineInY.x1 = lineInY.x2 = null;
lineInY.horizontalLines = lineInY.verticalLines = null;
return lineInY;
}
private Absorptionline(Integer x1, Integer x2, Integer middleInX, boolean trans) {
this.x1 = x1;
this.x2 = x2;
this.middle = middleInX;
this.trans = trans;
}
public void setFirstLine(Integer x) {
this.x1 = x;
}
public void setMidLine(Integer x) {
this.middle = x;
}
public void setSecondLine(Integer x) {
this.x2 = x;
}
/**
* 是否相关参数都已设置完毕
*
* @return 相关参数都已设置完毕
*
* @date 2015-2-12-下午2:44:46
*
*/
public boolean isFull() {
return x1 != null && x2 != null && middle != null;
}
public int[] getVerticalLines() {
return verticalLines;
}
public void setVerticalLines(int[] verticalLines) {
this.verticalLines = verticalLines;
}
public int[] getHorizontalLines() {
return horizontalLines;
}
public void setHorizontalLines(int[] horizontalLines) {
this.horizontalLines = horizontalLines;
}
public void paint(Graphics g, ScrollRulerComponent designer) {
g = g.create();
if (trans) {
for (int i = 0; i < ArrayUtils.getLength(verticalLines); i++) {
g.setColor(lineColor);
GraphHelper.drawLine(g, verticalLines[i] - designer.getHorizontalValue(), 0, verticalLines[i] - designer.getHorizontalValue(),
designer.getDesignerHeight());
}
if (x1 != null) {
g.setColor(lineColor);
GraphHelper.drawLine(g, x1 - designer.getHorizontalValue(), 0, x1 - designer.getHorizontalValue(),
designer.getDesignerHeight());
}
if (x2 != null) {
g.setColor(lineColor);
GraphHelper.drawLine(g, x2 - designer.getHorizontalValue(), 0, x2 - designer.getHorizontalValue(),
designer.getDesignerWidth());
}
if (middle != null) {
g.setColor(midLineColor);
GraphHelper.drawLine(g, middle - designer.getHorizontalValue(), 0, middle
- designer.getHorizontalValue(), designer.getDesignerHeight());
}
} else {
for (int i = 0; i < ArrayUtils.getLength(horizontalLines); i++) {
g.setColor(lineColor);
GraphHelper.drawLine(g, 0, horizontalLines[i] - designer.getVerticalValue(),
designer.getDesignerWidth(), horizontalLines[i] - designer.getVerticalValue());
}
if (x1 != null) {
g.setColor(lineColor);
GraphHelper.drawLine(g, 0, x1 - designer.getVerticalValue(), designer.getDesignerWidth(), x1
- designer.getVerticalValue());
}
if (x2 != null) {
g.setColor(lineColor);
GraphHelper.drawLine(g, 0, x2 - designer.getVerticalValue(), designer.getDesignerWidth(), x2
- designer.getVerticalValue());
}
if (middle != null) {
g.setColor(midLineColor);
GraphHelper.drawLine(g, 0, middle - designer.getVerticalValue(), designer.getDesignerWidth(), middle
- designer.getVerticalValue());
}
}
}
}

332
designer_base/src/com/fr/design/beans/location/MoveUtils.java

@ -0,0 +1,332 @@
/*
* Copyright(c) 2001-2011, FineReport Inc, All Rights Reserved.
*/
package com.fr.design.beans.location;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
/**
* Created by IntelliJ IDEA.
*
* @author: Richer
* @since : 6.5.5 Date: 11-7-1 Time: 下午2:22
*/
public class MoveUtils {
public static final int SORPTION_UNIT = 5;
private MoveUtils() {
}
public interface RectangleDesigner {
/**
* 获取块边界的迭代器
*
* @return 块边界的迭代器
*
* @date 2015-2-12-下午2:43:47
*
*/
RectangleIterator createRectangleIterator();
/**
* 设置X轴的线
*
* @param line 连接线
*
* @date 2015-2-12-下午2:44:04
*
*/
void setXAbsorptionline(Absorptionline line);
/**
* 设置Y轴的线
*
* @param line 连接线
*
* @date 2015-2-12-下午2:44:04
*
*/
void setYAbsorptionline(Absorptionline line);
/**
* 获取当前选中块的垂直线数组
*
* @return 块的垂直线数组
*
*/
int[] getVerticalLine();
/**
* 获取当前选中块的水平线数组
*
* @return 块的水平线数组
*
*/
int[] getHorizontalLine();
}
public interface RectangleIterator {
/**
* 是否存在下一个块
*
* @return 是否存在下一个块
*
* @date 2015-2-12-下午2:41:32
*
*/
boolean hasNext();
/**
* 获取下一个块的bounds
*
* @return 下一个块的bounds
*
* @date 2015-2-12-下午2:41:55
*
*/
Rectangle nextRectangle();
/**
* 获取块的垂直线数组
*
* @return 块的垂直线数组
*
* @date 2015-2-12-下午2:42:27
*
*/
int[] getVerticalLine();
/**
* 获取块的水平线数组
*
* @return 块的水平线数组
*
* @date 2015-2-12-下午2:42:27
*
*/
int[] getHorizontalLine();
}
private static class PlacePointing {
public PlacePointing(int x) {
this.palce = x;
}
private boolean isFind() {
return direction != -1;
}
private int palce;
private int direction = -1;
}
private static void findX(PlacePointing px, Rectangle bounds, int left, int right, int width) {
if (px.isFind()) {
return;
}
if (Math.abs(bounds.x + bounds.width / 2 - (left + right) / 2) <= SORPTION_UNIT) {
px.palce = bounds.x + bounds.width / 2 - width / 2;
px.direction = SwingConstants.CENTER;
}
int x1 = bounds.x;
if (Math.abs(x1 - left) <= SORPTION_UNIT) {
px.palce = x1;
px.direction = SwingConstants.LEFT;
}
if (Math.abs(x1 - right) <= SORPTION_UNIT) {
px.palce = x1 - width;
px.direction = SwingConstants.RIGHT;
}
int x2 = bounds.x + bounds.width;
if (Math.abs(x2 - left) <= SORPTION_UNIT) {
px.palce = x2;
px.direction = SwingConstants.LEFT;
}
if (Math.abs(x2 - right) <= SORPTION_UNIT) {
px.palce = x2 - width;
px.direction = SwingConstants.RIGHT;
}
}
private static void findY(PlacePointing py, Rectangle bounds, int top, int bottom, int height) {
if (py.isFind()) {
return;
}
if (Math.abs(bounds.y + bounds.height / 2 - (top + bottom) / 2) <= SORPTION_UNIT) {
py.palce = bounds.y + bounds.height / 2 - height / 2;
py.direction = SwingConstants.CENTER;
}
int y1 = bounds.y;
if (Math.abs(y1 - top) <= SORPTION_UNIT) {
py.palce = y1;
py.direction = SwingConstants.TOP;
}
if (Math.abs(y1 - bottom) <= SORPTION_UNIT) {
py.palce = y1 - height;
py.direction = SwingConstants.BOTTOM;
}
int y2 = bounds.y + bounds.height;
if (Math.abs(y2 - top) <= SORPTION_UNIT) {
py.palce = y2;
py.direction = SwingConstants.TOP;
}
if (Math.abs(y2 - bottom) <= SORPTION_UNIT) {
py.palce = y2 - height;
py.direction = SwingConstants.BOTTOM;
}
}
/**
* 吸附
*
* @param x x坐标
* @param y y坐标
* @param width 宽度
* @param height 高度
* @param designer 块设计器
*
* @return 吸附后坐标
*
* @date 2015-2-12-下午2:39:16
*
*/
public static Point sorption(int x, int y, int width, int height, RectangleDesigner designer) {
int left = x, top = y, bottom = top + height, right = left + width;
PlacePointing px = new PlacePointing(x);
PlacePointing py = new PlacePointing(y);
RectangleIterator iterator = designer.createRectangleIterator();
java.util.List<Rectangle> cacheRecs = new ArrayList<Rectangle>();
while (iterator.hasNext()) {
Rectangle bounds = iterator.nextRectangle();
cacheRecs.add(bounds);
findX(px, bounds, left, right, width);
findY(py, bounds, top, bottom, height);
if (px.isFind() && py.isFind()) {
break;
}
}
createXAbsorptionline(px, designer, width, cacheRecs);
createYAbsorptionline(py, designer, height, cacheRecs);
return new Point(px.palce, py.palce);
}
private static void createXAbsorptionline(PlacePointing px, RectangleDesigner designer, int width, java.util.List<Rectangle> cacheRecs) {
Absorptionline line = null;
RectangleIterator iterator = designer.createRectangleIterator();
int[] selfVertical = designer.getVerticalLine();
if (px.direction == SwingConstants.CENTER) {
line = Absorptionline.createXMidAbsorptionline(px.palce + width / 2);
int left = px.palce;
int right = px.palce + width;
for (Rectangle bounds : cacheRecs) {
if (bounds.x == left || bounds.x + bounds.width == left) {
line.setFirstLine(left);
}
if (bounds.x == right || bounds.x + bounds.width == right) {
line.setSecondLine(right);
}
updateVerticalLine(selfVertical, iterator, line);
if (line.isFull()) {
break;
}
}
} else if (px.direction == SwingConstants.LEFT || px.direction == SwingConstants.RIGHT) {
int left = px.direction == SwingConstants.LEFT ? px.palce + width : px.palce;
line = Absorptionline.createXAbsorptionline(px.direction == SwingConstants.LEFT ? px.palce : px.palce + width);
int middle = px.palce + width / 2;
for (Rectangle bounds : cacheRecs) {
if (bounds.x == left || bounds.x + bounds.width == left) {
line.setSecondLine(left);
}
if (bounds.x + bounds.width / 2 == middle) {
line.setMidLine(middle);
}
updateVerticalLine(selfVertical, iterator, line);
if (line.isFull()) {
break;
}
}
}
designer.setXAbsorptionline(line);
}
private static void createYAbsorptionline(PlacePointing py, RectangleDesigner designer, int height, java.util.List<Rectangle> cacheRecs) {
Absorptionline line = null;
RectangleIterator iterator = designer.createRectangleIterator();
int[] selfHorizontal = designer.getHorizontalLine();
if (py.direction == SwingConstants.CENTER) {
line = Absorptionline.createYMidAbsorptionline(py.palce + height / 2);
int top = py.palce;
int bottom = py.palce + height;
for (Rectangle bounds : cacheRecs) {
if (bounds.y == top || bounds.y + bounds.height == top) {
line.setFirstLine(top);
}
if (bounds.y == bottom || bounds.y + bounds.height == bottom) {
line.setSecondLine(bottom);
}
updateHorizontalLine(selfHorizontal, iterator, line);
if (line.isFull()) {
break;
}
}
} else if (py.direction == SwingConstants.TOP || py.direction == SwingConstants.BOTTOM) {
int top = py.direction == SwingConstants.TOP ? py.palce + height : py.palce;
line = Absorptionline.createYAbsorptionline(py.direction == SwingConstants.TOP ? py.palce : py.palce + height);
int middle = py.palce + height / 2;
for (Rectangle bounds : cacheRecs) {
if (bounds.y == top || bounds.y + bounds.height == top) {
line.setSecondLine(top);
}
if (bounds.y + bounds.height / 2 == middle) {
line.setMidLine(middle);
}
updateHorizontalLine(selfHorizontal, iterator, line);
if (line.isFull()) {
break;
}
}
}
designer.setYAbsorptionline(line);
}
//更新纵向行列线
private static void updateVerticalLine(int[] selfVertical, RectangleIterator iterator, Absorptionline line){
int[] targetArray = iterator.getVerticalLine();
if (intersectArrays(targetArray, selfVertical)){
line.setVerticalLines(targetArray);
}
}
//更新横向行列线
private static void updateHorizontalLine(int[] selfHorizontal, RectangleIterator iterator, Absorptionline line){
int[] targetArray = iterator.getHorizontalLine();
if (intersectArrays(targetArray, selfHorizontal)){
line.setHorizontalLines(targetArray);
}
}
//检测两个数组是否有相交的部分
private static boolean intersectArrays(int[] targetArray, int[] selfArray){
for (int i : targetArray) {
for (int j : selfArray) {
if(i == j){
return true;
}
}
}
return false;
}
}

50
designer_base/src/com/fr/design/border/UIRoundedBorder.java

@ -0,0 +1,50 @@
package com.fr.design.border;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.RoundRectangle2D;
import javax.swing.border.LineBorder;
import com.fr.base.GraphHelper;
public class UIRoundedBorder extends LineBorder {
private static final long serialVersionUID = 1L;
private int roundedCorner;
private int lineStyle;
public UIRoundedBorder(Color color) {
super(color);
}
public UIRoundedBorder(Color color, int thickness){
super(color, thickness);
}
public UIRoundedBorder(Color color, int thickness, int roundedCorners){
super(color, thickness, true);
this.roundedCorner = roundedCorners;
}
public UIRoundedBorder(int lineStyle, Color color, int roundedCorners){
super(color, GraphHelper.getLineStyleSize(lineStyle), true);
this.lineStyle = lineStyle;
this.roundedCorner = roundedCorners;
}
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height){
Color oldColor = g.getColor();
Graphics2D g2d = (Graphics2D)g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(lineColor);
GraphHelper.draw(g2d, new RoundRectangle2D.Double(x, y, width - 1, height-1, roundedCorner, roundedCorner),lineStyle);
g2d.setColor(oldColor);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
}
}

28
designer_base/src/com/fr/design/border/UITitledBorder.java

@ -0,0 +1,28 @@
package com.fr.design.border;
import java.awt.Color;
import javax.swing.BorderFactory;
import javax.swing.border.TitledBorder;
public class UITitledBorder extends TitledBorder {
private static final long serialVersionUID = 1L;
public static UITitledBorder createBorderWithTitle(String title) {
return new UITitledBorder(title);
}
private UITitledBorder(String title) {
super(null, title, 4, 2, null, new Color(1, 159, 222));
init(title);
}
private void init(String title){
UIRoundedBorder roundedborder = new UIRoundedBorder(new Color(204, 204, 204), 1, 10);
this.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0), roundedborder));
this.setTitle(title);
}
}

17
designer_base/src/com/fr/design/bridge/DesignToolbarProvider.java

@ -0,0 +1,17 @@
package com.fr.design.bridge;
/**
* @author richie
* @date 14/11/10
* @since 8.0
* 工具栏界面接口
*/
public interface DesignToolbarProvider {
public static final String STRING_MARKED = "DesignToolbarProvider";
/**
* 刷新工具栏
*/
public void refreshToolbar();
}

15
designer_base/src/com/fr/design/cell/FloatElementsProvider.java

@ -0,0 +1,15 @@
/**
*
*/
package com.fr.design.cell;
/**
* 悬浮元素
*
* @author focus
* @time 2014年11月17日下午10:44:10
* @version
*/
public interface FloatElementsProvider {
}

66
designer_base/src/com/fr/design/condition/CellHighlightAddMenuDef.java

@ -0,0 +1,66 @@
package com.fr.design.condition;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import com.fr.base.BaseUtils;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.menu.MenuDef;
import com.fr.design.utils.gui.GUICoreUtils;
/**
* Define Menu.
*/
public class CellHighlightAddMenuDef extends MenuDef {
public CellHighlightAddMenuDef() {
}
public CellHighlightAddMenuDef(String name) {
this.setName(name);
}
public CellHighlightAddMenuDef(String name, char mnemonic) {
this.setName(name);
this.setMnemonic(mnemonic);
}
// 生成UIButton,iconpath不可为null
public UIButton createUIButton() {
if (createdButton == null) {
if (this.iconPath != null && this.name != null) {
createdButton = new UIButton(BaseUtils.readIcon(this.iconPath));
} else if (this.iconPath != null) {
createdButton = new UIButton(BaseUtils.readIcon(this.iconPath));
} else {
createdButton = new UIButton(this.name);
}
createdButton.addMouseListener(mouseListener);
}
return createdButton;
}
private MouseListener mouseListener = new MouseAdapter() {
public void mouseReleased(MouseEvent evt) {
Object source = evt.getSource();
UIButton button = (UIButton) source;
if (!button.isEnabled()) {
return;
}
UIPopupMenu popupMenu = new UIPopupMenu();
popupMenu.setInvoker(button);
CellHighlightAddMenuDef.this.updatePopupMenu(popupMenu);
GUICoreUtils.showPopupMenu(popupMenu, button, 0, button.getSize().height);
}
public void mouseExited(MouseEvent evt) {
if (createdButton != null) {
createdButton.setEnabled(true);
}
}
};
}

52
designer_base/src/com/fr/design/condition/ConditionAttrSingleConditionPane.java

@ -0,0 +1,52 @@
package com.fr.design.condition;
/**
* @author richie
* @date 2015-03-26
* @since 8.0
*/
public abstract class ConditionAttrSingleConditionPane<T> extends SingleConditionPane<T> {
protected HighLightConditionAction hightLighAttrUpdateAction = null;
private ConditionAttributesPane conditionAttributesPane;
public ConditionAttrSingleConditionPane(ConditionAttributesPane conditionAttributesPane) {
this(conditionAttributesPane, true);
}
public ConditionAttrSingleConditionPane(ConditionAttributesPane conditionAttributesPane, boolean isRemove) {
super(isRemove);
this.conditionAttributesPane = conditionAttributesPane;
}
/**
* 条目名称
* @return 名称
*/
public abstract String nameForPopupMenuItem();
@Override
protected String title4PopupWindow() {
return nameForPopupMenuItem();
}
/**
* 取消
*/
public void doCancel() {
conditionAttributesPane.removeConditionAttrSingleConditionPane(this);
conditionAttributesPane.resetUseAbleActionList();
conditionAttributesPane.updateMenuDef();
conditionAttributesPane.checkConditionPane();
conditionAttributesPane.redraw();
}
public void setDefault() {
}
public HighLightConditionAction getHighLightConditionAction() {
if (hightLighAttrUpdateAction == null) {
hightLighAttrUpdateAction = new HighLightConditionAction(nameForPopupMenuItem(), conditionAttributesPane, this);
}
return hightLighAttrUpdateAction;
}
}

133
designer_base/src/com/fr/design/condition/ConditionAttributesPane.java

@ -0,0 +1,133 @@
package com.fr.design.condition;
import com.fr.base.FRContext;
import com.fr.design.actions.UpdateAction;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.menu.ToolBarDef;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.Inter;
import javax.swing.*;
import java.util.HashMap;
import java.util.Iterator;
public abstract class ConditionAttributesPane<T> extends BasicBeanPane<T> {
protected CellHighlightAddMenuDef menuDef;
protected JPanel selectedItemPane;
protected LiteConditionPane liteConditionPane;
protected java.util.Map<Class, ConditionAttrSingleConditionPane> classPaneMap = new HashMap<Class, ConditionAttrSingleConditionPane>();
//可用的Actions.
protected java.util.List<UpdateAction> useAbleActionList = new java.util.ArrayList<UpdateAction>();
protected void initComponents() {
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
// 属性 界面
JPanel propertyChangePane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane();
this.add(propertyChangePane);
propertyChangePane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("Property") + ":", null));
// 选择要改变的属性.
JPanel addItemPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
ToolBarDef toolbarDef = new ToolBarDef();
menuDef = new CellHighlightAddMenuDef();
menuDef.setName(Inter.getLocText("Highlight-Click_to_Choose_Property_To_Modify"));
menuDef.setIconPath("com/fr/design/images/control/addPopup.png");
toolbarDef.addShortCut(menuDef);
updateMenuDef();
UIToolbar toolBar = ToolBarDef.createJToolBar();
toolbarDef.updateToolBar(toolBar);
addItemPane.add(toolBar);
propertyChangePane.add(addItemPane);
selectedItemPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane();
// selectedItemPane.setLayout(new BoxLayout(selectedItemPane,BoxLayout.Y_AXIS));
// 选中的添加Itempane
JScrollPane selectedItemScrollPane = new JScrollPane();
selectedItemScrollPane.setViewportView(selectedItemPane);
selectedItemScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
propertyChangePane.add(selectedItemScrollPane);
}
public void updateBean(T ob) {
updateMenuDef();
}
protected void updateMenuDef() {
menuDef.clearShortCuts();
for (UpdateAction ac : useAbleActionList) {
menuDef.addShortCut(ac);
}
menuDef.updateMenu();
menuDef.setEnabled(true);
}
public void checkConditionPane() {
GUICoreUtils.setEnabled(this.liteConditionPane, this.selectedItemPane.getComponentCount() >= 1);
}
public ConditionAttrSingleConditionPane createConditionAttrSingleConditionPane(Class<? extends ConditionAttrSingleConditionPane> clazz) {
try {
return clazz.newInstance();
} catch (InstantiationException e) {
FRContext.getLogger().error(e.getMessage(), e);
} catch (IllegalAccessException e) {
FRContext.getLogger().error(e.getMessage(), e);
}
return null;
}
protected void addAction2UseAbleActionList() {
useAbleActionList.clear();
Iterator<ConditionAttrSingleConditionPane> iterator = classPaneMap.values().iterator();
while (iterator.hasNext()) {
useAbleActionList.add(iterator.next().getHighLightConditionAction());
}
}
public void resetUseAbleActionList() {
Iterator<ConditionAttrSingleConditionPane> iterator = classPaneMap.values().iterator();
while (iterator.hasNext()) {
ConditionAttrSingleConditionPane pane = iterator.next();
if (pane.getParent() != this.selectedItemPane && !this.useAbleActionList.contains(pane.getHighLightConditionAction())) {
this.useAbleActionList.add(pane.getHighLightConditionAction());
}
}
}
public void removeConditionAttrSingleConditionPane(JComponent component) {
selectedItemPane.remove(component);
}
public void addConditionAttrSingleConditionPane(JComponent component) {
selectedItemPane.add(component);
}
public void removeUpdateActionFromUsableList(UpdateAction action) {
useAbleActionList.remove(action);
}
public void redraw() {
validate();
repaint();
}
}

128
designer_base/src/com/fr/design/condition/ContinuousTreeSelectionModel.java

@ -0,0 +1,128 @@
package com.fr.design.condition;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeSelectionModel;
import javax.swing.tree.TreePath;
import com.fr.general.ComparatorUtils;
import com.fr.design.utils.gui.GUICoreUtils;
/**
* 一个层次连续节点.
*/
public class ContinuousTreeSelectionModel extends DefaultTreeSelectionModel {
public ContinuousTreeSelectionModel() {
}
public void addSelectionPaths(TreePath[] paths) {
if (paths == null || paths.length == 0) {
return;
}
int firstIndex = 0;
Map indexTreePathMap = new HashMap();
TreePath[] oldSelectedPaths = this.getSelectionPaths();
//peter:需要检查是否是同一个父亲的孩子
if (oldSelectedPaths != null && oldSelectedPaths.length > 0) {
TreePath parentTreePath = oldSelectedPaths[0].getParentPath();
DefaultMutableTreeNode parentTreeNode = (DefaultMutableTreeNode) parentTreePath.getLastPathComponent();
for (int i = 0; i < oldSelectedPaths.length; i++) {
if (ComparatorUtils.equals(parentTreePath, oldSelectedPaths[i].getParentPath())) {
DefaultMutableTreeNode tmpTreeNode = (DefaultMutableTreeNode) oldSelectedPaths[i].getLastPathComponent();
int treeNodeIndex = parentTreeNode.getIndex(tmpTreeNode);
if (i == 0) {
firstIndex = treeNodeIndex;
}
indexTreePathMap.put(new Integer(treeNodeIndex), GUICoreUtils.getTreePath(tmpTreeNode));
}
}
for (int i = 0; i < paths.length; i++) {
if (ComparatorUtils.equals(parentTreePath, paths[i].getParentPath())) {
DefaultMutableTreeNode tmpTreeNode = (DefaultMutableTreeNode) paths[i].getLastPathComponent();
int treeNodeIndex = parentTreeNode.getIndex(tmpTreeNode);
indexTreePathMap.put(new Integer(treeNodeIndex), GUICoreUtils.getTreePath(tmpTreeNode));
}
}
} else {
firstIndex = findFirstIndexIfNotEmpty(indexTreePathMap, paths);
}
List newTreePathList = resolveNewTreePathList(firstIndex, indexTreePathMap);
if (newTreePathList.size() > 0) {
super.addSelectionPaths((TreePath[])newTreePathList.toArray(new TreePath[newTreePathList.size()]));
}
}
public int findFirstIndexIfNotEmpty(Map indexTreePathMap, TreePath[] paths) {
int firstIndex = 0;
TreePath parentTreePath = paths[0].getParentPath();
DefaultMutableTreeNode parentTreeNode = (DefaultMutableTreeNode) parentTreePath.getLastPathComponent();
for (int i = 0; i < paths.length; i++) {
if (ComparatorUtils.equals(parentTreePath, paths[i].getParentPath())) {
DefaultMutableTreeNode tmpTreeNode = (DefaultMutableTreeNode) paths[i].getLastPathComponent();
int treeNodeIndex = parentTreeNode.getIndex(tmpTreeNode);
if (i == 0) {
firstIndex = treeNodeIndex;
}
indexTreePathMap.put(new Integer(treeNodeIndex), GUICoreUtils.getTreePath(tmpTreeNode));
}
}
return firstIndex;
}
public List resolveNewTreePathList(int firstIndex, Map indexTreePathMap) {
List newTreePathList = new ArrayList();
//peter: 先向下找.
for (int i = firstIndex - 1; i >= 0 && indexTreePathMap.size() > 0; i--) {
Object obj = indexTreePathMap.get(new Integer(i));
if (obj == null) {
break;
}
newTreePathList.add(obj);
indexTreePathMap.remove(new Integer(i));
}
//peter: 先向下找.
for (int i = firstIndex; i < Integer.MAX_VALUE && indexTreePathMap.size() > 0; i++) {
Object obj = indexTreePathMap.get(new Integer(i));
if (obj == null) {
break;
}
newTreePathList.add(obj);
indexTreePathMap.remove(new Integer(i));
}
return newTreePathList;
}
//
public void setSelectionPaths(TreePath[] paths) {
if (paths == null || paths.length == 0) {
return;
}
int firstIndex = 0;
Map indexTreePathMap = new HashMap();
firstIndex = findFirstIndexIfNotEmpty(indexTreePathMap, paths);
List newTreePathList = resolveNewTreePathList(firstIndex, indexTreePathMap);
if (newTreePathList.size() > 0) {
super.setSelectionPaths((TreePath[])newTreePathList.toArray(new TreePath[newTreePathList.size()]));
}
}
}

200
designer_base/src/com/fr/design/condition/DSColumnLiteConditionPane.java

@ -0,0 +1,200 @@
package com.fr.design.condition;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import javax.swing.DefaultComboBoxModel;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.ilable.UILabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.tree.TreePath;
import com.fr.data.condition.CommonCondition;
import com.fr.design.mainframe.JTemplate;
import com.fr.general.ComparatorUtils;
import com.fr.general.data.Condition;
import com.fr.data.condition.JoinCondition;
import com.fr.data.core.Compare;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.formula.CustomVariableResolver;
import com.fr.design.formula.VariableResolver;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxRenderer;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.editor.ValueEditorPane;
import com.fr.design.editor.ValueEditorPaneFactory;
import com.fr.design.editor.editor.ColumnIndexEditor;
import com.fr.design.editor.editor.ColumnNameEditor;
import com.fr.design.editor.editor.Editor;
import com.fr.general.Inter;
import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils;
public class DSColumnLiteConditionPane extends LiteConditionPane<CommonCondition> {
/**
*
*/
private static final long serialVersionUID = 1L;
private String[] displayNames = ArrayUtils.EMPTY_STRING_ARRAY;
@Override
protected BasicBeanPane<CommonCondition> createUnFormulaConditionPane() {
return new CommonConditionPane();
}
@Override
protected VariableResolver variableResolver4FormulaPane() {
return new CustomVariableResolver(displayNames, false);
}
/**
* 刷新数据列
* @param displayNames 数据列名称
*/
public void populateColumns(String[] displayNames) {
CommonConditionPane ccp = (CommonConditionPane) this.defaultConditionPane;
this.displayNames = displayNames;
if(ArrayUtils.isNotEmpty(displayNames)){
ccp.setEditor(new Editor[] { new ColumnNameEditor(displayNames), new ColumnIndexEditor(displayNames.length)}, displayNames[0]);
}
TreePath selectedTreePath = conditionsTree.getSelectionPath();
if (selectedTreePath != null) {
ExpandMutableTreeNode selectedTreeNode = (ExpandMutableTreeNode) selectedTreePath.getLastPathComponent();
JoinCondition joinCondition = (JoinCondition) selectedTreeNode.getUserObject();
Condition liteCondition = joinCondition.getCondition();
if(liteCondition instanceof CommonCondition){
CommonCondition commonCondition = (CommonCondition) liteCondition;
int columnNumber = commonCondition.getColumnNumber();
if (columnNumber > 0){
ccp.keyColumnPane.populate(columnNumber);
} else {
String columnName = commonCondition.getColumnName();
ccp.keyColumnPane.populate(columnName);
}
}
}
}
protected class CommonConditionPane extends BasicBeanPane<CommonCondition> {
private static final long serialVersionUID = 1L;
private ValueEditorPane keyColumnPane;
private UIComboBox conditionOPComboBox;
private ValueEditorPane conditionValuePane;
CommonConditionPane() {
initComponents();
}
public void setEditor(Editor[] editors, Object obj) {
keyColumnPane.setEditors(editors, obj);
}
protected void initComponents() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
keyColumnPane = ValueEditorPaneFactory.createValueEditorPane(new Editor[] { new ColumnNameEditor(), new ColumnIndexEditor() });
conditionOPComboBox = new UIComboBox(new DefaultComboBoxModel());
DefaultComboBoxModel opComboBoxModel = (DefaultComboBoxModel) conditionOPComboBox.getModel();
int[] allOperators = Compare.getAllOperators();
for (int i = 0; i < allOperators.length; i++) {
opComboBoxModel.addElement(new Integer(allOperators[i]));
}
this.conditionOPComboBox.setRenderer(new UIComboBoxRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof Integer) {
this.setText(Compare.operator2String(((Integer) value).intValue()));
}
return this;
}
});
conditionValuePane = createValueEditorPane();
keyColumnPane.setPreferredSize(new Dimension(175, keyColumnPane.getPreferredSize().height));
conditionOPComboBox.setPreferredSize(new Dimension(80, 20));
Component[][] components = {
{ new UILabel(Inter.getLocText("Utils-Available_Columns") + ":"), new UILabel(Inter.getLocText("FR-ConditionB_Operator") + ":"),
new UILabel() }, { keyColumnPane, conditionOPComboBox, conditionValuePane } };
double p = TableLayout.PREFERRED;
double rowSize[] = { p, p };
double columnSize[] = { p, p, TableLayout.FILL };
JPanel leftPanel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
this.add(leftPanel, BorderLayout.CENTER);
}
protected ValueEditorPane createValueEditorPane() {
JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if(jTemplate.isChartBook()){
return ValueEditorPaneFactory.createBasicEditorWithoutFormulaPane();
}
return ValueEditorPaneFactory.createAllValueEditorPane();
}
@Override
public CommonCondition updateBean() {
Object value = conditionValuePane.update();
int columnNumber = (Integer) keyColumnPane.update();
String columnName = StringUtils.EMPTY;
if(keyColumnPane.getCurrentEditor() instanceof ColumnNameEditor && ArrayUtils.isNotEmpty(displayNames)){
columnName = DSColumnLiteConditionPane.this.displayNames[columnNumber - 1];
columnNumber = -1;
}
return new CommonCondition(columnName, columnNumber, new Compare(
((Integer) conditionOPComboBox.getSelectedItem()).intValue(), value));
}
@Override
public void populateBean(CommonCondition condition) {
String selectionColumn = condition.getColumnName();
int selectionColumnNumber = condition.getColumnNumber();
if(StringUtils.isNotEmpty(selectionColumn)){
for (int i = 0; i < DSColumnLiteConditionPane.this.displayNames.length; i++) {
if(ComparatorUtils.equals(DSColumnLiteConditionPane.this.displayNames[i],selectionColumn)) {
//keyColumnPane.populate(i + 1);
keyColumnPane.populate(selectionColumn);
break;
}
}
}else{
keyColumnPane.populate(selectionColumnNumber);
}
Compare compare = condition.getCompare();
if (compare == null) {
return;
}
conditionOPComboBox.setSelectedItem(new Integer(compare.getOp()));
Object value = compare.getValue();
conditionValuePane.populate(value);
}
@Override
protected String title4PopupWindow() {
return " ";
}
@Override
public void checkValid() throws Exception {
conditionOPComboBox.setSelectedIndex(0);
conditionValuePane.populate(StringUtils.EMPTY);
}
}
}

21
designer_base/src/com/fr/design/condition/DSColumnSimpleLiteConditionPane.java

@ -0,0 +1,21 @@
package com.fr.design.condition;
import com.fr.data.condition.CommonCondition;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.editor.ValueEditorPane;
import com.fr.design.editor.ValueEditorPaneFactory;
public class DSColumnSimpleLiteConditionPane extends DSColumnLiteConditionPane {
@Override
protected BasicBeanPane<CommonCondition> createUnFormulaConditionPane() {
return new SimpleCommonConditionPane();
}
protected class SimpleCommonConditionPane extends CommonConditionPane {
protected ValueEditorPane createValueEditorPane() {
return ValueEditorPaneFactory.createNoCRNoColumnValueEditorPane();
}
}
}

36
designer_base/src/com/fr/design/condition/HighLightConditionAction.java

@ -0,0 +1,36 @@
package com.fr.design.condition;
import com.fr.design.actions.UpdateAction;
import java.awt.event.ActionEvent;
/**
* @author richie
* @date 2015-03-26
* @since 8.0
*/
public class HighLightConditionAction extends UpdateAction {
private ConditionAttributesPane conditionAttributesPane;
private ConditionAttrSingleConditionPane conditionAttrSingleConditionPane;
public HighLightConditionAction(String name, ConditionAttributesPane conditionAttributesPane, ConditionAttrSingleConditionPane conditionAttrSingleConditionPane) {
this.setName(name);
this.conditionAttributesPane = conditionAttributesPane;
this.conditionAttrSingleConditionPane = conditionAttrSingleConditionPane;
}
/**
* 响应事件
* @param e 事件
*/
@Override
public void actionPerformed(ActionEvent e) {
conditionAttributesPane.addConditionAttrSingleConditionPane(conditionAttrSingleConditionPane);
conditionAttributesPane.removeUpdateActionFromUsableList(this);
conditionAttributesPane.updateMenuDef();
conditionAttributesPane.checkConditionPane();
conditionAttributesPane.redraw();
conditionAttrSingleConditionPane.setDefault();
}
}

950
designer_base/src/com/fr/design/condition/LiteConditionPane.java

@ -0,0 +1,950 @@
package com.fr.design.condition;
import com.fr.base.BaseUtils;
import com.fr.base.Formula;
import com.fr.data.DataConstants;
import com.fr.data.condition.*;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.formula.FormulaFactory;
import com.fr.design.formula.UIFormula;
import com.fr.design.formula.VariableResolver;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextarea.UITextArea;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.scrollruler.ModLineBorder;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import com.fr.general.data.Condition;
import javax.swing.*;
import javax.swing.event.TreeExpansionEvent;
import javax.swing.event.TreeExpansionListener;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
/**
* peter: LiteCondition Pane.
*/
public abstract class LiteConditionPane<T extends Condition> extends BasicBeanPane<Condition> {
private static int MOVE_UP = 0;
private static int MOVE_DOWN = 1;
private static final long serialVersionUID = 1L;
// peter:这两个变量在弹出公式编辑器的时候,需要用.
private UIRadioButton commonRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer_LiteCondition_Common"));
private UIRadioButton formulaRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer_LiteCondition_Formula"));
private JPanel conditionCardPane;
protected BasicBeanPane<T> defaultConditionPane;
// card2
private UITextArea formulaTextArea;
private UIButton modifyButton;
private UIButton addButton;
private UIRadioButton andRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer_LiteCondition_ConditionB-AND") + " ");
private UIRadioButton orRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer_LiteCondition_ConditionB-OR"));
protected JTree conditionsTree;// Conditions
private UIButton removeButton;
private UIButton moveUpButton;
private UIButton moveDownButton;
private UIButton bracketButton;
private UIButton unBracketButton;
private ActionListener actionListener1 = new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
Formula formula;
String text = formulaTextArea.getText();
if (text == null || text.length() <= 0) {
formula = new Formula("");
} else {
formula = new Formula(text);
}
final UIFormula formulaPane = FormulaFactory.createFormulaPane();
formulaPane.populate(formula, variableResolver4FormulaPane());
formulaPane.showLargeWindow(SwingUtilities.getWindowAncestor(LiteConditionPane.this), new DialogActionAdapter() {
@Override
public void doOk() {
Formula formula = formulaPane.update();
if (formula.getContent().length() <= 1) {// 如果没有填任何字符,则是空白文本
formulaTextArea.setText("");
} else {
formulaTextArea.setText(formula.getContent().substring(1));
}
}
}).setVisible(true);
}
};
private ActionListener actionListener2 = new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
// peter:先获得当前的LiteCondition.
Condition liteCondition = null;
if (commonRadioButton.isSelected()) {
liteCondition = defaultConditionPane.updateBean();
} else {
liteCondition = new FormulaCondition(formulaTextArea.getText());
}
JoinCondition newJoinCondition = new JoinCondition(andRadioButton.isSelected() ? DataConstants.AND : DataConstants.OR, liteCondition);
ExpandMutableTreeNode parentTreeNode = getParentTreeNode();
boolean result = isExistedInParentTreeNode(parentTreeNode, newJoinCondition);
if (result) {
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(LiteConditionPane.this),
Inter.getLocText("BindColumn-This_Condition_has_been_existed"));
return;
}
ExpandMutableTreeNode newJionConditionTreeNode = new ExpandMutableTreeNode(newJoinCondition);
parentTreeNode.add(newJionConditionTreeNode);
DefaultTreeModel defaultTreeModel = (DefaultTreeModel) conditionsTree.getModel();
defaultTreeModel.reload(parentTreeNode);
parentTreeNode.expandCurrentTreeNode(conditionsTree);
conditionsTree.setSelectionPath(GUICoreUtils.getTreePath(newJionConditionTreeNode));
// peter:必须要检查Enabled.
checkButtonEnabledForList();
}
};
private MouseAdapter mouseAdapter = new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent evt) {
TreePath selectedTreePath = conditionsTree.getSelectionPath();
// peter:当前的节点
if (selectedTreePath != null) {
ExpandMutableTreeNode selectedTreeNode = (ExpandMutableTreeNode) selectedTreePath.getLastPathComponent();
JoinCondition oldJoinCondition = (JoinCondition) selectedTreeNode.getUserObject();
oldJoinCondition.setJoin(andRadioButton.isSelected() ? DataConstants.AND : DataConstants.OR);
Condition oldLiteCondition = oldJoinCondition.getCondition();
// peter:如果当前选中的是ListCondition,只要改变Join为AND或者OR,直接返回.
if (oldLiteCondition instanceof ListCondition) {
GUICoreUtils.setEnabled(conditionCardPane, false);
}
}
}
@Override
public void mouseExited(MouseEvent evt) {
GUICoreUtils.setEnabled(conditionCardPane, conditionCardPane.isEnabled());
}
};
private TreeSelectionListener treeSelectionListener = new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent evt) {
checkButtonEnabledForList();
TreePath selectedTreePath = conditionsTree.getSelectionPath();
if (selectedTreePath == null) {
return;
}
ExpandMutableTreeNode selectedTreeNode = (ExpandMutableTreeNode) selectedTreePath.getLastPathComponent();
Object userObject = selectedTreeNode.getUserObject();
if (userObject instanceof JoinCondition) {
JoinCondition joinCondition = (JoinCondition) userObject;
// peter:先弄join.
int join = joinCondition.getJoin();
if (join == DataConstants.AND) {
andRadioButton.setSelected(true);
} else {
orRadioButton.setSelected(true);
}
// peter:当前的liteCondtion.
Condition liteCondition = joinCondition.getCondition();
// elake:两种Condition对应于数据列和高亮.
if (liteCondition instanceof CommonCondition || liteCondition instanceof ObjectCondition) {
Condition commonCondition = liteCondition;
commonRadioButton.setSelected(true);
applyCardsPane();
defaultConditionPane.populateBean((T) commonCondition);
} else if (liteCondition instanceof FormulaCondition) {
FormulaCondition formulaCondition = (FormulaCondition) liteCondition;
formulaRadioButton.setSelected(true);
applyCardsPane();
formulaTextArea.setText(formulaCondition.getFormula());
}
}
}
};
private ActionListener actionListener3 = new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
TreePath selectedTreePath = conditionsTree.getSelectionPath();
if (selectedTreePath == null) {
return;
}
int returnVal = JOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(LiteConditionPane.this),
Inter.getLocText("Utils-Are_you_sure_to_remove_the_selected_item") + "?", Inter.getLocText("FR-Designer_Remove"),
JOptionPane.OK_CANCEL_OPTION);
if (returnVal == JOptionPane.OK_OPTION) {
DefaultTreeModel treeModel = (DefaultTreeModel) conditionsTree.getModel();
TreePath[] selectedTreePaths = conditionsTree.getSelectionPaths();
for (int i = selectedTreePaths.length - 1; i >= 0; i--) {
ExpandMutableTreeNode selectedTreeNode = (ExpandMutableTreeNode) selectedTreePaths[i].getLastPathComponent();
ExpandMutableTreeNode parentTreeNode = (ExpandMutableTreeNode) selectedTreeNode.getParent();
// peter:将要选择节点.
ExpandMutableTreeNode nextSelectTreeNode;
if (parentTreeNode.getChildAfter(selectedTreeNode) != null) {
nextSelectTreeNode = (ExpandMutableTreeNode) parentTreeNode.getChildAfter(selectedTreeNode);
} else if (parentTreeNode.getChildBefore(selectedTreeNode) != null) {
nextSelectTreeNode = (ExpandMutableTreeNode) parentTreeNode.getChildBefore(selectedTreeNode);
} else {
nextSelectTreeNode = parentTreeNode;
}
parentTreeNode.remove(selectedTreeNode);
if (!ComparatorUtils.equals(nextSelectTreeNode, treeModel.getRoot())) {
conditionsTree.setSelectionPath(GUICoreUtils.getTreePath(nextSelectTreeNode));
}
treeModel.reload(parentTreeNode);
parentTreeNode.expandCurrentTreeNode(conditionsTree);
if (!ComparatorUtils.equals(nextSelectTreeNode, treeModel.getRoot())) {
conditionsTree.setSelectionPath(GUICoreUtils.getTreePath(nextSelectTreeNode));
}
}
// peter:检查Button Enabled.
checkButtonEnabledForList();
}
}
};
private ActionListener actionListener4 = new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
TreePath selectedTreePath = conditionsTree.getSelectionPath();
if (selectedTreePath == null) {
return;
}
ExpandMutableTreeNode selectedTreeNode = (ExpandMutableTreeNode) selectedTreePath.getLastPathComponent();
ExpandMutableTreeNode parentTreeNode = (ExpandMutableTreeNode) selectedTreeNode.getParent();
if (parentTreeNode.getChildBefore(selectedTreeNode) != null) {
swapNodesOfConditionTree(parentTreeNode, (ExpandMutableTreeNode) parentTreeNode.getChildBefore(selectedTreeNode),
selectedTreeNode, MOVE_UP);
}
}
};
private ActionListener actionListener5 = new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
TreePath selectedTreePath = conditionsTree.getSelectionPath();
if (selectedTreePath == null) {
return;
}
ExpandMutableTreeNode selectedTreeNode = (ExpandMutableTreeNode) selectedTreePath.getLastPathComponent();
ExpandMutableTreeNode parentTreeNode = (ExpandMutableTreeNode) selectedTreeNode.getParent();
if (parentTreeNode.getChildAfter(selectedTreeNode) != null) {
swapNodesOfConditionTree(parentTreeNode, selectedTreeNode, (ExpandMutableTreeNode) parentTreeNode.getChildAfter(selectedTreeNode), MOVE_DOWN);
}
}
};
private ActionListener actionListener6 = new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
TreePath[] selectedTreePaths = conditionsTree.getSelectionPaths();
// peter:当前的节点
if (selectedTreePaths == null || selectedTreePaths.length <= 1) {
return;
}
// peter: 找到父亲节点,并且删除所有的节点.
TreePath topTreePath = GUICoreUtils.getTopTreePath(conditionsTree, selectedTreePaths);
ExpandMutableTreeNode leadTreeNode = (ExpandMutableTreeNode) topTreePath.getLastPathComponent();
ExpandMutableTreeNode parentTreeNode = (ExpandMutableTreeNode) leadTreeNode.getParent();
int topIndex = parentTreeNode.getIndex(leadTreeNode);
JoinCondition firstJionCondition = (JoinCondition) leadTreeNode.getUserObject();
for (int i = 0; i < selectedTreePaths.length; i++) {
ExpandMutableTreeNode tmpTreeNode = (ExpandMutableTreeNode) selectedTreePaths[i].getLastPathComponent();
parentTreeNode.remove(tmpTreeNode);
}
// peter:建立新的节点.
JoinCondition newJionCondition = new JoinCondition();
newJionCondition.setJoin(firstJionCondition.getJoin());
newJionCondition.setCondition(new ListCondition());
ExpandMutableTreeNode newTreeNode = new ExpandMutableTreeNode(newJionCondition);
for (int i = 0; i < selectedTreePaths.length; i++) {
ExpandMutableTreeNode tmpTreeNode = (ExpandMutableTreeNode) selectedTreePaths[i].getLastPathComponent();
newTreeNode.add(tmpTreeNode);
}
// peter:添加新的节点
parentTreeNode.insert(newTreeNode, topIndex);
// peter:需要reload
DefaultTreeModel defaultTreeModel = (DefaultTreeModel) conditionsTree.getModel();
defaultTreeModel.reload(parentTreeNode);
parentTreeNode.expandCurrentTreeNode(conditionsTree);
// peter:选择一个节点
conditionsTree.setSelectionPath(GUICoreUtils.getTreePath(newTreeNode));
}
};
ActionListener actionListener7 = new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
TreePath selectedTreePath = conditionsTree.getSelectionPath();
// peter:当前的节点
if (selectedTreePath == null) {
return;
}
ExpandMutableTreeNode selectedTreeNode = (ExpandMutableTreeNode) selectedTreePath.getLastPathComponent();
JoinCondition joinCondition = (JoinCondition) selectedTreeNode.getUserObject();
Condition liteCondition = joinCondition.getCondition();
if (liteCondition instanceof ListCondition) {
ExpandMutableTreeNode parentTreeNode = (ExpandMutableTreeNode) selectedTreeNode.getParent();
int index = parentTreeNode.getIndex(selectedTreeNode);
// peter:添加节点
List<TreePath> treePathList = new ArrayList<TreePath>();
for (int i = selectedTreeNode.getChildCount() - 1; i >= 0; i--) {
ExpandMutableTreeNode tmpTreeNode = (ExpandMutableTreeNode) selectedTreeNode.getChildAt(i);
parentTreeNode.insert(tmpTreeNode, index);
treePathList.add(GUICoreUtils.getTreePath(tmpTreeNode));
}
// peter;删除这个List节点
parentTreeNode.remove(selectedTreeNode);
// peter:需要reload
DefaultTreeModel defaultTreeModel = (DefaultTreeModel) conditionsTree.getModel();
defaultTreeModel.reload(parentTreeNode);
parentTreeNode.expandCurrentTreeNode(conditionsTree);
// peter:选择所有选择的节点
TreePath[] selectedTreePaths = new TreePath[treePathList.size()];
treePathList.toArray(selectedTreePaths);
conditionsTree.setSelectionPaths(selectedTreePaths);
}
}
};
private ActionListener actionListener8 = new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
modify();
}
};
// 图表条件高亮时没有公式选择
protected JPanel conditonTypePane;
public LiteConditionPane() {
this.initComponents();
}
protected abstract BasicBeanPane<T> createUnFormulaConditionPane();
protected abstract VariableResolver variableResolver4FormulaPane();
protected void initComponents() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
// north
initNorth();
//center
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.add(centerPane, BorderLayout.CENTER);
centerPane.setLayout(FRGUIPaneFactory.createBorderLayout());
// Control
JPanel controlPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
centerPane.add(controlPane, BorderLayout.NORTH);
// controlPane.setLayout(FRGUIPaneFactory.createBorderLayout());
// conditionCardPane
initConditionCardPane(controlPane);
// addControlPane, contains or,and Radio, add,modify Button
initControlPane(controlPane);
// Preview
JPanel previewPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
centerPane.add(previewPane, BorderLayout.CENTER);
previewPane.setBorder(BorderFactory.createEmptyBorder(0, 2, 2, 0));
// conTreeScrollPane.setPreferredSize(new Dimension(400, 125));
previewPane.add(iniTreeScrollPane(), BorderLayout.CENTER);
conditionsTree.addTreeSelectionListener(treeSelectionListener);
JPanel buttonPane = FRGUIPaneFactory.createNColumnGridInnerContainer_S_Pane(1);
previewPane.add(GUICoreUtils.createBorderPane(buttonPane, BorderLayout.NORTH), BorderLayout.EAST);
initButtonPane(buttonPane);
// peter:必须要检查Enabled.
checkButtonEnabledForList();
}
private void initButtonPane(JPanel buttonPane) {
removeButton = new UIButton(Inter.getLocText("FR-Designer_Remove"));
buttonPane.add(removeButton);
removeButton.setIcon(BaseUtils.readIcon("com/fr/base/images/cell/control/remove.png"));
removeButton.setEnabled(false);
removeButton.addActionListener(actionListener3);
moveUpButton = new UIButton(Inter.getLocText("Utils-Move_Up"));
buttonPane.add(moveUpButton);
moveUpButton.setIcon(BaseUtils.readIcon("com/fr/design/images/control/up.png"));
moveUpButton.addActionListener(actionListener4);
moveDownButton = new UIButton(Inter.getLocText("Utils-Move_Down"));
buttonPane.add(moveDownButton);
moveDownButton.setIcon(BaseUtils.readIcon("com/fr/design/images/control/down.png"));
moveDownButton.addActionListener(actionListener5);
// peter:加括号
bracketButton = new UIButton(Inter.getLocText("ConditionB-Add_bracket"));
buttonPane.add(bracketButton);
bracketButton.setIcon(BaseUtils.readIcon("com/fr/design/images/condition/bracket.png"));
bracketButton.addActionListener(actionListener6);
// peter:去掉括号
unBracketButton = new UIButton(Inter.getLocText("ConditionB-Remove_bracket"));
buttonPane.add(unBracketButton);
unBracketButton.setIcon(BaseUtils.readIcon("com/fr/design/images/condition/unBracket.png"));
unBracketButton.addActionListener(actionListener7);
}
private JScrollPane iniTreeScrollPane() {
conditionsTree = new JTree(new DefaultTreeModel(new ExpandMutableTreeNode(new JoinCondition(DataConstants.AND, new ListCondition()))));
conditionsTree.setRootVisible(false);
conditionsTree.setCellRenderer(conditionsTreeCellRenderer);
conditionsTree.setSelectionModel(new ContinuousTreeSelectionModel());
conditionsTree.addTreeExpansionListener(treeExpansionListener);
conditionsTree.setShowsRootHandles(true);
return new JScrollPane(conditionsTree);
}
private void initNorth() {
conditonTypePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.add(conditonTypePane, BorderLayout.NORTH);
conditonTypePane.setBorder(new ModLineBorder(ModLineBorder.BOTTOM));
UILabel conditionTypeLabel = new UILabel(Inter.getLocText("FR-Designer_Type") + ":");
conditonTypePane.add(conditionTypeLabel, BorderLayout.WEST);
conditionTypeLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 4, 0));
JPanel northPane = FRGUIPaneFactory.createNColumnGridInnerContainer_S_Pane(2);
conditonTypePane.add(northPane, BorderLayout.CENTER);
northPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 4, 0));
northPane.add(GUICoreUtils.createFlowPane(commonRadioButton, FlowLayout.CENTER));
northPane.add(GUICoreUtils.createFlowPane(formulaRadioButton, FlowLayout.CENTER));
commonRadioButton.addActionListener(radioActionListener);
formulaRadioButton.addActionListener(radioActionListener);
ButtonGroup mainBg = new ButtonGroup();
mainBg.add(commonRadioButton);
mainBg.add(formulaRadioButton);
commonRadioButton.setSelected(true);
}
private void initConditionCardPane(JPanel controlPane) {
conditionCardPane = FRGUIPaneFactory.createCardLayout_S_Pane();
controlPane.add(conditionCardPane, BorderLayout.CENTER);
conditionCardPane.setLayout(new CardLayout());
conditionCardPane.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0));
// defaultConditionPane
conditionCardPane.add(defaultConditionPane = createUnFormulaConditionPane(), "DEFAULT");
// formulaConditionPane
JPanel formulaConditionPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
conditionCardPane.add(formulaConditionPane, "FORMULA");
// formulaConditionPane.setLayout(FRGUIPaneFactory.createBorderLayout());
// formulaPane
JPanel formulaPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
formulaConditionPane.add(formulaPane, BorderLayout.CENTER);
formulaPane.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 2));
formulaPane.add(GUICoreUtils.createBorderPane(new UILabel(Inter.getLocText("FR-Designer_LiteCondition_Formula") + "="), BorderLayout.NORTH), BorderLayout.WEST);
formulaTextArea = new UITextArea();
formulaPane.add(new JScrollPane(formulaTextArea), BorderLayout.CENTER);
UIButton editFormulaButton = new UIButton(Inter.getLocText("FR-Designer_LiteCondition_Define"));
formulaPane.add(GUICoreUtils.createBorderPane(editFormulaButton, BorderLayout.NORTH), BorderLayout.EAST);
editFormulaButton.addActionListener(actionListener1);
applyCardsPane();
}
private void initControlPane(JPanel controlPane) {
JPanel addControlPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
controlPane.add(addControlPane, BorderLayout.SOUTH);
addControlPane.setBorder(new ModLineBorder(ModLineBorder.TOP));
ButtonGroup bg = new ButtonGroup();
bg.add(andRadioButton);
bg.add(orRadioButton);
andRadioButton.setSelected(true);
JPanel radioPane = FRGUIPaneFactory.createNColumnGridInnerContainer_S_Pane(3);
addControlPane.add(radioPane);
radioPane.add(andRadioButton);
addControlPane.add(Box.createHorizontalStrut(4));
radioPane.add(orRadioButton);
addControlPane.add(Box.createHorizontalStrut(12));
addButton = new UIButton(Inter.getLocText("FR-Designer_Add"), BaseUtils.readIcon("com/fr/base/images/cell/control/add.png"));
addButton.setMnemonic('A');
addControlPane.add(addButton);
addButton.addActionListener(actionListener2);
addControlPane.add(Box.createHorizontalStrut(4));
modifyButton = new UIButton(Inter.getLocText("FR-Designer_Modify"), BaseUtils.readIcon("com/fr/base/images/cell/control/rename.png"));
modifyButton.setMnemonic('M');
addControlPane.add(modifyButton);
modifyButton.addActionListener(actionListener8);
// peter:当鼠标进入修改按钮的时候,如果是ListConditon内容编辑区域不可编辑
modifyButton.addMouseListener(mouseAdapter);
}
@Override
protected String title4PopupWindow() {
return Inter.getLocText("FR-Designer-Submit_Condition");
}
// samuel:移出来,方便调用
protected void modify() {
TreePath selectedTreePath = conditionsTree.getSelectionPath();
// peter:当前的节点
if (selectedTreePath != null) {
ExpandMutableTreeNode selectedTreeNode = (ExpandMutableTreeNode) selectedTreePath.getLastPathComponent();
JoinCondition oldJoinCondition = (JoinCondition) selectedTreeNode.getUserObject();
oldJoinCondition.setJoin(andRadioButton.isSelected() ? DataConstants.AND : DataConstants.OR);
Condition oldLiteCondition = oldJoinCondition.getCondition();
// peter:如果当前选中的是ListCondition,只要改变Join为AND或者OR,直接返回.
if (oldLiteCondition != null && !(oldLiteCondition instanceof ListCondition)) {
// peter:先获得当前的LiteCondition.
Condition liteCondition;
if (commonRadioButton.isSelected()) {
liteCondition = defaultConditionPane.updateBean();
} else {
liteCondition = new FormulaCondition(formulaTextArea.getText());
}
oldJoinCondition.setCondition(liteCondition);
}
// peter:需要reload parent
DefaultTreeModel defaultTreeModel = (DefaultTreeModel) conditionsTree.getModel();
ExpandMutableTreeNode parentTreeNode = (ExpandMutableTreeNode) selectedTreeNode.getParent();
defaultTreeModel.reload(parentTreeNode);
parentTreeNode.expandCurrentTreeNode(conditionsTree);
conditionsTree.setSelectionPath(GUICoreUtils.getTreePath(selectedTreeNode));
}
}
protected void swapNodesOfConditionTree(ExpandMutableTreeNode parentTreeNode, ExpandMutableTreeNode firstSelectTreeNode,
ExpandMutableTreeNode secondTreeNode, int type) {
int nextIndex = parentTreeNode.getIndex(firstSelectTreeNode);
parentTreeNode.remove(firstSelectTreeNode);
parentTreeNode.remove(secondTreeNode);
parentTreeNode.insert(firstSelectTreeNode, nextIndex);
parentTreeNode.insert(secondTreeNode, nextIndex);
DefaultTreeModel treeModel = (DefaultTreeModel) conditionsTree.getModel();
treeModel.reload(parentTreeNode);
parentTreeNode.expandCurrentTreeNode(conditionsTree);
if (type == MOVE_UP) {
conditionsTree.setSelectionPath(GUICoreUtils.getTreePath(secondTreeNode));
} else if (type == MOVE_DOWN) {
conditionsTree.setSelectionPath(GUICoreUtils.getTreePath(firstSelectTreeNode));
}
// peter:检查Button Enabled.
checkButtonEnabledForList();
}
ActionListener radioActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
applyCardsPane();
}
};
private void applyCardsPane() {
CardLayout cl = (CardLayout) (conditionCardPane.getLayout());
if (this.commonRadioButton.isSelected()) {
this.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("FR-Designer_LiteCondition_Common_Condition"), null));
cl.show(conditionCardPane, "DEFAULT");
} else {
this.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("FR-Designer_LiteCondition_Formula_Condition"), null));
cl.show(conditionCardPane, "FORMULA");
}
}
/**
* peter:检查Button是否可以编辑.
*/
private void checkButtonEnabledForList() {
modifyButton.setEnabled(false);
removeButton.setEnabled(false);
this.moveUpButton.setEnabled(false);
this.moveDownButton.setEnabled(false);
this.bracketButton.setEnabled(false);
this.unBracketButton.setEnabled(false);
TreePath selectedTreePath = conditionsTree.getSelectionPath();
if (selectedTreePath != null) {
modifyButton.setEnabled(true);
removeButton.setEnabled(true);
// peter:根据选中的节点的是否是第一个或者最后一个.
ExpandMutableTreeNode selectedTreeNode = (ExpandMutableTreeNode) selectedTreePath.getLastPathComponent();
DefaultMutableTreeNode parentTreeNode = (DefaultMutableTreeNode) selectedTreeNode.getParent();
if (parentTreeNode.getChildBefore(selectedTreeNode) != null) {
moveUpButton.setEnabled(true);
}
if (parentTreeNode.getChildAfter(selectedTreeNode) != null) {
moveDownButton.setEnabled(true);
}
// peter: 连续选中了超过两个条件,同时没有选中所有的节点.
int selectionCount = conditionsTree.getSelectionCount();
if (selectionCount > 1 && parentTreeNode.getChildCount() > selectionCount) {
this.bracketButton.setEnabled(true);
}
// peter:选中的节点必须是ListCondition,才可以删除括号
JoinCondition jonCondition = (JoinCondition) selectedTreeNode.getUserObject();
Condition liteCondtion = jonCondition.getCondition();
if (liteCondtion instanceof ListCondition) {
this.unBracketButton.setEnabled(true);
}
}
}
/**
* 扩展事件.
*/
TreeExpansionListener treeExpansionListener = new TreeExpansionListener() {
@Override
public void treeExpanded(TreeExpansionEvent event) {
TreePath selectedTreePath = event.getPath();
if (selectedTreePath == null) {
return;
}
ExpandMutableTreeNode selectedTreeNode = (ExpandMutableTreeNode) selectedTreePath.getLastPathComponent();
selectedTreeNode.setExpanded(true);
}
@Override
public void treeCollapsed(TreeExpansionEvent event) {
TreePath selectedTreePath = event.getPath();
if (selectedTreePath == null) {
return;
}
ExpandMutableTreeNode selectedTreeNode = (ExpandMutableTreeNode) selectedTreePath.getLastPathComponent();
selectedTreeNode.setExpanded(false);
}
};
private ExpandMutableTreeNode getParentTreeNode() {
DefaultTreeModel defaultTreeModel = (DefaultTreeModel) conditionsTree.getModel();
TreePath selectedTreePath = conditionsTree.getSelectionPath();
// peter:如果没有选择的节点,直接添加到根节点.
ExpandMutableTreeNode parentTreeNode;
if (selectedTreePath == null) {
parentTreeNode = (ExpandMutableTreeNode) defaultTreeModel.getRoot();
} else {
parentTreeNode = (ExpandMutableTreeNode) ((ExpandMutableTreeNode) selectedTreePath.getLastPathComponent()).getParent();
}
// peter:如果没有选中的节点,直接返回.
return parentTreeNode;
}
private boolean isExistedInParentTreeNode(ExpandMutableTreeNode parentTreeNode, JoinCondition newJoinCondition) {
if (parentTreeNode == null) {
return false;
}
JoinCondition parentJoinCondition = (JoinCondition) parentTreeNode.getUserObject();
Condition parentLiteCondition = parentJoinCondition.getCondition();
if (parentLiteCondition instanceof ListCondition) {
// peter:在添加UserObject的节点.
for (int i = 0; i < parentTreeNode.getChildCount(); i++) {
ExpandMutableTreeNode tempTreeNode = (ExpandMutableTreeNode) parentTreeNode.getChildAt(i);
Object tempObject = tempTreeNode.getUserObject();
if (tempObject instanceof JoinCondition) {
JoinCondition tempJoinCondition = (JoinCondition) tempObject;
if (ComparatorUtils.equals(tempJoinCondition, newJoinCondition)) {
return true;
}
}
}
}
return false;
}
private DefaultTreeCellRenderer conditionsTreeCellRenderer = new DefaultTreeCellRenderer() {
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row,
boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
DefaultMutableTreeNode currentTreeNode = (DefaultMutableTreeNode) value;
adjustParentListCondition(currentTreeNode);
DefaultMutableTreeNode parentTreeNode = (DefaultMutableTreeNode) currentTreeNode.getParent();
this.setIcon(null);
JoinCondition joinCondition = (JoinCondition) currentTreeNode.getUserObject();
StringBuilder sBuf = new StringBuilder();
Condition liteCondition = joinCondition.getCondition();
if (parentTreeNode != null && parentTreeNode.getFirstChild() != currentTreeNode) {
if (joinCondition.getJoin() == DataConstants.AND) {
sBuf.append("and ");
} else {
sBuf.append("or ");
}
}
if (liteCondition != null) {
// TODO alex:这里得到的liteCondition为什么会是null呢?
sBuf.append(liteCondition.toString());
}
this.setText(sBuf.toString());
return this;
}
};
// peter:根据孩子几点,调整当前节点的ListCondition的值.
protected void adjustParentListCondition(DefaultMutableTreeNode currentTreeNode) {
DefaultMutableTreeNode parentTreeNode = (DefaultMutableTreeNode) currentTreeNode.getParent();
Object userObj = currentTreeNode.getUserObject();
if (userObj instanceof JoinCondition) {
StringBuilder sBuf = new StringBuilder();
JoinCondition joinCondition = (JoinCondition) userObj;
Condition liteCondition = joinCondition.getCondition();
if (parentTreeNode != null && parentTreeNode.getFirstChild() != currentTreeNode) {
if (joinCondition.getJoin() == DataConstants.AND) {
sBuf.append("and ");
} else {
sBuf.append("or ");
}
}
// peter:这个地方动态产生ListCondition,因为ListCondition的节点会变化的,
// 父亲节点的ListCondition这个UserObject需要跟着变化.
if (liteCondition instanceof ListCondition) {
ListCondition listCondition = (ListCondition) liteCondition;
listCondition.clearJoinConditions();
// peter:动态添加孩子节点
int childCount = currentTreeNode.getChildCount();
for (int i = 0; i < childCount; i++) {
Object tmpUserObject = ((DefaultMutableTreeNode) currentTreeNode.getChildAt(i)).getUserObject();
if (tmpUserObject instanceof JoinCondition) {
listCondition.addJoinCondition((JoinCondition) tmpUserObject);
}
}
}
}
}
/**
* Sets whether or not this component is enabled.
*/
@Override
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
// checkenabled.
checkButtonEnabledForList();
}
/**
* Populate.
*
* @param liteCondition lite condition.
*/
@Override
public void populateBean(Condition liteCondition) {
if(liteCondition == null){
return;
}
// peter: 先删除所有的节点
DefaultTreeModel defaultTreeModel = (DefaultTreeModel) this.conditionsTree.getModel();
ExpandMutableTreeNode rootTreeNode = (ExpandMutableTreeNode) defaultTreeModel.getRoot();
rootTreeNode.setUserObject(new JoinCondition(DataConstants.AND, new ListCondition()));
rootTreeNode.removeAllChildren();
// peter:需要构建成ListCondition,加入到里面.
if (liteCondition instanceof ListCondition) {
ListCondition listCondition = (ListCondition) liteCondition;
int joinConditionCount = listCondition.getJoinConditionCount();
if (joinConditionCount == 0) {
commonRadioButton.setSelected(true);
applyCardsPane();
}
for (int i = 0; i < joinConditionCount; i++) {
addLiteConditionToListCondition(rootTreeNode, listCondition.getJoinCondition(i));
}
} else if (needDoWithCondition(liteCondition)) {
// peter:直接添加
ExpandMutableTreeNode newTreeNode = new ExpandMutableTreeNode(new JoinCondition(DataConstants.AND, liteCondition));
rootTreeNode.add(newTreeNode);
}
// peter:需要reload
defaultTreeModel.reload(rootTreeNode);
rootTreeNode.expandCurrentTreeNode(conditionsTree);
// marks:默认的选择第一行
if (conditionsTree.getRowCount() > 0) {
conditionsTree.setSelectionRow(0);
}
this.checkButtonEnabledForList();
if (liteCondition == null) {
try {
defaultConditionPane.checkValid();
} catch (Exception e) {//not need
}
}
}
protected boolean needDoWithCondition(Condition liteCondition) {
return true;
}
// peter:运用递归方式,构建初始的节点
private void addLiteConditionToListCondition(ExpandMutableTreeNode parentTreeNode, JoinCondition joinCondition) {
ExpandMutableTreeNode newTreeNode = new ExpandMutableTreeNode(joinCondition);
parentTreeNode.add(newTreeNode);
// peter:继续添加.
Condition liteCondition = joinCondition.getCondition();
if (liteCondition instanceof ListCondition) {
ListCondition listCondition = (ListCondition) liteCondition;
int joinConditionCount = listCondition.getJoinConditionCount();
for (int i = 0; i < joinConditionCount; i++) {
addLiteConditionToListCondition(newTreeNode, listCondition.getJoinCondition(i));
}
}
}
/**
* Update.
*
* @return the new lite condition.
*/
@Override
public Condition updateBean() {
// Samuel:先按modifybutton
modify();
// peter: 先删除所有的节点
DefaultTreeModel defaultTreeModel = (DefaultTreeModel) this.conditionsTree.getModel();
ExpandMutableTreeNode rootTreeNode = (ExpandMutableTreeNode) defaultTreeModel.getRoot();
int childCount = rootTreeNode.getChildCount();
// peter: 如果只有一个孩子节点, 返回空的 ListCondition
if (childCount == 0) {
return new ListCondition();
} // peter: 如果roottreeNode只有一个孩子节点.
else if (childCount == 1) {
JoinCondition joinCondition = (JoinCondition) ((ExpandMutableTreeNode) rootTreeNode.getChildAt(0)).getUserObject();
return joinCondition.getCondition();
} // peter: 有好多的孩子节点.
else {
// peter:深度遍历所有的孩子节点
Enumeration depthEnumeration = rootTreeNode.depthFirstEnumeration();
while (depthEnumeration.hasMoreElements()) {
this.adjustParentListCondition((ExpandMutableTreeNode) depthEnumeration.nextElement());
}
JoinCondition joinCondition = (JoinCondition) rootTreeNode.getUserObject();
Condition newCondition = joinCondition.getCondition();
//clone(),防止多个条件分组使用同一个condition对象
try{
newCondition = (Condition)joinCondition.getCondition().clone();
}catch (CloneNotSupportedException e){
FRLogger.getLogger().error(e.getMessage());
}
return newCondition;
}
}
}

103
designer_base/src/com/fr/design/condition/ObjectLiteConditionPane.java

@ -0,0 +1,103 @@
package com.fr.design.condition;
import java.awt.BorderLayout;
import java.awt.Component;
import javax.swing.DefaultComboBoxModel;
import com.fr.design.gui.ilable.UILabel;
import javax.swing.JList;
import javax.swing.JPanel;
import com.fr.data.condition.ObjectCondition;
import com.fr.data.core.Compare;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.formula.VariableResolver;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxRenderer;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.editor.ValueEditorPane;
import com.fr.design.editor.ValueEditorPaneFactory;
import com.fr.general.Inter;
public class ObjectLiteConditionPane extends LiteConditionPane<ObjectCondition> {
@Override
protected BasicBeanPane<ObjectCondition> createUnFormulaConditionPane() {
return new ObjectConditionPane();
}
@Override
protected VariableResolver variableResolver4FormulaPane() {
return VariableResolver.DEFAULT;
}
private class ObjectConditionPane extends BasicBeanPane<ObjectCondition> {
private UIComboBox conditionOPComboBox;
private ValueEditorPane conditionValuePane;
ObjectConditionPane() {
this.initComponents();
}
protected void initComponents() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
// condition operation
conditionOPComboBox = new UIComboBox();
DefaultComboBoxModel opComboBoxModel = (DefaultComboBoxModel) conditionOPComboBox.getModel();
int[] allOperators = Compare.getAllOperators();
for (int i = 0; i < allOperators.length; i++) {
opComboBoxModel.addElement(new Integer(allOperators[i]));
}
// conditionOPComboBox.setPreferredSize(new Dimension(120, 25));
this.conditionOPComboBox.setRenderer(new UIComboBoxRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof Integer) {
this.setText(Compare.operator2String(((Integer) value).intValue()));
}
return this;
}
});
conditionValuePane = ValueEditorPaneFactory.createAllValueEditorPane();
Component[][] components = { { new UILabel(Inter.getLocText("ConditionB-Operator") + ":"), new UILabel() },
{ conditionOPComboBox, conditionValuePane } };
double p = TableLayout.PREFERRED;
double rowSize[] = { p, p };
double columnSize[] = { p, TableLayout.FILL };
JPanel leftPanel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
this.add(leftPanel, BorderLayout.CENTER);
}
@Override
public ObjectCondition updateBean() {
Object value = conditionValuePane.update();
return new ObjectCondition(new Compare(((Integer) conditionOPComboBox.getSelectedItem()).intValue(), value));
}
@Override
public void populateBean(ObjectCondition condition) {
Compare compare = condition.getCompare();
conditionOPComboBox.setSelectedItem(new Integer(compare.getOp()));
this.conditionValuePane.populate(compare.getValue());
}
@Override
protected String title4PopupWindow() {
return " ";
}
}
}

54
designer_base/src/com/fr/design/condition/SingleConditionPane.java

@ -0,0 +1,54 @@
package com.fr.design.condition;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import com.fr.base.BaseUtils;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.dialog.BasicPane;
import com.fr.general.Inter;
public abstract class SingleConditionPane<T> extends BasicPane {
private static final long serialVersionUID = -4274960170813368817L;
protected UIButton cancel;
public SingleConditionPane(){
this(true);
}
public SingleConditionPane(boolean isRemove) {
this.setLayout(FRGUIPaneFactory.createLabelFlowLayout());
if (isRemove) {
if(cancel == null) {
cancel = new UIButton(BaseUtils.readIcon("/com/fr/base/images/cell/control/remove.png"));
cancel.setToolTipText(Inter.getLocText("FR-Action_Remove"));
cancel.addActionListener(cancleListener);
cancel.setMargin(new Insets(0, 0, 0, 0));
}
this.add(cancel);
}
}
ActionListener cancleListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
doCancel();
}
};
/**
* 取消
*/
public abstract void doCancel();
public abstract void setDefault();
public abstract void populate(T condition);
public abstract T update();
}

206
designer_base/src/com/fr/design/constants/KeyWords.java

@ -0,0 +1,206 @@
package com.fr.design.constants;
/**
* Created with IntelliJ IDEA.
* User: richie
* Date: 13-11-13
* Time: 下午6:50
*/
public class KeyWords {
private KeyWords() {
}
/* parameterEl object
返回对象参数界面
例如
contentPane.parameterEl
currentPageIndex
curLGP
reportTotalPage
zoom
*/
public static final String[] JAVASCRIPT = new String[]{
// normal js
"Array",
"attr",
"break",
"case",
"catch",
"children",
"close",
"concat",
"continue",
"default",
"delete",
"do",
"document",
"else",
"event",
"finally",
"fireEvent",
"for",
"function",
"getElementById",
"getText",
"html",
"if",
"in",
"instanceof",
"length",
"location",
"new",
"open",
"parent",
"parseFloat",
"parseInt",
"replace",
"return",
"search",
"setInterval",
"split",
"substr",
"switch",
"this",
"throw",
"tostring",
"try",
"typeof",
"var",
"void",
"while",
"window",
// contentPane
"cellselect",
"contentPane",
"curLGP",
"currentPageIndex",
"lgps",
"options",
"parameterEl",
"reportTotalPage",
"selectedIndex", //当前选中的sheet号
"zoom",
"appendReportRC()",
"appletPrint()",
"deleteReportRC()",
"deleteRows()",
"emailReport()",
"exportReportToExcel(mode)",
"exportReportToImage(pattern)",
"exportReportToPDF(ori)",
"exportReportToWord()",
"flashPrint()",
"getCellValue(reportIndex, columnIndex, rowIndex)",
"getWidgetByCell(cell)",
"getWidgetByName(name)",
"getWidgetsByName(name)",
"gotoFirstPage()",
"gotoLastPage()",
"gotoNextPage()",
"gotoPage(n)",
"gotoPreviousPage()",
"importExcelData()",
"makeHighlight(color, op)",
"on()",
"pageSetup()",
"parameterCommit()",
"pdfPrint()",
"printPreview()",
"scale()",
"setCellValue([reportIndex], columnIndex, rowIndex, cv)",
"stopEditing()",
"verifyAndWriteReport(true)", //空或false为提交所有sheet,true为提交当前sheet
"verifyReport()",
"writeReportIgnoreVerify(true)",
"writeReport(index)",
// curLGP
"currentTDCell",
"dirtyCell",
"write",
"form",
"cut2ColumnRowString(td)",
"displayTDCell(tdCell, cv, presentValue)",
"getColumnWidth(i)",
"getRowHeight(i)",
"getTDCell()",
"getTDCol(td)",
"getTDRow(td)",
"getWidgetCell(widget)",
"resetCellValue(widget)",
"stopCellEditing()",
// parameterEl
//getWidgetByName
"name_widgets",
// widget
//"fireEvent",
"getValue()",
"isEnabled()",
"isVisible()",
"reset()",
"setValue(value)",
"setEnable()",
"setVisible()",
// other
"${servletURL}?reportlet="
};
public static final String[][] JAVASCRIPT_SHORT = new String[][]{
/*
* FR.Msg
*/
new String[]{"alert", "FR.Msg.alert(title, message, callback)"},
new String[]{"confirm", "FR.Msg.confirm(title, message, callback)"},
new String[]{"prompt", "FR.Msg.prompt(title, message, value, callback)"},
new String[]{"toast", "FR.Msg.toast(message)"},
/*
* FR
*/
new String[]{"ajax","FR.ajax(o)"},
new String[]{"cellStr2ColumnRow","FR.cellStr2ColumnRow(name)"},
new String[]{"chart_Change_Parameter","FR.Chart.WebUtils.chart_Change_Parameter(pos, id, para)"},
new String[]{"chart_Refresh()","FR.Chart.WebUtils.chart_Refresh(str)"},
new String[]{"cjkDecode","FR.cjkDecode(str)"},
new String[]{"cjkEncode","FR.cjkEncode(str)"},
new String[]{"closeDialog","FR.closeDialog()"},
new String[]{"columnRow2CellStr","FR.columnRow2CellStr(cr)"},
new String[]{"destroyDialog","FR.destroyDialog()"},
new String[]{"digit2Letter","FR.digit2Letter(k)"},
new String[]{"doAppletPrint", "FR.doAppletPrint(sessionID)"},
new String[]{"doFlashPrint", "FR.doFlashPrint(sessionID, currentPageIndex)"},
new String[]{"doHyperlinkByGet","FR.doHyperlinkByGet(url, para, target, feature)"},
new String[]{"doHyperlinkByPost","FR.doHyperlinkByPost(url, para, target, feature)"},
new String[]{"doHyperlinkByGet4Reportlet","FR.doHyperlinkByGet4Reportlet(url,para,target,featrue)"},
new String[]{"doPDFPrint", "FR.doPDFPrint(sessionID, popupSetup)"},
new String[]{"doURLAppletPrint","FR.doURLAppletPrint(printurl,isPopUp,config)"},
new String[]{"doURLFlashPrint","FR.doURLFlashPrint(printurl,isPopUp,config)"},
new String[]{"doURLPDFPrint","FR.doURLPDFPrint(printurl,isPopUp,config)"},
new String[]{"htmlDecode","FR.htmlDecode(text)"},
new String[]{"htmlEncode","FR.htmlEncode(text)"},
new String[]{"id2ColumnRow","FR.id2ColumnRow(id)"},
new String[]{"id2ColumnRowStr","FR.id2ColumnRowStr(id)"},
new String[]{"id2Location","FR.id2Location(id)"},
new String[]{"isEmptyArray","FR.isEmptyArray(array)"},
new String[]{"letter2Digit","FR.letter2Digit(abc)"},
new String[]{"showDialog","FR.showDialog(title, width, height, innerContent)"},
new String[]{"showIframeDialog","FR.showIframeDialog(o)"},
new String[]{"showHyperlinkDialog","FR.showHyperlinkDialog(url,featur)"},
/*
* FS
*/
new String[]{"signOut","FS.Trans.signOut()"},
new String[]{"closeActiveTab","FS.tabPane.closeActiveTab()"},
new String[]{"addItem","FS.tabPane.addItem(o)"}
};
}

1
designer_base/src/com/fr/design/constants/LayoutConstants.java

@ -0,0 +1 @@
package com.fr.design.constants; /** * Created by IntelliJ IDEA. * Author : Richer * Version: 7.0.3 * Date: 12-12-27 * Time: 下午2:28 * 所有的间隙常数都从这里取,注意写上PMD检测规则来检查 */ public class LayoutConstants { private LayoutConstants() { } /** * 水平间隙 */ public static final int HGAP_SMALL = 1; /** * 水平间隙 */ public static final int HGAP_LARGE = 4; /** * 垂直间隙 */ public static final int VGAP_SMALL = 4; /** * 垂直间隙 */ public static final int VGAP_MEDIUM = 6; /** * 垂直间隙 */ public static final int VGAP_LARGE = 10; /** * 图表属性表中二级菜单距离右边框的距离 */ public static final int CHART_ATTR_TOMARGIN = 46; }

172
designer_base/src/com/fr/design/constants/UIConstants.java

@ -0,0 +1,172 @@
/*
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved.
*/
package com.fr.design.constants;
import com.fr.base.BaseUtils;
import com.fr.general.Inter;
import com.fr.stable.Constants;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
/**
* This class defines the constants used in the designer.
*/
public interface UIConstants {
public static final Icon BLACK_ICON = BaseUtils.readIcon("/com/fr/base/images/cell/blank.gif");
public static final int SIZE = 17;
/**
* Cell default cursor.
*/
public static final Cursor CELL_DEFAULT_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor(
BaseUtils.readImage("/com/fr/base/images/cell/cursor/cell_default.png"),
new Point(16, 16), "CellDefaultCursor");
public static final Cursor DRAW_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor(
BaseUtils.readImage("/com/fr/base/images/cell/cursor/cursor_draw.png"),
new Point(16, 16), "DrawCursor");
public static final Cursor FORMAT_BRUSH_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor(
BaseUtils.readImage("/com/fr/base/images/cell/cursor/brush_cursor0.png"),
new Point(16, 16), "formatBrushCursor");
/**
* Border style array.
*/
public final static int[] BORDER_LINE_STYLE_ARRAY = new int[]{
Constants.LINE_THIN, //Thin border.
Constants.LINE_MEDIUM, //Medium border
Constants.LINE_DASH, //dash border
Constants.LINE_HAIR, //hair-line border
Constants.LINE_HAIR2, //hair-line border
Constants.LINE_THICK, //Thick border
Constants.LINE_DOUBLE, //double-line border
Constants.LINE_DOT, //dot border
Constants.LINE_MEDIUM_DASH, //Medium dashed border
Constants.LINE_DASH_DOT, //dash-dot border
Constants.LINE_MEDIUM_DASH_DOT, //medium dash-dot border
Constants.LINE_DASH_DOT_DOT, //dash-dot-dot border
Constants.LINE_MEDIUM_DASH_DOT_DOT, //medium dash-dot-dot border
Constants.LINE_SLANTED_DASH_DOT, //slanted dash-dot border
};
public static final Color LINE_COLOR = new Color(153, 153, 153);
public static final Color FONT_COLOR = new Color(51, 51, 51);
public static final Color LIGHT_BLUE = new Color(182, 217, 253);
public static final Color SKY_BLUE = new Color(164, 192, 220);
public static final Color OCEAN_BLUE = new Color(141, 179, 217);
public static final Color DARK_BLUE = new Color(0, 88, 144);
public static final Color NORMAL_BACKGROUND = new Color(240, 240, 240);
public static final Color SHADOW_GREY = new Color(0xe2e2e2);
public static final Color SHADOW_CENTER = new Color(200, 200, 200);
public static final Color SHADOW_PURPLE = new Color(255, 0, 255);
public static final Color FLESH_BLUE = new Color(168, 180, 202);
public static final Color HOVER_BLUE = new Color(0xd2d2d2);
public static final Color DOTTED_LINE_COLOR = new Color(35, 108, 184);
public static final Color AUTHORITY_COLOR = new Color(88, 125, 153);
public static final Color AUTHORITY_BLUE = new Color(0xe2e2e2);
public static final Color AUTHORITY_DARK_BLUE = new Color(136, 164, 186);
public static final Color AUTHORITY_PRESS_BLUE = new Color(131, 159, 181);
public static final Color AUTHORITY_LINE_COLOR = new Color(0, 124, 229);
public static final Color AUTHORITY_SHEET_DARK = new Color(86, 120, 143);
public static final Color AUTHORITY_SHEET_LIGHT = new Color(156, 204, 238);
public static final Color AUTHORITY_SHEET_UNSELECTED = new Color(146, 192, 225);
public static final Color ATTRIBUTE_PRESS = new Color(0xdfecfc);
public static final Color ATTRIBUTE_NORMAL = new Color(0xe2e2e2);
public static final Color ATTRIBUTE_HOVER = new Color(0xd3d3d3);
public static final Color CHECKBOX_HOVER_SELECTED = new Color(0x3394f0);
public static final Color TEXT_FILED_BORDER_SELECTED = new Color(0x3384f0);
public static final Color SHEET_NORMAL = new Color(0xc8c8ca);
public static final Color SELECTED_BACKGROUND = new Color(0xdeedfe);
public static final Color SELECTED_BORDER_LINE_COLOR = new Color(0x3384f0);
public static final Color DEFAULT_BG_RULER = new Color(0xf7f7f7);
public static final Color RULER_LINE_COLOR = new Color(0xababab);
public static final Color RULER_SCALE_COLOR = new Color(0x4e504f);
public static final BufferedImage DRAG_BAR = BaseUtils.readImage("com/fr/design/images/control/bar.png");
public static final BufferedImage DRAG_BAR_RIGHT = BaseUtils.readImage("com/fr/design/images/control/barm.png");
public static final BufferedImage DRAG_BAR_LEFT = BaseUtils.readImage("com/fr/design/images/control/barl.png");
public static final BufferedImage DRAG_UP_NORMAL = BaseUtils.readImage("com/fr/design/images/control/upnor.png");
public static final BufferedImage DRAG_UP_PRESS = BaseUtils.readImage("com/fr/design/images/control/uppre.png");
public static final BufferedImage DRAG_DOWN_NORMAL = BaseUtils.readImage("com/fr/design/images/control/downnor.png");
public static final BufferedImage DRAG_DOWN_PRESS = BaseUtils.readImage("com/fr/design/images/control/downpre.png");
public static final BufferedImage DRAG_RIGHT_NORMAL = BaseUtils.readImage("com/fr/design/images/control/rightnor.png");
public static final BufferedImage DRAG_RIGHT_PRESS = BaseUtils.readImage("com/fr/design/images/control/rightpre.png");
public static final BufferedImage DRAG_LEFT_NORMAL = BaseUtils.readImage("com/fr/design/images/control/leftnor.png");
public static final BufferedImage DRAG_LEFT_PRESS = BaseUtils.readImage("com/fr/design/images/control/leftpre.png");
public static final BufferedImage DRAG_DOT = BaseUtils.readImage("com/fr/design/images/control/dot.png");
public static final BufferedImage DRAG_DOT_VERTICAL = BaseUtils.readImage("com/fr/design/images/control/dotv.png");
public static final int MODEL_NORMAL = 0;
public static final int MODEL_PRESS = 1;
public static final Icon ARROW_DOWN_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/arrowdown.png");
public static final Icon ARROW_UP_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/arrowup.png");
public static final Icon YES_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/yes.png");
public static final Icon CHOOSEN_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/select_item.png");
public static final Icon PRE_WIDGET_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/prewidget.png");
public static final Icon EDIT_NORMAL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/editn.png");
public static final Icon EDIT_PRESSED_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/editp.png");
public static final Icon HIDE_NORMAL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/hiden.png");
public static final Icon HIDE_PRESSED_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/hidep.png");
public static final Icon VIEW_NORMAL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/viewn.png");
public static final Icon VIEW_PRESSED_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/viewp.png");
public static final Icon RUN_BIG_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/run24.png");
public static final Icon RUN_SMALL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/runs.png");
public static final Icon PAGE_BIG_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/pageb24.png");
public static final Icon WRITE_BIG_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/writeb24.png");
public static final Icon ANA_BIG_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/anab24.png");
public static final Icon PAGE_SMALL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/pages.png");
public static final Icon WRITE_SMALL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/writes.png");
public static final Icon ANA_SMALL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/anas.png");
public static final Icon REFRESH_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/refresh.png");
public static final Icon FONT_ICON = BaseUtils.readIcon("/com/fr/design/images/gui/color/foreground.png");
public static final Icon HISTORY_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/history.png");
public static final Icon DELETE_ICON = BaseUtils.readIcon("com/fr/design/images/m_file/close.png");
public static final Icon EDIT_ICON = BaseUtils.readIcon("com/fr/design/images/m_file/edit.png");
public static final Icon SEARCH_ICON = BaseUtils.readIcon("/com/fr/design/images/data/search.png");
public static final Icon CLEAR_ICON = BaseUtils.readIcon("/com/fr/design/images/data/source/delete.png");
public static final Color PRESSED_DARK_GRAY = new Color(127, 127, 127);
public static final Color GRDIENT_DARK_GRAY = new Color(45, 45, 45);
public static final Color BARNOMAL = new Color(153, 153, 153);
public static final int ARC = 0;
public static final int LARGEARC = 0;
public static final Stroke BS = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 2f, new float[]{3, 1}, 0);
public static final Icon PREVIEW_DOWN = BaseUtils.readIcon("com/fr/design/images/buttonicon/prevew_down_icon.png");
public static final Icon CLOSE_OF_AUTHORITY = BaseUtils.readIcon("/com/fr/design/images/m_report/close.png");
public static final Icon CLOSE_OVER_AUTHORITY = BaseUtils.readIcon("/com/fr/design/images/m_report/close_over.png");
public static final Icon CLOSE_PRESS_AUTHORITY = BaseUtils.readIcon("/com/fr/design/images/m_report/close_press.png");
public static final int CLOSE_AUTHORITY_HEIGHT_AND_WIDTH = 24;
/**
* 正在加载的界面
*/
public static final Object PENDING = new Object() {
@Override
public String toString() {
return Inter.getLocText("Loading") + "...";
}
};
/**
* 数据库连接失败的界面
*/
public static final Object CONNECTION_FAILED = new Object() {
public String toString() {
return Inter.getLocText(new String[]{"Database", "Datasource-Connection_failed"}) + "!";
}
};
/**
* 自动补全的默认快捷键一般来说是 alt + /.
*/
public static final String DEFAULT_AUTO_COMPLETE = "alt + SLASH";
}

12
designer_base/src/com/fr/design/data/DataCreatorUI.java

@ -0,0 +1,12 @@
package com.fr.design.data;
import javax.swing.*;
/**
* Created by richie on 15/11/16.
*/
public interface DataCreatorUI {
JComponent toSwingComponent();
}

468
designer_base/src/com/fr/design/data/DesignTableDataManager.java

@ -0,0 +1,468 @@
package com.fr.design.data;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.base.StoreProcedureParameter;
import com.fr.base.TableData;
import com.fr.data.TableDataSource;
import com.fr.data.core.DataCoreXmlUtils;
import com.fr.design.data.datapane.preview.PreviewTablePane;
import com.fr.data.impl.EmbeddedTableData;
import com.fr.data.impl.storeproc.ProcedureDataModel;
import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.data.impl.storeproc.StoreProcedureConstants;
import com.fr.design.data.tabledata.wrapper.*;
import com.fr.design.DesignModelAdapter;
import com.fr.design.gui.iprogressbar.AutoProgressBar;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.parameter.ParameterInputPane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.file.DatasourceManager;
import com.fr.file.DatasourceManagerProvider;
import com.fr.general.ComparatorUtils;
import com.fr.general.data.DataModel;
import com.fr.general.data.TableDataException;
import com.fr.script.Calculator;
import com.fr.stable.ArrayUtils;
import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.io.ByteArrayOutputStream;
import java.text.Collator;
import java.util.*;
import java.util.Map.Entry;
/**
* 设计器管理操作数据集的类:
* 1.对于每个TableData,会生成相应的TableDataWrapper.TableDataWrapper里面有TableData的数据列缓存
* 2.TableDataWrapper是不支持对TableData的修改查询语句 重命名等修改删除操作
* 如果TableData变化了那么TableDataWrapper 也会重新生成,然后存进缓存.这样保证缓存是正确的,不会取到错误的数据列
* 3.对于模板数据集关键词应该保证各个模板数据集之间不同所以默认有个加上模板名的操作
* 4.个人觉得完全没有必要做成那种一个SQL语句对应一个数据列的情况那样子太复杂了而且每次比较关键词都很慢
* <p/>
* !!!Notice: 除了预览数据集的操作其他所有涉及到数据集的界面操作都要经过这个类(因为它有数据集的缓存,不需要重复计算
*
* @author zhou
*/
public abstract class DesignTableDataManager {
/**
* 其实globalDsCache没有绝对的必要只是为了操作方便如果没有它那么每次清空服务器数据集或者存储过程的时候还要去遍历找一下
* 这个操作可能比较复杂 从减少代码复杂度的角度看还是很有必要的
*/
private static java.util.Map<String, TableDataWrapper> globalDsCache = new java.util.HashMap<String, TableDataWrapper>();
private static java.util.Map<String, String> dsNameChangedMap = new HashMap<String, String>();
private static List<ChangeListener> dsListeners = new ArrayList<ChangeListener>();
public static String NO_PARAMETER = "no_paramater_pane";
//用于记录是否要弹出参数框
private static ThreadLocal<String> threadLocal = new ThreadLocal<String>();
/**
* 清除全局 数据集缓存.
*/
public static void clearGlobalDs() {
globalDsCache.clear();
}
/**
* 响应数据集改变.
*/
private static void fireDsChanged() {
for (int i = 0; i < dsListeners.size(); i++) {
//增强for循环用的iterator实现的, 如果中间哪个listener修改或删除了(如ChartEditPane.dsChangeListener),
// 由于dsListeners是arraylist, 此时会ConcurrentModifyException
// for (ChangeListener l : dsListeners) {
ChangeEvent e = null;
dsListeners.get(i).stateChanged(e);
}
}
/**
* 响应数据集改变
*
* @param dsNameChangedMap 改变名字的数据集
*/
public static void fireDSChanged(Map<String, String> dsNameChangedMap) {
if (!dsNameChangedMap.isEmpty()) {
setDsNameChangedMap(dsNameChangedMap);
}
fireDsChanged();
dsNameChangedMap.clear();
}
private static void setDsNameChangedMap(Map<String, String> map) {
Iterator iterator = map.keySet().iterator();
while (iterator.hasNext()) {
String key = (String) iterator.next();
dsNameChangedMap.put(key, map.get(key));
}
}
/**
* 数据库是否改变
*
* @param oldDsName 旧名字
* @return 是则返回true
*/
public static boolean isDsNameChanged(String oldDsName) {
return dsNameChangedMap.containsKey(oldDsName);
}
public static String getChangedDsNameByOldDsName(String oldDsName) {
if (isDsNameChanged(oldDsName)) {
return dsNameChangedMap.get(oldDsName);
} else {
return StringUtils.EMPTY;
}
}
/**
* 添加模板数据集改变 监听事件.
*
* @param l ChangeListener监听器
*/
public static void addDsChangeListener(ChangeListener l) {
dsListeners.add(l);
}
/**
* 获取数据源source中dsName的所有字段
*
* @param source 数据源
* @param dsName 数据集名字
* @return
*/
public static String[] getSelectedColumnNames(TableDataSource source, String dsName) {
java.util.Map<String, TableDataWrapper> resMap = getAllEditingDataSet(source);
java.util.Map<String, TableDataWrapper> dsMap = getAllDataSetIncludingProcedure(resMap);
TableDataWrapper tabledataWrapper = dsMap.get(dsName);
return tabledataWrapper == null ? new String[0] : tabledataWrapper.calculateColumnNameList().toArray(new String[0]);
}
/**
* august:返回当前正在编辑的具有报表数据源的模板(基本报表聚合报表) 包括 : 图表模板
*
* @return TableDataSource
* attention:与这个方法有关系的静态组件不随着切换模板tab而变化的应该重新执行该方法再刷新组件
*/
public static TableDataSource getEditingTableDataSource() {
return DesignModelAdapter.getCurrentModelAdapter() == null ? null : DesignModelAdapter.getCurrentModelAdapter().getBook();
}
/**
* 返回当前模板(source)数据集服务器数据集和存储过程中所有的数据集名字
*
* @param source
* @return
*/
public static String[] getAllDSNames(TableDataSource source) {
Iterator<Entry<String, TableDataWrapper>> entryIt = getAllEditingDataSet(source).entrySet().iterator();
List<String> list = new ArrayList<String>();
while (entryIt.hasNext()) {
Entry<String, TableDataWrapper> entry = entryIt.next();
list.add(entry.getKey());
}
return list.toArray(new String[list.size()]);
}
/**
* 不根据过滤设置返回当前模板数据集服务器数据集存储过程本身是有顺序的
*/
public static java.util.Map<String, TableDataWrapper> getAllEditingDataSet(TableDataSource source) {
java.util.Map<String, TableDataWrapper> resMap = new java.util.LinkedHashMap<String, TableDataWrapper>();
// 模板数据集
addTemplateData(resMap, source);
// 服务器数据集
addServerData(resMap);
// 存储过程
addStoreProcedureData(resMap);
return resMap;
}
public static java.util.Map<String, TableDataWrapper> getAllDataSetIncludingProcedure(java.util.Map<String, TableDataWrapper> resMap) {
java.util.LinkedHashMap<String, TableDataWrapper> dsMap = new java.util.LinkedHashMap<String, TableDataWrapper>();
Iterator<Entry<String, TableDataWrapper>> entryIt = resMap.entrySet().iterator();
while (entryIt.hasNext()) {
String key = entryIt.next().getKey();
TableDataWrapper tableDataWrapper = resMap.get(key);
if (tableDataWrapper.getTableData() instanceof StoreProcedure) {
StoreProcedure storeProcedure = (StoreProcedure) tableDataWrapper.getTableData();
boolean hasSchemaOrResult = false;
StoreProcedureParameter[] parameters = StoreProcedure.getSortPara(storeProcedure.getParameters());
String name = tableDataWrapper.getTableDataName();
ArrayList<String> resultNames = storeProcedure.getResultNames();
TableDataWrapper tdw = new StoreProcedureNameWrapper(name + "_Table", storeProcedure);
for (StoreProcedureParameter parameter : parameters) {
if (parameter.getSchema() != StoreProcedureConstants.IN) {
String parameterName = name + "_" + parameter.getName();
TableDataWrapper newTwd = new StoreProcedureDataWrapper(storeProcedure, name, parameterName, false);
dsMap.put(parameterName, newTwd);
hasSchemaOrResult = true;
}
}
if (!resultNames.isEmpty()) {
hasSchemaOrResult = true;
for (int i = 0; i < resultNames.size(); i++) {
String parameterName = name + "_" + resultNames.get(i);
TableDataWrapper newTwd = new StoreProcedureDataWrapper(storeProcedure, name, parameterName, false);
dsMap.put(parameterName, newTwd);
}
}
if (!hasSchemaOrResult) {
dsMap.put(name + "_Table", tdw);
}
} else {
dsMap.put(key, tableDataWrapper);
}
}
return dsMap;
}
/**
* 不根据过滤设置返回当前服务器数据集存储过程所有的数据集是有顺序的
*/
public static java.util.Map<String, TableDataWrapper> getGlobalDataSet() {
java.util.Map<String, TableDataWrapper> resMap = new java.util.LinkedHashMap<String, TableDataWrapper>();
// 服务器数据集
addServerData(resMap);
// 存储过程
addStoreProcedureData(resMap);
return resMap;
}
/**
* 根据过滤设置返回当前模板数据集服务器数据集存储过程所有的数据集是有顺序的
*/
public static List<Map<String, TableDataWrapper>> getEditingDataSet(TableDataSource source) {
Map<String, TableDataWrapper> templateDataMap = new LinkedHashMap<String, TableDataWrapper>();
Map<String, TableDataWrapper> serverDataMap = new LinkedHashMap<String, TableDataWrapper>();
Map<String, TableDataWrapper> storeProcedureMap = new LinkedHashMap<String, TableDataWrapper>();
addTemplateData(templateDataMap, source);
addServerData(serverDataMap);
addStoreProcedureData(storeProcedureMap);
List<Map<String, TableDataWrapper>> list = new ArrayList<Map<String, TableDataWrapper>>();
list.add(templateDataMap);
list.add(serverDataMap);
list.add(storeProcedureMap);
return list;
}
private static void addTemplateData(java.util.Map<String, TableDataWrapper> resMap, TableDataSource source) {
if (source != null) {
String[] namearray = TableDataFactory.getSortOfChineseNameOfTemplateData(source);
for (String tabledataname : namearray) {
TableData td = source.getTableData(tabledataname);
TableDataWrapper tdw = new TemplateTableDataWrapper(td, tabledataname);
resMap.put(tabledataname, tdw);
}
}
}
private static void addServerData(java.util.Map<String, TableDataWrapper> resMap) {
DatasourceManagerProvider mgr = DatasourceManager.getProviderInstance();
String[] namearray = TableDataFactory.getSortOfChineseNameOfServerData(mgr);
for (String name : namearray) {
if (globalDsCache.containsKey(name)) {
resMap.put(name, globalDsCache.get(name));
} else {
TableDataWrapper tdw = new ServerTableDataWrapper(mgr.getTableData(name), name);
resMap.put(name, tdw);
globalDsCache.put(name, tdw);
}
}
}
private static void addStoreProcedureData(java.util.Map<String, TableDataWrapper> resMap) {
DatasourceManagerProvider mgr = DatasourceManager.getProviderInstance();
String[] namearray = new String[0];
@SuppressWarnings("unchecked")
java.util.Iterator<String> nameIt = mgr.getProcedureNameIterator();
while (nameIt.hasNext()) {
namearray = (String[]) ArrayUtils.add(namearray, nameIt.next());
}
Arrays.sort(namearray, Collator.getInstance(java.util.Locale.CHINA));
for (String name : namearray) {
StoreProcedure storeProcedure = mgr.getProcedure(name);
if (globalDsCache.containsKey(name)) {
resMap.put(name, globalDsCache.get(name));
} else {
TableDataWrapper tdw = new StoreProcedureNameWrapper(name, storeProcedure);
resMap.put(name, tdw);
globalDsCache.put(name, tdw);
}
}
}
/**
* 预览需要参数的数据集
*
* @param tabledata 数据集
* @param rowCount 需要预览的行数
* @param needLoadingBar 是否需要加载进度条
* @return 数据集
* @throws Exception 异常
*/
public static EmbeddedTableData previewTableDataNeedInputParameters(TableData tabledata, int rowCount, boolean needLoadingBar) throws Exception {
return previewTableData(tabledata, rowCount, true, needLoadingBar);
}
/**
* 预览不需要参数的数据集
*
* @param tabledata 数据集
* @param rowCount 需要预览的行数
* @param needLoadingBar 是否需要加载进度条
* @return 数据集
* @throws Exception 异常
*/
public static EmbeddedTableData previewTableDataNotNeedInputParameters(TableData tabledata, int rowCount, boolean needLoadingBar) throws Exception {
return previewTableData(tabledata, rowCount, false, needLoadingBar);
}
/**
* 获取预览后的EmbeddedTableData考虑到Env
*
* @param tabledata
* @param rowCount
* @param isMustInputParameters 是否必须输入参数值不管参数有没有默认值一般预览时这个值为true因为一般预览是要看不同的参数的结果的
* 而获取数据集的字段名字时则没必要
* @return
*/
private static EmbeddedTableData previewTableData(TableData tabledata, int rowCount, boolean isMustInputParameters, boolean needLoadingBar) throws Exception {
final AutoProgressBar loadingBar = PreviewTablePane.getInstance().getProgressBar();
Env currentEnv = FRContext.getCurrentEnv();
EmbeddedTableData embeddedTableData = null;
ParameterProvider[] parameters = currentEnv.getTableDataParameters(tabledata);
boolean isNullParameter = parameters == null || parameters.length == 0;
ParameterProvider[] tableDataParameter = tabledata.getParameters(Calculator.createCalculator());
boolean isOriginalNUllParameter = tableDataParameter == null || tableDataParameter.length == 0;
if (isNullParameter && !isOriginalNUllParameter) {
parameters = tableDataParameter;
}
boolean hasValue = true;
for (ParameterProvider parameter : parameters) {
if (parameter.getValue() == null || ComparatorUtils.equals(StringUtils.EMPTY, parameter.getValue())) {
hasValue = false;
break;
}
}
final Map<String, Object> parameterMap = new HashMap<String, Object>();
if (!hasValue || isMustInputParameters) {
if (parameters != null && parameters.length > 0) {
final ParameterInputPane pPane = new ParameterInputPane(parameters);
pPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
public void doOk() {
parameterMap.putAll(pPane.update());
}
}).setVisible(true);
}
} else {
for (int i = 0; i < parameters.length; i++) {
parameterMap.put(parameters[i].getName(), parameters[i].getValue());
}
}
if (loadingBar != null && needLoadingBar) {
loadingBar.start();
}
try {
embeddedTableData = currentEnv.previewTableData(tabledata, parameterMap, rowCount);
} catch (TableDataException e) {
throw new TableDataException(e.getMessage(), e);
} finally {
new Timer().schedule(new TimerTask() {
public void run() {
loadingBar.close();
}
}, 100);
}
return embeddedTableData;
}
/**
* 返回<code>TableData</code>的数据列,注意<code>TableData</code>
* 是没有考虑参数的用于简单的查询语句生成的<code>TableData</code>, 或者
* <code>EmbeddedTableData</code>. 比如说数据字典-数据库表生成的<code>TableData</code>
* 使用该方法是没有数据集缓存的功能的
*
* @return List<String>
*/
public static List<String> getColumnNamesByTableData(TableData tableData) {
List<String> columnNames = new ArrayList<String>();
if (tableData != null) {
DataModel rs = tableData.createDataModel(Calculator.createCalculator());
int value;
try {
value = rs.getColumnCount();
for (int i = 0; i < value; i++) {
columnNames.add(rs.getColumnName(i));
}
rs.release();
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage());
}
}
return columnNames;
}
/**
* 该方法主要利用了StoreProcedure里面的dataModelList有缓存作用的机制
* 所以用该方法不会对一个已经计算了的存储过程重复计算.和分页预览时处理机制一样这样对有多个返回数据集的存储过程来说很有必要
*
* @param needLoadingBar 是否需要进度条
* @param storeProcedure 存储过程
* @return 数据
*/
public static ProcedureDataModel[] createLazyDataModel(StoreProcedure storeProcedure, boolean needLoadingBar) throws Exception {
ByteArrayOutputStream out = new ByteArrayOutputStream();
XMLPrintWriter writer = XMLPrintWriter.create(out);
// 把storeProcedure写成xml文件到out
DataCoreXmlUtils.writeXMLStoreProcedure(writer, storeProcedure, null);
Env currentEnv = FRContext.getCurrentEnv();
if (storeProcedure.getDataModelSize() > 0 && !storeProcedure.isFirstExpand()) {
return storeProcedure.creatLazyDataModel();
}
ParameterProvider[] inParameters = currentEnv.getStoreProcedureParameters(storeProcedure);
final Map<String, Object> parameterMap = new HashMap<String, Object>();
if (inParameters.length > 0 && !ComparatorUtils.equals(threadLocal.get(), NO_PARAMETER)) {// 检查Parameter.
final ParameterInputPane pPane = new ParameterInputPane(inParameters);
pPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
public void doOk() {
parameterMap.putAll(pPane.update());
}
}).setVisible(true);
}
storeProcedure.setFirstExpand(false);
if (needLoadingBar) {
StoreProcedureDataWrapper.loadingBar.start();
}
return FRContext.getCurrentEnv().previewProcedureDataModel(storeProcedure, parameterMap, 0);
}
public static void setThreadLocal(String value) {
threadLocal.set(value);
}
}

602
designer_base/src/com/fr/design/data/datapane/ChoosePane.java

@ -0,0 +1,602 @@
package com.fr.design.data.datapane;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.base.TableData;
import com.fr.data.core.DataCoreUtils;
import com.fr.data.core.db.DBUtils;
import com.fr.data.core.db.TableProcedure;
import com.fr.data.core.db.dialect.DialectFactory;
import com.fr.data.impl.DBTableData;
import com.fr.dav.LocalEnv;
import com.fr.design.DesignerEnvManager;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.RefreshLabel.Refreshable;
import com.fr.design.data.datapane.preview.PreviewLabel;
import com.fr.design.data.datapane.preview.PreviewLabel.Previewable;
import com.fr.design.data.datapane.preview.PreviewTablePane;
import com.fr.design.data.tabledata.Prepare4DataSourceChange;
import com.fr.design.gui.icombobox.*;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.file.DatasourceManager;
import com.fr.file.DatasourceManagerProvider;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import com.fr.stable.StringUtils;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import javax.swing.tree.*;
import java.awt.*;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
/**
* @author zhou
* @since 2012-7-11下午4:49:39
*/
public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refreshable, Previewable, Prepare4DataSourceChange {
private static final double COLUMN_SIZE = 24;
/**
* 数据库
*/
protected StringUIComboBox dsNameComboBox;
/**
* 模式
*/
protected StringUIComboBox schemaBox;
/**
* 表名
*/
protected FRTreeComboBox tableNameComboBox;
private SwingWorker populateWorker;
private PopupMenuListener popupMenuListener = new PopupMenuListener() {
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
new Thread() {
@Override
public void run() {
calculateTableDataNames();
}
}.start();
}
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
}
public void popupMenuCanceled(PopupMenuEvent e) {
}
};
private PopupMenuListener listener = new PopupMenuListener() {
public void popupMenuCanceled(PopupMenuEvent e) {
}
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
}
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
executePopulateWorker();
}
};
public ChoosePane() {
this(null);
}
public ChoosePane(Previewable parent) {
this(parent, -1);
}
public ChoosePane(Previewable parent, int labelSize) {
this.initBasicComponet();
this.initComponentsLayout(new PreviewLabel(parent == null ? this : parent), labelSize);
}
private void initBasicComponet() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
dsNameComboBox = new StringUIComboBox();
initDsNameComboBox();
schemaBox = new StringUIComboBox();
schemaBox.setEditor(new ComboBoxEditor());
tableNameComboBox = new FRTreeComboBox(new JTree(new DefaultMutableTreeNode()), tableNameTreeRenderer, false);
tableNameComboBox.setEditable(true);
tableNameComboBox.setRenderer(listCellRenderer);
registerDSChangeListener();
initBoxListener();
}
private void initBoxListener() {
addDSBoxListener();
schemaBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent evt) {
tableNameComboBox.setSelectedItem("");
}
});
schemaBox.addPopupMenuListener(listener);
addFocusListener();
this.tableNameComboBox.addPopupMenuListener(popupMenuListener);
}
protected void addDSBoxListener() {
dsNameComboBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
schemaBox.setSelectedIndex(-1);
tableNameComboBox.setSelectedItem("");
JTree tree = tableNameComboBox.getTree();
if (tree == null) {
return;
}
DefaultMutableTreeNode rootTreeNode = (DefaultMutableTreeNode) tree.getModel().getRoot();
rootTreeNode.removeAllChildren();
rootTreeNode.add(new ExpandMutableTreeNode("Loading..."));
((DefaultTreeModel) tree.getModel()).reload();
}
});
}
protected void addFocusListener() {
schemaBox.addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent e) {
if (schemaBox.getSelectedIndex() == -1) {
schemaBox.updateUI();
schemaBox.showPopup();
}
}
});
}
protected void initDsNameComboBox() {
dsNameComboBox.setRefreshingModel(true);
DatasourceManagerProvider datasourceManager = DatasourceManager.getProviderInstance();
@SuppressWarnings("unchecked")
Iterator<String> datasourceNameIterator = datasourceManager.getConnectionNameIterator();
List<String> dsList = new ArrayList<String>();
while (datasourceNameIterator.hasNext()) {
dsList.add((String) datasourceNameIterator.next());
}
FilterableComboBoxModel dsNameComboBoxModel = new FilterableComboBoxModel(dsList);
dsNameComboBox.setModel(dsNameComboBoxModel);
dsNameComboBox.setRefreshingModel(false);
}
protected void initComponentsLayout(PreviewLabel previewLabel, int labelSize) {
UILabel l1 = new UILabel(Inter.getLocText("FR-Designer_Database") + ":");
UILabel l2 = new UILabel(Inter.getLocText("FR-Designer_Model") + ":");
UILabel l3 = new UILabel(Inter.getLocText("FR-Designer_Table") + ":");
if (labelSize > 0) {
Dimension pSize = new Dimension(labelSize, 25);
l1.setPreferredSize(pSize);
l2.setPreferredSize(pSize);
l3.setPreferredSize(pSize);
}
Component[][] coms = new Component[][]{{l1, dsNameComboBox, l2, schemaBox,
l3, this.tableNameComboBox, new RefreshLabel(this), previewLabel}};
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
JPanel northDSPane = TableLayoutHelper.createTableLayoutPane(coms, new double[]{p}, new double[]{p, f, p, f, p, f, COLUMN_SIZE, COLUMN_SIZE});
this.add(northDSPane, BorderLayout.CENTER);
}
@Override
public void populateBean(final DataBaseItems ob) {
this.dsNameComboBox.setSelectedItem(ob.getDatabaseName());
schemaBox.setSelectedItem(ob.getSchemaName());
this.tableNameComboBox.setSelectedItem(ob.getTableName());
}
private void executePopulateWorker() {
if (populateWorker != null) {
populateWorker.cancel(true);
}
populateWorker = new SwingWorker<com.fr.data.impl.Connection, Void>() {
protected com.fr.data.impl.Connection doInBackground() throws Exception {
schemaBox.addItem(Inter.getLocText("FR-Designer_Loading") + "...");
schemaBox.setSelectedItem(null);
return getConnection();
}
public void done() {
try {
com.fr.data.impl.Connection selectedDatabase = get();
String selectedItem = schemaBox.getSelectedItem();
schemaBox.setRefreshingModel(true);
schemaBox.removeAllItems();
schemaBox.updateUI();
if (selectedDatabase == null) {
return;
}
String[] schema = DataCoreUtils.getDatabaseSchema(selectedDatabase);
schema = schema == null ? new String[]{""} : schema;
for (String aa : schema) {
schemaBox.addItem(aa);
}
int index = schemaBox.getSelectedIndex();
if (selectedItem != null) {
schemaBox.setSelectedItem(selectedItem);
} else if (index < schema.length) {
schemaBox.setSelectedIndex(index);
}
} catch (Exception e) {
FRLogger.getLogger().error(e.getMessage());
}
schemaBox.setRefreshingModel(false);
schemaBox.removePopupMenuListener(listener);
schemaBox.setPopupVisible(true);
schemaBox.addPopupMenuListener(listener);
}
};
populateWorker.execute();
}
@Override
public DataBaseItems updateBean() {
return new DataBaseItems(this.getDSName(), this.schemaBox.getSelectedItem(), getTableName());
}
/**
* 重置选中的box
*/
public void resetComponets() {
GUICoreUtils.setSelectedItemQuietly(dsNameComboBox, -1);
GUICoreUtils.setSelectedItemQuietly(schemaBox, -1);
GUICoreUtils.setSelectedItemQuietly(tableNameComboBox, -1);
}
protected com.fr.data.impl.Connection getConnection() {
String selectedDSName = this.getDSName();
if (StringUtils.isEmpty(selectedDSName)) {
return null; // peter:选中了当前的零长度的节点,直接返回.
}
DatasourceManagerProvider datasourceManager = DatasourceManager.getProviderInstance();
@SuppressWarnings("unchecked")
Iterator<String> datasourceNameIterator = datasourceManager.getConnectionNameIterator();
while (datasourceNameIterator.hasNext()) {
String datasourceName = datasourceNameIterator.next();
if (ComparatorUtils.equals(selectedDSName, datasourceName)) {
return datasourceManager.getConnection(datasourceName);
}
}
return null;
}
/**
* 刷新没多大用而且要刷新也不是这儿刷新
*/
public void refresh() {
DBUtils.refreshDatabase();
String schema = StringUtils.isEmpty(schemaBox.getSelectedItem()) ? null : schemaBox.getSelectedItem();
DataCoreUtils.refreshTables(getConnection(), TableProcedure.TABLE, schema);
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Designer_Refresh_Successfully") + "!", Inter.getLocText("FR-Designer_Refresh_Database"),
JOptionPane.INFORMATION_MESSAGE);
}
TreeCellRenderer tableNameTreeRenderer = new DefaultTreeCellRenderer() {
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
if (value instanceof DefaultMutableTreeNode) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
Object userObj = node.getUserObject();
if (userObj instanceof String) {
this.setIcon(BaseUtils.readIcon("com/fr/design/images/m_insert/expandCell.gif"));
} else if (userObj instanceof TableProcedure) {
this.setText(((TableProcedure) userObj).getName());
}
}
return this;
}
};
public static UIComboBoxRenderer listCellRenderer = new UIComboBoxRenderer() {
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof TreePath) {
DefaultMutableTreeNode dmt = (DefaultMutableTreeNode) ((TreePath) value).getLastPathComponent();
if (dmt.getUserObject() instanceof TableProcedure) {
this.setText(((TableProcedure) dmt.getUserObject()).getName());
} else {
this.setText(null);
}
}
return this;
}
};
/**
* 添加项目监听事件
* @param aListener 事件监听器
*/
public void addItemListener(ItemListener aListener) {
this.tableNameComboBox.addItemListener(aListener);
}
/**
* 删除项目监听事件
* @param aListener 事件监听器
*/
public void removeItemListener(ItemListener aListener) {
this.tableNameComboBox.removeItemListener(aListener);
}
@Override
protected String title4PopupWindow() {
return "choosepane";
}
protected void calculateTableDataNames() {
JTree tree = tableNameComboBox.getTree();
if (tree == null) {
return;
}
DefaultMutableTreeNode rootTreeNode = (DefaultMutableTreeNode) tree.getModel().getRoot();
rootTreeNode.removeAllChildren();
String selectedDSName = this.getDSName();
com.fr.data.impl.Connection selectedDatabase = this.getConnection();
if (selectedDatabase == null) {
return;
}
try {
String schema = StringUtils.isEmpty(this.schemaBox.getSelectedItem()) ? null : this.schemaBox.getSelectedItem();
TableProcedure[] sqlTableArray = DataCoreUtils.getTables(selectedDatabase, TableProcedure.TABLE, schema, DesignerEnvManager.getEnvManager().isOracleSystemSpace());
if (sqlTableArray.length > 0) {
ExpandMutableTreeNode tableTreeNode = new ExpandMutableTreeNode(selectedDSName + "-" + Inter.getLocText("FR-Designer_SQL-Table"));
rootTreeNode.add(tableTreeNode);
for (int i = 0; i < sqlTableArray.length; i++) {
ExpandMutableTreeNode tableChildTreeNode = new ExpandMutableTreeNode(sqlTableArray[i]);
tableTreeNode.add(tableChildTreeNode);
}
}
TableProcedure[] sqlViewArray = DataCoreUtils.getTables(selectedDatabase, TableProcedure.VIEW, schema, DesignerEnvManager.getEnvManager().isOracleSystemSpace());
if (sqlViewArray.length > 0) {
ExpandMutableTreeNode viewTreeNode = new ExpandMutableTreeNode(selectedDSName + "-" + Inter.getLocText("FR-Designer_SQL-View"));
rootTreeNode.add(viewTreeNode);
for (int i = 0; i < sqlViewArray.length; i++) {
ExpandMutableTreeNode viewChildTreeNode = new ExpandMutableTreeNode(sqlViewArray[i]);
viewTreeNode.add(viewChildTreeNode);
}
}
((DefaultTreeModel) tree.getModel()).reload();
/**
* daniel 展开所有tree
*/
TreeNode root = (TreeNode) tree.getModel().getRoot();
TreePath parent = new TreePath(root);
TreeNode node = (TreeNode) parent.getLastPathComponent();
for (Enumeration e = node.children(); e.hasMoreElements(); ) {
TreeNode n = (TreeNode) e.nextElement();
TreePath path = parent.pathByAddingChild(n);
tree.expandPath(path);
}
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
/**
* 创建选中的数据集数据
* @return 数据集数据
*/
public TableData createSelectTableData() {
DataBaseItems paras = this.updateBean();
boolean connect = false;
com.fr.data.impl.Connection database = DBUtils.checkDBConnection(paras.getDatabaseName());
if (database == null) {
failedToFindTable();
return TableData.EMPTY_TABLEDATA;
}
try {
connect = FRContext.getCurrentEnv().testConnection(database);
} catch (Exception e1) {
connect = false;
}
if (!connect) {
DesignerFrame designerFrame = DesignerContext.getDesignerFrame();
JOptionPane.showMessageDialog(designerFrame, Inter.getLocText("Datasource-Connection_failed"),
Inter.getLocText("FR-Designer_Failed"), JOptionPane.INFORMATION_MESSAGE);
failedToFindTable();
return null;
}
// 显示Table数据.
TableData tableData = null;
if (FRContext.getCurrentEnv() instanceof LocalEnv) {
TableData tableDataLocal = new DBTableData(database, DataCoreUtils.createSelectSQL(paras.getSchemaName(), paras.getTableName(),
DialectFactory.getDialectByName(paras.getDatabaseName())));
tableData = tableDataLocal;
} else {
try {
TableData tableDataLocal = new DBTableData(database, DataCoreUtils.createSelectSQL(paras.getSchemaName(), paras.getTableName(), DialectFactory.getDialectByName(paras.getDatabaseName())));
tableData = FRContext.getCurrentEnv().previewTableData(tableDataLocal, java.util.Collections.EMPTY_MAP,
DesignerEnvManager.getEnvManager().getMaxNumberOrPreviewRow());
} catch (Exception e) {
failedToFindTable();
FRContext.getLogger().error(e.getMessage(), e);
}
}
return tableData;
}
protected String getDSName() {
return this.dsNameComboBox.getSelectedItem();
}
protected void failedToFindTable() {
}
protected String getTableName() {
String tableName = "";
Object obj = this.tableNameComboBox.getSelectedItem();
if (obj == null) {
obj = this.tableNameComboBox.getEditor().getItem();
}
if (obj instanceof TreePath) {
Object tp = ((ExpandMutableTreeNode) ((TreePath) obj).getLastPathComponent()).getUserObject();
if (tp instanceof TableProcedure) {
tableName = ((TableProcedure) tp).getName();
}
} else if (obj instanceof String) {
tableName = (String) obj;
}
return tableName;
}
/**
* 得到当前的ColumnName[]
* @return 返回当前的ColumnName[]
*/
public String[] currentColumnNames() {
String[] colNames = null;
DataBaseItems paras = this.updateBean();
String selectedDSName = paras.getDatabaseName();
if (StringUtils.isBlank(selectedDSName)) {
return colNames = new String[0]; // peter:选中了当前的零长度的节点,直接返回.
}
String selectedTableObject = paras.getTableName();
if (StringUtils.isEmpty(selectedTableObject)) {
return colNames = new String[0];
}
java.sql.Connection conn = null;
try {
// daniel:增加参数
colNames = FRContext.getCurrentEnv().getColumns(selectedDSName, paras.getSchemaName(), selectedTableObject);
} catch (Exception e2) {
FRContext.getLogger().error(e2.getMessage(), e2);
} finally {
DBUtils.closeConnection(conn);
}
if (colNames == null) {
colNames = new String[0];
}
return colNames;
}
/**
* 预览key value对应的数据
* @param key
* @param value
*/
public void preview(int key, int value) {
PreviewTablePane.previewTableData(createSelectTableData(), key, value);
}
/**
* 默认预览
*/
public void preview() {
preview(-1, -1);
}
/**
* 设置数据集名.
*/
public void setTableNameComboBoxPopSize(int width, int height) {
tableNameComboBox.setPopSize(width, height);
}
/**
*注册listener,相应数据集改变
*/
public void registerDSChangeListener() {
DesignTableDataManager.addDsChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
initDsNameComboBox();
}
});
}
protected class StringUIComboBox extends UIComboBox {
private boolean refreshingModel = false;
@Override
protected void fireItemStateChanged(ItemEvent e) {
if (!isRefreshingModel()) {
super.fireItemStateChanged(e);
}
}
@Override
public String getSelectedItem() {
Object ob = super.getSelectedItem();
if (ob instanceof String) {
return (String) ob;
} else
return StringUtils.EMPTY;
}
public boolean isRefreshingModel() {
return refreshingModel;
}
public void setRefreshingModel(boolean refreshingModel) {
this.refreshingModel = refreshingModel;
}
public void setSelectedItem(Object ob) {
this.getModel().setSelectedItem(ob);
if (ob != null && StringUtils.isEmpty(ob.toString())) {
super.setSelectedIndex(-1);
} else {
super.setSelectedItem(ob);
}
}
}
private class ComboBoxEditor extends UIComboBoxEditor {
private Object item;
public void setItem(Object item) {
this.item = item;
textField.setText((item == null) ? "" : item.toString());
}
public Object getItem() {
return this.item;
}
}
}

1
designer_base/src/com/fr/design/data/datapane/ChoosePaneSupportFormula.java

File diff suppressed because one or more lines are too long

48
designer_base/src/com/fr/design/data/datapane/DSButtonGroup.java

@ -0,0 +1,48 @@
package com.fr.design.data.datapane;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.mainframe.WestRegionContainerPane;
import javax.swing.*;
import java.awt.*;
/**
* Created with IntelliJ IDEA.
* User: pony
* Date: 13-4-27
* Time: 上午10:32
* To change this template use File | Settings | File Templates.
*/
public class DSButtonGroup extends UIButtonGroup<Integer> {
public DSButtonGroup(Icon[] iconArray, Integer[] objects) {
super(iconArray, objects);
}
protected void paintBorder(Graphics g) {
int tabledatatreepaneWidth = WestRegionContainerPane.getInstance().getWidth()-10;
int labelX = 54 - (290 - tabledatatreepaneWidth) / 4 - 1;
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(UIConstants.LINE_COLOR);
int width = 0;
width += labelButtonList.get(0).getWidth() + 1;
int height = labelButtonList.get(0).getHeight();
g.drawLine(width + labelX, 0, width + labelX, height);
width += labelButtonList.get(labelButtonList.size() - 1).getWidth() + 1;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.drawRoundRect( labelX, 0, width, getHeight() - 1, UIConstants.ARC, UIConstants.ARC);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
g2d.drawLine(labelX / 2, getHeight() / 2, width + 3 * labelX / 2 , getHeight() / 2);
}
}

49
designer_base/src/com/fr/design/data/datapane/DataBaseItems.java

@ -0,0 +1,49 @@
package com.fr.design.data.datapane;
import com.fr.stable.StringUtils;
/**
*
* @author zhou
* @since 2012-7-11下午5:11:31
*/
public class DataBaseItems {
private String databaseName;
private String schemaName;
private String tableName;
public DataBaseItems() {
this(null, null, null);
}
public DataBaseItems(String databaseName, String schemaName, String tableName) {
this.setDatabaseName(databaseName);
this.setSchemaName(schemaName);
this.setTableName(tableName);
}
public String getDatabaseName() {
return databaseName;
}
public void setDatabaseName(String databaseName) {
this.databaseName = databaseName == null ? StringUtils.EMPTY : databaseName;
}
public String getSchemaName() {
return schemaName;
}
public void setSchemaName(String schemaName) {
this.schemaName = schemaName == null ? StringUtils.EMPTY : schemaName;
}
public String getTableName() {
return tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName == null ? StringUtils.EMPTY : tableName;
}
}

34
designer_base/src/com/fr/design/data/datapane/EditOrNewLabel.java

@ -0,0 +1,34 @@
package com.fr.design.data.datapane;
import java.awt.Cursor;
import com.fr.design.gui.ilable.UILabel;
import javax.swing.JPanel;
import com.fr.base.BaseUtils;
import com.fr.design.data.datapane.FlashLookLabelMouseAdapter.ReleaseAction;
import com.fr.general.Inter;
public class EditOrNewLabel extends UILabel {
JPanel editTablePane;
Editable editable;
public EditOrNewLabel(Editable editable, JPanel editPane) {
super(BaseUtils.readIcon("/com/fr/design/images/m_file/edit.png"));
this.setToolTipText(Inter.getLocText("Edit"));
this.setCursor(new Cursor(Cursor.HAND_CURSOR));
this.editable = editable;
this.editTablePane = editPane;
this.addMouseListener(new FlashLookLabelMouseAdapter(this, new ReleaseAction() {
@Override
public void releaseAction() {
EditOrNewLabel.this.editable.edit(EditOrNewLabel.this.editTablePane);
}
}));
}
public static interface Editable {
public void edit(JPanel jPanel);
}
}

57
designer_base/src/com/fr/design/data/datapane/FlashLookLabelMouseAdapter.java

@ -0,0 +1,57 @@
package com.fr.design.data.datapane;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.BorderFactory;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ilable.UILabel;
import javax.swing.border.Border;
public class FlashLookLabelMouseAdapter extends MouseAdapter {
boolean mouseEntered = false;
boolean buttonPressed = false;
private UILabel label;
private ReleaseAction releaseAction;
private static final Border NORMAL_BORDER = BorderFactory.createLineBorder(UIConstants.NORMAL_BACKGROUND);
private static final Border ENTERED_BORDER = BorderFactory.createLineBorder(java.awt.Color.GRAY);
public FlashLookLabelMouseAdapter(UILabel label, ReleaseAction releaseAction) {
this.label = label;
label.setBorder(NORMAL_BORDER);
this.releaseAction = releaseAction;
}
public void mouseEntered(MouseEvent e) { //当鼠标进入时候调用.
mouseEntered = true;
if(!buttonPressed){
label.setBackground(java.awt.Color.WHITE);
label.setOpaque(true);
label.setBorder(ENTERED_BORDER);
}
}
public void mouseExited(MouseEvent e) {
mouseEntered = false;
label.setOpaque(false);
label.setBorder(NORMAL_BORDER);
}
public void mousePressed(MouseEvent e){
buttonPressed = true;
label.setBackground(java.awt.Color.lightGray);
}
public void mouseReleased(MouseEvent e){
buttonPressed = false;
if(mouseEntered){
label.setBackground(java.awt.Color.WHITE);
this.releaseAction.releaseAction();
}
}
public static interface ReleaseAction {
public void releaseAction();
}
}

22
designer_base/src/com/fr/design/data/datapane/GlobalTableDataComboBox.java

@ -0,0 +1,22 @@
package com.fr.design.data.datapane;
import com.fr.design.data.DesignTableDataManager;
import com.fr.data.TableDataSource;
/**
* Created with IntelliJ IDEA.
* User: pony
* Date: 13-4-20
* Time: 上午11:16
* To change this template use File | Settings | File Templates.
*/
public class GlobalTableDataComboBox extends TableDataComboBox {
public GlobalTableDataComboBox(TableDataSource source, String treeName) {
super(source, treeName);
}
protected void setResMap(TableDataSource source){
resMap = DesignTableDataManager.getGlobalDataSet();
}
}

21
designer_base/src/com/fr/design/data/datapane/GlobalTreeTableDataDictPane.java

@ -0,0 +1,21 @@
package com.fr.design.data.datapane;
import com.fr.design.data.DesignTableDataManager;
/**
* Created with IntelliJ IDEA.
* User: pony
* Date: 13-4-20
* Time: 上午11:27
* To change this template use File | Settings | File Templates.
*/
public class GlobalTreeTableDataDictPane extends TreeTableDataDictPane {
public GlobalTreeTableDataDictPane(String treeName) {
super(treeName);
}
protected void setTableDataNameComboBox(String string) {
tableDataNameComboBox = new GlobalTableDataComboBox(DesignTableDataManager.getEditingTableDataSource(),string);
}
}

37
designer_base/src/com/fr/design/data/datapane/RefreshLabel.java

@ -0,0 +1,37 @@
package com.fr.design.data.datapane;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import com.fr.base.BaseUtils;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.general.Inter;
public class RefreshLabel extends UIButton {
private Refreshable refreshable;
public RefreshLabel(Refreshable refreshable) {
super(BaseUtils.readIcon("/com/fr/design/images/control/refresh.png"));
this.refreshable = refreshable;
this.setToolTipText(Inter.getLocText("Refresh_Database"));
this.setCursor(new Cursor(Cursor.HAND_CURSOR));
this.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
RefreshLabel.this.refreshable.refresh();
}
});
this.setPreferredSize(new Dimension(24, 20));
}
public static interface Refreshable {
public void refresh();
}
}

62
designer_base/src/com/fr/design/data/datapane/ReportTableDataPane.java

@ -0,0 +1,62 @@
/*
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved.
*/
package com.fr.design.data.datapane;
import com.fr.data.TableDataSource;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.gui.frpane.LoadingBasicPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.*;
import java.util.Map;
/**
* @author richer
* @since 6.5.5
* 创建于2011-6-14
*/
public class ReportTableDataPane extends LoadingBasicPane {
private TableDataListPane tdListPane;
@Override
protected void initComponents(JPanel container) {
container.setLayout(FRGUIPaneFactory.createBorderLayout());
this.tdListPane = new TableDataListPane() {
@Override
public NameableCreator[] createNameableCreators() {
return TableDataCreatorProducer.getInstance().createReportTableDataCreator();
}
};
container.add(tdListPane, BorderLayout.CENTER);
}
@Override
protected String title4PopupWindow() {
return Inter.getLocText("DS-Report_TableData");
}
public void populate(TableDataSource tds) {
tdListPane.populate(tds);
}
public void update(TableDataSource tds) {
tdListPane.update(tds);
}
/**
* 检查tdListPane有效性check Valid
*
* @throws Exception 异常
*/
public void checkValid() throws Exception {
this.tdListPane.checkValid();
}
public Map<String, String> getDsNameChangedMap() {
return tdListPane.getDsNameChangedMap();
}
}

149
designer_base/src/com/fr/design/data/datapane/TableDataComboBox.java

@ -0,0 +1,149 @@
package com.fr.design.data.datapane;
import java.awt.Component;
import java.awt.event.ItemEvent;
import java.util.Iterator;
import java.util.Map.Entry;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import com.fr.design.constants.UIConstants;
import com.fr.design.data.DesignTableDataManager;
import com.fr.data.TableDataSource;
import com.fr.design.data.tabledata.Prepare4DataSourceChange;
import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxRenderer;
import com.fr.general.ComparatorUtils;
import com.fr.stable.StringUtils;
/**
* 包含所有数据集的下拉框
*
* @author zhou
* @since 2012-4-20上午10:34:30
*/
public class TableDataComboBox extends UIComboBox implements Prepare4DataSourceChange {
protected java.util.Map<String, TableDataWrapper> resMap;
private java.util.Map<String, TableDataWrapper> dsMap;
private static final long serialVersionUID = 1L;
private boolean refresModel = false;
private String treeName; //树数据集本身的名字
public TableDataComboBox(TableDataSource source){
this(source,StringUtils.EMPTY);
}
public TableDataComboBox(TableDataSource source, String treeName) {
super();
this.treeName = treeName;
this.setRenderer(new UIComboBoxRenderer() {
private static final long serialVersionUID = 1L;
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel renderer = (JLabel)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof TableDataWrapper) {
TableDataWrapper tabledatawrappe = (TableDataWrapper)value;
renderer.setIcon(tabledatawrappe.getIcon());
renderer.setText(tabledatawrappe.getTableDataName());
renderer.setToolTipText(tabledatawrappe.getTableDataName());
} else {
renderer.setIcon(null);
renderer.setText(StringUtils.EMPTY);
}
return renderer;
}
});
refresh(source);
registerDSChangeListener();
}
/**
* refresh ComboBox
* @param source
*/
public void refresh(TableDataSource source) {
TableDataWrapper dataWrapper = getSelectedItem();
refresModel = true;
setResMap(source);
setDsMap();
DefaultComboBoxModel model = new DefaultComboBoxModel();
this.setModel(model);
model.addElement(UIConstants.PENDING);
Iterator<Entry<String, TableDataWrapper>> entryIt = dsMap.entrySet().iterator();
while (entryIt.hasNext()) {
TableDataWrapper tableDataWrapper = entryIt.next().getValue();
if (!ComparatorUtils.equals(tableDataWrapper.getTableDataName(), treeName)) {
model.addElement(tableDataWrapper);
}
}
if (dataWrapper != null) {
if (DesignTableDataManager.isDsNameChanged(dataWrapper.getTableDataName())) {
this.setSelectedTableDataByName(DesignTableDataManager.getChangedDsNameByOldDsName(dataWrapper.getTableDataName()));
} else {
this.getModel().setSelectedItem(dataWrapper);
}
}
refresModel = false;
}
protected void setResMap(TableDataSource source) {
this.resMap = DesignTableDataManager.getAllEditingDataSet(source);
}
private void setDsMap() {
dsMap = DesignTableDataManager.getAllDataSetIncludingProcedure(resMap);
}
/**
* 向resMap中添加TableData信息
* @param name 数据集名字
* @param templateTableDataWrappe 数据集
*/
public void putTableDataIntoMap(String name, TemplateTableDataWrapper templateTableDataWrappe) {
if (dsMap.containsKey(name)) {
return;
}
this.addItem(templateTableDataWrappe);
dsMap.put(name, templateTableDataWrappe);
}
public void setSelectedTableDataByName(String name) {
TableDataWrapper tableDataWrappe = dsMap.get(name) == null? dsMap.get(name + "_P_CURSOR") : dsMap.get(name);
this.getModel().setSelectedItem(tableDataWrappe);
}
@Override
public TableDataWrapper getSelectedItem() {
if (dataModel.getSelectedItem() instanceof TableDataWrapper) {
return (TableDataWrapper)dataModel.getSelectedItem();
}
return null;
}
//august:addElement方法竟然会fireItemStateChanged,蛋疼
@Override
protected void fireItemStateChanged(ItemEvent e) {
if (!refresModel) {
super.fireItemStateChanged(e);
}
}
/**
*注册listener,相应数据集改变
*/
public void registerDSChangeListener() {
DesignTableDataManager.addDsChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
TableDataComboBox.this.refresh(DesignTableDataManager.getEditingTableDataSource());
}
});
}
}

134
designer_base/src/com/fr/design/data/datapane/TableDataCreatorProducer.java

@ -0,0 +1,134 @@
/*
* Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved.
*/
package com.fr.design.data.datapane;
import com.fr.data.impl.*;
import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.data.tabledata.tabledatapane.*;
import com.fr.design.fun.TableDataCreatorProvider;
import com.fr.general.Inter;
import com.fr.stable.ArrayUtils;
import java.util.ArrayList;
import java.util.List;
/**
* @author : richie
* @since : 8.0
*/
public class TableDataCreatorProducer {
private static TableDataCreatorProducer ourInstance = new TableDataCreatorProducer();
public static TableDataCreatorProducer getInstance() {
return ourInstance;
}
private TableDataCreatorProducer() {
}
public TableDataNameObjectCreator[] createReportTableDataCreator() {
TableDataNameObjectCreator dataBase = new TableDataNameObjectCreator(Inter.getLocText("DS-Database_Query"),
"ds",
"/com/fr/design/images/data/database.png", DBTableData.class, DBTableDataPane.class);
TableDataNameObjectCreator ds_Class = new TableDataNameObjectCreator(Inter.getLocText("DS-Class"),
"/com/fr/design/images/data/source/classTableData.png", ClassTableData.class, ClassTableDataPane.class);
TableDataNameObjectCreator table = new TableDataNameObjectCreator(Inter.getLocText("DS-Embedded_TableData"),
"Embedded",
"/com/fr/design/images/data/dataTable.png", EmbeddedTableData.class, EmbeddedTableDataPane.class);
TableDataNameObjectCreator multiTable = new TableDataNameObjectCreator(Inter.getLocText("DS-Relation_TableData"),
"Multi",
"/com/fr/design/images/data/multi.png", ConditionTableData.class, MultiTDTableDataPane.class) {
public boolean isNeedParameterWhenPopulateJControlPane() {
return true;
}
};
TableDataNameObjectCreator fileTable = new TableDataNameObjectCreator(Inter.getLocText(new String[]{"File", "DS-TableData"}),
"File",
"/com/fr/design/images/data/file.png", FileTableData.class, FileTableDataSmallHeightPane.class);
TableDataNameObjectCreator treeTable = new TableDataNameObjectCreator(Inter.getLocText(new String[]{"Tree", "DS-TableData"}),
"Tree",
"/com/fr/design/images/data/tree.png", RecursionTableData.class, TreeTableDataPane.class) {
public boolean isNeedParameterWhenPopulateJControlPane() {
return true;
}
};
TableDataNameObjectCreator storeProcedure = new TableDataNameObjectCreator(Inter.getLocText("Datasource-Stored_Procedure"),
"Proc",
"/com/fr/design/images/data/store_procedure.png",
StoreProcedure.class, ProcedureDataPane.class) {
public boolean shouldInsertSeparator() {
return true;
}
};
TableDataNameObjectCreator[] creators = new TableDataNameObjectCreator[]{dataBase, ds_Class, table, fileTable, storeProcedure, multiTable, treeTable};
return merge(creators, ExtraDesignClassManager.getInstance().getReportTableDataCreators());
}
public TableDataNameObjectCreator[] createServerTableDataCreator() {
TableDataNameObjectCreator dataBase = new TableDataNameObjectCreator(Inter.getLocText("DS-Database_Query"), "/com/fr/design/images/data/dock/serverdatabase.png", DBTableData.class,
DBTableDataPane.class);
TableDataNameObjectCreator ds_Class = new TableDataNameObjectCreator(Inter.getLocText("DS-Class"), "/com/fr/design/images/data/dock/serverclasstabledata.png", ClassTableData.class,
ClassTableDataPane.class);
TableDataNameObjectCreator table = new TableDataNameObjectCreator(Inter.getLocText("DS-Embedded_TableData"), "/com/fr/design/images/data/dock/serverdatatable.png", EmbeddedTableData.class,
EmbeddedTableDataPane.class);
TableDataNameObjectCreator fileTable = new TableDataNameObjectCreator(Inter.getLocText(new String[]{"File", "DS-TableData"}), "/com/fr/design/images/data/file.png", FileTableData.class,
FileTableDataSmallPane.class);
TableDataNameObjectCreator treeTable = new TableDataNameObjectCreator(Inter.getLocText(new String[]{"Tree", "DS-TableData"}), "/com/fr/design/images/data/tree.png",
RecursionTableData.class, GlobalTreeTableDataPane.class) {
public boolean isNeedParameterWhenPopulateJControlPane() {
return true;
}
};
TableDataNameObjectCreator multiTable = new TableDataNameObjectCreator(Inter.getLocText("DS-Relation_TableData"), "/com/fr/design/images/data/multi.png",
ConditionTableData.class, GlobalMultiTDTableDataPane.class) {
public boolean isNeedParameterWhenPopulateJControlPane() {
return true;
}
};
TableDataNameObjectCreator storeProcedure = new TableDataNameObjectCreator(Inter.getLocText("Datasource-Stored_Procedure"), "/com/fr/design/images/data/store_procedure.png",
StoreProcedure.class, ProcedureDataPane.class) {
public boolean shouldInsertSeparator() {
return true;
}
};
TableDataNameObjectCreator[] creators = new TableDataNameObjectCreator[]{dataBase, ds_Class, table, fileTable, storeProcedure, multiTable, treeTable};
TableDataCreatorProvider creatorProvider = ExtraDesignClassManager.getInstance().getTableDataCreatorProvider();
if (creatorProvider != null) {
return creatorProvider.produceServerTableDataCreator(creators);
}
return merge(creators, ExtraDesignClassManager.getInstance().getServerTableDataCreators());
}
private TableDataNameObjectCreator[] merge(TableDataNameObjectCreator[] creators, TableDataNameObjectCreator[] extraCreators) {
if (ArrayUtils.isEmpty(extraCreators)) {
return creators;
}
List<TableDataNameObjectCreator> list = new ArrayList<>();
List<Integer> coverIndexList = new ArrayList<>();
List<TableDataNameObjectCreator> coverCreators = new ArrayList<>();
for (TableDataNameObjectCreator ex : extraCreators) {
int index = ArrayUtils.indexOf(creators, ex);
// 说明已经存在了一个同类型的数据集,需要用插件的覆盖掉原先的
if (index != ArrayUtils.INDEX_NOT_FOUND) {
// 需要替换到列表里的
coverIndexList.add(index);
coverCreators.add(ex);
} else {
// 需要添加到列表中去的
list.add(ex);
}
}
for (int i = 0; i < coverIndexList.size(); i ++) {
creators[coverIndexList.get(i)] = coverCreators.get(i);
}
return (TableDataNameObjectCreator[])ArrayUtils.addAll(creators, list.toArray(new TableDataNameObjectCreator[list.size()]));
}
}

261
designer_base/src/com/fr/design/data/datapane/TableDataListPane.java

@ -0,0 +1,261 @@
package com.fr.design.data.datapane;
import com.fr.base.TableData;
import com.fr.data.TableDataSource;
import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.gui.controlpane.JControlPane;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.gui.ilist.ListModelElement;
import com.fr.file.DatasourceManagerProvider;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import com.fr.general.NameObject;
import com.fr.stable.Nameable;
import com.fr.stable.StringUtils;
import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.*;
import java.util.*;
/**
* TableDataList Pane.
*/
public class TableDataListPane extends JControlPane {
private Map<String, String> dsNameChangedMap = new HashMap<String, String>();
private boolean isNamePermitted = true;
public TableDataListPane() {
super();
dsNameChangedMap.clear();
this.addEditingListner(new PropertyChangeAdapter() {
@Override
public void propertyChange() {
isNamePermitted = true;
TableDataSource source = DesignTableDataManager.getEditingTableDataSource();
String[] allDSNames = DesignTableDataManager.getAllDSNames(source);
String[] allListNames = nameableList.getAllNames();
allListNames[nameableList.getSelectedIndex()] = StringUtils.EMPTY;
String tempName = getEditingName();
Object editingType = getEditingType();
if (StringUtils.isEmpty(tempName)) {
String[] warning = new String[]{"NOT_NULL_Des", "Please_Rename"};
String[] sign = new String[]{",", "!"};
isNamePermitted = false;
nameableList.stopEditing();
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataListPane.this), Inter.getLocText(warning, sign));
setWarnigText(editingIndex);
return;
}
if (!ComparatorUtils.equals(tempName, selectedName)
&& isNameRepeted(new List[]{Arrays.asList(allDSNames), Arrays.asList(allListNames)}, tempName)) {
String[] waning = new String[]{"already_exists", "TableData", "Please_Rename"};
String[] sign = new String[]{"", tempName + ",", "!"};
isNamePermitted = false;
nameableList.stopEditing();
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataListPane.this), Inter.getLocText(waning, sign));
setWarnigText(editingIndex);
} else if (editingType instanceof StoreProcedure && isIncludeUnderline(tempName)) {
String[] datasource_underline = new String[]{"Datasource-Stored_Procedure", "Name", "can_not_include_underline"};
String[] sign = new String[]{"", "", "!"};
isNamePermitted = false;
nameableList.stopEditing();
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataListPane.this), Inter.getLocText(datasource_underline, sign));
setWarnigText(editingIndex);
}
if (nameableList.getSelectedValue() instanceof ListModelElement) {
Nameable selected = ((ListModelElement) nameableList.getSelectedValue()).wrapper;
if (!ComparatorUtils.equals(tempName, selected.getName())) {
rename(selected.getName(), tempName);
}
}
}
});
}
protected void rename(String oldName, String newName) {
dsNameChangedMap.put(oldName, newName);
}
/**
* 名字是否允许
*
* @return /
*/
public boolean isNamePermitted() {
return isNamePermitted;
}
/**
* 检查按钮可用状态 Check button enabled.
*/
public void checkButtonEnabled() {
super.checkButtonEnabled();
isNamePermitted = !isContainsRename();
}
private boolean isIncludeUnderline(String name) {
return ComparatorUtils.equals(name.indexOf(StoreProcedure.SPLIT), -1) ? false : true;
}
/**
* 创建服务器数据集所需要的NameableCreator数组
*
* @return 数组
*/
public NameableCreator[] createNameableCreators() {
return TableDataCreatorProducer.getInstance().createServerTableDataCreator();
}
// 只能保证当前模板不重名了
/**
* 新建不重名的面板
*
* @param prefix 前缀字符
* @return 生成的名字
*/
@Override
public String createUnrepeatedName(String prefix) {
TableDataSource source = DesignTableDataManager.getEditingTableDataSource();
if (source == null) {
return super.createUnrepeatedName(prefix);
}
String[] allDsNames = DesignTableDataManager.getAllDSNames(source);
DefaultListModel model = this.getModel();
Nameable[] all = new Nameable[model.getSize()];
for (int i = 0; i < model.size(); i++) {
all[i] = ((ListModelElement) model.get(i)).wrapper;
}
// richer:生成的名字从1开始. kunsnat: 添加属性从0开始.
int count = all.length + 1;
while (true) {
String name_test = prefix + count;
boolean repeated = false;
for (int i = 0, len = model.size(); i < len; i++) {
Nameable nameable = all[i];
if (ComparatorUtils.equals(nameable.getName(), name_test)) {
repeated = true;
break;
}
}
for (String dsname : allDsNames) {
if (ComparatorUtils.equals(dsname, name_test)) {
repeated = true;
break;
}
}
if (!repeated) {
return name_test;
}
count++;
}
}
@Override
protected String title4PopupWindow() {
return "TableData";
}
/**
* Populate.
*/
public void populate(TableDataSource tds) {
List<NameObject> nameObjectList = new ArrayList<NameObject>();
Iterator tableDataNameIterator = tds.getTableDataNameIterator();
while (tableDataNameIterator.hasNext()) {
String tableDataName = (String) tableDataNameIterator.next();
TableData tableData = tds.getTableData(tableDataName);
if (tableData != null) {
nameObjectList.add(new NameObject(tableDataName, tableData));
}
}
populate(nameObjectList.toArray(new NameObject[nameObjectList.size()]));
}
/**
* Populate.
*/
public void populate(DatasourceManagerProvider datasourceManager) {
Iterator<String> nameIt = datasourceManager.getTableDataNameIterator();
Iterator<String> procedurenameIt = datasourceManager.getProcedureNameIterator();
List<NameObject> nameObjectList = new ArrayList<NameObject>();
while (nameIt.hasNext()) {
String name = nameIt.next();
nameObjectList.add(new NameObject(name, datasourceManager.getTableData(name)));
}
while (procedurenameIt.hasNext()) {
String name = procedurenameIt.next();
nameObjectList.add(new NameObject(name, datasourceManager.getProcedureByName(name)));
}
populate(nameObjectList.toArray(new NameObject[nameObjectList.size()]));
}
public void update(DatasourceManagerProvider datasourceManager) {
datasourceManager.clearAllTableData();
datasourceManager.clearAllProcedure();
Nameable[] tableDataArray = this.update();
for (int i = 0; i < tableDataArray.length; i++) {
NameObject nameObject = (NameObject) tableDataArray[i];
datasourceManager.putTableData(nameObject.getName(), (TableData) nameObject.getObject());
}
}
public void update(TableDataSource tds) {
tds.clearAllTableData();
Nameable[] tableDataArray = this.update();
for (int i = 0; i < tableDataArray.length; i++) {
NameObject nameObject = (NameObject) tableDataArray[i];
tds.putTableData(nameObject.getName(), (TableData) nameObject.getObject());
}
}
/**
* 判断数据集是否重名
*/
public void checkValid() throws Exception {
List<String> exsitTableDataNameList = new ArrayList<String>();
// _denny: 判断是否有重复的数据集名
checkRepeatedDSName(exsitTableDataNameList);
Nameable[] tableDataArray = this.update();
for (int i = 0; i < tableDataArray.length; i++) {
NameObject nameObject = (NameObject) tableDataArray[i];
if (exsitTableDataNameList.contains(nameObject.getName())) {
String[] waring = new String[]{"TableData", "Error_TableDataNameRepeat"};
String[] sign = new String[]{": " + nameObject.getName()};
throw new Exception(Inter.getLocText(waring, sign));
}
exsitTableDataNameList.add(nameObject.getName());
}
}
protected void checkRepeatedDSName(List<String> exsitTableDataNameList) {
}
/**
* 在JJControlPane的左侧Tree里面选中某一Item
*
* @param name 被选择的Item名称
*/
public void selectName(String name) {
this.setSelectedName(name);
}
public Map<String, String> getDsNameChangedMap() {
return this.dsNameChangedMap;
}
}

178
designer_base/src/com/fr/design/data/datapane/TableDataNameObjectCreator.java

@ -0,0 +1,178 @@
package com.fr.design.data.datapane;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.data.impl.DBTableData;
import com.fr.design.actions.tabledata.TableDataAction;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.controlpane.NameObjectCreator;
import com.fr.design.icon.WarningIcon;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.*;
import java.text.Collator;
import java.util.*;
import java.util.List;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 13-12-20
* Time: 上午9:55
*/
public class TableDataNameObjectCreator extends NameObjectCreator {
private boolean b = false;
private Image menuImage;
private String iconPath;
private boolean isNeedInsertSeparator = false;
private String prefix = "";
private java.util.List<String> names = new ArrayList<String>();
public TableDataNameObjectCreator(TableDataAction action) {
super(action.getDisplayName(), action.getIconPath(), action.getTableDataClass(), action.getUpdateTableDataPaneClass());
this.iconPath = action.getIconPath();
menuImage = BaseUtils.readImage(iconPath);
isNeedInsertSeparator = action.isNeedInsertSeparator();
prefix = action.getPrefix();
}
public TableDataNameObjectCreator(TableDataAction action, Class clazz4Init) {
super(action.getDisplayName(), action.getIconPath(), action.getTableDataClass(), clazz4Init, action.getUpdateTableDataPaneClass());
isNeedInsertSeparator = action.isNeedInsertSeparator();
prefix = action.getPrefix();
}
public TableDataNameObjectCreator(String menuName, String iconPath, Class clazz, Class<? extends BasicBeanPane> updatePane) {
super(menuName, iconPath, clazz, updatePane);
if (iconPath != null) {
this.iconPath = iconPath;
menuImage = BaseUtils.readImage(iconPath);
}
}
public TableDataNameObjectCreator(String menuName, String prefix, String iconPath, Class clazz, Class<? extends BasicBeanPane> updatePane) {
super(menuName, iconPath, clazz, updatePane);
if (iconPath != null) {
this.iconPath = iconPath;
menuImage = BaseUtils.readImage(iconPath);
}
this.prefix = prefix;
}
public TableDataNameObjectCreator(String menuName, String iconPath, Class clazz, Class clazz4Init, Class<? extends BasicBeanPane> updatePane) {
super(menuName, iconPath, clazz, clazz4Init, updatePane);
if (iconPath != null) {
this.iconPath = iconPath;
menuImage = BaseUtils.readImage(iconPath);
}
}
public TableDataNameObjectCreator(String menuName, String prefix, String iconPath, Class clazz, Class clazz4Init, Class<? extends BasicBeanPane> updatePane) {
super(menuName, iconPath, clazz, clazz4Init, updatePane);
if (iconPath != null) {
this.iconPath = iconPath;
menuImage = BaseUtils.readImage(iconPath);
}
this.prefix = prefix;
}
@Override
protected void doSthChanged4Icon(Object ob) {
if (ob instanceof DBTableData) {
DBTableData db = (DBTableData) ob;
b = StringUtils.isBlank(db.getQuery());
}
}
/**
* 取得菜单的图片
*
* @return 图片
*/
public Icon menuIcon() {
return createMenuIcon();
}
public String getIconPath() {
return iconPath;
}
private Icon createMenuIcon() {
return b ? new WarningIcon(this.menuImage) : this.menuIcon;
}
/**
* 创建提示
*
* @return 提示
*/
public String createTooltip() {
return b ? Inter.getLocText("Connect_SQL_Cannot_Null") : null;
}
public String getPrefix() {
return StringUtils.isNotBlank(prefix) ? prefix : menuName();
}
/**
* 将names排序
*
* @return
*/
public List<String> getNames() {
String[] namearray = names.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
Arrays.sort(namearray, Collator.getInstance(java.util.Locale.CHINA));
return Arrays.asList(namearray);
}
public Object createObject() {
try {
return clazzOfObject.newInstance();
} catch (InstantiationException e) {
try {
return clazzOfInitCase.newInstance();
} catch (InstantiationException | IllegalAccessException e1) {
FRContext.getLogger().error(e.getMessage(), e);
}
} catch (IllegalAccessException e) {
FRContext.getLogger().error(e.getMessage(), e);
}
return null;
}
/**
* 加入名字
*
* @param names 名字
*/
public void addNames(String names) {
this.names.add(names);
}
/**
* 清除
*/
public void clear() {
this.names.clear();
}
public boolean shouldInsertSeparator() {
return false;
}
public boolean equals(Object obj) {
return obj instanceof TableDataNameObjectCreator
&& ComparatorUtils.equals(menuName, ((TableDataNameObjectCreator) obj).menuName);
}
@Override
public int hashCode() {
return menuName == null ? 0 : menuName.hashCode();
}
}

236
designer_base/src/com/fr/design/data/datapane/TableDataSourceOP.java

@ -0,0 +1,236 @@
package com.fr.design.data.datapane;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import com.fr.general.NameObject;
import com.fr.base.StoreProcedureParameter;
import com.fr.base.TableData;
import com.fr.design.data.DesignTableDataManager;
import com.fr.data.TableDataSource;
import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.data.impl.storeproc.StoreProcedureConstants;
import com.fr.design.data.tabledata.wrapper.StoreProcedureDataWrapper;
import com.fr.design.data.tabledata.wrapper.StoreProcedureNameWrapper;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.DesignModelAdapter;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.gui.itree.refreshabletree.UserObjectOP;
import com.fr.general.Inter;
/**
* 数据集树的操作
*
* @editor zhou
* @since 2012-3-28下午9:58:53
*/
public class TableDataSourceOP implements UserObjectOP<TableDataWrapper> {
public static final int TEMPLATE_TABLE_DATA = 0;
public static final int SERVER_TABLE_DATA = 1;
public static final int STORE_PRECEDURE_DATA = 2;
public static int dataMode = -1;
private DesignModelAdapter<?, ?> tc;
public TableDataSourceOP(DesignModelAdapter<?, ?> tc) {
this.tc = tc;
}
/**
* 初始化数据集的list
*
* @return
*/
@Override
public List<Map<String, TableDataWrapper>> init() {
if (tc != null) {
return DesignTableDataManager.getEditingDataSet(tc.getBook());
}
List<Map<String, TableDataWrapper>> empty = new ArrayList<Map<String, TableDataWrapper>>();
empty.add(Collections.<String, TableDataWrapper>emptyMap());//数据集
empty.add(Collections.<String, TableDataWrapper>emptyMap());//服务器数据集
empty.add(Collections.<String, TableDataWrapper>emptyMap());//存储过程
return empty;
}
/**
* ButtonEnabled intercept
* @return interceptbuttonEnabled
*/
@Override
public boolean interceptButtonEnabled() {
return tc == null;
}
/**
* 移除名字是name的TableData
* @param name tabledata name
*/
public void removeAction(String name) {
if (tc != null) {
TableDataSource tds = tc.getBook();
tds.removeTableData(name);
tc.fireTargetModified();
}
}
private ExpandMutableTreeNode[] getNodeArrayFromMap(Map<String, TableDataWrapper> map) {
List<ExpandMutableTreeNode> dataList = new ArrayList<ExpandMutableTreeNode>();
Iterator<Entry<String, TableDataWrapper>> entryIt = map.entrySet().iterator();
while (entryIt.hasNext()) {
Entry<String, TableDataWrapper> entry = entryIt.next();
String name = entry.getKey();
TableDataWrapper t = entry.getValue();
ExpandMutableTreeNode newChildTreeNode = new ExpandMutableTreeNode(new NameObject(name, t));
dataList.add(newChildTreeNode);
newChildTreeNode.add(new ExpandMutableTreeNode());
}
return dataList.toArray(new ExpandMutableTreeNode[dataList.size()]);
}
private ExpandMutableTreeNode initTemplateDataNode(Map<String, TableDataWrapper> templateDataMap) {
ExpandMutableTreeNode templateNode = new ExpandMutableTreeNode(new NameObject(Inter.getLocText("DS-TableData"), TEMPLATE_TABLE_DATA), true);
templateNode.addChildTreeNodes(getNodeArrayFromMap(templateDataMap));
return templateNode;
}
private ExpandMutableTreeNode initServerDataNode(Map<String, TableDataWrapper> serverDataMap) {
ExpandMutableTreeNode templateNode = new ExpandMutableTreeNode(new NameObject(Inter.getLocText("DS-Server_TableData"), SERVER_TABLE_DATA), false);
templateNode.addChildTreeNodes(getNodeArrayFromMap(serverDataMap));
return templateNode;
}
private ExpandMutableTreeNode initStoreProcedureNode(Map<String, TableDataWrapper> storeProcedureMap) {
ExpandMutableTreeNode templateNode = new ExpandMutableTreeNode(new NameObject(Inter.getLocText("Datasource-Stored_Procedure"), STORE_PRECEDURE_DATA), false);
templateNode.addChildTreeNodes(getNodeArrayFromMap(storeProcedureMap));
return templateNode;
}
/**
* 根据不同模式生成子节点
*
* @return
*/
@Override
public ExpandMutableTreeNode[] load() {
Map<String, TableDataWrapper> templateDataMap = null;
Map<String, TableDataWrapper> serverDataMap = null;
Map<String, TableDataWrapper> storeProcedureMap = null;
if (this != null) {
templateDataMap = this.init().get(0);
serverDataMap = this.init().get(1);
storeProcedureMap = this.init().get(2);
} else {
templateDataMap = Collections.emptyMap();
serverDataMap = Collections.emptyMap();
storeProcedureMap = Collections.emptyMap();
}
List<ExpandMutableTreeNode> list = new ArrayList<ExpandMutableTreeNode>(); //所有的数据集
List<ExpandMutableTreeNode> templist = new ArrayList<ExpandMutableTreeNode>(); //模板数据集
List<ExpandMutableTreeNode> serverlist = new ArrayList<ExpandMutableTreeNode>(); //服务器数据集
list.add(initTemplateDataNode(templateDataMap));
addNodeToList(templateDataMap, templist);
if (!serverDataMap.isEmpty()) {
list.add(initServerDataNode(serverDataMap));
addNodeToList(serverDataMap, serverlist);
}
if (!storeProcedureMap.isEmpty()) {
list.add(initStoreProcedureNode(storeProcedureMap));
for (int i = 0; i < getNodeArrayFromMap(storeProcedureMap).length; i++) {
ExpandMutableTreeNode tmpNode = getNodeArrayFromMap(storeProcedureMap)[i];
if (((NameObject) tmpNode.getUserObject()).getObject() instanceof StoreProcedureNameWrapper) {
TableData tableData = ((StoreProcedureNameWrapper) (((NameObject) tmpNode.getUserObject()).getObject())).getStoreProcedure();
setStoreProcedureTree(tableData, tmpNode);
serverlist.add(tmpNode);
}
}
}
switch (dataMode) {
case TEMPLATE_TABLE_DATA:
return templist.toArray(new ExpandMutableTreeNode[templist.size()]);
case SERVER_TABLE_DATA:
return serverlist.toArray(new ExpandMutableTreeNode[serverlist.size()]);
default:
return list.toArray(new ExpandMutableTreeNode[list.size()]);
}
}
private void addNodeToList(Map<String, TableDataWrapper> dataMap, List<ExpandMutableTreeNode> dataList) {
for (int i = 0; i < getNodeArrayFromMap(dataMap).length; i++) {
ExpandMutableTreeNode tmpNode = getNodeArrayFromMap(dataMap)[i];
TableData tableData = ((TableDataWrapper) (((NameObject) tmpNode.getUserObject()).getObject())).getTableData();
if (tableData instanceof StoreProcedure) {
setStoreProcedureTree(tableData, tmpNode);
dataList.add(tmpNode);
} else {
dataList.add(tmpNode);
}
}
}
private void setStoreProcedureTree(TableData tableData, ExpandMutableTreeNode tmpNode) {
ArrayList<String> nodeName = new ArrayList<String>();
StoreProcedure storeProcedure = (StoreProcedure) tableData;
String name = ((NameObject) tmpNode.getUserObject()).getName();
StoreProcedureParameter[] parameters = StoreProcedure.getSortPara(storeProcedure.getParameters());
ArrayList<String> resultNames = storeProcedure.getResultNames();
boolean hasChild = false;
tmpNode.remove(0);
TableDataWrapper tdw = new StoreProcedureNameWrapper(name + "_Table1", storeProcedure);
ExpandMutableTreeNode childNode = new ExpandMutableTreeNode(new NameObject("Table", tdw));
childNode.add(new ExpandMutableTreeNode());
tmpNode.add(childNode);
for (StoreProcedureParameter parameter : parameters) {
if (parameter.getSchema() != StoreProcedureConstants.IN) {
if (!nodeName.contains(parameter.getName())) {
nodeName.add(parameter.getName());
hasChild = true;
String parameterName = name + "_" + parameter.getName();
TableDataWrapper newTwd = new StoreProcedureDataWrapper(storeProcedure, name, parameterName, false);
ExpandMutableTreeNode newChildNode = new ExpandMutableTreeNode(new NameObject(parameter.getName(), newTwd));
newChildNode.add(new ExpandMutableTreeNode());
tmpNode.add(newChildNode);
}
}
}
if (!resultNames.isEmpty()) {
for (int i = 0; i < resultNames.size(); i++) {
if (!nodeName.contains(resultNames.get(i))) {
nodeName.add(resultNames.get(i));
hasChild = true;
String parameterName = name + "_" + resultNames.get(i);
TableDataWrapper newTwd = new StoreProcedureDataWrapper(storeProcedure, name, parameterName, false);
ExpandMutableTreeNode newChildNode = new ExpandMutableTreeNode(new NameObject(resultNames.get(i), newTwd));
newChildNode.add(new ExpandMutableTreeNode());
tmpNode.add(newChildNode);
}
}
}
if (hasChild) {
tmpNode.remove(0);
}
}
protected void setDataMode(int i) {
this.dataMode = i;
}
protected int getDataMode() {
return dataMode;
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save