Browse Source

REPORT-71331 在选择表头区域时预览模板,预览效果异常

newui
Henry.Wang 2 years ago
parent
commit
8856e44221
  1. 17
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  2. 12
      designer-base/src/main/java/com/fr/design/mainframe/JTemplateActionListener.java
  3. 39
      designer-realize/src/main/java/com/fr/design/sort/common/SortColumnRowPane.java

17
designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

@ -1112,6 +1112,20 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
this.listenerList.remove(JTemplateActionListener.class, l);
}
/**
* 模板保存前触发
*/
public void fireJTemplateSaveBefore() {
Object[] listeners = listenerList.getListenerList();
for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == JTemplateActionListener.class) {
((JTemplateActionListener) listeners[i + 1]).templateSaveBefore(this);
}
}
this.repaint(30);
}
/**
* 触发模板关闭
*/
@ -1622,6 +1636,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
}
private CallbackSaveWorker save(boolean showLoc) {
fireJTemplateSaveBefore();
FILE editingFILE = this.getEditingFILE();
// carl:editingFILE没有,当然不存了,虽然不会有这种情况
if (editingFILE == null) {
@ -1917,7 +1932,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
}
public void setDesignerUIMode(){
public void setDesignerUIMode() {
DesignerUIModeConfig.getInstance().setAbsoluteMeasureUIMode();
}

12
designer-base/src/main/java/com/fr/design/mainframe/JTemplateActionListener.java

@ -4,9 +4,15 @@ import java.util.EventListener;
public interface JTemplateActionListener extends EventListener {
public void templateOpened(JTemplate<?, ?> jt);
default void templateOpened(JTemplate<?, ?> jt) {
}
public void templateSaved(JTemplate<?, ?> jt);
default void templateSaved(JTemplate<?, ?> jt) {
}
public void templateClosed(JTemplate<?, ?> jt);
default void templateClosed(JTemplate<?, ?> jt) {
}
default void templateSaveBefore(JTemplate<?, ?> jt) {
}
}

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

@ -3,13 +3,14 @@ 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;
import com.fr.design.event.UIObserverListener;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JTemplateActionListener;
import com.fr.design.selection.SelectionEvent;
import com.fr.design.selection.SelectionListener;
import com.fr.design.sort.header.HeaderAreaPane;
@ -18,10 +19,6 @@ 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;
@ -157,6 +154,7 @@ public class SortColumnRowPane extends JPanel implements UIObserver {
class SelectActionListener extends MouseAdapter {
SortColumnRowPane columnRowPane;
ColumnRow oldColumnRow;
JTemplateActionListener jTemplateActionListener;
Map<ColumnRow, Style> disableHeaderCellsStyleMap = new HashMap<>();
java.util.List<TemplateCellElement> tempHeaderCells = new ArrayList<>();
@ -178,13 +176,44 @@ public class SortColumnRowPane extends JPanel implements UIObserver {
@Override
public void selectionChanged(SelectionEvent e) {
completeSelectHeader(elementCasePane);
removeJTemplateActionListener();
}
};
elementCasePane.addSelectionChangeListener(gridSelectionChangeListener);
this.addJTemplateActionListener();
isAlreadyAddListener = true;
}
}
private void addJTemplateActionListener() {
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (jTemplate != null) {
removeJTemplateActionListener();
jTemplateActionListener = new JTemplateActionListener() {
@Override
public void templateSaveBefore(JTemplate<?, ?> jt) {
ElementCasePane elementCasePane = SortUtils.getCurrentElementCase();
if (elementCasePane != null) {
recoverSelectHeader(elementCasePane);
}
removeJTemplateActionListener();
}
};
jTemplate.addJTemplateActionListener(jTemplateActionListener);
}
}
private void removeJTemplateActionListener() {
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (jTemplate != null) {
if (jTemplateActionListener != null) {
jTemplate.removeJTemplateActionListener(jTemplateActionListener);
}
}
}
private void prepareSelectHeader(ElementCasePane elementCasePane) {
ashDisableHeaderCellsStyle(elementCasePane.getEditingElementCase());
oldSelection = (CellSelection) elementCasePane.getSelection();

Loading…
Cancel
Save