Browse Source

Merge branch 'release' of http://www.finedevelop.com:2015/scm/~zhouping/design into release

master
zhouping 8 years ago
parent
commit
5c1674ce9e
  1. 1
      .gitignore
  2. 1
      designer/src/com/fr/design/mainframe/templateinfo/JWorkBookProcessInfo.java
  3. 6
      designer_base/src/com/fr/design/locale/designer.properties
  4. 6
      designer_base/src/com/fr/design/locale/designer_en_US.properties
  5. 34
      designer_base/src/com/fr/design/locale/designer_ja_JP.properties
  6. 4
      designer_base/src/com/fr/design/locale/designer_ko_KR.properties
  7. 6
      designer_base/src/com/fr/design/locale/designer_zh_CN.properties
  8. 29
      designer_base/src/com/fr/design/locale/designer_zh_TW.properties
  9. 12
      designer_base/src/com/fr/design/mainframe/JTemplate.java
  10. 43
      designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java
  11. 18
      designer_chart/src/com/fr/design/chart/axis/MinMaxValuePane.java
  12. 13
      designer_chart/src/com/fr/design/mainframe/chart/gui/style/axis/ChartValuePane.java
  13. 11
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java
  14. 26
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRBodyLayoutAdapter.java
  15. 2
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java
  16. 11
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRTabFitLayoutAdapter.java
  17. 36
      designer_form/src/com/fr/design/designer/beans/models/AddingModel.java
  18. 46
      designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java
  19. 106
      designer_form/src/com/fr/design/designer/beans/models/StateModel.java
  20. 3
      designer_form/src/com/fr/design/designer/beans/painters/AbstractPainter.java
  21. 31
      designer_form/src/com/fr/design/designer/creator/XLayoutContainer.java
  22. 12
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java
  23. 17
      designer_form/src/com/fr/design/mainframe/FormCreatorDropTarget.java
  24. 6
      designer_form/src/com/fr/design/mainframe/FormDesigner.java
  25. 12
      designer_form/src/com/fr/design/mainframe/FormSelection.java
  26. 73
      designer_form/src/com/fr/design/mainframe/FormSelectionUtils.java
  27. 0
      designer_form/src/com/fr/design/mainframe/templateinfo/JFormProcessInfo.java

1
.gitignore vendored

@ -3,5 +3,6 @@ designer_base/bin
designer_chart/bin designer_chart/bin
designer_form/bin designer_form/bin
*.iml *.iml
designer_base/src/com/fr/design/locale/.idea

1
designer_base/src/com/fr/design/mainframe/templateinfo/JWorkBookProcessInfo.java → designer/src/com/fr/design/mainframe/templateinfo/JWorkBookProcessInfo.java

@ -1,6 +1,5 @@
package com.fr.design.mainframe.templateinfo; package com.fr.design.mainframe.templateinfo;
import com.fr.base.io.IOFile;
import com.fr.base.parameter.ParameterUI; import com.fr.base.parameter.ParameterUI;
import com.fr.main.impl.WorkBook; import com.fr.main.impl.WorkBook;
import com.fr.report.cellcase.CellCase; import com.fr.report.cellcase.CellCase;

6
designer_base/src/com/fr/design/locale/designer.properties

@ -585,3 +585,9 @@ FR-Designer-Move_Tab_First=move to first
FR-Designer-Move_Tab_End=move to end FR-Designer-Move_Tab_End=move to end
FR-Designer-Move_Tab_Next=move to next FR-Designer-Move_Tab_Next=move to next
FR-Designer-Move_Tab_Prev=move to previous FR-Designer-Move_Tab_Prev=move to previous
FR-Designer_AxisReversed=AxisValue
FR-Designer_Logarithmic=Logarithmic
FR-Designer_Chart_Log_Base=Log Base
FR-Designer_Chart_F_Radar_Axis=Chart_F_Radar_Axis
FR-Designer_Too_Large_To_Paste=too large to paste
FR-Designer_Too_Small_To_Paste=Too small to paste

6
designer_base/src/com/fr/design/locale/designer_en_US.properties

@ -586,3 +586,9 @@ FR-Designer-Move_Tab_First=move to first
FR-Designer-Move_Tab_End=move to end FR-Designer-Move_Tab_End=move to end
FR-Designer-Move_Tab_Next=move to next FR-Designer-Move_Tab_Next=move to next
FR-Designer-Move_Tab_Prev=move to previous FR-Designer-Move_Tab_Prev=move to previous
FR-Designer_AxisReversed=Axis in reverse order
FR-Designer_Logarithmic=Log scale
FR-Designer_Chart_Log_Base=Log Base
FR-Designer_Chart_F_Radar_Axis=Value Axis
FR-Designer_Too_Large_To_Paste=Too large to paste!
FR-Designer_Too_Small_To_Paste=Too small to paste!

34
designer_base/src/com/fr/design/locale/designer_ja_JP.properties

@ -541,18 +541,22 @@ FR-Designer_No=\u3044\u3044\u3048
FR-Designer_Pagination=\u30DA\u30FC\u30B8\u30F3\u30B0 FR-Designer_Pagination=\u30DA\u30FC\u30B8\u30F3\u30B0
FR-Designer_DS_TableData=\u30C7\u30FC\u30BF\u30BD\u30FC\u30B9 FR-Designer_DS_TableData=\u30C7\u30FC\u30BF\u30BD\u30FC\u30B9
FR-Designer_Parameter-Formula=\u6570\u5F0F FR-Designer_Parameter-Formula=\u6570\u5F0F
FR-Designer_Background_Null= FR-Designer_Background_Null=\u80CC\u666F\u306A\u3057
FR-Designer_Background_Color= FR-Designer_Background_Color=\u8272
FR-Designer_Background_Texture= FR-Designer_Background_Texture=\u67C4
FR-Designer_Background_Pattern= FR-Designer_Background_Pattern=\u6A21\u69D8
FR-Designer_Background_Gradient_Color= FR-Designer_Background_Gradient_Color=\u30B0\u30E9\u30C7\u30FC\u30B7\u30E7\u30F3\u8272
FR-Designer_Background_Image= FR-Designer_Background_Image=\u5199\u771F
FR-Designer_Background_Clear= FR-Designer_Background_Clear=\u30AF\u30EA\u30A2
FR-Designer_Background_Image_Select= FR-Designer_Background_Image_Select=\u5199\u771F\u3092\u9078\u629E
FR-Designer_Initial_Background_Tips= FR-Designer_Initial_Background_Tips=\u30DC\u30BF\u30F3\u306E\u521D\u671F\u80CC\u666F
FR-Designer_Mouse_Move_Tips= FR-Designer_Mouse_Move_Tips=\u30DE\u30A6\u30B9\u304C\u30DC\u30BF\u30F3\u306B\u79FB\u3059\u6642\u306E\u80CC\u666F
FR-Designer_Mouse_Click_Tips= FR-Designer_Mouse_Click_Tips=\u30DE\u30A6\u30B9\u304C\u30DC\u30BF\u30F3\u306B\u79FB\u3059\u6642\u306E\u80CC\u666F
FR-Designer-Move_Tab_First= FR-Designer-Move_Tab_First=\u30C8\u30C3\u30D7\u306B\u79FB\u3059
FR-Designer-Move_Tab_End= FR-Designer-Move_Tab_End=\u6700\u5F8C\u306B\u79FB\u3059
FR-Designer-Move_Tab_Next= FR-Designer-Move_Tab_Next=\u5F8C\u308D\u306B\u79FB\u3059
FR-Designer-Move_Tab_Prev= FR-Designer-Move_Tab_Prev=\u524D\u306B\u79FB\u3059
FR-Designer_AxisReversed=\u8EF8\u9006\u914D\u5217
FR-Designer_Logarithmic=\u5BFE\u6570\u76EE\u76DB\u308A
FR-Designer_Chart_Log_Base=\u5E95\u6570
FR-Designer_Chart_F_Radar_Axis=\u5782\u76F4\u8EF8

4
designer_base/src/com/fr/design/locale/designer_ko_KR.properties

@ -553,3 +553,7 @@ FR-Designer-Move_Tab_First=
FR-Designer-Move_Tab_End= FR-Designer-Move_Tab_End=
FR-Designer-Move_Tab_Next= FR-Designer-Move_Tab_Next=
FR-Designer-Move_Tab_Prev= FR-Designer-Move_Tab_Prev=
FR-Designer_AxisReversed=\uCD95\uC5ED\uC21C
FR-Designer_Logarithmic=\uB85C\uADF8\uB208\uAE08
FR-Designer_Chart_Log_Base=\uAE30\uC218
FR-Designer_Chart_F_Radar_Axis=\uAC12\uCD95

6
designer_base/src/com/fr/design/locale/designer_zh_CN.properties

@ -590,3 +590,9 @@ FR-Designer-Move_Tab_First=\u79FB\u52A8\u5230\u9996\u4F4D
FR-Designer-Move_Tab_End=\u79FB\u52A8\u5230\u672B\u5C3E FR-Designer-Move_Tab_End=\u79FB\u52A8\u5230\u672B\u5C3E
FR-Designer-Move_Tab_Next=\u5F80\u540E\u79FB\u52A8 FR-Designer-Move_Tab_Next=\u5F80\u540E\u79FB\u52A8
FR-Designer-Move_Tab_Prev=\u5F80\u524D\u79FB\u52A8 FR-Designer-Move_Tab_Prev=\u5F80\u524D\u79FB\u52A8
FR-Designer_AxisReversed=\u8F74\u9006\u5E8F
FR-Designer_Logarithmic=\u5BF9\u6570\u523B\u5EA6
FR-Designer_Chart_Log_Base=\u5E95\u6570
FR-Designer_Chart_F_Radar_Axis=\u503C\u8F74
FR-Designer_Too_Large_To_Paste=\u7EC4\u4EF6\u5927\u5C0F\u8D85\u51FA\u8FB9\u754C\uFF0C\u65E0\u6CD5\u7C98\u8D34\uFF01
FR-Designer_Too_Small_To_Paste=\u6B64\u5904\u65E0\u6CD5\u7C98\u8D34\uFF0C\u5C0F\u4E8E\u7EC4\u4EF6\u6700\u5C0F\u9AD8\u5EA6\uFF01

29
designer_base/src/com/fr/design/locale/designer_zh_TW.properties

@ -563,18 +563,25 @@ FR-Designer_Plugin_Should_Update_Please_Contact_Developer=\u63D2\u4EF6\u7248\u67
FR-Designer_WidgetOrder=\u63A7\u4EF6\u9806\u5E8F FR-Designer_WidgetOrder=\u63A7\u4EF6\u9806\u5E8F
FR-Designer_Mobile_Form_Analysis_Annotation=\u6CE8\u91CB\uFF1A\u53EF\u4EE5\u901A\u904E\u8A72\u5C6C\u6027\u63A7\u5236\u8868\u55AE\u5728APP\u4E2D\u7684\u89E3\u6790\u65B9\u5F0F\u3002 FR-Designer_Mobile_Form_Analysis_Annotation=\u6CE8\u91CB\uFF1A\u53EF\u4EE5\u901A\u904E\u8A72\u5C6C\u6027\u63A7\u5236\u8868\u55AE\u5728APP\u4E2D\u7684\u89E3\u6790\u65B9\u5F0F\u3002
FR-Designer_Mobile_Report_Analysis_Annotation=\u6CE8\u91CB\uFF1A\u53EF\u4EE5\u901A\u904E\u8A72\u5C6C\u6027\u63A7\u5236\u5831\u8868\u5728APP\u4E2D\u7684\u89E3\u6790\u65B9\u5F0F\uFF0C\u53EA\u652F\u6301\u5206\u9801\u9810\u89BD\uFF0C\u586B\u5831\u9810\u89BD\u6642\u5C6C\u6027\u7121\u6548\u3002 FR-Designer_Mobile_Report_Analysis_Annotation=\u6CE8\u91CB\uFF1A\u53EF\u4EE5\u901A\u904E\u8A72\u5C6C\u6027\u63A7\u5236\u5831\u8868\u5728APP\u4E2D\u7684\u89E3\u6790\u65B9\u5F0F\uFF0C\u53EA\u652F\u6301\u5206\u9801\u9810\u89BD\uFF0C\u586B\u5831\u9810\u89BD\u6642\u5C6C\u6027\u7121\u6548\u3002
FR-Designer_Background_Null=
FR-Designer_Background_Color= FR-Designer_Background_Null=\u6C92\u6709\u80CC\u666F
FR-Designer_Background_Texture= FR-Designer_Background_Color=\u984F\u8272
FR-Designer_Background_Pattern= FR-Designer_Background_Texture=\u7D0B\u7406
FR-Designer_Background_Gradient_Color= FR-Designer_Background_Pattern=\u5716\u6848
FR-Designer_Background_Image= FR-Designer_Background_Gradient_Color=\u6F38\u8B8A\u8272
FR-Designer_Background_Clear= FR-Designer_Background_Image=\u5716\u7247
FR-Designer_Background_Image_Select= FR-Designer_Background_Clear=\u6E05\u9664
FR-Designer_Initial_Background_Tips= FR-Designer_Background_Image_Select=\u9078\u64C7\u5716\u7247
FR-Designer_Mouse_Move_Tips= FR-Designer_Initial_Background_Tips=\u6309\u9215\u7684\u521D\u59CB\u80CC\u666F
FR-Designer_Mouse_Click_Tips= FR-Designer_Mouse_Move_Tips=\u6ED1\u9F20\u79FB\u52D5\u5230\u6309\u9215\u4E0A\u7684\u80CC\u666F\uFF0C\u82E5\u7121\u5247\u4E0D\u6539\u8B8A\u80CC\u666F
FR-Designer_Mouse_Click_Tips=\u6ED1\u9F20\u9EDE\u64CA\u6309\u9215\u6642\u80CC\u666F\uFF0C\u82E5\u7121\u5247\u4E0D\u6539\u8B8A\u80CC\u666F
FR-Designer-Move_Tab_First=\u79FB\u52D5\u5230\u9996\u4F4D FR-Designer-Move_Tab_First=\u79FB\u52D5\u5230\u9996\u4F4D
FR-Designer-Move_Tab_End=\u79FB\u52D5\u5230\u672B\u5C3E FR-Designer-Move_Tab_End=\u79FB\u52D5\u5230\u672B\u5C3E
FR-Designer-Move_Tab_Next=\u5F80\u5F8C\u79FB\u52D5 FR-Designer-Move_Tab_Next=\u5F80\u5F8C\u79FB\u52D5
FR-Designer-Move_Tab_Prev=\u5F80\u524D\u79FB\u52D5 FR-Designer-Move_Tab_Prev=\u5F80\u524D\u79FB\u52D5
FR-Designer_AxisReversed=\u8EF8\u9006\u5E8F
FR-Designer_Logarithmic=\u5C0D\u6578\u523B\u5EA6
FR-Designer_Chart_Log_Base=\u5E95\u6578
FR-Designer_Chart_F_Radar_Axis=\u503C\u8EF8
FR-Designer_Too_Large_To_Paste=\u7D44\u4EF6\u5927\u5C0F\u8D85\u51FA\u908A\u754C\uFF0C\u7121\u6CD5\u7C98\u8CBC\uFF01
FR-Designer_Too_Small_To_Paste=\u6B64\u8655\u7121\u6CD5\u7C98\u8CBC\uFF0C\u5C0F\u65BC\u7D44\u4EF6\u6700\u5C0F\u9AD8\u5EA6\uFF01

12
designer_base/src/com/fr/design/mainframe/JTemplate.java

@ -85,7 +85,7 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
public JTemplate(T t, String defaultFileName) { public JTemplate(T t, String defaultFileName) {
this(t, new MemFILE(newTemplateNameByIndex(defaultFileName)), true); this(t, new MemFILE(newTemplateNameByIndex(defaultFileName)), true);
initForCollect(); openTime = System.currentTimeMillis();
} }
public JTemplate(T t, FILE file) { public JTemplate(T t, FILE file) {
@ -111,14 +111,15 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
// 为收集模版信息作准备 // 为收集模版信息作准备
private void initForCollect() { private void initForCollect() {
if (template.getTemplateID() == null) {
template.initTemplateID(); // 为新模板设置 templateID 属性 template.initTemplateID(); // 为新模板设置 templateID 属性
}
if (openTime == 0) { if (openTime == 0) {
openTime = System.currentTimeMillis(); openTime = System.currentTimeMillis();
} }
} }
private void collectInfo() { // 执行收集操作 private void collectInfo() { // 执行收集操作
if (openTime == 0) { // 旧模板,不收集数据
return;
}
long saveTime = System.currentTimeMillis(); // 保存模板的时间点 long saveTime = System.currentTimeMillis(); // 保存模板的时间点
tic.collectInfo(template, this, openTime, saveTime); tic.collectInfo(template, this, openTime, saveTime);
openTime = saveTime; // 更新 openTime,准备下一次计算 openTime = saveTime; // 更新 openTime,准备下一次计算
@ -528,12 +529,13 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
} }
protected boolean saveNewFile(FILE editingFILE, String oldName){ protected boolean saveNewFile(FILE editingFILE, String oldName){
this.editingFILE = editingFILE; // 在保存之前,初始化 templateID
initForCollect(); // 如果保存新模板(新建模板直接保存,或者另存为),则添加 templateID
this.editingFILE = editingFILE;
boolean result = this.saveFile(); boolean result = this.saveFile();
if (result) { if (result) {
DesignerFrameFileDealerPane.getInstance().refresh(); DesignerFrameFileDealerPane.getInstance().refresh();
initForCollect(); // 如果是旧模板另存为新模板,则添加 templateID
collectInfo(); collectInfo();
} }
//更换最近打开 //更换最近打开

43
designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java

@ -5,6 +5,7 @@ import com.fr.base.io.IOFile;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.env.RemoteEnv;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
@ -15,9 +16,7 @@ import org.json.JSONObject;
import java.io.*; import java.io.*;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.*;
import java.util.Calendar;
import java.util.HashMap;
/** /**
* 做模板的过程和耗时收集辅助类 * 做模板的过程和耗时收集辅助类
@ -32,6 +31,7 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
private static final int VALID_WIDGET_COUNT = 5; // 有效报表模板的控件数 private static final int VALID_WIDGET_COUNT = 5; // 有效报表模板的控件数
private static final int COMPLETE_DAY_COUNT = 15; // 判断模板是否完成的天数 private static final int COMPLETE_DAY_COUNT = 15; // 判断模板是否完成的天数
private static final int ONE_THOUSAND = 1000; private static final int ONE_THOUSAND = 1000;
static final long serialVersionUID = 2007L;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private TemplateInfoCollector() { private TemplateInfoCollector() {
@ -70,18 +70,28 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
} catch (FileNotFoundException ex) { } catch (FileNotFoundException ex) {
// 如果之前没有存储过,则创建新对象 // 如果之前没有存储过,则创建新对象
instance = new TemplateInfoCollector(); instance = new TemplateInfoCollector();
} catch (Exception ex) { } catch (InvalidClassException ex) {
// 如果 TemplateInfoCollecor 类结构有改动,则放弃之前收集的数据(下次保存时覆盖)
// 这种情况主要在开发、测试过程中遇到,正式上线后不应该出现
FRLogger.getLogger().info(ex.getMessage());
FRLogger.getLogger().info("use a new instance");
instance = new TemplateInfoCollector();
}
catch (Exception ex) {
FRLogger.getLogger().error(ex.getMessage(), ex); FRLogger.getLogger().error(ex.getMessage(), ex);
} }
} }
return instance; return instance;
} }
private static boolean shouldCollectInfo() { private boolean shouldCollectInfo() {
if (FRContext.getCurrentEnv() instanceof RemoteEnv) { // 远程设计不收集数据
return false;
}
return DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv(); return DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv();
} }
public static void appendProcess(String log) { public void appendProcess(String log) {
if (!shouldCollectInfo()) { if (!shouldCollectInfo()) {
return; return;
} }
@ -113,7 +123,14 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
private void saveInfo() { private void saveInfo() {
try { try {
ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream(getInfoFile())); ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream(getInfoFile()));
FRLogger.getLogger().info("writing: " + instance.templateInfoList); String log = "";
int count = 1;
for (String key : templateInfoList.keySet()) {
String createTime = ((HashMap)templateInfoList.get(key).get("consumingMap")).get("create_time").toString();
log += (count + ". id: " + key + " " + createTime + "\n" + templateInfoList.get(key).toString() + "\n");
count ++;
}
FRLogger.getLogger().info("writing tplInfo: \n" + log);
os.writeObject(instance); os.writeObject(instance);
os.close(); os.close();
} catch (Exception ex) { } catch (Exception ex) {
@ -225,7 +242,9 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
if (sendSingleTemplateInfo(consumingUrl, jsonConsumingMap) && sendSingleTemplateInfo(processUrl, jsonProcessMap)) { if (sendSingleTemplateInfo(consumingUrl, jsonConsumingMap) && sendSingleTemplateInfo(processUrl, jsonProcessMap)) {
// 清空记录 // 清空记录
FRLogger.getLogger().info("successfully send " + templateInfo.get("templateID")); FRLogger.getLogger().info("successfully send " + templateInfo.get("templateID"));
templateInfoList.remove(templateInfo.get("templateID")); removeFromTemplateInfoList(templateInfo.get("templateID"));
} else {
FRLogger.getLogger().info("send template info failed, will try next time, " + templateInfo.get("templateID"));
} }
} }
saveInfo(); saveInfo();
@ -277,12 +296,16 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable {
} }
// 删除测试模板 // 删除测试模板
for (String key : testTemplateKeys) { for (String key : testTemplateKeys) {
templateInfoList.remove(key); removeFromTemplateInfoList(key);
// System.out.println(key + " is removed...");
} }
return completeTemplatesInfo; return completeTemplatesInfo;
} }
private void removeFromTemplateInfoList(String key) {
templateInfoList.remove(key);
FRLogger.getLogger().info(key + " is removed...");
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private boolean isTestTemplate(HashMap<String, Object> templateInfo) { private boolean isTestTemplate(HashMap<String, Object> templateInfo) {
HashMap<String, Object> processMap = (HashMap<String, Object>) templateInfo.get("processMap"); HashMap<String, Object> processMap = (HashMap<String, Object>) templateInfo.get("processMap");

18
designer_chart/src/com/fr/design/chart/axis/MinMaxValuePane.java

@ -42,14 +42,14 @@ public class MinMaxValuePane extends JPanel {
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
double[] columnSize = { p, f }; double[] columnSize = { p, f };
double[] rowSize = { p, p, p, p, p, p, p, p}; double[] rowSize = { p, p, p, p};
Component[][] components = getPanelComponents(); Component[][] components = getPanelComponents();
JPanel panel = TableLayoutHelper.createTableLayoutPane(components ,rowSize,columnSize); JPanel panel = TableLayoutHelper.createTableLayoutPane(components ,rowSize,columnSize);
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
this.add(panel,BorderLayout.CENTER); this.add(panel,BorderLayout.CENTER);
for(int i = 0; i < components.length; i+=2) { for(int i = 0; i < components.length; i++) {
((UICheckBox)components[i][0]).addActionListener(new ActionListener() { ((UICheckBox)components[i][0]).addActionListener(new ActionListener() {
@Override @Override
@ -57,19 +57,15 @@ public class MinMaxValuePane extends JPanel {
checkBoxUse(); checkBoxUse();
} }
}); });
ChartSwingUtils.addListener((UICheckBox)components[i][0], (UITextField)components[i+1][0]); ChartSwingUtils.addListener((UICheckBox)components[i][0], (UITextField)components[i][1]);
} }
} }
protected Component[][] getPanelComponents() { protected Component[][] getPanelComponents() {
return new Component[][]{ return new Component[][]{
new Component[]{minCheckBox}, new Component[]{minCheckBox, minValueField},
new Component[]{minValueField}, new Component[]{maxCheckBox, maxValueField},
new Component[]{maxCheckBox}, new Component[]{isCustomMainUnitBox, mainUnitField},
new Component[]{maxValueField}, new Component[]{isCustomSecUnitBox, secUnitField},
new Component[]{isCustomMainUnitBox},
new Component[]{mainUnitField},
new Component[]{isCustomSecUnitBox},
new Component[]{secUnitField},
}; };
} }

13
designer_chart/src/com/fr/design/mainframe/chart/gui/style/axis/ChartValuePane.java

@ -72,7 +72,7 @@ public class ChartValuePane extends ChartAxisUsePane<Axis>{
axisLineStylePane = new ChartAxisLineStylePane(); axisLineStylePane = new ChartAxisLineStylePane();
zeroPane = aliagnZero4Second(); zeroPane = aliagnZero4Second();
axisReversed = new UICheckBox(Inter.getLocText("AxisReversed")); axisReversed = new UICheckBox(Inter.getLocText("FR-Designer_AxisReversed"));
unitCombox = new UIComboBox(ChartConstants.UNIT_I18N_VALUES); unitCombox = new UIComboBox(ChartConstants.UNIT_I18N_VALUES);
formatPane = new FormatPane(); formatPane = new FormatPane();
axisLabelPane = new ChartAxisLabelPane(); axisLabelPane = new ChartAxisLabelPane();
@ -151,11 +151,10 @@ public class ChartValuePane extends ChartAxisUsePane<Axis>{
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
double[] columnSize = { LayoutConstants.CHART_ATTR_TOMARGIN,p,f}; double[] columnSize = { LayoutConstants.CHART_ATTR_TOMARGIN,p,f};
double[] rowSize = { p, p, p}; double[] rowSize = { p, p};
Component[][] component = new Component[][]{ Component[][] component = new Component[][]{
new Component[]{null,initMinMaxValue(),null}, new Component[]{null,initMinMaxValue(),null},
new Component[]{null, addLogarithmicPane2ValuePane(), null}, new Component[]{null, addLogarithmicPane2ValuePane(), addLogText()},
new Component[]{null, null, addLogText()},
}; };
return TableLayoutHelper.createTableLayoutPane(component, rowSize, columnSize); return TableLayoutHelper.createTableLayoutPane(component, rowSize, columnSize);
} }
@ -172,8 +171,8 @@ public class ChartValuePane extends ChartAxisUsePane<Axis>{
// 返回对数相关界面. 百分比 没有此界面. // 返回对数相关界面. 百分比 没有此界面.
protected JPanel addLogarithmicPane2ValuePane() { protected JPanel addLogarithmicPane2ValuePane() {
JPanel labelLogPane = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); JPanel labelLogPane = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane();
labelLogPane.add(logBox = new UICheckBox(Inter.getLocText("Logarithmic")+":")); labelLogPane.add(logBox = new UICheckBox(Inter.getLocText("FR-Designer_Logarithmic")+":"));
labelLogPane.add(new UILabel(Inter.getLocText("Chart_Log_Base"))); labelLogPane.add(new UILabel(Inter.getLocText("FR-Designer_Chart_Log_Base")));
logBaseField = new UITextField(4); logBaseField = new UITextField(4);
logBaseField.setText("10"); logBaseField.setText("10");
@ -222,7 +221,7 @@ public class ChartValuePane extends ChartAxisUsePane<Axis>{
* @return 返回标题. * @return 返回标题.
*/ */
public String title4PopupWindow() { public String title4PopupWindow() {
return Inter.getLocText("Chart_F_Radar_Axis"); return Inter.getLocText("FR-Designer_Chart_F_Radar_Axis");
} }
@Override @Override

11
designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java

@ -283,7 +283,6 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
} else if (isCrossPointArea(parentComp, x, y)) { } else if (isCrossPointArea(parentComp, x, y)) {
//交叉区域插入组件时,根据具体位置进行上下或者左右或者相邻三个组件的位置大小插入 //交叉区域插入组件时,根据具体位置进行上下或者左右或者相邻三个组件的位置大小插入
fixCrossPointArea(parentComp, child, x, y); fixCrossPointArea(parentComp, child, x, y);
//TODO 尽量不要出现这种写法吧?if else条件要么互斥,要么多个if判断return,不要在一条if else语句里面return吧?
return; return;
} else if (isTrisectionArea(parentComp, x, y)) { } else if (isTrisectionArea(parentComp, x, y)) {
// 在边界三等分区域,就不再和组件二等分了 // 在边界三等分区域,就不再和组件二等分了
@ -320,17 +319,15 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
int height = creator.getHeight(); int height = creator.getHeight();
int width = creator.getWidth(); int width = creator.getWidth();
if (x < 0) { if (x < 0) {
width += x; x = container.getX();
x = 0;
} else if (x + creator.getWidth() > container.getWidth()) { } else if (x + creator.getWidth() > container.getWidth()) {
width = container.getWidth() - x; x = container.getWidth() - width;
} }
if (y < 0) { if (y < 0) {
height += y; y = container.getY();
y = 0;
} else if (y + creator.getHeight() > container.getHeight()) { } else if (y + creator.getHeight() > container.getHeight()) {
height = container.getHeight() - y; y = container.getHeight() - height;
} }
creator.setBounds(x, y, width, height); creator.setBounds(x, y, width, height);

26
designer_form/src/com/fr/design/designer/beans/adapters/layout/FRBodyLayoutAdapter.java

@ -640,11 +640,7 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter {
* 又通过ComponentUtils.getRelativeBounds()方法获取到了绝对坐标 * 又通过ComponentUtils.getRelativeBounds()方法获取到了绝对坐标
* 再次计算相对坐标所以将y值重新变成绝对坐标 * 再次计算相对坐标所以将y值重新变成绝对坐标
* */ * */
if (currentCreator.getBackupParent().getLocation().y == WBorderLayout.DEFAULT_SIZE) { y = y + WCardMainBorderLayout.TAB_HEIGHT + this.getParaEditorYOffset();
y = y + WCardMainBorderLayout.TAB_HEIGHT + WBorderLayout.DEFAULT_SIZE;
} else {
y = y + WCardMainBorderLayout.TAB_HEIGHT;
}
int tempX = x - rect.x; int tempX = x - rect.x;
int tempY = y - rect.y; int tempY = y - rect.y;
int containerX = container.getX(); int containerX = container.getX();
@ -675,6 +671,26 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter {
return position; return position;
} }
/**
* 获取因为参数面板导致的Y坐标偏移
*
* @return 参数面板导致的Y坐标偏移
*/
protected int getParaEditorYOffset() {
int offset = 0;
if (container.getParent() != null) {
Component components[] = container.getParent().getComponents();
for (Component component : components) {
if (component instanceof XWParameterLayout) {
offset = component.getY() + component.getHeight();
break;
}
}
}
return offset;
}
/** /**
* 组件交叉区域进行插入时调整受到变动的其他组件,之前是交叉区域插入也按照三等分逻辑后面测试中发现有bug改为和bi一样的鼠标所在侧平分 * 组件交叉区域进行插入时调整受到变动的其他组件,之前是交叉区域插入也按照三等分逻辑后面测试中发现有bug改为和bi一样的鼠标所在侧平分
* 默认左上角右下角区域是垂直方向插入组件 * 默认左上角右下角区域是垂直方向插入组件

2
designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java

@ -133,7 +133,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
isFindRelatedComps = false; isFindRelatedComps = false;
//拖入组件判断时,先判断是否为交叉点区域,其次三等分区域,再次平分区域 //拖入组件判断时,先判断是否为交叉点区域,其次三等分区域,再次平分区域
Component comp = container.getComponentAt(x, y); Component comp = container.getComponentAt(x, y);
if (checkInterval(comp)) { if (comp == null || checkInterval(comp)) {
return false; return false;
} }
//如果当前处于边缘地带, 那么就把他贴到父容器上 //如果当前处于边缘地带, 那么就把他贴到父容器上

11
designer_form/src/com/fr/design/designer/beans/adapters/layout/FRTabFitLayoutAdapter.java

@ -7,11 +7,13 @@ package com.fr.design.designer.beans.adapters.layout;
import com.fr.design.beans.GroupModel; import com.fr.design.beans.GroupModel;
import com.fr.design.designer.creator.XCreator; 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.XWParameterLayout;
import com.fr.design.designer.creator.XWidgetCreator; import com.fr.design.designer.creator.XWidgetCreator;
import com.fr.design.designer.creator.cardlayout.XWCardLayout; import com.fr.design.designer.creator.cardlayout.XWCardLayout;
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
import com.fr.design.designer.properties.FRTabFitLayoutPropertiesGroupModel; import com.fr.design.designer.properties.FRTabFitLayoutPropertiesGroupModel;
import com.fr.design.mainframe.widget.editors.ParameterEditor;
import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.ComponentUtils;
import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WBorderLayout;
@ -82,16 +84,14 @@ public class FRTabFitLayoutAdapter extends FRFitLayoutAdapter {
return true; return true;
} }
// tab布局的纵坐标受到tab高度的影响,判断的上边界取得是里面XWTabFitLayout的上边界, // tab布局的纵坐标受到tab高度以及参数面板高度的影响,判断的上边界取得是里面XWTabFitLayout的上边界,
// 实际计算的时候的纵坐标用了外层的CardMainBorerLayout,需要将tab高度减掉 // 实际计算的时候的纵坐标用了外层的CardMainBorerLayout,需要将tab高度和参数面板高度减掉
// 将y值变为相对坐标以实现获取到鼠标drop位置的控件 // 将y值变为相对坐标以实现获取到鼠标drop位置的控件
// TODO 可以直接在这边将x,y都变成相对坐标,这样在后面判断拖进来的新控件放置方式的时候就不用再判断了 // TODO 可以直接在这边将x,y都变成相对坐标,这样在后面判断拖进来的新控件放置方式的时候就不用再判断了
private int adjustY(int y, XWTabFitLayout tabLayout) { private int adjustY(int y, XWTabFitLayout tabLayout) {
XWCardLayout cardLayout = (XWCardLayout) tabLayout.getBackupParent(); XWCardLayout cardLayout = (XWCardLayout) tabLayout.getBackupParent();
LayoutBorderStyle style = cardLayout.toData().getBorderStyle(); LayoutBorderStyle style = cardLayout.toData().getBorderStyle();
if (container.getLocation().y == WBorderLayout.DEFAULT_SIZE) { y = y - this.getParaEditorYOffset();
y = y - WBorderLayout.DEFAULT_SIZE;
}
if (ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)) { if (ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)) {
y = y - WCardMainBorderLayout.TAB_HEIGHT; y = y - WCardMainBorderLayout.TAB_HEIGHT;
} }
@ -101,4 +101,5 @@ public class FRTabFitLayoutAdapter extends FRFitLayoutAdapter {
protected Rectangle getLayoutBound(XWCardMainBorderLayout mainLayout) { protected Rectangle getLayoutBound(XWCardMainBorderLayout mainLayout) {
return ComponentUtils.getRelativeBounds(mainLayout); return ComponentUtils.getRelativeBounds(mainLayout);
} }
} }

36
designer_form/src/com/fr/design/designer/beans/models/AddingModel.java

@ -21,8 +21,8 @@ public class AddingModel {
// 当前要添加的组件 // 当前要添加的组件
private XCreator creator; private XCreator creator;
// 记录当前鼠标的位置信息 // 记录当前鼠标的位置信息
private int current_x; private int currentX;
private int current_y; private int currentY;
private boolean added; private boolean added;
public AddingModel(FormDesigner designer, XCreator xCreator) { public AddingModel(FormDesigner designer, XCreator xCreator) {
@ -30,12 +30,13 @@ public class AddingModel {
this.creator = xCreator; this.creator = xCreator;
instantiateCreator(designer, creatorName); instantiateCreator(designer, creatorName);
// 初始的时候隐藏该组件的图标 // 初始的时候隐藏该组件的图标
current_x = -this.creator.getWidth(); currentY = -this.creator.getWidth();
current_y = -this.creator.getHeight(); currentX = -this.creator.getHeight();
} }
/** /**
* 待说明 * 待说明
*
* @param designer 设计器 * @param designer 设计器
* @param creatorName 组件名 * @param creatorName 组件名
*/ */
@ -52,16 +53,16 @@ public class AddingModel {
this.creator.backupCurrentSize(); this.creator.backupCurrentSize();
this.creator.backupParent(); this.creator.backupParent();
this.creator.setSize(xCreator.initEditorSize()); this.creator.setSize(xCreator.initEditorSize());
current_x = x - (xCreator.getWidth() / 2); currentX = x - (xCreator.getWidth() / 2);
current_y = y - (xCreator.getHeight() / 2); currentY = y - (xCreator.getHeight() / 2);
} }
/** /**
* 隐藏当前组件的图标 * 隐藏当前组件的图标
*/ */
public void reset() { public void reset() {
current_x = -this.creator.getWidth(); currentX = -this.creator.getWidth();
current_y = -this.creator.getHeight(); currentY = -this.creator.getHeight();
} }
public String getXCreatorName(FormDesigner designer, XCreator x) { public String getXCreatorName(FormDesigner designer, XCreator x) {
@ -77,22 +78,23 @@ public class AddingModel {
} }
public int getCurrentX() { public int getCurrentX() {
return current_x; return currentX;
} }
public int getCurrentY() { public int getCurrentY() {
return current_y; return currentY;
} }
/** /**
* 移动组件图标到鼠标事件发生的位置 * 移动组件图标到鼠标事件发生的位置
*
* @param x 坐标 * @param x 坐标
* @param y 坐标 * @param y 坐标
*/ */
public void moveTo(int x, int y) { public void moveTo(int x, int y) {
current_x = x - (this.creator.getWidth() / 2); currentX = x - (this.creator.getWidth() / 2);
current_y = y - (this.creator.getHeight() / 2); currentY = y - (this.creator.getHeight() / 2);
} }
public XCreator getXCreator() { public XCreator getXCreator() {
@ -101,6 +103,7 @@ public class AddingModel {
/** /**
* 当前组件是否已经添加到某个容器中 * 当前组件是否已经添加到某个容器中
*
* @return 是返回true * @return 是返回true
*/ */
public boolean isCreatorAdded() { public boolean isCreatorAdded() {
@ -109,6 +112,7 @@ public class AddingModel {
/** /**
* 加入容器 * 加入容器
*
* @param designer 设计器 * @param designer 设计器
* @param container 容器 * @param container 容器
* @param x 坐标 * @param x 坐标
@ -124,10 +128,14 @@ public class AddingModel {
Rectangle rect = ComponentUtils.getRelativeBounds(container); Rectangle rect = ComponentUtils.getRelativeBounds(container);
if (!ComparatorUtils.equals(container.getOuterLayout(), container.getBackupParent())) { if (!ComparatorUtils.equals(container.getOuterLayout(), container.getBackupParent())) {
return added = container.getLayoutAdapter().addBean(creator, x + designer.getArea().getHorizontalValue(), y + designer.getArea().getVerticalValue()); added = container.getLayoutAdapter().addBean(creator,
x + designer.getArea().getHorizontalValue(),
y + designer.getArea().getVerticalValue());
return added;
} }
return added = container.getLayoutAdapter().addBean(creator, added = container.getLayoutAdapter().addBean(creator,
x + designer.getArea().getHorizontalValue() - rect.x, x + designer.getArea().getHorizontalValue() - rect.x,
y + designer.getArea().getVerticalValue() - rect.y); y + designer.getArea().getVerticalValue() - rect.y);
return added;
} }
} }

46
designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java

@ -13,6 +13,7 @@ import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelection; import com.fr.design.mainframe.FormSelection;
import com.fr.design.mainframe.FormSelectionUtils; import com.fr.design.mainframe.FormSelectionUtils;
import com.fr.design.utils.ComponentUtils;
import com.fr.design.utils.gui.LayoutUtils; import com.fr.design.utils.gui.LayoutUtils;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
@ -26,7 +27,7 @@ import java.util.ArrayList;
public class SelectionModel { public class SelectionModel {
//被粘贴组件在所选组件位置处往下、往右各错开20像素。执行多次粘贴时,在上一次粘贴的位置处错开20像素。 //被粘贴组件在所选组件位置处往下、往右各错开20像素。执行多次粘贴时,在上一次粘贴的位置处错开20像素。
private static final int DELTA_X_Y = 20; //粘贴时候的偏移距离 private static final int DELTA_X_Y = 20; //粘贴时候的偏移距离
private static final int BORDER_PROPORTION = 20; private static final double OFFSET_RELATIVE = 0.80;
private static FormSelection clipboard = new FormSelection(); private static FormSelection clipboard = new FormSelection();
private FormDesigner designer; private FormDesigner designer;
private FormSelection selection; private FormSelection selection;
@ -111,7 +112,7 @@ public class SelectionModel {
*/ */
public boolean pasteFromClipBoard() { public boolean pasteFromClipBoard() {
if (!clipboard.isEmpty()) { if (!clipboard.isEmpty()) {
if (!hasSelectionComponent()) { if (!hasSelectedPasteSource()) {
//未选 //未选
unselectedPaste(); unselectedPaste();
} else { } else {
@ -140,14 +141,14 @@ public class SelectionModel {
FormSelectionUtils.paste2Container(designer, (XLayoutContainer) selection.getSelectedCreator(), FormSelectionUtils.paste2Container(designer, (XLayoutContainer) selection.getSelectedCreator(),
clipboard, clipboard,
rec.x + rec.width / 2, rec.x + rec.width / 2,
rec.y + BORDER_PROPORTION); rec.y + DELTA_X_Y);
} else { } else {
Rectangle rec = selection.getRelativeBounds(); Rectangle rec = selection.getRelativeBounds();
//自适应布局 //自适应布局
FormSelectionUtils.paste2Container(designer, designer.getRootComponent(), FormSelectionUtils.paste2Container(designer, designer.getRootComponent(),
clipboard, clipboard,
rec.x + rec.width / 2, rec.x + rec.width / 2,
rec.y + BORDER_PROPORTION); rec.y + DELTA_X_Y);
} }
} else { } else {
//绝对布局 //绝对布局
@ -172,18 +173,22 @@ public class SelectionModel {
* 粘贴时选择组件 * 粘贴时选择组件
*/ */
private void selectedPaste() { private void selectedPaste() {
XLayoutContainer parent = null; XLayoutContainer container = null;
//获取到编辑器的表层容器(已选的组件的父容器就是表层容器) //获取到编辑器的表层容器(已选的组件的父容器就是表层容器)
parent = XCreatorUtils.getParentXLayoutContainer(selection.getSelectedCreator()); container = XCreatorUtils.getParentXLayoutContainer(selection.getSelectedCreator());
if (parent != null && selection.getSelectedCreator().getParent() instanceof XWFitLayout) { if (container != null && selection.getSelectedCreator().getParent() instanceof XWFitLayout) {
//自适应布局 //自适应布局
Rectangle rec = selection.getRelativeBounds(); Rectangle selectionRec = selection.getRelativeBounds();
FormSelectionUtils.paste2Container(designer, parent, clipboard, rec.x + rec.width / 2, rec.y + Rectangle containerRec = ComponentUtils.getRelativeBounds(container);
rec.height - BORDER_PROPORTION); //计算自适应布局位置
} else if (parent != null && selection.getSelectedCreator().getParent() instanceof XWAbsoluteLayout) { int positionX = selectionRec.x - containerRec.x + selectionRec.width / 2;
int positionY = (int) (selectionRec.y - containerRec.y + selectionRec.height * OFFSET_RELATIVE);
FormSelectionUtils.paste2Container(designer, container, clipboard, positionX, positionY);
} else if (container != null && selection.getSelectedCreator().getParent() instanceof XWAbsoluteLayout) {
//绝对布局 //绝对布局
Rectangle rec = selection.getSelctionBounds(); Rectangle rec = selection.getSelctionBounds();
FormSelectionUtils.paste2Container(designer, parent, clipboard, rec.x + DELTA_X_Y, rec.y + DELTA_X_Y); FormSelectionUtils.paste2Container(designer, container, clipboard, rec.x + DELTA_X_Y, rec.y + DELTA_X_Y);
} }
} }
@ -198,13 +203,13 @@ public class SelectionModel {
if (creator.acceptType(XWParameterLayout.class)) { if (creator.acceptType(XWParameterLayout.class)) {
designer.removeParaComponent(); designer.removeParaComponent();
} }
removeCreatorFromContainer(creator, creator.getWidth(), creator.getHeight()); removeCreatorFromContainer(creator, creator.getWidth(), creator.getHeight());
creator.removeAll(); creator.removeAll();
// 清除被选中的组件 // 清除被选中的组件
selection.reset(); selection.reset();
} }
setSelectedCreator(designer.getRootComponent()); setSelectedCreator(designer.getRootComponent());
FormSelectionUtils.rebuildSelection(designer);
// 触发事件 // 触发事件
designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_DELETED); designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_DELETED);
designer.repaint(); designer.repaint();
@ -275,7 +280,7 @@ public class SelectionModel {
* 但是编辑窗口的最外层其实是表层@see {@link com.fr.design.designer.creator.XWAbsoluteBodyLayout}, * 但是编辑窗口的最外层其实是表层@see {@link com.fr.design.designer.creator.XWAbsoluteBodyLayout},
* 其他两层不是靠添加组件就可以编辑的 * 其他两层不是靠添加组件就可以编辑的
*/ */
public boolean hasSelectionComponent() { public boolean hasSelectedPasteSource() {
XCreator selectionXCreator = selection.getSelectedCreator(); XCreator selectionXCreator = selection.getSelectedCreator();
if (designer.getClass().equals(FormDesigner.class)) { if (designer.getClass().equals(FormDesigner.class)) {
//frm本地组件复用 //frm本地组件复用
@ -286,10 +291,12 @@ public class SelectionModel {
|| selectionXCreator.getClass().equals(XWTabFitLayout.class); || selectionXCreator.getClass().equals(XWTabFitLayout.class);
//选中的是否是frm绝对布局编辑器本身 //选中的是否是frm绝对布局编辑器本身
boolean absoluteEditor = selectionXCreator.getClass().equals(XWAbsoluteBodyLayout.class); boolean absoluteEditor = selectionXCreator.getClass().equals(XWAbsoluteBodyLayout.class);
//选中是否是frm绝对画布块编辑器本身
boolean absoluteCanvas = selectionXCreator.getClass().equals(XWAbsoluteLayout.class);
//选中的是否是相对布局编辑器本身 //选中的是否是相对布局编辑器本身
boolean relativeEditor = selectionXCreator.getClass().equals(XWFitLayout.class); boolean relativeEditor = selectionXCreator.getClass().equals(XWFitLayout.class);
return !(tabEditor || absoluteEditor || relativeEditor); return !(tabEditor || absoluteEditor || absoluteCanvas || relativeEditor);
} else { } else {
return false; return false;
} }
@ -299,6 +306,15 @@ public class SelectionModel {
} }
} }
/**
* 是否有组件被选择如果所选组件是最底层容器也视为无选择
*
* @return 是则返回true
*/
public boolean hasSelectionComponent() {
return !selection.isEmpty() && selection.getSelectedCreator().getParent() != null;
}
/** /**
* 移动组件至指定位置 * 移动组件至指定位置
* *

106
designer_form/src/com/fr/design/designer/beans/models/StateModel.java

@ -1,30 +1,21 @@
package com.fr.design.designer.beans.models; package com.fr.design.designer.beans.models;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import com.fr.design.beans.location.Absorptionline; import com.fr.design.beans.location.Absorptionline;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelectionUtils;
import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.HoverPainter; import com.fr.design.designer.beans.HoverPainter;
import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.beans.location.Direction; import com.fr.design.designer.beans.location.Direction;
import com.fr.design.designer.beans.location.Location; import com.fr.design.designer.beans.location.Location;
import com.fr.design.designer.creator.XConnector; import com.fr.design.designer.creator.*;
import com.fr.design.designer.creator.XCreator; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.mainframe.FormSelectionUtils;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.ComponentUtils;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
/** /**
* 普通模式下的状态model * 普通模式下的状态model
*/ */
@ -36,8 +27,11 @@ public class StateModel {
private Direction driection; private Direction driection;
// 当前拖拽的起始位置 // 当前拖拽的起始位置
private int current_x; private int currentX;
private int current_y; private int currentY;
//拖拽组件原始位置大小备份
private Rectangle selectedPositionBackup;
private Point startPoint = new Point(); private Point startPoint = new Point();
private Point currentPoint = new Point(); private Point currentPoint = new Point();
@ -62,6 +56,7 @@ public class StateModel {
/** /**
* 返回direction * 返回direction
*
* @return direction方向 * @return direction方向
*/ */
public Direction getDirection() { public Direction getDirection() {
@ -79,6 +74,7 @@ public class StateModel {
/** /**
* 是否能拖拽 * 是否能拖拽
*
* @return 非outer且选中为空 * @return 非outer且选中为空
*/ */
public boolean dragable() { public boolean dragable() {
@ -118,22 +114,35 @@ public class StateModel {
} }
} }
private boolean addBean(XLayoutContainer container, int x, int y) { /**
* @param container 容器
* @param mouseX 鼠标释放位置X
* @param mouseY 鼠标释放位置Y
* @return 是否成功
*/
private boolean addBean(XLayoutContainer container, int mouseX, int mouseY) {
LayoutAdapter adapter = container.getLayoutAdapter(); LayoutAdapter adapter = container.getLayoutAdapter();
Rectangle r = ComponentUtils.getRelativeBounds(container); Rectangle rectangleContainer = ComponentUtils.getRelativeBounds(container);
if (selectionModel.getSelection().size() == 1) { if (selectionModel.getSelection().size() == 1) {
return adapter.addBean(selectionModel.getSelection().getSelectedCreator(), x return adapter.addBean(selectionModel.getSelection().getSelectedCreator(),
+ designer.getArea().getHorizontalValue() - r.x, y + designer.getArea().getVerticalValue() - r.y); mouseX + designer.getArea().getHorizontalValue() - rectangleContainer.x,
mouseY + designer.getArea().getVerticalValue() - rectangleContainer.y);
} }
for (XCreator creator : selectionModel.getSelection().getSelectedCreators()) { for (XCreator creator : selectionModel.getSelection().getSelectedCreators()) {
adapter.addBean(creator, x + designer.getArea().getHorizontalValue() - r.x, y + designer.getArea().getVerticalValue()- r.y); adapter.addBean(creator,
mouseX + designer.getArea().getHorizontalValue() - rectangleContainer.x,
mouseY + designer.getArea().getVerticalValue() - rectangleContainer.y);
} }
return true; return true;
} }
private void adding(int x, int y) { /**
* @param mouseReleasedX 鼠标释放位置X
* @param mouseReleasedY 鼠标释放位置Y
*/
private void adding(int mouseReleasedX, int mouseReleasedY) {
// 当前鼠标所在的组件 // 当前鼠标所在的组件
XCreator hoveredComponent = designer.getComponentAt(x, y, selectionModel.getSelection().getSelectedCreators()); XCreator hoveredComponent = designer.getComponentAt(mouseReleasedX, mouseReleasedY, selectionModel.getSelection().getSelectedCreators());
// 获取该组件所在的焦点容器 // 获取该组件所在的焦点容器
XLayoutContainer container = XCreatorUtils.getHotspotContainer(hoveredComponent); XLayoutContainer container = XCreatorUtils.getHotspotContainer(hoveredComponent);
@ -142,7 +151,7 @@ public class StateModel {
if (container != null) { if (container != null) {
// 如果是容器,则调用其acceptComponent接受组件 // 如果是容器,则调用其acceptComponent接受组件
success = addBean(container, x, y); success = addBean(container, mouseReleasedX, mouseReleasedY);
} }
if (success) { if (success) {
@ -150,15 +159,16 @@ public class StateModel {
designer.getEditListenerTable().fireCreatorModified( designer.getEditListenerTable().fireCreatorModified(
selectionModel.getSelection().getSelectedCreator(), DesignerEvent.CREATOR_ADDED); selectionModel.getSelection().getSelectedCreator(), DesignerEvent.CREATOR_ADDED);
} else { } else {
selectionModel.getSelection().setSelectionBounds(selectedPositionBackup, designer);
Toolkit.getDefaultToolkit().beep(); Toolkit.getDefaultToolkit().beep();
} }
// 取消提示 // 取消提示
designer.setPainter(null); designer.setPainter(null);
} }
/** /**
* 是否拖拽 * 是否拖拽
*
* @return dragging状态 * @return dragging状态
*/ */
public boolean isDragging() { public boolean isDragging() {
@ -167,6 +177,7 @@ public class StateModel {
/** /**
* 是否可以开始画线 * 是否可以开始画线
*
* @return startPoint不为空返回true * @return startPoint不为空返回true
*/ */
public boolean prepareForDrawLining() { public boolean prepareForDrawLining() {
@ -175,6 +186,7 @@ public class StateModel {
/** /**
* 设置开始位置 * 设置开始位置
*
* @param p point位置 * @param p point位置
*/ */
public void setStartPoint(Point p) { public void setStartPoint(Point p) {
@ -183,6 +195,7 @@ public class StateModel {
/** /**
* 返回开始位置 * 返回开始位置
*
* @return 点位置 * @return 点位置
*/ */
public Point getStartPoint() { public Point getStartPoint() {
@ -191,6 +204,7 @@ public class StateModel {
/** /**
* 返回当前点位置 * 返回当前点位置
*
* @return 点位置 * @return 点位置
*/ */
public Point getEndPoint() { public Point getEndPoint() {
@ -199,29 +213,32 @@ public class StateModel {
/** /**
* 当前选中组件 * 当前选中组件
*
* @param e 鼠标事件 * @param e 鼠标事件
*/ */
public void startSelecting(MouseEvent e) { public void startSelecting(MouseEvent e) {
selecting = true; selecting = true;
selectionModel.setHotspotBounds(new Rectangle()); selectionModel.setHotspotBounds(new Rectangle());
current_x = getMouseXY(e).x; currentX = getMouseXY(e).x;
current_y = getMouseXY(e).y; currentY = getMouseXY(e).y;
} }
/** /**
* 当前鼠标的xy * 当前鼠标的xy
*
* @param e 鼠标事件 * @param e 鼠标事件
*/ */
public void startResizing(MouseEvent e) { public void startResizing(MouseEvent e) {
if (!selectionModel.getSelection().isEmpty()) { if (!selectionModel.getSelection().isEmpty()) {
driection.backupBounds(designer); driection.backupBounds(designer);
} }
current_x = getMouseXY(e).x; currentX = getMouseXY(e).x;
current_y = getMouseXY(e).y; currentY = getMouseXY(e).y;
} }
/** /**
* 起始点开始DrawLine * 起始点开始DrawLine
*
* @param p 点位置 * @param p 点位置
*/ */
public void startDrawLine(Point p) { public void startDrawLine(Point p) {
@ -238,6 +255,7 @@ public class StateModel {
/** /**
* 鼠标释放时所在的区域及圈中的组件 * 鼠标释放时所在的区域及圈中的组件
*
* @param e 鼠标事件 * @param e 鼠标事件
*/ */
public void selectCreators(MouseEvent e) { public void selectCreators(MouseEvent e) {
@ -246,7 +264,7 @@ public class StateModel {
Rectangle bounds = createCurrentBounds(x, y); Rectangle bounds = createCurrentBounds(x, y);
if ((x != current_x) || (y != current_y)) { if ((x != currentX) || (y != currentY)) {
selectionModel.setSelectedCreators(getHotspotCreators(bounds, designer.getRootComponent())); selectionModel.setSelectedCreators(getHotspotCreators(bounds, designer.getRootComponent()));
} }
selectionModel.setHotspotBounds(null); selectionModel.setHotspotBounds(null);
@ -254,6 +272,7 @@ public class StateModel {
/** /**
* 画所在区域线 * 画所在区域线
*
* @param e 鼠标事件 * @param e 鼠标事件
*/ */
public void drawLine(MouseEvent e) { public void drawLine(MouseEvent e) {
@ -270,16 +289,16 @@ public class StateModel {
private Rectangle createCurrentBounds(int x, int y) { private Rectangle createCurrentBounds(int x, int y) {
Rectangle bounds = new Rectangle(); Rectangle bounds = new Rectangle();
bounds.x = Math.min(x, current_x); bounds.x = Math.min(x, currentX);
bounds.y = Math.min(y, current_y); bounds.y = Math.min(y, currentY);
bounds.width = Math.max(x, current_x) - bounds.x; bounds.width = Math.max(x, currentX) - bounds.x;
bounds.height = Math.max(y, current_y) - bounds.y; bounds.height = Math.max(y, currentY) - bounds.y;
return bounds; return bounds;
} }
private ArrayList<XCreator> getHotspotCreators(Rectangle selection, XCreator root) { private ArrayList<XCreator> getHotspotCreators(Rectangle selection, XCreator root) {
ArrayList<XCreator> creators = new ArrayList<XCreator>(); ArrayList<XCreator> creators = new ArrayList<>();
if (!root.isVisible() && !designer.isRoot(root)) { if (!root.isVisible() && !designer.isRoot(root)) {
return creators; return creators;
@ -334,6 +353,7 @@ public class StateModel {
/** /**
* 设置可拉伸方向 * 设置可拉伸方向
*
* @param dir 拉伸方向 * @param dir 拉伸方向
*/ */
public void setDirection(Direction dir) { public void setDirection(Direction dir) {
@ -345,6 +365,7 @@ public class StateModel {
/** /**
* x吸附线赋值 * x吸附线赋值
*
* @param line 线 * @param line 线
*/ */
public void setXAbsorptionline(Absorptionline line) { public void setXAbsorptionline(Absorptionline line) {
@ -353,6 +374,7 @@ public class StateModel {
/** /**
* y吸附线赋值 * y吸附线赋值
*
* @param line 线 * @param line 线
*/ */
public void setYAbsorptionline(Absorptionline line) { public void setYAbsorptionline(Absorptionline line) {
@ -361,6 +383,7 @@ public class StateModel {
/** /**
* 等距线赋值 * 等距线赋值
*
* @param line 线 * @param line 线
*/ */
public void setEquidistantLine(Absorptionline line) { public void setEquidistantLine(Absorptionline line) {
@ -369,6 +392,7 @@ public class StateModel {
/** /**
* 画吸附线 * 画吸附线
*
* @param g Graphics类 * @param g Graphics类
*/ */
public void paintAbsorptionline(Graphics g) { public void paintAbsorptionline(Graphics g) {
@ -385,12 +409,17 @@ public class StateModel {
/** /**
* 拖拽 * 拖拽
*
* @param e 鼠标事件 * @param e 鼠标事件
*/ */
public void dragging(MouseEvent e) { public void dragging(MouseEvent e) {
//进入dragging状态时备份组件大小和位置
if (!dragging) {
selectedPositionBackup = selectionModel.getSelection().getRelativeBounds();
}
checkAddable(e); checkAddable(e);
setDependLinePainter(e); setDependLinePainter(e);
driection.drag(getMouseXY(e).x-current_x, getMouseXY(e).y-current_y, designer); driection.drag(getMouseXY(e).x - currentX, getMouseXY(e).y - currentY, designer);
this.dragging = true; this.dragging = true;
} }
@ -409,6 +438,7 @@ public class StateModel {
/** /**
* 释放捕获 * 释放捕获
*
* @param e 鼠标事件 * @param e 鼠标事件
*/ */
public void releaseDragging(MouseEvent e) { public void releaseDragging(MouseEvent e) {

3
designer_form/src/com/fr/design/designer/beans/painters/AbstractPainter.java

@ -22,6 +22,7 @@ public abstract class AbstractPainter implements HoverPainter {
/** /**
* 构造函数 * 构造函数
*
* @param container 容器 * @param container 容器
*/ */
public AbstractPainter(XLayoutContainer container) { public AbstractPainter(XLayoutContainer container) {
@ -35,6 +36,7 @@ public abstract class AbstractPainter implements HoverPainter {
/** /**
* 画初始区域 * 画初始区域
*
* @param g 画图类 * @param g 画图类
* @param startX 起始x位置 * @param startX 起始x位置
* @param startY 起始y位置 * @param startY 起始y位置
@ -47,6 +49,7 @@ public abstract class AbstractPainter implements HoverPainter {
/** /**
* 设置边界 * 设置边界
*
* @param rect 位置 * @param rect 位置
*/ */
@Override @Override

31
designer_form/src/com/fr/design/designer/creator/XLayoutContainer.java

@ -45,6 +45,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
protected boolean editable = false; protected boolean editable = false;
//鼠标移动到布局画出编辑层 //鼠标移动到布局画出编辑层
protected boolean isMouseEnter = false; protected boolean isMouseEnter = false;
public void setMouseEnter(boolean mouseEnter) { public void setMouseEnter(boolean mouseEnter) {
isMouseEnter = mouseEnter; isMouseEnter = mouseEnter;
} }
@ -56,6 +57,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
/** /**
* 得到属性名 * 得到属性名
*
* @return 属性名 * @return 属性名
* @throws IntrospectionException * @throws IntrospectionException
*/ */
@ -81,6 +83,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
/** /**
* 控件名属性 * 控件名属性
*
* @return * @return
* @throws IntrospectionException * @throws IntrospectionException
*/ */
@ -91,6 +94,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
/** /**
* 边距属性 * 边距属性
*
* @return * @return
* @throws IntrospectionException * @throws IntrospectionException
*/ */
@ -102,6 +106,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
/** /**
* 返回对应的wlayout * 返回对应的wlayout
*
* @return wlayout控件 * @return wlayout控件
*/ */
public WLayout toData() { public WLayout toData() {
@ -123,6 +128,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
/** /**
* 当前组件zorder位置替换新的控件 * 当前组件zorder位置替换新的控件
*
* @param widget 控件 * @param widget 控件
* @param oldcreator 旧组件 * @param oldcreator 旧组件
* @return 组件 * @return 组件
@ -141,6 +147,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
/** /**
* 初始化时默认的组件大小 * 初始化时默认的组件大小
*
* @return 默认Dimension * @return 默认Dimension
*/ */
public Dimension initEditorSize() { public Dimension initEditorSize() {
@ -172,6 +179,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
/** /**
* 设计界面中有组件添加时要通知WLayout容器重新paint * 设计界面中有组件添加时要通知WLayout容器重新paint
*
* @param e 待说明 * @param e 待说明
*/ */
@Override @Override
@ -188,6 +196,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
/** /**
* 设计界面中有组件添加时要通知WLayout容器重新paint * 设计界面中有组件添加时要通知WLayout容器重新paint
*
* @param e 待说明 * @param e 待说明
*/ */
@Override @Override
@ -203,6 +212,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
/** /**
* 根据widget的属性值来获取 * 根据widget的属性值来获取
*
* @param wgt * @param wgt
* @return * @return
*/ */
@ -233,6 +243,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
/** /**
* 该组件是否可以拖入参数面板 * 该组件是否可以拖入参数面板
*
* @return 是则返回true * @return 是则返回true
*/ */
public boolean canEnterIntoParaPane() { public boolean canEnterIntoParaPane() {
@ -241,6 +252,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
/** /**
* 是否作为控件树的叶子节点 * 是否作为控件树的叶子节点
*
* @return 是则返回true * @return 是则返回true
*/ */
public boolean isComponentTreeLeaf() { public boolean isComponentTreeLeaf() {
@ -257,6 +269,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
/** /**
* 是否有查询按钮 * 是否有查询按钮
*
* @param xCreator 控件或容器 * @param xCreator 控件或容器
* @return 有无查询按钮 * @return 有无查询按钮
*/ */
@ -295,6 +308,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
/** /**
* 主要为自适应用 * 主要为自适应用
* 返回指定point的上方组件 * 返回指定point的上方组件
*
* @param x x位置 * @param x x位置
* @param y y位置 * @param y y位置
* @return 指定位置的组件 * @return 指定位置的组件
@ -306,6 +320,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
/** /**
* 主要为自适应用 * 主要为自适应用
* 返回指定point的左方组件 * 返回指定point的左方组件
*
* @param x x位置 * @param x x位置
* @param y y位置 * @param y y位置
* @return 指定位置的组件 * @return 指定位置的组件
@ -316,6 +331,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
/** /**
* 返回指定point的右方组件 * 返回指定point的右方组件
*
* @param x x位置 * @param x x位置
* @param y y位置 * @param y y位置
* @param w 宽度 * @param w 宽度
@ -327,6 +343,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
/** /**
* 返回指定point的下方组件 * 返回指定point的下方组件
*
* @param x x位置 * @param x x位置
* @param y y位置 * @param y y位置
* @param h 高度 * @param h 高度
@ -338,6 +355,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
/** /**
* 返回指定point的上方且是右侧的组件 * 返回指定point的上方且是右侧的组件
*
* @param x x位置 * @param x x位置
* @param y y位置 * @param y y位置
* @param w 宽度 * @param w 宽度
@ -349,6 +367,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
/** /**
* 返回指定point的左方且是下侧的组件 * 返回指定point的左方且是下侧的组件
*
* @param x x位置 * @param x x位置
* @param y y位置 * @param y y位置
* @param h 高度 * @param h 高度
@ -360,6 +379,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
/** /**
* 返回指定point的右方且是下侧的组件 * 返回指定point的右方且是下侧的组件
*
* @param x x位置 * @param x x位置
* @param y y位置 * @param y y位置
* @param h 高度 * @param h 高度
@ -372,6 +392,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
/** /**
* 返回指定point的下方且是右侧的组件 * 返回指定point的下方且是右侧的组件
*
* @param x x位置 * @param x x位置
* @param y y位置 * @param y y位置
* @param h 高度 * @param h 高度
@ -384,6 +405,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
/** /**
* 是否延迟展示报表内容也就是说是否要等点击了查询之后才执行报表 * 是否延迟展示报表内容也就是说是否要等点击了查询之后才执行报表
*
* @return 如果是true则表示点击之后才开始计算false则表示会根据参数默认值直接计算报表并展现 * @return 如果是true则表示点击之后才开始计算false则表示会根据参数默认值直接计算报表并展现
*/ */
public boolean isDelayDisplayContent() { public boolean isDelayDisplayContent() {
@ -392,6 +414,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
/** /**
* 是否显示参数界面 * 是否显示参数界面
*
* @return 显示参数界面则返回true否则返回false * @return 显示参数界面则返回true否则返回false
*/ */
public boolean isDisplay() { public boolean isDisplay() {
@ -404,6 +427,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
/** /**
* 获取参数界面的宽度 * 获取参数界面的宽度
*
* @return 宽度 * @return 宽度
*/ */
public int getDesignWidth() { public int getDesignWidth() {
@ -412,6 +436,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
/** /**
* 获取参数面板的对齐方式 * 获取参数面板的对齐方式
*
* @return 左中右三种对齐方式 * @return 左中右三种对齐方式
*/ */
public int getPosition() { public int getPosition() {
@ -424,17 +449,13 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
* @param designer 表单设计器 * @param designer 表单设计器
*/ */
public void stopAddingState(FormDesigner designer) { public void stopAddingState(FormDesigner designer) {
return;
} }
/** /**
* 寻找最近的为自适应布局的父容器 * 寻找最近的为自适应布局的父容器
* *
* @return 布局容器 * @return 布局容器
*
*
* @date 2014-12-30-下午3:15:28 * @date 2014-12-30-下午3:15:28
*
*/ */
public XLayoutContainer findNearestFit() { public XLayoutContainer findNearestFit() {
//一层一层网上找, 找到最近的fit那一层就return //一层一层网上找, 找到最近的fit那一层就return
@ -478,6 +499,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
/** /**
* 布局是否可编辑不可则显示编辑蒙层 * 布局是否可编辑不可则显示编辑蒙层
*
* @return 可否编辑 * @return 可否编辑
*/ */
public boolean isEditable() { public boolean isEditable() {
@ -486,6 +508,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
/** /**
* 设置布局是否可编辑不可则显示编辑蒙层 * 设置布局是否可编辑不可则显示编辑蒙层
*
* @param isEditable 可否编辑 * @param isEditable 可否编辑
*/ */
public void setEditable(boolean isEditable) { public void setEditable(boolean isEditable) {

12
designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java

@ -25,8 +25,6 @@ import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.form.ui.container.cardlayout.WTabFitLayout; import com.fr.form.ui.container.cardlayout.WTabFitLayout;
/** /**
*
*
* @date: 2014-11-25-下午3:11:14 * @date: 2014-11-25-下午3:11:14
*/ */
public class XWCardTagLayout extends XWHorizontalBoxLayout { public class XWCardTagLayout extends XWHorizontalBoxLayout {
@ -92,10 +90,7 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
* 添加组件的监听事件 * 添加组件的监听事件
* *
* @param e 事件 * @param e 事件
*
*
* @date 2014-11-25-下午6:20:10 * @date 2014-11-25-下午6:20:10
*
*/ */
public void componentAdded(ContainerEvent e) { public void componentAdded(ContainerEvent e) {
super.componentAdded(e); super.componentAdded(e);
@ -152,7 +147,6 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
*/ */
public void stopAddingState(FormDesigner designer) { public void stopAddingState(FormDesigner designer) {
designer.stopAddingState(); designer.stopAddingState();
return;
} }
//新增时去tabFitLayout名字中最大的Index+1,防止重名 //新增时去tabFitLayout名字中最大的Index+1,防止重名
@ -173,7 +167,7 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
/** /**
* 调整tab宽度 * 调整tab宽度
* * <p>
* void * void
*/ */
public void adjustComponentWidth() { public void adjustComponentWidth() {
@ -182,11 +176,11 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
/** /**
* 该布局需要隐藏无需对边框进行操作 * 该布局需要隐藏无需对边框进行操作
* @param 边框
* *
* @param
*/ */
public void setBorder(Border border) { public void setBorder(Border border) {
return;
} }
@Override @Override

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

@ -43,7 +43,7 @@ public class FormCreatorDropTarget extends DropTarget {
* 当前添加模式对应的model * 当前添加模式对应的model
*/ */
private AddingModel addingModel; private AddingModel addingModel;
private final static int GAP = 30; private static final int GAP = 30;
private JWindow promptWindow = new JWindow(); private JWindow promptWindow = new JWindow();
private UIButton promptButton = new UIButton("", BaseUtils.readIcon(IconPathConstants.FORBID_ICON_PATH)); private UIButton promptButton = new UIButton("", BaseUtils.readIcon(IconPathConstants.FORBID_ICON_PATH));
@ -59,10 +59,11 @@ public class FormCreatorDropTarget extends DropTarget {
XCreator hoveredComponent = designer.getComponentAt(x, y); XCreator hoveredComponent = designer.getComponentAt(x, y);
// 获取该组件所在的焦点容器 // 获取该组件所在的焦点容器
XLayoutContainer container = XCreatorUtils.getHotspotContainer(hoveredComponent); XLayoutContainer container = XCreatorUtils.getHotspotContainer(hoveredComponent);
//cardTagLayout里用到
container.stopAddingState(designer);
boolean success = false; boolean success = false;
if (container != null) { if (container != null) {
//XWCardTagLayout 切换添加状态到普通状态
container.stopAddingState(designer);
// 如果是容器,则调用其acceptComponent接受组件 // 如果是容器,则调用其acceptComponent接受组件
AddingModel model = designer.getAddingModel(); AddingModel model = designer.getAddingModel();
@ -129,9 +130,7 @@ public class FormCreatorDropTarget extends DropTarget {
//提示组件是否可以拖入 //提示组件是否可以拖入
promptUser(x, y, container); promptUser(x, y, container);
if (container != null) { if (container != null) {
dealWithContainer(x, y, container); dealWithContainer(x, y, container);
} else { } else {
// 如果鼠标不在任何组件上,则取消提示器 // 如果鼠标不在任何组件上,则取消提示器
designer.setPainter(null); designer.setPainter(null);
@ -197,11 +196,9 @@ public class FormCreatorDropTarget extends DropTarget {
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)); container.setBorder(BorderFactory.createLineBorder(Color.RED, Constants.LINE_MEDIUM));
int screen_X = (int) designer.getArea().getLocationOnScreen().getX(); int screenX = designer.getArea().getLocationOnScreen().x;
int screen_Y = (int) designer.getArea().getLocationOnScreen().getY(); int screenY = designer.getArea().getLocationOnScreen().y;
this.promptWindow.setSize(promptWindow.getPreferredSize()); promptWindow.setLocation(screenX + x + GAP, screenY + y + GAP);
this.promptWindow.setPreferredSize(promptWindow.getPreferredSize());
promptWindow.setLocation(screen_X + x + GAP, screen_Y + y + GAP);
promptWindow.setVisible(true); promptWindow.setVisible(true);
} }

6
designer_form/src/com/fr/design/mainframe/FormDesigner.java

@ -612,6 +612,12 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
return true; return true;
} }
public void showMessageDialog(String message) {
JOptionPane.showMessageDialog(this, message, Inter.getLocText("FR-Designer_Alert"), JOptionPane.WARNING_MESSAGE);
FormSelectionUtils.rebuildSelection(this);
repaint();
}
/** /**
* 保存参数界面的宽度 * 保存参数界面的宽度
* *

12
designer_form/src/com/fr/design/mainframe/FormSelection.java

@ -8,12 +8,7 @@ import com.fr.base.FRContext;
import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.location.Direction; import com.fr.design.designer.beans.location.Direction;
import com.fr.design.designer.creator.XComponent; import com.fr.design.designer.creator.*;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.ComponentUtils;
import com.fr.design.utils.gui.LayoutUtils; import com.fr.design.utils.gui.LayoutUtils;
@ -273,6 +268,11 @@ public class FormSelection {
if (parent == null) { if (parent == null) {
return; return;
} }
boolean changeCreator = creator.shouldScaleCreator() || creator.hasTitleStyle();
if (parent.acceptType(XWFitLayout.class) && changeCreator) {
creator = (XCreator) creator.getParent();
}
parent.getLayoutAdapter().removeBean(creator, creator.getWidth(), creator.getHeight());
// 删除其根组件,同时就删除了同时被选择的叶子组件 // 删除其根组件,同时就删除了同时被选择的叶子组件
parent.remove(creator); parent.remove(creator);
LayoutManager layout = parent.getLayout(); LayoutManager layout = parent.getLayout();

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

@ -8,6 +8,7 @@ import com.fr.design.designer.creator.*;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WTitleLayout; import com.fr.form.ui.container.WTitleLayout;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import java.awt.*; import java.awt.*;
import java.util.ArrayList; import java.util.ArrayList;
@ -17,11 +18,7 @@ import java.util.List;
public class FormSelectionUtils { public class FormSelectionUtils {
//组件复制时坐标偏移 //组件复制时坐标偏移
private static final int DELAY_X = 20; private static final int DELAY_X_Y = 20;
private static final int DELAY_Y = 20;
//组件复制时是否已经向左上偏移
private static boolean backoffset = false;
//组件重命名后缀 //组件重命名后缀
private static final String POSTFIX = "_c"; private static final String POSTFIX = "_c";
@ -31,11 +28,7 @@ public class FormSelectionUtils {
} }
/** /**
* @param designer 编辑器 * 粘贴到容器
* @param parent 粘贴依据的组件
* @param clipboard 剪贴板内容
* @param x x
* @param y y
*/ */
public static void paste2Container(FormDesigner designer, XLayoutContainer parent, public static void paste2Container(FormDesigner designer, XLayoutContainer parent,
FormSelection clipboard, int x, int y) { FormSelection clipboard, int x, int y) {
@ -54,12 +47,6 @@ public class FormSelectionUtils {
/** /**
* 绝对布局粘贴 * 绝对布局粘贴
*
* @param designer
* @param clipboard
* @param adapter
* @param x
* @param y
*/ */
private static void absolutePaste(FormDesigner designer, FormSelection clipboard, LayoutAdapter adapter, int x, int y) { private static void absolutePaste(FormDesigner designer, FormSelection clipboard, LayoutAdapter adapter, int x, int y) {
@ -74,6 +61,10 @@ public class FormSelectionUtils {
copiedCreator, copiedCreator,
x + creator.getX() - rec.x + copiedCreator.getWidth() / 2, x + creator.getX() - rec.x + copiedCreator.getWidth() / 2,
y + creator.getY() - rec.y + copiedCreator.getHeight() / 2); y + creator.getY() - rec.y + copiedCreator.getHeight() / 2);
if (!adapter.accept(copiedCreator, point.x, point.y)) {
designer.showMessageDialog(Inter.getLocText("FR-Designer_Too_Large_To_Paste"));
return;
}
boolean addSuccess = adapter.addBean(copiedCreator, point.x, point.y); boolean addSuccess = adapter.addBean(copiedCreator, point.x, point.y);
if (addSuccess) { if (addSuccess) {
designer.getSelectionModel().getSelection().addSelectedCreator(copiedCreator); designer.getSelectionModel().getSelection().addSelectedCreator(copiedCreator);
@ -90,12 +81,6 @@ public class FormSelectionUtils {
/** /**
* 相对布局粘贴 * 相对布局粘贴
*
* @param designer
* @param clipboard
* @param adapter
* @param x
* @param y
*/ */
private static void relativePaste(FormDesigner designer, FormSelection clipboard, LayoutAdapter adapter, int x, int y) { private static void relativePaste(FormDesigner designer, FormSelection clipboard, LayoutAdapter adapter, int x, int y) {
designer.getSelectionModel().getSelection().reset(); designer.getSelectionModel().getSelection().reset();
@ -103,6 +88,10 @@ public class FormSelectionUtils {
try { try {
Widget copied = copyWidget(designer, creator); Widget copied = copyWidget(designer, creator);
XCreator copiedCreator = XCreatorUtils.createXCreator(copied, creator.getSize()); XCreator copiedCreator = XCreatorUtils.createXCreator(copied, creator.getSize());
if (!adapter.accept(copiedCreator, x, y)) {
designer.showMessageDialog(Inter.getLocText("FR-Designer_Too_Small_To_Paste"));
return;
}
boolean addSuccess = adapter.addBean(copiedCreator, x, y); boolean addSuccess = adapter.addBean(copiedCreator, x, y);
if (addSuccess) { if (addSuccess) {
designer.getSelectionModel().getSelection().addSelectedCreator(copiedCreator); designer.getSelectionModel().getSelection().addSelectedCreator(copiedCreator);
@ -118,14 +107,6 @@ public class FormSelectionUtils {
/** /**
* 组件复用绝对布局获取粘贴组件位置 * 组件复用绝对布局获取粘贴组件位置
*
* @param layoutAdapter 绝对布局容器AbstractLayoutAdapter
* @param copiedCreator 复制的组件
* @param x x=组件x + clonedCreator.getWidth() / 2
* @param y y=组件y + clonedCreator.getHeight() / 2
* 除2的步骤会导致当宽度或者高度为奇数是中心点向左上各偏移一个像素
* 由于中心点向左上各偏移一个像素依赖中心点计算的右下点就会相应的想做上偏移一个像素导致结果不准确
* @return 新位置坐标
*/ */
private static Point getPasteLocation(AbstractLayoutAdapter layoutAdapter, XCreator copiedCreator, int x, int y) { private static Point getPasteLocation(AbstractLayoutAdapter layoutAdapter, XCreator copiedCreator, int x, int y) {
//当宽度为奇数时 设置偏移 //当宽度为奇数时 设置偏移
@ -144,12 +125,10 @@ public class FormSelectionUtils {
* x,y同时越界 * x,y同时越界
*/ */
if (xOut && yOut) { if (xOut && yOut) {
x = backoffset ? container.getWidth() - copiedCreator.getWidth() / 2 - xoffset //向左偏移
: container.getWidth() - copiedCreator.getWidth() / 2 - DELAY_X - xoffset; x = container.getWidth() - copiedCreator.getWidth() / 2 - DELAY_X_Y - xoffset;
y = backoffset ? //紧贴下边界
container.getHeight() - copiedCreator.getHeight() / 2 - yoffset y = container.getHeight() - copiedCreator.getHeight() / 2 - yoffset;
: container.getHeight() - copiedCreator.getHeight() / 2 - DELAY_Y - yoffset;
backoffset = !backoffset;
return new Point(x, y); return new Point(x, y);
} }
/* /*
@ -158,7 +137,7 @@ public class FormSelectionUtils {
* 距离大于20像素的一侧正常错开 * 距离大于20像素的一侧正常错开
* x,y中只有一个越界 * x,y中只有一个越界
*/ */
else if ((xOut || yOut)) { if ((xOut || yOut)) {
x = xOut ? container.getWidth() - copiedCreator.getWidth() / 2 - xoffset : x; x = xOut ? container.getWidth() - copiedCreator.getWidth() / 2 - xoffset : x;
y = yOut ? container.getHeight() - copiedCreator.getHeight() / 2 - yoffset : y; y = yOut ? container.getHeight() - copiedCreator.getHeight() / 2 - yoffset : y;
return new Point(x, y); return new Point(x, y);
@ -170,15 +149,10 @@ public class FormSelectionUtils {
/** /**
* 拷贝组件 * 拷贝组件
*
* @param formDesigner
* @param xCreator
* @return
* @throws CloneNotSupportedException
*/ */
private static Widget copyWidget(FormDesigner formDesigner, XCreator xCreator) throws private static Widget copyWidget(FormDesigner formDesigner, XCreator xCreator) throws
CloneNotSupportedException { CloneNotSupportedException {
ArrayList<String> nameSpace = new ArrayList<String>(); ArrayList<String> nameSpace = new ArrayList<>();
Widget copied = (Widget) xCreator.toData().clone(); Widget copied = (Widget) xCreator.toData().clone();
//重命名拷贝的组件 //重命名拷贝的组件
String name = getCopiedName(formDesigner, copied, nameSpace); String name = getCopiedName(formDesigner, copied, nameSpace);
@ -193,14 +167,9 @@ public class FormSelectionUtils {
/** /**
* 组件拷贝命名规则 * 组件拷贝命名规则
*
* @param formDesigner
* @param copied
* @param nameSpace
* @return name
*/ */
private static String getCopiedName(FormDesigner formDesigner, Widget copied, ArrayList<String> nameSpace) { private static String getCopiedName(FormDesigner formDesigner, Widget copied, ArrayList<String> nameSpace) {
StringBuffer name = new StringBuffer(copied.getWidgetName()); StringBuilder name = new StringBuilder(copied.getWidgetName());
do { do {
name.append(POSTFIX); name.append(POSTFIX);
} while (formDesigner.getTarget().isNameExist(name.toString()) || nameSpace.contains(name.toString())); } while (formDesigner.getTarget().isNameExist(name.toString()) || nameSpace.contains(name.toString()));
@ -209,8 +178,8 @@ public class FormSelectionUtils {
} }
public static void rebuildSelection(FormDesigner designer) { public static void rebuildSelection(FormDesigner designer) {
ArrayList<XCreator> newSelection = new ArrayList<XCreator>(); ArrayList<XCreator> newSelection = new ArrayList<>();
List<Widget> widgetList = new ArrayList<Widget>(); List<Widget> widgetList = new ArrayList<>();
for (XCreator comp : designer.getSelectionModel().getSelection().getSelectedCreators()) { for (XCreator comp : designer.getSelectionModel().getSelection().getSelectedCreators()) {
widgetList.add(comp.toData()); widgetList.add(comp.toData());
} }
@ -219,7 +188,7 @@ public class FormSelectionUtils {
} }
public static ArrayList<XCreator> rebuildSelection(XCreator rootComponent, Widget[] selectWidgets) { public static ArrayList<XCreator> rebuildSelection(XCreator rootComponent, Widget[] selectWidgets) {
List<Widget> selectionWidget = new ArrayList<Widget>(); List<Widget> selectionWidget = new ArrayList<>();
if (selectWidgets != null) { if (selectWidgets != null) {
selectionWidget.addAll(Arrays.asList(selectWidgets)); selectionWidget.addAll(Arrays.asList(selectWidgets));
} }

0
designer_base/src/com/fr/design/mainframe/templateinfo/JFormProcessInfo.java → designer_form/src/com/fr/design/mainframe/templateinfo/JFormProcessInfo.java

Loading…
Cancel
Save