From 1c3f2cb2a310327396d6c340458cefa0b75dcd2e Mon Sep 17 00:00:00 2001 From: fangdong sun Date: Tue, 16 Aug 2016 10:27:36 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E7=BC=96=E7=A0=81?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 +- build.gradle.bak | 86 +++++++++++++++++++++++++++++++++ designer_base/build.gradle | 16 +++--- designer_base/build.gradle.bak | 70 +++++++++++++++++++++++++++ designer_chart/build.gradle | 12 ++--- designer_chart/build.gradle.bak | 66 +++++++++++++++++++++++++ designer_form/build.gradle | 18 +++---- designer_form/build.gradle.bak | 83 +++++++++++++++++++++++++++++++ 8 files changed, 329 insertions(+), 24 deletions(-) create mode 100644 build.gradle.bak create mode 100644 designer_base/build.gradle.bak create mode 100644 designer_chart/build.gradle.bak create mode 100644 designer_form/build.gradle.bak diff --git a/build.gradle b/build.gradle index 633739a74..659130f9e 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ tasks.withType(JavaCompile){ 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) diff --git a/build.gradle.bak b/build.gradle.bak new file mode 100644 index 000000000..633739a74 --- /dev/null +++ b/build.gradle.bak @@ -0,0 +1,86 @@ +apply plugin: "java" +tasks.withType(JavaCompile){ + options.encoding = "UTF-8" +} + +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 "CN=FineReport L=NanJing C=China" -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") + + } + +} \ No newline at end of file diff --git a/designer_base/build.gradle b/designer_base/build.gradle index a48a4d2c5..bd5f62e8e 100644 --- a/designer_base/build.gradle +++ b/designer_base/build.gradle @@ -3,11 +3,11 @@ apply plugin: 'java' tasks.withType(JavaCompile){ options.encoding = 'UTF-8' } -//指定构建的jdk版本 +//鎸囧畾鏋勫缓鐨刯dk鐗堟湰 sourceCompatibility=1.8 -//指定生成jar包版本 +//鎸囧畾鐢熸垚jar鍖呯増鏈 version='8.0' -//生成jar包重命名 +//鐢熸垚jar鍖呴噸鍛藉悕 jar{ baseName='fr-designer-core' } @@ -15,7 +15,7 @@ jar{ def srcDir="." -//指定源码路径 +//鎸囧畾婧愮爜璺緞 sourceSets{ main{ java{ @@ -23,13 +23,13 @@ sourceSets{ } } } -//获取什么分支名 +//鑾峰彇浠涔堝垎鏀悕 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') @@ -37,7 +37,7 @@ compile fileTree(dir:'../../../',include:"finereport-*-stable/${branchName}/**/* testCompile 'junit:junit:4.12' } -//复制非.java文件到classes文件夹下参与打包 +//澶嶅埗闈.java鏂囦欢鍒癱lasses鏂囦欢澶逛笅鍙備笌鎵撳寘 task copyFile(type:Copy,dependsOn:compileJava){ copy{ from ("${srcDir}/src"){ @@ -49,7 +49,7 @@ task copyFile(type:Copy,dependsOn:compileJava){ } -//压缩项目中的js文件 +//鍘嬬缉椤圭洰涓殑js鏂囦欢 task compressJS{ ant.taskdef(name:'yuicompress',classname:'com.yahoo.platform.yui.compressor.YUICompressTask'){ classpath { diff --git a/designer_base/build.gradle.bak b/designer_base/build.gradle.bak new file mode 100644 index 000000000..a48a4d2c5 --- /dev/null +++ b/designer_base/build.gradle.bak @@ -0,0 +1,70 @@ + +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}/**/*.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 + + + diff --git a/designer_chart/build.gradle b/designer_chart/build.gradle index 2b465eca9..2a9777371 100644 --- a/designer_chart/build.gradle +++ b/designer_chart/build.gradle @@ -3,14 +3,14 @@ apply plugin: 'java' tasks.withType(JavaCompile){ options.encoding = 'UTF-8' } -//指定构建的jdk版本 +//鎸囧畾鏋勫缓鐨刯dk鐗堟湰 sourceCompatibility=1.8 -//指定生成jar包的版本 +//鎸囧畾鐢熸垚jar鍖呯殑鐗堟湰 version='8.0' def srcDir="." -//对生成的jar包进行重命名 +//瀵圭敓鎴愮殑jar鍖呰繘琛岄噸鍛藉悕 jar{ baseName='fr-designer-chart' @@ -28,14 +28,14 @@ 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}/**/*.jar") testCompile 'junit:junit:4.12' } -//将非.java 文件复制到classes文件夹下参与打包 +//灏嗛潪.java 鏂囦欢澶嶅埗鍒癱lasses鏂囦欢澶逛笅鍙備笌鎵撳寘 task copyFile(type:Copy,dependsOn:compileJava){ copy{ from ("${srcDir}/src"){ @@ -47,7 +47,7 @@ task copyFile(type:Copy,dependsOn:compileJava){ } -//压缩项目中的js文件 +//鍘嬬缉椤圭洰涓殑js鏂囦欢 task compressJS{ ant.taskdef(name:'yuicompress',classname:'com.yahoo.platform.yui.compressor.YUICompressTask'){ classpath { diff --git a/designer_chart/build.gradle.bak b/designer_chart/build.gradle.bak new file mode 100644 index 000000000..2b465eca9 --- /dev/null +++ b/designer_chart/build.gradle.bak @@ -0,0 +1,66 @@ + +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}/**/*.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 + diff --git a/designer_form/build.gradle b/designer_form/build.gradle index f6c634dd1..ca89333a4 100644 --- a/designer_form/build.gradle +++ b/designer_form/build.gradle @@ -3,19 +3,19 @@ apply plugin: 'java' tasks.withType(JavaCompile){ options.encoding = 'UTF-8' } -//指定构建的jdk版本 +//鎸囧畾鏋勫缓鐨刯dk鐗堟湰 sourceCompatibility=1.8 -//指定生成的jar包版本 +//鎸囧畾鐢熸垚鐨刯ar鍖呯増鏈 version='8.0' def srcDir="." -//指明生成jar包的名字 +//鎸囨槑鐢熸垚jar鍖呯殑鍚嶅瓧 jar{ baseName='fr-designer-report' } -//源码所在位置 +//婧愮爜鎵鍦ㄤ綅缃 sourceSets{ main{ java{ @@ -25,12 +25,12 @@ sourceSets{ } } -//获取什么分支名 +//鑾峰彇浠涔堝垎鏀悕 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")//,exclude:"finereport-design-stable/${branchName}/build/libs/*.jar") @@ -38,7 +38,7 @@ compile fileTree(dir:'../../../',include:"finereport-*-stable/${branchName}/**/b testCompile 'junit:junit:4.12' } -//指明无法编译文件所在路径 +//鎸囨槑鏃犳硶缂栬瘧鏂囦欢鎵鍦ㄨ矾寰 def dataContent ={def dir -> copySpec{ from ("${dir}"){ @@ -47,7 +47,7 @@ def dataContent ={def dir -> } } -//将非.java文件复制到classes文件夹下 参与打包 +//灏嗛潪.java鏂囦欢澶嶅埗鍒癱lasses鏂囦欢澶逛笅 鍙備笌鎵撳寘 task copyFile(type:Copy,dependsOn:compileJava){ copy{ with dataContent.call("${srcDir}/src") @@ -58,7 +58,7 @@ task copyFile(type:Copy,dependsOn:compileJava){ } -//压缩项目中的js文件 +//鍘嬬缉椤圭洰涓殑js鏂囦欢 task compressJS{ ant.taskdef(name:'yuicompress',classname:'com.yahoo.platform.yui.compressor.YUICompressTask'){ classpath { diff --git a/designer_form/build.gradle.bak b/designer_form/build.gradle.bak new file mode 100644 index 000000000..f6c634dd1 --- /dev/null +++ b/designer_form/build.gradle.bak @@ -0,0 +1,83 @@ + +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',include:'**/*.jar') +compile fileTree(dir:'../../../',include:"finereport-*-stable/${branchName}/**/build/libs/*.jar")//,exclude:"finereport-design-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 + From c164b99aecfc5f49a5ddef147519bcb0edf8d7e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=94=80?= Date: Wed, 17 Aug 2016 20:28:29 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E5=99=A8=E5=86=85?= =?UTF-8?q?=E8=AE=BA=E5=9D=9B=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 璁捐鍣ㄥ彸涓婅閮ㄥ垎鐨勭櫥褰曚笌绉佷汉娑堟伅澶勭悊 --- .../design/mainframe/bbs/BBSLoginDialog.java | 3 - .../fr/design/mainframe/bbs/LoginDialog.java | 35 ++++ .../design/mainframe/bbs/UserInfoLabel.java | 68 +++++-- .../fr/design/mainframe/bbs/UserInfoPane.java | 21 +- .../fr/design/extra/LoginContextListener.java | 8 + .../src/com/fr/design/extra/LoginPane.java | 43 ++++ .../com/fr/design/extra/LoginWebBridge.java | 187 ++++++++++++++++++ .../src/com/fr/design/extra/LoginWebPane.java | 61 ++++++ .../com/fr/design/extra/PluginWebBridge.java | 37 ++++ .../com/fr/design/extra/QQLoginDialog.java | 34 ++++ .../src/com/fr/design/extra/QQLoginPane.java | 44 +++++ .../com/fr/design/extra/QQLoginWebBridge.java | 103 ++++++++++ .../com/fr/design/extra/QQLoginWebPane.java | 55 ++++++ .../com/fr/design/extra/UserLoginContext.java | 28 +++ .../extra/exe/GetLoginInfoExecutor.java | 37 ++++ 15 files changed, 726 insertions(+), 38 deletions(-) create mode 100644 designer/src/com/fr/design/mainframe/bbs/LoginDialog.java create mode 100644 designer_base/src/com/fr/design/extra/LoginContextListener.java create mode 100644 designer_base/src/com/fr/design/extra/LoginPane.java create mode 100644 designer_base/src/com/fr/design/extra/LoginWebBridge.java create mode 100644 designer_base/src/com/fr/design/extra/LoginWebPane.java create mode 100644 designer_base/src/com/fr/design/extra/QQLoginDialog.java create mode 100644 designer_base/src/com/fr/design/extra/QQLoginPane.java create mode 100644 designer_base/src/com/fr/design/extra/QQLoginWebBridge.java create mode 100644 designer_base/src/com/fr/design/extra/QQLoginWebPane.java create mode 100644 designer_base/src/com/fr/design/extra/UserLoginContext.java create mode 100644 designer_base/src/com/fr/design/extra/exe/GetLoginInfoExecutor.java diff --git a/designer/src/com/fr/design/mainframe/bbs/BBSLoginDialog.java b/designer/src/com/fr/design/mainframe/bbs/BBSLoginDialog.java index 2845ccece..f9369928e 100644 --- a/designer/src/com/fr/design/mainframe/bbs/BBSLoginDialog.java +++ b/designer/src/com/fr/design/mainframe/bbs/BBSLoginDialog.java @@ -75,7 +75,6 @@ public class BBSLoginDialog extends UIDialog { // 鐢ㄦ埛鐧诲綍鐘舵乴abel private UserInfoLabel userInfoLabel; - public UILabel getTipLabel() { return tipLabel; } @@ -84,7 +83,6 @@ public class BBSLoginDialog extends UIDialog { this.tipLabel = tipLabel; } - /** * 鏋勯犲嚱鏁 * @@ -213,7 +211,6 @@ public class BBSLoginDialog extends UIDialog { DesignerEnvManager.getEnvManager().setBBSPassword(String.valueOf(passField.getPassword())); userInfoLabel.setUserName(nameField.getText()); userInfoLabel.getUserInfoPane().markSignIn(nameField.getText()); - userInfoLabel.getUserInfoPane().getSwitchAccountLabel().setVisible(true); BBSLoginDialog.this.setVisible(false); } diff --git a/designer/src/com/fr/design/mainframe/bbs/LoginDialog.java b/designer/src/com/fr/design/mainframe/bbs/LoginDialog.java new file mode 100644 index 000000000..1d1926bf9 --- /dev/null +++ b/designer/src/com/fr/design/mainframe/bbs/LoginDialog.java @@ -0,0 +1,35 @@ +package com.fr.design.mainframe.bbs; + +import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.UIDialog; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.Inter; +import com.fr.general.SiteCenter; +import com.fr.general.http.HttpClient; +import com.fr.stable.StringUtils; + +import javax.swing.*; +import java.awt.*; + +/** + * Created by zhaohehe on 16/7/26. + */ +public class LoginDialog extends UIDialog { + private static final Dimension DEFAULT_SHOP = new Dimension(404, 234); + + public LoginDialog(Frame frame, BasicPane pane) { + super(frame); + setUndecorated(true); + JPanel panel = (JPanel) getContentPane(); + panel.setLayout(new BorderLayout()); + add(pane, BorderLayout.CENTER); + setSize(DEFAULT_SHOP); + GUICoreUtils.centerWindow(this); + setResizable(false); + setTitle(Inter.getLocText("FR-Designer-Plugin_Manager")); + } + + @Override + public void checkValid() throws Exception { + } +} diff --git a/designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java b/designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java index 712bba5eb..a2e0946c5 100644 --- a/designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java +++ b/designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java @@ -5,12 +5,16 @@ package com.fr.design.mainframe.bbs; import com.fr.base.FRContext; import com.fr.design.DesignerEnvManager; -import com.fr.design.extra.LoginCheckContext; -import com.fr.design.extra.LoginCheckListener; +import com.fr.design.dialog.UIDialog; +import com.fr.design.extra.*; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.imenu.UIMenuItem; +import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; import com.fr.general.DateUtils; +import com.fr.general.Inter; import com.fr.general.SiteCenter; import com.fr.general.http.HttpClient; import com.fr.stable.EncodeConstants; @@ -41,7 +45,7 @@ public class UserInfoLabel extends UILabel{ private static final String MESSAGE_KEY = "messageCount"; private static final int MIN_MESSAGE_COUNT = 1; - + private static final int MENU_HEIGHT = 20; //鐢ㄦ埛鍚 private String userName; @@ -87,6 +91,19 @@ public class UserInfoLabel extends UILabel{ bbsLoginDialog.showWindow(); } }); + + UserLoginContext.addLoginContextListener(new LoginContextListener() { + @Override + public void showLoginContext() { + LoginPane managerPane = new LoginPane(); + UIDialog qqdlg = new LoginDialog(DesignerContext.getDesignerFrame(),managerPane); + LoginWebBridge.getHelper().setDialogHandle(qqdlg); + LoginWebBridge.getHelper().setUILabel(UserInfoLabel.this); + QQLoginWebBridge.getHelper().setLoginlabel(); + qqdlg.setVisible(true); + } + }); + } /** @@ -242,22 +259,41 @@ public class UserInfoLabel extends UILabel{ @Override public void mouseClicked(MouseEvent e) { - if(StringUtils.isNotEmpty(userName)){ - try { - Desktop.getDesktop().browse(new URI(SiteCenter.getInstance().acquireUrlByKind("bbs.default"))); - } catch (Exception exp) { + if(StringUtils.isNotEmpty(userName)) { + UIPopupMenu menu = new UIPopupMenu(); + menu.setOnlyText(true); + menu.setPopupSize(userInfoPane.getWidth(),userInfoPane.getHeight()*3); + + //绉佷汉娑堟伅 + UIMenuItem priviteMessage = new UIMenuItem(Inter.getLocText("FR-Designer-BBSLogin_Privite-Message")); + priviteMessage.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent e) { + if(StringUtils.isNotEmpty(userName)){ + try { + Desktop.getDesktop().browse(new URI(SiteCenter.getInstance().acquireUrlByKind("bbs.default"))); + } catch (Exception exp) { + FRContext.getLogger().info(exp.getMessage()); + } + return; + } + } - } - return; + }); + //鍒囨崲璐﹀彿 + UIMenuItem closeOther = new UIMenuItem(Inter.getLocText("FR-Designer-BBSLogin_Switch-Account")); + closeOther.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent e) { + UserLoginContext.fireLoginContextListener(); + } + + }); + menu.add(priviteMessage); + menu.add(closeOther); + GUICoreUtils.showPopupMenu(menu, UserInfoLabel.this, 0, MENU_HEIGHT); + } else { + UserLoginContext.fireLoginContextListener(); } - if(bbsLoginDialog == null){ - bbsLoginDialog = new BBSLoginDialog(DesignerContext.getDesignerFrame(),UserInfoLabel.this); - } - bbsLoginDialog.clearLoginInformation(); - bbsLoginDialog.setModal(true); - bbsLoginDialog.showWindow(); } - }; } \ No newline at end of file diff --git a/designer/src/com/fr/design/mainframe/bbs/UserInfoPane.java b/designer/src/com/fr/design/mainframe/bbs/UserInfoPane.java index 45593f2a6..b73ac6717 100644 --- a/designer/src/com/fr/design/mainframe/bbs/UserInfoPane.java +++ b/designer/src/com/fr/design/mainframe/bbs/UserInfoPane.java @@ -40,8 +40,6 @@ public class UserInfoPane extends BasicPane{ private static final int WAIT_TIME = 10000; private UserInfoLabel userInfoLabel; - private ExitLabel switchAccountLabel; - public UserInfoLabel getUserInfoLabel() { return userInfoLabel; @@ -51,13 +49,6 @@ public class UserInfoPane extends BasicPane{ this.userInfoLabel = userInfoLabel; } - public ExitLabel getSwitchAccountLabel() { - return switchAccountLabel; - } - - public void setSwitchAccountLabel(ExitLabel switchAccountLabel) { - this.switchAccountLabel = switchAccountLabel; - } /** * 鏋勯犲嚱鏁 @@ -67,14 +58,12 @@ public class UserInfoPane extends BasicPane{ this.setLayout(new BorderLayout()); this.userInfoLabel = new UserInfoLabel(this); - this.switchAccountLabel = new ExitLabel(this); - + this.markUnSignIn(); autoLogin(); autoPushLoginDialog(); this.add(userInfoLabel, BorderLayout.CENTER); - this.add(switchAccountLabel, BorderLayout.EAST); } // 鍚庡彴鑷姩鐧诲綍 @@ -149,7 +138,7 @@ public class UserInfoPane extends BasicPane{ bbsLoginDialog = new BBSLoginDialog(DesignerContext.getDesignerFrame(),userInfoLabel); userInfoLabel.setBbsLoginDialog(bbsLoginDialog); } - + bbsLoginDialog.showWindow(); DesignerEnvManager.getEnvManager().setLastShowBBSTime(DateUtils.DATEFORMAT2.format(new Date())); } @@ -164,11 +153,9 @@ public class UserInfoPane extends BasicPane{ */ public void markUnSignIn(){ this.userInfoLabel.setText(Inter.getLocText("FR-Base_UnSignIn")); - this.switchAccountLabel.setVisible(false); this.userInfoLabel.setOpaque(true); this.userInfoLabel.setBackground(UN_LOGIN_BACKGROUND); this.userInfoLabel.resetUserName(); - } /** @@ -179,11 +166,8 @@ public class UserInfoPane extends BasicPane{ public void markSignIn(String userName){ this.userInfoLabel.setText(userName); this.userInfoLabel.setUserName(userName); - this.switchAccountLabel.setVisible(true); this.userInfoLabel.setOpaque(true); this.userInfoLabel.setBackground(LOGIN_BACKGROUND); - this.switchAccountLabel.setOpaque(true); - this.switchAccountLabel.setBackground(LOGIN_BACKGROUND); } @Override @@ -191,5 +175,4 @@ public class UserInfoPane extends BasicPane{ return StringUtils.EMPTY; } - } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/extra/LoginContextListener.java b/designer_base/src/com/fr/design/extra/LoginContextListener.java new file mode 100644 index 000000000..ca1354443 --- /dev/null +++ b/designer_base/src/com/fr/design/extra/LoginContextListener.java @@ -0,0 +1,8 @@ +package com.fr.design.extra; + +/** + * Created by lp on 2016/8/16. + */ +public interface LoginContextListener { + void showLoginContext(); +} diff --git a/designer_base/src/com/fr/design/extra/LoginPane.java b/designer_base/src/com/fr/design/extra/LoginPane.java new file mode 100644 index 000000000..206696192 --- /dev/null +++ b/designer_base/src/com/fr/design/extra/LoginPane.java @@ -0,0 +1,43 @@ +package com.fr.design.extra; + +import com.fr.design.dialog.BasicPane; +import com.fr.general.Inter; +import com.fr.stable.StableUtils; + +import java.awt.*; +import java.io.File; +import java.net.URL; + +/** + * Created by zhaohehe on 16/7/27. + */ +public class LoginPane extends BasicPane { + private static final String LATEST = "latest"; + + public LoginPane() { + setLayout(new BorderLayout()); + if (System.getProperty("java.version").startsWith("1.8")) { + String installHome; + if (StableUtils.isDebug()) { + URL url = ClassLoader.getSystemResource(""); + installHome = url.getPath(); + addPane(installHome); + } else { + installHome = StableUtils.getInstallHome(); + File file = new File(StableUtils.pathJoin(installHome, "scripts")); + } + } else { + } + } + + private void addPane(String installHome) { + LoginWebPane webPane = new LoginWebPane(new File(installHome).getAbsolutePath(),LoginPane.this); + add(webPane, BorderLayout.CENTER); + } + + + @Override + protected String title4PopupWindow() { + return Inter.getLocText("FR-Designer-Plugin_Manager"); + } +} \ No newline at end of file diff --git a/designer_base/src/com/fr/design/extra/LoginWebBridge.java b/designer_base/src/com/fr/design/extra/LoginWebBridge.java new file mode 100644 index 000000000..34a906a36 --- /dev/null +++ b/designer_base/src/com/fr/design/extra/LoginWebBridge.java @@ -0,0 +1,187 @@ +package com.fr.design.extra; + +import com.fr.base.FRContext; +import com.fr.design.DesignerEnvManager; +import com.fr.design.dialog.UIDialog; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.mainframe.DesignerContext; +import com.fr.general.FRLogger; +import com.fr.general.SiteCenter; +import com.fr.general.http.HttpClient; +import com.fr.stable.EncodeConstants; +import com.fr.stable.StringUtils; +import javafx.scene.web.WebEngine; + +import java.io.UnsupportedEncodingException; +import java.net.HttpURLConnection; +import java.net.URI; +import javax.swing.*; +import java.awt.*; +import java.net.URLEncoder; + +/** + * Created by zhaohehe on 16/8/1. + */ +public class LoginWebBridge { + + private static final String LOGIN_SUCCESS_FLAG = "http://bbs.finereport.com"; + private static final int TIME_OUT = 10000; + + private static com.fr.design.extra.LoginWebBridge helper; + private UIDialog uiDialog; + private UILabel uiLabel; + + private boolean testConnection() { + HttpClient client = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("bbs.test")); + return client.isServerAlive(); + } + + public static com.fr.design.extra.LoginWebBridge getHelper() { + if (helper != null) { + return helper; + } + synchronized (com.fr.design.extra.LoginWebBridge.class) { + if (helper == null) { + helper = new com.fr.design.extra.LoginWebBridge(); + } + return helper; + } + } + + public static com.fr.design.extra.LoginWebBridge getHelper(WebEngine webEngine) { + getHelper(); + helper.setEngine(webEngine); + return helper; + } + + private WebEngine webEngine; + + private LoginWebBridge() { + } + + public void setEngine(WebEngine webEngine) { + this.webEngine = webEngine; + } + + public void setDialogHandle(UIDialog uiDialog) { + this.uiDialog = uiDialog; + } + + public void setUILabel(UILabel uiLabel) { + this.uiLabel = uiLabel; + } + + /** + * 娉ㄥ唽椤甸潰 + */ + public void registerHref() { + try { + Desktop.getDesktop().browse(new URI(SiteCenter.getInstance().acquireUrlByKind("bbs.default"))); + }catch (Exception e) { + FRContext.getLogger().info(e.getMessage()); + } + } + + /** + * 蹇樿瀵嗙爜 + */ + public void forgetHref() { + try { + Desktop.getDesktop().browse(new URI(SiteCenter.getInstance().acquireUrlByKind("bbs.default"))); + }catch (Exception e) { + FRContext.getLogger().info(e.getMessage()); + } + } + + /** + * 鐧诲綍鎿嶄綔鐨勫洖璋 + * @param username + * @param password + * @param callback + * @return + */ + public String defaultLogin(String username, String password) { + if (!StringUtils.isNotBlank(username) && !StringUtils.isNotBlank(password)) { + //鐢ㄦ埛鍚嶅瘑鐮佷负绌 + return "-1"; + } + if (!testConnection()) { + //缃戠粶娴嬭瘯杩炴帴涓嶉氳繃 + return "-2"; + } + if (login(username, password)) { + updateUserInfo(username, password); + loginSuccess(username); + return "0"; + }else { + return "-3"; + } + } + + /** + * 鍏抽棴绐楀彛 + */ + public void closeWindow() { + if (uiDialog != null) { + uiDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); + uiDialog.setVisible(false); + } + } + + public void updateUserInfo(String username,String password) { + DesignerEnvManager.getEnvManager().setBBSName(username); + DesignerEnvManager.getEnvManager().setBBSPassword(password); + } + + /** + * 鍏抽棴绐楀彛骞朵笖閲嶆柊璧嬪 + * @param username + */ + public void loginSuccess(String username) { + closeWindow(); + uiLabel.setText(username); + } + + /** + * 寮瑰嚭QQ鎺堟潈椤甸潰 + */ + public void showQQ() { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + //寮瑰嚭qq鐧诲綍鐨勭獥鍙 + QQLoginPane managerPane = new QQLoginPane(); + UIDialog qqlog = new QQLoginDialog(DesignerContext.getDesignerFrame(),managerPane); + QQLoginWebBridge.getHelper().setDialogHandle(uiDialog); + QQLoginWebBridge.getHelper().setQQDialogHandle(qqlog); + QQLoginWebBridge.getHelper().setUILabel(uiLabel); + qqlog.setVisible(true); + } + }); + } + + public boolean login(String username, String password) { + if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password)) { + try { + username = URLEncoder.encode(username, EncodeConstants.ENCODING_GBK); + password = URLEncoder.encode(password, EncodeConstants.ENCODING_GBK); + } catch (UnsupportedEncodingException e) { + FRLogger.getLogger().error(e.getMessage()); + } + String url = SiteCenter.getInstance().acquireUrlByKind("bbs.login") + "&username=" + username + "&password=" + password; + HttpClient client = new HttpClient(url); + client.setTimeout(TIME_OUT); + if (client.getResponseCodeNoException() == HttpURLConnection.HTTP_OK) { + try { + String res = client.getResponseText(EncodeConstants.ENCODING_GBK); + if (res.contains(LOGIN_SUCCESS_FLAG)) { + return true; + } + } catch (Exception e) { + FRLogger.getLogger().error(e.getMessage()); + } + } + } + return false; + } +} \ No newline at end of file diff --git a/designer_base/src/com/fr/design/extra/LoginWebPane.java b/designer_base/src/com/fr/design/extra/LoginWebPane.java new file mode 100644 index 000000000..f31889c28 --- /dev/null +++ b/designer_base/src/com/fr/design/extra/LoginWebPane.java @@ -0,0 +1,61 @@ +package com.fr.design.extra; + +import javafx.application.Platform; +import javafx.embed.swing.JFXPanel; +import javafx.event.EventHandler; +import javafx.scene.Scene; +import javafx.scene.layout.BorderPane; +import javafx.scene.web.WebEngine; +import javafx.scene.web.WebEvent; +import javafx.scene.web.WebView; +import netscape.javascript.JSObject; + +import javax.swing.*; + +/** + * Created by zhaohehe on 16/7/26. + */ +public class LoginWebPane extends JFXPanel { + + private WebEngine webEngine; + private LoginPane loginPane; + + public LoginWebPane(final String installHome,LoginPane loginPane) { + this.loginPane = loginPane; + Platform.setImplicitExit(false); + Platform.runLater(new Runnable() { + @Override + public void run() { + BorderPane root = new BorderPane(); + Scene scene = new Scene(root); + LoginWebPane.this.setScene(scene); + WebView webView = new WebView(); + webEngine = webView.getEngine(); + webEngine.load("file:///" + installHome + "/scripts/store/web/login.html"); + webEngine.setOnAlert(new EventHandler>() { + @Override + public void handle(WebEvent event) { + showAlert(event.getData()); + } + }); + JSObject obj = (JSObject) webEngine.executeScript("window"); + obj.setMember("LoginHelper", LoginWebBridge.getHelper(webEngine)); + webView.setContextMenuEnabled(false);//灞忚斀鍙抽敭 + root.setCenter(webView); + } + }); + } + + public void setEngine(WebEngine webEngine) { + this.webEngine = webEngine; + } + + private void showAlert(final String message) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + JOptionPane.showMessageDialog(LoginWebPane.this, message); + } + }); + } +} diff --git a/designer_base/src/com/fr/design/extra/PluginWebBridge.java b/designer_base/src/com/fr/design/extra/PluginWebBridge.java index 144f913da..82dd4cf35 100644 --- a/designer_base/src/com/fr/design/extra/PluginWebBridge.java +++ b/designer_base/src/com/fr/design/extra/PluginWebBridge.java @@ -6,6 +6,7 @@ import com.fr.design.dialog.UIDialog; import com.fr.design.extra.exe.*; import com.fr.general.FRLogger; import com.fr.general.Inter; +import com.fr.general.SiteCenter; import com.fr.plugin.Plugin; import com.fr.plugin.PluginLicense; import com.fr.plugin.PluginLicenseManager; @@ -361,6 +362,42 @@ public class PluginWebBridge { return false; } + /** + * 鑾峰彇绯荤粺鐧诲綍鐨勭敤鎴峰悕 + * @param callback + */ + public void getLoginInfo(final JSObject callback) { + Task task = new PluginTask<>(webEngine, callback, new GetLoginInfoExecutor()); + new Thread(task).start(); + } + + /** + * 鎵撳紑璁哄潧娑堟伅鐣岄潰 + */ + public void getPriviteMessage() { + try { + Desktop.getDesktop().browse(new URI(SiteCenter.getInstance().acquireUrlByKind("bbs.default"))); + }catch (Exception exp) { + FRContext.getLogger().info(exp.getMessage()); + } + } + + /** + * 鎵撳紑鐧诲綍椤甸潰 + */ + public void loginContent() { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + UserLoginContext.fireLoginContextListener(); + } + }); + } + + public void getUsername() { + + } + /** * 鍦ㄦ湰鍦版祻瑙堝櫒閲屾墦寮url * tips:閲嶈浇鐨勬椂鍊,闇瑕佺粰js璋冪敤鐨勬柟娉曢渶瑕佹斁鍦ㄥ墠闈,鍚﹀垯鍙兘涓嶄細琚皟鐢(姝や箖鍧) diff --git a/designer_base/src/com/fr/design/extra/QQLoginDialog.java b/designer_base/src/com/fr/design/extra/QQLoginDialog.java new file mode 100644 index 000000000..1a6416174 --- /dev/null +++ b/designer_base/src/com/fr/design/extra/QQLoginDialog.java @@ -0,0 +1,34 @@ +package com.fr.design.extra; + +import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.UIDialog; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.Inter; + +import javax.swing.*; +import java.awt.*; + +/** + * Created by zhaohehe on 16/7/28. + */ +public class QQLoginDialog extends UIDialog { + private static final Dimension DEFAULT_SHOP = new Dimension(700, 500); + + public QQLoginDialog(Frame frame, BasicPane pane) { + super(frame); + setUndecorated(true); + JPanel panel = (JPanel) getContentPane(); + panel.setLayout(new BorderLayout()); + add(pane, BorderLayout.CENTER); + setSize(DEFAULT_SHOP); + GUICoreUtils.centerWindow(this); + setResizable(false); + setTitle(Inter.getLocText("FR-Designer-Plugin_Manager")); + + } + + @Override + public void checkValid() throws Exception { + } + +} \ No newline at end of file diff --git a/designer_base/src/com/fr/design/extra/QQLoginPane.java b/designer_base/src/com/fr/design/extra/QQLoginPane.java new file mode 100644 index 000000000..e93c611fe --- /dev/null +++ b/designer_base/src/com/fr/design/extra/QQLoginPane.java @@ -0,0 +1,44 @@ +package com.fr.design.extra; + +import com.fr.design.dialog.BasicPane; +import com.fr.general.Inter; +import com.fr.stable.StableUtils; + +import java.awt.*; +import java.io.File; +import java.net.URL; + +/** + * Created by zhaohehe on 16/7/28. + */ +public class QQLoginPane extends BasicPane { + private static final String LATEST = "latest"; + + public QQLoginPane() { + setLayout(new BorderLayout()); + if (System.getProperty("java.version").startsWith("1.8")) { + String installHome; + if (StableUtils.isDebug()) { + URL url = ClassLoader.getSystemResource(""); + installHome = url.getPath(); + addPane(installHome); + } else { + installHome = StableUtils.getInstallHome(); + File file = new File(StableUtils.pathJoin(installHome, "scripts")); + + } + } else { + } + } + + private void addPane(String installHome) { + QQLoginWebPane webPane = new QQLoginWebPane(new File(installHome).getAbsolutePath()); + add(webPane, BorderLayout.CENTER); + } + + + @Override + protected String title4PopupWindow() { + return Inter.getLocText("FR-Designer-Plugin_Manager"); + } +} \ No newline at end of file diff --git a/designer_base/src/com/fr/design/extra/QQLoginWebBridge.java b/designer_base/src/com/fr/design/extra/QQLoginWebBridge.java new file mode 100644 index 000000000..bc76cef1c --- /dev/null +++ b/designer_base/src/com/fr/design/extra/QQLoginWebBridge.java @@ -0,0 +1,103 @@ +package com.fr.design.extra; + +import com.fr.base.FRContext; +import com.fr.design.DesignerEnvManager; +import com.fr.design.dialog.UIDialog; +import com.fr.design.gui.ilable.UILabel; +import javafx.scene.web.WebEngine; +import org.json.JSONObject; + +import javax.swing.*; + +/** + * Created by lp on 2016/8/10. + */ +public class QQLoginWebBridge { + + private static com.fr.design.extra.QQLoginWebBridge helper; + private WebEngine webEngine; + private static String LOGINSUCCESS = "ok"; + private UIDialog uiDialog; + private UILabel uiLabel; + private UIDialog qqDialog; + private String username; + + + private QQLoginWebBridge() { + } + + public static com.fr.design.extra.QQLoginWebBridge getHelper() { + if (helper != null) { + return helper; + } + synchronized (com.fr.design.extra.QQLoginWebBridge.class) { + if (helper == null) { + helper = new com.fr.design.extra.QQLoginWebBridge(); + } + return helper; + } + } + + public void setEngine(WebEngine webEngine) { + this.webEngine = webEngine; + } + + public void setDialogHandle(UIDialog uiDialog) { + this.uiDialog = uiDialog; + } + + public void setQQDialogHandle(UIDialog uiDialog) { + this.qqDialog = uiDialog; + } + + public void setUILabel(UILabel uiLabel) { + this.uiLabel = uiLabel; + } + + public void setLoginlabel() { + username = DesignerEnvManager.getEnvManager().getBBSName(); + } + + public static com.fr.design.extra.QQLoginWebBridge getHelper(WebEngine webEngine) { + getHelper(); + helper.setEngine(webEngine); + return helper; + } + + /** + * 鍏抽棴QQ鎺堟潈绐楀彛 + */ + public void closeQQWindow() { + if (qqDialog != null) { + qqDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); + qqDialog.setVisible(false); + } + } + + /** + * 鍏抽棴鐖剁獥鍙 + */ + public void closeParentWindow() { + if (uiDialog != null) { + uiDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); + uiDialog.setVisible(false); + } + } + + /** + * 鑾峰彇鐢ㄦ埛淇℃伅 + * @param userInfo + */ + public void getLoginInfo(String userInfo) { + JSONObject jo = new JSONObject(userInfo); + String status = jo.get("status").toString(); + if (status.equals(LOGINSUCCESS)) { + String username = jo.get("username").toString(); + closeQQWindow(); + closeParentWindow(); + //璁剧疆label鐨勭敤鎴峰悕 + uiLabel.setText(username); + }else { + } + } +} diff --git a/designer_base/src/com/fr/design/extra/QQLoginWebPane.java b/designer_base/src/com/fr/design/extra/QQLoginWebPane.java new file mode 100644 index 000000000..9644f0666 --- /dev/null +++ b/designer_base/src/com/fr/design/extra/QQLoginWebPane.java @@ -0,0 +1,55 @@ +package com.fr.design.extra; + +import javafx.application.Platform; +import javafx.embed.swing.JFXPanel; +import javafx.event.EventHandler; +import javafx.scene.Scene; +import javafx.scene.layout.BorderPane; +import javafx.scene.web.WebEngine; +import javafx.scene.web.WebEvent; +import javafx.scene.web.WebView; +import netscape.javascript.JSObject; + +import javax.swing.*; + +/** + * Created by zhaohehe on 16/7/28. + */ +public class QQLoginWebPane extends JFXPanel { + + private WebEngine webEngine; + + public QQLoginWebPane(final String installHome) { + Platform.setImplicitExit(false); + Platform.runLater(new Runnable() { + @Override + public void run() { + BorderPane root = new BorderPane(); + Scene scene = new Scene(root); + QQLoginWebPane.this.setScene(scene); + WebView webView = new WebView(); + webEngine = webView.getEngine(); + webEngine.load("file:///" + installHome + "/scripts/store/web/qqLogin.html"); + webEngine.setOnAlert(new EventHandler>() { + @Override + public void handle(WebEvent event) { + showAlert(event.getData()); + } + }); + JSObject obj = (JSObject) webEngine.executeScript("window"); + obj.setMember("QQLoginHelper", QQLoginWebBridge.getHelper(webEngine)); + webView.setContextMenuEnabled(false);//灞忚斀鍙抽敭 + root.setCenter(webView); + } + }); + } + + private void showAlert(final String message) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + JOptionPane.showMessageDialog(QQLoginWebPane.this, message); + } + }); + } +} \ No newline at end of file diff --git a/designer_base/src/com/fr/design/extra/UserLoginContext.java b/designer_base/src/com/fr/design/extra/UserLoginContext.java new file mode 100644 index 000000000..a6d68f076 --- /dev/null +++ b/designer_base/src/com/fr/design/extra/UserLoginContext.java @@ -0,0 +1,28 @@ +package com.fr.design.extra; + +import java.util.ArrayList; + +/** + * Created by lp on 2016/8/16. + */ +public class UserLoginContext { + private static ArrayList fireLoginContextListener = new ArrayList(); + + /** + * 瑙﹀彂鐧诲綍妗嗗脊鍑虹殑鐩戝惉鍣 + */ + public static void fireLoginContextListener() { + for (LoginContextListener l : fireLoginContextListener) { + l.showLoginContext(); + } + } + + /** + * 娣诲姞涓涓脊鍑虹櫥褰曟鐨勭洃鍚簨浠 + * + * @param l 鐧诲綍妗嗗脊鍑虹洃鍚簨浠 + */ + public static void addLoginContextListener(LoginContextListener l) { + fireLoginContextListener.add(l); + } +} diff --git a/designer_base/src/com/fr/design/extra/exe/GetLoginInfoExecutor.java b/designer_base/src/com/fr/design/extra/exe/GetLoginInfoExecutor.java new file mode 100644 index 000000000..79fb20dce --- /dev/null +++ b/designer_base/src/com/fr/design/extra/exe/GetLoginInfoExecutor.java @@ -0,0 +1,37 @@ +package com.fr.design.extra.exe; + +import com.fr.design.DesignerEnvManager; +import com.fr.design.extra.Process; + +/** + * Created by lp on 2016/8/16. + */ +public class GetLoginInfoExecutor implements Executor { + private String result = "[]"; + + @Override + public String getTaskFinishMessage() { + return result; + } + + @Override + public Command[] getCommands() { + return new Command[]{ + new Command() { + @Override + public String getExecuteMessage() { + return null; + } + + @Override + public void run(Process process) { + String username = DesignerEnvManager.getEnvManager().getBBSName(); + if (username == null) { + }else { + result = username; + } + } + } + }; + } +} From 1e7c7d2afbcc15b5b10e21b3e8b00c5d98348a4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=94=80?= Date: Thu, 18 Aug 2016 18:12:53 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E5=99=A8=E5=86=85?= =?UTF-8?q?=E8=AE=BA=E5=9D=9B=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/extra/LoginPane.java | 2 +- .../src/com/fr/design/extra/LoginWebBridge.java | 14 ++++++++------ .../src/com/fr/design/extra/QQLoginWebBridge.java | 8 +++++--- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/designer_base/src/com/fr/design/extra/LoginPane.java b/designer_base/src/com/fr/design/extra/LoginPane.java index 206696192..f49088af2 100644 --- a/designer_base/src/com/fr/design/extra/LoginPane.java +++ b/designer_base/src/com/fr/design/extra/LoginPane.java @@ -16,7 +16,7 @@ public class LoginPane extends BasicPane { public LoginPane() { setLayout(new BorderLayout()); - if (System.getProperty("java.version").startsWith("1.8")) { + if (StableUtils.getMajorJavaVersion() == 8) { String installHome; if (StableUtils.isDebug()) { URL url = ClassLoader.getSystemResource(""); diff --git a/designer_base/src/com/fr/design/extra/LoginWebBridge.java b/designer_base/src/com/fr/design/extra/LoginWebBridge.java index 34a906a36..4f1811431 100644 --- a/designer_base/src/com/fr/design/extra/LoginWebBridge.java +++ b/designer_base/src/com/fr/design/extra/LoginWebBridge.java @@ -25,6 +25,10 @@ import java.net.URLEncoder; public class LoginWebBridge { private static final String LOGIN_SUCCESS_FLAG = "http://bbs.finereport.com"; + private static final String LOGININ = "0"; + private static final String LOGIN_INFO_EMPTY = "-1"; + private static final String DISCONNECTED = "-2"; + private static final String UNKNOWN_ERROR = "-3"; private static final int TIME_OUT = 10000; private static com.fr.design.extra.LoginWebBridge helper; @@ -102,19 +106,17 @@ public class LoginWebBridge { */ public String defaultLogin(String username, String password) { if (!StringUtils.isNotBlank(username) && !StringUtils.isNotBlank(password)) { - //鐢ㄦ埛鍚嶅瘑鐮佷负绌 - return "-1"; + return LOGIN_INFO_EMPTY; } if (!testConnection()) { - //缃戠粶娴嬭瘯杩炴帴涓嶉氳繃 - return "-2"; + return DISCONNECTED; } if (login(username, password)) { updateUserInfo(username, password); loginSuccess(username); - return "0"; + return LOGININ; }else { - return "-3"; + return UNKNOWN_ERROR; } } diff --git a/designer_base/src/com/fr/design/extra/QQLoginWebBridge.java b/designer_base/src/com/fr/design/extra/QQLoginWebBridge.java index bc76cef1c..a038d56ce 100644 --- a/designer_base/src/com/fr/design/extra/QQLoginWebBridge.java +++ b/designer_base/src/com/fr/design/extra/QQLoginWebBridge.java @@ -1,6 +1,5 @@ package com.fr.design.extra; -import com.fr.base.FRContext; import com.fr.design.DesignerEnvManager; import com.fr.design.dialog.UIDialog; import com.fr.design.gui.ilable.UILabel; @@ -17,6 +16,7 @@ public class QQLoginWebBridge { private static com.fr.design.extra.QQLoginWebBridge helper; private WebEngine webEngine; private static String LOGINSUCCESS = "ok"; + private static String LOGINFAILED = "failed"; private UIDialog uiDialog; private UILabel uiLabel; private UIDialog qqDialog; @@ -95,9 +95,11 @@ public class QQLoginWebBridge { String username = jo.get("username").toString(); closeQQWindow(); closeParentWindow(); - //璁剧疆label鐨勭敤鎴峰悕 uiLabel.setText(username); - }else { + DesignerEnvManager.getEnvManager().setBBSName(username); + }else if (status.equals(LOGINFAILED)){ + //璐﹀彿娌℃湁QQ鎺堟潈 + closeQQWindow(); } } } From c54e5b9819826c437bda5b970393125840d4e782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=94=80?= Date: Thu, 18 Aug 2016 18:19:41 +0800 Subject: [PATCH 4/7] 1 1 --- designer_base/src/com/fr/design/extra/LoginWebBridge.java | 1 - 1 file changed, 1 deletion(-) diff --git a/designer_base/src/com/fr/design/extra/LoginWebBridge.java b/designer_base/src/com/fr/design/extra/LoginWebBridge.java index 4f1811431..514967693 100644 --- a/designer_base/src/com/fr/design/extra/LoginWebBridge.java +++ b/designer_base/src/com/fr/design/extra/LoginWebBridge.java @@ -101,7 +101,6 @@ public class LoginWebBridge { * 鐧诲綍鎿嶄綔鐨勫洖璋 * @param username * @param password - * @param callback * @return */ public String defaultLogin(String username, String password) { From d213b7894525b79a480e5eec911097249d4300bb Mon Sep 17 00:00:00 2001 From: fangdong sun Date: Thu, 18 Aug 2016 19:16:25 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E6=97=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 1 - build.gradle.bak | 4 ++-- designer_base/build.gradle | 2 +- designer_base/build.gradle.bak | 16 ++++++++-------- designer_chart/build.gradle | 2 +- designer_chart/build.gradle.bak | 12 ++++++------ 6 files changed, 18 insertions(+), 19 deletions(-) diff --git a/build.gradle b/build.gradle index 659130f9e..abc981595 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,6 @@ apply plugin: "java" tasks.withType(JavaCompile){ options.encoding = "UTF-8" } - def basicDir="../../" def libDir="${basicDir}/finereport-lib-stable" //鑾峰彇浠涔堝垎鏀悕 diff --git a/build.gradle.bak b/build.gradle.bak index 633739a74..67a8a0e70 100644 --- a/build.gradle.bak +++ b/build.gradle.bak @@ -2,10 +2,10 @@ 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) diff --git a/designer_base/build.gradle b/designer_base/build.gradle index bd5f62e8e..cbaf1a695 100644 --- a/designer_base/build.gradle +++ b/designer_base/build.gradle @@ -56,7 +56,7 @@ task compressJS{ 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'){ + 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') diff --git a/designer_base/build.gradle.bak b/designer_base/build.gradle.bak index a48a4d2c5..bd5f62e8e 100644 --- a/designer_base/build.gradle.bak +++ b/designer_base/build.gradle.bak @@ -3,11 +3,11 @@ apply plugin: 'java' tasks.withType(JavaCompile){ options.encoding = 'UTF-8' } -//指定构建的jdk版本 +//鎸囧畾鏋勫缓鐨刯dk鐗堟湰 sourceCompatibility=1.8 -//指定生成jar包版本 +//鎸囧畾鐢熸垚jar鍖呯増鏈 version='8.0' -//生成jar包重命名 +//鐢熸垚jar鍖呴噸鍛藉悕 jar{ baseName='fr-designer-core' } @@ -15,7 +15,7 @@ jar{ def srcDir="." -//指定源码路径 +//鎸囧畾婧愮爜璺緞 sourceSets{ main{ java{ @@ -23,13 +23,13 @@ sourceSets{ } } } -//获取什么分支名 +//鑾峰彇浠涔堝垎鏀悕 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') @@ -37,7 +37,7 @@ compile fileTree(dir:'../../../',include:"finereport-*-stable/${branchName}/**/* testCompile 'junit:junit:4.12' } -//复制非.java文件到classes文件夹下参与打包 +//澶嶅埗闈.java鏂囦欢鍒癱lasses鏂囦欢澶逛笅鍙備笌鎵撳寘 task copyFile(type:Copy,dependsOn:compileJava){ copy{ from ("${srcDir}/src"){ @@ -49,7 +49,7 @@ task copyFile(type:Copy,dependsOn:compileJava){ } -//压缩项目中的js文件 +//鍘嬬缉椤圭洰涓殑js鏂囦欢 task compressJS{ ant.taskdef(name:'yuicompress',classname:'com.yahoo.platform.yui.compressor.YUICompressTask'){ classpath { diff --git a/designer_chart/build.gradle b/designer_chart/build.gradle index 2a9777371..946649195 100644 --- a/designer_chart/build.gradle +++ b/designer_chart/build.gradle @@ -54,7 +54,7 @@ task compressJS{ 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'){ + 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') diff --git a/designer_chart/build.gradle.bak b/designer_chart/build.gradle.bak index 2b465eca9..2a9777371 100644 --- a/designer_chart/build.gradle.bak +++ b/designer_chart/build.gradle.bak @@ -3,14 +3,14 @@ apply plugin: 'java' tasks.withType(JavaCompile){ options.encoding = 'UTF-8' } -//指定构建的jdk版本 +//鎸囧畾鏋勫缓鐨刯dk鐗堟湰 sourceCompatibility=1.8 -//指定生成jar包的版本 +//鎸囧畾鐢熸垚jar鍖呯殑鐗堟湰 version='8.0' def srcDir="." -//对生成的jar包进行重命名 +//瀵圭敓鎴愮殑jar鍖呰繘琛岄噸鍛藉悕 jar{ baseName='fr-designer-chart' @@ -28,14 +28,14 @@ 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}/**/*.jar") testCompile 'junit:junit:4.12' } -//将非.java 文件复制到classes文件夹下参与打包 +//灏嗛潪.java 鏂囦欢澶嶅埗鍒癱lasses鏂囦欢澶逛笅鍙備笌鎵撳寘 task copyFile(type:Copy,dependsOn:compileJava){ copy{ from ("${srcDir}/src"){ @@ -47,7 +47,7 @@ task copyFile(type:Copy,dependsOn:compileJava){ } -//压缩项目中的js文件 +//鍘嬬缉椤圭洰涓殑js鏂囦欢 task compressJS{ ant.taskdef(name:'yuicompress',classname:'com.yahoo.platform.yui.compressor.YUICompressTask'){ classpath { From 1586f20b0d89895d0ee3643a353cedf8385306d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=94=80?= Date: Fri, 19 Aug 2016 10:38:27 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=A1=86=E9=83=A8?= =?UTF-8?q?=E5=88=86=E4=B8=8B=E8=BD=BD=E5=AE=89=E8=A3=85=E6=83=85=E5=86=B5?= =?UTF-8?q?=E4=B8=8B=E7=9A=84=E4=B8=8B=E8=BD=BDscripts=E9=83=A8=E5=88=86?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/extra/LoginPane.java | 102 ++++++++++++++++- .../fr/design/extra/PluginManagerPane.java | 2 +- .../src/com/fr/design/extra/QQLoginPane.java | 105 +++++++++++++++++- 3 files changed, 205 insertions(+), 4 deletions(-) diff --git a/designer_base/src/com/fr/design/extra/LoginPane.java b/designer_base/src/com/fr/design/extra/LoginPane.java index f49088af2..c8c231b24 100644 --- a/designer_base/src/com/fr/design/extra/LoginPane.java +++ b/designer_base/src/com/fr/design/extra/LoginPane.java @@ -1,12 +1,23 @@ package com.fr.design.extra; +import com.fr.base.FRContext; +import com.fr.design.DesignerEnvManager; +import com.fr.design.RestartHelper; import com.fr.design.dialog.BasicPane; +import com.fr.general.ComparatorUtils; +import com.fr.general.IOUtils; import com.fr.general.Inter; +import com.fr.general.SiteCenter; +import com.fr.general.http.HttpClient; +import com.fr.plugin.PluginVerifyException; import com.fr.stable.StableUtils; +import javax.swing.*; import java.awt.*; import java.io.File; +import java.net.HttpURLConnection; import java.net.URL; +import java.util.concurrent.ExecutionException; /** * Created by zhaohehe on 16/7/27. @@ -25,6 +36,21 @@ public class LoginPane extends BasicPane { } else { installHome = StableUtils.getInstallHome(); File file = new File(StableUtils.pathJoin(installHome, "scripts")); + if (!file.exists()) { + int rv = JOptionPane.showConfirmDialog( + this, + Inter.getLocText("FR-Designer-Plugin_Shop_Need_Install"), + Inter.getLocText("FR-Designer-Plugin_Warning"), + JOptionPane.OK_CANCEL_OPTION, + JOptionPane.INFORMATION_MESSAGE + ); + if (rv == JOptionPane.OK_OPTION) { + downloadShopScripts(); + } + } else { + addPane(installHome); + updateShopScripts(); + } } } else { } @@ -35,9 +61,83 @@ public class LoginPane extends BasicPane { add(webPane, BorderLayout.CENTER); } - @Override protected String title4PopupWindow() { return Inter.getLocText("FR-Designer-Plugin_Manager"); } + + private void downloadShopScripts() { + new SwingWorker() { + @Override + protected Boolean doInBackground() throws Exception { + String id = "shop_scripts"; + String username = DesignerEnvManager.getEnvManager().getBBSName(); + String password = DesignerEnvManager.getEnvManager().getBBSPassword(); + try { + PluginHelper.downloadPluginFile(id, username, password, new Process() { + @Override + public void process(Double integer) { + } + }); + } catch (PluginVerifyException e) { + JOptionPane.showMessageDialog(LoginPane.this, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + return false; + } catch (Exception e) { + FRContext.getLogger().error(e.getMessage(), e); + return false; + } + return true; + } + + @Override + protected void done() { + + try { + if (get()) { + IOUtils.unzip(new File(StableUtils.pathJoin(PluginHelper.DOWNLOAD_PATH, PluginHelper.TEMP_FILE)), StableUtils.getInstallHome()); + int rv = JOptionPane.showOptionDialog( + LoginPane.this, + Inter.getLocText("FR-Designer-Plugin_Shop_Installed"), + Inter.getLocText("FR-Designer-Plugin_Warning"), + JOptionPane.YES_NO_OPTION, + JOptionPane.INFORMATION_MESSAGE, + null, + new String[]{Inter.getLocText("FR-Designer-Basic_Restart_Designer"), Inter.getLocText("FR-Designer-Basic_Restart_Designer_Later")}, + null + ); + if (rv == JOptionPane.OK_OPTION) { + RestartHelper.restart(); + } + } + } catch (InterruptedException | ExecutionException e) { + FRContext.getLogger().error(e.getMessage(), e); + } + + } + }.execute(); + } + + private void updateShopScripts() { + new SwingWorker() { + @Override + protected Void doInBackground() throws Exception { + HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("store.version") + "&version=" + PluginStoreConstants.VERSION); + if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) { + if (!ComparatorUtils.equals(httpClient.getResponseText(), LATEST)) { + int rv = JOptionPane.showConfirmDialog( + LoginPane.this, + Inter.getLocText("FR-Designer-Plugin_Shop_Need_Update"), + Inter.getLocText("FR-Designer-Plugin_Warning"), + JOptionPane.OK_CANCEL_OPTION, + JOptionPane.INFORMATION_MESSAGE + ); + if (rv == JOptionPane.OK_OPTION) { + downloadShopScripts(); + } + } + } + return null; + } + }.execute(); + } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/extra/PluginManagerPane.java b/designer_base/src/com/fr/design/extra/PluginManagerPane.java index 64ceea369..1c9f7aafa 100644 --- a/designer_base/src/com/fr/design/extra/PluginManagerPane.java +++ b/designer_base/src/com/fr/design/extra/PluginManagerPane.java @@ -37,7 +37,7 @@ public class PluginManagerPane extends BasicPane { public PluginManagerPane() { setLayout(new BorderLayout()); - if (System.getProperty("java.version").startsWith("1.8")) { + if (StableUtils.getMajorJavaVersion() == 8) { String installHome; if (StableUtils.isDebug()) { URL url = ClassLoader.getSystemResource(""); diff --git a/designer_base/src/com/fr/design/extra/QQLoginPane.java b/designer_base/src/com/fr/design/extra/QQLoginPane.java index e93c611fe..2bbdd7e53 100644 --- a/designer_base/src/com/fr/design/extra/QQLoginPane.java +++ b/designer_base/src/com/fr/design/extra/QQLoginPane.java @@ -1,12 +1,23 @@ package com.fr.design.extra; +import com.fr.base.FRContext; +import com.fr.design.DesignerEnvManager; +import com.fr.design.RestartHelper; import com.fr.design.dialog.BasicPane; +import com.fr.general.ComparatorUtils; +import com.fr.general.IOUtils; import com.fr.general.Inter; +import com.fr.general.SiteCenter; +import com.fr.general.http.HttpClient; +import com.fr.plugin.PluginVerifyException; import com.fr.stable.StableUtils; +import javax.swing.*; import java.awt.*; import java.io.File; +import java.net.HttpURLConnection; import java.net.URL; +import java.util.concurrent.ExecutionException; /** * Created by zhaohehe on 16/7/28. @@ -16,7 +27,7 @@ public class QQLoginPane extends BasicPane { public QQLoginPane() { setLayout(new BorderLayout()); - if (System.getProperty("java.version").startsWith("1.8")) { + if (StableUtils.getMajorJavaVersion() == 8) { String installHome; if (StableUtils.isDebug()) { URL url = ClassLoader.getSystemResource(""); @@ -25,7 +36,21 @@ public class QQLoginPane extends BasicPane { } else { installHome = StableUtils.getInstallHome(); File file = new File(StableUtils.pathJoin(installHome, "scripts")); - + if (!file.exists()) { + int rv = JOptionPane.showConfirmDialog( + this, + Inter.getLocText("FR-Designer-Plugin_Shop_Need_Install"), + Inter.getLocText("FR-Designer-Plugin_Warning"), + JOptionPane.OK_CANCEL_OPTION, + JOptionPane.INFORMATION_MESSAGE + ); + if (rv == JOptionPane.OK_OPTION) { + downloadShopScripts(); + } + } else { + addPane(installHome); + updateShopScripts(); + } } } else { } @@ -41,4 +66,80 @@ public class QQLoginPane extends BasicPane { protected String title4PopupWindow() { return Inter.getLocText("FR-Designer-Plugin_Manager"); } + + + private void downloadShopScripts() { + new SwingWorker() { + @Override + protected Boolean doInBackground() throws Exception { + String id = "shop_scripts"; + String username = DesignerEnvManager.getEnvManager().getBBSName(); + String password = DesignerEnvManager.getEnvManager().getBBSPassword(); + try { + PluginHelper.downloadPluginFile(id, username, password, new Process() { + @Override + public void process(Double integer) { + } + }); + } catch (PluginVerifyException e) { + JOptionPane.showMessageDialog(QQLoginPane.this, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + return false; + } catch (Exception e) { + FRContext.getLogger().error(e.getMessage(), e); + return false; + } + return true; + } + + @Override + protected void done() { + + try { + if (get()) { + IOUtils.unzip(new File(StableUtils.pathJoin(PluginHelper.DOWNLOAD_PATH, PluginHelper.TEMP_FILE)), StableUtils.getInstallHome()); + int rv = JOptionPane.showOptionDialog( + QQLoginPane.this, + Inter.getLocText("FR-Designer-Plugin_Shop_Installed"), + Inter.getLocText("FR-Designer-Plugin_Warning"), + JOptionPane.YES_NO_OPTION, + JOptionPane.INFORMATION_MESSAGE, + null, + new String[]{Inter.getLocText("FR-Designer-Basic_Restart_Designer"), Inter.getLocText("FR-Designer-Basic_Restart_Designer_Later")}, + null + ); + if (rv == JOptionPane.OK_OPTION) { + RestartHelper.restart(); + } + } + } catch (InterruptedException | ExecutionException e) { + FRContext.getLogger().error(e.getMessage(), e); + } + + } + }.execute(); + } + + private void updateShopScripts() { + new SwingWorker() { + @Override + protected Void doInBackground() throws Exception { + HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("store.version") + "&version=" + PluginStoreConstants.VERSION); + if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) { + if (!ComparatorUtils.equals(httpClient.getResponseText(), LATEST)) { + int rv = JOptionPane.showConfirmDialog( + QQLoginPane.this, + Inter.getLocText("FR-Designer-Plugin_Shop_Need_Update"), + Inter.getLocText("FR-Designer-Plugin_Warning"), + JOptionPane.OK_CANCEL_OPTION, + JOptionPane.INFORMATION_MESSAGE + ); + if (rv == JOptionPane.OK_OPTION) { + downloadShopScripts(); + } + } + } + return null; + } + }.execute(); + } } \ No newline at end of file From adb74f86c8065eb1cd32323042d57db86910dcf7 Mon Sep 17 00:00:00 2001 From: zhouping Date: Fri, 19 Aug 2016 13:08:34 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E8=A1=A8=E5=8D=95=E7=BB=9D=E5=AF=B9?= =?UTF-8?q?=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../layout/FRAbsoluteLayoutAdapter.java | 219 +++- .../adapters/layout/FRBodyLayoutAdapter.java | 1146 +++++++++++++++++ .../adapters/layout/FRFitLayoutAdapter.java | 1055 +-------------- .../design/designer/beans/location/Inner.java | 4 +- .../painters/FRAbsoluteLayoutPainter.java | 180 ++- .../designer/creator/XWAbsoluteLayout.java | 76 +- .../design/designer/creator/XWFitLayout.java | 5 + .../designer/creator/XWParameterLayout.java | 7 + .../fr/design/gui/core/FormWidgetOption.java | 2 +- .../fr/design/mainframe/FormDesignerUI.java | 4 +- 10 files changed, 1629 insertions(+), 1069 deletions(-) create mode 100644 designer_form/src/com/fr/design/designer/beans/adapters/layout/FRBodyLayoutAdapter.java diff --git a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java index 6b72255ed..e54271cd0 100644 --- a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java +++ b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java @@ -9,18 +9,31 @@ import com.fr.design.designer.beans.painters.FRAbsoluteLayoutPainter; import com.fr.design.designer.creator.*; import com.fr.design.designer.properties.BoundsGroupModel; import com.fr.design.designer.properties.FRAbsoluteLayoutPropertiesGroupModel; -import com.fr.design.designer.properties.FRFitLayoutPropertiesGroupModel; import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.gui.LayoutUtils; +import com.fr.general.ComparatorUtils; +import com.fr.general.FRLogger; -public class FRAbsoluteLayoutAdapter extends AbstractLayoutAdapter { +public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter { + //鏄笉鏄坊鍔犲埌鐖跺鍣ㄤ笂 + private boolean isAdd2ParentLayout = false; private HoverPainter painter; + public FRAbsoluteLayoutAdapter(XLayoutContainer container) { super(container); painter = new FRAbsoluteLayoutPainter(container); + initMinSize(); } + private void initMinSize() { + XWAbsoluteLayout layout = (XWAbsoluteLayout) container; + minWidth = layout.getActualMinWidth(); + minHeight = layout.getActualMinHeight(); + actualVal = layout.getAcualInterval(); + margin = layout.toData().getMargin(); + } + @Override public HoverPainter getPainter() { return painter; @@ -37,39 +50,169 @@ public class FRAbsoluteLayoutAdapter extends AbstractLayoutAdapter { public boolean accept(XCreator creator, int x, int y) { Component comp = container.getComponentAt(x, y); //甯冨眬鎺т欢瑕佸厛鍒ゆ柇鏄笉鏄彲缂栬緫 + //鍙互缂栬緫锛屾寜鍘熸湁閫昏緫鍒ゆ柇 + //涓嶅彲缂栬緫锛屽綋鎴愪竴鏁翠釜鎺т欢澶勭悊 + if (comp == null){ + return false; + } XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer((XCreator)comp).getTopLayout(); - if(topLayout != null && !topLayout.isEditable()){ + if(topLayout != null){ + if (topLayout.isEditable()){ + return x >= 0 && y >= 0 && creator.getHeight() <= container.getHeight() + && creator.getWidth() <= container.getWidth(); + } + else { + return acceptWidget(creator, x, y); + } + } + else{ + FRLogger.getLogger().error("top layout is null!"); + } + + return false; + } + + /** + * 鍒ゆ柇鏄惁榧犳爣鍦ㄧ粍浠剁殑涓夌瓑鍒嗗尯鍩燂紝濡傛灉缁勪欢鍦ㄥ竷灞绠$悊鍣ㄤ腑闂达紝涓婁笅宸﹀彸閮藉彲鑳戒細涓夌瓑鍒 + * @param parentComp 榧犳爣鎵鍦ㄥ尯鍩熺殑缁勪欢 + * @param x 鍧愭爣x + * @param y 鍧愭爣y + * @return 鏄垯杩斿洖true + */ + public boolean isTrisectionArea(Component parentComp, int x, int y) { + XCreator creator = (XCreator)parentComp; + trisectAreaDirect = 0; + if (container.getComponentCount()<=1) { return false; } - boolean isAccept = x >= 0 && y >= 0 && creator.getHeight() <= container.getHeight() - && creator.getWidth() <= container.getWidth(); - return isAccept; + int maxWidth = parentComp.getWidth(); + int maxHeight = parentComp.getHeight(); + int xL = parentComp.getX(); + int yL = parentComp.getY(); + // 缁勪欢瀹介珮鐨勫崄鍒嗕箣涓鍜岄粯璁ゅ煎彇澶 + int minRangeWidth = Math.max(maxWidth/BORDER_PROPORTION, DEFAULT_AREA_LENGTH); + int minRangeHeight = Math.max(maxHeight/BORDER_PROPORTION, DEFAULT_AREA_LENGTH); + if(yyL+maxHeight-minRangeHeight) { + // 鍦ㄧ粍浠朵笅渚т笁绛夊垎 + trisectAreaDirect = COMP_BOTTOM; + } else if (xxL+maxWidth-minRangeWidth) { + // 鍦ㄧ粍浠跺彸渚т笁绛夊垎 + trisectAreaDirect = COMP_RIGHT; + } + // tab甯冨眬鐨勮竟鐣岀壒娈婂鐞嗭紝涓嶈繘琛屼笁绛夊垎 + if(!creator.getTargetChildrenList().isEmpty()){ + return false; + } + + return !ComparatorUtils.equals(trisectAreaDirect, 0); } - @Override + private boolean acceptWidget(XCreator creator, int x, int y){ + isFindRelatedComps = false; + //鎷栧叆缁勪欢鍒ゆ柇鏃讹紝鍏堝垽鏂槸鍚︿负浜ゅ弶鐐瑰尯鍩燂紝鍏舵涓夌瓑鍒嗗尯鍩燂紝鍐嶆骞冲垎鍖哄煙 + Component comp = container.getComponentAt(x, y); + boolean isMatchEdge = false; + //濡傛灉褰撳墠澶勪簬杈圭紭鍦板甫, 閭d箞灏辨妸浠栬创鍒扮埗瀹瑰櫒涓 + XLayoutContainer parent = container.findNearestFit(); + container = parent != null ? parent : container; + isAdd2ParentLayout = true; + + int componentHeight = comp.getHeight(); + int componentWidth = comp.getWidth(); + //涓婂崐閮ㄥ垎楂樺害 + int upHeight = (int) (componentHeight * TOP_HALF) + comp.getY(); + //涓嬪崐閮ㄥ垎楂樺害 + int downHeight = (int) (componentHeight * BOTTOM_HALF) + comp.getY(); + + if (isCrossPointArea(comp, x, y)) { + return canAcceptWhileCrossPoint(comp, x, y); + } + + if (isTrisectionArea(comp, x, y)) { + return canAcceptWhileTrisection(comp, x, y); + } + + boolean horizonValid = componentWidth >= minWidth * 2 + actualVal; + boolean verticalValid = componentHeight >= minHeight * 2 + actualVal; + return y > upHeight && y < downHeight ? horizonValid : verticalValid; + } + + /** + * 缁勪欢鐨凜omponentAdapter鍦ㄦ坊鍔犵粍浠舵椂锛屽鏋滃彂鐜板竷灞绠$悊鍣ㄤ笉涓虹┖锛屼細缁ц岃皟鐢ㄨ甯冨眬绠$悊鍣ㄧ殑 + * addComp鏂规硶鏉ュ畬鎴愮粍浠剁殑鍏蜂綋娣诲姞銆傚湪璇ユ柟娉曞唴锛屽竷灞绠$悊鍣ㄥ彲浠ユ彁渚涢澶栫殑鍔熻兘銆 + * + * @param creator 琚坊鍔犵殑鏂扮粍浠 + * @param x 娣诲姞鐨勪綅缃畑锛岃浣嶇疆鏄浉瀵逛簬container鐨 + * @param y 娣诲姞鐨勪綅缃畒锛岃浣嶇疆鏄浉瀵逛簬container鐨 + * @return 鏄惁娣诲姞鎴愬姛锛屾垚鍔熻繑鍥瀟rue锛屽惁鍒檉alse + */ + @Override + public boolean addBean(XCreator creator, int x, int y) { + Rectangle rect = ComponentUtils.getRelativeBounds(container); + + int posX = x + rect.x; + int posY = y + rect.y; + if (!accept(creator, x, y)) { + return false; + } + addComp(creator, posX, posY); + ((XWidgetCreator) creator).recalculateChildrenSize(); + return true; + } + + @Override protected void addComp(XCreator creator, int x, int y) { - if (XCreatorUtils.getParentXLayoutContainer(creator) != null) { + if(!isAdd2ParentLayout) { Rectangle r = ComponentUtils.getRelativeBounds(container); - Rectangle creatorRectangle = ComponentUtils.getRelativeBounds(creator); - x = creatorRectangle.x - r.x; - y = creatorRectangle.y - r.y; - } else { - int w = creator.getWidth() / 2; - int h = creator.getHeight() / 2; - x = x - w; - y = y - h; - } + x = x - r.x; + y = y - r.y; + if (XCreatorUtils.getParentXLayoutContainer(creator) != null) { - fix(creator, x, y); + Rectangle creatorRectangle = ComponentUtils.getRelativeBounds(creator); + x = creatorRectangle.x - r.x; + y = creatorRectangle.y - r.y; + } else { + int w = creator.getWidth() / 2; + int h = creator.getHeight() / 2; + x = x - w; + y = y - h; + } + fix(creator, x, y); - if (creator.shouldScaleCreator() || creator.hasTitleStyle()) { - addParentCreator(creator); - } else { - container.add(creator, creator.toData().getWidgetName()); + if (creator.hasTitleStyle()) { + addParentCreator(creator); + } else { + container.add(creator, creator.toData().getWidgetName()); + } + XWAbsoluteLayout layout = (XWAbsoluteLayout) container; + layout.updateBoundsWidget(creator); + LayoutUtils.layoutRootContainer(container); + }else{ + fixAbsolute(creator, x, y); + if (creator.shouldScaleCreator() || creator.hasTitleStyle()) { + addParentCreator(creator); + } else { + container.add(creator, creator.toData().getWidgetName()); + } + XWFitLayout layout = (XWFitLayout) container; + // 鏇存柊瀵瑰簲鐨凚oundsWidget + layout.updateBoundsWidget(); + updateCreatorBackBound(); + } + } + + private void updateCreatorBackBound() { + for (int i=0,size=container.getComponentCount(); i rightComps; + protected java.util.List leftComps; + protected java.util.List downComps; + protected java.util.List upComps; + // 涓夌瓑鍒嗘椂璁$畻瀵瑰簲渚х殑缁勪欢 + protected boolean isFindRelatedComps = false; + // 娓叉煋鏃跺彧璁$畻瀵瑰簲鐨刡ounds鑰屼笉璋冩暣 + private boolean isCalculateChildPos = false; + private int[] childPosition = null; //painter鐢ㄧ殑浣嶇疆 + protected int minWidth = 0; // 鏈灏忓昂瀵革紝鐢变簬灞忓箷鐧惧垎姣旈噷涓嶅悓锛屾樉绀虹殑鏈灏忓ぇ灏忎篃涓嶅悓 + protected int minHeight = 0; + protected int actualVal = 0; // 瀛樺湪闂撮殧鏃讹紝add move drag 鍒ゆ柇瀵归綈绛夐兘瑕佽冭檻 + protected PaddingMargin margin; // 甯冨眬瀹瑰櫒杈硅窛 + /** + * 鍦ㄦ坊鍔犵粍浠剁姸鎬佹椂锛屽綋榧犳爣绉诲姩鍒版煇涓鍣ㄤ笂鏂规椂锛屽鏋滆瀹瑰櫒鏈夊竷灞绠$悊鍣紝鍒欎細璋冪敤璇ュ竷灞 + * 绠$悊閫傞厤鍣ㄧ殑accept鏉ュ喅瀹氬綋鍓嶄綅缃槸鍚﹀彲浠ユ斁缃紝骞舵彁渚涚壒娈婄殑鏍囪瘑锛屾瘮濡傜孩鑹插尯鍩熸爣璇嗐傛瘮 + * 濡傚湪BorderLayout涓紝濡傛灉鏌愪釜鏂逛綅宸茬粡鏀剧疆浜嗙粍浠讹紝鍒欐鏃跺簲璇ヨ繑鍥瀎alse鏍囪瘑璇ュ尯鍩熶笉鍙互 + * 鏀剧疆銆 + * + * @param creator 缁勪欢 + * @param x 娣诲姞鐨勪綅缃畑锛岃浣嶇疆鏄浉瀵逛簬container鐨 + * @param y 娣诲姞鐨勪綅缃畒锛岃浣嶇疆鏄浉瀵逛簬container鐨 + * @return 鏄惁鍙互鏀剧疆 + */ + @Override + public boolean accept(XCreator creator, int x, int y) { + return false; + } + + @Override + protected void addComp(XCreator creator, int x, int y) { + + } + + public FRBodyLayoutAdapter(XLayoutContainer container) { + super(container); + } + + /** + * 浜ゅ弶鐐瑰尯鍩熸椂锛岃兘鍚﹀搴斾綅缃斁鍏ョ粍浠 + * @param comp 寰呮斁缃粍浠 + * @param x x + * @param y y + * @return 鑳藉惁鏀惧叆 + */ + protected boolean canAcceptWhileCrossPoint(Component comp, int x, int y) { + int cX = comp.getX(), cY = comp.getY(), cH = comp.getHeight(), cW = comp.getWidth(); + Component topComp = container.getTopComp(cX, cY); + Component bottomComp = container.getBottomComp(cX, cY, cH); + Component rightComp = container.getRightComp(cX, cY, cW); + Component leftComp = container.getLeftComp(cX, cY); + int minLength = 0, min = minHeight * 2; + boolean isNotDefaultArea = false; + if (ComparatorUtils.equals(crossPointAreaDirect, COMP_LEFT_TOP)) { + isNotDefaultArea = (topComp == null) || (topComp.getX() != cX); + minLength = isNotDefaultArea ? Math.min(cH, leftComp.getHeight()) : Math.min(cW, topComp.getWidth()); + min = isNotDefaultArea ? min : minWidth * 2; + } else if (ComparatorUtils.equals(crossPointAreaDirect, COMP_RIGHT_BOTTOM)) { + bottomComp = container.getRightBottomComp(cX, cY, cH, cW); + isNotDefaultArea = (bottomComp == null) || (bottomComp.getX()+bottomComp.getWidth() != cX + cW) ; + rightComp = container.getBottomRightComp(cX, cY, cH, cW); + minLength = isNotDefaultArea ? Math.min(cH, rightComp.getHeight()) : Math.min(cW, bottomComp.getWidth()); + min = isNotDefaultArea ? min : minWidth * 2; + } else if (ComparatorUtils.equals(crossPointAreaDirect, COMP_LEFT_BOTTOM)) { + leftComp = container.getBottomLeftComp(cX, cY, cH); + isNotDefaultArea = (leftComp == null) || (leftComp.getY() + leftComp.getHeight() != cY + cH); + minLength = isNotDefaultArea ? Math.min(cW, bottomComp.getWidth()) : Math.min(cH, leftComp.getHeight()); + min = isNotDefaultArea ? minWidth * 2 : min; + } else if (ComparatorUtils.equals(crossPointAreaDirect, COMP_RIGHT_TOP)) { + isNotDefaultArea = (rightComp == null) || (rightComp.getY() != cY) ; + topComp = container.getRightTopComp(cX, cY, cW); + minLength = isNotDefaultArea ? Math.min(cW, topComp.getWidth()) : Math.min(cH, rightComp.getWidth()); + min = isNotDefaultArea ? minWidth * 2 : min ; + } else if (ComparatorUtils.equals(crossPointAreaDirect, COMP_TOP)) { + minLength= Math.min(rightComp.getHeight(), Math.min(cH, leftComp.getHeight())); + } else if (ComparatorUtils.equals(crossPointAreaDirect, COMP_BOTTOM)) { + leftComp = container.getBottomLeftComp(cX, cY, cH); + rightComp = container.getBottomRightComp(cX, cY, cH, cW); + minLength = Math.min(rightComp.getHeight(), Math.min(cH, leftComp.getHeight())); + } else { + if (ComparatorUtils.equals(crossPointAreaDirect, COMP_RIGHT)) { + topComp = container.getRightTopComp(cX, cY, cW); + bottomComp = container.getRightBottomComp(cX, cY, cH, cW); + } + minLength = Math.min(topComp.getWidth(), Math.min(cW, bottomComp.getWidth())); + min = minWidth * 2; + } + // 鏈夐棿闅旂殑璇濓紝瑕佽冭檻瀹圭撼闂撮殧 + return minLength >= min + actualVal; + } + + /** + * 涓夌瓑鍒嗗尯鍩熸椂锛岃兘鍚﹀搴斾綅缃斁鍏ョ粍浠 + * @param comp 寰呮斁缃粍浠 + * @param x x + * @param y y + * @return 鑳藉惁鏀惧叆 + */ + protected boolean canAcceptWhileTrisection(Component comp, int x, int y) { + //绗﹀悎涓夌瓑鍒嗭紝瀹為檯鍖哄煙涓嶆弧瓒充笁绛夊垎鐨勫ぇ灏 + int cX = comp.getX(), cY = comp.getY(), cH = comp.getHeight(), cW = comp.getWidth(); + int upMinHeight = 0, downMinHeight = 0, leftMinWidth = 0, rightMinWidth = 0; + if (ComparatorUtils.equals(trisectAreaDirect, COMP_TOP)) { + upMinHeight = getUpMinHeightComp(cY, x); + downMinHeight = getDownMinHeightComp(comp, y); + return upMinHeight == 0 ? downMinHeight >= minHeight * 2 + actualVal : (upMinHeight + downMinHeight) >= minHeight * 3 + actualVal; + } else if(ComparatorUtils.equals(trisectAreaDirect, COMP_BOTTOM)) { + upMinHeight = getUpMinHeightComp(cY + cH + actualVal, x); + if (cY + cH + DEFAULT_AREA_LENGTH>container.getHeight() - margin.getBottom()){ + downMinHeight = 0; + } else { + Component targetComp = container.getBottomComp(x, cY, cH); + downMinHeight = getDownMinHeightComp(targetComp, cY + cH + DEFAULT_AREA_LENGTH + actualVal); + } + return downMinHeight == 0 ? (upMinHeight >= minHeight * 2 + actualVal) : ((upMinHeight+downMinHeight) >= minHeight * 3 + actualVal); + } else if(ComparatorUtils.equals(trisectAreaDirect, COMP_LEFT)) { + rightMinWidth = getMinRightWidth(cX, 0, y); + if(cX - DEFAULT_AREA_LENGTH < margin.getLeft()) { + leftMinWidth = 0; + } else { + Component targetRightComp = container.getLeftComp(cX, y); + leftMinWidth = getMinLeftWidth(targetRightComp, cX - DEFAULT_AREA_LENGTH - actualVal); + } + return leftMinWidth == 0 ? (rightMinWidth >= minWidth * 2 + actualVal) : ((leftMinWidth+rightMinWidth) >= minWidth * 3 + actualVal); + } else if(ComparatorUtils.equals(trisectAreaDirect, COMP_RIGHT)) { + leftMinWidth = getMinLeftWidth(comp, x); + rightMinWidth = getMinRightWidth(cX, cW, y); + return rightMinWidth == 0 ? (leftMinWidth >= minWidth * 2 + actualVal) : ((leftMinWidth+rightMinWidth) >= minWidth * 3 + actualVal); + } + return false; + } + + /** + * 杩斿洖褰撳墠缁勪欢鎵鍦▂鍊间笂鏂圭殑鎵鏈夌粍浠朵腑鏈灏忛珮搴︼紝涓斾繚璇佽繖浜涙帶浠舵槸鐩搁偦涓嶉殧鏂殑 + * 鍒ゆ柇瀵归綈鏃惰冭檻闂撮殧 + */ + private int getUpMinHeightComp(int cY, int x) { + if (cY == margin.getTop()) { + return 0; + } + int max=container.getWidth() - margin.getRight(); + int mouseX = x; + int minHeight = cY; + int bott = 0; + if (isFindRelatedComps) { + upComps = new ArrayList(); + } + for(; mouseX margin.getLeft()) { + Component comp = container.getTopComp(mouseX, cY); + bott = comp.getHeight() + comp.getY()+actualVal; + if (bott == cY) { + if (comp.getHeight() < minHeight) { + minHeight = comp.getHeight(); + } + mouseX = comp.getX()-DEFAULT_AREA_LENGTH-actualVal; + if (isFindRelatedComps) { + upComps.add(comp); + } + } else{ + break; + } + } + return minHeight; + } + + /** + * 杩斿洖鍜屽綋鍓嶇粍浠剁浉鍚寉鍧愭爣鐨勬墍鏈夌粍浠朵腑鏈灏忛珮搴︼紝涓斾繚璇佽繖浜涙帶浠舵槸鐩搁偦涓嶉殧鏂殑 + * 鍒ゆ柇瀵归綈鏃惰冭檻闂撮殧 + */ + private int getDownMinHeightComp(Component currentcomp, int y) { + int cX = currentcomp.getX(); + int cY = currentcomp.getY(); + int minHeight = currentcomp.getHeight(); + int max=container.getWidth() - margin.getRight(); + if (isFindRelatedComps) { + downComps = new ArrayList(); + } + int mouseX = cX + DEFAULT_AREA_LENGTH; + while (mouseX < max) { + Component comp = container.getComponentAt(mouseX, y); + if (comp.getY() == cY) { + if (comp.getHeight() < minHeight) { + minHeight = comp.getHeight(); + } + mouseX = comp.getX() + comp.getWidth() + DEFAULT_AREA_LENGTH + actualVal; + if (isFindRelatedComps) { + downComps.add(comp); + } + }else{ + break; + } + } + mouseX = cX - DEFAULT_AREA_LENGTH - actualVal; + while(mouseX > margin.getLeft()) { + Component comp = container.getComponentAt(mouseX, y); + if (comp.getY() == cY) { + if (comp.getHeight() < minHeight) { + minHeight = comp.getHeight(); + } + mouseX = comp.getX() - DEFAULT_AREA_LENGTH - actualVal; + if (isFindRelatedComps) { + downComps.add(comp); + } + }else{ + break; + } + } + return minHeight; + } + + /** + * 杩斿洖褰撳墠缁勪欢鍙充晶鐩稿悓x鐨勬墍鏈夌粍浠朵腑鏈灏忓搴︼紝涓斾繚璇佽繖浜涙帶浠舵槸鐩搁偦涓嶉殧鏂殑 + * 鍒ゆ柇瀵归綈鏃惰冭檻闂撮殧 + */ + private int getMinRightWidth(int cX, int cW, int y) { + int xL = cX + DEFAULT_AREA_LENGTH ; + xL = cW == 0 ? xL : (xL + cW + actualVal); + if (xL > container.getWidth() - margin.getRight()){ + return 0; + } + // 浠ュ綋鍓嶇粍浠剁揣鎸ㄧ潃鍙充晶鐨勭粍浠朵负鍩哄噯锛屽湪y杞存柟鍚戞煡鎵剧鍚堟潯浠剁殑缁勪欢 + Component targetComp = container.getComponentAt(xL, y); + int minWidth = targetComp.getWidth(); + int max = container.getHeight() - margin.getBottom(); + if (isFindRelatedComps) { + rightComps = new ArrayList(); + } + int mouseY = targetComp.getY() + DEFAULT_AREA_LENGTH; + while (mouseY margin.getTop()) { + Component comp = container.getComponentAt(xL, mouseY); + if (comp.getX() == targetComp.getX()) { + if (comp.getWidth() < minWidth) { + minWidth = comp.getWidth(); + } + mouseY = comp.getY() - DEFAULT_AREA_LENGTH - actualVal; + if (isFindRelatedComps) { + rightComps.add(comp); + } + }else{ + break; + } + } + return minWidth; + } + + /** + * 杩斿洖褰撳墠缁勪欢鍨傜洿鏂瑰悜鍚屼晶鐨勭粍浠(缁勪欢鍙宠竟鐣岀浉杩)涓渶灏忓搴 + * 鍒ゆ柇瀵归綈鏃惰冭檻闂撮殧 + */ + private int getMinLeftWidth(Component currentComp, int x) { + int minWidth = currentComp.getWidth(); + int compRightLength = currentComp.getX() + currentComp.getWidth(); + int max = container.getHeight() - margin.getBottom(); + if (isFindRelatedComps) { + leftComps = new ArrayList(); + } + int rightx = 0; + int mouseY = currentComp.getY() + DEFAULT_AREA_LENGTH; + while(mouseYmargin.getTop()) { + Component comp = container.getComponentAt(x, mouseY); + rightx = comp.getX()+comp.getWidth(); + if (rightx == compRightLength) { + if (comp.getWidth() < minWidth) { + minWidth = comp.getWidth(); + } + mouseY = comp.getY() - DEFAULT_AREA_LENGTH - actualVal; + if (isFindRelatedComps) { + leftComps.add(comp); + } + }else{ + break; + } + } + return minWidth; + } + + /** + * 鍒ゆ柇鏄惁榧犳爣鍦ㄧ粍浠剁殑涓夌瓑鍒嗗尯鍩燂紝濡傛灉缁勪欢鍦ㄥ竷灞绠$悊鍣ㄤ腑闂达紝涓婁笅宸﹀彸閮藉彲鑳戒細涓夌瓑鍒 + * @param parentComp 榧犳爣鎵鍦ㄥ尯鍩熺殑缁勪欢 + * @param x 鍧愭爣x + * @param y 鍧愭爣y + * @return 鏄垯杩斿洖true + */ + public boolean isTrisectionArea(Component parentComp, int x, int y) { + XCreator creator = (XCreator)parentComp; + if (container.getComponentCount() <= 1) { + return false; + } + int maxWidth = parentComp.getWidth(); + int maxHeight = parentComp.getHeight(); + int xL = parentComp.getX(); + int yL = parentComp.getY(); + // 缁勪欢瀹介珮鐨勫崄鍒嗕箣涓鍜岄粯璁ゅ煎彇澶 + int minRangeWidth = Math.max(maxWidth/BORDER_PROPORTION, DEFAULT_AREA_LENGTH); + int minRangeHeight = Math.max(maxHeight/BORDER_PROPORTION, DEFAULT_AREA_LENGTH); + if(y < yL+minRangeHeight ) { + // 鍦ㄧ粍浠朵笂渚т笁绛夊垎 + trisectAreaDirect = COMP_TOP; + } else if(y > yL + maxHeight - minRangeHeight) { + // 鍦ㄧ粍浠朵笅渚т笁绛夊垎 + trisectAreaDirect = COMP_BOTTOM; + } else if (x < xL + minRangeWidth) { + // 鍦ㄧ粍浠跺乏渚т笁绛夊垎 + trisectAreaDirect = COMP_LEFT; + } else if(x > xL + maxWidth - minRangeWidth) { + // 鍦ㄧ粍浠跺彸渚т笁绛夊垎 + trisectAreaDirect = COMP_RIGHT; + } + // tab甯冨眬鐨勮竟鐣岀壒娈婂鐞嗭紝涓嶈繘琛屼笁绛夊垎 + if(!creator.getTargetChildrenList().isEmpty()){ + return false; + } + + return !ComparatorUtils.equals(trisectAreaDirect, 0); + } + + /** + * 鏄惁涓虹粍浠朵氦鍙夌偣鍖哄煙 鎴栬呮槸鐩搁偦涓夌粍寤轰腑闂寸偣 + * @param currentComp 褰撳墠缁勪欢 + * @param x 鍧愭爣x + * @param y 鍧愭爣y + * @return 鏄垯杩斿洖true + */ + public boolean isCrossPointArea(Component currentComp, int x, int y) { + // 3涓強浠ヤ笂閮戒細鍑虹幇浜ゅ弶鐐瑰尯鍩燂紙鍖呮嫭杈圭晫澶勭殑锛 + if(currentComp == null || container.getComponentCount() <= 2){ + return false; + } + int cX = currentComp.getX(); + int cY = currentComp.getY(); + int cW = currentComp.getWidth(); + int cH = currentComp.getHeight(); + int areaWidth = Math.max(cW / BORDER_PROPORTION ,DEFAULT_AREA_LENGTH); + int areaHeight = Math.max(cH / BORDER_PROPORTION, DEFAULT_AREA_LENGTH); + int rx = cX + cW; + int by = cY + cH; + int objX = cX + areaWidth; + int objY = cY + areaHeight; + int containerW = container.getWidth() - margin.getRight(); + int containerH = container.getHeight() - margin.getBottom(); + if (x < objX && y < objY) { + //宸︿笂瑙掑尯鍩 + crossPointAreaDirect = cY > margin.getTop() || cX > margin.getLeft() ? COMP_LEFT_TOP : 0; + } else if (y < objY && x > rx - areaWidth){ + //鍙充笂瑙 + crossPointAreaDirect = cY > margin.getTop() || rx < containerW ? COMP_RIGHT_TOP : 0; + } else if (x < objX && y > by - areaHeight) { + //宸︿笅瑙 + crossPointAreaDirect = cX > margin.getLeft() || by < containerH ? COMP_LEFT_BOTTOM : 0; + } else if (x > rx-areaWidth && y > by - areaHeight) { + //鍙充笅瑙 + crossPointAreaDirect = by < containerH || rx < containerW ? COMP_RIGHT_BOTTOM : 0; + } else { + isMiddlePosition(currentComp, x, y, areaWidth, areaHeight); + } + // tab甯冨眬鐨勮竟鐣岀壒娈婂鐞 + XCreator creator = (XCreator)currentComp; + if(!creator.getTargetChildrenList().isEmpty()){ + return false; + } + return crossPointAreaDirect != 0; + } + + private void isMiddlePosition(Component comp, int x, int y, int areaWidth , int areaHeight) { + int cX = comp.getX(); + int cY = comp.getY(); + int cW = comp.getWidth(); + int cH = comp.getHeight(); + boolean isCrosspoint = false; + if (x > (cX + cW / 2 - areaWidth) && x < (cX + cW / 2 + areaWidth)) { + // 涓婁笅杈规绾夸腑闂翠綅缃 + Component leftComp = container.getLeftComp(cX, cY); + Component rightComp = container.getRightComp(cX, cY, cW); + if (y < cY + areaHeight) { + isCrosspoint = leftComp != null && rightComp != null && leftComp.getY() == cY && rightComp.getY() == cY; + crossPointAreaDirect = isCrosspoint ? COMP_TOP : 0; + } else if (y > cY + cH - areaHeight) { + leftComp = container.getBottomLeftComp(cX, cY, cH); + rightComp = container.getBottomRightComp(cX, cY, cH, cW); + if (leftComp != null && rightComp != null) { + isCrosspoint = leftComp.getY() + leftComp.getHeight() == cY + cH && rightComp.getY() + rightComp.getHeight() == cY + cH; + } + crossPointAreaDirect = isCrosspoint ? COMP_BOTTOM : 0; + } + } else if (y > (cY + cH / 2 - areaHeight) && y < (cY + cH / 2 + areaHeight)) { + // 宸﹀彸杈规绾夸腑闂翠綅缃 + Component topComp = container.getTopComp(cX, cY); + Component bottomComp = container.getBottomComp(cX, cY, cH); + if (x < (cX + areaWidth)) { + isCrosspoint = topComp != null && bottomComp != null && topComp.getX() == cX && bottomComp.getX() == cX; + crossPointAreaDirect = isCrosspoint ? COMP_LEFT : 0; + } else if (x > (cX + cW - areaWidth)) { + topComp = container.getRightTopComp(cX, cY, cW); + bottomComp = container.getRightBottomComp(cX, cY, cH, cW); + if (topComp != null && bottomComp != null) { + isCrosspoint = topComp.getX() + topComp.getWidth() == cX + cW && bottomComp.getX() + bottomComp.getWidth() == cX+cW; + } + crossPointAreaDirect = isCrosspoint ? COMP_RIGHT : 0; + } + } + } + + /** + * 鍒濆鍖栧懆杈圭粍浠跺垪琛 + */ + protected void initCompsList() { + rightComps = new ArrayList(); + leftComps = new ArrayList(); + upComps = new ArrayList(); + downComps = new ArrayList(); + } + + /** + * 娓呴櫎鍛ㄨ竟缁勪欢鍒楄〃 + */ + protected void clearCompsList() { + rightComps = null; + leftComps = null; + upComps = null; + downComps = null; + } + + /** + * 骞冲垎锛屾甯告儏鍐垫嫋鍏ョ粍浠舵椂锛屾寜鐓т笂1/4鍖哄煙銆佷笅1/4鍖哄煙涓轰笂涓嬪钩鍒嗭紝涓乏渚1/2鍖哄煙銆佷腑鍙充晶1/2鍖哄煙涓哄乏鍙冲钩鍒 + * @param currentComp 褰撳墠浣嶇疆缁勪欢 + * @param child 寰呮斁缃粍浠 + * @param x x + * @param y y + */ + protected void fixHalve(Component currentComp, XCreator child, int x, int y) { + XCreator creator = (XCreator)currentComp; + if(!creator.getTargetChildrenList().isEmpty()){ + fixHalveOfTab(creator,child,x,y); + return; + } + int maxWidth = currentComp.getWidth(); + int maxHeight = currentComp.getHeight(); + int xL = currentComp.getX(); + int yL = currentComp.getY(); + Dimension dim = new Dimension(); + boolean isDividUp = y - yL <= maxHeight * TOP_HALF; + boolean isDividDown = y - yL >= maxHeight * BOTTOM_HALF; + boolean isDividLeft = x - xL < maxWidth / 2; + int finalX = xL; + int finalY = yL; + int finalW = maxWidth; + int finalH = maxHeight; + if (isDividUp){ + dim.width = maxWidth; + dim.height = maxHeight / 2 - actualVal / 2; + finalY = yL + dim.height + actualVal; + finalH = maxHeight - dim.height - actualVal; + } else if(isDividDown){ + // 鑻ュ綋鍓嶅尯鍩熼珮搴﹂潪鍋舵暟锛岄偅涔堝拰isDividUp鏃惰绠椾竴鑷达紝鍚﹀垯姘歌繙閮芥槸涓婂崐閮ㄥ垎灏1px + dim.height = maxHeight / 2 - actualVal / 2; + dim.width = maxWidth; + finalH = maxHeight - dim.height - actualVal; + yL = yL + finalH + actualVal; + } else if(isDividLeft){ + dim.width = maxWidth / 2 - actualVal / 2; + dim.height = maxHeight; + finalX = xL + dim.width + actualVal; + finalW = maxWidth - dim.width - actualVal; + } else { + finalW = maxWidth / 2 - actualVal / 2; + xL = xL + finalW + actualVal; + dim.width = maxWidth - finalW - actualVal; + dim.height = maxHeight; + } + if (isCalculateChildPos) { + childPosition = new int[]{xL, yL, dim.width, dim.height}; + } else { + currentComp.setLocation(finalX, finalY); + currentComp.setSize(finalW, finalH); + child.setLocation(xL, yL); + child.setSize(dim); + } + } + + // 杈圭晫鍒ゆ柇鎶勫緱鍘熸潵鐨勯昏緫 + // tab甯冨眬鐨勮竟鐣屾嫋鍏ユ柊缁勪欢锛屽拰褰撳墠tab甯冨眬骞冲垎锛岃繖鏃跺欑殑actualVal缁勫缓闂撮殧鏄痶ab閲岄潰鐨勭粍寤洪棿闅 + // 涓嶅簲璇ュ湪澶栧眰鑷傚簲甯冨眬娣诲姞 + private void fixHalveOfTab(XCreator currentCreator, XCreator child, int x, int y){ + int maxWidth = currentCreator.getWidth(); + int maxHeight = currentCreator.getHeight(); + int xL = currentCreator.getX(); + int yL = currentCreator.getY(); + Dimension dim = new Dimension(); + int position = getPositionOfFix(currentCreator, x, y); + int finalX = xL; + int finalY = yL; + int finalW = maxWidth; + int finalH = maxHeight; + switch(position){ + case COMP_TOP: + dim.width = maxWidth; + dim.height = maxHeight / 2; + finalY = yL + dim.height; + finalH = maxHeight - dim.height; + break; + case COMP_BOTTOM: + dim.height = maxHeight / 2; + dim.width = maxWidth; + finalH = maxHeight-dim.height; + yL = yL + finalH; + break; + case COMP_LEFT: + dim.width = maxWidth / 2; + dim.height = maxHeight; + finalX = xL + dim.width; + finalW = maxWidth - dim.width; + break; + default: + finalW = maxWidth / 2; + xL = xL + finalW; + dim.width = maxWidth - finalW; + dim.height = maxHeight; + } + if (isCalculateChildPos) { + childPosition = new int[]{xL, yL, dim.width, dim.height}; + } else { + currentCreator.setLocation(finalX, finalY); + currentCreator.setSize(finalW, finalH); + currentCreator.recalculateChildWidth(finalW); + currentCreator.recalculateChildHeight(finalH); + child.setLocation(xL, yL); + child.setSize(dim); + } + } + + private int getPositionOfFix(XCreator currentCreator,int x,int y){ + int position = 0; + XLayoutContainer cardLayout = ((XWCardMainBorderLayout) currentCreator).getCardPart(); + XLayoutContainer container = (XLayoutContainer) cardLayout.getComponent(0); + Rectangle rect = ComponentUtils.getRelativeBounds(container); + int tempX = x - rect.x; + int tempY = y - rect.y + WCardMainBorderLayout.TAB_HEIGHT; + int containerX = container.getX(); + int containerY = container.getY(); + int containerWidth = container.getWidth(); + int containerHeight = container.getHeight(); + // 褰撳墠鍧愭爣鐐 + Rectangle currentXY = new Rectangle(tempX, tempY, 1, 1); + // 涓婅竟缂 + Rectangle upEdge = new Rectangle(containerX, containerY, containerWidth, BORDER_PROPORTION); + if(upEdge.intersects(currentXY)){ + position = COMP_TOP; + } + int bottomY = containerY + containerHeight - BORDER_PROPORTION; + // 涓嬭竟缂 + Rectangle bottomEdge = new Rectangle(containerX, bottomY, containerWidth, BORDER_PROPORTION); + if(bottomEdge.intersects(currentXY)){ + position = COMP_BOTTOM; + } + //宸﹀彸杈圭紭鐨勯珮搴 -10*2 鏄负浜嗕笉鍜屼笂涓嬭竟缂橀噸鍚 + int verticalHeight = containerHeight - BORDER_PROPORTION * 2; + int leftY = containerY + BORDER_PROPORTION; + // 宸﹁竟缂 + Rectangle leftEdge = new Rectangle(containerX, leftY, BORDER_PROPORTION, verticalHeight); + if(leftEdge.intersects(currentXY)){ + position = COMP_LEFT; + } + return position; + } + + /** + * 缁勪欢浜ゅ弶鍖哄煙杩涜鎻掑叆鏃讹紝璋冩暣鍙楀埌鍙樺姩鐨勫叾浠栫粍浠,涔嬪墠鏄氦鍙夊尯鍩熸彃鍏ヤ篃鎸夌収涓夌瓑鍒嗛昏緫锛屽悗闈㈡祴璇曚腑鍙戠幇鏈塨ug锛屾敼涓哄拰bi涓鏍风殑榧犳爣鎵鍦ㄤ晶骞冲垎 + * 榛樿宸︿笂瑙掋佸彸涓嬭鍖哄煙鏄瀭鐩存柟鍚戞彃鍏ョ粍浠 + * 鍙充笂瑙掑拰宸︿笅瑙掓槸姘村钩鏂瑰悜鎻掑叆缁勪欢锛岃繖鏍烽伩鍏嶇敯瀛楀潡鏃堕噸澶 + * @param currentComp 褰撳墠浣嶇疆缁勪欢 + * @param child 寰呮斁缃粍浠 + * @param x x + * @param y y + */ + protected void fixCrossPointArea(Component currentComp, XCreator child, int x, int y) { + //璁$畻鍓嶅厛鍏ㄩ儴鍒濆鍖栧緟璋冩暣鎺т欢鎵鍦ㄧ殑list + initCompsList(); + switch(crossPointAreaDirect) { + case COMP_LEFT_TOP : + dealCrossPointAtLeftTop(currentComp, child); + break; + case COMP_RIGHT_BOTTOM : + dealCrossPointAtRightBottom(currentComp, child); + break; + case COMP_LEFT_BOTTOM : + dealCrossPointAtLeftBottom(currentComp, child); + break; + case COMP_RIGHT_TOP : + dealCrossPointAtRightTop(currentComp, child); + break; + case COMP_TOP : + dealCrossPointAtTop(currentComp, child); + break; + case COMP_BOTTOM : + dealCrossPointAtBottom(currentComp, child); + break; + case COMP_LEFT : + dealCrossPointAtLeft(currentComp, child); + break; + case COMP_RIGHT : + dealCrossPointAtRight(currentComp, child); + break; + } + crossPointAreaDirect = 0; + clearCompsList(); + } + + /** + * 宸︿笂浜ゅ弶鍖哄煙鎻掑叆缁勪欢锛岄粯璁ゅ瀭鐩存柟鍚戞彃鍏 + */ + private void dealCrossPointAtLeftTop(Component currentComp, XCreator child) { + int minDH = 0, minRW = 0, childw = 0, childh = 0; + int cX = currentComp.getX(); + int cY = currentComp.getY(); + int cH = currentComp.getHeight(); + int cW = currentComp.getWidth(); + Component topComp = container.getTopComp(cX, cY); + Component leftComp = container.getLeftComp(cX, cY); + //涓婃柟娌℃湁缁勪欢鎴栬呮湁涓涓獂鍧愭爣涓嶇浉鍚岀殑缁勪欢 + if (topComp==null || topComp.getX()!=cX) { + minDH = cH < leftComp.getHeight() ? cH : leftComp.getHeight(); + downComps.add(leftComp); + downComps.add(currentComp); + int dLength = minDH / 2; + childw = leftComp.getWidth()+cW+actualVal; + childh = dLength-actualVal / 2; + if (isCalculateChildPos) { + childPosition = new int[]{leftComp.getX(), leftComp.getY(), childw, childh}; + } else{ + //鍏堣缃甤hild浣嶇疆锛屼笉鐒秎eftComp鍧愭爣璋冩暣鍚庡氨涓嶅浜 + child.setLocation(leftComp.getX(), leftComp.getY()); + child.setSize(childw, childh); + calculateBottomComps(dLength); + } + } else { + rightComps.add(currentComp); + rightComps.add(topComp); + minRW = cW margin.getLeft()) { + Component targetRightComp = container.getLeftComp(cX, y); + minLeftW = getMinLeftWidth(targetRightComp, cX-DEFAULT_AREA_LENGTH); + } + dealTrisectAtRight(child, minLeftW, minRightW); + } + crossPointAreaDirect = 0; + clearCompsList(); + } + + /** + * 褰撳墠缁勪欢涓婅竟鐣屽尯鍩熶笁绛夊垎 + */ + private void dealTrisectAtTop(XCreator child, int minUH, int minDH) { + // 涓夌瓑鍒嗘湁闂撮殧鏃讹紝瀹為檯鏄袱渚ч兘瑕佸噺鍘诲崐涓棿闅斿ぇ灏 + int averageH = (minUH+minDH - actualVal) / 3; + int dLength = 0; + int uLength = 0; + if (minDH==0) { + dLength = 0; + uLength = minUH / 2; + calculateTopComps(uLength, child, uLength); + return; + } else if(minUH == 0){ + dLength = minDH / 2; + int witdh = container.getWidth() - margin.getLeft() - margin.getRight(); + if (!isCalculateChildPos) { + calculateBottomComps(dLength); + child.setLocation(margin.getLeft(), margin.getRight()); + child.setSize(witdh, dLength - actualVal / 2); + } else { + childPosition = new int[] {margin.getLeft(), margin.getRight(), witdh, dLength - actualVal / 2}; + } + return; + } else if (minUH >= minDH) { + minDH -= actualVal / 2; + if ((minDH * 2 / 3) < minHeight) { + dLength = minDH - minHeight; + }else { + dLength = minDH / 3; + } + uLength = averageH - dLength; + } else{ + minUH -= actualVal / 2; + if ((minUH * 2 / 3) < minHeight) { + uLength = minUH - minHeight; + }else { + uLength = minUH / 3; + } + dLength = averageH - uLength; + } + if (!isCalculateChildPos) { + calculateBottomComps(dLength); + } + // 璁$畻涓や晶鏃讹紝閮介澶栧幓鎺夊崐涓棿闅旓紝3绛夊垎鍜屽钩鍒嗕氦鍙夌偣涓嶅悓锛屽彧鑳界壒娈婂鐞嗕笅 + averageH += actualVal / 2; + calculateTopComps(uLength, child, averageH); + } + + /** + * 褰撳墠缁勪欢鍙宠竟鐣屽尯鍩熶笁绛夊垎 + */ + private void dealTrisectAtRight(XCreator child, int minLW, int minRW) { + int averageW = (minLW + minRW - actualVal) / 3; + int leftLength = 0; + int rightLength = 0; + if (minLW == 0) { + rightLength = minRW / 2; + int height = container.getHeight() - margin.getBottom() - margin.getTop(); + if (!isCalculateChildPos) { + calculateRightComps(rightLength); + child.setLocation(margin.getLeft(), margin.getRight()); + child.setSize(rightLength - actualVal / 2, height); + } else { + childPosition = new int[] {margin.getLeft(), margin.getRight(), rightLength - actualVal / 2, height}; + } + return; + } else if(minRW == 0){ + leftLength = minLW / 2; + calculateLeftComps(leftLength, child, leftLength); + return; + } else if (minRW >= minLW) { + minLW -= actualVal / 2; + if(minLW * 2 / 3 < minWidth) { + leftLength = minLW - minWidth; + } else { + leftLength = minLW / 3; + } + rightLength = averageW - leftLength; + } else { + minRW -= actualVal / 2; + if(minRW * 2 / 3 < minWidth) { + rightLength = minRW - minWidth; + } else { + rightLength = minRW / 3; + } + leftLength = averageW - rightLength; + } + if (!isCalculateChildPos) { + calculateRightComps(rightLength); + } + // averageW 鏄凡缁忓幓闄ら棿闅斿悗鐨勫ぇ灏忥紝鎵浠ュ啀鍔犱笂鍗婁釜闂撮殧锛屽惁鍒欏鐞嗘椂浼氬彉灏 + averageW += actualVal / 2; + calculateLeftComps(leftLength, child, averageW); + } + + private void calculateBottomComps(int length) { + length += actualVal / 2; + for (int i = 0,num = downComps.size(); i < num; i++){ + Component comp = downComps.get(i); + comp.setLocation(comp.getX(), comp.getY() + length); + int offset = comp.getHeight() - length; + comp.setSize(comp.getWidth(), offset); + XCreator creator = (XCreator)comp; + creator.recalculateChildHeight(offset); + } + } + + private void calculateTopComps(int length, XCreator child, int averageH) { + length += actualVal / 2; + int childWidth = (upComps.size() - 1) * actualVal; + int childX = container.getWidth() - margin.getLeft() - margin.getRight(); + int childY = 0; + if(upComps.size() > INDEX_ZERO){ + childY = upComps.get(INDEX_ZERO).getY() + upComps.get(INDEX_ZERO).getHeight() - length; + } + for (int i = 0,num = upComps.size(); i < num; i++){ + Component comp = upComps.get(i); + childWidth += comp.getWidth(); + if (comp.getX() < childX){ + childX = comp.getX(); + } + if (!isCalculateChildPos) { + int offset = comp.getHeight() - length; + comp.setSize(comp.getWidth(), offset); + XCreator creator = (XCreator)comp; + creator.recalculateChildHeight(offset); + } + } + childY += actualVal; + averageH -= actualVal/2; + if (isCalculateChildPos) { + childPosition = new int[]{childX, childY, childWidth, averageH}; + } else { + child.setLocation(childX, childY); + child.setSize(childWidth, averageH); + } + } + + private void calculateLeftComps(int length, XCreator child, int averageW) { + length += actualVal / 2; + if (leftComps.isEmpty()) { + return; + } + int childH = (leftComps.size() - 1) * actualVal; + int childX = 0; + if(leftComps.size() > INDEX_ZERO){ + childX = leftComps.get(INDEX_ZERO).getX() + leftComps.get(INDEX_ZERO).getWidth() - length; + } + int childY = container.getHeight() - margin.getBottom(); + for (int i = 0,num = leftComps.size(); i < num; i++){ + Component comp = leftComps.get(i); + childH += comp.getHeight(); + if (comp.getY() < childY){ + childY = comp.getY(); + } + if (!isCalculateChildPos) { + int offset = comp.getWidth() - length; + comp.setSize(offset, comp.getHeight()); + XCreator creator = (XCreator)comp; + creator.recalculateChildWidth(offset); + } + } + childX += actualVal; + averageW -= actualVal/2; + if (isCalculateChildPos) { + childPosition = new int[]{childX, childY, averageW, childH}; + } else { + child.setLocation(childX, childY); + child.setSize(averageW, childH); + } + } + + private void calculateRightComps(int length) { + length += actualVal / 2; + for (int i=0,num=rightComps.size(); i rightComps; - private List leftComps; - private List downComps; - private List upComps; - // 涓夌瓑鍒嗘椂璁$畻瀵瑰簲渚х殑缁勪欢 - private boolean isFindRelatedComps = false; - // 娓叉煋鏃跺彧璁$畻瀵瑰簲鐨刡ounds鑰屼笉璋冩暣 - private boolean isCalculateChildPos = false; - private int[] childPosition = null; //painter鐢ㄧ殑浣嶇疆 private HoverPainter painter; - private int minWidth = 0; // 鏈灏忓昂瀵革紝鐢变簬灞忓箷鐧惧垎姣旈噷涓嶅悓锛屾樉绀虹殑鏈灏忓ぇ灏忎篃涓嶅悓 - private int minHeight = 0; - private int actualVal = 0; // 瀛樺湪闂撮殧鏃讹紝add move drag 鍒ゆ柇瀵归綈绛夐兘瑕佽冭檻 - private PaddingMargin margin; // 甯冨眬瀹瑰櫒杈硅窛 /** * 鏋勯犲嚱鏁 @@ -129,7 +95,7 @@ public class FRFitLayoutAdapter extends AbstractLayoutAdapter { updateCreatorBackBound(); } - private void updateCreatorBackBound() { + public void updateCreatorBackBound() { for (int i=0,size=container.getComponentCount(); i= min+actualVal; - } - - private boolean canAcceptWhileTrisection(Component comp, int x, int y) { - //绗﹀悎涓夌瓑鍒嗭紝瀹為檯鍖哄煙涓嶆弧瓒充笁绛夊垎鐨勫ぇ灏 - int cX = comp.getX(), cY = comp.getY(), cH = comp.getHeight(), cW = comp.getWidth(); - int upMinHeight = 0, downMinHeight = 0, leftMinWidth = 0, rightMinWidth = 0; - if (ComparatorUtils.equals(trisectAreaDirect, COMP_TOP)) { - upMinHeight = getUpMinHeightComp(cY, x); - downMinHeight = getDownMinHeightComp(comp, y); - return upMinHeight==0 ? downMinHeight>= minHeight*2+actualVal : (upMinHeight+downMinHeight)>= minHeight*3+actualVal; - } else if(ComparatorUtils.equals(trisectAreaDirect, COMP_BOTTOM)) { - upMinHeight = getUpMinHeightComp(cY+cH+actualVal, x); - if (cY+cH+DEFAULT_AREA_LENGTH>container.getHeight() - margin.getBottom()){ - downMinHeight = 0; - } else { - Component targetComp = container.getBottomComp(x, cY, cH); - downMinHeight = getDownMinHeightComp(targetComp, cY+cH+DEFAULT_AREA_LENGTH+actualVal); - } - return downMinHeight == 0 ? upMinHeight>= minHeight*2+actualVal : (upMinHeight+downMinHeight)>= minHeight*3+actualVal; - } else if(ComparatorUtils.equals(trisectAreaDirect, COMP_LEFT)) { - rightMinWidth = getMinRightWidth(cX, 0, y); - if(cX-DEFAULT_AREA_LENGTH < margin.getLeft()) { - leftMinWidth = 0; - } else { - Component targetRightComp = container.getLeftComp(cX, y); - leftMinWidth = getMinLeftWidth(targetRightComp, cX-DEFAULT_AREA_LENGTH - actualVal); - } - return leftMinWidth==0 ? rightMinWidth>=minWidth*2+actualVal : (leftMinWidth+rightMinWidth)>= minWidth*3+actualVal; - } else if(ComparatorUtils.equals(trisectAreaDirect, COMP_RIGHT)) { - leftMinWidth = getMinLeftWidth(comp, x); - rightMinWidth = getMinRightWidth(cX, cW, y); - return rightMinWidth==0 ? leftMinWidth>=minWidth*2+actualVal : (leftMinWidth+rightMinWidth)>= minWidth*3+actualVal; - } - return false; - } - - /** - * 杩斿洖褰撳墠缁勪欢鎵鍦▂鍊间笂鏂圭殑鎵鏈夌粍浠朵腑鏈灏忛珮搴︼紝涓斾繚璇佽繖浜涙帶浠舵槸鐩搁偦涓嶉殧鏂殑 - * 鍒ゆ柇瀵归綈鏃惰冭檻闂撮殧 - */ - private int getUpMinHeightComp(int cY, int x) { - if (cY == margin.getTop()) { - return 0; - } - int max=container.getWidth() - margin.getRight(); - int mouseX = x; - int minHeight = cY; - int bott = 0; - if (isFindRelatedComps) { - upComps = new ArrayList(); - } - for(; mouseX margin.getLeft()) { - Component comp = container.getTopComp(mouseX, cY); - bott = comp.getHeight()+comp.getY()+actualVal; - if (bott == cY) { - if (comp.getHeight() < minHeight) { - minHeight = comp.getHeight(); - } - mouseX = comp.getX()-DEFAULT_AREA_LENGTH-actualVal; - if (isFindRelatedComps) { - upComps.add(comp); - } - } else{ - break; - } - } - return minHeight; - } - - /** - * 杩斿洖鍜屽綋鍓嶇粍浠剁浉鍚寉鍧愭爣鐨勬墍鏈夌粍浠朵腑鏈灏忛珮搴︼紝涓斾繚璇佽繖浜涙帶浠舵槸鐩搁偦涓嶉殧鏂殑 - * 鍒ゆ柇瀵归綈鏃惰冭檻闂撮殧 - */ - private int getDownMinHeightComp(Component currentcomp, int y) { - int cX = currentcomp.getX(); - int cY = currentcomp.getY(); - int minHeight = currentcomp.getHeight(); - int max=container.getWidth() - margin.getRight(); - if (isFindRelatedComps) { - downComps = new ArrayList(); - } - int mouseX = cX + DEFAULT_AREA_LENGTH; - while (mouseX < max) { - Component comp = container.getComponentAt(mouseX, y); - if (comp.getY()==cY) { - if (comp.getHeight() < minHeight) { - minHeight = comp.getHeight(); - } - mouseX = comp.getX()+comp.getWidth()+DEFAULT_AREA_LENGTH + actualVal; - if (isFindRelatedComps) { - downComps.add(comp); - } - }else{ - break; - } - } - mouseX = cX - DEFAULT_AREA_LENGTH-actualVal; - while(mouseX > margin.getLeft()) { - Component comp = container.getComponentAt(mouseX, y); - if (comp.getY()==cY) { - if (comp.getHeight() < minHeight) { - minHeight = comp.getHeight(); - } - mouseX = comp.getX() - DEFAULT_AREA_LENGTH - actualVal; - if (isFindRelatedComps) { - downComps.add(comp); - } - }else{ - break; - } - } - return minHeight; + protected boolean canAcceptWhileCrossPoint(Component comp, int x, int y) { + return super.canAcceptWhileCrossPoint(comp, x, y); } - - /** - * 杩斿洖褰撳墠缁勪欢鍙充晶鐩稿悓x鐨勬墍鏈夌粍浠朵腑鏈灏忓搴︼紝涓斾繚璇佽繖浜涙帶浠舵槸鐩搁偦涓嶉殧鏂殑 - * 鍒ゆ柇瀵归綈鏃惰冭檻闂撮殧 - */ - private int getMinRightWidth(int cX, int cW, int y) { - int xL = cX+DEFAULT_AREA_LENGTH ; - xL = cW==0 ? xL : xL+cW+actualVal; - if (xL>container.getWidth() - margin.getRight()){ - return 0; - } - // 浠ュ綋鍓嶇粍浠剁揣鎸ㄧ潃鍙充晶鐨勭粍浠朵负鍩哄噯锛屽湪y杞存柟鍚戞煡鎵剧鍚堟潯浠剁殑缁勪欢 - Component targetComp = container.getComponentAt(xL, y); - int minWidth = targetComp.getWidth(); - int max=container.getHeight() - margin.getBottom(); - if (isFindRelatedComps) { - rightComps = new ArrayList(); - } - int mouseY = targetComp.getY() + DEFAULT_AREA_LENGTH; - while (mouseYmargin.getTop()) { - Component comp = container.getComponentAt(xL, mouseY); - if (comp.getX()==targetComp.getX()) { - if (comp.getWidth() < minWidth) { - minWidth = comp.getWidth(); - } - mouseY = comp.getY() - DEFAULT_AREA_LENGTH - actualVal; - if (isFindRelatedComps) { - rightComps.add(comp); - } - }else{ - break; - } - } - return minWidth; - } - - /** - * 杩斿洖褰撳墠缁勪欢鍨傜洿鏂瑰悜鍚屼晶鐨勭粍浠(缁勪欢鍙宠竟鐣岀浉杩)涓渶灏忓搴 - * 鍒ゆ柇瀵归綈鏃惰冭檻闂撮殧 - */ - private int getMinLeftWidth(Component currentComp, int x) { - int minWidth = currentComp.getWidth(); - int compRightLength = currentComp.getX()+currentComp.getWidth(); - int max=container.getHeight() - margin.getBottom(); - if (isFindRelatedComps) { - leftComps = new ArrayList(); - } - int rightx = 0; - int mouseY = currentComp.getY()+DEFAULT_AREA_LENGTH; - while(mouseYmargin.getTop()) { - Component comp = container.getComponentAt(x, mouseY); - rightx = comp.getX()+comp.getWidth(); - if (rightx == compRightLength) { - if (comp.getWidth() < minWidth) { - minWidth = comp.getWidth(); - } - mouseY = comp.getY() - DEFAULT_AREA_LENGTH - actualVal; - if (isFindRelatedComps) { - leftComps.add(comp); - } - }else{ - break; - } - } - return minWidth; + + protected boolean canAcceptWhileTrisection(Component comp, int x, int y) { + return super.canAcceptWhileTrisection(comp, x, y); } /** @@ -543,36 +240,7 @@ public class FRFitLayoutAdapter extends AbstractLayoutAdapter { * @return 鏄垯杩斿洖true */ public boolean isTrisectionArea(Component parentComp, int x, int y) { - XCreator creator = (XCreator)parentComp; - if (container.getComponentCount()<=1) { - return false; - } - int maxWidth = parentComp.getWidth(); - int maxHeight = parentComp.getHeight(); - int xL = parentComp.getX(); - int yL = parentComp.getY(); - // 缁勪欢瀹介珮鐨勫崄鍒嗕箣涓鍜岄粯璁ゅ煎彇澶 - int minRangeWidth = Math.max(maxWidth/BORDER_PROPORTION, DEFAULT_AREA_LENGTH); - int minRangeHeight = Math.max(maxHeight/BORDER_PROPORTION, DEFAULT_AREA_LENGTH); - if(yyL+maxHeight-minRangeHeight) { - // 鍦ㄧ粍浠朵笅渚т笁绛夊垎 - trisectAreaDirect = COMP_BOTTOM; - } else if (xxL+maxWidth-minRangeWidth) { - // 鍦ㄧ粍浠跺彸渚т笁绛夊垎 - trisectAreaDirect = COMP_RIGHT; - } - // tab甯冨眬鐨勮竟鐣岀壒娈婂鐞嗭紝涓嶈繘琛屼笁绛夊垎 - if(!creator.getTargetChildrenList().isEmpty()){ - return false; - } - - return !ComparatorUtils.equals(trisectAreaDirect, 0); + return super.isTrisectionArea(parentComp, x, y); } /** @@ -583,96 +251,15 @@ public class FRFitLayoutAdapter extends AbstractLayoutAdapter { * @return 鏄垯杩斿洖true */ public boolean isCrossPointArea(Component currentComp, int x, int y) { - // 3涓強浠ヤ笂閮戒細鍑虹幇浜ゅ弶鐐瑰尯鍩燂紙鍖呮嫭杈圭晫澶勭殑锛 - if(currentComp == null || container.getComponentCount() <= 2){ - return false; - } - int cX = currentComp.getX(); - int cY = currentComp.getY(); - int cW = currentComp.getWidth(); - int cH = currentComp.getHeight(); - int areaWidth = Math.max(cW/BORDER_PROPORTION ,DEFAULT_AREA_LENGTH); - int areaHeight = Math.max(cH/BORDER_PROPORTION, DEFAULT_AREA_LENGTH); - int rx = cX + cW; - int by = cY + cH; - int objX = cX + areaWidth; - int objY = cY + areaHeight; - int containerW = container.getWidth() - margin.getRight(); - int containerH = container.getHeight() - margin.getBottom(); - if (x margin.getTop() || cX > margin.getLeft() ? COMP_LEFT_TOP : 0; - } else if (yrx-areaWidth){ - //鍙充笂瑙 - crossPointAreaDirect = cY>margin.getTop() || rx < containerW ? COMP_RIGHT_TOP : 0; - } else if (xby-areaHeight) { - //宸︿笅瑙 - crossPointAreaDirect = cX>margin.getLeft() || byrx-areaWidth && y>by-areaHeight) { - //鍙充笅瑙 - crossPointAreaDirect = bycX+cW/2-areaWidth && x cY + cH - areaHeight) { - leftComp = container.getBottomLeftComp(cX, cY, cH); - rightComp = container.getBottomRightComp(cX, cY, cH, cW); - if (leftComp!=null && rightComp!=null) { - isCrosspoint = leftComp.getY()+leftComp.getHeight() == cY + cH && rightComp.getY()+rightComp.getHeight()== cY + cH; - } - crossPointAreaDirect = isCrosspoint ? COMP_BOTTOM : 0; - } - } else if (y>cY+cH/2-areaHeight && y cX+cW-areaWidth) { - topComp = container.getRightTopComp(cX, cY, cW); - bottomComp = container.getRightBottomComp(cX, cY, cH, cW); - if (topComp!=null && bottomComp!=null) { - isCrosspoint = topComp.getX()+topComp.getWidth()==cX+cW && bottomComp.getX()+bottomComp.getWidth()== cX+cW; - } - crossPointAreaDirect = isCrosspoint ? COMP_RIGHT : 0; - } - } - } - - private void initCompsList() { - rightComps = new ArrayList(); - leftComps = new ArrayList(); - upComps = new ArrayList(); - downComps = new ArrayList(); + + protected void initCompsList() { + super.initCompsList(); } - - private void clearCompsList() { - rightComps = null; - leftComps = null; - upComps = null; - downComps = null; + + protected void clearCompsList() { + super.clearCompsList(); } private Rectangle adjustBackupBound(Rectangle backupBound,XWCardMainBorderLayout mainLayout){ // 鍙傛暟鐣岄潰楂樺害瀵圭旱鍧愭爣浜х敓鐨勫奖鍝 @@ -1057,604 +644,28 @@ public class FRFitLayoutAdapter extends AbstractLayoutAdapter { /** * 骞冲垎锛屾甯告儏鍐垫嫋鍏ョ粍浠舵椂锛屾寜鐓т笂1/4鍖哄煙銆佷笅1/4鍖哄煙涓轰笂涓嬪钩鍒嗭紝涓乏渚1/2鍖哄煙銆佷腑鍙充晶1/2鍖哄煙涓哄乏鍙冲钩鍒 */ - private void fixHalve(Component currentComp, XCreator child, int x, int y) { - XCreator creator = (XCreator)currentComp; - if(!creator.getTargetChildrenList().isEmpty()){ - fixHalveOfTab(creator,child,x,y); - return; - } - int maxWidth = currentComp.getWidth(); - int maxHeight = currentComp.getHeight(); - int xL = currentComp.getX(); - int yL = currentComp.getY(); - Dimension dim = new Dimension(); - boolean isDividUp = y - yL<=maxHeight*TOP_HALF; - boolean isDividDown = y - yL>=maxHeight*BOTTOM_HALF; - boolean isDividLeft = x -xL margin.getLeft()) { - Component targetRightComp = container.getLeftComp(cX, y); - minLeftW = getMinLeftWidth(targetRightComp, cX-DEFAULT_AREA_LENGTH); - } - dealTrisectAtRight(child, minLeftW, minRightW); - } - crossPointAreaDirect = 0; - clearCompsList(); + protected void fixTrisect(Component currentComp, XCreator child, int x, int y) { + super.fixTrisect(currentComp, child, x, y); } - - /** - * 褰撳墠缁勪欢涓婅竟鐣屽尯鍩熶笁绛夊垎 - */ - private void dealTrisectAtTop(XCreator child, int minUH, int minDH) { - // 涓夌瓑鍒嗘湁闂撮殧鏃讹紝瀹為檯鏄袱渚ч兘瑕佸噺鍘诲崐涓棿闅斿ぇ灏 - int averageH = (minUH+minDH - actualVal)/3; - int dLength = 0; - int uLength = 0; - if (minDH==0) { - dLength = 0; - uLength = minUH/2; - calculateTopComps(uLength, child, uLength); - return; - } else if(minUH==0){ - dLength = minDH/2; - int witdh = container.getWidth() - margin.getLeft() - margin.getRight(); - if (!isCalculateChildPos) { - calculateBottomComps(dLength); - child.setLocation(margin.getLeft(), margin.getRight()); - child.setSize(witdh, dLength - actualVal/2); - } else { - childPosition = new int[] {margin.getLeft(), margin.getRight(), witdh, dLength - actualVal/2}; - } - return; - } else if (minUH >= minDH) { - minDH -= actualVal/2; - if ((minDH*2/3)=minLW) { - minLW -= actualVal/2; - if(minLW*2/3 INDEX_ZERO){ - childY = upComps.get(INDEX_ZERO).getY()+upComps.get(INDEX_ZERO).getHeight()-length; - } - for (int i=0,num=upComps.size(); i INDEX_ZERO){ - childX = leftComps.get(INDEX_ZERO).getX()+leftComps.get(INDEX_ZERO).getWidth()-length; - } - int childY = container.getHeight() - margin.getBottom(); - for (int i=0,num=leftComps.size(); i designer.getRootComponent().getHeight() + } else if (y + current_bounds.getHeight() > (designer.getRootComponent().getHeight() + designer.getParaHeight()) && designer.getSelectionModel().hasSelectionComponent()) { - y = designer.getRootComponent().getHeight() - current_bounds.height; + y = designer.getRootComponent().getHeight() + designer.getParaHeight() - current_bounds.height; } return new Point(x, y); } diff --git a/designer_form/src/com/fr/design/designer/beans/painters/FRAbsoluteLayoutPainter.java b/designer_form/src/com/fr/design/designer/beans/painters/FRAbsoluteLayoutPainter.java index 04e6018fc..a6da42a04 100644 --- a/designer_form/src/com/fr/design/designer/beans/painters/FRAbsoluteLayoutPainter.java +++ b/designer_form/src/com/fr/design/designer/beans/painters/FRAbsoluteLayoutPainter.java @@ -1,6 +1,13 @@ package com.fr.design.designer.beans.painters; +import com.fr.design.designer.beans.adapters.layout.FRAbsoluteLayoutAdapter; +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.form.util.XCreatorConstants; +import com.fr.design.mainframe.DesignerFrame; +import com.fr.design.mainframe.FormDesigner; +import com.fr.general.FRLogger; import java.awt.*; @@ -8,19 +15,188 @@ import java.awt.*; * Created by zhouping on 2016/7/11. */ public class FRAbsoluteLayoutPainter extends AbstractPainter { + + private static final int BORDER_PROPORTION = 10; + private static final int X = 0; + private static final int Y = 1; + private static final int WIDTH = 2; + private static final int HEIGHT = 3; + + private static final Color DEPEND_LINE_COLOR = new Color(200, 200, 200); + private static final int DEPEND_LINE_SCOPE = 3; + + /** + * 鏋勯犲嚱鏁 + * @param container + */ public FRAbsoluteLayoutPainter(XLayoutContainer container) { super(container); } /** * 缁勪欢娓叉煋 - * - * @param g 鐢诲浘绫 + * @param g 鐢诲浘绫 * @param startX 寮濮嬩綅缃畑 * @param startY 寮濮嬩綅缃畒 */ @Override public void paint(Graphics g, int startX, int startY) { + if(hotspot_bounds == null && creator != null && container != null){ + drawDependingLine(g); + return; + } super.paint(g, startX, startY); + //濡傛灉absolute涓嶅彲缂栬緫閭d箞灏卞皢涔嬪綋鏅氭帶浠跺鐞嗭紝鍦ㄥ懆鍥存坊鍔犳帶浠讹紝 + //鍚﹀垯锛屽彧寰鍐呴儴娣诲姞锛屼笉闇瑕佸嚭鐜拌摑鑹叉偓娴彁绀烘 + if(container.isEditable()){ + return; + } + int x = hotspot.x - hotspot_bounds.x; + int y = hotspot.y - hotspot_bounds.y; + FRAbsoluteLayoutAdapter adapter = (FRAbsoluteLayoutAdapter) container.getLayoutAdapter(); + + int[] hot_rec; + + boolean accept = adapter.accept(creator, x, y); + Component currentComp = container.getComponentAt(x, y); + //涓嶅彲缂栬緫鐨勬椂鍊欒鑾峰彇椤跺眰鐨勭粷瀵瑰竷灞瀹瑰櫒 + if (XCreatorUtils.getHotspotContainer((XCreator) currentComp) != null) { + currentComp = XCreatorUtils.getHotspotContainer((XCreator) currentComp).getTopLayout(); + if (currentComp == null) { + FRLogger.getLogger().info("FRAbsoluteLayoutPainter get currentComp null!"); + return; + } + } + else{ + FRLogger.getLogger().info("FRAbsoluteLayoutPainter getHotspotContainer currentComp null!"); + return; + } + Color bColor = XCreatorConstants.FIT_LAYOUT_HOTSPOT_COLOR; + if (accept) { + y = (y == container.getHeight()) ? y - 1 : y; + x = (x == container.getWidth()) ? x - 1 : x; + hot_rec = adapter.getChildPosition(currentComp, creator, x + hotspot_bounds.x, y + hotspot_bounds.y); + } else { + bColor = XCreatorConstants.LAYOUT_FORBIDDEN_COLOR; + Rectangle rec = currentComp.getBounds(); + hot_rec = currentComp == container ? new int[]{x, y, 0, 0} : new int[]{rec.x, rec.y, rec.width, rec.height}; + } + drawRegionBackground(g, hot_rec[X], hot_rec[Y] + startY, hot_rec[WIDTH], hot_rec[HEIGHT], bColor, accept); + if (accept) { + //鐢讳氦鍙夊尯鍩熷拰涓棿鐐瑰尯鍩 + //鎷栧叆鐨勫尯鍩熶篃鏀逛负鏁翠釜娓叉煋锛岀偣鍖哄煙鐨勫悗鐢讳笅锛屼笉鐒惰閬綇浜 + paintCrossPoint(currentComp, g, x, y); + } + } + + private void paintCrossPoint(Component currentComp, Graphics g, int x, int y) { + if (currentComp == container) { + return; + } + Color bColor = XCreatorConstants.FIT_LAYOUT_POINT_COLOR; + int cX = currentComp.getX(), cY = currentComp.getY(), cH = currentComp.getHeight(), cW = currentComp.getWidth(); + int defaultWidth = cW / BORDER_PROPORTION, defaultHeight = cH / BORDER_PROPORTION; + // 浜ゅ弶鐐规彁绀哄尯鍩熸渶澶у间负10px + int defaultLength = Math.min(BORDER_PROPORTION, Math.min(defaultWidth, defaultHeight)); + Component topComp = container.getTopComp(cX, cY); + Component bottomComp = container.getBottomComp(cX, cY, cH); + Component rightComp = container.getRightComp(cX, cY, cW); //缁勪欢鐨勫乏鍙崇粍浠惰鍖哄垎涓婁晶鍜屼笅渚 + Component leftComp = container.getLeftComp(cX, cY); + boolean top = topComp != null && topComp != container, left = leftComp != null && leftComp != container, + bottom = bottomComp != null && bottomComp != container, right = rightComp != null && rightComp != container; + if (top || left) { + drawRegionBackground(g, cX + hotspot_bounds.x, cY + hotspot_bounds.y, defaultLength, defaultLength, bColor, true); + } + if (bottom || left) { + drawRegionBackground(g, cX + hotspot_bounds.x, cY + cH - defaultLength + hotspot_bounds.y, defaultLength, defaultLength, bColor,true); + } + if (top || right) { + drawRegionBackground(g, cX + cW - defaultLength + hotspot_bounds.x, cY + hotspot_bounds.y, defaultLength, defaultLength, bColor,true); + } + if (bottom || right) { + drawRegionBackground(g, cX + cW - defaultLength + hotspot_bounds.x, cY + cH - defaultLength + hotspot_bounds.y, defaultLength, defaultLength, bColor,true); + } + if (left && right) { + if (leftComp.getY() == cY && rightComp.getY() == cY) { + drawRegionBackground(g, cX + cW / 2 - defaultWidth + hotspot_bounds.x, cY + hotspot_bounds.y, defaultWidth * 2, defaultLength, bColor,true); + } + //搴曡竟绾夸綅缃紝宸﹀彸缁勪欢閮戒笉涓簄ull涓斾綆绔榻愶紝鍙栧乏銆佸彸闈犱笅渚х粍浠跺垽鏂 + leftComp = container.getBottomLeftComp(cX, cY, cH); + rightComp = container.getBottomRightComp(cX, cY, cH, cW); + if ((leftComp.getY() + leftComp.getHeight() == cY + cH) && (rightComp.getY() + rightComp.getHeight()== cY + cH)) { + drawRegionBackground(g, cX + cW / 2 - defaultWidth + hotspot_bounds.x, cY + cH - defaultLength + hotspot_bounds.y, defaultWidth * 2, defaultLength, bColor,true); + } + } + if (top && bottom) { + if (topComp.getX() == cX && bottomComp.getX() == cX) { + drawRegionBackground(g, cX + hotspot_bounds.x, cY + cH / 2 - defaultHeight + hotspot_bounds.y, defaultLength, defaultHeight * 2, bColor,true); + } + // 鍙宠竟绾夸綅缃紝涓婁笅缁勪欢涓嶄负null涓斿彸绔榻愶紝鍙栦笂銆佷笅闈犲彸渚х粍浠跺垽鏂 + topComp = container.getRightTopComp(cX, cY, cW); + bottomComp = container.getRightBottomComp(cX, cY, cH, cW); + if ((topComp.getX() + topComp.getWidth() == cX + cW) && (bottomComp.getX() + bottomComp.getWidth() == cX + cW)) { + drawRegionBackground(g, cX + cW - defaultLength + hotspot_bounds.x, cY + cH / 2 - defaultHeight + hotspot_bounds.y, defaultLength, defaultHeight * 2, bColor,true); + } + } + } + + // 鐢讳緷闄勭嚎 + private void drawDependingLine(Graphics g){ + Graphics2D g2d = (Graphics2D) g; + Stroke backup = g2d.getStroke(); + + // 褰撳墠鎷栨嫿缁勪欢鐨勫潗鏍 + int oriX = creator.getX(); + int oriY = creator.getY(); + + // 鎷栨嫿浣嶇疆鐨勫嵆鏃跺潗鏍 + double x = hotspot.getX(); + double y = hotspot.getY(); + + // 瀹瑰櫒鎵鏈夌殑鍐呴儴缁勪欢鐨勬í绾靛潗鏍囧 + int[] posXs = container.getHors(); + int[] posYs = container.getVeris(); + + // 渚濋檮绾跨殑鍧愭爣 + int lineX = 0; + int lineY = 0; + + // 鏍规嵁鎷栨嫿浣嶇疆璋冩暣渚濋檮绾跨殑鍧愭爣 + lineX = getDependLinePos(lineX, posXs, oriX, x); + lineY = getDependLinePos(lineY, posYs, oriY, y); + + + g2d.setStroke(backup); + g2d.setColor(DEPEND_LINE_COLOR); + if(lineX != 0){ + g2d.drawRect(lineX, 0, 0, container.getHeight()); + } + if(lineY != 0){ + g2d.drawRect(0, lineY, container.getWidth(), 0); + } + + } + + /** + * 鏍规嵁瀹瑰櫒鍐呴儴缁勪欢鐨勬í绾靛潗鏍囧肩敾渚濋檮绾 + * + * @param lineCoordinate 渚濋檮绾垮潗鏍囧 + * @param referCoordinates 瀹瑰櫒鍐呴儴鎵鏈夌粍浠跺潗鏍囧 + * @param oriCoordinate 褰撳墠鎷栨嫿缁勪欢鍧愭爣 + * @param currentCoordinate 鎷栨嫿浣嶇疆鐨勫嵆鏃跺潗鏍 + * @return 渚濋檮绾跨殑鍧愭爣 + * + */ + private int getDependLinePos(int lineCoordinate,int referCoordinates[],int oriCoordinate,double currentCoordinate){ + for(int i = 0; i < referCoordinates.length; i++){ + if(referCoordinates[i] == oriCoordinate){ + continue; + } + if(currentCoordinate > referCoordinates[i] - DEPEND_LINE_SCOPE && currentCoordinate < referCoordinates[i] + DEPEND_LINE_SCOPE){ + lineCoordinate = referCoordinates[i]; + break; + } + } + return lineCoordinate; } } diff --git a/designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java b/designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java index 3a110e321..4c543300b 100644 --- a/designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java +++ b/designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java @@ -21,10 +21,9 @@ import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.form.layout.FRAbsoluteLayout; import com.fr.design.form.util.XCreatorConstants; +import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.icon.IconPathConstants; -import com.fr.design.mainframe.EditingMouseListener; -import com.fr.design.mainframe.FormArea; -import com.fr.design.mainframe.FormDesigner; +import com.fr.design.mainframe.*; import com.fr.design.mainframe.widget.editors.PaddingMarginEditor; import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor; import com.fr.design.mainframe.widget.renderer.LayoutBorderStyleRenderer; @@ -34,10 +33,14 @@ import com.fr.form.ui.Widget; import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; import com.fr.form.ui.container.WFitLayout; +import com.fr.form.ui.container.WLayout; import com.fr.general.FRScreen; import com.fr.general.IOUtils; import com.fr.general.Inter; import com.fr.stable.core.PropertyChangeAdapter; +import org.eclipse.swt.internal.gdip.Rect; + +import javax.swing.*; /** * @author richer @@ -47,6 +50,8 @@ public class XWAbsoluteLayout extends XLayoutContainer { private static final int EDIT_BTN_WIDTH = 60; private static final int EDIT_BTN_HEIGHT = 24; + private int minWidth = WLayout.MIN_WIDTH; + private int minHeight = WLayout.MIN_HEIGHT; //鐢变簬灞忓箷鍒嗚鲸鐜囦笉鍚岋紝鐣岄潰涓婄殑瀹瑰櫒澶у皬鍙兘涓嶆槸榛樿鐨100%锛屾鏃舵嫋鍏ョ粍浠舵椂锛屼繚瀛樼殑澶у皬鎸夌収100%鏃剁殑璁$畻 protected double containerPercent = 1.0; @@ -97,6 +102,35 @@ public class XWAbsoluteLayout extends XLayoutContainer { */ public void setContainerPercent(double containerPercent) { this.containerPercent = containerPercent; + minWidth = (int) (XWAbsoluteLayout.MIN_WIDTH*containerPercent); + minHeight = (int) (XWAbsoluteLayout.MIN_HEIGHT*containerPercent); + } + + /** + * 杩斿洖鐣岄潰澶勬牴鎹櫨鍒嗘瘮璋冩暣鍚庣殑鏈灏忓搴 + * @return 鏈灏忓搴 + */ + public int getActualMinWidth() { + return this.minWidth; + } + + /** + * 杩斿洖鐣岄潰澶勬牴鎹櫨鍒嗘瘮璋冩暣鍚庣殑鏈灏忛珮搴 + * @return 鏈灏忛珮搴 + */ + public int getActualMinHeight() { + return this.minHeight; + } + + /** + * 杩斿洖鐣岄潰澶勬牴鎹櫨鍒嗘瘮璋冩暣鍚庣殑闂撮殧澶у皬锛堜笖涓哄伓鏁帮級 + * @return 闂撮殧 + */ + public int getAcualInterval() { + // adapter閭h竟浜ゅ弶涓夌瓑鍒嗐佸垹闄ら兘瑕佸垽鏂槸鍚﹀榻愶紝鎵浠ラ棿闅旇浆涓哄伓鏁 + int interval = (int) (toData().getCompInterval()*containerPercent); + int val = interval/2; + return val*2; } /** @@ -114,16 +148,46 @@ public class XWAbsoluteLayout extends XLayoutContainer { } /** - * 鏂板鍒犻櫎鎷変几鍚庢洿鏂版瘡涓粍浠剁殑BoundsWidget + * 鏂板鍒犻櫎鎷変几鍚庡崟涓粍浠剁殑BoundsWidget */ public void updateBoundsWidget(XCreator xCreator) { WAbsoluteLayout layout = this.toData(); - if (xCreator.shouldScaleCreator() || xCreator.hasTitleStyle()) { + if (xCreator.hasTitleStyle()) { xCreator = (XLayoutContainer)xCreator.getParent(); } BoundsWidget boundsWidget = layout.getBoundsWidget(xCreator.toData()); Rectangle rectangle = dealWidgetBound(xCreator.getBounds()); - boundsWidget.setCalculatedBounds(rectangle); + } + + private Rectangle calculateBound(Rectangle rec, double pw, double ph){ + Rectangle calRec = new Rectangle(0,0,0,0); + calRec.x = (int)(rec.x / pw); + calRec.y = (int)(rec.y / ph); + calRec.width = (int)(rec.width / pw); + calRec.height = (int)(rec.height / ph); + return calRec; + } + + /** + * 鏂板鍒犻櫎鎷変几鍚庢瘡涓粍浠剁殑BoundsWidget + */ + public void updateBoundsWidget() { + WAbsoluteLayout layout = this.toData(); + Rectangle backupBound = this.getBackupBound(); + Rectangle currentBound = this.getBounds(); + if (backupBound != null && layout.getCompState() == WAbsoluteLayout.STATE_FIT) { + double percentW = ((double) backupBound.width / (double) currentBound.width); + double percentH = ((double) backupBound.height / (double) currentBound.height); + for (int index = 0, n = this.getComponentCount(); index < n; index++){ + XCreator creator = (XCreator) this.getComponent(index); + BoundsWidget wgt = layout.getBoundsWidget(creator.toData()); + // 鐢ㄥ綋鍓嶇殑鏄剧ず澶у皬璁$畻鍚庤皟姝e叿浣撲綅缃 + Rectangle wgtBound = dealWidgetBound(creator.getBounds()); + Rectangle rec = calculateBound(wgtBound, percentW, percentH); + wgt.setBounds(rec); + creator.setBounds(rec); + } + } } /** diff --git a/designer_form/src/com/fr/design/designer/creator/XWFitLayout.java b/designer_form/src/com/fr/design/designer/creator/XWFitLayout.java index a67e7c878..8f4df6e74 100644 --- a/designer_form/src/com/fr/design/designer/creator/XWFitLayout.java +++ b/designer_form/src/com/fr/design/designer/creator/XWFitLayout.java @@ -744,6 +744,10 @@ public class XWFitLayout extends XLayoutContainer { tabLayout.updateBoundsWidget(); } } + //濡傛灉瀛愮粍浠舵槸缁濆甯冨眬锛屽垯鍐呴儴鐨剋idget涔熻鏇存柊 + if (creator.acceptType(XWAbsoluteLayout.class)){ + ((XWAbsoluteLayout) creator).updateBoundsWidget(); + } } layout.setContainerHeight(containerHeight); layout.setContainerWidth(containerWidth); @@ -801,6 +805,7 @@ public class XWFitLayout extends XLayoutContainer { BoundsWidget bw = wlayout.getBoundsWidget(wgt); wlayout.removeWidget(bw); updateBoundsWidget(); + ((FRFitLayoutAdapter)getLayoutAdapter()).updateCreatorBackBound(); } /** diff --git a/designer_form/src/com/fr/design/designer/creator/XWParameterLayout.java b/designer_form/src/com/fr/design/designer/creator/XWParameterLayout.java index e1ab80b7c..d847245e1 100644 --- a/designer_form/src/com/fr/design/designer/creator/XWParameterLayout.java +++ b/designer_form/src/com/fr/design/designer/creator/XWParameterLayout.java @@ -183,4 +183,11 @@ public class XWParameterLayout extends XWAbsoluteLayout { @Override public void updateBoundsWidget(XCreator xCreator) { } + + /** + * 鏂板鍒犻櫎鎷変几鍚庢瘡涓粍浠剁殑BoundsWidget + */ + @Override + public void updateBoundsWidget() { + } } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/gui/core/FormWidgetOption.java b/designer_form/src/com/fr/design/gui/core/FormWidgetOption.java index e99888c72..76287c30f 100644 --- a/designer_form/src/com/fr/design/gui/core/FormWidgetOption.java +++ b/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 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); } \ No newline at end of file +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 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); } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/mainframe/FormDesignerUI.java b/designer_form/src/com/fr/design/mainframe/FormDesignerUI.java index 9fc5cb1bf..259e1b65e 100644 --- a/designer_form/src/com/fr/design/mainframe/FormDesignerUI.java +++ b/designer_form/src/com/fr/design/mainframe/FormDesignerUI.java @@ -95,9 +95,9 @@ public class FormDesignerUI extends ComponentUI { if (designer.getPainter() != null) { // ComponentAdapter鍜孡ayoutAdapter鎻愪緵鐨勯澶栫殑Painter锛岃Painter涓鑸敤浜庢彁绀轰綔鐢紝 - // 鐩稿綋浜庝竴涓诞鍔ㄥ眰 + // 鐩稿綋浜庝竴涓诞鍔ㄥ眰, 瑕佽冭檻鍙傛暟闈㈡澘鐨勯珮搴 designer.getPainter().paint(g, designer.getArea().getHorizontalValue(), - designer.getArea().getVerticalValue()); + designer.getArea().getVerticalValue() + designer.getParaHeight()); } AddingModel addingModel = designer.getAddingModel();