diff --git a/designer-base/src/main/java/com/fr/design/cell/CellRectangleStylePreviewPane.java b/designer-base/src/main/java/com/fr/design/cell/CellRectangleStylePreviewPane.java new file mode 100644 index 000000000..bde6b1371 --- /dev/null +++ b/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(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java b/designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java index cb6cfc8d5..885d3e8e1 100644 --- a/designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java +++ b/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; diff --git a/designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java b/designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java index 2e04b6ce5..fe85d5503 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java +++ b/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 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 @@ -213,7 +244,7 @@ public class BorderPane extends AbstractBasicStylePane implements GlobalNameObse if (BORDER_SET.contains(globalNameListener.getGlobalName())) { CellBorderStyle cellBorderStyle = this.update(); style = style.deriveBorder(cellBorderStyle.getTopStyle(), cellBorderStyle.getTopColor(), cellBorderStyle.getBottomStyle(), cellBorderStyle.getBottomColor(), - cellBorderStyle.getLeftStyle(), cellBorderStyle.getLeftColor(), cellBorderStyle.getRightStyle(), cellBorderStyle.getRightColor()); + cellBorderStyle.getLeftStyle(), cellBorderStyle.getLeftColor(), cellBorderStyle.getRightStyle(), cellBorderStyle.getRightColor()); } return style; @@ -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; } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/ThemedCellStyleListPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/ThemedCellStyleListPane.java similarity index 64% rename from designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/ThemedCellStyleListPane.java rename to designer-base/src/main/java/com/fr/design/mainframe/theme/ThemedCellStyleListPane.java index 78369ba13..53838d1c7 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/ThemedCellStyleListPane.java +++ b/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 implements DesignerBean { +public class ThemedCellStyleListPane extends FurtherBasicBeanPane implements DesignerBean { private static final int LEFT_BORDER = 10; private static final int RIGHT_BORDER = 10; - private final DefaultListModel defaultListModel; - private final JList styleList; + private final DefaultListModel defaultListModel; + private final JList 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 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 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 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 imp TemplateTheme theme = template.getTemplateTheme(); List 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, Serializable { + private static class RadioButtonListCellRenderer extends JPanel implements ListCellRenderer, Serializable { private final UIRadioButton button; private final CellStylePreviewPane previewArea; @@ -151,9 +132,36 @@ public class ThemedCellStyleListPane extends FurtherBasicBeanPane imp } @Override - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + public Component getListCellRendererComponent(JList 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, 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 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; } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/ThemedFeatureController.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/ThemedFeatureController.java new file mode 100644 index 000000000..2e0fc5c38 --- /dev/null +++ b/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; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/CellStyleListEditPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/CellStyleListEditPane.java index 6b12c37d4..ec0d085b9 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/CellStyleListEditPane.java +++ b/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 updatePane) { + public CellStyleNameObjectCreator(Class> 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); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/cell/CellStyleEditPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/cell/CellStyleEditPane.java index b2d182422..39e4394b8 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/cell/CellStyleEditPane.java +++ b/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 { private ThemedCellStyle cellStyle; - private CellStylePreviewPane previewArea; + private CellRectangleStylePreviewPane previewArea; private boolean populating; private AttributeChangeListener attributeChangeListener; @@ -74,7 +75,11 @@ public class CellStyleEditPane extends MultiTabPane { 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 { 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 { 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 cellStyle = updateBean(); if (cellStyle != null) { - previewArea.setStyle(cellStyle.getStyle()); + previewArea.setPlainText(cellStyle.getName()); + previewArea.setStyle(cellStyle.getStyle(), cellStyle.getCellBorderStyle()); } fireAttrChangeListener(); } diff --git a/designer-realize/src/main/java/com/fr/design/actions/cell/BorderAction.java b/designer-realize/src/main/java/com/fr/design/actions/cell/BorderAction.java index a23ec781b..596b61157 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/cell/BorderAction.java +++ b/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); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java index a678c501a..c28c00de5 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java +++ b/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,51 +72,28 @@ 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++) { - 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); - } - cellElement.setStyle(s); + 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 = stylePane.updateBean(); + cellElement.setStyle(style); } } - } 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); - cellElement.setStyle(style); - } - } - } - // border必须特别处理 - stylePane.updateBorder(selectionCellBorderObjects); + } + // border必须特别处理 + CellBorderStyle cellBorderStyle = stylePane.updateBorderStyle(); + if (cellBorderStyle != null) { + BorderUtils.update(elementCasePane, selectionCellBorderObjects, cellBorderStyle); } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/CellPredefinedStyleSettingPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/CellPredefinedStyleSettingPane.java index 4f38c8baa..bc246da8c 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/CellPredefinedStyleSettingPane.java +++ b/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 { } 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