Browse Source

REPORT-53175【10.0.18】组件背景分离为标题/背景/边框

子功能: 设计器绝对布局内可锁定组件宽高比例

修复尺寸比例锁定按钮不能保存锁定状态的问题
1. 尺寸比例锁定按钮不应该保存XCreator对象(点击按钮时不能直接通过保存的XCreator,
改变widget锁定状态)
2. 尺寸比例锁定按钮需要实现GlobalNameObserver接口才能成功使得update被调用,
从而更新XCreator中widget的锁定状态

弹出提示显示逻辑
仅选中绝对布局内组件且该组件未勾选比例锁定按钮时,显示Shift键锁定组件尺寸比例功能
提示信息
feature/10.0
Starryi 3 years ago
parent
commit
869aff12f3
  1. 5
      designer-form/src/main/java/com/fr/design/designer/beans/location/AccessDirection.java
  2. 7
      designer-form/src/main/java/com/fr/design/designer/beans/models/StateModel.java
  3. 10
      designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java
  4. 3
      designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetAbsoluteBoundPane.java
  5. 74
      designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java

5
designer-form/src/main/java/com/fr/design/designer/beans/location/AccessDirection.java

@ -195,8 +195,11 @@ public abstract class AccessDirection implements Direction {
if (type != formEditor.getCursor().getType()) { if (type != formEditor.getCursor().getType()) {
// 设置当前形状 // 设置当前形状
formEditor.setCursor(Cursor.getPredefinedCursor(type)); formEditor.setCursor(Cursor.getPredefinedCursor(type));
FormSelection selection = formEditor.getSelectionModel().getSelection();
boolean canLockAspectRatioOnlyByShift = !selection.isCreatorAspectRatioLockedInAbsLayout(formEditor) && selection.isCreatorInAbsLayout(formEditor);
ServerPreferenceConfig config = ServerPreferenceConfig.getInstance(); ServerPreferenceConfig config = ServerPreferenceConfig.getInstance();
if (!config.isHasShownLockedAspectRatioResizingToolTip()) { if (canLockAspectRatioOnlyByShift && !config.isHasShownLockedAspectRatioResizingToolTip()) {
formEditor.setToolTipText(getTooltip()); formEditor.setToolTipText(getTooltip());
config.setHasShownLockedAspectRatioResizingToolTip(true); config.setHasShownLockedAspectRatioResizingToolTip(true);
} }

7
designer-form/src/main/java/com/fr/design/designer/beans/models/StateModel.java

@ -15,6 +15,7 @@ import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWAbsoluteBodyLayout; import com.fr.design.designer.creator.XWAbsoluteBodyLayout;
import com.fr.design.designer.creator.XWAbsoluteLayout; import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelection;
import com.fr.design.mainframe.FormSelectionUtils; import com.fr.design.mainframe.FormSelectionUtils;
import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.ComponentUtils;
@ -486,12 +487,14 @@ public class StateModel {
public void dragging(MouseEvent e) { public void dragging(MouseEvent e) {
//进入dragging状态时备份组件大小和位置 //进入dragging状态时备份组件大小和位置
if (!dragging) { if (!dragging) {
this.aspectRatioLocked = this.selectionModel.getSelection().isCreatorAspectRatioLockedInAbsLayout(designer);
selectedPositionBackup = selectionModel.getSelection().getRelativeBounds(); selectedPositionBackup = selectionModel.getSelection().getRelativeBounds();
} }
checkAddable(e); checkAddable(e);
setDependLinePainter(e); setDependLinePainter(e);
this.aspectRatioLocked = this.aspectRatioLocked || e.isShiftDown();
FormSelection selection = this.selectionModel.getSelection();
this.aspectRatioLocked = selection.isCreatorAspectRatioLockedInAbsLayout(designer) ||
(this.selectionModel.getSelection().isCreatorInAbsLayout(designer) && e.isShiftDown());
driection.drag(getMouseXY(e).x - currentX, getMouseXY(e).y - currentY, designer); driection.drag(getMouseXY(e).x - currentX, getMouseXY(e).y - currentY, designer);
this.dragging = true; this.dragging = true;
} }

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

@ -300,6 +300,16 @@ public class FormSelection {
return false; return false;
} }
public boolean isCreatorInAbsLayout(FormDesigner designer) {
for (XCreator creator : selection) {
LayoutAdapter layoutAdapter = AdapterBus.searchLayoutAdapter(designer, creator);
if (layoutAdapter instanceof FRAbsoluteLayoutAdapter) {
return true;
}
}
return false;
}
/** /**
* @Description 重置报表块缩略图 * @Description 重置报表块缩略图
* @param: creator * @param: creator

3
designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetAbsoluteBoundPane.java

@ -29,11 +29,12 @@ public class WidgetAbsoluteBoundPane extends WidgetBoundPane {
y = new UIBoundSpinner(0, Integer.MAX_VALUE, 1, 0d); y = new UIBoundSpinner(0, Integer.MAX_VALUE, 1, 0d);
width = new UIBoundSpinner(0, Integer.MAX_VALUE, 1, 0d); width = new UIBoundSpinner(0, Integer.MAX_VALUE, 1, 0d);
height = new UIBoundSpinner(0, Integer.MAX_VALUE, 1, 0d); height = new UIBoundSpinner(0, Integer.MAX_VALUE, 1, 0d);
ratioLockedButton = new AspectRatioLockedButton(width, height, creator); ratioLockedButton = new AspectRatioLockedButton(width, height);
x.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Coords_And_Size")); x.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Coords_And_Size"));
y.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Coords_And_Size")); y.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Coords_And_Size"));
width.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Coords_And_Size")); width.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Coords_And_Size"));
height.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Coords_And_Size")); height.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Coords_And_Size"));
ratioLockedButton.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Coords_And_Size"));
this.add(WidgetBoundsPaneFactory.createAbsoluteBoundsPane(x, y, width, height, ratioLockedButton, WidgetBoundsPaneFactory.NameAttribute.WIDGET)); this.add(WidgetBoundsPaneFactory.createAbsoluteBoundsPane(x, y, width, height, ratioLockedButton, WidgetBoundsPaneFactory.NameAttribute.WIDGET));
} }

74
designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java

@ -11,8 +11,11 @@ import com.fr.design.designer.creator.cardlayout.XWCardLayout;
import com.fr.design.designer.creator.cardlayout.XWCardTagLayout; import com.fr.design.designer.creator.cardlayout.XWCardTagLayout;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.event.GlobalNameListener;
import com.fr.design.event.GlobalNameObserver;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
@ -81,7 +84,8 @@ public class WidgetBoundPane extends BasicPane {
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (jTemplate.isJWorkBook() || !((JForm)jTemplate).isSelectRootPane()) { if (jTemplate.isJWorkBook() || !((JForm)jTemplate).isSelectRootPane()) {
ratioLockedButton = new AspectRatioLockedButton(width, height, creator); ratioLockedButton = new AspectRatioLockedButton(width, height);
ratioLockedButton.setGlobalName(i18nText("Fine-Design_Form_Coords_And_Size"));
ratioLockedButton.setLockEnabled(false); ratioLockedButton.setLockEnabled(false);
} }
@ -121,7 +125,7 @@ public class WidgetBoundPane extends BasicPane {
limitHeight(wabs, h, bounds, rec); limitHeight(wabs, h, bounds, rec);
} }
if (ratioLockedButton != null) { if (ratioLockedButton != null) {
ratioLockedButton.setLocked(creator.toData().isAspectRatioLocked()); ratioLockedButton.update(creator);
} }
} }
@ -191,21 +195,24 @@ public class WidgetBoundPane extends BasicPane {
} }
protected static class AspectRatioLockedButton extends UIButton { protected static class AspectRatioLockedButton extends JButton implements UIObserver, GlobalNameObserver {
private final Icon enabledLocked = IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_lock_enabled.png"); private final Icon enabledLocked = IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_lock_enabled.png");
private final Icon disabledLocked = IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_lock_disabled.png"); private final Icon disabledLocked = IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_lock_disabled.png");
private final Icon enabledUnLocked = IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_unlock_enabled.png"); private final Icon enabledUnLocked = IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_unlock_enabled.png");
private final Icon disabledUnLocked = IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_unlock_disabled.png"); private final Icon disabledUnLocked = IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_unlock_disabled.png");
private UISpinner mWidthSpinner; private UIObserverListener uiObserverListener;
private UISpinner mHeightSpinner; private GlobalNameListener globalNameListener;
private XCreator mCreator; private String globalName = null;
private final UISpinner mWidthSpinner;
private final UISpinner mHeightSpinner;
protected double width4Backup = 0; protected double width4Backup = 0;
protected double height4Backup = 0; protected double height4Backup = 0;
public AspectRatioLockedButton(UISpinner widthSpinner, UISpinner heightSpinner, XCreator creator) { public AspectRatioLockedButton(UISpinner widthSpinner, UISpinner heightSpinner) {
setUI(new BasicButtonUI()); setUI(new BasicButtonUI());
setBorderPainted(false); setBorderPainted(false);
setBorder(null); setBorder(null);
@ -214,25 +221,25 @@ public class WidgetBoundPane extends BasicPane {
this.mWidthSpinner = widthSpinner; this.mWidthSpinner = widthSpinner;
this.mHeightSpinner = heightSpinner; this.mHeightSpinner = heightSpinner;
this.mCreator = creator;
addActionListener(new ActionListener() { addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
setSelected(!isSelected()); // 改变图标icon
} setLocked(!isLocked());
});
addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
mCreator.toData().setAspectRatioLocked(isLocked());
setToolTipText(isLockEnabled() ? null : i18nText("Fine-Design_Form_Widget_Lock_Aspect_Ratio_Button_ToolTip"));
if (isLocked() && isLockEnabled()) { if (isLocked() && isLockEnabled()) {
width4Backup = mWidthSpinner.getValue(); width4Backup = mWidthSpinner.getValue();
height4Backup = mHeightSpinner.getValue(); height4Backup = mHeightSpinner.getValue();
} }
if (globalNameListener != null) {
globalNameListener.setGlobalName(globalName);
}
if (uiObserverListener != null) {
uiObserverListener.doChange();
}
} }
}); });
@ -285,15 +292,44 @@ public class WidgetBoundPane extends BasicPane {
public void setLockEnabled(boolean enabled) { public void setLockEnabled(boolean enabled) {
this.setEnabled(enabled); this.setEnabled(enabled);
setToolTipText(isLockEnabled() ? null : i18nText("Fine-Design_Form_Widget_Lock_Aspect_Ratio_Button_ToolTip"));
} }
public void populate(XCreator creator) { public void populate(XCreator creator) {
Rectangle bounds = new Rectangle(creator.getBounds()); Rectangle bounds = new Rectangle(creator.getBounds());
mCreator = creator;
width4Backup = bounds.width; width4Backup = bounds.width;
height4Backup = bounds.height; height4Backup = bounds.height;
Widget widget = creator.toData(); Widget widget = creator.toData();
setLocked(widget.isAspectRatioLocked()); setLocked(widget.isAspectRatioLocked());
} }
public void update(XCreator creator) {
creator.toData().setAspectRatioLocked(this.isLocked());
}
@Override
public void registerChangeListener(UIObserverListener listener) {
uiObserverListener = listener;
}
@Override
public boolean shouldResponseChangeListener() {
return true;
}
@Override
public void registerNameListener(GlobalNameListener listener) {
this.globalNameListener = listener;
}
@Override
public boolean shouldResponseNameListener() {
return true;
}
@Override
public void setGlobalName(String name) {
this.globalName = name;
}
} }
} }

Loading…
Cancel
Save