Browse Source

Pull request #10460: REPORT-80690 批量操作单元格

Merge in DESIGN/design from ~LEO.QIN/design:feature/x to feature/x

* commit 'aca1701772f2df3c87acd5d5bdee85cd4801cf34':
  REPORT-80690 批量操作单元格 【问题原因】 【改动思路】增加批量操作单元格功能 【review建议】
  REPORT-80690 批量操作单元格 【问题原因】 【改动思路】增加批量操作单元格功能 【review建议】
feature/x
Leo.Qin-覃宇攀 2 years ago
parent
commit
b7cd5a7c04
  1. 5
      designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java
  2. 19
      designer-realize/src/main/java/com/fr/design/actions/cell/AbstractCellElementAction.java
  3. 80
      designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java
  4. 11
      designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupDockingPane.java
  5. 23
      designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupPane.java
  6. 70
      designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java
  7. 238
      designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java
  8. 188
      designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java
  9. 50
      designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellFormulaQuickEditor.java
  10. 52
      designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellStringQuickEditor.java

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

@ -354,12 +354,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
public void updateCellElementState(boolean isSelectedOneCell) {
PropertyItem cellElement = propertyItemMap.get(KEY_CELL_ELEMENT);
if (isSelectedOneCell) {
enableCellElementPane(cellElement);
} else { // 如果选中多个单元格,禁用单元格元素 tab
disableCellElementPane(cellElement);
refreshRightPane();
}
}
// 禁用单元格元素tab

19
designer-realize/src/main/java/com/fr/design/actions/cell/AbstractCellElementAction.java

@ -14,6 +14,8 @@ import com.fr.report.core.SheetUtils;
import com.fr.report.elementcase.TemplateElementCase;
import com.fr.report.stable.ReportConstants;
import java.awt.Rectangle;
/**
* TODO ALEX_SEP 这个类与AbstractCellAction有什么关系?
*
@ -45,11 +47,13 @@ public abstract class AbstractCellElementAction extends CellSelectionAction {
dialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
for (int rect = 0; rect < finalCS.getCellRectangleCount(); rect++) {
Rectangle cellRectangle = finalCS.getCellRectangle(rect);
// 需要先行后列地增加新元素。
for (int j = 0; j < finalCS.getRowSpan(); j++) {
for (int i = 0; i < finalCS.getColumnSpan(); i++) {
int column = i + finalCS.getColumn();
int row = j + finalCS.getRow();
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 editCellElement = tplEC.getTemplateCellElement(column, row);
if (editCellElement == null) {
editCellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row);
@ -64,15 +68,20 @@ public abstract class AbstractCellElementAction extends CellSelectionAction {
if (isNeedShinkToFit()) {
// shink to fit.(如果value是String)
Object editElementValue = editCellElement.getValue();
if (editElementValue != null && (editElementValue instanceof String || editElementValue instanceof Number)) {
if (checkValueType(editElementValue)) {
// TODO ALEX_SEP 暂时用FIT_DEFAULT替代,不取reportsetting里面的设置,因为也不知道是应该放在report里面还是elementcase里面
GridUtils.shrinkToFit(ReportConstants.AUTO_SHRINK_TO_FIT_DEFAULT, tplEC, editCellElement);
}
}
}
}
}
ePane.fireTargetModified();
}
private boolean checkValueType(Object editElementValue) {
return editElementValue instanceof String || editElementValue instanceof Number;
}
});
//控件设置记住dlg,提交入库智能添加单元格后可以show出来
DesignerContext.setReportWritePane(dialog);

80
designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java

@ -8,7 +8,6 @@ import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.formula.CustomVariableResolver;
import com.fr.design.formula.FormulaFactory;
import com.fr.design.formula.UIFormula;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox;
@ -16,7 +15,6 @@ 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;
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;
@ -52,7 +50,6 @@ public class DSColumnAdvancedPane extends BasicPane {
private SortPane sortPane;
private SelectCountPane selectCountPane;
private ValuePane valuePane;
private FormatAttrPane formatAttrPane;
private UICheckBox horizontalExtendableCheckBox;
private UICheckBox verticalExtendableCheckBox;
private UICheckBox useMultiplyNumCheckBox;
@ -89,10 +86,6 @@ public class DSColumnAdvancedPane extends BasicPane {
valuePane = new ValuePane();
valuePane.setBorder(UITitledBorder.createBorderWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Bind_Column_Custom_Data_Appearance")));
formatAttrPane = new FormatAttrPane();
JPanel titleBorderedFormatPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Format"));
titleBorderedFormatPane.add(formatAttrPane, BorderLayout.NORTH);
JPanel extendablePane = null;
if (setting > DSColumnPane.SETTING_DSRELATED) {
// extendableDirectionPane
@ -130,7 +123,6 @@ public class DSColumnAdvancedPane extends BasicPane {
{sortPane},
{selectCountPane},
{valuePane},
{titleBorderedFormatPane},
{extendablePane},
{multiNumPane}
};
@ -138,7 +130,6 @@ public class DSColumnAdvancedPane extends BasicPane {
components = new Component[][]{
{sortPane},
{valuePane},
{titleBorderedFormatPane}
};
}
@ -161,7 +152,6 @@ public class DSColumnAdvancedPane extends BasicPane {
sortPane.populateBean(cellElement);
valuePane.populate(cellElement);
formatAttrPane.populate(cellElement);
if (selectCountPane != null) {
selectCountPane.populate(cellElement);
@ -211,7 +201,6 @@ public class DSColumnAdvancedPane extends BasicPane {
sortPane.updateBean(cellElement);
valuePane.update(cellElement);
formatAttrPane.update(cellElement);
if (selectCountPane != null) {
selectCountPane.update(cellElement);
@ -518,75 +507,6 @@ public class DSColumnAdvancedPane extends BasicPane {
}
}
public static class ReLayoutTextFormatPane extends TextFormatPane {
protected void initLayout() {
JComponent[][] components = new JComponent[][] { {typeComboBox, textField, roundingBox} };
double[] rowSize = new double[] { TableLayout.FILL };
double[] columnSize = {TableLayout.PREFERRED, 200, TableLayout.PREFERRED};
JPanel settingPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 4, 0);
addComponents(4, new JComponent[]{settingPane, previewLabel});
}
@Override
protected void setRoundingBoxVisible(boolean visible) {
roundingBox.setVisible(visible);
}
public void populate(CellElement cellElement) {
if (cellElement != null) {
populateBean(cellElement.getStyle());
}
}
public void update(CellElement cellElement) {
if (cellElement != null) {
cellElement.setStyle(update(cellElement.getStyle()));
}
}
}
public static class FormatAttrPane extends AbstractAttrNoScrollPane {
private TextFormatPane formatPane;
@Override
protected JPanel createContentPane() {
this.formatPane = new ReLayoutTextFormatPane();
return this.formatPane;
}
@Override
public Dimension getPreferredSize() {
if (formatPane == null) {
return super.getPreferredSize();
}
return formatPane.getPreferredSize();
}
protected void initContentPane() {
leftContentPane = createContentPane();
if (leftContentPane != null) {
leftContentPane.setBorder(BorderFactory.createEmptyBorder());
this.add(leftContentPane, BorderLayout.CENTER);
}
}
public void populate(CellElement cellElement) {
if (cellElement != null && formatPane != null) {
formatPane.populateBean(cellElement.getStyle());
}
}
public void update(CellElement cellElement) {
if (cellElement != null && formatPane != null) {
cellElement.setStyle(formatPane.update(cellElement.getStyle()));
}
}
}
private void checkButtonEnabled() {
if (useMultiplyNumCheckBox.isSelected()) {
multiNumSpinner.setEnabled(true);

11
designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupDockingPane.java

@ -26,6 +26,7 @@ import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.Set;
/**
* 这个pane是选中数据列后在上方QuickRegion处显示的pane
@ -167,6 +168,11 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane {
@Override
public void update() {
updateCellElement(cellElement);
}
private void updateCellElement(TemplateCellElement cellElement) {
if (isNPE(cellElement)) {
return;
}
@ -242,4 +248,9 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane {
groupComboBox.removeItemListener(this.listener);
functionComboBox.removeItemListener(this.listener);
}
@Override
public void update(Set<TemplateCellElement> cellElements) {
cellElements.forEach(this::updateCellElement);
}
}

23
designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupPane.java

@ -1,17 +1,10 @@
package com.fr.design.dscolumn;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.report.cell.CellElement;
import com.fr.report.cell.TemplateCellElement;
import com.fr.report.cell.cellattr.core.group.CustomGrouper;
@ -19,6 +12,12 @@ import com.fr.report.cell.cellattr.core.group.DSColumn;
import com.fr.report.cell.cellattr.core.group.FunctionGrouper;
import com.fr.report.cell.cellattr.core.group.RecordGrouper;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Set;
//august:1:31 我又改回以前的样子了 neil那个方法还是有bug 9922
public abstract class ResultSetGroupPane extends JPanel {
@ -38,6 +37,14 @@ public abstract class ResultSetGroupPane extends JPanel {
abstract void update();
/**
* 批量更新数据设置
*
* @param cellElements 需要更新的单元格
*/
public void update(Set<TemplateCellElement> cellElements) {
}
abstract void setRecordGrouper(RecordGrouper recordGrouper);
void fireTargetChanged() {

70
designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java

@ -34,6 +34,7 @@ import com.fr.design.report.RowColumnPane;
import com.fr.design.selection.QuickEditor;
import com.fr.grid.GridUtils;
import com.fr.report.cell.CellElement;
import com.fr.report.cell.DefaultTemplateCellElement;
import com.fr.report.cell.TemplateCellElement;
import com.fr.report.cell.cellattr.CellGUIAttr;
import com.fr.report.elementcase.TemplateElementCase;
@ -46,8 +47,10 @@ import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
/**
* the cell selection (columnrow)是所选单元格中左上角的位置 这个数据结构就是一个Rectangle
@ -739,16 +742,77 @@ public class CellSelection extends Selection {
TemplateElementCase tplEC = ePane.getEditingElementCase();
TemplateCellElement cellElement = tplEC.getTemplateCellElement(column, row);
Object value = null;
boolean b = ePane.isSelectedOneCell();
if (cellElement != null && b) {
if (cellElement != null) {
value = cellElement.getValue();
}
value = value == null ? StringUtils.EMPTY : value;
Set<TemplateCellElement> allCellElement = getAllCellElements(tplEC);
boolean sameType = checkSameType(allCellElement);
// 多选时,多元格元素类型
value = sameType && value != null ? value : StringUtils.EMPTY;
//之前是少了个bigInteger,刚kunsnat又发现少了个bigDecimal,数字类型的都用stringEditor,没必要那个样子
QuickEditor editor = ActionFactory.getCellEditor((value instanceof Number) ? (Number.class) : (value.getClass()));
return editor;
}
/**
* 选中的单元格插入元素类型是否相同
*
* @param cellElements 单元格
* @return true: 相同
*/
public boolean checkSameType(Set<TemplateCellElement> cellElements) {
Class lastType = null;
for (TemplateCellElement cellElement : cellElements) {
Object value = cellElement.getValue();
if (value == null) {
value = StringUtils.EMPTY;
}
Class<?> type = value.getClass();
if (lastType != null && lastType != type) {
return false;
}
lastType = type;
}
return true;
}
/**
* 获取当前选中的所有单元格若选中未编辑状态的单元格暂时不添加为编辑状态
*
* @param elementCase
* @return 获取当前选中的所有单元格
*/
public Set<TemplateCellElement> getAllCellElements(TemplateElementCase elementCase) {
Set<TemplateCellElement> cellElements = new HashSet<>();
// 遍历选择的rect
for (int rect = 0; rect < getCellRectangleCount(); rect++) {
Rectangle cellRectangle = getCellRectangle(rect);
// 遍历rect中每个ce
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 = new DefaultTemplateCellElement(column, row);
}
cellElements.add(cellElement);
}
}
}
return cellElements;
}
@Override
public void populatePropertyPane(ElementCasePane ePane) {
CellElementPropertyPane.getInstance().reInit(ePane);

238
designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java

@ -1,13 +1,17 @@
package com.fr.quickeditor;
import com.fr.base.GraphHelper;
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.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
@ -23,6 +27,7 @@ import com.fr.design.widget.FRWidgetFactory;
import com.fr.grid.selection.CellSelection;
import com.fr.quickeditor.cellquick.layout.CellElementBarLayout;
import com.fr.report.cell.TemplateCellElement;
import com.fr.report.elementcase.TemplateElementCase;
import com.fr.stable.ColumnRow;
import javax.swing.BorderFactory;
@ -31,6 +36,7 @@ import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollBar;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
@ -41,6 +47,8 @@ import java.awt.event.AdjustmentListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.util.ArrayList;
import java.util.Objects;
import java.util.Set;
/**
* @author zhou, yaoh.wu
@ -59,6 +67,13 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
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 int maxHeight = 280;
private static final int TITLE_HEIGHT = 50;
@ -67,11 +82,22 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
*/
protected UITextField columnRowTextField;
protected TemplateCellElement cellElement;
private TextFormatPane formatPane;
private final JPanel topContentContainer;
private final JComponent centerBodyContainer;
private CardLayout topCardLayout;
/**
* 不同单元格元素产生的面板
*/
private CardLayout centerCardLayout;
// 占位label
protected final UILabel EMPTY_LABEL = new UILabel();
private UIComboBox comboBox;
private UIComboBox singleComboBox;
private UIComboBox multipleComboBox;
private UpdateAction[] cellInsertActions;
private int selectedIndex;
private int currentSelectedIndex;
@ -84,16 +110,19 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {p, f};
JComponent centerBody = createCenterBody();
JPanel topContent = initTopContent();
JPanel formatContainerPanel = createFormatPane();
topContentContainer = initTopContent();
centerBodyContainer = createAllCenterBody();
if (isScrollAll()) {
double[] scrollAllRowSize = {p, p};
double[] scrollAllRowSize = {p, p, p};
prepareScrollBar();
topContent.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 0, this.getBackground()));
centerBody.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 0, this.getBackground()));
topContentContainer.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 0, this.getBackground()));
formatContainerPanel.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[]{topContent, null},
new Component[]{centerBody, null}
new Component[]{topContentContainer, null},
new Component[]{formatContainerPanel, null},
new Component[]{centerBodyContainer, null}
};
leftContentPane = TableLayoutHelper.createGapTableLayoutPane(components, scrollAllRowSize, columnSize, HGAP, VGAP);
this.setLayout(new CellElementBarLayout(leftContentPane) {
@ -122,12 +151,14 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
this.add(scrollBar);
this.add(leftContentPane);
} else {
double[] scrollContentRowSize = {p, f};
topContent.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 10, this.getBackground()));
centerBody.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 0, this.getBackground()));
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()));
centerBodyContainer.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 0, this.getBackground()));
Component[][] components = new Component[][]{
new Component[]{topContent, null},
new Component[]{centerBody, null}
new Component[]{topContentContainer, null},
new Component[]{formatContainerPanel, null},
new Component[]{centerBodyContainer, null}
};
this.setLayout(new BorderLayout());
this.add(TableLayoutHelper.createGapTableLayoutPane(components, scrollContentRowSize, columnSize, HGAP, VGAP), BorderLayout.CENTER);
@ -156,48 +187,99 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
*/
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();
}
/**
* 刷新
*/
@Override
protected void refresh() {
refreshPanel();
refreshFormatPanel();
refreshDetails();
}
private void refreshFormatPanel() {
if (cellElement != null) {
formatPane.populateBean(cellElement.getStyle());
} else {
formatPane.populateBean(Style.DEFAULT_STYLE);
}
}
private void refreshPanel() {
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) {
comboBox.removeActionListener(comboBoxActionListener);
comboBox.removeAllItems();
singleComboBox.removeActionListener(comboBoxActionListener);
singleComboBox.removeAllItems();
String[] items = getDefaultComboBoxItems();
for (String item : items) {
comboBox.addItem(item);
singleComboBox.addItem(item);
multipleComboBox.addItem(item);
}
Object comboBoxSelected = getComboBoxSelected();
if (comboBoxSelected != null) {
comboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName());
singleComboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName());
multipleComboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName());
} else {
comboBox.setSelectedIndex(1);
singleComboBox.setSelectedIndex(1);
multipleComboBox.setSelectedIndex(1);
}
currentSelectedIndex = comboBox.getSelectedIndex();
currentSelectedIndex = singleComboBox.getSelectedIndex();
comboBoxActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
cellInsertActions = ActionFactory.createCellInsertAction(ElementCasePane.class, tc);
selectedIndex = comboBox.getSelectedIndex();
comboBox.setPopupVisible(false);
comboBox.repaint();
selectedIndex = singleComboBox.getSelectedIndex();
singleComboBox.setPopupVisible(false);
singleComboBox.repaint();
// comboBox.getSelectedIndex()可能返回-1
if (selectedIndex != -1 && selectedIndex < cellInsertActions.length) {
cellInsertActions[selectedIndex].actionPerformed(e);
}
comboBox.setSelectedIndex(currentSelectedIndex);
singleComboBox.setSelectedIndex(currentSelectedIndex);
}
};
comboBox.addActionListener(comboBoxActionListener);
singleComboBox.addActionListener(comboBoxActionListener);
}
refreshDetails();
}
/**
@ -207,6 +289,10 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
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};
@ -216,9 +302,31 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
initCellElementEditComboBox();
Component[][] components = new Component[][]{
new Component[]{cellLabel, columnRowTextField = initColumnRowTextField()},
new Component[]{insertContentLabel, UIComponentUtils.wrapWithBorderLayoutPane(comboBox)},
new Component[]{insertContentLabel, UIComponentUtils.wrapWithBorderLayoutPane(singleComboBox)},
};
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP);
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},
};
JPanel multiplePanel = TableLayoutHelper.createGapTableLayoutPane(components2, rowSize, new double[]{f}, HGAP, VGAP);
topContentPane.add(MULTIPLE_SELECT, multiplePanel);
return topContentPane;
}
private void prepareScrollBar() {
@ -266,19 +374,23 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
private void initCellElementEditComboBox() {
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (jTemplate == null) {
comboBox = new UIComboBox();
singleComboBox = new UIComboBox();
multipleComboBox = new UIComboBox();
return;
}
final String[] items = getDefaultComboBoxItems();
comboBox = new UIComboBox(items);
singleComboBox = new UIComboBox(items);
multipleComboBox = new UIComboBox(items);
final Object comboBoxSelected = getComboBoxSelected();
if (comboBoxSelected != null) {
comboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName());
singleComboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName());
multipleComboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName());
} else {
comboBox.setSelectedIndex(1);
singleComboBox.setSelectedIndex(1);
multipleComboBox.setSelectedIndex(1);
}
currentSelectedIndex = comboBox.getSelectedIndex();
comboBox.addActionListener(comboBoxActionListener);
currentSelectedIndex = singleComboBox.getSelectedIndex();
singleComboBox.addActionListener(comboBoxActionListener);
}
private String[] getDefaultComboBoxItems() {
@ -324,4 +436,64 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
});
return columnRowTextField;
}
/**
* 创建格式化面板
* @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);
}
}
@Override
public Dimension getPreferredSize() {
if (formatPane == null) {
return super.getPreferredSize();
}
return formatPane.getPreferredSize();
}
};
container.addAttributeChangeListener(new AttributeChangeListener() {
@Override
public void attributeChange() {
isEditing = true;
boolean updateStyle = false;
CellSelection cs = (CellSelection) tc.getSelection();
TemplateElementCase editingElementCase = tc.getEditingElementCase();
Set<TemplateCellElement> 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;
}
}
if (updateStyle) {
// 防止频繁触发保存
fireTargetModified();
}
isEditing = false;
}
});
return container;
}
}

188
designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java

@ -15,10 +15,8 @@ import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.formula.CustomVariableResolver;
import com.fr.design.formula.FormulaFactory;
import com.fr.design.formula.UIFormula;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ibutton.UIHeadGroup;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox;
@ -26,7 +24,6 @@ import com.fr.design.gui.ilable.MultilineLabel;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.style.TextFormatPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
@ -36,6 +33,7 @@ import com.fr.design.sort.celldscolumn.CellDSColumnSortPane;
import com.fr.design.utils.gui.UIComponentUtils;
import com.fr.design.widget.FRWidgetFactory;
import com.fr.general.IOUtils;
import com.fr.grid.selection.CellSelection;
import com.fr.quickeditor.CellQuickEditor;
import com.fr.report.cell.CellElement;
import com.fr.report.cell.TemplateCellElement;
@ -46,12 +44,9 @@ import com.fr.report.cell.cellattr.core.group.SelectCount;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
@ -63,6 +58,8 @@ 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;
import static com.fr.report.cell.cellattr.core.group.FilterTypeEnum.EVEN;
@ -110,6 +107,10 @@ public class CellDSColumnEditor extends CellQuickEditor {
* 数据列高级设置
*/
private DSColumnAdvancedEditorPane cellDSColumnAdvancedPane;
/**
* 多选面板设置
*/
private DSColumnMultipleEditorPane cellDSColumnMultiplePane;
public CellDSColumnEditor() {
super();
@ -144,6 +145,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
protected void refreshDetails() {
cellDSColumnBasicPane.populate();
cellDSColumnAdvancedPane.populate();
cellDSColumnMultiplePane.populate();
this.validate();
}
@ -188,6 +190,8 @@ public class CellDSColumnEditor extends CellQuickEditor {
super.release();
cellDSColumnBasicPane.release();
cellDSColumnAdvancedPane.release();
cellDSColumnMultiplePane.release();
}
/**
@ -352,10 +356,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
* 自定义值显示
*/
private CustomValuePane valuePane;
/**
* 文本格式
*/
private FormatAttrPane formatAttrPane;
/**
* 横向可扩展性
*/
@ -402,7 +402,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
public void update() {
if (cellElement != null) {
valuePane.update(cellElement);
formatAttrPane.update(cellElement);
filterPane.update(cellElement);
//更新单元格扩展属性
updateExtendConfig();
@ -417,7 +416,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
if (cellElement != null) {
this.removeAttributeChangeListener();
valuePane.populate(cellElement);
formatAttrPane.populate(cellElement);
filterPane.populate(cellElement);
CellExpandAttr cellExpandAttr = cellElement.getCellExpandAttr();
if (cellExpandAttr == null) {
@ -529,9 +527,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
//自定义值显示
valuePane = new CustomValuePane();
// 文本格式
formatAttrPane = new FormatAttrPane();
//可扩展性
JPanel extendableDirectionPane = FRGUIPaneFactory.createYBoxEmptyBorderPane();
extendableDirectionPane.add(heCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_ExpandD_Horizontal_Extendable")));
@ -559,7 +554,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
Component[][] components = new Component[][]{
{filterPane},
{valuePane},
{formatAttrPane},
{extendableDirectionPane},
{multiNumPane}
};
@ -1030,43 +1024,165 @@ public class CellDSColumnEditor extends CellQuickEditor {
}
}
public class FormatAttrPane extends AbstractAttrNoScrollPane {
private TextFormatPane formatPane;
}
class DSColumnMultipleEditorPane extends AbstractDSCellEditorPane {
/**
* 数据分组设置
*/
private ResultSetGroupDockingPane groupPane;
/**
* 条件过滤按钮面板
*/
private JPanel conditionPane;
/**
* 条件过滤按钮触发动作
*/
private DSColumnConditionAction condition;
/**
* 条件过滤按钮
*/
private UIButton conditionUIButton;
@Override
protected JPanel createContentPane() {
this.formatPane = new TextFormatPane();
return this.formatPane;
public String getIconPath() {
return Toolkit.i18nText("Fine-Design_Report_Basic");
}
@Override
public Dimension getPreferredSize() {
if (formatPane == null) {
return super.getPreferredSize();
public String title4PopupWindow() {
return Toolkit.i18nText("FR-Designer_Basic");
}
return formatPane.getPreferredSize();
@Override
public void update() {
groupPane.update();
}
protected void initContentPane() {
leftContentPane = createContentPane();
if (leftContentPane != null) {
leftContentPane.setBorder(BorderFactory.createEmptyBorder());
this.add(leftContentPane, BorderLayout.CENTER);
@Override
public void populate() {
this.removeAttributeChangeListener();
if (tc != null) {
CellSelection selection = (CellSelection) tc.getSelection();
Set<TemplateCellElement> cellElements = selection.getAllCellElements(tc.getEditingElementCase());
conditionPane.setVisible(checkSameDSName(cellElements));
condition.setEditingComponent(tc);
cellElements.forEach(cellElement -> groupPane.populate(cellElement));
}
this.addAttributeChangeListener();
}
public void populate(CellElement cellElement) {
if (cellElement != null && formatPane != null) {
formatPane.populateBean(cellElement.getStyle());
/**
* 判断是否属于同一个数据集
*
* @param cellElements
* @return
*/
private boolean checkSameDSName(Set<TemplateCellElement> 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;
}
public void update(CellElement cellElement) {
if (cellElement != null && formatPane != null) {
cellElement.setStyle(formatPane.update(cellElement.getStyle()));
@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<TemplateCellElement> 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;
}
@Override

50
designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellFormulaQuickEditor.java

@ -8,17 +8,13 @@ import com.fr.design.actions.insert.cell.FormulaCellAction;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.formula.FormulaFactory;
import com.fr.design.formula.UIFormula;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.style.TextFormatPane;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase;
import com.fr.general.IOUtils;
import com.fr.grid.selection.CellSelection;
import com.fr.quickeditor.CellQuickEditor;
import com.fr.report.ReportHelper;
@ -50,7 +46,6 @@ import java.util.Arrays;
public class CellFormulaQuickEditor extends CellQuickEditor {
//文本域
private UITextField formulaTextField;
private TextFormatPane formatPane;
//编辑状态
private boolean isEditing = false;
@ -144,57 +139,16 @@ public class CellFormulaQuickEditor extends CellQuickEditor {
Component[][] componentLines = new Component[][] {
new Component[]{EMPTY_LABEL, content},
new Component[]{createFormatPane(), null},
};
double[] rowSize = new double[componentLines.length];
Arrays.fill(rowSize, TableLayout.PREFERRED);
double[] columnSize = new double[] {TableLayout.PREFERRED, TableLayout.FILL };
return TableLayoutHelper.createGapTableLayoutPane(new Component[][]{
new Component[]{EMPTY_LABEL, content},
new Component[]{createFormatPane(), null},
},
rowSize, columnSize, HGAP, VGAP);
}
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);
}
}
};
container.addAttributeChangeListener(new AttributeChangeListener() {
@Override
public void attributeChange() {
isEditing = true;
CellSelection cs1 = (CellSelection) tc.getSelection();
cellElement = tc.getEditingElementCase().getTemplateCellElement(cs1.getColumn(), cs1.getRow());
if (cellElement == null) {
CellSelection cs = (CellSelection) tc.getSelection();
cellElement = DefaultThemedTemplateCellElementCase.createInstance(cs.getColumn(), cs.getRow());
tc.getEditingElementCase().addCellElement(cellElement, false);
}
cellElement.setStyle(formatPane.update(cellElement.getStyle()));
fireTargetModified();
isEditing = false;
}
});
return container;
}
@Override
public Object getComboBoxSelected() {
@ -257,10 +211,6 @@ public class CellFormulaQuickEditor extends CellQuickEditor {
showText(str);
formulaTextField.setEditable(tc.isSelectedOneCell());
if (cellElement != null) {
Style style = cellElement.getStyle();
formatPane.populateBean(style);
}
}
/**

52
designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellStringQuickEditor.java

@ -4,10 +4,7 @@ import com.fr.base.BaseFormula;
import com.fr.base.Style;
import com.fr.base.TextFormat;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.gui.itextarea.UITextArea;
import com.fr.design.gui.style.TextFormatPane;
import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase;
import com.fr.grid.GridKeyListener;
import com.fr.grid.selection.CellSelection;
@ -16,7 +13,6 @@ import com.fr.report.ReportHelper;
import com.fr.stable.ColumnRow;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.event.DocumentEvent;
@ -31,7 +27,6 @@ import java.awt.event.KeyEvent;
public class CellStringQuickEditor extends CellQuickEditor {
//文本域 直接可以自适应大小
private UITextArea stringTextArea;
private TextFormatPane formatPane;
//编辑状态
private boolean isEditing = false;
@ -95,51 +90,9 @@ public class CellStringQuickEditor extends CellQuickEditor {
});
content.add(stringTextArea, BorderLayout.NORTH);
content.add(createFormatPane(), BorderLayout.CENTER);
return content;
}
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);
}
}
};
container.addAttributeChangeListener(new AttributeChangeListener() {
@Override
public void attributeChange() {
isEditing = true;
CellSelection cs1 = (CellSelection) tc.getSelection();
cellElement = tc.getEditingElementCase().getTemplateCellElement(cs1.getColumn(), cs1.getRow());
if (cellElement == null) {
CellSelection cs = (CellSelection) tc.getSelection();
cellElement = DefaultThemedTemplateCellElementCase.createInstance(cs.getColumn(), cs.getRow());
tc.getEditingElementCase().addCellElement(cellElement, false);
}
cellElement.setStyle(formatPane.update(cellElement.getStyle()));
fireTargetModified();
isEditing = false;
}
});
return container;
}
@Override
public boolean isScrollAll() {
return true;
@ -200,11 +153,6 @@ public class CellStringQuickEditor extends CellQuickEditor {
}
showText(str);
stringTextArea.setEditable(tc.isSelectedOneCell());
if (cellElement != null) {
Style style = cellElement.getStyle();
formatPane.populateBean(style);
}
}
/**

Loading…
Cancel
Save