|
|
@ -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(); |
|
|
|