|
|
@ -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,33 +129,52 @@ 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; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
prepareSelectHeader(elementCasePane); |
|
|
|
|
|
|
|
gridSelectionChangeListener = new SelectionListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void selectionChanged(SelectionEvent e) { |
|
|
|
|
|
|
|
completeSelectHeader(elementCasePane); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
elementCasePane.addSelectionChangeListener(gridSelectionChangeListener); |
|
|
|
|
|
|
|
isAlreadyAddListener = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void prepareSelectHeader(ElementCasePane elementCasePane) { |
|
|
|
|
|
|
|
ashDisableHeaderCellsStyle(elementCasePane.getEditingElementCase()); |
|
|
|
oldSelection = (CellSelection) elementCasePane.getSelection(); |
|
|
|
oldSelection = (CellSelection) elementCasePane.getSelection(); |
|
|
|
elementCasePane.getGrid().setNotShowingTableSelectPane(false); |
|
|
|
elementCasePane.getGrid().setNotShowingTableSelectPane(false); |
|
|
|
elementCasePane.setEditable(false); |
|
|
|
elementCasePane.setEditable(false); |
|
|
|
elementCasePane.repaint(10); |
|
|
|
elementCasePane.repaint(10); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
gridSelectionChangeListener = new SelectionListener() { |
|
|
|
private void completeSelectHeader(ElementCasePane elementCasePane) { |
|
|
|
@Override |
|
|
|
|
|
|
|
public void selectionChanged(SelectionEvent e) { |
|
|
|
|
|
|
|
Selection selection = elementCasePane.getSelection(); |
|
|
|
Selection selection = elementCasePane.getSelection(); |
|
|
|
if (selection instanceof CellSelection) { |
|
|
|
if (selection instanceof CellSelection) { |
|
|
|
CellSelection cellselection = (CellSelection) selection; |
|
|
|
CellSelection cellselection = (CellSelection) selection; |
|
|
|
ColumnRow cr = ColumnRow.valueOf(cellselection.getColumn(), cellselection.getRow()); |
|
|
|
ColumnRow columnRow = ColumnRow.valueOf(cellselection.getColumn(), cellselection.getRow()); |
|
|
|
elementCasePane.setOldSelecton(oldSelection); |
|
|
|
elementCasePane.setOldSelecton(oldSelection); |
|
|
|
columnRowPane.setColumnRow(cr); |
|
|
|
oldSelection.getQuickEditor(elementCasePane); |
|
|
|
|
|
|
|
if (!disableHeaderCellsStyleMap.keySet().contains(columnRow)) { |
|
|
|
|
|
|
|
columnRowPane.setColumnRow(columnRow); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
restoreDisableHeaderCellsStyle(elementCasePane.getEditingElementCase()); |
|
|
|
} |
|
|
|
} |
|
|
|
elementCasePane.removeSelectionChangeListener(gridSelectionChangeListener); |
|
|
|
elementCasePane.removeSelectionChangeListener(gridSelectionChangeListener); |
|
|
|
isAlreadyAddListener = false; |
|
|
|
isAlreadyAddListener = false; |
|
|
@ -146,9 +182,74 @@ public class SortColumnRowPane extends JPanel implements UIObserver { |
|
|
|
elementCasePane.setEditable(true); |
|
|
|
elementCasePane.setEditable(true); |
|
|
|
elementCasePane.repaint(); |
|
|
|
elementCasePane.repaint(); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
elementCasePane.addSelectionChangeListener(gridSelectionChangeListener); |
|
|
|
private void ashDisableHeaderCellsStyle(TemplateElementCase elementCase) { |
|
|
|
isAlreadyAddListener = true; |
|
|
|
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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -164,6 +265,8 @@ public class SortColumnRowPane extends JPanel implements UIObserver { |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected void refresh() { |
|
|
|
protected void refresh() { |
|
|
|
validate(); |
|
|
|
validate(); |
|
|
|