From 176b9752aa2abeb1224c7a0881ecb97511612184 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Mon, 28 Nov 2016 15:50:24 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89SQL=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=95=B0=E6=8D=AE=E9=9B=86=E6=80=BB=E8=A1=8C=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tabledatapane/DBTableDataPane.java | 165 +++++++++++------- 1 file changed, 98 insertions(+), 67 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 b0fba71c96..81a50d2ac2 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 @@ -57,7 +57,8 @@ public class DBTableDataPane extends AbstractTableDataPane { private UICheckBox isShareCheckBox; private MaxMemRowCountPanel maxPanel; private String pageQuery = null; - + private String customCountQuery = null; + public DBTableDataPane() { this.setLayout(new BorderLayout(4, 4)); @@ -134,23 +135,24 @@ public class DBTableDataPane extends AbstractTableDataPane { this.add(mainSplitPane, BorderLayout.CENTER); } - private boolean isPreviewOrRefreshButton (FocusEvent e) { - if (e.getOppositeComponent() != null) { - String name = e.getOppositeComponent().getName(); - return ComparatorUtils.equals(name, PREVIEW_BUTTON) || ComparatorUtils.equals(name, REFRESH_BUTTON); - } - return false; - } + private boolean isPreviewOrRefreshButton (FocusEvent e) { + if (e.getOppositeComponent() != null) { + String name = e.getOppositeComponent().getName(); + return ComparatorUtils.equals(name, PREVIEW_BUTTON) || ComparatorUtils.equals(name, REFRESH_BUTTON); + } + return false; + } @Override protected String title4PopupWindow() { - return Inter.getLocText("FR-Designer-DS-Database_Query"); + return Inter.getLocText("DS-Database_Query"); } private void refresh() { - String[] paramTexts = new String[2]; + String[] paramTexts = new String[3]; paramTexts[0] = sqlTextPane.getText(); paramTexts[1] = pageQuery; + paramTexts[2] = customCountQuery; List existParameterList = editorPane.update(); Parameter[] ps = existParameterList == null ? new Parameter[0] : existParameterList.toArray(new Parameter[existParameterList.size()]); @@ -164,9 +166,11 @@ public class DBTableDataPane extends AbstractTableDataPane { toolBarDef.addShortCut(new PreviewAction()); toolBarDef.addShortCut(SeparatorDef.DEFAULT); toolBarDef.addShortCut(new EditPageQueryAction()); - isShareCheckBox = new UICheckBox(Inter.getLocText("FR-Designer_Is_Share_DBTableData")); + toolBarDef.addShortCut(SeparatorDef.DEFAULT); + toolBarDef.addShortCut(new EditCustomCountQueryAction()); + isShareCheckBox = new UICheckBox(Inter.getLocText("Is_Share_DBTableData")); maxPanel = new MaxMemRowCountPanel(); - maxPanel.setBorder(null); + maxPanel.setBorder(null); UIToolbar editToolBar = ToolBarDef.createJToolBar(); toolBarDef.updateToolBar(editToolBar); editToolBar.add(isShareCheckBox); @@ -175,9 +179,10 @@ public class DBTableDataPane extends AbstractTableDataPane { } private void checkParameter() { - String[] paramTexts = new String[2]; + String[] paramTexts = new String[3]; paramTexts[0] = sqlTextPane.getText(); paramTexts[1] = pageQuery; + paramTexts[2] = customCountQuery; Parameter[] parameters = ParameterHelper.analyze4Parameters(paramTexts, false); @@ -222,6 +227,7 @@ 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); @@ -258,6 +264,7 @@ public class DBTableDataPane extends AbstractTableDataPane { dbTableData.setShare(isShareCheckBox.isSelected()); dbTableData.setMaxMemRowCount(maxPanel.getValue()); dbTableData.setPageQuerySql(this.pageQuery); + dbTableData.setCustomCountQuery(this.customCountQuery); return dbTableData; } @@ -285,64 +292,88 @@ public class DBTableDataPane extends AbstractTableDataPane { } public void actionPerformed(ActionEvent evt) { - checkParameter(); - PreviewTablePane.previewTableData(DBTableDataPane.this.updateBean()); + checkParameter(); + PreviewTablePane.previewTableData(DBTableDataPane.this.updateBean()); + } + } + + 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 EditPageQueryAction extends UpdateAction { + public EditPageQueryAction() { + this.setName(Inter.getLocText("FR-Designer-LayerPageReport_PageQuery")); + this.setMnemonic('L'); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/text.png")); + } + + public void actionPerformed(ActionEvent e) { + final QueryPane pane = new QueryPane(Inter.getLocText("FR-Designer-LayerPageReport_Define_PageQuerySQL")); + pane.populate(pageQuery); + BasicDialog dialog = pane.showWindow(DesignerContext.getDesignerFrame()); + dialog.addDialogActionListener(new DialogActionAdapter() { + public void doOk() { + pageQuery = pane.update(); + checkParameter(); + } + }); + dialog.setVisible(true); } } - - private class EditPageQueryAction extends UpdateAction { - public EditPageQueryAction() { - this.setName(Inter.getLocText("FR-Designer-LayerPageReport_PageQuery")); - this.setMnemonic('L'); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/text.png")); - } - - public void actionPerformed(ActionEvent e) { - final PageQueryPane pane = new PageQueryPane(); - pane.populate(pageQuery); - BasicDialog dialog = pane.showWindow(DesignerContext.getDesignerFrame()); - dialog.addDialogActionListener(new DialogActionAdapter() { - public void doOk() { - pageQuery = pane.update(); - checkParameter(); - } - }); - dialog.setVisible(true); - } - } - - private class PageQueryPane extends BasicPane { - private SQLEditPane pageQueryPane; - - public PageQueryPane() { - this.initComponents(); - } - - public void initComponents() { - this.setLayout(new BorderLayout()); - pageQueryPane = new SQLEditPane(); - this.add(new JScrollPane(pageQueryPane)); - } - - public void populate(String text) { - if (StringUtils.isBlank(text)) { - return; - } - pageQueryPane.setText(text); - } - - public String update() { - String text = pageQueryPane.getText(); - if (StringUtils.isBlank(text)) { - return null; - } else { - return text; - } - } + + private class QueryPane extends BasicPane { + private SQLEditPane pageQueryPane; + private String title; + + public QueryPane(String title) { + this.title = title; + this.initComponents(); + } + + public void initComponents() { + this.setLayout(new BorderLayout()); + pageQueryPane = new SQLEditPane(); + this.add(new JScrollPane(pageQueryPane)); + } + + public void populate(String text) { + if (StringUtils.isBlank(text)) { + return; + } + pageQueryPane.setText(text); + } + + public String update() { + String text = pageQueryPane.getText(); + if (StringUtils.isBlank(text)) { + return null; + } else { + return text; + } + } @Override protected String title4PopupWindow() { - return Inter.getLocText("FR-Designer-LayerPageReport_Define_PageQuerySQL"); + return title; } - } + } } \ No newline at end of file From a72ce46cc96155e22026e056b11c961eba86fcbf Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Mon, 28 Nov 2016 16:12:21 +0800 Subject: [PATCH 2/2] rt --- .../tabledatapane/DBTableDataPane.java | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 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 81a50d2ac2..553e6814c0 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 @@ -145,7 +145,7 @@ public class DBTableDataPane extends AbstractTableDataPane { @Override protected String title4PopupWindow() { - return Inter.getLocText("DS-Database_Query"); + return Inter.getLocText("FR-Designer-DS-Database_Query"); } private void refresh() { @@ -168,7 +168,7 @@ public class DBTableDataPane extends AbstractTableDataPane { toolBarDef.addShortCut(new EditPageQueryAction()); toolBarDef.addShortCut(SeparatorDef.DEFAULT); toolBarDef.addShortCut(new EditCustomCountQueryAction()); - isShareCheckBox = new UICheckBox(Inter.getLocText("Is_Share_DBTableData")); + isShareCheckBox = new UICheckBox(Inter.getLocText("FR-Designer_Is_Share_DBTableData")); maxPanel = new MaxMemRowCountPanel(); maxPanel.setBorder(null); UIToolbar editToolBar = ToolBarDef.createJToolBar(); @@ -297,46 +297,46 @@ public class DBTableDataPane extends AbstractTableDataPane { } } - private class EditCustomCountQueryAction extends UpdateAction { - public EditCustomCountQueryAction() { - this.setName(Inter.getLocText("FR-Designer-LayerPageReport_CustomCountQuery")); + private class EditPageQueryAction extends UpdateAction { + public EditPageQueryAction() { + this.setName(Inter.getLocText("FR-Designer-LayerPageReport_PageQuery")); + this.setMnemonic('L'); 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()); + final QueryPane pane = new QueryPane(Inter.getLocText("FR-Designer-LayerPageReport_Define_PageQuerySQL")); + pane.populate(pageQuery); + BasicDialog dialog = pane.showWindow(DesignerContext.getDesignerFrame()); dialog.addDialogActionListener(new DialogActionAdapter() { public void doOk() { - customCountQuery = editPane.update(); + pageQuery = pane.update(); checkParameter(); } }); dialog.setVisible(true); - } } - private class EditPageQueryAction extends UpdateAction { - public EditPageQueryAction() { - this.setName(Inter.getLocText("FR-Designer-LayerPageReport_PageQuery")); - this.setMnemonic('L'); + 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 pane = new QueryPane(Inter.getLocText("FR-Designer-LayerPageReport_Define_PageQuerySQL")); - pane.populate(pageQuery); - BasicDialog dialog = pane.showWindow(DesignerContext.getDesignerFrame()); + 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() { - pageQuery = pane.update(); + customCountQuery = editPane.update(); checkParameter(); } }); dialog.setVisible(true); + } }