Browse Source

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

* commit 'fabd06ef62dcc5311bf4b62975dbd9762d0d340c': (73 commits)
  REPORT-34780 && CHART-14441
  CHART-14624  调整面积图系列面板不透明的enable属性的check
  REPORT-35381 && REPORT-35379
  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条件合并
  ...
feature/big-screen
Qinghui.Liu 4 years ago
parent
commit
e150d25183
  1. 2
      designer-base/src/main/java/com/fr/design/actions/help/AboutDialog.java
  2. 12
      designer-base/src/main/java/com/fr/design/actions/help/AboutPane.java
  3. 14
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java
  4. 5
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java
  5. 719
      designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java
  6. 6
      designer-base/src/main/java/com/fr/design/dialog/FineJOptionPane.java
  7. 20
      designer-base/src/main/java/com/fr/design/extra/exe/GetPluginCategoriesExecutor.java
  8. 83
      designer-base/src/main/java/com/fr/design/formula/FormulaPane.java
  9. 12
      designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java
  10. 10
      designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java
  11. 25
      designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfo.java
  12. 17
      designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java
  13. 1
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBar.java
  14. 6
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogMessageBar.java
  15. 6
      designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java
  16. 1
      designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java
  17. 15
      designer-chart/src/main/java/com/fr/design/chart/AutoChartDialog.java
  18. 2
      designer-chart/src/main/java/com/fr/design/chart/AutoChartIcon.java
  19. 122
      designer-chart/src/main/java/com/fr/design/chart/AutoChartTypePane.java
  20. 18
      designer-chart/src/main/java/com/fr/design/chart/ChartDialog.java
  21. 143
      designer-chart/src/main/java/com/fr/design/chart/auto/AutoTypeCalculate.java
  22. 26
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java
  23. 1
      designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomDataPane.java
  24. 75
      designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotDataContentsTabPane.java
  25. 11
      designer-chart/src/main/java/com/fr/van/chart/designer/other/condition/item/VanChartAreaFillColorConditionPane.java
  26. 262
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java
  27. 8
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartTimeAxisPane.java
  28. 2
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartValueAxisPane.java
  29. 15
      designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartAbstractPlotSeriesPane.java
  30. 12
      designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/table/VanPointMapPlotTableDataContentPane.java
  31. 2
      designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java
  32. 4
      designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java
  33. 53
      designer-form/src/main/java/com/fr/design/mainframe/ShareWidgetButton.java
  34. 38
      designer-form/src/test/java/com/fr/design/mainframe/ShareWidgetButtonTest.java
  35. 11
      designer-realize/src/main/java/com/fr/design/actions/columnrow/ColumnRowSizingAction.java
  36. 10
      designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java
  37. 2
      designer-realize/src/main/java/com/fr/design/mainframe/SheetNameTabPane.java
  38. 37
      designer-realize/src/main/java/com/fr/design/report/PageSetupPane.java
  39. 16
      designer-realize/src/main/java/com/fr/grid/GridUI.java
  40. 8
      designer-realize/src/main/java/com/fr/grid/IntelliElements.java

2
designer-base/src/main/java/com/fr/design/actions/help/AboutDialog.java

@ -76,7 +76,7 @@ public class AboutDialog extends JDialog implements ActionListener {
this.getRootPane().setDefaultButton(okButton);
this.setSize(new Dimension(660, 600));
this.setSize(defaultPane.getPreferredSize().width, 600);
GUICoreUtils.centerWindow(this);
}

12
designer-base/src/main/java/com/fr/design/actions/help/AboutPane.java

@ -4,6 +4,7 @@
package com.fr.design.actions.help;
import com.fr.base.FRContext;
import com.fr.base.GraphHelper;
import com.fr.design.DesignerEnvManager;
import com.fr.design.gui.ilable.ActionLabel;
import com.fr.design.gui.ilable.BoldFontTextLabel;
@ -36,9 +37,13 @@ public class AboutPane extends JPanel {
private static final String COMPANY_TELEPHONE = CloudCenter.getInstance().acquireUrlByKind("help.compNo");
private static final String PRESIDENT_PHONE = CloudCenter.getInstance().acquireUrlByKind("help.PNo");
private int maxWidth;
public AboutPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.maxWidth = GraphHelper.getWidth(getBuildTitle() + GeneralUtils.readFullBuildNO() +
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Copy_Build_NO") +
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Copy_Build_NO_OK"));
//center panel
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_L_Pane();
this.add(centerPane, BorderLayout.CENTER);
@ -90,6 +95,11 @@ public class AboutPane extends JPanel {
}
}
@Override
public Dimension getPreferredSize() {
return new Dimension(this.maxWidth, super.getPreferredSize().height);
}
private void addPhoneAndQQPane(JPanel contentPane) {
BoxCenterAligmentPane boxCenterAlignmentPane;
// 英文版不显示服务电话和QQ

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

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

5
designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java

@ -60,7 +60,10 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
if (StringUtils.isEmpty(tempName)) {
isNamePermitted = false;
nameableList.stopEditing();
FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataPaneListPane.this), Toolkit.i18nText("Fine-Design_Basic_Table_Data_Empty_Name_Tips"));
FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataPaneListPane.this),
Toolkit.i18nText("Fine-Design_Basic_Table_Data_Empty_Name_Tips"),
Toolkit.i18nText("Fine-Design_Report_Alert"),
JOptionPane.WARNING_MESSAGE);
setIllegalIndex(editingIndex);
return;
}

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;
import com.fr.base.GraphHelper;
import com.fr.design.constants.UIConstants;
import com.fr.data.impl.JDBCDatabaseConnection;
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.dialog.BasicPane;
import com.fr.design.editor.editor.IntegerEditor;
import com.fr.design.utils.BrowseUtils;
import com.fr.file.filter.ChooseFileFilter;
import com.fr.general.CloudCenter;
import com.fr.general.ComparatorUtils;
import com.fr.stable.StringUtils;
@ -32,351 +35,375 @@ import java.util.Map;
import java.util.Map.Entry;
public class JDBCDefPane extends JPanel {
public static final String DRIVER_TYPE = "driver_type";
public static final String USER_NAME = "user_name";
public static final String DRIVER_TYPE = "driver_type";
public static final String USER_NAME = "user_name";
public static final int TIME_MULTIPLE = 1000;
private static final String OTHER_DB = "Others";
private static Map<String, DriverURLName[]> jdbcMap = new HashMap<String, DriverURLName[]>();
static {
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("COM.cloudscape.JDBCDriver", "jdbc:cloudscape:/cloudscape/"),
new DriverURLName("com.internetcds.jdbc.tds.Driver", "jdbc:freetds:sqlserver://localhost/"),
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"),
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("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("MySQL", new DriverURLName[]{new DriverURLName("com.mysql.jdbc.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("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("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")});
}
private UIButton dbtypeButton;
private UIComboBox dbtypeComboBox;
private UIComboBox driverComboBox;
private UITextField urlTextField;
private UITextField userNameTextField;
private JPasswordField passwordTextField;
// 请不要改动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();
private IntegerEditor DBCP_MAX_ACTIVE = new IntegerEditor();
private IntegerEditor DBCP_MAX_IDLE = new IntegerEditor();
private IntegerEditor DBCP_MIN_IDLE = new IntegerEditor();
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_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_MINEVICTABLEIDLETIMEMILLIS = new IntegerEditor();
public JDBCDefPane() {
this.setBorder(UITitledBorder.createBorderWithTitle("JDBC" + ":"));
this.setLayout(FRGUIPaneFactory.createLabelFlowLayout());
JPanel innerthis = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
innerthis.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
this.add(innerthis);
dbtypeComboBox = new UIComboBox();
dbtypeComboBox.setName(DRIVER_TYPE);
for (int i = 0; i < dbtype.length; i++) {
dbtypeComboBox.addItem(dbtype[i]);
}
dbtypeComboBox.addActionListener(dbtypeActionListener);
dbtypeComboBox.setMaximumRowCount(10);
driverComboBox = new UIComboBox();
driverComboBox.setEditable(true);
driverComboBox.addActionListener(driverListener);
urlTextField = new UITextField(15);
userNameTextField = new UITextField(15);
userNameTextField.setName(USER_NAME);
passwordTextField = new UIPassWordField(15);
dbtypeButton = new UIButton(".");
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;
JPanel dbtypePane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
dbtypePane.add(new UILabel((com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database") + ":")));
JPanel dbtypeComPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
Component[][] dbtypeComComponents = {{dbtypeComboBox}};
double[] dbtypeRowSize = {p};
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 urlPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
urlPane.add(new UILabel("URL:"));
JPanel urlComPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
Component[][] urlComComponents = {{urlTextField, dbtypeButton}};
double[] urlRowSize = {p};
double[] urlColumnSize = {f, 21};
urlComPane = TableLayoutHelper.createCommonTableLayoutPane(urlComComponents, urlRowSize, urlColumnSize, 4);
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();
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);
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},};
double[] rowSize = {p, p, p, p};
double[] columnSize = {p, f, 22};
JPanel centerPanel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 6);
innerthis.add(centerPanel);
JPanel southPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
innerthis.add(southPanel);
southPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 4, 20));
ActionLabel actionLabel = new ActionLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_ConnectionPool_Attr"));
southPanel.add(actionLabel, BorderLayout.EAST);
actionLabel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
JDialog wDialog = createJDialog();
wDialog.setVisible(true);
}
});
}
public void populate(JDBCDatabaseConnection jdbcDatabase) {
if (jdbcDatabase == null) {
jdbcDatabase = new JDBCDatabaseConnection();
}
if (ComparatorUtils.equals(jdbcDatabase.getDriver(), "sun.jdbc.odbc.JdbcOdbcDriver")
&& jdbcDatabase.getURL().startsWith("jdbc:odbc:Driver={Microsoft")) {
this.dbtypeComboBox.setSelectedItem("Access");
} else {
Iterator<Entry<String, DriverURLName[]>> jdbc = jdbcMap.entrySet().iterator();
boolean out = false;
while (jdbc.hasNext()) {
Entry<String, DriverURLName[]> entry = jdbc.next();
DriverURLName[] dus = entry.getValue();
for (int i = 0, len = dus.length; i < len; i++) {
if (ComparatorUtils.equals(dus[i].getDriver(), jdbcDatabase.getDriver())) {
this.dbtypeComboBox.setSelectedItem(entry.getKey());
out = true;
break;
}
}
if (out) {
break;
}
}
if (!out) {
this.dbtypeComboBox.setSelectedItem(OTHER_DB);
}
}
this.driverComboBox.setSelectedItem(jdbcDatabase.getDriver());
this.urlTextField.setText(jdbcDatabase.getURL());
this.userNameTextField.setText(jdbcDatabase.getUser());
this.passwordTextField.setText(jdbcDatabase.getPassword());
DBCPConnectionPoolAttr dbcpAttr = jdbcDatabase.getDbcpAttr();
if (dbcpAttr == null) {
dbcpAttr = new DBCPConnectionPoolAttr();
jdbcDatabase.setDbcpAttr(dbcpAttr);
}
this.DBCP_INITIAL_SIZE.setValue(dbcpAttr.getInitialSize());
this.DBCP_MAX_ACTIVE.setValue(dbcpAttr.getMaxActive());
this.DBCP_MAX_IDLE.setValue(dbcpAttr.getMaxIdle());
this.DBCP_MAX_WAIT.setValue(dbcpAttr.getMaxWait());
this.DBCP_MIN_IDLE.setValue(dbcpAttr.getMinIdle());
this.DBCP_VALIDATION_QUERY.setText(dbcpAttr.getValidationQuery());
this.DBCP_TESTONBORROW.setSelectedIndex(dbcpAttr.isTestOnBorrow() ? 1 : 0);
this.DBCP_TESTONRETURN.setSelectedIndex(dbcpAttr.isTestOnReturn() ? 1 : 0);
this.DBCP_TESTWHILEIDLE.setSelectedIndex(dbcpAttr.isTestWhileIdle() ? 1 : 0);
this.DBCP_MINEVICTABLEIDLETIMEMILLIS.setValue(dbcpAttr.getMinEvictableIdleTimeMillis() / TIME_MULTIPLE);
this.DBCP_NUMTESTSPEREVICTIONRUN.setValue(dbcpAttr.getNumTestsPerEvictionRun());
this.DBCP_TIMEBETWEENEVICTIONRUNSMILLS.setValue(dbcpAttr.getTimeBetweenEvictionRunsMillis());
}
public JDBCDatabaseConnection update() {
JDBCDatabaseConnection jdbcDatabase = new JDBCDatabaseConnection();
Object driveItem = this.driverComboBox.getSelectedItem();
jdbcDatabase.setDriver(driveItem == null ? null : driveItem.toString());
jdbcDatabase.setURL(this.urlTextField.getText().trim());
jdbcDatabase.setUser(this.userNameTextField.getText().trim());
jdbcDatabase.setPassword(new String(this.passwordTextField.getPassword()).trim());
DBCPConnectionPoolAttr dbcpAttr = jdbcDatabase.getDbcpAttr();
if (dbcpAttr == null) {
dbcpAttr = new DBCPConnectionPoolAttr();
jdbcDatabase.setDbcpAttr(dbcpAttr);
}
dbcpAttr.setInitialSize(this.DBCP_INITIAL_SIZE.getValue().intValue());
dbcpAttr.setMaxActive(this.DBCP_MAX_ACTIVE.getValue().intValue());
dbcpAttr.setMaxIdle(this.DBCP_MAX_IDLE.getValue().intValue());
dbcpAttr.setMaxWait(this.DBCP_MAX_WAIT.getValue().intValue());
dbcpAttr.setMinIdle(this.DBCP_MIN_IDLE.getValue().intValue());
dbcpAttr.setValidationQuery(this.DBCP_VALIDATION_QUERY.getText());
dbcpAttr.setTestOnBorrow(this.DBCP_TESTONBORROW.getSelectedIndex() == 0 ? false : true);
dbcpAttr.setTestOnReturn(this.DBCP_TESTONRETURN.getSelectedIndex() == 0 ? false : true);
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 dbtypeActionListener = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
urlTextField.setText(StringUtils.EMPTY);
driverComboBox.removeAllItems();
if (ComparatorUtils.equals(dbtypeComboBox.getSelectedItem(), StringUtils.EMPTY)) {
driverComboBox.setSelectedItem(StringUtils.EMPTY);
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 driverListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (driverComboBox.getSelectedItem() == null ||ComparatorUtils.equals(driverComboBox.getSelectedItem(), StringUtils.EMPTY)) {
return;
}
Iterator<Entry<String, DriverURLName[]>> jdbc = jdbcMap.entrySet().iterator();
while (jdbc.hasNext()) {
Entry<String, DriverURLName[]> entry = jdbc.next();
DriverURLName[] dus = entry.getValue();
for (int i = 0, len = dus.length; i < len; i++) {
if (ComparatorUtils.equals(dus[i].getDriver(), (driverComboBox.getSelectedItem()))) {
urlTextField.setText(dus[i].getURL());
return;
}
}
}
}
};
ActionListener dbtypeButtonActionListener = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (ComparatorUtils.equals(dbtypeComboBox.getSelectedItem(), StringUtils.EMPTY)) {
return;
}
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"))) {
// ben:这个能不能换种处理方案- -
JFileChooser filechooser = new JFileChooser();
filechooser.setDialogTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Open"));
filechooser.setMultiSelectionEnabled(false);
filechooser.addChoosableFileFilter(new ChooseFileFilter(new String[]{"accdb", "mdb"}, "Microsoft Office Access"));
int result = filechooser.showOpenDialog(DesignerContext.getDesignerFrame());
File selectedfile = null;
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());
}
}
}
}
break;
}
}
}
};
private JDialog createJDialog() {
return new DBCPAttrPane().showWindow(SwingUtilities.getWindowAncestor(JDBCDefPane.this));
}
class DBCPAttrPane extends BasicPane {
public DBCPAttrPane() {
JPanel defaultPane = this;
// JPanel northFlowPane
JPanel northFlowPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
defaultPane.add(northFlowPane, BorderLayout.NORTH);
DBCP_VALIDATION_QUERY.setColumns(15);
// ContextPane
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};
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},
{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},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dbcp_Test_While_Idle") + ":", SwingConstants.RIGHT), DBCP_TESTWHILEIDLE},
{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},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connection_Pool_Mix_Evictable_Idle_Time_Millis") + ":" , SwingConstants.RIGHT),
DBCP_MINEVICTABLEIDLETIMEMILLIS}};
JPanel contextPane = TableLayoutHelper.createGapTableLayoutPane(comps, rowSize, columnSize, 10, 4);
contextPane.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, UIConstants.LINE_COLOR));
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;
}
private static final String OTHER_DB = "Others";
private static Map<String, DriverURLName[]> jdbcMap = new HashMap<String, DriverURLName[]>();
static {
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("COM.cloudscape.JDBCDriver", "jdbc:cloudscape:/cloudscape/"),
new DriverURLName("com.internetcds.jdbc.tds.Driver", "jdbc:freetds:sqlserver://localhost/"),
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"),
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("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("MySQL", new DriverURLName[]{new DriverURLName("com.mysql.jdbc.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("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("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")});
}
private UIButton dbtypeButton;
private UIComboBox dbtypeComboBox;
private UIComboBox driverComboBox;
private UITextField urlTextField;
private UITextField userNameTextField;
private JPasswordField passwordTextField;
private ActionLabel odbcTipsLink;
// 请不要改动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();
private IntegerEditor DBCP_MAX_ACTIVE = new IntegerEditor();
private IntegerEditor DBCP_MAX_IDLE = new IntegerEditor();
private IntegerEditor DBCP_MIN_IDLE = new IntegerEditor();
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_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_MINEVICTABLEIDLETIMEMILLIS = new IntegerEditor();
public JDBCDefPane() {
this.setBorder(UITitledBorder.createBorderWithTitle("JDBC" + ":"));
this.setLayout(FRGUIPaneFactory.createLabelFlowLayout());
JPanel innerthis = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
innerthis.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
this.add(innerthis);
dbtypeComboBox = new UIComboBox();
dbtypeComboBox.setName(DRIVER_TYPE);
for (int i = 0; i < dbtype.length; i++) {
dbtypeComboBox.addItem(dbtype[i]);
}
dbtypeComboBox.addActionListener(dbtypeActionListener);
dbtypeComboBox.setMaximumRowCount(10);
driverComboBox = new UIComboBox();
driverComboBox.setEditable(true);
driverComboBox.addActionListener(driverListener);
urlTextField = new UITextField(15);
userNameTextField = new UITextField(15);
userNameTextField.setName(USER_NAME);
passwordTextField = new UIPassWordField(15);
dbtypeButton = new UIButton(".");
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;
JPanel dbtypePane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
dbtypePane.add(new UILabel((com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database") + ":")));
JPanel dbtypeComPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
Component[][] dbtypeComComponents = {{dbtypeComboBox}};
double[] dbtypeRowSize = {p};
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") + ":"));
// 选择ODBC数据源的时候的提示链接
JPanel odbcTipsPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
odbcTipsLink = new ActionLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Odbc_Tips")) {
@Override
public void paintComponent(Graphics _gfx) {
super.paintComponent(_gfx);
_gfx.setColor(Color.blue);
_gfx.drawLine(0, this.getHeight() - 1, GraphHelper.getWidth(this.getText()), this.getHeight() - 1);
}
};
odbcTipsPane.add(odbcTipsLink);
odbcTipsLink.setPreferredSize(new Dimension(GraphHelper.getWidth(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Odbc_Tips")), odbcTipsLink.getPreferredSize().height));
odbcTipsLink.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
String url = CloudCenter.getInstance().acquireUrlByKind("odbc.help");
BrowseUtils.browser(url);
}
});
JPanel driverComboBoxAndTips = new JPanel(new BorderLayout());
driverComboBoxAndTips.add(driverComboBox, BorderLayout.WEST);
driverComboBoxAndTips.add(odbcTipsPane, BorderLayout.CENTER);
JPanel urlPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
urlPane.add(new UILabel("URL:"));
JPanel urlComPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
Component[][] urlComComponents = {{urlTextField, dbtypeButton}};
double[] urlRowSize = {p};
double[] urlColumnSize = {f, 21};
urlComPane = TableLayoutHelper.createCommonTableLayoutPane(urlComComponents, urlRowSize, urlColumnSize, 4);
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();
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);
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, driverComboBoxAndTips}, {urlPane, urlComPane}, {userPane, userComPane},};
double[] rowSize = {p, p, p, p};
double[] columnSize = {p, f, 22};
JPanel centerPanel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 6);
innerthis.add(centerPanel);
JPanel southPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
innerthis.add(southPanel);
southPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 4, 20));
ActionLabel actionLabel = new ActionLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_ConnectionPool_Attr"));
southPanel.add(actionLabel, BorderLayout.EAST);
actionLabel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
JDialog wDialog = createJDialog();
wDialog.setVisible(true);
}
});
}
public void populate(JDBCDatabaseConnection jdbcDatabase) {
if (jdbcDatabase == null) {
jdbcDatabase = new JDBCDatabaseConnection();
}
if (ComparatorUtils.equals(jdbcDatabase.getDriver(), "sun.jdbc.odbc.JdbcOdbcDriver")
&& jdbcDatabase.getURL().startsWith("jdbc:odbc:Driver={Microsoft")) {
this.dbtypeComboBox.setSelectedItem("Access");
} else {
Iterator<Entry<String, DriverURLName[]>> jdbc = jdbcMap.entrySet().iterator();
boolean out = false;
while (jdbc.hasNext()) {
Entry<String, DriverURLName[]> entry = jdbc.next();
DriverURLName[] dus = entry.getValue();
for (int i = 0, len = dus.length; i < len; i++) {
if (ComparatorUtils.equals(dus[i].getDriver(), jdbcDatabase.getDriver())) {
this.dbtypeComboBox.setSelectedItem(entry.getKey());
out = true;
break;
}
}
if (out) {
break;
}
}
if (!out) {
this.dbtypeComboBox.setSelectedItem(OTHER_DB);
}
}
this.driverComboBox.setSelectedItem(jdbcDatabase.getDriver());
this.urlTextField.setText(jdbcDatabase.getURL());
this.userNameTextField.setText(jdbcDatabase.getUser());
this.passwordTextField.setText(jdbcDatabase.getPassword());
DBCPConnectionPoolAttr dbcpAttr = jdbcDatabase.getDbcpAttr();
if (dbcpAttr == null) {
dbcpAttr = new DBCPConnectionPoolAttr();
jdbcDatabase.setDbcpAttr(dbcpAttr);
}
this.DBCP_INITIAL_SIZE.setValue(dbcpAttr.getInitialSize());
this.DBCP_MAX_ACTIVE.setValue(dbcpAttr.getMaxActive());
this.DBCP_MAX_IDLE.setValue(dbcpAttr.getMaxIdle());
this.DBCP_MAX_WAIT.setValue(dbcpAttr.getMaxWait());
this.DBCP_MIN_IDLE.setValue(dbcpAttr.getMinIdle());
this.DBCP_VALIDATION_QUERY.setText(dbcpAttr.getValidationQuery());
this.DBCP_TESTONBORROW.setSelectedIndex(dbcpAttr.isTestOnBorrow() ? 1 : 0);
this.DBCP_TESTONRETURN.setSelectedIndex(dbcpAttr.isTestOnReturn() ? 1 : 0);
this.DBCP_TESTWHILEIDLE.setSelectedIndex(dbcpAttr.isTestWhileIdle() ? 1 : 0);
this.DBCP_MINEVICTABLEIDLETIMEMILLIS.setValue(dbcpAttr.getMinEvictableIdleTimeMillis() / TIME_MULTIPLE);
this.DBCP_NUMTESTSPEREVICTIONRUN.setValue(dbcpAttr.getNumTestsPerEvictionRun());
this.DBCP_TIMEBETWEENEVICTIONRUNSMILLS.setValue(dbcpAttr.getTimeBetweenEvictionRunsMillis());
}
public JDBCDatabaseConnection update() {
JDBCDatabaseConnection jdbcDatabase = new JDBCDatabaseConnection();
Object driveItem = this.driverComboBox.getSelectedItem();
jdbcDatabase.setDriver(driveItem == null ? null : driveItem.toString());
jdbcDatabase.setURL(this.urlTextField.getText().trim());
jdbcDatabase.setUser(this.userNameTextField.getText().trim());
jdbcDatabase.setPassword(new String(this.passwordTextField.getPassword()).trim());
DBCPConnectionPoolAttr dbcpAttr = jdbcDatabase.getDbcpAttr();
if (dbcpAttr == null) {
dbcpAttr = new DBCPConnectionPoolAttr();
jdbcDatabase.setDbcpAttr(dbcpAttr);
}
dbcpAttr.setInitialSize(this.DBCP_INITIAL_SIZE.getValue().intValue());
dbcpAttr.setMaxActive(this.DBCP_MAX_ACTIVE.getValue().intValue());
dbcpAttr.setMaxIdle(this.DBCP_MAX_IDLE.getValue().intValue());
dbcpAttr.setMaxWait(this.DBCP_MAX_WAIT.getValue().intValue());
dbcpAttr.setMinIdle(this.DBCP_MIN_IDLE.getValue().intValue());
dbcpAttr.setValidationQuery(this.DBCP_VALIDATION_QUERY.getText());
dbcpAttr.setTestOnBorrow(this.DBCP_TESTONBORROW.getSelectedIndex() == 0 ? false : true);
dbcpAttr.setTestOnReturn(this.DBCP_TESTONRETURN.getSelectedIndex() == 0 ? false : true);
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 dbtypeActionListener = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
urlTextField.setText(StringUtils.EMPTY);
driverComboBox.removeAllItems();
if (ComparatorUtils.equals(dbtypeComboBox.getSelectedItem(), StringUtils.EMPTY)) {
driverComboBox.setSelectedItem(StringUtils.EMPTY);
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 driverListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (driverComboBox.getSelectedItem() == null || ComparatorUtils.equals(driverComboBox.getSelectedItem(), StringUtils.EMPTY)) {
return;
}
odbcTipsLink.setVisible(ComparatorUtils.equals("sun.jdbc.odbc.JdbcOdbcDriver", driverComboBox.getSelectedItem())); // 选择的如果是ODBC就显示提示
Iterator<Entry<String, DriverURLName[]>> jdbc = jdbcMap.entrySet().iterator();
while (jdbc.hasNext()) {
Entry<String, DriverURLName[]> entry = jdbc.next();
DriverURLName[] dus = entry.getValue();
for (int i = 0, len = dus.length; i < len; i++) {
if (ComparatorUtils.equals(dus[i].getDriver(), (driverComboBox.getSelectedItem()))) {
urlTextField.setText(dus[i].getURL());
return;
}
}
}
}
};
ActionListener dbtypeButtonActionListener = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (ComparatorUtils.equals(dbtypeComboBox.getSelectedItem(), StringUtils.EMPTY)) {
return;
}
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"))) {
// ben:这个能不能换种处理方案- -
JFileChooser filechooser = new JFileChooser();
filechooser.setDialogTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Open"));
filechooser.setMultiSelectionEnabled(false);
filechooser.addChoosableFileFilter(new ChooseFileFilter(new String[]{"accdb", "mdb"}, "Microsoft Office Access"));
int result = filechooser.showOpenDialog(DesignerContext.getDesignerFrame());
File selectedfile = null;
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());
}
}
}
}
break;
}
}
}
};
private JDialog createJDialog() {
return new DBCPAttrPane().showWindow(SwingUtilities.getWindowAncestor(JDBCDefPane.this));
}
class DBCPAttrPane extends BasicPane {
public DBCPAttrPane() {
JPanel defaultPane = this;
// JPanel northFlowPane
JPanel northFlowPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
defaultPane.add(northFlowPane, BorderLayout.NORTH);
DBCP_VALIDATION_QUERY.setColumns(15);
// ContextPane
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};
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},
{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},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dbcp_Test_While_Idle") + ":", SwingConstants.RIGHT), DBCP_TESTWHILEIDLE},
{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},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connection_Pool_Mix_Evictable_Idle_Time_Millis") + ":", SwingConstants.RIGHT),
DBCP_MINEVICTABLEIDLETIMEMILLIS}};
JPanel contextPane = TableLayoutHelper.createGapTableLayoutPane(comps, rowSize, columnSize, 10, 4);
contextPane.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, UIConstants.LINE_COLOR));
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;
import com.fr.invoke.Reflect;
import com.fr.stable.StringUtils;
import javax.swing.Icon;
import javax.swing.JDialog;
@ -279,8 +280,11 @@ public class FineJOptionPane extends JOptionPane {
dialog.show();
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) {
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;
import com.fr.design.DesignerEnvManager;
import com.fr.design.extra.PluginConstants;
import com.fr.design.extra.Process;
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 java.util.Locale;
/**
* Created by vito on 16/5/16.
@ -28,14 +31,17 @@ public class GetPluginCategoriesExecutor implements Executor {
@Override
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)) {
HttpClient httpClient = new HttpClient(url);
result = httpClient.getResponseText();
} else {
result = PluginConstants.CONNECTION_404;
try {
result = HttpToolbox.get(url);
return;
} 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 {
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
public void mouseClicked(MouseEvent e) {
public void mouseReleased(MouseEvent e) {
int index = tipsList.getSelectedIndex();
if (index != -1) {
String currentLineContent = (String) listModel.getElementAt(index);
if (e.getClickCount() == 2) {
if (ifHasBeenWriten == 0) {
formulaTextArea.setForeground(Color.black);
formulaTextArea.setText("");
if (e.getClickCount() == 1) {
if (ComparatorUtils.equals((String) listModel.getElementAt(index), singlePressContent)) {
singleClickActuator(singlePressContent);
}
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;
} else if (e.getClickCount() == 2) {
if (ComparatorUtils.equals((String) listModel.getElementAt(index), doublePressContent)) {
doubleClickActuator(doublePressContent);
}
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

12
designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java

@ -18,6 +18,10 @@ import java.awt.event.MouseMotionListener;
*/
public class UIEastResizableContainer extends JPanel {
private static final long serialVersionUID = 1854340560790476907L;
public static final int MAX_CONTAINER_WIDTH = 500;
public static final int MIN_CONTAINER_WIDTH = 286;
private int containerWidth = 240;
private int preferredWidth = 240;
private int topToolPaneHeight = 25;
@ -262,7 +266,13 @@ public class UIEastResizableContainer extends JPanel {
@Override
public void mouseDragged(MouseEvent e) {
// do nothing
containerWidth = UIEastResizableContainer.this.getWidth() + (UIEastResizableContainer.this.getLocationOnScreen().x - e.getXOnScreen());
containerWidth = Math.min(containerWidth, MAX_CONTAINER_WIDTH);
containerWidth = Math.max(containerWidth, MIN_CONTAINER_WIDTH);
refreshContainer();
if ( DesignModeContext.isAuthorityEditing()) {
DesignerContext.getDesignerFrame().doResize();
}
}
});
addMouseListener(new MouseAdapter() {

10
designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java

@ -1,6 +1,7 @@
package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager;
@ -66,7 +67,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
private JPanel leftPane;
private JPanel rightPane;
private FixedPopupPane currentPopupPane;
private static final int CONTAINER_WIDTH = 286;
private static final int CONTAINER_WIDTH = containerWidth();
private static final int TAB_WIDTH = 38;
private static final int TAB_BUTTON_WIDTH = 32;
private static final int TAB_BUTTON_HEIGHT = 28;
@ -107,6 +108,13 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
private PropertyMode currentMode; // 当前模式(根据不同模式,显示不同的可用面板)
private static int containerWidth() {
if (FRContext.isChineseEnv()) {
return UIEastResizableContainer.MIN_CONTAINER_WIDTH;
}
return UIEastResizableContainer.MAX_CONTAINER_WIDTH;
}
/**
* 得到实例
*

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_IS_NEW = "isNew";
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; // 判断图表是否可以上传的天数
@ -122,10 +124,10 @@ public class ChartInfo extends AbstractPointInfo {
}
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<>();
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_IS_NEW, String.valueOf(isNew));
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.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_IS_NEW, chartConsumingMap.get(ATTR_IS_NEW));
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();
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_IS_NEW, reader.getAttrAsString(ATTR_IS_NEW, 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)) {
this.chartConfigInfo = (ChartConfigInfo) reader.readXMLObject(new ChartConfigInfo());
@ -276,6 +290,10 @@ public class ChartInfo extends AbstractPointInfo {
}
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");
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);
count = StringUtils.isEmpty(count) ? "1" : String.valueOf(Integer.parseInt(count) + 1);
chartConsumingMap.put(ATTR_OVER_CHART_TYPE_COUNT, count);
if (isAutoChart) {
chartConsumingMap.put(ATTR_AUTO_CHART_ENSURE_TIME, typeTime);
}
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.XMLableReader;
import com.fr.third.joda.time.DateTime;
import java.util.HashMap;
import java.util.Map;
@ -49,18 +50,22 @@ public class ChartInfoCollector extends AbstractPointCollector<ChartInfo> {
}
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();
if (!shouldCollectInfo() || StringUtils.isEmpty(chartId)) {
return;
}
ChartInfo chartInfo = ChartInfo.newInstance(chartProvider, createTime, true, isReuse);
ChartInfo chartInfo = ChartInfo.newInstance(chartProvider, createTime, true, isReuse, isAutoChart);
chartInfoCacheMap.put(chartId, chartInfo);
}
@ -116,6 +121,10 @@ public class ChartInfoCollector extends AbstractPointCollector<ChartInfo> {
* 图表类型变化更新类型和类型确认时间
*/
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())) {
return;
}
@ -123,7 +132,7 @@ public class ChartInfoCollector extends AbstractPointCollector<ChartInfo> {
ChartInfo chartInfo = getOrCreateChartInfo(chartProvider, oldType);
//更新类型确认时间和类型
chartInfo.updateChartType(chartProvider);
chartInfo.updateChartType(chartProvider, isAutoChart);
//重置计数
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() {
INFONUM = ERRORNUM = SERVERNUM = 0;
LogMessageBar.getInstance().clear();
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.gui.ilable.UILabel;
import com.fr.stable.StringUtils;
import javax.swing.JFrame;
@ -63,6 +64,11 @@ public class LogMessageBar extends JPanel {
repaint();
}
public void clear() {
messageLabel.setText(StringUtils.EMPTY);
repaint();
}
public void setLoggerBarWidth(int 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();
screen.setSize(screen.getSize().width, screen.height - HEIGHT_GAP);
int showOnScreenX = Math.min(screen.width, parentComponent.getLocationOnScreen().x + parentComponent.getWidth());
// peter:调整X的高度.
if (point.x + size.width > screen.width && size.width < screen.width) {
x += (screen.width - point.x - size.width);
if (point.x + size.width > showOnScreenX && size.width < showOnScreenX) {
x += (showOnScreenX - point.x - size.width);
}
// 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
context.setLoader(new FRTomcatLoader());
//直接指定initializer,tomcat就不用再扫描一遍了
SpringServletContainerInitializer initializer = new SpringServletContainerInitializer();
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.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.Dialog;
import java.awt.Frame;
@ -33,14 +36,22 @@ public class AutoChartDialog extends ChartDialog {
protected Component initCenterPane() {
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;
}
protected ActionListener getActionListener() {
protected ActionListener getActionListener(final String createTime) {
return new ActionListener() {
public void actionPerformed(ActionEvent e) {
ChartCollection chartCollection = (ChartCollection) getChartCollection();
autoChartTypePane.update(chartCollection);
autoChartTypePane.update(chartCollection, createTime);
if (chartCollection.getChartCount() > 0) {
doOK();
} 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) {
BaseChartPainter painter = chartCollection.createResultChartPainterWithOutDealFormula(Calculator.createCalculator(),
WebChartIDInfo.createEmptyDesignerInfo(), getIconWidth(), getIconHeight());
WebChartIDInfo.createAutoTypeInfo(), getIconWidth(), getIconHeight());
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.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.datapane.TableDataComboBox;
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.icombocheckbox.UIComboCheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.iprogressbar.AutoProgressBar;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.chart.info.ChartInfoCollector;
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.DefaultListCellRenderer;
import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
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.List;
import java.util.Map;
import java.util.concurrent.CancellationException;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
@ -46,6 +60,9 @@ public class AutoChartTypePane extends ChartWizardPane implements CallbackEvent
private TableDataComboBox tableNameComboBox;
private UIComboCheckBox dataFieldBox;
private AutoProgressBar connectionBar;
private SwingWorker worker;
public AutoChartTypePane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
initButtonGroup();
@ -62,10 +79,15 @@ public class AutoChartTypePane extends ChartWizardPane implements CallbackEvent
chartViewList.setCellRenderer(iconCellRenderer);
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.setBorder(BorderFactory.createTitledBorder(Toolkit.i18nText("Fine-Design_Chart_M_Popup_Auto_Chart_Type")));
this.add(splitPane);
}
@ -94,7 +116,7 @@ public class AutoChartTypePane extends ChartWizardPane implements CallbackEvent
JPanel tableDataPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
panel.add(tableDataPane);
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);
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(dataFieldBox);
panel.add(refreshButton);
panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
return panel;
}
@ -136,6 +159,10 @@ public class AutoChartTypePane extends ChartWizardPane implements CallbackEvent
}
}
public void registsListAction(ListSelectionListener listSelectionListener) {
chartViewList.addListSelectionListener(listSelectionListener);
}
private void refreshBox() {
TableDataWrapper dataWrap = tableNameComboBox.getSelectedItem();
@ -154,6 +181,7 @@ public class AutoChartTypePane extends ChartWizardPane implements CallbackEvent
refreshButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
refreshButton.setEnabled(false);
calculateAutoChart();
}
});
@ -161,7 +189,56 @@ public class AutoChartTypePane extends ChartWizardPane implements CallbackEvent
}
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
@ -171,16 +248,7 @@ public class AutoChartTypePane extends ChartWizardPane implements CallbackEvent
@Override
public void update(ChartCollection cc) {
if (chartViewList.getSelectedIndex() < 0) {
return;
}
AutoChartIcon chartIcon = (AutoChartIcon) chartViewList.getSelectedValue();
ChartProvider chartProvider = chartIcon.getChartCollection().getSelectedChartProvider(ChartProvider.class);
if (cc.getChartCount() > 0) {
cc.setSelectChart(chartProvider);
} else {
cc.addChart(chartProvider);
}
update(cc, null);
}
public void populate(String tableName, String[] dataFields) {
@ -190,6 +258,30 @@ public class AutoChartTypePane extends ChartWizardPane implements CallbackEvent
map.put(dataField, true);
}
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

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 cancel;
private ChartTypePane chartTypePane;
private String createTime;
public ChartDialog(Frame owner) {
super(owner);
@ -44,11 +43,14 @@ public class ChartDialog extends MiddleChartDialog {
}
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.setLayout(new BorderLayout());
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.applyEscapeAction();
this.setBasicDialogSize(BasicDialog.DEFAULT);
@ -58,10 +60,7 @@ public class ChartDialog extends MiddleChartDialog {
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
this.add(buttonPane, BorderLayout.SOUTH);
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"));
ok.addActionListener(getActionListener());
ok.addActionListener(getActionListener(createTime));
cancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
doCancel();
@ -83,7 +82,7 @@ public class ChartDialog extends MiddleChartDialog {
return chartTypePane;
}
protected ActionListener getActionListener() {
protected ActionListener getActionListener(final String createTime) {
return new ActionListener() {
public void actionPerformed(ActionEvent e) {
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() {
@Override
public void actionPerformed(ActionEvent e) {
final String lastId = editingCollection.getSelectedChartProvider(ChartProvider.class).getID();
final MiddleChartDialog autoChartDialog = DesignModuleFactory.getAutoChartDialog(DesignerContext.getDesignerFrame());
autoChartDialog.populate(editingCollection);
autoChartDialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
populate(editingCollection);
ChartProvider chart = editingCollection.getSelectedChartProvider(ChartProvider.class);
reLayoutEditPane(chart, lastId);
}
});
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> {
private Map<String, Map<String, FurtherBasicBeanPane<? extends ChartProvider>>> allChartTypePane;
@ -167,17 +181,7 @@ public class ChartTypePane extends AbstractChartAttrPane {
//这一步会替换plot
((AbstractChartTypePane) getSelectedPane()).updateBean(chart);
String chartID = chart.getID();
//chartID改变的话图表类型就算改变了
if (StringUtils.isNotEmpty(chartID)) {
boolean isUseDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(chartID);
if (editPane.isDefaultPane() != isUseDefault || (!isUseDefault && !ComparatorUtils.equals(lastPlotID, chartID))) {
editPane.reLayout(chart);
}
}
reLayoutEditPane(chart,lastPlotID);
}
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.setSupportCellData(isSupportCellData());
content.add(contentsTabPane, BorderLayout.CENTER);
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.
*/
public class VanChartCustomPlotDataContentsTabPane extends VanChartCustomPlotTabPane<VanChartCustomPlot, ChartCollection> {
private boolean supportCellData;
public VanChartCustomPlotDataContentsTabPane(VanChartCustomPlot plot, VanChartCustomDataPane parent, AttributeChangeListener listener) {
super(plot, parent, listener);
}
public boolean isSupportCellData() {
return supportCellData;
}
public void setSupportCellData(boolean supportCellData) {
this.supportCellData = supportCellData;
}
@Override
protected void initTabTitle() {
if (plot == null){
if (plot == null) {
return;
}
@ -49,7 +60,7 @@ public class VanChartCustomPlotDataContentsTabPane extends VanChartCustomPlotTab
@Override
protected List<JPanel> initPaneList() {
if (plot == null){
if (plot == null) {
return null;
}
@ -57,9 +68,10 @@ public class VanChartCustomPlotDataContentsTabPane extends VanChartCustomPlotTab
List<VanChartPlot> customPlotList = plot.getCustomPlotList();
for (int i = 0; i < customPlotList.size(); i++){
for (int i = 0; i < customPlotList.size(); i++) {
//根据不同的plot创建不同的数据配置界面
ChartDataPane contentPane = new VanChartDataPane(listener);
contentPane.setSupportCellData(supportCellData);
paneList.add(contentPane);
}
@ -67,42 +79,38 @@ public class VanChartCustomPlotDataContentsTabPane extends VanChartCustomPlotTab
}
@Override
public void populateBean(ChartCollection chartCollection){
public void populateBean(ChartCollection chartCollection) {
plot = (VanChartCustomPlot) chartCollection.getSelectedChart().getPlot();
if (paneList == null){
paneList = initPaneList();
}
if (paneList != null){
try {
paneList = initPaneList();
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
cloneCollection.getSelectedChart().setPlot(customPlotList.get(i));
for (int i = 0; i < paneList.size() && i < customPlotList.size(); i++) {
//將plot包裝起来,主要是为了获取dataDefinition
ChartCollection cloneCollection = (ChartCollection) chartCollection.clone();
//获取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)));
}
cloneCollection.getSelectedChart().setFilterDefinition(dataDefinition);
//设置collection的plot
cloneCollection.getSelectedChart().setPlot(customPlotList.get(i));
((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){
return;
cloneCollection.getSelectedChart().setFilterDefinition(dataDefinition);
((ChartDataPane) paneList.get(i)).populate(cloneCollection);
}
} catch (Exception e) {
return;
}
}
@ -112,8 +120,8 @@ public class VanChartCustomPlotDataContentsTabPane extends VanChartCustomPlotTab
}
@Override
public void updateBean(ChartCollection collection){
if (paneList == null || plot == null){
public void updateBean(ChartCollection collection) {
if (paneList == null || plot == null) {
return;
}
try {
@ -146,7 +154,7 @@ public class VanChartCustomPlotDataContentsTabPane extends VanChartCustomPlotTab
customDefinition.setDefinitionProviderMap(definitionMap);
collection.getSelectedChart().setFilterDefinition(customDefinition);
}catch (Exception e){
} catch (Exception e) {
return;
}
}
@ -168,10 +176,11 @@ public class VanChartCustomPlotDataContentsTabPane extends VanChartCustomPlotTab
/**
* 返回绑定的属性事件.
* @param listener 增加监听
*
* @param 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);
}
}

11
designer-chart/src/main/java/com/fr/van/chart/designer/other/condition/item/VanChartAreaFillColorConditionPane.java

@ -1,11 +1,11 @@
package com.fr.van.chart.designer.other.condition.item;
import com.fr.chart.base.ChartConstants;
import com.fr.chart.base.DataSeriesCondition;
import com.fr.chart.chartattr.Plot;
import com.fr.design.condition.ConditionAttributesPane;
import com.fr.plugin.chart.attr.plot.VanChartPlot;
import com.fr.plugin.chart.base.AttrAreaSeriesFillColorBackground;
import com.fr.plugin.chart.type.GradientType;
import com.fr.van.chart.designer.component.VanChartAreaSeriesFillColorPane;
import javax.swing.JPanel;
@ -13,7 +13,7 @@ import javax.swing.JPanel;
/**
* 面积图填充色
*/
public class VanChartAreaFillColorConditionPane extends AbstractNormalMultiLineConditionPane {
public class VanChartAreaFillColorConditionPane extends AbstractNormalMultiLineConditionPane {
private Plot plot;
private static final long serialVersionUID = -4148284851967140012L;
private VanChartAreaSeriesFillColorPane fillColorBackground;
@ -40,6 +40,7 @@ public class VanChartAreaFillColorConditionPane extends AbstractNormalMultiLine
/**
* 条件属性item的名称
*
* @return item的名称
*/
public String nameForPopupMenuItem() {
@ -54,13 +55,13 @@ public class VanChartAreaFillColorConditionPane extends AbstractNormalMultiLine
public void setDefault() {
//下面这句话是给各组件一个默认值
fillColorBackground.populate(new AttrAreaSeriesFillColorBackground());
fillColorBackground.checkoutAlpha(!(plot != null && plot.getPlotStyle() == ChartConstants.STYLE_SHADE));
fillColorBackground.checkoutAlpha(plot != null && ((VanChartPlot) plot).getGradientStyle().getGradientType() == GradientType.NONE);
}
public void populate(DataSeriesCondition condition) {
if (condition instanceof AttrAreaSeriesFillColorBackground) {
fillColorBackground.populate((AttrAreaSeriesFillColorBackground) condition);
fillColorBackground.checkoutAlpha(!(plot != null && plot.getPlotStyle() == ChartConstants.STYLE_SHADE));
fillColorBackground.checkoutAlpha(plot != null && ((VanChartPlot) plot).getGradientStyle().getGradientType() == GradientType.NONE);
}
}

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 double ROTATION_MAX = 90.0;
protected UIButtonGroup showTitle;
protected TinyFormulaPane titleContent;
protected UIButtonGroup<Integer> titleAlignPane;
protected UIToggleButton titleUseHtml;
protected ChartTextAttrPane titleTextAttrPane;
protected UINumberDragPane titleTextRotation;
protected JPanel titlePane;
protected UIButtonGroup showLabel;
protected ChartTextAttrPane labelTextAttrPane;
@ -96,11 +98,11 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
protected JPanel centerPane;
private VanChartHtmlLabelPane htmlLabelPane;
public VanChartBaseAxisPane(){
public VanChartBaseAxisPane() {
this(true);
}
public VanChartBaseAxisPane(boolean isXAxis){
public VanChartBaseAxisPane(boolean isXAxis) {
this.setLayout(new BorderLayout());
this.add(createContentPane(isXAxis), BorderLayout.CENTER);
}
@ -108,12 +110,13 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
public void setParentPane(VanChartStylePane parent) {
htmlLabelPane.setParent(parent);
}
protected void reLayoutPane(boolean isXAxis){
protected void reLayoutPane(boolean isXAxis) {
this.removeAll();
this.add(createContentPane(isXAxis), BorderLayout.CENTER);
}
protected JPanel createContentPane(boolean isXAxis){
protected JPanel createContentPane(boolean isXAxis) {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
@ -121,9 +124,9 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
double s = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH;
double[] columnSize = {f, e};
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[][]{
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[]{createLineStylePane(new double[]{p, p, p, p, p}, columnSize), 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},
};
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.setSelectedItem(Constants.CENTER);
titleContent = new TinyFormulaPane();
titleUseHtml = new UIToggleButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Html"));
UIComponentUtils.setLineWrap(titleUseHtml);
titleTextAttrPane = new ChartTextAttrPane();
titleTextRotation = new UINumberDragPane(-ROTATION_MAX,ROTATION_MAX);
if(isXAxis){
titleTextAttrPane = getChartTextAttrPane();
titleTextRotation = new UINumberDragPane(-ROTATION_MAX, ROTATION_MAX);
if (isXAxis) {
titleTextRotation.populateBean(0.0);
} else {
titleTextRotation.populateBean(-ROTATION_MAX);
}
Component[][] components = new Component[][]{
new Component[]{null,null},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Content")),titleContent},
new Component[]{null,titleUseHtml},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout_Position")),titleAlignPane},
new Component[]{titleTextAttrPane,null},
new Component[]{null, null},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Content")), titleContent},
new Component[]{null, titleUseHtml},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout_Position")), titleAlignPane},
new Component[]{titleTextAttrPane, null},
new Component[]{
FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_TextRotation")),
UIComponentUtils.wrapWithBorderLayoutPane(titleTextRotation)
},
};
titlePane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col);
titlePane.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col);
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(PaneTitleConstants.CHART_STYLE_TITLE_TITLE, panel);
JPanel showTitlePane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Axis_Title"), showTitle);
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"),
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")};
@ -171,7 +188,8 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
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"),
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")};
@ -180,7 +198,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
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")});
labelTextAttrPane = getChartTextAttrPane();
@ -205,9 +223,9 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
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.setBorder(BorderFactory.createEmptyBorder(0,10,0,0));
labelPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
showLabel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
@ -308,11 +326,11 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
}
protected ChartTextAttrPane getChartTextAttrPane(){
return new ChartTextAttrPane(){
protected ChartTextAttrPane getChartTextAttrPane() {
return new ChartTextAttrPane() {
@Override
protected JPanel getContentPane (JPanel buttonPane) {
protected JPanel getContentPane(JPanel buttonPane) {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
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();
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};
mainTick = new UIButtonGroup<AxisTickLineType>(strings, values);
secondTick = new UIButtonGroup<AxisTickLineType>(strings, values);
@ -342,15 +360,15 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
protected Component[][] getLineStylePaneComponents() {
return new Component[][]{
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_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_Second_Graduation_Line")),secondTick},
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_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_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));
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[][]{
@ -359,30 +377,30 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Label_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);
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout_Position"), panel);
}
private String[] getAxisPositionNameArray(boolean isXAxis){
if(isXAxis){
private String[] getAxisPositionNameArray(boolean 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")};
} 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")};
}
}
private Integer[] getAxisPositionValueArray(boolean isXAxis){
if(isXAxis){
private Integer[] getAxisPositionValueArray(boolean isXAxis) {
if (isXAxis) {
return new Integer[]{VanChartConstants.AXIS_TOP, VanChartConstants.AXIS_BOTTOM, VanChartConstants.AXIS_VERTICAL_ZERO};
} else {
return new Integer[]{VanChartConstants.AXIS_LEFT, VanChartConstants.AXIS_RIGHT, VanChartConstants.AXIS_VERTICAL_ZERO};
}
}
protected JPanel createDisplayStrategy(){
protected JPanel createDisplayStrategy() {
//区域显示策略 恢复用注释。删除到return,即除了注释的代码都删除。
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")});
@ -408,7 +426,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
// return limitPane;
}
protected JPanel createValueStylePane(){
protected JPanel createValueStylePane() {
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")});
@ -418,19 +436,19 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
htmlLabelPane = new VanChartHtmlLabelPane();
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"));
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {p,f};
double[] rowSize = {p,p,p};
double[] columnSize = {p, f};
double[] rowSize = {p, p, p};
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[]{null, centerPane},
};
JPanel contentPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components,rowSize,columnSize);
JPanel contentPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize);
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);
}
protected FormatPane createFormatPane(){
return new FormatPane(){
protected Component[][] getComponent (JPanel fontPane, JPanel centerPane, JPanel typePane) {
protected FormatPane createFormatPane() {
return new FormatPane() {
protected Component[][] getComponent(JPanel fontPane, JPanel centerPane, JPanel typePane) {
typePane.setBorder(BorderFactory.createEmptyBorder());
return new Component[][]{
new Component[]{typePane,null},
new Component[]{typePane, null},
new Component[]{centerPane, null},
};
}
@ -462,6 +480,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
protected void checkAllUse() {
checkCardPane();
checkLabelPane();
checkTitlePane();
//区域显示策略 恢复用注释。删除下面一行。
checkMaxProPortionUse();
@ -480,10 +499,10 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
}
protected void checkCardPane() {
if(centerPane != null && valueFormatStyle != null){
if (centerPane != null && valueFormatStyle != null) {
CardLayout cardLayout = (CardLayout) centerPane.getLayout();
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 {
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() {
if(showLabel != null){
if (showLabel != null) {
boolean enabled = showLabel.getSelectedIndex() == 0;
if(labelPanel != null){
if (labelPanel != null) {
labelPanel.setVisible(enabled);
}
if(enabled){
if (enabled) {
//轴标签缩略间隔显示 恢复用注释。下面1行删除。
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() {
if (overlapHandleTypeGroup != null && labelGapStylePane != null) {
boolean visible = overlapHandleTypeGroup.getSelectedItem() == OverlapHandleType.INTERVAL;
@ -528,28 +553,31 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
/**
* 是否是指定类型
*
* @param ob 对象
* @return 是否是指定类型
*/
public boolean accept(Object ob){
public boolean accept(Object ob) {
return false;
}
/**
* title应该是一个属性不只是对话框的标题时用到与其他组件结合时也会用得到
*
* @return 绥化狂标题
*/
@Override
public String title4PopupWindow(){
public String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Category_Axis");
}
/**
* 重置
*/
public void reset(){
public void reset() {
}
@Override
public void populateBean(VanChartAxis 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();
if(axisTitle != null){
if (axisTitle != null) {
if (axisTitle.getTextObject() instanceof BaseFormula && titleContent != null) {
titleContent.populateBean(((BaseFormula) axisTitle.getTextObject()).getContent());
} else if(titleContent != null){
} else if (titleContent != null) {
titleContent.populateBean(Utils.objectToString(axisTitle.getTextObject()));
}
if(titleAlignPane != null){
if (titleAlignPane != null) {
titleAlignPane.setSelectedItem(axisTitle.getPosition());
}
if(titleTextAttrPane != null){
if (titleTextAttrPane != null) {
titleTextAttrPane.populate(axisTitle.getTextAttr());
}
if(titleUseHtml != null){
if (titleUseHtml != null) {
titleUseHtml.setSelected(axis.isTitleUseHtml());
}
if(titleTextRotation != null){
titleTextRotation.populateBean((double)axisTitle.getTextAttr().getRotation());
if (titleTextRotation != null) {
titleTextRotation.populateBean((double) axisTitle.getTextAttr().getRotation());
}
}
}
//标签
private void populateLabel(VanChartAxis axis){
if(showLabel != null){
private void populateLabel(VanChartAxis axis) {
if (showLabel != null) {
showLabel.setSelectedIndex(axis.isShowAxisLabel() ? 0 : 1);
}
TextAttr labelTextAttr = axis.getTextAttr();
if(labelTextAttrPane != null){
if (labelTextAttrPane != null) {
labelTextAttrPane.populate(labelTextAttr);
}
if(labelTextRotation != null){
labelTextRotation.populateBean((double)labelTextAttr.getRotation());
if (labelTextRotation != null) {
labelTextRotation.populateBean((double) labelTextAttr.getRotation());
}
//轴标签缩略间隔显示 恢复用注释。取消注释。
// if (overlapHandleTypeGroup != null) {
// overlapHandleTypeGroup.setSelectedItem(axis.getOverlapHandleType());
// }
if(labelGapStyle != null){
if (labelGapStyle != null) {
labelGapStyle.setSelectedIndex(axis.isAutoLabelGap() ? 0 : 1);
}
if(labelGapValue != null){
if (labelGapValue != null) {
//轴标签缩略间隔显示 恢复用注释。下面1行删除。
labelGapValue.setText(axis.getLabelNumber().getContent());
//轴标签缩略间隔显示 恢复用注释。取消注释。
@ -620,30 +651,30 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
}
//轴线样式
private void populateLineStyle(VanChartAxis axis){
if(axisLineStyle != null){
private void populateLineStyle(VanChartAxis axis) {
if (axisLineStyle != null) {
axisLineStyle.setSelectedLineStyle(axis.getAxisStyle());
}
if(axisLineColor != null){
if (axisLineColor != null) {
axisLineColor.setSelectObject(axis.getAxisColor());
}
if(mainTick != null){
if (mainTick != null) {
mainTick.setSelectedItem(axis.getMainTickLine());
}
if(secondTick != null){
if (secondTick != null) {
secondTick.setSelectedItem(axis.getSecTickLine());
}
}
//位置
private void populatePosition(VanChartAxis axis){
if(position != null){
private void populatePosition(VanChartAxis axis) {
if (position != null) {
position.setSelectedItem(axis.getPosition());
if(position.getSelectedItem() == null){
if (position.getSelectedItem() == null) {
position.setSelectedIndex(1);
}
}
if(reversed != null){
if (reversed != null) {
reversed.setSelectedIndex(axis.hasAxisReversed() == true ? 0 : 1);
}
}
@ -666,13 +697,13 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
//格式
protected void populateFormat(VanChartAxis axis) {
if(valueFormatStyle != null){
if (valueFormatStyle != null) {
valueFormatStyle.setSelectedIndex(axis.isCommonValueFormat() ? 0 : 1);
}
if(valueFormat != null){
if (valueFormat != null) {
valueFormat.populateBean(axis.getFormat());
}
if(htmlLabelPane != null){
if (htmlLabelPane != null) {
htmlLabelPane.populate(axis.getHtmlLabel());
}
}
@ -690,15 +721,19 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
updateFormat(axis);
}
//标题
private void updateTitle(VanChartAxis axis){
private void updateTitle(VanChartAxis axis) {
if (showTitle != null) {
axis.setShowAxisTitle(showTitle.getSelectedIndex() == 0);
}
Title axisTitle = axis.getTitle();
if(axisTitle == null){
if (axisTitle == null) {
axisTitle = new Title();
axis.setTitle(axisTitle);
}
if(titleContent != null){
if (titleContent != null) {
String titleString = titleContent.updateBean();
Object titleObj;
if (StableUtils.maybeFormula(titleString)) {
@ -708,42 +743,42 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
}
axisTitle.setTextObject(titleObj);
}
if(titleAlignPane != null){
if (titleAlignPane != null) {
axisTitle.setPosition(titleAlignPane.getSelectedItem());
}
TextAttr textAttr = axisTitle.getTextAttr();
if(titleTextAttrPane != null){
if (titleTextAttrPane != null) {
titleTextAttrPane.update(textAttr);
}
if(titleUseHtml != null){
if (titleUseHtml != null) {
axis.setTitleUseHtml(titleUseHtml.isSelected());
}
if(titleTextRotation != null){
if (titleTextRotation != null) {
textAttr.setRotation(titleTextRotation.updateBean().intValue());
}
}
//标签
private void updateLabel(VanChartAxis axis){
if(showLabel != null){
private void updateLabel(VanChartAxis axis) {
if (showLabel != null) {
axis.setShowAxisLabel(showLabel.getSelectedIndex() == 0);
}
TextAttr labelTextAttr = axis.getTextAttr();
if(labelTextAttrPane != null){
if (labelTextAttrPane != null) {
labelTextAttrPane.update(labelTextAttr);
}
if(labelTextRotation != null){
if (labelTextRotation != null) {
labelTextAttr.setRotation(labelTextRotation.updateBean().intValue());
}
//轴标签缩略间隔显示 恢复用注释。取消注释。
// if (overlapHandleTypeGroup != null) {
// axis.setOverlapHandleType(overlapHandleTypeGroup.getSelectedItem());
// }
if(labelGapStyle != null){
if (labelGapStyle != null) {
axis.setAutoLabelGap(labelGapStyle.getSelectedIndex() == 0);
}
if(labelGapValue != null){
if (labelGapValue != null) {
//轴标签缩略间隔显示 恢复用注释。下面5行删除。
if (axis.isAutoLabelGap()) {
axis.setLabelIntervalNumber(BaseFormula.createFormulaBuilder().build("1"));
@ -756,33 +791,33 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
}
//轴线样式
private void updateLineStyle(VanChartAxis axis){
if(axisLineStyle != null){
private void updateLineStyle(VanChartAxis axis) {
if (axisLineStyle != null) {
axis.setAxisStyle(axisLineStyle.getSelectedLineStyle());
}
if(axisLineColor != null){
if (axisLineColor != null) {
axis.setAxisColor(axisLineColor.getSelectObject());
}
if(mainTick != null){
if (mainTick != null) {
axis.setMainTickLine(mainTick.getSelectedItem());
}
if(secondTick != null){
if (secondTick != null) {
axis.setSecTickLine(secondTick.getSelectedItem());
}
}
//位置
private void updatePosition(VanChartAxis axis){
if(position != null){
private void updatePosition(VanChartAxis axis) {
if (position != null) {
axis.setPosition(position.getSelectedItem());
}
if(reversed != null){
if (reversed != null) {
axis.setAxisReversed(reversed.getSelectedItem());
}
}
//显示策略
private void updateDisplayStrategy(VanChartAxis axis){
private void updateDisplayStrategy(VanChartAxis axis) {
//区域显示策略 恢复用注释。下面6行删除。
if (axisLimitSize != null) {
axis.setLimitSize(axisLimitSize.getSelectedIndex() == 0);
@ -797,29 +832,30 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
}
protected void updateFormat(VanChartAxis axis) {
if(valueFormatStyle != null){
if (valueFormatStyle != null) {
axis.setCommonValueFormat(valueFormatStyle.getSelectedIndex() == 0);
}
if(valueFormat != null){
if (valueFormat != null) {
axis.setFormat(valueFormat.update());
}
if(htmlLabelPane != null){
if (htmlLabelPane != null) {
htmlLabelPane.update(axis.getHtmlLabel());
}
}
/**
* X坐标轴不同类型切换,new一个新的
*
* @param axisName 坐标轴名称
* @return 新的axis
*/
public VanChartAxis updateBean(String axisName, int position){
public VanChartAxis updateBean(String axisName, int position) {
VanChartAxis axis = new VanChartAxis(axisName, position);
this.updateBean(axis);
return axis;
}
public VanChartAxis updateBean(){
public VanChartAxis updateBean() {
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.JPanel;
import java.text.ParseException;
import java.util.Date;
import java.util.regex.Pattern;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
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[] rowSize = {p,p,p,p,p,p,p,p,p,p,p,p,p,p};
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[]{createValueDefinition(),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[] rowSize = {p,p,p,p,p,p,p,p,p,p,p,p,p,p};
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[]{createMinMaxValuePane(new double[]{p, p}, columnSize), null},
new Component[]{createLineStylePane(new double[]{p, p, p, p, p}, columnSize), null},

15
designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartAbstractPlotSeriesPane.java

@ -5,7 +5,6 @@ import com.fr.base.chart.chartdata.model.LargeDataModel;
import com.fr.base.chart.chartdata.model.NormalDataModel;
import com.fr.chart.base.AttrAlpha;
import com.fr.chart.base.AttrBorder;
import com.fr.chart.base.ChartConstants;
import com.fr.chart.base.GradientStyle;
import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartglyph.ConditionAttr;
@ -90,7 +89,7 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP
}
JPanel panel = new JPanel(new BorderLayout());
JPanel colorPane = getColorPane();
if(colorPane != null) {
if (colorPane != null) {
panel.add(colorPane, BorderLayout.NORTH);
}
panel.add(getContentInPlotType(), BorderLayout.CENTER);
@ -279,7 +278,7 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP
checkoutMapType(plot);
if(vanChartFillStylePane != null) { //配色
if (vanChartFillStylePane != null) { //配色
vanChartFillStylePane.populateBean(plot.getPlotFillStyle());
}
@ -310,7 +309,7 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP
populateCondition(plot.getConditionCollection().getDefaultAttr());
checkAreaSeriesFillColorPane(plot.getPlotStyle());
checkAreaSeriesFillColorPane(((VanChartPlot) plot).getGradientStyle());
checkCompsEnabledWithLarge(plot);
}
@ -340,7 +339,7 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP
//更新之前先更新界面的map类型属性
checkoutMapType(plot);
if(vanChartFillStylePane != null) {//配色
if (vanChartFillStylePane != null) {//配色
plot.setPlotFillStyle(vanChartFillStylePane.updateBean());
}
@ -369,16 +368,16 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP
updateCondition(plot.getConditionCollection().getDefaultAttr());
checkAreaSeriesFillColorPane(plot.getPlotStyle());
checkAreaSeriesFillColorPane(((VanChartPlot) plot).getGradientStyle());
}
protected void checkoutMapType(Plot plot) {
}
protected void checkAreaSeriesFillColorPane(int plotStyle) {
protected void checkAreaSeriesFillColorPane(GradientStyle gradientStyle) {
if (areaSeriesFillColorPane != null) {
areaSeriesFillColorPane.checkoutAlpha(plotStyle == ChartConstants.STYLE_NONE);
areaSeriesFillColorPane.checkoutAlpha(gradientStyle.getGradientType() == GradientType.NONE);
}
}

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.ilable.BoldFontTextLabel;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
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.van.chart.map.designer.data.component.table.AbstractLongLatAreaPane;
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 f = TableLayout.FILL;
double labelWidth = 65;
this.setLayout(new BorderLayout(0, 5));
centerPane = new JPanel(new CardLayout()) {
@ -122,13 +125,14 @@ public class VanPointMapPlotTableDataContentPane extends VanAreaMapPlotTableData
locationType.setSelectedIndex(0);
double[] columnSize = {p, f};
double[] columnSize = {labelWidth, f};
double[] rowSize = {p};
UILabel label = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Geographic"));
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(centerPane, BorderLayout.CENTER);
@ -219,7 +223,7 @@ public class VanPointMapPlotTableDataContentPane extends VanAreaMapPlotTableData
return new PointMapAreaPane(longLatAreaTableComboPane) {
protected void initAreaPane(VanPointMapPlotTableDataContentPane.LongLatAreaTableComboPane parentPane) {
areaPane = new AreaPane(parentPane) {
protected Component[][] getComponent () {
protected Component[][] getComponent() {
return new Component[][]{
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();
FormSelectionUtils.paste2Container(designer, container, clipboard, rec.x + DELTA_X_Y, rec.y + DELTA_X_Y);
} else if (isExtraContainer(container)) {
provider.paste2Container(selection);
provider.paste2Container(clipboard);
}
}

4
designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java

@ -11,6 +11,7 @@ import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
import com.fr.design.designer.creator.cardlayout.XWCardTagLayout;
import com.fr.design.designer.creator.cardlayout.XWCardTitleLayout;
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
import com.fr.design.fun.ChartWidgetOptionProvider;
import com.fr.design.fun.FormWidgetOptionProvider;
import com.fr.design.fun.ParameterWidgetOptionProvider;
import com.fr.design.module.DesignModuleFactory;
@ -102,7 +103,8 @@ public class XCreatorUtils {
public boolean accept(PluginContext context) {
return context.contain(PluginModule.ExtraDesign, ParameterWidgetOptionProvider.XML_TAG)
|| context.contain(PluginModule.ExtraDesign, FormWidgetOptionProvider.XML_TAG);
|| context.contain(PluginModule.ExtraDesign, FormWidgetOptionProvider.XML_TAG)
|| context.contain(PluginModule.ExtraDesign, ChartWidgetOptionProvider.XML_TAG);
}
});
}

53
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.share.ShareConstants;
import com.fr.stable.StringUtils;
import org.jetbrains.annotations.NotNull;
import javax.swing.Icon;
import javax.swing.ImageIcon;
@ -52,12 +53,12 @@ import java.io.Serializable;
*/
public class ShareWidgetButton extends JPanel implements MouseListener, MouseMotionListener, Serializable {
private static final Dimension TAB_DEFAULT_SIZE = new Dimension(500, 300);
private SharableWidgetProvider bindInfo;
private MouseEvent lastPressEvent;
private JPanel reportPane;
private boolean isEdit;
private boolean isMarked;
protected SharableWidgetProvider bindInfo;
protected MouseEvent lastPressEvent;
protected JPanel reportPane;
protected boolean isEdit;
protected boolean isMarked;
private ShareWidgetUI ui;
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 AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 60 / 100.0F);
@ -72,8 +73,10 @@ public class ShareWidgetButton extends JPanel implements MouseListener, MouseMot
}
};
public ShareWidgetButton(SharableWidgetProvider bindInfo) {
public ShareWidgetButton(SharableWidgetProvider bindInfo, ShareWidgetUI ui) {
this.bindInfo = bindInfo;
this.ui = ui;
this.setPreferredSize(new Dimension(108, 68));
initUI();
this.setLayout(getCoverLayout());
@ -82,6 +85,11 @@ public class ShareWidgetButton extends JPanel implements MouseListener, MouseMot
new DragAndDropDragGestureListener(this, DnDConstants.ACTION_COPY_OR_MOVE);
}
public ShareWidgetButton(SharableWidgetProvider bindInfo) {
this(bindInfo, new ShareWidgetUI());
}
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
Composite oldComposite = g2d.getComposite();
@ -219,14 +227,7 @@ public class ShareWidgetButton extends JPanel implements MouseListener, MouseMot
if (creatorSource != null) {
((AbstractBorderStyleWidget)creatorSource).addWidgetAttrMark(new SharableAttrMark(true));
//tab布局WCardMainBorderLayout通过反射出来的大小是960*480
XCreator xCreator = null;
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);
XCreator xCreator = ui.createXCreator(creatorSource, shareId, no.getBindInfo());
WidgetToolBarPane.getTarget().startDraggingBean(xCreator);
lastPressEvent = null;
this.setBorder(null);
@ -288,4 +289,26 @@ public class ShareWidgetButton extends JPanel implements MouseListener, MouseMot
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());
}
}

11
designer-realize/src/main/java/com/fr/design/actions/columnrow/ColumnRowSizingAction.java

@ -13,6 +13,7 @@ import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.fun.ReportLengthUNITProvider;
import com.fr.design.unit.UnitConvertUtil;
import com.fr.general.ComparatorUtils;
import com.fr.grid.selection.CellSelection;
import com.fr.report.elementcase.ElementCase;
import com.fr.stable.ArrayUtils;
@ -39,8 +40,8 @@ public abstract class ColumnRowSizingAction extends AbstractColumnRowIndexAction
return ColumnRowSizingAction.this.title4UnitInputPane();
}
};
UNIT len = getShowLen(report, cs);
populateNumberDialog(uPane, len);
final UNIT oldLen = getShowLen(report, cs);
populateNumberDialog(uPane, oldLen);
final CellSelection finalCS = cs;
uPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
@ -51,8 +52,10 @@ public abstract class ColumnRowSizingAction extends AbstractColumnRowIndexAction
float newHeight = (float) uPane.update();
int unitType = DesignerEnvManager.getEnvManager().getReportLengthUnit();
ReportLengthUNITProvider lengthUNIT = UnitConvertUtil.parseLengthUNIT(unitType);
UNIT len = lengthUNIT.float2UNIT(newHeight);
updateAction(report, len, finalCS);
UNIT newLen = lengthUNIT.float2UNIT(newHeight);
if (!ComparatorUtils.equals(oldLen, newLen)) {
updateAction(report, newLen, finalCS);
}
} catch (ValueNotChangeException e) {
// nothing
}

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

@ -256,8 +256,11 @@ public class RichTextToolBar extends BasicPane{
@Override
public void actionPerformed(ActionEvent e) {
boolean isSub = RichTextToolBar.this.subPane.isSelected();
// 调用setCharacterAttributes函数设置文本区选择文本的字体
MutableAttributeSet attr = new SimpleAttributeSet();
if (!isSub && RichTextToolBar.this.superPane.isSelected()) {
StyleConstants.setSuperscript(attr, false);
}
// 调用setCharacterAttributes函数设置文本区选择文本的字体
StyleConstants.setSubscript(attr, !isSub);
setCharacterAttributes(RichTextToolBar.this.textPane, attr, false);
}
@ -269,6 +272,9 @@ public class RichTextToolBar extends BasicPane{
boolean isSuper = RichTextToolBar.this.superPane.isSelected();
// 调用setCharacterAttributes函数设置文本区选择文本的字体
MutableAttributeSet attr = new SimpleAttributeSet();
if (!isSuper && RichTextToolBar.this.subPane.isSelected()) {
StyleConstants.setSubscript(attr, false);
}
StyleConstants.setSuperscript(attr, !isSuper);
setCharacterAttributes(RichTextToolBar.this.textPane, attr, false);
}
@ -402,7 +408,7 @@ public class RichTextToolBar extends BasicPane{
bold.setSelected(isBold);
italic.setSelected(isItalic);
underline.setSelected(isUnderline);
subPane.setSelected(isSubscript);
subPane.setSelected(isSuperscript ? false : isSubscript);
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:判断是否重名
boolean isExisted = false;
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;
break;
}

37
designer-realize/src/main/java/com/fr/design/report/PageSetupPane.java

@ -19,25 +19,20 @@ import java.awt.event.FocusEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.ButtonGroup;
import javax.swing.Icon;
import javax.swing.*;
import com.fr.design.gui.ispinner.ColumnRowSpinner;
import com.fr.page.PaperSettingProvider;
import com.fr.page.ReportSettingsProvider;
import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.ilable.UILabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.NumberFormatter;
import com.fr.base.BaseUtils;
import com.fr.base.Margin;
@ -72,6 +67,7 @@ public class PageSetupPane extends BasicPane {
private PagePane pagePane;
private OtherPane otherPane;
private UILabel zeroMarginWarn;
private static final String E = "E";
public PageSetupPane() {
this.initComponents();
@ -212,6 +208,13 @@ public class PageSetupPane extends BasicPane {
((JSpinner.DefaultEditor) paperWidthSpinner.getEditor()).getTextField().setColumns(7);
paperHeightSpinner = new UIBasicSpinner(new SpinnerNumberModel(0.0, 0.0, Double.MAX_VALUE, 1.0));
((JSpinner.DefaultEditor) paperHeightSpinner.getEditor()).getTextField().setColumns(7);
JFormattedTextField txt = ((JSpinner.NumberEditor) paperWidthSpinner.getEditor()).getTextField();
((NumberFormatter) txt.getFormatter()).setAllowsInvalid(false);
txt = ((JSpinner.NumberEditor) paperHeightSpinner.getEditor()).getTextField();
((NumberFormatter) txt.getFormatter()).setAllowsInvalid(false);
unitLabel = new UnitFieldPane.UnitLabel(Constants.UNIT_MM, paperHeightSpinner.getPreferredSize().height);
String[] inch = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Unit_MM"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Unit_INCH")};
@ -738,8 +741,8 @@ public class PageSetupPane extends BasicPane {
return;
}
// 最大2000,以免画的时候超边
this.paper_width = Math.min(paper_width, 2000);
this.paper_height = Math.min(paper_height, 2000);
this.paper_width = Math.min(paper_width, Double.MAX_VALUE);
this.paper_height = Math.min(paper_height, Double.MAX_VALUE);
this.paper_orientation = paper_orientation;
length_scale = !useLocale ? NUM_3 : NUM_POINT_3;
}
@ -766,22 +769,28 @@ public class PageSetupPane extends BasicPane {
FontMetrics fm = g2d.getFontMetrics();
// 横向的长度
String w_str = "" + paper_width;
if (w_str.indexOf(CoreConstants.DOT) > 0) {
if (!w_str.contains(E) && w_str.indexOf(CoreConstants.DOT) > 0) {
w_str = w_str.substring(0, w_str.indexOf(CoreConstants.DOT) + 2);
}
int w_length = fm.stringWidth(w_str);
paint_width = Math.max(paint_width, w_length + 26);
// 纵向的长度
String h_str = "" + paper_height;
if (h_str.indexOf(".") > 0) {
h_str = h_str.substring(0, h_str.indexOf(".") + 2);
//使用科学计数法显示长度的时候,限制纵向显示长度为9位
if (h_str.contains(E)) {
String str1 = h_str.substring(h_str.indexOf(E));
String str2 = h_str.substring(0, 9 - str1.length());
h_str = str2 + str1;
} else if (h_str.indexOf(CoreConstants.DOT) > 0) {
h_str = h_str.substring(0, h_str.indexOf(CoreConstants.DOT) + 2);
}
int h_length = fm.stringWidth(h_str);
paint_height = Math.max(paint_height, h_length + 26);
paint_height = Math.min(paint_height, 74);
double startX = (pane_width - paint_width) / 2;
double startY = (pane_height - paint_height) / 2;
g2d.translate(startX, startY);
g2d = getG2d(paint_width, paint_height,g2d,w_str,h_str,w_length,h_length);
g2d = getG2d(paint_width, paint_height, g2d, w_str, h_str, w_length, h_length);
if (paper_orientation == ReportConstants.PORTRAIT) {
g2d.drawImage(img, (int) ((paint_width - img.getWidth(null)) / 2),
(int) ((paint_height - img.getHeight(null)) / 2), null);

16
designer-realize/src/main/java/com/fr/grid/GridUI.java

@ -300,6 +300,8 @@ public class GridUI extends ComponentUI {
private int resolution;
private static final double THRESHOLD = 1.0E-4D;
DrawLineHelper(int startIndex, int endIndex, boolean showGridLine,
boolean showPaginateLine, DynamicUnitList sizeList, double paperPaintSize,
List paginateLineList, int resolution) {
@ -342,7 +344,7 @@ public class GridUI extends ComponentUI {
}
// paint paper margin line.
if (showPaginateLine && paperSumSize >= paperPaintSize) {
if (showPaginateLine && paperSumSize - paperPaintSize > THRESHOLD) {
paginateLineList.add(getPaginateLine2D((int) sumSize));
paperSumSize = tmpSize;
}
@ -497,8 +499,8 @@ public class GridUI extends ComponentUI {
paintCellElementRectangleList.add(this.tmpRectangle.clone());
double cellWidth = this.tmpRectangle.getWidth();
double cellHeight = this.tmpRectangle.getHeight();
double cellWidth = this.tmpRectangle.getWidth();
double cellHeight = this.tmpRectangle.getHeight();
// denny_Grid: 画Grid中单元格的内容(包括单元格的背景Content + Background), 不包括边框
painter.paintBackground(g2d, report, tmpCellElement, cellWidth - 1, cellHeight - 1);
@ -625,10 +627,10 @@ public class GridUI extends ComponentUI {
tmpLine2D = (Line2D) paginateLineList.get(j);// 直接强制转换,因为List中肯定都是Line2D型的
for (int k = j + 1; k < paginateLineList.size(); k++) {
tmpLine2D2 = (Line2D) paginateLineList.get(k);
if (AssistUtils.equals(tmpLine2D2.getX1() ,tmpLine2D.getX1())
&& AssistUtils.equals(tmpLine2D2.getX2() , tmpLine2D.getX2())
&& AssistUtils.equals(tmpLine2D2.getY1() , tmpLine2D.getY1())
&& AssistUtils.equals(tmpLine2D2.getY2() , tmpLine2D.getY2())) {
if (AssistUtils.equals(tmpLine2D2.getX1(), tmpLine2D.getX1())
&& AssistUtils.equals(tmpLine2D2.getX2(), tmpLine2D.getX2())
&& AssistUtils.equals(tmpLine2D2.getY1(), tmpLine2D.getY1())
&& AssistUtils.equals(tmpLine2D2.getY2(), tmpLine2D.getY2())) {
paginateLineList.remove(k);
}
}

8
designer-realize/src/main/java/com/fr/grid/IntelliElements.java

@ -194,8 +194,12 @@ public class IntelliElements {
TemplateCellElement newCellElement = new DefaultTemplateCellElement(colIndex, rowIndex);
applyStyle(newCellElement, sourceCellElement);//style
if (sourceCellElement.getValue() instanceof DSColumn) {
DSColumn dsColumn = (DSColumn) sourceCellElement.getValue();
newCellElement.setValue(dsColumn);
try{
DSColumn dsColumn = (DSColumn)((DSColumn) sourceCellElement.getValue()).clone();
newCellElement.setValue(dsColumn);
}catch (CloneNotSupportedException e){
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
newCellElement.setCellExpandAttr(sourceCellElement.getCellExpandAttr());
} else if (sourceCellElement.getValue() instanceof Number) {
newCellElement.setValue(processNumber((Number) sourceCellElement.getValue()));

Loading…
Cancel
Save