Browse Source

REPORT-62440 表头排序内置

feature/x
Henry.Wang 3 years ago
parent
commit
dcc2606106
  1. 95
      designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java
  2. 13
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java
  3. 18
      designer-realize/src/main/java/com/fr/design/sort/celldscolumn/CellDSColumnSortGroupPane.java
  4. 9
      designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortGroupPane.java
  5. 30
      designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortPane.java
  6. 165
      designer-realize/src/main/java/com/fr/design/sort/common/SortColumnRowPane.java
  7. 1
      designer-realize/src/main/java/com/fr/design/sort/common/SortUIExpandablePane.java
  8. 6
      designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequencePane.java
  9. 6
      designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequenceSortExpressionPane.java
  10. 4
      designer-realize/src/main/java/com/fr/design/sort/expressionpane/FormulaSortExpressionPane.java
  11. 144
      designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java

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

@ -13,6 +13,7 @@ import com.fr.design.formula.UIFormula;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.itextfield.UITextField;
@ -20,6 +21,7 @@ import com.fr.design.gui.style.TextFormatPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.sort.celldscolumn.CellDSColumnSortPane;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.report.cell.CellElement;
import com.fr.report.cell.TemplateCellElement;
@ -47,14 +49,26 @@ public class DSColumnAdvancedPane extends BasicPane {
private UICheckBox verticalExtendableCheckBox;
private UICheckBox useMultiplyNumCheckBox;
private UISpinner multiNumSpinner;
private JPanel contentPane;
public DSColumnAdvancedPane() {
this(DSColumnPane.SETTING_ALL);
}
public DSColumnAdvancedPane(int setting) {
this.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
this.setLayout(FRGUIPaneFactory.createBorderLayout());
initContentPane(setting);
initScrollPane();
}
private void initScrollPane() {
ScrollPane scrollPane = new ScrollPane(contentPane);
this.add(scrollPane);
}
private void initContentPane(int setting) {
contentPane = new JPanel();
contentPane.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
contentPane.setLayout(FRGUIPaneFactory.createBorderLayout());
sortPane = new SortPane();
sortPane.setBorder(UITitledBorder.createBorderWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Sort_Sort_Order")));
@ -124,7 +138,7 @@ public class DSColumnAdvancedPane extends BasicPane {
TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED};
double[] columnSize = {TableLayout.FILL};
this.add(TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize), BorderLayout.CENTER);
contentPane.add(TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize), BorderLayout.CENTER);
}
@Override
@ -137,7 +151,7 @@ public class DSColumnAdvancedPane extends BasicPane {
return;
}
sortPane.populate(cellElement);
sortPane.populateBean(cellElement);
valuePane.populate(cellElement);
formatAttrPane.populate(cellElement);
@ -187,7 +201,7 @@ public class DSColumnAdvancedPane extends BasicPane {
return;
}
sortPane.update(cellElement);
sortPane.updateBean(cellElement);
valuePane.update(cellElement);
formatAttrPane.update(cellElement);
@ -223,66 +237,25 @@ public class DSColumnAdvancedPane extends BasicPane {
}
}
private static class SortPane extends SortFormulaPane {
private CellElement cellElement;
private static class ScrollPane extends UIScrollPane {
ScrollPane(Component component) {
super(component);
this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
}
@Override
public void formulaAction() {
if (cellElement == null) {
return;
}
Object value = cellElement.getValue();
if (value == null || !(value instanceof DSColumn)) {
return;
}
String[] displayNames = DesignTableDataManager.getSelectedColumnNames(
DesignTableDataManager.getEditingTableDataSource(), ((DSColumn) value).getDSName());
showFormulaDialog(displayNames);
public Dimension getPreferredSize() {
return new Dimension(DSColumnPane.DEFAULT_DIMENSION.width - 20, DSColumnPane.DEFAULT_DIMENSION.height - 100);
}
}
void populate(CellElement cellElement) {
if (cellElement == null) {
return;
}
this.cellElement = cellElement;
Object value = cellElement.getValue();
if (value == null || !(value instanceof DSColumn)) {
return;
}
DSColumn dSColumn = (DSColumn) value;
int sort = dSColumn.getOrder();
this.sortOrderComboBox.setSortOrder(new SortOrder(sort));
String sortFormula = dSColumn.getSortFormula();
sortFormulaTextField.setText(sortFormula);
private static class SortPane extends CellDSColumnSortPane {
SortPane() {
this.setLayout(new FlowLayout(FlowLayout.LEFT));
}
public void update(CellElement cellElement) {
if (cellElement == null) {
return;
}
Object value = cellElement.getValue();
if (value == null || !(value instanceof DSColumn)) {
return;
}
DSColumn dSColumn = (DSColumn) (cellElement.getValue());
dSColumn.setOrder(this.sortOrderComboBox.getSortOrder().getOrder());
//lance:sort formula
String sText = null;
if (!(sortFormulaTextField.getText() == null || sortFormulaTextField.getText().trim().equals("") || sortFormulaTextField.getText().trim().equals("$$$"))) {
sText = new String(sortFormulaTextField.getText());
}
if (!(sText == null || sText.length() < 1)) {
dSColumn.setSortFormula(sText);
} else {
dSColumn.setSortFormula(null);
}
protected boolean needSortHeaderPane() {
return false;
}
}
@ -540,12 +513,12 @@ public class DSColumnAdvancedPane extends BasicPane {
public static class FormatAttrPane extends TextFormatPane {
protected void initLayout() {
JPanel settingPane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(0, 4, 0);
JPanel settingPane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(0, 4, 0);
settingPane.add(typeComboBox);
settingPane.add(textField);
settingPane.add(roundingBox);
addComponents(4, new JComponent[] { settingPane, previewLabel});
addComponents(4, new JComponent[]{settingPane, previewLabel});
}
@Override

13
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java

@ -4,7 +4,6 @@ import com.fr.design.constants.LayoutConstants;
import com.fr.design.constants.UIConstants;
import com.fr.design.expand.ExpandLeftFatherPane;
import com.fr.design.expand.ExpandUpFatherPane;
import com.fr.design.expand.SortExpandAttrPane;
import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.icheckbox.UICheckBox;
@ -39,7 +38,6 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
private ExpandUpFatherPane rightFatherPane;
private UICheckBox horizontalExpandableCheckBox;
private UICheckBox verticalExpandableCheckBox;
private SortExpandAttrPane sortAfterExpand;
private JPanel layoutPane;
private JPanel basicPane;
private JPanel seniorPane;
@ -64,7 +62,6 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
rightFatherPane = new ExpandUpFatherPane();
horizontalExpandableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_ExpandD_Horizontal_Extendable"));
verticalExpandableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_ExpandD_Vertical_Extendable"));
sortAfterExpand = new SortExpandAttrPane();
initAllNames();
return layoutPane();
}
@ -124,16 +121,12 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
private JPanel seniorPane() {
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
UILabel expendSort = new UILabel(Toolkit.i18nText("Fine-Design_Report_Expend_Sort"), SwingConstants.LEFT);
JPanel expendSortPane = new JPanel(new BorderLayout());
expendSortPane.add(expendSort, BorderLayout.NORTH);
horizontalExpandableCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER);
verticalExpandableCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER);
Component[][] components = new Component[][]{
new Component[]{null, null},
new Component[]{horizontalExpandableCheckBox, null},
new Component[]{verticalExpandableCheckBox, null},
new Component[]{expendSortPane, sortAfterExpand},
};
double[] rowSize = {p, p, p, p, p};
double[] columnSize = {p, f};
@ -174,8 +167,6 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
}
}
sortAfterExpand.populate(cellExpandAttr);
extraPane.populate(cellElement);
cellExpandSortPane.populateBean(cellElement);
}
@ -223,10 +214,6 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
}
}
if (ComparatorUtils.equals(getGlobalName(), Toolkit.i18nText("Fine-Design_Basic_ExpandD_Sort_After_Expand"))) {
sortAfterExpand.update(cellExpandAttr);
}
extraPane.update(cellElement);
cellExpandSortPane.updateBean(cellElement);
}

18
designer-realize/src/main/java/com/fr/design/sort/celldscolumn/CellDSColumnSortGroupPane.java

@ -15,22 +15,24 @@ public class CellDSColumnSortGroupPane extends AbstractSortGroupPane {
super(sortGroupPaneWidth, sortGroupPaneRightWidth);
}
public void populateDsColumn( DSColumn dsColumn){
public void populateDsColumn(DSColumn dsColumn) {
this.dsColumn = dsColumn;
}
@Override
protected AbstractSortItemPane refreshSortItemPane(int sortItemPaneWidth, int sortItemPaneRightWidth, SortExpression sortExpression) {
CellDSColumnSortItemPane cellDSColumnSortItemPane = new CellDSColumnSortItemPane( sortItemPaneWidth, sortItemPaneRightWidth);
CellDSColumnSortItemPane cellDSColumnSortItemPane = new CellDSColumnSortItemPane(sortItemPaneWidth, sortItemPaneRightWidth);
java.util.Map<String, TableDataWrapper> tableDataWrapperMap =
DesignTableDataManager.getAllEditingDataSet(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget());
TableDataWrapper tableDataWrapper = tableDataWrapperMap.get(dsColumn.getDSName());
java.util.List<String> columnNameList = tableDataWrapper.calculateColumnNameList();
String[] columnNames = new String[columnNameList.size()];
columnNameList.toArray(columnNames);
cellDSColumnSortItemPane.sortAreaUiComboBox.removeAllItems();
for (String columnName : columnNames) {
cellDSColumnSortItemPane.sortAreaUiComboBox.addItem(columnName);
if (tableDataWrapper != null) {
java.util.List<String> columnNameList = tableDataWrapper.calculateColumnNameList();
String[] columnNames = new String[columnNameList.size()];
columnNameList.toArray(columnNames);
cellDSColumnSortItemPane.sortAreaUiComboBox.removeAllItems();
for (String columnName : columnNames) {
cellDSColumnSortItemPane.sortAreaUiComboBox.addItem(columnName);
}
}
cellDSColumnSortItemPane.populateBean(sortExpression);
return cellDSColumnSortItemPane;

9
designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortGroupPane.java

@ -18,6 +18,8 @@ import java.util.List;
public abstract class AbstractSortGroupPane extends JPanel implements ComponentChangeObserver {
private static final int SECOND_SORT_LENGTH_REDUCTION = 13;
protected int sortGroupPaneWidth;
protected int sortGroupPaneRightWidth;
List<SortExpression> sortExpressions;
@ -95,8 +97,8 @@ public abstract class AbstractSortGroupPane extends JPanel implements ComponentC
int sortItemPaneWidth = sortGroupPaneWidth;
int sortItemPaneRightWidth = sortGroupPaneRightWidth;
if (!mainSort) {
sortItemPaneWidth -= 12;
sortItemPaneRightWidth -= 12;
sortItemPaneWidth -= SECOND_SORT_LENGTH_REDUCTION;
sortItemPaneRightWidth -= SECOND_SORT_LENGTH_REDUCTION;
}
if (sortExpression == null) {
sortExpression = new CellSortExpression(selfSortArea);
@ -131,12 +133,13 @@ public abstract class AbstractSortGroupPane extends JPanel implements ComponentC
AddSortItemBar(AbstractSortGroupPane sortGroupPane) {
init();
this.sortGroupPane = sortGroupPane;
this.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 5));
}
void init() {
uiButton = new UIButton(Toolkit.i18nText("Fine-Design_Sort_Add_Second_Sort"),
IconUtils.readIcon("/com/fr/design/images/sort/add.png"));
uiButton.setPreferredSize(new Dimension(sortGroupPaneWidth - 4, 20));
uiButton.setPreferredSize(new Dimension(sortGroupPaneWidth - 4, AbstractSortPane.PANE_COMPONENT_HEIGHT));
this.add(uiButton);
uiButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {

30
designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortPane.java

@ -34,13 +34,19 @@ public abstract class AbstractSortPane extends JPanel {
private void initComponents() {
initSortGroupPane();
sortHeaderPane = new SortHeaderPane(sortPaneWidth, sortPaneRightWidth + 5);
this.add(sortHeaderPane);
if (needSortHeaderPane()) {
sortHeaderPane = new SortHeaderPane(sortPaneWidth, sortPaneRightWidth + 5);
this.add(sortHeaderPane);
}
}
protected abstract void initSortGroupPane();
protected boolean needSortHeaderPane() {
return true;
}
protected abstract CellSortAttr getCellSortAttr(TemplateCellElement cellElement);
public void populateBean(TemplateCellElement cellElement) {
@ -55,11 +61,13 @@ public abstract class AbstractSortPane extends JPanel {
sortExpressions.add(new CellSortExpression(selfSortArea));
}
sortGroupPane.populateBean(sortExpressions, selfSortArea);
SortHeader sortHeader = null;
if (cellSortAttr != null) {
sortHeader = cellSortAttr.getSortHeader();
if (needSortHeaderPane()) {
SortHeader sortHeader = null;
if (cellSortAttr != null) {
sortHeader = cellSortAttr.getSortHeader();
}
sortHeaderPane.populateBean(sortHeader, defaultHeaderArea);
}
sortHeaderPane.populateBean(sortHeader, defaultHeaderArea);
refresh();
}
@ -76,13 +84,15 @@ public abstract class AbstractSortPane extends JPanel {
public void updateBean(TemplateCellElement cellElement) {
List<SortExpression> sortExpressions = sortGroupPane.updateBean();
SortHeader sortHeader = sortHeaderPane.updateBean();
CellSortAttr cellSortAttr = getCellSortAttr(cellElement);
cellSortAttr.setSortExpressions(sortExpressions);
if (sortHeader != null) {
sortHeader.setSortArea(selfSortArea);
if (needSortHeaderPane()) {
SortHeader sortHeader = sortHeaderPane.updateBean();
if (sortHeader != null) {
sortHeader.setSortArea(selfSortArea);
}
cellSortAttr.setSortHeader(sortHeader);
}
cellSortAttr.setSortHeader(sortHeader);
}
protected void refresh() {

165
designer-realize/src/main/java/com/fr/design/sort/common/SortColumnRowPane.java

@ -1,5 +1,7 @@
package com.fr.design.sort.common;
import com.fr.base.Style;
import com.fr.base.background.ColorBackground;
import com.fr.base.svg.IconUtils;
import com.fr.design.designer.TargetComponent;
import com.fr.design.event.UIObserver;
@ -10,9 +12,18 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.selection.SelectionEvent;
import com.fr.design.selection.SelectionListener;
import com.fr.design.ui.util.UIUtil;
import com.fr.general.Background;
import com.fr.grid.selection.CellSelection;
import com.fr.grid.selection.Selection;
import com.fr.log.FineLoggerFactory;
import com.fr.report.cell.DefaultTemplateCellElement;
import com.fr.report.cell.TemplateCellElement;
import com.fr.report.cell.cellattr.CellExpandAttr;
import com.fr.report.cell.cellattr.core.group.DSColumn;
import com.fr.report.core.sort.common.CellSortable;
import com.fr.report.core.sort.header.SortHeader;
import com.fr.report.elementcase.TemplateElementCase;
import com.fr.stable.ColumnRow;
import com.fr.stable.EssentialUtils;
import com.fr.stable.StringUtils;
@ -21,6 +32,12 @@ import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class SortColumnRowPane extends JPanel implements UIObserver {
int paneWidth;
@ -75,7 +92,7 @@ public class SortColumnRowPane extends JPanel implements UIObserver {
void initSelectButton() {
selectButton = new UIButton(IconUtils.readIcon("/com/fr/design/images/buttonicon/select.png"));
selectButton.addActionListener(new SelectActionListener(this));
selectButton.addMouseListener(new SelectActionListener(this));
this.add(selectButton);
}
@ -90,7 +107,7 @@ public class SortColumnRowPane extends JPanel implements UIObserver {
refresh();
}
public void setColumnRow(ColumnRow columnRow){
public void setColumnRow(ColumnRow columnRow) {
populateBean(columnRow);
uiObserverListener.doChange();
}
@ -112,59 +129,145 @@ public class SortColumnRowPane extends JPanel implements UIObserver {
return true;
}
class SelectActionListener implements ActionListener {
class SelectActionListener extends MouseAdapter {
SortColumnRowPane columnRowPane;
Map<ColumnRow, Style> disableHeaderCellsStyleMap = new HashMap<>();
java.util.List<TemplateCellElement> tempHeaderCells = new ArrayList<>();
SelectActionListener(SortColumnRowPane columnRowPane) {
this.columnRowPane = columnRowPane;
}
@Override
public void actionPerformed(ActionEvent e) {
public void mouseClicked(MouseEvent e) {
ElementCasePane elementCasePane = getCurrentElementCase();
if (elementCasePane == null || isAlreadyAddListener) {
return;
}
oldSelection = (CellSelection) elementCasePane.getSelection();
elementCasePane.getGrid().setNotShowingTableSelectPane(false);
elementCasePane.setEditable(false);
elementCasePane.repaint(10);
prepareSelectHeader(elementCasePane);
gridSelectionChangeListener = new SelectionListener() {
@Override
public void selectionChanged(SelectionEvent e) {
Selection selection = elementCasePane.getSelection();
if (selection instanceof CellSelection) {
CellSelection cellselection = (CellSelection) selection;
ColumnRow cr = ColumnRow.valueOf(cellselection.getColumn(), cellselection.getRow());
elementCasePane.setOldSelecton(oldSelection);
columnRowPane.setColumnRow(cr);
}
elementCasePane.removeSelectionChangeListener(gridSelectionChangeListener);
isAlreadyAddListener = false;
elementCasePane.getGrid().setNotShowingTableSelectPane(true);
elementCasePane.setEditable(true);
elementCasePane.repaint();
completeSelectHeader(elementCasePane);
}
};
elementCasePane.addSelectionChangeListener(gridSelectionChangeListener);
isAlreadyAddListener = true;
}
}
private ElementCasePane getCurrentElementCase() {
try {
TargetComponent targetComponent
= HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane();
if (targetComponent instanceof ElementCasePane) {
return (ElementCasePane) targetComponent;
private void prepareSelectHeader(ElementCasePane elementCasePane) {
ashDisableHeaderCellsStyle(elementCasePane.getEditingElementCase());
oldSelection = (CellSelection) elementCasePane.getSelection();
elementCasePane.getGrid().setNotShowingTableSelectPane(false);
elementCasePane.setEditable(false);
elementCasePane.repaint(10);
}
private void completeSelectHeader(ElementCasePane elementCasePane) {
Selection selection = elementCasePane.getSelection();
if (selection instanceof CellSelection) {
CellSelection cellselection = (CellSelection) selection;
ColumnRow columnRow = ColumnRow.valueOf(cellselection.getColumn(), cellselection.getRow());
elementCasePane.setOldSelecton(oldSelection);
oldSelection.getQuickEditor(elementCasePane);
if (!disableHeaderCellsStyleMap.keySet().contains(columnRow)) {
columnRowPane.setColumnRow(columnRow);
}
restoreDisableHeaderCellsStyle(elementCasePane.getEditingElementCase());
}
elementCasePane.removeSelectionChangeListener(gridSelectionChangeListener);
isAlreadyAddListener = false;
elementCasePane.getGrid().setNotShowingTableSelectPane(true);
elementCasePane.setEditable(true);
elementCasePane.repaint();
}
private void ashDisableHeaderCellsStyle(TemplateElementCase elementCase) {
disableHeaderCellsStyleMap = new HashMap<>();
tempHeaderCells = new ArrayList<>();
Map<ColumnRow, TemplateCellElement> disableHeaderCellsMap = getDisableHeaderCellsMap(elementCase);
for (ColumnRow headerColumnRow : disableHeaderCellsMap.keySet()) {
TemplateCellElement headerCell = disableHeaderCellsMap.get(headerColumnRow);
if (headerCell == null) {
headerCell = new DefaultTemplateCellElement(headerColumnRow.column, headerColumnRow.row);
elementCase.addCellElement(headerCell);
tempHeaderCells.add(headerCell);
}
Style style = headerCell.getStyle();
disableHeaderCellsStyleMap.put(headerColumnRow, style);
style = style.deriveBackground(ColorBackground.getInstance(Color.gray));
headerCell.setStyle(style);
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
}
return null;
private void restoreDisableHeaderCellsStyle(TemplateElementCase elementCase) {
try {
for (ColumnRow headerColumnRow : disableHeaderCellsStyleMap.keySet()) {
TemplateCellElement headerTemplateCellElement
= elementCase.getTemplateCellElement(headerColumnRow.column, headerColumnRow.row);
headerTemplateCellElement.setStyle(disableHeaderCellsStyleMap.get(headerColumnRow));
}
for (TemplateCellElement templateCellElement : tempHeaderCells) {
elementCase.removeCellElement(templateCellElement);
}
disableHeaderCellsStyleMap = new HashMap<>();
tempHeaderCells = new ArrayList<>();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
}
}
private Map<ColumnRow, TemplateCellElement> getDisableHeaderCellsMap(TemplateElementCase elementCase) {
Map<ColumnRow, TemplateCellElement> headerCellsMap = new HashMap<>();
Iterator iterator = elementCase.cellIterator();
while (iterator.hasNext()) {
TemplateCellElement templateCellElement = (TemplateCellElement) iterator.next();
CellExpandAttr cellExpandAttr = templateCellElement.getCellExpandAttr();
if (cellExpandAttr != null) {
handleDisableHeaderCell(elementCase, cellExpandAttr, headerCellsMap);
}
Object value = templateCellElement.getValue();
if (value instanceof DSColumn) {
handleDisableHeaderCell(elementCase, (DSColumn) value, headerCellsMap);
}
}
return headerCellsMap;
}
private void handleDisableHeaderCell(TemplateElementCase elementCase, CellSortable cellSortable, Map<ColumnRow, TemplateCellElement> headerCellsMap) {
if (cellSortable.getCellSortAttr() != null) {
SortHeader sortHeader = cellSortable.getCellSortAttr().getSortHeader();
if (sortHeader != null) {
String headerArea = sortHeader.getHeaderArea();
if (headerArea != null) {
ColumnRow headerColumnRow = ColumnRow.valueOf(headerArea);
ColumnRow columnRow = columnRowPane.updateBean();
if (!headerColumnRow.equals(columnRow)) {
TemplateCellElement headerCell
= elementCase.getTemplateCellElement(headerColumnRow.column, headerColumnRow.row);
headerCellsMap.put(headerColumnRow, headerCell);
}
}
}
}
}
private ElementCasePane getCurrentElementCase() {
try {
TargetComponent targetComponent
= HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane();
if (targetComponent instanceof ElementCasePane) {
return (ElementCasePane) targetComponent;
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
}
return null;
}
}
protected void refresh() {
validate();
repaint();

1
designer-realize/src/main/java/com/fr/design/sort/common/SortUIExpandablePane.java

@ -31,6 +31,7 @@ public class SortUIExpandablePane extends JPanel {
initComponents();
wrapPane.setBorder(BorderFactory.createLineBorder(Color.gray, 1));
wrapPane.setBackground(Color.WHITE);
this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 5));
}

6
designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequencePane.java

@ -1,6 +1,5 @@
package com.fr.design.sort.expressionpane;
import com.fr.base.BaseUtils;
import com.fr.base.svg.IconUtils;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.ibutton.UIButton;
@ -29,11 +28,10 @@ public class CustomSequencePane extends JPanel {
protected void initComponents(int width) {
textField = new UITextField();
textField.setEditable(false);
textField.setPreferredSize(new Dimension(width - 20, 20));
textField.setPreferredSize(new Dimension(width - 20, AbstractSortPane.PANE_COMPONENT_HEIGHT));
Icon icon = IconUtils.readIcon("/com/fr/design/images/control/refresh.png");
button = new UIButton(icon);
button.setBackground(Color.RED);
button.setPreferredSize(new Dimension(24, 20));
button.setOpaque(false);
button.setCursor(new Cursor(Cursor.HAND_CURSOR));
button.addActionListener(new ActionListener() {
@ -48,7 +46,7 @@ public class CustomSequencePane extends JPanel {
}, new Dimension(700, 400)).setVisible(true);
}
});
button.setPreferredSize(new Dimension(24, AbstractSortPane.PANE_COMPONENT_HEIGHT));
button.setPreferredSize(new Dimension(20, AbstractSortPane.PANE_COMPONENT_HEIGHT));
this.add(textField);
this.add(button);

6
designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequenceSortExpressionPane.java

@ -13,10 +13,8 @@ public class CustomSequenceSortExpressionPane extends SortExpressionPane<CustomS
CustomSequencePane customSequencePane;
public CustomSequenceSortExpressionPane(int width, int rightWidth) {
this.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0));
customSequencePane = new CustomSequencePane(rightWidth);
customSequencePane.setPreferredSize(new Dimension(width, AbstractSortPane.PANE_COMPONENT_HEIGHT));
customSequencePane.setBorder(BorderFactory.createEmptyBorder(0,0,0,3));
this.setLayout(new FlowLayout(FlowLayout.RIGHT, 2, 0));
customSequencePane = new CustomSequencePane(rightWidth + 5);
this.add(customSequencePane);
}

4
designer-realize/src/main/java/com/fr/design/sort/expressionpane/FormulaSortExpressionPane.java

@ -12,9 +12,9 @@ public class FormulaSortExpressionPane extends SortExpressionPane<FormulaSortExp
TinyFormulaPane tinyFormulaPane;
public FormulaSortExpressionPane(int width) {
this.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 1));
this.setLayout(new FlowLayout(FlowLayout.RIGHT, 2, 0));
tinyFormulaPane = new TinyFormulaPane();
tinyFormulaPane.setPreferredSize(new Dimension(width, AbstractSortPane.PANE_COMPONENT_HEIGHT));
tinyFormulaPane.setPreferredSize(new Dimension(width + 5, AbstractSortPane.PANE_COMPONENT_HEIGHT));
this.add(tinyFormulaPane);
}

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

@ -316,10 +316,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
class DSColumnAdvancedEditorPane extends AbstractDSCellEditorPane {
/*pane begin*/
/**
* 排列顺序
*/
private ResultSetSortConfigPane sortPane;
/**
* 结果集筛选
*/
@ -377,7 +373,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
@Override
public void update() {
if (cellElement != null) {
sortPane.update(cellElement);
valuePane.update(cellElement);
formatAttrPane.update(cellElement);
filterPane.update(cellElement);
@ -393,7 +388,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
public void populate() {
if (cellElement != null) {
this.removeAttributeChangeListener();
sortPane.populate(cellElement);
valuePane.populate(cellElement);
formatAttrPane.populate(cellElement);
filterPane.populate(cellElement);
@ -500,10 +494,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
protected JPanel createContentPane() {
JPanel contentPane = new JPanel(new BorderLayout());
this.setLayout(FRGUIPaneFactory.createBorderLayout());
//结果集排序
sortPane = new ResultSetSortConfigPane();
//结果筛选
filterPane = new ResultSetFilterConfigPane();
@ -538,7 +528,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
multiNumPane.add(multiPane);
Component[][] components = new Component[][]{
{sortPane},
{filterPane},
{valuePane},
{formatAttrPane},
@ -552,9 +541,8 @@ public class CellDSColumnEditor extends CellQuickEditor {
JPanel advancePropertyPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP);
contentPane.add(advancePropertyPane, BorderLayout.NORTH);
UIExpandablePane sortUIExpandablePane =
new UIExpandablePane(Toolkit.i18nText("Fine-Design_Report_Expend_Sort"),
new UIExpandablePane(Toolkit.i18nText("Fine-Design_Sort_Data_Column_Sort"),
223, 24, cellDSColumnSortPane = new CellDSColumnSortPane());
contentPane.add(sortUIExpandablePane, BorderLayout.CENTER);
return contentPane;
}
@ -569,136 +557,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
}
}
/**
* 单元格元素>数据集>高级设置>结果排序设置面板
*
* @see com.fr.design.expand.SortExpandAttrPane
* @see DSColumnAdvancedPane.SortPane
*/
public class ResultSetSortConfigPane extends JPanel {
private static final String DEFAULT_VALUE = "=";
private JPanel contentPane;
private UIButtonGroup sortTypePane;
private JFormulaField formulaField;
private CardLayout cardLayout;
private JPanel centerPane;
public ResultSetSortConfigPane() {
this.setLayout(new BorderLayout());
Icon[] iconArray = {
IOUtils.readIcon("/com/fr/design/images/expand/none16x16.png"),
IOUtils.readIcon("/com/fr/design/images/expand/asc.png"),
IOUtils.readIcon("/com/fr/design/images/expand/des.png")
};
String[] nameArray = {Toolkit.i18nText("Fine-Design_Report_Sort_Original"), Toolkit.i18nText("Fine-Design_Report_Sort_Ascending"), Toolkit.i18nText("Fine-Design_Report_Sort_Descending")};
sortTypePane = new UIButtonGroup(iconArray);
sortTypePane.setAllToolTips(nameArray);
sortTypePane.setGlobalName(Toolkit.i18nText("Fine-Design_Basic_ExpandD_Sort_After_Expand"));
cardLayout = new CardLayout();
centerPane = new JPanel(cardLayout);
formulaField = new JFormulaField(DEFAULT_VALUE);
centerPane.add(new JPanel(), "none");
centerPane.add(formulaField, "content");
UILabel sortLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_Sort_Sort_Order"));
sortLabel.setPreferredSize(LABEL_DIMENSION);
sortTypePane.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
boolean noContent = sortTypePane.getSelectedIndex() == 0;
cardLayout.show(centerPane, noContent ? "none" : "content");
if (noContent) {
centerPane.setPreferredSize(new Dimension(0, 0));
TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, 0);
} else {
centerPane.setPreferredSize(new Dimension(165, 20));
TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, VGAP);
}
}
});
Component[][] components = new Component[][]{
new Component[]{sortLabel, sortTypePane},
new Component[]{null, centerPane}
};
double[] rowSize = {P, P}, columnSize = {P, F};
contentPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP);
this.add(contentPane, BorderLayout.CENTER);
}
/**
* 刷新面板信息
*
* @param cellElement 单元格
*/
public void populate(TemplateCellElement cellElement) {
if (cellElement != null) {
Object value = cellElement.getValue();
if (value instanceof DSColumn) {
this.formulaField.populateElement(cellElement);
DSColumn dSColumn = (DSColumn) value;
int sort = dSColumn.getOrder();
this.sortTypePane.setSelectedIndex(sort);
boolean noContent = sortTypePane.getSelectedIndex() == 0;
cardLayout.show(centerPane, noContent ? "none" : "content");
if (noContent) {
centerPane.setPreferredSize(new Dimension(0, 0));
TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, 0);
} else {
centerPane.setPreferredSize(new Dimension(156, 20));
TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, VGAP);
}
String sortFormula = dSColumn.getSortFormula();
if (sortFormula != null && sortFormula.length() >= 1) {
this.formulaField.populate(sortFormula);
} else {
this.formulaField.populate(DEFAULT_VALUE);
}
}
}
}
/**
* 保存面板配置信息
*
* @param cellElement 单元格
*/
public void update(CellElement cellElement) {
if (cellElement != null) {
Object value = cellElement.getValue();
if (value instanceof DSColumn) {
DSColumn dSColumn = (DSColumn) value;
dSColumn.setOrder(this.sortTypePane.getSelectedIndex());
dSColumn.setSortFormula(this.formulaField.getFormulaText());
}
}
}
/**
* 添加事件监听器
*
* @param formulaChangeListener 公式输入框改动事件监听器
* @param changeListener 排序类型下拉框改动事件监听器
*/
public void addListener(UIObserverListener formulaChangeListener, ChangeListener changeListener) {
formulaField.addListener(formulaChangeListener);
sortTypePane.addChangeListener(changeListener);
}
/**
* 去除事件监听器
*
* @param changeListener 排序类型下拉框改动事件监听器
*/
public void removeListener(ChangeListener changeListener) {
formulaField.removeListener();
sortTypePane.removeChangeListener(changeListener);
}
}
/**
* 单元格元素>数据集>高级设置>结果集筛选设置面板
*

Loading…
Cancel
Save