Browse Source

Merge pull request #5102 in DESIGN/design from feature/10.0 to release/11.0

* commit '7bea7b0d55fdf5c98c4258d94a20dcebd6ebfd05':
  REPORT-53175 - 【10.0.18】组件背景分离为标题/背景/边框
  REPORT-53175 - 【10.0.18】组件背景分离为标题/背景/边框
  REPORT-55753 【组件背景分离】组件复用-工具栏的显示位置不超过绘制区域
  REPORT-55748 【组件背景分离】组件复用-组件悬浮状态没有显示蓝色边框
  EPORT-55747 【组件背景分离】组件复用-设计器画布效果,标题背景遮挡边框图片
  REPORT-55743 【组件背景分离】组件复用-在新jar下新建的报表块,放到旧版本jar下设计器显示黑色缩略图
  REPORT-55228 ctrl/shift多选时不出现工具栏 + 老插件管理工具栏不显示
  REPORT-55715 【组件背景分离】组件复用-颜色选择器和设计器里其他地方的颜色选择器不太一样,看起来有点奇怪
  REPORT-55554 【组件背景分离】组件复用-mac上,组件标题的默认字体 和 单元格默认字体 不是一个字体;windows这边是一致的,都是宋体
  REPORT-55669 【组件背景分离】组件复用-线型边框在设计画布里可以看到,标题和组件内容之间是有显示边框线的,但是预览时这里没有显示边框线,不符合所见即所得,这个看下预期是什么样
  REPORT-55719 【组件背景分离】组件复用-报表块在画布内显示问题 REPORT-55737 【组件背景分离】组件复用-主体背景遮挡边框
  REPORT-55658 【稳定共创】组件设置-图表块标题图案-删除后再操作
  REPORT-55715 【组件背景分离】组件复用-颜色选择器和设计器里其他地方的颜色选择器不太一样,看起来有点奇怪
persist/11.0
superman 3 years ago
parent
commit
05941a3893
  1. 2
      designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java
  2. 38
      designer-base/src/main/java/com/fr/design/style/AbstractSelectBox.java
  3. 121
      designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java
  4. 9
      designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java
  5. 8
      designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java
  6. 54
      designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java
  7. 16
      designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java
  8. 28
      designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java
  9. 20
      designer-form/src/main/java/com/fr/design/gui/xpane/TitleInsetImagePane.java
  10. 6
      designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java
  11. 10
      designer-form/src/main/java/com/fr/design/mainframe/CoverPane.java
  12. 2
      designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java
  13. 5
      designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java
  14. 12
      designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java

2
designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java

@ -399,6 +399,8 @@ public class PluginWebBridge {
if (uiDialog != null) {
uiDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
uiDialog.setVisible(false);
}
if (uiDialog == DesignerPluginContext.getPluginDialog()) {
DesignerPluginContext.setPluginDialog(null);
}
}

38
designer-base/src/main/java/com/fr/design/style/AbstractSelectBox.java

@ -10,16 +10,20 @@ import java.awt.RenderingHints;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.AbstractButton;
import javax.swing.JPanel;
import javax.swing.border.AbstractBorder;
import javax.swing.event.AncestorEvent;
import javax.swing.event.AncestorListener;
import javax.swing.plaf.ButtonUI;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIButtonUI;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.stable.Constants;
import com.fr.design.utils.gui.GUIPaintUtils;
import com.fr.design.style.background.BackgroundJComponent;
import com.fr.stable.Constants;
/**
* @author kunsnat E-mail:kunsnat@gmail.com
@ -29,7 +33,7 @@ import com.fr.design.style.background.BackgroundJComponent;
public abstract class AbstractSelectBox<T> extends AbstractPopBox implements MouseListener {
private static final long serialVersionUID = 2355250206956896774L;
private UIToggleButton triggleButton;
private UIButton triggleButton;
protected void initBox(int preWidth) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
@ -37,8 +41,34 @@ public abstract class AbstractSelectBox<T> extends AbstractPopBox implements Mou
displayComponent = new BackgroundJComponent();
displayComponent.setEmptyBackground();
displayComponent.setBorder(new TriggleLineBorder());
triggleButton = new UIToggleButton(UIConstants.ARROW_DOWN_ICON);
triggleButton = new UIButton(UIConstants.ARROW_DOWN_ICON) {
public boolean shouldResponseChangeListener() {
return false;
}
@Override
public ButtonUI getUI() {
return new UIButtonUI() {
@Override
protected boolean isPressed(AbstractButton b) {
return model.isArmed() && model.isPressed();
}
@Override
protected void doExtraPainting(UIButton b, Graphics2D g2d, int w, int h, String selectedRoles) {
if (isPressed(b) && b.isPressedPainted()) {
GUIPaintUtils.fillPressed(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), UIConstants.COMBOBOX_BTN_PRESS);
} else if (isRollOver(b)) {
GUIPaintUtils.fillRollOver(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted(), UIConstants.COMBOBOX_BTN_ROLLOVER);
} else if (b.isNormalPainted()) {
GUIPaintUtils.fillNormal(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted(), UIConstants.COMBOBOX_BTN_NORMAL);
}
}
};
}
};
triggleButton.setPreferredSize(new Dimension(20, 20));
triggleButton.setRoundBorder(true, Constants.LEFT);
JPanel displayPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
displayPane.add(displayComponent, BorderLayout.CENTER);

121
designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java

@ -35,6 +35,9 @@ import java.awt.geom.RoundRectangle2D;
public class XBorderStyleWidgetCreator extends XWidgetCreator{
protected static final Dimension BORDER_PREFERRED_SIZE = new Dimension(250, 150);
protected Background background4Painting; // 设计器预览界面中绘制组件背景图
protected double backgroundOpacity4Painting; // 设计器预览界面中绘制组件背景图
protected Background borderImage4Painting; // 设计器预览界面中绘制边框图片
protected double borderImageOpacity4Painting;
public XBorderStyleWidgetCreator(Widget widget, Dimension initSize) {
super(widget, initSize);
@ -49,9 +52,26 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
return this.background4Painting;
}
public void setBackground4Painting(Background background4Painting) {
this.background4Painting = background4Painting;
this.repaint();
public double getBackgroundOpacity4Painting() {
return backgroundOpacity4Painting;
}
public void setBackground4Painting(Background background, double opacity) {
this.background4Painting = background;
this.backgroundOpacity4Painting = opacity;
}
public Background getBorderImage4Painting() {
return borderImage4Painting;
}
public double getBorderImageOpacity4Painting() {
return borderImageOpacity4Painting;
}
public void setBorderImage4Painting(Background borderImage, double opacity) {
this.borderImage4Painting = borderImage;
this.borderImageOpacity4Painting = opacity;
}
/**
@ -102,8 +122,13 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
}
this.setBorder(border);
this.setBackground4Painting(style != null ? style.getBackground() : null);
if (style != null) {
this.setBorderImage4Painting(style.getBorderImage(), style.getBorderImageOpacity());
this.setBackground4Painting(style.getBackground(), style.getAlpha());
} else {
this.setBorderImage4Painting(null, 0.0);
this.setBackground4Painting(null, 0.0);
}
}
private void clearTitleWidget() {
@ -183,29 +208,56 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
XCreator titleCreator = titleParent.getTitleCreator();
XCreator bodyXCreator = titleParent.getBodyCreator();
Border border = bodyXCreator.getBorder();
titleParent.setBorder(border); // 容器绘制完整边框
bodyXCreator.setBorder(BorderFactory.createEmptyBorder()); // body不绘制边框
titleCreator.setBorder(BorderFactory.createEmptyBorder()); // title绘制底部边框
if (border instanceof LineBorder) {
Color color = ((LineBorder) border).getLineColor();
int thickness = ((LineBorder) border).getThickness();
titleCreator.setBorder(new BottomLineBorder(color, thickness));
}
// 主体背景的生效范围暂时保持原样,不作用于包含标题区域的整体范围内
// if (bodyXCreator instanceof XBorderStyleWidgetCreator) {
// XBorderStyleWidgetCreator styledBodyXCreator = (XBorderStyleWidgetCreator) bodyXCreator;
// Background background4Painting = styledBodyXCreator.getBackground4Painting();
//
// styledBodyXCreator.setBackground4Painting(null); // body不绘制背景
// titleParent.setBackground4Painting(background4Painting); // 容器绘制完整背景
// }
reshuffleBorderPaintingEffectIfTitleExists(titleParent, titleCreator, bodyXCreator);
reshuffleBackgroundPaintingEffectIfTitleExists(titleParent, titleCreator, bodyXCreator);
}
}
}
private void reshuffleBorderPaintingEffectIfTitleExists(XWTitleLayout parentCreator, XCreator titleCreator, XCreator bodyCreator) {
Border border = bodyCreator.getBorder();
parentCreator.setBorder(border); // 容器绘制完整边框
bodyCreator.setBorder(BorderFactory.createEmptyBorder()); // body不绘制边框
titleCreator.setBorder(BorderFactory.createEmptyBorder()); // title绘制底部边框
if (border instanceof LineBorder) {
Color color = ((LineBorder) border).getLineColor();
int thickness = ((LineBorder) border).getThickness();
titleCreator.setBorder(new BottomLineBorder(color, thickness));
}
if (bodyCreator instanceof XBorderStyleWidgetCreator) {
XBorderStyleWidgetCreator styledBodyXCreator = (XBorderStyleWidgetCreator) bodyCreator;
Background borderImage= styledBodyXCreator.getBorderImage4Painting();
double opacity = styledBodyXCreator.getBorderImageOpacity4Painting();
styledBodyXCreator.setBorderImage4Painting(null, 0.0); // body不绘制图片边框
parentCreator.setBorderImage4Painting(borderImage, opacity); // 容器绘制完整图片边框
}
}
private void reshuffleBackgroundPaintingEffectIfTitleExists(XWTitleLayout parentCreator, XCreator titleCreator, XCreator bodyCreator) {
if (titleCreator instanceof XLabel) {
XLabel labelCreator = (XLabel) titleCreator;
Label titleLabel = labelCreator.toData();
Background background = titleLabel.getBackground();
double opacity = titleLabel.getBackgroundOpacity();
labelCreator.setEnabledBackgroundPainting(false); // 标题不绘制背景
parentCreator.setTitleBackground4Painting(background, opacity); // 容器绘制完整背景
}
if (bodyCreator instanceof XBorderStyleWidgetCreator) {
XBorderStyleWidgetCreator styledBodyXCreator = (XBorderStyleWidgetCreator) bodyCreator;
Background background = styledBodyXCreator.getBackground4Painting();
double opacity = styledBodyXCreator.getBackgroundOpacity4Painting();
styledBodyXCreator.setBackground4Painting(null, 0.0); // body不绘制背景
parentCreator.setBodyBackground4Painting(background, opacity); // 容器绘制完整背景
}
}
// 根据当前组件边框裁剪内容,如果当前组件存在圆角,则应当按圆角裁剪内容
private void clipByRoundedBorder(Graphics2D g2d) {
@ -226,10 +278,22 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
public void paintBackground(Graphics2D g2d) {
Background background4Painting = getBackground4Painting();
if (background4Painting != null) {
BorderPacker style = toData().getBorderStyle();
Composite oldComposite = g2d.getComposite();
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, style.getAlpha()));
background4Painting.paint(g2d, new Rectangle2D.Double(0, 0, getWidth(), getHeight()));
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, (float) backgroundOpacity4Painting));
Shape shape = new Rectangle2D.Double(0, 0, getWidth(), getHeight());
background4Painting.paint(g2d, shape);
g2d.setComposite(oldComposite);
}
}
public void paintBorderImage(Graphics2D g2d) {
Background borderImage4Painting = getBorderImage4Painting();
if (borderImage4Painting != null) {
Composite oldComposite = g2d.getComposite();
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, (float) borderImageOpacity4Painting));
borderImage4Painting.paint(g2d, new Rectangle2D.Double(0, 0, getWidth(), getHeight()));
g2d.setComposite(oldComposite);
}
}
@ -243,6 +307,7 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
public void paint(Graphics g) {
this.clipByRoundedBorder((Graphics2D) g);
this.paintBackground((Graphics2D) g);
this.paintBorderImage((Graphics2D) g);
this.paintForeground((Graphics2D) g);
}
@ -293,7 +358,7 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(getLineColor());
g2d.setStroke(new BasicStroke(getThickness()));
g2d.setStroke(new BasicStroke(getThickness() * 2));
g2d.drawLine(0, height, width, height);
g2d.setStroke(oldStroke);

9
designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java

@ -776,8 +776,13 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
if (popup == null) {
popup = new SelectedPopupDialog(this, designer);
}
int extraX = (int) ((bounds.x + bounds.width + SelectedPopupDialog.OFFSET_X) * designer.getScale());
int extraY = (int) (bounds.y * designer.getScale());
int creatorRightX = (int) ((bounds.x + bounds.width + SelectedPopupDialog.OFFSET_X) * designer.getScale());
int creatorRightY = (int) (bounds.y * designer.getScale());
int formDesignerWidth = designer.getWidth();
int formDesignerHeight = designer.getHeight();
// 不超过可绘制区域
int extraX = Math.min(creatorRightX, formDesignerWidth);
int extraY = creatorRightY < 0 ? 0 : Math.min(creatorRightY, formDesignerHeight);
// 放到事件尾部执行
SwingUtilities.invokeLater(new Runnable() {
@Override

8
designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java

@ -19,7 +19,6 @@ import com.fr.form.ui.Label;
import com.fr.form.ui.container.WParameterLayout;
import com.fr.general.Background;
import com.fr.general.act.BorderPacker;
import com.fr.stable.ArrayUtils;
import com.fr.stable.Constants;
import com.fr.stable.core.PropertyChangeAdapter;
@ -36,11 +35,16 @@ import java.beans.IntrospectionException;
public class XLabel extends XWidgetCreator {
private int cornerSize = 15;
private boolean enabledBackgroundPainting = true;
public XLabel(Label widget, Dimension initSize) {
super(widget, initSize);
}
public void setEnabledBackgroundPainting(boolean enable) {
this.enabledBackgroundPainting = enable;
}
/**
* 生成creator对应的控件widget
*
@ -93,7 +97,7 @@ public class XLabel extends XWidgetCreator {
Dimension size = this.getSize();
//先画背景,再画标题
Background background = label.getBackground();
if (background != null) {
if (background != null && enabledBackgroundPainting) {
Graphics2D g2d = (Graphics2D) g;
Composite oldComposite = g2d.getComposite();
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, label.getBackgroundOpacity()));

54
designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java

@ -12,10 +12,12 @@ import com.fr.form.ui.Widget;
import com.fr.form.ui.WidgetTitle;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.form.ui.container.WTitleLayout;
import com.fr.general.Background;
import com.fr.general.ComparatorUtils;
import java.awt.*;
import java.awt.event.ContainerEvent;
import java.awt.geom.Rectangle2D;
/**
* 一些控件 如图表报表块有标题设置且标题的高度字体等不变
@ -31,6 +33,11 @@ public class XWTitleLayout extends DedicateLayoutContainer {
private static final int INDEX = 0;
protected Background titleBackground4Painting; // 设计器预览界面中绘制title背景图
protected double titleBackgroundOpacity4Painting;
protected Background bodyBackground4Painting; // 设计器预览界面中绘制body背景图
protected double bodyBackgroundOpacity4Painting;
public XWTitleLayout() {
super(new WTitleLayout("titlePane"), new Dimension());
}
@ -45,6 +52,16 @@ public class XWTitleLayout extends DedicateLayoutContainer {
super(widget, initSize);
}
public void setTitleBackground4Painting(Background background, double opacity) {
this.titleBackground4Painting = background;
this.titleBackgroundOpacity4Painting = opacity;
}
public void setBodyBackground4Painting(Background background, double opacity) {
this.bodyBackground4Painting = background;
this.bodyBackgroundOpacity4Painting = opacity;
}
@Override
protected void initXCreatorProperties() {
super.initXCreatorProperties();
@ -150,6 +167,43 @@ public class XWTitleLayout extends DedicateLayoutContainer {
}
@Override
public void paintBackground(Graphics2D g2d) {
if (getComponentCount() > 1) {
paintTitleBackground(g2d);
paintBodyBackground(g2d);
}
}
private void paintTitleBackground(Graphics2D g2d) {
if (titleBackground4Painting != null) {
Composite oldComposite = g2d.getComposite();
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, (float) this.titleBackgroundOpacity4Painting));
XCreator titleCreator = getTitleCreator();
int titleHeight = titleCreator != null ? titleCreator.getHeight() : 0;
Shape shape = new Rectangle2D.Double(0, 0, getWidth(), titleHeight);
titleBackground4Painting.paint(g2d, shape);
g2d.setComposite(oldComposite);
}
}
private void paintBodyBackground(Graphics2D g2d) {
if (bodyBackground4Painting != null) {
Composite oldComposite = g2d.getComposite();
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, (float) this.bodyBackgroundOpacity4Painting));
XCreator titleCreator = getTitleCreator();
int titleHeight = titleCreator != null ? titleCreator.getHeight() : 0;
// 兼容性考虑,组件样式背景不作用在标题范围内,只作用在控件整体,但同时不能遮挡作用于整体的边框图片
// 所以考虑样式背景与边框图片都由XWTitleLayout绘制,但样式背景要向下偏移标题栏的高度
Shape shape = new Rectangle2D.Double(0, titleHeight, getWidth(), getHeight() - titleHeight);
bodyBackground4Painting.paint(g2d, shape);
g2d.setComposite(oldComposite);
}
}
/**
* 将WLayout转换为XLayoutContainer

16
designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java

@ -26,6 +26,7 @@ import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.backgroundpane.ImagePreviewPane;
import com.fr.design.style.background.image.ImageFileChooser;
import com.fr.design.style.color.NewColorSelectBox;
import com.fr.env.utils.DesignerInteractionHistory;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.general.Background;
@ -85,7 +86,7 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
private UIObserverListener uiObserverListener;
private BorderLineAndImageComboBox borderLineCombo;
private UIColorButton borderColorPane;
private NewColorSelectBox borderColorPane;
private ImagePreviewPane imagePreviewPane;
private UIButton chooseImageButton;
private UIButton tweakNinePointHelpButton;
@ -104,10 +105,7 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
private void initComponents() {
borderLineCombo = new BorderLineAndImageComboBox();
borderColorPane = new UIColorButton(null) {{
setUI(createButtonUI(this));
set4ToolbarButton();
}};
borderColorPane = new NewColorSelectBox(145);
imagePreviewPane = new ImagePreviewPane() {{
setImageStyle(Style.DEFAULT_STYLE);
}};
@ -228,7 +226,7 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
getComponent(2).setVisible(borderLineCombo.isSelectedBorderImage());
if (!borderLineCombo.isSelectedBorderLine()) {
borderColorPane.setColor(Color.BLACK);
borderColorPane.setSelectObject(Color.BLACK);
}
if (!borderLineCombo.isSelectedBorderImage()) {
imagePreviewPane.setImageWithSuffix(null);
@ -294,7 +292,7 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
Color borderColor = style.getColor();
this.borderLineCombo.setSelectedLineStyle(borderLine);
this.borderColorPane.setColor(borderColor);
this.borderColorPane.setSelectObject(borderColor);
Background borderImage = style.getBorderImage();
if (borderImage instanceof ImageBackground) {
@ -332,13 +330,13 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
}
this.borderLineCombo.setSelectedLineStyle(style.getBorder());
this.borderColorPane.setColor(style.getColor());
this.borderColorPane.setSelectObject(style.getColor());
}
public void updateBean(LayoutBorderStyle style) {
style.setBorder(this.borderLineCombo.getSelectedLineStyle());
style.setColor(this.borderColorPane.getColor());
style.setColor(this.borderColorPane.getSelectObject());
style.setBorderImage(null);
if (this.borderLineCombo.isSelectedBorderImage()) {

28
designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java

@ -138,8 +138,13 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
double[] rowSize = {p, p, p, p};
double[] columnSize = {SETTING_LABEL_WIDTH, f};
UILabel uiLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Background_Style"));
Font font = uiLabel.getFont().deriveFont(Font.BOLD);
uiLabel.setFont(font);
uiLabel.setForeground(new Color(143, 143, 146));
JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Background_Style")), null},
{uiLabel, null},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Render_Style")), borderStyleCombo},
{this.borderLineAndImagePane, null},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Radius")), cornerSpinner},
@ -168,8 +173,12 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
this.backgroundPane,
this.backgroundOpacityPane);
UILabel uiLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Content"));
Font font = uiLabel.getFont().deriveFont(Font.BOLD);
uiLabel.setFont(font);
uiLabel.setForeground(new Color(143, 143, 146));
JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Content")), null},
{uiLabel, null},
{bodyBackground, null},
},
rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1);
@ -215,6 +224,15 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
titleTextPane = new TinyFormulaPane();
titleFontFamilyComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report());
TitlePacker title = style.getTitle();
if (title != null) {
FRFont frFont = title.getFrFont();
if (frFont != null) {
String fontFamily = frFont.getFamily();
// 使用style中默认的字体初始化titleFontFamilyComboBox,保证UI和数据的一致性
this.titleFontFamilyComboBox.setSelectedItem(fontFamily);
}
}
titleFontFamilyComboBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Family"));
titleFontSizeComboBox = new UIComboBox(FRFontPane.FONT_SIZES);
@ -289,8 +307,12 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
visibleComposedPane.add(titleVisibleCheckbox, BorderLayout.WEST);
visibleComposedPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Visible")), BorderLayout.CENTER);
UILabel uiLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title"));
Font font = uiLabel.getFont().deriveFont(Font.BOLD);
uiLabel.setFont(font);
uiLabel.setForeground(new Color(143, 143, 146));
JPanel topPane = TableLayoutHelper.createCommonTableLayoutPane( new JComponent[][] {
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title")), null},
{uiLabel, null},
{visibleComposedPane, null}
}, new double[]{p, p}, new double[]{SETTING_LABEL_WIDTH, p}, IntervalConstants.INTERVAL_L1);
topPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));

20
designer-form/src/main/java/com/fr/design/gui/xpane/TitleInsetImagePane.java

@ -57,6 +57,7 @@ public class TitleInsetImagePane extends JPanel implements UIObserver {
private UIButton imageChooseButton;
private UIButton imageDeleteButton;
private ImagePreviewPane imagePreviewPane;
private JPanel imagePreviewOverlayPane;
private UIButtonGroup<Integer> imageLocationPane;
private UISpinner imagePaddingPane;
@ -89,24 +90,24 @@ public class TitleInsetImagePane extends JPanel implements UIObserver {
deletableImagePreviewPane.setLayout(null);
deletableImagePreviewPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5));
deletableImagePreviewPane.setPreferredSize(new Dimension(IMAGE_PREVIEW_SIZE, IMAGE_PREVIEW_SIZE));
JPanel overlayPane = new JPanel();
overlayPane.setPreferredSize(new Dimension(IMAGE_PREVIEW_SIZE - 2, IMAGE_PREVIEW_SIZE - 2));
overlayPane.setBackground(IMAGE_PREVIEW_OVERLAY_COLOR);
imagePreviewOverlayPane = new JPanel();
imagePreviewOverlayPane.setPreferredSize(new Dimension(IMAGE_PREVIEW_SIZE - 2, IMAGE_PREVIEW_SIZE - 2));
imagePreviewOverlayPane.setBackground(IMAGE_PREVIEW_OVERLAY_COLOR);
imagePreviewPane.setBounds(0, 0, IMAGE_PREVIEW_SIZE, IMAGE_PREVIEW_SIZE);
overlayPane.setBounds(1, 1, IMAGE_PREVIEW_SIZE - 2, IMAGE_PREVIEW_SIZE - 2);
imagePreviewOverlayPane.setBounds(1, 1, IMAGE_PREVIEW_SIZE - 2, IMAGE_PREVIEW_SIZE - 2);
imageDeleteButton.setBounds(IMAGE_PREVIEW_SIZE - DELETE_BUTTON_SIZE, 0, DELETE_BUTTON_SIZE, DELETE_BUTTON_SIZE);
deletableImagePreviewPane.add(imageDeleteButton, 0);
deletableImagePreviewPane.add(overlayPane, 1);
deletableImagePreviewPane.add(imagePreviewOverlayPane, 1);
deletableImagePreviewPane.add(imagePreviewPane, 2);
overlayPane.setVisible(false);
imagePreviewOverlayPane.setVisible(false);
imageDeleteButton.setVisible(false);
imageDeleteButton.setEnabled(false);
deletableImagePreviewPane.addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
super.mouseEntered(e);
overlayPane.setVisible(true);
imagePreviewOverlayPane.setVisible(true);
imageDeleteButton.setVisible(true);
imageDeleteButton.setEnabled(true);
}
@ -117,7 +118,7 @@ public class TitleInsetImagePane extends JPanel implements UIObserver {
int x = e.getX();
int y = e.getY();
if (x <= 0 || getWidth() <= x || y <= 0 || y >= getHeight()) {
overlayPane.setVisible(false);
imagePreviewOverlayPane.setVisible(false);
imageDeleteButton.setVisible(false);
imageDeleteButton.setEnabled(false);
}
@ -216,6 +217,9 @@ public class TitleInsetImagePane extends JPanel implements UIObserver {
imagePreviewPane.setImageWithSuffix(null);
imageLocationPane.setSelectedIndex(DEFAULT_INSET_LOCATION_INDEX);
imagePaddingPane.setValue(DEFAULT_INSET_PADDING);
imagePreviewOverlayPane.setVisible(false);
imageDeleteButton.setVisible(false);
imageDeleteButton.setEnabled(false);
getComponent(1).setVisible(false);
fireStateChanged();

6
designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java

@ -408,6 +408,9 @@ public class ComponentTree extends JTree {
@Override
public void mouseReleased(MouseEvent e) {
if (e.isControlDown() || e.isShiftDown()) {
return;
}
if (e.getButton() == MouseEvent.BUTTON1 && selectedCreator != null) {
showSelectedPopup(selectedCreator);
}
@ -426,6 +429,9 @@ public class ComponentTree extends JTree {
* @param consumer
*/
private void onMouseEvent(final MouseEvent e, Consumer<XCreator> consumer) {
if (e.isControlDown() || e.isShiftDown()) {
return;
}
Point p = e.getPoint();
// 解析组件树路径 获取选中的组件
int selRow = tree.getRowForLocation(p.x, p.y);

10
designer-form/src/main/java/com/fr/design/mainframe/CoverPane.java

@ -2,12 +2,13 @@ package com.fr.design.mainframe;
import com.fr.base.GraphHelper;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.icon.IconPathConstants;
import com.fr.general.IOUtils;
import com.fr.stable.Constants;
import java.awt.BasicStroke;
import java.awt.Stroke;
import javax.swing.JComponent;
import java.awt.AlphaComposite;
import java.awt.Color;
@ -32,6 +33,8 @@ public class CoverPane extends JComponent {
protected static final int BORDER_WIDTH = 2;
public static final int EDIT_BTN_W = 75;
public static final int EDIT_BTN_H = 20;
private static final int BORDER_GAP = 2;
private static final BasicStroke BORDER_STROKE = new BasicStroke(2f);
public static void paintEditButton(Graphics g, Component component) {
int x = 0;
@ -82,6 +85,11 @@ public class CoverPane extends JComponent {
g2d.setColor(XCreatorConstants.COVER_COLOR);
g2d.fillRect(0, 0, component.getWidth(), component.getHeight());
g2d.setComposite(oldComposite);
g2d.setColor(XCreatorConstants.FORM_BORDER_COLOR);
Stroke oldStroke = g2d.getStroke();
g2d.setStroke(BORDER_STROKE);
g2d.drawRect(BORDER_GAP, BORDER_GAP, component.getWidth() - BORDER_GAP * 2, component.getHeight() - BORDER_GAP * 2);
g2d.setStroke(oldStroke);
}
public CoverPane() {

2
designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java

@ -647,7 +647,7 @@ public class EditingMouseListener extends MouseInputAdapter {
@Override
public void run() {
for (XCreator xCreator : xCreators) {
xCreator.setSelected(!e.isShiftDown());
xCreator.setSelected(!e.isShiftDown() && !e.isControlDown());
}
}
});

5
designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java

@ -145,6 +145,11 @@ public class FormCreatorDropTarget extends DropTarget {
tabDragInner.tryDragIn();
} else {
Toolkit.getDefaultToolkit().beep();
// 拖入失败 取消选中
XCreator creator = addingModel.getXCreator();
if (creator != null) {
creator.setSelected(false);
}
}
// 取消提示
designer.setPainter(null);

12
designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java

@ -44,6 +44,7 @@ import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JScrollBar;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Transparency;
@ -133,13 +134,22 @@ public class FormElementCaseDesigner
int width = size.width;
int height = size.height;
image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
// 使用TYPE_INT_RGB和new Color(255, 255, 255, 1)设置有透明背景buffer image,
// 使得创建出来的透明像素是(255, 255, 255, 1),而不是(0, 0, 0, 0)
// 这样不支持透明通道缩略图的旧设计器打开新设计器创建的模版时,就不会创建出拥有黑色背景的缩略图
image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = image.createGraphics();
// 创建一个支持透明背景的buffer image
image = g2d.getDeviceConfiguration().createCompatibleImage(width, height, Transparency.TRANSLUCENT);
g2d.dispose();
g2d = image.createGraphics();
// 使用TYPE_INT_RGB和new Color(255, 255, 255, 1)设置有透明背景buffer image,
// 使得创建出来的透明像素是(255, 255, 255, 1),而不是(0, 0, 0, 0)
// 这样不支持透明通道缩略图的旧设计器打开新设计器创建的模版时,就不会创建出拥有黑色背景的缩略图
g2d.setColor(new Color(255, 255, 255, 1));
g2d.fillRect(0, 0, (int) size.getWidth(), (int) size.getHeight());
Grid grid = this.elementCasePane != null ? this.elementCasePane.getGrid() : null;
if (grid != null) {
boolean oldTranslucent = grid.isTranslucent();

Loading…
Cancel
Save