Browse Source

Merge branch 'feature/10.0' of ssh://code.fineres.com:7999/~tommy/design into feature/10.0

feature/10.0
kuangshuai 3 years ago
parent
commit
3132a16e09
  1. 25
      designer-base/src/main/java/com/fr/design/border/UIRoundedBorder.java
  2. 9
      designer-base/src/main/java/com/fr/design/data/datapane/connect/DBCPAttrPane.java
  3. 4
      designer-base/src/main/java/com/fr/design/editor/editor/Editor.java
  4. 5
      designer-base/src/main/java/com/fr/design/file/Releasable.java
  5. 6
      designer-base/src/main/java/com/fr/design/gui/ipasswordfield/UIPasswordFieldWithFixedLength.java
  6. 7
      designer-base/src/main/java/com/fr/design/gui/style/BackgroundSpecialPane.java
  7. 5
      designer-base/src/main/java/com/fr/env/CheckServiceDialog.java
  8. 148
      designer-base/src/main/java/com/fr/env/utils/DesignerInteractionHistory.java
  9. BIN
      designer-base/src/main/resources/com/fr/design/images/control/edit_lock.png
  10. BIN
      designer-base/src/main/resources/com/fr/design/images/control/edit_unlock.png
  11. 16
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java
  12. 2
      designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java
  13. 9
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartTimeAxisPane.java
  14. 1
      designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/SeriesTypeUseComboxPaneWithOutFilter.java
  15. 28
      designer-form/src/main/java/com/fr/design/designer/beans/location/AccessDirection.java
  16. 7
      designer-form/src/main/java/com/fr/design/designer/beans/models/StateModel.java
  17. 47
      designer-form/src/main/java/com/fr/design/designer/creator/SelectedBorderIcon.java
  18. 138
      designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java
  19. 2
      designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java
  20. 21
      designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java
  21. 10
      designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java
  22. 2
      designer-form/src/main/java/com/fr/design/designer/creator/XLayoutContainer.java
  23. 1
      designer-form/src/main/java/com/fr/design/designer/creator/XNameWidget.java
  24. 2
      designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java
  25. 4
      designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java
  26. 14
      designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java
  27. 2
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardLayout.java
  28. 191
      designer-form/src/main/java/com/fr/design/designer/ui/PopupControlPanel.java
  29. 36
      designer-form/src/main/java/com/fr/design/designer/ui/SelectedPopupDialog.java
  30. 9
      designer-form/src/main/java/com/fr/design/gui/controlpane/EventPropertyPane.java
  31. 31
      designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java
  32. 14
      designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java
  33. 71
      designer-form/src/main/java/com/fr/design/gui/xpane/TitleInsetImagePane.java
  34. 5
      designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java
  35. 12
      designer-form/src/main/java/com/fr/design/mainframe/FormParaWidgetPane.java
  36. 10
      designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java
  37. 8
      designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java
  38. 46
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  39. 28
      designer-form/src/main/java/com/fr/design/mainframe/WidgetPropertyPane.java
  40. 7
      designer-form/src/main/java/com/fr/design/mainframe/XCreateGather.java
  41. 15
      designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java
  42. 3
      designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetAbsoluteBoundPane.java
  43. 78
      designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java
  44. 4
      designer-realize/src/main/java/com/fr/start/MainDesigner.java

25
designer-base/src/main/java/com/fr/design/border/UIRoundedBorder.java

@ -1,32 +1,33 @@
package com.fr.design.border;
import com.fr.base.GraphHelper;
import com.fr.stable.GraphDrawHelper;
import javax.swing.border.LineBorder;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.*;
import java.awt.geom.RoundRectangle2D;
public class UIRoundedBorder extends LineBorder {
private static final long serialVersionUID = 1L;
private BasicStroke stroke4Thickness;
private int roundedCorner;
private int lineStyle;
public UIRoundedBorder(Color color) {
super(color);
this.stroke4Thickness = new BasicStroke(thickness, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER);
}
public UIRoundedBorder(Color color, int thickness){
super(color, thickness);
this.stroke4Thickness = new BasicStroke(thickness, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER);
}
public UIRoundedBorder(Color color, int thickness, int roundedCorners){
super(color, thickness, true);
this.stroke4Thickness = new BasicStroke(thickness, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER);
this.roundedCorner = roundedCorners;
}
@ -51,7 +52,19 @@ public class UIRoundedBorder extends LineBorder {
Graphics2D g2d = (Graphics2D)g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(lineColor);
GraphHelper.draw(g2d, new RoundRectangle2D.Double(x, y, width - 1.0D, height - 1.0D, roundedCorner, roundedCorner), lineStyle);
Shape shape = new RoundRectangle2D.Double(x, y, width - 1.0D, height - 1.0D, roundedCorner, roundedCorner);
if (stroke4Thickness != null) {
Stroke oldStroke = g2d.getStroke();
g2d.setStroke(stroke4Thickness);
g2d.draw(shape);
g2d.setStroke(oldStroke);
} else {
GraphHelper.draw(g2d, shape, lineStyle);
}
g2d.setColor(oldColor);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
}

9
designer-base/src/main/java/com/fr/design/data/datapane/connect/DBCPAttrPane.java

@ -42,6 +42,7 @@ public class DBCPAttrPane extends BasicPane {
private static final int ORACLE_DEFAULT_FETCHSIZE = 128;
private static final int DB2_DEFAULT_FETCHSIZE = 50;
private static final int POSTGRE_DEFAULT_FETCHSIZE = 10000;
private static final int EMPTY_FETCHSIZE = -2;
// carl:DBCP的一些属性
private IntegerEditor DBCP_INITIAL_SIZE = new IntegerEditor();
private IntegerEditor DBCP_MAX_ACTIVE = new IntegerEditor();
@ -125,9 +126,13 @@ public class DBCPAttrPane extends BasicPane {
this.DBCP_TIMEBETWEENEVICTIONRUNSMILLS.setValue(dbcpAttr.getTimeBetweenEvictionRunsMillis());
Integer fetchSize = DEFAULT_FETCHSIZE_MAP.get(JDBCConnectionDef.getInstance().getDatabaseName());
if (fetchSize != null) {
if (jdbcDatabase.getFetchSize() == EMPTY_FETCHSIZE) {
this.FETCHSIZE.setText(StringUtils.EMPTY);
} else {
this.FETCHSIZE.setText(jdbcDatabase.getFetchSize() == -1 ? String.valueOf(fetchSize) : String.valueOf(jdbcDatabase.getFetchSize()));
}
}
}
public void update(JDBCDatabaseConnection jdbcDatabase) {
DBCPConnectionPoolAttr dbcpAttr = jdbcDatabase.getDbcpAttr();
@ -149,9 +154,13 @@ public class DBCPAttrPane extends BasicPane {
dbcpAttr.setTimeBetweenEvictionRunsMillis(((Number) this.DBCP_TIMEBETWEENEVICTIONRUNSMILLS.getValue()).intValue());
Integer fetchSize = DEFAULT_FETCHSIZE_MAP.get(JDBCConnectionDef.getInstance().getDatabaseName());
if (fetchSize != null) {
if (StringUtils.isEmpty(this.FETCHSIZE.getText())) {
jdbcDatabase.setFetchSize(EMPTY_FETCHSIZE);
} else {
jdbcDatabase.setFetchSize(Integer.parseInt(this.FETCHSIZE.getText()));
}
}
}
@Override
public BasicDialog showWindow(Window window) {

4
designer-base/src/main/java/com/fr/design/editor/editor/Editor.java

@ -4,6 +4,7 @@
package com.fr.design.editor.editor;
import com.fr.base.BaseUtils;
import com.fr.stable.StringUtils;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
@ -34,6 +35,9 @@ public abstract class Editor<T> extends JComponent {
// 约定图片的文件名为this.getName(),处理起来方便些
// b:这里国际化没有考虑
public Icon getIcon() {
if (StringUtils.isEmpty(this.getIconName())) {
return null;
}
String iconName = "com/fr/design/images/buttonicon/" + this.getIconName() + ".png";
try {
return BaseUtils.readIcon(iconName);

5
designer-base/src/main/java/com/fr/design/file/Releasable.java

@ -1,5 +0,0 @@
package com.fr.design.file;
public interface Releasable {
void releaseResources();
}

6
designer-base/src/main/java/com/fr/design/gui/ipasswordfield/UIPasswordFieldWithFixedLength.java

@ -70,6 +70,12 @@ public class UIPasswordFieldWithFixedLength extends UIPassWordField {
public void mouseClicked(MouseEvent e) {
UIPasswordFieldWithFixedLength.this.clearPassword = true;
}
@Override
public void mousePressed(MouseEvent e) {
// 防止拖动进入
UIPasswordFieldWithFixedLength.this.clearPassword = true;
}
});
this.addKeyListener(new KeyAdapter() {
@Override

7
designer-base/src/main/java/com/fr/design/gui/style/BackgroundSpecialPane.java

@ -39,7 +39,7 @@ public class BackgroundSpecialPane extends BackgroundPane{
fireStateChanged();
}
});
GradientBackgroundQuickPane gradientPane = new GradientBackgroundQuickPane();
GradientBackgroundQuickPane gradientPane = createGradientBackgroundQuickPane();
gradientPane.registerChangeListener(new UIObserverListener() {
@Override
public void doChange() {
@ -68,4 +68,9 @@ public class BackgroundSpecialPane extends BackgroundPane{
return kinds.toArray(new BackgroundQuickPane[kinds.size()]);
}
protected GradientBackgroundQuickPane createGradientBackgroundQuickPane() {
// 使用默认的150宽度构建渐变条
return new GradientBackgroundQuickPane();
}
}

5
designer-base/src/main/java/com/fr/env/CheckServiceDialog.java vendored

@ -167,7 +167,8 @@ public class CheckServiceDialog extends JDialog implements ActionListener {
centerPanel.add(detailsPane, BorderLayout.CENTER);
JPanel buttonPanel = FRGUIPaneFactory.createBorderLayout_M_Pane();
buttonPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
if (isOnline()) {
boolean Sync = false;
if (isOnline() && Sync) {
ignoreButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Sync_Ignore"));
ignoreButton.addActionListener(this);
syncButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Sync_To_Local"));
@ -183,8 +184,6 @@ public class CheckServiceDialog extends JDialog implements ActionListener {
buttonPanel.add(progressBar, BorderLayout.CENTER);
buttonPanel.add(syncButton, BorderLayout.EAST);
} else {
UILabel adviceLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Sync_Suggestion"));
centerPanel.add(adviceLabel, BorderLayout.SOUTH);
UIButton okButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Button_Confirm"));
okButton.addActionListener(this);
buttonPanel.add(okButton, BorderLayout.EAST);

148
designer-base/src/main/java/com/fr/env/utils/DesignerInteractionHistory.java vendored

@ -0,0 +1,148 @@
package com.fr.env.utils;
import com.fr.common.annotations.Compatible;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.EncodeConstants;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLReadable;
import com.fr.stable.xml.XMLTools;
import com.fr.stable.xml.XMLWriter;
import com.fr.stable.xml.XMLableReader;
import com.fr.third.javax.xml.stream.XMLStreamException;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
/**
* @author Starryi
* @version 10.0.18
* Created by Starryi on 2021/7/7
* 设计器访问和获取关键历史交互信息的持久化工具该关键历史交互信息
* 如用户是否点击过某按钮是否查看过某弹窗信息上次选择过的文件所在目录等
*/
@Compatible
public class DesignerInteractionHistory implements XMLReadable, XMLWriter {
private static final String FILE_NAME = "designer.ix.history.info";
private static final String ROOT_TAG = "History";
private static DesignerInteractionHistory history;
public static DesignerInteractionHistory getInstance() {
if (history == null) {
history = new DesignerInteractionHistory();
readXMLFile(history, history.getHistoryFile());
}
return history;
}
private File getHistoryFile() {
return new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), FILE_NAME));
}
private static void readXMLFile(XMLReadable xmlReadable, File xmlFile) {
if (xmlFile == null || !xmlFile.exists()) {
return;
}
String charset = EncodeConstants.ENCODING_UTF_8;
try {
String decodeContent = getFileContent(xmlFile);
InputStream xmlInputStream = new ByteArrayInputStream(decodeContent.getBytes(charset));
InputStreamReader inputStreamReader = new InputStreamReader(xmlInputStream, charset);
XMLableReader xmlReader = XMLableReader.createXMLableReader(inputStreamReader);
if (xmlReader != null) {
xmlReader.readXMLObject(xmlReadable);
}
xmlInputStream.close();
} catch (IOException | XMLStreamException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
private static String getFileContent(File xmlFile) throws FileNotFoundException, UnsupportedEncodingException {
InputStream encodeInputStream = new FileInputStream(xmlFile);
return IOUtils.inputStream2String(encodeInputStream);
}
private static void writeContentToFile(String fileContent, File file) {
try (FileOutputStream fos = new FileOutputStream(file);
OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
BufferedWriter bw = new BufferedWriter(osw)) {
bw.write(fileContent);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
public void saveXMLFile() {
File xmlFile = this.getHistoryFile();
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
XMLTools.writeOutputStreamXML(this, out);
out.flush();
out.close();
String fileContent = new String(out.toByteArray(), StandardCharsets.UTF_8);
writeContentToFile(fileContent, xmlFile);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
private static final String HAS_SHOWN_SHIFT_DRAG_RESIZING_TOOLTIP = "hasShownShiftDragResizingTooltip";
private static final String LAST_SELECTED_BORDER_IMAGE_DIR = "lastSelectedBorderImageDir";
// 是否已展示过按下Shift键可锁定比例拖拽尺寸的Tooltip
private boolean hasShownShiftDragResizingTooltip = false;
// 用户上次通过文件选择器选择的边框图片所在目录
private String lastSelectedBorderImageDir = StringUtils.EMPTY;
public boolean isHasShownShiftDragResizingTooltip() {
return hasShownShiftDragResizingTooltip;
}
public void setHasShownShiftDragResizingTooltip(boolean shown) {
this.hasShownShiftDragResizingTooltip = shown;
}
public String getLastSelectedBorderImageDir() {
return lastSelectedBorderImageDir;
}
public void setLastSelectedBorderImageDir(String dirPath) {
this.lastSelectedBorderImageDir = dirPath;
}
@Override
public void writeXML(XMLPrintWriter writer) {
writer.startTAG(ROOT_TAG)
.attr(HAS_SHOWN_SHIFT_DRAG_RESIZING_TOOLTIP, isHasShownShiftDragResizingTooltip())
.attr(LAST_SELECTED_BORDER_IMAGE_DIR, getLastSelectedBorderImageDir())
.end();
}
@Override
public void readXML(XMLableReader reader) {
setHasShownShiftDragResizingTooltip(reader.getAttrAsBoolean(HAS_SHOWN_SHIFT_DRAG_RESIZING_TOOLTIP, false));
setLastSelectedBorderImageDir(reader.getAttrAsString(LAST_SELECTED_BORDER_IMAGE_DIR, StringUtils.EMPTY));
}
}

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 B

16
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java

@ -111,15 +111,10 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
northPane.setLayout(new BorderLayout());
northPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
JPanel addPanel = new JPanel();
addPanel.setLayout(new BorderLayout());
addPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 3));
addPanel.add(addButton, BorderLayout.CENTER);
JPanel button = new JPanel();
button.setPreferredSize(new Dimension(95, 20));
button.setLayout(new GridLayout(1, 4, 0, 0));
button.add(addPanel);
button.setPreferredSize(new Dimension(89, 20));
button.setLayout(new GridLayout(1, 4, 3, 0));
button.add(addButton);
button.add(copyButton);
button.add(moveForwardButton);
button.add(moveBackButton);
@ -135,14 +130,11 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
addButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png"));
configButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/config.png"));
copyButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/m_edit/copy.png"));
copyButton.setBorderPainted(false);
copyButton.setToolTipText(Toolkit.i18nText("Fine-Design_Basic_Action_Copy"));
moveForwardButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/control/left.png"));
moveForwardButton.setToolTipText(Toolkit.i18nText("Fine-Design_Report_HF_Move_Left"));
moveForwardButton.setBorderPainted(false);
moveBackButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/control/right.png"));
moveBackButton.setToolTipText(Toolkit.i18nText("Fine-Design_Report_HF_Move_Right"));
moveBackButton.setBorderPainted(false);
initAddButton();
initConfigButton();
initMoveButton();
@ -312,7 +304,7 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
}
private String getCopyChartName() {
String chartName = "CopyOf" + editingCollection.getChartName(editingCollection.getSelectedIndex());
String chartName = editingCollection.getChartName(editingCollection.getSelectedIndex()) + "_Copy";
if (!nameRepeated(chartName)) {
return chartName;
}

2
designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java

@ -423,7 +423,7 @@ public class PlotFactory {
//大数据模式 恢复用注释。删除下面2个方法 largeDataModel lineMapLargeModel。
public static boolean largeDataModel(Plot plot) {
return plot != null && plot.getDataProcessor().getMark() == LargeDataModel.MARK;
return plot != null && plot.isLargeDataModel();
}
public static boolean lineMapLargeModel(Plot plot) {

9
designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartTimeAxisPane.java

@ -293,7 +293,7 @@ public class VanChartTimeAxisPane extends VanChartBaseAxisPane {
DateEditor dateEditor = (DateEditor)minValueField.getCurrentEditor();
String dateString = dateEditor.getUIDatePickerFormat().format(datetmp);
timeAxis.setCustomMinValue(StringUtils.isNotEmpty(dateString));
timeAxis.setMinValue(BaseFormula.createFormulaBuilder().build(dateString));
timeAxis.setMinValue(createDataFormula(dateString));
}
} else {
timeAxis.setCustomMinValue(false);
@ -308,7 +308,7 @@ public class VanChartTimeAxisPane extends VanChartBaseAxisPane {
DateEditor dateEditor = (DateEditor)maxValueField.getCurrentEditor();
String dateString = dateEditor.getUIDatePickerFormat().format(datetmp);
timeAxis.setCustomMaxValue(StringUtils.isNotEmpty(dateString));
timeAxis.setMaxValue(BaseFormula.createFormulaBuilder().build(dateString));
timeAxis.setMaxValue(createDataFormula(dateString));
}
} else {
timeAxis.setCustomMaxValue(false);
@ -332,6 +332,11 @@ public class VanChartTimeAxisPane extends VanChartBaseAxisPane {
checkBoxUse();
}
private BaseFormula createDataFormula(String dateString) {
String formulaString = "\"" + dateString + "\"";
return BaseFormula.createFormulaBuilder().build(formulaString);
}
public void populate(VanChartTimeAxis timeAxis){
// 最小值
if (timeAxis.isCustomMinValue() && timeAxis.getMinValue() != null) {

1
designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/SeriesTypeUseComboxPaneWithOutFilter.java

@ -26,6 +26,7 @@ public class SeriesTypeUseComboxPaneWithOutFilter extends SeriesTypeUseComboxPan
protected void initComponents() {
super.initComponents();
this.setSelectedIndex(1);
this.checkCardPane();
}
@Override

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

@ -3,17 +3,19 @@
*/
package com.fr.design.designer.beans.location;
import com.fr.config.ServerPreferenceConfig;
import com.fr.config.utils.ConfigReadUtils;
import com.fr.design.beans.location.Absorptionline;
import com.fr.design.beans.location.MoveUtils;
import com.fr.design.designer.creator.*;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.designer.creator.XWBorderLayout;
import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelection;
import com.fr.design.utils.ComponentUtils;
import com.fr.env.utils.DesignerInteractionHistory;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.form.ui.container.WParameterLayout;
import java.awt.*;
@ -195,10 +197,22 @@ public abstract class AccessDirection implements Direction {
if (type != formEditor.getCursor().getType()) {
// 设置当前形状
formEditor.setCursor(Cursor.getPredefinedCursor(type));
ServerPreferenceConfig config = ServerPreferenceConfig.getInstance();
if (!config.isHasShownLockedAspectRatioResizingToolTip()) {
// 显示/改变Tooltip
showTooltip(formEditor);
}
}
private void showTooltip(FormDesigner formEditor) {
// 显示拖拽改变组件尺寸相关的提示信息
int cursorType = formEditor.getCursor().getType();
if (Cursor.SW_RESIZE_CURSOR <= cursorType && cursorType <= Cursor.E_RESIZE_CURSOR) {
FormSelection selection = formEditor.getSelectionModel().getSelection();
boolean canLockAspectRatioOnlyByShift = !selection.isCreatorAspectRatioLockedInAbsLayout(formEditor) && selection.isCreatorInAbsLayout(formEditor);
DesignerInteractionHistory history = DesignerInteractionHistory.getInstance();
if (canLockAspectRatioOnlyByShift && !history.isHasShownShiftDragResizingTooltip()) {
formEditor.setToolTipText(getTooltip());
config.setHasShownLockedAspectRatioResizingToolTip(true);
history.setHasShownShiftDragResizingTooltip(true);
}
}
}

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

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

47
designer-form/src/main/java/com/fr/design/designer/creator/SelectedBorderIcon.java

@ -1,47 +0,0 @@
package com.fr.design.designer.creator;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.general.IOUtils;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Rectangle;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/06/30
*/
public class SelectedBorderIcon {
private static final Image EDIT_ICON = IOUtils.readImage("/com/fr/design/images/control/show_edit.png");
private static final Image SETTING_ICON = IOUtils.readImage("/com/fr/design/images/control/show_setting.png");
private static final float ALPHA = 0.7F;
private static final int TIP_WIDTH = 20;
private static final int TIP_HEIGHT = 40;
private static final int ARC_VALUE = 4;
// 组件到整个提示之间的空隙
private static final int CREATOR_TO_TIP_GAP = 5;
// icon在整个提示背景下缩进
private static final int TIP_ICON_GAP = 2;
/**
* 在bounds范围的右上角绘制特定图标
*
* @param g
* @param bounds
*/
public void paint(Graphics g, Rectangle bounds) {
Graphics2D g2d = (Graphics2D) g;
AlphaComposite alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, ALPHA);
g2d.setColor(XCreatorConstants.EDIT_COLOR);
g2d.setComposite(alphaComposite);
g2d.fillRoundRect(bounds.x + bounds.width + CREATOR_TO_TIP_GAP, bounds.y, TIP_WIDTH, TIP_HEIGHT, ARC_VALUE, ARC_VALUE);
g2d.drawImage(EDIT_ICON, bounds.x + bounds.width + CREATOR_TO_TIP_GAP + TIP_ICON_GAP, bounds.y + TIP_ICON_GAP, EDIT_ICON.getWidth(null), EDIT_ICON.getHeight(null), null);
g2d.drawImage(SETTING_ICON, bounds.x + bounds.width + CREATOR_TO_TIP_GAP + TIP_ICON_GAP, bounds.y + CREATOR_TO_TIP_GAP + EDIT_ICON.getHeight(null), SETTING_ICON.getWidth(null), SETTING_ICON.getHeight(null), null);
g2d.setColor(Color.WHITE);
g2d.drawLine(bounds.x + bounds.width + CREATOR_TO_TIP_GAP + TIP_ICON_GAP, bounds.y + TIP_WIDTH, bounds.x + bounds.width + CREATOR_TO_TIP_GAP + TIP_ICON_GAP + EDIT_ICON.getWidth(null), bounds.y + TIP_WIDTH);
}
}

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

@ -11,6 +11,7 @@ import com.fr.form.ui.Widget;
import com.fr.form.ui.WidgetTitle;
import com.fr.form.ui.WidgetValue;
import com.fr.form.ui.container.WTitleLayout;
import com.fr.general.Background;
import com.fr.general.ComparatorUtils;
import com.fr.general.act.BorderPacker;
import com.fr.general.act.TitlePacker;
@ -18,7 +19,11 @@ import com.fr.stable.Constants;
import com.fr.stable.StringUtils;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.LineBorder;
import java.awt.*;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RoundRectangle2D;
/**
* Created with IntelliJ IDEA.
@ -29,6 +34,7 @@ import java.awt.*;
public class XBorderStyleWidgetCreator extends XWidgetCreator{
protected static final Dimension BORDER_PREFERRED_SIZE = new Dimension(250, 150);
protected Background background4Painting; // 设计器预览界面中绘制组件背景图
public XBorderStyleWidgetCreator(Widget widget, Dimension initSize) {
super(widget, initSize);
@ -39,6 +45,15 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
}
}
public Background getBackground4Painting() {
return this.background4Painting;
}
public void setBackground4Painting(Background background4Painting) {
this.background4Painting = background4Painting;
this.repaint();
}
/**
* 返回容器对应的widget
* @return 同上
@ -58,22 +73,37 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
protected void initStyle() {
BorderPacker style = toData().getBorderStyle();
initBorderStyle();
initBorderAndBackgroundStyle();
if (ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)) {
initTitleStyle(style);
} else {
clearTitleWidget();
}
// 编辑右侧栏组件样式面板后,重新调整组件/标题/边框的显示效果
reshuffleBorderAndBackgroundPaintingEffectIfTitleExists();
}
// 边框默认值设为NONE,不然像scalelayout这种只用默认边框的会不显示边框
protected void initBorderStyle() {
protected void initBorderAndBackgroundStyle() {
BorderPacker style = toData().getBorderStyle();
if (style != null && style.getBorder() != Constants.LINE_NONE) {
this.setBorder(new UIRoundedBorder(style.getBorder(), style.getColor(), style.getBorderRadius()));
LineBorder DEFAULT_LINE_BORDER = (LineBorder) DEFALUTBORDER;
// 边框默认值设为NONE,不然像scalelayout这种只用默认边框的会不显示边框
Border border = DEFAULT_LINE_BORDER;
if (style != null) {
int radius = style.getBorderRadius(); // 不管有无边框线, 圆角裁剪总是生效
if (style.getBorder() != Constants.LINE_NONE) {
// 设置了边框线
border = new UIRoundedBorder(style.getBorder(), style.getColor(), radius);
} else {
this.setBorder(DEFALUTBORDER);
// 为设置边框线
border = new UIRoundedBorder(DEFAULT_LINE_BORDER.getLineColor(), DEFAULT_LINE_BORDER.getThickness(), radius);
}
}
this.setBorder(border);
this.setBackground4Painting(style != null ? style.getBackground() : null);
}
private void clearTitleWidget() {
@ -143,6 +173,75 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
return new WidgetValue(value);
}
// 如果存在标题栏,则需要重新弄调整边框和背景的显示效果,使得边框和背景的视觉效果出现在包含组件和标题的整体区域上,
// 而不是组件和标题各自出现独立的边框和背景,同时如存在标题栏,则标题栏下方还应有底部边框,作为标题和内容的分界线
protected void reshuffleBorderAndBackgroundPaintingEffectIfTitleExists() {
Container parent = this.getParent();
if (parent instanceof XWTitleLayout) {
XWTitleLayout titleParent = (XWTitleLayout) parent;
if (parent.getComponentCount() > 1) {
XCreator titleCreator = titleParent.getTitleCreator();
XCreator bodyXCreator = titleParent.getBodyCreator();
Border border = bodyXCreator.getBorder();
titleParent.setBorder(border); // 容器绘制完整边框
bodyXCreator.setBorder(BorderFactory.createEmptyBorder()); // body不绘制边框
titleCreator.setBorder(BorderFactory.createEmptyBorder()); // title绘制底部边框
if (border instanceof LineBorder) {
Color color = ((LineBorder) border).getLineColor();
int thickness = ((LineBorder) border).getThickness();
titleCreator.setBorder(new BottomLineBorder(color, thickness));
}
if (bodyXCreator instanceof XBorderStyleWidgetCreator) {
XBorderStyleWidgetCreator styledBodyXCreator = (XBorderStyleWidgetCreator) bodyXCreator;
Background background4Painting = styledBodyXCreator.getBackground4Painting();
styledBodyXCreator.setBackground4Painting(null); // body不绘制背景
titleParent.setBackground4Painting(background4Painting); // 容器绘制完整背景
}
}
}
}
// 根据当前组件边框裁剪内容,如果当前组件存在圆角,则应当按圆角裁剪内容
private void clipByRoundedBorder(Graphics2D g2d) {
Border currentBorder = getBorder();
if (currentBorder instanceof UIRoundedBorder) {
int thickness = ((UIRoundedBorder) currentBorder).getThickness();
int radius = ((UIRoundedBorder) currentBorder).getRoundedCorner();
int currentClipX = 0;
int currentClipY = 0;
int currentClipWidth = getWidth();
int currentClipHeight = getHeight();
int currentClipRadius = Math.max(radius - thickness, 0); // 应沿着边框外围进行裁剪
g2d.clip(new RoundRectangle2D.Double(currentClipX, currentClipY, currentClipWidth, currentClipHeight, currentClipRadius, currentClipRadius));
}
}
// 设计器预览界面中绘制组件背景效果
private void paintBackground(Graphics2D g2d) {
Background background4Painting = getBackground4Painting();
if (background4Painting != null) {
background4Painting.paint(g2d, new Rectangle2D.Double(0, 0, getWidth(), getHeight()));
}
}
@Override
protected void paintComponent(Graphics g) {
this.paintBackground((Graphics2D) g);
super.paintComponent(g);
}
@Override
public void paint(Graphics g) {
this.clipByRoundedBorder((Graphics2D) g);
super.paint(g);
paintBorder(g);
}
@Override
protected String getIconName() {
return StringUtils.EMPTY;
@ -169,8 +268,33 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
* data属性改变触发其他操作
*
*/
public void firePropertyChange(){
public void firePropertyChange() {
}
// 适用于标题栏的底部边框
public static class BottomLineBorder extends LineBorder {
private BottomLineBorder(Color color, int thickness) {
super(color, thickness);
}
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
Graphics2D g2d = (Graphics2D)g;
Color oldColor = g2d.getColor();
Stroke oldStroke = g2d.getStroke();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(getLineColor());
g2d.setStroke(new BasicStroke(getThickness()));
g2d.drawLine(0, height, width, height);
g2d.setStroke(oldStroke);
g2d.setColor(oldColor);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
}
}
}

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

@ -165,7 +165,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
@Override
protected void initXCreatorProperties() {
super.initXCreatorProperties();
initBorderStyle();
initBorderAndBackgroundStyle();
BaseChartCollection collection = ((BaseChartEditor) data).getChartCollection();
isRefreshing = true;
((MiddleChartComponent) designerEditor.getEditorTarget()).populate(collection);

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

@ -11,6 +11,7 @@ import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.events.DesignerEditor;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.ui.SelectedPopupDialog;
import com.fr.design.fun.ShareWidgetUIProcessor;
import com.fr.design.fun.WidgetPropertyUIProvider;
import com.fr.design.gui.imenu.UIPopupMenu;
@ -70,7 +71,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
private boolean isHelpBtnOnFocus = false;//焦点是否在帮助按钮上
// 当前组件是否处在选中状态
private boolean selected;
private SelectedBorderIcon selectedBorderIcon = new SelectedBorderIcon();
private SelectedPopupDialog popup;
private static final int SHORTS_SEPARATOR_POS = 4; // 弹出菜单分割的位置
public XCreator(Widget ob, Dimension initSize) {
@ -764,15 +765,20 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
}
/**
* 绘制选中时右上边框图标
* 选中时右侧展示小弹窗
*
* @param g
* @param designer
* @param bounds
*/
public void paintSelectedBorderIcon(Graphics g, Rectangle bounds) {
if (selected) {
selectedBorderIcon.paint(g, bounds);
public void showSelectedPopup(FormDesigner designer, Rectangle bounds, boolean accept) {
if (popup == null) {
popup = new SelectedPopupDialog(this, designer);
}
int extraX = (int) ((bounds.x + bounds.width + SelectedPopupDialog.OFFSET_X) * designer.getScale());
int extraY = (int) (bounds.y * designer.getScale());
popup.setLocation(designer.getLocationOnScreen().x + designer.getPaintX() + extraX, designer.getLocationOnScreen().y + designer.getPaintY() + extraY);
popup.setVisible(selected && accept);
popup.setRelativeBounds(bounds);
}
/**
@ -818,6 +824,9 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
public void setSelected(boolean selected) {
this.selected = selected;
if (popup != null && !selected) {
popup.setVisible(false);
}
}
}

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

@ -1,6 +1,7 @@
package com.fr.design.designer.creator;
import com.fr.base.BaseUtils;
import com.fr.base.Releasable;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.designer.properties.mobile.ElementCasePropertyUI;
import com.fr.design.form.util.XCreatorConstants;
@ -32,7 +33,7 @@ import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor;
import java.util.Set;
public class XElementCase extends XBorderStyleWidgetCreator implements FormElementCaseContainerProvider {
public class XElementCase extends XBorderStyleWidgetCreator implements FormElementCaseContainerProvider , Releasable {
private UILabel imageLable;
private FormDesigner designer;
private static BufferedImage DEFAULT_BACKGROUND;
@ -57,7 +58,7 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
super.initXCreatorProperties();
// 报表块初始化时要加载对应的borderStyle
initBorderStyle();
initBorderAndBackgroundStyle();
}
/**
@ -352,4 +353,9 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
public boolean isSupportShared() {
return true;
}
@Override
public void releaseResources() {
imageLable.setIcon(null);
}
}

2
designer-form/src/main/java/com/fr/design/designer/creator/XLayoutContainer.java

@ -118,7 +118,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
@Override
protected void initXCreatorProperties() {
super.initXCreatorProperties();
initBorderStyle();
initBorderAndBackgroundStyle();
this.initLayoutManager();
this.convert();
}

1
designer-form/src/main/java/com/fr/design/designer/creator/XNameWidget.java

@ -91,7 +91,6 @@ public class XNameWidget extends XWidgetCreator {
if (editor != null) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
add(editor, BorderLayout.CENTER);
this.setVisible(toData().isVisible());
}
}

2
designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java

@ -106,7 +106,7 @@ public class XWAbsoluteBodyLayout extends XWAbsoluteLayout {
@Override
protected void initStyle() {
initBorderStyle();
initBorderAndBackgroundStyle();
}
/**

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

@ -203,6 +203,10 @@ public class XWAbsoluteLayout extends XLayoutContainer {
double percentH = ((double) backupBound.height / (double) currentBound.height);
for (int index = 0, n = this.getComponentCount(); index < n; index++) {
XCreator creator = (XCreator) this.getComponent(index);
if (creator.toData().isAspectRatioLocked()) {
double percent = Math.min(percentW, percentH);
percentW = percentH = percent;
}
BoundsWidget wgt = (BoundsWidget) layout.getBoundsWidget(creator.toData());
// 用当前的显示大小计算后调正具体位置
Rectangle wgtBound = creator.getBounds();

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

@ -10,10 +10,9 @@ import com.fr.design.fun.WidgetPropertyUIProvider;
import com.fr.form.ui.Label;
import com.fr.form.ui.Widget;
import com.fr.form.ui.WidgetTitle;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.form.ui.container.WTitleLayout;
import com.fr.general.ComparatorUtils;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.stable.StringUtils;
import java.awt.*;
import java.awt.event.ContainerEvent;
@ -46,6 +45,17 @@ public class XWTitleLayout extends DedicateLayoutContainer {
super(widget, initSize);
}
@Override
protected void initXCreatorProperties() {
super.initXCreatorProperties();
// 初始化后(如打开旧模版),需要重新调整组件/标题/边框的显示效果
XCreator xCreator = getBodyCreator();
if (xCreator instanceof XBorderStyleWidgetCreator) {
((XBorderStyleWidgetCreator) xCreator).reshuffleBorderAndBackgroundPaintingEffectIfTitleExists();
}
}
/**
* 初始化容器对应的布局 由于是只装一个需要保持原样高度的控件布局设为absolute
*/

2
designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardLayout.java

@ -400,7 +400,7 @@ public class XWCardLayout extends XLayoutContainer {
protected void initStyle() {
BorderPacker style = toData().getBorderStyle();
initBorderTitleStyle(style);
initBorderStyle();
initBorderAndBackgroundStyle();
clearOrShowTitleLayout(ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE));
}

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

@ -0,0 +1,191 @@
package com.fr.design.designer.ui;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.CoverReportPane;
import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner;
import com.fr.general.IOUtils;
import com.fr.stable.ArrayUtils;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.AbstractButton;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToggleButton;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/7/8
*/
public class PopupControlPanel extends JPanel {
private static final int ARC_VALUE = 4;
private static final Color FILLED_COLOR = new Color(60, 63, 65);
private static final int V_GAP = 10;
private static final int H_GAP = 2;
private Dimension defaultDimension = new Dimension(20, 60);
private Rectangle rectangle;
private final JButton editButton;
private final JButton settingButton;
private final JToggleButton toggleButton;
private final XCreator creator;
private final UILabel firstLabel;
private final UILabel secondLabel;
public PopupControlPanel(XCreator creator, FormDesigner designer) {
if (creator.isShared()) {
defaultDimension = new Dimension(20, 85);
}
setLayout(getCustomLayout());
this.creator = creator;
editButton = createNormalButton(IOUtils.readIcon("/com/fr/design/images/control/show_edit.png"), Toolkit.i18nText("Fine-Design_Form_Edit_Widget"));
editButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
int x = rectangle.x + rectangle.width / 2;
int y = rectangle.y + rectangle.height / 2;
XCreator childCreator = PopupControlPanel.this.creator.getEditingChildCreator();
MouseListener[] listeners = designer.getMouseListeners();
if (ArrayUtils.isNotEmpty(listeners) && listeners[0] instanceof EditingMouseListener) {
childCreator.respondClick(((EditingMouseListener) listeners[0]), new MouseEvent(childCreator, MouseEvent.MOUSE_CLICKED, e.getWhen(), e.getModifiers(), x, y, 2, false));
}
}
});
settingButton = createNormalButton(IOUtils.readIcon("/com/fr/design/images/control/show_setting.png"), Toolkit.i18nText("Fine-Design_Share_Help_Settings"));
settingButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
CoverReportPane.showShareConfig(creator.toData());
}
});
toggleButton = new JToggleButton(IOUtils.readIcon("/com/fr/design/images/control/edit_lock.png"));
initButtonStyle(toggleButton);
toggleButton.setSelectedIcon(IOUtils.readIcon("com/fr/design/images/control/edit_unlock.png"));
toggleButton.setToolTipText(Toolkit.i18nText("Fine-Design_Form_Lock_Widget_Ratio"));
toggleButton.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
JToggleButton toggleBtn = (JToggleButton) e.getSource();
String toolTipText = toggleBtn.isSelected() ? Toolkit.i18nText("Fine-Design_Form_UnLock_Widget_Ratio") : Toolkit.i18nText("Fine-Design_Form_Lock_Widget_Ratio");
toggleBtn.setToolTipText(toolTipText);
}
});
firstLabel = createLabel();
secondLabel = createLabel();
add(editButton);
add(toggleButton);
add(settingButton);
add(firstLabel);
add(secondLabel);
}
protected LayoutManager getCustomLayout() {
return new LayoutManager() {
@Override
public void removeLayoutComponent(Component comp) {
}
@Override
public Dimension preferredLayoutSize(Container parent) {
return defaultDimension;
}
@Override
public Dimension minimumLayoutSize(Container parent) {
return null;
}
@Override
public void layoutContainer(Container parent) {
int width = parent.getPreferredSize().width;
int buttonWidth = editButton.getPreferredSize().width;
int buttonHeight = editButton.getPreferredSize().height;
int x = (width - buttonWidth) / 2;
editButton.setBounds(x, V_GAP, buttonWidth, buttonHeight);
firstLabel.setBounds(x, V_GAP + editButton.getHeight() + V_GAP / 2, buttonWidth, buttonHeight);
toggleButton.setBounds(x, V_GAP * 2 + editButton.getHeight(), buttonWidth, buttonHeight);
if (creator.isShared()) {
secondLabel.setBounds(x, V_GAP * 2 + editButton.getHeight() + toggleButton.getHeight() + V_GAP / 2, buttonWidth, buttonHeight);
settingButton.setBounds(x, V_GAP * 3 + editButton.getHeight() + toggleButton.getHeight(), buttonWidth, buttonHeight);
}
}
@Override
public void addLayoutComponent(String name, Component comp) {
}
};
}
private JButton createNormalButton(Icon icon, String toolTipText) {
JButton button = new JButton(icon);
initButtonStyle(button);
button.setToolTipText(toolTipText);
return button;
}
private void initButtonStyle(AbstractButton button) {
button.setBorderPainted(false);
button.setBorder(null);
button.setMargin(new Insets(0, 0, 0, 0));
button.setContentAreaFilled(false);
}
private UILabel createLabel() {
return new UILabel() {
@Override
public void paint(Graphics g) {
super.paint(g);
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(Color.WHITE);
g2d.drawLine(H_GAP, 0, toggleButton.getWidth() - H_GAP, 0);
}
};
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
int w = this.getWidth();
int h = this.getHeight();
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(FILLED_COLOR);
g2d.fillRoundRect(0, 0, w - 1, h - 1, ARC_VALUE, ARC_VALUE);
g2d.setColor(Color.WHITE);
g2d.drawRoundRect(0, 0, w - 1, h - 1, ARC_VALUE, ARC_VALUE);
}
public Dimension getDefaultDimension() {
return defaultDimension;
}
public void setRelativeBounds(Rectangle rectangle) {
this.rectangle = rectangle;
}
}

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

@ -0,0 +1,36 @@
package com.fr.design.designer.ui;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.FormDesigner;
import java.awt.Rectangle;
import javax.swing.JDialog;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/7/09
*/
public class SelectedPopupDialog extends JDialog {
/**
* 弹窗的相对组件的偏移
*/
public static final int OFFSET_X = 5;
private final PopupControlPanel controlPanel;
public SelectedPopupDialog(XCreator creator, FormDesigner designer) {
super(DesignerContext.getDesignerFrame());
this.setUndecorated(true);
this.setModal(false);
controlPanel = new PopupControlPanel(creator, designer);
this.getContentPane().add(controlPanel);
this.setSize(controlPanel.getDefaultDimension());
}
public void setRelativeBounds(Rectangle rectangle) {
this.controlPanel.setRelativeBounds(rectangle);
}
}

9
designer-form/src/main/java/com/fr/design/gui/controlpane/EventPropertyPane.java

@ -2,7 +2,6 @@ package com.fr.design.gui.controlpane;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.properties.EventPropertyTable;
import com.fr.design.file.Releasable;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.widget.EventCreator;
@ -14,7 +13,7 @@ import com.fr.stable.Nameable;
/**
* Created by kerry on 5/17/21
*/
public class EventPropertyPane extends UIListGroupControlPane implements Releasable {
public class EventPropertyPane extends UIListGroupControlPane {
private XCreator creator;
private FormDesigner designer;
@ -25,12 +24,6 @@ public class EventPropertyPane extends UIListGroupControlPane implements Releasa
this.designer = designer;
}
@Override
public void releaseResources() {
creator = null;
designer = null;
this.removeAll();
}
/**
* 刷新

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

@ -20,19 +20,22 @@ import com.fr.design.gui.ibutton.UIButtonUI;
import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.icombobox.LineComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itooltip.UIToolTip;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.backgroundpane.ImagePreviewPane;
import com.fr.design.style.background.image.ImageFileChooser;
import com.fr.env.utils.DesignerInteractionHistory;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.general.Background;
import com.fr.general.IOUtils;
import com.fr.stable.Constants;
import com.fr.stable.GraphDrawHelper;
import com.fr.stable.ProjectLibrary;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
@ -46,6 +49,7 @@ import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.geom.RoundRectangle2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
@ -58,7 +62,7 @@ import java.net.URISyntaxException;
* 可配置图片类型边框的样式设置面板
*/
public class BorderLineAndImagePane extends JPanel implements UIObserver {
private final int SETTING_LABEL_WIDTH = 60;
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 String TWEAK_NINE_POINT_HELP_URL = "";
@ -174,6 +178,20 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
}
}
private void initImageFileChooserDirectory() {
DesignerInteractionHistory history = DesignerInteractionHistory.getInstance();
String lastUsedBorderImageDirPath = history.getLastSelectedBorderImageDir();
File lastUsedBorderImageDir = StringUtils.isNotEmpty(lastUsedBorderImageDirPath) ? new File(lastUsedBorderImageDirPath) : null;
File inbuiltBorderImagesDir = new File(StableUtils.pathJoin(ProjectLibrary.getInstance().getLibHome(), ProjectConstants.ASSETS_NAME, "border_images"));
if (lastUsedBorderImageDir!= null && lastUsedBorderImageDir.exists()) {
imageFileChooser.setCurrentDirectory(lastUsedBorderImageDir);
} else if (inbuiltBorderImagesDir.exists()) {
imageFileChooser.setCurrentDirectory(inbuiltBorderImagesDir);
}
}
protected void initNinePointTweakPaneIfNotExist() {
if (tweakPane == null) {
tweakPane = new NinePointImageTweakDialogPane();
@ -210,8 +228,15 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
@Override
public void actionPerformed(ActionEvent e) {
initImageFileChooserIfNotExist();
initImageFileChooserDirectory();
int returnVal = imageFileChooser.showOpenDialog(DesignerContext.getDesignerFrame());
if (returnVal == JFileChooser.APPROVE_OPTION) {
DesignerInteractionHistory history = DesignerInteractionHistory.getInstance();
File selectedDirectory = imageFileChooser.getSelectedFile().getParentFile();
history.setLastSelectedBorderImageDir(selectedDirectory.getPath());
}
ImgChooseWrapper.getInstance(imagePreviewPane, imageFileChooser, DEFAULT_IMAGE_LAYOUT_STYLE, new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {

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

@ -24,6 +24,7 @@ import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.backgroundpane.GradientBackgroundQuickPane;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.WidgetTitle;
import com.fr.general.Background;
@ -51,7 +52,7 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Shadow")
};
private static final Dimension BUTTON_SIZE = new Dimension(20, 20);
private static final int SETTING_LABEL_WIDTH = 60;
public static final int SETTING_LABEL_WIDTH = 60;
protected LayoutBorderStyle style = new LayoutBorderStyle();
@ -124,7 +125,7 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
borderStyleCombo = new UIComboBox(BORDER_STYLE);
borderLineAndImagePane = new BorderLineAndImagePane();
cornerSpinner = new UISpinner(0,1000,1,0);
backgroundPane = new BackgroundSpecialPane();
backgroundPane = new LayoutBackgroundSpecialPane();
backgroundOpacityPane = new UIPercentDragPane();
}
@ -229,7 +230,7 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Right")
});
titleBackgroundPane = new BackgroundSpecialPane();
titleBackgroundPane = new LayoutBackgroundSpecialPane();
titleBackgroundOpacityPane = new UIPercentDragPane();
}
@ -499,4 +500,11 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
g2d.setColor(oldColor);
}
}
protected static class LayoutBackgroundSpecialPane extends BackgroundSpecialPane {
@Override
protected GradientBackgroundQuickPane createGradientBackgroundQuickPane() {
return new GradientBackgroundQuickPane(140);
}
}
}

71
designer-form/src/main/java/com/fr/design/gui/xpane/TitleInsetImagePane.java

@ -33,6 +33,10 @@ import javax.swing.plaf.basic.BasicButtonUI;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.geom.RoundRectangle2D;
/**
* @author Starryi
@ -40,7 +44,7 @@ import java.awt.event.ActionListener;
* Created by Starryi on 2021/7/3
*/
public class TitleInsetImagePane extends JPanel implements UIObserver {
private final int SETTING_LABEL_WIDTH = 60;
private final int SETTING_LABEL_WIDTH = LayoutStylePane.SETTING_LABEL_WIDTH;
private final int DELETE_BUTTON_SIZE = 24;
private final int IMAGE_PREVIEW_SIZE = 145;
private final Style DEFAULT_IMAGE_LAYOUT_STYLE = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_DEFAULT);
@ -89,6 +93,28 @@ public class TitleInsetImagePane extends JPanel implements UIObserver {
deletableImagePreviewPane.add(imageDeleteButton, 0);
deletableImagePreviewPane.add(imagePreviewPane, 1);
imageDeleteButton.setVisible(false);
imageDeleteButton.setEnabled(false);
deletableImagePreviewPane.addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
super.mouseEntered(e);
imageDeleteButton.setVisible(true);
imageDeleteButton.setEnabled(true);
}
@Override
public void mouseExited(MouseEvent e) {
super.mouseExited(e);
int x = e.getX();
int y = e.getY();
if (x <= 0 || getWidth() <= x || y <= 0 || y >= getHeight()) {
imageDeleteButton.setVisible(false);
imageDeleteButton.setEnabled(false);
}
}
});
return TableLayoutHelper.createCommonTableLayoutPane(
new JComponent[][]{
{null, deletableImagePreviewPane},
@ -110,15 +136,11 @@ public class TitleInsetImagePane extends JPanel implements UIObserver {
private void initComponents() {
imageChooseButton = new UIButton(IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_choose_inset.png"));
imageDeleteButton = new UIButton(IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_delete_inset.png"));
imageDeleteButton.setUI(new BasicButtonUI());
imageDeleteButton.setOpaque(true);
imageDeleteButton.setBorderPainted(false);
imageDeleteButton.setBorder(null);
imageDeleteButton.setFocusPainted(false);
imageDeleteButton.setContentAreaFilled(true);
imageDeleteButton = new OpaqueColorButton(
IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_delete_inset.png"),
new Color(51, 51, 52, 178),
2);
imageDeleteButton.setPreferredSize(new Dimension(DELETE_BUTTON_SIZE, DELETE_BUTTON_SIZE));
imageDeleteButton.setBackground(new Color(51, 51, 51));
imagePreviewPane = new ImagePreviewPane();
imagePreviewPane.setImageStyle(DEFAULT_IMAGE_LAYOUT_STYLE);
@ -255,4 +277,35 @@ public class TitleInsetImagePane extends JPanel implements UIObserver {
public boolean shouldResponseChangeListener() {
return true;
}
private static class OpaqueColorButton extends UIButton {
private final Color color;
private final int radius;
public OpaqueColorButton(Icon icon, Color color, int radius) {
super(icon);
setUI(new BasicButtonUI());
setOpaque(true);
setBorderPainted(false);
setBorder(null);
setFocusPainted(false);
setContentAreaFilled(false);
this.color = color;
this.radius = radius;
}
@Override
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
Color oldColor = g2d.getColor();
Shape shape = new RoundRectangle2D.Double(0, 0, getWidth(), getHeight(), radius, radius);
g2d.clip(shape);
g2d.setColor(color);
g2d.fillRect(0, 0, getWidth(), getHeight());
g2d.setColor(oldColor);
super.paint(g);
}
}
}

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

@ -13,6 +13,7 @@ import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.creator.XWTitleLayout;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.roleAuthority.ReportAndFSManagePane;
import com.fr.design.utils.ComponentUtils;
@ -325,9 +326,7 @@ public class FormDesignerUI extends ComponentUI {
}
creator.paintBorder(g, creatorBounds);
// 拖拽时不绘制
if (!designer.getStateModel().isDragging()) {
creator.paintSelectedBorderIcon(g, creatorBounds);
}
creator.showSelectedPopup(designer, creatorBounds, !designer.getStateModel().isDragging() && creator.acceptType(XWTitleLayout.class));
}
}

12
designer-form/src/main/java/com/fr/design/mainframe/FormParaWidgetPane.java

@ -7,7 +7,6 @@ import com.fr.design.constants.UIConstants;
import com.fr.design.designer.beans.events.DesignerEditListener;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.file.Releasable;
import com.fr.design.fun.FormWidgetOptionProvider;
import com.fr.design.gui.core.FormWidgetOption;
import com.fr.design.gui.core.UserDefinedWidgetOption;
@ -57,7 +56,7 @@ import java.awt.event.MouseEvent;
/**
* @author null
*/
public class FormParaWidgetPane extends JPanel implements Releasable {
public class FormParaWidgetPane extends JPanel {
private static FormParaWidgetPane THIS;
private final static int BORDER = 5;
private final static int WIDGET_WIDTHGAP = 4;
@ -120,15 +119,6 @@ public class FormParaWidgetPane extends JPanel implements Releasable {
return THIS;
}
public static FormParaWidgetPane getInstance(){
return THIS;
}
@Override
public void releaseResources() {
designer = null;
}
public FormParaWidgetPane() {
setLayout(new FlowLayout(FlowLayout.LEFT));
DesignerContext.getDesignerFrame().getCenterTemplateCardPane().addComponentListener(new ComponentAdapter() {

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

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

8
designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java

@ -2,7 +2,6 @@ package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.design.dialog.BasicPane;
import com.fr.design.file.Releasable;
import com.fr.design.gui.ibutton.UIHeadGroup;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
@ -31,7 +30,7 @@ import java.util.List;
* Date: 14-7-8
* Time: 下午8:18
*/
public class FormWidgetDetailPane extends FormDockView implements Releasable {
public class FormWidgetDetailPane extends FormDockView{
private static final int ONLINE_TAB = 1;
private JPanel centerPane;
@ -62,11 +61,6 @@ public class FormWidgetDetailPane extends FormDockView implements Releasable {
private static FormWidgetDetailPane singleton = new FormWidgetDetailPane();
}
@Override
public void releaseResources() {
setEditingFormDesigner(null);
}
public String getViewTitle() {
return Toolkit.i18nText("Fine-Design_Form_Widget_Tree_And_Table");
}

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

@ -3,6 +3,7 @@ package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.base.PaperSize;
import com.fr.base.Parameter;
import com.fr.base.Releasable;
import com.fr.base.extension.FileExtension;
import com.fr.base.iofile.attr.ExtendSharableAttrMark;
import com.fr.base.vcs.DesignerMode;
@ -26,6 +27,7 @@ import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XComponent;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XElementCase;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWAbsoluteBodyLayout;
import com.fr.design.designer.creator.XWParameterLayout;
@ -72,6 +74,7 @@ import com.fr.form.share.SharableWidgetProvider;
import com.fr.form.share.editor.SharableEditorProvider;
import com.fr.form.share.utils.ShareUtils;
import com.fr.form.ui.AbstractBorderStyleWidget;
import com.fr.form.ui.ElementCaseEditor;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WBorderLayout;
import com.fr.form.ui.container.WLayout;
@ -110,14 +113,13 @@ import java.util.Iterator;
import java.util.List;
import javax.swing.tree.TreePath;
public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<Form> {
public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<Form>, Releasable {
private static final String FORM_CARD = "FORM";
private static final String ELEMENTCASE_CARD = "ELEMENTCASE";
private static final String[] CARDNAME = new String[]{FORM_CARD, ELEMENTCASE_CARD};
private static final int TOOLBARPANEDIMHEIGHT_FORM = 60;
//当前使用的表单设计器
private static FormDesigner currentFormDesign;
//表单设计器
private FormDesigner formDesign;
//格子设计器
@ -859,7 +861,6 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
EastRegionContainerPane.getInstance().addParameterPane(parameterPropertyPane);
refreshWidgetLibPane();
currentFormDesign = formDesign;
}
private void refreshWidgetLibPane() {
@ -1096,18 +1097,41 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
}
}
public static void traversalXCreator(XCreator xCreator, XCreateGather xCreateGather, Class clz) {
xCreator.getComponentCount();
for (int i = 0; i < xCreator.getComponentCount(); i++) {
Component component = xCreator.getComponent(i);
if (component instanceof XCreator) {
if (clz == null || clz.isInstance(component)) {
xCreateGather.dealWith((XCreator) component);
}
traversalXCreator((XCreator) component, xCreateGather, clz);
}
}
}
@Override
public void whenClose() {
super.whenClose();
releaseResources();
this.releaseResources();
}
private void releaseResources() {
if (ComparatorUtils.equals(currentFormDesign, formDesign)) {
FormParaWidgetPane.getInstance().releaseResources();
FormWidgetDetailPane.getInstance().releaseResources();
WidgetPropertyPane.getInstance().releaseResources();
currentFormDesign = null;
@Override
public void releaseResources() {
if (formDesign != null) {
Form.traversalWidget(formDesign.getTarget().getContainer(), new WidgetGatherAdapter() {
@Override
public void dealWith(Widget widget) {
((ElementCaseEditor) widget).releaseResources();
}
}, ElementCaseEditor.class);
JForm.traversalXCreator(formDesign.getRootComponent(), new XCreateGather() {
@Override
public void dealWith(XCreator xCreator) {
((XElementCase) xCreator).releaseResources();
}
}, XElementCase.class);
}
}
}

28
designer-form/src/main/java/com/fr/design/mainframe/WidgetPropertyPane.java

@ -9,7 +9,6 @@ import com.fr.design.designer.creator.*;
import com.fr.design.designer.creator.cardlayout.XWCardTagLayout;
import com.fr.design.designer.properties.mobile.MobileBookMarkPropertyUI;
import com.fr.design.designer.properties.mobile.MobileStylePropertyUI;
import com.fr.design.file.Releasable;
import com.fr.design.form.util.FormDesignerUtils;
import com.fr.design.fun.WidgetPropertyUIProvider;
import com.fr.design.gui.controlpane.EventPropertyPane;
@ -33,7 +32,7 @@ import java.util.Set;
* 控件属性表绘制
* Modified by fanglei
*/
public class WidgetPropertyPane extends FormDockView implements BaseWidgetPropertyPane, Releasable {
public class WidgetPropertyPane extends FormDockView implements BaseWidgetPropertyPane {
private static final int PADDING = 10;
private static final int PADDING_M = 12;
@ -69,31 +68,6 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper
setLayout(FRGUIPaneFactory.createBorderLayout());
}
@Override
public void releaseResources() {
setEditingFormDesigner(null);
if (eventTable != null) {
eventTable.releaseResources();
}
if (formWidgetCardPane != null) {
formWidgetCardPane.releaseResources();
}
if (wsp != null) {
wsp.removeAll();
}
designer.getSelectionModel().reset();
formWidgetCardPane = null;
eventTable = null;
widgetPropertyTables = null;
mobileExtraPropertyPanes = null;
designer = null;
psp = null;
wsp = null;
tabsHeaderIconPane = null;
lastAffectedCreator = null;
this.removeAll();
}
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Control_Setting");

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

@ -0,0 +1,7 @@
package com.fr.design.mainframe;
import com.fr.design.designer.creator.XCreator;
public interface XCreateGather {
void dealWith(XCreator xCreator);
}

15
designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java

@ -14,7 +14,6 @@ import com.fr.design.designer.creator.XWTitleLayout;
import com.fr.design.designer.creator.cardlayout.XWCardTagLayout;
import com.fr.design.dialog.AttrScrollPane;
import com.fr.design.dialog.BasicScrollPane;
import com.fr.design.file.Releasable;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
@ -50,7 +49,7 @@ import java.awt.BorderLayout;
/**
* Created by ibm on 2017/7/25.
*/
public class FormWidgetCardPane extends AbstractAttrNoScrollPane implements Releasable {
public class FormWidgetCardPane extends AbstractAttrNoScrollPane {
private AttributeChangeListener listener;
private FormDesigner designer;
//当前的编辑器属性定义面板
@ -283,16 +282,4 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane implements Rele
public void firePropertyEdit() {
designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_EDITED);
}
@Override
public void releaseResources() {
listener = null;
designer = null;
currentEditorDefinePane = null;
widgetPropertyPane = null;
attriCardPane = null;
xCreator = null;
widgetBoundPane = null;
this.removeAll();
}
}

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

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

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

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

4
designer-realize/src/main/java/com/fr/start/MainDesigner.java

@ -42,6 +42,7 @@ import com.fr.design.monitor.DesignerLifecycleMonitorContext;
import com.fr.design.share.SharableManager;
import com.fr.design.utils.concurrent.ThreadFactoryBuilder;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.env.utils.DesignerInteractionHistory;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
@ -512,6 +513,9 @@ public class MainDesigner extends BaseDesigner {
InformationCollector collector = InformationCollector.getInstance();
collector.collectStopTime();
collector.saveXMLFile();
DesignerInteractionHistory historyCollector = DesignerInteractionHistory.getInstance();
historyCollector.saveXMLFile();
}
}

Loading…
Cancel
Save