From 81db8a7da5c357cabb25f7c1344d470395938272 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Mon, 16 Jan 2017 19:40:39 +0800 Subject: [PATCH 1/5] rt --- .../tabledatapane/DBTableDataPane.java | 53 ++++++------------- .../fr/design/fun/DBTableDataMenuHandler.java | 24 +++++++++ .../impl/AbstractDBTableDataMenuHandler.java | 34 ++++++++++++ 3 files changed, 75 insertions(+), 36 deletions(-) create mode 100644 designer_base/src/com/fr/design/fun/DBTableDataMenuHandler.java create mode 100644 designer_base/src/com/fr/design/fun/impl/AbstractDBTableDataMenuHandler.java diff --git a/designer_base/src/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java b/designer_base/src/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java index 553e6814c0..94e6b44b69 100644 --- a/designer_base/src/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java +++ b/designer_base/src/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java @@ -7,6 +7,7 @@ import com.fr.base.ParameterHelper; import com.fr.data.core.db.TableProcedure; import com.fr.data.impl.DBTableData; import com.fr.data.impl.NameDatabaseConnection; +import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.UpdateAction; import com.fr.design.border.UIRoundedBorder; import com.fr.design.constants.UIConstants; @@ -17,6 +18,7 @@ import com.fr.design.data.datapane.sqlpane.SQLEditPane; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.fun.DBTableDataMenuHandler; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itableeditorpane.ParameterTableModel; @@ -34,7 +36,6 @@ import com.fr.general.Inter; import com.fr.script.Calculator; import com.fr.stable.ArrayUtils; import com.fr.stable.ParameterProvider; -import com.fr.stable.ProductConstants; import com.fr.stable.StringUtils; import javax.swing.*; @@ -53,11 +54,11 @@ public class DBTableDataPane extends AbstractTableDataPane { private ConnectionTableProcedurePane connectionTableProcedurePane; private UITableEditorPane editorPane; + private DBTableDataMenuHandler dbTableDataMenuHandler; private SQLEditPane sqlTextPane; private UICheckBox isShareCheckBox; private MaxMemRowCountPanel maxPanel; private String pageQuery = null; - private String customCountQuery = null; public DBTableDataPane() { @@ -149,11 +150,10 @@ public class DBTableDataPane extends AbstractTableDataPane { } private void refresh() { - String[] paramTexts = new String[3]; + String[] paramTexts = new String[2]; paramTexts[0] = sqlTextPane.getText(); paramTexts[1] = pageQuery; - paramTexts[2] = customCountQuery; - + String queryText = null; List existParameterList = editorPane.update(); Parameter[] ps = existParameterList == null ? new Parameter[0] : existParameterList.toArray(new Parameter[existParameterList.size()]); @@ -166,8 +166,11 @@ public class DBTableDataPane extends AbstractTableDataPane { toolBarDef.addShortCut(new PreviewAction()); toolBarDef.addShortCut(SeparatorDef.DEFAULT); toolBarDef.addShortCut(new EditPageQueryAction()); - toolBarDef.addShortCut(SeparatorDef.DEFAULT); - toolBarDef.addShortCut(new EditCustomCountQueryAction()); + dbTableDataMenuHandler = ExtraDesignClassManager.getInstance().getSingle(DBTableDataMenuHandler.MARK_STRING); + if (dbTableDataMenuHandler != null) { + toolBarDef.addShortCut(SeparatorDef.DEFAULT); + toolBarDef.addShortCut(dbTableDataMenuHandler.createQueryAction()); + } isShareCheckBox = new UICheckBox(Inter.getLocText("FR-Designer_Is_Share_DBTableData")); maxPanel = new MaxMemRowCountPanel(); maxPanel.setBorder(null); @@ -179,11 +182,9 @@ public class DBTableDataPane extends AbstractTableDataPane { } private void checkParameter() { - String[] paramTexts = new String[3]; + String[] paramTexts = new String[2]; paramTexts[0] = sqlTextPane.getText(); paramTexts[1] = pageQuery; - paramTexts[2] = customCountQuery; - Parameter[] parameters = ParameterHelper.analyze4Parameters(paramTexts, false); if (parameters.length < 1 && editorPane.update().size() < 1) { @@ -210,6 +211,9 @@ public class DBTableDataPane extends AbstractTableDataPane { @Override public void populateBean(DBTableData dbtabledata) { + if (dbTableDataMenuHandler != null) { + dbTableDataMenuHandler.setDBTableData(dbtabledata); + } ParameterProvider[] parameters = null; Calculator c = Calculator.createCalculator(); @@ -227,8 +231,6 @@ public class DBTableDataPane extends AbstractTableDataPane { isShare = dbtabledata.isShare(); maxMemeryRow = dbtabledata.getMaxMemRowCount(); this.pageQuery = dbtabledata.getPageQuerySql(); - this.customCountQuery = dbtabledata.getCustomCountQuery(); - this.connectionTableProcedurePane.setSelectedDatabaseConnection(db); this.sqlTextPane.setText(query); this.sqlTextPane.requestFocus(); @@ -264,8 +266,9 @@ public class DBTableDataPane extends AbstractTableDataPane { dbTableData.setShare(isShareCheckBox.isSelected()); dbTableData.setMaxMemRowCount(maxPanel.getValue()); dbTableData.setPageQuerySql(this.pageQuery); - dbTableData.setCustomCountQuery(this.customCountQuery); - + if (dbTableDataMenuHandler != null) { + dbTableData.setCustomCountQuery(dbTableDataMenuHandler.getDbTableData().getCustomCountQuery()); + } return dbTableData; } @@ -318,28 +321,6 @@ public class DBTableDataPane extends AbstractTableDataPane { } } - private class EditCustomCountQueryAction extends UpdateAction { - public EditCustomCountQueryAction() { - this.setName(Inter.getLocText("FR-Designer-LayerPageReport_CustomCountQuery")); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/text.png")); - } - - @Override - public void actionPerformed(ActionEvent e) { - final QueryPane editPane = new QueryPane(Inter.getLocText("FR-Designer-LayerPageReport_Define_CustomCountQuery")); - editPane.populate(customCountQuery); - BasicDialog dialog = editPane.showWindow(DesignerContext.getDesignerFrame()); - dialog.addDialogActionListener(new DialogActionAdapter() { - public void doOk() { - customCountQuery = editPane.update(); - checkParameter(); - } - }); - dialog.setVisible(true); - - } - } - private class QueryPane extends BasicPane { private SQLEditPane pageQueryPane; private String title; diff --git a/designer_base/src/com/fr/design/fun/DBTableDataMenuHandler.java b/designer_base/src/com/fr/design/fun/DBTableDataMenuHandler.java new file mode 100644 index 0000000000..c32bf7e86a --- /dev/null +++ b/designer_base/src/com/fr/design/fun/DBTableDataMenuHandler.java @@ -0,0 +1,24 @@ +package com.fr.design.fun; + +import com.fr.data.impl.DBTableData; +import com.fr.design.actions.UpdateAction; +import com.fr.stable.fun.mark.Immutable; + +/** + * Created by xiaxiang on 2017/1/15. + */ +public interface DBTableDataMenuHandler extends Immutable { + String MARK_STRING = "DBTableDataMenuHandler"; + + int CURRENT_LEVEL = 1; + + UpdateAction createQueryAction(); + + DBTableData getDbTableData(); + + void setDBTableData(DBTableData dbTableData); + + + + +} diff --git a/designer_base/src/com/fr/design/fun/impl/AbstractDBTableDataMenuHandler.java b/designer_base/src/com/fr/design/fun/impl/AbstractDBTableDataMenuHandler.java new file mode 100644 index 0000000000..f0a8207f13 --- /dev/null +++ b/designer_base/src/com/fr/design/fun/impl/AbstractDBTableDataMenuHandler.java @@ -0,0 +1,34 @@ +package com.fr.design.fun.impl; + +import com.fr.data.impl.DBTableData; +import com.fr.design.actions.UpdateAction; +import com.fr.design.fun.DBTableDataMenuHandler; +import com.fr.stable.fun.mark.API; + +/** + * Created by xiaxiang on 2017/1/15. + */ +@API(level = DBTableDataMenuHandler.CURRENT_LEVEL) +public abstract class AbstractDBTableDataMenuHandler implements DBTableDataMenuHandler { + public int currentAPILevel() { + return CURRENT_LEVEL; + } + + public int layerIndex() { + return DEFAULT_LAYER_INDEX; + } + + public UpdateAction createQueryAction() { + return null; + } + + @Override + public DBTableData getDbTableData() { + return null; + } + + @Override + public void setDBTableData(DBTableData dbTableData) { + + } +} From e539908dcbc0e7964ad7a00effb9f3b3549b5aeb Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Tue, 17 Jan 2017 14:57:27 +0800 Subject: [PATCH 2/5] rt --- .../fr/design/data/tabledata/tabledatapane/DBTableDataPane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java b/designer_base/src/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java index 94e6b44b69..fed22c080d 100644 --- a/designer_base/src/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java +++ b/designer_base/src/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java @@ -267,7 +267,7 @@ public class DBTableDataPane extends AbstractTableDataPane { dbTableData.setMaxMemRowCount(maxPanel.getValue()); dbTableData.setPageQuerySql(this.pageQuery); if (dbTableDataMenuHandler != null) { - dbTableData.setCustomCountQuery(dbTableDataMenuHandler.getDbTableData().getCustomCountQuery()); + dbTableData.setDataQueryProcessor(dbTableDataMenuHandler.getDbTableData().getDataQueryProcessor()); } return dbTableData; } From a42bd2793829a8e84e8507d802b23c86a5977617 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Tue, 17 Jan 2017 18:53:12 +0800 Subject: [PATCH 3/5] rt --- .../fr/design/data/tabledata/tabledatapane/DBTableDataPane.java | 1 - 1 file changed, 1 deletion(-) diff --git a/designer_base/src/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java b/designer_base/src/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java index fed22c080d..94f88df8cc 100644 --- a/designer_base/src/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java +++ b/designer_base/src/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java @@ -153,7 +153,6 @@ public class DBTableDataPane extends AbstractTableDataPane { String[] paramTexts = new String[2]; paramTexts[0] = sqlTextPane.getText(); paramTexts[1] = pageQuery; - String queryText = null; List existParameterList = editorPane.update(); Parameter[] ps = existParameterList == null ? new Parameter[0] : existParameterList.toArray(new Parameter[existParameterList.size()]); From 74f529695de80d2fec5a0fa3993ceb1b41485e39 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Wed, 18 Jan 2017 10:19:00 +0800 Subject: [PATCH 4/5] rt --- .../data/tabledata/tabledatapane/DBTableDataPane.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/designer_base/src/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java b/designer_base/src/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java index 94f88df8cc..75b3219ebd 100644 --- a/designer_base/src/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java +++ b/designer_base/src/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java @@ -59,6 +59,8 @@ public class DBTableDataPane extends AbstractTableDataPane { private UICheckBox isShareCheckBox; private MaxMemRowCountPanel maxPanel; private String pageQuery = null; + private DBTableData dbTableData; + public DBTableDataPane() { @@ -210,8 +212,9 @@ public class DBTableDataPane extends AbstractTableDataPane { @Override public void populateBean(DBTableData dbtabledata) { + this.dbTableData = dbtabledata; if (dbTableDataMenuHandler != null) { - dbTableDataMenuHandler.setDBTableData(dbtabledata); + dbTableDataMenuHandler.populate(dbtabledata); } ParameterProvider[] parameters = null; @@ -254,7 +257,6 @@ public class DBTableDataPane extends AbstractTableDataPane { List parameterList = editorPane.update(); Parameter[] parameters = parameterList.toArray(new Parameter[parameterList.size()]); - DBTableData dbTableData = new DBTableData(); dbTableData.setDatabase(new NameDatabaseConnection(dbName)); // p:必须先设置Parameters数组,因为setQuery里面会自动设置的 @@ -266,7 +268,7 @@ public class DBTableDataPane extends AbstractTableDataPane { dbTableData.setMaxMemRowCount(maxPanel.getValue()); dbTableData.setPageQuerySql(this.pageQuery); if (dbTableDataMenuHandler != null) { - dbTableData.setDataQueryProcessor(dbTableDataMenuHandler.getDbTableData().getDataQueryProcessor()); + dbTableDataMenuHandler.update(); } return dbTableData; } From 5a16de43fa8ede11ce2e05662b0781cf96b992c2 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Wed, 18 Jan 2017 10:19:27 +0800 Subject: [PATCH 5/5] rt --- .../src/com/fr/design/fun/DBTableDataMenuHandler.java | 6 ++---- .../fr/design/fun/impl/AbstractDBTableDataMenuHandler.java | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/designer_base/src/com/fr/design/fun/DBTableDataMenuHandler.java b/designer_base/src/com/fr/design/fun/DBTableDataMenuHandler.java index c32bf7e86a..f06b63b712 100644 --- a/designer_base/src/com/fr/design/fun/DBTableDataMenuHandler.java +++ b/designer_base/src/com/fr/design/fun/DBTableDataMenuHandler.java @@ -14,11 +14,9 @@ public interface DBTableDataMenuHandler extends Immutable { UpdateAction createQueryAction(); - DBTableData getDbTableData(); - - void setDBTableData(DBTableData dbTableData); - + void populate(DBTableData dbTableData); + DBTableData update(); } diff --git a/designer_base/src/com/fr/design/fun/impl/AbstractDBTableDataMenuHandler.java b/designer_base/src/com/fr/design/fun/impl/AbstractDBTableDataMenuHandler.java index f0a8207f13..dd11712505 100644 --- a/designer_base/src/com/fr/design/fun/impl/AbstractDBTableDataMenuHandler.java +++ b/designer_base/src/com/fr/design/fun/impl/AbstractDBTableDataMenuHandler.java @@ -23,12 +23,12 @@ public abstract class AbstractDBTableDataMenuHandler implements DBTableDataMenuH } @Override - public DBTableData getDbTableData() { + public DBTableData update() { return null; } @Override - public void setDBTableData(DBTableData dbTableData) { + public void populate(DBTableData dbTableData) { } }