@ -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 ;
//格子设计器
@ -712,7 +714,7 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
}
@Override
protected FormModelAdapter createDesignModel ( Parameter [ ] parameters ) {
protected FormModelAdapter createDesignModel ( Parameter [ ] parameters ) {
return new FormModelAdapter ( this , parameters ) ;
}
@ -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 ) ;
}
}
}