Browse Source

REPORT-62689 主题编辑的边框配置完善

【问题原因】
实现主题单元格样式支持内边框配置

【改动思路】
同上
feature/x
Starryi 3 years ago
parent
commit
0113bf2e89
  1. 79
      designer-base/src/main/java/com/fr/design/cell/CellRectangleStylePreviewPane.java
  2. 13
      designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java
  3. 101
      designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java
  4. 86
      designer-base/src/main/java/com/fr/design/mainframe/theme/ThemedCellStyleListPane.java
  5. 17
      designer-base/src/main/java/com/fr/design/mainframe/theme/ThemedFeatureController.java
  6. 18
      designer-base/src/main/java/com/fr/design/mainframe/theme/edit/CellStyleListEditPane.java
  7. 21
      designer-base/src/main/java/com/fr/design/mainframe/theme/edit/cell/CellStyleEditPane.java
  8. 60
      designer-realize/src/main/java/com/fr/design/actions/cell/BorderAction.java
  9. 33
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java
  10. 15
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/CellPredefinedStyleSettingPane.java
  11. 27
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java
  12. 54
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/NameStyleListPane.java
  13. 36
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java
  14. 16
      designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java
  15. 96
      designer-realize/src/main/java/com/fr/design/style/BorderUtils.java

79
designer-base/src/main/java/com/fr/design/cell/CellRectangleStylePreviewPane.java

@ -0,0 +1,79 @@
package com.fr.design.cell;
import com.fr.report.cell.CellElementBorderSourceFlag;
import com.fr.base.CellBorderStyle;
import com.fr.base.Style;
import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase;
import com.fr.report.cell.TemplateCellElement;
import javax.swing.JPanel;
import java.awt.Dimension;
import java.awt.GridLayout;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2021/9/3
*/
public class CellRectangleStylePreviewPane extends JPanel {
private static final int ROW_COUNT = 2;
private static final int COLUMN_COUNT = 2;
private final TemplateCellElement[][] cellElementGrid = new TemplateCellElement[ROW_COUNT][COLUMN_COUNT];
private final CellStylePreviewPane[][] cellStylePreviewPaneGrid = new CellStylePreviewPane[ROW_COUNT][COLUMN_COUNT];
public CellRectangleStylePreviewPane() {
setLayout(new GridLayout(2, 2));
for (int r = 0; r < ROW_COUNT; r++) {
for (int c = 0; c < COLUMN_COUNT; c++) {
CellStylePreviewPane pane = new CellStylePreviewPane();
TemplateCellElement cellElement = DefaultThemedTemplateCellElementCase.createInstance(c, r);
int flags = CellElementBorderSourceFlag.ALL_BORDER_SOURCE_OUTER;
if (r != 0) {
flags |= CellElementBorderSourceFlag.TOP_BORDER_SOURCE_INNER;
}
if (r != ROW_COUNT - 1) {
flags |= CellElementBorderSourceFlag.BOTTOM_BORDER_SOURCE_INNER;
}
if (c != 0) {
flags |= CellElementBorderSourceFlag.LEFT_BORDER_SOURCE_INNER;
}
if (c != COLUMN_COUNT - 1) {
flags |= CellElementBorderSourceFlag.RIGHT_BORDER_SOURCE_INNER;
}
cellElement.setBorderSourceFlags(flags);
pane.setStyle(cellElement.getStyle());
add(pane);
cellElementGrid[r][c] = cellElement;
cellStylePreviewPaneGrid[r][c] = pane;
}
}
}
public void setPlainText(String text) {
cellStylePreviewPaneGrid[0][1].setPaintText(text);
cellStylePreviewPaneGrid[1][1].setPaintText(text);
repaint();
}
public void setStyle(Style style, CellBorderStyle borderStyle) {
for (int i = 0; i < ROW_COUNT; i++) {
for (int j = 0; j < COLUMN_COUNT; j++) {
CellStylePreviewPane pane = cellStylePreviewPaneGrid[i][j];
TemplateCellElement cellElement = cellElementGrid[i][j];
cellElement.setStyle(style, borderStyle);
pane.setStyle(cellElement.getStyle());
}
}
repaint();
}
@Override
public Dimension getMinimumSize() {
return getPreferredSize();
}
}

13
designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java

@ -33,14 +33,21 @@ public class CellStylePreviewPane extends JPanel {
transparentBackgroundHeight = transparentBackgroundImage.getHeight(null);
}
public void setPaintText(String paintText) {
this.paintText = paintText;
repaint();
}
public void setStyle(Style style) {
this.style = style;
if (style instanceof NameStyle) {
paintText = ((NameStyle) style).getName();
}
repaint();
}
public void setStyle(NameStyle style) {
paintText = style.getName();
setStyle(style.getRealStyle());
}
@Override
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D) g;

101
designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java

@ -4,7 +4,6 @@ package com.fr.design.gui.style;
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved.
*/
import com.fr.base.BaseUtils;
import com.fr.base.CellBorderStyle;
import com.fr.base.Style;
import com.fr.design.constants.LayoutConstants;
@ -17,14 +16,20 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.style.color.NewColorSelectBox;
import com.fr.general.IOUtils;
import com.fr.stable.Constants;
import com.fr.stable.CoreConstants;
import javax.swing.*;
import javax.swing.Icon;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
@ -38,7 +43,6 @@ public class BorderPane extends AbstractBasicStylePane implements GlobalNameObse
private static final String[] BORDERARRAY = {"currentLineCombo", "currentLineColorPane", "outerToggleButton", "topToggleButton",
"leftToggleButton", "bottomToggleButton", "rightToggleButton", "innerToggleButton", "horizontalToggleButton", "verticalToggleButton"};
private static final Set<String> BORDER_SET = new HashSet<>(Arrays.asList(BORDERARRAY));
private boolean insideMode = false;
private UIToggleButton topToggleButton;
private UIToggleButton horizontalToggleButton;
@ -50,11 +54,8 @@ public class BorderPane extends AbstractBasicStylePane implements GlobalNameObse
private UIToggleButton innerToggleButton;
private UIToggleButton outerToggleButton;
private LineComboBox currentLineCombo;
private NewColorSelectBox currentLineColorPane;
private JPanel panel;
private JPanel borderPanel;
private JPanel backgroundPanel;
protected LineComboBox currentLineCombo;
protected NewColorSelectBox currentLineColorPane;
private BackgroundPane backgroundPane;
private GlobalNameListener globalNameListener = null;
@ -81,18 +82,18 @@ public class BorderPane extends AbstractBasicStylePane implements GlobalNameObse
new Component[]{null, null},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Color") + " ", SwingConstants.LEFT), currentLineColorPane},
new Component[]{null, null},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Out_Border") + " ", SwingConstants.LEFT), outerToggleButton = new UIToggleButton(new Icon[]{BaseUtils.readIcon("com/fr/design/images/m_format/out.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/out_white.png")}, false)},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Out_Border") + " ", SwingConstants.LEFT), outerToggleButton = new UIToggleButton(new Icon[]{IOUtils.readIcon("com/fr/design/images/m_format/out.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/out_white.png")}, false)},
new Component[]{null, externalPane},
new Component[]{null, null},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_In_Border") + " ", SwingConstants.LEFT), innerToggleButton = new UIToggleButton(new Icon[]{BaseUtils.readIcon("com/fr/design/images/m_format/in.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/in_white.png")}, false)},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_In_Border") + " ", SwingConstants.LEFT), innerToggleButton = new UIToggleButton(new Icon[]{IOUtils.readIcon("com/fr/design/images/m_format/in.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/in_white.png")}, false)},
new Component[]{null, insidePane},
new Component[]{null, null}
};
double[] rowSize = {p, p, p, p, p, p, p, p, p, p, p};
double[] columnSize = {p, f};
int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}};
panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_SMALL, LayoutConstants.VGAP_MEDIUM);
borderPanel = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Border"), 280, 24, panel);
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_SMALL, LayoutConstants.VGAP_MEDIUM);
JPanel borderPanel = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Border"), 280, 24, panel);
this.add(borderPanel, BorderLayout.NORTH);
UILabel backgroundFillLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Background_Fill"));
@ -102,7 +103,7 @@ public class BorderPane extends AbstractBasicStylePane implements GlobalNameObse
JPanel backgroundContainPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{backgroundFillLabel, backgroundPane}},
TableLayoutHelper.FILL_LASTCOLUMN, LayoutConstants.VGAP_SMALL, LayoutConstants.VGAP_MEDIUM);
backgroundPanel = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background"), 280, 24, backgroundContainPane);
JPanel backgroundPanel = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background"), 280, 24, backgroundContainPane);
this.add(backgroundPanel, BorderLayout.CENTER);
initAllNames();
outerToggleButton.addChangeListener(outerToggleButtonChangeListener);
@ -130,12 +131,12 @@ public class BorderPane extends AbstractBasicStylePane implements GlobalNameObse
};
private void initButtonsWithIcon() {
topToggleButton = new UIToggleButton(new Icon[]{BaseUtils.readIcon("/com/fr/base/images/dialog/border/top.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/top_white.png")}, false);
leftToggleButton = new UIToggleButton(new Icon[]{BaseUtils.readIcon("/com/fr/base/images/dialog/border/left.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/left_white.png")}, false);
bottomToggleButton = new UIToggleButton(new Icon[]{BaseUtils.readIcon("/com/fr/base/images/dialog/border/bottom.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bottom_white.png")}, false);
rightToggleButton = new UIToggleButton(new Icon[]{BaseUtils.readIcon("/com/fr/base/images/dialog/border/right.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/right_white.png")}, false);
horizontalToggleButton = new UIToggleButton(new Icon[]{BaseUtils.readIcon("/com/fr/base/images/dialog/border/horizontal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/horizontal_white.png")}, false);
verticalToggleButton = new UIToggleButton(new Icon[]{BaseUtils.readIcon("/com/fr/base/images/dialog/border/vertical.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/vertical_white.png")}, false);
topToggleButton = new UIToggleButton(new Icon[]{IOUtils.readIcon("/com/fr/base/images/dialog/border/top.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/top_white.png")}, false);
leftToggleButton = new UIToggleButton(new Icon[]{IOUtils.readIcon("/com/fr/base/images/dialog/border/left.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/left_white.png")}, false);
bottomToggleButton = new UIToggleButton(new Icon[]{IOUtils.readIcon("/com/fr/base/images/dialog/border/bottom.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bottom_white.png")}, false);
rightToggleButton = new UIToggleButton(new Icon[]{IOUtils.readIcon("/com/fr/base/images/dialog/border/right.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/right_white.png")}, false);
horizontalToggleButton = new UIToggleButton(new Icon[]{IOUtils.readIcon("/com/fr/base/images/dialog/border/horizontal.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/horizontal_white.png")}, false);
verticalToggleButton = new UIToggleButton(new Icon[]{IOUtils.readIcon("/com/fr/base/images/dialog/border/vertical.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/vertical_white.png")}, false);
this.currentLineCombo = new LineComboBox(CoreConstants.UNDERLINE_STYLE_ARRAY);
this.currentLineColorPane = new NewColorSelectBox(100);
}
@ -174,15 +175,15 @@ public class BorderPane extends AbstractBasicStylePane implements GlobalNameObse
cellBorderStyle.setRightStyle(style.getBorderRight());
cellBorderStyle.setRightColor(style.getBorderRightColor());
this.backgroundPane.populateBean(style.getBackground());
this.populateBean(cellBorderStyle, false, style.getBorderTop(), style.getBorderTopColor());
this.populateBean(cellBorderStyle, false);
}
public void populateBean(CellBorderStyle cellBorderStyle, boolean insideMode, int currentStyle, Color currentColor) {
this.insideMode = insideMode;
public void populateBean(CellBorderStyle cellBorderStyle, boolean insideMode) {
populateBean(cellBorderStyle, insideMode, true);
}
this.currentLineCombo.setSelectedLineStyle(cellBorderStyle.getTopStyle() == Constants.LINE_NONE ? Constants.LINE_THIN : cellBorderStyle.getTopStyle());
this.currentLineColorPane.setSelectObject(cellBorderStyle.getTopColor());
public void populateBean(CellBorderStyle cellBorderStyle, boolean insideMode, boolean onlyInspectTop) {
this.topToggleButton.setSelected(cellBorderStyle.getTopStyle() != Constants.LINE_NONE);
this.bottomToggleButton.setSelected(cellBorderStyle.getBottomStyle() != Constants.LINE_NONE);
@ -195,9 +196,39 @@ public class BorderPane extends AbstractBasicStylePane implements GlobalNameObse
this.innerToggleButton.setSelected(cellBorderStyle.getInnerBorder() != Constants.LINE_NONE);
this.outerToggleButton.setSelected(cellBorderStyle.getOuterBorderStyle() != Constants.LINE_NONE);
this.innerToggleButton.setEnabled(this.insideMode);
this.horizontalToggleButton.setEnabled(this.insideMode);
this.verticalToggleButton.setEnabled(this.insideMode);
this.innerToggleButton.setEnabled(insideMode);
this.horizontalToggleButton.setEnabled(insideMode);
this.verticalToggleButton.setEnabled(insideMode);
populateLineStyleAndColor(cellBorderStyle, onlyInspectTop);
}
public void populateLineStyleAndColor(CellBorderStyle cellBorderStyle, boolean onlyInspectTop) {
if (cellBorderStyle.getTopStyle() != Constants.LINE_NONE) {
this.currentLineCombo.setSelectedLineStyle(cellBorderStyle.getTopStyle());
this.currentLineColorPane.setSelectObject(cellBorderStyle.getTopColor());
} else if (!onlyInspectTop) {
if (cellBorderStyle.getBottomStyle() != Constants.LINE_NONE) {
this.currentLineCombo.setSelectedLineStyle(cellBorderStyle.getBottomStyle());
this.currentLineColorPane.setSelectObject(cellBorderStyle.getBottomColor());
} else if (cellBorderStyle.getLeftStyle() != Constants.LINE_NONE) {
this.currentLineCombo.setSelectedLineStyle(cellBorderStyle.getLeftStyle());
this.currentLineColorPane.setSelectObject(cellBorderStyle.getLeftColor());
} else if (cellBorderStyle.getRightStyle() != Constants.LINE_NONE) {
this.currentLineCombo.setSelectedLineStyle(cellBorderStyle.getRightStyle());
this.currentLineColorPane.setSelectObject(cellBorderStyle.getRightColor());
} else if (cellBorderStyle.getVerticalStyle() != Constants.LINE_NONE) {
this.currentLineCombo.setSelectedLineStyle(cellBorderStyle.getVerticalStyle());
this.currentLineColorPane.setSelectObject(cellBorderStyle.getVerticalColor());
} else if (cellBorderStyle.getHorizontalStyle() != Constants.LINE_NONE) {
this.currentLineCombo.setSelectedLineStyle(cellBorderStyle.getHorizontalStyle());
this.currentLineColorPane.setSelectObject(cellBorderStyle.getHorizontalColor());
}
}
if (this.currentLineCombo.getSelectedLineStyle() == Constants.LINE_NONE) {
this.currentLineCombo.setSelectedLineStyle(Constants.LINE_THIN);
}
}
@Override
@ -253,16 +284,8 @@ public class BorderPane extends AbstractBasicStylePane implements GlobalNameObse
}
cellBorderStyle.setHorizontalStyle(horizontalToggleButton.isSelected() ? lineStyle : Constants.LINE_NONE);
if (leftToggleButton.isSelected() && bottomToggleButton.isSelected() && rightToggleButton.isSelected() && topToggleButton.isSelected()) {
outerToggleButton.setSelected(true);
} else {
outerToggleButton.setSelected(false);
}
if (verticalToggleButton.isSelected() && horizontalToggleButton.isSelected()) {
innerToggleButton.setSelected(true);
} else {
innerToggleButton.setSelected(false);
}
outerToggleButton.setSelected(leftToggleButton.isSelected() && bottomToggleButton.isSelected() && rightToggleButton.isSelected() && topToggleButton.isSelected());
innerToggleButton.setSelected(verticalToggleButton.isSelected() && horizontalToggleButton.isSelected());
return cellBorderStyle;
}

86
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/ThemedCellStyleListPane.java → designer-base/src/main/java/com/fr/design/mainframe/theme/ThemedCellStyleListPane.java

@ -1,17 +1,15 @@
package com.fr.design.mainframe.cell.settingpane.style;
package com.fr.design.mainframe.theme;
import com.fr.base.NameStyle;
import com.fr.base.Style;
import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.settings.ThemedCellStyle;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.cell.CellRectangleStylePreviewPane;
import com.fr.design.cell.CellStylePreviewPane;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerBean;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.general.ComparatorUtils;
@ -30,18 +28,22 @@ import java.awt.Dimension;
import java.io.Serializable;
import java.util.List;
public class ThemedCellStyleListPane extends FurtherBasicBeanPane<NameStyle> implements DesignerBean {
public class ThemedCellStyleListPane extends FurtherBasicBeanPane<ThemedCellStyle> implements DesignerBean {
private static final int LEFT_BORDER = 10;
private static final int RIGHT_BORDER = 10;
private final DefaultListModel<NameStyle> defaultListModel;
private final JList<NameStyle> styleList;
private final DefaultListModel<ThemedCellStyle> defaultListModel;
private final JList<ThemedCellStyle> styleList;
private ChangeListener changeListener;
public ThemedCellStyleListPane() {
this(false);
}
public ThemedCellStyleListPane(boolean supportCellRange) {
defaultListModel = new DefaultListModel<>();
styleList = new JList<>(defaultListModel);
styleList.setCellRenderer(new RadioButtonListCellRenderer());
styleList.setCellRenderer(supportCellRange ? new RadioButtonListCellRangeRenderer() : new RadioButtonListCellRenderer());
styleList.setOpaque(false);
styleList.setBackground(null);
styleList.addListSelectionListener(new ListSelectionListener() {
@ -55,15 +57,8 @@ public class ThemedCellStyleListPane extends FurtherBasicBeanPane<NameStyle> imp
setLayout(FRGUIPaneFactory.createBorderLayout());
add(styleList, BorderLayout.CENTER);
setBorder(BorderFactory.createEmptyBorder(0 ,LEFT_BORDER, 0, RIGHT_BORDER));
DesignerContext.setDesignerBean("predefinedStyle", this);
}
/**
* 添加改变监听
*
* @param changeListener 监听事件
*/
public void addChangeListener(ChangeListener changeListener) {
this.changeListener = changeListener;
}
@ -77,7 +72,7 @@ public class ThemedCellStyleListPane extends FurtherBasicBeanPane<NameStyle> imp
}
@Override
public void populateBean(NameStyle ob) {
public void populateBean(ThemedCellStyle ob) {
refreshBeanElement();
if (ob == null) {
styleList.setSelectedIndex(0);
@ -92,32 +87,21 @@ public class ThemedCellStyleListPane extends FurtherBasicBeanPane<NameStyle> imp
}
@Override
public NameStyle updateBean() {
public ThemedCellStyle updateBean() {
return styleList.getSelectedValue();
}
/**
* 获取面板标题
*
* @return 标题
*/
@Override
public String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Report_Predefined_Style");
}
/**
* 是否可以接纳对象
*
* @param ob 组件对象
* @return 是否可以接纳对象
*/
@Override
public boolean accept(Object ob) {
return ob instanceof NameStyle;
return ob instanceof ThemedCellStyle;
}
/**
* 刷新组件对象
*/
@Override
public void refreshBeanElement() {
defaultListModel.removeAllElements();
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
@ -125,16 +109,13 @@ public class ThemedCellStyleListPane extends FurtherBasicBeanPane<NameStyle> imp
TemplateTheme theme = template.getTemplateTheme();
List<ThemedCellStyle> styleList = theme.getCellStyleList().getCellStyleList();
for (ThemedCellStyle themedCellStyle: styleList) {
String name = themedCellStyle.getName();
Style realStyle = themedCellStyle.getStyle();
NameStyle nameStyle = NameStyle.getPassiveInstance(name, realStyle);
defaultListModel.addElement(nameStyle);
defaultListModel.addElement(themedCellStyle);
}
}
styleList.setModel(defaultListModel);
}
private static class RadioButtonListCellRenderer extends JPanel implements ListCellRenderer<Object>, Serializable {
private static class RadioButtonListCellRenderer extends JPanel implements ListCellRenderer<ThemedCellStyle>, Serializable {
private final UIRadioButton button;
private final CellStylePreviewPane previewArea;
@ -151,9 +132,36 @@ public class ThemedCellStyleListPane extends FurtherBasicBeanPane<NameStyle> imp
}
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
public Component getListCellRendererComponent(JList<? extends ThemedCellStyle> list, ThemedCellStyle value, int index, boolean isSelected, boolean cellHasFocus) {
button.setSelected(isSelected);
previewArea.setPaintText(value.getName());
previewArea.setStyle(value.getStyle());
return this;
}
}
private static class RadioButtonListCellRangeRenderer extends JPanel implements ListCellRenderer<ThemedCellStyle>, Serializable {
private final UIRadioButton button;
private final CellRectangleStylePreviewPane previewArea;
public RadioButtonListCellRangeRenderer() {
super();
setLayout(new BorderLayout(5, 0));
setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
setPreferredSize(new Dimension(getPreferredSize().width, 80));
button = new UIRadioButton();
button.setBorder(BorderFactory.createEmptyBorder());
previewArea = new CellRectangleStylePreviewPane();
add(button, BorderLayout.WEST);
add(previewArea, BorderLayout.CENTER);
}
@Override
public Component getListCellRendererComponent(JList<? extends ThemedCellStyle> list, ThemedCellStyle value, int index, boolean isSelected, boolean cellHasFocus) {
button.setSelected(isSelected);
previewArea.setStyle((Style) value);
previewArea.setPlainText(value.getName());
previewArea.setStyle(value.getStyle(), value.getCellBorderStyle());
return this;
}
}

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

@ -0,0 +1,17 @@
package com.fr.design.mainframe.theme;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.theme.SupportThemedCellInnerBorderFeature;
import com.fr.workspace.server.theme.ThemedCellBorderFeature;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2021/11/26
*/
public class ThemedFeatureController {
public static boolean isCellStyleSupportInnerBorder() {
ThemedCellBorderFeature controller = WorkContext.getCurrent().get(ThemedCellBorderFeature.class);
return controller instanceof SupportThemedCellInnerBorderFeature;
}
}

18
designer-base/src/main/java/com/fr/design/mainframe/theme/edit/CellStyleListEditPane.java

@ -1,9 +1,7 @@
package com.fr.design.mainframe.theme.edit;
import com.fr.base.Style;
import com.fr.base.theme.settings.ThemedCellStyle;
import com.fr.base.theme.settings.ThemedCellStyleList;
import com.fr.config.predefined.PredefinedCellStyle;
import com.fr.design.actions.UpdateAction;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.dialog.FineJOptionPane;
@ -122,7 +120,7 @@ public class CellStyleListEditPane extends JListControlPane {
}
@Override
public BasicBeanPane createPaneByCreators(NameableCreator creator) {
public BasicBeanPane<?> createPaneByCreators(NameableCreator creator) {
CellStyleEditPane stylePane = (CellStyleEditPane) super.createPaneByCreators(creator);
stylePane.registerAttrChangeListener(attributeChangeListener);
return stylePane;
@ -256,23 +254,15 @@ public class CellStyleListEditPane extends JListControlPane {
this(CellStyleEditPane.class);
}
public CellStyleNameObjectCreator(Class<? extends BasicBeanPane> updatePane) {
public CellStyleNameObjectCreator(Class<? extends BasicBeanPane<?>> updatePane) {
super(i18nText("Fine-Design_Predefined_Cell_New_Style"), ThemedCellStyle.class, updatePane);
}
@Override
public Nameable createNameable(UnrepeatedNameHelper helper) {
ThemedCellStyle cellStyle = new ThemedCellStyle();
ThemedCellStyle cellStyle = ThemedCellStyle.createInstanceUsed4New();
cellStyle.setName(menuName);
cellStyle.setStyle(Style.getInstance());
cellStyle.setRemovable(true);
cellStyle.setUse4Default(false);
cellStyle.setUse4BigTitle(false);
cellStyle.setUse4SmallTitle(false);
cellStyle.setUse4Header(false);
cellStyle.setUse4MainText(false);
cellStyle.setUse4SupportInfo(false);
cellStyle.setUse4HighlightText(false);
return new NameObject(helper.createUnrepeatedName(this.menuName()), cellStyle);
}

21
designer-base/src/main/java/com/fr/design/mainframe/theme/edit/cell/CellStyleEditPane.java

@ -1,7 +1,7 @@
package com.fr.design.mainframe.theme.edit.cell;
import com.fr.base.theme.settings.ThemedCellStyle;
import com.fr.design.cell.CellStylePreviewPane;
import com.fr.design.cell.CellRectangleStylePreviewPane;
import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.AttrScrollPane;
import com.fr.design.dialog.BasicPane;
@ -14,6 +14,7 @@ import com.fr.design.gui.style.AlignmentPane;
import com.fr.design.gui.style.BorderPane;
import com.fr.design.gui.style.TextFontTippedPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.theme.ThemedFeatureController;
import com.fr.design.mainframe.theme.ui.BorderUtils;
import javax.swing.BorderFactory;
@ -35,7 +36,7 @@ import static com.fr.design.i18n.Toolkit.i18nText;
*/
public class CellStyleEditPane extends MultiTabPane<ThemedCellStyle> {
private ThemedCellStyle cellStyle;
private CellStylePreviewPane previewArea;
private CellRectangleStylePreviewPane previewArea;
private boolean populating;
private AttributeChangeListener attributeChangeListener;
@ -74,7 +75,11 @@ public class CellStyleEditPane extends MultiTabPane<ThemedCellStyle> {
for (BasicPane basicPane : paneList) {
((AbstractBasicStylePane) basicPane).populateBean(ob.getStyle());
previewArea.setStyle(ob.getStyle());
previewArea.setPlainText(ob.getName());
previewArea.setStyle(ob.getStyle(), ob.getCellBorderStyle());
if (ThemedFeatureController.isCellStyleSupportInnerBorder() && basicPane instanceof BorderPane) {
((BorderPane) basicPane).populateBean(ob.getCellBorderStyle(), true, false);
}
}
this.populating = false;
}
@ -83,6 +88,9 @@ public class CellStyleEditPane extends MultiTabPane<ThemedCellStyle> {
public ThemedCellStyle updateBean() {
AbstractBasicStylePane basicStylePane = (AbstractBasicStylePane) paneList.get(tabPane.getSelectedIndex());
this.cellStyle.setStyle(basicStylePane.update(this.cellStyle.getStyle()));
if (ThemedFeatureController.isCellStyleSupportInnerBorder() && basicStylePane instanceof BorderPane) {
this.cellStyle.setCellBorderStyle(((BorderPane) basicStylePane).update());
}
return this.cellStyle;
}
@ -108,8 +116,8 @@ public class CellStyleEditPane extends MultiTabPane<ThemedCellStyle> {
jPanel.setLayout(new BorderLayout(0, 4));
JPanel previewPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
previewArea = new CellStylePreviewPane();
previewArea.setPreferredSize(new Dimension(223, 30));
previewArea = new CellRectangleStylePreviewPane();
previewArea.setPreferredSize(new Dimension(223, 60));
previewPane.setBorder(BorderUtils.createTitleBorder(i18nText("Fine-Design_Basic_Preview")));
previewPane.add(previewArea, BorderLayout.CENTER);
@ -135,7 +143,8 @@ public class CellStyleEditPane extends MultiTabPane<ThemedCellStyle> {
}
ThemedCellStyle cellStyle = updateBean();
if (cellStyle != null) {
previewArea.setStyle(cellStyle.getStyle());
previewArea.setPlainText(cellStyle.getName());
previewArea.setStyle(cellStyle.getStyle(), cellStyle.getCellBorderStyle());
}
fireAttrChangeListener();
}

60
designer-realize/src/main/java/com/fr/design/actions/cell/BorderAction.java

@ -3,17 +3,27 @@
*/
package com.fr.design.actions.cell;
import javax.swing.JComponent;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import com.fr.base.BaseUtils;
import com.fr.base.CellBorderStyle;
import com.fr.base.NameStyle;
import com.fr.base.Style;
import com.fr.design.actions.ElementCaseAction;
import com.fr.design.actions.core.ActionFactory;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.style.BorderUtils;
import com.fr.grid.selection.CellSelection;
import com.fr.grid.selection.FloatSelection;
import com.fr.grid.selection.Selection;
import com.fr.report.cell.CellElementBorderSourceFlag;
import com.fr.report.cell.FloatElement;
import com.fr.report.cell.StyleProvider;
import com.fr.report.cell.TemplateCellElement;
import com.fr.report.elementcase.TemplateElementCase;
import com.fr.design.mainframe.ElementCasePane;
import javax.swing.JComponent;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.Rectangle;
/**
* Border.
@ -65,7 +75,45 @@ public class BorderAction extends ElementCaseAction implements ChangeListener {
return (JComponent) object;
}
public boolean update(ElementCasePane elementCasePane) {
public void resetElementStyleToCustom(StyleProvider provider) {
Style style = provider.getStyle();
if (style instanceof NameStyle) {
style = ((NameStyle) style).getRealStyle();
}
provider.setStyle(style);
}
public void resetSelectedElementsStyleToCustom(ElementCasePane<?> elementCasePane) {
Selection selection = elementCasePane.getSelection();
TemplateElementCase elementCase = elementCasePane.getEditingElementCase();
if (selection instanceof FloatSelection) {
FloatSelection floatSelection = (FloatSelection) selection;
FloatElement selectedFloatElement = elementCase.getFloatElement(floatSelection.getSelectedFloatName());
resetElementStyleToCustom(selectedFloatElement);
} else {
CellSelection cellSelection = (CellSelection) selection;
int cellRectangleCount = cellSelection.getCellRectangleCount();
for (int rect = 0; rect < cellRectangleCount; rect++) {
Rectangle cellRectangle = cellSelection.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);
if (cellElement != null) {
resetElementStyleToCustom(cellElement);
cellElement.setBorderSourceFlags(CellElementBorderSourceFlag.INVALID_BORDER_SOURCE);
};
}
}
}
}
}
public boolean update(ElementCasePane<?> elementCasePane) {
resetSelectedElementsStyleToCustom(elementCasePane);
if (oldCellBorderStyle.isNoneBorderStyle()) {
//无边框格式
return BorderUtils.updateCellBorderStyle(elementCasePane, oldCellBorderStyle);

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

@ -1,8 +1,10 @@
package com.fr.design.mainframe.cell.settingpane;
import com.fr.base.CellBorderStyle;
import com.fr.base.Style;
import com.fr.design.actions.utils.ReportActionUtils;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.style.BorderPane;
import com.fr.design.mainframe.cell.settingpane.style.StylePane;
import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase;
import com.fr.design.style.BorderUtils;
@ -70,8 +72,6 @@ public class CellStylePane extends AbstractCellAttrPane {
@Override
public void updateBeans() {
Object[] selectionCellBorderObjects = BorderUtils.createCellBorderObject(elementCasePane);
if (stylePane.getSelectedIndex() == 0) {
Style s = stylePane.updateBean();
TemplateElementCase elementCase = elementCasePane.getEditingElementCase();
int cellRectangleCount = cs.getCellRectangleCount();
for (int rect = 0; rect < cellRectangleCount; rect++) {
@ -85,36 +85,15 @@ public class CellStylePane extends AbstractCellAttrPane {
cellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row);
elementCase.addCellElement(cellElement);
}
cellElement.setStyle(s);
}
}
}
} else {
TemplateElementCase elementCase = elementCasePane.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);
if (cellElement == null) {
cellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row);
elementCase.addCellElement(cellElement);
}
Style style = cellElement.getStyle();
if (style == null) {
style = Style.DEFAULT_STYLE;
}
style = stylePane.updateStyle(style);
Style style = stylePane.updateBean();
cellElement.setStyle(style);
}
}
}
// border必须特别处理
stylePane.updateBorder(selectionCellBorderObjects);
CellBorderStyle cellBorderStyle = stylePane.updateBorderStyle();
if (cellBorderStyle != null) {
BorderUtils.update(elementCasePane, selectionCellBorderObjects, cellBorderStyle);
}
}

15
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/CellPredefinedStyleSettingPane.java

@ -3,15 +3,11 @@ package com.fr.design.mainframe.cell.settingpane.style;
import com.fr.base.CellBorderStyle;
import com.fr.base.NameStyle;
import com.fr.base.Style;
import com.fr.config.predefined.PredefinedCellStyle;
import com.fr.config.predefined.PredefinedCellStyleConfig;
import com.fr.config.predefined.PredefinedStyle;
import com.fr.design.actions.utils.ReportActionUtils;
import com.fr.design.constants.UIConstants;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.MultiTabPane;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.style.AbstractBasicStylePane;
@ -21,25 +17,20 @@ import com.fr.design.gui.style.FormatPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.predefined.ui.PredefinedStyleSettingPane;
import com.fr.design.mainframe.predefined.ui.preview.StyleSettingPreviewPane;
import com.fr.design.style.BorderUtils;
//import com.fr.predefined.PredefinedPatternStyleManager;
import com.fr.stable.Constants;
import com.fr.stable.StringUtils;
import com.fr.third.javax.annotation.Nonnull;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* Created by kerry on 2020-09-02
@ -212,11 +203,9 @@ public class CellPredefinedStyleSettingPane extends PredefinedStyleSettingPane<N
if (fourObjectArray != null && fourObjectArray.length % LENGTH_FOUR == 0) {
if (fourObjectArray.length == LENGTH_FOUR) {
((BorderPane) paneList.get(ONE_INDEX)).populateBean((CellBorderStyle) fourObjectArray[0], ((Boolean) fourObjectArray[1]).booleanValue(), ((Integer) fourObjectArray[2]).intValue(),
(Color) fourObjectArray[THREE_INDEX]);
((BorderPane) paneList.get(ONE_INDEX)).populateBean((CellBorderStyle) fourObjectArray[0], ((Boolean) fourObjectArray[1]).booleanValue());
} else {
((BorderPane) paneList.get(ONE_INDEX)).populateBean(new CellBorderStyle(), Boolean.TRUE, Constants.LINE_NONE,
(Color) fourObjectArray[THREE_INDEX]);
((BorderPane) paneList.get(ONE_INDEX)).populateBean(new CellBorderStyle(), Boolean.TRUE);
}
}

27
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java

@ -11,8 +11,6 @@ import com.fr.design.gui.style.*;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.style.BorderUtils;
import com.fr.stable.Constants;
import javax.swing.*;
import javax.swing.event.ChangeListener;
import java.awt.*;
@ -115,19 +113,25 @@ public class CustomStylePane extends MultiTabPane<Style> {
}
public void dealWithBorder() {
dealWithBorder(true);
}
public void dealWithBorder(boolean onlyInspectTop) {
if (reportPane == null) {
return;
}
Object[] fourObjectArray = BorderUtils.createCellBorderObject(reportPane);
if (fourObjectArray != null && fourObjectArray.length % LENGTH_FOUR == 0) {
if (fourObjectArray.length % LENGTH_FOUR == 0) {
CellBorderStyle cellBorderStyle = new CellBorderStyle();
boolean insideMode = true;
if (fourObjectArray.length == LENGTH_FOUR) {
((BorderPane) paneList.get(ONE_INDEX)).populateBean((CellBorderStyle) fourObjectArray[0], ((Boolean) fourObjectArray[1]).booleanValue(), ((Integer) fourObjectArray[2]).intValue(),
(Color) fourObjectArray[THREE_INDEX]);
} else {
((BorderPane) paneList.get(ONE_INDEX)).populateBean(new CellBorderStyle(), Boolean.TRUE, Constants.LINE_NONE,
(Color) fourObjectArray[THREE_INDEX]);
cellBorderStyle = (CellBorderStyle) fourObjectArray[0];
insideMode = (Boolean) fourObjectArray[1];
}
BorderPane borderPane = (BorderPane) paneList.get(ONE_INDEX);
borderPane.populateBean(cellBorderStyle, insideMode, onlyInspectTop);
}
}
@ -139,11 +143,8 @@ public class CustomStylePane extends MultiTabPane<Style> {
dealWithBorder();
}
/**
*
*/
public void updateBorder(Object[] selectionCellBorderObjects) {
BorderUtils.update(reportPane, selectionCellBorderObjects, ((BorderPane) paneList.get(ONE_INDEX)).update());
public CellBorderStyle updateBorderStyle() {
return ((BorderPane) paneList.get(ONE_INDEX)).update();
}
/**

54
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/NameStyleListPane.java

@ -0,0 +1,54 @@
package com.fr.design.mainframe.cell.settingpane.style;
import com.fr.base.CellBorderStyle;
import com.fr.base.NameStyle;
import com.fr.base.Style;
import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.settings.ThemedCellStyle;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.theme.ThemedCellStyleListPane;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2021/11/23
*/
public class NameStyleListPane extends ThemedCellStyleListPane {
public NameStyleListPane() {
}
public NameStyleListPane(boolean supportCellRange) {
super(supportCellRange);
}
public void populateNameStyle(NameStyle style) {
String name = style.getName();
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) {
TemplateTheme theme = template.getTemplateTheme();
ThemedCellStyle themedCellStyle = theme.getCellStyleList().find(name);
populateBean(themedCellStyle);
}
}
public NameStyle updateNameStyle() {
ThemedCellStyle themedCellStyle = updateBean();
if (themedCellStyle != null) {
String name = themedCellStyle.getName();
Style style = themedCellStyle.getStyle();
return NameStyle.getPassiveInstance(name, style);
}
return null;
}
public CellBorderStyle updateBorderStyle() {
ThemedCellStyle nameStyle = updateBean();
if (nameStyle != null) {
return nameStyle.getCellBorderStyle();
}
return null;
}
}

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

@ -1,5 +1,6 @@
package com.fr.design.mainframe.cell.settingpane.style;
import com.fr.base.CellBorderStyle;
import com.fr.base.NameStyle;
import com.fr.base.Style;
import com.fr.design.designer.IntervalConstants;
@ -41,7 +42,7 @@ public class StylePane extends BasicPane implements UIObserver {
private final UIButtonGroup<String> followingThemeButtonGroup;
private JPanel followingThemePane;
private final CustomStylePane customStylePane;
private final ThemedCellStyleListPane themedCellStyleListPane;
private final NameStyleListPane nameStyleListPane;
private final CardLayout cardLayout;
private final JComponent[] panes = new JComponent[2];
@ -55,7 +56,7 @@ public class StylePane extends BasicPane implements UIObserver {
followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS);
followingThemeButtonGroup.setAutoFireStateChanged(false);
customStylePane = new CustomStylePane();
themedCellStyleListPane = new ThemedCellStyleListPane();
nameStyleListPane = new NameStyleListPane(true);
panes[0] = createThemedStylePane();
panes[1] = createCustomStylePane();
cardLayout = new CardLayout();
@ -102,7 +103,7 @@ public class StylePane extends BasicPane implements UIObserver {
cardLayout.show(contentPane, FOLLOWING_THEME_STRING_ARRAYS[selectedIndex]);
if (!isFollowingTheme) {
// 对于同一个单元格,跟随主题切换到自定义,自定义中的配置与其保持一致
NameStyle lastSelectedNameStyle = themedCellStyleListPane.updateBean();
NameStyle lastSelectedNameStyle = nameStyleListPane.updateNameStyle();
if (lastSelectedNameStyle != null) {
Style lastSelectedRealStyle = lastSelectedNameStyle.getRealStyle();
try {
@ -117,7 +118,7 @@ public class StylePane extends BasicPane implements UIObserver {
}
} else {
// 对于同一个单元格,自定义切换到跟随主题,跟随主题选中"默认"样式,并使用默认样式设置选中的单元格
themedCellStyleListPane.reset();
nameStyleListPane.reset();
}
}
@ -143,11 +144,11 @@ public class StylePane extends BasicPane implements UIObserver {
private JPanel createThemedStylePane() {
JPanel container = new JPanel(new BorderLayout(0, IntervalConstants.INTERVAL_L1));
UILabel uiLabel = new UILabel(Toolkit.i18nText("Fine-Design_Style_Selecting"));
UILabel uiLabel = new UILabel(Toolkit.i18nText("Fine-Design_Style_Applying"));
uiLabel.setPreferredSize(new Dimension(uiLabel.getPreferredSize().width, 20));
container.add(uiLabel, BorderLayout.NORTH);
themedCellStyleListPane.setBorder(BorderFactory.createEmptyBorder());
container.add(themedCellStyleListPane, BorderLayout.CENTER);
nameStyleListPane.setBorder(BorderFactory.createEmptyBorder());
container.add(nameStyleListPane, BorderLayout.CENTER);
return container;
}
@ -172,19 +173,13 @@ public class StylePane extends BasicPane implements UIObserver {
}
public void addPredefinedChangeListener(ChangeListener changeListener) {
themedCellStyleListPane.addChangeListener(changeListener);
nameStyleListPane.addChangeListener(changeListener);
}
public void addCustomTabChangeListener(ChangeListener changeListener) {
customStylePane.addTabChangeListener(changeListener);
}
public void updateBorder(Object[] selectionCellBorderObjects) {
if (getSelectedIndex() == 1 && customStylePane.isBorderPaneSelected()) {
customStylePane.updateBorder(selectionCellBorderObjects);
}
}
public void dealWithBorder(ElementCasePane ePane) {
customStylePane.dealWithBorder(ePane);
}
@ -193,14 +188,19 @@ public class StylePane extends BasicPane implements UIObserver {
setSelectedIndex(ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom"), id)? 1 : 0);
}
public Style updateStyle(Style style) {
return customStylePane.updateStyle(style);
public CellBorderStyle updateBorderStyle() {
if (getSelectedIndex() == 0) {
return nameStyleListPane.updateBorderStyle();
} else if (customStylePane.isBorderPaneSelected()) {
return customStylePane.updateBorderStyle();
}
return null;
}
public Style updateBean() {
Style finalStyle = null;
if (getSelectedIndex() == 0) {
finalStyle = themedCellStyleListPane.updateBean();
finalStyle = nameStyleListPane.updateNameStyle();
}
if (finalStyle == null) {
finalStyle = customStylePane.updateBean();
@ -216,7 +216,7 @@ public class StylePane extends BasicPane implements UIObserver {
if (style instanceof NameStyle) {
NameStyle nameStyle = (NameStyle) style;
setSelectedIndex(0);
themedCellStyleListPane.populateBean(nameStyle);
nameStyleListPane.populateNameStyle(nameStyle);
Style realStyle = nameStyle.getRealStyle();
try {
realStyle = (Style) realStyle.clone();

16
designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java

@ -18,7 +18,7 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.cell.settingpane.style.ThemedCellStyleListPane;
import com.fr.design.mainframe.cell.settingpane.style.NameStyleListPane;
import com.fr.design.mainframe.theme.ui.NoEdgeTitleBorder;
import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase;
import com.fr.design.style.AlignmentPane;
@ -531,7 +531,7 @@ public class ReportStylePane extends BasicPane {
private static class ThemedFloatStyleSettingPane extends BasicPane implements ChangeListener {
private final ThemedCellStyleListPane themedCellStyleListPane;
private final NameStyleListPane nameStyleListPane;
private final FormatPane formatPane;
private final List<ChangeListener> changeListeners = new ArrayList<>();
@ -541,9 +541,9 @@ public class ReportStylePane extends BasicPane {
UITabbedPane mainTabbedPane = new UITabbedPane();
setLayout(FRGUIPaneFactory.createBorderLayout());
themedCellStyleListPane = new ThemedCellStyleListPane();
themedCellStyleListPane.setBorder(BorderFactory.createEmptyBorder());
UIScrollPane scrollPane = new UIScrollPane(themedCellStyleListPane);
nameStyleListPane = new NameStyleListPane();
nameStyleListPane.setBorder(BorderFactory.createEmptyBorder());
UIScrollPane scrollPane = new UIScrollPane(nameStyleListPane);
scrollPane.setBorder(BorderFactory.createEmptyBorder(10, 5, 5, 0));
scrollPane.setPreferredSize(new Dimension(620, scrollPane.getPreferredSize().height));
add(scrollPane, BorderLayout.CENTER);
@ -558,17 +558,17 @@ public class ReportStylePane extends BasicPane {
}
public void populateBean(NameStyle style) {
themedCellStyleListPane.populateBean(style);
nameStyleListPane.populateNameStyle(style);
formatPane.populate(style.getFormat());
}
public NameStyle updateBean() {
NameStyle style = themedCellStyleListPane.updateBean();
NameStyle style = nameStyleListPane.updateNameStyle();
return (NameStyle) style.deriveFormat(formatPane.update());
}
public void reset(Style style) {
themedCellStyleListPane.reset();
nameStyleListPane.reset();
formatPane.populate(style.getFormat());
}

96
designer-realize/src/main/java/com/fr/design/style/BorderUtils.java

@ -6,9 +6,12 @@ import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import com.fr.report.cell.CellElementBorderSourceFlag;
import com.fr.base.CellBorderStyle;
import com.fr.base.NameStyle;
import com.fr.base.Style;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.theme.ThemedFeatureController;
import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase;
import com.fr.general.ComparatorUtils;
import com.fr.grid.selection.CellSelection;
@ -463,24 +466,24 @@ public abstract class BorderUtils {
* Update ElementCasePane. Return whether cell border changed. true is
* changed, need to support undo/redo
*/
public static boolean update(ElementCasePane reportPane, CellBorderStyle newCellBorderStyle) {
public static boolean update(ElementCasePane<?> reportPane, CellBorderStyle newCellBorderStyle) {
Object[] selectionCellBorderObjects = createCellBorderObject(reportPane);
return update(reportPane, selectionCellBorderObjects, newCellBorderStyle);
}
public static boolean update(ElementCasePane reportPane, Object[] selectionCellBorderObjects, CellBorderStyle newCellBorderStyle) {
public static boolean update(ElementCasePane<?> reportPane, Object[] selectionCellBorderObjects, CellBorderStyle newCellBorderStyle) {
boolean isBorderColorStyleChanged = false;
Object[] fourObjectArray = selectionCellBorderObjects;
if (fourObjectArray == null || fourObjectArray.length < NUMBER) {
return false;
}
CellBorderStyle cellBorderStyle = (CellBorderStyle) fourObjectArray[0];
TemplateElementCase report = reportPane.getEditingElementCase();
Selection sel = reportPane.getSelection();
if (sel instanceof FloatSelection) {
CellBorderStyle oldCellBorderStyle = (CellBorderStyle) fourObjectArray[0];
FloatElement selectedFloatElement = report.getFloatElement(((FloatSelection) sel).getSelectedFloatName());
// Border变化了.
if (!ComparatorUtils.equals(cellBorderStyle, newCellBorderStyle)) {
if (!ComparatorUtils.equals(oldCellBorderStyle, newCellBorderStyle)) {
isBorderColorStyleChanged = true;
// peter:复制边框.
Style style = selectedFloatElement.getStyle();
@ -493,7 +496,7 @@ public abstract class BorderUtils {
} else {
int cellRectangleCount = ((CellSelection) sel).getCellRectangleCount();
for (int rect = 0; rect < cellRectangleCount; rect++) {
cellBorderStyle = (CellBorderStyle) fourObjectArray[rect * NUMBER];
CellBorderStyle oldCellBorderStyle = (CellBorderStyle) fourObjectArray[rect * NUMBER];
Rectangle cellRectangle = ((CellSelection) sel).getCellRectangle(rect);
int column = cellRectangle.x;
int row = cellRectangle.y;
@ -501,9 +504,9 @@ public abstract class BorderUtils {
int rowSpan = cellRectangle.height;
// Border变化了.
if (!ComparatorUtils.equals(cellBorderStyle, newCellBorderStyle)) {
if (!ComparatorUtils.equals(oldCellBorderStyle, newCellBorderStyle)) {
isBorderColorStyleChanged = true;
setStyle(row, column, rowSpan, columnSpan, report, cellBorderStyle, newCellBorderStyle);
setStyle(row, column, rowSpan, columnSpan, report, newCellBorderStyle);
}
}
}
@ -511,7 +514,7 @@ public abstract class BorderUtils {
return isBorderColorStyleChanged;
}
private static void setStyle(int row, int column, int rowSpan, int columnSpan, TemplateElementCase report, CellBorderStyle cellBorderStyle, CellBorderStyle newCellBorderStyle) {
private static void setStyle(int row, int column, int rowSpan, int columnSpan, TemplateElementCase report, CellBorderStyle newCellBorderStyle) {
for (int i = column; i < column + columnSpan; i++) {
for (int j = row; j < row + rowSpan; j++) {
TemplateCellElement tmpCellElement = report.getTemplateCellElement(i, j);
@ -520,74 +523,21 @@ public abstract class BorderUtils {
report.addCellElement(tmpCellElement);
}
Style style = tmpCellElement.getStyle();
style = inspectStyle(row, column, rowSpan, columnSpan, cellBorderStyle, newCellBorderStyle, tmpCellElement, style);
tmpCellElement.setStyle(style);
}
}
}
private static Style inspectStyle(int row, int column, int rowSpan, int columnSpan, CellBorderStyle cellBorderStyle, CellBorderStyle newCellBorderStyle, TemplateCellElement tmpCellElement, Style style) {
if (tmpCellElement.getColumn() == column) {
if (cellBorderStyle.getLeftStyle() != newCellBorderStyle.getLeftStyle()
|| !ComparatorUtils.equals(cellBorderStyle.getLeftColor(), newCellBorderStyle.getLeftColor())) {
style = style.deriveBorderLeft(newCellBorderStyle.getLeftStyle(), newCellBorderStyle.getLeftColor());
} else {
style = style.deriveBorderLeft(cellBorderStyle.getLeftStyle(), cellBorderStyle.getLeftColor());
}
} else {
if (cellBorderStyle.getVerticalStyle() != newCellBorderStyle.getVerticalStyle()
|| !ComparatorUtils.equals(cellBorderStyle.getVerticalColor(), newCellBorderStyle.getVerticalColor())) {
style = style.deriveBorderLeft(newCellBorderStyle.getVerticalStyle(), newCellBorderStyle.getVerticalColor());
} else {
style = style.deriveBorderLeft(cellBorderStyle.getVerticalStyle(), cellBorderStyle.getVerticalColor());
int cellColumn = tmpCellElement.getColumn();
int cellColumnSpan = tmpCellElement.getColumnSpan();
int cellRow = tmpCellElement.getRow();
int cellRowSpan = tmpCellElement.getRowSpan();
int borderSourceFlags = CellElementBorderSourceFlag.inspectBorderSourceFlag(
column, row, column + columnSpan, row + rowSpan,
cellColumn, cellRow, cellColumn + cellColumnSpan, cellRow + cellRowSpan
);
tmpCellElement.setBorderSourceFlags(borderSourceFlags);
if (style instanceof NameStyle && !ThemedFeatureController.isCellStyleSupportInnerBorder()) {
tmpCellElement.setBorderSourceFlags(CellElementBorderSourceFlag.INVALID_BORDER_SOURCE);
}
}
if (tmpCellElement.getColumn() + tmpCellElement.getColumnSpan() == column + columnSpan) {
if (cellBorderStyle.getRightStyle() != newCellBorderStyle.getRightStyle()
|| !ComparatorUtils.equals(cellBorderStyle.getRightColor(), newCellBorderStyle.getRightColor())) {
style = style.deriveBorderRight(newCellBorderStyle.getRightStyle(), newCellBorderStyle.getRightColor());
} else {
style = style.deriveBorderRight(cellBorderStyle.getRightStyle(), cellBorderStyle.getRightColor());
}
} else {
if (cellBorderStyle.getVerticalStyle() != newCellBorderStyle.getVerticalStyle()
|| !ComparatorUtils.equals(cellBorderStyle.getVerticalColor(), newCellBorderStyle.getVerticalColor())) {
style = style.deriveBorderRight(newCellBorderStyle.getVerticalStyle(), newCellBorderStyle.getVerticalColor());
} else {
style = style.deriveBorderRight(cellBorderStyle.getVerticalStyle(), cellBorderStyle.getVerticalColor());
tmpCellElement.setStyle(style, newCellBorderStyle);
}
}
if (tmpCellElement.getRow() == row) {
if (cellBorderStyle.getTopStyle() != newCellBorderStyle.getTopStyle()
|| !ComparatorUtils.equals(cellBorderStyle.getTopColor(), newCellBorderStyle.getTopColor())) {
style = style.deriveBorderTop(newCellBorderStyle.getTopStyle(), newCellBorderStyle.getTopColor());
} else {
style = style.deriveBorderTop(cellBorderStyle.getTopStyle(), cellBorderStyle.getTopColor());
}
} else {
if (cellBorderStyle.getHorizontalStyle() != newCellBorderStyle.getHorizontalStyle()
|| !ComparatorUtils.equals(cellBorderStyle.getHorizontalColor(), newCellBorderStyle.getHorizontalColor())) {
style = style.deriveBorderTop(newCellBorderStyle.getHorizontalStyle(), newCellBorderStyle.getHorizontalColor());
} else {
style = style.deriveBorderTop(cellBorderStyle.getHorizontalStyle(), cellBorderStyle.getHorizontalColor());
}
}
if (tmpCellElement.getRow() + tmpCellElement.getRowSpan() == row + rowSpan) {
if (cellBorderStyle.getBottomStyle() != newCellBorderStyle.getBottomStyle()
|| !ComparatorUtils.equals(cellBorderStyle.getBottomColor(), newCellBorderStyle.getBottomColor())) {
style = style.deriveBorderBottom(newCellBorderStyle.getBottomStyle(), newCellBorderStyle.getBottomColor());
} else {
style = style.deriveBorderBottom(cellBorderStyle.getBottomStyle(), cellBorderStyle.getBottomColor());
}
} else {
if (cellBorderStyle.getHorizontalStyle() != newCellBorderStyle.getHorizontalStyle()
|| !ComparatorUtils.equals(cellBorderStyle.getHorizontalColor(), newCellBorderStyle.getHorizontalColor())) {
style = style.deriveBorderBottom(newCellBorderStyle.getHorizontalStyle(), newCellBorderStyle.getHorizontalColor());
} else {
style = style.deriveBorderBottom(cellBorderStyle.getHorizontalStyle(), cellBorderStyle.getHorizontalColor());
}
}
return style;
}
private static boolean isAllEquals(List borderStyleColorList) {

Loading…
Cancel
Save