Browse Source

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

feature/10.0
Henry.Wang 3 years ago
parent
commit
631dbe4893
  1. 5
      designer-base/src/main/java/com/fr/design/file/CloseReleasable.java
  2. 5
      designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java
  3. 12
      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. 20
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  7. 21
      designer-form/src/main/java/com/fr/design/mainframe/WidgetPropertyPane.java

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

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

5
designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java

@ -248,6 +248,11 @@ public class FRTreeComboBox extends UIComboBox {
private static TreePopup treePopup;
public static void releaseTreePopup(){
treePopup = null;
}
private static class FRTreeComboBoxUI extends BasicComboBoxUI implements MouseListener{
private boolean isRollover = false;

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

@ -2,6 +2,8 @@ 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.CloseReleasable;
import com.fr.design.gui.icombobox.FRTreeComboBox;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.widget.EventCreator;
@ -13,7 +15,7 @@ import com.fr.stable.Nameable;
/**
* Created by kerry on 5/17/21
*/
public class EventPropertyPane extends UIListGroupControlPane {
public class EventPropertyPane extends UIListGroupControlPane implements CloseReleasable {
private XCreator creator;
private FormDesigner designer;
@ -24,6 +26,14 @@ public class EventPropertyPane extends UIListGroupControlPane {
this.designer = designer;
}
@Override
public void releaseResources() {
Widget widget = creator.toData();
if (widget.getListenerSize() > 0) {
FRTreeComboBox.releaseTreePopup();
}
}
/**
* 刷新

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.DesignerEvent;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.file.CloseReleasable;
import com.fr.design.fun.FormWidgetOptionProvider;
import com.fr.design.gui.core.FormWidgetOption;
import com.fr.design.gui.core.UserDefinedWidgetOption;
@ -56,7 +57,7 @@ import java.awt.event.MouseEvent;
/**
* @author null
*/
public class FormParaWidgetPane extends JPanel {
public class FormParaWidgetPane extends JPanel implements CloseReleasable {
private static FormParaWidgetPane THIS;
private final static int BORDER = 5;
private final static int WIDGET_WIDTHGAP = 4;
@ -119,6 +120,15 @@ public class FormParaWidgetPane extends JPanel {
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,6 +2,7 @@ package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.design.dialog.BasicPane;
import com.fr.design.file.CloseReleasable;
import com.fr.design.gui.ibutton.UIHeadGroup;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.reuse.ComponentReuseNotificationInfo;
@ -23,7 +24,7 @@ import java.util.List;
* Date: 14-7-8
* Time: 下午8:18
*/
public class FormWidgetDetailPane extends FormDockView{
public class FormWidgetDetailPane extends FormDockView implements CloseReleasable {
private static final int ONLINE_TAB = 1;
private JPanel centerPane;
@ -52,6 +53,11 @@ public class FormWidgetDetailPane extends FormDockView{
private static FormWidgetDetailPane singleton = new FormWidgetDetailPane();
}
@Override
public void releaseResources() {
setEditingFormDesigner(null);
}
public String getViewTitle() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Tree_And_Table");
}

20
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 int TOOLBARPANEDIMHEIGHT_FORM = 60;
//当前使用的表单设计器
private static FormDesigner currentFormDesign;
//表单设计器
private FormDesigner formDesign;
//格子设计器
@ -858,6 +859,8 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
EastRegionContainerPane.getInstance().addParameterPane(parameterPropertyPane);
refreshWidgetLibPane();
System.out.println(this.getEditingFILE());
currentFormDesign = formDesign;
}
private void refreshWidgetLibPane() {
@ -1090,4 +1093,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;
}
}
}

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

Loading…
Cancel
Save