|
|
|
@ -1,10 +1,18 @@
|
|
|
|
|
package com.fr.design.designer.properties; |
|
|
|
|
|
|
|
|
|
import com.fr.design.designer.beans.AdapterBus; |
|
|
|
|
import com.fr.design.designer.beans.adapters.layout.FRFitLayoutAdapter; |
|
|
|
|
import com.fr.design.designer.creator.XCreatorUtils; |
|
|
|
|
import com.fr.design.designer.creator.XLayoutContainer; |
|
|
|
|
import com.fr.design.mainframe.FormDesigner; |
|
|
|
|
import com.fr.design.mainframe.WidgetPropertyPane; |
|
|
|
|
import com.fr.design.mainframe.widget.editors.IntegerPropertyEditor; |
|
|
|
|
import com.fr.design.mainframe.widget.editors.PropertyCellEditor; |
|
|
|
|
import com.fr.design.designer.beans.ConstraintsGroupModel; |
|
|
|
|
import com.fr.design.designer.creator.XCreator; |
|
|
|
|
import com.fr.design.designer.creator.XWFitLayout; |
|
|
|
|
import com.fr.design.utils.ComponentUtils; |
|
|
|
|
import com.fr.form.ui.Widget; |
|
|
|
|
import com.fr.form.ui.container.WFitLayout; |
|
|
|
|
import com.fr.general.Inter; |
|
|
|
|
|
|
|
|
@ -23,6 +31,7 @@ import java.awt.*;
|
|
|
|
|
//控件在自适应布局中宽度、高度属性,7.1.1不可编辑
|
|
|
|
|
public class FRFitLayoutConstraints implements ConstraintsGroupModel { |
|
|
|
|
private static final int MINHEIGHT = XCreator.SMALL_PREFERRED_SIZE.height; |
|
|
|
|
private static final int MINWIDTH = XCreator.SMALL_PREFERRED_SIZE.width; |
|
|
|
|
private static final int ROWNUM = 2; |
|
|
|
|
|
|
|
|
|
private DefaultTableCellRenderer renderer; |
|
|
|
@ -80,12 +89,18 @@ public class FRFitLayoutConstraints implements ConstraintsGroupModel {
|
|
|
|
|
public boolean setValue(Object value, int row, int column) { |
|
|
|
|
if (column == 1) { |
|
|
|
|
int v = value == null ? 0 : ((Number) value).intValue(); |
|
|
|
|
Rectangle bounds = new Rectangle(xCreator.getBounds()); |
|
|
|
|
int difference = 0; |
|
|
|
|
Rectangle bounds = getBounds(); |
|
|
|
|
switch (row) { |
|
|
|
|
case 0: |
|
|
|
|
if(v < MINWIDTH){ |
|
|
|
|
JOptionPane.showMessageDialog(null, Inter.getLocText("Min-Width") + Integer.toString(MINWIDTH)); |
|
|
|
|
v = xCreator.getWidth(); |
|
|
|
|
} |
|
|
|
|
if (bounds.width == v){ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
difference = bounds.width - v; |
|
|
|
|
bounds.width = v; |
|
|
|
|
break; |
|
|
|
|
case 1: |
|
|
|
@ -96,25 +111,44 @@ public class FRFitLayoutConstraints implements ConstraintsGroupModel {
|
|
|
|
|
if (bounds.height == v){ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
difference = bounds.height - v; |
|
|
|
|
bounds.height = v; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
WFitLayout wFitLayout = parent.toData(); |
|
|
|
|
wFitLayout.setBounds(xCreator.toData(),bounds); |
|
|
|
|
xCreator.setBounds(bounds); |
|
|
|
|
|
|
|
|
|
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); |
|
|
|
|
Rectangle backupBounds = getBounds(); |
|
|
|
|
FRFitLayoutAdapter layoutAdapter = (FRFitLayoutAdapter) AdapterBus.searchLayoutAdapter(formDesigner, xCreator); |
|
|
|
|
if (layoutAdapter != null) { |
|
|
|
|
layoutAdapter.calculateBounds(backupBounds, bounds, xCreator, row, difference); |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} else { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Rectangle getBounds(){ |
|
|
|
|
Rectangle bounds = new Rectangle(xCreator.getBounds()); |
|
|
|
|
XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(xCreator); |
|
|
|
|
if (parent == null) { |
|
|
|
|
return bounds; |
|
|
|
|
} |
|
|
|
|
Rectangle rec = ComponentUtils.getRelativeBounds(parent); |
|
|
|
|
bounds.x += rec.x; |
|
|
|
|
bounds.y += rec.y; |
|
|
|
|
return bounds; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 该行是否可编辑 |
|
|
|
|
* @param row 行 |
|
|
|
|
* @return 第row行可编辑返回true,否则返回false |
|
|
|
|
*/ |
|
|
|
|
public boolean isEditable(int row) { |
|
|
|
|
return false; |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |