Browse Source

Pull request #1803: 无jira任务, release/10.0 合 bugfix/10.0

Merge in DESIGN/design from release/10.0 to bugfix/10.0

* commit 'cbe384f48f1c71cb927cea1518de63c63ef0c815': (63 commits)
  CHART-14541 轴标题增加缩进
  REPORT-34020 【国际化】非简中设计器-界面右侧面板选择超链接或悬浮元素后下拉框溢出
  CHART-14120 英文设计器地图数据面板截断
  REPORT-33236
  REPORT-31546 公式面板的说明切换偶尔会失效
  REPORT-34351 ""改为StringUtils.EMPTY
  REPORT-33500 日志面板清除日志后同时清除设计器右上角日志提示信息
  REPORT-35016【组件生成】目前生成的组件,从组件库拖入模板中会变大 [场景] 从组件库拖入时,不会保持原有的大小。 [解决方案] 将原来的大小,在创建时一并初始化
  CHART-14346
  CHART-14346 悬浮窗图表组合图不允许选择单元格数据源
  REPORT-34954 富文本上标下标不应该可以同时设置
  REPORT-34954 富文本上标下标可以同时设置
  CHART-14180  优化代码
  CHART-14346 && CHART-14180  悬浮图表配置组合图不能选择单元格数据源 && 轴标题隐藏优化
  REPORT-34385 修改联网搜索的enable条件
  REPORT-34351 修正FineJOptionPane组件showInputDialog()方法点击弹出框的取消键后的行为;在组件重命名后将与自己的原来的名字进行对比的情况去除
  REPORT-34385 enabled4Locale与isSearchOnLine条件合并
  REPORT-34385 在alphafine设置窗口打开的时候,将联网搜索状态与几个相关选项的状态进行关联
  REPORT-29573 【国际化】插件管理类别、场景部分仍显示中文
  REPORT-34222 报表设计器给容器插件开个复制粘贴的接口 改下参数
  ...
bugfix/10.0
ju.ju 4 years ago
parent
commit
1604f2b76f
  1. 34
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java
  2. 719
      designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java
  3. 6
      designer-base/src/main/java/com/fr/design/dialog/FineJOptionPane.java
  4. 20
      designer-base/src/main/java/com/fr/design/extra/exe/GetPluginCategoriesExecutor.java
  5. 83
      designer-base/src/main/java/com/fr/design/formula/FormulaPane.java
  6. 25
      designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfo.java
  7. 17
      designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java
  8. 1
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBar.java
  9. 6
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogMessageBar.java
  10. 6
      designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java
  11. 1
      designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java
  12. 15
      designer-chart/src/main/java/com/fr/design/chart/AutoChartDialog.java
  13. 2
      designer-chart/src/main/java/com/fr/design/chart/AutoChartIcon.java
  14. 122
      designer-chart/src/main/java/com/fr/design/chart/AutoChartTypePane.java
  15. 18
      designer-chart/src/main/java/com/fr/design/chart/ChartDialog.java
  16. 143
      designer-chart/src/main/java/com/fr/design/chart/auto/AutoTypeCalculate.java
  17. 26
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java
  18. 1
      designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomDataPane.java
  19. 75
      designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotDataContentsTabPane.java
  20. 262
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java
  21. 8
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartTimeAxisPane.java
  22. 2
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartValueAxisPane.java
  23. 12
      designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/table/VanPointMapPlotTableDataContentPane.java
  24. 2
      designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java
  25. 61
      designer-form/src/main/java/com/fr/design/mainframe/ShareWidgetButton.java
  26. 38
      designer-form/src/test/java/com/fr/design/mainframe/ShareWidgetButtonTest.java
  27. 10
      designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java
  28. 2
      designer-realize/src/main/java/com/fr/design/mainframe/SheetNameTabPane.java
  29. 19
      designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellFormulaQuickEditor.java

34
designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java

@ -189,34 +189,34 @@ public class AlphaFineConfigPane extends BasicPane {
} }
public void populate(AlphaFineConfigManager alphaFineConfigManager) { public void populate(AlphaFineConfigManager alphaFineConfigManager) {
this.enabledCheckbox.setSelected(alphaFineConfigManager.isEnabled()); this.enabledCheckbox.setSelected(alphaFineConfigManager.isEnabled());
boolean enabled4Locale = FRContext.isChineseEnv(); boolean enabled4Locale = FRContext.isChineseEnv() && alphaFineConfigManager.isSearchOnLine();
this.searchOnlineCheckbox.setEnabled(enabled4Locale); this.searchOnlineCheckbox.setEnabled(FRContext.isChineseEnv());
this.searchOnlineCheckbox.setSelected(alphaFineConfigManager.isSearchOnLine()); this.searchOnlineCheckbox.setSelected(enabled4Locale);
this.containActionCheckbox.setSelected(alphaFineConfigManager.isContainAction()); this.containActionCheckbox.setSelected(alphaFineConfigManager.isContainAction());
this.containTemplateCheckbox.setSelected(alphaFineConfigManager.isContainTemplate()); this.containTemplateCheckbox.setSelected(alphaFineConfigManager.isContainTemplate());
this.containFileContentCheckbox.setSelected(alphaFineConfigManager.isContainFileContent()); this.containFileContentCheckbox.setSelected(alphaFineConfigManager.isContainFileContent());
this.containDocumentCheckbox.setSelected(alphaFineConfigManager.isContainDocument() && alphaFineConfigManager.isSearchOnLine()); this.containDocumentCheckbox.setSelected(alphaFineConfigManager.isContainDocument() && enabled4Locale);
this.containDocumentCheckbox.setEnabled(enabled4Locale); this.containDocumentCheckbox.setEnabled(enabled4Locale);
this.containPluginCheckbox.setSelected(alphaFineConfigManager.isContainPlugin() && alphaFineConfigManager.isSearchOnLine()); this.containPluginCheckbox.setSelected(alphaFineConfigManager.isContainPlugin() && enabled4Locale);
this.containPluginCheckbox.setEnabled(enabled4Locale); this.containPluginCheckbox.setEnabled(enabled4Locale);
this.containRecommendCheckbox.setSelected(alphaFineConfigManager.isContainRecommend() && alphaFineConfigManager.isSearchOnLine()); this.containRecommendCheckbox.setSelected(alphaFineConfigManager.isContainRecommend() && enabled4Locale);
this.containRecommendCheckbox.setEnabled(enabled4Locale); this.containRecommendCheckbox.setEnabled(enabled4Locale);
this.shortcutsField.setText(getDisplayShortCut(alphaFineConfigManager.getShortcuts())); this.shortcutsField.setText(getDisplayShortCut(alphaFineConfigManager.getShortcuts()));
this.needSegmentationCheckbox.setSelected(alphaFineConfigManager.isNeedSegmentationCheckbox()); this.needSegmentationCheckbox.setSelected(alphaFineConfigManager.isNeedSegmentationCheckbox());
this.needIntelligentCustomerService.setSelected(alphaFineConfigManager.isNeedIntelligentCustomerService() && alphaFineConfigManager.isSearchOnLine()); this.needIntelligentCustomerService.setSelected(alphaFineConfigManager.isNeedIntelligentCustomerService() && enabled4Locale);
this.needIntelligentCustomerService.setEnabled(enabled4Locale); this.needIntelligentCustomerService.setEnabled(enabled4Locale);
shortCutKeyStore = convert2KeyStroke(alphaFineConfigManager.getShortcuts()); shortCutKeyStore = convert2KeyStroke(alphaFineConfigManager.getShortcuts());
} }

719
designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java

@ -1,5 +1,6 @@
package com.fr.design.data.datapane.connect; package com.fr.design.data.datapane.connect;
import com.fr.base.GraphHelper;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.data.impl.JDBCDatabaseConnection; import com.fr.data.impl.JDBCDatabaseConnection;
import com.fr.data.pool.DBCPConnectionPoolAttr; import com.fr.data.pool.DBCPConnectionPoolAttr;
@ -16,7 +17,9 @@ import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.editor.editor.IntegerEditor; import com.fr.design.editor.editor.IntegerEditor;
import com.fr.design.utils.BrowseUtils;
import com.fr.file.filter.ChooseFileFilter; import com.fr.file.filter.ChooseFileFilter;
import com.fr.general.CloudCenter;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -32,351 +35,375 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
public class JDBCDefPane extends JPanel { public class JDBCDefPane extends JPanel {
public static final String DRIVER_TYPE = "driver_type"; public static final String DRIVER_TYPE = "driver_type";
public static final String USER_NAME = "user_name"; public static final String USER_NAME = "user_name";
public static final int TIME_MULTIPLE = 1000; public static final int TIME_MULTIPLE = 1000;
private static final String OTHER_DB = "Others"; private static final String OTHER_DB = "Others";
private static Map<String, DriverURLName[]> jdbcMap = new HashMap<String, DriverURLName[]>(); private static Map<String, DriverURLName[]> jdbcMap = new HashMap<String, DriverURLName[]>();
static { static {
jdbcMap.put(OTHER_DB, new DriverURLName[]{new DriverURLName("sun.jdbc.odbc.JdbcOdbcDriver", "jdbc:odbc:"), jdbcMap.put(OTHER_DB, new DriverURLName[]{new DriverURLName("sun.jdbc.odbc.JdbcOdbcDriver", "jdbc:odbc:"),
new DriverURLName("org.hsqldb.jdbcDriver", "jdbc:hsqldb:file:[PATH_TO_DB_FILES]"), new DriverURLName("com.inet.tds.TdsDriver", "jdbc:inetdae7:localhost:1433/"), new DriverURLName("org.hsqldb.jdbcDriver", "jdbc:hsqldb:file:[PATH_TO_DB_FILES]"), new DriverURLName("com.inet.tds.TdsDriver", "jdbc:inetdae7:localhost:1433/"),
new DriverURLName("COM.cloudscape.JDBCDriver", "jdbc:cloudscape:/cloudscape/"), new DriverURLName("COM.cloudscape.JDBCDriver", "jdbc:cloudscape:/cloudscape/"),
new DriverURLName("com.internetcds.jdbc.tds.Driver", "jdbc:freetds:sqlserver://localhost/"), new DriverURLName("com.internetcds.jdbc.tds.Driver", "jdbc:freetds:sqlserver://localhost/"),
new DriverURLName("com.fr.swift.jdbc.Driver", "jdbc:swift:emb://default")}); new DriverURLName("com.fr.swift.jdbc.Driver", "jdbc:swift:emb://default")});
jdbcMap.put("Inceptor",new DriverURLName[]{new DriverURLName("org.apache.hive.jdbc.HiveDriver","jdbc:inceptor2://localhost:10000/default"), jdbcMap.put("Inceptor", new DriverURLName[]{new DriverURLName("org.apache.hive.jdbc.HiveDriver", "jdbc:inceptor2://localhost:10000/default"),
new DriverURLName("org.apache.hadoop.hive.jdbc.HiveDriver","jdbc:inceptor://localhost:10000/default")}); new DriverURLName("org.apache.hadoop.hive.jdbc.HiveDriver", "jdbc:inceptor://localhost:10000/default")});
jdbcMap.put("Oracle", new DriverURLName[]{new DriverURLName("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@localhost:1521:databaseName")}); jdbcMap.put("Oracle", new DriverURLName[]{new DriverURLName("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@localhost:1521:databaseName")});
jdbcMap.put("DB2", new DriverURLName[]{new DriverURLName("com.ibm.db2.jcc.DB2Driver", "jdbc:db2://localhost:50000/")}); jdbcMap.put("DB2", new DriverURLName[]{new DriverURLName("com.ibm.db2.jcc.DB2Driver", "jdbc:db2://localhost:50000/")});
jdbcMap.put("SQL Server", new DriverURLName[]{new DriverURLName("com.microsoft.sqlserver.jdbc.SQLServerDriver", "jdbc:sqlserver://localhost:1433;" + "databaseName=")}); jdbcMap.put("SQL Server", new DriverURLName[]{new DriverURLName("com.microsoft.sqlserver.jdbc.SQLServerDriver", "jdbc:sqlserver://localhost:1433;" + "databaseName=")});
jdbcMap.put("MySQL", new DriverURLName[]{new DriverURLName("com.mysql.jdbc.Driver", "jdbc:mysql://localhost/"), jdbcMap.put("MySQL", new DriverURLName[]{new DriverURLName("com.mysql.jdbc.Driver", "jdbc:mysql://localhost/"),
new DriverURLName("org.gjt.mm.mysql.Driver", "jdbc:mysql://localhost/")}); new DriverURLName("org.gjt.mm.mysql.Driver", "jdbc:mysql://localhost/")});
jdbcMap.put("Sybase", new DriverURLName[]{new DriverURLName("com.sybase.jdbc2.jdbc.SybDriver", "jdbc:sybase:Tds:localhost:5000/")}); jdbcMap.put("Sybase", new DriverURLName[]{new DriverURLName("com.sybase.jdbc2.jdbc.SybDriver", "jdbc:sybase:Tds:localhost:5000/")});
jdbcMap.put("Access", new DriverURLName[]{new DriverURLName("sun.jdbc.odbc.JdbcOdbcDriver", "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=")}); jdbcMap.put("Access", new DriverURLName[]{new DriverURLName("sun.jdbc.odbc.JdbcOdbcDriver", "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=")});
jdbcMap.put("Derby", new DriverURLName[]{new DriverURLName("org.apache.derby.jdbc.ClientDriver", "jdbc:derby://localhost:1527/")}); jdbcMap.put("Derby", new DriverURLName[]{new DriverURLName("org.apache.derby.jdbc.ClientDriver", "jdbc:derby://localhost:1527/")});
jdbcMap.put("Postgre", new DriverURLName[]{new DriverURLName("org.postgresql.Driver", "jdbc:postgresql://localhost:5432/")}); jdbcMap.put("Postgre", new DriverURLName[]{new DriverURLName("org.postgresql.Driver", "jdbc:postgresql://localhost:5432/")});
jdbcMap.put("SQLite", new DriverURLName[]{new DriverURLName("org.sqlite.JDBC", "jdbc:sqlite://${ENV_HOME}/../help/FRDemo.db")}); jdbcMap.put("SQLite", new DriverURLName[]{new DriverURLName("org.sqlite.JDBC", "jdbc:sqlite://${ENV_HOME}/../help/FRDemo.db")});
} }
private UIButton dbtypeButton; private UIButton dbtypeButton;
private UIComboBox dbtypeComboBox; private UIComboBox dbtypeComboBox;
private UIComboBox driverComboBox; private UIComboBox driverComboBox;
private UITextField urlTextField; private UITextField urlTextField;
private UITextField userNameTextField; private UITextField userNameTextField;
private JPasswordField passwordTextField; private JPasswordField passwordTextField;
// 请不要改动dbtype,只应该最后添加 private ActionLabel odbcTipsLink;
private final String[] dbtype = {"Oracle", "DB2", "SQL Server", "MySQL", "Sybase", "Access", "Derby", "Postgre","SQLite","Inceptor", OTHER_DB}; // 请不要改动dbtype,只应该最后添加
private final String[] dbtype = {"Oracle", "DB2", "SQL Server", "MySQL", "Sybase", "Access", "Derby", "Postgre", "SQLite", "Inceptor", OTHER_DB};
// carl:DBCP的一些属性
private IntegerEditor DBCP_INITIAL_SIZE = new IntegerEditor(); // carl:DBCP的一些属性
private IntegerEditor DBCP_MAX_ACTIVE = new IntegerEditor(); private IntegerEditor DBCP_INITIAL_SIZE = new IntegerEditor();
private IntegerEditor DBCP_MAX_IDLE = new IntegerEditor(); private IntegerEditor DBCP_MAX_ACTIVE = new IntegerEditor();
private IntegerEditor DBCP_MIN_IDLE = new IntegerEditor(); private IntegerEditor DBCP_MAX_IDLE = new IntegerEditor();
private IntegerEditor DBCP_MAX_WAIT = new IntegerEditor(); private IntegerEditor DBCP_MIN_IDLE = new IntegerEditor();
private UITextField DBCP_VALIDATION_QUERY = new UITextField(); private IntegerEditor DBCP_MAX_WAIT = new IntegerEditor();
private UITextField DBCP_VALIDATION_QUERY = new UITextField();
private UIComboBox DBCP_TESTONBORROW = new UIComboBox(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_No"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Yes")});
private UIComboBox DBCP_TESTONRETURN = new UIComboBox(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_No"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Yes")}); private UIComboBox DBCP_TESTONBORROW = new UIComboBox(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_No"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Yes")});
private UIComboBox DBCP_TESTWHILEIDLE = new UIComboBox(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_No"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Yes")}); private UIComboBox DBCP_TESTONRETURN = new UIComboBox(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_No"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Yes")});
private UIComboBox DBCP_TESTWHILEIDLE = new UIComboBox(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_No"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Yes")});
private IntegerEditor DBCP_TIMEBETWEENEVICTIONRUNSMILLS = new IntegerEditor();
private IntegerEditor DBCP_NUMTESTSPEREVICTIONRUN = new IntegerEditor(); private IntegerEditor DBCP_TIMEBETWEENEVICTIONRUNSMILLS = new IntegerEditor();
private IntegerEditor DBCP_MINEVICTABLEIDLETIMEMILLIS = new IntegerEditor(); private IntegerEditor DBCP_NUMTESTSPEREVICTIONRUN = new IntegerEditor();
private IntegerEditor DBCP_MINEVICTABLEIDLETIMEMILLIS = new IntegerEditor();
public JDBCDefPane() {
this.setBorder(UITitledBorder.createBorderWithTitle("JDBC" + ":")); public JDBCDefPane() {
this.setLayout(FRGUIPaneFactory.createLabelFlowLayout()); this.setBorder(UITitledBorder.createBorderWithTitle("JDBC" + ":"));
JPanel innerthis = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); this.setLayout(FRGUIPaneFactory.createLabelFlowLayout());
innerthis.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); JPanel innerthis = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
this.add(innerthis); innerthis.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
dbtypeComboBox = new UIComboBox(); this.add(innerthis);
dbtypeComboBox.setName(DRIVER_TYPE); dbtypeComboBox = new UIComboBox();
for (int i = 0; i < dbtype.length; i++) { dbtypeComboBox.setName(DRIVER_TYPE);
dbtypeComboBox.addItem(dbtype[i]); for (int i = 0; i < dbtype.length; i++) {
} dbtypeComboBox.addItem(dbtype[i]);
dbtypeComboBox.addActionListener(dbtypeActionListener); }
dbtypeComboBox.setMaximumRowCount(10); dbtypeComboBox.addActionListener(dbtypeActionListener);
dbtypeComboBox.setMaximumRowCount(10);
driverComboBox = new UIComboBox();
driverComboBox.setEditable(true); driverComboBox = new UIComboBox();
driverComboBox.addActionListener(driverListener); driverComboBox.setEditable(true);
urlTextField = new UITextField(15); driverComboBox.addActionListener(driverListener);
userNameTextField = new UITextField(15); urlTextField = new UITextField(15);
userNameTextField.setName(USER_NAME); userNameTextField = new UITextField(15);
passwordTextField = new UIPassWordField(15); userNameTextField.setName(USER_NAME);
dbtypeButton = new UIButton("."); passwordTextField = new UIPassWordField(15);
dbtypeButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Click_Get_Default_URL")); dbtypeButton = new UIButton(".");
dbtypeButton.addActionListener(dbtypeButtonActionListener); dbtypeButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Click_Get_Default_URL"));
dbtypeButton.addActionListener(dbtypeButtonActionListener);
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double p = TableLayout.PREFERRED;
JPanel dbtypePane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); double f = TableLayout.FILL;
dbtypePane.add(new UILabel((com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database") + ":"))); JPanel dbtypePane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
JPanel dbtypeComPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); dbtypePane.add(new UILabel((com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database") + ":")));
Component[][] dbtypeComComponents = {{dbtypeComboBox}}; JPanel dbtypeComPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
double[] dbtypeRowSize = {p}; Component[][] dbtypeComComponents = {{dbtypeComboBox}};
double[] dbtypeColumnSize = {p}; double[] dbtypeRowSize = {p};
dbtypeComPane = TableLayoutHelper.createTableLayoutPane(dbtypeComComponents, dbtypeRowSize, dbtypeColumnSize); double[] dbtypeColumnSize = {p};
dbtypeComPane = TableLayoutHelper.createTableLayoutPane(dbtypeComComponents, dbtypeRowSize, dbtypeColumnSize);
JPanel driverPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
driverPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Driver") + ":")); JPanel driverPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
driverPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Driver") + ":"));
JPanel urlPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); // 选择ODBC数据源的时候的提示链接
urlPane.add(new UILabel("URL:")); JPanel odbcTipsPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
JPanel urlComPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); odbcTipsLink = new ActionLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Odbc_Tips")) {
Component[][] urlComComponents = {{urlTextField, dbtypeButton}}; @Override
double[] urlRowSize = {p}; public void paintComponent(Graphics _gfx) {
double[] urlColumnSize = {f, 21}; super.paintComponent(_gfx);
urlComPane = TableLayoutHelper.createCommonTableLayoutPane(urlComComponents, urlRowSize, urlColumnSize, 4); _gfx.setColor(Color.blue);
_gfx.drawLine(0, this.getHeight() - 1, GraphHelper.getWidth(this.getText()), this.getHeight() - 1);
JPanel userPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); }
userPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_UserName") + ":")); };
JPanel userComPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); odbcTipsPane.add(odbcTipsLink);
Component[][] userComComponents = {{userNameTextField, new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Password") + ":"), passwordTextField}}; odbcTipsLink.setPreferredSize(new Dimension(GraphHelper.getWidth(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Odbc_Tips")), odbcTipsLink.getPreferredSize().height));
double[] userRowSize = {p}; odbcTipsLink.addActionListener(new ActionListener() {
double[] userColumnSize = {f, p, f}; public void actionPerformed(ActionEvent evt) {
userComPane = TableLayoutHelper.createCommonTableLayoutPane(userComComponents, userRowSize, userColumnSize, 4); String url = CloudCenter.getInstance().acquireUrlByKind("odbc.help");
BrowseUtils.browser(url);
JPanel passwordPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); }
passwordPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Password") + ":")); });
Component[][] components = {{dbtypePane, dbtypeComPane}, {driverPane, driverComboBox}, {urlPane, urlComPane}, {userPane, userComPane},}; JPanel driverComboBoxAndTips = new JPanel(new BorderLayout());
driverComboBoxAndTips.add(driverComboBox, BorderLayout.WEST);
double[] rowSize = {p, p, p, p}; driverComboBoxAndTips.add(odbcTipsPane, BorderLayout.CENTER);
double[] columnSize = {p, f, 22};
JPanel centerPanel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 6); JPanel urlPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
innerthis.add(centerPanel); urlPane.add(new UILabel("URL:"));
JPanel southPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel urlComPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
innerthis.add(southPanel); Component[][] urlComComponents = {{urlTextField, dbtypeButton}};
southPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 4, 20)); double[] urlRowSize = {p};
ActionLabel actionLabel = new ActionLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_ConnectionPool_Attr")); double[] urlColumnSize = {f, 21};
southPanel.add(actionLabel, BorderLayout.EAST); urlComPane = TableLayoutHelper.createCommonTableLayoutPane(urlComComponents, urlRowSize, urlColumnSize, 4);
actionLabel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) { JPanel userPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
JDialog wDialog = createJDialog(); userPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_UserName") + ":"));
wDialog.setVisible(true); JPanel userComPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
} Component[][] userComComponents = {{userNameTextField, new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Password") + ":"), passwordTextField}};
}); double[] userRowSize = {p};
} double[] userColumnSize = {f, p, f};
userComPane = TableLayoutHelper.createCommonTableLayoutPane(userComComponents, userRowSize, userColumnSize, 4);
public void populate(JDBCDatabaseConnection jdbcDatabase) {
if (jdbcDatabase == null) { JPanel passwordPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
jdbcDatabase = new JDBCDatabaseConnection(); passwordPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Password") + ":"));
}
if (ComparatorUtils.equals(jdbcDatabase.getDriver(), "sun.jdbc.odbc.JdbcOdbcDriver") Component[][] components = {{dbtypePane, dbtypeComPane}, {driverPane, driverComboBoxAndTips}, {urlPane, urlComPane}, {userPane, userComPane},};
&& jdbcDatabase.getURL().startsWith("jdbc:odbc:Driver={Microsoft")) {
this.dbtypeComboBox.setSelectedItem("Access"); double[] rowSize = {p, p, p, p};
} else { double[] columnSize = {p, f, 22};
Iterator<Entry<String, DriverURLName[]>> jdbc = jdbcMap.entrySet().iterator(); JPanel centerPanel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 6);
boolean out = false; innerthis.add(centerPanel);
while (jdbc.hasNext()) { JPanel southPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
Entry<String, DriverURLName[]> entry = jdbc.next(); innerthis.add(southPanel);
DriverURLName[] dus = entry.getValue(); southPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 4, 20));
for (int i = 0, len = dus.length; i < len; i++) { ActionLabel actionLabel = new ActionLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_ConnectionPool_Attr"));
if (ComparatorUtils.equals(dus[i].getDriver(), jdbcDatabase.getDriver())) { southPanel.add(actionLabel, BorderLayout.EAST);
this.dbtypeComboBox.setSelectedItem(entry.getKey()); actionLabel.addActionListener(new ActionListener() {
out = true; public void actionPerformed(ActionEvent evt) {
break; JDialog wDialog = createJDialog();
} wDialog.setVisible(true);
} }
if (out) { });
break; }
}
} public void populate(JDBCDatabaseConnection jdbcDatabase) {
if (!out) { if (jdbcDatabase == null) {
this.dbtypeComboBox.setSelectedItem(OTHER_DB); jdbcDatabase = new JDBCDatabaseConnection();
} }
} if (ComparatorUtils.equals(jdbcDatabase.getDriver(), "sun.jdbc.odbc.JdbcOdbcDriver")
this.driverComboBox.setSelectedItem(jdbcDatabase.getDriver()); && jdbcDatabase.getURL().startsWith("jdbc:odbc:Driver={Microsoft")) {
this.urlTextField.setText(jdbcDatabase.getURL()); this.dbtypeComboBox.setSelectedItem("Access");
this.userNameTextField.setText(jdbcDatabase.getUser()); } else {
this.passwordTextField.setText(jdbcDatabase.getPassword()); Iterator<Entry<String, DriverURLName[]>> jdbc = jdbcMap.entrySet().iterator();
boolean out = false;
DBCPConnectionPoolAttr dbcpAttr = jdbcDatabase.getDbcpAttr(); while (jdbc.hasNext()) {
if (dbcpAttr == null) { Entry<String, DriverURLName[]> entry = jdbc.next();
dbcpAttr = new DBCPConnectionPoolAttr(); DriverURLName[] dus = entry.getValue();
jdbcDatabase.setDbcpAttr(dbcpAttr); for (int i = 0, len = dus.length; i < len; i++) {
} if (ComparatorUtils.equals(dus[i].getDriver(), jdbcDatabase.getDriver())) {
this.DBCP_INITIAL_SIZE.setValue(dbcpAttr.getInitialSize()); this.dbtypeComboBox.setSelectedItem(entry.getKey());
this.DBCP_MAX_ACTIVE.setValue(dbcpAttr.getMaxActive()); out = true;
this.DBCP_MAX_IDLE.setValue(dbcpAttr.getMaxIdle()); break;
this.DBCP_MAX_WAIT.setValue(dbcpAttr.getMaxWait()); }
this.DBCP_MIN_IDLE.setValue(dbcpAttr.getMinIdle()); }
this.DBCP_VALIDATION_QUERY.setText(dbcpAttr.getValidationQuery()); if (out) {
this.DBCP_TESTONBORROW.setSelectedIndex(dbcpAttr.isTestOnBorrow() ? 1 : 0); break;
this.DBCP_TESTONRETURN.setSelectedIndex(dbcpAttr.isTestOnReturn() ? 1 : 0); }
this.DBCP_TESTWHILEIDLE.setSelectedIndex(dbcpAttr.isTestWhileIdle() ? 1 : 0); }
this.DBCP_MINEVICTABLEIDLETIMEMILLIS.setValue(dbcpAttr.getMinEvictableIdleTimeMillis() / TIME_MULTIPLE); if (!out) {
this.DBCP_NUMTESTSPEREVICTIONRUN.setValue(dbcpAttr.getNumTestsPerEvictionRun()); this.dbtypeComboBox.setSelectedItem(OTHER_DB);
this.DBCP_TIMEBETWEENEVICTIONRUNSMILLS.setValue(dbcpAttr.getTimeBetweenEvictionRunsMillis()); }
} }
this.driverComboBox.setSelectedItem(jdbcDatabase.getDriver());
public JDBCDatabaseConnection update() { this.urlTextField.setText(jdbcDatabase.getURL());
JDBCDatabaseConnection jdbcDatabase = new JDBCDatabaseConnection(); this.userNameTextField.setText(jdbcDatabase.getUser());
Object driveItem = this.driverComboBox.getSelectedItem(); this.passwordTextField.setText(jdbcDatabase.getPassword());
jdbcDatabase.setDriver(driveItem == null ? null : driveItem.toString());
jdbcDatabase.setURL(this.urlTextField.getText().trim()); DBCPConnectionPoolAttr dbcpAttr = jdbcDatabase.getDbcpAttr();
jdbcDatabase.setUser(this.userNameTextField.getText().trim()); if (dbcpAttr == null) {
jdbcDatabase.setPassword(new String(this.passwordTextField.getPassword()).trim()); dbcpAttr = new DBCPConnectionPoolAttr();
jdbcDatabase.setDbcpAttr(dbcpAttr);
DBCPConnectionPoolAttr dbcpAttr = jdbcDatabase.getDbcpAttr(); }
if (dbcpAttr == null) { this.DBCP_INITIAL_SIZE.setValue(dbcpAttr.getInitialSize());
dbcpAttr = new DBCPConnectionPoolAttr(); this.DBCP_MAX_ACTIVE.setValue(dbcpAttr.getMaxActive());
jdbcDatabase.setDbcpAttr(dbcpAttr); this.DBCP_MAX_IDLE.setValue(dbcpAttr.getMaxIdle());
} this.DBCP_MAX_WAIT.setValue(dbcpAttr.getMaxWait());
dbcpAttr.setInitialSize(this.DBCP_INITIAL_SIZE.getValue().intValue()); this.DBCP_MIN_IDLE.setValue(dbcpAttr.getMinIdle());
dbcpAttr.setMaxActive(this.DBCP_MAX_ACTIVE.getValue().intValue()); this.DBCP_VALIDATION_QUERY.setText(dbcpAttr.getValidationQuery());
dbcpAttr.setMaxIdle(this.DBCP_MAX_IDLE.getValue().intValue()); this.DBCP_TESTONBORROW.setSelectedIndex(dbcpAttr.isTestOnBorrow() ? 1 : 0);
dbcpAttr.setMaxWait(this.DBCP_MAX_WAIT.getValue().intValue()); this.DBCP_TESTONRETURN.setSelectedIndex(dbcpAttr.isTestOnReturn() ? 1 : 0);
dbcpAttr.setMinIdle(this.DBCP_MIN_IDLE.getValue().intValue()); this.DBCP_TESTWHILEIDLE.setSelectedIndex(dbcpAttr.isTestWhileIdle() ? 1 : 0);
dbcpAttr.setValidationQuery(this.DBCP_VALIDATION_QUERY.getText()); this.DBCP_MINEVICTABLEIDLETIMEMILLIS.setValue(dbcpAttr.getMinEvictableIdleTimeMillis() / TIME_MULTIPLE);
dbcpAttr.setTestOnBorrow(this.DBCP_TESTONBORROW.getSelectedIndex() == 0 ? false : true); this.DBCP_NUMTESTSPEREVICTIONRUN.setValue(dbcpAttr.getNumTestsPerEvictionRun());
dbcpAttr.setTestOnReturn(this.DBCP_TESTONRETURN.getSelectedIndex() == 0 ? false : true); this.DBCP_TIMEBETWEENEVICTIONRUNSMILLS.setValue(dbcpAttr.getTimeBetweenEvictionRunsMillis());
dbcpAttr.setTestWhileIdle(this.DBCP_TESTWHILEIDLE.getSelectedIndex() == 0 ? false : true); }
dbcpAttr.setMinEvictableIdleTimeMillis(((Number) this.DBCP_MINEVICTABLEIDLETIMEMILLIS.getValue()).intValue() * TIME_MULTIPLE);
dbcpAttr.setNumTestsPerEvictionRun(((Number) this.DBCP_NUMTESTSPEREVICTIONRUN.getValue()).intValue()); public JDBCDatabaseConnection update() {
dbcpAttr.setTimeBetweenEvictionRunsMillis(((Number) this.DBCP_TIMEBETWEENEVICTIONRUNSMILLS.getValue()).intValue()); JDBCDatabaseConnection jdbcDatabase = new JDBCDatabaseConnection();
Object driveItem = this.driverComboBox.getSelectedItem();
return jdbcDatabase; jdbcDatabase.setDriver(driveItem == null ? null : driveItem.toString());
} jdbcDatabase.setURL(this.urlTextField.getText().trim());
jdbcDatabase.setUser(this.userNameTextField.getText().trim());
ActionListener dbtypeActionListener = new ActionListener() { jdbcDatabase.setPassword(new String(this.passwordTextField.getPassword()).trim());
public void actionPerformed(ActionEvent evt) {
DBCPConnectionPoolAttr dbcpAttr = jdbcDatabase.getDbcpAttr();
urlTextField.setText(StringUtils.EMPTY); if (dbcpAttr == null) {
driverComboBox.removeAllItems(); dbcpAttr = new DBCPConnectionPoolAttr();
if (ComparatorUtils.equals(dbtypeComboBox.getSelectedItem(), StringUtils.EMPTY)) { jdbcDatabase.setDbcpAttr(dbcpAttr);
driverComboBox.setSelectedItem(StringUtils.EMPTY); }
return; dbcpAttr.setInitialSize(this.DBCP_INITIAL_SIZE.getValue().intValue());
} dbcpAttr.setMaxActive(this.DBCP_MAX_ACTIVE.getValue().intValue());
dbcpAttr.setMaxIdle(this.DBCP_MAX_IDLE.getValue().intValue());
DriverURLName[] dus = jdbcMap.get(dbtypeComboBox.getSelectedItem()); dbcpAttr.setMaxWait(this.DBCP_MAX_WAIT.getValue().intValue());
for (int i = 0, len = dus.length; i < len; i++) { dbcpAttr.setMinIdle(this.DBCP_MIN_IDLE.getValue().intValue());
driverComboBox.addItem(dus[i].getDriver()); dbcpAttr.setValidationQuery(this.DBCP_VALIDATION_QUERY.getText());
if (i == 0) { dbcpAttr.setTestOnBorrow(this.DBCP_TESTONBORROW.getSelectedIndex() == 0 ? false : true);
driverComboBox.setSelectedItem(dus[i].getDriver()); dbcpAttr.setTestOnReturn(this.DBCP_TESTONRETURN.getSelectedIndex() == 0 ? false : true);
urlTextField.setText(dus[i].getURL()); dbcpAttr.setTestWhileIdle(this.DBCP_TESTWHILEIDLE.getSelectedIndex() == 0 ? false : true);
} dbcpAttr.setMinEvictableIdleTimeMillis(((Number) this.DBCP_MINEVICTABLEIDLETIMEMILLIS.getValue()).intValue() * TIME_MULTIPLE);
} dbcpAttr.setNumTestsPerEvictionRun(((Number) this.DBCP_NUMTESTSPEREVICTIONRUN.getValue()).intValue());
} dbcpAttr.setTimeBetweenEvictionRunsMillis(((Number) this.DBCP_TIMEBETWEENEVICTIONRUNSMILLS.getValue()).intValue());
};
return jdbcDatabase;
ActionListener driverListener = new ActionListener() { }
public void actionPerformed(ActionEvent e) {
if (driverComboBox.getSelectedItem() == null ||ComparatorUtils.equals(driverComboBox.getSelectedItem(), StringUtils.EMPTY)) { ActionListener dbtypeActionListener = new ActionListener() {
return; public void actionPerformed(ActionEvent evt) {
}
Iterator<Entry<String, DriverURLName[]>> jdbc = jdbcMap.entrySet().iterator(); urlTextField.setText(StringUtils.EMPTY);
while (jdbc.hasNext()) { driverComboBox.removeAllItems();
Entry<String, DriverURLName[]> entry = jdbc.next(); if (ComparatorUtils.equals(dbtypeComboBox.getSelectedItem(), StringUtils.EMPTY)) {
DriverURLName[] dus = entry.getValue(); driverComboBox.setSelectedItem(StringUtils.EMPTY);
for (int i = 0, len = dus.length; i < len; i++) { return;
if (ComparatorUtils.equals(dus[i].getDriver(), (driverComboBox.getSelectedItem()))) { }
urlTextField.setText(dus[i].getURL());
return; DriverURLName[] dus = jdbcMap.get(dbtypeComboBox.getSelectedItem());
} for (int i = 0, len = dus.length; i < len; i++) {
} driverComboBox.addItem(dus[i].getDriver());
} if (i == 0) {
} driverComboBox.setSelectedItem(dus[i].getDriver());
urlTextField.setText(dus[i].getURL());
}; }
}
ActionListener dbtypeButtonActionListener = new ActionListener() { }
public void actionPerformed(ActionEvent evt) { };
if (ComparatorUtils.equals(dbtypeComboBox.getSelectedItem(), StringUtils.EMPTY)) {
return; ActionListener driverListener = new ActionListener() {
} public void actionPerformed(ActionEvent e) {
DriverURLName[] dus = jdbcMap.get(dbtypeComboBox.getSelectedItem()); if (driverComboBox.getSelectedItem() == null || ComparatorUtils.equals(driverComboBox.getSelectedItem(), StringUtils.EMPTY)) {
for (int i = 0, len = dus.length; i < len; i++) { return;
if (ComparatorUtils.equals(driverComboBox.getSelectedItem(), (dus[i].getDriver()))) { }
urlTextField.setText(dus[i].getURL()); odbcTipsLink.setVisible(ComparatorUtils.equals("sun.jdbc.odbc.JdbcOdbcDriver", driverComboBox.getSelectedItem())); // 选择的如果是ODBC就显示提示
if (ComparatorUtils.equals(dbtypeComboBox.getSelectedItem(), ("Access"))) { Iterator<Entry<String, DriverURLName[]>> jdbc = jdbcMap.entrySet().iterator();
// ben:这个能不能换种处理方案- - while (jdbc.hasNext()) {
JFileChooser filechooser = new JFileChooser(); Entry<String, DriverURLName[]> entry = jdbc.next();
filechooser.setDialogTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Open")); DriverURLName[] dus = entry.getValue();
filechooser.setMultiSelectionEnabled(false); for (int i = 0, len = dus.length; i < len; i++) {
filechooser.addChoosableFileFilter(new ChooseFileFilter(new String[]{"accdb", "mdb"}, "Microsoft Office Access")); if (ComparatorUtils.equals(dus[i].getDriver(), (driverComboBox.getSelectedItem()))) {
int result = filechooser.showOpenDialog(DesignerContext.getDesignerFrame()); urlTextField.setText(dus[i].getURL());
File selectedfile = null; return;
}
if (result == JFileChooser.APPROVE_OPTION) { }
selectedfile = filechooser.getSelectedFile(); }
if (selectedfile != null) { }
String selectedName = selectedfile.getPath().substring(selectedfile.getPath().lastIndexOf('.') + 1);
if (selectedName.equalsIgnoreCase("mdb") || selectedName.equalsIgnoreCase("accdb")) { };
urlTextField.setText(urlTextField.getText() + selectedfile.getPath());
} ActionListener dbtypeButtonActionListener = new ActionListener() {
} public void actionPerformed(ActionEvent evt) {
} if (ComparatorUtils.equals(dbtypeComboBox.getSelectedItem(), StringUtils.EMPTY)) {
} return;
break; }
} DriverURLName[] dus = jdbcMap.get(dbtypeComboBox.getSelectedItem());
} for (int i = 0, len = dus.length; i < len; i++) {
} if (ComparatorUtils.equals(driverComboBox.getSelectedItem(), (dus[i].getDriver()))) {
}; urlTextField.setText(dus[i].getURL());
if (ComparatorUtils.equals(dbtypeComboBox.getSelectedItem(), ("Access"))) {
private JDialog createJDialog() { // ben:这个能不能换种处理方案- -
return new DBCPAttrPane().showWindow(SwingUtilities.getWindowAncestor(JDBCDefPane.this)); JFileChooser filechooser = new JFileChooser();
} filechooser.setDialogTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Open"));
filechooser.setMultiSelectionEnabled(false);
class DBCPAttrPane extends BasicPane { filechooser.addChoosableFileFilter(new ChooseFileFilter(new String[]{"accdb", "mdb"}, "Microsoft Office Access"));
public DBCPAttrPane() { int result = filechooser.showOpenDialog(DesignerContext.getDesignerFrame());
JPanel defaultPane = this; File selectedfile = null;
// JPanel northFlowPane if (result == JFileChooser.APPROVE_OPTION) {
JPanel northFlowPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); selectedfile = filechooser.getSelectedFile();
defaultPane.add(northFlowPane, BorderLayout.NORTH); if (selectedfile != null) {
String selectedName = selectedfile.getPath().substring(selectedfile.getPath().lastIndexOf('.') + 1);
DBCP_VALIDATION_QUERY.setColumns(15); if (selectedName.equalsIgnoreCase("mdb") || selectedName.equalsIgnoreCase("accdb")) {
// ContextPane urlTextField.setText(urlTextField.getText() + selectedfile.getPath());
}
double f = TableLayout.FILL; }
// double p = TableLayout.PREFERRED; }
double[] rowSize = {f, f, f, f, f, f, f, f, f, f, f, f}; }
double[] columnSize = {f, f}; break;
Component[][] comps = { }
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dbcp_Initial_Size") + ":", SwingConstants.RIGHT), DBCP_INITIAL_SIZE}, }
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dbcp_Max_Active") + ":", SwingConstants.RIGHT), DBCP_MAX_ACTIVE}, }
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dbcp_Max_Idle") + ":", SwingConstants.RIGHT), DBCP_MAX_IDLE}, };
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dbcp_Min_Idle") + ":", SwingConstants.RIGHT), DBCP_MIN_IDLE},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connection_Pool_Max_Wait_Time") + ":" , SwingConstants.RIGHT), DBCP_MAX_WAIT}, private JDialog createJDialog() {
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dbcp_Validation_Query") + ":", SwingConstants.RIGHT), DBCP_VALIDATION_QUERY}, return new DBCPAttrPane().showWindow(SwingUtilities.getWindowAncestor(JDBCDefPane.this));
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dbcp_Test_On_Borrow") + ":", SwingConstants.RIGHT), DBCP_TESTONBORROW}, }
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dbcp_Test_On_Return") + ":", SwingConstants.RIGHT), DBCP_TESTONRETURN},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dbcp_Test_While_Idle") + ":", SwingConstants.RIGHT), DBCP_TESTWHILEIDLE}, class DBCPAttrPane extends BasicPane {
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connection_Pool_Evictionruns_millis") + ":", SwingConstants.RIGHT), public DBCPAttrPane() {
DBCP_TIMEBETWEENEVICTIONRUNSMILLS}, JPanel defaultPane = this;
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dbcp_Num_Test_Per_Evction_Run") + ":", SwingConstants.RIGHT), DBCP_NUMTESTSPEREVICTIONRUN},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connection_Pool_Mix_Evictable_Idle_Time_Millis") + ":" , SwingConstants.RIGHT), // JPanel northFlowPane
DBCP_MINEVICTABLEIDLETIMEMILLIS}}; JPanel northFlowPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
defaultPane.add(northFlowPane, BorderLayout.NORTH);
JPanel contextPane = TableLayoutHelper.createGapTableLayoutPane(comps, rowSize, columnSize, 10, 4);
contextPane.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, UIConstants.LINE_COLOR)); DBCP_VALIDATION_QUERY.setColumns(15);
northFlowPane.add(contextPane); // ContextPane
}
double f = TableLayout.FILL;
@Override // double p = TableLayout.PREFERRED;
protected String title4PopupWindow() { double[] rowSize = {f, f, f, f, f, f, f, f, f, f, f, f};
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_ConnectionPool_Attr"); double[] columnSize = {f, f};
} Component[][] comps = {
} {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dbcp_Initial_Size") + ":", SwingConstants.RIGHT), DBCP_INITIAL_SIZE},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dbcp_Max_Active") + ":", SwingConstants.RIGHT), DBCP_MAX_ACTIVE},
private static class DriverURLName { {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dbcp_Max_Idle") + ":", SwingConstants.RIGHT), DBCP_MAX_IDLE},
public DriverURLName(String driver, String url) { {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dbcp_Min_Idle") + ":", SwingConstants.RIGHT), DBCP_MIN_IDLE},
this.driver = driver; {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connection_Pool_Max_Wait_Time") + ":", SwingConstants.RIGHT), DBCP_MAX_WAIT},
this.url = url; {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dbcp_Validation_Query") + ":", SwingConstants.RIGHT), DBCP_VALIDATION_QUERY},
} {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dbcp_Test_On_Borrow") + ":", SwingConstants.RIGHT), DBCP_TESTONBORROW},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dbcp_Test_On_Return") + ":", SwingConstants.RIGHT), DBCP_TESTONRETURN},
public String getDriver() { {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dbcp_Test_While_Idle") + ":", SwingConstants.RIGHT), DBCP_TESTWHILEIDLE},
return this.driver; {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connection_Pool_Evictionruns_millis") + ":", SwingConstants.RIGHT),
} DBCP_TIMEBETWEENEVICTIONRUNSMILLS},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dbcp_Num_Test_Per_Evction_Run") + ":", SwingConstants.RIGHT), DBCP_NUMTESTSPEREVICTIONRUN},
public String getURL() { {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connection_Pool_Mix_Evictable_Idle_Time_Millis") + ":", SwingConstants.RIGHT),
return this.url; DBCP_MINEVICTABLEIDLETIMEMILLIS}};
}
JPanel contextPane = TableLayoutHelper.createGapTableLayoutPane(comps, rowSize, columnSize, 10, 4);
private String driver; contextPane.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, UIConstants.LINE_COLOR));
private String url; northFlowPane.add(contextPane);
} }
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_ConnectionPool_Attr");
}
}
private static class DriverURLName {
public DriverURLName(String driver, String url) {
this.driver = driver;
this.url = url;
}
public String getDriver() {
return this.driver;
}
public String getURL() {
return this.url;
}
private String driver;
private String url;
}
} }

6
designer-base/src/main/java/com/fr/design/dialog/FineJOptionPane.java

@ -1,6 +1,7 @@
package com.fr.design.dialog; package com.fr.design.dialog;
import com.fr.invoke.Reflect; import com.fr.invoke.Reflect;
import com.fr.stable.StringUtils;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JDialog; import javax.swing.JDialog;
@ -279,8 +280,11 @@ public class FineJOptionPane extends JOptionPane {
dialog.show(); dialog.show();
dialog.dispose(); dialog.dispose();
Object value = pane.getInputValue(); //点击取消按钮,返回null
if (StringUtils.equals((String) pane.getValue(), OPTION_OK_CANCEL[1]))
return null;
Object value = pane.getInputValue();
if (value == UNINITIALIZED_VALUE) { if (value == UNINITIALIZED_VALUE) {
return null; return null;
} }

20
designer-base/src/main/java/com/fr/design/extra/exe/GetPluginCategoriesExecutor.java

@ -1,10 +1,13 @@
package com.fr.design.extra.exe; package com.fr.design.extra.exe;
import com.fr.design.DesignerEnvManager;
import com.fr.design.extra.PluginConstants; import com.fr.design.extra.PluginConstants;
import com.fr.design.extra.Process; import com.fr.design.extra.Process;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpToolbox;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import java.util.Locale;
/** /**
* Created by vito on 16/5/16. * Created by vito on 16/5/16.
@ -28,14 +31,17 @@ public class GetPluginCategoriesExecutor implements Executor {
@Override @Override
public void run(Process<String> process) { public void run(Process<String> process) {
String url = CloudCenter.getInstance().acquireUrlByKind("shop.plugin.category"); Locale locale = DesignerEnvManager.getEnvManager().getLanguage();
String url = CloudCenter.getInstance().acquireUrlByKind("shop.plugin.category") + "&locale=" + locale.toString();
if (StringUtils.isNotEmpty(url)) { if (StringUtils.isNotEmpty(url)) {
HttpClient httpClient = new HttpClient(url); try {
result = httpClient.getResponseText(); result = HttpToolbox.get(url);
} else { return;
result = PluginConstants.CONNECTION_404; } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
} }
result = PluginConstants.CONNECTION_404;
} }
} }
}; };

83
designer-base/src/main/java/com/fr/design/formula/FormulaPane.java

@ -246,44 +246,69 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
} }
public class DoubleClick extends MouseAdapter { public class DoubleClick extends MouseAdapter {
String singlePressContent;
String doublePressContent;
@Override
public void mousePressed(MouseEvent e) {
int index = tipsList.getSelectedIndex();
if (index != -1) {
if (e.getClickCount() == 1) {
singlePressContent = (String) listModel.getElementAt(index);
} else if (e.getClickCount() == 2) {
doublePressContent = (String) listModel.getElementAt(index);
}
}
}
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseReleased(MouseEvent e) {
int index = tipsList.getSelectedIndex(); int index = tipsList.getSelectedIndex();
if (index != -1) { if (index != -1) {
String currentLineContent = (String) listModel.getElementAt(index); if (e.getClickCount() == 1) {
if (e.getClickCount() == 2) { if (ComparatorUtils.equals((String) listModel.getElementAt(index), singlePressContent)) {
if (ifHasBeenWriten == 0) { singleClickActuator(singlePressContent);
formulaTextArea.setForeground(Color.black);
formulaTextArea.setText("");
} }
formulaTextArea.setForeground(Color.black); } else if (e.getClickCount() == 2) {
currentPosition = formulaTextArea.getCaretPosition(); if (ComparatorUtils.equals((String) listModel.getElementAt(index), doublePressContent)) {
String output = currentLineContent + "()"; doubleClickActuator(doublePressContent);
String textAll = formulaTextArea.getText();
String textReplaced;
int position = 0;
if (insertPosition <= currentPosition) {
textReplaced = textAll.substring(0, insertPosition) + output + textAll.substring(currentPosition);
position = insertPosition + output.length() - 1;
} else {
textReplaced = textAll.substring(0, currentPosition) + output + textAll.substring(insertPosition);
position = currentPosition + output.length() - 1;
} }
formulaTextArea.setText(textReplaced);
formulaTextArea.requestFocusInWindow();
formulaTextArea.setCaretPosition(position);
insertPosition = position;
ifHasBeenWriten = 1;
listModel.removeAllElements();
} else if (e.getClickCount() == 1) {
refreshDescriptionTextArea(currentLineContent);
formulaTextArea.requestFocusInWindow();
fixFunctionNameList();
} }
} }
} }
private void singleClickActuator(String currentLineContent) {
refreshDescriptionTextArea(currentLineContent);
formulaTextArea.requestFocusInWindow();
fixFunctionNameList();
}
private void doubleClickActuator(String currentLineContent) {
if (ifHasBeenWriten == 0) {
formulaTextArea.setForeground(Color.black);
formulaTextArea.setText("");
}
formulaTextArea.setForeground(Color.black);
currentPosition = formulaTextArea.getCaretPosition();
String output = currentLineContent + "()";
String textAll = formulaTextArea.getText();
String textReplaced;
int position = 0;
if (insertPosition <= currentPosition) {
textReplaced = textAll.substring(0, insertPosition) + output + textAll.substring(currentPosition);
position = insertPosition + output.length() - 1;
} else {
textReplaced = textAll.substring(0, currentPosition) + output + textAll.substring(insertPosition);
position = currentPosition + output.length() - 1;
}
formulaTextArea.setText(textReplaced);
formulaTextArea.requestFocusInWindow();
formulaTextArea.setCaretPosition(position);
insertPosition = position;
ifHasBeenWriten = 1;
listModel.removeAllElements();
}
} }
@Override @Override

25
designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfo.java

@ -54,6 +54,8 @@ public class ChartInfo extends AbstractPointInfo {
private static final String ATTR_OVER_CHART_TYPE_COUNT = "overChartTypeCount"; private static final String ATTR_OVER_CHART_TYPE_COUNT = "overChartTypeCount";
private static final String ATTR_IS_NEW = "isNew"; private static final String ATTR_IS_NEW = "isNew";
private static final String ATTR_IS_REUSE = "isReuse"; private static final String ATTR_IS_REUSE = "isReuse";
private static final String ATTR_AUTO_CHART_CREATE_TIME = "autoChartCreateTime";
private static final String ATTR_AUTO_CHART_ENSURE_TIME = "autoChartEnsureTime";
private static final int COMPLETE_DAY_COUNT = 3; // 判断图表是否可以上传的天数 private static final int COMPLETE_DAY_COUNT = 3; // 判断图表是否可以上传的天数
@ -122,10 +124,10 @@ public class ChartInfo extends AbstractPointInfo {
} }
public static ChartInfo newInstance(ChartProvider chartProvider) { public static ChartInfo newInstance(ChartProvider chartProvider) {
return newInstance(chartProvider, null, false, false); return newInstance(chartProvider, null, false, false, false);
} }
public static ChartInfo newInstance(ChartProvider chartProvider, String createTime, boolean isNew, boolean isReuse) { public static ChartInfo newInstance(ChartProvider chartProvider, String createTime, boolean isNew, boolean isReuse, boolean isAutoChart) {
HashMap<String, String> chartConsumingMap = new HashMap<>(); HashMap<String, String> chartConsumingMap = new HashMap<>();
String username = MarketConfig.getInstance().getBbsUsername(); String username = MarketConfig.getInstance().getBbsUsername();
@ -163,6 +165,13 @@ public class ChartInfo extends AbstractPointInfo {
chartConsumingMap.put(ATTR_OVER_CHART_TYPE_COUNT, "0"); chartConsumingMap.put(ATTR_OVER_CHART_TYPE_COUNT, "0");
chartConsumingMap.put(ATTR_IS_NEW, String.valueOf(isNew)); chartConsumingMap.put(ATTR_IS_NEW, String.valueOf(isNew));
chartConsumingMap.put(ATTR_IS_REUSE, String.valueOf(isReuse)); chartConsumingMap.put(ATTR_IS_REUSE, String.valueOf(isReuse));
if (isAutoChart) {
chartConsumingMap.put(ATTR_AUTO_CHART_CREATE_TIME, createTime);
chartConsumingMap.put(ATTR_AUTO_CHART_ENSURE_TIME, typeTime);
} else {
chartConsumingMap.put(ATTR_AUTO_CHART_CREATE_TIME, StringUtils.EMPTY);
chartConsumingMap.put(ATTR_AUTO_CHART_ENSURE_TIME, StringUtils.EMPTY);
}
ChartInfo chartInfo = new ChartInfo(chartId, templateId, book); ChartInfo chartInfo = new ChartInfo(chartId, templateId, book);
chartInfo.chartConsumingMap = chartConsumingMap; chartInfo.chartConsumingMap = chartConsumingMap;
@ -202,6 +211,9 @@ public class ChartInfo extends AbstractPointInfo {
writer.attr(ATTR_OVER_CHART_TYPE_COUNT, chartConsumingMap.get(ATTR_OVER_CHART_TYPE_COUNT)); writer.attr(ATTR_OVER_CHART_TYPE_COUNT, chartConsumingMap.get(ATTR_OVER_CHART_TYPE_COUNT));
writer.attr(ATTR_IS_NEW, chartConsumingMap.get(ATTR_IS_NEW)); writer.attr(ATTR_IS_NEW, chartConsumingMap.get(ATTR_IS_NEW));
writer.attr(ATTR_IS_REUSE, chartConsumingMap.get(ATTR_IS_REUSE)); writer.attr(ATTR_IS_REUSE, chartConsumingMap.get(ATTR_IS_REUSE));
writer.attr(ATTR_AUTO_CHART_CREATE_TIME, chartConsumingMap.get(ATTR_AUTO_CHART_CREATE_TIME));
writer.attr(ATTR_AUTO_CHART_ENSURE_TIME, chartConsumingMap.get(ATTR_AUTO_CHART_ENSURE_TIME));
writer.end(); writer.end();
chartConfigInfo.writeXML(writer); chartConfigInfo.writeXML(writer);
@ -238,6 +250,8 @@ public class ChartInfo extends AbstractPointInfo {
chartConsumingMap.put(ATTR_OVER_CHART_TYPE_COUNT, reader.getAttrAsString(ATTR_OVER_CHART_TYPE_COUNT, "0")); chartConsumingMap.put(ATTR_OVER_CHART_TYPE_COUNT, reader.getAttrAsString(ATTR_OVER_CHART_TYPE_COUNT, "0"));
chartConsumingMap.put(ATTR_IS_NEW, reader.getAttrAsString(ATTR_IS_NEW, StringUtils.EMPTY)); chartConsumingMap.put(ATTR_IS_NEW, reader.getAttrAsString(ATTR_IS_NEW, StringUtils.EMPTY));
chartConsumingMap.put(ATTR_IS_REUSE, reader.getAttrAsString(ATTR_IS_REUSE, StringUtils.EMPTY)); chartConsumingMap.put(ATTR_IS_REUSE, reader.getAttrAsString(ATTR_IS_REUSE, StringUtils.EMPTY));
chartConsumingMap.put(ATTR_AUTO_CHART_CREATE_TIME, reader.getAttrAsString(ATTR_AUTO_CHART_CREATE_TIME, StringUtils.EMPTY));
chartConsumingMap.put(ATTR_AUTO_CHART_ENSURE_TIME, reader.getAttrAsString(ATTR_AUTO_CHART_ENSURE_TIME, StringUtils.EMPTY));
} }
if (ChartConfigInfo.XML_TAG.equals(name)) { if (ChartConfigInfo.XML_TAG.equals(name)) {
this.chartConfigInfo = (ChartConfigInfo) reader.readXMLObject(new ChartConfigInfo()); this.chartConfigInfo = (ChartConfigInfo) reader.readXMLObject(new ChartConfigInfo());
@ -276,6 +290,10 @@ public class ChartInfo extends AbstractPointInfo {
} }
public void updateChartType(ChartProvider chartProvider) { public void updateChartType(ChartProvider chartProvider) {
updateChartType(chartProvider, false);
}
public void updateChartType(ChartProvider chartProvider, boolean isAutoChart) {
String typeTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss"); String typeTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss");
chartConsumingMap.put(ATTR_CHART_TYPE_TIME, typeTime); chartConsumingMap.put(ATTR_CHART_TYPE_TIME, typeTime);
@ -285,6 +303,9 @@ public class ChartInfo extends AbstractPointInfo {
String count = chartConsumingMap.get(ATTR_OVER_CHART_TYPE_COUNT); String count = chartConsumingMap.get(ATTR_OVER_CHART_TYPE_COUNT);
count = StringUtils.isEmpty(count) ? "1" : String.valueOf(Integer.parseInt(count) + 1); count = StringUtils.isEmpty(count) ? "1" : String.valueOf(Integer.parseInt(count) + 1);
chartConsumingMap.put(ATTR_OVER_CHART_TYPE_COUNT, count); chartConsumingMap.put(ATTR_OVER_CHART_TYPE_COUNT, count);
if (isAutoChart) {
chartConsumingMap.put(ATTR_AUTO_CHART_ENSURE_TIME, typeTime);
}
resetChartConfigInfo(chartProvider); resetChartConfigInfo(chartProvider);
} }

17
designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java

@ -12,6 +12,7 @@ import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import com.fr.third.joda.time.DateTime; import com.fr.third.joda.time.DateTime;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -49,18 +50,22 @@ public class ChartInfoCollector extends AbstractPointCollector<ChartInfo> {
} }
public void collection(ChartProvider chartProvider, String createTime) { public void collection(ChartProvider chartProvider, String createTime) {
collection(chartProvider, createTime, false); collection(chartProvider, createTime, false, false);
}
public void collection(ChartProvider chartProvider, String createTime, boolean isReuse) {
collection(chartProvider, createTime, isReuse, false);
} }
/** /**
* 新建图表保存状态 * 新建图表保存状态
*/ */
public void collection(ChartProvider chartProvider, String createTime, boolean isReuse) { public void collection(ChartProvider chartProvider, String createTime, boolean isReuse, boolean isAutoChart) {
String chartId = chartProvider.getChartUuid(); String chartId = chartProvider.getChartUuid();
if (!shouldCollectInfo() || StringUtils.isEmpty(chartId)) { if (!shouldCollectInfo() || StringUtils.isEmpty(chartId)) {
return; return;
} }
ChartInfo chartInfo = ChartInfo.newInstance(chartProvider, createTime, true, isReuse); ChartInfo chartInfo = ChartInfo.newInstance(chartProvider, createTime, true, isReuse, isAutoChart);
chartInfoCacheMap.put(chartId, chartInfo); chartInfoCacheMap.put(chartId, chartInfo);
} }
@ -116,6 +121,10 @@ public class ChartInfoCollector extends AbstractPointCollector<ChartInfo> {
* 图表类型变化更新类型和类型确认时间 * 图表类型变化更新类型和类型确认时间
*/ */
public void updateChartTypeTime(ChartProvider chartProvider, String oldType) { public void updateChartTypeTime(ChartProvider chartProvider, String oldType) {
updateChartTypeTime(chartProvider, oldType, false);
}
public void updateChartTypeTime(ChartProvider chartProvider, String oldType, boolean isAutoChart) {
if (!shouldCollectInfo() || StringUtils.isEmpty(chartProvider.getChartUuid())) { if (!shouldCollectInfo() || StringUtils.isEmpty(chartProvider.getChartUuid())) {
return; return;
} }
@ -123,7 +132,7 @@ public class ChartInfoCollector extends AbstractPointCollector<ChartInfo> {
ChartInfo chartInfo = getOrCreateChartInfo(chartProvider, oldType); ChartInfo chartInfo = getOrCreateChartInfo(chartProvider, oldType);
//更新类型确认时间和类型 //更新类型确认时间和类型
chartInfo.updateChartType(chartProvider); chartInfo.updateChartType(chartProvider, isAutoChart);
//重置计数 //重置计数
chartInfo.resetIdleDayCount(); chartInfo.resetIdleDayCount();

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

@ -93,6 +93,7 @@ public class LogHandlerBar extends JPanel implements ItemSelectable {
public void clearMessage() { public void clearMessage() {
INFONUM = ERRORNUM = SERVERNUM = 0; INFONUM = ERRORNUM = SERVERNUM = 0;
LogMessageBar.getInstance().clear();
changeLabel(); changeLabel();
} }

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

@ -2,6 +2,7 @@ package com.fr.design.mainframe.loghandler;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.stable.StringUtils;
import javax.swing.JFrame; import javax.swing.JFrame;
@ -63,6 +64,11 @@ public class LogMessageBar extends JPanel {
repaint(); repaint();
} }
public void clear() {
messageLabel.setText(StringUtils.EMPTY);
repaint();
}
public void setLoggerBarWidth(int width) { public void setLoggerBarWidth(int width) {
this.width = width; this.width = width;
} }

6
designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java

@ -398,9 +398,11 @@ public final class GUICoreUtils {
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
screen.setSize(screen.getSize().width, screen.height - HEIGHT_GAP); screen.setSize(screen.getSize().width, screen.height - HEIGHT_GAP);
int showOnScreenX = Math.min(screen.width, parentComponent.getLocationOnScreen().x + parentComponent.getWidth());
// peter:调整X的高度. // peter:调整X的高度.
if (point.x + size.width > screen.width && size.width < screen.width) { if (point.x + size.width > showOnScreenX && size.width < showOnScreenX) {
x += (screen.width - point.x - size.width); x += (showOnScreenX - point.x - size.width);
} }
// peter:调整y高度. // peter:调整y高度.

1
designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java

@ -73,6 +73,7 @@ public class FineEmbedServerActivator extends Activator {
//覆盖tomcat的WebAppClassLoader //覆盖tomcat的WebAppClassLoader
context.setLoader(new FRTomcatLoader()); context.setLoader(new FRTomcatLoader());
//直接指定initializer,tomcat就不用再扫描一遍了 //直接指定initializer,tomcat就不用再扫描一遍了
SpringServletContainerInitializer initializer = new SpringServletContainerInitializer(); SpringServletContainerInitializer initializer = new SpringServletContainerInitializer();
Set<Class<?>> classes = new HashSet<Class<?>>(); Set<Class<?>> classes = new HashSet<Class<?>>();

15
designer-chart/src/main/java/com/fr/design/chart/AutoChartDialog.java

@ -7,6 +7,9 @@ import com.fr.chartx.TwoTuple;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.plugin.chart.vanchart.VanChart; import com.fr.plugin.chart.vanchart.VanChart;
import javax.swing.JList;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.Component; import java.awt.Component;
import java.awt.Dialog; import java.awt.Dialog;
import java.awt.Frame; import java.awt.Frame;
@ -33,14 +36,22 @@ public class AutoChartDialog extends ChartDialog {
protected Component initCenterPane() { protected Component initCenterPane() {
autoChartTypePane = new AutoChartTypePane(); autoChartTypePane = new AutoChartTypePane();
getOk().setEnabled(false);
autoChartTypePane.registsListAction(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
getOk().setEnabled(((JList) e.getSource()).getSelectedIndex() >= 0);
}
});
return autoChartTypePane; return autoChartTypePane;
} }
protected ActionListener getActionListener() { protected ActionListener getActionListener(final String createTime) {
return new ActionListener() { return new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
ChartCollection chartCollection = (ChartCollection) getChartCollection(); ChartCollection chartCollection = (ChartCollection) getChartCollection();
autoChartTypePane.update(chartCollection); autoChartTypePane.update(chartCollection, createTime);
if (chartCollection.getChartCount() > 0) { if (chartCollection.getChartCount() > 0) {
doOK(); doOK();
} else { } else {

2
designer-chart/src/main/java/com/fr/design/chart/AutoChartIcon.java

@ -66,7 +66,7 @@ public class AutoChartIcon implements Icon {
public void paintIcon(Component c, Graphics g, int x, int y) { public void paintIcon(Component c, Graphics g, int x, int y) {
BaseChartPainter painter = chartCollection.createResultChartPainterWithOutDealFormula(Calculator.createCalculator(), BaseChartPainter painter = chartCollection.createResultChartPainterWithOutDealFormula(Calculator.createCalculator(),
WebChartIDInfo.createEmptyDesignerInfo(), getIconWidth(), getIconHeight()); WebChartIDInfo.createAutoTypeInfo(), getIconWidth(), getIconHeight());
int resolution = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getJTemplateResolution(); int resolution = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getJTemplateResolution();

122
designer-chart/src/main/java/com/fr/design/chart/AutoChartTypePane.java

@ -2,28 +2,42 @@ package com.fr.design.chart;
import com.fr.base.chart.chartdata.CallbackEvent; import com.fr.base.chart.chartdata.CallbackEvent;
import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.ChartCollection;
import com.fr.chartx.attr.ChartProvider; import com.fr.design.chart.auto.AutoTypeCalculate;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.TableDataComboBox; import com.fr.design.data.datapane.TableDataComboBox;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombocheckbox.UIComboCheckBox; import com.fr.design.gui.icombocheckbox.UIComboCheckBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.iprogressbar.AutoProgressBar;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.chart.info.ChartInfoCollector;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.GeneralUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.chart.vanchart.VanChart;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.DefaultListCellRenderer; import javax.swing.DefaultListCellRenderer;
import javax.swing.DefaultListModel; import javax.swing.DefaultListModel;
import javax.swing.JList; import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import javax.swing.JSplitPane; import javax.swing.JSplitPane;
import javax.swing.ListCellRenderer; import javax.swing.ListCellRenderer;
import javax.swing.SwingWorker;
import javax.swing.UIManager;
import javax.swing.event.ListSelectionListener;
import javax.swing.plaf.SplitPaneUI;
import javax.swing.plaf.basic.BasicSplitPaneUI;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.CancellationException;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
@ -46,6 +60,9 @@ public class AutoChartTypePane extends ChartWizardPane implements CallbackEvent
private TableDataComboBox tableNameComboBox; private TableDataComboBox tableNameComboBox;
private UIComboCheckBox dataFieldBox; private UIComboCheckBox dataFieldBox;
private AutoProgressBar connectionBar;
private SwingWorker worker;
public AutoChartTypePane() { public AutoChartTypePane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
initButtonGroup(); initButtonGroup();
@ -62,10 +79,15 @@ public class AutoChartTypePane extends ChartWizardPane implements CallbackEvent
chartViewList.setCellRenderer(iconCellRenderer); chartViewList.setCellRenderer(iconCellRenderer);
JScrollPane subListPane = new JScrollPane(chartViewList); JScrollPane subListPane = new JScrollPane(chartViewList);
subListPane.setBorder(BorderFactory.createTitledBorder(Toolkit.i18nText("Fine-Design_Chart_Recommended_Chart")));
JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, false, contentPane, subListPane);
JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, contentPane, subListPane); SplitPaneUI ui = splitPane.getUI();
if (ui instanceof BasicSplitPaneUI) {
((BasicSplitPaneUI) ui).getDivider().setBorder(null);
}
splitPane.setDividerLocation(60); splitPane.setDividerLocation(60);
splitPane.setBorder(BorderFactory.createTitledBorder(Toolkit.i18nText("Fine-Design_Chart_M_Popup_Auto_Chart_Type")));
this.add(splitPane); this.add(splitPane);
} }
@ -94,7 +116,7 @@ public class AutoChartTypePane extends ChartWizardPane implements CallbackEvent
JPanel tableDataPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); JPanel tableDataPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
panel.add(tableDataPane); panel.add(tableDataPane);
tableDataPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Chart_Table_Data") + ":")); tableDataPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Chart_Table_Data") + ":"));
tableNameComboBox.setPreferredSize(new Dimension(96, 20)); tableNameComboBox.setPreferredSize(new Dimension(126, 20));
tableDataPane.add(tableNameComboBox); tableDataPane.add(tableNameComboBox);
JPanel areaNamePane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); JPanel areaNamePane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
@ -102,6 +124,7 @@ public class AutoChartTypePane extends ChartWizardPane implements CallbackEvent
areaNamePane.add(new UILabel(Toolkit.i18nText("Fine-Design_Chart_Data_Field") + ":")); areaNamePane.add(new UILabel(Toolkit.i18nText("Fine-Design_Chart_Data_Field") + ":"));
areaNamePane.add(dataFieldBox); areaNamePane.add(dataFieldBox);
panel.add(refreshButton); panel.add(refreshButton);
panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
return panel; return panel;
} }
@ -136,6 +159,10 @@ public class AutoChartTypePane extends ChartWizardPane implements CallbackEvent
} }
} }
public void registsListAction(ListSelectionListener listSelectionListener) {
chartViewList.addListSelectionListener(listSelectionListener);
}
private void refreshBox() { private void refreshBox() {
TableDataWrapper dataWrap = tableNameComboBox.getSelectedItem(); TableDataWrapper dataWrap = tableNameComboBox.getSelectedItem();
@ -154,6 +181,7 @@ public class AutoChartTypePane extends ChartWizardPane implements CallbackEvent
refreshButton.addActionListener(new ActionListener() { refreshButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
refreshButton.setEnabled(false);
calculateAutoChart(); calculateAutoChart();
} }
}); });
@ -161,7 +189,56 @@ public class AutoChartTypePane extends ChartWizardPane implements CallbackEvent
} }
private void calculateAutoChart() { private void calculateAutoChart() {
chartResultModel.clear(); connectionBar = new AutoProgressBar(this, Toolkit.i18nText("Fine-Design_Chart_Generate_Recommended_Chart"), "", 0, 100) {
public void doMonitorCanceled() {
refreshButton.setEnabled(true);
worker.cancel(true);
}
};
setWorker();
worker.execute();
}
private void setWorker() {
worker = new SwingWorker<List<VanChart>, Void>() {
protected List<VanChart> doInBackground() {
connectionBar.start();
chartResultModel.clear();
List<String> columnList = new ArrayList<>();
Object[] selectedValues = dataFieldBox.getSelectedValues();
for (Object value : selectedValues) {
columnList.add(GeneralUtils.objectToString(value));
}
List<VanChart> vanChartList = AutoTypeCalculate.calculateType(tableNameComboBox.getSelectedItem().getTableDataName(), columnList);
connectionBar.close();
return vanChartList;
}
public void done() {
try {
List<VanChart> vanChartList = get();
if (vanChartList != null && !vanChartList.isEmpty()) {
for (VanChart vanChart : vanChartList) {
ChartCollection chartCollection = new ChartCollection(vanChart);
AutoChartIcon autoChartIcon = new AutoChartIcon(chartCollection);
autoChartIcon.registerCallBackEvent(AutoChartTypePane.this);
chartResultModel.addElement(autoChartIcon);
}
chartViewList.setSelectedIndex(0);
}
} catch (Exception e) {
if (!(e instanceof CancellationException)) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
FineJOptionPane.showMessageDialog(AutoChartTypePane.this, e.getMessage(),
Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon"));
}
} finally {
connectionBar.close();
refreshButton.setEnabled(true);
}
}
};
} }
@Override @Override
@ -171,16 +248,7 @@ public class AutoChartTypePane extends ChartWizardPane implements CallbackEvent
@Override @Override
public void update(ChartCollection cc) { public void update(ChartCollection cc) {
if (chartViewList.getSelectedIndex() < 0) { update(cc, null);
return;
}
AutoChartIcon chartIcon = (AutoChartIcon) chartViewList.getSelectedValue();
ChartProvider chartProvider = chartIcon.getChartCollection().getSelectedChartProvider(ChartProvider.class);
if (cc.getChartCount() > 0) {
cc.setSelectChart(chartProvider);
} else {
cc.addChart(chartProvider);
}
} }
public void populate(String tableName, String[] dataFields) { public void populate(String tableName, String[] dataFields) {
@ -190,6 +258,30 @@ public class AutoChartTypePane extends ChartWizardPane implements CallbackEvent
map.put(dataField, true); map.put(dataField, true);
} }
dataFieldBox.setSelectedValues(map); dataFieldBox.setSelectedValues(map);
if (refreshButton.isEnabled()) {
refreshButton.setEnabled(false);
calculateAutoChart();
}
}
public void update(ChartCollection cc, String createTime) {
if (chartViewList.getSelectedIndex() < 0) {
return;
}
AutoChartIcon chartIcon = (AutoChartIcon) chartViewList.getSelectedValue();
VanChart vanChart = chartIcon.getChartCollection().getSelectedChartProvider(VanChart.class);
if (cc.getChartCount() > 0) {
VanChart selectedChartProvider = cc.getSelectedChartProvider(VanChart.class);
if (selectedChartProvider.getChartUuid() != null) {
vanChart.setUuid(selectedChartProvider.getChartUuid());
}
cc.setSelectChart(vanChart);
ChartInfoCollector.getInstance().updateChartTypeTime(vanChart, null, true);
} else {
cc.addChart(vanChart);
//记录埋点
ChartInfoCollector.getInstance().collection(vanChart, createTime, false, true);
}
} }
@Override @Override

18
designer-chart/src/main/java/com/fr/design/chart/ChartDialog.java

@ -31,7 +31,6 @@ public class ChartDialog extends MiddleChartDialog {
private UIButton ok; private UIButton ok;
private UIButton cancel; private UIButton cancel;
private ChartTypePane chartTypePane; private ChartTypePane chartTypePane;
private String createTime;
public ChartDialog(Frame owner) { public ChartDialog(Frame owner) {
super(owner); super(owner);
@ -44,11 +43,14 @@ public class ChartDialog extends MiddleChartDialog {
} }
private void initComponent() { private void initComponent() {
createTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss"); String createTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss");
this.setModal(true); this.setModal(true);
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
setTitle(getDialogTitle()); setTitle(getDialogTitle());
ok = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_OK"));
cancel = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cancel"));
this.applyClosingAction(); this.applyClosingAction();
this.applyEscapeAction(); this.applyEscapeAction();
this.setBasicDialogSize(BasicDialog.DEFAULT); this.setBasicDialogSize(BasicDialog.DEFAULT);
@ -58,10 +60,7 @@ public class ChartDialog extends MiddleChartDialog {
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
this.add(buttonPane, BorderLayout.SOUTH); this.add(buttonPane, BorderLayout.SOUTH);
ok = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_OK")); ok.addActionListener(getActionListener(createTime));
cancel = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cancel"));
ok.addActionListener(getActionListener());
cancel.addActionListener(new ActionListener() { cancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
doCancel(); doCancel();
@ -83,7 +82,7 @@ public class ChartDialog extends MiddleChartDialog {
return chartTypePane; return chartTypePane;
} }
protected ActionListener getActionListener() { protected ActionListener getActionListener(final String createTime) {
return new ActionListener() { return new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
chartTypePane.update((ChartCollection) cc, createTime); chartTypePane.update((ChartCollection) cc, createTime);
@ -92,6 +91,11 @@ public class ChartDialog extends MiddleChartDialog {
}; };
} }
public UIButton getOk() {
return ok;
}
/** /**
* 不处理 * 不处理
*/ */

143
designer-chart/src/main/java/com/fr/design/chart/auto/AutoTypeCalculate.java

@ -0,0 +1,143 @@
package com.fr.design.chart.auto;
import com.fr.chart.auto.ColumnInfo;
import com.fr.chart.auto.strategy.AutoTypeStrategy;
import com.fr.chart.auto.strategy.imp.AvaStrategy;
import com.fr.chart.auto.strategy.imp.BubbleChartStrategy;
import com.fr.chart.auto.strategy.imp.SingleDimensionStrategy;
import com.fr.chart.auto.strategy.imp.SingleTargetStrategy;
import com.fr.data.TableDataSource;
import com.fr.data.TableDataSourceTailor;
import com.fr.data.impl.EmbeddedTableData;
import com.fr.data.impl.NameTableData;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils;
import com.fr.general.data.DataModel;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.chart.vanchart.VanChart;
import com.fr.script.Calculator;
import com.fr.stable.StringUtils;
import java.util.ArrayList;
import java.util.List;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-05-08
*/
public class AutoTypeCalculate {
public static List<VanChart> calculateType(String tableName, List<String> columns) {
List<ColumnInfo> columnValue = calculateField(tableName, columns);
if (columnValue.isEmpty()) {
return new ArrayList<>();
}
List<ColumnInfo> dimensions = new ArrayList<>();
List<ColumnInfo> targets = new ArrayList<>();
for (ColumnInfo field : columnValue) {
if (isTarget(field.getValues())) {
targets.add(field);
} else {
dimensions.add(field);
}
}
AutoTypeStrategy autoTypeStrategy = chooseStrategy(dimensions.size(), targets.size());
return autoTypeStrategy.rankChart(tableName, dimensions, targets);
}
private static AutoTypeStrategy chooseStrategy(int dimensionSize, int targetSize) {
if (dimensionSize == 0) {
//没有维度,并且只有一个指标,使用单指标匹配逻辑,大于1个指标,使用气泡图(散点图)匹配逻辑
if (targetSize == 1) {
return new SingleTargetStrategy();
} else {
return new BubbleChartStrategy();
}
} else if (dimensionSize == 1) {
//1个维度,并且没有指标,使用单维度匹配,2~3个指标,使用气泡图(散点图)匹配逻辑,其余使用ava匹配
if (targetSize == 0) {
return new SingleDimensionStrategy();
} else if (targetSize == 2 || targetSize == 3) {
return new BubbleChartStrategy();
} else {
return new AvaStrategy();
}
} else {
//大与1个维度,并且没有指标,使用单维度匹配(循环),否则使用ava匹配
if (targetSize == 0) {
return new SingleDimensionStrategy();
} else {
return new AvaStrategy();
}
}
}
private static boolean isTarget(List<String> values) {
for (String value : values) {
if (StringUtils.isEmpty(value)) {
continue;
}
Number number = GeneralUtils.string2Number(value);
if (number == null) {
return false;
}
}
return true;
}
private static List<ColumnInfo> calculateField(String tableName, List<String> columns) {
NameTableData nameTableData = new NameTableData(tableName);
TableDataSource dataSource = TableDataSourceTailor.extractTableData(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget());
Calculator calculator = Calculator.createCalculator();
calculator.setAttribute(TableDataSource.KEY, dataSource);
nameTableData.createTableData(calculator);
EmbeddedTableData tableData;
try {
tableData = DesignTableDataManager.previewTableDataNeedInputParameters(dataSource, nameTableData, Integer.MAX_VALUE, false);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return new ArrayList<>();
}
List<ColumnInfo> originalData = new ArrayList<>();
for (String column : columns) {
List<String> columnData = getColumnData(tableData, column);
if (columnData != null && !columnData.isEmpty()) {
originalData.add(new ColumnInfo(column, columnData));
}
}
return originalData;
}
private static List<String> getColumnData(EmbeddedTableData tableData, String columnName) {
List<String> columnData = new ArrayList<>();
int colIndex = getColIndex(tableData, columnName);
if (colIndex == DataModel.COLUMN_NAME_NOT_FOUND) {
return columnData;
}
int size = tableData.getRowCount();
for (int i = 0; i < size; i++) {
Object valueAt = tableData.getValueAt(i, colIndex);
columnData.add(GeneralUtils.objectToString(valueAt));
}
return columnData;
}
private static int getColIndex(EmbeddedTableData tableData, String columnName) {
int colIndex = 0;
for (int count = tableData.getColumnCount(); colIndex < count; ++colIndex) {
if (ComparatorUtils.tableDataColumnNameEquals(tableData.getColumnName(colIndex), columnName)) {
return colIndex;
}
}
return DataModel.COLUMN_NAME_NOT_FOUND;
}
}

26
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java

@ -111,12 +111,15 @@ public class ChartTypePane extends AbstractChartAttrPane {
autoButtonListener = new ActionListener() { autoButtonListener = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
final String lastId = editingCollection.getSelectedChartProvider(ChartProvider.class).getID();
final MiddleChartDialog autoChartDialog = DesignModuleFactory.getAutoChartDialog(DesignerContext.getDesignerFrame()); final MiddleChartDialog autoChartDialog = DesignModuleFactory.getAutoChartDialog(DesignerContext.getDesignerFrame());
autoChartDialog.populate(editingCollection); autoChartDialog.populate(editingCollection);
autoChartDialog.addDialogActionListener(new DialogActionAdapter() { autoChartDialog.addDialogActionListener(new DialogActionAdapter() {
@Override @Override
public void doOk() { public void doOk() {
populate(editingCollection); populate(editingCollection);
ChartProvider chart = editingCollection.getSelectedChartProvider(ChartProvider.class);
reLayoutEditPane(chart, lastId);
} }
}); });
autoChartDialog.setVisible(true); autoChartDialog.setVisible(true);
@ -124,6 +127,17 @@ public class ChartTypePane extends AbstractChartAttrPane {
}; };
} }
private void reLayoutEditPane(ChartProvider chart, String lastChartId) {
String chartId = chart.getID();
//chartID改变的话图表类型就算改变了
if (StringUtils.isNotEmpty(chartId)) {
boolean isUseDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(chartId);
if (editPane.isDefaultPane() != isUseDefault || (!isUseDefault && !ComparatorUtils.equals(lastChartId, chartId))) {
editPane.reLayout(chart);
}
}
}
class ComboBoxPane extends UIComboBoxPane<ChartProvider> { class ComboBoxPane extends UIComboBoxPane<ChartProvider> {
private Map<String, Map<String, FurtherBasicBeanPane<? extends ChartProvider>>> allChartTypePane; private Map<String, Map<String, FurtherBasicBeanPane<? extends ChartProvider>>> allChartTypePane;
@ -167,17 +181,7 @@ public class ChartTypePane extends AbstractChartAttrPane {
//这一步会替换plot //这一步会替换plot
((AbstractChartTypePane) getSelectedPane()).updateBean(chart); ((AbstractChartTypePane) getSelectedPane()).updateBean(chart);
String chartID = chart.getID(); reLayoutEditPane(chart,lastPlotID);
//chartID改变的话图表类型就算改变了
if (StringUtils.isNotEmpty(chartID)) {
boolean isUseDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(chartID);
if (editPane.isDefaultPane() != isUseDefault || (!isUseDefault && !ComparatorUtils.equals(lastPlotID, chartID))) {
editPane.reLayout(chart);
}
}
} }
protected UIComboBox createComboBox() { protected UIComboBox createComboBox() {

1
designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomDataPane.java

@ -27,6 +27,7 @@ public class VanChartCustomDataPane extends ChartDataPane {
} }
contentsTabPane = new VanChartCustomPlotDataContentsTabPane((VanChartCustomPlot)chart.getPlot(), VanChartCustomDataPane.this, listener); contentsTabPane = new VanChartCustomPlotDataContentsTabPane((VanChartCustomPlot)chart.getPlot(), VanChartCustomDataPane.this, listener);
contentsTabPane.setSupportCellData(isSupportCellData());
content.add(contentsTabPane, BorderLayout.CENTER); content.add(contentsTabPane, BorderLayout.CENTER);
return content; return content;

75
designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotDataContentsTabPane.java

@ -22,14 +22,25 @@ import java.util.Map;
* Created by Fangjie on 2016/4/29. * Created by Fangjie on 2016/4/29.
*/ */
public class VanChartCustomPlotDataContentsTabPane extends VanChartCustomPlotTabPane<VanChartCustomPlot, ChartCollection> { public class VanChartCustomPlotDataContentsTabPane extends VanChartCustomPlotTabPane<VanChartCustomPlot, ChartCollection> {
private boolean supportCellData;
public VanChartCustomPlotDataContentsTabPane(VanChartCustomPlot plot, VanChartCustomDataPane parent, AttributeChangeListener listener) { public VanChartCustomPlotDataContentsTabPane(VanChartCustomPlot plot, VanChartCustomDataPane parent, AttributeChangeListener listener) {
super(plot, parent, listener); super(plot, parent, listener);
} }
public boolean isSupportCellData() {
return supportCellData;
}
public void setSupportCellData(boolean supportCellData) {
this.supportCellData = supportCellData;
}
@Override @Override
protected void initTabTitle() { protected void initTabTitle() {
if (plot == null){ if (plot == null) {
return; return;
} }
@ -49,7 +60,7 @@ public class VanChartCustomPlotDataContentsTabPane extends VanChartCustomPlotTab
@Override @Override
protected List<JPanel> initPaneList() { protected List<JPanel> initPaneList() {
if (plot == null){ if (plot == null) {
return null; return null;
} }
@ -57,9 +68,10 @@ public class VanChartCustomPlotDataContentsTabPane extends VanChartCustomPlotTab
List<VanChartPlot> customPlotList = plot.getCustomPlotList(); List<VanChartPlot> customPlotList = plot.getCustomPlotList();
for (int i = 0; i < customPlotList.size(); i++){ for (int i = 0; i < customPlotList.size(); i++) {
//根据不同的plot创建不同的数据配置界面 //根据不同的plot创建不同的数据配置界面
ChartDataPane contentPane = new VanChartDataPane(listener); ChartDataPane contentPane = new VanChartDataPane(listener);
contentPane.setSupportCellData(supportCellData);
paneList.add(contentPane); paneList.add(contentPane);
} }
@ -67,42 +79,38 @@ public class VanChartCustomPlotDataContentsTabPane extends VanChartCustomPlotTab
} }
@Override @Override
public void populateBean(ChartCollection chartCollection){ public void populateBean(ChartCollection chartCollection) {
plot = (VanChartCustomPlot) chartCollection.getSelectedChart().getPlot(); plot = (VanChartCustomPlot) chartCollection.getSelectedChart().getPlot();
if (paneList == null){ paneList = initPaneList();
paneList = initPaneList();
}
if (paneList != null){
try {
List<VanChartPlot> customPlotList = plot.getCustomPlotList(); relayoutWhenListChange();
try {
List<VanChartPlot> customPlotList = plot.getCustomPlotList();
for (int i = 0; i < paneList.size() && i < customPlotList.size(); i++) {
//將plot包裝起来,主要是为了获取dataDefinition
ChartCollection cloneCollection = (ChartCollection) chartCollection.clone();
//设置collection的plot for (int i = 0; i < paneList.size() && i < customPlotList.size(); i++) {
cloneCollection.getSelectedChart().setPlot(customPlotList.get(i)); //將plot包裝起来,主要是为了获取dataDefinition
ChartCollection cloneCollection = (ChartCollection) chartCollection.clone();
//获取definitionMap中的dataDefinition //设置collection的plot
TopDefinitionProvider definition = chartCollection.getSelectedChart().getFilterDefinition(); cloneCollection.getSelectedChart().setPlot(customPlotList.get(i));
TopDefinitionProvider dataDefinition = null;
if (definition != null && definition instanceof CustomDefinition) {
Map<CustomPlotType, TopDefinitionProvider> definitionProviderMap = ((CustomDefinition)definition).getDefinitionProviderMap();
dataDefinition = definitionProviderMap.get(CustomPlotFactory.getCustomType(customPlotList.get(i)));
}
cloneCollection.getSelectedChart().setFilterDefinition(dataDefinition);
((ChartDataPane) paneList.get(i)).populate(cloneCollection); //获取definitionMap中的dataDefinition
TopDefinitionProvider definition = chartCollection.getSelectedChart().getFilterDefinition();
TopDefinitionProvider dataDefinition = null;
if (definition != null && definition instanceof CustomDefinition) {
Map<CustomPlotType, TopDefinitionProvider> definitionProviderMap = ((CustomDefinition) definition).getDefinitionProviderMap();
dataDefinition = definitionProviderMap.get(CustomPlotFactory.getCustomType(customPlotList.get(i)));
} }
}catch (Exception e){ cloneCollection.getSelectedChart().setFilterDefinition(dataDefinition);
return;
((ChartDataPane) paneList.get(i)).populate(cloneCollection);
} }
} catch (Exception e) {
return;
} }
} }
@ -112,8 +120,8 @@ public class VanChartCustomPlotDataContentsTabPane extends VanChartCustomPlotTab
} }
@Override @Override
public void updateBean(ChartCollection collection){ public void updateBean(ChartCollection collection) {
if (paneList == null || plot == null){ if (paneList == null || plot == null) {
return; return;
} }
try { try {
@ -146,7 +154,7 @@ public class VanChartCustomPlotDataContentsTabPane extends VanChartCustomPlotTab
customDefinition.setDefinitionProviderMap(definitionMap); customDefinition.setDefinitionProviderMap(definitionMap);
collection.getSelectedChart().setFilterDefinition(customDefinition); collection.getSelectedChart().setFilterDefinition(customDefinition);
}catch (Exception e){ } catch (Exception e) {
return; return;
} }
} }
@ -168,10 +176,11 @@ public class VanChartCustomPlotDataContentsTabPane extends VanChartCustomPlotTab
/** /**
* 返回绑定的属性事件. * 返回绑定的属性事件.
* @param listener 增加监听 *
* @param listener 增加监听
*/ */
public void addAttributeChangeListener(AttributeChangeListener listener) { public void addAttributeChangeListener(AttributeChangeListener listener) {
for (int i = 0; i < paneList.size(); i++){ for (int i = 0; i < paneList.size(); i++) {
((ChartDataPane) paneList.get(i)).addAttributeChangeListener(listener); ((ChartDataPane) paneList.get(i)).addAttributeChangeListener(listener);
} }
} }

262
designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java

@ -54,11 +54,13 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
private static final long serialVersionUID = -5717246802333308973L; private static final long serialVersionUID = -5717246802333308973L;
private static final double ROTATION_MAX = 90.0; private static final double ROTATION_MAX = 90.0;
protected UIButtonGroup showTitle;
protected TinyFormulaPane titleContent; protected TinyFormulaPane titleContent;
protected UIButtonGroup<Integer> titleAlignPane; protected UIButtonGroup<Integer> titleAlignPane;
protected UIToggleButton titleUseHtml; protected UIToggleButton titleUseHtml;
protected ChartTextAttrPane titleTextAttrPane; protected ChartTextAttrPane titleTextAttrPane;
protected UINumberDragPane titleTextRotation; protected UINumberDragPane titleTextRotation;
protected JPanel titlePane;
protected UIButtonGroup showLabel; protected UIButtonGroup showLabel;
protected ChartTextAttrPane labelTextAttrPane; protected ChartTextAttrPane labelTextAttrPane;
@ -96,11 +98,11 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
protected JPanel centerPane; protected JPanel centerPane;
private VanChartHtmlLabelPane htmlLabelPane; private VanChartHtmlLabelPane htmlLabelPane;
public VanChartBaseAxisPane(){ public VanChartBaseAxisPane() {
this(true); this(true);
} }
public VanChartBaseAxisPane(boolean isXAxis){ public VanChartBaseAxisPane(boolean isXAxis) {
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
this.add(createContentPane(isXAxis), BorderLayout.CENTER); this.add(createContentPane(isXAxis), BorderLayout.CENTER);
} }
@ -108,12 +110,13 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
public void setParentPane(VanChartStylePane parent) { public void setParentPane(VanChartStylePane parent) {
htmlLabelPane.setParent(parent); htmlLabelPane.setParent(parent);
} }
protected void reLayoutPane(boolean isXAxis){
protected void reLayoutPane(boolean isXAxis) {
this.removeAll(); this.removeAll();
this.add(createContentPane(isXAxis), BorderLayout.CENTER); this.add(createContentPane(isXAxis), BorderLayout.CENTER);
} }
protected JPanel createContentPane(boolean isXAxis){ protected JPanel createContentPane(boolean isXAxis) {
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
@ -121,9 +124,9 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
double s = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH; double s = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH;
double[] columnSize = {f, e}; double[] columnSize = {f, e};
double[] column = {f, s}; double[] column = {f, s};
double[] rowSize = {p, p, p, p, p, p, p,p}; double[] rowSize = {p, p, p, p, p, p, p, p};
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{createTitlePane(new double[]{p, p, p, p, p, p}, columnSize, isXAxis), null}, new Component[]{createTitlePane(new double[]{p, p, p, p, p, p}, column, isXAxis), null},
new Component[]{createLabelPane(new double[]{p, p}, column), null}, new Component[]{createLabelPane(new double[]{p, p}, column), null},
new Component[]{createLineStylePane(new double[]{p, p, p, p, p}, columnSize), null}, new Component[]{createLineStylePane(new double[]{p, p, p, p, p}, columnSize), null},
new Component[]{createAxisPositionPane(new double[]{p, p, p}, columnSize, isXAxis), null}, new Component[]{createAxisPositionPane(new double[]{p, p, p}, columnSize, isXAxis), null},
@ -131,39 +134,53 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
new Component[]{createValueStylePane(), null}, new Component[]{createValueStylePane(), null},
}; };
return TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize); return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
} }
protected JPanel createTitlePane(double[] row, double[] col, boolean isXAxis){ protected JPanel createTitlePane(double[] row, double[] col, boolean isXAxis) {
showTitle = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Use_Show"), Toolkit.i18nText("Fine-Design_Chart_Hidden")});
titleAlignPane = isXAxis ? getXAxisTitleAlignPane() : getYAxisTitleAlignPane(); titleAlignPane = isXAxis ? getXAxisTitleAlignPane() : getYAxisTitleAlignPane();
titleAlignPane.setSelectedItem(Constants.CENTER); titleAlignPane.setSelectedItem(Constants.CENTER);
titleContent = new TinyFormulaPane(); titleContent = new TinyFormulaPane();
titleUseHtml = new UIToggleButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Html")); titleUseHtml = new UIToggleButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Html"));
UIComponentUtils.setLineWrap(titleUseHtml); UIComponentUtils.setLineWrap(titleUseHtml);
titleTextAttrPane = new ChartTextAttrPane(); titleTextAttrPane = getChartTextAttrPane();
titleTextRotation = new UINumberDragPane(-ROTATION_MAX,ROTATION_MAX); titleTextRotation = new UINumberDragPane(-ROTATION_MAX, ROTATION_MAX);
if(isXAxis){ if (isXAxis) {
titleTextRotation.populateBean(0.0); titleTextRotation.populateBean(0.0);
} else { } else {
titleTextRotation.populateBean(-ROTATION_MAX); titleTextRotation.populateBean(-ROTATION_MAX);
} }
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{null,null}, new Component[]{null, null},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Content")),titleContent}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Content")), titleContent},
new Component[]{null,titleUseHtml}, new Component[]{null, titleUseHtml},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout_Position")),titleAlignPane}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout_Position")), titleAlignPane},
new Component[]{titleTextAttrPane,null}, new Component[]{titleTextAttrPane, null},
new Component[]{ new Component[]{
FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_TextRotation")), FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_TextRotation")),
UIComponentUtils.wrapWithBorderLayoutPane(titleTextRotation) UIComponentUtils.wrapWithBorderLayoutPane(titleTextRotation)
}, },
}; };
titlePane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col);
titlePane.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); JPanel showTitlePane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Axis_Title"), showTitle);
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(PaneTitleConstants.CHART_STYLE_TITLE_TITLE, panel); showTitle.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
checkTitlePane();
}
});
JPanel jPanel = new JPanel(new BorderLayout());
jPanel.add(showTitlePane, BorderLayout.NORTH);
jPanel.add(titlePane, BorderLayout.CENTER);
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(PaneTitleConstants.CHART_STYLE_TITLE_TITLE, jPanel);
} }
private UIButtonGroup<Integer> getXAxisTitleAlignPane(){ private UIButtonGroup<Integer> getXAxisTitleAlignPane() {
Icon[] alignmentIconArray = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal.png"), Icon[] alignmentIconArray = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal.png"),
BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal.png"),
BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal.png")}; BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal.png")};
@ -171,7 +188,8 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
return new UIButtonGroup<Integer>(alignmentIconArray, alignment); return new UIButtonGroup<Integer>(alignmentIconArray, alignment);
} }
private UIButtonGroup<Integer> getYAxisTitleAlignPane(){
private UIButtonGroup<Integer> getYAxisTitleAlignPane() {
Icon[] alignmentIconArray = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_top_normal.png"), Icon[] alignmentIconArray = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_top_normal.png"),
BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_center_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_center_normal.png"),
BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_down_normal.png")}; BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_down_normal.png")};
@ -180,7 +198,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
return new UIButtonGroup<Integer>(alignmentIconArray, alignment); return new UIButtonGroup<Integer>(alignmentIconArray, alignment);
} }
protected JPanel createLabelPane(double[] row, double[] col){ protected JPanel createLabelPane(double[] row, double[] col) {
showLabel = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Show"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Hidden")}); showLabel = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Show"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Hidden")});
labelTextAttrPane = getChartTextAttrPane(); labelTextAttrPane = getChartTextAttrPane();
@ -205,9 +223,9 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
new Component[]{gapPanel, null}, new Component[]{gapPanel, null},
}; };
JPanel showLabelPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Label"),showLabel); JPanel showLabelPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Label"), showLabel);
labelPanel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); labelPanel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col);
labelPanel.setBorder(BorderFactory.createEmptyBorder(0,10,0,0)); labelPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
showLabel.addActionListener(new ActionListener() { showLabel.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -308,11 +326,11 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
} }
protected ChartTextAttrPane getChartTextAttrPane(){ protected ChartTextAttrPane getChartTextAttrPane() {
return new ChartTextAttrPane(){ return new ChartTextAttrPane() {
@Override @Override
protected JPanel getContentPane (JPanel buttonPane) { protected JPanel getContentPane(JPanel buttonPane) {
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
double e = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH; double e = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH;
@ -324,10 +342,10 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
}; };
} }
protected JPanel createLineStylePane(double[] row, double[] col){ protected JPanel createLineStylePane(double[] row, double[] col) {
axisLineStyle = createLineComboBox(); axisLineStyle = createLineComboBox();
axisLineColor = new ColorSelectBox(100); axisLineColor = new ColorSelectBox(100);
String[] strings = new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Open"),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Close")}; String[] strings = new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Open"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Close")};
AxisTickLineType[] values = new AxisTickLineType[]{AxisTickLineType.TICK_LINE_OUTSIDE, AxisTickLineType.TICK_LINE_NONE}; AxisTickLineType[] values = new AxisTickLineType[]{AxisTickLineType.TICK_LINE_OUTSIDE, AxisTickLineType.TICK_LINE_NONE};
mainTick = new UIButtonGroup<AxisTickLineType>(strings, values); mainTick = new UIButtonGroup<AxisTickLineType>(strings, values);
secondTick = new UIButtonGroup<AxisTickLineType>(strings, values); secondTick = new UIButtonGroup<AxisTickLineType>(strings, values);
@ -342,15 +360,15 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
protected Component[][] getLineStylePaneComponents() { protected Component[][] getLineStylePaneComponents() {
return new Component[][]{ return new Component[][]{
new Component[]{null,null} , new Component[]{null, null},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Type")),axisLineStyle} , new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Type")), axisLineStyle},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color")),axisLineColor}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color")), axisLineColor},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Main_Graduation_Line")),mainTick}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Main_Graduation_Line")), mainTick},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Second_Graduation_Line")),secondTick}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Second_Graduation_Line")), secondTick},
}; };
} }
protected JPanel createAxisPositionPane(double[] row, double[] col, boolean isXAxis){ protected JPanel createAxisPositionPane(double[] row, double[] col, boolean isXAxis) {
position = new UIButtonGroup<Integer>(getAxisPositionNameArray(isXAxis), getAxisPositionValueArray(isXAxis)); position = new UIButtonGroup<Integer>(getAxisPositionNameArray(isXAxis), getAxisPositionValueArray(isXAxis));
reversed = new UIButtonGroup<Boolean>(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_On"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Off")}, new Boolean[]{true, false}); reversed = new UIButtonGroup<Boolean>(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_On"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Off")}, new Boolean[]{true, false});
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
@ -359,30 +377,30 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Label_Position")), FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Label_Position")),
UIComponentUtils.wrapWithBorderLayoutPane(position) UIComponentUtils.wrapWithBorderLayoutPane(position)
}, },
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_AxisReversed")),reversed}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_AxisReversed")), reversed},
} ; };
JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col);
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout_Position"), panel); return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout_Position"), panel);
} }
private String[] getAxisPositionNameArray(boolean isXAxis){ private String[] getAxisPositionNameArray(boolean isXAxis) {
if(isXAxis){ if (isXAxis) {
return new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Top"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Bottom"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Vertical_Zero")}; return new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Top"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Bottom"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Vertical_Zero")};
} else { } else {
return new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout_Left"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout_Right"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Vertical_Zero")}; return new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout_Left"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout_Right"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Vertical_Zero")};
} }
} }
private Integer[] getAxisPositionValueArray(boolean isXAxis){ private Integer[] getAxisPositionValueArray(boolean isXAxis) {
if(isXAxis){ if (isXAxis) {
return new Integer[]{VanChartConstants.AXIS_TOP, VanChartConstants.AXIS_BOTTOM, VanChartConstants.AXIS_VERTICAL_ZERO}; return new Integer[]{VanChartConstants.AXIS_TOP, VanChartConstants.AXIS_BOTTOM, VanChartConstants.AXIS_VERTICAL_ZERO};
} else { } else {
return new Integer[]{VanChartConstants.AXIS_LEFT, VanChartConstants.AXIS_RIGHT, VanChartConstants.AXIS_VERTICAL_ZERO}; return new Integer[]{VanChartConstants.AXIS_LEFT, VanChartConstants.AXIS_RIGHT, VanChartConstants.AXIS_VERTICAL_ZERO};
} }
} }
protected JPanel createDisplayStrategy(){ protected JPanel createDisplayStrategy() {
//区域显示策略 恢复用注释。删除到return,即除了注释的代码都删除。 //区域显示策略 恢复用注释。删除到return,即除了注释的代码都删除。
maxProportion = new UISpinner(0, 100, 1, 30); maxProportion = new UISpinner(0, 100, 1, 30);
axisLimitSize = new UIButtonGroup<Integer>(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Limit"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Not_Limit")}); axisLimitSize = new UIButtonGroup<Integer>(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Limit"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Not_Limit")});
@ -408,7 +426,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
// return limitPane; // return limitPane;
} }
protected JPanel createValueStylePane(){ protected JPanel createValueStylePane() {
valueFormatStyle = new UIButtonGroup<Integer>(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Common"), valueFormatStyle = new UIButtonGroup<Integer>(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Common"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom")}); com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom")});
@ -418,19 +436,19 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
htmlLabelPane = new VanChartHtmlLabelPane(); htmlLabelPane = new VanChartHtmlLabelPane();
centerPane = new JPanel(new CardLayout()); centerPane = new JPanel(new CardLayout());
centerPane.add(valueFormat,com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Common")); centerPane.add(valueFormat, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Common"));
centerPane.add(htmlLabelPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom")); centerPane.add(htmlLabelPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom"));
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
double[] columnSize = {p,f}; double[] columnSize = {p, f};
double[] rowSize = {p,p,p}; double[] rowSize = {p, p, p};
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{null,null}, new Component[]{null, null},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Label_Format"), SwingConstants.LEFT), valueFormatStyle}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Label_Format"), SwingConstants.LEFT), valueFormatStyle},
new Component[]{null, centerPane}, new Component[]{null, centerPane},
}; };
JPanel contentPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components,rowSize,columnSize); JPanel contentPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize);
valueFormatStyle.addActionListener(new ActionListener() { valueFormatStyle.addActionListener(new ActionListener() {
@ -443,12 +461,12 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Format"), contentPane); return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Format"), contentPane);
} }
protected FormatPane createFormatPane(){ protected FormatPane createFormatPane() {
return new FormatPane(){ return new FormatPane() {
protected Component[][] getComponent (JPanel fontPane, JPanel centerPane, JPanel typePane) { protected Component[][] getComponent(JPanel fontPane, JPanel centerPane, JPanel typePane) {
typePane.setBorder(BorderFactory.createEmptyBorder()); typePane.setBorder(BorderFactory.createEmptyBorder());
return new Component[][]{ return new Component[][]{
new Component[]{typePane,null}, new Component[]{typePane, null},
new Component[]{centerPane, null}, new Component[]{centerPane, null},
}; };
} }
@ -462,6 +480,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
protected void checkAllUse() { protected void checkAllUse() {
checkCardPane(); checkCardPane();
checkLabelPane(); checkLabelPane();
checkTitlePane();
//区域显示策略 恢复用注释。删除下面一行。 //区域显示策略 恢复用注释。删除下面一行。
checkMaxProPortionUse(); checkMaxProPortionUse();
@ -480,10 +499,10 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
} }
protected void checkCardPane() { protected void checkCardPane() {
if(centerPane != null && valueFormatStyle != null){ if (centerPane != null && valueFormatStyle != null) {
CardLayout cardLayout = (CardLayout) centerPane.getLayout(); CardLayout cardLayout = (CardLayout) centerPane.getLayout();
if (valueFormatStyle.getSelectedIndex() == 1) { if (valueFormatStyle.getSelectedIndex() == 1) {
cardLayout.show(centerPane,com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom")); cardLayout.show(centerPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom"));
} else { } else {
cardLayout.show(centerPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Common")); cardLayout.show(centerPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Common"));
} }
@ -491,12 +510,12 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
} }
protected void checkLabelPane() { protected void checkLabelPane() {
if(showLabel != null){ if (showLabel != null) {
boolean enabled = showLabel.getSelectedIndex() == 0; boolean enabled = showLabel.getSelectedIndex() == 0;
if(labelPanel != null){ if (labelPanel != null) {
labelPanel.setVisible(enabled); labelPanel.setVisible(enabled);
} }
if(enabled){ if (enabled) {
//轴标签缩略间隔显示 恢复用注释。下面1行删除。 //轴标签缩略间隔显示 恢复用注释。下面1行删除。
checkLabelGapValuePane(); checkLabelGapValuePane();
//轴标签缩略间隔显示 恢复用注释。取消注释。 //轴标签缩略间隔显示 恢复用注释。取消注释。
@ -505,6 +524,12 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
} }
} }
protected void checkTitlePane() {
if (showTitle != null && titlePane != null) {
titlePane.setVisible(showTitle.getSelectedIndex() == 0);
}
}
private void checkLabelGapAndStylePane() { private void checkLabelGapAndStylePane() {
if (overlapHandleTypeGroup != null && labelGapStylePane != null) { if (overlapHandleTypeGroup != null && labelGapStylePane != null) {
boolean visible = overlapHandleTypeGroup.getSelectedItem() == OverlapHandleType.INTERVAL; boolean visible = overlapHandleTypeGroup.getSelectedItem() == OverlapHandleType.INTERVAL;
@ -528,28 +553,31 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
/** /**
* 是否是指定类型 * 是否是指定类型
*
* @param ob 对象 * @param ob 对象
* @return 是否是指定类型 * @return 是否是指定类型
*/ */
public boolean accept(Object ob){ public boolean accept(Object ob) {
return false; return false;
} }
/** /**
* title应该是一个属性不只是对话框的标题时用到与其他组件结合时也会用得到 * title应该是一个属性不只是对话框的标题时用到与其他组件结合时也会用得到
*
* @return 绥化狂标题 * @return 绥化狂标题
*/ */
@Override @Override
public String title4PopupWindow(){ public String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Category_Axis"); return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Category_Axis");
} }
/** /**
* 重置 * 重置
*/ */
public void reset(){ public void reset() {
} }
@Override @Override
public void populateBean(VanChartAxis axis) { public void populateBean(VanChartAxis axis) {
populateTitle(axis); populateTitle(axis);
@ -568,50 +596,53 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
} }
//标题 //标题
private void populateTitle(VanChartAxis axis){ private void populateTitle(VanChartAxis axis) {
if (showTitle != null) {
showTitle.setSelectedIndex(axis.isShowAxisTitle() ? 0 : 1);
}
Title axisTitle = axis.getTitle(); Title axisTitle = axis.getTitle();
if(axisTitle != null){ if (axisTitle != null) {
if (axisTitle.getTextObject() instanceof BaseFormula && titleContent != null) { if (axisTitle.getTextObject() instanceof BaseFormula && titleContent != null) {
titleContent.populateBean(((BaseFormula) axisTitle.getTextObject()).getContent()); titleContent.populateBean(((BaseFormula) axisTitle.getTextObject()).getContent());
} else if(titleContent != null){ } else if (titleContent != null) {
titleContent.populateBean(Utils.objectToString(axisTitle.getTextObject())); titleContent.populateBean(Utils.objectToString(axisTitle.getTextObject()));
} }
if(titleAlignPane != null){ if (titleAlignPane != null) {
titleAlignPane.setSelectedItem(axisTitle.getPosition()); titleAlignPane.setSelectedItem(axisTitle.getPosition());
} }
if(titleTextAttrPane != null){ if (titleTextAttrPane != null) {
titleTextAttrPane.populate(axisTitle.getTextAttr()); titleTextAttrPane.populate(axisTitle.getTextAttr());
} }
if(titleUseHtml != null){ if (titleUseHtml != null) {
titleUseHtml.setSelected(axis.isTitleUseHtml()); titleUseHtml.setSelected(axis.isTitleUseHtml());
} }
if(titleTextRotation != null){ if (titleTextRotation != null) {
titleTextRotation.populateBean((double)axisTitle.getTextAttr().getRotation()); titleTextRotation.populateBean((double) axisTitle.getTextAttr().getRotation());
} }
} }
} }
//标签 //标签
private void populateLabel(VanChartAxis axis){ private void populateLabel(VanChartAxis axis) {
if(showLabel != null){ if (showLabel != null) {
showLabel.setSelectedIndex(axis.isShowAxisLabel() ? 0 : 1); showLabel.setSelectedIndex(axis.isShowAxisLabel() ? 0 : 1);
} }
TextAttr labelTextAttr = axis.getTextAttr(); TextAttr labelTextAttr = axis.getTextAttr();
if(labelTextAttrPane != null){ if (labelTextAttrPane != null) {
labelTextAttrPane.populate(labelTextAttr); labelTextAttrPane.populate(labelTextAttr);
} }
if(labelTextRotation != null){ if (labelTextRotation != null) {
labelTextRotation.populateBean((double)labelTextAttr.getRotation()); labelTextRotation.populateBean((double) labelTextAttr.getRotation());
} }
//轴标签缩略间隔显示 恢复用注释。取消注释。 //轴标签缩略间隔显示 恢复用注释。取消注释。
// if (overlapHandleTypeGroup != null) { // if (overlapHandleTypeGroup != null) {
// overlapHandleTypeGroup.setSelectedItem(axis.getOverlapHandleType()); // overlapHandleTypeGroup.setSelectedItem(axis.getOverlapHandleType());
// } // }
if(labelGapStyle != null){ if (labelGapStyle != null) {
labelGapStyle.setSelectedIndex(axis.isAutoLabelGap() ? 0 : 1); labelGapStyle.setSelectedIndex(axis.isAutoLabelGap() ? 0 : 1);
} }
if(labelGapValue != null){ if (labelGapValue != null) {
//轴标签缩略间隔显示 恢复用注释。下面1行删除。 //轴标签缩略间隔显示 恢复用注释。下面1行删除。
labelGapValue.setText(axis.getLabelNumber().getContent()); labelGapValue.setText(axis.getLabelNumber().getContent());
//轴标签缩略间隔显示 恢复用注释。取消注释。 //轴标签缩略间隔显示 恢复用注释。取消注释。
@ -620,30 +651,30 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
} }
//轴线样式 //轴线样式
private void populateLineStyle(VanChartAxis axis){ private void populateLineStyle(VanChartAxis axis) {
if(axisLineStyle != null){ if (axisLineStyle != null) {
axisLineStyle.setSelectedLineStyle(axis.getAxisStyle()); axisLineStyle.setSelectedLineStyle(axis.getAxisStyle());
} }
if(axisLineColor != null){ if (axisLineColor != null) {
axisLineColor.setSelectObject(axis.getAxisColor()); axisLineColor.setSelectObject(axis.getAxisColor());
} }
if(mainTick != null){ if (mainTick != null) {
mainTick.setSelectedItem(axis.getMainTickLine()); mainTick.setSelectedItem(axis.getMainTickLine());
} }
if(secondTick != null){ if (secondTick != null) {
secondTick.setSelectedItem(axis.getSecTickLine()); secondTick.setSelectedItem(axis.getSecTickLine());
} }
} }
//位置 //位置
private void populatePosition(VanChartAxis axis){ private void populatePosition(VanChartAxis axis) {
if(position != null){ if (position != null) {
position.setSelectedItem(axis.getPosition()); position.setSelectedItem(axis.getPosition());
if(position.getSelectedItem() == null){ if (position.getSelectedItem() == null) {
position.setSelectedIndex(1); position.setSelectedIndex(1);
} }
} }
if(reversed != null){ if (reversed != null) {
reversed.setSelectedIndex(axis.hasAxisReversed() == true ? 0 : 1); reversed.setSelectedIndex(axis.hasAxisReversed() == true ? 0 : 1);
} }
} }
@ -666,13 +697,13 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
//格式 //格式
protected void populateFormat(VanChartAxis axis) { protected void populateFormat(VanChartAxis axis) {
if(valueFormatStyle != null){ if (valueFormatStyle != null) {
valueFormatStyle.setSelectedIndex(axis.isCommonValueFormat() ? 0 : 1); valueFormatStyle.setSelectedIndex(axis.isCommonValueFormat() ? 0 : 1);
} }
if(valueFormat != null){ if (valueFormat != null) {
valueFormat.populateBean(axis.getFormat()); valueFormat.populateBean(axis.getFormat());
} }
if(htmlLabelPane != null){ if (htmlLabelPane != null) {
htmlLabelPane.populate(axis.getHtmlLabel()); htmlLabelPane.populate(axis.getHtmlLabel());
} }
} }
@ -690,15 +721,19 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
updateFormat(axis); updateFormat(axis);
} }
//标题 //标题
private void updateTitle(VanChartAxis axis){ private void updateTitle(VanChartAxis axis) {
if (showTitle != null) {
axis.setShowAxisTitle(showTitle.getSelectedIndex() == 0);
}
Title axisTitle = axis.getTitle(); Title axisTitle = axis.getTitle();
if(axisTitle == null){ if (axisTitle == null) {
axisTitle = new Title(); axisTitle = new Title();
axis.setTitle(axisTitle); axis.setTitle(axisTitle);
} }
if(titleContent != null){ if (titleContent != null) {
String titleString = titleContent.updateBean(); String titleString = titleContent.updateBean();
Object titleObj; Object titleObj;
if (StableUtils.maybeFormula(titleString)) { if (StableUtils.maybeFormula(titleString)) {
@ -708,42 +743,42 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
} }
axisTitle.setTextObject(titleObj); axisTitle.setTextObject(titleObj);
} }
if(titleAlignPane != null){ if (titleAlignPane != null) {
axisTitle.setPosition(titleAlignPane.getSelectedItem()); axisTitle.setPosition(titleAlignPane.getSelectedItem());
} }
TextAttr textAttr = axisTitle.getTextAttr(); TextAttr textAttr = axisTitle.getTextAttr();
if(titleTextAttrPane != null){ if (titleTextAttrPane != null) {
titleTextAttrPane.update(textAttr); titleTextAttrPane.update(textAttr);
} }
if(titleUseHtml != null){ if (titleUseHtml != null) {
axis.setTitleUseHtml(titleUseHtml.isSelected()); axis.setTitleUseHtml(titleUseHtml.isSelected());
} }
if(titleTextRotation != null){ if (titleTextRotation != null) {
textAttr.setRotation(titleTextRotation.updateBean().intValue()); textAttr.setRotation(titleTextRotation.updateBean().intValue());
} }
} }
//标签 //标签
private void updateLabel(VanChartAxis axis){ private void updateLabel(VanChartAxis axis) {
if(showLabel != null){ if (showLabel != null) {
axis.setShowAxisLabel(showLabel.getSelectedIndex() == 0); axis.setShowAxisLabel(showLabel.getSelectedIndex() == 0);
} }
TextAttr labelTextAttr = axis.getTextAttr(); TextAttr labelTextAttr = axis.getTextAttr();
if(labelTextAttrPane != null){ if (labelTextAttrPane != null) {
labelTextAttrPane.update(labelTextAttr); labelTextAttrPane.update(labelTextAttr);
} }
if(labelTextRotation != null){ if (labelTextRotation != null) {
labelTextAttr.setRotation(labelTextRotation.updateBean().intValue()); labelTextAttr.setRotation(labelTextRotation.updateBean().intValue());
} }
//轴标签缩略间隔显示 恢复用注释。取消注释。 //轴标签缩略间隔显示 恢复用注释。取消注释。
// if (overlapHandleTypeGroup != null) { // if (overlapHandleTypeGroup != null) {
// axis.setOverlapHandleType(overlapHandleTypeGroup.getSelectedItem()); // axis.setOverlapHandleType(overlapHandleTypeGroup.getSelectedItem());
// } // }
if(labelGapStyle != null){ if (labelGapStyle != null) {
axis.setAutoLabelGap(labelGapStyle.getSelectedIndex() == 0); axis.setAutoLabelGap(labelGapStyle.getSelectedIndex() == 0);
} }
if(labelGapValue != null){ if (labelGapValue != null) {
//轴标签缩略间隔显示 恢复用注释。下面5行删除。 //轴标签缩略间隔显示 恢复用注释。下面5行删除。
if (axis.isAutoLabelGap()) { if (axis.isAutoLabelGap()) {
axis.setLabelIntervalNumber(BaseFormula.createFormulaBuilder().build("1")); axis.setLabelIntervalNumber(BaseFormula.createFormulaBuilder().build("1"));
@ -756,33 +791,33 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
} }
//轴线样式 //轴线样式
private void updateLineStyle(VanChartAxis axis){ private void updateLineStyle(VanChartAxis axis) {
if(axisLineStyle != null){ if (axisLineStyle != null) {
axis.setAxisStyle(axisLineStyle.getSelectedLineStyle()); axis.setAxisStyle(axisLineStyle.getSelectedLineStyle());
} }
if(axisLineColor != null){ if (axisLineColor != null) {
axis.setAxisColor(axisLineColor.getSelectObject()); axis.setAxisColor(axisLineColor.getSelectObject());
} }
if(mainTick != null){ if (mainTick != null) {
axis.setMainTickLine(mainTick.getSelectedItem()); axis.setMainTickLine(mainTick.getSelectedItem());
} }
if(secondTick != null){ if (secondTick != null) {
axis.setSecTickLine(secondTick.getSelectedItem()); axis.setSecTickLine(secondTick.getSelectedItem());
} }
} }
//位置 //位置
private void updatePosition(VanChartAxis axis){ private void updatePosition(VanChartAxis axis) {
if(position != null){ if (position != null) {
axis.setPosition(position.getSelectedItem()); axis.setPosition(position.getSelectedItem());
} }
if(reversed != null){ if (reversed != null) {
axis.setAxisReversed(reversed.getSelectedItem()); axis.setAxisReversed(reversed.getSelectedItem());
} }
} }
//显示策略 //显示策略
private void updateDisplayStrategy(VanChartAxis axis){ private void updateDisplayStrategy(VanChartAxis axis) {
//区域显示策略 恢复用注释。下面6行删除。 //区域显示策略 恢复用注释。下面6行删除。
if (axisLimitSize != null) { if (axisLimitSize != null) {
axis.setLimitSize(axisLimitSize.getSelectedIndex() == 0); axis.setLimitSize(axisLimitSize.getSelectedIndex() == 0);
@ -797,29 +832,30 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
} }
protected void updateFormat(VanChartAxis axis) { protected void updateFormat(VanChartAxis axis) {
if(valueFormatStyle != null){ if (valueFormatStyle != null) {
axis.setCommonValueFormat(valueFormatStyle.getSelectedIndex() == 0); axis.setCommonValueFormat(valueFormatStyle.getSelectedIndex() == 0);
} }
if(valueFormat != null){ if (valueFormat != null) {
axis.setFormat(valueFormat.update()); axis.setFormat(valueFormat.update());
} }
if(htmlLabelPane != null){ if (htmlLabelPane != null) {
htmlLabelPane.update(axis.getHtmlLabel()); htmlLabelPane.update(axis.getHtmlLabel());
} }
} }
/** /**
* X坐标轴不同类型切换,new一个新的 * X坐标轴不同类型切换,new一个新的
*
* @param axisName 坐标轴名称 * @param axisName 坐标轴名称
* @return 新的axis * @return 新的axis
*/ */
public VanChartAxis updateBean(String axisName, int position){ public VanChartAxis updateBean(String axisName, int position) {
VanChartAxis axis = new VanChartAxis(axisName, position); VanChartAxis axis = new VanChartAxis(axisName, position);
this.updateBean(axis); this.updateBean(axis);
return axis; return axis;
} }
public VanChartAxis updateBean(){ public VanChartAxis updateBean() {
return null; return null;
} }
} }

8
designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartTimeAxisPane.java

@ -27,15 +27,15 @@ import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.text.ParseException;
import java.util.Date;
import java.util.regex.Pattern;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.text.ParseException;
import java.util.Date;
import java.util.regex.Pattern;
/** /**
* 时间坐标轴 * 时间坐标轴
@ -68,7 +68,7 @@ public class VanChartTimeAxisPane extends VanChartBaseAxisPane {
double[] column = {f, s}; double[] column = {f, s};
double[] rowSize = {p,p,p,p,p,p,p,p,p,p,p,p,p,p}; double[] rowSize = {p,p,p,p,p,p,p,p,p,p,p,p,p,p};
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{createTitlePane(new double[]{p, p, p, p, p,p}, columnSize, isXAxis),null}, new Component[]{createTitlePane(new double[]{p, p, p, p, p,p}, column, isXAxis),null},
new Component[]{createLabelPane(new double[]{p, p}, column),null}, new Component[]{createLabelPane(new double[]{p, p}, column),null},
new Component[]{createValueDefinition(),null}, new Component[]{createValueDefinition(),null},
new Component[]{createLineStylePane(new double[]{p, p,p,p,p}, columnSize),null}, new Component[]{createLineStylePane(new double[]{p, p,p,p,p}, columnSize),null},

2
designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartValueAxisPane.java

@ -49,7 +49,7 @@ public class VanChartValueAxisPane extends VanChartBaseAxisPane {
double[] column = {f, s}; double[] column = {f, s};
double[] rowSize = {p,p,p,p,p,p,p,p,p,p,p,p,p,p}; double[] rowSize = {p,p,p,p,p,p,p,p,p,p,p,p,p,p};
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{createTitlePane(new double[]{p, p, p, p, p, p}, columnSize, isXAxis), null}, new Component[]{createTitlePane(new double[]{p, p, p, p, p, p}, column, isXAxis), null},
new Component[]{createLabelPane(new double[]{p, p}, column), null}, new Component[]{createLabelPane(new double[]{p, p}, column), null},
new Component[]{createMinMaxValuePane(new double[]{p, p}, columnSize), null}, new Component[]{createMinMaxValuePane(new double[]{p, p}, columnSize), null},
new Component[]{createLineStylePane(new double[]{p, p, p, p, p}, columnSize), null}, new Component[]{createLineStylePane(new double[]{p, p, p, p, p}, columnSize), null},

12
designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/table/VanPointMapPlotTableDataContentPane.java

@ -4,9 +4,11 @@ import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ilable.BoldFontTextLabel; import com.fr.design.gui.ilable.BoldFontTextLabel;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.widget.FRWidgetFactory;
import com.fr.plugin.chart.map.data.VanMapTableDefinitionProvider; import com.fr.plugin.chart.map.data.VanMapTableDefinitionProvider;
import com.fr.van.chart.map.designer.data.component.table.AbstractLongLatAreaPane; import com.fr.van.chart.map.designer.data.component.table.AbstractLongLatAreaPane;
import com.fr.van.chart.map.designer.data.component.table.AreaPane; import com.fr.van.chart.map.designer.data.component.table.AreaPane;
@ -91,6 +93,7 @@ public class VanPointMapPlotTableDataContentPane extends VanAreaMapPlotTableData
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
double labelWidth = 65;
this.setLayout(new BorderLayout(0, 5)); this.setLayout(new BorderLayout(0, 5));
centerPane = new JPanel(new CardLayout()) { centerPane = new JPanel(new CardLayout()) {
@ -122,13 +125,14 @@ public class VanPointMapPlotTableDataContentPane extends VanAreaMapPlotTableData
locationType.setSelectedIndex(0); locationType.setSelectedIndex(0);
double[] columnSize = {p, f}; double[] columnSize = {labelWidth, f};
double[] rowSize = {p}; double[] rowSize = {p};
UILabel label = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Geographic"));
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Geographic")), locationType}, new Component[]{label, locationType},
}; };
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 30, 6); JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 5, 6);
this.add(panel, BorderLayout.NORTH); this.add(panel, BorderLayout.NORTH);
this.add(centerPane, BorderLayout.CENTER); this.add(centerPane, BorderLayout.CENTER);
@ -219,7 +223,7 @@ public class VanPointMapPlotTableDataContentPane extends VanAreaMapPlotTableData
return new PointMapAreaPane(longLatAreaTableComboPane) { return new PointMapAreaPane(longLatAreaTableComboPane) {
protected void initAreaPane(VanPointMapPlotTableDataContentPane.LongLatAreaTableComboPane parentPane) { protected void initAreaPane(VanPointMapPlotTableDataContentPane.LongLatAreaTableComboPane parentPane) {
areaPane = new AreaPane(parentPane) { areaPane = new AreaPane(parentPane) {
protected Component[][] getComponent () { protected Component[][] getComponent() {
return new Component[][]{ return new Component[][]{
new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Area_Name")), VanPointMapPlotTableDataContentPane.this.createAreaPanel(areaNameCom)} new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Area_Name")), VanPointMapPlotTableDataContentPane.this.createAreaPanel(areaNameCom)}
}; };

2
designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java

@ -262,7 +262,7 @@ public class SelectionModel {
Rectangle rec = selection.getSelctionBounds(); Rectangle rec = selection.getSelctionBounds();
FormSelectionUtils.paste2Container(designer, container, clipboard, rec.x + DELTA_X_Y, rec.y + DELTA_X_Y); FormSelectionUtils.paste2Container(designer, container, clipboard, rec.x + DELTA_X_Y, rec.y + DELTA_X_Y);
} else if (isExtraContainer(container)) { } else if (isExtraContainer(container)) {
provider.paste2Container(selection); provider.paste2Container(clipboard);
} }
} }

61
designer-form/src/main/java/com/fr/design/mainframe/ShareWidgetButton.java

@ -14,6 +14,7 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.share.ShareConstants; import com.fr.share.ShareConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import org.jetbrains.annotations.NotNull;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
@ -52,12 +53,12 @@ import java.io.Serializable;
*/ */
public class ShareWidgetButton extends JPanel implements MouseListener, MouseMotionListener, Serializable { public class ShareWidgetButton extends JPanel implements MouseListener, MouseMotionListener, Serializable {
private static final Dimension TAB_DEFAULT_SIZE = new Dimension(500, 300); protected SharableWidgetProvider bindInfo;
private SharableWidgetProvider bindInfo; protected MouseEvent lastPressEvent;
private MouseEvent lastPressEvent; protected JPanel reportPane;
private JPanel reportPane; protected boolean isEdit;
private boolean isEdit; protected boolean isMarked;
private boolean isMarked; private ShareWidgetUI ui;
private Icon markedMode = IOUtils.readIcon("/com/fr/design/form/images/marked.png"); private Icon markedMode = IOUtils.readIcon("/com/fr/design/form/images/marked.png");
private Icon unMarkedMode = IOUtils.readIcon("/com/fr/design/form/images/unmarked.png"); private Icon unMarkedMode = IOUtils.readIcon("/com/fr/design/form/images/unmarked.png");
private AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 60 / 100.0F); private AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 60 / 100.0F);
@ -71,9 +72,11 @@ public class ShareWidgetButton extends JPanel implements MouseListener, MouseMot
unMarkedMode.paintIcon(this, g, 0, 0); unMarkedMode.paintIcon(this, g, 0, 0);
} }
}; };
public ShareWidgetButton(SharableWidgetProvider bindInfo) { public ShareWidgetButton(SharableWidgetProvider bindInfo, ShareWidgetUI ui) {
this.bindInfo = bindInfo; this.bindInfo = bindInfo;
this.ui = ui;
this.setPreferredSize(new Dimension(108, 68)); this.setPreferredSize(new Dimension(108, 68));
initUI(); initUI();
this.setLayout(getCoverLayout()); this.setLayout(getCoverLayout());
@ -81,7 +84,12 @@ public class ShareWidgetButton extends JPanel implements MouseListener, MouseMot
this.addMouseMotionListener(this); this.addMouseMotionListener(this);
new DragAndDropDragGestureListener(this, DnDConstants.ACTION_COPY_OR_MOVE); new DragAndDropDragGestureListener(this, DnDConstants.ACTION_COPY_OR_MOVE);
} }
public ShareWidgetButton(SharableWidgetProvider bindInfo) {
this(bindInfo, new ShareWidgetUI());
}
public void paint(Graphics g) { public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
Composite oldComposite = g2d.getComposite(); Composite oldComposite = g2d.getComposite();
@ -219,21 +227,14 @@ public class ShareWidgetButton extends JPanel implements MouseListener, MouseMot
if (creatorSource != null) { if (creatorSource != null) {
((AbstractBorderStyleWidget)creatorSource).addWidgetAttrMark(new SharableAttrMark(true)); ((AbstractBorderStyleWidget)creatorSource).addWidgetAttrMark(new SharableAttrMark(true));
//tab布局WCardMainBorderLayout通过反射出来的大小是960*480 //tab布局WCardMainBorderLayout通过反射出来的大小是960*480
XCreator xCreator = null; XCreator xCreator = ui.createXCreator(creatorSource, shareId, no.getBindInfo());
if (creatorSource instanceof WCardMainBorderLayout) {
xCreator = XCreatorUtils.createXCreator(creatorSource, TAB_DEFAULT_SIZE);
} else {
xCreator = XCreatorUtils.createXCreator(creatorSource);
}
xCreator.setBackupBound(new Rectangle(no.getBindInfo().getWidth(), no.getBindInfo().getHeight()));
xCreator.setShareId(shareId);
WidgetToolBarPane.getTarget().startDraggingBean(xCreator); WidgetToolBarPane.getTarget().startDraggingBean(xCreator);
lastPressEvent = null; lastPressEvent = null;
this.setBorder(null); this.setBorder(null);
} }
} }
} }
@Override @Override
public void mouseMoved(MouseEvent e) { public void mouseMoved(MouseEvent e) {
@ -283,9 +284,31 @@ public class ShareWidgetButton extends JPanel implements MouseListener, MouseMot
} }
return false; return false;
} }
public Object getTransferData(DataFlavor df) throws UnsupportedFlavorException, IOException { public Object getTransferData(DataFlavor df) throws UnsupportedFlavorException, IOException {
return widget; return widget;
} }
} }
/**
* 抽出来专门为了创建 ui 来搞
*/
public static class ShareWidgetUI {
private static final Dimension TAB_DEFAULT_SIZE = new Dimension(500, 300);
@NotNull
public XCreator createXCreator(Widget creatorSource, String shareId, SharableWidgetProvider provider) {
XCreator xCreator = null;
if (creatorSource instanceof WCardMainBorderLayout) {
xCreator = XCreatorUtils.createXCreator(creatorSource, TAB_DEFAULT_SIZE);
} else {
xCreator = XCreatorUtils.createXCreator(creatorSource, new Dimension(provider.getWidth(), provider.getHeight()));
}
xCreator.setBackupBound(new Rectangle(provider.getWidth(), provider.getHeight()));
xCreator.setShareId(shareId);
return xCreator;
}
}
} }

38
designer-form/src/test/java/com/fr/design/mainframe/ShareWidgetButtonTest.java

@ -0,0 +1,38 @@
package com.fr.design.mainframe;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.design.designer.creator.XCreator;
import com.fr.form.share.SharableWidgetProvider;
import com.fr.form.ui.ChartEditor;
import com.fr.general.ImageWithSuffix;
import com.fr.invoke.Reflect;
import org.easymock.EasyMock;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
@PowerMockIgnore({"com.fr.jvm.assist.*", "javax.swing.*"})
public class ShareWidgetButtonTest {
@Test
public void testCreateXCreator() throws Exception {
SharableWidgetProvider provider = EasyMock.mock(SharableWidgetProvider.class);
EasyMock.expect(provider.getWidth()).andReturn(300).anyTimes();
EasyMock.expect(provider.getHeight()).andReturn(400).anyTimes();
EasyMock.expect(provider.getName()).andReturn("test-drag").anyTimes();
EasyMock.expect(provider.getCover()).andReturn(new ImageWithSuffix("utf-8")).anyTimes();
EasyMock.replay(provider);
ShareWidgetButton.ShareWidgetUI ui = new ShareWidgetButton.ShareWidgetUI();
ChartEditor editor = new ChartEditor();
Reflect.on(editor).set("chartCollection", new ChartCollection());
XCreator xCreator = ui.createXCreator(editor, "333", provider);
Assert.assertEquals(300, xCreator.getWidth());
Assert.assertEquals(400, xCreator.getHeight());
}
}

10
designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java

@ -256,8 +256,11 @@ public class RichTextToolBar extends BasicPane{
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
boolean isSub = RichTextToolBar.this.subPane.isSelected(); boolean isSub = RichTextToolBar.this.subPane.isSelected();
// 调用setCharacterAttributes函数设置文本区选择文本的字体
MutableAttributeSet attr = new SimpleAttributeSet(); MutableAttributeSet attr = new SimpleAttributeSet();
if (!isSub && RichTextToolBar.this.superPane.isSelected()) {
StyleConstants.setSuperscript(attr, false);
}
// 调用setCharacterAttributes函数设置文本区选择文本的字体
StyleConstants.setSubscript(attr, !isSub); StyleConstants.setSubscript(attr, !isSub);
setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); setCharacterAttributes(RichTextToolBar.this.textPane, attr, false);
} }
@ -269,6 +272,9 @@ public class RichTextToolBar extends BasicPane{
boolean isSuper = RichTextToolBar.this.superPane.isSelected(); boolean isSuper = RichTextToolBar.this.superPane.isSelected();
// 调用setCharacterAttributes函数设置文本区选择文本的字体 // 调用setCharacterAttributes函数设置文本区选择文本的字体
MutableAttributeSet attr = new SimpleAttributeSet(); MutableAttributeSet attr = new SimpleAttributeSet();
if (!isSuper && RichTextToolBar.this.subPane.isSelected()) {
StyleConstants.setSubscript(attr, false);
}
StyleConstants.setSuperscript(attr, !isSuper); StyleConstants.setSuperscript(attr, !isSuper);
setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); setCharacterAttributes(RichTextToolBar.this.textPane, attr, false);
} }
@ -402,7 +408,7 @@ public class RichTextToolBar extends BasicPane{
bold.setSelected(isBold); bold.setSelected(isBold);
italic.setSelected(isItalic); italic.setSelected(isItalic);
underline.setSelected(isUnderline); underline.setSelected(isUnderline);
subPane.setSelected(isSubscript); subPane.setSelected(isSuperscript ? false : isSubscript);
superPane.setSelected(isSuperscript); superPane.setSelected(isSuperscript);
//为什么字体名称, 大小, 颜色, 不需要去判断是否全相同呢 //为什么字体名称, 大小, 颜色, 不需要去判断是否全相同呢
//因为如果全相同, 则设置为第一个字符的样式, 如果不全相同, 那么默认也设置成第一个字符的样式. //因为如果全相同, 则设置为第一个字符的样式, 如果不全相同, 那么默认也设置成第一个字符的样式.

2
designer-realize/src/main/java/com/fr/design/mainframe/SheetNameTabPane.java

@ -945,7 +945,7 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse
// marks:判断是否重名 // marks:判断是否重名
boolean isExisted = false; boolean isExisted = false;
for (int i = 0; i < reportComposite.getEditingWorkBook().getReportCount(); i++) { for (int i = 0; i < reportComposite.getEditingWorkBook().getReportCount(); i++) {
if (newName.equalsIgnoreCase(reportComposite.getEditingWorkBook().getReportName(i))) { if (newName.equalsIgnoreCase(reportComposite.getEditingWorkBook().getReportName(i)) && i != selectedIndex) {
isExisted = true; isExisted = true;
break; break;
} }

19
designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellFormulaQuickEditor.java

@ -9,7 +9,6 @@ import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.formula.FormulaFactory; import com.fr.design.formula.FormulaFactory;
import com.fr.design.formula.UIFormula; import com.fr.design.formula.UIFormula;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
@ -20,6 +19,7 @@ import com.fr.grid.selection.CellSelection;
import com.fr.quickeditor.CellQuickEditor; import com.fr.quickeditor.CellQuickEditor;
import com.fr.report.ReportHelper; import com.fr.report.ReportHelper;
import com.fr.report.cell.DefaultTemplateCellElement; import com.fr.report.cell.DefaultTemplateCellElement;
import com.fr.report.cell.TemplateCellElement;
import com.fr.stable.ColumnRow; import com.fr.stable.ColumnRow;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -56,6 +56,9 @@ public class CellFormulaQuickEditor extends CellQuickEditor {
//默认值 //默认值
private static final String DEFAULT_FORMULA = "="; private static final String DEFAULT_FORMULA = "=";
//正在编辑的单元格
private TemplateCellElement editingCellElement;
private DocumentListener documentListener = new DocumentListener() { private DocumentListener documentListener = new DocumentListener() {
@Override @Override
public void insertUpdate(DocumentEvent e) { public void insertUpdate(DocumentEvent e) {
@ -102,19 +105,27 @@ public class CellFormulaQuickEditor extends CellQuickEditor {
formulaButton.setPreferredSize(new Dimension(20, formulaTextField.getPreferredSize().height)); formulaButton.setPreferredSize(new Dimension(20, formulaTextField.getPreferredSize().height));
formulaButton.addActionListener(new ActionListener() { formulaButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
String text = formulaTextField.getText();
final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula(); final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula();
formulaPane.populate(BaseFormula.createFormulaBuilder().build(text)); CellSelection cellSelection = (CellSelection) tc.getSelection();
editingCellElement = tc.getEditingElementCase().getTemplateCellElement(cellSelection.getColumn(), cellSelection.getRow());
Object object = editingCellElement.getValue();
if (object instanceof BaseFormula) {
formulaPane.populate((BaseFormula) object);
} else {
String text = formulaTextField.getText();
formulaPane.populate(BaseFormula.createFormulaBuilder().build(text));
}
formulaPane.showLargeWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { formulaPane.showLargeWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
@Override @Override
public void doOk() { public void doOk() {
BaseFormula fm = formulaPane.update(); BaseFormula fm = formulaPane.update();
if (fm.getContent().length() <= 1) { if (fm.getContent().length() <= 1) {
fm.setContent(DEFAULT_FORMULA);
formulaTextField.setText(DEFAULT_FORMULA); formulaTextField.setText(DEFAULT_FORMULA);
} else { } else {
formulaTextField.setText(fm.getContent()); formulaTextField.setText(fm.getContent());
} }
editingCellElement.setValue(fm);
} }
}).setVisible(true); }).setVisible(true);
} }

Loading…
Cancel
Save