Browse Source

REPORT-64080 【主题边框】框选设置样式外边框后,框选小部分切换自定义,之后设计器里显示有问题

【问题原因】
重新规范下交互效果,当框选的单元格样式从跟随主题切换到自定义时,
单元格的样式效果应当保持不变(从NameStyle变为Style),且右侧样式
面板应当是此框选区域的整体样式

【改动思路】
当样式设置从跟随主题切换到自定义时,应当将被选择的单元格样式设置
从NameStyle设置为Style,且不能使用样式面板中的设置重置单元格样式
feature/x
Starryi 3 years ago
parent
commit
07be63cef3
  1. 30
      designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java
  2. 62
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java
  3. 39
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java

30
designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java

@ -6,6 +6,7 @@ package com.fr.design.mainframe;
import com.fr.base.BaseFormula; import com.fr.base.BaseFormula;
import com.fr.base.DynamicUnitList; import com.fr.base.DynamicUnitList;
import com.fr.base.Formula; import com.fr.base.Formula;
import com.fr.base.NameStyle;
import com.fr.base.ScreenResolution; import com.fr.base.ScreenResolution;
import com.fr.base.Style; import com.fr.base.Style;
import com.fr.base.vcs.DesignerMode; import com.fr.base.vcs.DesignerMode;
@ -97,6 +98,7 @@ import com.fr.page.PageAttributeGetter;
import com.fr.page.ReportPageAttrProvider; import com.fr.page.ReportPageAttrProvider;
import com.fr.poly.creator.PolyElementCasePane; import com.fr.poly.creator.PolyElementCasePane;
import com.fr.report.ReportHelper; import com.fr.report.ReportHelper;
import com.fr.report.cell.CellElement;
import com.fr.report.cell.FloatElement; import com.fr.report.cell.FloatElement;
import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.TemplateCellElement;
import com.fr.report.cell.cellattr.core.RichText; import com.fr.report.cell.cellattr.core.RichText;
@ -133,6 +135,7 @@ import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.util.Iterator;
import java.util.Set; import java.util.Set;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
@ -1374,6 +1377,33 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
return cellNeedTOFormat; return cellNeedTOFormat;
} }
public void traverseSelectedCellElements(TemplateCellElementVisitor visitor) {
Selection selection = getSelection();
if (!(selection instanceof CellSelection)) {
return;
}
CellSelection cs = (CellSelection) selection;
TemplateElementCase elementCase = getEditingElementCase();
int cellRectangleCount = cs.getCellRectangleCount();
for (int rect = 0; rect < cellRectangleCount; rect++) {
Rectangle cellRectangle = cs.getCellRectangle(rect);
for (int j = 0; j < cellRectangle.height; j++) {
for (int i = 0; i < cellRectangle.width; i++) {
int column = i + cellRectangle.x;
int row = j + cellRectangle.y;
TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row);
visitor.visit(column, row, cellElement);
}
}
}
}
public interface TemplateCellElementVisitor {
void visit(int column, int row, TemplateCellElement cellElement);
}
private class ElementCaseEditingState implements EditingState { private class ElementCaseEditingState implements EditingState {
protected Selection selection; protected Selection selection;

62
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java

@ -1,22 +1,23 @@
package com.fr.design.mainframe.cell.settingpane; package com.fr.design.mainframe.cell.settingpane;
import com.fr.base.CellBorderStyle; import com.fr.base.CellBorderStyle;
import com.fr.base.NameStyle;
import com.fr.base.Style; import com.fr.base.Style;
import com.fr.design.actions.utils.ReportActionUtils; import com.fr.design.actions.utils.ReportActionUtils;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.gui.style.BorderPane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.cell.settingpane.style.StylePane; import com.fr.design.mainframe.cell.settingpane.style.StylePane;
import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase;
import com.fr.design.style.BorderUtils; import com.fr.design.style.BorderUtils;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.TemplateCellElement;
import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.elementcase.TemplateElementCase;
import javax.swing.*; import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import java.awt.*; import java.awt.BorderLayout;
/** /**
* @author zhou * @author zhou
@ -71,29 +72,56 @@ public class CellStylePane extends AbstractCellAttrPane {
@Override @Override
public void updateBeans() { public void updateBeans() {
Object[] selectionCellBorderObjects = BorderUtils.createCellBorderObject(elementCasePane); // 因为存在框选多个单元格的情况,跟随主题切换到自定义的行为似乎不太适合由updateBeans完成,它更像是个工具栏上的Action.
// 但它又会触发updateBeans...
boolean isSwitchToCustomStyleAction = stylePane.isFollowingThemeSettingChanged() && !stylePane.isFollowingTheme();
if (isSwitchToCustomStyleAction) {
switchCellStylesToCustom();
return;
}
updateCellStylesByPaneSettings();
}
private void switchCellStylesToCustom() {
TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); TemplateElementCase elementCase = elementCasePane.getEditingElementCase();
int cellRectangleCount = cs.getCellRectangleCount(); elementCasePane.traverseSelectedCellElements(new ElementCasePane.TemplateCellElementVisitor() {
for (int rect = 0; rect < cellRectangleCount; rect++) { @Override
Rectangle cellRectangle = cs.getCellRectangle(rect); public void visit(int column, int row, TemplateCellElement cellElement) {
for (int j = 0; j < cellRectangle.height; j++) {
for (int i = 0; i < cellRectangle.width; i++) {
int column = i + cellRectangle.x;
int row = j + cellRectangle.y;
TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row);
if (cellElement == null) { if (cellElement == null) {
cellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row); cellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row);
elementCase.addCellElement(cellElement); elementCase.addCellElement(cellElement);
} }
Style style = stylePane.updateBean(); Style style = cellElement.getStyle();
if (style instanceof NameStyle) {
style = ((NameStyle) style).getRealStyle();
}
if (style == null) {
style = Style.DEFAULT_STYLE;
}
cellElement.setStyle(style); cellElement.setStyle(style);
} }
});
}
private void updateCellStylesByPaneSettings() {
Object[] oldSelectionCellBorderObjects = BorderUtils.createCellBorderObject(elementCasePane);
TemplateElementCase elementCase = elementCasePane.getEditingElementCase();
elementCasePane.traverseSelectedCellElements(new ElementCasePane.TemplateCellElementVisitor() {
@Override
public void visit(int column, int row, TemplateCellElement cellElement) {
if (cellElement == null) {
cellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row);
elementCase.addCellElement(cellElement);
} }
Style style = stylePane.updateBean();
cellElement.setStyle(style);
} }
});
// border必须特别处理 // border必须特别处理
CellBorderStyle cellBorderStyle = stylePane.updateBorderStyle(); CellBorderStyle newCellBorderStyle = stylePane.updateBorderStyle();
if (cellBorderStyle != null) { if (newCellBorderStyle != null) {
BorderUtils.update(elementCasePane, selectionCellBorderObjects, cellBorderStyle); BorderUtils.update(elementCasePane, oldSelectionCellBorderObjects, newCellBorderStyle);
} }
} }

39
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java

@ -51,6 +51,7 @@ public class StylePane extends BasicPane implements UIObserver {
private final List<UIObserverListener> observerListeners = new ArrayList<>(); private final List<UIObserverListener> observerListeners = new ArrayList<>();
private Style backupStyleFromPopulating = Style.DEFAULT_STYLE; private Style backupStyleFromPopulating = Style.DEFAULT_STYLE;
private boolean isFollowingThemeSettingChanged = false;
public StylePane() { public StylePane() {
followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS); followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS);
@ -77,6 +78,7 @@ public class StylePane extends BasicPane implements UIObserver {
followingThemeButtonGroup.addActionListener(new ActionListener() { followingThemeButtonGroup.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
isFollowingThemeSettingChanged = true;
AttributeChangeUtils.changeComposedUI(StylePane.this, false, new AttributeChangeUtils.UIChangeAction() { AttributeChangeUtils.changeComposedUI(StylePane.this, false, new AttributeChangeUtils.UIChangeAction() {
@Override @Override
public void changeComposedUI() { public void changeComposedUI() {
@ -85,6 +87,7 @@ public class StylePane extends BasicPane implements UIObserver {
} }
}); });
fireStateChanged(); fireStateChanged();
isFollowingThemeSettingChanged = false;
} }
}); });
@ -103,6 +106,14 @@ public class StylePane extends BasicPane implements UIObserver {
cardLayout.show(contentPane, FOLLOWING_THEME_STRING_ARRAYS[selectedIndex]); cardLayout.show(contentPane, FOLLOWING_THEME_STRING_ARRAYS[selectedIndex]);
if (!isFollowingTheme) { if (!isFollowingTheme) {
// 对于同一个单元格,跟随主题切换到自定义,自定义中的配置与其保持一致 // 对于同一个单元格,跟随主题切换到自定义,自定义中的配置与其保持一致
syncCustomStylePaneBySelectedNameStyle();
} else {
// 对于同一个单元格,自定义切换到跟随主题,跟随主题选中"默认"样式,并使用默认样式设置选中的单元格
nameStyleListPane.reset();
}
}
private void syncCustomStylePaneBySelectedNameStyle() {
NameStyle lastSelectedNameStyle = nameStyleListPane.updateNameStyle(); NameStyle lastSelectedNameStyle = nameStyleListPane.updateNameStyle();
if (lastSelectedNameStyle != null) { if (lastSelectedNameStyle != null) {
Style lastSelectedRealStyle = lastSelectedNameStyle.getRealStyle(); Style lastSelectedRealStyle = lastSelectedNameStyle.getRealStyle();
@ -116,10 +127,10 @@ public class StylePane extends BasicPane implements UIObserver {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex); FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
} }
} }
} else {
// 对于同一个单元格,自定义切换到跟随主题,跟随主题选中"默认"样式,并使用默认样式设置选中的单元格
nameStyleListPane.reset();
} }
public boolean isFollowingThemeSettingChanged() {
return isFollowingThemeSettingChanged;
} }
protected JPanel createTabbedContentPane() { protected JPanel createTabbedContentPane() {
@ -161,14 +172,22 @@ public class StylePane extends BasicPane implements UIObserver {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style"); return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style");
} }
public void setSelectedIndex(int index) { public boolean isFollowingTheme() {
return getSelectedIndex() == 0;
}
public void setFollowingTheme(boolean followingTheme) {
setSelectedIndex(followingTheme ? 0 : 1);
}
private void setSelectedIndex(int index) {
if (0 <= index && index < FOLLOWING_THEME_STRING_ARRAYS.length) { if (0 <= index && index < FOLLOWING_THEME_STRING_ARRAYS.length) {
followingThemeButtonGroup.setSelectedIndex(index); followingThemeButtonGroup.setSelectedIndex(index);
cardLayout.show(contentPane, FOLLOWING_THEME_STRING_ARRAYS[index]); cardLayout.show(contentPane, FOLLOWING_THEME_STRING_ARRAYS[index]);
} }
} }
public int getSelectedIndex() { private int getSelectedIndex() {
return followingThemeButtonGroup.getSelectedIndex(); return followingThemeButtonGroup.getSelectedIndex();
} }
@ -185,11 +204,11 @@ public class StylePane extends BasicPane implements UIObserver {
} }
public void setSelctedByName(String id) { public void setSelctedByName(String id) {
setSelectedIndex(ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom"), id)? 1 : 0); setFollowingTheme(!ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom"), id));
} }
public CellBorderStyle updateBorderStyle() { public CellBorderStyle updateBorderStyle() {
if (getSelectedIndex() == 0) { if (isFollowingTheme()) {
return nameStyleListPane.updateBorderStyle(); return nameStyleListPane.updateBorderStyle();
} else if (customStylePane.isBorderPaneSelected()) { } else if (customStylePane.isBorderPaneSelected()) {
return customStylePane.updateBorderStyle(); return customStylePane.updateBorderStyle();
@ -199,7 +218,7 @@ public class StylePane extends BasicPane implements UIObserver {
public Style updateBean() { public Style updateBean() {
Style finalStyle = null; Style finalStyle = null;
if (getSelectedIndex() == 0) { if (isFollowingTheme()) {
finalStyle = nameStyleListPane.updateNameStyle(); finalStyle = nameStyleListPane.updateNameStyle();
} }
if (finalStyle == null) { if (finalStyle == null) {
@ -215,7 +234,7 @@ public class StylePane extends BasicPane implements UIObserver {
if (style instanceof NameStyle) { if (style instanceof NameStyle) {
NameStyle nameStyle = (NameStyle) style; NameStyle nameStyle = (NameStyle) style;
setSelectedIndex(0); setFollowingTheme(true);
nameStyleListPane.populateNameStyle(nameStyle); nameStyleListPane.populateNameStyle(nameStyle);
Style realStyle = nameStyle.getRealStyle(); Style realStyle = nameStyle.getRealStyle();
try { try {
@ -225,7 +244,7 @@ public class StylePane extends BasicPane implements UIObserver {
e.printStackTrace(); e.printStackTrace();
} }
} else { } else {
setSelectedIndex(1); setFollowingTheme(false);
customStylePane.populateBean(style); customStylePane.populateBean(style);
} }
//单元格配置界面是单例 所以直接在populate的时候把跟随主题的按钮组设置不可见 //单元格配置界面是单例 所以直接在populate的时候把跟随主题的按钮组设置不可见

Loading…
Cancel
Save