Fangjie Hu 8 years ago
parent
commit
3d9e8e3f7b
  1. 93
      designer/src/com/fr/design/widget/ui/DateEditorDefinePane.java
  2. 10
      designer_base/src/com/fr/design/data/BasicTableDataTreePane.java
  3. 28
      designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java
  4. 6
      designer_base/src/com/fr/design/gui/itable/AbstractPropertyTable.java
  5. 4
      designer_base/src/com/fr/design/hyperlink/AbstractHyperlinkPane.java
  6. 2
      designer_base/src/com/fr/design/icon/IconPathConstants.java
  7. BIN
      designer_base/src/com/fr/design/images/control/help_close.png
  8. BIN
      designer_base/src/com/fr/design/images/control/help_open.png
  9. 15
      designer_form/src/com/fr/design/designer/creator/XCreator.java
  10. 1
      designer_form/src/com/fr/design/designer/creator/XCreatorUtils.java
  11. 22
      designer_form/src/com/fr/design/designer/creator/XElementCase.java
  12. 8
      designer_form/src/com/fr/design/designer/creator/XWFitLayout.java
  13. 52
      designer_form/src/com/fr/design/designer/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java
  14. 26
      designer_form/src/com/fr/design/designer/properties/FRFitLayoutPropertiesGroupModel.java
  15. 142
      designer_form/src/com/fr/design/mainframe/CoverReportPane.java
  16. 38
      designer_form/src/com/fr/design/mainframe/EditingMouseListener.java
  17. 73
      designer_form/src/com/fr/design/mainframe/ElementCaseHelpDialog.java
  18. 343
      designer_form/src/com/fr/design/mainframe/FormCreatorDropTarget.java
  19. 14
      designer_form/src/com/fr/design/mainframe/FormHierarchyTreePane.java
  20. 20
      designer_form/src/com/fr/design/mainframe/JForm.java

93
designer/src/com/fr/design/widget/ui/DateEditorDefinePane.java

@ -31,7 +31,7 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
private UIComboBox returnTypeComboBox;
private UILabel sampleLabel;// preview
// content
private UITextField patternTextField = null;
private UIComboBox dateFormatComboBox;
private ValueEditorPane startDv;
private ValueEditorPane endDv;
@ -42,7 +42,7 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
private void initComponets() {
super.initComponents();
}
@Override
protected String title4PopupWindow() {
return "Date";
@ -63,25 +63,21 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
// sample pane
sampleLabel = new UILabel("");
// samplePane.add(sampleLabel, BorderLayout.CENTER);
sampleLabel.setBorder(BorderFactory.createEmptyBorder(2, 4, 4, 4));
sampleLabel.setHorizontalAlignment(SwingConstants.CENTER);
sampleLabel.setFont(FRContext.getDefaultValues().getFRFont());
// content pane
patternTextField = new UITextField();
patternTextField.getDocument().addDocumentListener(patternTextDocumentListener);
String[] arr = getDateFormateArray();
final UIComboBox comboBox = new UIComboBox(arr);
comboBox.setPreferredSize(new Dimension(150,20));
comboBox.addActionListener(new ActionListener(){
String[] arr = getDateFormateArray();
dateFormatComboBox = new UIComboBox(arr);
dateFormatComboBox.setPreferredSize(new Dimension(150,20));
dateFormatComboBox.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
patternTextField.setText( (String)comboBox.getSelectedItem());
refreshPreviewLabel();
}
});
JPanel secondPanel = GUICoreUtils.createFlowPane(new JComponent[]{new UILabel(Inter.getLocText("FR-Engine_Format") + ":"),comboBox,sampleLabel}, FlowLayout.LEFT, 5);
JPanel secondPanel = GUICoreUtils.createFlowPane(new JComponent[]{new UILabel(Inter.getLocText("FR-Engine_Format") + ":"),dateFormatComboBox,sampleLabel}, FlowLayout.LEFT, 5);
secondPanel.setPreferredSize(new Dimension(220,30));
otherContentPane.add(secondPanel);
otherContentPane.add(initStartEndDatePane(), BorderLayout.SOUTH);
@ -104,33 +100,20 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
return rangePane;
}
private DocumentListener patternTextDocumentListener = new DocumentListener() {
public void insertUpdate(DocumentEvent evt) {
refreshPreviewLabel();
}
public void removeUpdate(DocumentEvent evt) {
refreshPreviewLabel();
}
public void changedUpdate(DocumentEvent evt) {
refreshPreviewLabel();
}
};
private void refreshPreviewLabel() {
String text = patternTextField.getText();
String text = (String) dateFormatComboBox.getSelectedItem();
if (text != null && text.length() > 0) {
try {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(text);
String sample = simpleDateFormat.format(new Date());
Color c = Color.black;
if (!ArrayUtils.contains(FormatField.getInstance().getDateFormatArray(), text)) {
sample += " " + Inter.getLocText("DateFormat-Custom_Warning");
c = Color.red;
}
String sample = simpleDateFormat.format(new Date());
Color c = Color.black;
if (!ArrayUtils.contains(FormatField.getInstance().getDateFormatArray(), text)) {
sample += " " + Inter.getLocText("DateFormat-Custom_Warning");
c = Color.red;
}
this.sampleLabel.setText(sample);
this.sampleLabel.setForeground(c);
this.sampleLabel.setForeground(c);
} catch (Exception exp) {
this.sampleLabel.setForeground(Color.red);
this.sampleLabel.setText(exp.getMessage());
@ -143,12 +126,12 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
@Override
protected void populateSubDirectWriteEditorBean(DateEditor e) {
String formatText = e.getFormatText();
patternTextField.setText(formatText);
dateFormatComboBox.setSelectedItem(formatText);
returnTypeComboBox.setSelectedIndex(e.isReturnDate() ? 1 : 0);
populateStartEnd(e);
};
}
@Override
protected DateEditor updateSubDirectWriteEditorBean() {
@ -162,10 +145,10 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
return ob;
}
/**
* 初始起止日期
* @param dateWidgetEditor 日期控件
*/
/**
* 初始起止日期
* @param dateWidgetEditor 日期控件
*/
public void populateStartEnd(DateEditor dateWidgetEditor) {
Formula startFM = dateWidgetEditor.getStartDateFM();
Formula endFM = dateWidgetEditor.getEndDateFM();
@ -183,10 +166,10 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
}
}
/**
* 更新日期控件的起止日期
* @param dateWidgetEditor 日期控件
*/
/**
* 更新日期控件的起止日期
* @param dateWidgetEditor 日期控件
*/
public void updateStartEnd(DateEditor dateWidgetEditor) {
Object startObject = startDv.update();
Object endObject = endDv.update();
@ -204,11 +187,11 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
dateWidgetEditor.setStartDateFM(startFormula);
dateWidgetEditor.setStartText(null);
} else {
try {
dateWidgetEditor.setStartText(startObject == null ? "" : DateUtils.getDate2Str("MM/dd/yyyy", (Date)startObject));
} catch(ClassCastException e) {
//wei : TODO 说明应用的公式不能转化成日期格式,应该做些处理。
}
try {
dateWidgetEditor.setStartText(startObject == null ? "" : DateUtils.getDate2Str("MM/dd/yyyy", (Date)startObject));
} catch(ClassCastException e) {
//wei : TODO 说明应用的公式不能转化成日期格式,应该做些处理。
}
}
if (endObject instanceof Formula) {
cal = Calculator.createCalculator();
@ -222,20 +205,20 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
dateWidgetEditor.setEndDateFM(endFormula);
dateWidgetEditor.setEndText(null);
} else {
try {
dateWidgetEditor.setEndText(endObject == null ? "" : DateUtils.getDate2Str("MM/dd/yyyy", (Date)endObject));
} catch(ClassCastException e) {
}
try {
dateWidgetEditor.setEndText(endObject == null ? "" : DateUtils.getDate2Str("MM/dd/yyyy", (Date)endObject));
} catch(ClassCastException e) {
}
}
}
private SimpleDateFormat getSimpleDateFormat() {
String text = patternTextField.getText();
String text = (String) dateFormatComboBox.getSelectedItem();
SimpleDateFormat simpleDateFormat;
if (text != null && text.length() > 0) {
try {
simpleDateFormat = new SimpleDateFormat(patternTextField.getText());
simpleDateFormat = new SimpleDateFormat(text);
this.sampleLabel.setText(simpleDateFormat.format(new Date()));
} catch (Exception exp) {
simpleDateFormat = new SimpleDateFormat("");

10
designer_base/src/com/fr/design/data/BasicTableDataTreePane.java

@ -3,6 +3,7 @@ package com.fr.design.data;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.base.TableData;
import com.fr.data.TableDataSource;
import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.design.DesignModelAdapter;
import com.fr.design.actions.UpdateAction;
@ -423,4 +424,13 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp
this.setSmallIcon(BaseUtils.readIcon(IconPathConstants.TD_CONNECTION_ICON_PATH));
}
}
/**
* 合并数据集
* @param srcName 数据集来源(比如报表块就是报表块的名称)
* @param tableDataSource 数据集
*/
public void addTableData(String srcName, TableDataSource tableDataSource) {
}
}

28
designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java

@ -39,6 +39,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class TableDataTreePane extends BasicTableDataTreePane {
@ -138,6 +139,7 @@ public class TableDataTreePane extends BasicTableDataTreePane {
populate(new TableDataSourceOP(tc));
this.checkButtonEnabled();
}
protected void initbuttonGroup() {
Icon[] iconArray = {BaseUtils.readIcon("/com/fr/design/images/data/datasource.png"), BaseUtils.readIcon("/com/fr/design/images/data/dock/serverdatabase.png")};
final Integer[] modeArray = {TEMPLATE_TABLE_DATA, SERVER_TABLE_DATA};
@ -267,4 +269,30 @@ public class TableDataTreePane extends BasicTableDataTreePane {
public TableDataTree getDataTree() {
return dataTree;
}
/**
* 合并数据集
* @param srcName 数据集来源(比如报表块就是报表块的名称)
* @param tableDataSource 数据集
*/
public void addTableData(String srcName, TableDataSource tableDataSource) {
DesignTableDataManager.setThreadLocal(DesignTableDataManager.NO_PARAMETER);
TableDataSource tds = tc.getBook();
Iterator tdIterator = tableDataSource.getTableDataNameIterator();
while (tdIterator.hasNext()) {
String tdName = (String) tdIterator.next();
TableData td = tableDataSource.getTableData(tdName);
if (tds.getTableData(tdName) != null) {//如果有同名的就拼上来源名称
tdName = srcName + tdName;
}
int i = 0;
while (tds.getTableData(tdName) != null) {
i++;//如果拼上名字后依然已经存在就加编号
tdName += i;
}
tds.putTableData(tdName, td);
}
tc.parameterChanged();
dataTree.refresh();
}
}

6
designer_base/src/com/fr/design/gui/itable/AbstractPropertyTable.java

@ -66,6 +66,9 @@ public abstract class AbstractPropertyTable extends JTable {
public TableCellRenderer getCellRenderer(int row, int column) {
if (groups != null) {
Point pIndex = getGroupIndex(row);
if (pIndex == null){
return super.getCellRenderer(row, column);
}
PropertyGroup group = groups.get(pIndex.x);
if (pIndex.y == 0) {
if (column == 0) {
@ -192,6 +195,9 @@ public abstract class AbstractPropertyTable extends JTable {
@Override
public Object getValueAt(int row, int column) {
Point pIndex = getGroupIndex(row);
if (pIndex == null){
return null;
}
PropertyGroup group = groups.get(pIndex.x);
if (pIndex.y == 0) {
if (column == 0) {

4
designer_base/src/com/fr/design/hyperlink/AbstractHyperlinkPane.java

@ -63,12 +63,12 @@ public abstract class AbstractHyperlinkPane<T extends Hyperlink> extends BasicBe
newWindowConfPane.add(new UILabel(Inter.getLocText("FR-Designer_Height") + ": "));
heightTextFiled = new UINumberField();
heightTextFiled.setText(String.valueOf(DEFAULT_H_VALUE));
heightTextFiled.setPreferredSize(new Dimension(60, 20));
heightTextFiled.setPreferredSize(new Dimension(40, 20));
newWindowConfPane.add(heightTextFiled);
newWindowConfPane.add(new UILabel(" " + Inter.getLocText("FR-Designer_Width") + ": "));
widthTextFiled = new UINumberField();
widthTextFiled.setText(String.valueOf(DEFAULT_V_VALUE));
widthTextFiled.setPreferredSize(new Dimension(60, 20));
widthTextFiled.setPreferredSize(new Dimension(40, 20));
newWindowConfPane.add(widthTextFiled);
JPanel centerPanel = new JPanel(new BorderLayout());

2
designer_base/src/com/fr/design/icon/IconPathConstants.java

@ -1 +1 @@
package com.fr.design.icon; /** * Created by IntelliJ IDEA. * Author : Richer * Version: 6.5.6 * Date: 12-12-18 * Time: 上午9:42 * 用于保存所有图标路径的类 */ public class IconPathConstants { private IconPathConstants() { } public static final String ADD_POPMENU_ICON_PATH = "/com/fr/design/images/control/addPopup.png"; public static final String DS_ICON_PATH = "/com/fr/design/images/data/datasource.png"; public static final String CLASS_TD_ICON_PATH = "/com/fr/design/images/data/source/classTableData.png"; public static final String EMB_TD_ICON_PATH = "/com/fr/design/images/data/dataTable.png"; public static final String DS_RELATION_TD_ICON_PATH = "/com/fr/design/images/data/multi.png"; public static final String FILE_TD_ICON_PATH = "/com/fr/design/images/data/file.png"; public static final String DS_TREE_TD_ICON_PATH = "/com/fr/design/images/data/tree.png"; public static final String DS_QUERY_ICON_PATH = "/com/fr/design/images/data/database.png"; public static final String PREVIEW_ICON_PATH = "/com/fr/design/images/m_file/preview.png"; public static final String TD_EDIT_ICON_PATH = "/com/fr/design/images/control/edit.png"; public static final String TD_REMOVE_ICON_PATH = "/com/fr/base/images/cell/control/remove.png"; public static final String TD_CONNECTION_ICON_PATH = "/com/fr/design/images/m_web/connection.png"; public static final String SP_SHOW_ICON_PATH = "/com/fr/design/images/data/store_procedure.png"; public static final String STD_SHOW_ICON_PATH = "/com/fr/design/images/data/dock/serverdatabase.png"; public static final String XMLA_ICON_PATH = "/com/fr/design/images/data/cube.png"; public static final String FORBID_ICON_PATH ="/com/fr/web/images/form/forbid.png"; }
package com.fr.design.icon; /** * Created by IntelliJ IDEA. * Author : Richer * Version: 6.5.6 * Date: 12-12-18 * Time: 上午9:42 * 用于保存所有图标路径的类 */ public class IconPathConstants { private IconPathConstants() { } public static final String ADD_POPMENU_ICON_PATH = "/com/fr/design/images/control/addPopup.png"; public static final String DS_ICON_PATH = "/com/fr/design/images/data/datasource.png"; public static final String CLASS_TD_ICON_PATH = "/com/fr/design/images/data/source/classTableData.png"; public static final String EMB_TD_ICON_PATH = "/com/fr/design/images/data/dataTable.png"; public static final String DS_RELATION_TD_ICON_PATH = "/com/fr/design/images/data/multi.png"; public static final String FILE_TD_ICON_PATH = "/com/fr/design/images/data/file.png"; public static final String DS_TREE_TD_ICON_PATH = "/com/fr/design/images/data/tree.png"; public static final String DS_QUERY_ICON_PATH = "/com/fr/design/images/data/database.png"; public static final String PREVIEW_ICON_PATH = "/com/fr/design/images/m_file/preview.png"; public static final String TD_EDIT_ICON_PATH = "/com/fr/design/images/control/edit.png"; public static final String TD_EL_SHARE_HELP_ICON_PATH = "/com/fr/design/images/control/help_open.png"; public static final String TD_EL_SHARE_CLOSE_ICON_PATH = "/com/fr/design/images/control/help_close.png"; public static final String TD_REMOVE_ICON_PATH = "/com/fr/base/images/cell/control/remove.png"; public static final String TD_CONNECTION_ICON_PATH = "/com/fr/design/images/m_web/connection.png"; public static final String SP_SHOW_ICON_PATH = "/com/fr/design/images/data/store_procedure.png"; public static final String STD_SHOW_ICON_PATH = "/com/fr/design/images/data/dock/serverdatabase.png"; public static final String XMLA_ICON_PATH = "/com/fr/design/images/data/cube.png"; public static final String FORBID_ICON_PATH ="/com/fr/web/images/form/forbid.png"; }

BIN
designer_base/src/com/fr/design/images/control/help_close.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 801 B

BIN
designer_base/src/com/fr/design/images/control/help_open.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 895 B

15
designer_form/src/com/fr/design/designer/creator/XCreator.java

@ -586,8 +586,19 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
}
/**
* 设置共享帮助信息
* 设置描述信息
* @param msg 帮助信息
*/
public void setSharedMsg(String msg){}
public void setXDescrption(String msg){}
/**
* 根据widget设置Xcreator描述信息
* @param widget
*/
public void setXDescrption(Widget widget){
if (widget != null) {
setXDescrption(widget.getDescription());
}
}
}

1
designer_form/src/com/fr/design/designer/creator/XCreatorUtils.java

@ -157,6 +157,7 @@ public class XCreatorUtils {
FRContext.getLogger().error("Error to create xcreator!");
creator = new NullCreator(widget, d);
}
creator.setXDescrption(widget);//设置描述信息
return creator;
}

22
designer_form/src/com/fr/design/designer/creator/XElementCase.java

@ -35,7 +35,7 @@ import java.beans.PropertyDescriptor;
public class XElementCase extends XBorderStyleWidgetCreator implements FormElementCaseContainerProvider{
private UILabel imageLable;
private JPanel coverPanel;
private CoverReportPane coverPanel;
private FormDesigner designer;
//缩略图
private BufferedImage thumbnailImage;
@ -181,11 +181,10 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
* @param display 是否
*/
public void displayCoverPane(boolean display){
coverPanel.setVisible(display);
coverPanel.setPreferredSize(editor.getPreferredSize());
coverPanel.setBounds(editor.getBounds());
editor.repaint();
}
coverPanel.setVisible(display);
coverPanel.setBounds(1, 1, (int) editor.getBounds().getWidth(), (int) editor.getBounds().getHeight());
editor.repaint();
}
public JComponent getCoverPane(){
return coverPanel;
@ -263,7 +262,11 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
*/
public void respondClick(EditingMouseListener editingMouseListener,MouseEvent e){
super.respondClick(editingMouseListener, e);
switchTab(e,editingMouseListener);
if (this.isHelpBtnOnFocus()) {
coverPanel.setMsgDisplay(e);
}else {
switchTab(e,editingMouseListener);
}
}
@ -280,4 +283,9 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() {
return new WidgetPropertyUIProvider[]{ new ElementCasePropertyUI(this)};
}
@Override
public void setXDescrption(String msg) {
coverPanel.setHelpMsg(msg);
}
}

8
designer_form/src/com/fr/design/designer/creator/XWFitLayout.java

@ -21,6 +21,7 @@ import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.PaddingMargin;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.form.ui.container.WBodyLayoutType;
import com.fr.form.ui.container.WFitLayout;
import com.fr.form.ui.container.WLayout;
import com.fr.general.FRScreen;
@ -685,7 +686,10 @@ public class XWFitLayout extends XLayoutContainer {
if (isRefreshing) {
return;
}
LayoutUtils.layoutContainer(this);
//当前的body布局为绝对布局的时候不要doLayout
if (toData().getBodyLayoutType() != WBodyLayoutType.ABSOLUTE){
LayoutUtils.layoutContainer(this);
}
WFitLayout layout = this.toData();
//自适应布局新增控件后,其他控件位置也会变
XWidgetCreator creator = (XWidgetCreator) e.getChild();
@ -834,7 +838,7 @@ public class XWFitLayout extends XLayoutContainer {
* 处理自适应布局的directions
* @param xcreator 组件
*/
private void dealDirections(XCreator xcreator, boolean isInit) {
public void dealDirections(XCreator xcreator, boolean isInit) {
if (xcreator == null) {
return;
}

52
designer_form/src/com/fr/design/designer/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java

@ -1,7 +1,7 @@
package com.fr.design.designer.properties;
import com.fr.design.designer.creator.XWAbsoluteBodyLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.creator.*;
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelectionUtils;
import com.fr.design.mainframe.WidgetPropertyPane;
@ -93,24 +93,44 @@ public class FRAbsoluteBodyLayoutPropertiesGroupModel extends FRAbsoluteLayoutPr
if (row == 0) {
if (state == WBodyLayoutType.FIT.getTypeValue()) {
XWFitLayout xfl = (XWFitLayout) xwAbsoluteLayout.getBackupParent();
//备份一下组件间隔
int compInterval = xfl.toData().getCompInterval();
Component[] components = xwAbsoluteLayout.getComponents();
Arrays.sort(components, new ComparatorComponentLocation());
xfl.getLayoutAdapter().removeBean(xwAbsoluteLayout, xwAbsoluteLayout.getWidth(), xwAbsoluteLayout.getHeight());
xfl.remove(xwAbsoluteLayout);
xfl.toData().setLayoutType(WBodyLayoutType.FIT);
for (Component comp : components) {
xfl.add(comp);
XCreator xCreator = (XCreator)comp;
if (xCreator.shouldScaleCreator()){
XLayoutContainer parentPanel = xCreator.initCreatorWrapper(xCreator.getHeight());
xfl.add(parentPanel, xCreator.toData().getWidgetName());
parentPanel.updateChildBound(xfl.getActualMinHeight());
continue;
}
xfl.add(xCreator);
}
moveComponents2FitLayout(xfl, components);
//这边计算的时候会先把组件间隔去掉
moveComponents2FitLayout(xfl);
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
formDesigner.getSelectionModel().setSelectedCreators(
FormSelectionUtils.rebuildSelection(xfl, new Widget[]{xfl.toData()}));
xfl.convert();
LayoutUtils.layoutContainer(xfl);
xfl.adjustCreatorsWhileSlide(xfl.getContainerPercent() - 1.0);
formDesigner.getSelectionModel().setSelectedCreator(xfl);
for (int i = 0; i < components.length; i++) {
Component comp = xfl.getComponent(i);
XCreator creator = (XCreator) comp;
creator.setBackupBound(components[i].getBounds());
}
//把组件间隔加上
if (xfl.toData().getCompInterval() != compInterval) {
xfl.moveContainerMargin();
xfl.moveCompInterval(xfl.getAcualInterval());
xfl.toData().setCompInterval(compInterval);
xfl.addCompInterval(xfl.getAcualInterval());
}
xfl.toData().setLayoutType(WBodyLayoutType.FIT);
return true;
}
}
@ -147,15 +167,18 @@ public class FRAbsoluteBodyLayoutPropertiesGroupModel extends FRAbsoluteLayoutPr
}
//把绝对布局中的元素按规则移动到自适应布局中
private void moveComponents2FitLayout(XWFitLayout xwFitLayout, Component[] components) {
private void moveComponents2FitLayout(XWFitLayout xwFitLayout) {
int eachRowCount = 4;
Component[] components = xwFitLayout.getComponents();
if (components.length <= 1){
xwFitLayout.updateBoundsWidget();
return;
}
int layoutWidth = xwFitLayout.getWidth() - xwFitLayout.toData().getMargin().getLeft() - xwFitLayout.toData().getMargin().getRight();
int layoutHeight = xwFitLayout.getHeight() - xwFitLayout.toData().getMargin().getTop() - xwFitLayout.toData().getMargin().getBottom();
int leftMargin = xwFitLayout.toData().getMargin().getLeft();
int topMargin = xwFitLayout.toData().getMargin().getTop();
xwFitLayout.toData().setCompInterval(0);
int row = (components.length / eachRowCount) + (components.length % eachRowCount == 0 ? 0 : 1);
//最后一行的列数不定
int column = components.length % eachRowCount == 0 ? eachRowCount : components.length % eachRowCount;
@ -182,6 +205,13 @@ public class FRAbsoluteBodyLayoutPropertiesGroupModel extends FRAbsoluteLayoutPr
lastRowHeight
);
}
for (int i = 0;i < components.length;i++){
if (components[i] instanceof XWCardMainBorderLayout){
((XWCardMainBorderLayout)components[i]).recalculateChildWidth(components[i].getWidth());
((XWCardMainBorderLayout)components[i]).recalculateChildHeight(components[i].getHeight());
}
xwFitLayout.dealDirections((XCreator)components[i], false);
}
xwFitLayout.updateBoundsWidget();
}

26
designer_form/src/com/fr/design/designer/properties/FRFitLayoutPropertiesGroupModel.java

@ -4,8 +4,7 @@
package com.fr.design.designer.properties;
import com.fr.design.beans.GroupModel;
import com.fr.design.designer.creator.XWAbsoluteBodyLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.creator.*;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelectionUtils;
import com.fr.design.mainframe.WidgetPropertyPane;
@ -91,8 +90,23 @@ public class FRFitLayoutPropertiesGroupModel implements GroupModel {
}
}
private XLayoutContainer selectedBodyLayout(FormDesigner formDesigner) {
XLayoutContainer rootLayout = formDesigner.getRootComponent();
if (rootLayout.getComponentCount() == 1 && rootLayout.getXCreator(0).acceptType(XWAbsoluteBodyLayout.class)){
rootLayout = (XWAbsoluteBodyLayout)rootLayout.getXCreator(0);
}
return rootLayout;
}
@Override
public Object getValue(int row, int column) {
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
XLayoutContainer rootLayout = selectedBodyLayout(formDesigner);
if (rootLayout != formDesigner.getRootComponent()
&& formDesigner.getSelectionModel().getSelection().getSelectedCreator() == formDesigner.getRootComponent()) {
formDesigner.getSelectionModel().setSelectedCreators(
FormSelectionUtils.rebuildSelection(xfl, new Widget[]{selectedBodyLayout(formDesigner).toData()}));
}
if (column == 0) {
switch (row) {
case 0:
@ -140,6 +154,14 @@ public class FRFitLayoutPropertiesGroupModel implements GroupModel {
XWAbsoluteBodyLayout xwAbsoluteBodyLayout = new XWAbsoluteBodyLayout(wAbsoluteBodyLayout, new Dimension(0,0));
xfl.getLayoutAdapter().addBean(xwAbsoluteBodyLayout, 0, 0);
for (Component component : components) {
XCreator xCreator = (XCreator)component;
//部分控件被ScaleLayout包裹着,绝对布局里面要放出来
if (xCreator.acceptType(XWScaleLayout.class)){
if (xCreator.getComponentCount() > 0 && ((XCreator)xCreator.getComponent(0)).shouldScaleCreator()) {
component = xCreator.getComponent(0);
component.setBounds(xCreator.getBounds());
}
}
xwAbsoluteBodyLayout.add(component);
}
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();

142
designer_form/src/com/fr/design/mainframe/CoverReportPane.java

@ -1,12 +1,19 @@
package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
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.gui.ibutton.UIButton;
import com.fr.design.icon.IconPathConstants;
import com.fr.form.share.ShareConstants;
import com.fr.general.FRScreen;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
/**
* Created with IntelliJ IDEA.
@ -14,59 +21,124 @@ import java.awt.*;
* Date: 14-7-24
* Time: 上午9:09
*/
public class CoverReportPane extends JPanel{
public class CoverReportPane extends JPanel {
private UIButton editButton;
private Icon controlMode = IOUtils.readIcon(IconPathConstants.TD_EL_SHARE_CLOSE_ICON_PATH);
private JComponent controlButton = new JComponent() {
protected void paintComponent(Graphics g) {
g.setColor(UIConstants.NORMAL_BACKGROUND);
g.fillArc(0, 0, ShareConstants.SHARE_EL_CONTROL_BUTTON_HW, ShareConstants.SHARE_EL_CONTROL_BUTTON_HW,
0, 360);
controlMode.paintIcon(this, g, 0, 0);
}
};
private String helpMsg;//帮助信息(后续帮助信息可能会变成标配,就直接放这边了)
private ElementCaseHelpDialog helpDialog = null;
private AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 60 / 100.0F);
public CoverReportPane(){
setLayout(coverLayout);
public CoverReportPane() {
this(StringUtils.EMPTY);
}
public CoverReportPane(String helpMsg) {
this.helpMsg = helpMsg;
setLayout(getCoverLayout());
setBackground(null);
setOpaque(false);
editButton = new UIButton(Inter.getLocText("Edit"), BaseUtils.readIcon(IconPathConstants.TD_EDIT_ICON_PATH)){
editButton = new UIButton(Inter.getLocText("Edit"), IOUtils.readIcon(IconPathConstants.TD_EDIT_ICON_PATH)) {
@Override
public Dimension getPreferredSize() {
return new Dimension(60,24);
return new Dimension(60, 24);
}
};
editButton.setBorderPainted(false);
editButton.setExtraPainted(false);
editButton.setBackground(new Color(176,196,222));
editButton.setBackground(new Color(176, 196, 222));
add(editButton);
add(controlButton);
if (WidgetPropertyPane.getInstance().getEditingFormDesigner() != null) {
WidgetPropertyPane.getInstance().getEditingFormDesigner().addDesignerEditListener(new DesignerEditListener() {
@Override
public void fireCreatorModified(DesignerEvent evt) {
if (evt.getCreatorEventID() == (DesignerEvent.CREATOR_DELETED)
|| evt.getCreatorEventID() == (DesignerEvent.CREATOR_RESIZED)) {
destroyHelpDialog();
}
}
});
}
}
public String getHelpMsg() {
return helpMsg;
}
private LayoutManager coverLayout = new LayoutManager() {
public void setHelpMsg(String helpMsg) {
this.helpMsg = helpMsg;
}
@Override
public void removeLayoutComponent(Component comp) {
public void setMsgDisplay(MouseEvent e) {
if (helpDialog == null) {
controlMode = IOUtils.readIcon(IconPathConstants.TD_EL_SHARE_CLOSE_ICON_PATH);
controlButton.repaint();
helpDialog = new ElementCaseHelpDialog(DesignerContext.getDesignerFrame(), helpMsg);
double screenValue = FRScreen.getByDimension(Toolkit.getDefaultToolkit().getScreenSize()).getValue();
int offsetX = 0;
if (screenValue < FormArea.DEFAULT_SLIDER) {
offsetX = (int) ((1 - screenValue / FormArea.DEFAULT_SLIDER)
* WidgetPropertyPane.getInstance().getEditingFormDesigner().getRootComponent().getWidth() / 2);
}
int rX = WestRegionContainerPane.getInstance().getWidth() + e.getX() + offsetX - 227;//弹出框宽度190加上图标的宽度27加上10的偏移
int rY = 165 + e.getY();//165是设计器最上面几个面板的高度
helpDialog.setLocationRelativeTo(DesignerContext.getDesignerFrame(), rX, rY);
helpDialog.showWindow();
} else {
controlMode = IOUtils.readIcon(IconPathConstants.TD_EL_SHARE_HELP_ICON_PATH);
controlButton.repaint();
helpDialog.dispose();
helpDialog = null;
}
}
@Override
public Dimension preferredLayoutSize(Container parent) {
return parent.getPreferredSize();
}
protected LayoutManager getCoverLayout() {
return new LayoutManager() {
@Override
public Dimension minimumLayoutSize(Container parent) {
return null;
}
@Override
public void removeLayoutComponent(Component comp) {
}
@Override
public void layoutContainer(Container parent) {
int width = parent.getParent().getWidth();
int height = parent.getParent().getHeight();
int preferWidth = editButton.getPreferredSize().width;
int preferHeight = editButton.getPreferredSize().height;
editButton.setBounds((width - preferWidth)/2, (height - preferHeight)/2, preferWidth, preferHeight);
}
@Override
public Dimension preferredLayoutSize(Container parent) {
return parent.getPreferredSize();
}
@Override
public Dimension minimumLayoutSize(Container parent) {
return null;
}
@Override
public void layoutContainer(Container parent) {
int width = parent.getParent().getWidth();
int height = parent.getParent().getHeight();
int preferWidth = editButton.getPreferredSize().width;
int preferHeight = editButton.getPreferredSize().height;
editButton.setBounds((width - preferWidth) / 2, (height - preferHeight) / 2, preferWidth, preferHeight);
controlButton.setBounds((width - 28), 0, 27, 27);
}
@Override
public void addLayoutComponent(String name, Component comp) {
}
};
}
@Override
public void addLayoutComponent(String name, Component comp) {
}
};
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
@ -77,4 +149,14 @@ public class CoverReportPane extends JPanel{
g2d.setComposite(oldComposite);
super.paint(g);
}
public void destroyHelpDialog() {
if (helpDialog != null) {
controlMode = IOUtils.readIcon(IconPathConstants.TD_EL_SHARE_HELP_ICON_PATH);
controlButton.repaint();
helpDialog.dispose();
helpDialog = null;
}
}
}

38
designer_form/src/com/fr/design/mainframe/EditingMouseListener.java

@ -1,14 +1,5 @@
package com.fr.design.mainframe;
import java.awt.Color;
import java.awt.Container;
import java.awt.Cursor;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import javax.swing.*;
import javax.swing.event.MouseInputAdapter;
import com.fr.base.BaseUtils;
import com.fr.design.beans.location.MoveUtils;
import com.fr.design.designer.beans.AdapterBus;
@ -29,6 +20,11 @@ import com.fr.design.utils.gui.LayoutUtils;
import com.fr.general.Inter;
import com.fr.stable.Constants;
import javax.swing.*;
import javax.swing.event.MouseInputAdapter;
import java.awt.*;
import java.awt.event.MouseEvent;
/**
* 普通模式下的鼠标点击位置处理器
*/
@ -291,18 +287,28 @@ public class EditingMouseListener extends MouseInputAdapter {
if (component.isReport()) {
xElementCase = (XElementCase)component;
UIButton button = (UIButton)xElementCase.getCoverPane().getComponent(0);
UIButton button = (UIButton)xElementCase.getCoverPane().getComponent(0);
JComponent button1= (JComponent) xElementCase.getCoverPane().getComponent(1);
if(designer.getCursor().getType() ==Cursor.HAND_CURSOR) {
designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
} // component.getParent() 是报表块所在的XWTitleLayout
int minX = button.getX() + getParentPositionX(component, 0) - designer.getArea().getHorizontalValue();
int minX1 = button1.getX() + getParentPositionX(component, 0) - designer.getArea().getHorizontalValue();
int minY = button.getY() + getParentPositionY(component, 0) - designer.getArea().getVerticalValue();
if(e.getX() + GAP > minX && e.getX() - GAP < minX + button.getWidth()){
if( e.getY() + GAP > minY && e.getY() - GAP < minY + button.getHeight()){
designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
}
xElementCase.displayCoverPane(true);
int minY1 = button1.getY() + getParentPositionY(component, 0) - designer.getArea().getVerticalValue();
if (e.getX() + GAP - xElementCase.getInsets().left > minX && e.getX() - GAP - xElementCase.getInsets().left < minX + button.getWidth()) {
if (e.getY() + GAP - xElementCase.getInsets().top > minY && e.getY() - GAP - xElementCase.getInsets().top < minY + button.getHeight()) {
designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
}
xElementCase.setHelpBtnOnFocus(false);
if (e.getX() + GAP - xElementCase.getInsets().left > minX1 && e.getX() - GAP - xElementCase.getInsets().left < minX1 + button1.getWidth()) {
if (e.getY() + GAP - xElementCase.getInsets().top > minY1 && e.getY() - GAP - xElementCase.getInsets().top < minY1 + button1.getHeight()) {
designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
xElementCase.setHelpBtnOnFocus(true);
}
}
xElementCase.displayCoverPane(true);
xElementCase.setDirections(Direction.TOP_BOTTOM_LEFT_RIGHT);
designer.repaint();

73
designer_form/src/com/fr/design/mainframe/ElementCaseHelpDialog.java

@ -0,0 +1,73 @@
package com.fr.design.mainframe;
import com.fr.design.dialog.UIDialog;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.itextarea.UITextArea;
import javax.swing.*;
import java.awt.*;
/**
* @author zack
* @date 2016-10-14
* @since 8.0
*/
public class ElementCaseHelpDialog extends UIDialog {
private static final int OUTER_WIDTH = 190;
private static final int OUTER_HEIGHT = 120;
private String helpMsg;
private UIScrollPane helpArea;
public ElementCaseHelpDialog(Frame parent, String helpMsg) {
super(parent);
this.helpMsg = helpMsg;
setUndecorated(true);
initHelpArea();
JPanel panel = (JPanel) getContentPane();
initComponents(panel);
setSize(new Dimension(OUTER_WIDTH, OUTER_HEIGHT));
}
private void initHelpArea() {
UITextArea textArea = new UITextArea(helpMsg);
textArea.setEditable(false);
textArea.setBorder(null);
helpArea = new UIScrollPane(textArea);
helpArea.setBounds(0, 0, 190, 120);
helpArea.setBorder(null);
}
private void initComponents(JPanel contentPane) {
contentPane.setLayout(new BorderLayout());
add(helpArea, BorderLayout.CENTER);
}
/**
* 打开帮助框
*/
public void showWindow() {
setVisible(true);
this.setResizable(false);
}
/**
*
*/
@Override
public void checkValid() throws Exception {
}
public void setLocationRelativeTo(JFrame c, int x, int y) {
int dx = 0, dy = 0;
Point compLocation = c.getLocationOnScreen();//获取设计器Jframe坐标作为相对位置原点
setLocation(dx + x, dy + y);
dx = compLocation.x;
dy = compLocation.y + c.getRootPane().getY();//加上底层容器的y坐标(其实就是设计器最上方图标栏的高度)
setLocation(dx + x, dy + y);
}
}

343
designer_form/src/com/fr/design/mainframe/FormCreatorDropTarget.java

@ -1,20 +1,8 @@
package com.fr.design.mainframe;
import java.awt.Color;
import java.awt.Component;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDragEvent;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.dnd.DropTargetEvent;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JWindow;
import com.fr.base.BaseUtils;
import com.fr.design.DesignModelAdapter;
import com.fr.design.data.datapane.TableDataTreePane;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.HoverPainter;
import com.fr.design.designer.beans.Painter;
@ -25,177 +13,195 @@ import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.icon.IconPathConstants;
import com.fr.design.utils.ComponentUtils;
import com.fr.form.share.ShareLoader;
import com.fr.form.ui.ElCaseBindInfo;
import com.fr.form.ui.SharableElementCaseEditor;
import com.fr.form.ui.Widget;
import com.fr.general.Inter;
import com.fr.stable.Constants;
import javax.swing.*;
import java.awt.*;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDragEvent;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.dnd.DropTargetEvent;
/**
* 添加模式下鼠标事件处理器
*/
public class FormCreatorDropTarget extends DropTarget {
private FormDesigner designer;
/**
* 当前鼠标的设计组件
*/
private Component current;
/**
* 当前添加模式对应的model
*/
private AddingModel addingModel;
private FormDesigner designer;
/**
* 当前鼠标的设计组件
*/
private Component current;
/**
* 当前添加模式对应的model
*/
private AddingModel addingModel;
private final static int GAP = 30;
private JWindow promptWindow = new JWindow();
private UIButton promptButton = new UIButton("", BaseUtils.readIcon(IconPathConstants.FORBID_ICON_PATH));
public FormCreatorDropTarget(FormDesigner designer) {
this.designer = designer;
this.addingModel = designer.getAddingModel();
public FormCreatorDropTarget(FormDesigner designer) {
this.designer = designer;
this.addingModel = designer.getAddingModel();
this.promptWindow.add(promptButton);
}
}
private void adding(int x, int y) {
// 当前鼠标所在的组件
XCreator hoveredComponent = designer.getComponentAt(x, y);
private void adding(int x, int y) {
// 当前鼠标所在的组件
XCreator hoveredComponent = designer.getComponentAt(x, y);
// 获取该组件所在的焦点容器
XLayoutContainer container = XCreatorUtils.getHotspotContainer(hoveredComponent);
// 获取该组件所在的焦点容器
XLayoutContainer container = XCreatorUtils.getHotspotContainer(hoveredComponent);
//cardTagLayout里用到
container.stopAddingState(designer);
//cardTagLayout里用到
container.stopAddingState(designer);
boolean success = false;
boolean success = false;
if (container != null) {
// 如果是容器,则调用其acceptComponent接受组件
AddingModel model = designer.getAddingModel();
if (container != null) {
// 如果是容器,则调用其acceptComponent接受组件
AddingModel model = designer.getAddingModel();
boolean chartEnter2Para =!addingModel.getXCreator().canEnterIntoParaPane() && container.acceptType(XWParameterLayout.class);
boolean chartEnter2Para = !addingModel.getXCreator().canEnterIntoParaPane() && container.acceptType(XWParameterLayout.class);
boolean formSubmit2Adapt = !addingModel.getXCreator().canEnterIntoAdaptPane() && container.acceptType(XWFitLayout.class);
if (model != null && !chartEnter2Para && !formSubmit2Adapt) {
success = model.add2Container(designer, container, x, y);
}
if (model != null && !chartEnter2Para && !formSubmit2Adapt) {
success = model.add2Container(designer, container, x, y);
}
cancelPromptWidgetForbidEnter();
}
}
if (success) {
// 如果添加成功,则触发相应事件
if (success) {
// 如果添加成功,则触发相应事件
XCreator xCreator = container.acceptType(XWParameterLayout.class) ? designer.getParaComponent() : designer.getRootComponent();
//SetSelection时要确保选中的是最顶层的布局
//tab布局添加的时候是初始化了XWCardLayout,实际上最顶层的布局是XWCardMainBorderLayout
XCreator addingXCreator = addingModel.getXCreator();
Widget widget = (addingXCreator.getTopLayout() != null) ? (addingXCreator.getTopLayout().toData()) : addingXCreator.toData();
designer.getSelectionModel().setSelectedCreators(
FormSelectionUtils.rebuildSelection(xCreator, new Widget[]{widget}));
designer.getEditListenerTable().fireCreatorModified(addingModel.getXCreator(), DesignerEvent.CREATOR_ADDED);
} else {
Toolkit.getDefaultToolkit().beep();
}
// 取消提示
designer.setPainter(null);
// 切换添加状态到普通状态
designer.stopAddingState();
}
private void entering(int x, int y) {
// 将要添加的组件图标移动到鼠标下的位置
addingModel.moveTo(x, y);
designer.repaint();
}
private void exiting() {
//SetSelection时要确保选中的是最顶层的布局
//tab布局添加的时候是初始化了XWCardLayout,实际上最顶层的布局是XWCardMainBorderLayout
XCreator addingXCreator = addingModel.getXCreator();
if (addingXCreator.isShared()) {
String shareId = addingXCreator.getShareId();
SharableElementCaseEditor sharableEditor = ShareLoader.getLoader().getSharedElCaseEditorById(shareId);
ElCaseBindInfo bindInfo = ShareLoader.getLoader().getElCaseBindInfoById(shareId);
if (sharableEditor != null && bindInfo != null) {
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).addTableData(bindInfo.getName(),sharableEditor.getTableDataSource());
}
}
Widget widget = (addingXCreator.getTopLayout() != null) ? (addingXCreator.getTopLayout().toData()) : addingXCreator.toData();
designer.getSelectionModel().setSelectedCreators(
FormSelectionUtils.rebuildSelection(xCreator, new Widget[]{widget}));
designer.getEditListenerTable().fireCreatorModified(addingModel.getXCreator(), DesignerEvent.CREATOR_ADDED);
} else {
Toolkit.getDefaultToolkit().beep();
}
// 取消提示
designer.setPainter(null);
// 切换添加状态到普通状态
designer.stopAddingState();
}
private void entering(int x, int y) {
// 将要添加的组件图标移动到鼠标下的位置
addingModel.moveTo(x, y);
designer.repaint();
}
private void exiting() {
cancelPromptWidgetForbidEnter();
// 隐藏组件图标
addingModel.reset();
designer.setPainter(null);
designer.repaint();
}
private void hovering(int x, int y) {
// 当前位置移植鼠标e所在的位置
addingModel.moveTo(x, y);
// 获取e所在的焦点组件
XCreator hotspot = designer.getComponentAt(x, y);
// 获取焦点组件所在的焦点容器
XLayoutContainer container = XCreatorUtils.getHotspotContainer(hotspot);
// 隐藏组件图标
addingModel.reset();
designer.setPainter(null);
designer.repaint();
}
private void hovering(int x, int y) {
// 当前位置移植鼠标e所在的位置
addingModel.moveTo(x, y);
// 获取e所在的焦点组件
XCreator hotspot = designer.getComponentAt(x, y);
// 获取焦点组件所在的焦点容器
XLayoutContainer container = XCreatorUtils.getHotspotContainer(hotspot);
//提示组件是否可以拖入
promptUser(x, y, container);
if (container != null) {
HoverPainter painter = null;
if (container != current || designer.getPainter() == null) {
// 如果焦点容器不是当前容器
if (current != null) {
// 取消前一个焦点容器的提示渲染器
designer.setPainter(null);
}
//获取painter的时候要考虑布局之间嵌套的问题
XLayoutContainer xLayoutContainer = container.getTopLayout();
if (xLayoutContainer != null && xLayoutContainer.getParent() != null
&& ((XLayoutContainer)xLayoutContainer.getParent()).acceptType(XWAbsoluteLayout.class)){
if(!xLayoutContainer.isEditable()){
xLayoutContainer = (XLayoutContainer)xLayoutContainer.getParent();
}
}
painter = AdapterBus.getContainerPainter(designer,
xLayoutContainer != null && xLayoutContainer.acceptType(XWAbsoluteLayout.class) ? xLayoutContainer : container);
// 为界面设计器设置提示渲染提示器
designer.setPainter(painter);
// 将当前容器更新为新的容器
current = container;
} else {
// 获取当前设计界面的提示渲染器
Painter p = designer.getPainter();
if (p instanceof HoverPainter) {
painter = (HoverPainter) p;
}
}
if (painter != null) {
// 为提示渲染器设置焦点位置、区域等渲染参数
Rectangle rect = ComponentUtils.getRelativeBounds(container);
rect.x -= designer.getArea().getHorizontalValue();
rect.y -= designer.getArea().getVerticalValue();
painter.setRenderingBounds(rect);
painter.setHotspot(new Point(x, y));
painter.setCreator(addingModel.getXCreator());
}
} else {
// 如果鼠标不在任何组件上,则取消提示器
designer.setPainter(null);
current = null;
}
designer.repaint();
}
private void promptUser(int x, int y, XLayoutContainer container){
if (!addingModel.getXCreator().canEnterIntoParaPane() && container.acceptType(XWParameterLayout.class)){
if (container != null) {
HoverPainter painter = null;
if (container != current || designer.getPainter() == null) {
// 如果焦点容器不是当前容器
if (current != null) {
// 取消前一个焦点容器的提示渲染器
designer.setPainter(null);
}
//获取painter的时候要考虑布局之间嵌套的问题
XLayoutContainer xLayoutContainer = container.getTopLayout();
if (xLayoutContainer != null && xLayoutContainer.getParent() != null
&& ((XLayoutContainer) xLayoutContainer.getParent()).acceptType(XWAbsoluteLayout.class)) {
if (!xLayoutContainer.isEditable()) {
xLayoutContainer = (XLayoutContainer) xLayoutContainer.getParent();
}
}
painter = AdapterBus.getContainerPainter(designer,
xLayoutContainer != null && xLayoutContainer.acceptType(XWAbsoluteLayout.class) ? xLayoutContainer : container);
// 为界面设计器设置提示渲染提示器
designer.setPainter(painter);
// 将当前容器更新为新的容器
current = container;
} else {
// 获取当前设计界面的提示渲染器
Painter p = designer.getPainter();
if (p instanceof HoverPainter) {
painter = (HoverPainter) p;
}
}
if (painter != null) {
// 为提示渲染器设置焦点位置、区域等渲染参数
Rectangle rect = ComponentUtils.getRelativeBounds(container);
rect.x -= designer.getArea().getHorizontalValue();
rect.y -= designer.getArea().getVerticalValue();
painter.setRenderingBounds(rect);
painter.setHotspot(new Point(x, y));
painter.setCreator(addingModel.getXCreator());
}
} else {
// 如果鼠标不在任何组件上,则取消提示器
designer.setPainter(null);
current = null;
}
designer.repaint();
}
private void promptUser(int x, int y, XLayoutContainer container) {
if (!addingModel.getXCreator().canEnterIntoParaPane() && container.acceptType(XWParameterLayout.class)) {
promptButton.setText(Inter.getLocText("FR-Designer_Forbid_Drag_into_Para_Pane"));
promptWidgetForbidEnter(x ,y ,container);
} else if (!addingModel.getXCreator().canEnterIntoAdaptPane() && container.acceptType(XWFitLayout.class)){
promptWidgetForbidEnter(x, y, container);
} else if (!addingModel.getXCreator().canEnterIntoAdaptPane() && container.acceptType(XWFitLayout.class)) {
promptButton.setText(Inter.getLocText("FR-Designer_Forbid_Drag_into_Adapt_Pane"));
promptWidgetForbidEnter(x ,y , container);
promptWidgetForbidEnter(x, y, container);
} else {
cancelPromptWidgetForbidEnter();
}
}
private void promptWidgetForbidEnter(int x,int y, XLayoutContainer container){
private void promptWidgetForbidEnter(int x, int y, XLayoutContainer container) {
container.setBorder(BorderFactory.createLineBorder(Color.RED, Constants.LINE_MEDIUM));
int screen_X = (int)designer.getArea().getLocationOnScreen().getX();
int screen_Y = (int)designer.getArea().getLocationOnScreen().getY();
int screen_X = (int) designer.getArea().getLocationOnScreen().getX();
int screen_Y = (int) designer.getArea().getLocationOnScreen().getY();
this.promptWindow.setSize(promptWindow.getPreferredSize());
this.promptWindow.setPreferredSize(promptWindow.getPreferredSize());
promptWindow.setLocation( screen_X + x + GAP ,screen_Y + y + GAP);
promptWindow.setLocation(screen_X + x + GAP, screen_Y + y + GAP);
promptWindow.setVisible(true);
}
private void cancelPromptWidgetForbidEnter(){
if (designer.getParaComponent() != null){
private void cancelPromptWidgetForbidEnter() {
if (designer.getParaComponent() != null) {
designer.getParaComponent().setBorder(BorderFactory.createLineBorder(XCreatorConstants.LAYOUT_SEP_COLOR, Constants.LINE_THIN));
}
designer.getRootComponent().setBorder(BorderFactory.createLineBorder(XCreatorConstants.LAYOUT_SEP_COLOR, Constants.LINE_THIN));
@ -204,45 +210,50 @@ public class FormCreatorDropTarget extends DropTarget {
/**
* 拖拽进入
* @param dtde 事件
*
* @param dtde 事件
*/
public void dragEnter(DropTargetDragEvent dtde) {
Point loc = dtde.getLocation();
this.entering(loc.x, loc.y);
}
public void dragEnter(DropTargetDragEvent dtde) {
Point loc = dtde.getLocation();
this.entering(loc.x, loc.y);
}
/**
* 拖拽移动经过
* @param dtde 事件
*
* @param dtde 事件
*/
public void dragOver(DropTargetDragEvent dtde) {
Point loc = dtde.getLocation();
hovering(loc.x, loc.y);
}
public void dragOver(DropTargetDragEvent dtde) {
Point loc = dtde.getLocation();
hovering(loc.x, loc.y);
}
/**
* 拖拽事件
* @param dtde 事件
*
* @param dtde 事件
*/
public void dropActionChanged(DropTargetDragEvent dtde) {
}
public void dropActionChanged(DropTargetDragEvent dtde) {
}
/**
* 拖拽离开
* @param dte 事件
*
* @param dte 事件
*/
public void dragExit(DropTargetEvent dte) {
this.exiting();
}
public void dragExit(DropTargetEvent dte) {
this.exiting();
}
/**
* 拖拽释放
* @param dtde 事件
*
* @param dtde 事件
*/
public void drop(DropTargetDropEvent dtde) {
Point loc = dtde.getLocation();
this.adding(loc.x, loc.y);
public void drop(DropTargetDropEvent dtde) {
Point loc = dtde.getLocation();
this.adding(loc.x, loc.y);
//针对在表单中拖入一个控件直接ctrl+s无反应
designer.requestFocus();
}
}
}

14
designer_form/src/com/fr/design/mainframe/FormHierarchyTreePane.java

@ -5,7 +5,8 @@ import java.awt.event.ActionEvent;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWAbsoluteBodyLayout;
import com.fr.design.actions.community.NeedAction;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.mainframe.widget.UITreeComboBox;
@ -171,10 +172,17 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree
*/
private void adjustPosition(ComponentTreeModel treeModel,FormDesigner formDesigner){
XCreator root = (XCreator)treeModel.getRoot();
if(treeModel.getChild(root,PARA) instanceof XWParameterLayout){
XCreator firstChild = (XCreator)treeModel.getChild(root,PARA);
if(firstChild.acceptType(XWParameterLayout.class)){
return;
}
root.add((Component)(treeModel.getChild(root,PARA)),BODY);
// 绝对布局作为body的时候
// 获取第一个子节点的方法中屏蔽了fit
// 这边另外处理一下
else if (firstChild.acceptType(XWAbsoluteBodyLayout.class) && firstChild.getBackupParent() != null) {
firstChild = firstChild.getBackupParent();
}
root.add(firstChild,BODY);
treeModel.setRoot(root);
componentTree = new ComponentTree(formDesigner,treeModel);
}

20
designer_form/src/com/fr/design/mainframe/JForm.java

@ -9,9 +9,7 @@ import com.fr.design.constants.UIConstants;
import com.fr.design.designer.beans.actions.FormDeleteAction;
import com.fr.design.designer.beans.events.DesignerEditListener;
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.*;
import com.fr.design.designer.properties.FormWidgetAuthorityEditPane;
import com.fr.design.event.TargetModifiedEvent;
import com.fr.design.event.TargetModifiedListener;
@ -436,6 +434,18 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
return !inECUndoForm && this.getUndoManager().canUndo();
}
// 返回当前的body,
// 假如当前body是自适应的话就沿用,
// 假如当前body是绝对布局的话就返回绝对布局body
private XLayoutContainer selectedBodyLayout() {
XLayoutContainer rootLayout = formDesign.getRootComponent();
for (int i = 0; i < rootLayout.getComponentCount(); i++){
if (rootLayout.getXCreator(i).acceptType(XWAbsoluteBodyLayout.class)){
rootLayout = (XWAbsoluteBodyLayout)rootLayout.getXCreator(i);
}
}
return rootLayout;
}
@Override
/**
* 应用undoState的表单数据
@ -447,7 +457,9 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
if (this.index == FORM_TAB) {
JForm.this.refreshRoot();
this.formDesign.getArea().setAreaSize(u.getAreaSize(), u.getHorizontalValue(), u.getVerticalValue(), u.getWidthValue(), u.getHeightValue(), u.getSlideValue());
this.formDesign.getSelectionModel().setSelectedCreators(FormSelectionUtils.rebuildSelection(formDesign.getRootComponent(), u.getSelectWidgets()));
//撤销的时候要重新选择的body布局
this.formDesign.getSelectionModel().setSelectedCreators(FormSelectionUtils.rebuildSelection(formDesign.getRootComponent(),
formDesign.getRootComponent() == selectedBodyLayout() ? u.getSelectWidgets() : new Widget[]{selectedBodyLayout().toData()}));
} else {
String widgetName = this.formDesign.getElementCaseContainerName();
//这儿太坑了,u.getForm() 与 getTarget内容不一样

Loading…
Cancel
Save