Browse Source

Merge remote-tracking branch 'origin/dev' into dev

master
juhaoyu 8 years ago
parent
commit
ae2db153d9
  1. 2
      build.dev.gradle
  2. 86
      build.gradle.bak
  3. 5
      designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java
  4. 39
      designer/src/com/fr/design/present/CellWriteAttrPane.java
  5. 2
      designer_base/build.dev.gradle
  6. 70
      designer_base/build.gradle.bak
  7. 5
      designer_base/src/com/fr/design/extra/PluginWebBridge.java
  8. 19
      designer_base/src/com/fr/design/extra/QQLoginWebBridge.java
  9. 2
      designer_base/src/com/fr/design/hyperlink/AbstractHyperlinkPane.java
  10. 48
      designer_base/src/com/fr/design/hyperlink/HyperlinkTargetFrame.java
  11. BIN
      designer_base/src/com/fr/design/images/control/combobox.png
  12. 14
      designer_base/src/com/fr/design/utils/DesignUtils.java
  13. 2
      designer_chart/build.dev.gradle
  14. 66
      designer_chart/build.gradle.bak
  15. 2
      designer_form/build.dev.gradle
  16. 83
      designer_form/build.gradle.bak
  17. 30
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteBodyLayoutAdapter.java
  18. 1
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java
  19. 133
      designer_form/src/com/fr/design/designer/creator/XCreator.java
  20. 1
      designer_form/src/com/fr/design/designer/creator/XCreatorUtils.java
  21. 26
      designer_form/src/com/fr/design/designer/creator/XElementCase.java
  22. 45
      designer_form/src/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java
  23. 5
      designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java
  24. 5
      designer_form/src/com/fr/design/designer/properties/AbsoluteStateRenderer.java
  25. 23
      designer_form/src/com/fr/design/designer/properties/BodyLayoutAttrRenderer.java
  26. 239
      designer_form/src/com/fr/design/designer/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java
  27. 8
      designer_form/src/com/fr/design/designer/properties/FRAbsoluteLayoutPropertiesGroupModel.java
  28. 68
      designer_form/src/com/fr/design/designer/properties/FRFitLayoutPropertiesGroupModel.java
  29. 4
      designer_form/src/com/fr/design/designer/properties/FitStateRenderer.java
  30. 12
      designer_form/src/com/fr/design/designer/properties/LayoutTypeRenderer.java
  31. 13
      designer_form/src/com/fr/design/designer/properties/LayoutTypeWrapper.java
  32. 4
      designer_form/src/com/fr/design/designer/properties/items/FRFitConstraintsItems.java
  33. 16
      designer_form/src/com/fr/design/designer/properties/items/FRLayoutTypeItems.java
  34. 26
      designer_form/src/com/fr/design/designer/treeview/ComponentTreeModel.java
  35. 2
      designer_form/src/com/fr/design/gui/core/FormWidgetOption.java
  36. 192
      designer_form/src/com/fr/design/mainframe/ComponentTree.java
  37. 9
      designer_form/src/com/fr/design/mainframe/FormParaWidgetPane.java
  38. 192
      designer_form/src/com/fr/design/mainframe/ShareWidgetButton.java
  39. 29
      designer_form/src/com/fr/design/mainframe/ShareWidgetPane.java
  40. 291
      designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java
  41. 15
      designer_form/src/com/fr/design/mainframe/widget/editors/LayoutTypeEditor.java

2
build.gradle → build.dev.gradle

@ -5,7 +5,7 @@ tasks.withType(JavaCompile){
def basicDir="../../"
def libDir="${basicDir}/finereport-lib-stable"
//
FileTree files =fileTree(dir:"./",include:"build.gradle")
FileTree files =fileTree(dir:"./",include:"build.*.gradle")
def buildDir=files[0].path.substring(0,files[0].path.lastIndexOf ("\\"))
def branchName=buildDir.substring(buildDir.lastIndexOf ("\\")+1)

86
build.gradle.bak

@ -1,86 +0,0 @@
apply plugin: "java"
tasks.withType(JavaCompile){
options.encoding = "UTF-8"
}
sourceCompatibility=1.7
def basicDir="../../"
def libDir="${basicDir}/finereport-lib-stable"
//
FileTree files =fileTree(dir:"./",include:"build.gradle")
def buildDir=files[0].path.substring(0,files[0].path.lastIndexOf ("\\"))
def branchName=buildDir.substring(buildDir.lastIndexOf ("\\")+1)
task appletJar<<{
ant{
mkdir(dir:"${libDir}/tmp-${branchName}")
mkdir(dir:"build/classes/")
copy(todir:"build/classes/"){
fileset(dir:"${basicDir}/finereport-core-stable/${branchName}/build/classes/main")
fileset(dir:"${basicDir}/finereport-chart-stable/${branchName}/build/classes/main")
fileset(dir:"${basicDir}/finereport-report-stable/${branchName}/build/classes/main")
fileset(dir:"${basicDir}/finereport-platform-stable/${branchName}/build/classes/main")
fileset(dir:"${basicDir}/finereport-performance-stable/${branchName}/build/classes/main")
}
unjar(src:"${libDir}/3rd.jar",dest:"${libDir}/tmp-${branchName}")
unjar(src:"${libDir}/servlet-api.jar",dest:"${libDir}/tmp-${branchName}")
jar(jarfile:"build/libs/fr-applet-8.0.jar"){
fileset(dir:"build/classes"){
exclude(name:"*.*")
exclude(name:"bin/*.*")
exclude(name:"classes/**")
exclude(name:"com/fr/schedule/**")
exclude(name:"com/fr/cell/**")
exclude(name:"com/fr/dialog/**")
exclude(name:"com/fr/view/**")
exclude(name:"com/fr/web/**")
exclude(name:"com/fr/fs/**")
exclude(name:"com/fr/design/**")
exclude(name:"com/fr/start/**")
exclude(name:"com/fr/process/**")
}
fileset(dir:"${libDir}/tmp-${branchName}"){
include(name:"javax/mail/**")
include(name:"javax/servlet/**")
include(name:"org/freehep/**")
include(name:"com/fr/third/JAI/**")
include(name:"com/fr/third/antlr/**")
include(name:"com/fr/third/javax/**")
include(name:"com/sun/xml/**")
include(name:"javax/xml/**")
}
fileset(dir:"build/classes"){
include(name:"com/fr/web/*.class")
include(name:"com/fr/web/attr/*.class")
}
}
delete(dir:"${libDir}/tmp-${branchName}")
def jdk6home= "D:/FineReport/develop/java/jdk1.6u35"
def keystore="frapplet.store"
def keycert="fr.cert"
def keypassword="123456"
def keyalias="fr"
exec(executable:"${jdk6home}/bin/keytool"){
arg(line:"-genkey -dname &quot;CN=FineReport L=NanJing C=China&quot; -keystore ${keystore} -alias ${keyalias} -validity 3650 -storepass ${keypassword}")
}
exec(executable:"${jdk6home}/bin/keytool"){
arg(line:"-export -keystore ${keystore} -alias ${keyalias} -file ${keycert} -storepass ${keypassword}")
}
exec(executable:"${jdk6home}/bin/jarsigner"){
arg(line:"-keystore ${keystore} -storepass ${keypassword} 'build/libs/fr-applet-8.0.jar' ${keyalias}")
}
delete(file:"${keystore}")
delete(file:"${keycert}")
delete(dir:"build/classes")
}
}

5
designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java

@ -284,10 +284,7 @@ public class UserInfoLabel extends UILabel{
public void mousePressed(MouseEvent e) {
if(StringUtils.isNotEmpty(userName)){
try {
String loginUrl = SiteCenter.getInstance().acquireUrlByKind("bbs.default") +
"&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes&inajax=" +
"&username=" + DesignerEnvManager.getEnvManager().getBBSName() +
"&password=" + DesignerEnvManager.getEnvManager().getBBSPassword();
String loginUrl = SiteCenter.getInstance().acquireUrlByKind("bbs.default");
Desktop.getDesktop().browse(new URI(loginUrl));
} catch (Exception exp) {
FRContext.getLogger().info(exp.getMessage());

39
designer/src/com/fr/design/present/CellWriteAttrPane.java

@ -1,15 +1,13 @@
package com.fr.design.present;
import com.fr.base.FRContext;
import com.fr.base.Style;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.widget.WidgetPane;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.form.ui.DateEditor;
import com.fr.form.ui.NoneWidget;
import com.fr.form.ui.Widget;
import com.fr.general.FRLogger;
@ -22,8 +20,6 @@ import com.fr.report.cell.TemplateCellElement;
import com.fr.report.elementcase.TemplateElementCase;
import java.awt.*;
import java.text.Format;
import java.text.SimpleDateFormat;
public class CellWriteAttrPane extends BasicPane {
@ -78,22 +74,6 @@ public class CellWriteAttrPane extends BasicPane {
Widget cellWidget = cellElement.getWidget();
if (cellWidget != null && cellWidget instanceof DateEditor) {
// p:日期的格式需要设置到单元格子里面.
DateEditor dateCellEditorDef = (DateEditor) cellWidget;
// p:需要把下拉的编辑器,日期格式,都放到CellElement的Style里面
// 这个地方很方便用户,是alex提出的.
// p:日期的格式需要设置到单元格子里面.
Style style = cellElement.getStyle();
if (style != null) {
Format format = style.getFormat();
if (format != null && format instanceof SimpleDateFormat) {
SimpleDateFormat simpleDateFormat = (SimpleDateFormat) format;
dateCellEditorDef.setFormatText(simpleDateFormat.toPattern());
}
}
}
// 这里进行克隆的原因是为了保留原始的Widget以便和新的Widget做比较来判断是否发生了改变
if (cellWidget != null) {
try {
@ -111,19 +91,6 @@ public class CellWriteAttrPane extends BasicPane {
}
Widget cellWidget = this.cellEditorDefPane.update();
// p:需要把下拉的编辑器,日期格式,都放到CellElement的Style里面
if (cellWidget instanceof DateEditor) {
// p:日期的格式需要设置到单元格子里面.
DateEditor dateCellEditorDef = (DateEditor) cellWidget;
String formatText = dateCellEditorDef.getFormatText();
if (formatText != null) {
Style style = cellElement.getStyle();
if (style != null) {
cellElement.setStyle(style.deriveFormat(new SimpleDateFormat(formatText)));
}
}
}
// p:最后把这个cellEditorDef设置到CellGUIAttr.
if (cellWidget instanceof NoneWidget) {
cellElement.setWidget(null);

2
designer_base/build.gradle → designer_base/build.dev.gradle

@ -24,7 +24,7 @@ sourceSets{
}
}
//
FileTree files =fileTree(dir:'./',include:'build.gradle')
FileTree files =fileTree(dir:'./',include:'build.*.gradle')
def buildDir=files[0].path.substring(0,files[0].path.lastIndexOf ('\\'))
buildDir=buildDir.substring(0,buildDir.lastIndexOf ('\\'))
def branchName=buildDir.substring(buildDir.lastIndexOf ('\\')+1)

70
designer_base/build.gradle.bak

@ -1,70 +0,0 @@
apply plugin: 'java'
tasks.withType(JavaCompile){
options.encoding = 'UTF-8'
}
//jdk版本
sourceCompatibility=1.8
//jar包版本
version='8.0'
//jar包重命名
jar{
baseName='fr-designer-core'
}
def srcDir="."
//
sourceSets{
main{
java{
srcDirs=["${srcDir}/src"]
}
}
}
//
FileTree files =fileTree(dir:'./',include:'build.gradle')
def buildDir=files[0].path.substring(0,files[0].path.lastIndexOf ('\\'))
buildDir=buildDir.substring(0,buildDir.lastIndexOf ('\\'))
def branchName=buildDir.substring(buildDir.lastIndexOf ('\\')+1)
//
dependencies{
compile fileTree(dir:'../../../finereport-lib-stable',include:'**/*.jar')
compile fileTree(dir:'../../../',include:"finereport-*-stable/${branchName}/**/build/libs/*.jar")
testCompile 'junit:junit:4.12'
}
//.java文件到classes文件夹下参与打包
task copyFile(type:Copy,dependsOn:compileJava){
copy{
from ("${srcDir}/src"){
exclude '**/.setting/**','.classpath','.project','**/*.java','**/*.db','**/*.g','**/package.html'
}
into 'build/classes/main'
}
}
//js文件
task compressJS{
ant.taskdef(name:'yuicompress',classname:'com.yahoo.platform.yui.compressor.YUICompressTask'){
classpath {
fileset(dir:'../../../finereport-lib4build-stable',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}/src"){
include (name:'**/*.js')
include (name:'**/*.css')
}
}
}
jar.dependsOn compressJS

5
designer_base/src/com/fr/design/extra/PluginWebBridge.java

@ -379,10 +379,7 @@ public class PluginWebBridge {
*/
public void getPriviteMessage() {
try {
String loginUrl = SiteCenter.getInstance().acquireUrlByKind("bbs.default") +
"&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes&inajax=" +
"&username=" + DesignerEnvManager.getEnvManager().getBBSName() +
"&password=" + DesignerEnvManager.getEnvManager().getBBSPassword();
String loginUrl = SiteCenter.getInstance().acquireUrlByKind("bbs.default");
Desktop.getDesktop().browse(new URI(loginUrl));
}catch (Exception exp) {
FRContext.getLogger().info(exp.getMessage());

19
designer_base/src/com/fr/design/extra/QQLoginWebBridge.java

@ -127,24 +127,5 @@ public class QQLoginWebBridge {
if (url.indexOf("qqLogin.html") > 0) {
return;
}
if (Desktop.isDesktopSupported()) {
try {
//创建一个URI实例,注意不是URL
URI uri = URI.create(url);
//获取当前系统桌面扩展
Desktop desktop = Desktop.getDesktop();
//判断系统桌面是否支持要执行的功能
if (desktop.isSupported(Desktop.Action.BROWSE)) {
//获取系统默认浏览器打开链接
desktop.browse(uri);
}
} catch (NullPointerException e) {
//此为uri为空时抛出异常
FRLogger.getLogger().error(e.getMessage());
} catch (IOException e) {
//此为无法获取系统默认浏览器
FRLogger.getLogger().error(e.getMessage());
}
}
}
}

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

@ -127,7 +127,7 @@ public abstract class AbstractHyperlinkPane<T extends Hyperlink> extends BasicBe
public void updateBean(T link) {
updateSubHyperlinkBean(link);
link.setTargetFrame((String) targetFrameComboBox.getSelectedItem());
link.setTargetFrame(HyperlinkTargetFrame.parse(targetFrameComboBox.getSelectedIndex()).getName());
link.setHeight(Utils.objectToNumber(heightTextFiled.getText(), false).intValue());
link.setWidth(Utils.objectToNumber(widthTextFiled.getText(), false).intValue());
}

48
designer_base/src/com/fr/design/hyperlink/HyperlinkTargetFrame.java

@ -0,0 +1,48 @@
package com.fr.design.hyperlink;
/**
* Created by ibm on 2016/10/13.
*/
public enum HyperlinkTargetFrame {
BLANK_FRAME("_blank", 0), DIALOG_FRAME("_dialog", 1), SELF_FRAME("_self", 2);
private String name;
private int index;
private static HyperlinkTargetFrame[] arrayOfValues;
HyperlinkTargetFrame(String name, int index) {
this.name = name;
this.index = index;
}
public static HyperlinkTargetFrame parse(int index) {
if (arrayOfValues == null) {
arrayOfValues = HyperlinkTargetFrame.values();
}
for (HyperlinkTargetFrame hyperlinkTargetFrame : HyperlinkTargetFrame.values()) {
if (hyperlinkTargetFrame.getIndex() == index) {
return hyperlinkTargetFrame;
}
}
return BLANK_FRAME;
}
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 B

14
designer_base/src/com/fr/design/utils/DesignUtils.java

@ -230,15 +230,12 @@ public class DesignUtils {
private static FRFont getCurrentLocaleFont(){
FRFont guiFRFont;
Locale defaultLocale = FRContext.getLocale();
Locale defaultLocale = Locale.getDefault();
if (isDisplaySimSun(defaultLocale)) {
guiFRFont = getNamedFont("SimSun");
} else if(isDisplayDialog(defaultLocale)) {
guiFRFont = getNamedFont("Dialog");
} else if(isDisplayJapaneseFont(defaultLocale)){
//日文设计器默认用MS Mincho字体渲染
guiFRFont = getNamedFont("MS Mincho");
} else {
guiFRFont = getNamedFont("Tahoma");
}
@ -270,14 +267,11 @@ public class DesignUtils {
private static boolean isDisplaySimSun(Locale defaultLocale){
return ComparatorUtils.equals(defaultLocale, Locale.SIMPLIFIED_CHINESE);
}
private static boolean isDisplayJapaneseFont(Locale defaultLocale){
return ComparatorUtils.equals(defaultLocale, Locale.JAPANESE)
|| ComparatorUtils.equals(defaultLocale, Locale.JAPAN);
}
private static boolean isDisplayDialog(Locale defaultLocale){
return ComparatorUtils.equals(defaultLocale, Locale.TRADITIONAL_CHINESE)
return ComparatorUtils.equals(defaultLocale, Locale.TRADITIONAL_CHINESE)
|| ComparatorUtils.equals(defaultLocale, Locale.JAPANESE)
|| ComparatorUtils.equals(defaultLocale, Locale.JAPAN)
|| ComparatorUtils.equals(defaultLocale, Locale.KOREAN)
|| ComparatorUtils.equals(defaultLocale, Locale.KOREA);
}

2
designer_chart/build.gradle → designer_chart/build.dev.gradle

@ -23,7 +23,7 @@ sourceSets{
}
}
}
FileTree files =fileTree(dir:'./',include:'build.gradle')
FileTree files =fileTree(dir:'./',include:'build.*.gradle')
def buildDir=files[0].path.substring(0,files[0].path.lastIndexOf ('\\'))
buildDir=buildDir.substring(0,buildDir.lastIndexOf ('\\'))
def branchName=buildDir.substring(buildDir.lastIndexOf ('\\')+1)

66
designer_chart/build.gradle.bak

@ -1,66 +0,0 @@
apply plugin: 'java'
tasks.withType(JavaCompile){
options.encoding = 'UTF-8'
}
//jdk版本
sourceCompatibility=1.8
//jar包的版本
version='8.0'
def srcDir="."
//jar包进行重命名
jar{
baseName='fr-designer-chart'
}
sourceSets{
main{
java{
srcDirs=["${srcDir}/src"]
}
}
}
FileTree files =fileTree(dir:'./',include:'build.gradle')
def buildDir=files[0].path.substring(0,files[0].path.lastIndexOf ('\\'))
buildDir=buildDir.substring(0,buildDir.lastIndexOf ('\\'))
def branchName=buildDir.substring(buildDir.lastIndexOf ('\\')+1)
//
dependencies{
compile fileTree(dir:'../../../finereport-lib-stable',include:'**/*.jar')
compile fileTree(dir:'../../../',include:"finereport-*-stable/${branchName}/**/build/libs/*.jar")
testCompile 'junit:junit:4.12'
}
//.java classes文件夹下参与打包
task copyFile(type:Copy,dependsOn:compileJava){
copy{
from ("${srcDir}/src"){
exclude '**/.setting/**','.classpath','.project','**/*.java','**/*.db','**/*.g','**/package.html'
}
into 'build/classes/main'
}
}
//js文件
task compressJS{
ant.taskdef(name:'yuicompress',classname:'com.yahoo.platform.yui.compressor.YUICompressTask'){
classpath {
fileset(dir:'../../../finereport-lib4build-stable',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}/src"){
include (name:'**/*.js')
include (name:'**/*.css')
}
}
}
jar.dependsOn compressJS

2
designer_form/build.gradle → designer_form/build.dev.gradle

@ -26,7 +26,7 @@ sourceSets{
}
//
FileTree files =fileTree(dir:'./',include:'build.gradle')
FileTree files =fileTree(dir:'./',include:'build.*.gradle')
def buildDir=files[0].path.substring(0,files[0].path.lastIndexOf ('\\'))
buildDir=buildDir.substring(0,buildDir.lastIndexOf ('\\'))
def branchName=buildDir.substring(buildDir.lastIndexOf ('\\')+1)

83
designer_form/build.gradle.bak

@ -1,83 +0,0 @@
apply plugin: 'java'
tasks.withType(JavaCompile){
options.encoding = 'UTF-8'
}
//jdk版本
sourceCompatibility=1.8
//jar包版本
version='8.0'
def srcDir="."
//jar包的名字
jar{
baseName='fr-designer-report'
}
//
sourceSets{
main{
java{
srcDirs=["${srcDir}/src",
"${srcDir}/../designer/src"]
}
}
}
//
FileTree files =fileTree(dir:'./',include:'build.gradle')
def buildDir=files[0].path.substring(0,files[0].path.lastIndexOf ('\\'))
buildDir=buildDir.substring(0,buildDir.lastIndexOf ('\\'))
def branchName=buildDir.substring(buildDir.lastIndexOf ('\\')+1)
//
dependencies{
compile fileTree(dir:"../../../finereport-lib-stable${branchName}",include:'**/*.jar')
compile fileTree(dir:'../../../',include:"finereport-*-stable/${branchName}/**/build/libs/*.jar")
testCompile 'junit:junit:4.12'
}
//
def dataContent ={def dir ->
copySpec{
from ("${dir}"){
exclude '**/.setting/**','.classpath','.project','**/*.java','**/*.db','**/*.g','**/package.html'
}
}
}
//.java文件复制到classes文件夹下
task copyFile(type:Copy,dependsOn:compileJava){
copy{
with dataContent.call("${srcDir}/src")
with dataContent.call("${srcDir}/../designer/src")
into ('build/classes/main')
}
}
//js文件
task compressJS{
ant.taskdef(name:'yuicompress',classname:'com.yahoo.platform.yui.compressor.YUICompressTask'){
classpath {
fileset(dir:'../../../finereport-lib4build-stable',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}/src"){
include (name:'**/*.js')
include (name:'**/*.css')
}
fileset (dir:"${srcDir}/../designer/src"){
include (name:'**/*.js')
include (name:'**/*.css')
}
}
}
jar.dependsOn compressJS

30
designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteBodyLayoutAdapter.java

@ -0,0 +1,30 @@
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.XWAbsoluteBodyLayout;
import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.properties.FRAbsoluteBodyLayoutPropertiesGroupModel;
import com.fr.design.designer.properties.FRAbsoluteLayoutPropertiesGroupModel;
import com.fr.form.ui.container.WBodyLayoutType;
/**
* Created by zhouping on 2016/10/14.
*/
public class FRAbsoluteBodyLayoutAdapter extends FRAbsoluteLayoutAdapter {
public FRAbsoluteBodyLayoutAdapter(XLayoutContainer container) {
super(container);
}
@Override
public GroupModel getLayoutProperties() {
XWAbsoluteBodyLayout xwAbsoluteBodyLayout = (XWAbsoluteBodyLayout) container;
//如果body是绝对布局,那么获取原来自适应body的属性--布局类型
WBodyLayoutType layoutType = WBodyLayoutType.FIT;
if (container.getParent() != null) {
layoutType = ((XWFitLayout)container.getParent()).toData().getBodyLayoutType();
}
return new FRAbsoluteBodyLayoutPropertiesGroupModel(xwAbsoluteBodyLayout, layoutType);
}
}

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

@ -12,6 +12,7 @@ import com.fr.design.designer.properties.FRAbsoluteLayoutPropertiesGroupModel;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.design.utils.ComponentUtils;
import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.container.WBodyLayoutType;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;

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

@ -15,6 +15,7 @@ import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WTitleLayout;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import javax.swing.*;
import javax.swing.border.Border;
@ -27,7 +28,7 @@ import java.util.List;
/**
* @author richer
* @since 6.5.3 com.fr.base.listener.OB的设计组件
*
*
*/
public abstract class XCreator extends JPanel implements XComponent, XCreatorTools {
@ -44,6 +45,8 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
// XCreator加入到某些XLayoutContainer中时,能调整宽度或者高度
private int[] directions;
private Rectangle backupBound;
private String shareId = StringUtils.EMPTY;//如果组件是共享的会有这个属性
private boolean isHelpBtnOnFocus = false;//焦点是否在帮助按钮上
public XCreator(Widget ob, Dimension initSize) {
this.data = ob;
@ -83,7 +86,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
setSize(this.backupSize);
}
}
/**
* 备份当前大小
*/
@ -113,76 +116,76 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
public XLayoutContainer getTopLayout(){
return null;
}
/**
* 获取当前XCreator的一个封装父容器
*
*
* @param widgetName 当前组件名
*
*
* @return 封装的父容器
*
*
*
* @date 2014-11-25-下午4:47:23
*
*
*/
protected XLayoutContainer getCreatorWrapper(String widgetName){
return new XWTitleLayout();
}
/**
* 将当前对象添加到父容器中
*
*
* @param parentPanel 父容器组件
*
*
*
* @date 2014-11-25-下午4:57:55
*
*
*/
protected void addToWrapper(XLayoutContainer parentPanel, int width, int minHeight){
protected void addToWrapper(XLayoutContainer parentPanel, int width, int minHeight){
parentPanel.add(this, WTitleLayout.BODY);
}
/**
* 设置父容器的名字
*
*
* @param parentPanel 当前父容器
* @param widgetName 当前控件名
*
*
*
* @date 2014-11-27-上午9:47:00
*
*
*/
protected void setWrapperName(XLayoutContainer parentPanel, String widgetName){
parentPanel.toData().setWidgetName(widgetName);
}
/**
* 初始化当前组件的父容器
* 大体分为三种: Scale缩放型, Title标题型, Border自定义标题栏
*
*
* @param minHeight 最小高度
*
*
* @return 父容器
*
*
*
* @date 2014-11-25-下午5:15:23
*
*
*/
public XLayoutContainer initCreatorWrapper(int minHeight){
XLayoutContainer parentPanel;
String widgetName = this.toData().getWidgetName();
parentPanel = this.getCreatorWrapper(widgetName);
int width = this.getWidth();
int height = this.getHeight();
parentPanel.setLocation(this.getX(), this.getY());
parentPanel.setSize(width, height);
setWrapperName(parentPanel, widgetName);
this.setLocation(0, 0);
this.addToWrapper(parentPanel, width, minHeight);
LayoutUtils.layoutRootContainer(parentPanel);
return parentPanel;
}
@ -291,7 +294,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
public Dimension getMinimumSize() {
return new Dimension(0, 0);
}
/**
* 是否支持切换到报表界面编辑
* @return 是则返回true
@ -299,7 +302,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
public boolean isReport(){
return false;
}
/**
* 该组件是否可以拖入参数面板
* @return 是则返回true
@ -359,7 +362,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
public void setBackupBound(Rectangle rec) {
this.backupBound = rec;
}
/**
* 控件树不显示此组件
* @param path 控件树list
@ -367,7 +370,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
public void notShowInComponentTree(ArrayList<Component> path) {
return;
}
/**
* 重置组件的名称
* @param name 名称
@ -375,7 +378,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
public void resetCreatorName(String name) {
toData().setWidgetName(name);
}
/**
* 返回编辑的子组件scale为其内部组件
* @return 组件
@ -383,7 +386,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
public XCreator getEditingChildCreator() {
return this;
}
/**
* 返回对应属性表的组件scale和title返回其子组件
* @return 组件
@ -391,7 +394,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
public XCreator getPropertyDescriptorCreator() {
return this;
}
/**
* 更新子组件的Bound; 没有不处理
* @param minHeight 最小高度
@ -399,7 +402,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
public void updateChildBound(int minHeight) {
return;
}
/**
* 是否作为控件树的叶子节点
* @return 是则返回true
@ -407,7 +410,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
public boolean isComponentTreeLeaf() {
return true;
}
/**
* 是否为sclae和title专属容器
* @return 是则返回true
@ -415,7 +418,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
public boolean isDedicateContainer() {
return false;
}
/**
* 是否接收这种类型
* @param acceptTypes 接收的类型
@ -432,13 +435,13 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
/**
* 是否组件要缩放(自适应里部分组件需要, 如数字文本下拉框下拉复选框密码下拉树下拉复选树日期)
*
*
* @return 是则返回true
*/
public boolean shouldScaleCreator() {
return false;
}
/**
* 是否支持标题样式
* @return 默认false
@ -446,10 +449,10 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
public boolean hasTitleStyle() {
return false;
}
/**
* 响应点击事件
*
*
* @param editingMouseListener 鼠标点击位置处理器
* @param e 鼠标点击事件
*/
@ -468,10 +471,10 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
}
}
}
/**
* 删除相关组件
*
*
* @param creator 当前组件
* @param designer 表单设计器
*
@ -479,17 +482,17 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
public void deleteRelatedComponent(XCreator creator,FormDesigner designer){
return;
}
/**
* 选择相关组件
*
*
* @param creator 当前组件
*
*
*/
public void seleteRelatedComponent(XCreator creator){
return;
}
/**
* 返回组件
* @return
@ -498,7 +501,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
public XCreator getXCreator(){
return this;
}
/**
* 按百分比调整组件
* @param percent 百分比
@ -507,7 +510,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
public void adjustCompSize(double percent){
return;
}
/**
* 返回一些需要的子组件
* @return 返回一些需要的子组件
@ -516,11 +519,11 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
public ArrayList<?> getTargetChildrenList(){
return new ArrayList();
}
public XLayoutContainer getOuterLayout(){
return this.getBackupParent();
}
/**
* 重新调整子组件宽度
* @param width 宽度
@ -553,4 +556,38 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
public boolean supportRenameInWidgetTree() {
return true;
}
/**
* 组件是否是共享组件
* @return 是否是共享组件
*/
public boolean isShared() {
return StringUtils.isNotEmpty(shareId);
}
public void setShareId(String shareId) {
this.shareId = shareId;
}
public String getShareId() {
return shareId;
}
/**
* 焦点是否在帮助按钮上
* @return 焦点是否在帮助按钮上
*/
public boolean isHelpBtnOnFocus() {
return isHelpBtnOnFocus;
}
public void setHelpBtnOnFocus(boolean helpBtnOnFocus) {
isHelpBtnOnFocus = helpBtnOnFocus;
}
/**
* 设置共享帮助信息
* @param msg 帮助信息
*/
public void setSharedMsg(String msg){}
}

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

@ -77,6 +77,7 @@ public class XCreatorUtils {
xLayoutMap.put(WAbsoluteLayout.class, XWAbsoluteLayout.class);
xLayoutMap.put(WParameterLayout.class, XWParameterLayout.class);
xLayoutMap.put(WAbsoluteBodyLayout.class, XWAbsoluteBodyLayout.class);
xLayoutMap.put(WAbsoluteLayout.class, XWAbsoluteLayout.class);
xLayoutMap.put(WHorizontalBoxLayout.class, XWHorizontalBoxLayout.class);
xLayoutMap.put(WBorderLayout.class, XWBorderLayout.class);

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

@ -1,5 +1,6 @@
package com.fr.design.designer.creator;
import com.fr.base.BaseUtils;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.designer.properties.mobile.ElementCasePropertyUI;
import com.fr.design.form.util.XCreatorConstants;
@ -20,6 +21,7 @@ import com.fr.form.FormElementCaseProvider;
import com.fr.form.ui.ElementCaseEditor;
import com.fr.general.Inter;
import com.fr.stable.ArrayUtils;
import com.fr.stable.CoreGraphHelper;
import com.fr.stable.core.PropertyChangeAdapter;
import com.fr.stable.fun.FitProvider;
import com.fr.stable.fun.ReportFitAttrProvider;
@ -35,6 +37,18 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
private UILabel imageLable;
private JPanel coverPanel;
private FormDesigner designer;
//缩略图
private BufferedImage thumbnailImage;
private static BufferedImage DEFAULT_BACKGROUND;
static{
try{
DEFAULT_BACKGROUND = BaseUtils.readImageWithCache("com/fr/base/images/report/elementcase.png");
}catch (Throwable e) {
//IBM jdk 1.5.0_22 并发下读取图片有时会异常(EOFException), 这个图片反正只有设计器用到, 捕获住
DEFAULT_BACKGROUND = CoreGraphHelper.createBufferedImage(0, 0);
}
}
public XElementCase(ElementCaseEditor widget, Dimension initSize) {
super(widget, initSize);
@ -145,7 +159,7 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
*/
private UILabel initImageBackground(){
UILabel imageLable = new UILabel();
BufferedImage image = toData().getECImage();
BufferedImage image = getThumbnailImage();
setLabelBackground(image, imageLable);
return imageLable;
@ -222,10 +236,18 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
}
public void setBackground(BufferedImage image){
toData().setECImage(image);
setThumbnailImage(image);
setEditorIcon(image);
}
private void setThumbnailImage(BufferedImage image) {
this.thumbnailImage = image;
}
private BufferedImage getThumbnailImage(){
return thumbnailImage == null ? DEFAULT_BACKGROUND : thumbnailImage;
}
private void setEditorIcon(BufferedImage image){
setLabelBackground(image, imageLable);
}

45
designer_form/src/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java

@ -0,0 +1,45 @@
package com.fr.design.designer.creator;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRAbsoluteBodyLayoutAdapter;
import com.fr.form.ui.container.WAbsoluteBodyLayout;
import java.awt.*;
/**
* Created by zhouping on 2016/10/14.
* 用作body的绝对布局
*/
public class XWAbsoluteBodyLayout extends XWAbsoluteLayout {
public XWAbsoluteBodyLayout(WAbsoluteBodyLayout widget, Dimension initSize) {
super(widget, initSize);
this.editable = true;
}
/**
* 返回对应的widget容器
*
* @return 返回WAbsoluteLayout
*/
@Override
public WAbsoluteBodyLayout toData() {
return (WAbsoluteBodyLayout)data;
}
@Override
public LayoutAdapter getLayoutAdapter() {
return new FRAbsoluteBodyLayoutAdapter(this);
}
/**
* 假如是body的话始终要能编辑不会出现蒙层
*
* @param isEditable 可否编辑
*/
@Override
public void setEditable(boolean isEditable) {
super.setEditable(true);
}
}

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

@ -75,7 +75,7 @@ public class XWAbsoluteLayout extends XLayoutContainer {
xConnectorMap.put(connector, new XConnector(connector, this));
}
initPercent();
initPercent(widget);
}
/**
@ -89,13 +89,14 @@ public class XWAbsoluteLayout extends XLayoutContainer {
}
//根据屏幕大小来确定显示的百分比, 1440*900默认100%, 1366*768缩放90%
private void initPercent(){
private void initPercent(WAbsoluteLayout widget){
Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension scrnsize = toolkit.getScreenSize();
double screenValue = FRScreen.getByDimension(scrnsize).getValue();
if(screenValue != FormArea.DEFAULT_SLIDER){
this.setContainerPercent(screenValue / FormArea.DEFAULT_SLIDER);
}
widget.setDesigningResolution(scrnsize);
}
/**

5
designer_form/src/com/fr/design/designer/properties/AbsoluteStateRenderer.java

@ -1,11 +1,10 @@
package com.fr.design.designer.properties;
import com.fr.design.mainframe.widget.renderer.EncoderCellRenderer;
/**
* Created by zhouping on 2016/8/1.
*/
public class AbsoluteStateRenderer extends EncoderCellRenderer {
public class AbsoluteStateRenderer extends BodyLayoutAttrRenderer {
public AbsoluteStateRenderer() {
super(new AbsoluteStateWrapper());
}

23
designer_form/src/com/fr/design/designer/properties/BodyLayoutAttrRenderer.java

@ -0,0 +1,23 @@
package com.fr.design.designer.properties;
import com.fr.design.mainframe.widget.renderer.EncoderCellRenderer;
import com.fr.general.IOUtils;
import java.awt.*;
import java.awt.image.BufferedImage;
/**
* Created by zhouping on 2016/10/14.
*/
public class BodyLayoutAttrRenderer extends EncoderCellRenderer {
public BodyLayoutAttrRenderer(Encoder encoder) {
super(encoder);
}
@Override
public void paint(Graphics g) {
super.paint(g);
BufferedImage image = IOUtils.readImage("com/fr/design/images/control/combobox.png");
g.drawImage(image, getWidth() - image.getWidth(), 0, image.getWidth(), image.getHeight(), null, this);
}
}

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

@ -0,0 +1,239 @@
package com.fr.design.designer.properties;
import com.fr.design.designer.creator.XWAbsoluteBodyLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelectionUtils;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.widget.editors.LayoutTypeEditor;
import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WBodyLayoutType;
import com.fr.general.FRScreen;
import com.fr.general.Inter;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import java.awt.*;
import java.awt.geom.Arc2D;
import java.util.Arrays;
import java.util.Comparator;
/**
* Created by zhouping on 2016/10/14.
*/
public class FRAbsoluteBodyLayoutPropertiesGroupModel extends FRAbsoluteLayoutPropertiesGroupModel {
private LayoutTypeEditor layoutTypeEditor;
private LayoutTypeRenderer layoutTypeRenderer;
//默认body是0,自适应布局;1,绝对布局.
private WBodyLayoutType layoutType = WBodyLayoutType.ABSOLUTE;
public FRAbsoluteBodyLayoutPropertiesGroupModel(XWAbsoluteBodyLayout xwAbsoluteBodyLayout) {
super(xwAbsoluteBodyLayout);
}
public FRAbsoluteBodyLayoutPropertiesGroupModel(XWAbsoluteBodyLayout xwAbsoluteBodyLayout, WBodyLayoutType layoutType){
this(xwAbsoluteBodyLayout);
this.layoutTypeEditor = new LayoutTypeEditor();
this.layoutTypeRenderer = new LayoutTypeRenderer();
this.layoutType = layoutType;
}
/**
* 布局管理器自己的属性
*/
@Override
public String getGroupName() {
return Inter.getLocText("FR-Designer_Attr_Layout");
}
@Override
public int getRowCount() {
return 2;
}
@Override
public TableCellRenderer getRenderer(int row) {
return row == 0 ? layoutTypeRenderer : stateRenderer;
}
@Override
public TableCellEditor getEditor(int row) {
return row == 0 ? layoutTypeEditor : stateEditor;
}
@Override
public Object getValue(int row, int column) {
if (column == 0) {
switch (row) {
case 0:
return Inter.getLocText("FR-Designer_Attr_Layout_Type");
default:
return Inter.getLocText("FR-Designer-Widget_Scaling_Mode");
}
} else {
switch (row) {
case 0:
return layoutType.getTypeValue();
default:
return layout.getCompState();
}
}
}
@Override
public boolean setValue(Object value, int row, int column) {
if (layoutType == WBodyLayoutType.ABSOLUTE){
int state = 0;
if(value instanceof Integer) {
state = (Integer)value;
}
if (column == 0 || state < 0) {
return false;
} else {
if (row == 0) {
if (state == WBodyLayoutType.FIT.getTypeValue()) {
XWFitLayout xfl = (XWFitLayout) xwAbsoluteLayout.getBackupParent();
Component[] components = xwAbsoluteLayout.getComponents();
Arrays.sort(components, new ComparatorComponentLocation());
xfl.getLayoutAdapter().removeBean(xwAbsoluteLayout, xwAbsoluteLayout.getWidth(), xwAbsoluteLayout.getHeight());
xfl.remove(xwAbsoluteLayout);
xfl.toData().setLayoutType(WBodyLayoutType.FIT);
for (Component comp : components) {
xfl.add(comp);
}
moveComponents2FitLayout(xfl, components);
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
formDesigner.getSelectionModel().setSelectedCreators(
FormSelectionUtils.rebuildSelection(xfl, new Widget[]{xfl.toData()}));
xfl.convert();
LayoutUtils.layoutContainer(xfl);
xfl.adjustCreatorsWhileSlide(xfl.getContainerPercent() - 1.0);
return true;
}
}
if (row == 1) {
layout.setCompState(state);
return true;
}
return false;
}
}
int state = 0;
if(value instanceof Integer) {
state = (Integer)value;
}
if (column == 0 || state < 0) {
return false;
} else {
if (row == 0) {
layout.setCompState(state);
return true;
}
return false;
}
}
/**
* 是否可编辑
* @param row
* @return
*/
@Override
public boolean isEditable(int row) {
return true;
}
//把绝对布局中的元素按规则移动到自适应布局中
private void moveComponents2FitLayout(XWFitLayout xwFitLayout, Component[] components) {
int eachRowCount = 4;
if (components.length <= 1){
return;
}
int layoutWidth = xwFitLayout.getWidth() - xwFitLayout.toData().getMargin().getLeft() - xwFitLayout.toData().getMargin().getRight();
int layoutHeight = xwFitLayout.getHeight() - xwFitLayout.toData().getMargin().getTop() - xwFitLayout.toData().getMargin().getBottom();
int leftMargin = xwFitLayout.toData().getMargin().getLeft();
int topMargin = xwFitLayout.toData().getMargin().getTop();
int row = (components.length / eachRowCount) + (components.length % eachRowCount == 0 ? 0 : 1);
//最后一行的列数不定
int column = components.length % eachRowCount == 0 ? eachRowCount : components.length % eachRowCount;
int componentWidth = layoutWidth / eachRowCount;
int componentHeight = layoutHeight / row;
for(int i = 0;i < row - 1;i++){
for(int j = 0;j < eachRowCount;j++){
components[eachRowCount * i + j].setBounds(
leftMargin + componentWidth * j,
topMargin + componentHeight * i,
j == eachRowCount - 1 ? layoutWidth - componentWidth * (eachRowCount - 1) : componentWidth,
componentHeight
);
}
}
//最后一行列数是特殊的,要单独处理
int lastRowWidth = layoutWidth / column;
int lastRowHeight = layoutHeight - componentHeight * (row - 1);
for (int i = 0;i < column;i++) {
components[eachRowCount * (row - 1) + i].setBounds(
leftMargin + lastRowWidth * i,
topMargin + componentHeight * (row - 1),
i == column - 1 ? layoutWidth - lastRowWidth * (column - 1) : lastRowWidth,
lastRowHeight
);
}
xwFitLayout.updateBoundsWidget();
}
private class ComponentLocationInfo{
private Component component;
private int horizontalNO;
private int verticalNO;
public ComponentLocationInfo(Component component, int horizontalNO, int verticalNO){
this.component = component;
this.horizontalNO = horizontalNO;
this.verticalNO = verticalNO;
}
public int getHorizontalNO() {
return this.horizontalNO;
}
public int getVerticalNO() {
return this.verticalNO;
}
public void setHorizontalNO(int horizontalNO){
this.horizontalNO = horizontalNO;
}
public void setVerticalNO(int verticalNO){
this.verticalNO = verticalNO;
}
}
//以组件的位置来确定先后顺序,y小的在前,x小的在前
private class ComparatorComponentLocation implements Comparator {
@Override
public int compare(Object o1, Object o2) {
if(((Component)o1).getY() < ((Component)o2).getY()){
return -1;
}
else if (((Component)o1).getY() > ((Component)o2).getY()) {
return 1;
}
else {
if (((Component)o1).getX() < ((Component)o2).getX()){
return -1;
}
else if (((Component)o1).getX() > ((Component)o2).getX()) {
return 1;
}
else{
return 0;
}
}
}
}
}

8
designer_form/src/com/fr/design/designer/properties/FRAbsoluteLayoutPropertiesGroupModel.java

@ -19,10 +19,10 @@ public class FRAbsoluteLayoutPropertiesGroupModel implements GroupModel {
private PropertyCellEditor editor;
private DefaultTableCellRenderer renderer;
private AbsoluteLayoutDirectionEditor stateEditor;
private AbsoluteStateRenderer stateRenderer;
private WAbsoluteLayout layout;
private XWAbsoluteLayout xwAbsoluteLayout;
protected AbsoluteLayoutDirectionEditor stateEditor;
protected AbsoluteStateRenderer stateRenderer;
protected WAbsoluteLayout layout;
protected XWAbsoluteLayout xwAbsoluteLayout;
public FRAbsoluteLayoutPropertiesGroupModel(XWAbsoluteLayout xwAbsoluteLayout){
this.xwAbsoluteLayout = xwAbsoluteLayout;

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

@ -4,16 +4,26 @@
package com.fr.design.designer.properties;
import com.fr.design.beans.GroupModel;
import com.fr.design.designer.creator.XWAbsoluteBodyLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelectionUtils;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.widget.editors.FitLayoutDirectionEditor;
import com.fr.design.mainframe.widget.editors.LayoutTypeEditor;
import com.fr.design.mainframe.widget.editors.IntegerPropertyEditor;
import com.fr.design.mainframe.widget.editors.PropertyCellEditor;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteBodyLayout;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WBodyLayoutType;
import com.fr.form.ui.container.WFitLayout;
import com.fr.general.Inter;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import java.awt.*;
/**
* 自适应布局自身的属性表
@ -28,6 +38,8 @@ public class FRFitLayoutPropertiesGroupModel implements GroupModel {
private DefaultTableCellRenderer renderer;
private FitLayoutDirectionEditor stateEditor;
private FitStateRenderer stateRenderer;
private LayoutTypeEditor layoutTypeEditor;
private LayoutTypeRenderer layoutTypeRenderer;
private WFitLayout layout;
private XWFitLayout xfl;
@ -38,6 +50,8 @@ public class FRFitLayoutPropertiesGroupModel implements GroupModel {
editor = new PropertyCellEditor(new IntegerPropertyEditor());
stateEditor = new FitLayoutDirectionEditor();
stateRenderer = new FitStateRenderer();
layoutTypeEditor = new LayoutTypeEditor();
layoutTypeRenderer = new LayoutTypeRenderer();
}
/**
@ -45,31 +59,35 @@ public class FRFitLayoutPropertiesGroupModel implements GroupModel {
*/
@Override
public String getGroupName() {
return Inter.getLocText("FR-Designer-Layout_Adaptive_Layout");
return Inter.getLocText("FR-Designer_Layout");
}
@Override
public int getRowCount() {
return 2;
return 3;
}
@Override
public TableCellRenderer getRenderer(int row) {
switch (row) {
case 0:
return renderer;
return layoutTypeRenderer;
case 1:
return stateRenderer;
default:
return stateRenderer;
return renderer;
}
}
@Override
public TableCellEditor getEditor(int row) {
switch (row) {
case 0:
return editor;
case 0:
return layoutTypeEditor;
case 1:
return stateEditor;
default:
return stateEditor;
return editor;
}
}
@ -78,16 +96,20 @@ public class FRFitLayoutPropertiesGroupModel implements GroupModel {
if (column == 0) {
switch (row) {
case 0:
return Inter.getLocText("FR-Designer_Component_Interval");
return Inter.getLocText("FR-Designer_Attr_Layout_Type");
case 1:
return Inter.getLocText("FR-Designer_Component_Scale");
default:
return Inter.getLocText("FR-Designer_Component_Scale");
return Inter.getLocText("FR-Designer_Component_Interval");
}
} else {
switch (row) {
case 0:
return layout.getCompInterval();
return layout.getBodyLayoutType().getTypeValue();
case 1:
return layout.getCompState();
default:
return layout.getCompState();
return layout.getCompInterval();
}
}
}
@ -101,13 +123,35 @@ public class FRFitLayoutPropertiesGroupModel implements GroupModel {
if (column == 0 || state < 0) {
return false;
} else {
if (row ==0 && xfl.canAddInterval(state)) {
if (row == 2 && xfl.canAddInterval(state)) {
// 设置完间隔后,要同步处理界面组件,容器刷新后显示出对应效果
setLayoutGap(state);
return true;
}else if (row == 1) {
layout.setCompState(state);
return true;
}else if (row == 0) {
layout.setLayoutType(WBodyLayoutType.parse(state));
if (state == WBodyLayoutType.ABSOLUTE.getTypeValue()) {
WAbsoluteBodyLayout wAbsoluteBodyLayout = new WAbsoluteBodyLayout("body");
wAbsoluteBodyLayout.setCompState(WAbsoluteLayout.STATE_FIXED);
Component[] components = xfl.getComponents();
xfl.removeAll();
XWAbsoluteBodyLayout xwAbsoluteBodyLayout = new XWAbsoluteBodyLayout(wAbsoluteBodyLayout, new Dimension(0,0));
xfl.getLayoutAdapter().addBean(xwAbsoluteBodyLayout, 0, 0);
for (Component component : components) {
xwAbsoluteBodyLayout.add(component);
}
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
formDesigner.getSelectionModel().setSelectedCreators(
FormSelectionUtils.rebuildSelection(xfl, new Widget[]{wAbsoluteBodyLayout}));
}
else {
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
formDesigner.getSelectionModel().setSelectedCreators(
FormSelectionUtils.rebuildSelection(xfl, new Widget[]{xfl.toData()}));
}
return true;
}
return false;
}

4
designer_form/src/com/fr/design/designer/properties/FitStateRenderer.java

@ -3,13 +3,11 @@
*/
package com.fr.design.designer.properties;
import com.fr.design.mainframe.widget.renderer.EncoderCellRenderer;
/**
* @author jim
* @date 2014-7-31
*/
public class FitStateRenderer extends EncoderCellRenderer{
public class FitStateRenderer extends BodyLayoutAttrRenderer{
/**
* @param encoder

12
designer_form/src/com/fr/design/designer/properties/LayoutTypeRenderer.java

@ -0,0 +1,12 @@
package com.fr.design.designer.properties;
/**
* Created by zhouping on 2016/9/18.
*/
public class LayoutTypeRenderer extends BodyLayoutAttrRenderer {
public LayoutTypeRenderer() {
super(new LayoutTypeWrapper());
}
}

13
designer_form/src/com/fr/design/designer/properties/LayoutTypeWrapper.java

@ -0,0 +1,13 @@
package com.fr.design.designer.properties;
import com.fr.design.designer.properties.items.FRLayoutTypeItems;
/**
* Created by zhouping on 2016/9/18.
*/
public class LayoutTypeWrapper extends ItemWrapper{
public LayoutTypeWrapper() {
super(new FRLayoutTypeItems());
}
}

4
designer_form/src/com/fr/design/designer/properties/items/FRFitConstraintsItems.java

@ -13,8 +13,8 @@ import com.fr.general.Inter;
public class FRFitConstraintsItems implements ItemProvider{
public static final Item[] ITEMS = new Item[] {
new Item(Inter.getLocText("Adaptive_Full_Area"), WFitLayout.STATE_FULL),
new Item(Inter.getLocText("Adaptive_Original_Scale"), WFitLayout.STATE_ORIGIN)};
new Item(Inter.getLocText("FR-Designer_Attr_Bidirectional_Adaptive"), WFitLayout.STATE_FULL),
new Item(Inter.getLocText("FR_Designer_Attr_Horizontal_Adaptive"), WFitLayout.STATE_ORIGIN)};
public Item[] getItems() {
return ITEMS;

16
designer_form/src/com/fr/design/designer/properties/items/FRLayoutTypeItems.java

@ -0,0 +1,16 @@
package com.fr.design.designer.properties.items;
import com.fr.form.ui.container.WBodyLayoutType;
/**
* Created by zhouping on 2016/9/18.
*/
public class FRLayoutTypeItems implements ItemProvider{
public static final Item[] ITEMS = new Item[] {
new Item(WBodyLayoutType.FIT.description(), WBodyLayoutType.FIT.getTypeValue()),
new Item(WBodyLayoutType.ABSOLUTE.description(), WBodyLayoutType.ABSOLUTE.getTypeValue())};
public Item[] getItems() {
return ITEMS;
}
}

26
designer_form/src/com/fr/design/designer/treeview/ComponentTreeModel.java

@ -10,11 +10,9 @@ import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;
import com.fr.base.FRContext;
import com.fr.design.designer.creator.*;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWidgetCreator;
import com.fr.form.ui.Widget;
public class ComponentTreeModel implements TreeModel {
@ -23,6 +21,8 @@ public class ComponentTreeModel implements TreeModel {
private Component root;
private FormDesigner designer;
private final int ABSOLUTE_AS_BODY_NOT_FOUND = -1;
public ComponentTreeModel(FormDesigner designer, Component root) {
this.designer = designer;
this.root = root;
@ -38,6 +38,11 @@ public class ComponentTreeModel implements TreeModel {
if (parent != null && parent instanceof XLayoutContainer) {
XLayoutContainer xlayout = (XLayoutContainer) parent;
XCreator creator = xlayout.getXCreator(index);
//绝对布局作为body的时候不显示自适应布局父层
int absoluteBodyIndex = getAbsoluteBodyIndex(creator);
if (absoluteBodyIndex > ABSOLUTE_AS_BODY_NOT_FOUND){
return creator.getComponent(absoluteBodyIndex);
}
return creator.getXCreator();
}
return null;
@ -135,4 +140,19 @@ public class ComponentTreeModel implements TreeModel {
FRContext.getLogger().error(e.getMessage(), e);
}
}
private int getAbsoluteBodyIndex(XCreator xCreator){
//绝对布局作为body,父层是自适应布局,找到绝对布局位于父层的index
int index = ABSOLUTE_AS_BODY_NOT_FOUND;
if (xCreator.acceptType(XWFitLayout.class)){
XWFitLayout bodyFitLayout = (XWFitLayout)xCreator;
for (int i = 0;i < bodyFitLayout.getXCreatorCount();i++){
//类型是绝对布局并且还是body
if (bodyFitLayout.getXCreator(i).acceptType(XWAbsoluteBodyLayout.class)){
index = i;
}
}
}
return index;
}
}

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, ABSOLUTELAYOUTCONTAINER}; } public static final WidgetOption ABSOLUTELAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_AbsoluteLayout"), BaseUtils.readIcon("/com/fr/web/images/form/resources/layout_absolute_new.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_Layout_Block_Absolute"), BaseUtils.readIcon("/com/fr/web/images/form/resources/layout_absolute_new.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_Layout_Block_Tab"), 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); }

192
designer_form/src/com/fr/design/mainframe/ComponentTree.java

@ -16,8 +16,7 @@ import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.events.DesignerEditListener;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.*;
import com.fr.design.designer.treeview.ComponentTreeCellRenderer;
import com.fr.design.designer.treeview.ComponentTreeModel;
import com.fr.stable.StringUtils;
@ -40,7 +39,7 @@ public class ComponentTree extends JTree {
TreePath[] paths = getSelectedTreePath();
addTreeSelectionListener(designer);
setSelectionPaths(paths);
designer.addDesignerEditListener(new TreeDesignerEditAdapter());
this.addMouseListener(new MouseAdapter() {
@ -68,15 +67,19 @@ public class ComponentTree extends JTree {
setEditable(true);
}
public FormDesigner getDesigner() {
return designer;
}
/**
* 构造函数
*
*
* @param designer 设计界面组件
* @param model 构造JTree的model
*/
public ComponentTree(FormDesigner designer,ComponentTreeModel model) {
this(designer);
this.setModel(model);
this(designer);
this.setModel(model);
}
@ -96,17 +99,17 @@ public class ComponentTree extends JTree {
return super.isPathEditable(path);
}
/**
* 将值转换为文本
* @param value
* @param selected 是否选中
* @param expanded 扩展
* @param leaf 是否叶子
* @param row
* @param hasFocus 是否焦点
*
* @return 返回文本
*/
/**
* 将值转换为文本
* @param value
* @param selected 是否选中
* @param expanded 扩展
* @param leaf 是否叶子
* @param row
* @param hasFocus 是否焦点
*
* @return 返回文本
*/
@Override
public String convertValueToText(Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
if (value != null && value instanceof XCreator) {
@ -115,25 +118,25 @@ public class ComponentTree extends JTree {
return super.convertValueToText(value, selected, expanded, leaf, row, hasFocus);
}
}
public void setAndScrollSelectionPath(TreePath treepath) {
setSelectionPath(treepath);
scrollPathToVisible(treepath);
setSelectionPath(treepath);
scrollPathToVisible(treepath);
}
private void popupMenu(MouseEvent e) {
TreePath path = this.getSelectionPath();
if (path == null) {
return;
}
Component component = (Component) path.getLastPathComponent();
if (!(component instanceof XCreator)) {
return;
}
ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, (XCreator) component);
JPopupMenu menu = adapter.getContextPopupMenu(e);
menu.show(this, e.getX(), e.getY());
}
private void popupMenu(MouseEvent e) {
TreePath path = this.getSelectionPath();
if (path == null) {
return;
}
Component component = (Component) path.getLastPathComponent();
if (!(component instanceof XCreator)) {
return;
}
ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, (XCreator) component);
JPopupMenu menu = adapter.getContextPopupMenu(e);
menu.show(this, e.getX(), e.getY());
}
/**
* 刷新
@ -145,51 +148,51 @@ public class ComponentTree extends JTree {
public TreePath[] getSelectedTreePath() {
XCreator[] creators = designer.getSelectionModel().getSelection().getSelectedCreators();
TreePath[] paths = new TreePath[creators.length];
for (int i = 0; i < paths.length; i++) {
paths[i] = buildTreePath(creators[i]);
}
return paths;
}
private class TreeDesignerEditAdapter implements DesignerEditListener {
@Override
public void fireCreatorModified(DesignerEvent evt) {
if (evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) {
TreePath[] paths = getSelectedTreePath();
if (paths.length == 1) {
setAndScrollSelectionPath(paths[0]);
} else {
setSelectionPaths(paths);
}
} else if(evt.getCreatorEventID() == DesignerEvent.CREATOR_PASTED) {
ComponentTree.this.refreshUI();
TreePath[] paths = getSelectedTreePath();
if (paths.length == 1) {
setAndScrollSelectionPath(paths[0]);
} else {
setSelectionPaths(paths);
}
ComponentTree.this.repaint();
} else {
ComponentTree.this.refreshUI();
ComponentTree.this.repaint();
}
}
@Override
public boolean equals(Object o) {
return o.getClass() == this.getClass();
}
}
public TreePath[] getSelectedTreePath() {
XCreator[] creators = designer.getSelectionModel().getSelection().getSelectedCreators();
TreePath[] paths = new TreePath[creators.length];
for (int i = 0; i < paths.length; i++) {
paths[i] = buildTreePath(creators[i]);
}
return paths;
}
private class TreeDesignerEditAdapter implements DesignerEditListener {
@Override
public void fireCreatorModified(DesignerEvent evt) {
if (evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) {
TreePath[] paths = getSelectedTreePath();
if (paths.length == 1) {
setAndScrollSelectionPath(paths[0]);
} else {
setSelectionPaths(paths);
}
} else if(evt.getCreatorEventID() == DesignerEvent.CREATOR_PASTED) {
ComponentTree.this.refreshUI();
TreePath[] paths = getSelectedTreePath();
if (paths.length == 1) {
setAndScrollSelectionPath(paths[0]);
} else {
setSelectionPaths(paths);
}
ComponentTree.this.repaint();
} else {
ComponentTree.this.refreshUI();
ComponentTree.this.repaint();
}
}
@Override
public boolean equals(Object o) {
return o.getClass() == this.getClass();
}
}
/**
@ -211,11 +214,11 @@ public class ComponentTree extends JTree {
paths[i] = buildTreePath(searchList.get(i));
}
if(paths.length > 0) {
setAndScrollSelectionPath(paths[0]);
setAndScrollSelectionPath(paths[0]);
} else {
setSelectionPath();
setSelectionPath();
}
return paths;
return paths;
}
@ -248,7 +251,7 @@ public class ComponentTree extends JTree {
* 触发
*/
public void fireTreeChanged() {
designer.refreshDesignerUI();
designer.refreshDesignerUI();
}
/**
@ -267,14 +270,21 @@ public class ComponentTree extends JTree {
ArrayList<Component> path = new ArrayList<Component>();
Component parent = comp;
while (parent != null) {
XCreator creator = (XCreator) parent;
path.add(0, parent);
if (creator != comp ) {
creator.notShowInComponentTree(path);
}
parent = parent.getParent();
}
while (parent != null) {
XCreator creator = (XCreator) parent;
path.add(0, parent);
if (creator != comp ) {
creator.notShowInComponentTree(path);
}
//绝对布局作为body的时候不显示自适应布局父层
if (((XCreator) parent).acceptType(XWAbsoluteBodyLayout.class)
&& (parent.getParent() != null)
&& ((XCreator)parent.getParent()).acceptType(XWFitLayout.class)){
parent = parent.getParent().getParent();
continue;
}
parent = parent.getParent();
}
Object[] components = path.toArray();
return new TreePath(components);
}

9
designer_form/src/com/fr/design/mainframe/FormParaWidgetPane.java

@ -94,12 +94,6 @@ public class FormParaWidgetPane extends JPanel{
private void initFormParaComponent() {
this.removeAll();
// 菜单中的布局先注释掉
JPanel reportPane = new JPanel(new FlowLayout());
reportPane.add(new ToolBarButton(FormWidgetOption.ELEMENTCASE));
add(createNormalCombinationPane(reportPane,Inter.getLocText("FR-Designer-Form-ToolBar_Report")));
add(createJSeparator());
JPanel paraPane = new JPanel(new FlowLayout());
ToolBarButton paraButton = new paraButton(FormWidgetOption.PARAMETERCONTAINER);
paraPane.add(paraButton);
@ -111,7 +105,8 @@ public class FormParaWidgetPane extends JPanel{
for(WidgetOption option : loadLayoutOptions()){
layoutPane.add(new ToolBarButton(option));
}
add(createNormalCombinationPane(layoutPane,Inter.getLocText("FR-Designer_Layout")));
layoutPane.add(new ToolBarButton(FormWidgetOption.ELEMENTCASE));
add(createNormalCombinationPane(layoutPane,Inter.getLocText("FR-Designer_Layout_Block_Blank")));
jSeparatorLayout = createJSeparator();
add(jSeparatorLayout);

192
designer_form/src/com/fr/design/mainframe/ShareWidgetButton.java

@ -0,0 +1,192 @@
package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.form.share.ShareLoader;
import com.fr.form.ui.ElCaseBindInfo;
import com.fr.form.ui.Widget;
import com.fr.general.ComparatorUtils;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.Serializable;
/**
* Coder: zack
* Date: 2016/10/9
* Time: 16:14
*/
public class ShareWidgetButton extends JPanel implements MouseListener, MouseMotionListener, Serializable {
private ElCaseBindInfo bindInfo;
private MouseEvent lastPressEvent;
public ShareWidgetButton(ElCaseBindInfo bindInfo) {
this.bindInfo = bindInfo;
initUI();
this.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
this.addMouseListener(this);
this.addMouseMotionListener(this);
new DragAndDropDragGestureListener(this, DnDConstants.ACTION_COPY_OR_MOVE);
}
private void initUI() {
this.setBackground(Color.WHITE);
this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
setPreferredSize(new Dimension(110, 70));
setLayout(FRGUIPaneFactory.createBorderLayout());
ImagePanel imagePanel = new ImagePanel((BufferedImage) bindInfo.getCover());
this.add(imagePanel, BorderLayout.NORTH);
JPanel panel = new JPanel();
UILabel label = new UILabel(bindInfo.getName(), SwingConstants.HORIZONTAL);
panel.setBackground(new Color(184, 220, 242));
panel.add(label);
this.add(panel, BorderLayout.SOUTH);
}
private class ImagePanel extends JPanel {
private BufferedImage image;
public ImagePanel(BufferedImage image) {
this.image = image;
this.setPreferredSize(new Dimension(110, 50));
}
@Override
public void paintComponent(Graphics g) {
g.drawImage(image, 0, 0, 110, 70, null);
}
}
public ElCaseBindInfo getBindInfo() {
return bindInfo;
}
public void setBindInfo(ElCaseBindInfo bindInfo) {
this.bindInfo = bindInfo;
}
@Override
public void mouseClicked(MouseEvent e) {
}
@Override
public void mousePressed(MouseEvent e) {
lastPressEvent = e;
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void mouseDragged(MouseEvent e) {
if (BaseUtils.isAuthorityEditing()) {
return;
}
if (lastPressEvent == null) {
return;
}
Object source = e.getSource();
Widget creatorSource = null;
String shareId = StringUtils.EMPTY;
if (source instanceof ShareWidgetButton) {
ShareWidgetButton no = (ShareWidgetButton) e.getSource();
if (no == null) {
return;
}
shareId = no.getBindInfo().getId();
creatorSource = ShareLoader.getLoader().getElCaseEditorById(shareId);
}
if (creatorSource != null) {
XCreator xCreator = XCreatorUtils.createXCreator(creatorSource);
xCreator.setShareId(shareId);
WidgetToolBarPane.getTarget().startDraggingBean(xCreator);
lastPressEvent = null;
this.setBorder(null);
}
}
@Override
public void mouseMoved(MouseEvent e) {
}
public class DragAndDropDragGestureListener extends DragSourceAdapter implements DragGestureListener {
private DragSource source;
public DragAndDropDragGestureListener(ShareWidgetButton tt, int actions) {
source = new DragSource();
source.createDefaultDragGestureRecognizer(tt, actions, this);
}
public void dragGestureRecognized(DragGestureEvent dge) {
ShareWidgetButton shareWidgetButton = (ShareWidgetButton) dge.getComponent();
if (shareWidgetButton != null) {
Widget widget = ShareLoader.getLoader().getElCaseEditorById(shareWidgetButton.getBindInfo().getId());
DragAndDropTransferable dragAndDropTransferable = new DragAndDropTransferable(widget);
dge.startDrag(DragSource.DefaultCopyDrop, dragAndDropTransferable, this);
}
}
@Override
public void dragEnter(DragSourceDragEvent dragSourceDragEvent) {
}
}
public class DragAndDropTransferable implements Transferable {
private Widget widget;
public DragAndDropTransferable(Widget widget) {
this.widget = widget;
}
DataFlavor[] flavors = {new DataFlavor(Widget.class, "Widget")};
public DataFlavor[] getTransferDataFlavors() {
return flavors;
}
public boolean isDataFlavorSupported(DataFlavor flavor) {
for (DataFlavor df : flavors) {
if (ComparatorUtils.equals(df, flavor)) {
return true;
}
}
return false;
}
public Object getTransferData(DataFlavor df) throws UnsupportedFlavorException, IOException {
return widget;
}
}
}

29
designer_form/src/com/fr/design/mainframe/ShareWidgetPane.java

@ -0,0 +1,29 @@
package com.fr.design.mainframe;
import com.fr.form.ui.ElCaseBindInfo;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
/**
* Created by xiaxiang on 2016/10/10.
*/
public class ShareWidgetPane extends JPanel {
public ShareWidgetPane(ArrayList<ElCaseBindInfo> elCaseBindInfoList) {
this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));// 设置面板的边框 ,距离上、左、下、右 的距离
int rowCount = (elCaseBindInfoList.size() + 1)/2;
this.setLayout(new GridLayout(rowCount, 2, 10, 10));
for (ElCaseBindInfo rbModuleInfo : elCaseBindInfoList) {
ShareWidgetButton widgetButton = new ShareWidgetButton(rbModuleInfo);
this.add(widgetButton);
}
if (elCaseBindInfoList.size() == 1) {
this.add(new JPanel());
}
}
}

291
designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java

@ -0,0 +1,291 @@
package com.fr.design.mainframe.widget;
/**
* Created by xiaxiang on 2016/9/30.
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.*;
import javax.swing.plaf.metal.*;
import javax.swing.tree.*;
import com.fr.design.designer.beans.*;
import com.fr.design.designer.beans.events.DesignerEditListener;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.mainframe.ComponentTree;
import com.sun.java.swing.plaf.motif.*;
import com.sun.java.swing.plaf.windows.*;
/**
* 控件树下拉列表框
*/
public class UITreeComboBox extends JComboBox{
/**
* 显示用的树
*/
private ComponentTree tree;
public UITreeComboBox(ComponentTree componentTree){
this.setTree(componentTree);
tree.getDesigner().addDesignerEditListener(new TreeComboBoxDesignerEditAdapter());
// for(int i=0; i<tree.getRowCount(); i++)
// {
// tree.expandRow(i);
// }
setPreferredSize(new Dimension(200, 20));
}
/**
* 设置树
* @param tree ComponentTree
*/
public void setTree(ComponentTree tree){
this.tree = tree;
if(tree != null){
this.setSelectedItem(tree.getSelectionPath());
this.setRenderer(new UITreeComboBoxRenderer());
}
this.updateUI();
}
/**
* 取得树
* @return JTree
*/
public ComponentTree getTree(){
return tree;
}
/**
* 设置当前选择的树路径
* @param o Object
*/
public void setSelectedItem(Object o){
tree.setSelectionPath((TreePath)o);
getModel().setSelectedItem(o);
}
public void updateUI(){
ComboBoxUI cui = (ComboBoxUI)UIManager.getUI(this);
if(cui instanceof MetalComboBoxUI){
cui = new MetalJTreeComboBoxUI();
} else if(cui instanceof MotifComboBoxUI){
cui = new MotifJTreeComboBoxUI();
} else {
cui = new WindowsJTreeComboBoxUI();
}
setUI(cui);
}
// UI Inner classes -- one for each supported Look and Feel
class MetalJTreeComboBoxUI extends MetalComboBoxUI{
protected ComboPopup createPopup() {
return new TreePopup(comboBox);
}
}
class WindowsJTreeComboBoxUI extends WindowsComboBoxUI{
protected ComboPopup createPopup() {
return new TreePopup(comboBox);
}
}
class MotifJTreeComboBoxUI extends MotifComboBoxUI{
protected ComboPopup createPopup() {
return new TreePopup(comboBox);
}
}
/**
* <p>Title: UITreeComboBoxRenderer</p>
* <p>Description: 树形结构而来的DefaultListCellRenderer </p>
*/
class UITreeComboBoxRenderer extends DefaultListCellRenderer {
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus){
if(value != null){
TreePath path = (TreePath)value;
Object node = path.getLastPathComponent();
value = node;
TreeCellRenderer r = tree.getCellRenderer();
JLabel lb = (JLabel)r.getTreeCellRendererComponent(
tree, value, isSelected, false, false, index,
cellHasFocus);
return lb;
}
return super.getListCellRendererComponent(list, value, index,
isSelected, cellHasFocus);
}
}
private class TreeComboBoxDesignerEditAdapter implements DesignerEditListener {
@Override
public void fireCreatorModified(DesignerEvent evt) {
if (evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED || evt.getCreatorEventID() == DesignerEvent.CREATOR_PASTED) {
TreePath[] paths = tree.getSelectedTreePath();
if (paths.length == 1) {
tree.setAndScrollSelectionPath(paths[0]);
} else {
tree.setSelectionPaths(paths);
}
setSelectedItem(paths[0]);
MenuSelectionManager.defaultManager().clearSelectedPath();
} else {
return;
}
}
@Override
public boolean equals(Object o) {
return o.getClass() == this.getClass();
}
}
/**
* 测试
*/
// public static void main(String args[]){
// JFrame frame = new JFrame("UITreeComboBox");
// final UITreeComboBox box = new UITreeComboBox(new ComponentTree(new FormDesigner()));
// box.setPreferredSize(new Dimension(300, 28));
// frame.getContentPane().add(box);
// frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
// frame.pack();
// frame.setVisible(true);
// }
}
/**
* <p>Title: UITreeComboBox</p>
* <p>Description: TreePopup</p>
*/
class TreePopup extends JPopupMenu implements ComboPopup{
protected UITreeComboBox comboBox;
protected JScrollPane scrollPane;
protected MouseMotionListener mouseMotionListener;
protected MouseListener mouseListener;
public void popupMenu(MouseEvent e) {
TreePath path = comboBox.getTree().getSelectionPath();
if (path == null) {
return;
}
Component component = (Component) path.getLastPathComponent();
if (!(component instanceof XCreator)) {
return;
}
com.fr.design.designer.beans.ComponentAdapter adapter = AdapterBus.getComponentAdapter(comboBox.getTree().getDesigner(), (XCreator) component);
JPopupMenu menu = adapter.getContextPopupMenu(e);
menu.show(comboBox, e.getX(), e.getY());
}
public TreePopup(JComboBox comboBox){
this.comboBox = (UITreeComboBox)comboBox;
setBorder(BorderFactory.createLineBorder(Color.black));
setLayout(new BorderLayout());
setLightWeightPopupEnabled(comboBox.isLightWeightPopupEnabled());
JTree tree = this.comboBox.getTree();
if(tree != null){
scrollPane = new JScrollPane(tree);
scrollPane.setBorder(null);
add(scrollPane, BorderLayout.CENTER);
}
}
public void show(){
updatePopup();
show(comboBox, 0, comboBox.getHeight());
comboBox.getTree().requestFocus();
}
public void hide(){
setVisible(false);
comboBox.firePropertyChange("popupVisible", true, false);
}
protected JList list = new JList();
public JList getList(){
return list;
}
public MouseMotionListener getMouseMotionListener(){
if(mouseMotionListener == null){
mouseMotionListener = new MouseMotionAdapter(){};
}
return mouseMotionListener;
}
public KeyListener getKeyListener(){
return null;
}
public void uninstallingUI(){}
/**
* Implementation of ComboPopup.getMouseListener().
*
* @return a <code>MouseListener</code> or null
* @see ComboPopup#getMouseListener
*/
public MouseListener getMouseListener(){
if(mouseListener == null){
mouseListener = new InvocationMouseHandler();
}
return mouseListener;
}
protected void togglePopup(){
if(isVisible()){
hide();
} else{
show();
}
}
protected void updatePopup(){
setPreferredSize(new Dimension(comboBox.getSize().width, 200));
Object selectedObj = comboBox.getSelectedItem();
if(selectedObj != null){
TreePath tp = (TreePath)selectedObj;
((UITreeComboBox)comboBox).getTree().setSelectionPath(tp);
}
}
protected class InvocationMouseHandler extends MouseAdapter{
public void mousePressed(MouseEvent e){
if(!SwingUtilities.isLeftMouseButton(e) || !comboBox.isEnabled()){
return;
}
if(comboBox.isEditable()){
Component comp = comboBox.getEditor().getEditorComponent();
if((!(comp instanceof JComponent)) ||
((JComponent)comp).isRequestFocusEnabled()){
comp.requestFocus();
}
} else if(comboBox.isRequestFocusEnabled()){
comboBox.requestFocus();
}
togglePopup();
}
public void mouseClicked (MouseEvent e){
if (e.isMetaDown()) {
popupMenu(e);
} else {
return;
}
}
}
}

15
designer_form/src/com/fr/design/mainframe/widget/editors/LayoutTypeEditor.java

@ -0,0 +1,15 @@
package com.fr.design.mainframe.widget.editors;
import com.fr.design.designer.properties.EnumerationEditor;
import com.fr.design.designer.properties.items.FRLayoutTypeItems;
/**
* Created by zhouping on 2016/9/18.
*/
public class LayoutTypeEditor extends EnumerationEditor {
public LayoutTypeEditor() {
super(new FRLayoutTypeItems());
}
}
Loading…
Cancel
Save