Browse Source

Merge remote-tracking branch 'origin/release/10.0' into release/10.0

zheng-1641779399395
pengda 3 years ago
parent
commit
56911fd39b
  1. 24
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/FileTableDataPane.java
  2. 3
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  3. BIN
      designer-base/src/main/resources/com/fr/design/images/control/aspect_ratio_lock.png
  4. BIN
      designer-base/src/main/resources/com/fr/design/images/control/aspect_ratio_unlock.png
  5. BIN
      designer-base/src/main/resources/com/fr/design/images/transparent_background.jpg
  6. 10
      designer-form/src/main/java/com/fr/design/designer/beans/events/DesignerEditor.java
  7. 8
      designer-form/src/main/java/com/fr/design/designer/creator/XAutoChartCreator.java
  8. 13
      designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java
  9. 14
      designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java
  10. 8
      designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java
  11. 45
      designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java
  12. 12
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java
  13. 19
      designer-form/src/main/java/com/fr/design/designer/ui/PopupControlPanel.java
  14. 5
      designer-form/src/main/java/com/fr/design/designer/ui/SelectedPopupDialog.java
  15. 246
      designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java
  16. 67
      designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java
  17. 17
      designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java
  18. 4
      designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java
  19. 25
      designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java
  20. 4
      designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java
  21. 27
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  22. 1
      designer-form/src/main/java/com/fr/design/mainframe/TabDragInner.java
  23. 5
      designer-realize/src/main/java/com/fr/poly/creator/ECBlockPane.java

24
designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/FileTableDataPane.java

@ -26,6 +26,7 @@ import com.fr.design.gui.itableeditorpane.UITableEditorPane;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
@ -612,7 +613,7 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
private void setTextField(FileTableData ob) { private void setTextField(FileTableData ob) {
if (ob.getFilePath() != null) { if (ob.getFilePath() != null) {
if (ob.getFilePath().indexOf("http") != -1) { if (ob.getFilePath().contains("http")) {
urlRadioSelectAction(); urlRadioSelectAction();
urlText.setText(ob.getFilePath()); urlText.setText(ob.getFilePath());
} else { } else {
@ -625,6 +626,15 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
@Override @Override
public FileTableData updateBean() { public FileTableData updateBean() {
String filePath = getFilePathFromUrlOrLocal(); String filePath = getFilePathFromUrlOrLocal();
// 安全要求禁止 file 协议访问本地磁盘
if (FileTableData.isInvalidFilePath(filePath)) {
FineJOptionPane.showMessageDialog(this,
Toolkit.i18nText("Fine-Design_File_Table_Data_Path_Invalid"),
Toolkit.i18nText("Fine-Design_Basic_Widget_Error_Tip"),
JOptionPane.ERROR_MESSAGE);
// 阻止对话框关闭
throw new RuntimeException(Toolkit.i18nText("Fine-Design_File_Table_Data_Path_Invalid"));
}
if (StringUtils.isNotBlank(filePath)) { if (StringUtils.isNotBlank(filePath)) {
this.params = getEditorPaneParameter().length == 0 ? null : getEditorPaneParameter(); this.params = getEditorPaneParameter().length == 0 ? null : getEditorPaneParameter();
if (fileTypeComboBox.getSelectedIndex() == EXCEL) { if (fileTypeComboBox.getSelectedIndex() == EXCEL) {
@ -786,6 +796,14 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
if (this.fileTableData == null) { if (this.fileTableData == null) {
return; return;
} }
String filePath = getFilePathFromUrlOrLocal();
if (FileTableData.isInvalidFilePath(filePath)) {
FineJOptionPane.showMessageDialog(this,
Toolkit.i18nText("Fine-Design_File_Table_Data_Path_Invalid"),
Toolkit.i18nText("Fine-Design_Basic_Widget_Error_Tip"),
JOptionPane.ERROR_MESSAGE);
return;
}
PreviewTablePane.previewTableData(this.updateBean()); PreviewTablePane.previewTableData(this.updateBean());
} }
@ -802,7 +820,7 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
xmlNodeTree = new XMLNodeTree(); xmlNodeTree = new XMLNodeTree();
this.add(new JScrollPane(xmlNodeTree)); this.add(new JScrollPane(xmlNodeTree));
keyPointLaber = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Key_Point") + ":"); keyPointLaber = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Key_Point") + ":");
refreshAction = new RefreshParameterAction(); refreshAction = new RefreshParameterAction();
ToolBarDef toolbarDef = new ToolBarDef(); ToolBarDef toolbarDef = new ToolBarDef();
toolbarDef.addShortCut(refreshAction); toolbarDef.addShortCut(refreshAction);
@ -820,7 +838,7 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
private class RefreshParameterAction extends UpdateAction { private class RefreshParameterAction extends UpdateAction {
public RefreshParameterAction() { public RefreshParameterAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Refresh")); this.setName(Toolkit.i18nText("Fine-Design_Basic_Refresh"));
this.setMnemonic('r'); this.setMnemonic('r');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/refresh.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/refresh.png"));
} }

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

@ -17,6 +17,7 @@ import com.fr.design.actions.file.SaveAsTemplateAction;
import com.fr.design.actions.file.SaveTemplateAction; import com.fr.design.actions.file.SaveTemplateAction;
import com.fr.design.actions.file.WebPreviewUtils; import com.fr.design.actions.file.WebPreviewUtils;
import com.fr.design.base.mode.DesignModeContext; import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.data.datapane.TableDataTreePane;
import com.fr.design.designer.DesignerProxy; import com.fr.design.designer.DesignerProxy;
import com.fr.design.designer.TargetComponent; import com.fr.design.designer.TargetComponent;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
@ -389,6 +390,8 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
addCenterPane(); addCenterPane();
refreshToolArea(); refreshToolArea();
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).refreshDockingView();
} }
}); });

BIN
designer-base/src/main/resources/com/fr/design/images/control/aspect_ratio_lock.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 B

BIN
designer-base/src/main/resources/com/fr/design/images/control/aspect_ratio_unlock.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 B

BIN
designer-base/src/main/resources/com/fr/design/images/transparent_background.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

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

@ -86,9 +86,15 @@ public class DesignerEditor<T extends JComponent> implements PropertyChangeListe
int horizonMargin = marginLeft + marginRight; int horizonMargin = marginLeft + marginRight;
int verticalMargin = marginTop + marginBottom; int verticalMargin = marginTop + marginBottom;
comp.setSize(new Dimension(size.width - 2 - horizonMargin, size.height - 2 - verticalMargin)); int x = 1 + marginLeft;
int y = 1 + marginTop;
int width = size.width - 2 - horizonMargin;
int height = size.height - 2 - verticalMargin;
comp.setSize(new Dimension(width, height));
LayoutUtils.layoutContainer(comp); LayoutUtils.layoutContainer(comp);
Graphics clipg = g.create(1 + marginLeft, 1 + marginTop, size.width, size.height); comp.setBounds(comp.getX() + x, comp.getY() + y, width, height);
Graphics clipg = g.create(x, y, width, height);
this.comp.paint(clipg); this.comp.paint(clipg);
} }
} }

8
designer-form/src/main/java/com/fr/design/designer/creator/XAutoChartCreator.java

@ -18,8 +18,7 @@ import com.fr.stable.bridge.StableFactory;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.Dimension; import java.awt.*;
import java.awt.Graphics;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
@ -102,7 +101,8 @@ public class XAutoChartCreator extends XChartEditor {
} }
public void paint(Graphics g) { @Override
public void paintForeground(Graphics2D g) {
BufferedImage bufferedImage = IOUtils.readImage("com/fr/design/form/images/auto_chart_preview.png"); BufferedImage bufferedImage = IOUtils.readImage("com/fr/design/form/images/auto_chart_preview.png");
GraphHelper.paintImage( GraphHelper.paintImage(
g, this.getWidth(), this.getHeight(), bufferedImage, g, this.getWidth(), this.getHeight(), bufferedImage,
@ -110,7 +110,7 @@ public class XAutoChartCreator extends XChartEditor {
0, 0,
0, -1, -1 0, -1, -1
); );
super.paint(g); super.paintForeground(g);
} }
private void initChart(BaseChartCollection chartCollection) { private void initChart(BaseChartCollection chartCollection) {

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

@ -222,24 +222,23 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
} }
// 设计器预览界面中绘制组件背景效果 // 设计器预览界面中绘制组件背景效果
private void paintBackground(Graphics2D g2d) { public void paintBackground(Graphics2D g2d) {
Background background4Painting = getBackground4Painting(); Background background4Painting = getBackground4Painting();
if (background4Painting != null) { if (background4Painting != null) {
background4Painting.paint(g2d, new Rectangle2D.Double(0, 0, getWidth(), getHeight())); background4Painting.paint(g2d, new Rectangle2D.Double(0, 0, getWidth(), getHeight()));
} }
} }
@Override public void paintForeground(Graphics2D g2d) {
protected void paintComponent(Graphics g) { super.paint(g2d);
this.paintBackground((Graphics2D) g); super.paintBorder(g2d);
super.paintComponent(g);
} }
@Override @Override
public void paint(Graphics g) { public void paint(Graphics g) {
this.clipByRoundedBorder((Graphics2D) g); this.clipByRoundedBorder((Graphics2D) g);
super.paint(g); this.paintBackground((Graphics2D) g);
paintBorder(g); this.paintForeground((Graphics2D) g);
} }
@Override @Override

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

@ -29,12 +29,8 @@ 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.SwingUtilities;
import java.awt.*;
import java.beans.IntrospectionException; import java.beans.IntrospectionException;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
/** /**
@ -150,6 +146,9 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
if (isEditing) { if (isEditing) {
g.setColor(OUTER_BORDER_COLOR); g.setColor(OUTER_BORDER_COLOR);
GraphHelper.draw(g, new Rectangle(bounds.x - BORDER_WIDTH, bounds.y - BORDER_WIDTH, bounds.width + BORDER_WIDTH + 1, bounds.height + BORDER_WIDTH + 1), Constants.LINE_LARGE); GraphHelper.draw(g, new Rectangle(bounds.x - BORDER_WIDTH, bounds.y - BORDER_WIDTH, bounds.width + BORDER_WIDTH + 1, bounds.height + BORDER_WIDTH + 1), Constants.LINE_LARGE);
g.setColor(INNER_BORDER_COLOR);
GraphHelper.draw(g, new Rectangle(bounds.x, bounds.y, bounds.width, bounds.height), Constants.LINE_MEDIUM);
} else if (!isHovering) { } else if (!isHovering) {
super.paintBorder(g, bounds); super.paintBorder(g, bounds);
} }
@ -228,7 +227,8 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
/** /**
* 渲染Painter * 渲染Painter
*/ */
public void paint(Graphics g) { @Override
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);
@ -237,7 +237,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
int verticalMargin = margin != null ? margin.getTop() + margin.getBottom() : 0; int verticalMargin = margin != null ? margin.getTop() + margin.getBottom() : 0;
coverPanel.setSize(size.width - horizonMargin, size.height - verticalMargin); coverPanel.setSize(size.width - horizonMargin, size.height - verticalMargin);
} }
super.paint(g); super.paintForeground(g);
if (isEditing) { if (isEditing) {
g.setColor(INNER_BORDER_COLOR); g.setColor(INNER_BORDER_COLOR);
GraphHelper.draw(g, new Rectangle(0, 0, getWidth(), getHeight()), Constants.LINE_MEDIUM); GraphHelper.draw(g, new Rectangle(0, 0, getWidth(), getHeight()), Constants.LINE_MEDIUM);

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

@ -778,7 +778,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
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.setLocation(designer.getLocationOnScreen().x + designer.getPaintX() + extraX, designer.getLocationOnScreen().y + designer.getPaintY() + extraY);
popup.updatePane(designer); popup.updatePane(designer);
popup.setVisible(selected && accept); popup.setVisible(selected && accept && popup.hasVisibleButtons());
popup.setRelativeBounds(bounds); popup.setRelativeBounds(bounds);
} }
@ -830,4 +830,10 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
} }
} }
public void hidePopup() {
if (popup != null) {
popup.setVisible(false);
}
}
} }

45
designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java

@ -758,6 +758,11 @@ public class XWFitLayout extends XLayoutContainer {
int[] veris = getVeris(true); int[] veris = getVeris(true);
int containerWidth = 0; int containerWidth = 0;
int containerHeight = 0; int containerHeight = 0;
PaddingMargin margin = toData().getMargin();
int maxW = this.getWidth() - margin.getRight();
int maxH = this.getHeight() - margin.getBottom();
for (int index=0, n=this.getComponentCount(); index<n; index++) { for (int index=0, n=this.getComponentCount(); index<n; index++) {
XCreator creator = (XCreator) this.getComponent(index); XCreator creator = (XCreator) this.getComponent(index);
BoundsWidget wgt = (BoundsWidget) layout.getBoundsWidget(creator.toData()); BoundsWidget wgt = (BoundsWidget) layout.getBoundsWidget(creator.toData());
@ -793,6 +798,14 @@ public class XWFitLayout extends XLayoutContainer {
BoundsWidget wgt = (BoundsWidget) layout.getBoundsWidget(creator.toData()); BoundsWidget wgt = (BoundsWidget) layout.getBoundsWidget(creator.toData());
//如果子组件是绝对布局,则内部的widget也要更新 //如果子组件是绝对布局,则内部的widget也要更新
if (creator.acceptType(XWAbsoluteLayout.class)){ if (creator.acceptType(XWAbsoluteLayout.class)){
// backupBounds处理下内边距 否则计算缩放比例时总是存在一个内边距的误差
if (creator.getBackupBound() != null) {
Rectangle backUpBound = creator.getBackupBound();
processContainerMargin(margin, backUpBound, maxW, maxH);
creator.setBackupBound(backUpBound);
}
//更新的时候一定要带上backupBound //更新的时候一定要带上backupBound
if (creator.getBackupBound() == null && wgt.getBeforeScaleBounds() != null) { if (creator.getBackupBound() == null && wgt.getBeforeScaleBounds() != null) {
creator.setBackupBound(dealWgtBound(wgt.getBeforeScaleBounds())); creator.setBackupBound(dealWgtBound(wgt.getBeforeScaleBounds()));
@ -1064,24 +1077,28 @@ public class XWFitLayout extends XLayoutContainer {
for (int i=0; i<num; i++) { for (int i=0; i<num; i++) {
Component comp = this.getComponent(i); Component comp = this.getComponent(i);
Rectangle rec = comp.getBounds(); Rectangle rec = comp.getBounds();
if (rec.x == margin.getLeft()) { processContainerMargin(margin, rec, maxW, maxH);
rec.x = 0;
rec.width += margin.getLeft();
}
if (rec.y == margin.getTop()) {
rec.y = 0;
rec.height += margin.getTop();
}
if (rec.x +rec.width == maxW) {
rec.width += margin.getRight();
}
if (rec.y + rec.height == maxH) {
rec.height += margin.getBottom();
}
comp.setBounds(rec); comp.setBounds(rec);
} }
} }
private void processContainerMargin(PaddingMargin margin, Rectangle rec, int maxW, int maxH) {
if (rec.x == margin.getLeft()) {
rec.x = 0;
rec.width += margin.getLeft();
}
if (rec.y == margin.getTop()) {
rec.y = 0;
rec.height += margin.getTop();
}
if (rec.x +rec.width == maxW) {
rec.width += margin.getRight();
}
if (rec.y + rec.height == maxH) {
rec.height += margin.getBottom();
}
}
public Component getTopComp(int x, int y) { public Component getTopComp(int x, int y) {
int val = getAcualInterval(); int val = getAcualInterval();
return this.getComponentAt(x, y-default_Length-val); return this.getComponentAt(x, y-default_Length-val);

12
designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java

@ -3,6 +3,7 @@
*/ */
package com.fr.design.designer.creator.cardlayout; package com.fr.design.designer.creator.cardlayout;
import com.fr.base.GraphHelper;
import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.LayoutAdapter;
@ -32,6 +33,8 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.act.BorderPacker; import com.fr.general.act.BorderPacker;
import com.fr.stable.Constants;
import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Cursor; import java.awt.Cursor;
import java.awt.Dimension; import java.awt.Dimension;
@ -50,6 +53,9 @@ import java.util.List;
*/ */
public class XWCardMainBorderLayout extends XWBorderLayout { public class XWCardMainBorderLayout extends XWBorderLayout {
private static final int BORDER_WIDTH = 4;
private static final Color OUTER_BORDER_COLOR = new Color(65, 155, 249, 30);
private static final int CENTER = 1; private static final int CENTER = 1;
private static final int NORTH = 0; private static final int NORTH = 0;
private static final int TITLE_STYLE = 2; private static final int TITLE_STYLE = 2;
@ -345,6 +351,12 @@ public class XWCardMainBorderLayout extends XWBorderLayout {
@Override @Override
public void paintBorder(Graphics g, Rectangle bounds){ public void paintBorder(Graphics g, Rectangle bounds){
if (isDragInAble()) {
Color oldColor = g.getColor();
g.setColor(OUTER_BORDER_COLOR);
GraphHelper.draw(g, new Rectangle(bounds.x - BORDER_WIDTH, bounds.y - BORDER_WIDTH, bounds.width + BORDER_WIDTH + 3, bounds.height + BORDER_WIDTH + 3), Constants.LINE_LARGE);
g.setColor(oldColor);
}
if (!isMouseEnter) { if (!isMouseEnter) {
super.paintBorder(g, bounds); super.paintBorder(g, bounds);
} }

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

@ -4,6 +4,7 @@ import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.adapters.layout.FRAbsoluteLayoutAdapter; import com.fr.design.designer.beans.adapters.layout.FRAbsoluteLayoutAdapter;
import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XWTitleLayout;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.VerticalFlowLayout; import com.fr.design.layout.VerticalFlowLayout;
@ -58,7 +59,7 @@ public class PopupControlPanel extends JPanel {
addButton(toggleButton, 1); addButton(toggleButton, 1);
addButton(settingButton, 2); addButton(settingButton, 2);
setButtonVisible(editButton, true); setButtonVisible(editButton, false);
setButtonVisible(toggleButton, false); setButtonVisible(toggleButton, false);
setButtonVisible(settingButton, false); setButtonVisible(settingButton, false);
} }
@ -81,9 +82,9 @@ public class PopupControlPanel extends JPanel {
} }
private JToggleButton createAspectRatioLockedButton(FormDesigner designer) { private JToggleButton createAspectRatioLockedButton(FormDesigner designer) {
JToggleButton button = new JToggleButton(IOUtils.readIcon("/com/fr/design/images/control/edit_unlock.png")); JToggleButton button = new JToggleButton(IOUtils.readIcon("/com/fr/design/images/control/aspect_ratio_unlock.png"));
initButtonStyle(button); initButtonStyle(button);
button.setSelectedIcon(IOUtils.readIcon("com/fr/design/images/control/edit_lock.png")); button.setSelectedIcon(IOUtils.readIcon("com/fr/design/images/control/aspect_ratio_lock.png"));
button.setToolTipText(Toolkit.i18nText("Fine-Design_Form_UnLock_Widget_Ratio")); button.setToolTipText(Toolkit.i18nText("Fine-Design_Form_UnLock_Widget_Ratio"));
button.addActionListener(new ActionListener() { button.addActionListener(new ActionListener() {
@Override @Override
@ -139,7 +140,7 @@ public class PopupControlPanel extends JPanel {
if (index > 0) { if (index > 0) {
getComponent(2 * index - 1).setVisible(false); getComponent(2 * index - 1).setVisible(false);
} }
buttons.get(index).setVisible(true); buttons.get(index).setVisible(visible);
if (!visible) { if (!visible) {
// 如果当前按钮设置为不可见,且在当前按钮之前的其他按钮也不可见,则下一个可见按钮前无分割线 // 如果当前按钮设置为不可见,且在当前按钮之前的其他按钮也不可见,则下一个可见按钮前无分割线
@ -192,6 +193,7 @@ public class PopupControlPanel extends JPanel {
} }
public void updatePane(FormDesigner designer) { public void updatePane(FormDesigner designer) {
setButtonVisible(editButton, creator.acceptType(XWTitleLayout.class));
setButtonVisible(settingButton, creator.isShared()); setButtonVisible(settingButton, creator.isShared());
setButtonVisible(toggleButton, AdapterBus.searchLayoutAdapter(designer, creator) instanceof FRAbsoluteLayoutAdapter); setButtonVisible(toggleButton, AdapterBus.searchLayoutAdapter(designer, creator) instanceof FRAbsoluteLayoutAdapter);
toggleButton.setSelected(creator.toData().isAspectRatioLocked()); toggleButton.setSelected(creator.toData().isAspectRatioLocked());
@ -199,6 +201,15 @@ public class PopupControlPanel extends JPanel {
updateDimension(); updateDimension();
} }
public boolean hasVisibleButtons() {
for (int i = 0; i < buttons.size(); i++) {
if (buttons.get(i).isVisible()) {
return true;
}
}
return false;
}
private void updateDimension() { private void updateDimension() {
int height = 0; int height = 0;
for (int i = 0; i < buttons.size(); i++) { for (int i = 0; i < buttons.size(); i++) {

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

@ -24,6 +24,7 @@ public class SelectedPopupDialog extends JDialog {
super(DesignerContext.getDesignerFrame()); super(DesignerContext.getDesignerFrame());
this.setUndecorated(true); this.setUndecorated(true);
this.setModal(false); this.setModal(false);
this.setFocusableWindowState(false);
controlPanel = new PopupControlPanel(creator, designer); controlPanel = new PopupControlPanel(creator, designer);
this.getContentPane().add(controlPanel); this.getContentPane().add(controlPanel);
this.setSize(controlPanel.getDefaultDimension()); this.setSize(controlPanel.getDefaultDimension());
@ -34,6 +35,10 @@ public class SelectedPopupDialog extends JDialog {
this.setSize(controlPanel.getDefaultDimension()); this.setSize(controlPanel.getDefaultDimension());
} }
public boolean hasVisibleButtons() {
return controlPanel.hasVisibleButtons();
}
public void setRelativeBounds(Rectangle rectangle) { public void setRelativeBounds(Rectangle rectangle) {
this.controlPanel.setRelativeBounds(rectangle); this.controlPanel.setRelativeBounds(rectangle);
} }

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

@ -20,6 +20,7 @@ import com.fr.design.gui.ibutton.UIButtonUI;
import com.fr.design.gui.ibutton.UIColorButton; import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.icombobox.LineComboBox; import com.fr.design.gui.icombobox.LineComboBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UIIntNumberField;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
@ -44,11 +45,13 @@ import javax.swing.plaf.basic.BasicButtonUI;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener; import java.awt.event.MouseMotionListener;
import java.awt.geom.Line2D;
import java.awt.geom.RoundRectangle2D; import java.awt.geom.RoundRectangle2D;
import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
@ -65,7 +68,7 @@ import java.util.Arrays;
public class BorderLineAndImagePane extends JPanel implements UIObserver { public class BorderLineAndImagePane extends JPanel implements UIObserver {
private final int SETTING_LABEL_WIDTH = LayoutStylePane.SETTING_LABEL_WIDTH; private final int SETTING_LABEL_WIDTH = LayoutStylePane.SETTING_LABEL_WIDTH;
private final Style DEFAULT_IMAGE_LAYOUT_STYLE = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_DEFAULT); private final Style DEFAULT_IMAGE_LAYOUT_STYLE = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_DEFAULT);
private final String TWEAK_NINE_POINT_HELP_URL = ""; private final String TWEAK_NINE_POINT_HELP_URL = "https://help.fanruan.com/finereport/doc-view-4135.html";
private UIObserverListener uiObserverListener; private UIObserverListener uiObserverListener;
@ -415,18 +418,11 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
private void initComponents() { private void initComponents() {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
setBorder(BorderFactory.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Border_Image_Config_Nine_Point_Fill_Preview"))); setBorder(BorderFactory.createEmptyBorder());
add(previewPane, BorderLayout.CENTER);
JPanel content = FRGUIPaneFactory.createBorderLayout_S_Pane(); previewPane.setPreferredSize(new Dimension(615, 462));
content.setBorder(BorderFactory.createEmptyBorder( previewPane.setBorder(BorderFactory.createEmptyBorder());
IntervalConstants.INTERVAL_W1,
IntervalConstants.INTERVAL_W1,
IntervalConstants.INTERVAL_W1,
IntervalConstants.INTERVAL_W1));
content.add(previewPane);
previewPane.setPreferredSize(new Dimension(611, 457));
add(content, BorderLayout.CENTER);
} }
@Override @Override
@ -436,18 +432,23 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
} }
private class NinePointLinePreviewPane extends JPanel implements MouseMotionListener, MouseListener { private class NinePointLinePreviewPane extends JPanel implements MouseMotionListener, MouseListener {
private final BufferedImage transparentImage = IOUtils.readImage("/com/fr/design/images/transparent_background.jpg"); public final Color BACKGROUND_PANE_COLOR = Color.WHITE;
public final Color BACKGROUND_IMG_COLOR = Color.lightGray;
public final Color PATCH_COLOR = new Color(0, 0, 0, 38); public final Color DIVIDER_BACKGROUND_COLOR = Color.WHITE;
public final Color DIVIDER_COLOR = new Color(250, 250, 250); public final Color DIVIDER_FOREGROUND_COLOR = Color.BLACK;
public final Color TEXT_COLOR = Color.WHITE; public final Color HINT_BACKGROUND_COLOR = new Color(255, 255, 255, 100);
public final int PADDING = 15; public final Color HINT_FOREGROUND_COLOR = Color.RED;
public final Color HINT_LINE_BACKGROUND_COLOR = Color.WHITE;
public final Color HINT_LINE_FOREGROUND_COLOR = Color.RED;
public final int PADDING = 20;
private int ninePointLeft = -1; private int ninePointLeft = -1;
private int ninePointTop = -1; private int ninePointTop = -1;
private int ninePointRight = -1; private int ninePointRight = -1;
private int ninePointBottom = -1; private int ninePointBottom = -1;
private static final int MIN_NINE_POINT = 0;
private int imgWidth; private int imgWidth;
private int imgHeight; private int imgHeight;
private int scaleImgWidth; private int scaleImgWidth;
@ -456,9 +457,52 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
private int scaleImgY; private int scaleImgY;
private double scale = 1.0; private double scale = 1.0;
private final UIIntNumberField topField = createNumberField();
private final UIIntNumberField bottomField = createNumberField();
private final UIIntNumberField leftField = createNumberField();
private final UIIntNumberField rightField = createNumberField();
public NinePointLinePreviewPane() { public NinePointLinePreviewPane() {
this.setLayout(null);
this.addMouseMotionListener(this); this.addMouseMotionListener(this);
this.addMouseListener(this); this.addMouseListener(this);
this.setFocusable(true);
this.add(topField);
this.add(bottomField);
this.add(leftField);
this.add(rightField);
topField.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
int value = (int) topField.getValue();
onNinePointTopChanged(value);
}
});
bottomField.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
int value = (int) bottomField.getValue();
onNinePointBottomChanged(value);
}
});
leftField.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
int value = (int) leftField.getValue();
onNinePointLeftChanged(value);
}
});
rightField.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
int value = (int) rightField.getValue();
onNinePointRightChanged(value);
}
});
} }
@Override @Override
@ -466,7 +510,9 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
super.paintComponent(g); super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
g2d.drawImage(transparentImage, 0, 0, getWidth(), getHeight(), null);
g2d.setColor(BACKGROUND_PANE_COLOR);
g2d.fillRect(0, 0, getWidth(), getHeight());
Image image = imagePreviewPane.getImage(); Image image = imagePreviewPane.getImage();
@ -491,6 +537,8 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
scale = 1.0 * scaleImgHeight / imgHeight; scale = 1.0 * scaleImgHeight / imgHeight;
} }
g2d.setColor(BACKGROUND_IMG_COLOR);
g2d.fillRect(scaleImgX, scaleImgY, scaleImgWidth, scaleImgHeight);
g2d.drawImage(image, scaleImgX, scaleImgY, scaleImgWidth, scaleImgHeight, null); g2d.drawImage(image, scaleImgX, scaleImgY, scaleImgWidth, scaleImgHeight, null);
int scaleLeft = (int) (ninePointLeft * scale); int scaleLeft = (int) (ninePointLeft * scale);
@ -503,28 +551,45 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
double leftXInPane = scaleImgX + scaleLeft; double leftXInPane = scaleImgX + scaleLeft;
double rightXInPane = scaleImgX + scaleImgWidth - scaleRight; double rightXInPane = scaleImgX + scaleImgWidth - scaleRight;
g2d.setColor(PATCH_COLOR); // 绘制分割线
// draw horizontal patch // 顶部
GraphDrawHelper.fillRect(g2d, 0, topYInPane, getWidth(), scaleImgHeight - scaleTop - scaleBottom); drawLine(g2d, DIVIDER_BACKGROUND_COLOR, DIVIDER_FOREGROUND_COLOR, scaleImgX, topYInPane, scaleImgX + scaleImgWidth, topYInPane);
// draw vertical patch // 底部
GraphDrawHelper.fillRect(g2d, scaleImgX + scaleLeft, 0,scaleImgWidth - scaleLeft - scaleRight, getHeight()); drawLine(g2d, DIVIDER_BACKGROUND_COLOR, DIVIDER_FOREGROUND_COLOR, scaleImgX, bottomYInPane, scaleImgX + scaleImgWidth, bottomYInPane);
// 左侧
g2d.setColor(DIVIDER_COLOR); drawLine(g2d, DIVIDER_BACKGROUND_COLOR, DIVIDER_FOREGROUND_COLOR, leftXInPane, scaleImgY, leftXInPane, scaleImgY + scaleImgHeight);
// draw top divider // 右侧
GraphDrawHelper.drawLine(g2d, 0, topYInPane, getWidth(), topYInPane); drawLine(g2d, DIVIDER_BACKGROUND_COLOR, DIVIDER_FOREGROUND_COLOR, rightXInPane, scaleImgY, rightXInPane, scaleImgY + scaleImgHeight);
// draw bottom divider
GraphDrawHelper.drawLine(g2d, 0, bottomYInPane, getWidth(), bottomYInPane); // 绘制分割线位置提示
// draw left divider // 顶部
GraphDrawHelper.drawLine(g2d, leftXInPane, 0, leftXInPane, getHeight()); drawLine(g2d, HINT_LINE_BACKGROUND_COLOR, HINT_LINE_FOREGROUND_COLOR, (leftXInPane + rightXInPane) / 2.0F, scaleImgY, (leftXInPane + rightXInPane) / 2.0F, topYInPane);
// draw right divider drawHint(g2d, Integer.toString(ninePointTop), (leftXInPane + rightXInPane) / 2.0F, (scaleImgY + topYInPane) / 2.0, topField);
GraphDrawHelper.drawLine(g2d, rightXInPane, 0, rightXInPane, getHeight()); // 底部
drawLine(g2d, HINT_LINE_BACKGROUND_COLOR, HINT_LINE_FOREGROUND_COLOR, (leftXInPane + rightXInPane) / 2.0F, bottomYInPane, (leftXInPane + rightXInPane) / 2.0F, scaleImgY + scaleImgHeight);
g2d.setColor(TEXT_COLOR); drawHint(g2d, Integer.toString(ninePointBottom), (leftXInPane + rightXInPane) / 2.0F, (bottomYInPane + scaleImgY + scaleImgHeight) / 2.0, bottomField);
// draw nine point info // 左侧
GraphDrawHelper.drawString(g2d, Integer.toString(ninePointTop), (leftXInPane + rightXInPane) / 2.0F, topYInPane / 2.0); drawLine(g2d, HINT_LINE_BACKGROUND_COLOR, HINT_LINE_FOREGROUND_COLOR, scaleImgX, (topYInPane + bottomYInPane) / 2.0, leftXInPane, (topYInPane + bottomYInPane) / 2.0);
GraphDrawHelper.drawString(g2d, Integer.toString(ninePointBottom), (leftXInPane + rightXInPane) / 2.0F, (bottomYInPane + getHeight()) / 2.0); drawHint(g2d, Integer.toString(ninePointLeft), (scaleImgX + leftXInPane) / 2.0, (topYInPane + bottomYInPane) / 2.0, leftField);
GraphDrawHelper.drawString(g2d, Integer.toString(ninePointLeft), leftXInPane / 2.0, (topYInPane + bottomYInPane) / 2.0); // 右侧
GraphDrawHelper.drawString(g2d, Integer.toString(ninePointRight), (rightXInPane + getWidth()) / 2.0, (topYInPane + bottomYInPane) / 2.0); drawLine(g2d, HINT_LINE_BACKGROUND_COLOR, HINT_LINE_FOREGROUND_COLOR, rightXInPane, (topYInPane + bottomYInPane) / 2.0, scaleImgX + scaleImgWidth, (topYInPane + bottomYInPane) / 2.0);
drawHint(g2d, Integer.toString(ninePointRight), (rightXInPane + scaleImgX + scaleImgWidth) / 2.0, (topYInPane + bottomYInPane) / 2.0, rightField);
}
private void drawHint(Graphics2D g2d, String hint, double centerX, double centerY, UIIntNumberField hintField) {
FontMetrics metrics = GraphDrawHelper.getFontMetrics(g2d.getFont());
double height = metrics.getAscent() + metrics.getDescent();
double width = Math.max(metrics.stringWidth(" " + hint + " "), metrics.stringWidth(" 123 "));
hintField.setBounds((int) (centerX - width / 2.0), (int) (centerY - height / 2.0), (int) width, (int) height);
}
private void drawLine(Graphics2D g2d, Color backgroundColor, Color foregroundColor, double x1, double y1, double x2, double y2) {
g2d.setColor(backgroundColor);
GraphDrawHelper.draw(g2d, new Line2D.Double(x1, y1, x2, y2), Constants.LINE_THIN, 2.0F);
g2d.setColor(foregroundColor);
GraphDrawHelper.draw(g2d, new Line2D.Double(x1, y1, x2, y2), Constants.LINE_DASH, 1.0F);
} }
@Override @Override
@ -537,34 +602,22 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
switch (cursorType) { switch (cursorType) {
case Cursor.W_RESIZE_CURSOR: { case Cursor.W_RESIZE_CURSOR: {
int nextLeft = (int) ((x - scaleImgX) / scale); int nextLeft = (int) ((x - scaleImgX) / scale);
if (1 <= nextLeft && nextLeft < imgWidth - ninePointRight) { this.onNinePointLeftChanged(nextLeft);
ninePointLeft = nextLeft;
repaint();
}
return; return;
} }
case Cursor.E_RESIZE_CURSOR: { case Cursor.E_RESIZE_CURSOR: {
int nextRight = (int) ((scaleImgX + scaleImgWidth - x) / scale); int nextRight = (int) ((scaleImgX + scaleImgWidth - x) / scale);
if (1 <= nextRight && nextRight < imgWidth - ninePointLeft) { this.onNinePointRightChanged(nextRight);
ninePointRight = nextRight;
repaint();
}
return; return;
} }
case Cursor.N_RESIZE_CURSOR: { case Cursor.N_RESIZE_CURSOR: {
int nextTop = (int) ((y - scaleImgY) / scale); int nextTop = (int) ((y - scaleImgY) / scale);
if (1 <= nextTop && nextTop < imgHeight - ninePointBottom) { this.onNinePointTopChanged(nextTop);
ninePointTop = nextTop;
repaint();
}
return; return;
} }
case Cursor.S_RESIZE_CURSOR: { case Cursor.S_RESIZE_CURSOR: {
int nextBottom = (int) ((scaleImgY + scaleImgHeight - y) / scale); int nextBottom = (int) ((scaleImgY + scaleImgHeight - y) / scale);
if (1 <= nextBottom && nextBottom < imgHeight - ninePointTop) { this.onNinePointBottomChanged(nextBottom);
ninePointBottom = nextBottom;
repaint();
}
} }
} }
} }
@ -584,10 +637,17 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
// determine cursor // determine cursor
int cursorType = Cursor.DEFAULT_CURSOR; int cursorType = Cursor.DEFAULT_CURSOR;
boolean hoveringLeftDivider = Math.abs(x - (scaleImgX + scaleLeft)) < 2; boolean hoveringLeftDivider = false;
boolean hoveringRightDivider = Math.abs(x - (scaleImgX + scaleImgWidth - scaleRight)) < 2; boolean hoveringRightDivider = false;
boolean hoveringTopDivider = Math.abs(y - (scaleImgY + scaleTop)) < 2; boolean hoveringTopDivider = false;
boolean hoveringBottomDivider = Math.abs(y - (scaleImgY + scaleImgHeight - scaleBottom)) < 2; boolean hoveringBottomDivider = false;
if (scaleImgX - 2 <= x && x <= scaleImgX + scaleImgWidth + 2 && scaleImgY - 2 <= y && y <= scaleImgY + scaleImgHeight + 2) {
hoveringLeftDivider = Math.abs(x - (scaleImgX + scaleLeft)) < 2;
hoveringRightDivider = Math.abs(x - (scaleImgX + scaleImgWidth - scaleRight)) < 2;
hoveringTopDivider = Math.abs(y - (scaleImgY + scaleTop)) < 2;
hoveringBottomDivider = Math.abs(y - (scaleImgY + scaleImgHeight - scaleBottom)) < 2;
}
if (hoveringLeftDivider) { if (hoveringLeftDivider) {
cursorType = Cursor.W_RESIZE_CURSOR; cursorType = Cursor.W_RESIZE_CURSOR;
@ -609,7 +669,7 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
requestFocus();
} }
@Override @Override
@ -634,12 +694,72 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
} }
private void onNinePointTopChanged(int value) {
if (value < MIN_NINE_POINT) {
value = MIN_NINE_POINT;
} else if (value >= imgHeight - ninePointBottom) {
value = imgHeight - ninePointBottom - MIN_NINE_POINT;
}
this.ninePointTop = value;
topField.setText(Integer.toString(value));
repaint();
}
private void onNinePointBottomChanged(int value) {
if (value < MIN_NINE_POINT) {
value = MIN_NINE_POINT;
} else if (value >= imgHeight - ninePointTop) {
value = imgHeight - ninePointTop - MIN_NINE_POINT;
}
this.ninePointBottom = value;
bottomField.setText(Integer.toString(value));
repaint();
}
private void onNinePointLeftChanged(int value) {
if (value < MIN_NINE_POINT) {
value = MIN_NINE_POINT;
} else if (value >= imgWidth - ninePointRight) {
value = imgWidth - ninePointRight - MIN_NINE_POINT;
}
this.ninePointLeft = value;
leftField.setText(Integer.toString(value));
repaint();
}
private void onNinePointRightChanged(int value) {
if (value < MIN_NINE_POINT) {
value = MIN_NINE_POINT;
} else if (value >= imgWidth - ninePointLeft) {
value = imgWidth - ninePointLeft - MIN_NINE_POINT;
}
this.ninePointRight = value;
rightField.setText(Integer.toString(value));
repaint();
}
private UIIntNumberField createNumberField() {
UIIntNumberField field = new UIIntNumberField();
field.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1));
field.setOpaque(true);
field.setMinValue(MIN_NINE_POINT);
field.setForeground(HINT_FOREGROUND_COLOR);
field.setBackground(HINT_BACKGROUND_COLOR);
field.setHorizontalAlignment(SwingConstants.CENTER);
return field;
}
public void setNinePoint(int[] ninePoint) { public void setNinePoint(int[] ninePoint) {
ninePointLeft = ninePoint[0]; ninePointLeft = ninePoint[0];
ninePointTop = ninePoint[1]; ninePointTop = ninePoint[1];
ninePointRight = ninePoint[2]; ninePointRight = ninePoint[2];
ninePointBottom = ninePoint[3]; ninePointBottom = ninePoint[3];
leftField.setValue(ninePointLeft);
rightField.setValue(ninePointRight);
topField.setValue(ninePointTop);
bottomField.setValue(ninePointBottom);
} }
public int[] getNinePoint() { public int[] getNinePoint() {

67
designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java

@ -4,6 +4,7 @@ import com.fr.design.constants.UIConstants;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWTitleLayout;
import com.fr.design.designer.treeview.ComponentTreeCellRenderer; import com.fr.design.designer.treeview.ComponentTreeCellRenderer;
import com.fr.design.designer.treeview.ComponentTreeModel; import com.fr.design.designer.treeview.ComponentTreeModel;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
@ -16,6 +17,7 @@ import com.fr.stable.StringUtils;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
import java.util.Stack; import java.util.Stack;
import java.util.function.Consumer;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.DropMode; import javax.swing.DropMode;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -349,6 +351,7 @@ public class ComponentTree extends JTree {
private final class ComponetTreeMouseListener extends MouseAdapter { private final class ComponetTreeMouseListener extends MouseAdapter {
private final JTree tree; private final JTree tree;
private XCreator selectedCreator;
private ComponetTreeMouseListener(JTree tree) { private ComponetTreeMouseListener(JTree tree) {
this.tree = tree; this.tree = tree;
@ -378,19 +381,59 @@ public class ComponentTree extends JTree {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
// 鼠标左键 双击 onMouseEvent(e, new Consumer<XCreator>() {
if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1 && !designer.isFormParaDesigner()) { @Override
Point p = e.getPoint(); public void accept(XCreator creator) {
// 解析组件树路径 获取选中的组件 if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1 && !designer.isFormParaDesigner()) {
int selRow = tree.getRowForLocation(p.x, p.y); startEditing(creator, e);
TreePath path = tree.getPathForRow(selRow); }
Rectangle bounds = tree.getPathBounds(path); }
if (bounds != null) { });
Point point = bounds.getLocation();
SwingUtilities.convertPointToScreen(point, tree); }
XCreator comp = (XCreator) path.getLastPathComponent();
startEditing(comp, e); @Override
public void mousePressed(MouseEvent e) {
onMouseEvent(e, new Consumer<XCreator>() {
@Override
public void accept(XCreator creator) {
if (e.getButton() == MouseEvent.BUTTON1) {
selectedCreator = creator;
}
} }
});
}
@Override
public void mouseReleased(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON1 && selectedCreator != null) {
showSelectedPopup(selectedCreator);
}
}
private void showSelectedPopup(XCreator comp) {
Rectangle rectangle = getRelativeBounds(comp);
comp.showSelectedPopup(designer, rectangle, comp.acceptType(XWTitleLayout.class));
comp.setSelected(true);
}
/**
* 响应鼠标事件并解析选中的组件
*
* @param e
* @param consumer
*/
private void onMouseEvent(final MouseEvent e, Consumer<XCreator> consumer) {
Point p = e.getPoint();
// 解析组件树路径 获取选中的组件
int selRow = tree.getRowForLocation(p.x, p.y);
TreePath path = tree.getPathForRow(selRow);
Rectangle bounds = tree.getPathBounds(path);
if (bounds != null) {
Point point = bounds.getLocation();
SwingUtilities.convertPointToScreen(point, tree);
XCreator comp = (XCreator) path.getLastPathComponent();
consumer.accept(comp);
} }
} }

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

@ -624,6 +624,8 @@ public class EditingMouseListener extends MouseInputAdapter {
creator = processTopLayoutMouseClick(creator); creator = processTopLayoutMouseClick(creator);
if (creator != null) { if (creator != null) {
// tab块处于未编辑状态
boolean uneditedTab = designer.getCursor().getType() != Cursor.HAND_CURSOR && creator.acceptType(XWCardMainBorderLayout.class) && !((XWCardMainBorderLayout) creator).isEditable();
// 点击不在tab块的button中 // 点击不在tab块的button中
boolean clickedNonCardButton = !creator.acceptType(XCardAddButton.class, XCardSwitchButton.class); boolean clickedNonCardButton = !creator.acceptType(XCardAddButton.class, XCardSwitchButton.class);
if (clickedNonCardButton && e.getClickCount() == 1 && designer.getCursor().getType() != Cursor.HAND_CURSOR) { if (clickedNonCardButton && e.getClickCount() == 1 && designer.getCursor().getType() != Cursor.HAND_CURSOR) {
@ -631,10 +633,17 @@ public class EditingMouseListener extends MouseInputAdapter {
selectionModel.selectACreatorAtMouseEvent(e); selectionModel.selectACreatorAtMouseEvent(e);
refreshTopXCreator(); refreshTopXCreator();
XCreator[] xCreators = selectionModel.getSelection().getSelectedCreators(); XCreator[] xCreators = selectionModel.getSelection().getSelectedCreators();
for (XCreator xCreator : xCreators) { // 放到事件队尾执行
xCreator.setSelected(true); SwingUtilities.invokeLater(new Runnable() {
} @Override
} else if (clickedNonCardButton && responseTabLayout(oldCreator, e)) { public void run() {
for (XCreator xCreator : xCreators) {
xCreator.setSelected(true);
}
}
});
} else if (clickedNonCardButton && uneditedTab && responseTabLayout(oldCreator, e)) {
// do nothing // do nothing
} else { } else {
creator.respondClick(this, e); creator.respondClick(this, e);

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

@ -335,4 +335,8 @@ public class FormCreatorDropTarget extends DropTarget {
} }
} }
} }
public TabDragInner getTabDragInner() {
return this.tabDragInner;
}
} }

25
designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java

@ -13,7 +13,7 @@ import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.creator.XWTitleLayout; import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
import com.fr.design.form.util.XCreatorConstants; import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.roleAuthority.ReportAndFSManagePane; import com.fr.design.roleAuthority.ReportAndFSManagePane;
import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.ComponentUtils;
@ -24,6 +24,7 @@ import com.fr.report.core.ReportUtils;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import java.awt.dnd.DropTarget;
import javax.swing.*; import javax.swing.*;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
import java.awt.AlphaComposite; import java.awt.AlphaComposite;
@ -94,6 +95,7 @@ public class FormDesignerUI extends ComponentUI {
} }
paintBorder(g); paintBorder(g);
paintSelection(g); paintSelection(g);
paintDropBorderShadow(g);
if (DesignerMode.isAuthorityEditing()) { if (DesignerMode.isAuthorityEditing()) {
paintAuthorityDetails(g, designer.getRootComponent()); paintAuthorityDetails(g, designer.getRootComponent());
@ -326,7 +328,26 @@ public class FormDesignerUI extends ComponentUI {
} }
creator.paintBorder(g, creatorBounds); creator.paintBorder(g, creatorBounds);
// 拖拽时不绘制 // 拖拽时不绘制
creator.showSelectedPopup(designer, creatorBounds, !designer.getStateModel().isDragging() && creator.acceptType(XWTitleLayout.class)); creator.showSelectedPopup(designer, creatorBounds, !designer.getStateModel().isDragging());
}
}
/**
* 绘制可拖拽进tab块之前的阴影
*
* @param g
*/
private void paintDropBorderShadow(Graphics g) {
DropTarget dropTarget = designer.getDropTarget();
if (dropTarget instanceof FormCreatorDropTarget) {
FormCreatorDropTarget target = (FormCreatorDropTarget) dropTarget;
XLayoutContainer layoutContainer = target.getTabDragInner().getBelowXLayoutContainer();
if (layoutContainer != null && layoutContainer.acceptType(XWCardMainBorderLayout.class)) {
Rectangle creatorBounds = ComponentUtils.getRelativeBounds(layoutContainer);
creatorBounds.x -= designer.getHorizontalScaleValue();
creatorBounds.y -= designer.getVerticalScaleValue();
layoutContainer.paintBorder(g, creatorBounds);
}
} }
} }

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

@ -277,7 +277,9 @@ public class FormSelection {
for (XCreator creator : selection) { for (XCreator creator : selection) {
LayoutAdapter layoutAdapter = AdapterBus.searchLayoutAdapter(designer, creator); LayoutAdapter layoutAdapter = AdapterBus.searchLayoutAdapter(designer, creator);
if (layoutAdapter != null) { if (layoutAdapter != null) {
if (creator.acceptType(XWAbsoluteLayout.class) && recs.size() > i) { // 这里处理绝对画布块 仅局限于选中多个组件且其中包含了绝对画布块的情况
boolean accept = creator.acceptType(XWAbsoluteLayout.class) && recs.size() > i && selection.size() > 1;
if (accept) {
Rectangle rectangle = recs.get(i); Rectangle rectangle = recs.get(i);
check4ParaPane(rectangle); check4ParaPane(rectangle);
creator.setBackupBound(rectangle); creator.setBackupBound(rectangle);

27
designer-form/src/main/java/com/fr/design/mainframe/JForm.java

@ -47,8 +47,6 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.form.FormECCompositeProvider; import com.fr.design.mainframe.form.FormECCompositeProvider;
import com.fr.design.mainframe.form.FormECDesignerProvider; import com.fr.design.mainframe.form.FormECDesignerProvider;
import com.fr.design.mainframe.share.collect.ComponentCollector;
import com.fr.design.mainframe.share.util.ShareComponentUtils;
import com.fr.design.mainframe.template.info.JFormProcessInfo; import com.fr.design.mainframe.template.info.JFormProcessInfo;
import com.fr.design.mainframe.template.info.TemplateProcessInfo; import com.fr.design.mainframe.template.info.TemplateProcessInfo;
import com.fr.design.mainframe.toolbar.ToolBarMenuDock; import com.fr.design.mainframe.toolbar.ToolBarMenuDock;
@ -79,10 +77,8 @@ import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WBorderLayout;
import com.fr.form.ui.container.WLayout; import com.fr.form.ui.container.WLayout;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.json.JSONArray;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.page.PaperSettingProvider; import com.fr.page.PaperSettingProvider;
import com.fr.plugin.observer.PluginEventListener;
import com.fr.report.cell.Elem; import com.fr.report.cell.Elem;
import com.fr.report.cell.cellattr.CellImage; import com.fr.report.cell.cellattr.CellImage;
import com.fr.report.worksheet.FormElementCase; import com.fr.report.worksheet.FormElementCase;
@ -93,6 +89,8 @@ import com.fr.stable.StringUtils;
import com.fr.stable.bridge.StableFactory; import com.fr.stable.bridge.StableFactory;
import com.fr.web.controller.ViewRequestConstants; import com.fr.web.controller.ViewRequestConstants;
import java.awt.event.ContainerAdapter;
import java.awt.event.ContainerEvent;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JComponent; import javax.swing.JComponent;
@ -135,18 +133,36 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
//FORM_TAB代表是否点击编辑,用于点击编辑前后菜单的显示 //FORM_TAB代表是否点击编辑,用于点击编辑前后菜单的显示
protected int index = FORM_TAB; protected int index = FORM_TAB;
private PluginEventListener pluginListener; private ContainerAdapter containerAdapter = new ContainerAdapter() {
@Override
public void componentRemoved(ContainerEvent e) {
// 当前jfrom未在tab中显示时
if (formDesign != null) {
XCreator[] creators = formDesign.getSelectionModel().getSelection().getSelectedCreators();
for (XCreator creator : creators) {
creator.hidePopup();
}
}
}
};
public JForm() { public JForm() {
super(new Form(new WBorderLayout("form")), "Form"); super(new Form(new WBorderLayout("form")), "Form");
init();
} }
public JForm(Form form, FILE file, Parameter[] parameters) { public JForm(Form form, FILE file, Parameter[] parameters) {
super(form, file, parameters); super(form, file, parameters);
init();
} }
public JForm(Form form, FILE file) { public JForm(Form form, FILE file) {
super(form, file); super(form, file);
init();
}
private void init() {
DesignerContext.getDesignerFrame().getCenterTemplateCardPane().addContainerListener(containerAdapter);
} }
@Override @Override
@ -1114,6 +1130,7 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
public void whenClose() { public void whenClose() {
super.whenClose(); super.whenClose();
this.releaseResources(); this.releaseResources();
DesignerContext.getDesignerFrame().getCenterTemplateCardPane().removeContainerListener(this.containerAdapter);
} }
@Override @Override

1
designer-form/src/main/java/com/fr/design/mainframe/TabDragInner.java

@ -71,6 +71,7 @@ public class TabDragInner {
ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, belowXLayoutContainer); ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, belowXLayoutContainer);
if (adapter != null) { if (adapter != null) {
editingMouseListener.startEditing(belowXLayoutContainer, adapter.getDesignerEditor(), adapter); editingMouseListener.startEditing(belowXLayoutContainer, adapter.getDesignerEditor(), adapter);
belowXLayoutContainer.setDragInAble(false);
} }
} }
} }

5
designer-realize/src/main/java/com/fr/poly/creator/ECBlockPane.java

@ -18,6 +18,7 @@ import com.fr.design.actions.edit.HyperlinkAction;
import com.fr.design.actions.edit.merge.MergeCellAction; import com.fr.design.actions.edit.merge.MergeCellAction;
import com.fr.design.actions.edit.merge.UnmergeCellAction; import com.fr.design.actions.edit.merge.UnmergeCellAction;
import com.fr.design.actions.utils.DeprecatedActionManager; import com.fr.design.actions.utils.DeprecatedActionManager;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedEvent;
import com.fr.design.event.TargetModifiedListener; import com.fr.design.event.TargetModifiedListener;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
@ -55,10 +56,10 @@ public class ECBlockPane extends PolyElementCasePane {
@Override @Override
public void selectionChanged(SelectionEvent e) { public void selectionChanged(SelectionEvent e) {
if (!isEditable()) { if (!isEditable() && !DesignModeContext.isAuthorityEditing()) {
return; return;
} }
if (DesignerMode.isAuthorityEditing()) { if (DesignModeContext.isAuthorityEditing()) {
if (designer.getSelection().getEditingElementCasePane() == null) { if (designer.getSelection().getEditingElementCasePane() == null) {
EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.AUTHORITY_EDITION_DISABLED); EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.AUTHORITY_EDITION_DISABLED);
EastRegionContainerPane.getInstance().replaceAuthorityEditionPane(new NoSupportAuthorityEdit()); EastRegionContainerPane.getInstance().replaceAuthorityEditionPane(new NoSupportAuthorityEdit());

Loading…
Cancel
Save