Fangjie Hu 8 years ago
parent
commit
9b6e8401ed
  1. 2
      build.dev.gradle
  2. 86
      build.gradle.bak
  3. 18
      designer/src/com/fr/design/actions/ElementCaseAction.java
  4. 36
      designer/src/com/fr/design/actions/SelectionListenerAction.java
  5. 56
      designer/src/com/fr/design/actions/cell/GlobalStyleMenuDef.java
  6. 3
      designer/src/com/fr/design/actions/file/export/AbstractExportAction.java
  7. 3
      designer/src/com/fr/design/actions/file/export/PDFExportAction.java
  8. 5
      designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java
  9. 9
      designer/src/com/fr/design/mainframe/bbs/UserInfoPane.java
  10. 39
      designer/src/com/fr/design/present/CellWriteAttrPane.java
  11. 2
      designer_base/build.dev.gradle
  12. 70
      designer_base/build.gradle.bak
  13. 27
      designer_base/src/com/fr/design/actions/UpdateAction.java
  14. 5
      designer_base/src/com/fr/design/extra/PluginWebBridge.java
  15. 21
      designer_base/src/com/fr/design/extra/QQLoginWebBridge.java
  16. 2
      designer_base/src/com/fr/design/hyperlink/AbstractHyperlinkPane.java
  17. 48
      designer_base/src/com/fr/design/hyperlink/HyperlinkTargetFrame.java
  18. 11
      designer_base/src/com/fr/design/menu/MenuDef.java
  19. 2
      designer_chart/build.dev.gradle
  20. 66
      designer_chart/build.gradle.bak
  21. 2
      designer_form/build.dev.gradle
  22. 83
      designer_form/build.gradle.bak
  23. 12
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java
  24. 133
      designer_form/src/com/fr/design/designer/creator/XCreator.java
  25. 19
      designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java
  26. 184
      designer_form/src/com/fr/design/designer/properties/FRAbsoluteLayoutPropertiesGroupModel.java
  27. 67
      designer_form/src/com/fr/design/designer/properties/FRFitLayoutPropertiesGroupModel.java
  28. 14
      designer_form/src/com/fr/design/designer/properties/LayoutTypeRenderer.java
  29. 13
      designer_form/src/com/fr/design/designer/properties/LayoutTypeWrapper.java
  30. 4
      designer_form/src/com/fr/design/designer/properties/items/FRFitConstraintsItems.java
  31. 16
      designer_form/src/com/fr/design/designer/properties/items/FRLayoutTypeItems.java
  32. 27
      designer_form/src/com/fr/design/designer/treeview/ComponentTreeModel.java
  33. 2
      designer_form/src/com/fr/design/gui/core/FormWidgetOption.java
  34. 191
      designer_form/src/com/fr/design/mainframe/ComponentTree.java
  35. 11
      designer_form/src/com/fr/design/mainframe/FormParaWidgetPane.java
  36. 192
      designer_form/src/com/fr/design/mainframe/ShareWidgetButton.java
  37. 29
      designer_form/src/com/fr/design/mainframe/ShareWidgetPane.java
  38. 291
      designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java
  39. 15
      designer_form/src/com/fr/design/mainframe/widget/editors/LayoutTypeEditor.java

2
build.gradle → build.dev.gradle

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

86
build.gradle.bak

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

18
designer/src/com/fr/design/actions/ElementCaseAction.java

@ -10,24 +10,10 @@ import com.fr.grid.selection.Selection;
import com.fr.design.selection.SelectionEvent;
import com.fr.design.selection.SelectionListener;
public abstract class ElementCaseAction extends TemplateComponentAction<ElementCasePane> {
public abstract class ElementCaseAction extends SelectionListenerAction {
protected ElementCaseAction(ElementCasePane t) {
super(t);
t.addSelectionChangeListener(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);
}
}
}
});
t.addSelectionChangeListener(createSelectionListener());
}
}

36
designer/src/com/fr/design/actions/SelectionListenerAction.java

@ -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);
}
}
}
};
}
}

56
designer/src/com/fr/design/actions/cell/GlobalStyleMenuDef.java

@ -8,19 +8,27 @@ import com.fr.base.BaseUtils;
import com.fr.base.ConfigManager;
import com.fr.base.NameStyle;
import com.fr.design.actions.ElementCaseAction;
import com.fr.design.actions.SelectionListenerAction;
import com.fr.design.actions.TemplateComponentAction;
import com.fr.design.actions.UpdateAction;
import com.fr.design.gui.imenu.UIMenu;
import com.fr.design.mainframe.CellElementPropertyPane;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.menu.KeySetUtils;
import com.fr.design.menu.MenuDef;
import com.fr.design.selection.SelectionEvent;
import com.fr.design.selection.SelectionListener;
import com.fr.design.style.StylePane;
import com.fr.general.Inter;
import com.fr.base.ConfigManagerProvider;
import com.fr.grid.selection.CellSelection;
import com.fr.grid.selection.Selection;
import com.fr.stable.StringUtils;
import com.fr.stable.pinyin.PinyinHelper;
import java.awt.event.ActionEvent;
import java.awt.*;
import java.awt.event.*;
import java.util.Iterator;
public class GlobalStyleMenuDef extends MenuDef {
@ -35,6 +43,36 @@ public class GlobalStyleMenuDef extends MenuDef {
this.setIconPath("/com/fr/design/images/m_web/style.png");
}
protected ContainerListener getContainerListener() {
return containerListener;
}
private ContainerListener containerListener = new ContainerListener() {
@Override
public void componentAdded(ContainerEvent e) {
}
@Override
public void componentRemoved(ContainerEvent e) {
Component c = e.getChild();
c.dispatchEvent(new MenuDeleteEvent(c));
}
};
private class MenuDeleteEvent extends UpdateAction.ComponentRemoveEvent {
public MenuDeleteEvent(Component source) {
super(source);
}
@Override
public void release(SelectionListener listener) {
ePane.removeSelectionChangeListener(listener);
}
}
/**
* 更新菜单项
*/
@ -46,8 +84,7 @@ public class GlobalStyleMenuDef extends MenuDef {
while (iterator.hasNext()) {
String name = (String) iterator.next();
NameStyle nameStyle = NameStyle.getInstance(name);
UpdateAction.UseMenuItem useMenuItem = new GlobalStyleSelection(ePane, nameStyle).createUseMenuItem();
UpdateAction.UseMenuItem useMenuItem =new GlobalStyleSelection(ePane, nameStyle).createUseMenuItem();
useMenuItem.setNameStyle(nameStyle);
createdMenu.add(useMenuItem);
}
@ -113,7 +150,9 @@ public class GlobalStyleMenuDef extends MenuDef {
}
public static class GlobalStyleSelection extends ElementCaseAction {
public static class GlobalStyleSelection extends SelectionListenerAction {
private NameStyle nameStyle;
@ -149,5 +188,14 @@ public class GlobalStyleMenuDef extends MenuDef {
stylePane.updateGlobalStyle(getEditingComponent());
return true;
}
public UseMenuItem createUseMenuItem() {
UseMenuItem useMenuItem = super.createUseMenuItem();
SelectionListener listener = createSelectionListener();
getEditingComponent().addSelectionChangeListener(listener);
useMenuItem.setSelectionListener(listener);
return useMenuItem;
}
}
}

3
designer/src/com/fr/design/actions/file/export/AbstractExportAction.java

@ -5,6 +5,7 @@ package com.fr.design.actions.file.export;
import com.fr.base.FRContext;
import com.fr.base.Parameter;
import com.fr.io.exporter.pdfstream.PDFStreamExporter;
import com.fr.page.PageSetProvider;
import com.fr.design.actions.JWorkBookAction;
import com.fr.design.gui.iprogressbar.FRProgressBar;
@ -139,7 +140,7 @@ public abstract class AbstractExportAction extends JWorkBookAction {
if (exporter instanceof AppExporter) {
AppExporter appExporter = (AppExporter) exporter;
if (exporter instanceof ExcelExporter || exporter instanceof CSVExporter
|| exporter instanceof PDFExporter || exporter instanceof WordExporter) {
|| exporter instanceof PDFExporter || exporter instanceof PDFStreamExporter || exporter instanceof WordExporter) {
ReportHelper.clearFormulaResult(tpl);// 清空rpt中的公式计算结果
appExporter.export(fileOutputStream, tpl.execute(parameterMap, ActorFactory.getActor(ActorConstants.TYPE_PAGE)

3
designer/src/com/fr/design/actions/file/export/PDFExportAction.java

@ -10,6 +10,7 @@ import com.fr.file.filter.ChooseFileFilter;
import com.fr.general.Inter;
import com.fr.io.exporter.Exporter;
import com.fr.io.exporter.PDFExporter;
import com.fr.io.exporter.pdfstream.PDFStreamExporter;
/**
* Export pdf
@ -28,7 +29,7 @@ public class PDFExportAction extends AbstractExportAction {
@Override
protected Exporter getExporter() {
return new PDFExporter();
return new PDFStreamExporter();
}
@Override

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

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

9
designer/src/com/fr/design/mainframe/bbs/UserInfoPane.java

@ -77,12 +77,11 @@ public class UserInfoPane extends BasicPane{
@Override
public void run() {
String username = DesignerEnvManager.getEnvManager().getBBSName();
String password = DesignerEnvManager.getEnvManager().getBBSPassword();
String loginResult = LoginWebBridge.getHelper().login(username, password);
if (loginResult.equals(LOGININ)) {
markSignIn(username);
}else {
String inShowUsername = DesignerEnvManager.getEnvManager().getInShowBBsName();
if (StringUtils.isEmpty(username) && StringUtils.isEmpty(inShowUsername)){
markUnSignIn();
} else {
markSignIn(username);
}
}
});

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

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

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

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

70
designer_base/build.gradle.bak

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

27
designer_base/src/com/fr/design/actions/UpdateAction.java

@ -12,10 +12,13 @@ import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.imenu.UICheckBoxMenuItem;
import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.menu.ShortCut;
import com.fr.design.selection.SelectionListener;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ComponentEvent;
import java.awt.event.ContainerEvent;
import java.beans.PropertyChangeListener;
import java.util.HashMap;
import java.util.Iterator;
@ -321,12 +324,24 @@ public abstract class UpdateAction extends ShortCut implements Action {
toolBar.add(this.createToolBarComponent());
}
public abstract static class ComponentRemoveEvent extends ComponentEvent {
private static int EVENT_DELETE= 3001;
public ComponentRemoveEvent(Component source) {
super(source, EVENT_DELETE);
}
public abstract void release(SelectionListener listener);
}
/**
* 全局style的菜单
*/
public static class UseMenuItem extends UIMenuItem {
private NameStyle nameStyle;
private SelectionListener listener;
public UseMenuItem(Action action) {
super(action);
@ -337,6 +352,18 @@ public abstract class UpdateAction extends ShortCut implements Action {
super(text, icon);
}
protected void processEvent(AWTEvent e) {
if (e instanceof ComponentRemoveEvent) {
((ComponentRemoveEvent) e).release(listener);
return;
}
super.processEvent(e);
}
public void setSelectionListener(SelectionListener listener) {
this.listener = listener;
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);

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

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

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

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

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

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

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

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

11
designer_base/src/com/fr/design/menu/MenuDef.java

@ -13,9 +13,7 @@ import javax.swing.*;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.*;
import java.util.ArrayList;
import java.util.List;
@ -164,11 +162,18 @@ public class MenuDef extends ShortCut {
createdJMenu.setIcon(BaseUtils.readIcon(this.iconPath));
}
createdJMenu.addMenuListener(menuDefListener);
ContainerListener listener = getContainerListener();
if(listener != null){
createdJMenu.getPopupMenu().addContainerListener(listener);
}
}
return createdJMenu;
}
protected ContainerListener getContainerListener() {
return null;
}
/**
* 生成 JPopupMenu
* @return 弹出菜单

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

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

66
designer_chart/build.gradle.bak

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

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

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

83
designer_form/build.gradle.bak

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

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

@ -12,6 +12,7 @@ import com.fr.design.designer.properties.FRAbsoluteLayoutPropertiesGroupModel;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.design.utils.ComponentUtils;
import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.container.WBodyLayoutType;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
@ -330,6 +331,15 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
@Override
public GroupModel getLayoutProperties() {
XWAbsoluteLayout xwAbsoluteLayout = (XWAbsoluteLayout) container;
return new FRAbsoluteLayoutPropertiesGroupModel(xwAbsoluteLayout);
if (xwAbsoluteLayout.toData().isAbsoluteLayoutAsBody()){
//如果body是绝对布局,那么获取原来自适应body的属性--布局类型
WBodyLayoutType layoutType = WBodyLayoutType.FIT;
if (container.getParent() != null) {
layoutType = ((XWFitLayout)container.getParent()).toData().getBodyLayoutType();
}
return new FRAbsoluteLayoutPropertiesGroupModel(xwAbsoluteLayout, layoutType);
} else {
return new FRAbsoluteLayoutPropertiesGroupModel(xwAbsoluteLayout);
}
}
}

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

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

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

@ -75,9 +75,17 @@ public class XWAbsoluteLayout extends XLayoutContainer {
xConnectorMap.put(connector, new XConnector(connector, this));
}
this.editable = widget.isAbsoluteLayoutAsBody();
initPercent();
}
public XWAbsoluteLayout(WAbsoluteLayout widget, Dimension initSize, boolean isAbsoluteLayoutAsBody) {
this(widget, initSize);
widget.setAbsoluteLayoutAsBody(isAbsoluteLayoutAsBody);
this.editable = isAbsoluteLayoutAsBody;
}
/**
* 初始化时默认的组件大小
*
@ -443,4 +451,15 @@ public class XWAbsoluteLayout extends XLayoutContainer {
}
}
}
/**
* 设置布局是否可编辑不可则显示编辑蒙层
* 假如是body的话始终要能编辑不会出现蒙层
*
* @param isEditable 可否编辑
*/
@Override
public void setEditable(boolean isEditable) {
super.setEditable(toData().isAbsoluteLayoutAsBody() || isEditable);
}
}

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

@ -2,27 +2,40 @@ package com.fr.design.designer.properties;
import com.fr.design.beans.GroupModel;
import com.fr.design.designer.creator.XWAbsoluteLayout;
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.AbsoluteLayoutDirectionEditor;
import com.fr.design.mainframe.widget.editors.IntegerPropertyEditor;
import com.fr.design.mainframe.widget.editors.LayoutTypeEditor;
import com.fr.design.mainframe.widget.editors.PropertyCellEditor;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WBodyLayoutType;
import com.fr.general.Inter;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import java.awt.*;
import java.util.Arrays;
import java.util.Comparator;
/**
* Created by zhouping on 2016/8/1.
*/
public class FRAbsoluteLayoutPropertiesGroupModel implements GroupModel {
private PropertyCellEditor editor;
private DefaultTableCellRenderer renderer;
private AbsoluteLayoutDirectionEditor stateEditor;
private AbsoluteStateRenderer stateRenderer;
private WAbsoluteLayout layout;
private XWAbsoluteLayout xwAbsoluteLayout;
private LayoutTypeEditor layoutTypeEditor;
private LayoutTypeRenderer layoutTypeRenderer;
//默认body是0,自适应布局;1,绝对布局.
private WBodyLayoutType layoutType = WBodyLayoutType.FIT;
public FRAbsoluteLayoutPropertiesGroupModel(XWAbsoluteLayout xwAbsoluteLayout){
this.xwAbsoluteLayout = xwAbsoluteLayout;
@ -33,31 +46,65 @@ public class FRAbsoluteLayoutPropertiesGroupModel implements GroupModel {
stateRenderer = new AbsoluteStateRenderer();
}
public FRAbsoluteLayoutPropertiesGroupModel(XWAbsoluteLayout xwAbsoluteLayout, WBodyLayoutType layoutType){
this(xwAbsoluteLayout);
this.layoutTypeEditor = new LayoutTypeEditor();
this.layoutTypeRenderer = new LayoutTypeRenderer();
this.layoutType = layoutType;
}
/**
* 布局管理器自己的属性
*/
@Override
public String getGroupName() {
return Inter.getLocText("FR-Designer-Widget_Area_Scaling");
return Inter.getLocText(layoutType == WBodyLayoutType.ABSOLUTE ? "FR-Designer_Attr_Layout" : "FR-Designer-Widget_Area_Scaling");
}
@Override
public int getRowCount() {
return 1;
return layoutType == WBodyLayoutType.ABSOLUTE ? 2 : 1;
}
@Override
public TableCellRenderer getRenderer(int row) {
return stateRenderer;
if (layoutType == WBodyLayoutType.ABSOLUTE) {
return row == 0 ? layoutTypeRenderer : stateRenderer;
}
else {
return stateRenderer;
}
}
@Override
public TableCellEditor getEditor(int row) {
return stateEditor;
if (layoutType == WBodyLayoutType.ABSOLUTE) {
return row == 0 ? layoutTypeEditor : stateEditor;
}
else{
return stateEditor;
}
}
@Override
public Object getValue(int row, int column) {
if (layoutType == WBodyLayoutType.ABSOLUTE){
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();
}
}
}
if (column == 0) {
return Inter.getLocText("FR-Designer-Widget_Scaling_Mode");
} else {
@ -67,6 +114,42 @@ public class FRAbsoluteLayoutPropertiesGroupModel implements GroupModel {
@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()}));
return true;
}
}
if (row == 1) {
layout.setCompState(state);
return true;
}
return false;
}
}
int state = 0;
if(value instanceof Integer) {
state = (Integer)value;
@ -91,4 +174,95 @@ public class FRAbsoluteLayoutPropertiesGroupModel implements GroupModel {
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;
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;
}
}
}
}
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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