Browse Source

Merging in latest from upstream (BA/design:refs/heads/dev)

* commit '5d1bbe212e0dc3d366888b558a38a646c8a4a3a3': (46 commits)
  绝对布局基本功能2
  上传design项目的3个build.gradle文件
  1
  冲突
  冲突
  修改下instanceof,改成acceptType好一些
  国际化
  表单绝对布局的基本功能1
  方法名
  空import
  exe启动插件被禁用
  整理
  设计器无法保存文字竖排
  read plugin
  代码规范
  修改一些规范问题
  他装了插件后, 可以设置显示或者不显示
  装了插件后, 可以设置显示或者不显示
  装了插件后, 可以设置显示或者不显示
  去掉qq帮助,并在关于软件中显示qq号码,冻结时给提示
  ...
master
vito 8 years ago
parent
commit
e6ad20a976
  1. 3
      designer/src/com/fr/design/mainframe/bbs/BBSLoginDialog.java
  2. 20
      designer/src/com/fr/design/module/DesignerModule.java
  3. 80
      designer/src/com/fr/design/report/freeze/RepeatAndFreezeSettingPane.java
  4. 10
      designer/src/com/fr/design/webattr/EditToolBar.java
  5. 10
      designer/src/com/fr/design/write/submit/SubmitVisitorListPane.java
  6. 40
      designer/src/com/fr/poly/hanlder/BottomCornerMouseHanlder.java
  7. 61
      designer_base/build.gradle
  8. 3
      designer_base/src/com/fr/design/actions/help/AboutPane.java
  9. 2
      designer_base/src/com/fr/design/beans/BasicBeanPane.java
  10. 207
      designer_base/src/com/fr/design/beans/location/Absorptionline.java
  11. 229
      designer_base/src/com/fr/design/beans/location/MoveUtils.java
  12. 48
      designer_base/src/com/fr/design/beans/location/WidgetForbidWindow.java
  13. 4
      designer_base/src/com/fr/design/designer/creator/CRPropertyDescriptor.java
  14. 20
      designer_base/src/com/fr/design/fun/ParameterWindowEditorProcessor.java
  15. 31
      designer_base/src/com/fr/design/fun/impl/AbstractParameterWindowEditorProcessor.java
  16. 3
      designer_base/src/com/fr/design/gui/columnrow/ColumnRowPane.java
  17. 123
      designer_base/src/com/fr/design/gui/ispinner/ColumnRowSpinner.java
  18. 7
      designer_base/src/com/fr/design/gui/style/AlignmentPane.java
  19. BIN
      designer_base/src/com/fr/design/images/form/toolbar/ChartF-MultiPie.png
  20. BIN
      designer_base/src/com/fr/design/images/form/toolbar/ChartF-TreeMap.png
  21. BIN
      designer_base/src/com/fr/design/images/poly/toolbar/Plugin-ChartF_NewMultiPie.png
  22. BIN
      designer_base/src/com/fr/design/images/poly/toolbar/Plugin-ChartF_NewTreeMap.png
  23. 1
      designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java
  24. 8
      designer_base/src/com/fr/design/style/AlignmentPane.java
  25. 57
      designer_chart/build.gradle
  26. 20
      designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java
  27. 30
      designer_chart/src/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java
  28. 5
      designer_chart/src/com/fr/design/mainframe/chart/gui/data/NormalChartDataPane.java
  29. 1
      designer_chart/src/com/fr/design/mainframe/chart/gui/style/datalabel/ChartLabelFontPane.java
  30. 65
      designer_form/build.gradle
  31. 33
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java
  32. 21
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRBodyFitLayoutAdapter.java
  33. 12
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java
  34. 56
      designer_form/src/com/fr/design/designer/beans/location/AccessDirection.java
  35. 74
      designer_form/src/com/fr/design/designer/beans/location/Inner.java
  36. 7
      designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java
  37. 13
      designer_form/src/com/fr/design/designer/beans/models/StateModel.java
  38. 26
      designer_form/src/com/fr/design/designer/beans/painters/FRAbsoluteLayoutPainter.java
  39. 83
      designer_form/src/com/fr/design/designer/creator/XChartEditor.java
  40. 8
      designer_form/src/com/fr/design/designer/creator/XCreator.java
  41. 26
      designer_form/src/com/fr/design/designer/creator/XLayoutContainer.java
  42. 88
      designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java
  43. 20
      designer_form/src/com/fr/design/designer/creator/XWBodyFitLayout.java
  44. 4
      designer_form/src/com/fr/design/designer/creator/XWFitLayout.java
  45. 25
      designer_form/src/com/fr/design/designer/creator/XWParameterLayout.java
  46. 8
      designer_form/src/com/fr/design/designer/creator/cardlayout/XCardAddButton.java
  47. 5
      designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java
  48. 8
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java
  49. 98
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java
  50. 6
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java
  51. 6
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTitleLayout.java
  52. 7
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java
  53. 63
      designer_form/src/com/fr/design/designer/properties/BodyAppRelayoutTable.java
  54. 111
      designer_form/src/com/fr/design/designer/properties/BodyMobileLayoutPropertiesGroupModel.java
  55. 8
      designer_form/src/com/fr/design/designer/properties/mobile/BodyMobilePropertyUI.java
  56. 2
      designer_form/src/com/fr/design/gui/core/FormWidgetOption.java
  57. 183
      designer_form/src/com/fr/design/mainframe/EditingMouseListener.java
  58. 7
      designer_form/src/com/fr/design/mainframe/FormCreatorDropTarget.java
  59. 17
      designer_form/src/com/fr/design/mainframe/FormDesigner.java
  60. 15
      sonar-project.properties
  61. 1
      start.bat

3
designer/src/com/fr/design/mainframe/bbs/BBSLoginDialog.java

@ -279,8 +279,10 @@ public class BBSLoginDialog extends UIDialog {
* @return 同上 * @return 同上
*/ */
public static boolean login(String username, String password) { public static boolean login(String username, String password) {
if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password)) {
try { try {
username = URLEncoder.encode(username, EncodeConstants.ENCODING_GBK); username = URLEncoder.encode(username, EncodeConstants.ENCODING_GBK);
password = URLEncoder.encode(password, EncodeConstants.ENCODING_GBK);
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
FRLogger.getLogger().error(e.getMessage()); FRLogger.getLogger().error(e.getMessage());
} }
@ -297,6 +299,7 @@ public class BBSLoginDialog extends UIDialog {
FRLogger.getLogger().error(e.getMessage()); FRLogger.getLogger().error(e.getMessage());
} }
} }
}
return false; return false;
} }

20
designer/src/com/fr/design/module/DesignerModule.java

@ -14,15 +14,8 @@ import com.fr.design.actions.insert.flot.ImageFloatAction;
import com.fr.design.actions.insert.flot.TextBoxFloatAction; import com.fr.design.actions.insert.flot.TextBoxFloatAction;
import com.fr.design.actions.server.StyleListAction; import com.fr.design.actions.server.StyleListAction;
import com.fr.design.fun.ElementUIProvider; import com.fr.design.fun.ElementUIProvider;
import com.fr.design.gui.controlpane.NameObjectCreator;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.hyperlink.ReportletHyperlinkPane;
import com.fr.design.hyperlink.WebHyperlinkPane;
import com.fr.design.javascript.EmailPane;
import com.fr.design.javascript.JavaScriptImplPane;
import com.fr.design.javascript.ParameterJavaScriptPane;
import com.fr.design.javascript.ProcessTransitionAdapter; import com.fr.design.javascript.ProcessTransitionAdapter;
import com.fr.design.mainframe.*; import com.fr.design.mainframe.*;
import com.fr.design.mainframe.bbs.BBSGuestPane; import com.fr.design.mainframe.bbs.BBSGuestPane;
@ -38,7 +31,6 @@ import com.fr.general.*;
import com.fr.general.xml.GeneralXMLTools; import com.fr.general.xml.GeneralXMLTools;
import com.fr.io.importer.Excel2007ReportImporter; import com.fr.io.importer.Excel2007ReportImporter;
import com.fr.io.importer.ExcelReportImporter; import com.fr.io.importer.ExcelReportImporter;
import com.fr.js.*;
import com.fr.main.impl.WorkBook; import com.fr.main.impl.WorkBook;
import com.fr.plugin.ExtraClassManager; import com.fr.plugin.ExtraClassManager;
import com.fr.quickeditor.ChartQuickEditor; import com.fr.quickeditor.ChartQuickEditor;
@ -55,10 +47,11 @@ import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.bridge.StableFactory; import com.fr.stable.bridge.StableFactory;
import com.fr.stable.fun.LogProvider; import com.fr.stable.fun.LogProvider;
import com.fr.stable.module.Module;
import com.fr.stable.plugin.PluginSimplify; import com.fr.stable.plugin.PluginSimplify;
import com.fr.stable.script.CalculatorProviderContext; import com.fr.stable.script.CalculatorProviderContext;
import com.fr.stable.script.ValueConverter; import com.fr.stable.script.ValueConverter;
import com.fr.stable.web.ServletContext;
import com.fr.stable.web.ServletContextAdapter;
import com.fr.stable.xml.ObjectTokenizer; import com.fr.stable.xml.ObjectTokenizer;
import com.fr.stable.xml.ObjectXMLWriterFinder; import com.fr.stable.xml.ObjectXMLWriterFinder;
import com.fr.start.BBSGuestPaneProvider; import com.fr.start.BBSGuestPaneProvider;
@ -75,6 +68,15 @@ import java.util.Set;
public class DesignerModule extends DesignModule { public class DesignerModule extends DesignModule {
static {
ServletContext.addServletContextListener(new ServletContextAdapter() {
public void onServletStart() {
ModuleContext.startModule(DesignerModule.class.getName());
}
});
}
/** /**
* 启动设计器模块 * 启动设计器模块
*/ */

80
designer/src/com/fr/design/report/freeze/RepeatAndFreezeSettingPane.java

@ -1,17 +1,23 @@
package com.fr.design.report.freeze; package com.fr.design.report.freeze;
import java.awt.BorderLayout; import java.awt.*;
import java.awt.Color; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory; import javax.swing.*;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.UIDialog;
import com.fr.design.extra.PluginManagerPane;
import com.fr.design.extra.PluginShopDialog;
import com.fr.design.extra.PluginWebBridge;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.ActionLabel;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.page.ReportPageAttrProvider; import com.fr.page.ReportPageAttrProvider;
import com.fr.stable.ColumnRow; import com.fr.stable.ColumnRow;
@ -22,6 +28,10 @@ import com.fr.stable.bridge.StableFactory;
* Sets Report Page Attributes * Sets Report Page Attributes
*/ */
public class RepeatAndFreezeSettingPane extends BasicPane { public class RepeatAndFreezeSettingPane extends BasicPane {
//边框高度
private static final int LABEL_HEIGHT = 45;
// 重复标题行 // 重复标题行
private RepeatRowPane repeatTitleRowPane; private RepeatRowPane repeatTitleRowPane;
// 重复标题列 // 重复标题列
@ -206,7 +216,15 @@ public class RepeatAndFreezeSettingPane extends BasicPane {
JPanel repeatPanel = FRGUIPaneFactory.createNColumnGridInnerContainer_S_Pane(1); JPanel repeatPanel = FRGUIPaneFactory.createNColumnGridInnerContainer_S_Pane(1);
repeatPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); repeatPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0));
JPanel freezePanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel freezePanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
//自适应插件
JPanel infoPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("FR-Designer_Attention"));
BoxCenterAligmentPane actionLabel = getURLActionLabel(Inter.getLocText("FR-Designer_Form-Fit-Tip"));
infoPane.add(actionLabel, BorderLayout.SOUTH);
outfreezePanel.add(freezePanel); outfreezePanel.add(freezePanel);
this.add(infoPane, BorderLayout.SOUTH);
// 重复打印部分 // 重复打印部分
// 重复打印标题的起始行 // 重复打印标题的起始行
JPanel labelPanel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); JPanel labelPanel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
@ -536,4 +554,58 @@ public class RepeatAndFreezeSettingPane extends BasicPane {
return null; return null;
} }
private BoxCenterAligmentPane getURLActionLabel(final String text) {
ActionLabel actionLabel = new ActionLabel(text);
actionLabel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
//Desktop.getDesktop().browse(new URI(url));
final PluginManagerPane managerPane = new PluginManagerPane();
UIDialog dlg = new PluginShopDialog(DesignerContext.getDesignerFrame(),managerPane);
PluginWebBridge.getHelper().setDialogHandle(dlg);
dlg.setVisible(true);
RepeatAndFreezeSettingPane.this.getTopLevelAncestor().setVisible(false);
} catch (Exception exp) {
}
}
});
return new BoxCenterAligmentPane(actionLabel);
}
class BoxCenterAligmentPane extends JPanel {
private UILabel textLabel;
public BoxCenterAligmentPane(String text) {
this(new UILabel(text));
}
public BoxCenterAligmentPane(UILabel label) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel centerPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
this.add(centerPane, BorderLayout.CENTER);
UILabel label1 = new UILabel(Inter.getLocText("FR-Designer_Form-Frozen-Tip"));
label1.setForeground(new Color(255, 0, 0));
UILabel label2 = new UILabel(Inter.getLocText("FR-Designer_Form-Forzen-Speed"));
label2.setForeground(new Color(255, 0, 0));
this.textLabel = label;
centerPane.add(label1);
centerPane.add(textLabel);
centerPane.add(label2);
}
public void setFont(Font font) {
super.setFont(font);
if (textLabel != null) {
textLabel.setFont(font);
}
}
}
} }

10
designer/src/com/fr/design/webattr/EditToolBar.java

@ -63,16 +63,8 @@ public class EditToolBar extends BasicPane {
private ListSelectionListener listSelectionListener = new ListSelectionListener() { private ListSelectionListener listSelectionListener = new ListSelectionListener() {
public void valueChanged(ListSelectionEvent evt) { public void valueChanged(ListSelectionEvent evt) {
if (lastButton != null && lastButton.getWidget() instanceof Button) { if (lastButton != null) {
if (!((list.getSelectedValue() instanceof ToolBarButton)
&& ((ToolBarButton)(list.getSelectedValue())).getWidget() instanceof CustomToolBarButton)) {
lastButton.setWidget(bp.update()); lastButton.setWidget(bp.update());
} else {
((Button) lastButton.getWidget()).setShowIcon(bp.icon.isSelected());
((Button) lastButton.getWidget()).setShowText(bp.text.isSelected());
((Button) lastButton.getWidget()).setText(bp.nameField.getText());
((Button) lastButton.getWidget()).setIconName(bp.iconPane.update());
}
} }
if (list.getSelectedValue() instanceof ToolBarButton) { if (list.getSelectedValue() instanceof ToolBarButton) {
lastButton = (ToolBarButton) list.getSelectedValue(); lastButton = (ToolBarButton) list.getSelectedValue();

10
designer/src/com/fr/design/write/submit/SubmitVisitorListPane.java

@ -173,10 +173,9 @@ public class SubmitVisitorListPane extends ObjectJControlPane {
comboItemsMap = new HashMap<>(); comboItemsMap = new HashMap<>();
Set<SubmitProvider> providers = ExtraDesignClassManager.getInstance().getArray(SubmitProvider.MARK_STRING); Set<SubmitProvider> providers = ExtraDesignClassManager.getInstance().getArray(SubmitProvider.MARK_STRING);
providers.add(new DefaultSubmit()); addSubmitPane(new DefaultSubmit());
for (SubmitProvider provider : providers) { for (SubmitProvider provider : providers) {
customSubmitPanes.put(provider.keyForSubmit(), provider.appearanceForSubmit()); addSubmitPane(provider);
comboItemsMap.put(provider.keyForSubmit(), provider.dataForSubmit());
} }
configTypes = new ArrayList<>(); configTypes = new ArrayList<>();
@ -211,6 +210,11 @@ public class SubmitVisitorListPane extends ObjectJControlPane {
}); });
} }
private void addSubmitPane(SubmitProvider provider) {
customSubmitPanes.put(provider.keyForSubmit(), provider.appearanceForSubmit());
comboItemsMap.put(provider.keyForSubmit(), provider.dataForSubmit());
}
@Override @Override
public void populateBean(WClassSubmiterProvider ob) { public void populateBean(WClassSubmiterProvider ob) {
editing = ob; editing = ob;

40
designer/src/com/fr/poly/hanlder/BottomCornerMouseHanlder.java

@ -103,7 +103,7 @@ public class BottomCornerMouseHanlder extends MouseInputAdapter {
Rectangle bounds = block.getBounds().toRectangle(resolution); Rectangle bounds = block.getBounds().toRectangle(resolution);
Point resultPoint = MoveUtils.sorption(bounds.x + dragStart.x < 0 ? 0 : bounds.x + dragStart.x, bounds.y Point resultPoint = MoveUtils.sorption(bounds.x + dragStart.x < 0 ? 0 : bounds.x + dragStart.x, bounds.y
+ dragStart.y < 0 ? 0 : bounds.y + dragStart.y, bounds.width, bounds.height, rectDesigner); + dragStart.y < 0 ? 0 : bounds.y + dragStart.y, bounds.width, bounds.height, rectDesigner, false);
block.setBounds(new UnitRectangle(new Rectangle(resultPoint.x, resultPoint.y, bounds.width, bounds.height), block.setBounds(new UnitRectangle(new Rectangle(resultPoint.x, resultPoint.y, bounds.width, bounds.height),
resolution)); resolution));
designer.repaint(); designer.repaint();
@ -125,6 +125,16 @@ public class BottomCornerMouseHanlder extends MouseInputAdapter {
return getRectangleIt(); return getRectangleIt();
} }
/**
* 设置等距线
*
* @param line 吸附线
*/
@Override
public void setEquidistantLine(Absorptionline line) {
}
/** /**
* 获取当前选中块的垂直线数组 * 获取当前选中块的垂直线数组
* *
@ -145,6 +155,34 @@ public class BottomCornerMouseHanlder extends MouseInputAdapter {
return editor.getValue().getHorizontalLine(); return editor.getValue().getHorizontalLine();
} }
/**
* 设置designer内部组件是否重叠的标志位
*
* @param isIntersects 是否重叠
*/
@Override
public void setWidgetsIntersects(boolean isIntersects) {
}
/**
* 获取designer内部组件是否重叠的标志位
*
* @return 重叠
*/
@Override
public boolean getWidgetsIntersects() {
return false;
}
/**
* 获取designer相对屏幕的位置
*
* @return 位置
*/
@Override
public Point getDesignerLocationOnScreen() {
return null;
}
}; };
private RectangleIterator getRectangleIt(){ private RectangleIterator getRectangleIt(){

61
designer_base/build.gradle

@ -0,0 +1,61 @@
apply plugin: 'java'
tasks.withType(JavaCompile){
options.encoding = 'UTF-8'
}
version='8.0'
jar{
baseName='fr-designer-core'
}
def srcDir="${System.getenv()['JENKINS_HOME']}/workspace/design"
def libDir="${System.getenv()['JENKINS_HOME']}/workspace/lib"
sourceSets{
main{
java{
srcDirs=["${srcDir}/designer_base/src"]
}
}
}
dependencies{
compile fileTree(dir:'../../',include:'**/*.jar')
compile fileTree(dir:libDir,include:'*.jar')
compile fileTree(dir:"${libDir}/jetty",include:'*.jar')
testCompile 'junit:junit:4.12'
}
task copyFile(type:Copy,dependsOn:compileJava){
copy{
from ("${srcDir}/designer_base/src"){
exclude '**/*.java'
}
into 'build/classes/main'
}
}
//ѹËõÏîÄ¿ÖеÄjsÎļþ
task compressJS{
ant.taskdef(name:'yuicompress',classname:'com.yahoo.platform.yui.compressor.YUICompressTask'){
classpath {
fileset(dir:'../../lib',includes:'*.jar')
}
}
ant.yuicompress(linebreak:"500",warn:"false", munge:"yes",preserveallsemicolons:"false", , charset:"utf-8",encoding:"utf-8",outputfolder:'build/classes/main'){
fileset (dir:"${srcDir}/designer_base/src"){
include (name:'**/*.js')
}
}
}
jar.dependsOn compressJS

3
designer_base/src/com/fr/design/actions/help/AboutPane.java

@ -11,6 +11,7 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.general.SiteCenter;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.bridge.StableFactory; import com.fr.stable.bridge.StableFactory;
@ -69,6 +70,8 @@ public class AboutPane extends JPanel {
boxCenterAlignmentPane = new BoxCenterAligmentPane(Inter.getLocText("Service_Phone") + ProductConstants.COMPARE_TELEPHONE); boxCenterAlignmentPane = new BoxCenterAligmentPane(Inter.getLocText("Service_Phone") + ProductConstants.COMPARE_TELEPHONE);
contentPane.add(boxCenterAlignmentPane); contentPane.add(boxCenterAlignmentPane);
} }
boxCenterAlignmentPane = new BoxCenterAligmentPane("QQ:" + SiteCenter.getInstance().acquireUrlByKind("help.qq"));
contentPane.add(boxCenterAlignmentPane);
BoxCenterAligmentPane actionLabel = getURLActionLabel(ProductConstants.WEBSITE_URL); BoxCenterAligmentPane actionLabel = getURLActionLabel(ProductConstants.WEBSITE_URL);
BoxCenterAligmentPane emailLabel = getEmailActionLabel(ProductConstants.SUPPORT_EMAIL); BoxCenterAligmentPane emailLabel = getEmailActionLabel(ProductConstants.SUPPORT_EMAIL);

2
designer_base/src/com/fr/design/beans/BasicBeanPane.java

@ -7,6 +7,8 @@ import com.fr.design.dialog.BasicPane;
*/ */
public abstract class BasicBeanPane<T> extends BasicPane { public abstract class BasicBeanPane<T> extends BasicPane {
/** /**
* Populate. * Populate.
*/ */

207
designer_base/src/com/fr/design/beans/location/Absorptionline.java

@ -1,24 +1,44 @@
package com.fr.design.beans.location; package com.fr.design.beans.location;
import java.awt.Color; import java.awt.*;
import java.awt.Graphics;
import com.fr.base.GraphHelper; import com.fr.base.GraphHelper;
import com.fr.design.scrollruler.ScrollRulerComponent; import com.fr.design.scrollruler.ScrollRulerComponent;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.third.org.hsqldb.lib.Collection;
public class Absorptionline { public class Absorptionline {
//箭头线前段为4px的等边三角形,给定了一个点的坐标,计算一下剩下两个点的坐标偏移量
//而且箭头分为四个朝向,故有四组坐标(2根号3 约为 3)
// 1.(x,y)(x+2,y±2根号3)(x-2,y±2根号3)
// 2.(x,y)(x±2根号3,y-2)(x±2根号3,y+2)
private static int RECTANGLE_OFFSET_X = 2;
private static int RECTANGLE_OFFSET_Y = 3;
private static int WIDGET_DISTANCE_MIN = 8;
//控件周围八个拖拽框的大小
private static int RESIZE_BOX_SIZE = 5;
private static Absorptionline lineInX = new Absorptionline(null, null, null, true); private static Absorptionline lineInX = new Absorptionline(null, null, null, true);
private static Absorptionline lineInY = new Absorptionline(null, null, null, false); private static Absorptionline lineInY = new Absorptionline(null, null, null, false);
private static Absorptionline lineEquidistant = new Absorptionline(null, null, null, true);
private Color lineColor = new Color(228, 225, 199); private Color lineColor = new Color(228, 225, 199);
private Color midLineColor = new Color(196, 227, 237); private Color midLineColor = new Color(196, 227, 237);
private Color equidistantLineColor = new Color(0xff, 0x0d, 0x7b);
private Integer x1; private Integer x1;
private Integer x2; private Integer x2;
private Integer middle; private Integer middle;
private int[] verticalLines; private int[] verticalLines;
private int[] horizontalLines; private int[] horizontalLines;
private int top;
private int left;
private int bottom;
private int right;
private Rectangle equidistantStart;
private boolean trans; private boolean trans;
/** /**
@ -89,6 +109,19 @@ public class Absorptionline {
return lineInY; return lineInY;
} }
/**
* 创建等距线
* @return 等距线
*/
public static Absorptionline createEquidistantAbsorptionline(Rectangle equidistantStart, int top, int left, int bottom, int right) {
lineEquidistant.equidistantStart = equidistantStart;
lineEquidistant.top = top;
lineEquidistant.left = left;
lineEquidistant.bottom = bottom;
lineEquidistant.right = right;
return lineEquidistant;
}
private Absorptionline(Integer x1, Integer x2, Integer middleInX, boolean trans) { private Absorptionline(Integer x1, Integer x2, Integer middleInX, boolean trans) {
this.x1 = x1; this.x1 = x1;
this.x2 = x2; this.x2 = x2;
@ -186,5 +219,175 @@ public class Absorptionline {
} }
} }
//画等距线
if (equidistantStart != null) {
g.setColor(equidistantLineColor);
if (top > 0) {
paintTopEquidistantLine(g);
}
if (left > 0) {
paintLeftEquidistantLine(g);
}
if (bottom > 0) {
paintBottomEquidistantLine(g);
}
if (right > 0) {
paintRightEquidistantLine(g);
}
}
}
//朝向上方的等距线
private void paintTopEquidistantLine(Graphics g){
int x[] = {
equidistantStart.x + equidistantStart.width / 2,
equidistantStart.x + equidistantStart.width / 2 - RECTANGLE_OFFSET_X,
equidistantStart.x + equidistantStart.width / 2 + RECTANGLE_OFFSET_X
};
int[] y1, y2;
if (equidistantStart.y - top > WIDGET_DISTANCE_MIN) {
y1 = new int[] {
top,
top + RECTANGLE_OFFSET_Y,
top + RECTANGLE_OFFSET_Y
};
y2 = new int[]{
equidistantStart.y - RESIZE_BOX_SIZE,
equidistantStart.y - RESIZE_BOX_SIZE - RECTANGLE_OFFSET_Y,
equidistantStart.y - RESIZE_BOX_SIZE - RECTANGLE_OFFSET_Y
};
}
else{
y1 = new int[] {
top,
top - RECTANGLE_OFFSET_Y,
top - RECTANGLE_OFFSET_Y
};
y2 = new int[] {
equidistantStart.y,
equidistantStart.y + RECTANGLE_OFFSET_Y,
equidistantStart.y + RECTANGLE_OFFSET_Y
};
}
g.fillPolygon(x, y1, 3);
g.fillPolygon(x, y2, 3);
GraphHelper.drawLine(g,
equidistantStart.x + equidistantStart.width / 2, top,
equidistantStart.x + equidistantStart.width / 2, equidistantStart.y - RESIZE_BOX_SIZE);
}
//朝向左侧的等距线
private void paintLeftEquidistantLine(Graphics g){
int y[] = {
equidistantStart.y + equidistantStart.height / 2,
equidistantStart.y + equidistantStart.height / 2 - RECTANGLE_OFFSET_X,
equidistantStart.y + equidistantStart.height / 2 + RECTANGLE_OFFSET_X,
};
int[] x1, x2;
if (equidistantStart.x - left > WIDGET_DISTANCE_MIN) {
x1 = new int[] {
left,
left + RECTANGLE_OFFSET_Y,
left + RECTANGLE_OFFSET_Y,
};
x2 = new int[] {
equidistantStart.x - RESIZE_BOX_SIZE,
equidistantStart.x - RESIZE_BOX_SIZE - RECTANGLE_OFFSET_Y,
equidistantStart.x - RESIZE_BOX_SIZE - RECTANGLE_OFFSET_Y
};
}
else{
x1 = new int[] {
left,
left - RECTANGLE_OFFSET_Y,
left - RECTANGLE_OFFSET_Y,
};
x2 = new int[] {
equidistantStart.x,
equidistantStart.x + RECTANGLE_OFFSET_Y,
equidistantStart.x + RECTANGLE_OFFSET_Y
};
}
g.fillPolygon(x1, y, 3);
g.fillPolygon(x2, y, 3);
GraphHelper.drawLine(g,
left, equidistantStart.y + equidistantStart.height / 2,
equidistantStart.x, equidistantStart.y + equidistantStart.height / 2);
}
//朝向下方的等距线
private void paintBottomEquidistantLine(Graphics g) {
int x[] = {
equidistantStart.x + equidistantStart.width / 2,
equidistantStart.x + equidistantStart.width / 2 + RECTANGLE_OFFSET_X,
equidistantStart.x + equidistantStart.width / 2 - RECTANGLE_OFFSET_X,
};
int[] y1, y2;
if (bottom - equidistantStart.y + equidistantStart.height > WIDGET_DISTANCE_MIN) {
y1 = new int[] {
equidistantStart.y + equidistantStart.height + RESIZE_BOX_SIZE,
equidistantStart.y + equidistantStart.height + RESIZE_BOX_SIZE + RECTANGLE_OFFSET_Y,
equidistantStart.y + equidistantStart.height + RESIZE_BOX_SIZE + RECTANGLE_OFFSET_Y,
};
y2 = new int[] {
bottom,
bottom - RECTANGLE_OFFSET_Y,
bottom - RECTANGLE_OFFSET_Y
};
}
else{
y1 = new int[] {
equidistantStart.y + equidistantStart.height,
equidistantStart.y + equidistantStart.height - RECTANGLE_OFFSET_Y,
equidistantStart.y + equidistantStart.height - RECTANGLE_OFFSET_Y,
};
y2 = new int[] {
bottom,
bottom + RECTANGLE_OFFSET_Y,
bottom + RECTANGLE_OFFSET_Y
};
}
g.fillPolygon(x, y1, 3);
g.fillPolygon(x, y2, 3);
GraphHelper.drawLine(g,
equidistantStart.x + equidistantStart.width / 2, equidistantStart.y + equidistantStart.height,
equidistantStart.x + equidistantStart.width / 2, bottom);
}
//朝向右侧的等距线
private void paintRightEquidistantLine(Graphics g){
int y[] = {
equidistantStart.y + equidistantStart.height / 2,
equidistantStart.y + equidistantStart.height / 2 - RECTANGLE_OFFSET_X,
equidistantStart.y + equidistantStart.height / 2 + RECTANGLE_OFFSET_X
};
int[] x1, x2;
if(right - equidistantStart.x > WIDGET_DISTANCE_MIN) {
x1 = new int[]{
right,
right - RECTANGLE_OFFSET_Y,
right - RECTANGLE_OFFSET_Y
};
x2 = new int[]{
equidistantStart.x + equidistantStart.width + RESIZE_BOX_SIZE,
equidistantStart.x + equidistantStart.width + RESIZE_BOX_SIZE + RECTANGLE_OFFSET_Y,
equidistantStart.x + equidistantStart.width + RESIZE_BOX_SIZE + RECTANGLE_OFFSET_Y
};
}
else{
x1 = new int[]{
right,
right + RECTANGLE_OFFSET_Y,
right + RECTANGLE_OFFSET_Y
};
x2 = new int[]{
equidistantStart.x + equidistantStart.width,
equidistantStart.x + equidistantStart.width - RECTANGLE_OFFSET_Y,
equidistantStart.x + equidistantStart.width - RECTANGLE_OFFSET_Y
};
}
g.fillPolygon(x1, y, 3);
g.fillPolygon(x2, y, 3);
GraphHelper.drawLine(g,
equidistantStart.x + equidistantStart.width, equidistantStart.y + equidistantStart.height / 2,
right, equidistantStart.y + equidistantStart.height / 2);
} }
} }

229
designer_base/src/com/fr/design/beans/location/MoveUtils.java

@ -3,6 +3,8 @@
*/ */
package com.fr.design.beans.location; package com.fr.design.beans.location;
import com.fr.stable.ArrayUtils;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.util.ArrayList; import java.util.ArrayList;
@ -17,6 +19,10 @@ public class MoveUtils {
public static final int SORPTION_UNIT = 5; public static final int SORPTION_UNIT = 5;
public static WidgetForbidWindow widgetForbidWindow = new WidgetForbidWindow();
public static ArrayList<EquidistantLine> equidistantLines = new ArrayList<>();
private MoveUtils() { private MoveUtils() {
} }
@ -68,6 +74,30 @@ public class MoveUtils {
* *
*/ */
int[] getHorizontalLine(); int[] getHorizontalLine();
/**
* 设置designer内部组件是否重叠的标志位
* @param isIntersects 是否重叠
*/
void setWidgetsIntersects(boolean isIntersects);
/**
* 获取designer内部组件是否重叠的标志位
* @return 重叠
*/
boolean getWidgetsIntersects();
/**
* 获取designer相对屏幕的位置
* @return 位置
*/
Point getDesignerLocationOnScreen();
/**
* 设置等距线
* @param line 吸附线
*/
void setEquidistantLine(Absorptionline line);
} }
public interface RectangleIterator { public interface RectangleIterator {
@ -183,6 +213,53 @@ public class MoveUtils {
} }
} }
private static void findEquidistantLine(Rectangle bounds, int left, int top, int height, int width) {
//最近的距离与坐标
EquidistantLine equidistantLineInfo = new EquidistantLine(0, 0, 0);
//等距线从各边中点画出,先要判断是不是在范围内
int topMiddleX = left + width / 2;
int leftMiddleY = top + height / 2;
if ((topMiddleX > bounds.getX()) && (topMiddleX < (bounds.getX() + bounds.getWidth()))){
//当前操作rec在bounds的下方
if (top > (bounds.getY() + bounds.getHeight())){
equidistantLineInfo.setDistance(top - (bounds.y + bounds.height));
equidistantLineInfo.setReference(bounds.y + bounds.height);
equidistantLineInfo.setDirection(SwingConstants.TOP);
}
//当前操作rec在bounds上方
if ((top + height) < bounds.getY()){
equidistantLineInfo.setDistance(bounds.y - (top + height));
equidistantLineInfo.setReference(bounds.y);
equidistantLineInfo.setDirection(SwingConstants.BOTTOM);
}
}
else if ((leftMiddleY > bounds.getY()) && (leftMiddleY < (bounds.getY() + bounds.getHeight()))){
//当前操作rec在bounds的右侧
if (left > (bounds.getX() + bounds.getWidth())){
equidistantLineInfo.setDistance(left - (bounds.x + bounds.width));
equidistantLineInfo.setReference(bounds.x + bounds.width);
equidistantLineInfo.setDirection(SwingConstants.LEFT);
}
//当前操作rec在bounds的左侧
if ((left + width) < bounds.getX()){
equidistantLineInfo.setDistance(bounds.x - (left + width));
equidistantLineInfo.setReference(bounds.x);
equidistantLineInfo.setDirection(SwingConstants.RIGHT);
}
}
if(equidistantLineInfo.getDistance() > 0) {
equidistantLines.add(equidistantLineInfo);
}
}
public static void displayForbidWindow(int x, int y) {
widgetForbidWindow.showWindow(x, y);
}
public static void hideForbidWindow() {
widgetForbidWindow.hideWindow();
}
/** /**
* 吸附 * 吸附
* *
@ -197,28 +274,67 @@ public class MoveUtils {
* @date 2015-2-12-下午2:39:16 * @date 2015-2-12-下午2:39:16
* *
*/ */
public static Point sorption(int x, int y, int width, int height, RectangleDesigner designer) { public static Point sorption(int x, int y, int width, int height, RectangleDesigner designer, boolean isParameterLayout) {
int left = x, top = y, bottom = top + height, right = left + width; int left = x, top = y, bottom = top + height, right = left + width;
Rectangle operatingRectangle = new Rectangle(x, y, width, height);
equidistantLines.clear();
PlacePointing px = new PlacePointing(x); PlacePointing px = new PlacePointing(x);
PlacePointing py = new PlacePointing(y); PlacePointing py = new PlacePointing(y);
PlacePointing pEquidistantX = new PlacePointing(x);
PlacePointing pEquidistantY = new PlacePointing(y);
RectangleIterator iterator = designer.createRectangleIterator(); RectangleIterator iterator = designer.createRectangleIterator();
java.util.List<Rectangle> cacheRecs = new ArrayList<Rectangle>(); java.util.List<Rectangle> cacheRecs = new ArrayList<Rectangle>();
//是否存在控件重叠
boolean isWidgetsIntersects = false;
while (iterator.hasNext()) { while (iterator.hasNext()) {
Rectangle bounds = iterator.nextRectangle(); Rectangle bounds = iterator.nextRectangle();
cacheRecs.add(bounds); cacheRecs.add(bounds);
boolean isIntersects = operatingRectangle.intersects(bounds);
findX(px, bounds, left, right, width); findX(px, bounds, left, right, width);
findY(py, bounds, top, bottom, height); findY(py, bounds, top, bottom, height);
if (px.isFind() && py.isFind()) {
break; if(isIntersects && !isParameterLayout){
isWidgetsIntersects = true;
}
else{
findEquidistantLine(bounds, left, top, height, width);
} }
} }
showForbiddenWindow(designer, x, y, isWidgetsIntersects);
createXAbsorptionline(px, designer, width, cacheRecs); createXAbsorptionline(px, designer, width, cacheRecs);
createYAbsorptionline(py, designer, height, cacheRecs); createYAbsorptionline(py, designer, height, cacheRecs);
return new Point(px.palce, py.palce); operatingRectangle.x = px.palce;
operatingRectangle.y = py.palce;
createEquidistantLine(pEquidistantX, pEquidistantY, operatingRectangle, designer);
Point sorptionPoint = new Point(px.palce,py.palce);
if (!px.isFind()){
sorptionPoint.x = pEquidistantX.palce;
}
if (!py.isFind()){
sorptionPoint.y = pEquidistantY.palce;
}
return sorptionPoint;
}
public static void showForbiddenWindow(RectangleDesigner designer, int x, int y, boolean isIntersects){
if (isIntersects){
if(designer.getDesignerLocationOnScreen() != null) {
displayForbidWindow(x + designer.getDesignerLocationOnScreen().x, y + designer.getDesignerLocationOnScreen().y);
}
designer.setWidgetsIntersects(true);
}
else{
designer.setWidgetsIntersects(false);
hideForbidWindow();
}
} }
private static void createXAbsorptionline(PlacePointing px, RectangleDesigner designer, int width, java.util.List<Rectangle> cacheRecs) { private static void createXAbsorptionline(PlacePointing px, RectangleDesigner designer, int width, java.util.List<Rectangle> cacheRecs) {
@ -301,6 +417,72 @@ public class MoveUtils {
designer.setYAbsorptionline(line); designer.setYAbsorptionline(line);
} }
private static void createEquidistantLine(PlacePointing px, PlacePointing py, Rectangle operatingRectangle, RectangleDesigner designer){
processEquidistantLinesList(px, py, operatingRectangle);
Absorptionline line = null;
if(equidistantLines.size() > 0) {
int top = -1;
int left = -1;
int bottom = -1;
int right = -1;
for(int i = 0; i < equidistantLines.size(); i++){
if (equidistantLines.get(i).getDirection() == SwingConstants.TOP){
top = equidistantLines.get(i).getReference();
}
if (equidistantLines.get(i).getDirection() == SwingConstants.LEFT){
left = equidistantLines.get(i).getReference();
}
if (equidistantLines.get(i).getDirection() == SwingConstants.BOTTOM){
bottom = equidistantLines.get(i).getReference();
}
if (equidistantLines.get(i).getDirection() == SwingConstants.RIGHT){
right = equidistantLines.get(i).getReference();
}
}
line = Absorptionline.createEquidistantAbsorptionline(operatingRectangle, top, left, bottom, right);
}
designer.setEquidistantLine(line);
}
private static void processEquidistantLinesList(PlacePointing pEquidistantX, PlacePointing pEquidistantY, Rectangle operatingRectangle){
EquidistantLine[] equidistantLines1 = new EquidistantLine[4];
//先按方向处理,只保留四个方向上距离最近
for(int count = 0; count < equidistantLines.size(); count++){
for (int direction = 0; direction < 4; direction++){
if(equidistantLines.get(count).getDirection() == (direction + 1)){//direction 1,2,3,4 分别对应top,left,bottom,right
if(equidistantLines1[direction] != null
&& equidistantLines1[direction].getDistance() > equidistantLines.get(count).getDistance()
|| equidistantLines1[direction] == null) {
equidistantLines1[direction] = equidistantLines.get(count);
}
}
}
}
equidistantLines.clear();
//找list中横纵分别等距的组合
if (equidistantLines1[0] != null && equidistantLines1[2] != null){//top, bottom
int offset = equidistantLines1[0].getDistance() - equidistantLines1[2].getDistance();
if (Math.abs(offset) <= SORPTION_UNIT * 2){
pEquidistantY.direction = SwingConstants.TOP;
equidistantLines.add(equidistantLines1[0]);
equidistantLines.add(equidistantLines1[2]);
pEquidistantY.palce = operatingRectangle.y - offset / 2;
operatingRectangle.y = pEquidistantY.palce;
}
}
if (equidistantLines1[1] != null && equidistantLines1[3] != null){//left, right
int offset = equidistantLines1[1].getDistance() - equidistantLines1[3].getDistance();
if (Math.abs(offset) <= SORPTION_UNIT * 2){
pEquidistantX.direction = SwingConstants.LEFT;
equidistantLines.add(equidistantLines1[1]);
equidistantLines.add(equidistantLines1[3]);
pEquidistantX.palce = operatingRectangle.x - offset / 2;
operatingRectangle.x = pEquidistantX.palce;
}
}
}
//更新纵向行列线 //更新纵向行列线
private static void updateVerticalLine(int[] selfVertical, RectangleIterator iterator, Absorptionline line){ private static void updateVerticalLine(int[] selfVertical, RectangleIterator iterator, Absorptionline line){
int[] targetArray = iterator.getVerticalLine(); int[] targetArray = iterator.getVerticalLine();
@ -329,4 +511,43 @@ public class MoveUtils {
return false; return false;
} }
private static class EquidistantLine{
//与操作rectangle的距离
private int distance;
//参考rectangle的位置
private int reference;
//等距线的方向
private int direction;
EquidistantLine(int distance, int reference, int direction){
this.distance = distance;
this.reference = reference;
this.direction = direction;
}
public void setDistance(int distance){
this.distance = distance;
}
public int getDistance(){
return this.distance;
}
public void setReference(int reference){
this.reference = reference;
}
public int getReference(){
return this.reference;
}
public void setDirection(int direction){
this.direction = direction;
}
public int getDirection(){
return this.direction;
}
}
} }

48
designer_base/src/com/fr/design/beans/location/WidgetForbidWindow.java

@ -0,0 +1,48 @@
package com.fr.design.beans.location;
import com.fr.base.BaseUtils;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.icon.IconPathConstants;
import com.fr.general.Inter;
import javax.swing.*;
/**
* Created by zhouping on 2016/7/24.
*/
public class WidgetForbidWindow extends JWindow {
private static final int WIDTH = 150;
private static final int HEIGHT = 20;
private UIButton promptButton = new UIButton(Inter.getLocText("FR-Designer_Forbid_Widgets_Intersects"), BaseUtils.readIcon(IconPathConstants.FORBID_ICON_PATH));
/**
* 构造函数
*/
public WidgetForbidWindow() {
this.add(promptButton);
this.setSize(WIDTH, HEIGHT);
}
/**
* 在指定位置显示窗口, 默认将window的中心点放到指定位置上
*
* @param x x坐标
* @param y y坐标
*
*/
public void showWindow(int x, int y){
this.setLocation(x - WIDTH / 2, y - HEIGHT / 2);
this.setVisible(true);
}
/**
* 隐藏当前窗口
*
*/
public void hideWindow(){
this.setVisible(false);
}
}

4
designer_form/src/com/fr/design/designer/creator/CRPropertyDescriptor.java → designer_base/src/com/fr/design/designer/creator/CRPropertyDescriptor.java

@ -3,7 +3,6 @@
*/ */
package com.fr.design.designer.creator; package com.fr.design.designer.creator;
import com.fr.design.gui.xtable.AbstractPropertyGroupModel;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
@ -15,6 +14,7 @@ import java.beans.PropertyDescriptor;
* @since 6.5.3 * @since 6.5.3
*/ */
public final class CRPropertyDescriptor extends PropertyDescriptor { public final class CRPropertyDescriptor extends PropertyDescriptor {
public static final String RENDERER = "renderer";
private PropertyChangeAdapter l; private PropertyChangeAdapter l;
@ -51,7 +51,7 @@ public final class CRPropertyDescriptor extends PropertyDescriptor {
} }
public CRPropertyDescriptor setRendererClass(Class<?> clazz) { public CRPropertyDescriptor setRendererClass(Class<?> clazz) {
this.putKeyValue(AbstractPropertyGroupModel.RENDERER, clazz); this.putKeyValue(RENDERER, clazz);
return this; return this;
} }

20
designer_base/src/com/fr/design/fun/ParameterWindowEditorProcessor.java

@ -0,0 +1,20 @@
package com.fr.design.fun;
import com.fr.design.designer.creator.CRPropertyDescriptor;
import com.fr.stable.fun.mark.Immutable;
/**
* Created by zpc on 16/7/21.
*/
public interface ParameterWindowEditorProcessor extends Immutable {
String MARK_STRING = "ParameterWindowEditorProcessor";
int CURRENT_LEVEL = 1;
/**
* 生成属性表
*/
CRPropertyDescriptor[] createPropertyDescriptor(Class<?> temp);
}

31
designer_base/src/com/fr/design/fun/impl/AbstractParameterWindowEditorProcessor.java

@ -0,0 +1,31 @@
package com.fr.design.fun.impl;
import com.fr.design.designer.creator.CRPropertyDescriptor;
import com.fr.design.fun.ParameterWindowEditorProcessor;
import com.fr.stable.fun.mark.API;
/**
* Created by zpc on 2016/7/21.
*/
@API(level = ParameterWindowEditorProcessor.CURRENT_LEVEL)
public abstract class AbstractParameterWindowEditorProcessor implements ParameterWindowEditorProcessor {
public int currentAPILevel() {
return CURRENT_LEVEL;
}
public int layerIndex() {
return DEFAULT_LAYER_INDEX;
}
/**
* 生成属性表
*/
@Override
public CRPropertyDescriptor[] createPropertyDescriptor(Class<?> temp) {
return new CRPropertyDescriptor[0];
}
}

3
designer_base/src/com/fr/design/gui/columnrow/ColumnRowPane.java

@ -22,6 +22,7 @@ import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.ispinner.UIBasicSpinner; import com.fr.design.gui.ispinner.UIBasicSpinner;
import com.fr.design.gui.ispinner.UpperCaseSpinner; import com.fr.design.gui.ispinner.UpperCaseSpinner;
import com.fr.design.gui.ispinner.ColumnRowSpinner;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.stable.ColumnRow; import com.fr.stable.ColumnRow;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
@ -119,7 +120,7 @@ public class ColumnRowPane extends JPanel implements UIObserver {
protected void initRowSpinner() { protected void initRowSpinner() {
rowSpinner = new UIBasicSpinner((new SpinnerListModel(rowarray))) { rowSpinner = new ColumnRowSpinner((new SpinnerListModel(rowarray))) {
public boolean shouldResponseChangeListener() { public boolean shouldResponseChangeListener() {
return false; return false;
} }

123
designer_base/src/com/fr/design/gui/ispinner/ColumnRowSpinner.java

@ -0,0 +1,123 @@
package com.fr.design.gui.ispinner;
import java.text.ParseException;
import java.util.List;
import javax.swing.JComponent;
import javax.swing.JFormattedTextField;
import javax.swing.JSpinner;
import javax.swing.SpinnerDateModel;
import javax.swing.SpinnerListModel;
import javax.swing.SpinnerModel;
import javax.swing.SpinnerNumberModel;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.DefaultFormatterFactory;
import javax.swing.text.DocumentFilter;
import com.fr.stable.StableUtils;
//_kerry: 用来修复Spinner输入数字自动填充的bug
public class ColumnRowSpinner extends UIBasicSpinner {
public ColumnRowSpinner(SpinnerModel model) {
super(model);
}
protected JComponent createEditor(SpinnerModel model) {
if (model instanceof SpinnerDateModel) {
return new DateEditor(this);
} else if (model instanceof SpinnerListModel) {
return new FillBugEditor(this);
} else if (model instanceof SpinnerNumberModel) {
return new NumberEditor(this);
} else {
return new DefaultEditor(this);
}
}
private class FillBugEditor extends DefaultEditor {
public FillBugEditor(JSpinner spinner) {
super(spinner);
if (!(spinner.getModel() instanceof SpinnerListModel)) {
throw new IllegalArgumentException(
"model not a SpinnerListModel");
}
getTextField().setEditable(true);
getTextField().setFormatterFactory(
new DefaultFormatterFactory(new ListFormatter()));
}
public SpinnerListModel getModel() {
return (SpinnerListModel) (getSpinner().getModel());
}
private class ListFormatter extends
JFormattedTextField.AbstractFormatter {
private DocumentFilter filter;
public String valueToString(Object value) throws ParseException {
if (value == null) {
return "";
}
return value.toString();
}
public Object stringToValue(String string)
throws ParseException {
//add将行数转换成ABC
return string;
}
protected DocumentFilter getDocumentFilter() {
if (filter == null) {
filter = new Filter();
}
return filter;
}
private class Filter extends DocumentFilter {
public void replace(FilterBypass fb, int offset,
int length, String string, AttributeSet attrs)
throws BadLocationException {
if (string != null
&& (offset + length) == fb.getDocument()
.getLength()) {
List list = getModel().getList();
Object next = null;
for (int counter = 0; counter < list.size(); counter++) {
Object value = list.get(counter);
String str = value.toString();
if (str != null
&& str.startsWith(fb.getDocument()
.getText(0, offset)
+ string)) {
next = value;
break;
}
}
String value = (next != null) ? next.toString()
: null;
if (value != null) {
fb.remove(0, offset + length);
fb.insertString(0, value, null);
getFormattedTextField().select(
offset + string.length(),
value.length());
return;
}
}
super.replace(fb, offset, length, string, attrs);
}
public void insertString(FilterBypass fb, int offset,
String string, AttributeSet attr)
throws BadLocationException {
replace(fb, offset, 0, string, attr);
}
}
}
}
}

7
designer_base/src/com/fr/design/gui/style/AlignmentPane.java

@ -22,6 +22,7 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.plugin.ExtraClassManager; import com.fr.plugin.ExtraClassManager;
import com.fr.report.fun.VerticalTextProcessor; import com.fr.report.fun.VerticalTextProcessor;
import com.fr.report.fun.impl.DefaultVerticalTextProcessor;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import javax.swing.*; import javax.swing.*;
@ -134,10 +135,8 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO
private void initTextRotationCombox(){ private void initTextRotationCombox(){
ArrayList<String> selectOption = new ArrayList<String>(); ArrayList<String> selectOption = new ArrayList<String>();
selectOption.add(Inter.getLocText("FR-Designer_Custom-Angle")); selectOption.add(Inter.getLocText("FR-Designer_Custom-Angle"));
VerticalTextProcessor processor = ExtraClassManager.getInstance().getSingle(VerticalTextProcessor.XML_TAG); VerticalTextProcessor processor = ExtraClassManager.getInstance().getSingle(VerticalTextProcessor.XML_TAG, DefaultVerticalTextProcessor.class);
if (processor != null){
selectOption.addAll(Arrays.asList(processor.getComboxOption())); selectOption.addAll(Arrays.asList(processor.getComboxOption()));
}
textRotationComboBox = new UIComboBox(selectOption.toArray(new String[selectOption.size()])); textRotationComboBox = new UIComboBox(selectOption.toArray(new String[selectOption.size()]));
} }
@ -241,7 +240,7 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO
} else { } else {
this.textComboBox.setSelectedIndex(0); this.textComboBox.setSelectedIndex(0);
} }
if (style.getVerticalText() == Style.VERTICALTEXT && ExtraClassManager.getInstance().getSingle(VerticalTextProcessor.XML_TAG) != null) { if (style.getVerticalText() == Style.VERTICALTEXT) {
textRotationComboBox.setSelectedIndex(style.getTextDirection() == Style.LEFT_TO_RIGHT ? 1 : 2); textRotationComboBox.setSelectedIndex(style.getTextDirection() == Style.LEFT_TO_RIGHT ? 1 : 2);
} else { } else {
textRotationComboBox.setSelectedIndex(0); textRotationComboBox.setSelectedIndex(0);

BIN
designer_base/src/com/fr/design/images/form/toolbar/ChartF-MultiPie.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 861 B

BIN
designer_base/src/com/fr/design/images/form/toolbar/ChartF-TreeMap.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 269 B

BIN
designer_base/src/com/fr/design/images/poly/toolbar/Plugin-ChartF_NewMultiPie.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 861 B

BIN
designer_base/src/com/fr/design/images/poly/toolbar/Plugin-ChartF_NewTreeMap.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 269 B

1
designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java

@ -301,7 +301,6 @@ public abstract class ToolBarMenuDock {
if (ComparatorUtils.equals(ProductConstants.APP_NAME,FINEREPORT)) { if (ComparatorUtils.equals(ProductConstants.APP_NAME,FINEREPORT)) {
shortCuts.add(new FeedBackAction()); shortCuts.add(new FeedBackAction());
shortCuts.add(SeparatorDef.DEFAULT); shortCuts.add(SeparatorDef.DEFAULT);
shortCuts.add(new SupportQQAction());
shortCuts.add(SeparatorDef.DEFAULT); shortCuts.add(SeparatorDef.DEFAULT);
// shortCuts.add(new ForumAction()); // shortCuts.add(new ForumAction());
} }

8
designer_base/src/com/fr/design/style/AlignmentPane.java

@ -16,8 +16,6 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.plugin.ExtraClassManager;
import com.fr.report.fun.VerticalTextProcessor;
import com.fr.stable.CoreConstants; import com.fr.stable.CoreConstants;
import javax.swing.*; import javax.swing.*;
@ -126,9 +124,6 @@ public class AlignmentPane extends BasicPane {
directionBG.add(rightToLeftRB); directionBG.add(rightToLeftRB);
rightToLeftRB.setSelected(true); rightToLeftRB.setSelected(true);
if (ExtraClassManager.getInstance().getSingle(VerticalTextProcessor.XML_TAG) == null){
return;
}
isVerticalTextPanel.add(isVerticalTextCheckBox); isVerticalTextPanel.add(isVerticalTextCheckBox);
isVerticalTextPanel.add(leftToRightRB); isVerticalTextPanel.add(leftToRightRB);
isVerticalTextPanel.add(rightToLeftRB); isVerticalTextPanel.add(rightToLeftRB);
@ -302,9 +297,6 @@ public class AlignmentPane extends BasicPane {
} }
private void populateVertical(Style style){ private void populateVertical(Style style){
if (ExtraClassManager.getInstance().getSingle(VerticalTextProcessor.XML_TAG) == null){
return;
}
this.isVerticalTextCheckBox.setSelected(true); this.isVerticalTextCheckBox.setSelected(true);
this.rotationSpinner.setEnabled(false); this.rotationSpinner.setEnabled(false);
if (style.getTextDirection() == Style.LEFT_TO_RIGHT) { if (style.getTextDirection() == Style.LEFT_TO_RIGHT) {

57
designer_chart/build.gradle

@ -0,0 +1,57 @@
apply plugin: 'java'
tasks.withType(JavaCompile){
options.encoding = 'UTF-8'
}
version='8.0'
def srcDir="${System.getenv()['JENKINS_HOME']}/workspace/design"
def libDir="${System.getenv()['JENKINS_HOME']}/workspace/lib"
jar{
baseName='fr-designer-chart'
}
sourceSets{
main{
java{
srcDirs=["${srcDir}/designer_chart/src"]
}
}
}
dependencies{
compile fileTree(dir:'../../',include:'**/*.jar')
compile fileTree(dir:libDir,include:'*.jar')
compile fileTree(dir:"${libDir}/jetty",include:'*.jar')
testCompile 'junit:junit:4.12'
}
task copyFile(type:Copy,dependsOn:compileJava){
copy{
from ("${srcDir}/designer_chart/src"){
exclude '**/*.java'
}
into 'build/classes/main'
}
}
//ѹËõÏîÄ¿ÖеÄjsÎļþ
task compressJS{
ant.taskdef(name:'yuicompress',classname:'com.yahoo.platform.yui.compressor.YUICompressTask'){
classpath {
fileset(dir:'../../lib',includes:'*.jar')
}
}
ant.yuicompress(linebreak:"500",warn:"false", munge:"yes",preserveallsemicolons:"false", , charset:"utf-8",encoding:"utf-8",outputfolder:'build/classes/main'){
fileset (dir:"${srcDir}/designer_chart/src"){
include (name:'**/*.js')
}
}
}
jar.dependsOn compressJS

20
designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java

@ -58,7 +58,6 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh
if (classManager == null) { if (classManager == null) {
classManager = new ChartTypeInterfaceManager(); classManager = new ChartTypeInterfaceManager();
chartTypeInterfaces.clear(); chartTypeInterfaces.clear();
classManager.readXMLFile();
} }
return classManager; return classManager;
} }
@ -75,16 +74,15 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh
GeneralContext.addPluginReadListener(new PluginReadListener() { GeneralContext.addPluginReadListener(new PluginReadListener() {
@Override @Override
public void success() { public void success() {
if (chartTypeInterfaces != null) { ChartTypeInterfaceManager.getInstance().readDefault();
readDefault();
//重新注册designModuleFactory //重新注册designModuleFactory
DesignModuleFactory.registerExtraWidgetOptions(initWidgetOption()); DesignModuleFactory.registerExtraWidgetOptions(initWidgetOption());
} }
}
}); });
} }
public static WidgetOption[] initWidgetOption(){ public static WidgetOption[] initWidgetOption(){
ChartInternationalNameContentBean[] typeName = ChartTypeManager.getInstance().getAllChartBaseNames(); ChartInternationalNameContentBean[] typeName = ChartTypeManager.getInstance().getAllChartBaseNames();
ChartWidgetOption[] child = new ChartWidgetOption[typeName.length]; ChartWidgetOption[] child = new ChartWidgetOption[typeName.length];
for (int i = 0; i < typeName.length; i++) { for (int i = 0; i < typeName.length; i++) {
@ -101,7 +99,7 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh
} }
private synchronized static void envChanged() { private synchronized static void envChanged() {
chartTypeInterfaces.clear(); classManager = null;
} }
private static void readDefault() { private static void readDefault() {
@ -132,6 +130,12 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh
} }
} }
public static void addChartTypeInterface(IndependentChartUIProvider provider, String plotID) {
if (chartTypeInterfaces != null && !chartTypeInterfaces.containsKey(plotID)) {
chartTypeInterfaces.put(plotID, provider);
}
}
/** /**
* 增加界面接口定义 * 增加界面接口定义
* *
@ -141,7 +145,7 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh
public void addChartInterface(String className, String plotID, PluginSimplify simplify) { public void addChartInterface(String className, String plotID, PluginSimplify simplify) {
if (StringUtils.isNotBlank(className)) { if (StringUtils.isNotBlank(className)) {
try { try {
Class<?> clazz = loader.loadClass(className); Class<?> clazz = Class.forName(className);
Authorize authorize = clazz.getAnnotation(Authorize.class); Authorize authorize = clazz.getAnnotation(Authorize.class);
if (authorize != null) { if (authorize != null) {
PluginLicenseManager.getInstance().registerPaid(authorize, simplify); PluginLicenseManager.getInstance().registerPaid(authorize, simplify);
@ -149,8 +153,8 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh
IndependentChartUIProvider provider = (IndependentChartUIProvider) clazz.newInstance(); IndependentChartUIProvider provider = (IndependentChartUIProvider) clazz.newInstance();
if (PluginCollector.getCollector().isError(provider, IndependentChartUIProvider.CURRENT_API_LEVEL, simplify.getPluginName()) || !containsChart(plotID)) { if (PluginCollector.getCollector().isError(provider, IndependentChartUIProvider.CURRENT_API_LEVEL, simplify.getPluginName()) || !containsChart(plotID)) {
PluginMessage.remindUpdate(className); PluginMessage.remindUpdate(className);
} else if (!chartTypeInterfaces.containsKey(plotID)) { } else {
chartTypeInterfaces.put(plotID, provider); ChartTypeInterfaceManager.getInstance().addChartTypeInterface(provider, plotID);
} }
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
FRLogger.getLogger().error("class not found:" + e.getMessage()); FRLogger.getLogger().error("class not found:" + e.getMessage());

30
designer_chart/src/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java

@ -4,7 +4,6 @@ import com.fr.base.chart.BaseChartCollection;
import com.fr.chart.chartattr.Bar2DPlot; import com.fr.chart.chartattr.Bar2DPlot;
import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.ChartFactory;
import com.fr.chart.charttypes.ChartTypeManager; import com.fr.chart.charttypes.ChartTypeManager;
import com.fr.chart.web.ChartHyperPoplink; import com.fr.chart.web.ChartHyperPoplink;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
@ -43,7 +42,21 @@ public class ChartHyperPoplinkPane extends BasicBeanPane<ChartHyperPoplink> {
hyperEditPane = new ChartHyperEditPane(getChartParaType(), getValueEditorPane(), getValueEditorPane()); hyperEditPane = new ChartHyperEditPane(getChartParaType(), getValueEditorPane(), getValueEditorPane());
this.add(hyperEditPane, BorderLayout.CENTER); this.add(hyperEditPane, BorderLayout.CENTER);
ChartCollection cc = createChartCollection();
chartComponent = new ChartComponent();
chartComponent.setPreferredSize(new Dimension(220, 170));// 在单元格弹出时 需要调整保证属性表的大小.
chartComponent.setSupportEdit(false);
chartComponent.populate(cc);
this.add(chartComponent, BorderLayout.EAST);
hyperEditPane.populate(cc);
hyperEditPane.useChartComponent(chartComponent);
}
private ChartCollection createChartCollection() {
ChartCollection cc = new ChartCollection(); ChartCollection cc = new ChartCollection();
Chart chart = ChartTypeManager.getFirstChart(); Chart chart = ChartTypeManager.getFirstChart();
@ -57,17 +70,7 @@ public class ChartHyperPoplinkPane extends BasicBeanPane<ChartHyperPoplink> {
}else { }else {
cc.addChart(new Chart(new Bar2DPlot())); cc.addChart(new Chart(new Bar2DPlot()));
} }
return cc;
chartComponent = new ChartComponent();
chartComponent.setPreferredSize(new Dimension(220, 170));// 在单元格弹出时 需要调整保证属性表的大小.
chartComponent.setSupportEdit(false);
chartComponent.populate(cc);
this.add(chartComponent, BorderLayout.EAST);
hyperEditPane.populate(cc);
hyperEditPane.useChartComponent(chartComponent);
} }
protected int getChartParaType() { protected int getChartParaType() {
@ -99,8 +102,7 @@ public class ChartHyperPoplinkPane extends BasicBeanPane<ChartHyperPoplink> {
BaseChartCollection cc = chartHyperlink.getChartCollection(); BaseChartCollection cc = chartHyperlink.getChartCollection();
if (cc == null || cc.getChartCount() < 1) { if (cc == null || cc.getChartCount() < 1) {
cc = new ChartCollection(); cc = createChartCollection();
cc.addChart(new Chart(ChartFactory.createBar2DPlot()));
chartHyperlink.setChartCollection(cc); chartHyperlink.setChartCollection(cc);
} }

5
designer_chart/src/com/fr/design/mainframe/chart/gui/data/NormalChartDataPane.java

@ -103,7 +103,12 @@ public class NormalChartDataPane extends DataContentsPane {
reportDataPane.refreshContentPane(collection); reportDataPane.refreshContentPane(collection);
tableDataPane.refreshContentPane(collection); tableDataPane.refreshContentPane(collection);
if(collection != null && collection.getSelectedChart().getFilterDefinition() == null) {
reportDataPane.populateBean(collection);
tableDataPane.populateBean(collection);
} else {
dataPane.populateBean(collection); dataPane.populateBean(collection);
}
this.initAllListeners(); this.initAllListeners();
this.addAttributeChangeListener(listener); this.addAttributeChangeListener(listener);

1
designer_chart/src/com/fr/design/mainframe/chart/gui/style/datalabel/ChartLabelFontPane.java

@ -58,6 +58,7 @@ public class ChartLabelFontPane extends BasicScrollPane<Chart> {
} }
cateTextAttrPane.populate(cateTextAttr); cateTextAttrPane.populate(cateTextAttr);
categoryName.setSelected(meterPlot.isShowCateName()); categoryName.setSelected(meterPlot.isShowCateName());
cateTextAttrPane.setEnabled(meterPlot.isShowCateName());
} }

65
designer_form/build.gradle

@ -0,0 +1,65 @@
apply plugin: 'java'
tasks.withType(JavaCompile){
options.encoding = 'UTF-8'
}
version='8.0'
def srcDir="${System.getenv()['JENKINS_HOME']}/workspace/design"
def libDir="${System.getenv()['JENKINS_HOME']}/workspace/lib"
jar{
baseName='fr-designer-report'
}
sourceSets{
main{
java{
srcDirs=["${srcDir}/designer/src",
"${srcDir}/designer_form/src"]
}
}
}
dependencies{
compile fileTree(dir:'../../',include:'**/*.jar')
compile fileTree(dir:libDir,include:'*.jar')
compile fileTree(dir:"${libDir}/jetty",include:'*.jar')
testCompile 'junit:junit:4.12'
}
task copyFile(type:Copy,dependsOn:compileJava){
copy{
from ("${srcDir}/designer/src"){
exclude '**/*.java'
}
from ("${srcDir}/designer_form/src")
into ('build/classes/main')
}
}
//ѹËõÏîÄ¿ÖеÄjsÎļþ
task compressJS{
ant.taskdef(name:'yuicompress',classname:'com.yahoo.platform.yui.compressor.YUICompressTask'){
classpath {
fileset(dir:'../../lib',includes:'*.jar')
}
}
ant.yuicompress(linebreak:"500",warn:"false", munge:"yes",preserveallsemicolons:"false", , charset:"utf-8",encoding:"utf-8",outputfolder:'build/classes/main'){
fileset (dir:"${srcDir}/designer/src"){
include (name:'**/*.js')
}
fileset (dir:"${srcDir}/designer_form/src"){
include (name:'**/*.js')
}
}
}
jar.dependsOn compressJS

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

@ -1,8 +1,10 @@
package com.fr.design.designer.beans.adapters.layout; package com.fr.design.designer.beans.adapters.layout;
import java.awt.Rectangle; import java.awt.*;
import com.fr.design.designer.beans.ConstraintsGroupModel; import com.fr.design.designer.beans.ConstraintsGroupModel;
import com.fr.design.designer.beans.HoverPainter;
import com.fr.design.designer.beans.painters.FRAbsoluteLayoutPainter;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XLayoutContainer;
@ -13,9 +15,15 @@ import com.fr.design.utils.ComponentUtils;
import com.fr.design.utils.gui.LayoutUtils; import com.fr.design.utils.gui.LayoutUtils;
public class FRAbsoluteLayoutAdapter extends AbstractLayoutAdapter { public class FRAbsoluteLayoutAdapter extends AbstractLayoutAdapter {
private HoverPainter painter;
public FRAbsoluteLayoutAdapter(XLayoutContainer container) { public FRAbsoluteLayoutAdapter(XLayoutContainer container) {
super(container); super(container);
painter = new FRAbsoluteLayoutPainter(container);
}
@Override
public HoverPainter getPainter() {
return painter;
} }
/** /**
@ -27,8 +35,15 @@ public class FRAbsoluteLayoutAdapter extends AbstractLayoutAdapter {
*/ */
@Override @Override
public boolean accept(XCreator creator, int x, int y) { public boolean accept(XCreator creator, int x, int y) {
return x >= 0 && y >= 0 && creator.getHeight() <= container.getHeight() Component comp = container.getComponentAt(x, y);
//布局控件要先判断是不是可编辑
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer((XCreator)comp).getTopLayout();
if(topLayout != null && !topLayout.isEditable()){
return false;
}
boolean isAccept = x >= 0 && y >= 0 && creator.getHeight() <= container.getHeight()
&& creator.getWidth() <= container.getWidth(); && creator.getWidth() <= container.getWidth();
return isAccept;
} }
@Override @Override
@ -46,10 +61,20 @@ public class FRAbsoluteLayoutAdapter extends AbstractLayoutAdapter {
} }
fix(creator, x, y); fix(creator, x, y);
container.add(creator);
if (creator.shouldScaleCreator() || creator.hasTitleStyle()) {
addParentCreator(creator);
} else {
container.add(creator, creator.toData().getWidgetName());
}
LayoutUtils.layoutRootContainer(container); LayoutUtils.layoutRootContainer(container);
} }
private void addParentCreator(XCreator child) {
XLayoutContainer parentPanel = child.initCreatorWrapper(child.getHeight());
container.add(parentPanel, child.toData().getWidgetName());
}
/** /**
* 组件拖拽后调整大小 * 组件拖拽后调整大小
* @param creator 组件 * @param creator 组件

21
designer_form/src/com/fr/design/designer/beans/adapters/layout/FRBodyFitLayoutAdapter.java

@ -1,21 +0,0 @@
package com.fr.design.designer.beans.adapters.layout;
import com.fr.design.beans.GroupModel;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.properties.BodyMobileLayoutPropertiesGroupModel;
public class FRBodyFitLayoutAdapter extends FRFitLayoutAdapter {
public FRBodyFitLayoutAdapter(XLayoutContainer container) {
super(container);
}
/**
* 返回布局自身属性方便一些特有设置在layout刷新时处理
*/
@Override
public GroupModel getLayoutProperties() {
XWFitLayout xfl = (XWFitLayout) container;
return new BodyMobileLayoutPropertiesGroupModel(xfl);
}
}

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

@ -14,6 +14,7 @@ import com.fr.design.designer.beans.ConstraintsGroupModel;
import com.fr.design.designer.beans.HoverPainter; import com.fr.design.designer.beans.HoverPainter;
import com.fr.design.designer.beans.painters.FRFitLayoutPainter; import com.fr.design.designer.beans.painters.FRFitLayoutPainter;
import com.fr.design.designer.creator.XCreator; 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.XLayoutContainer;
import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.creator.cardlayout.XWCardLayout; import com.fr.design.designer.creator.cardlayout.XWCardLayout;
@ -116,9 +117,6 @@ public class FRFitLayoutAdapter extends AbstractLayoutAdapter {
*/ */
@Override @Override
public void addComp(XCreator child, int x, int y) { public void addComp(XCreator child, int x, int y) {
if (ComparatorUtils.equals(child.getIconPath(), WIDGETPANEICONPATH)) {
return;
}
fix(child, x, y); fix(child, x, y);
if (child.shouldScaleCreator() || child.hasTitleStyle()) { if (child.shouldScaleCreator() || child.hasTitleStyle()) {
addParentCreator(child); addParentCreator(child);
@ -163,7 +161,7 @@ public class FRFitLayoutAdapter extends AbstractLayoutAdapter {
return false; return false;
} }
//如果当前处于边缘地带, 那么就把他贴到父容器上 //如果当前处于边缘地带, 那么就把他贴到父容器上
matchEdge(x, y); boolean isMatchEdge = matchEdge(x, y);
int componentHeight = comp.getHeight(); int componentHeight = comp.getHeight();
int componentWidth = comp.getWidth(); int componentWidth = comp.getWidth();
@ -172,6 +170,12 @@ public class FRFitLayoutAdapter extends AbstractLayoutAdapter {
//下半部分高度 //下半部分高度
int downHeight = (int) (componentHeight * BOTTOM_HALF) + comp.getY(); int downHeight = (int) (componentHeight * BOTTOM_HALF) + comp.getY();
//布局控件要先判断是不是可编辑
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer((XCreator)comp).getTopLayout();
if(topLayout != null && !isMatchEdge && !topLayout.isEditable()){
return false;
}
if (isCrossPointArea(comp, x, y)) { if (isCrossPointArea(comp, x, y)) {
return canAcceptWhileCrossPoint(comp, x, y); return canAcceptWhileCrossPoint(comp, x, y);
} }

56
designer_form/src/com/fr/design/designer/beans/location/AccessDirection.java

@ -3,20 +3,17 @@
*/ */
package com.fr.design.designer.beans.location; package com.fr.design.designer.beans.location;
import java.awt.Cursor; import java.awt.*;
import java.awt.Point;
import java.awt.Rectangle;
import com.fr.design.beans.location.Absorptionline; import com.fr.design.beans.location.Absorptionline;
import com.fr.design.beans.location.MoveUtils; import com.fr.design.beans.location.MoveUtils;
import com.fr.design.designer.creator.*;
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.designer.creator.XCreatorUtils; import com.fr.design.utils.ComponentUtils;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWBorderLayout;
import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.form.ui.container.WParameterLayout;
/** /**
* @author richer * @author richer
@ -39,9 +36,6 @@ public abstract class AccessDirection implements Direction {
return new int[] { x, y }; return new int[] { x, y };
} else { } else {
int posy = current_bounds.y; int posy = current_bounds.y;
if (posy >= designer.getParaHeight() && !designer.isFormParaDesigner()) {
return new int[] { x, y };
}
Point relativePoint = getRelativePoint(x, y, current_bounds,designer); Point relativePoint = getRelativePoint(x, y, current_bounds,designer);
sorptionPoint(relativePoint,current_bounds, designer); sorptionPoint(relativePoint,current_bounds, designer);
@ -72,12 +66,14 @@ public abstract class AccessDirection implements Direction {
WAbsoluteLayout layout =getLayout(designer); WAbsoluteLayout layout =getLayout(designer);
FormSelection selection = designer.getSelectionModel().getSelection(); FormSelection selection = designer.getSelectionModel().getSelection();
boolean isWidgetsIntersect = false;
for (int i = 0, count = layout.getWidgetCount(); i < count; i++) { for (int i = 0, count = layout.getWidgetCount(); i < count; i++) {
BoundsWidget temp = (BoundsWidget) layout.getWidget(i); BoundsWidget temp = (BoundsWidget) layout.getWidget(i);
if (!temp.isVisible() || selection.contains(temp.getWidget())) { if (!temp.isVisible() || selection.contains(temp.getWidget())) {
continue; continue;
} }
Rectangle bounds = temp.getBounds(); Rectangle bounds = getWidgetRelativeBounds(temp.getBounds(), selection);
if (!findInX) { if (!findInX) {
int x1 = bounds.x; int x1 = bounds.x;
if (Math.abs(x1 - point.x) <= MoveUtils.SORPTION_UNIT) { if (Math.abs(x1 - point.x) <= MoveUtils.SORPTION_UNIT) {
@ -106,18 +102,54 @@ public abstract class AccessDirection implements Direction {
if (findInX && findInY) { if (findInX && findInY) {
break; break;
} }
if (current_bounds.intersects(bounds) && !(layout instanceof WParameterLayout)){
isWidgetsIntersect = true;
}
} }
processRectangleIntersects(designer, point.x, point.y, isWidgetsIntersect);
designer.getStateModel().setXAbsorptionline(findInX && current_bounds.getWidth() > MoveUtils.SORPTION_UNIT ? Absorptionline.createXAbsorptionline(point.x) : null); designer.getStateModel().setXAbsorptionline(findInX && current_bounds.getWidth() > MoveUtils.SORPTION_UNIT ? Absorptionline.createXAbsorptionline(point.x) : null);
designer.getStateModel().setYAbsorptionline(findInY && current_bounds.getHeight() > MoveUtils.SORPTION_UNIT ? Absorptionline.createYAbsorptionline(point.y) : null); designer.getStateModel().setYAbsorptionline(findInY && current_bounds.getHeight() > MoveUtils.SORPTION_UNIT ? Absorptionline.createYAbsorptionline(point.y) : null);
} }
private Rectangle getWidgetRelativeBounds(Rectangle bounds, FormSelection selection){
Rectangle relativeRec = new Rectangle(bounds.x, bounds.y, bounds.width, bounds.height);
XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(selection.getSelectedCreator());
if (parent == null) {
return relativeRec;
}
Rectangle rec = ComponentUtils.getRelativeBounds(parent);
relativeRec.x += rec.x;
relativeRec.y += rec.y;
return relativeRec;
}
private void processRectangleIntersects(FormDesigner designer, int x, int y, boolean isIntersects){
if(isIntersects){
if(designer.getLocationOnScreen() != null) {
MoveUtils.displayForbidWindow(x + designer.getLocationOnScreen().x, y + designer.getLocationOnScreen().y);
}
designer.setWidgetsIntersect(true);
}
else{
MoveUtils.hideForbidWindow();
designer.setWidgetsIntersect(false);
}
}
private WAbsoluteLayout getLayout(final FormDesigner designer){ private WAbsoluteLayout getLayout(final FormDesigner designer){
XLayoutContainer formLayoutContainer = (XLayoutContainer) XCreatorUtils.createXCreator( XLayoutContainer formLayoutContainer = (XLayoutContainer) XCreatorUtils.createXCreator(
designer.getTarget().getContainer()); designer.getTarget().getContainer());
WAbsoluteLayout layout; WAbsoluteLayout layout;
if (formLayoutContainer.acceptType(XWBorderLayout.class)){ if (formLayoutContainer.acceptType(XWBorderLayout.class)){//看起来这边的作用应该是为了区别cpt(得到XWParameterLayout)还是frm(得到XWBorderLayout)的参数界面
Container container = designer.getSelectionModel().getSelection().getSelectedCreator().getParent();
if(container instanceof XWAbsoluteLayout){
layout = ((XWAbsoluteLayout)container).toData();
}
else {
layout = (WAbsoluteLayout) designer.getParaComponent().toData(); layout = (WAbsoluteLayout) designer.getParaComponent().toData();
}
} else{ } else{
layout = (WAbsoluteLayout) designer.getTarget().getContainer(); layout = (WAbsoluteLayout) designer.getTarget().getContainer();
} }

74
designer_form/src/com/fr/design/designer/beans/location/Inner.java

@ -4,16 +4,17 @@ import com.fr.design.beans.location.Absorptionline;
import com.fr.design.beans.location.MoveUtils; import com.fr.design.beans.location.MoveUtils;
import com.fr.design.beans.location.MoveUtils.RectangleDesigner; import com.fr.design.beans.location.MoveUtils.RectangleDesigner;
import com.fr.design.beans.location.MoveUtils.RectangleIterator; import com.fr.design.beans.location.MoveUtils.RectangleIterator;
import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.designer.creator.*;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWBorderLayout;
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.utils.ComponentUtils;
import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.third.com.lowagie.text.*;
import java.awt.*; import java.awt.*;
import java.awt.Rectangle;
public class Inner extends AccessDirection { public class Inner extends AccessDirection {
@ -78,17 +79,72 @@ public class Inner extends AccessDirection {
public RectangleIterator createRectangleIterator() { public RectangleIterator createRectangleIterator() {
return getRectangleIterator(designer); return getRectangleIterator(designer);
} }
/**
* 设置designer内部组件是否重叠的标志位
*
* @param isIntersects 是否重叠
*/
@Override
public void setWidgetsIntersects(boolean isIntersects) {
designer.setWidgetsIntersect(isIntersects);
}
/**
* 获取designer内部组件是否重叠的标志位
*
* @return 重叠
*/
@Override
public boolean getWidgetsIntersects() {
return designer.isWidgetsIntersect();
}
/**
* 获取designer相对屏幕的位置
*
* @return 位置
*/
@Override
public Point getDesignerLocationOnScreen() {
return designer.getLocationOnScreen();
}
/**
* 设置等距线
*
* @param line 吸附线
*/
@Override
public void setEquidistantLine(Absorptionline line) {
designer.getStateModel().setEquidistantLine(line);
}
}; };
point.setLocation(MoveUtils.sorption(point.x, point.y, current_bounds.width, current_bounds.height, rd)); //判断当前操作的是不是参数面板,要特殊处理
boolean isParameterLayout = ((XCreator)(designer.getSelectionModel().getSelection().getSelectedCreator().getParent())).acceptType(XWParameterLayout.class);
point.setLocation(MoveUtils.sorption(point.x, point.y, current_bounds.width, current_bounds.height, rd, isParameterLayout));
} }
private RectangleIterator getRectangleIterator(final FormDesigner designer){ private RectangleIterator getRectangleIterator(final FormDesigner designer){
return new RectangleIterator() { return new RectangleIterator() {
private int i; private int i;
private WAbsoluteLayout layout = getLayout(designer); private WAbsoluteLayout layout = getLayout(designer);
private int count = layout.getWidgetCount(); private int count = layout.getWidgetCount();
private FormSelection selection = designer.getSelectionModel().getSelection(); private FormSelection selection = designer.getSelectionModel().getSelection();
private Rectangle getWidgetRelativeBounds(Rectangle bounds){
Rectangle relativeRec = new Rectangle(bounds.x, bounds.y, bounds.width, bounds.height);
XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(selection.getSelectedCreator());
if (parent == null) {
return relativeRec;
}
Rectangle rec = ComponentUtils.getRelativeBounds(parent);
relativeRec.x += rec.x;
relativeRec.y += rec.y;
return relativeRec;
}
public boolean hasNext() { public boolean hasNext() {
if (i >= count) { if (i >= count) {
return false; return false;
@ -110,7 +166,7 @@ public class Inner extends AccessDirection {
} }
public Rectangle nextRectangle() { public Rectangle nextRectangle() {
BoundsWidget temp = (BoundsWidget) layout.getWidget(i++); BoundsWidget temp = (BoundsWidget) layout.getWidget(i++);
return temp.getBounds(); return getWidgetRelativeBounds(temp.getBounds());
} }
}; };
} }
@ -119,8 +175,14 @@ public class Inner extends AccessDirection {
XLayoutContainer formLayoutContainer = (XLayoutContainer) XCreatorUtils.createXCreator( XLayoutContainer formLayoutContainer = (XLayoutContainer) XCreatorUtils.createXCreator(
designer.getTarget().getContainer()); designer.getTarget().getContainer());
WAbsoluteLayout layout; WAbsoluteLayout layout;
if (formLayoutContainer.acceptType(XWBorderLayout.class)){ if (formLayoutContainer.acceptType(XWBorderLayout.class)){//看起来这边的作用应该是为了区别cpt(得到XWParameterLayout)还是frm(得到XWBorderLayout)的参数界面
Container container = designer.getSelectionModel().getSelection().getSelectedCreator().getParent();
if(container instanceof XWAbsoluteLayout){
layout = ((XWAbsoluteLayout)container).toData();
}
else {
layout = (WAbsoluteLayout) designer.getParaComponent().toData(); layout = (WAbsoluteLayout) designer.getParaComponent().toData();
}
} else{ } else{
layout = (WAbsoluteLayout) designer.getTarget().getContainer(); layout = (WAbsoluteLayout) designer.getTarget().getContainer();
} }

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

@ -66,6 +66,13 @@ public class SelectionModel {
// 获取e所在的组件 // 获取e所在的组件
XCreator comp = designer.getComponentAt(e); XCreator comp = designer.getComponentAt(e);
//布局组件的顶层布局如不可编辑,要获取其顶层布局
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer(comp).getTopLayout();
if(topLayout != null && !topLayout.isEditable()){
comp = topLayout;
}
// 如果父层是scale和title两个专属容器,返回其父层,组件本身是不让被选中的 // 如果父层是scale和title两个专属容器,返回其父层,组件本身是不让被选中的
if (comp != designer.getRootComponent() && comp != designer.getParaComponent()) { if (comp != designer.getRootComponent() && comp != designer.getParaComponent()) {
XCreator parentContainer = (XCreator) comp.getParent(); XCreator parentContainer = (XCreator) comp.getParent();

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

@ -44,6 +44,8 @@ public class StateModel {
private Absorptionline lineInX; private Absorptionline lineInX;
private Absorptionline lineInY; private Absorptionline lineInY;
//等距线
private Absorptionline lineEquidistant;
// 当前是否处于拖拽选择状态 // 当前是否处于拖拽选择状态
private boolean selecting; private boolean selecting;
@ -357,6 +359,14 @@ public class StateModel {
this.lineInY = line; this.lineInY = line;
} }
/**
* 等距线赋值
* @param line 线
*/
public void setEquidistantLine(Absorptionline line){
this.lineEquidistant = line;
}
/** /**
*画吸附线 *画吸附线
* @param g Graphics类 * @param g Graphics类
@ -368,6 +378,9 @@ public class StateModel {
if(lineInY != null) { if(lineInY != null) {
lineInY.paint(g,designer.getArea()); lineInY.paint(g,designer.getArea());
} }
if(lineEquidistant != null){
lineEquidistant.paint(g,designer.getArea());
}
} }
/** /**

26
designer_form/src/com/fr/design/designer/beans/painters/FRAbsoluteLayoutPainter.java

@ -0,0 +1,26 @@
package com.fr.design.designer.beans.painters;
import com.fr.design.designer.creator.XLayoutContainer;
import java.awt.*;
/**
* Created by zhouping on 2016/7/11.
*/
public class FRAbsoluteLayoutPainter extends AbstractPainter {
public FRAbsoluteLayoutPainter(XLayoutContainer container) {
super(container);
}
/**
* 组件渲染
*
* @param g 画图类
* @param startX 开始位置x
* @param startY 开始位置y
*/
@Override
public void paint(Graphics g, int startX, int startY) {
super.paint(g, startX, startY);
}
}

83
designer_form/src/com/fr/design/designer/creator/XChartEditor.java

@ -1,20 +1,22 @@
package com.fr.design.designer.creator; package com.fr.design.designer.creator;
import java.awt.Color; import java.awt.*;
import java.awt.Dimension; import java.awt.event.MouseEvent;
import java.awt.Graphics; import java.awt.image.BufferedImage;
import java.beans.IntrospectionException; import java.beans.IntrospectionException;
import javax.swing.BorderFactory; import javax.swing.*;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import com.fr.base.BaseUtils;
import com.fr.base.chart.BaseChart; import com.fr.base.chart.BaseChart;
import com.fr.base.chart.BaseChartCollection; import com.fr.base.chart.BaseChartCollection;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.gui.chart.BaseChartPropertyPane; import com.fr.design.gui.chart.BaseChartPropertyPane;
import com.fr.design.gui.chart.MiddleChartComponent; import com.fr.design.gui.chart.MiddleChartComponent;
import com.fr.design.mainframe.BaseJForm; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.*;
import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor; import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor;
import com.fr.design.mainframe.widget.renderer.LayoutBorderStyleRenderer; import com.fr.design.mainframe.widget.renderer.LayoutBorderStyleRenderer;
import com.fr.design.module.DesignModuleFactory; import com.fr.design.module.DesignModuleFactory;
@ -41,6 +43,9 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
//marro:无奈的属性,暂时想不出好办法 //marro:无奈的属性,暂时想不出好办法
private boolean isRefreshing = false; private boolean isRefreshing = false;
private boolean isEditing = false;
private JPanel coverPanel;
public XChartEditor(BaseChartEditor editor) { public XChartEditor(BaseChartEditor editor) {
this(editor, new Dimension(250, 150)); this(editor, new Dimension(250, 150));
} }
@ -142,7 +147,8 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
} }
}); });
final BaseChartPropertyPane propertyPane = DesignModuleFactory.getChartWidgetPropertyPane(formDesigner); if (isEditing){
final BaseChartPropertyPane propertyPane = DesignModuleFactory.getChartPropertyPane();
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -154,6 +160,10 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
}); });
return (JComponent)propertyPane; return (JComponent)propertyPane;
} }
else{
return (JComponent)DesignModuleFactory.getWidgetPropertyPane(formDesigner);
}
}
private MiddleChartComponent getDesignerEditorTarget() { private MiddleChartComponent getDesignerEditorTarget() {
MiddleChartComponent bcc = null; MiddleChartComponent bcc = null;
@ -167,8 +177,8 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
* 渲染Painter * 渲染Painter
*/ */
public void paint(Graphics g) { public void paint(Graphics g) {
super.paint(g);
designerEditor.paintEditor(g, this.getSize()); designerEditor.paintEditor(g, this.getSize());
super.paint(g);
} }
/** /**
@ -180,6 +190,27 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
return new Dimension(250, 100); return new Dimension(250, 100);
} }
/**
* 响应点击事件
*
* @param editingMouseListener 鼠标点击位置处理器
* @param e 鼠标点击事件
*/
public void respondClick(EditingMouseListener editingMouseListener,MouseEvent e){
FormDesigner designer = editingMouseListener.getDesigner();
SelectionModel selectionModel = editingMouseListener.getSelectionModel();
isEditing = e.getClickCount() == 2 || designer.getCursor().getType() == Cursor.HAND_CURSOR;
displayCoverPane(!isEditing);
selectionModel.selectACreatorAtMouseEvent(e);
if (editingMouseListener.stopEditing()) {
if (this != (XCreator)designer.getRootComponent()) {
ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, this);
editingMouseListener.startEditing(this, isEditing ? adapter.getDesignerEditor() : null, adapter);
}
}
}
@Override @Override
protected JComponent initEditor() { protected JComponent initEditor() {
if (designerEditor == null) { if (designerEditor == null) {
@ -198,6 +229,36 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
}); });
} }
} }
return null;
if (editor == null) {
setBorder(DEFALUTBORDER);
editor = new JPanel();
editor.setBackground(null);
editor.setLayout(null);
editor.setOpaque(false);
coverPanel = new CoverReportPane();
coverPanel.setPreferredSize(this.getPreferredSize());
coverPanel.setBounds(this.getBounds());
editor.add(coverPanel);
coverPanel.setVisible(false);
}
return editor;
}
/**
* 是否展现覆盖的pane
* @param display 是否
*/
public void displayCoverPane(boolean display){
coverPanel.setVisible(display);
coverPanel.setPreferredSize(editor.getPreferredSize());
coverPanel.setBounds(editor.getBounds());
editor.repaint();
}
public JComponent getCoverPane(){
return coverPanel;
} }
} }

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

@ -106,6 +106,14 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
setBackupParent(XCreatorUtils.getParentXLayoutContainer(this)); setBackupParent(XCreatorUtils.getParentXLayoutContainer(this));
} }
/**
* 获取当前布局控件的顶层布局框架如tab布局绝对布局
* @return 封装的顶层布局
*/
public XLayoutContainer getTopLayout(){
return null;
}
/** /**
* 获取当前XCreator的一个封装父容器 * 获取当前XCreator的一个封装父容器
* *

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

@ -41,6 +41,16 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
protected boolean isRefreshing; protected boolean isRefreshing;
protected int default_Length = 5; // 取指定点坐在的组件,默认为5保证取四侧相邻的组件时x、y在组件内非边框上 protected int default_Length = 5; // 取指定点坐在的组件,默认为5保证取四侧相邻的组件时x、y在组件内非边框上
/**
* 布局是否可编辑不可则显示编辑层
*/
protected boolean editable = false;
//鼠标移动到布局画出编辑层
protected boolean isMouseEnter = false;
public void setMouseEnter(boolean mouseEnter) {
isMouseEnter = mouseEnter;
}
public XLayoutContainer(WLayout widget, Dimension initSize) { public XLayoutContainer(WLayout widget, Dimension initSize) {
super(widget, initSize); super(widget, initSize);
this.addContainerListener(this); this.addContainerListener(this);
@ -446,4 +456,20 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
public void setBackground(Background background){ public void setBackground(Background background){
} }
/**
* 布局是否可编辑不可则显示编辑蒙层
* @return 可否编辑
*/
public boolean isEditable(){
return this.editable;
}
/**
* 设置布局是否可编辑不可则显示编辑蒙层
* @param isEditable 可否编辑
*/
public void setEditable(boolean isEditable){
this.editable = isEditable;
}
} }

88
designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java

@ -3,20 +3,29 @@
*/ */
package com.fr.design.designer.creator; package com.fr.design.designer.creator;
import java.awt.Dimension; import java.awt.*;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.event.ContainerEvent; import java.awt.event.ContainerEvent;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.util.HashMap; import java.util.HashMap;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.AbsoluteLayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRAbsoluteLayoutAdapter; import com.fr.design.designer.beans.adapters.layout.FRAbsoluteLayoutAdapter;
import com.fr.design.designer.beans.location.Direction; import com.fr.design.designer.beans.location.Direction;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.form.layout.FRAbsoluteLayout; import com.fr.design.form.layout.FRAbsoluteLayout;
import com.fr.design.icon.IconPathConstants;
import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner;
import com.fr.form.ui.Connector; import com.fr.form.ui.Connector;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
/** /**
* @author richer * @author richer
@ -24,6 +33,9 @@ import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
*/ */
public class XWAbsoluteLayout extends XLayoutContainer { public class XWAbsoluteLayout extends XLayoutContainer {
private static final int EDIT_BTN_WIDTH = 60;
private static final int EDIT_BTN_HEIGHT = 24;
private HashMap<Connector,XConnector> xConnectorMap; private HashMap<Connector,XConnector> xConnectorMap;
public XWAbsoluteLayout() { public XWAbsoluteLayout() {
@ -187,4 +199,74 @@ public class XWAbsoluteLayout extends XLayoutContainer {
public LayoutAdapter getLayoutAdapter() { public LayoutAdapter getLayoutAdapter() {
return new FRAbsoluteLayoutAdapter(this); return new FRAbsoluteLayoutAdapter(this);
} }
@Override
public XLayoutContainer getTopLayout() {
XLayoutContainer xTopLayout = XCreatorUtils.getParentXLayoutContainer(this).getTopLayout();
if (xTopLayout != null && !xTopLayout.isEditable()){
return xTopLayout;
}
else{
return this;
}
}
public void paint(Graphics g) {
super.paint(g);
//如果鼠标移动到布局内且布局不可编辑,画出编辑蒙层
if (isMouseEnter && !this.editable) {
int x = 0;
int y = 0;
int w = getWidth();
int h = getHeight();
Graphics2D g2d = (Graphics2D) g;
Composite oldComposite = g2d.getComposite();
//画白色的编辑层
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 60 / 100.0F));
g2d.setColor(Color.WHITE);
g2d.fillRect(x, y, w, h);
//画编辑按钮所在框
g2d.setComposite(oldComposite);
g2d.setColor(new Color(176, 196, 222));
g2d.fillRect((x + w / 2 - EDIT_BTN_WIDTH / 2), (y + h / 2 - EDIT_BTN_HEIGHT / 2), EDIT_BTN_WIDTH, EDIT_BTN_HEIGHT);
//画编辑按钮图标
BufferedImage image = IOUtils.readImage(IconPathConstants.TD_EDIT_ICON_PATH);
g2d.drawImage(
image,
(x + w / 2 - 23),
(y + h / 2 - image.getHeight() / 2),
image.getWidth(),
image.getHeight(),
null,
this
);
g2d.setColor(Color.BLACK);
//画编辑文字
g2d.drawString(Inter.getLocText("Edit"), x + w / 2 - 2, y + h / 2 + 5);
}
}
/**
* 响应点击事件
*
* @param editingMouseListener 鼠标点击位置处理器
* @param e 鼠标点击事件
*/
public void respondClick(EditingMouseListener editingMouseListener,MouseEvent e){
FormDesigner designer = editingMouseListener.getDesigner();
SelectionModel selectionModel = editingMouseListener.getSelectionModel();
boolean isEditing = isEditable() || designer.getCursor().getType() == Cursor.HAND_CURSOR || e.getClickCount() == 2;
setEditable(isEditing);
selectionModel.selectACreatorAtMouseEvent(e);
designer.repaint();
if (editingMouseListener.stopEditing()) {
if (this != designer.getRootComponent()) {
ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, this);
editingMouseListener.startEditing(this, isEditing ? adapter.getDesignerEditor() : null, adapter);
}
}
}
} }

20
designer_form/src/com/fr/design/designer/creator/XWBodyFitLayout.java

@ -1,20 +0,0 @@
package com.fr.design.designer.creator;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRBodyFitLayoutAdapter;
import com.fr.form.ui.container.WFitLayout;
import java.awt.Dimension;
public class XWBodyFitLayout extends XWFitLayout {
public XWBodyFitLayout() {
this(new WFitLayout(), new Dimension());
}
public XWBodyFitLayout(WFitLayout widget, Dimension initSize) {
super(widget, initSize);
}
@Override
public LayoutAdapter getLayoutAdapter() {
return new FRBodyFitLayoutAdapter(this);
}
}

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

@ -825,7 +825,7 @@ public class XWFitLayout extends XLayoutContainer {
/** /**
* 处理自适应布局的directions * 处理自适应布局的directions
* @param creator 组件 * @param xcreator 组件
*/ */
private void dealDirections(XCreator xcreator, boolean isInit) { private void dealDirections(XCreator xcreator, boolean isInit) {
if (xcreator == null) { if (xcreator == null) {
@ -1160,7 +1160,7 @@ public class XWFitLayout extends XLayoutContainer {
@Override @Override
public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() { public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() {
return new WidgetPropertyUIProvider[]{ new BodyMobilePropertyUI(new XWBodyFitLayout())}; return new WidgetPropertyUIProvider[]{ new BodyMobilePropertyUI(this)};
} }
} }

25
designer_form/src/com/fr/design/designer/creator/XWParameterLayout.java

@ -3,6 +3,7 @@
*/ */
package com.fr.design.designer.creator; package com.fr.design.designer.creator;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRParameterLayoutAdapter; import com.fr.design.designer.beans.adapters.layout.FRParameterLayoutAdapter;
import com.fr.design.form.util.XCreatorConstants; import com.fr.design.form.util.XCreatorConstants;
@ -16,9 +17,12 @@ import com.fr.form.ui.container.WFitLayout;
import com.fr.form.ui.container.WParameterLayout; import com.fr.form.ui.container.WParameterLayout;
import com.fr.general.Background; import com.fr.general.Background;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.design.fun.ParameterWindowEditorProcessor;
import com.fr.stable.ArrayUtils;
import java.awt.*; import java.awt.*;
import java.beans.IntrospectionException; import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor;
/** /**
* 表单参数界面container * 表单参数界面container
@ -51,7 +55,7 @@ public class XWParameterLayout extends XWAbsoluteLayout {
* @throws java.beans.IntrospectionException * @throws java.beans.IntrospectionException
*/ */
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException {
return new CRPropertyDescriptor[]{ CRPropertyDescriptor[] propertyTableEditor = new CRPropertyDescriptor[]{
new CRPropertyDescriptor("widgetName", this.data.getClass()).setI18NName(Inter new CRPropertyDescriptor("widgetName", this.data.getClass()).setI18NName(Inter
.getLocText("FR-Designer_Form-Widget_Name")), .getLocText("FR-Designer_Form-Widget_Name")),
new CRPropertyDescriptor("background", this.data.getClass()).setEditorClass(BackgroundEditor.class) new CRPropertyDescriptor("background", this.data.getClass()).setEditorClass(BackgroundEditor.class)
@ -64,6 +68,14 @@ public class XWParameterLayout extends XWAbsoluteLayout {
.setRendererClass(WidgetDisplayPositionRender.class).setI18NName(Inter.getLocText("FR-Designer_WidgetDisplyPosition")) .setRendererClass(WidgetDisplayPositionRender.class).setI18NName(Inter.getLocText("FR-Designer_WidgetDisplyPosition"))
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"),
}; };
ParameterWindowEditorProcessor processor = ExtraDesignClassManager.getInstance().getSingle(ParameterWindowEditorProcessor.MARK_STRING);
if (processor == null) {
return propertyTableEditor;
}
CRPropertyDescriptor[] extraEditor = processor.createPropertyDescriptor(this.data.getClass());
return ArrayUtils.addAll(propertyTableEditor, extraEditor);
} }
@Override @Override
@ -151,4 +163,15 @@ public class XWParameterLayout extends XWAbsoluteLayout {
public void setBackground(Background background){ public void setBackground(Background background){
this.toData().setBackground(background); this.toData().setBackground(background);
} }
@Override
public void paint(Graphics g) {
//参数面板特殊处理,不出现编辑层
setEditable(true);
super.paint(g);
}
@Override
public XLayoutContainer getTopLayout() {
return this;
}
} }

8
designer_form/src/com/fr/design/designer/creator/cardlayout/XCardAddButton.java

@ -12,6 +12,7 @@ import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.XButton; import com.fr.design.designer.creator.XButton;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormHierarchyTreePane; import com.fr.design.mainframe.FormHierarchyTreePane;
@ -149,6 +150,8 @@ public class XCardAddButton extends XButton{
XCardSwitchButton showButton = new XCardSwitchButton(titleButton,dimension,cardLayout,tagLayout); XCardSwitchButton showButton = new XCardSwitchButton(titleButton,dimension,cardLayout,tagLayout);
titleButton.setCustomStyle(true); titleButton.setCustomStyle(true);
titleButton.setShowButton(true); titleButton.setShowButton(true);
showButton.setBackupParent(tagLayout);
this.tagLayout.setCurrentCard(titleButton); this.tagLayout.setCurrentCard(titleButton);
this.tagLayout.setTabFitIndex(index); this.tagLayout.setTabFitIndex(index);
@ -180,4 +183,9 @@ public class XCardAddButton extends XButton{
} }
return newTextName; return newTextName;
} }
@Override
public XLayoutContainer getTopLayout() {
return this.getBackupParent().getTopLayout();
}
} }

5
designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java

@ -293,4 +293,9 @@ public class XCardSwitchButton extends XButton {
selectionModel.setSelectedCreator(designer.getRootComponent()); selectionModel.setSelectedCreator(designer.getRootComponent());
} }
@Override
public XLayoutContainer getTopLayout() {
return this.getBackupParent().getTopLayout();
}
} }

8
designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java

@ -219,8 +219,7 @@ public class XWCardLayout extends XLayoutContainer {
* *
*/ */
protected void setWrapperName(XLayoutContainer parentPanel, String widgetName) { protected void setWrapperName(XLayoutContainer parentPanel, String widgetName) {
//先随便set一个, 以后还是要隐藏的 parentPanel.toData().setWidgetName("tablayout" + widgetName.replaceAll(createDefaultName(),""));
parentPanel.toData().setWidgetName("border_card_" + widgetName);
} }
/** /**
@ -367,4 +366,9 @@ public class XWCardLayout extends XLayoutContainer {
mainLayout.setBorder(border); mainLayout.setBorder(border);
} }
} }
@Override
public XLayoutContainer getTopLayout() {
return this.getBackupParent().getTopLayout();
}
} }

98
designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java

@ -3,18 +3,25 @@
*/ */
package com.fr.design.designer.creator.cardlayout; package com.fr.design.designer.creator.cardlayout;
import java.awt.Color; import java.awt.*;
import java.awt.Component; import java.awt.event.MouseEvent;
import java.awt.Dimension; import java.awt.image.BufferedImage;
import java.util.ArrayList; import java.util.ArrayList;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.XCreator; 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.XWBorderLayout; import com.fr.design.designer.creator.XWBorderLayout;
import com.fr.design.icon.IconPathConstants;
import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner;
import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WBorderLayout;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
/** /**
* card布局主体框架 * card布局主体框架
@ -32,6 +39,9 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
private static final int TITLE_STYLE = 2; private static final int TITLE_STYLE = 2;
private static final int NORMAL_STYLE = 1; private static final int NORMAL_STYLE = 1;
private static final int EDIT_BTN_WIDTH = 60;
private static final int EDIT_BTN_HEIGHT = 24;
/** /**
* 构造函数 * 构造函数
*/ */
@ -124,7 +134,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
/** /**
* 重新调整子组件的宽度 * 重新调整子组件的宽度
* @param 宽度 * @param width 宽度
*/ */
public void recalculateChildWidth(int width){ public void recalculateChildWidth(int width){
ArrayList<?> childrenList = this.getTargetChildrenList(); ArrayList<?> childrenList = this.getTargetChildrenList();
@ -188,4 +198,78 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
} }
} }
public void paint(Graphics g) {
super.paint(g);
//如果鼠标移动到布局内且布局不可编辑,画出编辑蒙层
if (isMouseEnter && !editable) {
int x = 0;
int y = 0;
int w = getWidth();
int h = getHeight();
Graphics2D g2d = (Graphics2D) g;
Composite oldComposite = g2d.getComposite();
//画白色的编辑层
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 60 / 100.0F));
g2d.setColor(Color.WHITE);
g2d.fillRect(x, y, w, h);
//画编辑按钮所在框
g2d.setComposite(oldComposite);
g2d.setColor(new Color(176, 196, 222));
g2d.fillRect((x + w / 2 - EDIT_BTN_WIDTH / 2), (y + h / 2 - EDIT_BTN_HEIGHT / 2), EDIT_BTN_WIDTH, EDIT_BTN_HEIGHT);
//画编辑按钮图标
BufferedImage image = IOUtils.readImage(IconPathConstants.TD_EDIT_ICON_PATH);
g2d.drawImage(
image,
(x + w / 2 - 23),
(y + h / 2 - image.getHeight() / 2),
image.getWidth(),
image.getHeight(),
null,
this
);
g2d.setColor(Color.BLACK);
//画编辑文字
g2d.drawString(Inter.getLocText("Edit"), x + w / 2 - 2, y + h / 2 + 5);
}
}
/**
* 响应点击事件
*
* @param editingMouseListener 鼠标点击位置处理器
* @param e 鼠标点击事件
*/
public void respondClick(EditingMouseListener editingMouseListener,MouseEvent e){
FormDesigner designer = editingMouseListener.getDesigner();
SelectionModel selectionModel = editingMouseListener.getSelectionModel();
boolean isEditing = designer.getCursor().getType() == Cursor.HAND_CURSOR || e.getClickCount() == 2;
setEditable(isEditing);
selectionModel.selectACreatorAtMouseEvent(e);
designer.repaint();
if (editingMouseListener.stopEditing()) {
if (this != designer.getRootComponent()) {
ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, this);
editingMouseListener.startEditing(this, isEditing ? adapter.getDesignerEditor() : null, adapter);
}
}
}
/**
* XWCardMainBorderLayout是card布局主体框架tab的顶层布局
* @return
*/
@Override
public XLayoutContainer getTopLayout() {
XLayoutContainer xTopLayout = XCreatorUtils.getParentXLayoutContainer(this).getTopLayout();
if (xTopLayout != null && !xTopLayout.isEditable()){
return xTopLayout;
}
else{
return this;
}
}
} }

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

@ -13,6 +13,7 @@ import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWHorizontalBoxLayout; import com.fr.design.designer.creator.XWHorizontalBoxLayout;
import com.fr.design.designer.creator.XWidgetCreator; import com.fr.design.designer.creator.XWidgetCreator;
import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.EditingMouseListener;
@ -214,4 +215,9 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
} }
} }
} }
@Override
public XLayoutContainer getTopLayout() {
return this.getBackupParent().getTopLayout();
}
} }

6
designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTitleLayout.java

@ -12,6 +12,7 @@ import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWBorderLayout; import com.fr.design.designer.creator.XWBorderLayout;
import com.fr.design.designer.creator.XWidgetCreator; import com.fr.design.designer.creator.XWidgetCreator;
import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.EditingMouseListener;
@ -146,4 +147,9 @@ public class XWCardTitleLayout extends XWBorderLayout {
} }
} }
} }
@Override
public XLayoutContainer getTopLayout() {
return this.getBackupParent().getTopLayout();
}
} }

7
designer_form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java

@ -188,7 +188,7 @@ public class XWTabFitLayout extends XWFitLayout {
/** /**
* 该布局需要隐藏无需对边框进行操作 * 该布局需要隐藏无需对边框进行操作
* @param 边框 * @param border 边框
* *
*/ */
public void setBorder(Border border) { public void setBorder(Border border) {
@ -362,4 +362,9 @@ public class XWTabFitLayout extends XWFitLayout {
this.hasCalGap = true; this.hasCalGap = true;
} }
@Override
public XLayoutContainer getTopLayout() {
return this.getBackupParent().getTopLayout();
}
} }

63
designer_form/src/com/fr/design/designer/properties/BodyAppRelayoutTable.java

@ -1,40 +1,39 @@
package com.fr.design.designer.properties; package com.fr.design.designer.properties;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.beans.IntrospectionException;
import java.util.ArrayList; import java.util.ArrayList;
import javax.swing.JTable;
import javax.swing.table.TableColumn;
import javax.swing.table.TableModel; import javax.swing.table.TableModel;
import com.fr.design.beans.GroupModel; import com.fr.base.FRContext;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.*; import com.fr.design.designer.creator.*;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.gui.itable.AbstractPropertyTable; import com.fr.design.gui.itable.AbstractPropertyTable;
import com.fr.design.gui.itable.PropertyGroup; import com.fr.design.gui.itable.PropertyGroup;
import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.gui.xtable.ReportAppPropertyGroupModel;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.widget.editors.InChangeBooleanEditor;
import com.fr.general.Inter;
public class BodyAppRelayoutTable extends AbstractPropertyTable { public class BodyAppRelayoutTable extends AbstractPropertyTable {
private XWBodyFitLayout xwBodyFitLayout; private XCreator xCreator;
private FormDesigner designer;
public BodyAppRelayoutTable(XWBodyFitLayout xwBodyFitLayout) { public BodyAppRelayoutTable(XCreator xCreator) {
super(); this.xCreator = xCreator;
setDesigner(xwBodyFitLayout);
} }
public static ArrayList<PropertyGroup> getCreatorPropertyGroup(XCreator source) { public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException {
ArrayList<PropertyGroup> groups = new ArrayList<PropertyGroup>(); CRPropertyDescriptor[] propertyTableEditor = {
if (source instanceof XLayoutContainer) { new CRPropertyDescriptor("appRelayout", this.xCreator.toData().getClass()).setEditorClass(InChangeBooleanEditor.class)
LayoutAdapter layoutAdapter = ((XLayoutContainer)source).getLayoutAdapter(); .setI18NName(Inter.getLocText("FR-Designer-App_ReLayout"))
if(layoutAdapter != null){ .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, Inter.getLocText("FR-Designer-Layout_Adaptive_Layout"))
GroupModel m = layoutAdapter.getLayoutProperties(); };
if (m != null) { return propertyTableEditor;
groups.add(new PropertyGroup(m));
}
}
}
return groups;
} }
/** /**
@ -43,20 +42,24 @@ public class BodyAppRelayoutTable extends AbstractPropertyTable {
*/ */
public void initPropertyGroups(Object source) { public void initPropertyGroups(Object source) {
groups = getCreatorPropertyGroup(xwBodyFitLayout); this.designer = WidgetPropertyPane.getInstance().getEditingFormDesigner();
groups = new ArrayList<PropertyGroup>();
CRPropertyDescriptor[] propertyTableEditor = null;
try {
propertyTableEditor = supportedDescriptor();
}catch (IntrospectionException e) {
FRContext.getLogger().error(e.getMessage());
}
groups.add(new PropertyGroup(new ReportAppPropertyGroupModel(Inter.getLocText("FR-Designer-Layout_Adaptive_Layout"), xCreator, propertyTableEditor, designer)));
TableModel model = new BeanTableModel(); TableModel model = new BeanTableModel();
setModel(model); setModel(model);
this.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
TableColumn tc = this.getColumn(this.getColumnName(0));
tc.setPreferredWidth(30);
this.repaint(); this.repaint();
} }
private void setDesigner(XWBodyFitLayout xwBodyFitLayout) {
this.xwBodyFitLayout = xwBodyFitLayout;
}
/** /**
* 单元格tooltip * 单元格tooltip
@ -78,6 +81,6 @@ public class BodyAppRelayoutTable extends AbstractPropertyTable {
* 待说明 * 待说明
*/ */
public void firePropertyEdit() { public void firePropertyEdit() {
designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_EDITED);
} }
} }

111
designer_form/src/com/fr/design/designer/properties/BodyMobileLayoutPropertiesGroupModel.java

@ -1,111 +0,0 @@
package com.fr.design.designer.properties;
import com.fr.design.beans.GroupModel;
import com.fr.form.ui.container.WFitLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.mainframe.widget.editors.BooleanEditor;
import com.fr.design.mainframe.widget.editors.PropertyCellEditor;
import com.fr.general.Inter;
import javax.swing.*;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import java.awt.*;
public class BodyMobileLayoutPropertiesGroupModel implements GroupModel {
private PropertyCellEditor reLayoutEditor;
private CheckBoxCellRenderer reLayoutrenderer;
private WFitLayout layout;
private XWFitLayout xfl;
public BodyMobileLayoutPropertiesGroupModel(XWFitLayout xfl) {
this.xfl = xfl;
this.layout = xfl.toData();
reLayoutrenderer = new CheckBoxCellRenderer();
reLayoutEditor = new PropertyCellEditor(new BooleanEditor());
}
@Override
public String getGroupName() {
return Inter.getLocText("FR-Designer-Layout_Adaptive_Layout");
}
@Override
public int getRowCount() {
return 1;
}
@Override
public TableCellRenderer getRenderer(int row) {
return reLayoutrenderer;
}
@Override
public TableCellEditor getEditor(int row) {
return reLayoutEditor;
}
@Override
public Object getValue(int row, int column) {
if (column == 0) {
return Inter.getLocText("FR-Designer-App_ReLayout");
}else {
return layout.getAppRelayout();
}
}
@Override
public boolean setValue(Object value, int row, int column) {
int state = 0;
boolean appRelayoutState = true;
if(value instanceof Integer) {
state = (Integer)value;
}else if (value instanceof Boolean) {
appRelayoutState = (boolean)value;
}
if (column == 0 || state < 0) {
return false;
} else {
layout.setAppRelayout(appRelayoutState);
return true;
}
}
/**
* 是否可编辑
* @param row
* @return
*/
@Override
public boolean isEditable(int row) {
return true;
}
private class CheckBoxCellRenderer extends UICheckBox implements TableCellRenderer {
public CheckBoxCellRenderer() {
super();
setOpaque(true);
}
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (value instanceof Boolean) {
setSelected(((Boolean) value).booleanValue());
setEnabled(table.isCellEditable(row, column));
if (isSelected) {
setBackground(table.getSelectionBackground());
setForeground(table.getSelectionForeground());
} else {
setForeground(table.getForeground());
setBackground(table.getBackground());
}
} else {
return null;
}
return this;
}
}
}

8
designer_form/src/com/fr/design/designer/properties/mobile/BodyMobilePropertyUI.java

@ -1,7 +1,7 @@
package com.fr.design.designer.properties.mobile; package com.fr.design.designer.properties.mobile;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XWBodyFitLayout; import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.properties.BodyAppRelayoutTable; import com.fr.design.designer.properties.BodyAppRelayoutTable;
import com.fr.design.fun.impl.AbstractWidgetPropertyUIProvider; import com.fr.design.fun.impl.AbstractWidgetPropertyUIProvider;
import com.fr.design.gui.itable.AbstractPropertyTable; import com.fr.design.gui.itable.AbstractPropertyTable;
@ -14,13 +14,13 @@ public class BodyMobilePropertyUI extends AbstractWidgetPropertyUIProvider {
private XCreator xCreator; private XCreator xCreator;
public BodyMobilePropertyUI(XWBodyFitLayout xWBodyFitLayout) { public BodyMobilePropertyUI(XWFitLayout xwFitLayout) {
this.xCreator = xWBodyFitLayout; this.xCreator = xwFitLayout;
} }
@Override @Override
public AbstractPropertyTable createWidgetAttrTable() { public AbstractPropertyTable createWidgetAttrTable() {
return new BodyAppRelayoutTable((XWBodyFitLayout) xCreator); return new BodyAppRelayoutTable(xCreator);
} }
@Override @Override

2
designer_form/src/com/fr/design/gui/core/FormWidgetOption.java

@ -1 +1 @@
package com.fr.design.gui.core; import javax.swing.Icon; import com.fr.base.BaseUtils; import com.fr.form.ui.ElementCaseEditor; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WCardLayout; import com.fr.form.ui.container.WFitLayout; import com.fr.form.ui.container.WHorizontalBoxLayout; import com.fr.form.ui.container.WParameterLayout; import com.fr.form.ui.container.WVerticalBoxLayout; import com.fr.general.Inter; /** * Author : Shockway * Date: 13-6-17 * Time: 上午10:40 */ public class FormWidgetOption extends WidgetOption { /** * 返回名字 * @return 名字 */ @Override public String optionName() { return null; } /** * 返回图标 * @return 图标 */ @Override public Icon optionIcon() { return null; } /** * 组件类 * @return 类 */ @Override public Class<? extends Widget> widgetClass() { return null; } /** * 返回组件 * @return 控件 */ @Override public Widget createWidget() { return null; } /* * 表单容器 */ public static WidgetOption[] getFormContainerInstance() { return new WidgetOption[] { ABSOLUTELAYOUTCONTAINER, BORDERLAYOUTCONTAINER, HORIZONTALBOXLAYOUTCONTAINER, VERTICALBOXLAYOUTCONTAINER, CARDLAYOUTCONTAINER, FITLAYOUTCONTAINER }; } /** * 表单工具栏上的布局 * @return 控件 */ public static WidgetOption[] getFormLayoutInstance() { return new WidgetOption[] {CARDLAYOUTCONTAINER}; } public static final WidgetOption ABSOLUTELAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_AbsoluteLayout"), BaseUtils.readIcon("/com/fr/web/images/form/resources/layout_absolute.png"), WAbsoluteLayout.class); public static final WidgetOption BORDERLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_BorderLayout"), BaseUtils.readIcon("/com/fr/web/images/form/resources/layout_border.png"), WBorderLayout.class); public static final WidgetOption CARDLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_CardLayout"), BaseUtils.readIcon("/com/fr/web/images/form/resources/card_layout_16.png"), WCardLayout.class); public static final WidgetOption HORIZONTALBOXLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_Layout-HBox"), BaseUtils.readIcon("/com/fr/web/images/form/resources/boxlayout_h_16.png"), WHorizontalBoxLayout.class); public static final WidgetOption VERTICALBOXLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_VerticalBoxLayout"), BaseUtils.readIcon("/com/fr/web/images/form/resources/boxlayout_v_16.png"), WVerticalBoxLayout.class); public static final WidgetOption FITLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter.getLocText("FR-Designer-Layout_Adaptive_Layout"), BaseUtils.readIcon("/com/fr/web/images/form/resources/boxlayout_v_16.png"), WFitLayout.class); public static final WidgetOption PARAMETERCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_Para-Body"), BaseUtils.readIcon("/com/fr/web/images/form/resources/layout_parameter.png"), WParameterLayout.class); public static final WidgetOption ELEMENTCASE = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_Form-Report"), BaseUtils.readIcon("/com/fr/web/images/form/resources/report_16.png"), ElementCaseEditor.class); } package com.fr.design.gui.core; import javax.swing.Icon; import com.fr.base.BaseUtils; import com.fr.form.ui.ElementCaseEditor; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WCardLayout; import com.fr.form.ui.container.WFitLayout; import com.fr.form.ui.container.WHorizontalBoxLayout; import com.fr.form.ui.container.WParameterLayout; import com.fr.form.ui.container.WVerticalBoxLayout; import com.fr.general.Inter; /** * Author : Shockway * Date: 13-6-17 * Time: 上午10:40 */ public class FormWidgetOption extends WidgetOption { /** * 返回名字 * @return 名字 */ @Override public String optionName() { return null; } /** * 返回图标 * @return 图标 */ @Override public Icon optionIcon() { return null; } /** * 组件类 * @return 类 */ @Override public Class<? extends Widget> widgetClass() { return null; } /** * 返回组件 * @return 控件 */ @Override public Widget createWidget() { return null; } /* * 表单容器 */ public static WidgetOption[] getFormContainerInstance() { return new WidgetOption[] { ABSOLUTELAYOUTCONTAINER, BORDERLAYOUTCONTAINER, HORIZONTALBOXLAYOUTCONTAINER, VERTICALBOXLAYOUTCONTAINER, CARDLAYOUTCONTAINER, FITLAYOUTCONTAINER }; } /** * 表单工具栏上的布局 * @return 控件 */ public static WidgetOption[] getFormLayoutInstance() { return new WidgetOption[] {CARDLAYOUTCONTAINER, ABSOLUTELAYOUTCONTAINER}; } public static final WidgetOption ABSOLUTELAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_AbsoluteLayout"), BaseUtils.readIcon("/com/fr/web/images/form/resources/layout_absolute.png"), WAbsoluteLayout.class); public static final WidgetOption BORDERLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_BorderLayout"), BaseUtils.readIcon("/com/fr/web/images/form/resources/layout_border.png"), WBorderLayout.class); public static final WidgetOption CARDLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_CardLayout"), BaseUtils.readIcon("/com/fr/web/images/form/resources/card_layout_16.png"), WCardLayout.class); public static final WidgetOption HORIZONTALBOXLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_Layout-HBox"), BaseUtils.readIcon("/com/fr/web/images/form/resources/boxlayout_h_16.png"), WHorizontalBoxLayout.class); public static final WidgetOption VERTICALBOXLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_VerticalBoxLayout"), BaseUtils.readIcon("/com/fr/web/images/form/resources/boxlayout_v_16.png"), WVerticalBoxLayout.class); public static final WidgetOption FITLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter.getLocText("FR-Designer-Layout_Adaptive_Layout"), BaseUtils.readIcon("/com/fr/web/images/form/resources/boxlayout_v_16.png"), WFitLayout.class); public static final WidgetOption PARAMETERCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_Para-Body"), BaseUtils.readIcon("/com/fr/web/images/form/resources/layout_parameter.png"), WParameterLayout.class); public static final WidgetOption ELEMENTCASE = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_Form-Report"), BaseUtils.readIcon("/com/fr/web/images/form/resources/report_16.png"), ElementCaseEditor.class); }

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

@ -10,6 +10,7 @@ import javax.swing.*;
import javax.swing.event.MouseInputAdapter; import javax.swing.event.MouseInputAdapter;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.beans.location.MoveUtils;
import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.events.DesignerEditor; import com.fr.design.designer.beans.events.DesignerEditor;
@ -18,12 +19,7 @@ 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.beans.models.SelectionModel; import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.beans.models.StateModel; import com.fr.design.designer.beans.models.StateModel;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.*;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XEditorHolder;
import com.fr.design.designer.creator.XElementCase;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.form.util.XCreatorConstants; import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.xpane.ToolTipEditor; import com.fr.design.gui.xpane.ToolTipEditor;
@ -46,6 +42,10 @@ public class EditingMouseListener extends MouseInputAdapter {
*/ */
private StateModel stateModel; private StateModel stateModel;
private XLayoutContainer xTopLayoutContainer;
private XLayoutContainer clickTopLayout;
/** /**
* 获取表单设计器 * 获取表单设计器
* *
@ -73,6 +73,9 @@ public class EditingMouseListener extends MouseInputAdapter {
private DesignerEditor<? extends JComponent> current_editor; private DesignerEditor<? extends JComponent> current_editor;
private XCreator current_creator; private XCreator current_creator;
//备份开始拖动的位置和大小
private Rectangle dragBackupBounds;
/** /**
* 获取最小移动距离 * 获取最小移动距离
* *
@ -84,10 +87,14 @@ public class EditingMouseListener extends MouseInputAdapter {
private int minDragSize = 5; private int minDragSize = 5;
private int minMoveSize = 8; private int minMoveSize = 8;
private static final int EDIT_BTN_WIDTH = 60;
private static final int EDIT_BTN_HEIGHT = 24;
//报表块的编辑按钮不灵敏,范围扩大一点 //报表块的编辑按钮不灵敏,范围扩大一点
private static final int GAP = 10; private static final int GAP = 10;
private XElementCase xElementCase; private XElementCase xElementCase;
private XChartEditor xChartEditor;
private JWindow promptWindow = new JWindow(); private JWindow promptWindow = new JWindow();
@ -186,6 +193,14 @@ public class EditingMouseListener extends MouseInputAdapter {
if (stateModel.isDragging()) { if (stateModel.isDragging()) {
// 当前鼠标所在的组件 // 当前鼠标所在的组件
XCreator hoveredComponent = designer.getComponentAt(e.getX(), e.getY()); XCreator hoveredComponent = designer.getComponentAt(e.getX(), e.getY());
if(designer.isWidgetsIntersect() && dragBackupBounds != null && hoveredComponent != null){
XCreator selectionXCreator = designer.getSelectionModel().getSelection().getSelectedCreator();
if(selectionXCreator != null){
selectionXCreator.setBounds(dragBackupBounds.x, dragBackupBounds.y, dragBackupBounds.width, dragBackupBounds.height);
MoveUtils.hideForbidWindow();
}
}
dragBackupBounds = null;
// 拉伸时鼠标拖动过快,导致所在组件获取会为空 // 拉伸时鼠标拖动过快,导致所在组件获取会为空
if (hoveredComponent == null && e.getY() < 0) { if (hoveredComponent == null && e.getY() < 0) {
// bug63538 // bug63538
@ -244,6 +259,12 @@ public class EditingMouseListener extends MouseInputAdapter {
*/ */
public void mouseMoved(MouseEvent e) { public void mouseMoved(MouseEvent e) {
XCreator component = designer.getComponentAt(e); XCreator component = designer.getComponentAt(e);
setCoverPaneNotDisplay();
if(processTopLayoutMouseMove(component, e)){
return;
}
if (component instanceof XEditorHolder) { if (component instanceof XEditorHolder) {
XEditorHolder xcreator = (XEditorHolder) component; XEditorHolder xcreator = (XEditorHolder) component;
Rectangle rect = xcreator.getBounds(); Rectangle rect = xcreator.getBounds();
@ -267,17 +288,15 @@ public class EditingMouseListener extends MouseInputAdapter {
if (!BaseUtils.isAuthorityEditing()) { if (!BaseUtils.isAuthorityEditing()) {
stateModel.setDirection(dir); stateModel.setDirection(dir);
} }
if(xElementCase != null){
xElementCase.displayCoverPane(false);
}
if (component.isReport()) { if (component.isReport()) {
xElementCase = (XElementCase)component; xElementCase = (XElementCase)component;
UIButton button = (UIButton)xElementCase.getCoverPane().getComponent(0); UIButton button = (UIButton)xElementCase.getCoverPane().getComponent(0);
if(designer.getCursor().getType() ==Cursor.HAND_CURSOR) { if(designer.getCursor().getType() ==Cursor.HAND_CURSOR) {
designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
} // component.getParent() 是报表块所在的XWTitleLayout } // component.getParent() 是报表块所在的XWTitleLayout
int minX = button.getX() + component.getX() + component.getParent().getX() - designer.getArea().getHorizontalValue(); int minX = button.getX() + getParentPositionX(component, 0) - designer.getArea().getHorizontalValue();
int minY = button.getY() + component.getY() + component.getParent().getY() + designer.getParaHeight() - designer.getArea().getVerticalValue(); int minY = button.getY() + getParentPositionY(component, 0) - designer.getArea().getVerticalValue();
if(e.getX() + GAP > minX && e.getX() - GAP < minX + button.getWidth()){ if(e.getX() + GAP > minX && e.getX() - GAP < minX + button.getWidth()){
if( e.getY() + GAP > minY && e.getY() - GAP < minY + button.getHeight()){ if( e.getY() + GAP > minY && e.getY() - GAP < minY + button.getHeight()){
designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
@ -285,13 +304,83 @@ public class EditingMouseListener extends MouseInputAdapter {
} }
xElementCase.displayCoverPane(true); xElementCase.displayCoverPane(true);
xElementCase.setDirections(Direction.TOP_BOTTOM_LEFT_RIGHT); xElementCase.setDirections(Direction.TOP_BOTTOM_LEFT_RIGHT);
designer.repaint(); designer.repaint();
} else { return;
if(xElementCase != null){ }
processChartEditorMouseMove(component, e);
designer.repaint();
}
private void setCoverPaneNotDisplay(){
if (xElementCase != null){
xElementCase.displayCoverPane(false); xElementCase.displayCoverPane(false);
}
if (xChartEditor != null){
xChartEditor.displayCoverPane(false);
}
if (xTopLayoutContainer != null) {
xTopLayoutContainer.setMouseEnter(false);
}
designer.repaint();
}
private boolean processTopLayoutMouseMove(XCreator component, MouseEvent e){
XLayoutContainer parent = XCreatorUtils.getHotspotContainer(component).getTopLayout();
if (parent != null){
xTopLayoutContainer = parent;
xTopLayoutContainer.setMouseEnter(true);
designer.repaint();
if(!xTopLayoutContainer.isEditable()) {
if (designer.getCursor().getType() == Cursor.HAND_CURSOR) {
designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
int minX = getParentPositionX(parent, parent.getX()) + parent.getWidth() / 2;
int minY = getParentPositionY(parent, parent.getY()) + parent.getHeight() / 2;
int offsetX = EDIT_BTN_WIDTH / 2 + GAP;
int offsetY = EDIT_BTN_HEIGHT / 2 + GAP;
if (e.getX() > (minX - offsetX) && e.getX() < (minX + offsetX)) {
if (e.getY() > (minY - offsetY) && e.getY() < (minY + offsetY + designer.getParaHeight())) {
designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
}
return true;
}
}
return false;
}
private void processChartEditorMouseMove(XCreator component, MouseEvent e){
if (component instanceof XChartEditor) {
xChartEditor = (XChartEditor)component;
UIButton button = (UIButton)xChartEditor.getCoverPane().getComponent(0);
if(designer.getCursor().getType() ==Cursor.HAND_CURSOR) {
designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
int minX = button.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));
}
}
xChartEditor.displayCoverPane(true);
xChartEditor.setDirections(Direction.TOP_BOTTOM_LEFT_RIGHT);
designer.repaint(); designer.repaint();
} }
} }
private int getParentPositionX(XCreator comp, int x){
return comp.getParent() == null ?
x : getParentPositionX((XCreator)comp.getParent(), comp.getParent().getX() + x);
}
private int getParentPositionY(XCreator comp, int y) {
return comp.getParent() == null ?
y : getParentPositionY((XCreator) comp.getParent(), comp.getParent().getY() + y);
} }
/** /**
@ -310,6 +399,12 @@ public class EditingMouseListener extends MouseInputAdapter {
stateModel.dragging(e); stateModel.dragging(e);
// 获取e所在的焦点组件 // 获取e所在的焦点组件
XCreator hotspot = designer.getComponentAt(e.getX(), e.getY()); XCreator hotspot = designer.getComponentAt(e.getX(), e.getY());
if(dragBackupBounds == null) {
XCreator selectingXCreator = designer.getSelectionModel().getSelection().getSelectedCreator();
if(selectingXCreator != null){
dragBackupBounds = new Rectangle(selectingXCreator.getX(), selectingXCreator.getY(), selectingXCreator.getWidth(), selectingXCreator.getHeight());
}
}
// 拉伸时鼠标拖动过快,导致所在组件获取会为空 // 拉伸时鼠标拖动过快,导致所在组件获取会为空
if (hotspot == null) { if (hotspot == null) {
return; return;
@ -342,6 +437,58 @@ public class EditingMouseListener extends MouseInputAdapter {
designer.repaint(); designer.repaint();
} }
//当前编辑的组件是在布局中,鼠标点击布局外部,需要一次性将布局及其父布局都置为不可编辑
private void setTopLayoutUnEditable(XLayoutContainer clickedTopLayout, XLayoutContainer clickingTopLayout){
//双击的前后点击click为相同对象,过滤掉
if (clickedTopLayout == null || clickedTopLayout == clickingTopLayout){
return;
}
//位于同一层级的控件,父布局相同,过滤掉
if (clickingTopLayout != null && clickedTopLayout.getParent() == clickingTopLayout.getParent()){
return;
}
//前后点击的位于不同层级,要置为不可编辑
XLayoutContainer xLayoutContainer = (XLayoutContainer)clickedTopLayout.getParent();
if (xLayoutContainer == clickingTopLayout){
return;
}
if (xLayoutContainer != null){
xLayoutContainer.setEditable(false);
setTopLayoutUnEditable((XLayoutContainer) clickedTopLayout.getParent(), clickingTopLayout);
}
}
private boolean isCreatorInLayout(XCreator creator, XCreator layout){
if (creator == layout){
return true;
}
if(layout.getParent() != null){
return isCreatorInLayout(creator, (XCreator)layout.getParent());
}
return false;
}
private XCreator processTopLayoutMouseClick(XCreator creator){
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer(creator).getTopLayout();
if(topLayout != null){
if (clickTopLayout != null && clickTopLayout != topLayout && !isCreatorInLayout(clickTopLayout, topLayout)){
clickTopLayout.setEditable(false);
setTopLayoutUnEditable(clickTopLayout, topLayout);
}
clickTopLayout = topLayout;
if(!topLayout.isEditable()) {
creator = topLayout;
}
}
else{
if(clickTopLayout != null){
clickTopLayout.setEditable(false);
setTopLayoutUnEditable(clickTopLayout, null);
}
}
return creator;
}
/** /**
* 点击 * 点击
* @param e 鼠标事件 * @param e 鼠标事件
@ -351,6 +498,9 @@ public class EditingMouseListener extends MouseInputAdapter {
return; return;
} }
XCreator creator = designer.getComponentAt(e); XCreator creator = designer.getComponentAt(e);
creator = processTopLayoutMouseClick(creator);
if(creator != null){ if(creator != null){
creator.respondClick(this, e); creator.respondClick(this, e);
} }
@ -368,10 +518,9 @@ public class EditingMouseListener extends MouseInputAdapter {
if (designer.getCursor().getType() != Cursor.DEFAULT_CURSOR) { if (designer.getCursor().getType() != Cursor.DEFAULT_CURSOR) {
designer.setCursor(Cursor.getDefaultCursor()); designer.setCursor(Cursor.getDefaultCursor());
} }
if (xElementCase != null){
xElementCase.displayCoverPane(false); setCoverPaneNotDisplay();
designer.repaint();
}
cancelPromptWidgetForbidEnter(); cancelPromptWidgetForbidEnter();
} }

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

@ -9,6 +9,7 @@ import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDragEvent; import java.awt.dnd.DropTargetDragEvent;
import java.awt.dnd.DropTargetDropEvent; import java.awt.dnd.DropTargetDropEvent;
import java.awt.dnd.DropTargetEvent; import java.awt.dnd.DropTargetEvent;
import java.util.ArrayList;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JWindow; import javax.swing.JWindow;
@ -85,8 +86,12 @@ public class FormCreatorDropTarget extends DropTarget {
if (success) { if (success) {
// 如果添加成功,则触发相应事件 // 如果添加成功,则触发相应事件
XCreator xCreator = container.acceptType(XWParameterLayout.class) ? designer.getParaComponent() : designer.getRootComponent(); 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( designer.getSelectionModel().setSelectedCreators(
FormSelectionUtils.rebuildSelection(xCreator, new Widget[]{addingModel.getXCreator().toData()})); FormSelectionUtils.rebuildSelection(xCreator, new Widget[]{widget}));
designer.getEditListenerTable().fireCreatorModified(addingModel.getXCreator(), DesignerEvent.CREATOR_ADDED); designer.getEditListenerTable().fireCreatorModified(addingModel.getXCreator(), DesignerEvent.CREATOR_ADDED);
} else { } else {
Toolkit.getDefaultToolkit().beep(); Toolkit.getDefaultToolkit().beep();

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

@ -84,6 +84,9 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
private ConnectorHelper ConnectorHelper; private ConnectorHelper ConnectorHelper;
private boolean isReportBlockEditing = false; private boolean isReportBlockEditing = false;
//组件重叠
private boolean isWidgetsIntersect = false;
/** /**
* 下面的变量都是非序列化成员不记录设计状态只作为设计时临时状态使用 * 下面的变量都是非序列化成员不记录设计状态只作为设计时临时状态使用
*/ */
@ -539,6 +542,12 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
if (paraComponent != null && paraComponent.acceptType(XWParameterLayout.class)){ if (paraComponent != null && paraComponent.acceptType(XWParameterLayout.class)){
return true; return true;
} }
else{
if (this.getSelectionModel().getSelection().getSelectedCreator().getParent() != null
&& ((XLayoutContainer)this.getSelectionModel().getSelection().getSelectedCreator().getParent()).acceptType(XWAbsoluteLayout.class)){
return true;
}
}
return false; return false;
} }
@ -558,6 +567,14 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
return this.isReportBlockEditing; return this.isReportBlockEditing;
} }
public void setWidgetsIntersect(boolean isWidgetsIntersect){
this.isWidgetsIntersect = isWidgetsIntersect;
}
public boolean isWidgetsIntersect(){
return this.isWidgetsIntersect;
}
/** /**
* 是否重命名控件 * 是否重命名控件
* @param creator 组件 * @param creator 组件

15
sonar-project.properties

@ -0,0 +1,15 @@
# must be unique in a given SonarQube instance
sonar.projectKey=finereport.design
# this is the name displayed in the SonarQube UI
sonar.projectName=finereport.design
sonar.projectVersion=1.0
sonar.branch=master
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# Since SonarQube 4.2, this property is optional if sonar.modules is set.
# If not set, SonarQube starts looking for source code from the directory containing
# the sonar-project.properties file.
sonar.sources=.
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8

1
start.bat

@ -0,0 +1 @@
sonar-scanner
Loading…
Cancel
Save