diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java b/designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java index 93f8021d83..f455686415 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java +++ b/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); } } diff --git a/designer-base/src/main/java/com/fr/design/style/AbstractSelectBox.java b/designer-base/src/main/java/com/fr/design/style/AbstractSelectBox.java index 8b727e0991..1d66094f15 100644 --- a/designer-base/src/main/java/com/fr/design/style/AbstractSelectBox.java +++ b/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 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 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); diff --git a/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java b/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java index 58f5d2a5f6..8bd4e880d9 100644 --- a/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java @@ -10,6 +10,7 @@ import com.fr.design.fun.DesignerEnvProcessor; import com.fr.design.gui.UILookAndFeel; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.ui.util.UIUtil; import com.fr.exit.DesignerExiter; import com.fr.file.FileFILE; import com.fr.general.ComparatorUtils; @@ -205,7 +206,13 @@ public class DesignUtils { isMatch = isMatch || path.endsWith(suffix); } if (isMatch) { - DesignerContext.getDesignerFrame().openTemplate(new FileFILE(f)); + // ui线程作为打开入口 + UIUtil.invokeLaterIfNeeded(new Runnable() { + @Override + public void run() { + DesignerContext.getDesignerFrame().openTemplate(new FileFILE(f)); + } + }); } } } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java index 645f38706e..485c73b164 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java +++ b/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,60 @@ 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); + } else { + titleParent.setBorder(null); + titleParent.setBorderImage4Painting(null, 0.0); + titleParent.setBackground4Painting(null, 0.0); } } } + 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 +282,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 +311,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 +362,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); diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java index dbc956c857..3b991d4a03 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java +++ b/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 diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java b/designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java index 13358f2b20..3993c4daa7 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java +++ b/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())); diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java index ba864e6070..71129bed46 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java +++ b/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,23 @@ 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 initBorderAndBackgroundStyle() { + setBorder(null); + setBorderImage4Painting(null, 0.0); + setBackground4Painting(null, 0.0); + } + @Override protected void initXCreatorProperties() { super.initXCreatorProperties(); @@ -150,6 +174,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 diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java index 6009711f71..2f7200acf6 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java @@ -415,7 +415,10 @@ public class XWCardMainBorderLayout extends XWBorderLayout { */ @Override public void firePropertyChange(){ - return; + XWCardLayout cardLayout = this.getCardPart(); + if (cardLayout != null && cardLayout.toData() != null) { + cardLayout.initStyle(); + } } diff --git a/designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java b/designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java index 324213bc3d..0f2b853d1b 100644 --- a/designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java +++ b/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; @@ -97,17 +98,14 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver { private int[] ninePoint = new int[] {-1, -1, -1, -1}; - public BorderLineAndImagePane() { - this.initComponents(); + public BorderLineAndImagePane(boolean supportBorderImage) { + this.initComponents(supportBorderImage); this.initLayout(); } - private void initComponents() { - borderLineCombo = new BorderLineAndImageComboBox(); - borderColorPane = new UIColorButton(null) {{ - setUI(createButtonUI(this)); - set4ToolbarButton(); - }}; + private void initComponents(boolean supportBorderImage) { + borderLineCombo = new BorderLineAndImageComboBox(supportBorderImage); + 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()) { @@ -388,16 +386,25 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver { protected static class BorderLineAndImageComboBox extends LineComboBox { public static final int LINE_PICTURE = -1; - public final static int[] BORDER_LINE_STYLE_ARRAY = new int[] { + public final static int[] BORDER_LINE_AND_IMAGE_STYLE_ARRAY = new int[] { Constants.LINE_NONE, LINE_PICTURE, Constants.LINE_THIN, //1px Constants.LINE_MEDIUM, //2px Constants.LINE_THICK, //3px }; + public final static int[] BORDER_LINE_STYLE_ARRAY = new int[] { + Constants.LINE_NONE, + Constants.LINE_THIN, //1px + Constants.LINE_MEDIUM, //2px + Constants.LINE_THICK, //3px + }; + + private boolean supportBorderImage = false; - public BorderLineAndImageComboBox() { - super(BORDER_LINE_STYLE_ARRAY); + public BorderLineAndImageComboBox(boolean supportBorderImage) { + super(supportBorderImage ? BORDER_LINE_AND_IMAGE_STYLE_ARRAY : BORDER_LINE_STYLE_ARRAY); + this.supportBorderImage = supportBorderImage; } @Override @@ -409,15 +416,27 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver { } public boolean isSelectedBorderLine() { - return getSelectedIndex() > 1; + Object object = getSelectedItem(); + if (object != null) { + int value = (int) object; + return value > 0; + } + return false; } public boolean isSelectedBorderImage() { - return getSelectedIndex() == 1; + Object object = getSelectedItem(); + if (object != null) { + int value = (int) object; + return value == LINE_PICTURE; + } + return false; } public void selectBorderImage() { - this.setSelectedIndex(1); + if (supportBorderImage) { + this.setSelectedIndex(1); + } } } diff --git a/designer-form/src/main/java/com/fr/design/gui/xpane/CardTagLayoutStylePane.java b/designer-form/src/main/java/com/fr/design/gui/xpane/CardTagLayoutStylePane.java index 5e6f7c06c5..37db551027 100644 --- a/designer-form/src/main/java/com/fr/design/gui/xpane/CardTagLayoutStylePane.java +++ b/designer-form/src/main/java/com/fr/design/gui/xpane/CardTagLayoutStylePane.java @@ -3,9 +3,7 @@ */ package com.fr.design.gui.xpane; -import com.fr.form.ui.LayoutBorderStyle; - -import javax.swing.*; +import javax.swing.JPanel; /** * CardTagLayoutBorderPane Pane. @@ -14,14 +12,13 @@ public class CardTagLayoutStylePane extends LayoutStylePane { @Override protected JPanel createTitleStylePane(){ - return null; + JPanel panel = super.createTitleStylePane(); + panel.setVisible(false); + return panel; } @Override - public void updateTitle(LayoutBorderStyle style) { - + protected JPanel createBackgroundStylePane(boolean supportCornerRadius) { + return super.createBackgroundStylePane(false); } - - @Override - protected void populateTitle() { } } diff --git a/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java b/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java index c0ad60ad4f..453bd5e0da 100644 --- a/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java +++ b/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java @@ -88,7 +88,14 @@ public class LayoutStylePane extends BasicBeanPane { //标题背景透明度 protected UIPercentDragPane titleBackgroundOpacityPane; + private boolean supportBorderImage = false; + public LayoutStylePane() { + this(false); + } + + public LayoutStylePane(boolean supportBorderImage) { + this.supportBorderImage = supportBorderImage; this.initLayout(); } @@ -103,7 +110,7 @@ public class LayoutStylePane extends BasicBeanPane { JPanel titlePane = createTitleStylePane(); JPanel bodyContentPane = currentIsRootLayout ? createBodyContentPane4RootLayout() : createBodyContentPane(); - JPanel backgroundPane = createBackgroundStylePane(); + JPanel backgroundPane = createBackgroundStylePane(true); if (titlePane != null) { container.add(titlePane, BorderLayout.NORTH); @@ -128,18 +135,23 @@ public class LayoutStylePane extends BasicBeanPane { this.add(container, BorderLayout.CENTER); } - protected JPanel createBackgroundStylePane() { + protected JPanel createBackgroundStylePane(boolean supportCornerRadius) { borderStyleCombo = new UIComboBox(BORDER_STYLE); - borderLineAndImagePane = new BorderLineAndImagePane(); + borderLineAndImagePane = new BorderLineAndImagePane(this.supportBorderImage); cornerSpinner = new UISpinner(0,1000,1,0); double p = TableLayout.PREFERRED; double f = TableLayout.FILL; - double[] rowSize = {p, p, p, p}; + double[] rowSize = supportCornerRadius ? new double[] {p, p, p, p} : new double[]{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 +180,12 @@ public class LayoutStylePane extends BasicBeanPane { 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 +231,15 @@ public class LayoutStylePane extends BasicBeanPane { 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 +314,12 @@ public class LayoutStylePane extends BasicBeanPane { 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)); diff --git a/designer-form/src/main/java/com/fr/design/gui/xpane/TitleInsetImagePane.java b/designer-form/src/main/java/com/fr/design/gui/xpane/TitleInsetImagePane.java index 6b5391fb1d..3671259a20 100644 --- a/designer-form/src/main/java/com/fr/design/gui/xpane/TitleInsetImagePane.java +++ b/designer-form/src/main/java/com/fr/design/gui/xpane/TitleInsetImagePane.java @@ -35,7 +35,6 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; import java.awt.geom.RoundRectangle2D; /** @@ -57,6 +56,7 @@ public class TitleInsetImagePane extends JPanel implements UIObserver { private UIButton imageChooseButton; private UIButton imageDeleteButton; private ImagePreviewPane imagePreviewPane; + private JPanel imagePreviewOverlayPane; private UIButtonGroup imageLocationPane; private UISpinner imagePaddingPane; @@ -89,24 +89,31 @@ 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(imagePreviewPane, 2); - overlayPane.setVisible(false); + JPanel mousePane = new JPanel(); + mousePane.setBounds(0, 0, IMAGE_PREVIEW_SIZE, IMAGE_PREVIEW_SIZE); + mousePane.setOpaque(false); + mousePane.setBackground(null); + + deletableImagePreviewPane.add(mousePane, 0); + deletableImagePreviewPane.add(imageDeleteButton, 1); + deletableImagePreviewPane.add(imagePreviewOverlayPane, 2); + deletableImagePreviewPane.add(imagePreviewPane, 3); + + imagePreviewOverlayPane.setVisible(false); imageDeleteButton.setVisible(false); imageDeleteButton.setEnabled(false); - deletableImagePreviewPane.addMouseListener(new MouseAdapter() { + mousePane.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { super.mouseEntered(e); - overlayPane.setVisible(true); + imagePreviewOverlayPane.setVisible(true); imageDeleteButton.setVisible(true); imageDeleteButton.setEnabled(true); } @@ -114,12 +121,27 @@ public class TitleInsetImagePane extends JPanel implements UIObserver { @Override public void mouseExited(MouseEvent e) { super.mouseExited(e); + imagePreviewOverlayPane.setVisible(false); + imageDeleteButton.setVisible(false); + imageDeleteButton.setEnabled(false); + } + + @Override + public void mouseClicked(MouseEvent e) { + super.mouseClicked(e); int x = e.getX(); int y = e.getY(); - if (x <= 0 || getWidth() <= x || y <= 0 || y >= getHeight()) { - overlayPane.setVisible(false); + Rectangle bounds = imageDeleteButton.getBounds(); + if (bounds.x < x && x < bounds.x + bounds.width && bounds.y < y && y < bounds.y + bounds.height) { + 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(); } } }); @@ -210,17 +232,6 @@ public class TitleInsetImagePane extends JPanel implements UIObserver { }).dealWithImageFile(returnVal); } }); - this.imageDeleteButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - imagePreviewPane.setImageWithSuffix(null); - imageLocationPane.setSelectedIndex(DEFAULT_INSET_LOCATION_INDEX); - imagePaddingPane.setValue(DEFAULT_INSET_PADDING); - getComponent(1).setVisible(false); - - fireStateChanged(); - } - }); } public void populateBean(TitlePacker packer) { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java b/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java index 0c838b61ec..0f39f089f8 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java @@ -408,6 +408,14 @@ public class ComponentTree extends JTree { @Override public void mouseReleased(MouseEvent e) { + if (e.isControlDown() || e.isShiftDown()) { + return; + } + XCreator currentCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); + // 以当前选中的为准 + if (currentCreator != selectedCreator) { + selectedCreator = currentCreator; + } if (e.getButton() == MouseEvent.BUTTON1 && selectedCreator != null) { showSelectedPopup(selectedCreator); } @@ -426,6 +434,9 @@ public class ComponentTree extends JTree { * @param consumer */ private void onMouseEvent(final MouseEvent e, Consumer consumer) { + if (e.isControlDown() || e.isShiftDown()) { + return; + } Point p = e.getPoint(); // 解析组件树路径 获取选中的组件 int selRow = tree.getRowForLocation(p.x, p.y); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/CoverPane.java b/designer-form/src/main/java/com/fr/design/mainframe/CoverPane.java index 6bafb317f3..2c071a70b4 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/CoverPane.java +++ b/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() { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java index c1d834fa94..4e44e134e2 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java +++ b/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()); } } }); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java b/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java index d1aa9fc56e..7a6a73f4ba 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java +++ b/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); diff --git a/designer-form/src/main/java/com/fr/design/widget/FormWidgetDefinePaneFactoryBase.java b/designer-form/src/main/java/com/fr/design/widget/FormWidgetDefinePaneFactoryBase.java index e6217dbf02..9b1097d37a 100644 --- a/designer-form/src/main/java/com/fr/design/widget/FormWidgetDefinePaneFactoryBase.java +++ b/designer-form/src/main/java/com/fr/design/widget/FormWidgetDefinePaneFactoryBase.java @@ -132,6 +132,10 @@ public class FormWidgetDefinePaneFactoryBase { defineMap.put(widget, appearance); } + public static Appearance getDefinePane(Class widget) { + return defineMap.get(widget); + } + public static RN createWidgetDefinePane(XCreator creator, FormDesigner designer, Widget widget, Operator operator) { if (isExtraXWidget(widget)) { WidgetDefinePane widgetDefinePane = new WidgetDefinePane(creator, designer); diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/WTitleLayoutDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/WTitleLayoutDefinePane.java index bae310fdb9..004c3e2c67 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/WTitleLayoutDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/WTitleLayoutDefinePane.java @@ -27,7 +27,7 @@ public abstract class WTitleLayoutDefinePane mainClazz) { + String newClazzName = ClazzCreatorFactory.getInstance().createName(mainClazz); + Class newClazz; + try { + newClazz = (Class) Class.forName(newClazzName, false, mainClazz.getClassLoader()); + } catch (Exception e) { + newClazz = (Class) ClazzCreatorFactory.getInstance().newSharableClazz(mainClazz.getClassLoader(), mainClazz); + } + if (FormWidgetDefinePaneFactoryBase.getDefinePane(newClazz) == null) { + FormWidgetDefinePaneFactoryBase.registerDefinePane(newClazz, FormWidgetDefinePaneFactoryBase.getDefinePane(mainClazz)); + } + + } + + private static void registerSharableEncryptDefinePanes() { + registerSharableEncryptDefinePane(ElementCaseEditor.class); + registerSharableEncryptDefinePane(StableFactory.getMarkedClass(BridgeMark.CHART_EDITOR, AbstractBorderStyleWidget.class)); + registerSharableEncryptDefinePane(WAbsoluteLayout.class); + registerSharableEncryptDefinePane(WCardMainBorderLayout.class); + } }