From 4f62f88149dace31c3bf6fd84cd2fcd714217979 Mon Sep 17 00:00:00 2001 From: Tommy Date: Mon, 13 Dec 2021 11:48:34 +0800 Subject: [PATCH 1/4] =?UTF-8?q?REPORT-63505=20=E5=9B=BE=E8=A1=A8=E8=BF=9B?= =?UTF-8?q?=E5=85=A5=E7=BC=96=E8=BE=91=E7=8A=B6=E6=80=81=E5=90=8E=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E7=BB=84=E4=BB=B6=E9=A2=84=E8=A7=88=E5=9B=BE=E4=B8=8D?= =?UTF-8?q?=E6=B8=B2=E6=9F=93=E5=9B=BE=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../share/action/CreateComponentAction.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/action/CreateComponentAction.java b/designer-form/src/main/java/com/fr/design/mainframe/share/action/CreateComponentAction.java index 1baac868f..8d2adceb8 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/action/CreateComponentAction.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/action/CreateComponentAction.java @@ -10,7 +10,9 @@ import com.fr.data.impl.NameTableData; import com.fr.data.impl.TableDataDictionary; import com.fr.design.actions.UpdateAction; import com.fr.design.data.DesignTableDataManager; +import com.fr.design.designer.creator.XChartEditor; import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XWTitleLayout; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.FineJOptionPane; @@ -33,6 +35,7 @@ import com.fr.form.ui.ChartEditor; import com.fr.form.ui.DataControl; import com.fr.form.ui.DictionaryContainer; import com.fr.form.ui.ElementCaseEditor; +import com.fr.form.ui.PaddingMargin; import com.fr.form.ui.Widget; import com.fr.general.IOUtils; import com.fr.log.FineLoggerFactory; @@ -56,6 +59,7 @@ import javax.swing.Action; import javax.swing.UIManager; import java.awt.Color; import java.awt.Component; +import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Image; import java.awt.Rectangle; @@ -253,6 +257,17 @@ public class CreateComponentAction extends UpdateAction { BufferedImage im = new BufferedImage((int) rect.getWidth(), (int) rect.getHeight(), BufferedImage.TYPE_INT_ARGB); comp.paint(im.getGraphics()); + if (comp instanceof XWTitleLayout) { + XCreator body = ((XWTitleLayout) comp).getBodyCreator(); + if (body instanceof XChartEditor) { + XChartEditor chartEditor = (XChartEditor) body; + Dimension size = chartEditor.getSize(); + BufferedImage chartImage = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_ARGB); + PaddingMargin margin = chartEditor.toData().getMargin(); + chartEditor.getDesignerEditor().paintEditor(chartImage.getGraphics(), size, margin); + im.getGraphics().drawImage(chartImage, 0, chartEditor.getY(), null); + } + } return im; } From 07be63cef322c072d22a16ae4048640b83b5b196 Mon Sep 17 00:00:00 2001 From: Starryi Date: Fri, 10 Dec 2021 16:39:53 +0800 Subject: [PATCH 2/4] =?UTF-8?q?REPORT-64080=20=E3=80=90=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E8=BE=B9=E6=A1=86=E3=80=91=E6=A1=86=E9=80=89=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E5=A4=96=E8=BE=B9=E6=A1=86=E5=90=8E=EF=BC=8C?= =?UTF-8?q?=E6=A1=86=E9=80=89=E5=B0=8F=E9=83=A8=E5=88=86=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=EF=BC=8C=E4=B9=8B=E5=90=8E=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E5=99=A8=E9=87=8C=E6=98=BE=E7=A4=BA=E6=9C=89=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 重新规范下交互效果,当框选的单元格样式从跟随主题切换到自定义时, 单元格的样式效果应当保持不变(从NameStyle变为Style),且右侧样式 面板应当是此框选区域的整体样式 【改动思路】 当样式设置从跟随主题切换到自定义时,应当将被选择的单元格样式设置 从NameStyle设置为Style,且不能使用样式面板中的设置重置单元格样式 --- .../fr/design/mainframe/ElementCasePane.java | 30 ++++++++ .../cell/settingpane/CellStylePane.java | 74 +++++++++++++------ .../cell/settingpane/style/StylePane.java | 59 ++++++++++----- 3 files changed, 120 insertions(+), 43 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java b/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java index dbc4269d6..0a580badc 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java @@ -6,6 +6,7 @@ package com.fr.design.mainframe; import com.fr.base.BaseFormula; import com.fr.base.DynamicUnitList; import com.fr.base.Formula; +import com.fr.base.NameStyle; import com.fr.base.ScreenResolution; import com.fr.base.Style; import com.fr.base.vcs.DesignerMode; @@ -97,6 +98,7 @@ import com.fr.page.PageAttributeGetter; import com.fr.page.ReportPageAttrProvider; import com.fr.poly.creator.PolyElementCasePane; import com.fr.report.ReportHelper; +import com.fr.report.cell.CellElement; import com.fr.report.cell.FloatElement; import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.cellattr.core.RichText; @@ -133,6 +135,7 @@ import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.lang.reflect.Constructor; +import java.util.Iterator; import java.util.Set; import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; @@ -1374,6 +1377,33 @@ public abstract class ElementCasePane extends Tar return cellNeedTOFormat; } + public void traverseSelectedCellElements(TemplateCellElementVisitor visitor) { + Selection selection = getSelection(); + if (!(selection instanceof CellSelection)) { + return; + } + CellSelection cs = (CellSelection) selection; + TemplateElementCase elementCase = getEditingElementCase(); + int cellRectangleCount = cs.getCellRectangleCount(); + + for (int rect = 0; rect < cellRectangleCount; rect++) { + Rectangle cellRectangle = cs.getCellRectangle(rect); + for (int j = 0; j < cellRectangle.height; j++) { + for (int i = 0; i < cellRectangle.width; i++) { + int column = i + cellRectangle.x; + int row = j + cellRectangle.y; + + TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); + visitor.visit(column, row, cellElement); + } + } + } + } + + public interface TemplateCellElementVisitor { + void visit(int column, int row, TemplateCellElement cellElement); + } + private class ElementCaseEditingState implements EditingState { protected Selection selection; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java index c28c00de5..24ea3209d 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java @@ -1,22 +1,23 @@ package com.fr.design.mainframe.cell.settingpane; import com.fr.base.CellBorderStyle; +import com.fr.base.NameStyle; import com.fr.base.Style; import com.fr.design.actions.utils.ReportActionUtils; import com.fr.design.constants.UIConstants; -import com.fr.design.gui.style.BorderPane; +import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.cell.settingpane.style.StylePane; import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.design.style.BorderUtils; import com.fr.design.utils.gui.GUICoreUtils; - import com.fr.report.cell.TemplateCellElement; import com.fr.report.elementcase.TemplateElementCase; -import javax.swing.*; +import javax.swing.JFrame; +import javax.swing.JPanel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import java.awt.*; +import java.awt.BorderLayout; /** * @author zhou @@ -71,29 +72,56 @@ public class CellStylePane extends AbstractCellAttrPane { @Override public void updateBeans() { - Object[] selectionCellBorderObjects = BorderUtils.createCellBorderObject(elementCasePane); + // 因为存在框选多个单元格的情况,跟随主题切换到自定义的行为似乎不太适合由updateBeans完成,它更像是个工具栏上的Action. + // 但它又会触发updateBeans... + boolean isSwitchToCustomStyleAction = stylePane.isFollowingThemeSettingChanged() && !stylePane.isFollowingTheme(); + if (isSwitchToCustomStyleAction) { + switchCellStylesToCustom(); + return; + } + updateCellStylesByPaneSettings(); + } + + private void switchCellStylesToCustom() { TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); - int cellRectangleCount = cs.getCellRectangleCount(); - for (int rect = 0; rect < cellRectangleCount; rect++) { - Rectangle cellRectangle = cs.getCellRectangle(rect); - for (int j = 0; j < cellRectangle.height; j++) { - for (int i = 0; i < cellRectangle.width; i++) { - int column = i + cellRectangle.x; - int row = j + cellRectangle.y; - TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); - if (cellElement == null) { - cellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row); - elementCase.addCellElement(cellElement); - } - Style style = stylePane.updateBean(); - cellElement.setStyle(style); + elementCasePane.traverseSelectedCellElements(new ElementCasePane.TemplateCellElementVisitor() { + @Override + public void visit(int column, int row, TemplateCellElement cellElement) { + if (cellElement == null) { + cellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row); + elementCase.addCellElement(cellElement); } + Style style = cellElement.getStyle(); + if (style instanceof NameStyle) { + style = ((NameStyle) style).getRealStyle(); + } + if (style == null) { + style = Style.DEFAULT_STYLE; + } + cellElement.setStyle(style); } - } + }); + } + + private void updateCellStylesByPaneSettings() { + Object[] oldSelectionCellBorderObjects = BorderUtils.createCellBorderObject(elementCasePane); + + TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); + elementCasePane.traverseSelectedCellElements(new ElementCasePane.TemplateCellElementVisitor() { + @Override + public void visit(int column, int row, TemplateCellElement cellElement) { + if (cellElement == null) { + cellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row); + elementCase.addCellElement(cellElement); + } + Style style = stylePane.updateBean(); + cellElement.setStyle(style); + } + }); // border必须特别处理 - CellBorderStyle cellBorderStyle = stylePane.updateBorderStyle(); - if (cellBorderStyle != null) { - BorderUtils.update(elementCasePane, selectionCellBorderObjects, cellBorderStyle); + CellBorderStyle newCellBorderStyle = stylePane.updateBorderStyle(); + if (newCellBorderStyle != null) { + BorderUtils.update(elementCasePane, oldSelectionCellBorderObjects, newCellBorderStyle); } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java index c6613befa..7f382ed44 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java @@ -51,6 +51,7 @@ public class StylePane extends BasicPane implements UIObserver { private final List observerListeners = new ArrayList<>(); private Style backupStyleFromPopulating = Style.DEFAULT_STYLE; + private boolean isFollowingThemeSettingChanged = false; public StylePane() { followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS); @@ -77,6 +78,7 @@ public class StylePane extends BasicPane implements UIObserver { followingThemeButtonGroup.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { + isFollowingThemeSettingChanged = true; AttributeChangeUtils.changeComposedUI(StylePane.this, false, new AttributeChangeUtils.UIChangeAction() { @Override public void changeComposedUI() { @@ -85,6 +87,7 @@ public class StylePane extends BasicPane implements UIObserver { } }); fireStateChanged(); + isFollowingThemeSettingChanged = false; } }); @@ -103,25 +106,33 @@ public class StylePane extends BasicPane implements UIObserver { cardLayout.show(contentPane, FOLLOWING_THEME_STRING_ARRAYS[selectedIndex]); if (!isFollowingTheme) { // 对于同一个单元格,跟随主题切换到自定义,自定义中的配置与其保持一致 - NameStyle lastSelectedNameStyle = nameStyleListPane.updateNameStyle(); - if (lastSelectedNameStyle != null) { - Style lastSelectedRealStyle = lastSelectedNameStyle.getRealStyle(); - try { - lastSelectedRealStyle = (Style) lastSelectedRealStyle.clone(); - if (lastSelectedRealStyle != null) { - customStylePane.populateBean(lastSelectedRealStyle); - customStylePane.dealWithBorder(); - } - } catch (CloneNotSupportedException ex) { - FineLoggerFactory.getLogger().error(ex.getMessage(), ex); - } - } + syncCustomStylePaneBySelectedNameStyle(); } else { // 对于同一个单元格,自定义切换到跟随主题,跟随主题选中"默认"样式,并使用默认样式设置选中的单元格 nameStyleListPane.reset(); } } + private void syncCustomStylePaneBySelectedNameStyle() { + NameStyle lastSelectedNameStyle = nameStyleListPane.updateNameStyle(); + if (lastSelectedNameStyle != null) { + Style lastSelectedRealStyle = lastSelectedNameStyle.getRealStyle(); + try { + lastSelectedRealStyle = (Style) lastSelectedRealStyle.clone(); + if (lastSelectedRealStyle != null) { + customStylePane.populateBean(lastSelectedRealStyle); + customStylePane.dealWithBorder(); + } + } catch (CloneNotSupportedException ex) { + FineLoggerFactory.getLogger().error(ex.getMessage(), ex); + } + } + } + + public boolean isFollowingThemeSettingChanged() { + return isFollowingThemeSettingChanged; + } + protected JPanel createTabbedContentPane() { JPanel contentPane = new JPanel(cardLayout) { @Override @@ -161,14 +172,22 @@ public class StylePane extends BasicPane implements UIObserver { return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style"); } - public void setSelectedIndex(int index) { + public boolean isFollowingTheme() { + return getSelectedIndex() == 0; + } + + public void setFollowingTheme(boolean followingTheme) { + setSelectedIndex(followingTheme ? 0 : 1); + } + + private void setSelectedIndex(int index) { if (0 <= index && index < FOLLOWING_THEME_STRING_ARRAYS.length) { followingThemeButtonGroup.setSelectedIndex(index); cardLayout.show(contentPane, FOLLOWING_THEME_STRING_ARRAYS[index]); } } - public int getSelectedIndex() { + private int getSelectedIndex() { return followingThemeButtonGroup.getSelectedIndex(); } @@ -185,11 +204,11 @@ public class StylePane extends BasicPane implements UIObserver { } public void setSelctedByName(String id) { - setSelectedIndex(ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom"), id)? 1 : 0); + setFollowingTheme(!ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom"), id)); } public CellBorderStyle updateBorderStyle() { - if (getSelectedIndex() == 0) { + if (isFollowingTheme()) { return nameStyleListPane.updateBorderStyle(); } else if (customStylePane.isBorderPaneSelected()) { return customStylePane.updateBorderStyle(); @@ -199,7 +218,7 @@ public class StylePane extends BasicPane implements UIObserver { public Style updateBean() { Style finalStyle = null; - if (getSelectedIndex() == 0) { + if (isFollowingTheme()) { finalStyle = nameStyleListPane.updateNameStyle(); } if (finalStyle == null) { @@ -215,7 +234,7 @@ public class StylePane extends BasicPane implements UIObserver { if (style instanceof NameStyle) { NameStyle nameStyle = (NameStyle) style; - setSelectedIndex(0); + setFollowingTheme(true); nameStyleListPane.populateNameStyle(nameStyle); Style realStyle = nameStyle.getRealStyle(); try { @@ -225,7 +244,7 @@ public class StylePane extends BasicPane implements UIObserver { e.printStackTrace(); } } else { - setSelectedIndex(1); + setFollowingTheme(false); customStylePane.populateBean(style); } //单元格配置界面是单例 所以直接在populate的时候把跟随主题的按钮组设置不可见 From d075335787fa68cfaf133a9711036b2928091c8a Mon Sep 17 00:00:00 2001 From: lucian Date: Tue, 14 Dec 2021 16:30:10 +0800 Subject: [PATCH 3/4] =?UTF-8?q?REPORT-62876=20=E5=A1=AB=E6=8A=A5=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=97=B6=E6=94=AF=E6=8C=81=E8=A1=A8=E7=9A=84=E7=B2=BE?= =?UTF-8?q?=E7=A1=AE=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/data/datapane/ChoosePane.java | 112 ++-------- .../datapane/ChoosePaneSupportFormula.java | 2 +- .../design/gui/icombobox/FRTreeComboBox.java | 4 +- .../gui/icombobox/SearchFRTreeComboBox.java | 200 ++++++++++++++++++ .../icombobox/SearchPreTaskTreeComboBox.java | 77 ------- 5 files changed, 218 insertions(+), 177 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/gui/icombobox/SearchFRTreeComboBox.java delete mode 100644 designer-base/src/main/java/com/fr/design/gui/icombobox/SearchPreTaskTreeComboBox.java diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java index f65610526..38d287a20 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java @@ -1,12 +1,12 @@ package com.fr.design.data.datapane; import com.fr.base.TableData; -import com.fr.concurrent.NamedThreadFactory; import com.fr.data.core.DataCoreUtils; import com.fr.data.core.db.DBUtils; import com.fr.data.core.db.TableProcedure; import com.fr.data.core.db.dialect.Dialect; import com.fr.data.core.db.dialect.DialectFactory; +import com.fr.data.impl.Connection; import com.fr.data.impl.DBTableData; import com.fr.data.operator.DataOperator; import com.fr.design.DesignerEnvManager; @@ -19,7 +19,7 @@ import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.design.data.tabledata.Prepare4DataSourceChange; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.icombobox.FilterableComboBoxModel; -import com.fr.design.gui.icombobox.SearchPreTaskTreeComboBox; +import com.fr.design.gui.icombobox.SearchFRTreeComboBox; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBoxEditor; import com.fr.design.gui.icombobox.UIComboBoxRenderer; @@ -40,11 +40,6 @@ import com.fr.stable.StringUtils; import com.fr.workspace.WorkContext; import com.fr.workspace.server.connection.DBConnectAuth; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dimension; -import java.util.Collections; -import java.util.concurrent.CancellationException; import javax.swing.JList; import javax.swing.JOptionPane; import javax.swing.JPanel; @@ -58,21 +53,20 @@ import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreeCellRenderer; -import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.ArrayList; import java.util.Collection; -import java.util.Enumeration; +import java.util.Collections; import java.util.List; import java.util.Set; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.FutureTask; +import java.util.concurrent.CancellationException; /** * @author zhou @@ -97,41 +91,12 @@ public class ChoosePane extends BasicBeanPane implements Refresha /** * 表名 */ - protected SearchPreTaskTreeComboBox tableNameComboBox; - - private static final ExecutorService SERVICE = Executors.newSingleThreadExecutor(new NamedThreadFactory("ChoosePane")); + protected SearchFRTreeComboBox tableNameComboBox; private SwingWorker populateWorker; private SwingWorker, Void> initWorker; - private PopupMenuListener popupMenuListener = new PopupMenuListener() { - - @Override - public void popupMenuWillBecomeVisible(PopupMenuEvent e) { - FutureTask task = new FutureTask(new Callable() { - @Override - public Void call() throws Exception { - calculateTableDataNames(); - return null; - } - }); - tableNameComboBox.setPreSearchTask(task); - SERVICE.submit(task); - } - - @Override - public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { - // Do nothing - } - - @Override - public void popupMenuCanceled(PopupMenuEvent e) { - // Do nothing - } - }; - - private PopupMenuListener listener = new PopupMenuListener() { @Override public void popupMenuCanceled(PopupMenuEvent e) { @@ -181,7 +146,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha schemaBox = new StringUIComboBox(); schemaBox.setEditor(new ComboBoxEditor()); - tableNameComboBox = new SearchPreTaskTreeComboBox(new JTree(new DefaultMutableTreeNode()), tableNameTreeRenderer, false); + tableNameComboBox = new SearchFRTreeComboBox(this, new JTree(new DefaultMutableTreeNode()), tableNameTreeRenderer); tableNameComboBox.setEditable(true); tableNameComboBox.setRenderer(listCellRenderer); registerDSChangeListener(); @@ -198,7 +163,6 @@ public class ChoosePane extends BasicBeanPane implements Refresha }); schemaBox.addPopupMenuListener(listener); addFocusListener(); - this.tableNameComboBox.addPopupMenuListener(popupMenuListener); } protected void addDSBoxListener() { @@ -355,7 +319,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha GUICoreUtils.setSelectedItemQuietly(tableNameComboBox, -1); } - protected com.fr.data.impl.Connection getConnection() { + public Connection getConnection() { String selectedDSName = this.getDSName(); if (StringUtils.isEmpty(selectedDSName)) { return null; // peter:选中了当前的零长度的节点,直接返回. @@ -455,56 +419,6 @@ public class ChoosePane extends BasicBeanPane implements Refresha return "choosepane"; } - protected void calculateTableDataNames() { - JTree tree = tableNameComboBox.getTree(); - if (tree == null) { - return; - } - DefaultMutableTreeNode rootTreeNode = (DefaultMutableTreeNode) tree.getModel().getRoot(); - rootTreeNode.removeAllChildren(); - - String selectedDSName = this.getDSName(); - com.fr.data.impl.Connection selectedDatabase = this.getConnection(); - if (selectedDatabase == null) { - return; - } - try { - String schema = StringUtils.isEmpty(this.schemaBox.getSelectedItem()) ? null : this.schemaBox.getSelectedItem(); - TableProcedure[] sqlTableArray = DataCoreUtils.getTables(selectedDatabase, TableProcedure.TABLE, schema, DesignerEnvManager.getEnvManager().isOracleSystemSpace()); - if (sqlTableArray.length > 0) { - ExpandMutableTreeNode tableTreeNode = new ExpandMutableTreeNode(selectedDSName + "-" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_SQL_Table")); - rootTreeNode.add(tableTreeNode); - for (int i = 0; i < sqlTableArray.length; i++) { - ExpandMutableTreeNode tableChildTreeNode = new ExpandMutableTreeNode(sqlTableArray[i]); - tableTreeNode.add(tableChildTreeNode); - } - } - TableProcedure[] sqlViewArray = DataCoreUtils.getTables(selectedDatabase, TableProcedure.VIEW, schema, DesignerEnvManager.getEnvManager().isOracleSystemSpace()); - if (sqlViewArray.length > 0) { - ExpandMutableTreeNode viewTreeNode = new ExpandMutableTreeNode(selectedDSName + "-" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_SQL_View")); - rootTreeNode.add(viewTreeNode); - for (int i = 0; i < sqlViewArray.length; i++) { - ExpandMutableTreeNode viewChildTreeNode = new ExpandMutableTreeNode(sqlViewArray[i]); - viewTreeNode.add(viewChildTreeNode); - } - } - ((DefaultTreeModel) tree.getModel()).reload(); - // daniel 展开所有tree - TreeNode root = (TreeNode) tree.getModel().getRoot(); - TreePath parent = new TreePath(root); - TreeNode node = (TreeNode) parent.getLastPathComponent(); - for (Enumeration e = node.children(); e.hasMoreElements(); ) { - TreeNode n = (TreeNode) e.nextElement(); - TreePath path = parent.pathByAddingChild(n); - tree.expandPath(path); - } - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Failed"), JOptionPane.ERROR_MESSAGE); - } - } - /** * 创建选中的数据集数据 * @@ -558,10 +472,14 @@ public class ChoosePane extends BasicBeanPane implements Refresha return tableData; } - protected String getDSName() { + public String getDSName() { return this.dsNameComboBox.getSelectedItem(); } + public String getSchema() { + return this.schemaBox.getSelectedItem(); + } + protected void failedToFindTable() { // Do nothing } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePaneSupportFormula.java b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePaneSupportFormula.java index 14d0431e2..8fc62cd77 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePaneSupportFormula.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePaneSupportFormula.java @@ -83,7 +83,7 @@ public class ChoosePaneSupportFormula extends ChoosePane { * * @return */ - protected String getDSName() { + public String getDSName() { String selectedDSName = null; String item = Utils.objectToString(this.dsNameComboBox.getEditor().getItem()); // 没有选中的列表项 那么看看是不是手输值 diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java index 8fe79d41e..c12239447 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java @@ -248,7 +248,7 @@ public class FRTreeComboBox extends UIComboBox { private static TreePopup treePopup; - private static class FRTreeComboBoxUI extends BasicComboBoxUI implements MouseListener{ + protected static class FRTreeComboBoxUI extends BasicComboBoxUI implements MouseListener{ private boolean isRollover = false; public FRTreeComboBoxUI() { @@ -535,7 +535,7 @@ public class FRTreeComboBox extends UIComboBox { public class FrTreeSearchComboBoxEditor extends UIComboBoxEditor implements DocumentListener { private volatile boolean setting = false; private FRTreeComboBox comboBox; - private Object item; + protected Object item; public FrTreeSearchComboBoxEditor(FRTreeComboBox comboBox) { super(); diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/SearchFRTreeComboBox.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/SearchFRTreeComboBox.java new file mode 100644 index 000000000..06f50e211 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/SearchFRTreeComboBox.java @@ -0,0 +1,200 @@ +package com.fr.design.gui.icombobox; + +import com.fr.data.core.DataCoreUtils; +import com.fr.data.core.db.TableProcedure; +import com.fr.data.impl.Connection; +import com.fr.design.DesignerEnvManager; +import com.fr.design.data.datapane.ChoosePane; +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; +import com.fr.design.mainframe.DesignerContext; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.ArrayUtils; +import com.fr.stable.StringUtils; + +import javax.swing.JOptionPane; +import javax.swing.JTree; +import javax.swing.SwingWorker; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreeCellRenderer; +import javax.swing.tree.TreeNode; +import javax.swing.tree.TreePath; +import java.awt.event.MouseEvent; +import java.util.Enumeration; + +/** + * 实现模糊搜索的FRTreeComboBox + * FRTreeComboBox:搜索后滚动到首个匹配节点 + * SearchFRTreeComboBox:显示所有匹配的节点 + * + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2021/4/14 + */ +public class SearchFRTreeComboBox extends FRTreeComboBox { + + // 持有父容器,需要实时获取其他组件值 + private final ChoosePane parent; + + public SearchFRTreeComboBox(ChoosePane parent, JTree tree, TreeCellRenderer renderer) { + super(tree, renderer); + this.parent = parent; + setUI(new SearchFRTreeComboBoxUI()); + } + + protected UIComboBoxEditor createEditor() { + return new SearchFRComboBoxEditor(this); + } + + /** + * 执行模糊搜索 + */ + private void searchExecute() { + UIComboBoxEditor searchEditor = (UIComboBoxEditor) this.getEditor(); + new SwingWorker() { + @Override + protected Void doInBackground() { + processTableDataNames( + parent.getDSName(), + parent.getConnection(), + parent.getSchema(), + createFilter((String) searchEditor.getItem())); + return null; + } + + @Override + protected void done() { + expandTree(); + // 输入框获取焦点 + searchEditor.getEditorComponent().requestFocus(); + } + }.execute(); + } + + private TableNameFilter createFilter(String text) { + return StringUtils.isEmpty(text) ? EMPTY_FILTER : new TableNameFilter(text); + } + + /** + * 查询数据库表,并构建节点目录 + * + * @param databaseName 数据库名 + * @param connection 数据连接 + * @param schema 模式 + * @param filter 模糊搜索过滤器 + */ + private void processTableDataNames(String databaseName, Connection connection, String schema, TableNameFilter filter) { + if (tree == null) { + return; + } + DefaultMutableTreeNode rootTreeNode = (DefaultMutableTreeNode) tree.getModel().getRoot(); + rootTreeNode.removeAllChildren(); + + if (connection == null) { + return; + } + try { + schema = StringUtils.isEmpty(schema) ? null : schema; + TableProcedure[] sqlTableArray = DataCoreUtils.getTables(connection, TableProcedure.TABLE, schema, DesignerEnvManager.getEnvManager().isOracleSystemSpace()); + if (ArrayUtils.isNotEmpty(sqlTableArray)) { + ExpandMutableTreeNode tableTreeNode = new ExpandMutableTreeNode(databaseName + "-" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_SQL_Table")); + rootTreeNode.add(tableTreeNode); + addArrayNode(tableTreeNode, sqlTableArray, filter); + } + TableProcedure[] sqlViewArray = DataCoreUtils.getTables(connection, TableProcedure.VIEW, schema, DesignerEnvManager.getEnvManager().isOracleSystemSpace()); + if (ArrayUtils.isNotEmpty(sqlViewArray)) { + ExpandMutableTreeNode viewTreeNode = new ExpandMutableTreeNode(databaseName + "-" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_SQL_View")); + rootTreeNode.add(viewTreeNode); + addArrayNode(viewTreeNode, sqlViewArray, filter); + } + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Failed"), JOptionPane.ERROR_MESSAGE); + } + } + + private void addArrayNode(ExpandMutableTreeNode rootNode, TableProcedure[] sqlArray, TableNameFilter filter) { + if (sqlArray != null) { + for (TableProcedure procedure : sqlArray) { + if (filter.accept(procedure)) { + ExpandMutableTreeNode viewChildTreeNode = new ExpandMutableTreeNode(procedure); + rootNode.add(viewChildTreeNode); + } + } + } + } + + /** + * 展开节点 + */ + private void expandTree() { + ((DefaultTreeModel) tree.getModel()).reload(); + // daniel 展开所有tree + TreeNode root = (TreeNode) tree.getModel().getRoot(); + TreePath parent = new TreePath(root); + TreeNode node = (TreeNode) parent.getLastPathComponent(); + for (Enumeration e = node.children(); e.hasMoreElements(); ) { + TreeNode n = (TreeNode) e.nextElement(); + TreePath path = parent.pathByAddingChild(n); + tree.expandPath(path); + } + } + + /** + * 重写输入框编辑器,实现输入框模糊搜索逻辑 + */ + private class SearchFRComboBoxEditor extends FrTreeSearchComboBoxEditor { + + public SearchFRComboBoxEditor(FRTreeComboBox comboBox) { + super(comboBox); + } + + @Override + protected void changeHandler() { + if (isSetting()) { + return; + } + setPopupVisible(true); + this.item = textField.getText(); + searchExecute(); + } + } + + private static final TableNameFilter EMPTY_FILTER = new TableNameFilter(StringUtils.EMPTY) { + public boolean accept(TableProcedure procedure) { + return true; + } + }; + + /** + * 表名模糊搜索实现 + */ + private static class TableNameFilter { + private final String searchFilter; + + public TableNameFilter(String searchFilter) { + if (StringUtils.isNotEmpty(searchFilter)) { + searchFilter = searchFilter.toLowerCase().trim(); + } + this.searchFilter = searchFilter; + } + + // 字符串匹配 + public boolean accept(TableProcedure procedure) { + return procedure.getName().toLowerCase().contains(searchFilter); + } + } + + /** + * 重写FRTreeComboBoxUI,实现点击下拉时触发模糊搜索 + */ + private class SearchFRTreeComboBoxUI extends FRTreeComboBoxUI { + + @Override + public void mouseClicked(MouseEvent e) { + searchExecute(); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/SearchPreTaskTreeComboBox.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/SearchPreTaskTreeComboBox.java deleted file mode 100644 index 2d936d896..000000000 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/SearchPreTaskTreeComboBox.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.fr.design.gui.icombobox; - -import com.fr.log.FineLoggerFactory; - -import javax.swing.JTree; -import javax.swing.SwingWorker; -import javax.swing.tree.TreeCellRenderer; -import java.util.concurrent.FutureTask; - -/** - * 模糊搜索前需执行完前置任务的TreeComboBox - * @author Lucian.Chen - * @version 10.0 - * Created by Lucian.Chen on 2021/4/14 - */ -public class SearchPreTaskTreeComboBox extends FRTreeComboBox { - - /** - * 模糊搜索前任务 - */ - private FutureTask preSearchTask; - - public SearchPreTaskTreeComboBox(JTree tree, TreeCellRenderer renderer, boolean editable) { - super(tree, renderer, editable); - } - - public FutureTask getPreSearchTask() { - return preSearchTask; - } - - public void setPreSearchTask(FutureTask preSearchTask) { - this.preSearchTask = preSearchTask; - } - - protected UIComboBoxEditor createEditor() { - return new SearchPreTaskComboBoxEditor(this); - } - - private class SearchPreTaskComboBoxEditor extends FrTreeSearchComboBoxEditor { - - public SearchPreTaskComboBoxEditor(FRTreeComboBox comboBox) { - super(comboBox); - } - - protected void changeHandler() { - if (isSetting()) { - return; - } - setPopupVisible(true); - new SwingWorker() { - @Override - protected Void doInBackground() { - FutureTask task = getPreSearchTask(); - try { - // 确保模糊搜索前任务执行完成后,再进行模糊搜索 - if (task != null) { - task.get(); - } - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - if (task != null) { - // 任务执行后置空,否则会被别的操作重复触发 - setPreSearchTask(null); - } - return null; - } - - @Override - protected void done() { - // 模糊搜索 - search(); - } - }.execute(); - } - } -} From dcc26061060613abb8e2f786adb960eeb1878ad1 Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Tue, 14 Dec 2021 20:13:16 +0800 Subject: [PATCH 4/4] =?UTF-8?q?REPORT-62440=20=E8=A1=A8=E5=A4=B4=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E5=86=85=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/dscolumn/DSColumnAdvancedPane.java | 95 ++++------ .../cell/settingpane/CellExpandAttrPane.java | 13 -- .../CellDSColumnSortGroupPane.java | 18 +- .../sort/common/AbstractSortGroupPane.java | 9 +- .../design/sort/common/AbstractSortPane.java | 30 ++-- .../design/sort/common/SortColumnRowPane.java | 165 ++++++++++++++---- .../sort/common/SortUIExpandablePane.java | 1 + .../expressionpane/CustomSequencePane.java | 6 +- .../CustomSequenceSortExpressionPane.java | 6 +- .../FormulaSortExpressionPane.java | 4 +- .../cellquick/CellDSColumnEditor.java | 144 +-------------- 11 files changed, 212 insertions(+), 279 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java b/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java index 1061b6363..de223b511 100644 --- a/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java +++ b/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java @@ -13,6 +13,7 @@ import com.fr.design.formula.UIFormula; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.itextfield.UITextField; @@ -20,6 +21,7 @@ import com.fr.design.gui.style.TextFormatPane; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.sort.celldscolumn.CellDSColumnSortPane; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.report.cell.CellElement; import com.fr.report.cell.TemplateCellElement; @@ -47,14 +49,26 @@ public class DSColumnAdvancedPane extends BasicPane { private UICheckBox verticalExtendableCheckBox; private UICheckBox useMultiplyNumCheckBox; private UISpinner multiNumSpinner; + private JPanel contentPane; public DSColumnAdvancedPane() { this(DSColumnPane.SETTING_ALL); } public DSColumnAdvancedPane(int setting) { - this.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); - this.setLayout(FRGUIPaneFactory.createBorderLayout()); + initContentPane(setting); + initScrollPane(); + } + + private void initScrollPane() { + ScrollPane scrollPane = new ScrollPane(contentPane); + this.add(scrollPane); + } + + private void initContentPane(int setting) { + contentPane = new JPanel(); + contentPane.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); + contentPane.setLayout(FRGUIPaneFactory.createBorderLayout()); sortPane = new SortPane(); sortPane.setBorder(UITitledBorder.createBorderWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Sort_Sort_Order"))); @@ -124,7 +138,7 @@ public class DSColumnAdvancedPane extends BasicPane { TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED}; double[] columnSize = {TableLayout.FILL}; - this.add(TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize), BorderLayout.CENTER); + contentPane.add(TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize), BorderLayout.CENTER); } @Override @@ -137,7 +151,7 @@ public class DSColumnAdvancedPane extends BasicPane { return; } - sortPane.populate(cellElement); + sortPane.populateBean(cellElement); valuePane.populate(cellElement); formatAttrPane.populate(cellElement); @@ -187,7 +201,7 @@ public class DSColumnAdvancedPane extends BasicPane { return; } - sortPane.update(cellElement); + sortPane.updateBean(cellElement); valuePane.update(cellElement); formatAttrPane.update(cellElement); @@ -223,66 +237,25 @@ public class DSColumnAdvancedPane extends BasicPane { } } - private static class SortPane extends SortFormulaPane { - private CellElement cellElement; + private static class ScrollPane extends UIScrollPane { + ScrollPane(Component component) { + super(component); + this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + } @Override - public void formulaAction() { - if (cellElement == null) { - return; - } - Object value = cellElement.getValue(); - if (value == null || !(value instanceof DSColumn)) { - return; - } - - String[] displayNames = DesignTableDataManager.getSelectedColumnNames( - DesignTableDataManager.getEditingTableDataSource(), ((DSColumn) value).getDSName()); - - showFormulaDialog(displayNames); + public Dimension getPreferredSize() { + return new Dimension(DSColumnPane.DEFAULT_DIMENSION.width - 20, DSColumnPane.DEFAULT_DIMENSION.height - 100); } + } - void populate(CellElement cellElement) { - if (cellElement == null) { - return; - } - this.cellElement = cellElement; - - Object value = cellElement.getValue(); - if (value == null || !(value instanceof DSColumn)) { - return; - } - DSColumn dSColumn = (DSColumn) value; - - int sort = dSColumn.getOrder(); - this.sortOrderComboBox.setSortOrder(new SortOrder(sort)); - - String sortFormula = dSColumn.getSortFormula(); - sortFormulaTextField.setText(sortFormula); + private static class SortPane extends CellDSColumnSortPane { + SortPane() { + this.setLayout(new FlowLayout(FlowLayout.LEFT)); } - public void update(CellElement cellElement) { - if (cellElement == null) { - return; - } - Object value = cellElement.getValue(); - if (value == null || !(value instanceof DSColumn)) { - return; - } - DSColumn dSColumn = (DSColumn) (cellElement.getValue()); - - dSColumn.setOrder(this.sortOrderComboBox.getSortOrder().getOrder()); - //lance:sort formula - - String sText = null; - if (!(sortFormulaTextField.getText() == null || sortFormulaTextField.getText().trim().equals("") || sortFormulaTextField.getText().trim().equals("$$$"))) { - sText = new String(sortFormulaTextField.getText()); - } - if (!(sText == null || sText.length() < 1)) { - dSColumn.setSortFormula(sText); - } else { - dSColumn.setSortFormula(null); - } + protected boolean needSortHeaderPane() { + return false; } } @@ -540,12 +513,12 @@ public class DSColumnAdvancedPane extends BasicPane { public static class FormatAttrPane extends TextFormatPane { protected void initLayout() { - JPanel settingPane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(0, 4, 0); + JPanel settingPane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(0, 4, 0); settingPane.add(typeComboBox); settingPane.add(textField); settingPane.add(roundingBox); - addComponents(4, new JComponent[] { settingPane, previewLabel}); + addComponents(4, new JComponent[]{settingPane, previewLabel}); } @Override diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java index 2a9aab95d..9549a3a7e 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java @@ -4,7 +4,6 @@ import com.fr.design.constants.LayoutConstants; import com.fr.design.constants.UIConstants; import com.fr.design.expand.ExpandLeftFatherPane; import com.fr.design.expand.ExpandUpFatherPane; -import com.fr.design.expand.SortExpandAttrPane; import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.icheckbox.UICheckBox; @@ -39,7 +38,6 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { private ExpandUpFatherPane rightFatherPane; private UICheckBox horizontalExpandableCheckBox; private UICheckBox verticalExpandableCheckBox; - private SortExpandAttrPane sortAfterExpand; private JPanel layoutPane; private JPanel basicPane; private JPanel seniorPane; @@ -64,7 +62,6 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { rightFatherPane = new ExpandUpFatherPane(); horizontalExpandableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_ExpandD_Horizontal_Extendable")); verticalExpandableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_ExpandD_Vertical_Extendable")); - sortAfterExpand = new SortExpandAttrPane(); initAllNames(); return layoutPane(); } @@ -124,16 +121,12 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { private JPanel seniorPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; - UILabel expendSort = new UILabel(Toolkit.i18nText("Fine-Design_Report_Expend_Sort"), SwingConstants.LEFT); - JPanel expendSortPane = new JPanel(new BorderLayout()); - expendSortPane.add(expendSort, BorderLayout.NORTH); horizontalExpandableCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER); verticalExpandableCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER); Component[][] components = new Component[][]{ new Component[]{null, null}, new Component[]{horizontalExpandableCheckBox, null}, new Component[]{verticalExpandableCheckBox, null}, - new Component[]{expendSortPane, sortAfterExpand}, }; double[] rowSize = {p, p, p, p, p}; double[] columnSize = {p, f}; @@ -174,8 +167,6 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { } } - sortAfterExpand.populate(cellExpandAttr); - extraPane.populate(cellElement); cellExpandSortPane.populateBean(cellElement); } @@ -223,10 +214,6 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { } } - if (ComparatorUtils.equals(getGlobalName(), Toolkit.i18nText("Fine-Design_Basic_ExpandD_Sort_After_Expand"))) { - sortAfterExpand.update(cellExpandAttr); - } - extraPane.update(cellElement); cellExpandSortPane.updateBean(cellElement); } diff --git a/designer-realize/src/main/java/com/fr/design/sort/celldscolumn/CellDSColumnSortGroupPane.java b/designer-realize/src/main/java/com/fr/design/sort/celldscolumn/CellDSColumnSortGroupPane.java index c74c3c9e3..788f1a57c 100644 --- a/designer-realize/src/main/java/com/fr/design/sort/celldscolumn/CellDSColumnSortGroupPane.java +++ b/designer-realize/src/main/java/com/fr/design/sort/celldscolumn/CellDSColumnSortGroupPane.java @@ -15,22 +15,24 @@ public class CellDSColumnSortGroupPane extends AbstractSortGroupPane { super(sortGroupPaneWidth, sortGroupPaneRightWidth); } - public void populateDsColumn( DSColumn dsColumn){ + public void populateDsColumn(DSColumn dsColumn) { this.dsColumn = dsColumn; } @Override protected AbstractSortItemPane refreshSortItemPane(int sortItemPaneWidth, int sortItemPaneRightWidth, SortExpression sortExpression) { - CellDSColumnSortItemPane cellDSColumnSortItemPane = new CellDSColumnSortItemPane( sortItemPaneWidth, sortItemPaneRightWidth); + CellDSColumnSortItemPane cellDSColumnSortItemPane = new CellDSColumnSortItemPane(sortItemPaneWidth, sortItemPaneRightWidth); java.util.Map tableDataWrapperMap = DesignTableDataManager.getAllEditingDataSet(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget()); TableDataWrapper tableDataWrapper = tableDataWrapperMap.get(dsColumn.getDSName()); - java.util.List columnNameList = tableDataWrapper.calculateColumnNameList(); - String[] columnNames = new String[columnNameList.size()]; - columnNameList.toArray(columnNames); - cellDSColumnSortItemPane.sortAreaUiComboBox.removeAllItems(); - for (String columnName : columnNames) { - cellDSColumnSortItemPane.sortAreaUiComboBox.addItem(columnName); + if (tableDataWrapper != null) { + java.util.List columnNameList = tableDataWrapper.calculateColumnNameList(); + String[] columnNames = new String[columnNameList.size()]; + columnNameList.toArray(columnNames); + cellDSColumnSortItemPane.sortAreaUiComboBox.removeAllItems(); + for (String columnName : columnNames) { + cellDSColumnSortItemPane.sortAreaUiComboBox.addItem(columnName); + } } cellDSColumnSortItemPane.populateBean(sortExpression); return cellDSColumnSortItemPane; diff --git a/designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortGroupPane.java b/designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortGroupPane.java index 85cd58ec9..6cdde9eb4 100644 --- a/designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortGroupPane.java +++ b/designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortGroupPane.java @@ -18,6 +18,8 @@ import java.util.List; public abstract class AbstractSortGroupPane extends JPanel implements ComponentChangeObserver { + private static final int SECOND_SORT_LENGTH_REDUCTION = 13; + protected int sortGroupPaneWidth; protected int sortGroupPaneRightWidth; List sortExpressions; @@ -95,8 +97,8 @@ public abstract class AbstractSortGroupPane extends JPanel implements ComponentC int sortItemPaneWidth = sortGroupPaneWidth; int sortItemPaneRightWidth = sortGroupPaneRightWidth; if (!mainSort) { - sortItemPaneWidth -= 12; - sortItemPaneRightWidth -= 12; + sortItemPaneWidth -= SECOND_SORT_LENGTH_REDUCTION; + sortItemPaneRightWidth -= SECOND_SORT_LENGTH_REDUCTION; } if (sortExpression == null) { sortExpression = new CellSortExpression(selfSortArea); @@ -131,12 +133,13 @@ public abstract class AbstractSortGroupPane extends JPanel implements ComponentC AddSortItemBar(AbstractSortGroupPane sortGroupPane) { init(); this.sortGroupPane = sortGroupPane; + this.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 5)); } void init() { uiButton = new UIButton(Toolkit.i18nText("Fine-Design_Sort_Add_Second_Sort"), IconUtils.readIcon("/com/fr/design/images/sort/add.png")); - uiButton.setPreferredSize(new Dimension(sortGroupPaneWidth - 4, 20)); + uiButton.setPreferredSize(new Dimension(sortGroupPaneWidth - 4, AbstractSortPane.PANE_COMPONENT_HEIGHT)); this.add(uiButton); uiButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { diff --git a/designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortPane.java b/designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortPane.java index 7dd539361..bfddee38c 100644 --- a/designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortPane.java +++ b/designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortPane.java @@ -34,13 +34,19 @@ public abstract class AbstractSortPane extends JPanel { private void initComponents() { initSortGroupPane(); - sortHeaderPane = new SortHeaderPane(sortPaneWidth, sortPaneRightWidth + 5); - this.add(sortHeaderPane); + if (needSortHeaderPane()) { + sortHeaderPane = new SortHeaderPane(sortPaneWidth, sortPaneRightWidth + 5); + this.add(sortHeaderPane); + } } protected abstract void initSortGroupPane(); + protected boolean needSortHeaderPane() { + return true; + } + protected abstract CellSortAttr getCellSortAttr(TemplateCellElement cellElement); public void populateBean(TemplateCellElement cellElement) { @@ -55,11 +61,13 @@ public abstract class AbstractSortPane extends JPanel { sortExpressions.add(new CellSortExpression(selfSortArea)); } sortGroupPane.populateBean(sortExpressions, selfSortArea); - SortHeader sortHeader = null; - if (cellSortAttr != null) { - sortHeader = cellSortAttr.getSortHeader(); + if (needSortHeaderPane()) { + SortHeader sortHeader = null; + if (cellSortAttr != null) { + sortHeader = cellSortAttr.getSortHeader(); + } + sortHeaderPane.populateBean(sortHeader, defaultHeaderArea); } - sortHeaderPane.populateBean(sortHeader, defaultHeaderArea); refresh(); } @@ -76,13 +84,15 @@ public abstract class AbstractSortPane extends JPanel { public void updateBean(TemplateCellElement cellElement) { List sortExpressions = sortGroupPane.updateBean(); - SortHeader sortHeader = sortHeaderPane.updateBean(); CellSortAttr cellSortAttr = getCellSortAttr(cellElement); cellSortAttr.setSortExpressions(sortExpressions); - if (sortHeader != null) { - sortHeader.setSortArea(selfSortArea); + if (needSortHeaderPane()) { + SortHeader sortHeader = sortHeaderPane.updateBean(); + if (sortHeader != null) { + sortHeader.setSortArea(selfSortArea); + } + cellSortAttr.setSortHeader(sortHeader); } - cellSortAttr.setSortHeader(sortHeader); } protected void refresh() { diff --git a/designer-realize/src/main/java/com/fr/design/sort/common/SortColumnRowPane.java b/designer-realize/src/main/java/com/fr/design/sort/common/SortColumnRowPane.java index e8371b3e1..cc276711a 100644 --- a/designer-realize/src/main/java/com/fr/design/sort/common/SortColumnRowPane.java +++ b/designer-realize/src/main/java/com/fr/design/sort/common/SortColumnRowPane.java @@ -1,5 +1,7 @@ package com.fr.design.sort.common; +import com.fr.base.Style; +import com.fr.base.background.ColorBackground; import com.fr.base.svg.IconUtils; import com.fr.design.designer.TargetComponent; import com.fr.design.event.UIObserver; @@ -10,9 +12,18 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.ElementCasePane; import com.fr.design.selection.SelectionEvent; import com.fr.design.selection.SelectionListener; +import com.fr.design.ui.util.UIUtil; +import com.fr.general.Background; import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.Selection; import com.fr.log.FineLoggerFactory; +import com.fr.report.cell.DefaultTemplateCellElement; +import com.fr.report.cell.TemplateCellElement; +import com.fr.report.cell.cellattr.CellExpandAttr; +import com.fr.report.cell.cellattr.core.group.DSColumn; +import com.fr.report.core.sort.common.CellSortable; +import com.fr.report.core.sort.header.SortHeader; +import com.fr.report.elementcase.TemplateElementCase; import com.fr.stable.ColumnRow; import com.fr.stable.EssentialUtils; import com.fr.stable.StringUtils; @@ -21,6 +32,12 @@ import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; public class SortColumnRowPane extends JPanel implements UIObserver { int paneWidth; @@ -75,7 +92,7 @@ public class SortColumnRowPane extends JPanel implements UIObserver { void initSelectButton() { selectButton = new UIButton(IconUtils.readIcon("/com/fr/design/images/buttonicon/select.png")); - selectButton.addActionListener(new SelectActionListener(this)); + selectButton.addMouseListener(new SelectActionListener(this)); this.add(selectButton); } @@ -90,7 +107,7 @@ public class SortColumnRowPane extends JPanel implements UIObserver { refresh(); } - public void setColumnRow(ColumnRow columnRow){ + public void setColumnRow(ColumnRow columnRow) { populateBean(columnRow); uiObserverListener.doChange(); } @@ -112,59 +129,145 @@ public class SortColumnRowPane extends JPanel implements UIObserver { return true; } - class SelectActionListener implements ActionListener { + class SelectActionListener extends MouseAdapter { SortColumnRowPane columnRowPane; + Map disableHeaderCellsStyleMap = new HashMap<>(); + java.util.List tempHeaderCells = new ArrayList<>(); + SelectActionListener(SortColumnRowPane columnRowPane) { this.columnRowPane = columnRowPane; } @Override - public void actionPerformed(ActionEvent e) { + public void mouseClicked(MouseEvent e) { ElementCasePane elementCasePane = getCurrentElementCase(); if (elementCasePane == null || isAlreadyAddListener) { return; } - oldSelection = (CellSelection) elementCasePane.getSelection(); - elementCasePane.getGrid().setNotShowingTableSelectPane(false); - elementCasePane.setEditable(false); - elementCasePane.repaint(10); - + prepareSelectHeader(elementCasePane); gridSelectionChangeListener = new SelectionListener() { @Override public void selectionChanged(SelectionEvent e) { - Selection selection = elementCasePane.getSelection(); - if (selection instanceof CellSelection) { - CellSelection cellselection = (CellSelection) selection; - ColumnRow cr = ColumnRow.valueOf(cellselection.getColumn(), cellselection.getRow()); - elementCasePane.setOldSelecton(oldSelection); - columnRowPane.setColumnRow(cr); - } - elementCasePane.removeSelectionChangeListener(gridSelectionChangeListener); - isAlreadyAddListener = false; - elementCasePane.getGrid().setNotShowingTableSelectPane(true); - elementCasePane.setEditable(true); - elementCasePane.repaint(); + completeSelectHeader(elementCasePane); } }; elementCasePane.addSelectionChangeListener(gridSelectionChangeListener); isAlreadyAddListener = true; } - } - private ElementCasePane getCurrentElementCase() { - try { - TargetComponent targetComponent - = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane(); - if (targetComponent instanceof ElementCasePane) { - return (ElementCasePane) targetComponent; + private void prepareSelectHeader(ElementCasePane elementCasePane) { + ashDisableHeaderCellsStyle(elementCasePane.getEditingElementCase()); + oldSelection = (CellSelection) elementCasePane.getSelection(); + elementCasePane.getGrid().setNotShowingTableSelectPane(false); + elementCasePane.setEditable(false); + elementCasePane.repaint(10); + } + + private void completeSelectHeader(ElementCasePane elementCasePane) { + Selection selection = elementCasePane.getSelection(); + if (selection instanceof CellSelection) { + CellSelection cellselection = (CellSelection) selection; + ColumnRow columnRow = ColumnRow.valueOf(cellselection.getColumn(), cellselection.getRow()); + elementCasePane.setOldSelecton(oldSelection); + oldSelection.getQuickEditor(elementCasePane); + if (!disableHeaderCellsStyleMap.keySet().contains(columnRow)) { + columnRowPane.setColumnRow(columnRow); + } + restoreDisableHeaderCellsStyle(elementCasePane.getEditingElementCase()); + } + elementCasePane.removeSelectionChangeListener(gridSelectionChangeListener); + isAlreadyAddListener = false; + elementCasePane.getGrid().setNotShowingTableSelectPane(true); + elementCasePane.setEditable(true); + elementCasePane.repaint(); + } + + private void ashDisableHeaderCellsStyle(TemplateElementCase elementCase) { + disableHeaderCellsStyleMap = new HashMap<>(); + tempHeaderCells = new ArrayList<>(); + Map disableHeaderCellsMap = getDisableHeaderCellsMap(elementCase); + for (ColumnRow headerColumnRow : disableHeaderCellsMap.keySet()) { + TemplateCellElement headerCell = disableHeaderCellsMap.get(headerColumnRow); + if (headerCell == null) { + headerCell = new DefaultTemplateCellElement(headerColumnRow.column, headerColumnRow.row); + elementCase.addCellElement(headerCell); + tempHeaderCells.add(headerCell); + } + Style style = headerCell.getStyle(); + disableHeaderCellsStyleMap.put(headerColumnRow, style); + style = style.deriveBackground(ColorBackground.getInstance(Color.gray)); + headerCell.setStyle(style); } - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e, e.getMessage()); } - return null; + + private void restoreDisableHeaderCellsStyle(TemplateElementCase elementCase) { + try { + for (ColumnRow headerColumnRow : disableHeaderCellsStyleMap.keySet()) { + TemplateCellElement headerTemplateCellElement + = elementCase.getTemplateCellElement(headerColumnRow.column, headerColumnRow.row); + headerTemplateCellElement.setStyle(disableHeaderCellsStyleMap.get(headerColumnRow)); + } + for (TemplateCellElement templateCellElement : tempHeaderCells) { + elementCase.removeCellElement(templateCellElement); + } + disableHeaderCellsStyleMap = new HashMap<>(); + tempHeaderCells = new ArrayList<>(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e, e.getMessage()); + } + } + + private Map getDisableHeaderCellsMap(TemplateElementCase elementCase) { + Map headerCellsMap = new HashMap<>(); + Iterator iterator = elementCase.cellIterator(); + while (iterator.hasNext()) { + TemplateCellElement templateCellElement = (TemplateCellElement) iterator.next(); + CellExpandAttr cellExpandAttr = templateCellElement.getCellExpandAttr(); + if (cellExpandAttr != null) { + handleDisableHeaderCell(elementCase, cellExpandAttr, headerCellsMap); + } + Object value = templateCellElement.getValue(); + if (value instanceof DSColumn) { + handleDisableHeaderCell(elementCase, (DSColumn) value, headerCellsMap); + } + } + return headerCellsMap; + } + + private void handleDisableHeaderCell(TemplateElementCase elementCase, CellSortable cellSortable, Map headerCellsMap) { + if (cellSortable.getCellSortAttr() != null) { + SortHeader sortHeader = cellSortable.getCellSortAttr().getSortHeader(); + if (sortHeader != null) { + String headerArea = sortHeader.getHeaderArea(); + if (headerArea != null) { + ColumnRow headerColumnRow = ColumnRow.valueOf(headerArea); + ColumnRow columnRow = columnRowPane.updateBean(); + if (!headerColumnRow.equals(columnRow)) { + TemplateCellElement headerCell + = elementCase.getTemplateCellElement(headerColumnRow.column, headerColumnRow.row); + headerCellsMap.put(headerColumnRow, headerCell); + } + } + } + } + } + + private ElementCasePane getCurrentElementCase() { + try { + TargetComponent targetComponent + = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane(); + if (targetComponent instanceof ElementCasePane) { + return (ElementCasePane) targetComponent; + } + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e, e.getMessage()); + } + return null; + } } + protected void refresh() { validate(); repaint(); diff --git a/designer-realize/src/main/java/com/fr/design/sort/common/SortUIExpandablePane.java b/designer-realize/src/main/java/com/fr/design/sort/common/SortUIExpandablePane.java index c5537ff53..3e9dece09 100644 --- a/designer-realize/src/main/java/com/fr/design/sort/common/SortUIExpandablePane.java +++ b/designer-realize/src/main/java/com/fr/design/sort/common/SortUIExpandablePane.java @@ -31,6 +31,7 @@ public class SortUIExpandablePane extends JPanel { initComponents(); wrapPane.setBorder(BorderFactory.createLineBorder(Color.gray, 1)); wrapPane.setBackground(Color.WHITE); + this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 5)); } diff --git a/designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequencePane.java b/designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequencePane.java index 5a15f78c1..50344f1b6 100644 --- a/designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequencePane.java +++ b/designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequencePane.java @@ -1,6 +1,5 @@ package com.fr.design.sort.expressionpane; -import com.fr.base.BaseUtils; import com.fr.base.svg.IconUtils; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.gui.ibutton.UIButton; @@ -29,11 +28,10 @@ public class CustomSequencePane extends JPanel { protected void initComponents(int width) { textField = new UITextField(); textField.setEditable(false); - textField.setPreferredSize(new Dimension(width - 20, 20)); + textField.setPreferredSize(new Dimension(width - 20, AbstractSortPane.PANE_COMPONENT_HEIGHT)); Icon icon = IconUtils.readIcon("/com/fr/design/images/control/refresh.png"); button = new UIButton(icon); button.setBackground(Color.RED); - button.setPreferredSize(new Dimension(24, 20)); button.setOpaque(false); button.setCursor(new Cursor(Cursor.HAND_CURSOR)); button.addActionListener(new ActionListener() { @@ -48,7 +46,7 @@ public class CustomSequencePane extends JPanel { }, new Dimension(700, 400)).setVisible(true); } }); - button.setPreferredSize(new Dimension(24, AbstractSortPane.PANE_COMPONENT_HEIGHT)); + button.setPreferredSize(new Dimension(20, AbstractSortPane.PANE_COMPONENT_HEIGHT)); this.add(textField); this.add(button); diff --git a/designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequenceSortExpressionPane.java b/designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequenceSortExpressionPane.java index 3e20d5de9..69dac2a2a 100644 --- a/designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequenceSortExpressionPane.java +++ b/designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequenceSortExpressionPane.java @@ -13,10 +13,8 @@ public class CustomSequenceSortExpressionPane extends SortExpressionPane数据集>高级设置>结果排序设置面板 - * - * @see com.fr.design.expand.SortExpandAttrPane - * @see DSColumnAdvancedPane.SortPane - */ - public class ResultSetSortConfigPane extends JPanel { - private static final String DEFAULT_VALUE = "="; - private JPanel contentPane; - private UIButtonGroup sortTypePane; - private JFormulaField formulaField; - private CardLayout cardLayout; - private JPanel centerPane; - - - public ResultSetSortConfigPane() { - this.setLayout(new BorderLayout()); - Icon[] iconArray = { - IOUtils.readIcon("/com/fr/design/images/expand/none16x16.png"), - IOUtils.readIcon("/com/fr/design/images/expand/asc.png"), - IOUtils.readIcon("/com/fr/design/images/expand/des.png") - }; - String[] nameArray = {Toolkit.i18nText("Fine-Design_Report_Sort_Original"), Toolkit.i18nText("Fine-Design_Report_Sort_Ascending"), Toolkit.i18nText("Fine-Design_Report_Sort_Descending")}; - sortTypePane = new UIButtonGroup(iconArray); - sortTypePane.setAllToolTips(nameArray); - sortTypePane.setGlobalName(Toolkit.i18nText("Fine-Design_Basic_ExpandD_Sort_After_Expand")); - - cardLayout = new CardLayout(); - centerPane = new JPanel(cardLayout); - formulaField = new JFormulaField(DEFAULT_VALUE); - centerPane.add(new JPanel(), "none"); - centerPane.add(formulaField, "content"); - UILabel sortLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_Sort_Sort_Order")); - sortLabel.setPreferredSize(LABEL_DIMENSION); - sortTypePane.addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - boolean noContent = sortTypePane.getSelectedIndex() == 0; - cardLayout.show(centerPane, noContent ? "none" : "content"); - if (noContent) { - centerPane.setPreferredSize(new Dimension(0, 0)); - TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, 0); - } else { - centerPane.setPreferredSize(new Dimension(165, 20)); - TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, VGAP); - } - } - }); - - Component[][] components = new Component[][]{ - new Component[]{sortLabel, sortTypePane}, - new Component[]{null, centerPane} - }; - - double[] rowSize = {P, P}, columnSize = {P, F}; - contentPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); - this.add(contentPane, BorderLayout.CENTER); - } - - - /** - * 刷新面板信息 - * - * @param cellElement 单元格 - */ - public void populate(TemplateCellElement cellElement) { - if (cellElement != null) { - Object value = cellElement.getValue(); - if (value instanceof DSColumn) { - this.formulaField.populateElement(cellElement); - DSColumn dSColumn = (DSColumn) value; - int sort = dSColumn.getOrder(); - this.sortTypePane.setSelectedIndex(sort); - boolean noContent = sortTypePane.getSelectedIndex() == 0; - cardLayout.show(centerPane, noContent ? "none" : "content"); - if (noContent) { - centerPane.setPreferredSize(new Dimension(0, 0)); - TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, 0); - } else { - centerPane.setPreferredSize(new Dimension(156, 20)); - TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, VGAP); - } - String sortFormula = dSColumn.getSortFormula(); - if (sortFormula != null && sortFormula.length() >= 1) { - this.formulaField.populate(sortFormula); - } else { - this.formulaField.populate(DEFAULT_VALUE); - } - } - } - } - - /** - * 保存面板配置信息 - * - * @param cellElement 单元格 - */ - public void update(CellElement cellElement) { - if (cellElement != null) { - Object value = cellElement.getValue(); - if (value instanceof DSColumn) { - DSColumn dSColumn = (DSColumn) value; - dSColumn.setOrder(this.sortTypePane.getSelectedIndex()); - dSColumn.setSortFormula(this.formulaField.getFormulaText()); - } - } - } - - /** - * 添加事件监听器 - * - * @param formulaChangeListener 公式输入框改动事件监听器 - * @param changeListener 排序类型下拉框改动事件监听器 - */ - public void addListener(UIObserverListener formulaChangeListener, ChangeListener changeListener) { - formulaField.addListener(formulaChangeListener); - sortTypePane.addChangeListener(changeListener); - } - - /** - * 去除事件监听器 - * - * @param changeListener 排序类型下拉框改动事件监听器 - */ - public void removeListener(ChangeListener changeListener) { - formulaField.removeListener(); - sortTypePane.removeChangeListener(changeListener); - } - } - /** * 单元格元素>数据集>高级设置>结果集筛选设置面板 *