Browse Source

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

* commit '21495ad514f26e0059a9ce3bd33c65e8b02cafd2':
  REPORT-55228 工具栏问题  && REPORT-55228 设计器启动引导页面与切换账号页面 也要提示"更新相关组件"
  REPORT-55694 【组件背景分离】组件复用-组件/控件锁定时,通过右侧设置面板先增加宽度时,高度不变;但减小宽度时,高度会1单位1单位减小,最后组件变成一条横线
  REPORT-55709 frm中body背景设置了背景,不透明度设置0%没有透明效果
  REPORT-55553 【组件背景分离】组件复用-现在组件右侧设置面板的层次效果和视觉稿不一样,层次间隔不清晰
  REPORT-55492 【交互验收】【组件背景分离】macos中小工具栏的按钮区域浮到最上面来了(应该被dialog覆盖)
  REPORT-55228 【组件背景分离】组件复用-偶现,工具栏会留在设计页面上
  REPORT-55629 【组件背景分离】组件复用-控件/组件刚拖入设计画布时,工具栏没加载完全,只显示了一条线,移动鼠标的话才显示正常
  REPORT-55491 【交互验收】【组件背景分离】在组件属性下的「主体背景」设置,在配置界面不生效,看不到效果
  REPORT-55694 【组件背景分离】组件复用-组件/控件锁定时,通过右侧设置面板先增加宽度时,高度不变;但减小宽度时,高度会1单位1单位减小,最后组件变成一条横线
  REPORT-55672 悬浮元素-新建模板第一次添加的悬浮元素不能移动位置
  REPORT-55689 mac打开新插件管理也需要提示下更新新组件
persist/11.0
superman 3 years ago
parent
commit
e8f9a2874b
  1. 3
      designer-base/src/main/java/com/fr/design/PluginClassRefreshManager.java
  2. 4
      designer-base/src/main/java/com/fr/design/login/DesignerLoginHelper.java
  3. 2
      designer-base/src/main/java/com/fr/design/login/DesignerLoginShowDialog.java
  4. 2
      designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideHelper.java
  5. 6
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  6. 3
      designer-base/src/main/java/com/fr/design/upm/UpmFinder.java
  7. 12
      designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java
  8. 7
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java
  9. 2
      designer-form/src/main/java/com/fr/design/designer/beans/events/DesignerEditor.java
  10. 4
      designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java
  11. 3
      designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java
  12. 23
      designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java
  13. 10
      designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java
  14. 18
      designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java
  15. 13
      designer-form/src/main/java/com/fr/design/designer/ui/PopupControlPanel.java
  16. 5
      designer-form/src/main/java/com/fr/design/designer/ui/SelectedPopupDialog.java
  17. 89
      designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java
  18. 2
      designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java
  19. 7
      designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java
  20. 70
      designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java
  21. 18
      designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java

3
designer-base/src/main/java/com/fr/design/PluginClassRefreshManager.java

@ -27,6 +27,8 @@ public class PluginClassRefreshManager {
private final PluginEventListener pluginAfterRunEventListener = new PluginEventListener() { private final PluginEventListener pluginAfterRunEventListener = new PluginEventListener() {
@Override @Override
public void on(PluginEvent event) { public void on(PluginEvent event) {
// 重载模版之前 触发下hide
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTabChange();
// 兼容之前版本特性 // 兼容之前版本特性
for (String tag : context) { for (String tag : context) {
if (event.getContext().contain(tag)) { if (event.getContext().contain(tag)) {
@ -51,6 +53,7 @@ public class PluginClassRefreshManager {
public void on(PluginEvent event) { public void on(PluginEvent event) {
PluginListenerRegistration.getInstance().listen(PluginEventType.AfterRun, pluginAfterRunEventListener); PluginListenerRegistration.getInstance().listen(PluginEventType.AfterRun, pluginAfterRunEventListener);
if (DesignerLaunchStatus.getStatus() != DesignerLaunchStatus.WORKSPACE_INIT_COMPLETE) { if (DesignerLaunchStatus.getStatus() != DesignerLaunchStatus.WORKSPACE_INIT_COMPLETE) {
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTabChange();
HistoryTemplateListCache.getInstance().reloadAllEditingTemplate(); HistoryTemplateListCache.getInstance().reloadAllEditingTemplate();
} }
} }

4
designer-base/src/main/java/com/fr/design/login/DesignerLoginHelper.java

@ -6,6 +6,7 @@ import com.fr.design.extra.WebViewDlgHelper;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.os.impl.SupportOSImpl;
import com.fr.design.plugin.DesignerPluginContext;
import com.fr.design.update.ui.dialog.UpdateMainDialog; import com.fr.design.update.ui.dialog.UpdateMainDialog;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import java.awt.Dialog; import java.awt.Dialog;
@ -25,7 +26,7 @@ import javax.swing.WindowConstants;
public class DesignerLoginHelper { public class DesignerLoginHelper {
private static final String MAIN_RESOURCE_PATH = "/com/fr/design/login/login.html"; private static final String MAIN_RESOURCE_PATH = "/com/fr/design/login/login.html";
private static final String JXBROWSER = "com.teamdev.jxbrowser.chromium.Browser"; private static final String JXBROWSER = "com.teamdev.jxbrowser.browser.Browser";
private static UIDialog dialog = null; private static UIDialog dialog = null;
@ -91,6 +92,7 @@ public class DesignerLoginHelper {
dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
dialog.setVisible(false); dialog.setVisible(false);
dialog = null; dialog = null;
DesignerPluginContext.setPluginDialog(null);
} }
} }

2
designer-base/src/main/java/com/fr/design/login/DesignerLoginShowDialog.java

@ -1,6 +1,7 @@
package com.fr.design.login; package com.fr.design.login;
import com.fr.design.dialog.UIDialog; import com.fr.design.dialog.UIDialog;
import com.fr.design.plugin.DesignerPluginContext;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
@ -36,6 +37,7 @@ public class DesignerLoginShowDialog extends UIDialog {
setSize(DEFAULT); setSize(DEFAULT);
GUICoreUtils.centerWindow(this); GUICoreUtils.centerWindow(this);
setResizable(false); setResizable(false);
DesignerPluginContext.setPluginDialog(this);
} }
@Override @Override

2
designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideHelper.java

@ -22,7 +22,7 @@ import javax.swing.WindowConstants;
public class DesignerGuideHelper { public class DesignerGuideHelper {
private static final String MAIN_RESOURCE_PATH = "/com/fr/design/login/guide.html"; private static final String MAIN_RESOURCE_PATH = "/com/fr/design/login/guide.html";
private static final String JXBROWSER = "com.teamdev.jxbrowser.chromium.Browser"; private static final String JXBROWSER = "com.teamdev.jxbrowser.browser.Browser";
private static final long ONE_WEEK = 7 * 24 * 3600 * 1000L; private static final long ONE_WEEK = 7 * 24 * 3600 * 1000L;
private static final long ONE_MONTH = 30 * 24 * 3600 * 1000L; private static final long ONE_MONTH = 30 * 24 * 3600 * 1000L;
private static final long SIX_MONTH = 6 * ONE_MONTH; private static final long SIX_MONTH = 6 * ONE_MONTH;

6
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java

@ -212,6 +212,12 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} }
} }
@Override
public void windowIconified(WindowEvent e) {
// 最小化时 hide工具栏
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTabChange();
}
}; };
private JComponent closeButton = new JComponent() { private JComponent closeButton = new JComponent() {

3
designer-base/src/main/java/com/fr/design/upm/UpmFinder.java

@ -15,7 +15,6 @@ import com.fr.event.Listener;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.os.OperatingSystem;
import com.fr.workspace.Workspace; import com.fr.workspace.Workspace;
import com.fr.workspace.WorkspaceEvent; import com.fr.workspace.WorkspaceEvent;
@ -32,7 +31,7 @@ public class UpmFinder {
private static final String UPM_DIR = "/upm"; private static final String UPM_DIR = "/upm";
private static final String MAIN_RESOURCE_PATH = UPM_DIR + "/plugin_design.html"; private static final String MAIN_RESOURCE_PATH = UPM_DIR + "/plugin_design.html";
private static final String JXBROWSER = OperatingSystem.isWindows() ? "com.teamdev.jxbrowser.browser.Browser" : "com.teamdev.jxbrowser.chromium.Browser"; private static final String JXBROWSER = "com.teamdev.jxbrowser.browser.Browser";
public static String installHome = FRContext.getCommonOperator().getWebRootPath(); public static String installHome = FRContext.getCommonOperator().getWebRootPath();

12
designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java

@ -43,6 +43,7 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
public ChartComponent() { public ChartComponent() {
super(); super();
setOpaque(true);
addMouseListener(this); addMouseListener(this);
addMouseMotionListener(this); addMouseMotionListener(this);
} }
@ -148,11 +149,12 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
chartCollection4Design.setPredefinedStyleName(getGlobalPredefinedStyleName(), false); chartCollection4Design.setPredefinedStyleName(getGlobalPredefinedStyleName(), false);
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
Paint oldPaint = g2d.getPaint(); if (this.isOpaque()) {
Paint oldPaint = g2d.getPaint();
g2d.setPaint(Color.WHITE); g2d.setPaint(Color.WHITE);
g2d.fillRect(0, 0, this.getBounds().width, this.getBounds().height); g2d.fillRect(0, 0, this.getBounds().width, this.getBounds().height);
g2d.setPaint(oldPaint); g2d.setPaint(oldPaint);
}
g2d.translate(ChartConstants.PREGAP4BOUNDS/2, ChartConstants.PREGAP4BOUNDS/2); g2d.translate(ChartConstants.PREGAP4BOUNDS/2, ChartConstants.PREGAP4BOUNDS/2);

7
designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java

@ -9,6 +9,7 @@ import com.fr.design.designer.properties.BoundsGroupModel;
import com.fr.design.designer.properties.FRAbsoluteLayoutPropertiesGroupModel; import com.fr.design.designer.properties.FRAbsoluteLayoutPropertiesGroupModel;
import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.ComponentUtils;
import com.fr.design.utils.gui.LayoutUtils; import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
@ -295,6 +296,12 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
*/ */
@Override @Override
public void fix(XCreator creator) { public void fix(XCreator creator) {
Widget widget = creator.toData();
Rectangle bounds = creator.getBounds();
if (widget != null && widget.isAspectRatioLocked() && (bounds.width == 0 || bounds.height == 0)) {
widget.setAspectRatioLocked(false);
widget.setAspectRatioBackup(-1.0);
}
WAbsoluteLayout wabs = (WAbsoluteLayout)container.toData(); WAbsoluteLayout wabs = (WAbsoluteLayout)container.toData();
fix(creator,creator.getX(),creator.getY()); fix(creator,creator.getX(),creator.getY());
wabs.setBounds(creator.toData(),creator.getBounds()); wabs.setBounds(creator.toData(),creator.getBounds());

2
designer-form/src/main/java/com/fr/design/designer/beans/events/DesignerEditor.java

@ -93,7 +93,7 @@ public class DesignerEditor<T extends JComponent> implements PropertyChangeListe
comp.setSize(new Dimension(width, height)); comp.setSize(new Dimension(width, height));
LayoutUtils.layoutContainer(comp); LayoutUtils.layoutContainer(comp);
comp.setBounds(comp.getX() + x, comp.getY() + y, width, height); comp.setBounds(comp.getX() + x - 1, comp.getY() + y - 1, width, height);
Graphics clipg = g.create(x, y, width, height); Graphics clipg = g.create(x, y, width, height);
this.comp.paint(clipg); this.comp.paint(clipg);
} }

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

@ -226,7 +226,11 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
public void paintBackground(Graphics2D g2d) { public void paintBackground(Graphics2D g2d) {
Background background4Painting = getBackground4Painting(); Background background4Painting = getBackground4Painting();
if (background4Painting != null) { 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())); background4Painting.paint(g2d, new Rectangle2D.Double(0, 0, getWidth(), getHeight()));
g2d.setComposite(oldComposite);
} }
} }

3
designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java

@ -231,7 +231,9 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
public void paintForeground(Graphics2D g) { public void paintForeground(Graphics2D g) {
Dimension size = getSize(); Dimension size = getSize();
PaddingMargin margin = toData().getMargin(); PaddingMargin margin = toData().getMargin();
designerEditor.paintEditor(g, size, margin); designerEditor.paintEditor(g, size, margin);
if (coverPanel != null) { if (coverPanel != null) {
int horizonMargin = margin != null ? margin.getLeft() + margin.getRight() : 0; int horizonMargin = margin != null ? margin.getLeft() + margin.getRight() : 0;
int verticalMargin = margin != null ? margin.getTop() + margin.getBottom() : 0; int verticalMargin = margin != null ? margin.getTop() + margin.getBottom() : 0;
@ -292,6 +294,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
final MiddleChartComponent chartComponent = DesignModuleFactory.getChartComponent(((BaseChartEditor) data).getChartCollection()); final MiddleChartComponent chartComponent = DesignModuleFactory.getChartComponent(((BaseChartEditor) data).getChartCollection());
if (chartComponent != null) { if (chartComponent != null) {
JComponent jChart = chartComponent; JComponent jChart = chartComponent;
chartComponent.setOpaque(false);
jChart.setBorder(BorderFactory.createLineBorder(Color.lightGray)); jChart.setBorder(BorderFactory.createLineBorder(Color.lightGray));
designerEditor = new DesignerEditor<JComponent>(jChart); designerEditor = new DesignerEditor<JComponent>(jChart);
chartComponent.addStopEditingListener(designerEditor); chartComponent.addStopEditingListener(designerEditor);

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

@ -23,6 +23,7 @@ import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.NoSupportAuthorityEdit; import com.fr.design.mainframe.NoSupportAuthorityEdit;
import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.plugin.DesignerPluginContext;
import com.fr.design.utils.gui.LayoutUtils; import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WTitleLayout; import com.fr.form.ui.container.WTitleLayout;
@ -33,6 +34,7 @@ import com.fr.stable.StringUtils;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.border.Border; import javax.swing.border.Border;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
@ -776,10 +778,23 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
} }
int extraX = (int) ((bounds.x + bounds.width + SelectedPopupDialog.OFFSET_X) * designer.getScale()); int extraX = (int) ((bounds.x + bounds.width + SelectedPopupDialog.OFFSET_X) * designer.getScale());
int extraY = (int) (bounds.y * designer.getScale()); int extraY = (int) (bounds.y * designer.getScale());
popup.setLocation(designer.getLocationOnScreen().x + designer.getPaintX() + extraX, designer.getLocationOnScreen().y + designer.getPaintY() + extraY); // 放到事件尾部执行
popup.updatePane(designer); SwingUtilities.invokeLater(new Runnable() {
popup.setVisible(selected && accept && popup.hasVisibleButtons() && popup.isCanVisible()); @Override
popup.setRelativeBounds(bounds); public void run() {
popup.setLocation(designer.getLocationOnScreen().x + designer.getPaintX() + extraX, designer.getLocationOnScreen().y + designer.getPaintY() + extraY);
popup.updatePane(designer);
popup.setVisible(selected && accept && popup.hasVisibleButtons() && popup.isCanVisible() && !isShowPluginDialog());
popup.setRelativeBounds(bounds);
}
});
}
private boolean isShowPluginDialog() {
if (DesignerPluginContext.getPluginDialog() == null) {
return false;
}
return DesignerPluginContext.getPluginDialog().isVisible();
} }
/** /**

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

@ -19,6 +19,7 @@ import com.fr.form.ui.Label;
import com.fr.form.ui.container.WParameterLayout; import com.fr.form.ui.container.WParameterLayout;
import com.fr.general.Background; import com.fr.general.Background;
import com.fr.general.act.BorderPacker;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
@ -91,8 +92,13 @@ public class XLabel extends XWidgetCreator {
Label label = (Label) data; Label label = (Label) data;
Dimension size = this.getSize(); Dimension size = this.getSize();
//先画背景,再画标题 //先画背景,再画标题
if (toData().getBackground() != null) { Background background = label.getBackground();
toData().getBackground().paint(g, new Rectangle2D.Double(0, 0, size.getWidth(), size.getHeight())); if (background != null) {
Graphics2D g2d = (Graphics2D) g;
Composite oldComposite = g2d.getComposite();
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, label.getBackgroundOpacity()));
background.paint(g, new Rectangle2D.Double(0, 0, size.getWidth(), size.getHeight()));
g2d.setComposite(oldComposite);
} }
if (label.getWidgetValue() != null) { if (label.getWidgetValue() != null) {
Graphics2D g2d = (Graphics2D) g.create(); Graphics2D g2d = (Graphics2D) g.create();

18
designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java

@ -386,7 +386,18 @@ public class XWAbsoluteLayout extends XLayoutContainer {
if (!creator.acceptType(XWFitLayout.class)) { if (!creator.acceptType(XWFitLayout.class)) {
creator.setDirections(Direction.ALL); creator.setDirections(Direction.ALL);
} }
wabs.addWidget(new BoundsWidget(creator.toData(), creator.getBounds())); Widget wgt = creator.toData();
if (wgt != null && wgt.isAspectRatioLocked() && wgt.getAspectRatioBackup() <= 0) {
// 将比例锁定的组件重新移会绝对布局内时(如body修改绝对布局),尺寸比例可能失效,需要重新计算
Rectangle bounds = creator.getBounds();
if (bounds.width > 0 && bounds.height > 0) {
wgt.setAspectRatioBackup(1.0 * bounds.width / bounds.height);
} else {
wgt.setAspectRatioLocked(false);
wgt.setAspectRatioBackup(-1);
}
}
wabs.addWidget(new BoundsWidget(wgt, creator.getBounds()));
} }
/** /**
@ -402,6 +413,11 @@ public class XWAbsoluteLayout extends XLayoutContainer {
WAbsoluteLayout wlayout = this.toData(); WAbsoluteLayout wlayout = this.toData();
XWidgetCreator xwc = ((XWidgetCreator) e.getChild()); XWidgetCreator xwc = ((XWidgetCreator) e.getChild());
Widget wgt = xwc.toData(); Widget wgt = xwc.toData();
// 将比例锁定的组件重新移出绝对布局时(如body修改为自适应布局),锁定的尺寸比例失效
if (wgt != null) {
wgt.setAspectRatioBackup(-1.0);
}
BoundsWidget bw = new BoundsWidget(wgt, xwc.getBounds()); BoundsWidget bw = new BoundsWidget(wgt, xwc.getBounds());
wlayout.removeWidget(bw); wlayout.removeWidget(bw);
} }

13
designer-form/src/main/java/com/fr/design/designer/ui/PopupControlPanel.java

@ -13,6 +13,7 @@ import com.fr.design.layout.VerticalFlowLayout;
import com.fr.design.mainframe.CoverReportPane; import com.fr.design.mainframe.CoverReportPane;
import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.form.ui.Widget;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
@ -94,7 +95,17 @@ public class PopupControlPanel extends JPanel {
JToggleButton toggleBtn = (JToggleButton) e.getSource(); JToggleButton toggleBtn = (JToggleButton) e.getSource();
String toolTipText = toggleBtn.isSelected() ? Toolkit.i18nText("Fine-Design_Form_Lock_Widget_Ratio") : Toolkit.i18nText("Fine-Design_Form_UnLock_Widget_Ratio"); String toolTipText = toggleBtn.isSelected() ? Toolkit.i18nText("Fine-Design_Form_Lock_Widget_Ratio") : Toolkit.i18nText("Fine-Design_Form_UnLock_Widget_Ratio");
toggleBtn.setToolTipText(toolTipText); toggleBtn.setToolTipText(toolTipText);
creator.toData().setAspectRatioLocked(toggleBtn.isSelected()); Widget widget = creator.toData();
if (widget != null) {
Rectangle bounds = new Rectangle(creator.getBounds());
if (toggleBtn.isSelected() && bounds.width > 0 && bounds.height > 0) {
widget.setAspectRatioLocked(true);
widget.setAspectRatioBackup(1.0 * bounds.width / bounds.height);
} else {
widget.setAspectRatioLocked(false);
widget.setAspectRatioBackup(-1.0);
}
}
designer.getEditListenerTable().fireCreatorModified(creator, DesignerEvent.CREATOR_RESIZED); designer.getEditListenerTable().fireCreatorModified(creator, DesignerEvent.CREATOR_RESIZED);
} }
}); });

5
designer-form/src/main/java/com/fr/design/designer/ui/SelectedPopupDialog.java

@ -3,8 +3,11 @@ package com.fr.design.designer.ui;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.stable.os.OperatingSystem;
import java.awt.Rectangle; import java.awt.Rectangle;
import javax.swing.JDialog; import javax.swing.JDialog;
import javax.swing.JFrame;
/** /**
* @author hades * @author hades
@ -23,7 +26,7 @@ public class SelectedPopupDialog extends JDialog {
private boolean canVisible = true; private boolean canVisible = true;
public SelectedPopupDialog(XCreator creator, FormDesigner designer) { public SelectedPopupDialog(XCreator creator, FormDesigner designer) {
super(DesignerContext.getDesignerFrame()); super(OperatingSystem.isMacos() ? new JFrame() : DesignerContext.getDesignerFrame());
this.setUndecorated(true); this.setUndecorated(true);
this.setModal(false); this.setModal(false);
this.setFocusableWindowState(false); this.setFocusableWindowState(false);

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

@ -1,10 +1,8 @@
package com.fr.design.gui.xpane; package com.fr.design.gui.xpane;
import com.fr.base.GraphHelper;
import com.fr.base.Utils; import com.fr.base.Utils;
import com.fr.base.svg.IconUtils; import com.fr.base.svg.IconUtils;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.constants.UIConstants;
import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.IntervalConstants;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.formula.TinyFormulaPane; import com.fr.design.formula.TinyFormulaPane;
@ -13,7 +11,6 @@ import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ibutton.UIColorButton; import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.LineComboBox;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.ispinner.UISpinner;
@ -105,42 +102,46 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
boolean currentIsRootLayout = currentEditingTemplate != null && !currentEditingTemplate.isJWorkBook() && ((JForm)currentEditingTemplate).isSelectRootPane(); boolean currentIsRootLayout = currentEditingTemplate != null && !currentEditingTemplate.isJWorkBook() && ((JForm)currentEditingTemplate).isSelectRootPane();
JPanel titlePane = createTitleStylePane(); JPanel titlePane = createTitleStylePane();
JPanel bodyContentPane = currentIsRootLayout ? createBodyContentPane4RootLayout() : createBodyContentPane();
JPanel backgroundPane = createBackgroundStylePane();
if (titlePane != null) { if (titlePane != null) {
container.add(titlePane, BorderLayout.NORTH); container.add(titlePane, BorderLayout.NORTH);
if (currentIsRootLayout) { if (currentIsRootLayout) {
titlePane.setVisible(false); titlePane.setVisible(false);
} }
} }
JPanel nextContainerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
container.add(nextContainerPane, BorderLayout.CENTER);
//界面上表单主体只有背景和透明度可以设置 if (bodyContentPane != null) {
JPanel mainStylePane = currentIsRootLayout ? createMainStylePane4RootLayout() : createMainStylePane4WidgetLayout(); //界面上表单主体只有背景和透明度可以设置
if (mainStylePane != null) { nextContainerPane.add(bodyContentPane, BorderLayout.NORTH);
container.add(mainStylePane, BorderLayout.CENTER); }
if (backgroundPane != null) {
nextContainerPane.add(backgroundPane, BorderLayout.CENTER);
if (currentIsRootLayout) {
backgroundPane.setVisible(false);
}
} }
this.add(container, BorderLayout.CENTER); this.add(container, BorderLayout.CENTER);
} }
protected void initMainComponents() { protected JPanel createBackgroundStylePane() {
borderStyleCombo = new UIComboBox(BORDER_STYLE); borderStyleCombo = new UIComboBox(BORDER_STYLE);
borderLineAndImagePane = new BorderLineAndImagePane(); borderLineAndImagePane = new BorderLineAndImagePane();
cornerSpinner = new UISpinner(0,1000,1,0); cornerSpinner = new UISpinner(0,1000,1,0);
backgroundPane = new LayoutBackgroundSpecialPane();
backgroundOpacityPane = new UIPercentDragPane();
}
protected JPanel createMainStylePane4WidgetLayout() {
initMainComponents();
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
double[] rowSize = {p, p, p, p, p}; double[] rowSize = {p, p, p, p};
double[] columnSize = {SETTING_LABEL_WIDTH, f}; double[] columnSize = {SETTING_LABEL_WIDTH, f};
JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{ JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Frame_Style")), null}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Background_Style")), null},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Render_Style")), borderStyleCombo}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Render_Style")), borderStyleCombo},
{this.borderLineAndImagePane, null}, {this.borderLineAndImagePane, null},
{this.createMainBackgroundAndOpacityPane(), null},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Radius")), cornerSpinner}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Radius")), cornerSpinner},
}, },
rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1); rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1);
@ -153,16 +154,23 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
return container; return container;
} }
protected JPanel createMainStylePane4RootLayout() { protected JPanel createBodyContentPane() {
initMainComponents(); backgroundPane = new LayoutBackgroundSpecialPane();
backgroundOpacityPane = new UIPercentDragPane();
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
double[] rowSize = {p, p}; double[] rowSize = {p, p};
double[] columnSize = {SETTING_LABEL_WIDTH, f}; double[] columnSize = {SETTING_LABEL_WIDTH, f};
JPanel bodyBackground = createBackgroundAndOpacityPane(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Fill"),
this.backgroundPane,
this.backgroundOpacityPane);
JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{ JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Frame_Style")), null}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Content")), null},
{this.createMainBackgroundAndOpacityPane(), null}, {bodyBackground, null},
}, },
rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1); rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1);
contentPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); contentPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
@ -174,11 +182,31 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
return container; return container;
} }
protected JPanel createMainBackgroundAndOpacityPane() { protected JPanel createBodyContentPane4RootLayout() {
return createBackgroundAndOpacityPane( backgroundPane = new LayoutBackgroundSpecialPane();
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Background"), backgroundOpacityPane = new UIPercentDragPane();
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] rowSize = {p};
double[] columnSize = {SETTING_LABEL_WIDTH, f};
JPanel bodyBackground = createBackgroundAndOpacityPane(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Fill"),
this.backgroundPane, this.backgroundPane,
this.backgroundOpacityPane); this.backgroundOpacityPane);
JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{
{bodyBackground, null},
},
rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1);
contentPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane();
container.setBorder(new BottomLineBorder());
container.add(contentPane, BorderLayout.NORTH);
return container;
} }
protected void initTitleComponents() { protected void initTitleComponents() {
@ -489,16 +517,25 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
protected static class BottomLineBorder extends LineBorder { protected static class BottomLineBorder extends LineBorder {
public BottomLineBorder() { public BottomLineBorder() {
super(Color.lightGray, 1); super(new Color(217, 218, 221), 1);
} }
@Override @Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
Color oldColor = g2d.getColor(); Color oldColor = g2d.getColor();
g2d.setColor(this.lineColor); Stroke oldStroke = g2d.getStroke();
GraphHelper.drawLine(g, 0, height, width, height, 1);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(getLineColor());
g2d.setStroke(new BasicStroke(getThickness() * 2));
g2d.drawLine(0, height, width, height);
g2d.setStroke(oldStroke);
g2d.setColor(oldColor); g2d.setColor(oldColor);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
} }
} }

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

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

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

@ -112,7 +112,12 @@ public class FormCreatorDropTarget extends DropTarget {
if (addingXCreator.isShared()) { if (addingXCreator.isShared()) {
if (container.acceptType(XWAbsoluteLayout.class)) { if (container.acceptType(XWAbsoluteLayout.class)) {
// 绝对布局中新添加的共享组件默认锁定尺寸比例 // 绝对布局中新添加的共享组件默认锁定尺寸比例
addingXCreator.toData().setAspectRatioLocked(true); Rectangle bounds = new Rectangle(addingXCreator.getBounds());
Widget addingWidget = addingXCreator.toData();
if (addingWidget != null && bounds.width > 0 && bounds.height > 0) {
addingXCreator.toData().setAspectRatioLocked(true);
addingXCreator.toData().setAspectRatioBackup(1.0 * bounds.width / bounds.height);
}
} }
String shareId = addingXCreator.getShareId(); String shareId = addingXCreator.getShareId();

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

@ -103,14 +103,11 @@ public class WidgetBoundPane extends BasicPane {
} }
public void populate() { public void populate() {
Rectangle bounds = new Rectangle(creator.getBounds()); if (ratioLockedButton == null) {
if (ratioLockedButton != null) { Rectangle bounds = new Rectangle(creator.getBounds());
// 临时禁止尺寸比例锁定,关掉widthSpinner/heightSpinner之间的数值关联,以更新其高度和宽度值 width.setValue(bounds.width);
ratioLockedButton.setLocked(false); height.setValue(bounds.height);
} } else {
width.setValue(bounds.width);
height.setValue(bounds.height);
if (ratioLockedButton != null) {
ratioLockedButton.populate(creator); ratioLockedButton.populate(creator);
} }
} }
@ -213,8 +210,7 @@ public class WidgetBoundPane extends BasicPane {
private final UISpinner mWidthSpinner; private final UISpinner mWidthSpinner;
private final UISpinner mHeightSpinner; private final UISpinner mHeightSpinner;
protected double width4Backup = 0; protected double aspectRatioBackup = 0;
protected double height4Backup = 0;
public AspectRatioLockedButton(UISpinner widthSpinner, UISpinner heightSpinner) { public AspectRatioLockedButton(UISpinner widthSpinner, UISpinner heightSpinner) {
setUI(new BasicButtonUI()); setUI(new BasicButtonUI());
@ -229,12 +225,16 @@ public class WidgetBoundPane extends BasicPane {
addActionListener(new ActionListener() { addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
// 改变图标icon double width = mWidthSpinner.getValue();
setLocked(!isLocked()); double height = mHeightSpinner.getValue();
boolean nextLocked = !isLocked();
if (isLocked() && isLockEnabled()) {
width4Backup = mWidthSpinner.getValue(); if (nextLocked && width > 0 && height > 0) {
height4Backup = mHeightSpinner.getValue(); setLocked(true);
aspectRatioBackup = width / height;
} else {
setLocked(false);
aspectRatioBackup = -1;
} }
if (globalNameListener != null) { if (globalNameListener != null) {
@ -250,16 +250,28 @@ public class WidgetBoundPane extends BasicPane {
mWidthSpinner.addChangeListener(new ChangeListener() { mWidthSpinner.addChangeListener(new ChangeListener() {
@Override @Override
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
if (isLockEnabled() && isLocked() && width4Backup > 0 && height4Backup > 0) { if (isLockEnabled() && isLocked()) {
mHeightSpinner.setValue(mWidthSpinner.getValue() * height4Backup / width4Backup, false); if (mWidthSpinner.getValue() == 0) {
setLocked(false);
aspectRatioBackup = -1;
} else if (aspectRatioBackup > 0) {
double value = mWidthSpinner.getValue() / aspectRatioBackup;
mHeightSpinner.setValue(Math.round(value), false);
}
} }
} }
}); });
mHeightSpinner.addChangeListener(new ChangeListener() { mHeightSpinner.addChangeListener(new ChangeListener() {
@Override @Override
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
if (isLockEnabled() && isLocked() && width4Backup > 0 && height4Backup > 0) { if (isLockEnabled() && isLocked()) {
mWidthSpinner.setValue(mHeightSpinner.getValue() * width4Backup / height4Backup, false); if (mHeightSpinner.getValue() == 0) {
setLocked(false);
aspectRatioBackup = -1;
}else if (aspectRatioBackup > 0) {
double value = mHeightSpinner.getValue() * aspectRatioBackup;
mWidthSpinner.setValue(Math.round(value), false);
}
} }
} }
}); });
@ -301,14 +313,26 @@ public class WidgetBoundPane extends BasicPane {
public void populate(XCreator creator) { public void populate(XCreator creator) {
Rectangle bounds = new Rectangle(creator.getBounds()); Rectangle bounds = new Rectangle(creator.getBounds());
width4Backup = bounds.width;
height4Backup = bounds.height;
Widget widget = creator.toData(); Widget widget = creator.toData();
aspectRatioBackup = widget.getAspectRatioBackup();
setLocked(widget.isAspectRatioLocked()); setLocked(widget.isAspectRatioLocked());
mWidthSpinner.setValue(bounds.width, false);
mHeightSpinner.setValue(bounds.height, false);
} }
public void update(XCreator creator) { public void update(XCreator creator) {
creator.toData().setAspectRatioLocked(this.isLocked()); Widget widget = creator.toData();
if (widget != null) {
if (this.isLocked()) {
widget.setAspectRatioLocked(true);
widget.setAspectRatioBackup(this.aspectRatioBackup);
} else {
widget.setAspectRatioLocked(false);
widget.setAspectRatioBackup(-1.0);
}
}
} }
@Override @Override

18
designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java

@ -409,11 +409,11 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
int currentWidth = currentRight - currentLeft; int currentWidth = currentRight - currentLeft;
int currentHeight = currentBottom - currentTop; int currentHeight = currentBottom - currentTop;
int backupWidth= resizingBackupBounds[2];
int backupHeight= resizingBackupBounds[3];
if (cursorType == Cursor.NW_RESIZE_CURSOR || cursorType == Cursor.NE_RESIZE_CURSOR || cursorType == Cursor.SE_RESIZE_CURSOR || cursorType == Cursor.SW_RESIZE_CURSOR) { if (cursorType == Cursor.NW_RESIZE_CURSOR || cursorType == Cursor.NE_RESIZE_CURSOR || cursorType == Cursor.SE_RESIZE_CURSOR || cursorType == Cursor.SW_RESIZE_CURSOR) {
if (aspectRatio) { if (aspectRatio && resizingBackupBounds != null) {
int backupWidth= resizingBackupBounds[2];
int backupHeight= resizingBackupBounds[3];
double currentDiagonal = Math.pow(currentWidth, 2) + Math.pow(currentHeight, 2); double currentDiagonal = Math.pow(currentWidth, 2) + Math.pow(currentHeight, 2);
double backupDiagonal = Math.pow(backupWidth, 2) + Math.pow(backupHeight, 2); double backupDiagonal = Math.pow(backupWidth, 2) + Math.pow(backupHeight, 2);
@ -453,7 +453,10 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
floatElement.setTopDistance(topDistance); floatElement.setTopDistance(topDistance);
floatElement.setHeight(FU.valueOfPix(currentBottom, resolution).subtract(floatY1_fu)); floatElement.setHeight(FU.valueOfPix(currentBottom, resolution).subtract(floatY1_fu));
if (aspectRatio) { if (aspectRatio && resizingBackupBounds != null) {
int backupWidth= resizingBackupBounds[2];
int backupHeight= resizingBackupBounds[3];
currentWidth = backupWidth * currentHeight / backupHeight; currentWidth = backupWidth * currentHeight / backupHeight;
currentRight = currentLeft + currentWidth; currentRight = currentLeft + currentWidth;
FU floatX1_fu = FU.valueOfPix(currentLeft, resolution); FU floatX1_fu = FU.valueOfPix(currentLeft, resolution);
@ -466,7 +469,10 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
floatElement.setLeftDistance(leftDistance); floatElement.setLeftDistance(leftDistance);
floatElement.setWidth(FU.valueOfPix(currentRight, resolution).subtract(floatX1_fu)); floatElement.setWidth(FU.valueOfPix(currentRight, resolution).subtract(floatX1_fu));
if (aspectRatio) { if (aspectRatio && resizingBackupBounds != null) {
int backupWidth= resizingBackupBounds[2];
int backupHeight= resizingBackupBounds[3];
currentHeight = backupHeight * currentWidth / backupWidth; currentHeight = backupHeight * currentWidth / backupWidth;
currentBottom = currentTop + currentHeight; currentBottom = currentTop + currentHeight;
FU floatY1_fu = FU.valueOfPix(currentTop, resolution); FU floatY1_fu = FU.valueOfPix(currentTop, resolution);

Loading…
Cancel
Save