Browse Source

Merge pull request #7074 in DESIGN/design from bugfix/10.0 to release/10.0

* commit '656a9d1930552eadd5f90bc0e8aac1d92bf80a7d':
  REPORT-60161 【组件背景分离】设置九点图的线在边界上后,其他操作回来发现恢复成默认井字型
  REPORT-56014 & REPORT-56015 【组件背景分离】【下个版本】组件复用-组件边框点九图,如果线重叠了的话,web端显示有问题
  REPORT-63322 决策报表及聚合报表,无法拖动组件
  REPORT-62691 11.0版本产出的组件,在10.0下正常安装,但复用时模板保存失败
zheng-1641779399395
superman 3 years ago
parent
commit
2097038292
  1. 24
      designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java
  2. 22
      designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java
  3. 73
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java

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

@ -298,15 +298,16 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
Background borderImage = style.getBorderImage(); Background borderImage = style.getBorderImage();
if (borderImage instanceof ImageBackground) { if (borderImage instanceof ImageBackground) {
// 图片类型边框 // 图片类型边框
Image image = ((ImageBackground) borderImage).getImage(); ImageBackground imageBackground = (ImageBackground) borderImage;
int[] ninePoint = ((ImageBackground) borderImage).getNinePoint(); Image image = imageBackground.getImage();
if (image != null) { if (image != null) {
this.borderLineCombo.selectBorderImage(); this.borderLineCombo.selectBorderImage();
this.imagePreviewPane.setImageWithSuffix(((ImageBackground) borderImage).getImageWithSuffix()); this.imagePreviewPane.setImageWithSuffix(((ImageBackground) borderImage).getImageWithSuffix());
this.tweakNinePointButton.setEnabled(true); this.tweakNinePointButton.setEnabled(true);
this.borderImageOpacityPane.populateBean(style.getBorderImageOpacity()); this.borderImageOpacityPane.populateBean(style.getBorderImageOpacity());
if (ninePoint != null && ninePoint.length == 4 && ninePoint[0] > 0 && ninePoint[1] > 0 && ninePoint[2] > 0 && ninePoint[3] > 0) { int[] ninePoint = ((ImageBackground) borderImage).getNinePoint();
if (ninePoint != null && ninePoint.length == 4 && ninePoint[0] >= 0 && ninePoint[1] >= 0 && ninePoint[2] >= 0 && ninePoint[3] >= 0) {
this.ninePoint = Arrays.copyOf(ninePoint, 4); this.ninePoint = Arrays.copyOf(ninePoint, 4);
} else { } else {
this.ninePoint = new int[4]; this.ninePoint = new int[4];
@ -503,6 +504,7 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
private int ninePointBottom = -1; private int ninePointBottom = -1;
private static final int MIN_NINE_POINT = 0; private static final int MIN_NINE_POINT = 0;
private static final int MIN_GAP_PARALLEL_LINES = 1;
private int imgWidth; private int imgWidth;
private int imgHeight; private int imgHeight;
@ -773,8 +775,8 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
private void onNinePointTopChanged(int value) { private void onNinePointTopChanged(int value) {
if (value < MIN_NINE_POINT) { if (value < MIN_NINE_POINT) {
value = MIN_NINE_POINT; value = MIN_NINE_POINT;
} else if (value >= imgHeight - ninePointBottom) { } else if (value >= imgHeight - ninePointBottom - MIN_GAP_PARALLEL_LINES) {
value = imgHeight - ninePointBottom - MIN_NINE_POINT; value = imgHeight - ninePointBottom - MIN_GAP_PARALLEL_LINES;
} }
this.ninePointTop = value; this.ninePointTop = value;
repaint(); repaint();
@ -783,8 +785,8 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
private void onNinePointBottomChanged(int value) { private void onNinePointBottomChanged(int value) {
if (value < MIN_NINE_POINT) { if (value < MIN_NINE_POINT) {
value = MIN_NINE_POINT; value = MIN_NINE_POINT;
} else if (value >= imgHeight - ninePointTop) { } else if (value >= imgHeight - ninePointTop - MIN_GAP_PARALLEL_LINES) {
value = imgHeight - ninePointTop - MIN_NINE_POINT; value = imgHeight - ninePointTop - MIN_GAP_PARALLEL_LINES;
} }
this.ninePointBottom = value; this.ninePointBottom = value;
repaint(); repaint();
@ -793,8 +795,8 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
private void onNinePointLeftChanged(int value) { private void onNinePointLeftChanged(int value) {
if (value < MIN_NINE_POINT) { if (value < MIN_NINE_POINT) {
value = MIN_NINE_POINT; value = MIN_NINE_POINT;
} else if (value >= imgWidth - ninePointRight) { } else if (value >= imgWidth - ninePointRight - MIN_GAP_PARALLEL_LINES) {
value = imgWidth - ninePointRight - MIN_NINE_POINT; value = imgWidth - ninePointRight - MIN_GAP_PARALLEL_LINES;
} }
this.ninePointLeft = value; this.ninePointLeft = value;
repaint(); repaint();
@ -803,8 +805,8 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
private void onNinePointRightChanged(int value) { private void onNinePointRightChanged(int value) {
if (value < MIN_NINE_POINT) { if (value < MIN_NINE_POINT) {
value = MIN_NINE_POINT; value = MIN_NINE_POINT;
} else if (value >= imgWidth - ninePointLeft) { } else if (value >= imgWidth - ninePointLeft - MIN_GAP_PARALLEL_LINES) {
value = imgWidth - ninePointLeft - MIN_NINE_POINT; value = imgWidth - ninePointLeft - MIN_GAP_PARALLEL_LINES;
} }
this.ninePointRight = value; this.ninePointRight = value;
repaint(); repaint();

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

@ -18,6 +18,7 @@ import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWAbsoluteLayout; import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.creator.XWParameterLayout; import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.form.util.XCreatorConstants; import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.icon.IconPathConstants; import com.fr.design.icon.IconPathConstants;
@ -31,12 +32,15 @@ import com.fr.form.share.SharableWidgetProvider;
import com.fr.form.share.ShareLoader; import com.fr.form.share.ShareLoader;
import com.fr.form.share.editor.SharableEditorProvider; import com.fr.form.share.editor.SharableEditorProvider;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JOptionPane;
import javax.swing.JWindow; import javax.swing.JWindow;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Point; import java.awt.Point;
@ -318,6 +322,24 @@ public class FormCreatorDropTarget extends DropTarget {
*/ */
@Override @Override
public synchronized void drop(DropTargetDropEvent dtde) { public synchronized void drop(DropTargetDropEvent dtde) {
try {
dropXCreator(dtde);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
if (addingModel.getXCreator().isShared()) {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Share_Drag_Component_Error_Info"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Error"),
JOptionPane.ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon")
);
}
dtde.rejectDrop();
}
}
private void dropXCreator(DropTargetDropEvent dtde) {
Point loc = dtde.getLocation(); Point loc = dtde.getLocation();
this.adding(designer.getRelativeX(loc.x), designer.getRelativeY(loc.y)); this.adding(designer.getRelativeX(loc.x), designer.getRelativeY(loc.y));
// 放到事件末尾执行 // 放到事件末尾执行

73
designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java

@ -1,5 +1,6 @@
package com.fr.design.mainframe.share.ui.block; package com.fr.design.mainframe.share.ui.block;
import com.fr.base.FRContext;
import com.fr.base.GraphHelper; import com.fr.base.GraphHelper;
import com.fr.base.iofile.attr.SharableAttrMark; import com.fr.base.iofile.attr.SharableAttrMark;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
@ -37,17 +38,24 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.Action; import javax.swing.Action;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.UIManager;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Cursor; import java.awt.Cursor;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image; import java.awt.Image;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.dnd.DnDConstants; import java.awt.dnd.DnDConstants;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.font.FontRenderContext;
import java.awt.font.LineMetrics;
import java.util.UUID; import java.util.UUID;
/** /**
@ -67,6 +75,7 @@ public class LocalWidgetBlock extends PreviewWidgetBlock<DefaultSharableWidget>
private boolean hover; private boolean hover;
private final Icon markedMode = IOUtils.readIcon("/com/fr/base/images/share/marked.png"); private final Icon markedMode = IOUtils.readIcon("/com/fr/base/images/share/marked.png");
private final Icon unMarkedMode = IOUtils.readIcon("/com/fr/base/images/share/unmarked.png"); private final Icon unMarkedMode = IOUtils.readIcon("/com/fr/base/images/share/unmarked.png");
private final Icon incompatibleMarker = IOUtils.readIcon("/com/fr/base/images/share/marker_incompatible.png");
public LocalWidgetBlock(DefaultSharableWidget provider, LocalWidgetSelectPane parentPane) { public LocalWidgetBlock(DefaultSharableWidget provider, LocalWidgetSelectPane parentPane) {
super(provider); super(provider);
@ -198,11 +207,24 @@ public class LocalWidgetBlock extends PreviewWidgetBlock<DefaultSharableWidget>
Widget creatorSource; Widget creatorSource;
String shareId; String shareId;
if (source instanceof LocalWidgetBlock) { if (source instanceof LocalWidgetBlock) {
LocalWidgetBlock no = (LocalWidgetBlock) e.getSource(); LocalWidgetBlock widgetBlock = (LocalWidgetBlock) e.getSource();
if (no == null) { if (widgetBlock == null) {
return; return;
} }
shareId = no.getBindInfo().getId(); SharableWidgetProvider widget = widgetBlock.getWidget();
if (widget == null) {
return;
}
if (!widget.isCompatibleWithCurrentEnv()) {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Share_Drag_And_Make_Incompatible_Component_Tip"),
Toolkit.i18nText("Fine-Design_Basic_Error"),
JOptionPane.ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon")
);
return;
}
shareId = widgetBlock.getBindInfo().getId();
creatorSource = getGroup().getElCaseEditorById(shareId); creatorSource = getGroup().getElCaseEditorById(shareId);
if (creatorSource == null) { if (creatorSource == null) {
ShareUIUtils.showErrorMessageDialog(Toolkit.i18nText("Fine-Design_Share_Drag_Error_Info")); ShareUIUtils.showErrorMessageDialog(Toolkit.i18nText("Fine-Design_Share_Drag_Error_Info"));
@ -211,7 +233,7 @@ public class LocalWidgetBlock extends PreviewWidgetBlock<DefaultSharableWidget>
creatorSource.setWidgetID(UUID.randomUUID().toString()); creatorSource.setWidgetID(UUID.randomUUID().toString());
((AbstractBorderStyleWidget) creatorSource).addWidgetAttrMark(new SharableAttrMark(true)); ((AbstractBorderStyleWidget) creatorSource).addWidgetAttrMark(new SharableAttrMark(true));
//tab布局WCardMainBorderLayout通过反射出来的大小是960*480 //tab布局WCardMainBorderLayout通过反射出来的大小是960*480
XCreator xCreator = ShareComponentUtils.createXCreator(creatorSource, shareId, no.getBindInfo()); XCreator xCreator = ShareComponentUtils.createXCreator(creatorSource, shareId, widgetBlock.getBindInfo());
WidgetToolBarPane.getTarget().startDraggingBean(xCreator); WidgetToolBarPane.getTarget().startDraggingBean(xCreator);
lastPressEvent = null; lastPressEvent = null;
this.setBorder(null); this.setBorder(null);
@ -221,6 +243,13 @@ public class LocalWidgetBlock extends PreviewWidgetBlock<DefaultSharableWidget>
@Override @Override
public void paint(Graphics g) { public void paint(Graphics g) {
super.paint(g); super.paint(g);
Graphics2D g2d = (Graphics2D) g;
boolean isUnusable = !getWidget().isCompatibleWithCurrentEnv();
if (isUnusable) {
paintUnusableMask(g2d);
}
//绘制删除标志 //绘制删除标志
if (isEdit) { if (isEdit) {
Icon icon = isMarked ? markedMode : unMarkedMode; Icon icon = isMarked ? markedMode : unMarkedMode;
@ -235,6 +264,42 @@ public class LocalWidgetBlock extends PreviewWidgetBlock<DefaultSharableWidget>
} }
} }
protected void paintUnusableMask(Graphics2D g2d) {
Color oldColor = g2d.getColor();
Font oldFont = g2d.getFont();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
Dimension coverDim = getCoverDimension();
double canvasX = 0;
double canvasY = 0;
double canvasW = coverDim.getWidth();
double canvasH = coverDim.getHeight();
g2d.setColor(new Color(0.0F, 0.0F, 0.0F, 0.4F));
GraphHelper.fillRect(g2d, canvasX, canvasY, canvasW, canvasH);
g2d.setColor(new Color(0.0F, 0.0F, 0.0F, 0.5F));
GraphHelper.fillRect(g2d, canvasX, canvasH - 16, canvasW, 16);
String tipText = Toolkit.i18nText("Fine-Design_Share_Incompatible_Version_Tip");
Font tipFont = FRContext.getDefaultValues().getFRFont().deriveFont(8.0F);
FontRenderContext frc = g2d.getFontRenderContext();
double tipTextWidth = GraphHelper.stringWidth(tipText, tipFont, frc);
LineMetrics metrics = tipFont.getLineMetrics(tipText, frc);
double tipTextHeight = metrics.getHeight();
g2d.setColor(Color.WHITE);
g2d.setFont(tipFont);
GraphHelper.drawString(g2d, tipText, canvasX + (canvasW - tipTextWidth) / 2.0F, canvasY + canvasH - (16 - tipTextHeight) / 2.0F);
int markerX = (int) (canvasX + (canvasW - incompatibleMarker.getIconWidth()) / 2);
int markerY = (int) (canvasY + (canvasH - incompatibleMarker.getIconHeight()) / 2);
incompatibleMarker.paintIcon(this, g2d, markerX, markerY);
g2d.setColor(oldColor);
g2d.setFont(oldFont);
}
/** /**
* 由鼠标释放时调用该方法来触发左键点击事件 * 由鼠标释放时调用该方法来触发左键点击事件
*/ */

Loading…
Cancel
Save