Browse Source

POM-2302 cpt组件默认样式

feature/10.0
shine 3 years ago
parent
commit
68a3d41504
  1. 7
      designer-base/src/main/java/com/fr/design/gui/itextfield/EditTextField.java
  2. 45
      designer-base/src/main/java/com/fr/design/utils/gui/AdjustWorkBookDefaultStyleUtils.java
  3. 8
      designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java
  4. 6
      designer-realize/src/main/java/com/fr/design/actions/insert/flot/FormulaFloatAction.java
  5. 5
      designer-realize/src/main/java/com/fr/design/actions/insert/flot/TextBoxFloatAction.java
  6. 2
      designer-realize/src/main/java/com/fr/design/mainframe/CellWidgetPropertyPane.java
  7. 16
      designer-realize/src/main/java/com/fr/design/mainframe/cell/CellElementEditPane.java
  8. 3
      designer-realize/src/main/java/com/fr/grid/Grid.java
  9. 11
      designer-realize/src/main/java/com/fr/grid/GridUI.java

7
designer-base/src/main/java/com/fr/design/gui/itextfield/EditTextField.java

@ -1,12 +1,11 @@
package com.fr.design.gui.itextfield;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Toolkit;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Toolkit;
/**

45
designer-base/src/main/java/com/fr/design/utils/gui/AdjustWorkBookDefaultStyleUtils.java

@ -0,0 +1,45 @@
package com.fr.design.utils.gui;
import com.fr.base.Style;
import com.fr.base.background.ColorBackground;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.report.cell.CellElement;
import com.fr.report.cell.FloatElement;
import java.awt.Color;
/**
* @author shine
* @version 10.0
* Created by shine on 2021/9/6
*/
public class AdjustWorkBookDefaultStyleUtils {
private static final Color TEMPLATE_BACKGROUND = new Color(16, 11, 43);
public static void adjustCellElement(CellElement cellElement) {
if (DesignModeContext.isDuchampMode()) {
Style style = cellElement.getStyle();
style = style.deriveFRFont(style.getFRFont().applyForeground(Color.WHITE));
style = style.deriveBorder(0, Color.WHITE,
0, Color.WHITE,
0, Color.WHITE,
0, Color.WHITE);
cellElement.setStyle(style);
}
}
public static void adjustFloat(FloatElement floatElement) {
if (DesignModeContext.isDuchampMode()) {
Style style = floatElement.getStyle();
style = style.deriveBackground(ColorBackground.getInstance(TEMPLATE_BACKGROUND));
style = style.deriveFRFont(style.getFRFont().applyForeground(Color.WHITE));
floatElement.setStyle(style);
}
}
public static Color adjustBack(Color color) {
return DesignModeContext.isDuchampMode() ? TEMPLATE_BACKGROUND : color;
}
}

8
designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java

@ -38,7 +38,6 @@ import com.fr.stable.Constants;
import com.fr.stable.OperatingSystem;
import com.fr.stable.StringUtils;
import java.awt.Container;
import javax.swing.AbstractButton;
import javax.swing.Action;
import javax.swing.BorderFactory;
@ -67,10 +66,13 @@ import javax.swing.tree.TreePath;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Point;
@ -82,8 +84,6 @@ import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -176,7 +176,7 @@ public final class GUICoreUtils {
if (style.getBackground() instanceof ColorBackground) {
textField.setBackground(((ColorBackground) style.getBackground()).getColor());
} else {
textField.setBackground(Color.WHITE);
textField.setBackground(AdjustWorkBookDefaultStyleUtils.adjustBack(Color.WHITE));
}
}

6
designer-realize/src/main/java/com/fr/design/actions/insert/flot/FormulaFloatAction.java

@ -5,7 +5,6 @@ package com.fr.design.actions.insert.flot;
import com.fr.base.BaseFormula;
import com.fr.base.DynamicUnitList;
import com.fr.design.actions.ElementCaseAction;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
@ -15,7 +14,7 @@ import com.fr.design.formula.UIFormula;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.menu.MenuKeySet;
import com.fr.design.utils.gui.AdjustWorkBookDefaultStyleUtils;
import com.fr.grid.Grid;
import com.fr.grid.selection.FloatSelection;
import com.fr.report.ReportHelper;
@ -23,7 +22,7 @@ import com.fr.report.cell.FloatElement;
import com.fr.report.elementcase.TemplateElementCase;
import com.fr.stable.unit.FU;
import javax.swing.*;
import javax.swing.KeyStroke;
/**
* Insert formula.
@ -100,6 +99,7 @@ public class FormulaFloatAction extends ElementCaseAction {
reportPane.stopEditing();
final FloatElement floatElement = new FloatElement();
AdjustWorkBookDefaultStyleUtils.adjustFloat(floatElement);
final UIFormula formulaPane = FormulaFactory.createFormulaPane();
formulaPane.populate(BaseFormula.createFormulaBuilder().build());

5
designer-realize/src/main/java/com/fr/design/actions/insert/flot/TextBoxFloatAction.java

@ -7,7 +7,7 @@ import com.fr.base.DynamicUnitList;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.menu.MenuKeySet;
import com.fr.design.utils.gui.AdjustWorkBookDefaultStyleUtils;
import com.fr.grid.Grid;
import com.fr.grid.selection.FloatSelection;
import com.fr.report.ReportHelper;
@ -15,7 +15,7 @@ import com.fr.report.cell.FloatElement;
import com.fr.report.elementcase.TemplateElementCase;
import com.fr.stable.unit.FU;
import javax.swing.*;
import javax.swing.KeyStroke;
import java.awt.event.ActionEvent;
/**
@ -60,6 +60,7 @@ public class TextBoxFloatAction extends AbstractShapeAction {
return;
}
FloatElement floatElement = new FloatElement("Text");
AdjustWorkBookDefaultStyleUtils.adjustFloat(floatElement);
this.startDraw(floatElement);
doWithDrawingFloatElement();
}

2
designer-realize/src/main/java/com/fr/design/mainframe/CellWidgetPropertyPane.java

@ -3,6 +3,7 @@ package com.fr.design.mainframe;
import com.fr.design.actions.utils.ReportActionUtils;
import com.fr.design.dialog.BasicPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.AdjustWorkBookDefaultStyleUtils;
import com.fr.design.widget.WidgetPane;
import com.fr.form.ui.NoneWidget;
import com.fr.form.ui.Widget;
@ -89,6 +90,7 @@ public class CellWidgetPropertyPane extends BasicPane {
TemplateCellElement editCellElement = tplEC.getTemplateCellElement(cs.getColumn(), cs.getRow());
if (editCellElement == null) {
editCellElement = new DefaultTemplateCellElement(cs.getColumn(), cs.getRow());
AdjustWorkBookDefaultStyleUtils.adjustCellElement(editCellElement);
}
this.cellElement = editCellElement;
this.populate(editCellElement);

16
designer-realize/src/main/java/com/fr/design/mainframe/cell/CellElementEditPane.java

@ -7,10 +7,14 @@ import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.gui.ibutton.UIHeadGroup;
import com.fr.design.gui.itabpane.TitleChangeListener;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.cell.settingpane.*;
import com.fr.design.mainframe.cell.settingpane.AbstractCellAttrPane;
import com.fr.design.mainframe.cell.settingpane.CellExpandAttrPane;
import com.fr.design.mainframe.cell.settingpane.CellOtherSetPane;
import com.fr.design.mainframe.cell.settingpane.CellPresentPane;
import com.fr.design.mainframe.cell.settingpane.CellStylePane;
import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.gui.AdjustWorkBookDefaultStyleUtils;
import com.fr.general.ComparatorUtils;
import com.fr.grid.selection.CellSelection;
import com.fr.grid.selection.Selection;
import com.fr.report.cell.CellElement;
@ -18,8 +22,11 @@ import com.fr.report.cell.DefaultTemplateCellElement;
import com.fr.report.cell.TemplateCellElement;
import com.fr.report.elementcase.TemplateElementCase;
import javax.swing.*;
import java.awt.*;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Dimension;
import java.util.ArrayList;
import java.util.List;
@ -113,6 +120,7 @@ public class CellElementEditPane extends BasicPane {
CellElement cellElement = elementCase.getCellElement(cs.getColumn(), cs.getRow());
if (cellElement == null) {
cellElement = new DefaultTemplateCellElement(cs.getColumn(), cs.getRow());
AdjustWorkBookDefaultStyleUtils.adjustCellElement(cellElement);
//默认选中的是A1单元格,所以若是A1单元格没有加到列表时要加上,否则在聚合报表时会出错
if (cs.isSelectedOneCell(elementCasePane) && (cs.getColumn() + cs.getRow() == 0)) {
elementCase.addCellElement((TemplateCellElement) cellElement);

3
designer-realize/src/main/java/com/fr/grid/Grid.java

@ -18,6 +18,7 @@ import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.mainframe.DesignOperationEvent;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.utils.gui.AdjustWorkBookDefaultStyleUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.event.EventDispatcher;
import com.fr.general.ComparatorUtils;
@ -871,6 +872,7 @@ public class Grid extends BaseGridComponent {
// 必须保证editingCellElement不是null。
if (editingCellElement == null) {
editingCellElement = new DefaultTemplateCellElement(column, row);
AdjustWorkBookDefaultStyleUtils.adjustCellElement(editingCellElement);
}
editorComponent = getCellEditingComp();
if (editorComponent == null) {
@ -1036,6 +1038,7 @@ public class Grid extends BaseGridComponent {
if (editingCellElement == null) {
editingCellElement = new DefaultTemplateCellElement(editingColumn, editingRow);
tplEC.addCellElement(editingCellElement);
AdjustWorkBookDefaultStyleUtils.adjustCellElement(editingCellElement);
}
if (setValue4EditingElement(newValue)) {
shrinkToFit(tplEC);

11
designer-realize/src/main/java/com/fr/grid/GridUI.java

@ -10,15 +10,14 @@ import com.fr.base.background.ColorBackground;
import com.fr.base.background.ImageFileBackground;
import com.fr.base.iofile.attr.WatermarkAttr;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignerEnvManager;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.constants.UIConstants;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.fun.ReportLengthUNITProvider;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.roleAuthority.ReportAndFSManagePane;
import com.fr.design.unit.UnitConvertUtil;
import com.fr.design.utils.gui.AdjustWorkBookDefaultStyleUtils;
import com.fr.general.Background;
import com.fr.general.ComparatorUtils;
import com.fr.grid.selection.CellSelection;
@ -46,11 +45,11 @@ import com.fr.report.stable.ReportConstants;
import com.fr.report.stable.ReportSettings;
import com.fr.report.worksheet.FormElementCase;
import com.fr.report.worksheet.WorkSheet;
import com.fr.stable.AssistUtils;
import com.fr.stable.ColumnRow;
import com.fr.stable.Constants;
import com.fr.stable.script.CalculatorUtils;
import com.fr.stable.unit.FU;
import com.fr.stable.AssistUtils;
import com.fr.stable.unit.UNIT;
import com.fr.third.antlr.ANTLRException;
import com.fr.third.guava.collect.HashMultimap;
@ -176,7 +175,7 @@ public class GridUI extends ComponentUI {
// denny:画背景.Background
Background background = reportSettings.getBackground();
if (background != null) {
if (background != null && !DesignModeContext.isDuchampMode()) {
// denny: except the ColorBackground and ImageBackground
if (grid.isEnabled() && !(background instanceof ImageFileBackground)) {
background.paint(g2d, this.back_or_selection_rect);
@ -189,7 +188,7 @@ public class GridUI extends ComponentUI {
private void clearBackground(Graphics2D g2d, Grid grid) {
if (grid.isEnabled()) {
g2d.setPaint(Color.WHITE);
g2d.setPaint(AdjustWorkBookDefaultStyleUtils.adjustBack(Color.WHITE));
} else {
g2d.setPaint(UIManager.getColor("control"));
}

Loading…
Cancel
Save