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) { public void updateCellElementState(boolean isSelectedOneCell) {
PropertyItem cellElement = propertyItemMap.get(KEY_CELL_ELEMENT); PropertyItem cellElement = propertyItemMap.get(KEY_CELL_ELEMENT);
if (isSelectedOneCell) {
enableCellElementPane(cellElement); enableCellElementPane(cellElement);
} else { // 如果选中多个单元格,禁用单元格元素 tab
disableCellElementPane(cellElement);
refreshRightPane();
}
} }
// 禁用单元格元素tab // 禁用单元格元素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.elementcase.TemplateElementCase;
import com.fr.report.stable.ReportConstants; import com.fr.report.stable.ReportConstants;
import java.awt.Rectangle;
/** /**
* TODO ALEX_SEP 这个类与AbstractCellAction有什么关系? * TODO ALEX_SEP 这个类与AbstractCellAction有什么关系?
* *
@ -45,11 +47,13 @@ public abstract class AbstractCellElementAction extends CellSelectionAction {
dialog.addDialogActionListener(new DialogActionAdapter() { dialog.addDialogActionListener(new DialogActionAdapter() {
@Override @Override
public void doOk() { 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 j = 0; j < cellRectangle.height; j++) {
for (int i = 0; i < finalCS.getColumnSpan(); i++) { for (int i = 0; i < cellRectangle.width; i++) {
int column = i + finalCS.getColumn(); int column = i + cellRectangle.x;
int row = j + finalCS.getRow(); int row = j + cellRectangle.y;
TemplateCellElement editCellElement = tplEC.getTemplateCellElement(column, row); TemplateCellElement editCellElement = tplEC.getTemplateCellElement(column, row);
if (editCellElement == null) { if (editCellElement == null) {
editCellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row); editCellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row);
@ -64,15 +68,20 @@ public abstract class AbstractCellElementAction extends CellSelectionAction {
if (isNeedShinkToFit()) { if (isNeedShinkToFit()) {
// shink to fit.(如果value是String) // shink to fit.(如果value是String)
Object editElementValue = editCellElement.getValue(); Object editElementValue = editCellElement.getValue();
if (editElementValue != null && (editElementValue instanceof String || editElementValue instanceof Number)) { if (checkValueType(editElementValue)) {
// TODO ALEX_SEP 暂时用FIT_DEFAULT替代,不取reportsetting里面的设置,因为也不知道是应该放在report里面还是elementcase里面 // TODO ALEX_SEP 暂时用FIT_DEFAULT替代,不取reportsetting里面的设置,因为也不知道是应该放在report里面还是elementcase里面
GridUtils.shrinkToFit(ReportConstants.AUTO_SHRINK_TO_FIT_DEFAULT, tplEC, editCellElement); GridUtils.shrinkToFit(ReportConstants.AUTO_SHRINK_TO_FIT_DEFAULT, tplEC, editCellElement);
} }
} }
} }
} }
}
ePane.fireTargetModified(); ePane.fireTargetModified();
} }
private boolean checkValueType(Object editElementValue) {
return editElementValue instanceof String || editElementValue instanceof Number;
}
}); });
//控件设置记住dlg,提交入库智能添加单元格后可以show出来 //控件设置记住dlg,提交入库智能添加单元格后可以show出来
DesignerContext.setReportWritePane(dialog); 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.CustomVariableResolver;
import com.fr.design.formula.FormulaFactory; import com.fr.design.formula.FormulaFactory;
import com.fr.design.formula.UIFormula; 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.ibutton.UIButton;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox; 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.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.itextfield.UITextField; 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.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
@ -52,7 +50,6 @@ public class DSColumnAdvancedPane extends BasicPane {
private SortPane sortPane; private SortPane sortPane;
private SelectCountPane selectCountPane; private SelectCountPane selectCountPane;
private ValuePane valuePane; private ValuePane valuePane;
private FormatAttrPane formatAttrPane;
private UICheckBox horizontalExtendableCheckBox; private UICheckBox horizontalExtendableCheckBox;
private UICheckBox verticalExtendableCheckBox; private UICheckBox verticalExtendableCheckBox;
private UICheckBox useMultiplyNumCheckBox; private UICheckBox useMultiplyNumCheckBox;
@ -89,10 +86,6 @@ public class DSColumnAdvancedPane extends BasicPane {
valuePane = new ValuePane(); valuePane = new ValuePane();
valuePane.setBorder(UITitledBorder.createBorderWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Bind_Column_Custom_Data_Appearance"))); 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; JPanel extendablePane = null;
if (setting > DSColumnPane.SETTING_DSRELATED) { if (setting > DSColumnPane.SETTING_DSRELATED) {
// extendableDirectionPane // extendableDirectionPane
@ -130,7 +123,6 @@ public class DSColumnAdvancedPane extends BasicPane {
{sortPane}, {sortPane},
{selectCountPane}, {selectCountPane},
{valuePane}, {valuePane},
{titleBorderedFormatPane},
{extendablePane}, {extendablePane},
{multiNumPane} {multiNumPane}
}; };
@ -138,7 +130,6 @@ public class DSColumnAdvancedPane extends BasicPane {
components = new Component[][]{ components = new Component[][]{
{sortPane}, {sortPane},
{valuePane}, {valuePane},
{titleBorderedFormatPane}
}; };
} }
@ -161,7 +152,6 @@ public class DSColumnAdvancedPane extends BasicPane {
sortPane.populateBean(cellElement); sortPane.populateBean(cellElement);
valuePane.populate(cellElement); valuePane.populate(cellElement);
formatAttrPane.populate(cellElement);
if (selectCountPane != null) { if (selectCountPane != null) {
selectCountPane.populate(cellElement); selectCountPane.populate(cellElement);
@ -211,7 +201,6 @@ public class DSColumnAdvancedPane extends BasicPane {
sortPane.updateBean(cellElement); sortPane.updateBean(cellElement);
valuePane.update(cellElement); valuePane.update(cellElement);
formatAttrPane.update(cellElement);
if (selectCountPane != null) { if (selectCountPane != null) {
selectCountPane.update(cellElement); 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() { private void checkButtonEnabled() {
if (useMultiplyNumCheckBox.isSelected()) { if (useMultiplyNumCheckBox.isSelected()) {
multiNumSpinner.setEnabled(true); 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.Dimension;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
import java.util.Set;
/** /**
* 这个pane是选中数据列后在上方QuickRegion处显示的pane * 这个pane是选中数据列后在上方QuickRegion处显示的pane
@ -167,6 +168,11 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane {
@Override @Override
public void update() { public void update() {
updateCellElement(cellElement);
}
private void updateCellElement(TemplateCellElement cellElement) {
if (isNPE(cellElement)) { if (isNPE(cellElement)) {
return; return;
} }
@ -242,4 +248,9 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane {
groupComboBox.removeItemListener(this.listener); groupComboBox.removeItemListener(this.listener);
functionComboBox.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; 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.data.DesignTableDataManager;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.report.cell.CellElement; import com.fr.report.cell.CellElement;
import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.TemplateCellElement;
import com.fr.report.cell.cellattr.core.group.CustomGrouper; 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.FunctionGrouper;
import com.fr.report.cell.cellattr.core.group.RecordGrouper; 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 //august:1:31 我又改回以前的样子了 neil那个方法还是有bug 9922
public abstract class ResultSetGroupPane extends JPanel { public abstract class ResultSetGroupPane extends JPanel {
@ -38,6 +37,14 @@ public abstract class ResultSetGroupPane extends JPanel {
abstract void update(); abstract void update();
/**
* 批量更新数据设置
*
* @param cellElements 需要更新的单元格
*/
public void update(Set<TemplateCellElement> cellElements) {
}
abstract void setRecordGrouper(RecordGrouper recordGrouper); abstract void setRecordGrouper(RecordGrouper recordGrouper);
void fireTargetChanged() { 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.design.selection.QuickEditor;
import com.fr.grid.GridUtils; import com.fr.grid.GridUtils;
import com.fr.report.cell.CellElement; import com.fr.report.cell.CellElement;
import com.fr.report.cell.DefaultTemplateCellElement;
import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.TemplateCellElement;
import com.fr.report.cell.cellattr.CellGUIAttr; import com.fr.report.cell.cellattr.CellGUIAttr;
import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.elementcase.TemplateElementCase;
@ -46,8 +47,10 @@ import javax.swing.JOptionPane;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set;
/** /**
* the cell selection (columnrow)是所选单元格中左上角的位置 这个数据结构就是一个Rectangle * the cell selection (columnrow)是所选单元格中左上角的位置 这个数据结构就是一个Rectangle
@ -739,16 +742,77 @@ public class CellSelection extends Selection {
TemplateElementCase tplEC = ePane.getEditingElementCase(); TemplateElementCase tplEC = ePane.getEditingElementCase();
TemplateCellElement cellElement = tplEC.getTemplateCellElement(column, row); TemplateCellElement cellElement = tplEC.getTemplateCellElement(column, row);
Object value = null; Object value = null;
boolean b = ePane.isSelectedOneCell(); if (cellElement != null) {
if (cellElement != null && b) {
value = cellElement.getValue(); 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,没必要那个样子 //之前是少了个bigInteger,刚kunsnat又发现少了个bigDecimal,数字类型的都用stringEditor,没必要那个样子
QuickEditor editor = ActionFactory.getCellEditor((value instanceof Number) ? (Number.class) : (value.getClass())); QuickEditor editor = ActionFactory.getCellEditor((value instanceof Number) ? (Number.class) : (value.getClass()));
return editor; 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 @Override
public void populatePropertyPane(ElementCasePane ePane) { public void populatePropertyPane(ElementCasePane ePane) {
CellElementPropertyPane.getInstance().reInit(ePane); CellElementPropertyPane.getInstance().reInit(ePane);

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

@ -1,13 +1,17 @@
package com.fr.quickeditor; package com.fr.quickeditor;
import com.fr.base.GraphHelper; import com.fr.base.GraphHelper;
import com.fr.base.Style;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.actions.core.ActionFactory; import com.fr.design.actions.core.ActionFactory;
import com.fr.design.file.HistoryTemplateListCache; 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.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.iscrollbar.UIScrollBar; import com.fr.design.gui.iscrollbar.UIScrollBar;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.style.TextFormatPane;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; 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.grid.selection.CellSelection;
import com.fr.quickeditor.cellquick.layout.CellElementBarLayout; import com.fr.quickeditor.cellquick.layout.CellElementBarLayout;
import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.TemplateCellElement;
import com.fr.report.elementcase.TemplateElementCase;
import com.fr.stable.ColumnRow; import com.fr.stable.ColumnRow;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
@ -31,6 +36,7 @@ import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JScrollBar; import javax.swing.JScrollBar;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Component; import java.awt.Component;
import java.awt.Container; import java.awt.Container;
import java.awt.Dimension; import java.awt.Dimension;
@ -41,6 +47,8 @@ import java.awt.event.AdjustmentListener;
import java.awt.event.MouseWheelEvent; import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener; import java.awt.event.MouseWheelListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Objects;
import java.util.Set;
/** /**
* @author zhou, yaoh.wu * @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 CONTENT_PANE_WIDTH_GAP = 3;
private static final int MOUSE_WHEEL_SPEED = 5; private static final int MOUSE_WHEEL_SPEED = 5;
private static final int SCROLLBAR_WIDTH = 7; private static final int SCROLLBAR_WIDTH = 7;
/**
* 区分单选多选单元格生成相应设置面板
*/
private final String SINGLE_SELECT = "singleSelect";
private final String MULTIPLE_SELECT = "multipleSelect";
private int maxHeight = 280; private int maxHeight = 280;
private static final int TITLE_HEIGHT = 50; private static final int TITLE_HEIGHT = 50;
@ -67,11 +82,22 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
*/ */
protected UITextField columnRowTextField; protected UITextField columnRowTextField;
protected TemplateCellElement cellElement; protected TemplateCellElement cellElement;
private TextFormatPane formatPane;
private final JPanel topContentContainer;
private final JComponent centerBodyContainer;
private CardLayout topCardLayout;
/**
* 不同单元格元素产生的面板
*/
private CardLayout centerCardLayout;
// 占位label // 占位label
protected final UILabel EMPTY_LABEL = new UILabel(); protected final UILabel EMPTY_LABEL = new UILabel();
private UIComboBox comboBox; private UIComboBox singleComboBox;
private UIComboBox multipleComboBox;
private UpdateAction[] cellInsertActions; private UpdateAction[] cellInsertActions;
private int selectedIndex; private int selectedIndex;
private int currentSelectedIndex; private int currentSelectedIndex;
@ -84,16 +110,19 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
double[] columnSize = {p, f}; double[] columnSize = {p, f};
JComponent centerBody = createCenterBody(); JPanel formatContainerPanel = createFormatPane();
JPanel topContent = initTopContent(); topContentContainer = initTopContent();
centerBodyContainer = createAllCenterBody();
if (isScrollAll()) { if (isScrollAll()) {
double[] scrollAllRowSize = {p, p}; double[] scrollAllRowSize = {p, p, p};
prepareScrollBar(); prepareScrollBar();
topContent.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 0, this.getBackground())); topContentContainer.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 0, this.getBackground()));
centerBody.setBorder(BorderFactory.createMatteBorder(0, 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[][]{ Component[][] components = new Component[][]{
new Component[]{topContent, null}, new Component[]{topContentContainer, null},
new Component[]{centerBody, null} new Component[]{formatContainerPanel, null},
new Component[]{centerBodyContainer, null}
}; };
leftContentPane = TableLayoutHelper.createGapTableLayoutPane(components, scrollAllRowSize, columnSize, HGAP, VGAP); leftContentPane = TableLayoutHelper.createGapTableLayoutPane(components, scrollAllRowSize, columnSize, HGAP, VGAP);
this.setLayout(new CellElementBarLayout(leftContentPane) { this.setLayout(new CellElementBarLayout(leftContentPane) {
@ -122,12 +151,14 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
this.add(scrollBar); this.add(scrollBar);
this.add(leftContentPane); this.add(leftContentPane);
} else { } else {
double[] scrollContentRowSize = {p, f}; double[] scrollContentRowSize = {p, p, f};
topContent.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 10, this.getBackground())); topContentContainer.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 10, this.getBackground()));
centerBody.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 0, 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[][]{ Component[][] components = new Component[][]{
new Component[]{topContent, null}, new Component[]{topContentContainer, null},
new Component[]{centerBody, null} new Component[]{formatContainerPanel, null},
new Component[]{centerBodyContainer, null}
}; };
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
this.add(TableLayoutHelper.createGapTableLayoutPane(components, scrollContentRowSize, columnSize, HGAP, VGAP), BorderLayout.CENTER); 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(); 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 @Override
protected void refresh() { 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(); CellSelection cs = (CellSelection) tc.getSelection();
ColumnRow columnRow = ColumnRow.valueOf(cs.getColumn(), cs.getRow()); 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()); columnRowTextField.setText(columnRow.toString());
cellElement = tc.getEditingElementCase().getTemplateCellElement(cs.getColumn(), cs.getRow()); cellElement = tc.getEditingElementCase().getTemplateCellElement(cs.getColumn(), cs.getRow());
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (jTemplate != null) { if (jTemplate != null) {
comboBox.removeActionListener(comboBoxActionListener); singleComboBox.removeActionListener(comboBoxActionListener);
comboBox.removeAllItems(); singleComboBox.removeAllItems();
String[] items = getDefaultComboBoxItems(); String[] items = getDefaultComboBoxItems();
for (String item : items) { for (String item : items) {
comboBox.addItem(item); singleComboBox.addItem(item);
multipleComboBox.addItem(item);
} }
Object comboBoxSelected = getComboBoxSelected(); Object comboBoxSelected = getComboBoxSelected();
if (comboBoxSelected != null) { if (comboBoxSelected != null) {
comboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName()); singleComboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName());
multipleComboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName());
} else { } else {
comboBox.setSelectedIndex(1); singleComboBox.setSelectedIndex(1);
multipleComboBox.setSelectedIndex(1);
} }
currentSelectedIndex = comboBox.getSelectedIndex(); currentSelectedIndex = singleComboBox.getSelectedIndex();
comboBoxActionListener = new ActionListener() { comboBoxActionListener = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
cellInsertActions = ActionFactory.createCellInsertAction(ElementCasePane.class, tc); cellInsertActions = ActionFactory.createCellInsertAction(ElementCasePane.class, tc);
selectedIndex = comboBox.getSelectedIndex(); selectedIndex = singleComboBox.getSelectedIndex();
comboBox.setPopupVisible(false); singleComboBox.setPopupVisible(false);
comboBox.repaint(); singleComboBox.repaint();
// comboBox.getSelectedIndex()可能返回-1 // comboBox.getSelectedIndex()可能返回-1
if (selectedIndex != -1 && selectedIndex < cellInsertActions.length) { if (selectedIndex != -1 && selectedIndex < cellInsertActions.length) {
cellInsertActions[selectedIndex].actionPerformed(e); 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() { private JPanel initTopContent() {
topCardLayout = new CardLayout();
JPanel topContentPane = new JPanel(topCardLayout);
// 单选面板
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
double[] columnSize = {GraphHelper.getWidth(Toolkit.i18nText("Fine-Design_Report_Insert_Cell_Element")), f}; 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(); initCellElementEditComboBox();
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{cellLabel, columnRowTextField = initColumnRowTextField()}, 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() { private void prepareScrollBar() {
@ -266,19 +374,23 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
private void initCellElementEditComboBox() { private void initCellElementEditComboBox() {
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (jTemplate == null) { if (jTemplate == null) {
comboBox = new UIComboBox(); singleComboBox = new UIComboBox();
multipleComboBox = new UIComboBox();
return; return;
} }
final String[] items = getDefaultComboBoxItems(); final String[] items = getDefaultComboBoxItems();
comboBox = new UIComboBox(items); singleComboBox = new UIComboBox(items);
multipleComboBox = new UIComboBox(items);
final Object comboBoxSelected = getComboBoxSelected(); final Object comboBoxSelected = getComboBoxSelected();
if (comboBoxSelected != null) { if (comboBoxSelected != null) {
comboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName()); singleComboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName());
multipleComboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName());
} else { } else {
comboBox.setSelectedIndex(1); singleComboBox.setSelectedIndex(1);
multipleComboBox.setSelectedIndex(1);
} }
currentSelectedIndex = comboBox.getSelectedIndex(); currentSelectedIndex = singleComboBox.getSelectedIndex();
comboBox.addActionListener(comboBoxActionListener); singleComboBox.addActionListener(comboBoxActionListener);
} }
private String[] getDefaultComboBoxItems() { private String[] getDefaultComboBoxItems() {
@ -324,4 +436,64 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
}); });
return columnRowTextField; 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.CustomVariableResolver;
import com.fr.design.formula.FormulaFactory; import com.fr.design.formula.FormulaFactory;
import com.fr.design.formula.UIFormula; 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.frpane.AttributeChangeListener;
import com.fr.design.gui.ibutton.UIButton; 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.ibutton.UIHeadGroup;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox; 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.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.style.TextFormatPane;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; 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.utils.gui.UIComponentUtils;
import com.fr.design.widget.FRWidgetFactory; import com.fr.design.widget.FRWidgetFactory;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.grid.selection.CellSelection;
import com.fr.quickeditor.CellQuickEditor; import com.fr.quickeditor.CellQuickEditor;
import com.fr.report.cell.CellElement; import com.fr.report.cell.CellElement;
import com.fr.report.cell.TemplateCellElement; 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 com.fr.stable.StringUtils;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.CardLayout; import java.awt.CardLayout;
import java.awt.Color; import java.awt.Color;
@ -63,6 +58,8 @@ import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; 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.BOTTOM;
import static com.fr.report.cell.cellattr.core.group.FilterTypeEnum.EVEN; import static com.fr.report.cell.cellattr.core.group.FilterTypeEnum.EVEN;
@ -110,6 +107,10 @@ public class CellDSColumnEditor extends CellQuickEditor {
* 数据列高级设置 * 数据列高级设置
*/ */
private DSColumnAdvancedEditorPane cellDSColumnAdvancedPane; private DSColumnAdvancedEditorPane cellDSColumnAdvancedPane;
/**
* 多选面板设置
*/
private DSColumnMultipleEditorPane cellDSColumnMultiplePane;
public CellDSColumnEditor() { public CellDSColumnEditor() {
super(); super();
@ -144,6 +145,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
protected void refreshDetails() { protected void refreshDetails() {
cellDSColumnBasicPane.populate(); cellDSColumnBasicPane.populate();
cellDSColumnAdvancedPane.populate(); cellDSColumnAdvancedPane.populate();
cellDSColumnMultiplePane.populate();
this.validate(); this.validate();
} }
@ -188,6 +190,8 @@ public class CellDSColumnEditor extends CellQuickEditor {
super.release(); super.release();
cellDSColumnBasicPane.release(); cellDSColumnBasicPane.release();
cellDSColumnAdvancedPane.release(); cellDSColumnAdvancedPane.release();
cellDSColumnMultiplePane.release();
} }
/** /**
@ -352,10 +356,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
* 自定义值显示 * 自定义值显示
*/ */
private CustomValuePane valuePane; private CustomValuePane valuePane;
/**
* 文本格式
*/
private FormatAttrPane formatAttrPane;
/** /**
* 横向可扩展性 * 横向可扩展性
*/ */
@ -402,7 +402,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
public void update() { public void update() {
if (cellElement != null) { if (cellElement != null) {
valuePane.update(cellElement); valuePane.update(cellElement);
formatAttrPane.update(cellElement);
filterPane.update(cellElement); filterPane.update(cellElement);
//更新单元格扩展属性 //更新单元格扩展属性
updateExtendConfig(); updateExtendConfig();
@ -417,7 +416,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
if (cellElement != null) { if (cellElement != null) {
this.removeAttributeChangeListener(); this.removeAttributeChangeListener();
valuePane.populate(cellElement); valuePane.populate(cellElement);
formatAttrPane.populate(cellElement);
filterPane.populate(cellElement); filterPane.populate(cellElement);
CellExpandAttr cellExpandAttr = cellElement.getCellExpandAttr(); CellExpandAttr cellExpandAttr = cellElement.getCellExpandAttr();
if (cellExpandAttr == null) { if (cellExpandAttr == null) {
@ -529,9 +527,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
//自定义值显示 //自定义值显示
valuePane = new CustomValuePane(); valuePane = new CustomValuePane();
// 文本格式
formatAttrPane = new FormatAttrPane();
//可扩展性 //可扩展性
JPanel extendableDirectionPane = FRGUIPaneFactory.createYBoxEmptyBorderPane(); JPanel extendableDirectionPane = FRGUIPaneFactory.createYBoxEmptyBorderPane();
extendableDirectionPane.add(heCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_ExpandD_Horizontal_Extendable"))); 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[][]{ Component[][] components = new Component[][]{
{filterPane}, {filterPane},
{valuePane}, {valuePane},
{formatAttrPane},
{extendableDirectionPane}, {extendableDirectionPane},
{multiNumPane} {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 @Override
protected JPanel createContentPane() { public String getIconPath() {
this.formatPane = new TextFormatPane(); return Toolkit.i18nText("Fine-Design_Report_Basic");
return this.formatPane;
} }
@Override @Override
public Dimension getPreferredSize() { public String title4PopupWindow() {
if (formatPane == null) { return Toolkit.i18nText("FR-Designer_Basic");
return super.getPreferredSize();
} }
return formatPane.getPreferredSize();
@Override
public void update() {
groupPane.update();
} }
protected void initContentPane() { @Override
leftContentPane = createContentPane(); public void populate() {
if (leftContentPane != null) { this.removeAttributeChangeListener();
leftContentPane.setBorder(BorderFactory.createEmptyBorder()); if (tc != null) {
this.add(leftContentPane, BorderLayout.CENTER); 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) { @Override
if (cellElement != null && formatPane != null) { protected void release() {
cellElement.setStyle(formatPane.update(cellElement.getStyle())); 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 @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.dialog.DialogActionAdapter;
import com.fr.design.formula.FormulaFactory; import com.fr.design.formula.FormulaFactory;
import com.fr.design.formula.UIFormula; 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.UIButton;
import com.fr.design.gui.itextfield.UITextField; 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.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.CellSelection;
import com.fr.quickeditor.CellQuickEditor; import com.fr.quickeditor.CellQuickEditor;
import com.fr.report.ReportHelper; import com.fr.report.ReportHelper;
@ -50,7 +46,6 @@ import java.util.Arrays;
public class CellFormulaQuickEditor extends CellQuickEditor { public class CellFormulaQuickEditor extends CellQuickEditor {
//文本域 //文本域
private UITextField formulaTextField; private UITextField formulaTextField;
private TextFormatPane formatPane;
//编辑状态 //编辑状态
private boolean isEditing = false; private boolean isEditing = false;
@ -144,57 +139,16 @@ public class CellFormulaQuickEditor extends CellQuickEditor {
Component[][] componentLines = new Component[][] { Component[][] componentLines = new Component[][] {
new Component[]{EMPTY_LABEL, content}, new Component[]{EMPTY_LABEL, content},
new Component[]{createFormatPane(), null},
}; };
double[] rowSize = new double[componentLines.length]; double[] rowSize = new double[componentLines.length];
Arrays.fill(rowSize, TableLayout.PREFERRED); Arrays.fill(rowSize, TableLayout.PREFERRED);
double[] columnSize = new double[] {TableLayout.PREFERRED, TableLayout.FILL }; double[] columnSize = new double[] {TableLayout.PREFERRED, TableLayout.FILL };
return TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ return TableLayoutHelper.createGapTableLayoutPane(new Component[][]{
new Component[]{EMPTY_LABEL, content}, new Component[]{EMPTY_LABEL, content},
new Component[]{createFormatPane(), null},
}, },
rowSize, columnSize, HGAP, VGAP); 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 @Override
public Object getComboBoxSelected() { public Object getComboBoxSelected() {
@ -257,10 +211,6 @@ public class CellFormulaQuickEditor extends CellQuickEditor {
showText(str); showText(str);
formulaTextField.setEditable(tc.isSelectedOneCell()); 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.Style;
import com.fr.base.TextFormat; import com.fr.base.TextFormat;
import com.fr.design.designer.IntervalConstants; 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.itextarea.UITextArea;
import com.fr.design.gui.style.TextFormatPane;
import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase;
import com.fr.grid.GridKeyListener; import com.fr.grid.GridKeyListener;
import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.CellSelection;
@ -16,7 +13,6 @@ import com.fr.report.ReportHelper;
import com.fr.stable.ColumnRow; import com.fr.stable.ColumnRow;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
@ -31,7 +27,6 @@ import java.awt.event.KeyEvent;
public class CellStringQuickEditor extends CellQuickEditor { public class CellStringQuickEditor extends CellQuickEditor {
//文本域 直接可以自适应大小 //文本域 直接可以自适应大小
private UITextArea stringTextArea; private UITextArea stringTextArea;
private TextFormatPane formatPane;
//编辑状态 //编辑状态
private boolean isEditing = false; private boolean isEditing = false;
@ -95,51 +90,9 @@ public class CellStringQuickEditor extends CellQuickEditor {
}); });
content.add(stringTextArea, BorderLayout.NORTH); content.add(stringTextArea, BorderLayout.NORTH);
content.add(createFormatPane(), BorderLayout.CENTER);
return content; 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 @Override
public boolean isScrollAll() { public boolean isScrollAll() {
return true; return true;
@ -200,11 +153,6 @@ public class CellStringQuickEditor extends CellQuickEditor {
} }
showText(str); showText(str);
stringTextArea.setEditable(tc.isSelectedOneCell()); stringTextArea.setEditable(tc.isSelectedOneCell());
if (cellElement != null) {
Style style = cellElement.getStyle();
formatPane.populateBean(style);
}
} }
/** /**

Loading…
Cancel
Save