Browse Source

Pull request #4653: KERNEL-8038 设计器存在一些静态方法导致最近关闭的模板对象不释放内存

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

* commit 'd240aba665366092c3872e986ef409b81c755da0':
  KERNEL-8038 设计器存在一些静态方法导致最近关闭的模板对象不释放内存
  KERNEL-8038 设计器存在一些静态方法导致最近关闭的模板对象不释放内存
  KERNEL-8038 设计器存在一些静态方法导致最近关闭的模板对象不释放内存
  KERNEL-8038 设计器存在一些静态方法导致最近关闭的模板对象不释放内存
  KERNEL-8038 设计器存在一些静态方法导致最近关闭的模板对象不释放内存
feature/10.0
Henry.Wang 3 years ago
parent
commit
c9569afa24
  1. 5
      designer-base/src/main/java/com/fr/design/file/Releasable.java
  2. 12
      designer-form/src/main/java/com/fr/design/gui/controlpane/EventPropertyPane.java
  3. 12
      designer-form/src/main/java/com/fr/design/mainframe/FormParaWidgetPane.java
  4. 8
      designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java
  5. 19
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  6. 28
      designer-form/src/main/java/com/fr/design/mainframe/WidgetPropertyPane.java
  7. 16
      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

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

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

@ -2,6 +2,7 @@ package com.fr.design.gui.controlpane;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.properties.EventPropertyTable; import com.fr.design.designer.properties.EventPropertyTable;
import com.fr.design.file.Releasable;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.widget.EventCreator; import com.fr.design.widget.EventCreator;
@ -13,7 +14,7 @@ import com.fr.stable.Nameable;
/** /**
* Created by kerry on 5/17/21 * Created by kerry on 5/17/21
*/ */
public class EventPropertyPane extends UIListGroupControlPane { public class EventPropertyPane extends UIListGroupControlPane implements Releasable {
private XCreator creator; private XCreator creator;
private FormDesigner designer; private FormDesigner designer;
@ -24,6 +25,12 @@ public class EventPropertyPane extends UIListGroupControlPane {
this.designer = designer; this.designer = designer;
} }
@Override
public void releaseResources() {
creator = null;
designer = null;
this.removeAll();
}
/** /**
* 刷新 * 刷新
@ -44,7 +51,6 @@ public class EventPropertyPane extends UIListGroupControlPane {
} }
public void populateNameObjects() { public void populateNameObjects() {
Widget widget = creator.toData(); Widget widget = creator.toData();
populateNameObjects(widget); populateNameObjects(widget);
@ -93,7 +99,7 @@ public class EventPropertyPane extends UIListGroupControlPane {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Add_Event"); return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Add_Event");
} }
protected String getWrapperLabelText(){ protected String getWrapperLabelText() {
return Toolkit.i18nText("Fine-Design_Report_Event"); return Toolkit.i18nText("Fine-Design_Report_Event");
} }

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

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

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

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

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

@ -116,7 +116,8 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
private static final String[] CARDNAME = new String[]{FORM_CARD, ELEMENTCASE_CARD}; private static final String[] CARDNAME = new String[]{FORM_CARD, ELEMENTCASE_CARD};
private static final int TOOLBARPANEDIMHEIGHT_FORM = 60; private static final int TOOLBARPANEDIMHEIGHT_FORM = 60;
//当前使用的表单设计器
private static FormDesigner currentFormDesign;
//表单设计器 //表单设计器
private FormDesigner formDesign; private FormDesigner formDesign;
//格子设计器 //格子设计器
@ -858,6 +859,7 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
EastRegionContainerPane.getInstance().addParameterPane(parameterPropertyPane); EastRegionContainerPane.getInstance().addParameterPane(parameterPropertyPane);
refreshWidgetLibPane(); refreshWidgetLibPane();
currentFormDesign = formDesign;
} }
private void refreshWidgetLibPane() { private void refreshWidgetLibPane() {
@ -1090,4 +1092,19 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
} }
} }
} }
@Override
public void whenClose() {
super.whenClose();
releaseResources();
}
private void releaseResources() {
if (ComparatorUtils.equals(currentFormDesign, formDesign)) {
FormParaWidgetPane.getInstance().releaseResources();
FormWidgetDetailPane.getInstance().releaseResources();
WidgetPropertyPane.getInstance().releaseResources();
currentFormDesign = null;
}
}
} }

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

@ -9,6 +9,7 @@ import com.fr.design.designer.creator.*;
import com.fr.design.designer.creator.cardlayout.XWCardTagLayout; import com.fr.design.designer.creator.cardlayout.XWCardTagLayout;
import com.fr.design.designer.properties.mobile.MobileBookMarkPropertyUI; import com.fr.design.designer.properties.mobile.MobileBookMarkPropertyUI;
import com.fr.design.designer.properties.mobile.MobileStylePropertyUI; 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.form.util.FormDesignerUtils;
import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.fun.WidgetPropertyUIProvider;
import com.fr.design.gui.controlpane.EventPropertyPane; import com.fr.design.gui.controlpane.EventPropertyPane;
@ -32,7 +33,7 @@ import java.util.Set;
* 控件属性表绘制 * 控件属性表绘制
* Modified by fanglei * Modified by fanglei
*/ */
public class WidgetPropertyPane extends FormDockView implements BaseWidgetPropertyPane { public class WidgetPropertyPane extends FormDockView implements BaseWidgetPropertyPane, Releasable {
private static final int PADDING = 10; private static final int PADDING = 10;
private static final int PADDING_M = 12; private static final int PADDING_M = 12;
@ -68,6 +69,31 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper
setLayout(FRGUIPaneFactory.createBorderLayout()); 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 @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Control_Setting"); return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Control_Setting");

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

@ -14,6 +14,7 @@ import com.fr.design.designer.creator.XWTitleLayout;
import com.fr.design.designer.creator.cardlayout.XWCardTagLayout; import com.fr.design.designer.creator.cardlayout.XWCardTagLayout;
import com.fr.design.dialog.AttrScrollPane; import com.fr.design.dialog.AttrScrollPane;
import com.fr.design.dialog.BasicScrollPane; import com.fr.design.dialog.BasicScrollPane;
import com.fr.design.file.Releasable;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
@ -48,7 +49,7 @@ import java.awt.BorderLayout;
/** /**
* Created by ibm on 2017/7/25. * Created by ibm on 2017/7/25.
*/ */
public class FormWidgetCardPane extends AbstractAttrNoScrollPane { public class FormWidgetCardPane extends AbstractAttrNoScrollPane implements Releasable {
private AttributeChangeListener listener; private AttributeChangeListener listener;
private FormDesigner designer; private FormDesigner designer;
//当前的编辑器属性定义面板 //当前的编辑器属性定义面板
@ -86,7 +87,7 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane {
return null; return null;
} else if (xLayoutContainer.acceptType(XWAbsoluteLayout.class)) { } else if (xLayoutContainer.acceptType(XWAbsoluteLayout.class)) {
return new WidgetAbsoluteBoundPane(xCreator); return new WidgetAbsoluteBoundPane(xCreator);
} else if(xCreator.acceptType(XWCardTagLayout.class)){ } else if (xCreator.acceptType(XWCardTagLayout.class)) {
return new WidgetCardTagBoundPane(xCreator); return new WidgetCardTagBoundPane(xCreator);
} }
return new WidgetBoundPane(xCreator); return new WidgetBoundPane(xCreator);
@ -281,4 +282,15 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane {
designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_EDITED); 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