@ -4,11 +4,12 @@ import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer ;
import com.fr.design.designer.creator.XLayoutContainer ;
import com.fr.design.designer.creator.cardlayout.XWCardTagLayout ;
import com.fr.design.designer.creator.cardlayout.XWCardTagLayout ;
import com.fr.design.dialog.FineJOptionPane ;
import com.fr.design.dialog.FineJOptionPane ;
import com.fr.design.file.HistoryTemplateListPane ;
import com.fr.design.form.layout.FRBorderLayout ;
import com.fr.design.form.layout.FRBorderLayout ;
import com.fr.design.mainframe.JTemplate ;
import com.fr.design.ui.util.UIUtil ;
import com.fr.general.ComparatorUtils ;
import com.fr.general.ComparatorUtils ;
import javax.swing.JOptionPane ;
import java.awt.BorderLayout ;
import java.awt.BorderLayout ;
import java.awt.Rectangle ;
import java.awt.Rectangle ;
@ -46,18 +47,42 @@ public class FRCardMainBorderLayoutAdapter extends FRBorderLayoutAdapter {
Rectangle rectangle = creator . getBounds ( ) ;
Rectangle rectangle = creator . getBounds ( ) ;
//不能超出控件边界
//不能超出控件边界
if ( ComparatorUtils . equals ( constraints , BorderLayout . NORTH ) | | ComparatorUtils . equals ( constraints , BorderLayout . SOUTH ) ) {
if ( ComparatorUtils . equals ( constraints , BorderLayout . NORTH ) | | ComparatorUtils . equals ( constraints , BorderLayout . SOUTH ) ) {
int containerHeight = container . getHeight ( ) ;
return isBeyondMinConstraint ( rectangle . height , container . getHeight ( ) ) ;
if ( rectangle . height > containerHeight ) {
FineJOptionPane . showMessageDialog ( null , com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Form_Beyond_Tablayout_Bounds" ) ) ;
return true ;
}
} else if ( ComparatorUtils . equals ( constraints , BorderLayout . EAST ) | | ComparatorUtils . equals ( constraints , BorderLayout . WEST ) ) {
} else if ( ComparatorUtils . equals ( constraints , BorderLayout . EAST ) | | ComparatorUtils . equals ( constraints , BorderLayout . WEST ) ) {
int containerWidth = container . getWidth ( ) ;
return isBeyondMinConstraint ( rectangle . width , container . getWidth ( ) ) ;
if ( rectangle . width > containerWidth ) {
FineJOptionPane . showMessageDialog ( null , com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Form_Beyond_Tablayout_Bounds" ) ) ;
return true ;
}
}
}
return false ;
return false ;
}
}
/ * *
* 是否超出最小限制
*
* @param minConstraint 最小限制
* @param value 数值
* @return 是否超出最小限制
* /
private boolean isBeyondMinConstraint ( int minConstraint , int value ) {
if ( minConstraint > value ) {
FineJOptionPane . showMessageDialog ( null , com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Form_Beyond_Tablayout_Bounds" ) ) ;
if ( container . getBackupBound ( ) ! = null ) {
// 手动拖动导致变矮的场景
container . setSize ( container . getBackupBound ( ) . getSize ( ) ) ;
} else {
// 自适应布局平分高度导致变矮的场景
UIUtil . invokeLaterIfNeeded ( new Runnable ( ) {
@Override
public void run ( ) {
JTemplate < ? , ? > jt = HistoryTemplateListPane . getInstance ( ) . getCurrentEditingTemplate ( ) ;
if ( jt ! = null ) {
jt . undo ( ) ;
}
}
} ) ;
}
return true ;
} else {
return false ;
}
}
}
}