sunmondong
8 years ago
80 changed files with 3762 additions and 1086 deletions
@ -0,0 +1,85 @@ |
|||||||
|
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") |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,36 @@ |
|||||||
|
package com.fr.design.actions; |
||||||
|
|
||||||
|
import com.fr.design.mainframe.DesignerContext; |
||||||
|
import com.fr.design.mainframe.ElementCasePane; |
||||||
|
import com.fr.design.selection.SelectionEvent; |
||||||
|
import com.fr.design.selection.SelectionListener; |
||||||
|
import com.fr.grid.selection.CellSelection; |
||||||
|
import com.fr.grid.selection.Selection; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by daniel on 2016/10/10. |
||||||
|
*/ |
||||||
|
public abstract class SelectionListenerAction extends TemplateComponentAction<ElementCasePane> { |
||||||
|
|
||||||
|
protected SelectionListenerAction(ElementCasePane elementCasePane) { |
||||||
|
super(elementCasePane); |
||||||
|
} |
||||||
|
|
||||||
|
protected SelectionListener createSelectionListener () { |
||||||
|
return new SelectionListener() { |
||||||
|
|
||||||
|
@Override |
||||||
|
public void selectionChanged(SelectionEvent e) { |
||||||
|
update(); |
||||||
|
if (DesignerContext.getFormatState() != DesignerContext.FORMAT_STATE_NULL) { |
||||||
|
Selection selection = getEditingComponent().getSelection(); |
||||||
|
if (selection instanceof CellSelection) { |
||||||
|
CellSelection cellselection = (CellSelection) selection; |
||||||
|
//样式处理
|
||||||
|
getEditingComponent().setCellNeedTOFormat(cellselection); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
}; |
||||||
|
} |
||||||
|
} |
@ -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/${branchName}",include:'**/*.jar') |
||||||
|
compile fileTree(dir:'../../../',include:"finereport-*-stable/${branchName}/**/build/libs/*.jar") |
||||||
|
|
||||||
|
testCompile 'junit:junit:4.12' |
||||||
|
} |
||||||
|
//复制非.java文件到classes文件夹下参与打包 |
||||||
|
task copyFile(type:Copy,dependsOn:compileJava){ |
||||||
|
copy{ |
||||||
|
from ("${srcDir}/src"){ |
||||||
|
exclude '**/.setting/**','.classpath','.project','**/*.java','**/*.db','**/*.g','**/package.html' |
||||||
|
} |
||||||
|
into 'build/classes/main' |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
//压缩项目中的js文件 |
||||||
|
task compressJS{ |
||||||
|
ant.taskdef(name:'yuicompress',classname:'com.yahoo.platform.yui.compressor.YUICompressTask'){ |
||||||
|
classpath { |
||||||
|
fileset(dir:'../../../finereport-lib4build-stable',includes:'**/*.jar') |
||||||
|
} |
||||||
|
} |
||||||
|
ant.yuicompress(linebreak:"500",warn:"false", munge:"yes",preserveallsemicolons:"false",charset:"utf-8",encoding:"utf-8",outputfolder:'build/classes/main'){ |
||||||
|
fileset (dir:"${srcDir}/src"){ |
||||||
|
include (name:'**/*.js') |
||||||
|
include (name:'**/*.css') |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
jar.dependsOn compressJS |
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,53 @@ |
|||||||
|
package com.fr.design.actions.server; |
||||||
|
|
||||||
|
import com.fr.base.BaseUtils; |
||||||
|
import com.fr.design.actions.UpdateAction; |
||||||
|
import com.fr.design.dialog.BasicPane; |
||||||
|
import com.fr.design.dialog.UIDialog; |
||||||
|
import com.fr.design.extra.ShopDialog; |
||||||
|
import com.fr.design.extra.PluginWebBridge; |
||||||
|
import com.fr.design.extra.WebManagerPaneFactory; |
||||||
|
import com.fr.design.mainframe.DesignerContext; |
||||||
|
import com.fr.design.menu.MenuKeySet; |
||||||
|
import com.fr.general.Inter; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by vito on 2016/9/27. |
||||||
|
*/ |
||||||
|
public class ReuseManagerAction extends UpdateAction { |
||||||
|
|
||||||
|
public ReuseManagerAction() { |
||||||
|
this.setMenuKeySet(REUSE_MANAGER); |
||||||
|
this.setName(getMenuKeySet().getMenuKeySetName()); |
||||||
|
this.setMnemonic(getMenuKeySet().getMnemonic()); |
||||||
|
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/server/plugin.png")); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
BasicPane managerPane = new WebManagerPaneFactory().createReusePane(); |
||||||
|
UIDialog dlg = new ShopDialog(DesignerContext.getDesignerFrame(), managerPane); |
||||||
|
PluginWebBridge.getHelper().setDialogHandle(dlg); |
||||||
|
dlg.setVisible(true); |
||||||
|
} |
||||||
|
|
||||||
|
public static final MenuKeySet REUSE_MANAGER = new MenuKeySet() { |
||||||
|
@Override |
||||||
|
public char getMnemonic() { |
||||||
|
return 'R'; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getMenuName() { |
||||||
|
return Inter.getLocText("FR-Designer-Reuse_Manager"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public KeyStroke getKeyStroke() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
}; |
||||||
|
} |
@ -0,0 +1,36 @@ |
|||||||
|
package com.fr.design.extra; |
||||||
|
|
||||||
|
import javafx.scene.web.WebEngine; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by vito on 2016/9/28. |
||||||
|
*/ |
||||||
|
public class ReuseWebBridge { |
||||||
|
public static ReuseWebBridge helper; |
||||||
|
private WebEngine webEngine; |
||||||
|
|
||||||
|
public static ReuseWebBridge getHelper() { |
||||||
|
if (helper != null) { |
||||||
|
return helper; |
||||||
|
} |
||||||
|
synchronized (ReuseWebBridge.class) { |
||||||
|
if (helper == null) { |
||||||
|
helper = new ReuseWebBridge(); |
||||||
|
} |
||||||
|
return helper; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static ReuseWebBridge getHelper(WebEngine webEngine) { |
||||||
|
getHelper(); |
||||||
|
helper.setEngine(webEngine); |
||||||
|
return helper; |
||||||
|
} |
||||||
|
|
||||||
|
private ReuseWebBridge() { |
||||||
|
} |
||||||
|
|
||||||
|
public void setEngine(WebEngine webEngine) { |
||||||
|
this.webEngine = webEngine; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,54 @@ |
|||||||
|
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 vito on 2016/9/28. |
||||||
|
*/ |
||||||
|
public class ReuseWebPane extends JFXPanel { |
||||||
|
private WebEngine webEngine; |
||||||
|
|
||||||
|
public ReuseWebPane(final String mainJs) { |
||||||
|
Platform.setImplicitExit(false); |
||||||
|
Platform.runLater(new Runnable() { |
||||||
|
@Override |
||||||
|
public void run() { |
||||||
|
BorderPane root = new BorderPane(); |
||||||
|
Scene scene = new Scene(root); |
||||||
|
ReuseWebPane.this.setScene(scene); |
||||||
|
WebView webView = new WebView(); |
||||||
|
webEngine = webView.getEngine(); |
||||||
|
webEngine.load("file:///" + mainJs); |
||||||
|
webEngine.setOnAlert(new EventHandler<WebEvent<String>>() { |
||||||
|
@Override |
||||||
|
public void handle(WebEvent<String> event) { |
||||||
|
showAlert(event.getData()); |
||||||
|
} |
||||||
|
}); |
||||||
|
JSObject obj = (JSObject) webEngine.executeScript("window"); |
||||||
|
obj.setMember("ReuseHelper", ReuseWebBridge.getHelper(webEngine)); |
||||||
|
webView.setContextMenuEnabled(false);//屏蔽右键
|
||||||
|
root.setCenter(webView); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
private void showAlert(final String message) { |
||||||
|
SwingUtilities.invokeLater(new Runnable() { |
||||||
|
@Override |
||||||
|
public void run() { |
||||||
|
JOptionPane.showMessageDialog(ReuseWebPane.this, message); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
package com.fr.design.extra; |
||||||
|
|
||||||
|
import javafx.embed.swing.JFXPanel; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by vito on 2016/9/28. |
||||||
|
*/ |
||||||
|
public abstract class ShopPaneConfig { |
||||||
|
private String mainJS; |
||||||
|
private String scriptsId; |
||||||
|
private JFXPanel webPane; |
||||||
|
|
||||||
|
public ShopPaneConfig() { |
||||||
|
this.mainJS = getMainJS(); |
||||||
|
this.scriptsId = getScriptsId(); |
||||||
|
this.webPane = getWebPane(); |
||||||
|
} |
||||||
|
|
||||||
|
abstract String getMainJS(); |
||||||
|
|
||||||
|
abstract String getScriptsId(); |
||||||
|
|
||||||
|
abstract JFXPanel getWebPane(); |
||||||
|
} |
@ -0,0 +1,99 @@ |
|||||||
|
package com.fr.design.extra; |
||||||
|
|
||||||
|
import com.fr.design.dialog.BasicPane; |
||||||
|
import com.fr.design.gui.frpane.UITabbedPane; |
||||||
|
import com.fr.general.Inter; |
||||||
|
import com.fr.stable.StableUtils; |
||||||
|
import javafx.embed.swing.JFXPanel; |
||||||
|
|
||||||
|
import java.awt.*; |
||||||
|
import java.io.File; |
||||||
|
import java.net.URL; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by vito on 2016/9/28. |
||||||
|
*/ |
||||||
|
public class WebManagerPaneFactory { |
||||||
|
private String installHome; |
||||||
|
|
||||||
|
public WebManagerPaneFactory() { |
||||||
|
if (StableUtils.isDebug()) { |
||||||
|
URL url = ClassLoader.getSystemResource(""); |
||||||
|
this.installHome = url.getPath(); |
||||||
|
} else { |
||||||
|
this.installHome = StableUtils.getInstallHome(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public BasicPane createPluginPane() { |
||||||
|
if (StableUtils.getMajorJavaVersion() == 8) { |
||||||
|
return new ShopManagerPane(new ShopPaneConfig() { |
||||||
|
@Override |
||||||
|
String getMainJS() { |
||||||
|
String relativePath = "/scripts/store/web/index.html"; |
||||||
|
return StableUtils.pathJoin(new File(installHome).getAbsolutePath(), relativePath); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
String getScriptsId() { |
||||||
|
return "shop_scripts"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
JFXPanel getWebPane() { |
||||||
|
return new PluginWebPane(getMainJS()); |
||||||
|
} |
||||||
|
|
||||||
|
}); |
||||||
|
} else { |
||||||
|
BasicPane traditionalStorePane = new BasicPane() { |
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return Inter.getLocText("FR-Designer-Plugin_Manager"); |
||||||
|
} |
||||||
|
}; |
||||||
|
traditionalStorePane.setLayout(new BorderLayout()); |
||||||
|
traditionalStorePane.add(initTraditionalStore(), BorderLayout.CENTER); |
||||||
|
return traditionalStorePane; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public BasicPane createReusePane() { |
||||||
|
return new ShopManagerPane(new ShopPaneConfig() { |
||||||
|
@Override |
||||||
|
String getMainJS() { |
||||||
|
String relativePath = "/scripts/store/reuse/index.html"; |
||||||
|
return StableUtils.pathJoin(new File(installHome).getAbsolutePath(), relativePath); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
String getScriptsId() { |
||||||
|
return "reuse_scripts"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
JFXPanel getWebPane() { |
||||||
|
return new ReuseWebPane(getMainJS()); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 以关键词打开设计器商店 |
||||||
|
* |
||||||
|
* @param keyword 关键词 |
||||||
|
*/ |
||||||
|
public BasicPane createPluginPane(String keyword) { |
||||||
|
PluginWebBridge.getHelper().openWithSearch(keyword); |
||||||
|
return createPluginPane(); |
||||||
|
} |
||||||
|
|
||||||
|
private Component initTraditionalStore() { |
||||||
|
UITabbedPane tabbedPane = new UITabbedPane(); |
||||||
|
PluginInstalledPane installedPane = new PluginInstalledPane(); |
||||||
|
tabbedPane.addTab(installedPane.tabTitle(), installedPane); |
||||||
|
tabbedPane.addTab(Inter.getLocText("FR-Designer-Plugin_Update"), new PluginUpdatePane(tabbedPane)); |
||||||
|
tabbedPane.addTab(Inter.getLocText("FR-Designer-Plugin_All_Plugins"), new PluginFromStorePane(tabbedPane)); |
||||||
|
return tabbedPane; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
package com.fr.design.fun; |
||||||
|
|
||||||
|
import com.fr.design.gui.ibutton.UIButton; |
||||||
|
import com.fr.stable.fun.mark.Mutable; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设计器面板最上方的按钮接口(保存,赋值,撤销同级) |
||||||
|
* Coder: zack |
||||||
|
* Date: 2016/9/22 |
||||||
|
* Time: 15:40 |
||||||
|
*/ |
||||||
|
public interface DesignerFrameUpButtonProvider extends Mutable { |
||||||
|
|
||||||
|
int CURRENT_LEVEL = 1; |
||||||
|
|
||||||
|
String XML_TAG = "DesignerFrameUpButtonProvider"; |
||||||
|
|
||||||
|
/** |
||||||
|
* 根据当前的设计状态返回最上层工具按钮 |
||||||
|
* @param menuState 现在设计器的设计状态 |
||||||
|
* @return 按钮 |
||||||
|
*/ |
||||||
|
UIButton[] getUpButtons(int menuState); |
||||||
|
} |
@ -0,0 +1,23 @@ |
|||||||
|
package com.fr.design.fun.impl; |
||||||
|
|
||||||
|
import com.fr.design.fun.DesignerFrameUpButtonProvider; |
||||||
|
import com.fr.design.gui.ibutton.UIButton; |
||||||
|
import com.fr.stable.fun.mark.API; |
||||||
|
|
||||||
|
/** |
||||||
|
* Coder: zack |
||||||
|
* Date: 2016/9/22 |
||||||
|
* Time: 15:50 |
||||||
|
*/ |
||||||
|
@API(level = DesignerFrameUpButtonProvider.CURRENT_LEVEL) |
||||||
|
public abstract class AbstractDsinFrameUpButtonProvider implements DesignerFrameUpButtonProvider { |
||||||
|
@Override |
||||||
|
public UIButton[] getUpButtons(int menuState) { |
||||||
|
return new UIButton[0]; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String mark4Provider() { |
||||||
|
return getClass().getName(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,102 @@ |
|||||||
|
package com.fr.design.gui.frpane.tree.layer.config; |
||||||
|
|
||||||
|
import com.fr.base.TableData; |
||||||
|
import com.fr.data.impl.TableDataDictionary; |
||||||
|
import com.fr.design.beans.BasicBeanPane; |
||||||
|
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; |
||||||
|
import com.fr.design.present.dict.TableDataDictPane; |
||||||
|
import com.fr.form.ui.tree.LayerConfig; |
||||||
|
import com.fr.form.ui.tree.LayerDependence; |
||||||
|
|
||||||
|
import java.awt.*; |
||||||
|
import java.util.*; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by juhaoyu on 16/9/13. |
||||||
|
*/ |
||||||
|
public class LayerDataConfigPane extends BasicBeanPane<LayerConfig> { |
||||||
|
|
||||||
|
/** |
||||||
|
* 数据集数据字典选择panel |
||||||
|
*/ |
||||||
|
private TableDataDictPane tableDataDictPane; |
||||||
|
|
||||||
|
/** |
||||||
|
* 与父级关联的字段选择 |
||||||
|
*/ |
||||||
|
private LayerDependenceSettingPane dependenceSettingPane; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 当前用户正在修改的LayerData |
||||||
|
*/ |
||||||
|
private LayerConfig layerConfig; |
||||||
|
|
||||||
|
public LayerDataConfigPane() { |
||||||
|
//初始化组件及布局
|
||||||
|
this.tableDataDictPane = new TableDataDictPane(); |
||||||
|
this.dependenceSettingPane = new LayerDependenceSettingPane(tableDataDictPane); |
||||||
|
this.setLayout(new BorderLayout(2, 2)); |
||||||
|
this.add(tableDataDictPane, BorderLayout.NORTH); |
||||||
|
this.add(dependenceSettingPane, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 1.切换层级时 |
||||||
|
* |
||||||
|
* @param layerConfig |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void populateBean(LayerConfig layerConfig) { |
||||||
|
|
||||||
|
if (layerConfig != null) { |
||||||
|
this.layerConfig = layerConfig; |
||||||
|
TableDataDictionary ta = layerConfig.getDictionary(); |
||||||
|
this.tableDataDictPane.populateBean(ta); |
||||||
|
this.dependenceSettingPane.populate(layerConfig.getIndex(), layerConfig.getDependenceList()); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public LayerConfig updateBean() { |
||||||
|
|
||||||
|
if (layerConfig == null) { |
||||||
|
return null; |
||||||
|
|
||||||
|
} |
||||||
|
//从下层panel中读取数据
|
||||||
|
TableData tableData = tableDataDictPane.updateBean().getTableData(); |
||||||
|
TableDataWrapper wrapper = tableDataDictPane.tableDataNameComboBox.getSelectedItem(); |
||||||
|
List<String> columnNames; |
||||||
|
if (wrapper != null) { |
||||||
|
columnNames = wrapper.calculateColumnNameList(); |
||||||
|
} else { |
||||||
|
columnNames = new ArrayList<String>(); |
||||||
|
} |
||||||
|
String viewColStr = tableDataDictPane.updateBean().getValueColumnName(); |
||||||
|
String modelColStr = tableDataDictPane.updateBean().getKeyColumnName(); |
||||||
|
TableDataDictionary dictionary = tableDataDictPane.updateBean(); |
||||||
|
int viewCol = columnNames.indexOf(viewColStr); |
||||||
|
int modelCol = columnNames.indexOf(modelColStr); |
||||||
|
//将数据设置到当前正在修改的layerData中
|
||||||
|
this.layerConfig.setDictionary(dictionary); |
||||||
|
this.layerConfig.setModelColumn(modelCol); |
||||||
|
this.layerConfig.setViewColumn(viewCol); |
||||||
|
this.layerConfig.setTableData(tableData); |
||||||
|
//添加依赖
|
||||||
|
java.util.List<LayerDependence> dependenceList = dependenceSettingPane.updateLayerDependence(); |
||||||
|
layerConfig.getDependenceList().clear(); |
||||||
|
layerConfig.addAll(dependenceList); |
||||||
|
return layerConfig; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
|
||||||
|
return "Layer Data Config Panel"; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,254 @@ |
|||||||
|
package com.fr.design.gui.frpane.tree.layer.config; |
||||||
|
|
||||||
|
import com.fr.base.BaseUtils; |
||||||
|
import com.fr.design.actions.UpdateAction; |
||||||
|
import com.fr.design.gui.controlpane.ControlPane; |
||||||
|
import com.fr.design.gui.icontainer.UIScrollPane; |
||||||
|
import com.fr.design.gui.itoolbar.UIToolbar; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.mainframe.DesignerContext; |
||||||
|
import com.fr.design.menu.ToolBarDef; |
||||||
|
import com.fr.form.ui.tree.LayerConfig; |
||||||
|
import com.fr.general.ComparatorUtils; |
||||||
|
import com.fr.general.Inter; |
||||||
|
import com.fr.general.NameObject; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import javax.swing.event.TreeSelectionEvent; |
||||||
|
import javax.swing.event.TreeSelectionListener; |
||||||
|
import javax.swing.tree.*; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.util.ArrayList; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by juhaoyu on 16/9/21. |
||||||
|
*/ |
||||||
|
public class LayerDataControlPane extends ControlPane { |
||||||
|
|
||||||
|
public static final String BEAN_NAME = "Tree Layer Data"; |
||||||
|
|
||||||
|
// 添加一个treeNode
|
||||||
|
private AddTreeNodeAction addTreeNode; |
||||||
|
|
||||||
|
// 移除一个treeNode
|
||||||
|
private RemoveTreeNodeAction removeTreeNode; |
||||||
|
|
||||||
|
private LayerDataConfigPane configPane; |
||||||
|
|
||||||
|
private JTree tree; |
||||||
|
|
||||||
|
private DefaultTreeModel defaultTreeModel; |
||||||
|
|
||||||
|
public LayerDataControlPane() { |
||||||
|
|
||||||
|
this.setLayout(new BorderLayout(2, 2)); |
||||||
|
//创建层编辑panel
|
||||||
|
configPane = new LayerDataConfigPane(); |
||||||
|
//创建树结构及树控件
|
||||||
|
JPanel leftPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(Inter.getLocText("FR-Designer_Root")); |
||||||
|
defaultTreeModel = new DefaultTreeModel(rootNode); |
||||||
|
tree = new JTree(defaultTreeModel); |
||||||
|
DefaultMutableTreeNode firstLayer = new DefaultMutableTreeNode(new NameObject(Inter.getLocText("FR-Designer_Gradation") + 1, new LayerConfig(1))); |
||||||
|
tree.setRootVisible(false); |
||||||
|
((DefaultMutableTreeNode) defaultTreeModel.getRoot()).getLastLeaf().add(firstLayer); |
||||||
|
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); |
||||||
|
leftPane.add(new UIScrollPane(tree), BorderLayout.CENTER); |
||||||
|
|
||||||
|
tree.setPreferredSize(new Dimension(170, 350)); |
||||||
|
tree.setCellRenderer(renderer); |
||||||
|
|
||||||
|
tree.addTreeSelectionListener(new TreeSelectionListener() { |
||||||
|
|
||||||
|
public void valueChanged(TreeSelectionEvent e) { |
||||||
|
|
||||||
|
configPane.updateBean(); |
||||||
|
refreshCurrentUpdatePane(); |
||||||
|
checkButtonEnabled(); |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
|
||||||
|
// JTreeControlPane控制栏
|
||||||
|
ToolBarDef toolbarDef = new ToolBarDef(); |
||||||
|
toolbarDef.addShortCut(addTreeNode = new AddTreeNodeAction()); |
||||||
|
toolbarDef.addShortCut(removeTreeNode = new RemoveTreeNodeAction()); |
||||||
|
UIToolbar toolBar = ToolBarDef.createJToolBar(); |
||||||
|
toolbarDef.updateToolBar(toolBar); |
||||||
|
leftPane.add(toolBar, BorderLayout.NORTH); |
||||||
|
|
||||||
|
|
||||||
|
this.add(leftPane, BorderLayout.WEST); |
||||||
|
this.add(this.configPane, BorderLayout.CENTER); |
||||||
|
|
||||||
|
defaultTreeModel.reload(); |
||||||
|
TreePath path = new TreePath(defaultTreeModel.getPathToRoot(rootNode.getLastLeaf())); |
||||||
|
tree.setSelectionPath(path); |
||||||
|
|
||||||
|
this.checkButtonEnabled(); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public void refreshCurrentUpdatePane() { |
||||||
|
|
||||||
|
TreePath selectTreePath = this.tree.getSelectionPath(); |
||||||
|
if (selectTreePath != null) { |
||||||
|
NameObject object = (NameObject) ((DefaultMutableTreeNode) selectTreePath.getLastPathComponent()).getUserObject(); |
||||||
|
if (object != null && object.getObject() != null) { |
||||||
|
configPane.populateBean((LayerConfig) object.getObject()); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
TreeCellRenderer renderer = new DefaultTreeCellRenderer() { |
||||||
|
|
||||||
|
@Override |
||||||
|
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { |
||||||
|
|
||||||
|
super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); |
||||||
|
if (leaf) { |
||||||
|
this.setIcon(BaseUtils.readIcon("com/fr/design/images/data/default_widget.png")); |
||||||
|
} else { |
||||||
|
this.setIcon(BaseUtils.readIcon("com/fr/design/images/data/arrow_branch.png")); |
||||||
|
} |
||||||
|
|
||||||
|
if (value instanceof DefaultMutableTreeNode) { |
||||||
|
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; |
||||||
|
Object userObj = node.getUserObject(); |
||||||
|
if (userObj instanceof NameObject) { |
||||||
|
this.setText(((NameObject) userObj).getName()); |
||||||
|
} |
||||||
|
} |
||||||
|
this.setBorder(BorderFactory.createEmptyBorder(0, 0, 2, 0)); |
||||||
|
return this; |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
private void checkButtonEnabled() { |
||||||
|
|
||||||
|
this.addTreeNode.setEnabled(true); |
||||||
|
this.removeTreeNode.setEnabled(true); |
||||||
|
|
||||||
|
// richer:当选择了树根节点时,不能被删除、上移和下移
|
||||||
|
DefaultMutableTreeNode root = (DefaultMutableTreeNode) defaultTreeModel.getRoot(); |
||||||
|
TreePath rootPath = new TreePath(defaultTreeModel.getPathToRoot(root)); |
||||||
|
if (ComparatorUtils.equals(rootPath, tree.getSelectionPath())) { |
||||||
|
this.removeTreeNode.setEnabled(false); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private class AddTreeNodeAction extends UpdateAction { |
||||||
|
|
||||||
|
|
||||||
|
public AddTreeNodeAction() { |
||||||
|
|
||||||
|
this.setName(Inter.getLocText("FR-Designer_Add")); |
||||||
|
this.setMnemonic('A'); |
||||||
|
this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/cell/control/add.png")); |
||||||
|
} |
||||||
|
|
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
|
||||||
|
DefaultMutableTreeNode node = (DefaultMutableTreeNode) defaultTreeModel.getRoot(); |
||||||
|
|
||||||
|
DefaultMutableTreeNode innerNode = node; |
||||||
|
int nodeCount = 0; |
||||||
|
do { |
||||||
|
nodeCount++; |
||||||
|
} while ((innerNode = innerNode.getNextNode()) != null); |
||||||
|
NameObject nameable = new NameObject(Inter.getLocText("FR-Designer_Gradation") + nodeCount, new LayerConfig(nodeCount)); |
||||||
|
|
||||||
|
node.getLastLeaf().add(new DefaultMutableTreeNode(nameable)); |
||||||
|
defaultTreeModel.reload(); |
||||||
|
TreePath path = new TreePath(defaultTreeModel.getPathToRoot(node.getLastLeaf())); |
||||||
|
tree.setSelectionPath(path); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private class RemoveTreeNodeAction extends UpdateAction { |
||||||
|
|
||||||
|
public RemoveTreeNodeAction() { |
||||||
|
|
||||||
|
this.setName(Inter.getLocText("FR-Designer_Remove")); |
||||||
|
this.setMnemonic('R'); |
||||||
|
this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/cell/control/remove.png")); |
||||||
|
} |
||||||
|
|
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
// TODO remove tree node
|
||||||
|
int val = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Utils-Are_you_sure_to_remove_the_selected_item") + "?", |
||||||
|
Inter.getLocText("FR-Designer_Remove"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); |
||||||
|
if (val != JOptionPane.OK_OPTION) { |
||||||
|
return; |
||||||
|
} |
||||||
|
TreePath selectionPath = tree.getSelectionPath(); |
||||||
|
DefaultMutableTreeNode tmpNode = (DefaultMutableTreeNode) selectionPath.getLastPathComponent(); |
||||||
|
tmpNode.removeFromParent(); |
||||||
|
defaultTreeModel.reload(); |
||||||
|
DefaultMutableTreeNode node = (DefaultMutableTreeNode) defaultTreeModel.getRoot(); |
||||||
|
TreePath path = new TreePath(defaultTreeModel.getPathToRoot(node.getLastLeaf())); |
||||||
|
tree.setSelectionPath(path); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void populate(NameObject nameObject) { |
||||||
|
// 重新添加tree节点的时候需要remove掉原来的所有子节点
|
||||||
|
((DefaultMutableTreeNode) defaultTreeModel.getRoot()).removeAllChildren(); |
||||||
|
if (BEAN_NAME.equals(nameObject.getName())) { |
||||||
|
Object obj = nameObject.getObject(); |
||||||
|
LayerConfig[] layerConfigs = null; |
||||||
|
if (obj instanceof LayerConfig[]) { |
||||||
|
layerConfigs = ((LayerConfig[]) obj); |
||||||
|
} |
||||||
|
|
||||||
|
int count = layerConfigs == null ? 0 : layerConfigs.length; |
||||||
|
//将树的层次一层一层的加上去
|
||||||
|
DefaultMutableTreeNode node4root = (DefaultMutableTreeNode) defaultTreeModel.getRoot(); |
||||||
|
for (int i = 0; i < count; i++) { |
||||||
|
|
||||||
|
DefaultMutableTreeNode node4add = new DefaultMutableTreeNode( |
||||||
|
new NameObject(Inter.getLocText("FR-Designer_Gradation") + (i + 1), layerConfigs[i].clone())); |
||||||
|
node4root.add(node4add); |
||||||
|
node4root = node4add; |
||||||
|
} |
||||||
|
|
||||||
|
defaultTreeModel.reload(); |
||||||
|
expandAll(tree, true); |
||||||
|
tree.setSelectionRow(0); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public NameObject update() { |
||||||
|
|
||||||
|
return new NameObject(BEAN_NAME, updateLayerDatas()); |
||||||
|
} |
||||||
|
|
||||||
|
private LayerConfig[] updateLayerDatas() { |
||||||
|
|
||||||
|
//保存最后一个设置的层级
|
||||||
|
configPane.updateBean(); |
||||||
|
DefaultMutableTreeNode root = (DefaultMutableTreeNode) defaultTreeModel.getRoot(); |
||||||
|
java.util.List<LayerConfig> nodeList = new ArrayList<LayerConfig>(); |
||||||
|
|
||||||
|
for (; root != null; root = root.getNextNode()) { |
||||||
|
if (!(root.getUserObject() instanceof NameObject)) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
NameObject no = (NameObject) root.getUserObject(); |
||||||
|
if (no.getObject() instanceof LayerConfig) { |
||||||
|
nodeList.add((LayerConfig) no.getObject()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return nodeList.toArray(new LayerConfig[nodeList.size()]); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
|
||||||
|
return "Layer Data Control Pane"; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,459 @@ |
|||||||
|
package com.fr.design.gui.frpane.tree.layer.config; |
||||||
|
|
||||||
|
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; |
||||||
|
import com.fr.design.gui.ibutton.UIButton; |
||||||
|
import com.fr.design.gui.icombobox.UIComboBox; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.present.dict.TableDataDictPane; |
||||||
|
import com.fr.form.ui.tree.LayerDependence; |
||||||
|
import com.fr.general.Inter; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import javax.swing.table.AbstractTableModel; |
||||||
|
import javax.swing.table.TableCellEditor; |
||||||
|
import javax.swing.table.TableCellRenderer; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.ActionListener; |
||||||
|
import java.awt.event.ItemEvent; |
||||||
|
import java.awt.event.ItemListener; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by juhaoyu on 16/9/19. |
||||||
|
*/ |
||||||
|
public class LayerDependenceSettingPane extends JPanel implements ItemListener { |
||||||
|
|
||||||
|
/** |
||||||
|
* 用户选择数据集的pane,在LayerDataConfigPane中传入 |
||||||
|
*/ |
||||||
|
private TableDataDictPane tableDataDictPane; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 添加依赖按钮 |
||||||
|
*/ |
||||||
|
private UIButton addButton; |
||||||
|
|
||||||
|
/** |
||||||
|
* 删除依赖按钮 |
||||||
|
*/ |
||||||
|
private UIButton delButton; |
||||||
|
|
||||||
|
/** |
||||||
|
* 依赖关系编辑Table |
||||||
|
*/ |
||||||
|
private JTable dependenceTable; |
||||||
|
|
||||||
|
/** |
||||||
|
* Table的数据模型,两个按钮的操作直接对应于model |
||||||
|
*/ |
||||||
|
private LayerDepenceTableModel model; |
||||||
|
|
||||||
|
/** |
||||||
|
* 当前该panel所设置的层级 |
||||||
|
*/ |
||||||
|
private int currentLayerIndex = 1; |
||||||
|
|
||||||
|
private FieldRenderer fieldRenderer; |
||||||
|
|
||||||
|
private LayerIndexEditor layerIndexEditor; |
||||||
|
|
||||||
|
private FiledEditor fieldEditor; |
||||||
|
|
||||||
|
|
||||||
|
public LayerDependenceSettingPane(TableDataDictPane tableDictPane) { |
||||||
|
//关联数据集选择,并添加监听
|
||||||
|
this.tableDataDictPane = tableDictPane; |
||||||
|
tableDataDictPane.tableDataNameComboBox.addItemListener(this); |
||||||
|
|
||||||
|
//初始化按钮对象
|
||||||
|
addButton = new UIButton(Inter.getLocText("add")); |
||||||
|
delButton = new UIButton(Inter.getLocText("Delete")); |
||||||
|
//初始化Table对象,并添加renderer和editor
|
||||||
|
model = new LayerDepenceTableModel(); |
||||||
|
dependenceTable = new JTable(); |
||||||
|
dependenceTable.setModel(model); |
||||||
|
//初始化辅助组件
|
||||||
|
fieldEditor = new FiledEditor(tableDataDictPane); |
||||||
|
fieldRenderer = new FieldRenderer(tableDictPane); |
||||||
|
layerIndexEditor = new LayerIndexEditor(currentLayerIndex); |
||||||
|
//添加renderer
|
||||||
|
dependenceTable.getColumnModel().getColumn(0).setCellRenderer(new FirstRenderer()); |
||||||
|
dependenceTable.getColumnModel().getColumn(1).setCellRenderer(fieldRenderer); |
||||||
|
//添加第一列editor
|
||||||
|
dependenceTable.getColumnModel().getColumn(0).setCellEditor(layerIndexEditor); |
||||||
|
//添加第二列editor
|
||||||
|
dependenceTable.getColumnModel().getColumn(1).setCellEditor(fieldEditor); |
||||||
|
//添加add按钮监听
|
||||||
|
addButton.addActionListener(new ActionListener() { |
||||||
|
|
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
//先要停止编辑,然后再添加
|
||||||
|
fieldEditor.stopCellEditing(); |
||||||
|
layerIndexEditor.stopCellEditing(); |
||||||
|
LayerDependenceSettingPane.this.model.addDependence(); |
||||||
|
} |
||||||
|
}); |
||||||
|
//添加del按钮监听
|
||||||
|
delButton.addActionListener(new ActionListener() { |
||||||
|
|
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
|
||||||
|
if (0 == dependenceTable.getSelectedRowCount()) { |
||||||
|
return; |
||||||
|
} |
||||||
|
//获取视图索引,并根据视图索引获取model索引,删除model指定行
|
||||||
|
int selectedRow = dependenceTable.getSelectedRow(); |
||||||
|
int selectedRowModelIndex = dependenceTable.convertRowIndexToModel(selectedRow); |
||||||
|
//先要停止编辑,然后再删除
|
||||||
|
fieldEditor.stopCellEditing(); |
||||||
|
layerIndexEditor.stopCellEditing(); |
||||||
|
model.delDependence(selectedRowModelIndex); |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
|
||||||
|
//生成布局
|
||||||
|
this.setLayout(new BorderLayout(2, 2)); |
||||||
|
//添加按钮panel
|
||||||
|
JPanel buttonPanel = new JPanel(); |
||||||
|
buttonPanel.setLayout(new FlowLayout(2)); |
||||||
|
buttonPanel.add(addButton); |
||||||
|
buttonPanel.add(delButton); |
||||||
|
this.add(buttonPanel, BorderLayout.NORTH); |
||||||
|
//添加Table的panel
|
||||||
|
JScrollPane tablePanel = new JScrollPane(dependenceTable); |
||||||
|
this.add(tablePanel, BorderLayout.CENTER); |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public void populate(int layerIndex, List<LayerDependence> dependenceList) { |
||||||
|
|
||||||
|
this.currentLayerIndex = layerIndex; |
||||||
|
//更新Editor
|
||||||
|
this.layerIndexEditor.layerChanged(layerIndex); |
||||||
|
this.fieldEditor.layerChanged(); |
||||||
|
|
||||||
|
this.model.clear(); |
||||||
|
this.model.addAll(dependenceList); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public List<LayerDependence> updateLayerDependence() { |
||||||
|
//保存现有编辑
|
||||||
|
this.fieldEditor.stopCellEditing(); |
||||||
|
this.layerIndexEditor.stopCellEditing(); |
||||||
|
return this.model.update(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 当tableDataDictPane变化时,调用该方法 |
||||||
|
*/ |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public void itemStateChanged(ItemEvent e) { |
||||||
|
|
||||||
|
clearDependences(); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 清楚当前设置的依赖关系 |
||||||
|
*/ |
||||||
|
private void clearDependences() { |
||||||
|
|
||||||
|
this.model.clear(); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 第一列renderer |
||||||
|
*/ |
||||||
|
private static final class FirstRenderer extends UILabel implements TableCellRenderer { |
||||||
|
|
||||||
|
@Override |
||||||
|
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { |
||||||
|
|
||||||
|
if (value != null) { |
||||||
|
//value是用户选择的字段索引值,从1开始的
|
||||||
|
this.setText(String.valueOf(value)); |
||||||
|
} else { |
||||||
|
this.setText(""); |
||||||
|
} |
||||||
|
if (hasFocus) { |
||||||
|
this.setBorder(UIManager.getBorder("Table.focusCelHighlightBorder")); |
||||||
|
} else { |
||||||
|
this.setBorder(null); |
||||||
|
} |
||||||
|
return this; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 第二列renderer |
||||||
|
* 由于从model中获取的数据是数据集列的索引值,这里要转换为列的名称 |
||||||
|
*/ |
||||||
|
private static final class FieldRenderer extends UILabel implements TableCellRenderer { |
||||||
|
|
||||||
|
//用于将字段索引转换为字段名;保存改pane,是为了当用户选择其他数据集时,renderer可同步更新
|
||||||
|
private TableDataDictPane tableDataDictPane; |
||||||
|
|
||||||
|
public FieldRenderer(TableDataDictPane tableDataDictPane) { |
||||||
|
|
||||||
|
this.tableDataDictPane = tableDataDictPane; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 由于数据是从tableDataDictPane中现取的,所以用户选择不同的数据集时,renderer同步更新; |
||||||
|
* 此时只需要在用户选择数据集时,刷新Table即可,不需要对renderer处理 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { |
||||||
|
|
||||||
|
if (value != null) { |
||||||
|
List<String> columnNames = getColumnNameList(this.tableDataDictPane); |
||||||
|
//value是用户选择的字段索引值,从1开始的
|
||||||
|
this.setText(columnNames.get(Integer.valueOf(String.valueOf(value)))); |
||||||
|
} else { |
||||||
|
this.setText(""); |
||||||
|
} |
||||||
|
if (hasFocus) { |
||||||
|
this.setBorder(UIManager.getBorder("Table.focusCelHighlightBorder")); |
||||||
|
} else { |
||||||
|
this.setBorder(null); |
||||||
|
} |
||||||
|
return this; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 第一列editor |
||||||
|
* 该editor于layerIndex关联,当用户选择不同的层时,这个editor要同步更新 |
||||||
|
*/ |
||||||
|
private static final class LayerIndexEditor extends AbstractCellEditor implements TableCellEditor { |
||||||
|
|
||||||
|
private int currentLayerIndex; |
||||||
|
|
||||||
|
private UIComboBox layerChoseCombobox = new UIComboBox(); |
||||||
|
|
||||||
|
public LayerIndexEditor(int currentLayerIndex) { |
||||||
|
|
||||||
|
this.currentLayerIndex = currentLayerIndex; |
||||||
|
for (int i = 1; i < currentLayerIndex; i++) { |
||||||
|
layerChoseCombobox.addItem(i); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { |
||||||
|
|
||||||
|
if (value != null) { |
||||||
|
layerChoseCombobox.setSelectedIndex(Integer.valueOf(String.valueOf(value)) - 1); |
||||||
|
} |
||||||
|
return layerChoseCombobox; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Object getCellEditorValue() { |
||||||
|
|
||||||
|
return layerChoseCombobox.getSelectedItem(); |
||||||
|
} |
||||||
|
|
||||||
|
public void layerChanged(int newLayerIndex) { |
||||||
|
|
||||||
|
this.currentLayerIndex = newLayerIndex; |
||||||
|
layerChoseCombobox.removeAllItems(); |
||||||
|
for (int i = 1; i < currentLayerIndex; i++) { |
||||||
|
layerChoseCombobox.addItem(i); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 第二列editor |
||||||
|
*/ |
||||||
|
private static final class FiledEditor extends AbstractCellEditor implements TableCellEditor { |
||||||
|
|
||||||
|
private UIComboBox layerChoseCombobox = new UIComboBox(); |
||||||
|
|
||||||
|
TableDataDictPane tableDataDictPane; |
||||||
|
|
||||||
|
public FiledEditor(TableDataDictPane tableDataDictPane) { |
||||||
|
|
||||||
|
this.tableDataDictPane = tableDataDictPane; |
||||||
|
List<String> columnNames = getColumnNameList(this.tableDataDictPane); |
||||||
|
for (String columnName : columnNames) { |
||||||
|
this.layerChoseCombobox.addItem(columnName); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { |
||||||
|
|
||||||
|
List<String> columnNames = getColumnNameList(this.tableDataDictPane); |
||||||
|
layerChoseCombobox.removeAllItems(); |
||||||
|
for (String columnName : columnNames) { |
||||||
|
|
||||||
|
layerChoseCombobox.addItem(columnName); |
||||||
|
} |
||||||
|
if (value != null) { |
||||||
|
layerChoseCombobox.setSelectedIndex(Integer.valueOf(String.valueOf(value))); |
||||||
|
} |
||||||
|
return layerChoseCombobox; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Object getCellEditorValue() { |
||||||
|
//转化为数据集的列索引(从0开始)
|
||||||
|
return layerChoseCombobox.getSelectedIndex(); |
||||||
|
} |
||||||
|
|
||||||
|
public void layerChanged() { |
||||||
|
|
||||||
|
List<String> columnNames = getColumnNameList(this.tableDataDictPane); |
||||||
|
layerChoseCombobox.removeAllItems(); |
||||||
|
for (String columnName : columnNames) { |
||||||
|
|
||||||
|
layerChoseCombobox.addItem(columnName); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private static List<String> getColumnNameList(TableDataDictPane tableDataDictPane) { |
||||||
|
|
||||||
|
TableDataWrapper wrapper = tableDataDictPane.tableDataNameComboBox.getSelectedItem(); |
||||||
|
if (wrapper == null) { |
||||||
|
return new ArrayList<String>(); |
||||||
|
} else { |
||||||
|
return wrapper.calculateColumnNameList(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private static class LayerDepenceTableModel extends AbstractTableModel { |
||||||
|
|
||||||
|
private List<LayerDependence> dependences; |
||||||
|
|
||||||
|
public LayerDepenceTableModel() { |
||||||
|
|
||||||
|
dependences = new ArrayList<LayerDependence>(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 添加一条数据,该方法会请求Table进行重绘(通过发送时间,告诉JTable数据更新,JTable会自动重绘) |
||||||
|
*/ |
||||||
|
public void addDependence() { |
||||||
|
|
||||||
|
dependences.add(new LayerDependence()); |
||||||
|
fireTableRowsInserted(dependences.size(), dependences.size()); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 删除一条数据 |
||||||
|
* |
||||||
|
* @param rowIndex |
||||||
|
*/ |
||||||
|
public void delDependence(int rowIndex) { |
||||||
|
|
||||||
|
if (rowIndex < 0 || rowIndex >= dependences.size()) { |
||||||
|
return; |
||||||
|
} |
||||||
|
dependences.remove(rowIndex); |
||||||
|
fireTableRowsDeleted(rowIndex + 1, rowIndex + 1); |
||||||
|
} |
||||||
|
|
||||||
|
public void addAll(List<LayerDependence> dependenceList) { |
||||||
|
|
||||||
|
dependences.addAll(dependenceList); |
||||||
|
fireTableRowsInserted(1, dependenceList.size()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isCellEditable(int rowIndex, int columnIndex) { |
||||||
|
|
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Class<?> getColumnClass(int column) { |
||||||
|
|
||||||
|
return Integer.class; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getColumnName(int column) { |
||||||
|
|
||||||
|
String name; |
||||||
|
if (column == 0) { |
||||||
|
name = Inter.getLocText("FR-Designer_layerIndex"); |
||||||
|
} else { |
||||||
|
name = Inter.getLocText("FR-Designer_filedChosen"); |
||||||
|
} |
||||||
|
return name; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int getRowCount() { |
||||||
|
|
||||||
|
return dependences.size(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int getColumnCount() { |
||||||
|
|
||||||
|
return 2; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Object getValueAt(int rowIndex, int columnIndex) { |
||||||
|
|
||||||
|
LayerDependence dependence = dependences.get(rowIndex); |
||||||
|
Object obj; |
||||||
|
if (columnIndex == 0) { |
||||||
|
obj = dependence.getLayerIndex(); |
||||||
|
} else { |
||||||
|
obj = dependence.getThisColumnIndex(); |
||||||
|
} |
||||||
|
return obj; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void setValueAt(Object aValue, int rowIndex, int columnIndex) { |
||||||
|
|
||||||
|
LayerDependence dependence = dependences.get(rowIndex); |
||||||
|
if (aValue != null) { |
||||||
|
if (columnIndex == 0) { |
||||||
|
dependence.setLayerIndex((Integer) aValue); |
||||||
|
} else { |
||||||
|
dependence.setThisColumnIndex((Integer) aValue); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public void clear() { |
||||||
|
|
||||||
|
int length = dependences.size(); |
||||||
|
dependences.clear(); |
||||||
|
fireTableRowsDeleted(1, length); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public List<LayerDependence> update() { |
||||||
|
|
||||||
|
return this.dependences; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
@ -0,0 +1,48 @@ |
|||||||
|
package com.fr.design.hyperlink; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by ibm on 2016/10/13. |
||||||
|
*/ |
||||||
|
public enum HyperlinkTargetFrame { |
||||||
|
BLANK_FRAME("_blank", 0), DIALOG_FRAME("_dialog", 1), SELF_FRAME("_self", 2); |
||||||
|
|
||||||
|
private String name; |
||||||
|
private int index; |
||||||
|
private static HyperlinkTargetFrame[] arrayOfValues; |
||||||
|
|
||||||
|
HyperlinkTargetFrame(String name, int index) { |
||||||
|
this.name = name; |
||||||
|
this.index = index; |
||||||
|
} |
||||||
|
|
||||||
|
public static HyperlinkTargetFrame parse(int index) { |
||||||
|
if (arrayOfValues == null) { |
||||||
|
arrayOfValues = HyperlinkTargetFrame.values(); |
||||||
|
} |
||||||
|
for (HyperlinkTargetFrame hyperlinkTargetFrame : HyperlinkTargetFrame.values()) { |
||||||
|
if (hyperlinkTargetFrame.getIndex() == index) { |
||||||
|
return hyperlinkTargetFrame; |
||||||
|
} |
||||||
|
} |
||||||
|
return BLANK_FRAME; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public int getIndex() { |
||||||
|
return index; |
||||||
|
} |
||||||
|
|
||||||
|
public void setIndex(int index) { |
||||||
|
this.index = index; |
||||||
|
} |
||||||
|
|
||||||
|
public String getName() { |
||||||
|
return name; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public void setName(String name) { |
||||||
|
this.name = name; |
||||||
|
} |
||||||
|
} |
||||||
|
|
After Width: | Height: | Size: 239 B |
@ -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/${branchName}",include:'**/*.jar') |
||||||
|
compile fileTree(dir:'../../../',include:"finereport-*-stable/${branchName}/**/build/libs/*.jar") |
||||||
|
|
||||||
|
testCompile 'junit:junit:4.12' |
||||||
|
} |
||||||
|
//将非.java 文件复制到classes文件夹下参与打包 |
||||||
|
task copyFile(type:Copy,dependsOn:compileJava){ |
||||||
|
copy{ |
||||||
|
from ("${srcDir}/src"){ |
||||||
|
exclude '**/.setting/**','.classpath','.project','**/*.java','**/*.db','**/*.g','**/package.html' |
||||||
|
|
||||||
|
} |
||||||
|
into 'build/classes/main' |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
//压缩项目中的js文件 |
||||||
|
task compressJS{ |
||||||
|
ant.taskdef(name:'yuicompress',classname:'com.yahoo.platform.yui.compressor.YUICompressTask'){ |
||||||
|
classpath { |
||||||
|
fileset(dir:'../../../finereport-lib4build-stable',includes:'**/*.jar') |
||||||
|
} |
||||||
|
} |
||||||
|
ant.yuicompress(linebreak:"500",warn:"false", munge:"yes",preserveallsemicolons:"false",charset:"utf-8",encoding:"utf-8",outputfolder:'build/classes/main'){ |
||||||
|
fileset (dir:"${srcDir}/src"){ |
||||||
|
include (name:'**/*.js') |
||||||
|
include (name:'**/*.css') |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
jar.dependsOn compressJS |
||||||
|
|
@ -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/${branchName}",include:'**/*.jar') |
||||||
|
compile fileTree(dir:'../../../',include:"finereport-*-stable/${branchName}/**/build/libs/*.jar") |
||||||
|
|
||||||
|
testCompile 'junit:junit:4.12' |
||||||
|
} |
||||||
|
|
||||||
|
//指明无法编译文件所在路径 |
||||||
|
def dataContent ={def dir -> |
||||||
|
copySpec{ |
||||||
|
from ("${dir}"){ |
||||||
|
exclude '**/.setting/**','.classpath','.project','**/*.java','**/*.db','**/*.g','**/package.html' |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
//将非.java文件复制到classes文件夹下 参与打包 |
||||||
|
task copyFile(type:Copy,dependsOn:compileJava){ |
||||||
|
copy{ |
||||||
|
with dataContent.call("${srcDir}/src") |
||||||
|
with dataContent.call("${srcDir}/../designer/src") |
||||||
|
into ('build/classes/main') |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
//压缩项目中的js文件 |
||||||
|
task compressJS{ |
||||||
|
ant.taskdef(name:'yuicompress',classname:'com.yahoo.platform.yui.compressor.YUICompressTask'){ |
||||||
|
classpath { |
||||||
|
|
||||||
|
fileset(dir:'../../../finereport-lib4build-stable',includes:'**/*.jar') |
||||||
|
} |
||||||
|
} |
||||||
|
ant.yuicompress(linebreak:"500",warn:"false", munge:"yes",preserveallsemicolons:"false", charset:"utf-8",encoding:"utf-8",outputfolder:'build/classes/main'){ |
||||||
|
fileset (dir:"${srcDir}/src"){ |
||||||
|
include (name:'**/*.js') |
||||||
|
include (name:'**/*.css') |
||||||
|
|
||||||
|
} |
||||||
|
fileset (dir:"${srcDir}/../designer/src"){ |
||||||
|
include (name:'**/*.js') |
||||||
|
include (name:'**/*.css') |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
jar.dependsOn compressJS |
||||||
|
|
@ -0,0 +1,30 @@ |
|||||||
|
package com.fr.design.designer.beans.adapters.layout; |
||||||
|
|
||||||
|
import com.fr.design.beans.GroupModel; |
||||||
|
import com.fr.design.designer.creator.XLayoutContainer; |
||||||
|
import com.fr.design.designer.creator.XWAbsoluteBodyLayout; |
||||||
|
import com.fr.design.designer.creator.XWAbsoluteLayout; |
||||||
|
import com.fr.design.designer.creator.XWFitLayout; |
||||||
|
import com.fr.design.designer.properties.FRAbsoluteBodyLayoutPropertiesGroupModel; |
||||||
|
import com.fr.design.designer.properties.FRAbsoluteLayoutPropertiesGroupModel; |
||||||
|
import com.fr.form.ui.container.WBodyLayoutType; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by zhouping on 2016/10/14. |
||||||
|
*/ |
||||||
|
public class FRAbsoluteBodyLayoutAdapter extends FRAbsoluteLayoutAdapter { |
||||||
|
public FRAbsoluteBodyLayoutAdapter(XLayoutContainer container) { |
||||||
|
super(container); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public GroupModel getLayoutProperties() { |
||||||
|
XWAbsoluteBodyLayout xwAbsoluteBodyLayout = (XWAbsoluteBodyLayout) container; |
||||||
|
//如果body是绝对布局,那么获取原来自适应body的属性--布局类型
|
||||||
|
WBodyLayoutType layoutType = WBodyLayoutType.FIT; |
||||||
|
if (container.getParent() != null) { |
||||||
|
layoutType = ((XWFitLayout)container.getParent()).toData().getBodyLayoutType(); |
||||||
|
} |
||||||
|
return new FRAbsoluteBodyLayoutPropertiesGroupModel(xwAbsoluteBodyLayout, layoutType); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,45 @@ |
|||||||
|
package com.fr.design.designer.creator; |
||||||
|
|
||||||
|
import com.fr.design.designer.beans.LayoutAdapter; |
||||||
|
import com.fr.design.designer.beans.adapters.layout.FRAbsoluteBodyLayoutAdapter; |
||||||
|
import com.fr.form.ui.container.WAbsoluteBodyLayout; |
||||||
|
|
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by zhouping on 2016/10/14. |
||||||
|
* 用作body的绝对布局 |
||||||
|
*/ |
||||||
|
public class XWAbsoluteBodyLayout extends XWAbsoluteLayout { |
||||||
|
public XWAbsoluteBodyLayout(WAbsoluteBodyLayout widget, Dimension initSize) { |
||||||
|
super(widget, initSize); |
||||||
|
this.editable = true; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 返回对应的widget容器 |
||||||
|
* |
||||||
|
* @return 返回WAbsoluteLayout |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public WAbsoluteBodyLayout toData() { |
||||||
|
return (WAbsoluteBodyLayout)data; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public LayoutAdapter getLayoutAdapter() { |
||||||
|
return new FRAbsoluteBodyLayoutAdapter(this); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 假如是body的话,始终要能编辑,不会出现蒙层 |
||||||
|
* |
||||||
|
* @param isEditable 可否编辑 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void setEditable(boolean isEditable) { |
||||||
|
super.setEditable(true); |
||||||
|
} |
||||||
|
} |
@ -1,11 +1,10 @@ |
|||||||
package com.fr.design.designer.properties; |
package com.fr.design.designer.properties; |
||||||
|
|
||||||
import com.fr.design.mainframe.widget.renderer.EncoderCellRenderer; |
|
||||||
|
|
||||||
/** |
/** |
||||||
* Created by zhouping on 2016/8/1. |
* Created by zhouping on 2016/8/1. |
||||||
*/ |
*/ |
||||||
public class AbsoluteStateRenderer extends EncoderCellRenderer { |
public class AbsoluteStateRenderer extends BodyLayoutAttrRenderer { |
||||||
|
|
||||||
public AbsoluteStateRenderer() { |
public AbsoluteStateRenderer() { |
||||||
super(new AbsoluteStateWrapper()); |
super(new AbsoluteStateWrapper()); |
||||||
} |
} |
||||||
|
@ -0,0 +1,23 @@ |
|||||||
|
package com.fr.design.designer.properties; |
||||||
|
|
||||||
|
import com.fr.design.mainframe.widget.renderer.EncoderCellRenderer; |
||||||
|
import com.fr.general.IOUtils; |
||||||
|
|
||||||
|
import java.awt.*; |
||||||
|
import java.awt.image.BufferedImage; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by zhouping on 2016/10/14. |
||||||
|
*/ |
||||||
|
public class BodyLayoutAttrRenderer extends EncoderCellRenderer { |
||||||
|
public BodyLayoutAttrRenderer(Encoder encoder) { |
||||||
|
super(encoder); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void paint(Graphics g) { |
||||||
|
super.paint(g); |
||||||
|
BufferedImage image = IOUtils.readImage("com/fr/design/images/control/combobox.png"); |
||||||
|
g.drawImage(image, getWidth() - image.getWidth(), 0, image.getWidth(), image.getHeight(), null, this); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,239 @@ |
|||||||
|
package com.fr.design.designer.properties; |
||||||
|
|
||||||
|
import com.fr.design.designer.creator.XWAbsoluteBodyLayout; |
||||||
|
import com.fr.design.designer.creator.XWFitLayout; |
||||||
|
import com.fr.design.mainframe.FormDesigner; |
||||||
|
import com.fr.design.mainframe.FormSelectionUtils; |
||||||
|
import com.fr.design.mainframe.WidgetPropertyPane; |
||||||
|
import com.fr.design.mainframe.widget.editors.LayoutTypeEditor; |
||||||
|
import com.fr.design.utils.gui.LayoutUtils; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.form.ui.container.WBodyLayoutType; |
||||||
|
import com.fr.general.FRScreen; |
||||||
|
import com.fr.general.Inter; |
||||||
|
|
||||||
|
import javax.swing.table.TableCellEditor; |
||||||
|
import javax.swing.table.TableCellRenderer; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.geom.Arc2D; |
||||||
|
import java.util.Arrays; |
||||||
|
import java.util.Comparator; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by zhouping on 2016/10/14. |
||||||
|
*/ |
||||||
|
public class FRAbsoluteBodyLayoutPropertiesGroupModel extends FRAbsoluteLayoutPropertiesGroupModel { |
||||||
|
private LayoutTypeEditor layoutTypeEditor; |
||||||
|
private LayoutTypeRenderer layoutTypeRenderer; |
||||||
|
//默认body是0,自适应布局;1,绝对布局.
|
||||||
|
private WBodyLayoutType layoutType = WBodyLayoutType.ABSOLUTE; |
||||||
|
public FRAbsoluteBodyLayoutPropertiesGroupModel(XWAbsoluteBodyLayout xwAbsoluteBodyLayout) { |
||||||
|
super(xwAbsoluteBodyLayout); |
||||||
|
} |
||||||
|
|
||||||
|
public FRAbsoluteBodyLayoutPropertiesGroupModel(XWAbsoluteBodyLayout xwAbsoluteBodyLayout, WBodyLayoutType layoutType){ |
||||||
|
this(xwAbsoluteBodyLayout); |
||||||
|
this.layoutTypeEditor = new LayoutTypeEditor(); |
||||||
|
this.layoutTypeRenderer = new LayoutTypeRenderer(); |
||||||
|
this.layoutType = layoutType; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 布局管理器自己的属性 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public String getGroupName() { |
||||||
|
return Inter.getLocText("FR-Designer_Attr_Layout"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int getRowCount() { |
||||||
|
return 2; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public TableCellRenderer getRenderer(int row) { |
||||||
|
return row == 0 ? layoutTypeRenderer : stateRenderer; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public TableCellEditor getEditor(int row) { |
||||||
|
return row == 0 ? layoutTypeEditor : stateEditor; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Object getValue(int row, int column) { |
||||||
|
if (column == 0) { |
||||||
|
switch (row) { |
||||||
|
case 0: |
||||||
|
return Inter.getLocText("FR-Designer_Attr_Layout_Type"); |
||||||
|
default: |
||||||
|
return Inter.getLocText("FR-Designer-Widget_Scaling_Mode"); |
||||||
|
} |
||||||
|
} else { |
||||||
|
switch (row) { |
||||||
|
case 0: |
||||||
|
return layoutType.getTypeValue(); |
||||||
|
default: |
||||||
|
return layout.getCompState(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean setValue(Object value, int row, int column) { |
||||||
|
if (layoutType == WBodyLayoutType.ABSOLUTE){ |
||||||
|
int state = 0; |
||||||
|
if(value instanceof Integer) { |
||||||
|
state = (Integer)value; |
||||||
|
} |
||||||
|
if (column == 0 || state < 0) { |
||||||
|
return false; |
||||||
|
} else { |
||||||
|
if (row == 0) { |
||||||
|
if (state == WBodyLayoutType.FIT.getTypeValue()) { |
||||||
|
XWFitLayout xfl = (XWFitLayout) xwAbsoluteLayout.getBackupParent(); |
||||||
|
Component[] components = xwAbsoluteLayout.getComponents(); |
||||||
|
|
||||||
|
Arrays.sort(components, new ComparatorComponentLocation()); |
||||||
|
|
||||||
|
xfl.getLayoutAdapter().removeBean(xwAbsoluteLayout, xwAbsoluteLayout.getWidth(), xwAbsoluteLayout.getHeight()); |
||||||
|
xfl.remove(xwAbsoluteLayout); |
||||||
|
xfl.toData().setLayoutType(WBodyLayoutType.FIT); |
||||||
|
|
||||||
|
for (Component comp : components) { |
||||||
|
xfl.add(comp); |
||||||
|
} |
||||||
|
moveComponents2FitLayout(xfl, components); |
||||||
|
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); |
||||||
|
formDesigner.getSelectionModel().setSelectedCreators( |
||||||
|
FormSelectionUtils.rebuildSelection(xfl, new Widget[]{xfl.toData()})); |
||||||
|
xfl.convert(); |
||||||
|
LayoutUtils.layoutContainer(xfl); |
||||||
|
xfl.adjustCreatorsWhileSlide(xfl.getContainerPercent() - 1.0); |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
||||||
|
if (row == 1) { |
||||||
|
layout.setCompState(state); |
||||||
|
return true; |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
int state = 0; |
||||||
|
if(value instanceof Integer) { |
||||||
|
state = (Integer)value; |
||||||
|
} |
||||||
|
if (column == 0 || state < 0) { |
||||||
|
return false; |
||||||
|
} else { |
||||||
|
if (row == 0) { |
||||||
|
layout.setCompState(state); |
||||||
|
return true; |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 是否可编辑 |
||||||
|
* @param row 行 |
||||||
|
* @return 否 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public boolean isEditable(int row) { |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
//把绝对布局中的元素按规则移动到自适应布局中
|
||||||
|
private void moveComponents2FitLayout(XWFitLayout xwFitLayout, Component[] components) { |
||||||
|
int eachRowCount = 4; |
||||||
|
if (components.length <= 1){ |
||||||
|
return; |
||||||
|
} |
||||||
|
int layoutWidth = xwFitLayout.getWidth() - xwFitLayout.toData().getMargin().getLeft() - xwFitLayout.toData().getMargin().getRight(); |
||||||
|
int layoutHeight = xwFitLayout.getHeight() - xwFitLayout.toData().getMargin().getTop() - xwFitLayout.toData().getMargin().getBottom(); |
||||||
|
int leftMargin = xwFitLayout.toData().getMargin().getLeft(); |
||||||
|
int topMargin = xwFitLayout.toData().getMargin().getTop(); |
||||||
|
int row = (components.length / eachRowCount) + (components.length % eachRowCount == 0 ? 0 : 1); |
||||||
|
//最后一行的列数不定
|
||||||
|
int column = components.length % eachRowCount == 0 ? eachRowCount : components.length % eachRowCount; |
||||||
|
int componentWidth = layoutWidth / eachRowCount; |
||||||
|
int componentHeight = layoutHeight / row; |
||||||
|
for(int i = 0;i < row - 1;i++){ |
||||||
|
for(int j = 0;j < eachRowCount;j++){ |
||||||
|
components[eachRowCount * i + j].setBounds( |
||||||
|
leftMargin + componentWidth * j, |
||||||
|
topMargin + componentHeight * i, |
||||||
|
j == eachRowCount - 1 ? layoutWidth - componentWidth * (eachRowCount - 1) : componentWidth, |
||||||
|
componentHeight |
||||||
|
); |
||||||
|
} |
||||||
|
} |
||||||
|
//最后一行列数是特殊的,要单独处理
|
||||||
|
int lastRowWidth = layoutWidth / column; |
||||||
|
int lastRowHeight = layoutHeight - componentHeight * (row - 1); |
||||||
|
for (int i = 0;i < column;i++) { |
||||||
|
components[eachRowCount * (row - 1) + i].setBounds( |
||||||
|
leftMargin + lastRowWidth * i, |
||||||
|
topMargin + componentHeight * (row - 1), |
||||||
|
i == column - 1 ? layoutWidth - lastRowWidth * (column - 1) : lastRowWidth, |
||||||
|
lastRowHeight |
||||||
|
); |
||||||
|
} |
||||||
|
xwFitLayout.updateBoundsWidget(); |
||||||
|
} |
||||||
|
|
||||||
|
private class ComponentLocationInfo{ |
||||||
|
private Component component; |
||||||
|
private int horizontalNO; |
||||||
|
private int verticalNO; |
||||||
|
|
||||||
|
public ComponentLocationInfo(Component component, int horizontalNO, int verticalNO){ |
||||||
|
this.component = component; |
||||||
|
this.horizontalNO = horizontalNO; |
||||||
|
this.verticalNO = verticalNO; |
||||||
|
} |
||||||
|
|
||||||
|
public int getHorizontalNO() { |
||||||
|
return this.horizontalNO; |
||||||
|
} |
||||||
|
|
||||||
|
public int getVerticalNO() { |
||||||
|
return this.verticalNO; |
||||||
|
} |
||||||
|
|
||||||
|
public void setHorizontalNO(int horizontalNO){ |
||||||
|
this.horizontalNO = horizontalNO; |
||||||
|
} |
||||||
|
|
||||||
|
public void setVerticalNO(int verticalNO){ |
||||||
|
this.verticalNO = verticalNO; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
//以组件的位置来确定先后顺序,y小的在前,x小的在前
|
||||||
|
private class ComparatorComponentLocation implements Comparator { |
||||||
|
@Override |
||||||
|
public int compare(Object o1, Object o2) { |
||||||
|
if(((Component)o1).getY() < ((Component)o2).getY()){ |
||||||
|
return -1; |
||||||
|
} |
||||||
|
else if (((Component)o1).getY() > ((Component)o2).getY()) { |
||||||
|
return 1; |
||||||
|
} |
||||||
|
else { |
||||||
|
if (((Component)o1).getX() < ((Component)o2).getX()){ |
||||||
|
return -1; |
||||||
|
} |
||||||
|
else if (((Component)o1).getX() > ((Component)o2).getX()) { |
||||||
|
return 1; |
||||||
|
} |
||||||
|
else{ |
||||||
|
return 0; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,12 @@ |
|||||||
|
package com.fr.design.designer.properties; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by zhouping on 2016/9/18. |
||||||
|
*/ |
||||||
|
public class LayoutTypeRenderer extends BodyLayoutAttrRenderer { |
||||||
|
|
||||||
|
public LayoutTypeRenderer() { |
||||||
|
super(new LayoutTypeWrapper()); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,13 @@ |
|||||||
|
package com.fr.design.designer.properties; |
||||||
|
|
||||||
|
import com.fr.design.designer.properties.items.FRLayoutTypeItems; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by zhouping on 2016/9/18. |
||||||
|
*/ |
||||||
|
public class LayoutTypeWrapper extends ItemWrapper{ |
||||||
|
|
||||||
|
public LayoutTypeWrapper() { |
||||||
|
super(new FRLayoutTypeItems()); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,16 @@ |
|||||||
|
package com.fr.design.designer.properties.items; |
||||||
|
|
||||||
|
import com.fr.form.ui.container.WBodyLayoutType; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by zhouping on 2016/9/18. |
||||||
|
*/ |
||||||
|
public class FRLayoutTypeItems implements ItemProvider{ |
||||||
|
public static final Item[] ITEMS = new Item[] { |
||||||
|
new Item(WBodyLayoutType.FIT.description(), WBodyLayoutType.FIT.getTypeValue()), |
||||||
|
new Item(WBodyLayoutType.ABSOLUTE.description(), WBodyLayoutType.ABSOLUTE.getTypeValue())}; |
||||||
|
|
||||||
|
public Item[] getItems() { |
||||||
|
return ITEMS; |
||||||
|
} |
||||||
|
} |
@ -1 +1 @@ |
|||||||
package com.fr.design.gui.core;
import javax.swing.Icon;
import com.fr.base.BaseUtils;
import com.fr.form.ui.ElementCaseEditor;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WBorderLayout;
import com.fr.form.ui.container.WCardLayout;
import com.fr.form.ui.container.WFitLayout;
import com.fr.form.ui.container.WHorizontalBoxLayout;
import com.fr.form.ui.container.WParameterLayout;
import com.fr.form.ui.container.WVerticalBoxLayout;
import com.fr.general.Inter;
/**
* Author : Shockway
* Date: 13-6-17
* Time: 上午10:40
*/
public class FormWidgetOption extends WidgetOption {
/**
* 返回名字
* @return 名字
*/
@Override
public String optionName() {
return null;
}
/**
* 返回图标
* @return 图标
*/
@Override
public Icon optionIcon() {
return null;
}
/**
* 组件类
* @return 类
*/
@Override
public Class<? extends Widget> widgetClass() {
return null;
}
/**
* 返回组件
* @return 控件
*/
@Override
public Widget createWidget() {
return null;
}
/*
* 表单容器
*/
public static WidgetOption[] getFormContainerInstance() {
return new WidgetOption[] { ABSOLUTELAYOUTCONTAINER, BORDERLAYOUTCONTAINER, HORIZONTALBOXLAYOUTCONTAINER, VERTICALBOXLAYOUTCONTAINER,
CARDLAYOUTCONTAINER, FITLAYOUTCONTAINER };
}
/**
* 表单工具栏上的布局
* @return 控件
*/
public static WidgetOption[] getFormLayoutInstance() {
return new WidgetOption[] {CARDLAYOUTCONTAINER/*, ABSOLUTELAYOUTCONTAINER*/};
}
public static final WidgetOption ABSOLUTELAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter
.getLocText("FR-Designer_AbsoluteLayout"), BaseUtils.readIcon("/com/fr/web/images/form/resources/layout_absolute_new.png"),
WAbsoluteLayout.class);
public static final WidgetOption BORDERLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter
.getLocText("FR-Designer_BorderLayout"), BaseUtils.readIcon("/com/fr/web/images/form/resources/layout_border.png"),
WBorderLayout.class);
public static final WidgetOption CARDLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter
.getLocText("FR-Designer_CardLayout"), BaseUtils.readIcon("/com/fr/web/images/form/resources/card_layout_16.png"),
WCardLayout.class);
public static final WidgetOption HORIZONTALBOXLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter
.getLocText("FR-Designer_Layout-HBox"), BaseUtils.readIcon("/com/fr/web/images/form/resources/boxlayout_h_16.png"),
WHorizontalBoxLayout.class);
public static final WidgetOption VERTICALBOXLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter
.getLocText("FR-Designer_VerticalBoxLayout"), BaseUtils.readIcon("/com/fr/web/images/form/resources/boxlayout_v_16.png"),
WVerticalBoxLayout.class);
public static final WidgetOption FITLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter.getLocText("FR-Designer-Layout_Adaptive_Layout"),
BaseUtils.readIcon("/com/fr/web/images/form/resources/boxlayout_v_16.png"),
WFitLayout.class);
public static final WidgetOption PARAMETERCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter
.getLocText("FR-Designer_Para-Body"), BaseUtils.readIcon("/com/fr/web/images/form/resources/layout_parameter.png"),
WParameterLayout.class);
public static final WidgetOption ELEMENTCASE = WidgetOptionFactory.createByWidgetClass(Inter
.getLocText("FR-Designer_Form-Report"), BaseUtils.readIcon("/com/fr/web/images/form/resources/report_16.png"),
ElementCaseEditor.class);
} |
package com.fr.design.gui.core;
import javax.swing.Icon;
import com.fr.base.BaseUtils;
import com.fr.form.ui.ElementCaseEditor;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WBorderLayout;
import com.fr.form.ui.container.WCardLayout;
import com.fr.form.ui.container.WFitLayout;
import com.fr.form.ui.container.WHorizontalBoxLayout;
import com.fr.form.ui.container.WParameterLayout;
import com.fr.form.ui.container.WVerticalBoxLayout;
import com.fr.general.Inter;
/**
* Author : Shockway
* Date: 13-6-17
* Time: 上午10:40
*/
public class FormWidgetOption extends WidgetOption {
/**
* 返回名字
* @return 名字
*/
@Override
public String optionName() {
return null;
}
/**
* 返回图标
* @return 图标
*/
@Override
public Icon optionIcon() {
return null;
}
/**
* 组件类
* @return 类
*/
@Override
public Class<? extends Widget> widgetClass() {
return null;
}
/**
* 返回组件
* @return 控件
*/
@Override
public Widget createWidget() {
return null;
}
/*
* 表单容器
*/
public static WidgetOption[] getFormContainerInstance() {
return new WidgetOption[] { ABSOLUTELAYOUTCONTAINER, BORDERLAYOUTCONTAINER, HORIZONTALBOXLAYOUTCONTAINER, VERTICALBOXLAYOUTCONTAINER,
CARDLAYOUTCONTAINER, FITLAYOUTCONTAINER };
}
/**
* 表单工具栏上的布局
* @return 控件
*/
public static WidgetOption[] getFormLayoutInstance() {
return new WidgetOption[] {CARDLAYOUTCONTAINER, ABSOLUTELAYOUTCONTAINER};
}
public static final WidgetOption ABSOLUTELAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter
.getLocText("FR-Designer_Layout_Block_Absolute"), BaseUtils.readIcon("/com/fr/web/images/form/resources/layout_absolute_new.png"),
WAbsoluteLayout.class);
public static final WidgetOption BORDERLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter
.getLocText("FR-Designer_BorderLayout"), BaseUtils.readIcon("/com/fr/web/images/form/resources/layout_border.png"),
WBorderLayout.class);
public static final WidgetOption CARDLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter
.getLocText("FR-Designer_Layout_Block_Tab"), BaseUtils.readIcon("/com/fr/web/images/form/resources/card_layout_16.png"),
WCardLayout.class);
public static final WidgetOption HORIZONTALBOXLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter
.getLocText("FR-Designer_Layout-HBox"), BaseUtils.readIcon("/com/fr/web/images/form/resources/boxlayout_h_16.png"),
WHorizontalBoxLayout.class);
public static final WidgetOption VERTICALBOXLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter
.getLocText("FR-Designer_VerticalBoxLayout"), BaseUtils.readIcon("/com/fr/web/images/form/resources/boxlayout_v_16.png"),
WVerticalBoxLayout.class);
public static final WidgetOption FITLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter.getLocText("FR-Designer-Layout_Adaptive_Layout"),
BaseUtils.readIcon("/com/fr/web/images/form/resources/boxlayout_v_16.png"),
WFitLayout.class);
public static final WidgetOption PARAMETERCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter
.getLocText("FR-Designer_Para-Body"), BaseUtils.readIcon("/com/fr/web/images/form/resources/layout_parameter.png"),
WParameterLayout.class);
public static final WidgetOption ELEMENTCASE = WidgetOptionFactory.createByWidgetClass(Inter
.getLocText("FR-Designer_Form-Report"), BaseUtils.readIcon("/com/fr/web/images/form/resources/report_16.png"),
ElementCaseEditor.class);
} |
@ -0,0 +1,192 @@ |
|||||||
|
package com.fr.design.mainframe; |
||||||
|
|
||||||
|
import com.fr.base.BaseUtils; |
||||||
|
import com.fr.design.designer.creator.XCreator; |
||||||
|
import com.fr.design.designer.creator.XCreatorUtils; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.form.share.ShareLoader; |
||||||
|
import com.fr.form.ui.ElCaseBindInfo; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.general.ComparatorUtils; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.datatransfer.DataFlavor; |
||||||
|
import java.awt.datatransfer.Transferable; |
||||||
|
import java.awt.datatransfer.UnsupportedFlavorException; |
||||||
|
import java.awt.dnd.*; |
||||||
|
import java.awt.event.MouseEvent; |
||||||
|
import java.awt.event.MouseListener; |
||||||
|
import java.awt.event.MouseMotionListener; |
||||||
|
import java.awt.image.BufferedImage; |
||||||
|
import java.io.IOException; |
||||||
|
import java.io.Serializable; |
||||||
|
|
||||||
|
/** |
||||||
|
* Coder: zack |
||||||
|
* Date: 2016/10/9 |
||||||
|
* Time: 16:14 |
||||||
|
*/ |
||||||
|
public class ShareWidgetButton extends JPanel implements MouseListener, MouseMotionListener, Serializable { |
||||||
|
private ElCaseBindInfo bindInfo; |
||||||
|
private MouseEvent lastPressEvent; |
||||||
|
|
||||||
|
public ShareWidgetButton(ElCaseBindInfo bindInfo) { |
||||||
|
this.bindInfo = bindInfo; |
||||||
|
initUI(); |
||||||
|
this.setBorder(BorderFactory.createEmptyBorder(0,0,0,0)); |
||||||
|
this.addMouseListener(this); |
||||||
|
this.addMouseMotionListener(this); |
||||||
|
new DragAndDropDragGestureListener(this, DnDConstants.ACTION_COPY_OR_MOVE); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private void initUI() { |
||||||
|
this.setBackground(Color.WHITE); |
||||||
|
this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
||||||
|
setPreferredSize(new Dimension(110, 70)); |
||||||
|
setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
ImagePanel imagePanel = new ImagePanel((BufferedImage) bindInfo.getCover()); |
||||||
|
|
||||||
|
this.add(imagePanel, BorderLayout.NORTH); |
||||||
|
JPanel panel = new JPanel(); |
||||||
|
UILabel label = new UILabel(bindInfo.getName(), SwingConstants.HORIZONTAL); |
||||||
|
panel.setBackground(new Color(184, 220, 242)); |
||||||
|
panel.add(label); |
||||||
|
this.add(panel, BorderLayout.SOUTH); |
||||||
|
} |
||||||
|
|
||||||
|
private class ImagePanel extends JPanel { |
||||||
|
|
||||||
|
private BufferedImage image; |
||||||
|
|
||||||
|
public ImagePanel(BufferedImage image) { |
||||||
|
this.image = image; |
||||||
|
this.setPreferredSize(new Dimension(110, 50)); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void paintComponent(Graphics g) { |
||||||
|
g.drawImage(image, 0, 0, 110, 70, null); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public ElCaseBindInfo getBindInfo() { |
||||||
|
return bindInfo; |
||||||
|
} |
||||||
|
|
||||||
|
public void setBindInfo(ElCaseBindInfo bindInfo) { |
||||||
|
this.bindInfo = bindInfo; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void mouseClicked(MouseEvent e) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void mousePressed(MouseEvent e) { |
||||||
|
lastPressEvent = e; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void mouseReleased(MouseEvent e) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void mouseEntered(MouseEvent e) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void mouseExited(MouseEvent e) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void mouseDragged(MouseEvent e) { |
||||||
|
if (BaseUtils.isAuthorityEditing()) { |
||||||
|
return; |
||||||
|
} |
||||||
|
if (lastPressEvent == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
Object source = e.getSource(); |
||||||
|
Widget creatorSource = null; |
||||||
|
String shareId = StringUtils.EMPTY; |
||||||
|
if (source instanceof ShareWidgetButton) { |
||||||
|
ShareWidgetButton no = (ShareWidgetButton) e.getSource(); |
||||||
|
if (no == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
shareId = no.getBindInfo().getId(); |
||||||
|
creatorSource = ShareLoader.getLoader().getElCaseEditorById(shareId); |
||||||
|
} |
||||||
|
if (creatorSource != null) { |
||||||
|
XCreator xCreator = XCreatorUtils.createXCreator(creatorSource); |
||||||
|
xCreator.setShareId(shareId); |
||||||
|
WidgetToolBarPane.getTarget().startDraggingBean(xCreator); |
||||||
|
lastPressEvent = null; |
||||||
|
this.setBorder(null); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void mouseMoved(MouseEvent e) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public class DragAndDropDragGestureListener extends DragSourceAdapter implements DragGestureListener { |
||||||
|
private DragSource source; |
||||||
|
|
||||||
|
public DragAndDropDragGestureListener(ShareWidgetButton tt, int actions) { |
||||||
|
source = new DragSource(); |
||||||
|
source.createDefaultDragGestureRecognizer(tt, actions, this); |
||||||
|
} |
||||||
|
|
||||||
|
public void dragGestureRecognized(DragGestureEvent dge) { |
||||||
|
ShareWidgetButton shareWidgetButton = (ShareWidgetButton) dge.getComponent(); |
||||||
|
if (shareWidgetButton != null) { |
||||||
|
Widget widget = ShareLoader.getLoader().getElCaseEditorById(shareWidgetButton.getBindInfo().getId()); |
||||||
|
DragAndDropTransferable dragAndDropTransferable = new DragAndDropTransferable(widget); |
||||||
|
dge.startDrag(DragSource.DefaultCopyDrop, dragAndDropTransferable, this); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void dragEnter(DragSourceDragEvent dragSourceDragEvent) { |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public class DragAndDropTransferable implements Transferable { |
||||||
|
private Widget widget; |
||||||
|
|
||||||
|
public DragAndDropTransferable(Widget widget) { |
||||||
|
this.widget = widget; |
||||||
|
} |
||||||
|
|
||||||
|
DataFlavor[] flavors = {new DataFlavor(Widget.class, "Widget")}; |
||||||
|
|
||||||
|
public DataFlavor[] getTransferDataFlavors() { |
||||||
|
return flavors; |
||||||
|
} |
||||||
|
|
||||||
|
public boolean isDataFlavorSupported(DataFlavor flavor) { |
||||||
|
for (DataFlavor df : flavors) { |
||||||
|
if (ComparatorUtils.equals(df, flavor)) { |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
public Object getTransferData(DataFlavor df) throws UnsupportedFlavorException, IOException { |
||||||
|
return widget; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,29 @@ |
|||||||
|
package com.fr.design.mainframe; |
||||||
|
|
||||||
|
|
||||||
|
import com.fr.form.ui.ElCaseBindInfo; |
||||||
|
|
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
import java.util.ArrayList; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* Created by xiaxiang on 2016/10/10. |
||||||
|
*/ |
||||||
|
public class ShareWidgetPane extends JPanel { |
||||||
|
public ShareWidgetPane(ArrayList<ElCaseBindInfo> elCaseBindInfoList) { |
||||||
|
this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));// 设置面板的边框 ,距离上、左、下、右 的距离
|
||||||
|
int rowCount = (elCaseBindInfoList.size() + 1)/2; |
||||||
|
this.setLayout(new GridLayout(rowCount, 2, 10, 10)); |
||||||
|
for (ElCaseBindInfo rbModuleInfo : elCaseBindInfoList) { |
||||||
|
ShareWidgetButton widgetButton = new ShareWidgetButton(rbModuleInfo); |
||||||
|
this.add(widgetButton); |
||||||
|
} |
||||||
|
if (elCaseBindInfoList.size() == 1) { |
||||||
|
this.add(new JPanel()); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,291 @@ |
|||||||
|
package com.fr.design.mainframe.widget; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by xiaxiang on 2016/9/30. |
||||||
|
*/ |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.event.*; |
||||||
|
import javax.swing.*; |
||||||
|
import javax.swing.plaf.*; |
||||||
|
import javax.swing.plaf.basic.*; |
||||||
|
import javax.swing.plaf.metal.*; |
||||||
|
import javax.swing.tree.*; |
||||||
|
|
||||||
|
import com.fr.design.designer.beans.*; |
||||||
|
import com.fr.design.designer.beans.events.DesignerEditListener; |
||||||
|
import com.fr.design.designer.beans.events.DesignerEvent; |
||||||
|
import com.fr.design.designer.creator.XCreator; |
||||||
|
import com.fr.design.mainframe.ComponentTree; |
||||||
|
import com.sun.java.swing.plaf.motif.*; |
||||||
|
import com.sun.java.swing.plaf.windows.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* 控件树下拉列表框 |
||||||
|
*/ |
||||||
|
public class UITreeComboBox extends JComboBox{ |
||||||
|
/** |
||||||
|
* 显示用的树 |
||||||
|
*/ |
||||||
|
private ComponentTree tree; |
||||||
|
|
||||||
|
public UITreeComboBox(ComponentTree componentTree){ |
||||||
|
this.setTree(componentTree); |
||||||
|
tree.getDesigner().addDesignerEditListener(new TreeComboBoxDesignerEditAdapter()); |
||||||
|
// for(int i=0; i<tree.getRowCount(); i++)
|
||||||
|
// {
|
||||||
|
// tree.expandRow(i);
|
||||||
|
// }
|
||||||
|
setPreferredSize(new Dimension(200, 20)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 设置树 |
||||||
|
* @param tree ComponentTree |
||||||
|
*/ |
||||||
|
public void setTree(ComponentTree tree){ |
||||||
|
this.tree = tree; |
||||||
|
if(tree != null){ |
||||||
|
this.setSelectedItem(tree.getSelectionPath()); |
||||||
|
this.setRenderer(new UITreeComboBoxRenderer()); |
||||||
|
} |
||||||
|
this.updateUI(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 取得树 |
||||||
|
* @return JTree |
||||||
|
*/ |
||||||
|
public ComponentTree getTree(){ |
||||||
|
return tree; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 设置当前选择的树路径 |
||||||
|
* @param o Object |
||||||
|
*/ |
||||||
|
public void setSelectedItem(Object o){ |
||||||
|
tree.setSelectionPath((TreePath)o); |
||||||
|
getModel().setSelectedItem(o); |
||||||
|
} |
||||||
|
|
||||||
|
public void updateUI(){ |
||||||
|
ComboBoxUI cui = (ComboBoxUI)UIManager.getUI(this); |
||||||
|
if(cui instanceof MetalComboBoxUI){ |
||||||
|
cui = new MetalJTreeComboBoxUI(); |
||||||
|
} else if(cui instanceof MotifComboBoxUI){ |
||||||
|
cui = new MotifJTreeComboBoxUI(); |
||||||
|
} else { |
||||||
|
cui = new WindowsJTreeComboBoxUI(); |
||||||
|
} |
||||||
|
setUI(cui); |
||||||
|
} |
||||||
|
|
||||||
|
// UI Inner classes -- one for each supported Look and Feel
|
||||||
|
class MetalJTreeComboBoxUI extends MetalComboBoxUI{ |
||||||
|
protected ComboPopup createPopup() { |
||||||
|
return new TreePopup(comboBox); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
class WindowsJTreeComboBoxUI extends WindowsComboBoxUI{ |
||||||
|
protected ComboPopup createPopup() { |
||||||
|
return new TreePopup(comboBox); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
class MotifJTreeComboBoxUI extends MotifComboBoxUI{ |
||||||
|
protected ComboPopup createPopup() { |
||||||
|
return new TreePopup(comboBox); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* <p>Title: UITreeComboBoxRenderer</p> |
||||||
|
* <p>Description: 树形结构而来的DefaultListCellRenderer </p> |
||||||
|
*/ |
||||||
|
class UITreeComboBoxRenderer extends DefaultListCellRenderer { |
||||||
|
public Component getListCellRendererComponent(JList list, Object value, |
||||||
|
int index, boolean isSelected, boolean cellHasFocus){ |
||||||
|
if(value != null){ |
||||||
|
TreePath path = (TreePath)value; |
||||||
|
Object node = path.getLastPathComponent(); |
||||||
|
value = node; |
||||||
|
TreeCellRenderer r = tree.getCellRenderer(); |
||||||
|
JLabel lb = (JLabel)r.getTreeCellRendererComponent( |
||||||
|
tree, value, isSelected, false, false, index, |
||||||
|
cellHasFocus); |
||||||
|
return lb; |
||||||
|
} |
||||||
|
return super.getListCellRendererComponent(list, value, index, |
||||||
|
isSelected, cellHasFocus); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private class TreeComboBoxDesignerEditAdapter implements DesignerEditListener { |
||||||
|
|
||||||
|
@Override |
||||||
|
public void fireCreatorModified(DesignerEvent evt) { |
||||||
|
if (evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED || evt.getCreatorEventID() == DesignerEvent.CREATOR_PASTED) { |
||||||
|
TreePath[] paths = tree.getSelectedTreePath(); |
||||||
|
|
||||||
|
if (paths.length == 1) { |
||||||
|
tree.setAndScrollSelectionPath(paths[0]); |
||||||
|
} else { |
||||||
|
tree.setSelectionPaths(paths); |
||||||
|
} |
||||||
|
setSelectedItem(paths[0]); |
||||||
|
MenuSelectionManager.defaultManager().clearSelectedPath(); |
||||||
|
} else { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean equals(Object o) { |
||||||
|
return o.getClass() == this.getClass(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 测试 |
||||||
|
*/ |
||||||
|
// public static void main(String args[]){
|
||||||
|
// JFrame frame = new JFrame("UITreeComboBox");
|
||||||
|
// final UITreeComboBox box = new UITreeComboBox(new ComponentTree(new FormDesigner()));
|
||||||
|
// box.setPreferredSize(new Dimension(300, 28));
|
||||||
|
// frame.getContentPane().add(box);
|
||||||
|
// frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||||
|
// frame.pack();
|
||||||
|
// frame.setVisible(true);
|
||||||
|
// }
|
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* <p>Title: UITreeComboBox</p> |
||||||
|
* <p>Description: TreePopup</p> |
||||||
|
*/ |
||||||
|
class TreePopup extends JPopupMenu implements ComboPopup{ |
||||||
|
protected UITreeComboBox comboBox; |
||||||
|
protected JScrollPane scrollPane; |
||||||
|
|
||||||
|
protected MouseMotionListener mouseMotionListener; |
||||||
|
protected MouseListener mouseListener; |
||||||
|
|
||||||
|
|
||||||
|
public void popupMenu(MouseEvent e) { |
||||||
|
TreePath path = comboBox.getTree().getSelectionPath(); |
||||||
|
if (path == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
Component component = (Component) path.getLastPathComponent(); |
||||||
|
if (!(component instanceof XCreator)) { |
||||||
|
return; |
||||||
|
} |
||||||
|
com.fr.design.designer.beans.ComponentAdapter adapter = AdapterBus.getComponentAdapter(comboBox.getTree().getDesigner(), (XCreator) component); |
||||||
|
JPopupMenu menu = adapter.getContextPopupMenu(e); |
||||||
|
menu.show(comboBox, e.getX(), e.getY()); |
||||||
|
} |
||||||
|
|
||||||
|
public TreePopup(JComboBox comboBox){ |
||||||
|
this.comboBox = (UITreeComboBox)comboBox; |
||||||
|
setBorder(BorderFactory.createLineBorder(Color.black)); |
||||||
|
setLayout(new BorderLayout()); |
||||||
|
setLightWeightPopupEnabled(comboBox.isLightWeightPopupEnabled()); |
||||||
|
JTree tree = this.comboBox.getTree(); |
||||||
|
if(tree != null){ |
||||||
|
scrollPane = new JScrollPane(tree); |
||||||
|
scrollPane.setBorder(null); |
||||||
|
add(scrollPane, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void show(){ |
||||||
|
updatePopup(); |
||||||
|
show(comboBox, 0, comboBox.getHeight()); |
||||||
|
comboBox.getTree().requestFocus(); |
||||||
|
} |
||||||
|
|
||||||
|
public void hide(){ |
||||||
|
setVisible(false); |
||||||
|
comboBox.firePropertyChange("popupVisible", true, false); |
||||||
|
} |
||||||
|
|
||||||
|
protected JList list = new JList(); |
||||||
|
public JList getList(){ |
||||||
|
return list; |
||||||
|
} |
||||||
|
|
||||||
|
public MouseMotionListener getMouseMotionListener(){ |
||||||
|
if(mouseMotionListener == null){ |
||||||
|
mouseMotionListener = new MouseMotionAdapter(){}; |
||||||
|
} |
||||||
|
return mouseMotionListener; |
||||||
|
} |
||||||
|
|
||||||
|
public KeyListener getKeyListener(){ |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
public void uninstallingUI(){} |
||||||
|
|
||||||
|
/** |
||||||
|
* Implementation of ComboPopup.getMouseListener(). |
||||||
|
* |
||||||
|
* @return a <code>MouseListener</code> or null |
||||||
|
* @see ComboPopup#getMouseListener |
||||||
|
*/ |
||||||
|
public MouseListener getMouseListener(){ |
||||||
|
if(mouseListener == null){ |
||||||
|
mouseListener = new InvocationMouseHandler(); |
||||||
|
} |
||||||
|
return mouseListener; |
||||||
|
} |
||||||
|
|
||||||
|
protected void togglePopup(){ |
||||||
|
if(isVisible()){ |
||||||
|
hide(); |
||||||
|
} else{ |
||||||
|
show(); |
||||||
|
} |
||||||
|
} |
||||||
|
protected void updatePopup(){ |
||||||
|
setPreferredSize(new Dimension(comboBox.getSize().width, 200)); |
||||||
|
Object selectedObj = comboBox.getSelectedItem(); |
||||||
|
if(selectedObj != null){ |
||||||
|
TreePath tp = (TreePath)selectedObj; |
||||||
|
((UITreeComboBox)comboBox).getTree().setSelectionPath(tp); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
protected class InvocationMouseHandler extends MouseAdapter{ |
||||||
|
public void mousePressed(MouseEvent e){ |
||||||
|
if(!SwingUtilities.isLeftMouseButton(e) || !comboBox.isEnabled()){ |
||||||
|
return; |
||||||
|
} |
||||||
|
if(comboBox.isEditable()){ |
||||||
|
Component comp = comboBox.getEditor().getEditorComponent(); |
||||||
|
if((!(comp instanceof JComponent)) || |
||||||
|
((JComponent)comp).isRequestFocusEnabled()){ |
||||||
|
comp.requestFocus(); |
||||||
|
} |
||||||
|
} else if(comboBox.isRequestFocusEnabled()){ |
||||||
|
comboBox.requestFocus(); |
||||||
|
} |
||||||
|
togglePopup(); |
||||||
|
} |
||||||
|
|
||||||
|
public void mouseClicked (MouseEvent e){ |
||||||
|
if (e.isMetaDown()) { |
||||||
|
popupMenu(e); |
||||||
|
} else { |
||||||
|
return; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,15 @@ |
|||||||
|
package com.fr.design.mainframe.widget.editors; |
||||||
|
|
||||||
|
import com.fr.design.designer.properties.EnumerationEditor; |
||||||
|
import com.fr.design.designer.properties.items.FRLayoutTypeItems; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by zhouping on 2016/9/18. |
||||||
|
*/ |
||||||
|
public class LayoutTypeEditor extends EnumerationEditor { |
||||||
|
|
||||||
|
public LayoutTypeEditor() { |
||||||
|
super(new FRLayoutTypeItems()); |
||||||
|
} |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue