From 62affbceb37acda679ed4603c84ad8772f1ed26d Mon Sep 17 00:00:00 2001 From: "Leo.Qin" Date: Tue, 1 Nov 2022 11:21:02 +0800 Subject: [PATCH 1/4] =?UTF-8?q?REPORT-83305=20=E3=80=90=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E5=8D=95=E5=85=83=E6=A0=BC=E3=80=91=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=A0=BC=E5=BC=8F->=E6=92=A4=E9=94=80=EF=BC=8C?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E6=81=A2=E5=A4=8D=E5=BC=82=E5=B8=B8=20?= =?UTF-8?q?=E3=80=90=E9=97=AE=E9=A2=98=E5=8E=9F=E5=9B=A0=E3=80=91=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E4=B8=8D=E5=90=8C=E6=A0=BC=E5=BC=8F=EF=BC=8C=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E9=9D=A2=E6=9D=BF=E5=8F=91=E7=94=9F=E5=A4=9A=E6=AC=A1?= =?UTF-8?q?=E5=8F=98=E5=8C=96=EF=BC=8C=E5=AF=BC=E8=87=B4=E5=A4=9A=E6=AC=A1?= =?UTF-8?q?=E8=A7=A6=E5=8F=91=E4=BF=9D=E5=AD=98=20=E3=80=90=E6=94=B9?= =?UTF-8?q?=E5=8A=A8=E6=80=9D=E8=B7=AF=E3=80=91=E6=9B=B4=E6=94=B9=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E4=BF=AE=E6=94=B9=E6=96=B9=E5=BC=8F=20=E3=80=90review?= =?UTF-8?q?=E5=BB=BA=E8=AE=AE=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/style/TextFormatPaneContainer.java | 72 +++++ .../dscolumn/ResultSetGroupDockingPane.java | 12 +- .../design/dscolumn/ResultSetGroupPane.java | 4 - .../dscolumn/SelectedDataColumnPane.java | 10 + .../com/fr/grid/selection/CellSelection.java | 10 +- .../com/fr/quickeditor/CellQuickEditor.java | 301 ++++++++---------- .../cellquick/CellDSColumnEditor.java | 241 +++----------- 7 files changed, 282 insertions(+), 368 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/gui/style/TextFormatPaneContainer.java diff --git a/designer-base/src/main/java/com/fr/design/gui/style/TextFormatPaneContainer.java b/designer-base/src/main/java/com/fr/design/gui/style/TextFormatPaneContainer.java new file mode 100644 index 0000000000..3d2b658670 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/style/TextFormatPaneContainer.java @@ -0,0 +1,72 @@ +package com.fr.design.gui.style; + +import com.fr.base.Style; +import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; +import com.fr.design.gui.frpane.AttributeChangeListener; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.text.Format; + +/** + * 封装格式panel,管理 AttributeChangeListener + * + * @author Leo.Qin + * @version 11.0 + * Created by Leo.Qin on 2022/10/31 + */ +public class TextFormatPaneContainer extends AbstractAttrNoScrollPane { + private TextFormatPane formatPane; + private AttributeChangeListener oldListner; + + @Override + protected JPanel createContentPane() { + formatPane = new TextFormatPane(); + return formatPane; + } + + protected void initContentPane() { + leftContentPane = createContentPane(); + if (leftContentPane != null) { + leftContentPane.setBorder(BorderFactory.createEmptyBorder()); + this.add(leftContentPane, BorderLayout.CENTER); + } + } + + @Override + public Dimension getPreferredSize() { + if (formatPane == null) { + return super.getPreferredSize(); + } + return formatPane.getPreferredSize(); + } + + public void populateBean(Style style) { + formatPane.populateBean(style); + } + + public Format update() { + return formatPane.update(); + } + + public Style update(Style style) { + return formatPane.update(style); + } + + @Override + public void removeAttributeChangeListener() { + super.removeAttributeChangeListener(); + } + + @Override + public void addAttributeChangeListener(AttributeChangeListener listener) { + oldListner = listener; + super.addAttributeChangeListener(listener); + } + + public void restoreAttributeChangeListener() { + super.addAttributeChangeListener(oldListner); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupDockingPane.java b/designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupDockingPane.java index a485fab05d..2c994cc7be 100644 --- a/designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupDockingPane.java +++ b/designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupDockingPane.java @@ -229,7 +229,7 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane { } void fireTargetChanged() { - listener.itemStateChanged(null); + } @Override @@ -249,8 +249,16 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane { functionComboBox.removeItemListener(this.listener); } - @Override public void update(Set cellElements) { cellElements.forEach(this::updateCellElement); } + + @Override + public Dimension getPreferredSize() { + if (this.isVisible()) { + return super.getPreferredSize(); + } else { + return new Dimension(); + } + } } \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupPane.java b/designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupPane.java index 2fb7b98496..3741ba8296 100644 --- a/designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupPane.java +++ b/designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupPane.java @@ -47,9 +47,6 @@ public abstract class ResultSetGroupPane extends JPanel { abstract void setRecordGrouper(RecordGrouper recordGrouper); - void fireTargetChanged() { - }; - ActionListener groupAdvancedListener = new ActionListener() { public void actionPerformed(ActionEvent evt) { if (cellElement == null) { @@ -75,7 +72,6 @@ public abstract class ResultSetGroupPane extends JPanel { dSColumn.setGrouper(rg); } setRecordGrouper(rg); - fireTargetChanged(); JTemplate targetComponent = DesignerContext.getDesignerFrame().getSelectedJTemplate(); if (targetComponent != null) { targetComponent.fireTargetModified(); diff --git a/designer-realize/src/main/java/com/fr/design/dscolumn/SelectedDataColumnPane.java b/designer-realize/src/main/java/com/fr/design/dscolumn/SelectedDataColumnPane.java index ad670abf33..052fba9046 100644 --- a/designer-realize/src/main/java/com/fr/design/dscolumn/SelectedDataColumnPane.java +++ b/designer-realize/src/main/java/com/fr/design/dscolumn/SelectedDataColumnPane.java @@ -392,4 +392,14 @@ public class SelectedDataColumnPane extends BasicPane { } return new ArrayList<>(); } + + @Override + public Dimension getPreferredSize() { + if (this.isVisible()) { + return super.getPreferredSize(); + } + else { + return new Dimension(); + } + } } diff --git a/designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java b/designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java index 4d3568cd86..b5419cf391 100644 --- a/designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java +++ b/designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java @@ -70,6 +70,7 @@ public class CellSelection extends Selection { private Rectangle editRectangle = new Rectangle(0, 0, 1, 1); private List cellRectangleList = new ArrayList(); + private Set cellElements = new HashSet<>(); public CellSelection() { this(0, 0, 1, 1); @@ -745,9 +746,10 @@ public class CellSelection extends Selection { if (cellElement != null) { value = cellElement.getValue(); } - Set allCellElement = getAllCellElements(tplEC); - boolean sameType = checkSameType(allCellElement); + cellElements = getAllCellElements(tplEC); + + boolean sameType = checkSameType(cellElements); // 多选时,多元格元素类型 value = sameType && value != null ? value : StringUtils.EMPTY; @@ -813,6 +815,10 @@ public class CellSelection extends Selection { return cellElements; } + public Set getCellElements() { + return cellElements; + } + @Override public void populatePropertyPane(ElementCasePane ePane) { CellElementPropertyPane.getInstance().reInit(ePane); diff --git a/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java b/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java index 107b06e5e9..6f060b4f06 100644 --- a/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java +++ b/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java @@ -5,13 +5,12 @@ import com.fr.base.Style; import com.fr.design.actions.UpdateAction; import com.fr.design.actions.core.ActionFactory; import com.fr.design.file.HistoryTemplateListCache; -import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.iscrollbar.UIScrollBar; import com.fr.design.gui.itextfield.UITextField; -import com.fr.design.gui.style.TextFormatPane; +import com.fr.design.gui.style.TextFormatPaneContainer; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; @@ -35,8 +34,8 @@ import javax.swing.JComponent; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollBar; +import javax.swing.SwingUtilities; import java.awt.BorderLayout; -import java.awt.CardLayout; import java.awt.Component; import java.awt.Container; import java.awt.Dimension; @@ -46,6 +45,7 @@ import java.awt.event.AdjustmentEvent; import java.awt.event.AdjustmentListener; import java.awt.event.MouseWheelEvent; import java.awt.event.MouseWheelListener; +import java.text.Format; import java.util.ArrayList; import java.util.Objects; import java.util.Set; @@ -67,12 +67,7 @@ public abstract class CellQuickEditor extends QuickEditor { private static final int CONTENT_PANE_WIDTH_GAP = 3; private static final int MOUSE_WHEEL_SPEED = 5; private static final int SCROLLBAR_WIDTH = 7; - - /** - * 区分单选多选单元格,生成相应设置面板 - */ - private final String SINGLE_SELECT = "singleSelect"; - private final String MULTIPLE_SELECT = "multipleSelect"; + private UILabel cellLabel; private int maxHeight = 280; private static final int TITLE_HEIGHT = 50; @@ -82,21 +77,16 @@ public abstract class CellQuickEditor extends QuickEditor { */ protected UITextField columnRowTextField; protected TemplateCellElement cellElement; - private TextFormatPane formatPane; - private final JPanel topContentContainer; - private final JComponent centerBodyContainer; + private TextFormatPaneContainer formatPane; + private JPanel topContentContainer; + private JComponent centerBodyContainer; + private UILabel multipleLabelTip; - private CardLayout topCardLayout; - /** - * 不同单元格元素产生的面板 - */ - private CardLayout centerCardLayout; // 占位label protected final UILabel EMPTY_LABEL = new UILabel(); - private UIComboBox singleComboBox; - private UIComboBox multipleComboBox; + private UIComboBox comboBox; private UpdateAction[] cellInsertActions; private int selectedIndex; @@ -106,23 +96,38 @@ public abstract class CellQuickEditor extends QuickEditor { private ActionListener comboBoxActionListener; public CellQuickEditor() { + + initComponents(); + + createPanelBody(); + } + + private void initComponents() { EMPTY_LABEL.setPreferredSize(LABEL_DIMENSION); + topContentContainer = initTopContent(); + formatPane = createFormatPane(); + centerBodyContainer = createCenterBody(); + + multipleLabelTip = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Basic_Cell_Element_Multiple_Tip")); + multipleLabelTip.setEnabled(false); + } + + private void createPanelBody() { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; - double[] columnSize = {p, f}; - JPanel formatContainerPanel = createFormatPane(); - topContentContainer = initTopContent(); - centerBodyContainer = createAllCenterBody(); + double[] columnSize = {f}; if (isScrollAll()) { - double[] scrollAllRowSize = {p, p, p}; + double[] scrollAllRowSize = {p, p, p, p}; prepareScrollBar(); - topContentContainer.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 0, this.getBackground())); - formatContainerPanel.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 0, this.getBackground())); + multipleLabelTip.setBorder(BorderFactory.createMatteBorder(5, 10, 0, 0, this.getBackground())); + topContentContainer.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 0, this.getBackground())); + formatPane.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 0, this.getBackground())); centerBodyContainer.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 0, this.getBackground())); Component[][] components = new Component[][]{ - new Component[]{topContentContainer, null}, - new Component[]{formatContainerPanel, null}, - new Component[]{centerBodyContainer, null} + new Component[]{multipleLabelTip}, + new Component[]{topContentContainer}, + new Component[]{formatPane}, + new Component[]{centerBodyContainer} }; leftContentPane = TableLayoutHelper.createGapTableLayoutPane(components, scrollAllRowSize, columnSize, HGAP, VGAP); this.setLayout(new CellElementBarLayout(leftContentPane) { @@ -151,14 +156,16 @@ public abstract class CellQuickEditor extends QuickEditor { this.add(scrollBar); this.add(leftContentPane); } else { - double[] scrollContentRowSize = {p, p, f}; - topContentContainer.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 10, this.getBackground())); - formatContainerPanel.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 10, this.getBackground())); + double[] scrollContentRowSize = {p, p, p, f}; + multipleLabelTip.setBorder(BorderFactory.createMatteBorder(5, 10, 0, 0, this.getBackground())); + topContentContainer.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 10, this.getBackground())); + formatPane.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 10, this.getBackground())); centerBodyContainer.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 0, this.getBackground())); Component[][] components = new Component[][]{ - new Component[]{topContentContainer, null}, - new Component[]{formatContainerPanel, null}, - new Component[]{centerBodyContainer, null} + new Component[]{multipleLabelTip}, + new Component[]{topContentContainer}, + new Component[]{formatPane}, + new Component[]{centerBodyContainer} }; this.setLayout(new BorderLayout()); this.add(TableLayoutHelper.createGapTableLayoutPane(components, scrollContentRowSize, columnSize, HGAP, VGAP), BorderLayout.CENTER); @@ -187,31 +194,6 @@ public abstract class CellQuickEditor extends QuickEditor { */ public abstract Object getComboBoxSelected(); - /** - * 初始化创建单选及多选面板 - * - * @return 创建的面板 - */ - private JComponent createAllCenterBody() { - centerCardLayout = new CardLayout(); - - JPanel centerPanel = new JPanel(centerCardLayout); - - centerPanel.add(SINGLE_SELECT, createCenterBody()); - centerPanel.add(MULTIPLE_SELECT, createCenterBody4Multiple()); - - return centerPanel; - } - - /** - * 为多选单元格创建详细面板,默认创建空面板 - * - * @return 空面板 - */ - public JComponent createCenterBody4Multiple() { - return new JPanel(); - } - /** * 刷新 @@ -224,61 +206,90 @@ public abstract class CellQuickEditor extends QuickEditor { refreshFormatPanel(); refreshDetails(); + + refreshMultipleDetails(); + } + + /** + * 多选时默认隐藏与插入元素类型相关的所有面板 + * 若其他面板需要扩展多选时可修改的内容, + * 通过重写改方法,实现显示/隐藏部分组件 + */ + public void refreshMultipleDetails() { + centerBodyContainer.setVisible(tc.isSelectedOneCell()); } private void refreshFormatPanel() { + // 在populate的时候会多次触发AttributeChangeListener事件, + // 导致不断更新单元格格式,因此populate的时候暂时删除listener + formatPane.removeAttributeChangeListener(); + if (cellElement != null) { formatPane.populateBean(cellElement.getStyle()); } else { formatPane.populateBean(Style.DEFAULT_STYLE); } + + formatPane.restoreAttributeChangeListener(); } private void refreshPanel() { + changeVisiableState(); CellSelection cs = (CellSelection) tc.getSelection(); ColumnRow columnRow = ColumnRow.valueOf(cs.getColumn(), cs.getRow()); - String selectType = tc.isSelectedOneCell() ? SINGLE_SELECT : MULTIPLE_SELECT; - - topCardLayout.show(topContentContainer, selectType); - centerCardLayout.show(centerBodyContainer, selectType); columnRowTextField.setText(columnRow.toString()); cellElement = tc.getEditingElementCase().getTemplateCellElement(cs.getColumn(), cs.getRow()); JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); if (jTemplate != null) { - singleComboBox.removeActionListener(comboBoxActionListener); - singleComboBox.removeAllItems(); + comboBox.removeActionListener(comboBoxActionListener); + comboBox.removeAllItems(); String[] items = getDefaultComboBoxItems(); for (String item : items) { - singleComboBox.addItem(item); - multipleComboBox.addItem(item); + comboBox.addItem(item); } Object comboBoxSelected = getComboBoxSelected(); if (comboBoxSelected != null) { - singleComboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName()); - multipleComboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName()); + comboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName()); } else { - singleComboBox.setSelectedIndex(1); - multipleComboBox.setSelectedIndex(1); + comboBox.setSelectedIndex(1); } - currentSelectedIndex = singleComboBox.getSelectedIndex(); + currentSelectedIndex = comboBox.getSelectedIndex(); comboBoxActionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { cellInsertActions = ActionFactory.createCellInsertAction(ElementCasePane.class, tc); - selectedIndex = singleComboBox.getSelectedIndex(); - singleComboBox.setPopupVisible(false); - singleComboBox.repaint(); + selectedIndex = comboBox.getSelectedIndex(); + comboBox.setPopupVisible(false); + comboBox.repaint(); // comboBox.getSelectedIndex()可能返回-1 if (selectedIndex != -1 && selectedIndex < cellInsertActions.length) { cellInsertActions[selectedIndex].actionPerformed(e); } - singleComboBox.setSelectedIndex(currentSelectedIndex); + comboBox.setSelectedIndex(currentSelectedIndex); } }; - singleComboBox.addActionListener(comboBoxActionListener); + comboBox.addActionListener(comboBoxActionListener); + } + } + + /** + * 单选多选时切换部分组件的 隐藏/显示 状态 + */ + private void changeVisiableState() { + boolean selectedOneCell = tc.isSelectedOneCell(); + + comboBox.setEnabled(selectedOneCell); + if (selectedOneCell) { + columnRowTextField.setPreferredSize(null); + cellLabel.setPreferredSize(null); + multipleLabelTip.setPreferredSize(new Dimension()); + } else { + columnRowTextField.setPreferredSize(new Dimension()); + cellLabel.setPreferredSize(new Dimension()); + multipleLabelTip.setPreferredSize(null); } } @@ -289,44 +300,19 @@ public abstract class CellQuickEditor extends QuickEditor { private JPanel initTopContent() { - topCardLayout = new CardLayout(); - JPanel topContentPane = new JPanel(topCardLayout); - // 单选面板 double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double[] columnSize = {GraphHelper.getWidth(Toolkit.i18nText("Fine-Design_Report_Insert_Cell_Element")), f}; double[] rowSize = {p, p}; - UILabel cellLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Cell")); + cellLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Basic_Cell")); UILabel insertContentLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Report_Insert_Cell_Element")); initCellElementEditComboBox(); Component[][] components = new Component[][]{ new Component[]{cellLabel, columnRowTextField = initColumnRowTextField()}, - new Component[]{insertContentLabel, UIComponentUtils.wrapWithBorderLayoutPane(singleComboBox)}, - }; - JPanel singlePanel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); - topContentPane.add(SINGLE_SELECT, singlePanel); - - - // 多选面板 - UILabel multipleTipLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Basic_Cell_Element_Multiple_Tip")); - multipleTipLabel.setEnabled(false); - multipleTipLabel.setBorder(BorderFactory.createMatteBorder(5, 0, 0, 0, this.getBackground())); - UILabel insertContentLabel1 = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Report_Insert_Cell_Element")); - Component[][] components1 = new Component[][]{ - new Component[]{insertContentLabel1, UIComponentUtils.wrapWithBorderLayoutPane(multipleComboBox)}, - }; - multipleComboBox.setEnabled(false); - JPanel insertPanel = TableLayoutHelper.createGapTableLayoutPane(components1, new double[]{p}, columnSize, HGAP, - VGAP); - Component[][] components2 = new Component[][]{ - new Component[]{multipleTipLabel}, - new Component[]{insertPanel}, + new Component[]{insertContentLabel, UIComponentUtils.wrapWithBorderLayoutPane(comboBox)}, }; - JPanel multiplePanel = TableLayoutHelper.createGapTableLayoutPane(components2, rowSize, new double[]{f}, HGAP, VGAP); - topContentPane.add(MULTIPLE_SELECT, multiplePanel); - - return topContentPane; + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); } private void prepareScrollBar() { @@ -374,23 +360,19 @@ public abstract class CellQuickEditor extends QuickEditor { private void initCellElementEditComboBox() { JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); if (jTemplate == null) { - singleComboBox = new UIComboBox(); - multipleComboBox = new UIComboBox(); + comboBox = new UIComboBox(); return; } final String[] items = getDefaultComboBoxItems(); - singleComboBox = new UIComboBox(items); - multipleComboBox = new UIComboBox(items); + comboBox = new UIComboBox(items); final Object comboBoxSelected = getComboBoxSelected(); if (comboBoxSelected != null) { - singleComboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName()); - multipleComboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName()); + comboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName()); } else { - singleComboBox.setSelectedIndex(1); - multipleComboBox.setSelectedIndex(1); + comboBox.setSelectedIndex(1); } - currentSelectedIndex = singleComboBox.getSelectedIndex(); - singleComboBox.addActionListener(comboBoxActionListener); + currentSelectedIndex = comboBox.getSelectedIndex(); + comboBox.addActionListener(comboBoxActionListener); } private String[] getDefaultComboBoxItems() { @@ -439,61 +421,52 @@ public abstract class CellQuickEditor extends QuickEditor { /** * 创建格式化面板 - * @return */ - private JPanel createFormatPane() { - formatPane = new TextFormatPane(); - AbstractAttrNoScrollPane container = new AbstractAttrNoScrollPane() { - @Override - protected JPanel createContentPane() { - return formatPane; - } - - protected void initContentPane() { - leftContentPane = createContentPane(); - if (leftContentPane != null) { - leftContentPane.setBorder(BorderFactory.createEmptyBorder()); - this.add(leftContentPane, BorderLayout.CENTER); - } - } + private TextFormatPaneContainer createFormatPane() { + TextFormatPaneContainer formatPane = new TextFormatPaneContainer(); - @Override - public Dimension getPreferredSize() { - if (formatPane == null) { - return super.getPreferredSize(); - } - return formatPane.getPreferredSize(); - } - }; - - container.addAttributeChangeListener(new AttributeChangeListener() { + AttributeChangeListener attributeChangeListener = new AttributeChangeListener() { @Override public void attributeChange() { - isEditing = true; - boolean updateStyle = false; - - CellSelection cs = (CellSelection) tc.getSelection(); - TemplateElementCase editingElementCase = tc.getEditingElementCase(); - Set allCellElements = cs.getAllCellElements(editingElementCase); - for (TemplateCellElement cellElement : allCellElements) { - Style elementStyle = cellElement.getStyle(); - Style style = formatPane.update(elementStyle); - if (!Objects.equals(style.getFormat(), elementStyle.getFormat())) { - // 点击单元格,但未设置格式时,不将单元格设置为编辑状态,防止将所选的每个单元格都设置为编辑状态 - editingElementCase.addCellElement(cellElement); - cellElement.setStyle(style); - updateStyle = true; + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + // 耗时任务放线程中,让其他UI组件更新界面, + // 防止多次调用此处每次获取的界面值不同,导致不断更新单元格格式 + isEditing = true; + boolean updateStyle = false; + + CellSelection cs = (CellSelection) tc.getSelection(); + TemplateElementCase editingElementCase = tc.getEditingElementCase(); + Set allCellElements = cs.getCellElements(); + Style oldStyle = cellElement == null ? Style.DEFAULT_STYLE : cellElement.getStyle(); + Style style = formatPane.update(oldStyle); + for (TemplateCellElement cellElement : allCellElements) { + Format elementFormat = cellElement.getStyle().getFormat(); + Format paneFormat = style.getFormat(); + if (!Objects.equals(paneFormat, elementFormat)) { + // 点击单元格,但未设置格式时,不将单元格设置为编辑状态,防止将所选的每个单元格都设置为编辑状态 + editingElementCase.addCellElement(cellElement); + cellElement.setStyle(style); + updateStyle = true; + } + } + + if (updateStyle) { + // 防止频繁触发保存 + fireTargetModified(); + } + + isEditing = false; } - } + }); - if (updateStyle) { - // 防止频繁触发保存 - fireTargetModified(); - } - isEditing = false; } - }); - return container; + }; + + formatPane.addAttributeChangeListener(attributeChangeListener); + + return formatPane; } } diff --git a/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java b/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java index 0b7b011f04..c53439fcba 100644 --- a/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java +++ b/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java @@ -54,11 +54,8 @@ import java.awt.Component; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; import java.util.ArrayList; import java.util.Arrays; -import java.util.HashSet; import java.util.Set; import static com.fr.report.cell.cellattr.core.group.FilterTypeEnum.BOTTOM; @@ -107,10 +104,6 @@ public class CellDSColumnEditor extends CellQuickEditor { * 数据列高级设置 */ private DSColumnAdvancedEditorPane cellDSColumnAdvancedPane; - /** - * 多选面板设置 - */ - private DSColumnMultipleEditorPane cellDSColumnMultiplePane; public CellDSColumnEditor() { super(); @@ -145,7 +138,6 @@ public class CellDSColumnEditor extends CellQuickEditor { protected void refreshDetails() { cellDSColumnBasicPane.populate(); cellDSColumnAdvancedPane.populate(); - cellDSColumnMultiplePane.populate(); this.validate(); } @@ -190,7 +182,6 @@ public class CellDSColumnEditor extends CellQuickEditor { super.release(); cellDSColumnBasicPane.release(); cellDSColumnAdvancedPane.release(); - cellDSColumnMultiplePane.release(); } @@ -241,7 +232,10 @@ public class CellDSColumnEditor extends CellQuickEditor { @Override public void update() { dataPane.update(cellElement); - groupPane.update(); + + CellSelection selection = (CellSelection) tc.getSelection(); + Set allCellElements = selection.getCellElements(); + groupPane.update(allCellElements); } @Override @@ -286,7 +280,6 @@ public class CellDSColumnEditor extends CellQuickEditor { private void initComponents(){ dataPane = new SelectedDataColumnPane(true, true); groupPane = new ResultSetGroupDockingPane(); - initListener(); double[] rowSize = {P}, columnSize = {60, F}; UILabel uiLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Report_Filter_Conditions")); condition = new DSColumnConditionAction(); @@ -303,35 +296,8 @@ public class CellDSColumnEditor extends CellQuickEditor { conditionPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); this.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); } - - - private void initListener() { - dataPane.setListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - if (e.getStateChange() == ItemEvent.SELECTED) { - dataPane.update(cellElement); - fireTargetModified(); - } - } - }); - groupPane.setListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - if (e == null) { - //分组-高级-自定义点确定的时候传进来null的e,但是这时候应该触发保存 - groupPane.update(); - fireTargetModified(); - return; - } - if (e.getStateChange() == ItemEvent.DESELECTED) { - groupPane.update(); - fireTargetModified(); - } - } - }); - } - + + @Override protected AttributeChangeListener getAttributeChangeListener() { return new AttributeChangeListener() { @@ -342,6 +308,40 @@ public class CellDSColumnEditor extends CellQuickEditor { } }; } + + + public void setMultipleVisible(boolean selectedOneCell) { + // 数据源面板 需要在单选与多选间切换显示状态 + dataPane.setVisible(selectedOneCell); + + if (!selectedOneCell) { + // 只有在批量操作的时候才需要判断是否隐藏条件面板 + CellSelection selection = (CellSelection) tc.getSelection(); + boolean sameDSName = checkSameDSName(selection.getCellElements()); + conditionPane.setVisible(sameDSName); + } + } + + /** + * 判断是否属于同一个数据集 + * + * @param cellElements + * @return + */ + private boolean checkSameDSName(Set cellElements) { + String lastDSName = StringUtils.EMPTY; + for (TemplateCellElement cellElement : cellElements) { + DSColumn dsColumn = (DSColumn) cellElement.getValue(); + String dsName = dsColumn.getDSName(); + if (StringUtils.isNotEmpty(lastDSName) && !StringUtils.equals(dsName, lastDSName)) { + return false; + } + lastDSName = dsName; + } + return true; + } + + } @@ -1026,163 +1026,12 @@ public class CellDSColumnEditor extends CellQuickEditor { } - - class DSColumnMultipleEditorPane extends AbstractDSCellEditorPane { - - /** - * 数据分组设置 - */ - private ResultSetGroupDockingPane groupPane; - /** - * 条件过滤按钮面板 - */ - private JPanel conditionPane; - - /** - * 条件过滤按钮触发动作 - */ - private DSColumnConditionAction condition; - - /** - * 条件过滤按钮 - */ - private UIButton conditionUIButton; - - - @Override - public String getIconPath() { - return Toolkit.i18nText("Fine-Design_Report_Basic"); - } - - @Override - public String title4PopupWindow() { - return Toolkit.i18nText("FR-Designer_Basic"); - } - - - @Override - public void update() { - groupPane.update(); - } - - @Override - public void populate() { - this.removeAttributeChangeListener(); - if (tc != null) { - CellSelection selection = (CellSelection) tc.getSelection(); - Set cellElements = selection.getAllCellElements(tc.getEditingElementCase()); - conditionPane.setVisible(checkSameDSName(cellElements)); - condition.setEditingComponent(tc); - cellElements.forEach(cellElement -> groupPane.populate(cellElement)); - } - this.addAttributeChangeListener(); - } - - /** - * 判断是否属于同一个数据集 - * - * @param cellElements - * @return - */ - private boolean checkSameDSName(Set cellElements) { - String lastDSName = StringUtils.EMPTY; - for (TemplateCellElement cellElement : cellElements) { - DSColumn dsColumn = (DSColumn) cellElement.getValue(); - String dsName = dsColumn.getDSName(); - if (StringUtils.isNotEmpty(lastDSName) && !StringUtils.equals(dsName, lastDSName)) { - return false; - } - lastDSName = dsName; - } - return true; - } - - @Override - protected void release() { - condition.setEditingComponent(null); - } - - - /** - * 创建有内容的面板显示信息 - * - * @return content JPanel - */ - @Override - protected JPanel createContentPane() { - initComponents(); - double[] columnSize = {F}; - double[] rowSize = {P, P}; - Component[][] components = new Component[][]{ - //数据分组设置 - new Component[]{this.groupPane}, - //条件过滤 - new Component[]{this.conditionPane} - }; - return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); - } - - private void initComponents() { - groupPane = new ResultSetGroupDockingPane(); - initListener(); - double[] rowSize = {P}, columnSize = {60, F}; - UILabel uiLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Report_Filter_Conditions")); - condition = new DSColumnConditionAction(); - if (tc != null) { - condition.setEditingComponent(tc); - } - //丢掉icon,修改按钮名称为编辑 - condition.setSmallIcon(UIConstants.EMPTY_ICON); - condition.setName(Toolkit.i18nText("Fine-Design_Basic_Edit")); - conditionUIButton = new UIButton(condition); - Component[][] components = new Component[][]{ - new Component[]{uiLabel, UIComponentUtils.wrapWithBorderLayoutPane(conditionUIButton)} - }; - conditionPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); - this.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); - } - - - private void initListener() { - groupPane.setListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - Set cellElements = new HashSet<>(); - if (tc != null) { - CellSelection selection = (CellSelection) tc.getSelection(); - cellElements = selection.getAllCellElements(tc.getEditingElementCase()); - } - - if (e == null) { - //分组-高级-自定义点确定的时候传进来null的e,但是这时候应该触发保存 - groupPane.update(cellElements); - fireTargetModified(); - return; - } - if (e.getStateChange() == ItemEvent.DESELECTED) { - groupPane.update(cellElements); - fireTargetModified(); - } - } - }); - } - - @Override - protected AttributeChangeListener getAttributeChangeListener() { - return new AttributeChangeListener() { - @Override - public void attributeChange() { - update(); - fireTargetModified(); - } - }; - } - } - @Override - public JComponent createCenterBody4Multiple() { - cellDSColumnMultiplePane = new DSColumnMultipleEditorPane(); - return cellDSColumnMultiplePane; + public void refreshMultipleDetails() { + tabsHeaderIconPane.setVisible(tc.isSelectedOneCell()); + cellDSColumnAdvancedPane.setVisible(tc.isSelectedOneCell()); + + cellDSColumnBasicPane.setMultipleVisible(tc.isSelectedOneCell()); } @Override From 47cc6f0f27cb38f663de40d1ddb564f01cbf5d73 Mon Sep 17 00:00:00 2001 From: "Leo.Qin" Date: Tue, 1 Nov 2022 11:26:56 +0800 Subject: [PATCH 2/4] =?UTF-8?q?REPORT-83305=20=E6=B7=BB=E5=8A=A0=E6=B3=A8?= =?UTF-8?q?=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/style/TextFormatPaneContainer.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/style/TextFormatPaneContainer.java b/designer-base/src/main/java/com/fr/design/gui/style/TextFormatPaneContainer.java index 3d2b658670..bf58ab6558 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/TextFormatPaneContainer.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/TextFormatPaneContainer.java @@ -8,7 +8,6 @@ import javax.swing.BorderFactory; import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Dimension; -import java.text.Format; /** * 封装格式panel,管理 AttributeChangeListener @@ -43,14 +42,21 @@ public class TextFormatPaneContainer extends AbstractAttrNoScrollPane { return formatPane.getPreferredSize(); } + /** + * 根据单元格样式填充面板设置 + * + * @param style 单元格样式 + */ public void populateBean(Style style) { formatPane.populateBean(style); } - public Format update() { - return formatPane.update(); - } - + /** + * 根据面板设置获取修改后的单元格样式 + * + * @param style 单元格当前样式 + * @return 更新后的单元格样式 + */ public Style update(Style style) { return formatPane.update(style); } @@ -66,6 +72,9 @@ public class TextFormatPaneContainer extends AbstractAttrNoScrollPane { super.addAttributeChangeListener(listener); } + /** + * 恢复使用AttributeChangeListener + */ public void restoreAttributeChangeListener() { super.addAttributeChangeListener(oldListner); } From 7a272a97d78aa18941f1aa2fc8f5a5b93dd3aa6c Mon Sep 17 00:00:00 2001 From: "Leo.Qin" Date: Tue, 1 Nov 2022 11:37:13 +0800 Subject: [PATCH 3/4] =?UTF-8?q?REPORT-80690=20=E5=88=A0=E9=99=A4=E6=9C=AA?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/dscolumn/ResultSetGroupDockingPane.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupDockingPane.java b/designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupDockingPane.java index 2c994cc7be..3a51af2844 100644 --- a/designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupDockingPane.java +++ b/designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupDockingPane.java @@ -228,9 +228,6 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane { this.listener = listener; } - void fireTargetChanged() { - - } @Override public void setRecordGrouper(RecordGrouper recordGrouper) { From 59c4ea72018e566d027af9b594f6dd8c3a279ffe Mon Sep 17 00:00:00 2001 From: "Leo.Qin" Date: Tue, 1 Nov 2022 20:01:28 +0800 Subject: [PATCH 4/4] =?UTF-8?q?REPORT-83305=20=E4=BF=AE=E5=A4=8D=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=90=8E=E7=95=8C=E9=9D=A2=E5=87=BA=E7=8E=B0=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cellquick/CellDSColumnEditor.java | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java b/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java index c53439fcba..bd449de01d 100644 --- a/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java +++ b/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java @@ -54,6 +54,8 @@ import java.awt.Component; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; import java.util.ArrayList; import java.util.Arrays; import java.util.Set; @@ -157,6 +159,10 @@ public class CellDSColumnEditor extends CellQuickEditor { tabsHeaderIconPane = new UIHeadGroup(iconArray) { @Override public void tabChanged(int index) { + + // 由于多选的时候修改了 cellDSColumnBasicPane 中组件的visiable属性,切换时需要将其设置为false + cellDSColumnBasicPane.setVisible(false); + card.show(cardContainer, paneList.get(index).title4PopupWindow()); paneList.get(index).populate(); } @@ -280,6 +286,7 @@ public class CellDSColumnEditor extends CellQuickEditor { private void initComponents(){ dataPane = new SelectedDataColumnPane(true, true); groupPane = new ResultSetGroupDockingPane(); + initListener(); double[] rowSize = {P}, columnSize = {60, F}; UILabel uiLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Report_Filter_Conditions")); condition = new DSColumnConditionAction(); @@ -297,14 +304,38 @@ public class CellDSColumnEditor extends CellQuickEditor { this.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); } + private void initListener() { + dataPane.setListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + if (e.getStateChange() == ItemEvent.SELECTED) { + dataPane.update(cellElement); + fireTargetModified(); + } + } + }); + groupPane.setListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + CellSelection selection = (CellSelection) tc.getSelection(); + Set allCellElements = selection.getCellElements(); + groupPane.update(allCellElements); + if (e == null || e.getStateChange() == ItemEvent.DESELECTED) { + //分组-高级-自定义点确定的时候传进来null的e,但是这时候应该触发保存 + groupPane.update(allCellElements); + fireTargetModified(); + } + } + }); + } + @Override protected AttributeChangeListener getAttributeChangeListener() { return new AttributeChangeListener() { @Override public void attributeChange() { - update(); - fireTargetModified(); + } }; } @@ -319,6 +350,8 @@ public class CellDSColumnEditor extends CellQuickEditor { CellSelection selection = (CellSelection) tc.getSelection(); boolean sameDSName = checkSameDSName(selection.getCellElements()); conditionPane.setVisible(sameDSName); + } else { + conditionPane.setVisible(true); } }