Browse Source

Pull request #6264: REPORT-58796 【复用组件】组件封装尺寸超500*300,会自动缩小比例

Merge in DESIGN/design from ~FANGLEI/design10.0:release/11.0 to release/11.0

* commit '0c4766d46652ac6366cdef30986e0523914b560e':
  REPORT-58796
  REPORT-58796
  REPORT-58796 【复用组件】组件封装尺寸超500*300,会自动缩小比例
bugfix/11.0
fanglei 3 years ago
parent
commit
4e2966c43d
  1. 27
      designer-form/src/main/java/com/fr/design/mainframe/share/action/CreateComponentAction.java
  2. 51
      designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareGeneratePane.java

27
designer-form/src/main/java/com/fr/design/mainframe/share/action/CreateComponentAction.java

@ -81,6 +81,9 @@ import static javax.swing.JOptionPane.ERROR_MESSAGE;
* 创建组件事件 * 创建组件事件
*/ */
public class CreateComponentAction extends UpdateAction { public class CreateComponentAction extends UpdateAction {
private static final double MAX_WIDTH = 960.0;
private static final double MAX_HEIGHT = 540.0;
ShareUIAspect aspect; ShareUIAspect aspect;
/** /**
* 等待时间 500 ms. * 等待时间 500 ms.
@ -114,8 +117,12 @@ public class CreateComponentAction extends UpdateAction {
// 获取选中的组件 // 获取选中的组件
Triple<Widget, XCreator, Rectangle> sharedTriple = ComponentTransformerFactory.getInstance().transform(selection); Triple<Widget, XCreator, Rectangle> sharedTriple = ComponentTransformerFactory.getInstance().transform(selection);
if (sharedTriple == null) { if (sharedTriple == null) {
FineJOptionPane.showMessageDialog(designerFrame, Toolkit.i18nText("Fine-Design_Share_Select_Error_Tip"), showErrMsgDialog(Toolkit.i18nText("Fine-Design_Share_Select_Error_Tip"));
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), ERROR_MESSAGE, IOUtils.readIcon("/com/fr/base/images/share/Information_Icon_warning_normal_32x32.png")); return;
}
if (isBeyondMaxSize(sharedTriple.getRight())) {
showErrMsgDialog(Toolkit.i18nText("Fine-Design_Share_Widget_Size_Error_Tip"));
return; return;
} }
@ -398,4 +405,20 @@ public class CreateComponentAction extends UpdateAction {
} }
return paras; return paras;
} }
private boolean isBeyondMaxSize(Rectangle rec) {
double width = rec.getWidth();
double height = rec.getHeight();
return width > 0 && height > 0 && (width > MAX_WIDTH || height > MAX_HEIGHT);
}
private void showErrMsgDialog(String err) {
FineJOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
err,
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
ERROR_MESSAGE,
IOUtils.readIcon("/com/fr/base/images/share/Information_Icon_warning_normal_32x32.png")
);
}
} }

51
designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareGeneratePane.java

@ -19,24 +19,22 @@ import com.fr.design.mainframe.share.collect.ComponentCollector;
import com.fr.design.mainframe.share.exception.LackOfValueException; import com.fr.design.mainframe.share.exception.LackOfValueException;
import com.fr.design.mainframe.share.generate.ComponentGeneratorCenter; import com.fr.design.mainframe.share.generate.ComponentGeneratorCenter;
import com.fr.design.mainframe.share.select.ComponentTransformerFactory; import com.fr.design.mainframe.share.select.ComponentTransformerFactory;
import com.fr.design.mod.ContentObjectManager;
import com.fr.form.share.exception.NetWorkFailedException;
import com.fr.form.share.group.DefaultShareGroup;
import com.fr.design.mainframe.share.util.ShareUIUtils; import com.fr.design.mainframe.share.util.ShareUIUtils;
import com.fr.design.mod.ContentObjectManager;
import com.fr.design.share.effect.EffectItemGroup; import com.fr.design.share.effect.EffectItemGroup;
import com.fr.design.share.utils.EffectItemUtils; import com.fr.design.share.utils.EffectItemUtils;
import com.fr.design.share.utils.ShareDialogUtils; import com.fr.design.share.utils.ShareDialogUtils;
import com.fr.form.share.DefaultSharableWidget; import com.fr.form.share.DefaultSharableWidget;
import com.fr.form.share.Group;
import com.fr.form.share.config.ComponentReuseConfigManager; import com.fr.form.share.config.ComponentReuseConfigManager;
import com.fr.form.share.exception.NetWorkFailedException;
import com.fr.form.share.group.DefaultShareGroup;
import com.fr.form.share.group.DefaultShareGroupManager; import com.fr.form.share.group.DefaultShareGroupManager;
import com.fr.form.share.Group;
import com.fr.form.share.record.ShareWidgetInfoManager; import com.fr.form.share.record.ShareWidgetInfoManager;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import java.util.HashSet;
import java.util.Set;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.SwingWorker; import javax.swing.SwingWorker;
@ -51,7 +49,9 @@ import java.awt.Image;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -65,8 +65,6 @@ public class ShareGeneratePane extends BasicPane {
private static final Dimension DIALOG_SIZE = new Dimension(670, 760); private static final Dimension DIALOG_SIZE = new Dimension(670, 760);
private static final Dimension DIALOG_NORMAL_SIZE = new Dimension(670, 610); private static final Dimension DIALOG_NORMAL_SIZE = new Dimension(670, 610);
private static final Border DIALOG_BORDER = BorderFactory.createEmptyBorder(0, 6, 4, 6); private static final Border DIALOG_BORDER = BorderFactory.createEmptyBorder(0, 6, 4, 6);
private static final double MAX_WIDTH = 500.0;
private static final double MAX_HEIGHT = 260.0;
private JPanel mainPane = null; private JPanel mainPane = null;
private ShareMainPane uploadPane = null; private ShareMainPane uploadPane = null;
@ -213,7 +211,6 @@ public class ShareGeneratePane extends BasicPane {
dialog.setButtonEnabled(false); dialog.setButtonEnabled(false);
ShareDialogUtils.getInstance().setShareDialog(dialog); ShareDialogUtils.getInstance().setShareDialog(dialog);
dialog.addDialogActionListener(new DialogActionAdapter() { dialog.addDialogActionListener(new DialogActionAdapter() {
@Override @Override
public void doOk() { public void doOk() {
ShareMainPane mainPane = getSelectMainPane(); ShareMainPane mainPane = getSelectMainPane();
@ -297,29 +294,11 @@ public class ShareGeneratePane extends BasicPane {
} }
private boolean generateModule(DefaultSharableWidget info) throws Exception { private boolean generateModule(DefaultSharableWidget info) throws Exception {
ComponentGenerateInfo generateInfo = new ComponentGenerateInfo(uploadCheckbox.isSelected(), jt, paraMap, shareWidget, info);
DefaultSharableWidget transformInfo = transform(info);
ComponentGenerateInfo generateInfo = new ComponentGenerateInfo(uploadCheckbox.isSelected(), jt, paraMap, shareWidget, transformInfo);
ComponentGeneratorCenter center = new ComponentGeneratorCenter(generateInfo); ComponentGeneratorCenter center = new ComponentGeneratorCenter(generateInfo);
return center.generate(); return center.generate();
} }
private DefaultSharableWidget transform(DefaultSharableWidget info) {
confineSize(info);
//先屏蔽
//if (shareWidget instanceof AbstractBorderStyleWidget) {
// AbstractBorderStyleWidget styleWidget = (AbstractBorderStyleWidget) shareWidget;
// ExtendSharableAttrMark attrMark = styleWidget.getWidgetAttrMark(ExtendSharableAttrMark.XML_TAG);
// if (attrMark != null) {
// String shareId = attrMark.getShareId();
// info.setId(shareId);
// }
//}
return info;
}
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Share_Module_Msg"); return Toolkit.i18nText("Fine-Design_Share_Module_Msg");
@ -328,20 +307,4 @@ public class ShareGeneratePane extends BasicPane {
private Dimension getDialogSize() { private Dimension getDialogSize() {
return effectItemGroups.size() > 0 ? DIALOG_SIZE : DIALOG_NORMAL_SIZE; return effectItemGroups.size() > 0 ? DIALOG_SIZE : DIALOG_NORMAL_SIZE;
} }
private void confineSize(DefaultSharableWidget info) {
double width = info.getWidth();
double height = info.getHeight();
if (width > 0 && height > 0 && (width > MAX_WIDTH || height > MAX_HEIGHT)) {
double aspectRatio = width / height;
if (width / height > MAX_WIDTH / MAX_HEIGHT) {
info.setWidth((int) MAX_WIDTH);
info.setHeight((int) (MAX_WIDTH / aspectRatio));
} else {
info.setHeight((int) MAX_HEIGHT);
info.setWidth((int) (MAX_HEIGHT * aspectRatio));
}
}
}
} }

Loading…
Cancel
Save