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.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;
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;
@ -20,6 +21,7 @@ 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;
import com.fr.design.sort.celldscolumn.CellDSColumnSortPane;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.report.cell.CellElement; import com.fr.report.cell.CellElement;
import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.TemplateCellElement;
@ -47,14 +49,26 @@ public class DSColumnAdvancedPane extends BasicPane {
private UICheckBox verticalExtendableCheckBox; private UICheckBox verticalExtendableCheckBox;
private UICheckBox useMultiplyNumCheckBox; private UICheckBox useMultiplyNumCheckBox;
private UISpinner multiNumSpinner; private UISpinner multiNumSpinner;
private JPanel contentPane;
public DSColumnAdvancedPane() { public DSColumnAdvancedPane() {
this(DSColumnPane.SETTING_ALL); this(DSColumnPane.SETTING_ALL);
} }
public DSColumnAdvancedPane(int setting) { public DSColumnAdvancedPane(int setting) {
this.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); initContentPane(setting);
this.setLayout(FRGUIPaneFactory.createBorderLayout()); 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 = new SortPane();
sortPane.setBorder(UITitledBorder.createBorderWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Sort_Sort_Order"))); 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}; TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED};
double[] columnSize = {TableLayout.FILL}; double[] columnSize = {TableLayout.FILL};
this.add(TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize), BorderLayout.CENTER); contentPane.add(TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize), BorderLayout.CENTER);
} }
@Override @Override
@ -137,7 +151,7 @@ public class DSColumnAdvancedPane extends BasicPane {
return; return;
} }
sortPane.populate(cellElement); sortPane.populateBean(cellElement);
valuePane.populate(cellElement); valuePane.populate(cellElement);
formatAttrPane.populate(cellElement); formatAttrPane.populate(cellElement);
@ -187,7 +201,7 @@ public class DSColumnAdvancedPane extends BasicPane {
return; return;
} }
sortPane.update(cellElement); sortPane.updateBean(cellElement);
valuePane.update(cellElement); valuePane.update(cellElement);
formatAttrPane.update(cellElement); formatAttrPane.update(cellElement);
@ -223,66 +237,25 @@ public class DSColumnAdvancedPane extends BasicPane {
} }
} }
private static class SortPane extends SortFormulaPane { private static class ScrollPane extends UIScrollPane {
private CellElement cellElement; ScrollPane(Component component) {
super(component);
this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
}
@Override @Override
public void formulaAction() { public Dimension getPreferredSize() {
if (cellElement == null) { return new Dimension(DSColumnPane.DEFAULT_DIMENSION.width - 20, DSColumnPane.DEFAULT_DIMENSION.height - 100);
return;
}
Object value = cellElement.getValue();
if (value == null || !(value instanceof DSColumn)) {
return;
}
String[] displayNames = DesignTableDataManager.getSelectedColumnNames(
DesignTableDataManager.getEditingTableDataSource(), ((DSColumn) value).getDSName());
showFormulaDialog(displayNames);
} }
}
void populate(CellElement cellElement) { private static class SortPane extends CellDSColumnSortPane {
if (cellElement == null) { SortPane() {
return; this.setLayout(new FlowLayout(FlowLayout.LEFT));
}
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);
} }
public void update(CellElement cellElement) { protected boolean needSortHeaderPane() {
if (cellElement == null) { return false;
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);
}
} }
} }
@ -540,12 +513,12 @@ public class DSColumnAdvancedPane extends BasicPane {
public static class FormatAttrPane extends TextFormatPane { public static class FormatAttrPane extends TextFormatPane {
protected void initLayout() { 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(typeComboBox);
settingPane.add(textField); settingPane.add(textField);
settingPane.add(roundingBox); settingPane.add(roundingBox);
addComponents(4, new JComponent[] { settingPane, previewLabel}); addComponents(4, new JComponent[]{settingPane, previewLabel});
} }
@Override @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.constants.UIConstants;
import com.fr.design.expand.ExpandLeftFatherPane; import com.fr.design.expand.ExpandLeftFatherPane;
import com.fr.design.expand.ExpandUpFatherPane; import com.fr.design.expand.ExpandUpFatherPane;
import com.fr.design.expand.SortExpandAttrPane;
import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
@ -39,7 +38,6 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
private ExpandUpFatherPane rightFatherPane; private ExpandUpFatherPane rightFatherPane;
private UICheckBox horizontalExpandableCheckBox; private UICheckBox horizontalExpandableCheckBox;
private UICheckBox verticalExpandableCheckBox; private UICheckBox verticalExpandableCheckBox;
private SortExpandAttrPane sortAfterExpand;
private JPanel layoutPane; private JPanel layoutPane;
private JPanel basicPane; private JPanel basicPane;
private JPanel seniorPane; private JPanel seniorPane;
@ -64,7 +62,6 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
rightFatherPane = new ExpandUpFatherPane(); rightFatherPane = new ExpandUpFatherPane();
horizontalExpandableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_ExpandD_Horizontal_Extendable")); horizontalExpandableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_ExpandD_Horizontal_Extendable"));
verticalExpandableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_ExpandD_Vertical_Extendable")); verticalExpandableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_ExpandD_Vertical_Extendable"));
sortAfterExpand = new SortExpandAttrPane();
initAllNames(); initAllNames();
return layoutPane(); return layoutPane();
} }
@ -124,16 +121,12 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
private JPanel seniorPane() { private JPanel seniorPane() {
double f = TableLayout.FILL; double f = TableLayout.FILL;
double p = TableLayout.PREFERRED; 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); horizontalExpandableCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER);
verticalExpandableCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER); verticalExpandableCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER);
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{null, null}, new Component[]{null, null},
new Component[]{horizontalExpandableCheckBox, null}, new Component[]{horizontalExpandableCheckBox, null},
new Component[]{verticalExpandableCheckBox, null}, new Component[]{verticalExpandableCheckBox, null},
new Component[]{expendSortPane, sortAfterExpand},
}; };
double[] rowSize = {p, p, p, p, p}; double[] rowSize = {p, p, p, p, p};
double[] columnSize = {p, f}; double[] columnSize = {p, f};
@ -174,8 +167,6 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
} }
} }
sortAfterExpand.populate(cellExpandAttr);
extraPane.populate(cellElement); extraPane.populate(cellElement);
cellExpandSortPane.populateBean(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); extraPane.update(cellElement);
cellExpandSortPane.updateBean(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); super(sortGroupPaneWidth, sortGroupPaneRightWidth);
} }
public void populateDsColumn( DSColumn dsColumn){ public void populateDsColumn(DSColumn dsColumn) {
this.dsColumn = dsColumn; this.dsColumn = dsColumn;
} }
@Override @Override
protected AbstractSortItemPane refreshSortItemPane(int sortItemPaneWidth, int sortItemPaneRightWidth, SortExpression sortExpression) { 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 = java.util.Map<String, TableDataWrapper> tableDataWrapperMap =
DesignTableDataManager.getAllEditingDataSet(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget()); DesignTableDataManager.getAllEditingDataSet(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget());
TableDataWrapper tableDataWrapper = tableDataWrapperMap.get(dsColumn.getDSName()); TableDataWrapper tableDataWrapper = tableDataWrapperMap.get(dsColumn.getDSName());
java.util.List<String> columnNameList = tableDataWrapper.calculateColumnNameList(); if (tableDataWrapper != null) {
String[] columnNames = new String[columnNameList.size()]; java.util.List<String> columnNameList = tableDataWrapper.calculateColumnNameList();
columnNameList.toArray(columnNames); String[] columnNames = new String[columnNameList.size()];
cellDSColumnSortItemPane.sortAreaUiComboBox.removeAllItems(); columnNameList.toArray(columnNames);
for (String columnName : columnNames) { cellDSColumnSortItemPane.sortAreaUiComboBox.removeAllItems();
cellDSColumnSortItemPane.sortAreaUiComboBox.addItem(columnName); for (String columnName : columnNames) {
cellDSColumnSortItemPane.sortAreaUiComboBox.addItem(columnName);
}
} }
cellDSColumnSortItemPane.populateBean(sortExpression); cellDSColumnSortItemPane.populateBean(sortExpression);
return cellDSColumnSortItemPane; 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 { public abstract class AbstractSortGroupPane extends JPanel implements ComponentChangeObserver {
private static final int SECOND_SORT_LENGTH_REDUCTION = 13;
protected int sortGroupPaneWidth; protected int sortGroupPaneWidth;
protected int sortGroupPaneRightWidth; protected int sortGroupPaneRightWidth;
List<SortExpression> sortExpressions; List<SortExpression> sortExpressions;
@ -95,8 +97,8 @@ public abstract class AbstractSortGroupPane extends JPanel implements ComponentC
int sortItemPaneWidth = sortGroupPaneWidth; int sortItemPaneWidth = sortGroupPaneWidth;
int sortItemPaneRightWidth = sortGroupPaneRightWidth; int sortItemPaneRightWidth = sortGroupPaneRightWidth;
if (!mainSort) { if (!mainSort) {
sortItemPaneWidth -= 12; sortItemPaneWidth -= SECOND_SORT_LENGTH_REDUCTION;
sortItemPaneRightWidth -= 12; sortItemPaneRightWidth -= SECOND_SORT_LENGTH_REDUCTION;
} }
if (sortExpression == null) { if (sortExpression == null) {
sortExpression = new CellSortExpression(selfSortArea); sortExpression = new CellSortExpression(selfSortArea);
@ -131,12 +133,13 @@ public abstract class AbstractSortGroupPane extends JPanel implements ComponentC
AddSortItemBar(AbstractSortGroupPane sortGroupPane) { AddSortItemBar(AbstractSortGroupPane sortGroupPane) {
init(); init();
this.sortGroupPane = sortGroupPane; this.sortGroupPane = sortGroupPane;
this.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 5));
} }
void init() { void init() {
uiButton = new UIButton(Toolkit.i18nText("Fine-Design_Sort_Add_Second_Sort"), uiButton = new UIButton(Toolkit.i18nText("Fine-Design_Sort_Add_Second_Sort"),
IconUtils.readIcon("/com/fr/design/images/sort/add.png")); 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); this.add(uiButton);
uiButton.addActionListener(new ActionListener() { uiButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { 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() { private void initComponents() {
initSortGroupPane(); initSortGroupPane();
sortHeaderPane = new SortHeaderPane(sortPaneWidth, sortPaneRightWidth + 5); if (needSortHeaderPane()) {
this.add(sortHeaderPane); sortHeaderPane = new SortHeaderPane(sortPaneWidth, sortPaneRightWidth + 5);
this.add(sortHeaderPane);
}
} }
protected abstract void initSortGroupPane(); protected abstract void initSortGroupPane();
protected boolean needSortHeaderPane() {
return true;
}
protected abstract CellSortAttr getCellSortAttr(TemplateCellElement cellElement); protected abstract CellSortAttr getCellSortAttr(TemplateCellElement cellElement);
public void populateBean(TemplateCellElement cellElement) { public void populateBean(TemplateCellElement cellElement) {
@ -55,11 +61,13 @@ public abstract class AbstractSortPane extends JPanel {
sortExpressions.add(new CellSortExpression(selfSortArea)); sortExpressions.add(new CellSortExpression(selfSortArea));
} }
sortGroupPane.populateBean(sortExpressions, selfSortArea); sortGroupPane.populateBean(sortExpressions, selfSortArea);
SortHeader sortHeader = null; if (needSortHeaderPane()) {
if (cellSortAttr != null) { SortHeader sortHeader = null;
sortHeader = cellSortAttr.getSortHeader(); if (cellSortAttr != null) {
sortHeader = cellSortAttr.getSortHeader();
}
sortHeaderPane.populateBean(sortHeader, defaultHeaderArea);
} }
sortHeaderPane.populateBean(sortHeader, defaultHeaderArea);
refresh(); refresh();
} }
@ -76,13 +84,15 @@ public abstract class AbstractSortPane extends JPanel {
public void updateBean(TemplateCellElement cellElement) { public void updateBean(TemplateCellElement cellElement) {
List<SortExpression> sortExpressions = sortGroupPane.updateBean(); List<SortExpression> sortExpressions = sortGroupPane.updateBean();
SortHeader sortHeader = sortHeaderPane.updateBean();
CellSortAttr cellSortAttr = getCellSortAttr(cellElement); CellSortAttr cellSortAttr = getCellSortAttr(cellElement);
cellSortAttr.setSortExpressions(sortExpressions); cellSortAttr.setSortExpressions(sortExpressions);
if (sortHeader != null) { if (needSortHeaderPane()) {
sortHeader.setSortArea(selfSortArea); SortHeader sortHeader = sortHeaderPane.updateBean();
if (sortHeader != null) {
sortHeader.setSortArea(selfSortArea);
}
cellSortAttr.setSortHeader(sortHeader);
} }
cellSortAttr.setSortHeader(sortHeader);
} }
protected void refresh() { 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; 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.base.svg.IconUtils;
import com.fr.design.designer.TargetComponent; import com.fr.design.designer.TargetComponent;
import com.fr.design.event.UIObserver; 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.mainframe.ElementCasePane;
import com.fr.design.selection.SelectionEvent; import com.fr.design.selection.SelectionEvent;
import com.fr.design.selection.SelectionListener; 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.CellSelection;
import com.fr.grid.selection.Selection; import com.fr.grid.selection.Selection;
import com.fr.log.FineLoggerFactory; 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.ColumnRow;
import com.fr.stable.EssentialUtils; import com.fr.stable.EssentialUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -21,6 +32,12 @@ import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; 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 { public class SortColumnRowPane extends JPanel implements UIObserver {
int paneWidth; int paneWidth;
@ -75,7 +92,7 @@ public class SortColumnRowPane extends JPanel implements UIObserver {
void initSelectButton() { void initSelectButton() {
selectButton = new UIButton(IconUtils.readIcon("/com/fr/design/images/buttonicon/select.png")); 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); this.add(selectButton);
} }
@ -90,7 +107,7 @@ public class SortColumnRowPane extends JPanel implements UIObserver {
refresh(); refresh();
} }
public void setColumnRow(ColumnRow columnRow){ public void setColumnRow(ColumnRow columnRow) {
populateBean(columnRow); populateBean(columnRow);
uiObserverListener.doChange(); uiObserverListener.doChange();
} }
@ -112,59 +129,145 @@ public class SortColumnRowPane extends JPanel implements UIObserver {
return true; return true;
} }
class SelectActionListener implements ActionListener { class SelectActionListener extends MouseAdapter {
SortColumnRowPane columnRowPane; SortColumnRowPane columnRowPane;
Map<ColumnRow, Style> disableHeaderCellsStyleMap = new HashMap<>();
java.util.List<TemplateCellElement> tempHeaderCells = new ArrayList<>();
SelectActionListener(SortColumnRowPane columnRowPane) { SelectActionListener(SortColumnRowPane columnRowPane) {
this.columnRowPane = columnRowPane; this.columnRowPane = columnRowPane;
} }
@Override @Override
public void actionPerformed(ActionEvent e) { public void mouseClicked(MouseEvent e) {
ElementCasePane elementCasePane = getCurrentElementCase(); ElementCasePane elementCasePane = getCurrentElementCase();
if (elementCasePane == null || isAlreadyAddListener) { if (elementCasePane == null || isAlreadyAddListener) {
return; return;
} }
oldSelection = (CellSelection) elementCasePane.getSelection(); prepareSelectHeader(elementCasePane);
elementCasePane.getGrid().setNotShowingTableSelectPane(false);
elementCasePane.setEditable(false);
elementCasePane.repaint(10);
gridSelectionChangeListener = new SelectionListener() { gridSelectionChangeListener = new SelectionListener() {
@Override @Override
public void selectionChanged(SelectionEvent e) { public void selectionChanged(SelectionEvent e) {
Selection selection = elementCasePane.getSelection(); completeSelectHeader(elementCasePane);
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();
} }
}; };
elementCasePane.addSelectionChangeListener(gridSelectionChangeListener); elementCasePane.addSelectionChangeListener(gridSelectionChangeListener);
isAlreadyAddListener = true; isAlreadyAddListener = true;
} }
}
private ElementCasePane getCurrentElementCase() { private void prepareSelectHeader(ElementCasePane elementCasePane) {
try { ashDisableHeaderCellsStyle(elementCasePane.getEditingElementCase());
TargetComponent targetComponent oldSelection = (CellSelection) elementCasePane.getSelection();
= HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane(); elementCasePane.getGrid().setNotShowingTableSelectPane(false);
if (targetComponent instanceof ElementCasePane) { elementCasePane.setEditable(false);
return (ElementCasePane) targetComponent; 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() { protected void refresh() {
validate(); validate();
repaint(); repaint();

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

@ -31,6 +31,7 @@ public class SortUIExpandablePane extends JPanel {
initComponents(); initComponents();
wrapPane.setBorder(BorderFactory.createLineBorder(Color.gray, 1)); wrapPane.setBorder(BorderFactory.createLineBorder(Color.gray, 1));
wrapPane.setBackground(Color.WHITE); 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; package com.fr.design.sort.expressionpane;
import com.fr.base.BaseUtils;
import com.fr.base.svg.IconUtils; import com.fr.base.svg.IconUtils;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
@ -29,11 +28,10 @@ public class CustomSequencePane extends JPanel {
protected void initComponents(int width) { protected void initComponents(int width) {
textField = new UITextField(); textField = new UITextField();
textField.setEditable(false); 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"); Icon icon = IconUtils.readIcon("/com/fr/design/images/control/refresh.png");
button = new UIButton(icon); button = new UIButton(icon);
button.setBackground(Color.RED); button.setBackground(Color.RED);
button.setPreferredSize(new Dimension(24, 20));
button.setOpaque(false); button.setOpaque(false);
button.setCursor(new Cursor(Cursor.HAND_CURSOR)); button.setCursor(new Cursor(Cursor.HAND_CURSOR));
button.addActionListener(new ActionListener() { button.addActionListener(new ActionListener() {
@ -48,7 +46,7 @@ public class CustomSequencePane extends JPanel {
}, new Dimension(700, 400)).setVisible(true); }, 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(textField);
this.add(button); 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; CustomSequencePane customSequencePane;
public CustomSequenceSortExpressionPane(int width, int rightWidth) { public CustomSequenceSortExpressionPane(int width, int rightWidth) {
this.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0)); this.setLayout(new FlowLayout(FlowLayout.RIGHT, 2, 0));
customSequencePane = new CustomSequencePane(rightWidth); customSequencePane = new CustomSequencePane(rightWidth + 5);
customSequencePane.setPreferredSize(new Dimension(width, AbstractSortPane.PANE_COMPONENT_HEIGHT));
customSequencePane.setBorder(BorderFactory.createEmptyBorder(0,0,0,3));
this.add(customSequencePane); 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; TinyFormulaPane tinyFormulaPane;
public FormulaSortExpressionPane(int width) { public FormulaSortExpressionPane(int width) {
this.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 1)); this.setLayout(new FlowLayout(FlowLayout.RIGHT, 2, 0));
tinyFormulaPane = new TinyFormulaPane(); 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); 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 { class DSColumnAdvancedEditorPane extends AbstractDSCellEditorPane {
/*pane begin*/ /*pane begin*/
/**
* 排列顺序
*/
private ResultSetSortConfigPane sortPane;
/** /**
* 结果集筛选 * 结果集筛选
*/ */
@ -377,7 +373,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
@Override @Override
public void update() { public void update() {
if (cellElement != null) { if (cellElement != null) {
sortPane.update(cellElement);
valuePane.update(cellElement); valuePane.update(cellElement);
formatAttrPane.update(cellElement); formatAttrPane.update(cellElement);
filterPane.update(cellElement); filterPane.update(cellElement);
@ -393,7 +388,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
public void populate() { public void populate() {
if (cellElement != null) { if (cellElement != null) {
this.removeAttributeChangeListener(); this.removeAttributeChangeListener();
sortPane.populate(cellElement);
valuePane.populate(cellElement); valuePane.populate(cellElement);
formatAttrPane.populate(cellElement); formatAttrPane.populate(cellElement);
filterPane.populate(cellElement); filterPane.populate(cellElement);
@ -500,10 +494,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
protected JPanel createContentPane() { protected JPanel createContentPane() {
JPanel contentPane = new JPanel(new BorderLayout()); JPanel contentPane = new JPanel(new BorderLayout());
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
//结果集排序
sortPane = new ResultSetSortConfigPane();
//结果筛选 //结果筛选
filterPane = new ResultSetFilterConfigPane(); filterPane = new ResultSetFilterConfigPane();
@ -538,7 +528,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
multiNumPane.add(multiPane); multiNumPane.add(multiPane);
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
{sortPane},
{filterPane}, {filterPane},
{valuePane}, {valuePane},
{formatAttrPane}, {formatAttrPane},
@ -552,9 +541,8 @@ public class CellDSColumnEditor extends CellQuickEditor {
JPanel advancePropertyPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); JPanel advancePropertyPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP);
contentPane.add(advancePropertyPane, BorderLayout.NORTH); contentPane.add(advancePropertyPane, BorderLayout.NORTH);
UIExpandablePane sortUIExpandablePane = 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()); 223, 24, cellDSColumnSortPane = new CellDSColumnSortPane());
contentPane.add(sortUIExpandablePane, BorderLayout.CENTER); contentPane.add(sortUIExpandablePane, BorderLayout.CENTER);
return contentPane; 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