Browse Source

Pull request #4893: REPORT-54392 释放最近打开表单对象内存实现方式变更

Merge in DESIGN/design from ~HENRY.WANG/design:feature/10.0 to feature/10.0

* commit 'f788999a9ce31db7187999f81d88eefa145eb5a6':
  REPORT-54392 释放最近打开表单对象内存实现方式变更
feature/10.0
Henry.Wang 3 years ago
parent
commit
ed165ef4b9
  1. 5
      designer-base/src/main/java/com/fr/design/file/Releasable.java
  2. 8
      designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java
  3. 9
      designer-form/src/main/java/com/fr/design/gui/controlpane/EventPropertyPane.java
  4. 12
      designer-form/src/main/java/com/fr/design/mainframe/FormParaWidgetPane.java
  5. 8
      designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java
  6. 46
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  7. 28
      designer-form/src/main/java/com/fr/design/mainframe/WidgetPropertyPane.java
  8. 7
      designer-form/src/main/java/com/fr/design/mainframe/XCreateGather.java
  9. 15
      designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.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();
}

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

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

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

Loading…
Cancel
Save