Browse Source

Merge pull request #4924 in DESIGN/design from release/11.0 to feature/x

* commit 'bf86ef5bb21305c468b48003ad61c0f2056d64df':
  CHART-19488 日期轴的日期控件构建成字符串公式
  REPORT-54122 设计器组件选中状态右侧弹窗改进 去掉无用输出
  REPORT-54122 fix 无用import
  REPORT-54122 设计器组件选中状态右侧弹窗改进
  REPORT-53175【10.0.18】组件背景分离为标题/背景/边框
  REPORT-55090【组件背景分离】组件复用-标题图案的图片预览图,和交互文档里定的悬浮时出现删除按钮和不透明遮罩预期效果不同
  REPORT-55071 【组件背景分离】组件复用-标题填充选择渐变色时,设置面板出现纵向滚动条,遮挡住了渐变色右侧颜色选择按钮
  REPORT-55089 组件背景分离】组件复用-现在锁按钮在宽高值之间,锁定时,拖拽调整组件大小时,宽度值会变化成一个很长的小数
  CHART-19824 图表切换面板交互修改
  REPORT-53175【10.0.18】组件背景分离为标题/背景/边框
  REPORT-54392 释放最近打开表单对象内存实现方式变更
  REPORT-53949 UISpinner获取焦点后才可以滚动调整值
research/11.0
superman 3 years ago
parent
commit
345ed31301
  1. 5
      designer-base/src/main/java/com/fr/design/file/Releasable.java
  2. 9
      designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java
  3. 7
      designer-base/src/main/java/com/fr/design/gui/style/BackgroundSpecialPane.java
  4. 148
      designer-base/src/main/java/com/fr/env/utils/DesignerInteractionHistory.java
  5. BIN
      designer-base/src/main/resources/com/fr/design/images/control/edit_lock.png
  6. BIN
      designer-base/src/main/resources/com/fr/design/images/control/edit_unlock.png
  7. 16
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java
  8. 9
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartTimeAxisPane.java
  9. 25
      designer-form/src/main/java/com/fr/design/designer/beans/location/AccessDirection.java
  10. 47
      designer-form/src/main/java/com/fr/design/designer/creator/SelectedBorderIcon.java
  11. 21
      designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java
  12. 8
      designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java
  13. 4
      designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java
  14. 191
      designer-form/src/main/java/com/fr/design/designer/ui/PopupControlPanel.java
  15. 36
      designer-form/src/main/java/com/fr/design/designer/ui/SelectedPopupDialog.java
  16. 9
      designer-form/src/main/java/com/fr/design/gui/controlpane/EventPropertyPane.java
  17. 18
      designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java
  18. 14
      designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java
  19. 71
      designer-form/src/main/java/com/fr/design/gui/xpane/TitleInsetImagePane.java
  20. 5
      designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java
  21. 12
      designer-form/src/main/java/com/fr/design/mainframe/FormParaWidgetPane.java
  22. 8
      designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java
  23. 46
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  24. 28
      designer-form/src/main/java/com/fr/design/mainframe/WidgetPropertyPane.java
  25. 7
      designer-form/src/main/java/com/fr/design/mainframe/XCreateGather.java
  26. 15
      designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java
  27. 4
      designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java
  28. 4
      designer-realize/src/main/java/com/fr/start/MainDesigner.java

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();
}

9
designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java

@ -58,6 +58,7 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver
* Spinner内的数字文本框长度
*/
private int numberFieldColumns;
private boolean hasTextFieldFocus = false;
public UISpinner() {
@ -318,7 +319,7 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
if (isEnabled() && e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
if (hasTextFieldFocus && isEnabled() && e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
setValue(value - e.getWheelRotation());
}
}
@ -330,8 +331,14 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver
textField.getDocument().removeDocumentListener(docListener);
textField.getDocument().addDocumentListener(docListener);
textField.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
hasTextFieldFocus = true;
}
@Override
public void focusLost(FocusEvent e) {
hasTextFieldFocus = false;
textField.getDocument().removeDocumentListener(docListener);
textField.setValue(value);
textField.getDocument().addDocumentListener(docListener);

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();
}
}

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;
}

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) {

25
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.*;
@ -196,12 +198,21 @@ public abstract class AccessDirection implements Direction {
// 设置当前形状
formEditor.setCursor(Cursor.getPredefinedCursor(type));
// 显示/改变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);
ServerPreferenceConfig config = ServerPreferenceConfig.getInstance();
if (canLockAspectRatioOnlyByShift && !config.isHasShownLockedAspectRatioResizingToolTip()) {
DesignerInteractionHistory history = DesignerInteractionHistory.getInstance();
if (canLockAspectRatioOnlyByShift && !history.isHasShownShiftDragResizingTooltip()) {
formEditor.setToolTipText(getTooltip());
config.setHasShownLockedAspectRatioResizingToolTip(true);
history.setHasShownShiftDragResizingTooltip(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);
}
}

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);
}
}
}

8
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;
@ -352,4 +353,9 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
public boolean isSupportShared() {
return true;
}
@Override
public void releaseResources() {
imageLable.setIcon(null);
}
}

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();

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();
}
/**
* 刷新

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

@ -5,7 +5,6 @@ import com.fr.base.Style;
import com.fr.base.Utils;
import com.fr.base.background.ImageBackground;
import com.fr.base.background.ImageFileBackground;
import com.fr.config.ServerPreferenceConfig;
import com.fr.design.border.UIRoundedBorder;
import com.fr.design.constants.UIConstants;
import com.fr.design.designer.IntervalConstants;
@ -27,6 +26,7 @@ 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;
@ -62,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 = "";
@ -179,14 +179,14 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
}
private void initImageFileChooserDirectory() {
ServerPreferenceConfig config = ServerPreferenceConfig.getInstance();
String lastUsedBorderImagesDirPath = config.getLastUsedBorderImagesDir();
File lastUsedBorderImagesDir = StringUtils.isNotEmpty(lastUsedBorderImagesDirPath) ? new File(lastUsedBorderImagesDirPath) : null;
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 (lastUsedBorderImagesDir!= null && lastUsedBorderImagesDir.exists()) {
imageFileChooser.setCurrentDirectory(lastUsedBorderImagesDir);
if (lastUsedBorderImageDir!= null && lastUsedBorderImageDir.exists()) {
imageFileChooser.setCurrentDirectory(lastUsedBorderImageDir);
} else if (inbuiltBorderImagesDir.exists()) {
imageFileChooser.setCurrentDirectory(inbuiltBorderImagesDir);
}
@ -232,9 +232,9 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
int returnVal = imageFileChooser.showOpenDialog(DesignerContext.getDesignerFrame());
if (returnVal == JFileChooser.APPROVE_OPTION) {
ServerPreferenceConfig config = ServerPreferenceConfig.getInstance();
DesignerInteractionHistory history = DesignerInteractionHistory.getInstance();
File selectedDirectory = imageFileChooser.getSelectedFile().getParentFile();
config.setLastUsedBorderImagesDir(selectedDirectory.getPath());
history.setLastSelectedBorderImageDir(selectedDirectory.getPath());
}
ImgChooseWrapper.getInstance(imagePreviewPane, imageFileChooser, DEFAULT_IMAGE_LAYOUT_STYLE, new ChangeListener() {

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() {

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();
}
}

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

@ -104,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) {

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

@ -43,6 +43,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;
@ -514,6 +515,9 @@ public class MainDesigner extends BaseDesigner {
InformationCollector collector = InformationCollector.getInstance();
collector.collectStopTime();
collector.saveXMLFile();
DesignerInteractionHistory historyCollector = DesignerInteractionHistory.getInstance();
historyCollector.saveXMLFile();
}
}

Loading…
Cancel
Save