Browse Source
# Conflicts: # designer_base/src/com/fr/design/locale/designer.properties # designer_base/src/com/fr/design/locale/designer_en_US.properties # designer_base/src/com/fr/design/locale/designer_ja_JP.properties # designer_base/src/com/fr/design/locale/designer_ko_KR.properties # designer_base/src/com/fr/design/locale/designer_zh_CN.properties # designer_chart/src/com/fr/design/chart/axis/MinMaxValuePane.java # designer_chart/src/com/fr/design/mainframe/chart/gui/style/axis/ChartValuePane.java # designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java # designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java # designer_form/src/com/fr/design/designer/beans/location/AccessDirection.java # designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.javamaster
paul
8 years ago
80 changed files with 9722 additions and 6510 deletions
@ -0,0 +1,73 @@ |
|||||||
|
package com.fr.aspectj.designer; |
||||||
|
|
||||||
|
/** |
||||||
|
* 记录模板过程 |
||||||
|
* Created by plough on 2017/3/3. |
||||||
|
*/ |
||||||
|
|
||||||
|
import com.fr.design.mainframe.templateinfo.TemplateInfoCollector; |
||||||
|
import com.fr.grid.Grid; |
||||||
|
import org.aspectj.lang.reflect.SourceLocation; |
||||||
|
|
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.MouseEvent; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
public aspect TemplateProcessTracker { |
||||||
|
//声明一个pointcut,匹配你需要的方法 |
||||||
|
pointcut onMouseClicked(MouseEvent e) : |
||||||
|
execution(* mouseClicked(MouseEvent)) && args(e); |
||||||
|
pointcut onMousePressed(MouseEvent e) : |
||||||
|
execution(* mousePressed(MouseEvent)) && args(e); |
||||||
|
pointcut onMouseReleased(MouseEvent e) : |
||||||
|
execution(* mouseReleased(MouseEvent)) && args(e); |
||||||
|
pointcut onActionPerformed(ActionEvent e) : |
||||||
|
execution(* actionPerformed(ActionEvent)) && args(e); |
||||||
|
pointcut onSetValueAt(Object v, int r, int c) : |
||||||
|
execution(* setValueAt(java.lang.Object, int, int)) && args(v, r, c); |
||||||
|
pointcut onSetValue4EditingElement(Grid g, Object v) : |
||||||
|
call(* setValue4EditingElement(java.lang.Object)) && target(g) && args(v); |
||||||
|
|
||||||
|
//before表示之前的意思 |
||||||
|
//这整个表示在MouseAdapter的public void mouseXXX(MouseEvent)方法调用之前,你想要执行的代码 |
||||||
|
before(MouseEvent e) : onMouseClicked(e) || onMousePressed(e) || onMouseReleased(e) { |
||||||
|
SourceLocation sl = thisJoinPoint.getSourceLocation();//切面对应的代码位置 |
||||||
|
|
||||||
|
// String log = String.format("%s:\n%s\n%s\n%s\n\n", new Date(), sl, e, e.getSource()); |
||||||
|
String log = ""; |
||||||
|
TemplateInfoCollector.appendProcess(log); |
||||||
|
} |
||||||
|
//同上 |
||||||
|
before(ActionEvent e) : onActionPerformed(e) { |
||||||
|
SourceLocation sl = thisJoinPoint.getSourceLocation(); |
||||||
|
// !within(LogHandlerBar) 没用, 手动过滤 |
||||||
|
if (e.getSource().toString().contains("javax.swing.Timer")) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
//String log = String.format("%s:\n%s\n%s\n%s\n\n", new Date(), sl, e, e.getSource()); |
||||||
|
String log = ""; |
||||||
|
TemplateInfoCollector.appendProcess(log); |
||||||
|
|
||||||
|
} |
||||||
|
//同上 |
||||||
|
before(Object v, int r, int c) : onSetValueAt(v, r, c) { |
||||||
|
SourceLocation sl = thisJoinPoint.getSourceLocation(); |
||||||
|
|
||||||
|
//String log = String.format("%s:\n%s\nset value: %s at (%d, %d)\n\n", new Date(), sl, v, r, c); |
||||||
|
String log = ""; |
||||||
|
TemplateInfoCollector.appendProcess(log); |
||||||
|
|
||||||
|
} |
||||||
|
//同上 |
||||||
|
before(Grid g, Object v) : onSetValue4EditingElement(g, v) { |
||||||
|
SourceLocation sl = thisJoinPoint.getSourceLocation(); |
||||||
|
|
||||||
|
// String v = "test"; |
||||||
|
//String log = String.format("%s:\n%s\nset value: %s at %s\n\n", new Date(), sl, v, g.getEditingCellElement()); |
||||||
|
String log = ""; |
||||||
|
TemplateInfoCollector.appendProcess(log); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,74 @@ |
|||||||
|
package com.fr.design.mainframe.templateinfo; |
||||||
|
|
||||||
|
import com.fr.base.parameter.ParameterUI; |
||||||
|
import com.fr.main.impl.WorkBook; |
||||||
|
import com.fr.report.cellcase.CellCase; |
||||||
|
import com.fr.report.poly.PolyWorkSheet; |
||||||
|
import com.fr.report.worksheet.WorkSheet; |
||||||
|
|
||||||
|
import java.util.Iterator; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by plough on 2017/3/17. |
||||||
|
*/ |
||||||
|
public class JWorkBookProcessInfo extends TemplateProcessInfo<WorkBook> { |
||||||
|
|
||||||
|
public JWorkBookProcessInfo(WorkBook wb) { |
||||||
|
super(wb); |
||||||
|
} |
||||||
|
|
||||||
|
// 获取模板类型
|
||||||
|
public int getReportType() { |
||||||
|
return template.isElementCaseBook() ? 0 : 1; |
||||||
|
} |
||||||
|
|
||||||
|
// 获取模板格子数
|
||||||
|
public int getCellCount() { |
||||||
|
int cellCount = 0; |
||||||
|
if (template.isElementCaseBook()) { // 如果是普通报表
|
||||||
|
for (int i = 0; i < template.getReportCount(); i++) { |
||||||
|
WorkSheet r = (WorkSheet) template.getReport(i); |
||||||
|
CellCase cc = r.getBlock().getCellCase(); |
||||||
|
for (int j = 0; j < cc.getRowCount(); j++) { |
||||||
|
Iterator iter = cc.getRow(j); |
||||||
|
while (iter.hasNext()) { |
||||||
|
cellCount ++; |
||||||
|
iter.next(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
return cellCount; |
||||||
|
} |
||||||
|
// 获取模板悬浮元素个数
|
||||||
|
public int getFloatCount() { |
||||||
|
int chartCount = 0; |
||||||
|
if (template.isElementCaseBook()) { // 如果是普通报表
|
||||||
|
for (int i = 0; i < template.getReportCount(); i++) { |
||||||
|
WorkSheet r = (WorkSheet) template.getReport(i); |
||||||
|
Iterator fiter = r.getBlock().floatIterator(); |
||||||
|
while (fiter.hasNext()) { |
||||||
|
chartCount ++; |
||||||
|
fiter.next(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
return chartCount; |
||||||
|
} |
||||||
|
// 获取模板聚合块个数
|
||||||
|
public int getBlockCount() { |
||||||
|
int blockCount = 0; |
||||||
|
if (!template.isElementCaseBook()) { // 如果是聚合报表
|
||||||
|
for (int i = 0; i < template.getReportCount(); i++) { |
||||||
|
PolyWorkSheet r = (PolyWorkSheet) template.getReport(i); |
||||||
|
blockCount += r.getBlockCount(); |
||||||
|
} |
||||||
|
} |
||||||
|
return blockCount; |
||||||
|
} |
||||||
|
// 获取模板控件数
|
||||||
|
public int getWidgetCount() { |
||||||
|
ParameterUI pui = template.getReportParameterAttr().getParameterUI(); |
||||||
|
return pui == null ? 0 : (pui.getAllWidgets().length - 1); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,70 @@ |
|||||||
|
|
||||||
|
apply plugin: 'java' |
||||||
|
tasks.withType(JavaCompile){ |
||||||
|
options.encoding = 'UTF-8' |
||||||
|
} |
||||||
|
//指定构建的jdk版本 |
||||||
|
sourceCompatibility=1.7 |
||||||
|
//指定生成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,60 @@ |
|||||||
|
package com.fr.aspectj.designerbase; |
||||||
|
|
||||||
|
/** |
||||||
|
* 记录模板过程 |
||||||
|
* Created by plough on 2017/3/3. |
||||||
|
*/ |
||||||
|
|
||||||
|
import com.fr.design.mainframe.templateinfo.TemplateInfoCollector; |
||||||
|
import org.aspectj.lang.reflect.SourceLocation; |
||||||
|
|
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.MouseEvent; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
public aspect TemplateProcessTracker { |
||||||
|
//声明一个pointcut,匹配你需要的方法 |
||||||
|
pointcut onMouseClicked(MouseEvent e) : |
||||||
|
execution(* mouseClicked(MouseEvent)) && args(e); |
||||||
|
pointcut onMousePressed(MouseEvent e) : |
||||||
|
execution(* mousePressed(MouseEvent)) && args(e); |
||||||
|
pointcut onMouseReleased(MouseEvent e) : |
||||||
|
execution(* mouseReleased(MouseEvent)) && args(e); |
||||||
|
pointcut onActionPerformed(ActionEvent e) : |
||||||
|
execution(* actionPerformed(ActionEvent)) && args(e); |
||||||
|
pointcut onSetValueAt(Object v, int r, int c) : |
||||||
|
execution(* setValueAt(java.lang.Object, int, int)) && args(v, r, c); |
||||||
|
|
||||||
|
//before表示之前的意思 |
||||||
|
//这整个表示在MouseAdapter的public void mouseXXX(MouseEvent)方法调用之前,你想要执行的代码 |
||||||
|
before(MouseEvent e) : onMouseClicked(e) || onMousePressed(e) || onMouseReleased(e) { |
||||||
|
SourceLocation sl = thisJoinPoint.getSourceLocation();//切面对应的代码位置 |
||||||
|
|
||||||
|
//String log = String.format("%s:\n%s\n%s\n%s\n\n", new Date(), sl, e, e.getSource()); |
||||||
|
String log = ""; |
||||||
|
TemplateInfoCollector.appendProcess(log); |
||||||
|
} |
||||||
|
//同上 |
||||||
|
before(ActionEvent e) : onActionPerformed(e) { |
||||||
|
SourceLocation sl = thisJoinPoint.getSourceLocation(); |
||||||
|
// !within(LogHandlerBar) 没用, 手动过滤 |
||||||
|
if (e.getSource().toString().contains("javax.swing.Timer")) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
//String log = String.format("%s:\n%s\n%s\n%s\n\n", new Date(), sl, e, e.getSource()); |
||||||
|
String log = ""; |
||||||
|
TemplateInfoCollector.appendProcess(log); |
||||||
|
|
||||||
|
} |
||||||
|
//同上 |
||||||
|
before(Object v, int r, int c) : onSetValueAt(v, r, c) { |
||||||
|
SourceLocation sl = thisJoinPoint.getSourceLocation(); |
||||||
|
|
||||||
|
//String log = String.format("%s:\n%s\nset value: %s at (%d, %d)\n\n", new Date(), sl, v, r, c); |
||||||
|
String log = ""; |
||||||
|
TemplateInfoCollector.appendProcess(log); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -1,37 +1,35 @@ |
|||||||
/* |
/* |
||||||
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved. |
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved. |
||||||
*/ |
*/ |
||||||
package com.fr.design.actions.edit; |
package com.fr.design.actions.edit; |
||||||
|
|
||||||
import java.awt.event.KeyEvent; |
import com.fr.base.BaseUtils; |
||||||
|
import com.fr.design.actions.TemplateComponentAction; |
||||||
import javax.swing.KeyStroke; |
import com.fr.design.designer.TargetComponent; |
||||||
|
import com.fr.general.Inter; |
||||||
import com.fr.base.BaseUtils; |
|
||||||
import com.fr.design.actions.TemplateComponentAction; |
import javax.swing.*; |
||||||
import com.fr.design.designer.TargetComponent; |
import java.awt.event.KeyEvent; |
||||||
import com.fr.general.Inter; |
|
||||||
|
/** |
||||||
/** |
* Copy. |
||||||
* Copy. |
*/ |
||||||
*/ |
public class CopyAction extends TemplateComponentAction { |
||||||
public class CopyAction extends TemplateComponentAction { |
public CopyAction(TargetComponent t) { |
||||||
public CopyAction(TargetComponent t) { |
super(t); |
||||||
super(t); |
|
||||||
|
this.setName(Inter.getLocText("M_Edit-Copy")); |
||||||
this.setName(Inter.getLocText("M_Edit-Copy")); |
this.setMnemonic('C'); |
||||||
this.setMnemonic('C'); |
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/copy.png")); |
||||||
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/copy.png")); |
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_MASK)); |
||||||
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_MASK)); |
} |
||||||
} |
|
||||||
|
@Override |
||||||
@Override |
public boolean executeActionReturnUndoRecordNeeded() { |
||||||
public boolean executeActionReturnUndoRecordNeeded() { |
TargetComponent tc = getEditingComponent(); |
||||||
TargetComponent tc = getEditingComponent(); |
if (tc != null) { |
||||||
if (tc != null) { |
tc.copy(); |
||||||
tc.copy(); |
} |
||||||
} |
return false; |
||||||
|
} |
||||||
return false; |
|
||||||
} |
|
||||||
} |
} |
File diff suppressed because it is too large
Load Diff
@ -1 +1,66 @@ |
|||||||
package com.fr.design.mainframe;
import javax.swing.JComponent;
import com.fr.form.FormElementCaseContainerProvider;
/**
* Author : Shockway
* Date: 13-7-15
* Time: 上午10:28
*/
public interface BaseJForm extends JTemplateProvider{
public static final String XML_TAG = "JForm";
public static final int FORM_TAB = 0;
public static final int ELEMENTCASE_TAB = 1;
public static final int ELEMENTCASE_CHANGE_TAB = 2;
/**
* 刷新所有控件
*/
public void refreshAllNameWidgets();
/**
* 刷新参数
*/
public void populateParameter();
/**
* 刷新选中的控件
*/
public void refreshSelectedWidget();
/**
* 获取当前的Target
*/
public Object getTarget();
/**
* 执行撤销
*
* @param o 之前保存的状态
*/
public void applyUndoState4Form(BaseUndoState o);
/**
* 获取当前编辑的组件
*/
public JComponent getEditingPane();
/**
* 只在Form和ElementCase之间切换
* @param index 切换位置
*/
public void tabChanged(int index);
/**
* 在Form和ElementCase, 以及ElementCase和ElementCase之间切换
* @param index 切换位置
* @param ecContainer ElementCase所在container
*/
public void tabChanged(int index, FormElementCaseContainerProvider ecContainer);
} |
package com.fr.design.mainframe; |
||||||
|
|
||||||
|
import javax.swing.JComponent; |
||||||
|
|
||||||
|
import com.fr.form.FormElementCaseContainerProvider; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* Author : Shockway |
||||||
|
* Date: 13-7-15 |
||||||
|
* Time: 上午10:28 |
||||||
|
*/ |
||||||
|
public interface BaseJForm extends JTemplateProvider { |
||||||
|
|
||||||
|
String XML_TAG = "JForm"; |
||||||
|
int FORM_TAB = 0; |
||||||
|
int ELEMENTCASE_TAB = 1; |
||||||
|
int ELEMENTCASE_CHANGE_TAB = 2; |
||||||
|
|
||||||
|
/** |
||||||
|
* 刷新所有控件 |
||||||
|
*/ |
||||||
|
void refreshAllNameWidgets(); |
||||||
|
|
||||||
|
/** |
||||||
|
* 刷新参数 |
||||||
|
*/ |
||||||
|
void populateParameter(); |
||||||
|
|
||||||
|
/** |
||||||
|
* 刷新选中的控件 |
||||||
|
*/ |
||||||
|
void refreshSelectedWidget(); |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取当前的Target |
||||||
|
*/ |
||||||
|
Object getTarget(); |
||||||
|
|
||||||
|
/** |
||||||
|
* 执行撤销 |
||||||
|
* |
||||||
|
* @param o 之前保存的状态 |
||||||
|
*/ |
||||||
|
void applyUndoState4Form(BaseUndoState o); |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取当前编辑的组件 |
||||||
|
*/ |
||||||
|
JComponent getEditingPane(); |
||||||
|
|
||||||
|
/** |
||||||
|
* 只在Form和ElementCase之间切换 |
||||||
|
* |
||||||
|
* @param index 切换位置 |
||||||
|
*/ |
||||||
|
void tabChanged(int index); |
||||||
|
|
||||||
|
/** |
||||||
|
* 在Form和ElementCase, 以及ElementCase和ElementCase之间切换 |
||||||
|
* |
||||||
|
* @param index 切换位置 |
||||||
|
* @param ecContainer ElementCase所在container |
||||||
|
*/ |
||||||
|
void tabChanged(int index, FormElementCaseContainerProvider ecContainer); |
||||||
|
} |
@ -0,0 +1,332 @@ |
|||||||
|
package com.fr.design.mainframe.templateinfo; |
||||||
|
|
||||||
|
import com.fr.base.FRContext; |
||||||
|
import com.fr.base.io.IOFile; |
||||||
|
import com.fr.design.DesignerEnvManager; |
||||||
|
import com.fr.design.mainframe.DesignerContext; |
||||||
|
import com.fr.design.mainframe.JTemplate; |
||||||
|
import com.fr.env.RemoteEnv; |
||||||
|
import com.fr.general.ComparatorUtils; |
||||||
|
import com.fr.general.FRLogger; |
||||||
|
import com.fr.general.GeneralUtils; |
||||||
|
import com.fr.general.SiteCenter; |
||||||
|
import com.fr.general.http.HttpClient; |
||||||
|
import com.fr.stable.*; |
||||||
|
import org.json.JSONObject; |
||||||
|
|
||||||
|
import java.io.*; |
||||||
|
import java.text.SimpleDateFormat; |
||||||
|
import java.util.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* 做模板的过程和耗时收集,辅助类 |
||||||
|
* Created by plough on 2017/2/21. |
||||||
|
*/ |
||||||
|
public class TemplateInfoCollector<T extends IOFile> implements Serializable { |
||||||
|
private static final String FILE_NAME = "tplInfo.ser"; |
||||||
|
private static TemplateInfoCollector instance; |
||||||
|
private HashMap<String, HashMap<String, Object>> templateInfoList; |
||||||
|
private String designerOpenDate; //设计器最近一次打开日期
|
||||||
|
private static final int VALID_CELL_COUNT = 5; // 有效报表模板的格子数
|
||||||
|
private static final int VALID_WIDGET_COUNT = 5; // 有效报表模板的控件数
|
||||||
|
private static final int COMPLETE_DAY_COUNT = 15; // 判断模板是否完成的天数
|
||||||
|
private static final int ONE_THOUSAND = 1000; |
||||||
|
static final long serialVersionUID = 2007L; |
||||||
|
|
||||||
|
@SuppressWarnings("unchecked") |
||||||
|
private TemplateInfoCollector() { |
||||||
|
templateInfoList = new HashMap<>(); |
||||||
|
setDesignerOpenDate(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 把设计器最近打开日期设定为当前日期 |
||||||
|
*/ |
||||||
|
private void setDesignerOpenDate() { |
||||||
|
designerOpenDate = new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime()); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 判断今天是否第一次打开设计器 |
||||||
|
*/ |
||||||
|
private boolean designerOpenFirstTime() { |
||||||
|
String today = new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime()); |
||||||
|
return !ComparatorUtils.equals(today, designerOpenDate); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取缓存文件存放路径 |
||||||
|
*/ |
||||||
|
private static File getInfoFile() { |
||||||
|
return new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), FILE_NAME)); |
||||||
|
} |
||||||
|
|
||||||
|
public static TemplateInfoCollector getInstance() { |
||||||
|
if (instance == null) { |
||||||
|
// 先尝试从文件读取
|
||||||
|
try{ |
||||||
|
ObjectInputStream is = new ObjectInputStream(new FileInputStream(getInfoFile())); |
||||||
|
instance = (TemplateInfoCollector) is.readObject(); |
||||||
|
} catch (FileNotFoundException ex) { |
||||||
|
// 如果之前没有存储过,则创建新对象
|
||||||
|
instance = new TemplateInfoCollector(); |
||||||
|
} catch (InvalidClassException ex) { |
||||||
|
// 如果 TemplateInfoCollecor 类结构有改动,则放弃之前收集的数据(下次保存时覆盖)
|
||||||
|
// 这种情况主要在开发、测试过程中遇到,正式上线后不应该出现
|
||||||
|
FRLogger.getLogger().info(ex.getMessage()); |
||||||
|
FRLogger.getLogger().info("use a new instance"); |
||||||
|
instance = new TemplateInfoCollector(); |
||||||
|
} |
||||||
|
catch (Exception ex) { |
||||||
|
FRLogger.getLogger().error(ex.getMessage(), ex); |
||||||
|
} |
||||||
|
} |
||||||
|
return instance; |
||||||
|
} |
||||||
|
|
||||||
|
private boolean shouldCollectInfo() { |
||||||
|
if (FRContext.getCurrentEnv() instanceof RemoteEnv) { // 远程设计不收集数据
|
||||||
|
return false; |
||||||
|
} |
||||||
|
return DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv(); |
||||||
|
} |
||||||
|
|
||||||
|
public void appendProcess(String log) { |
||||||
|
if (!shouldCollectInfo()) { |
||||||
|
return; |
||||||
|
} |
||||||
|
// 获取当前编辑的模板
|
||||||
|
JTemplate jt = DesignerContext.getDesignerFrame().getSelectedJTemplate(); |
||||||
|
// 追加过程记录
|
||||||
|
jt.appendProcess(log); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 加载已经存储的模板过程 |
||||||
|
*/ |
||||||
|
@SuppressWarnings("unchecked") |
||||||
|
public String loadProcess(T t) { |
||||||
|
HashMap<String, Object> processMap = (HashMap<String, Object>) templateInfoList.get(t.getTemplateID()).get("processMap"); |
||||||
|
return (String)processMap.get("process"); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 根据模板ID是否在收集列表中,判断是否需要收集当前模板的信息 |
||||||
|
*/ |
||||||
|
public boolean inList(T t) { |
||||||
|
return templateInfoList.containsKey(t.getTemplateID()); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 将包含所有信息的对象保存到文件 |
||||||
|
*/ |
||||||
|
private void saveInfo() { |
||||||
|
try { |
||||||
|
ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream(getInfoFile())); |
||||||
|
String log = ""; |
||||||
|
int count = 1; |
||||||
|
for (String key : templateInfoList.keySet()) { |
||||||
|
String createTime = ((HashMap)templateInfoList.get(key).get("consumingMap")).get("create_time").toString(); |
||||||
|
log += (count + ". id: " + key + " " + createTime + "\n" + templateInfoList.get(key).toString() + "\n"); |
||||||
|
count ++; |
||||||
|
} |
||||||
|
FRLogger.getLogger().info("writing tplInfo: \n" + log); |
||||||
|
os.writeObject(instance); |
||||||
|
os.close(); |
||||||
|
} catch (Exception ex) { |
||||||
|
FRLogger.getLogger().error(ex.getMessage()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 更新 day_count:打开设计器却未编辑模板的连续日子 |
||||||
|
*/ |
||||||
|
private void addDayCount() { |
||||||
|
if (designerOpenFirstTime()) { |
||||||
|
for (String key : templateInfoList.keySet()) { |
||||||
|
HashMap<String, Object> templateInfo = templateInfoList.get(key); |
||||||
|
int dayCount = (int)templateInfo.get("day_count") + 1; |
||||||
|
templateInfo.put("day_count", dayCount); |
||||||
|
} |
||||||
|
setDesignerOpenDate(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 收集模板信息。如果之前没有记录,则新增;如果已有记录,则更新。 |
||||||
|
* 同时将最新数据保存到文件中。 |
||||||
|
*/ |
||||||
|
@SuppressWarnings("unchecked") |
||||||
|
public void collectInfo(T t, JTemplate jt, long openTime, long saveTime) { |
||||||
|
if (!shouldCollectInfo()) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
HashMap<String, Object> templateInfo; |
||||||
|
|
||||||
|
long timeConsume = ((saveTime - openTime) / ONE_THOUSAND); // 制作模板耗时(单位:s)
|
||||||
|
String templateID = t.getTemplateID(); |
||||||
|
|
||||||
|
if (inList(t)) { // 已有记录
|
||||||
|
templateInfo = templateInfoList.get(t.getTemplateID()); |
||||||
|
// 更新 conusmingMap
|
||||||
|
HashMap<String, Object> consumingMap = (HashMap<String, Object>) templateInfo.get("consumingMap"); |
||||||
|
timeConsume += (long)consumingMap.get("time_consume"); // 加上之前的累计编辑时间
|
||||||
|
consumingMap.put("time_consume", timeConsume); |
||||||
|
} |
||||||
|
else { // 新增
|
||||||
|
templateInfo = new HashMap<>(); |
||||||
|
templateInfo.put("consumingMap", getNewConsumingMap(templateID, openTime, timeConsume)); |
||||||
|
} |
||||||
|
|
||||||
|
// 直接覆盖 processMap
|
||||||
|
templateInfo.put("processMap", getProcessMap(templateID, jt)); |
||||||
|
|
||||||
|
// 保存模板时,让 day_count 归零
|
||||||
|
templateInfo.put("day_count", 0); |
||||||
|
|
||||||
|
|
||||||
|
templateInfoList.put(templateID, templateInfo); |
||||||
|
|
||||||
|
saveInfo(); // 每次更新之后,都同步到暂存文件中
|
||||||
|
} |
||||||
|
|
||||||
|
private HashMap<String, Object> getNewConsumingMap(String templateID, long openTime, long timeConsume) { |
||||||
|
HashMap<String, Object> consumingMap = new HashMap<>(); |
||||||
|
|
||||||
|
String username = DesignerEnvManager.getEnvManager().getBBSName(); |
||||||
|
String uuid = DesignerEnvManager.getEnvManager().getUUID(); |
||||||
|
String activitykey = DesignerEnvManager.getEnvManager().getActivationKey(); |
||||||
|
String createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(Calendar.getInstance().getTime()); |
||||||
|
String jarTime = GeneralUtils.readBuildNO(); |
||||||
|
String version = ProductConstants.VERSION; |
||||||
|
consumingMap.put("username", username); |
||||||
|
consumingMap.put("uuid", uuid); |
||||||
|
consumingMap.put("activitykey", activitykey); |
||||||
|
consumingMap.put("templateID", templateID); |
||||||
|
consumingMap.put("create_time", createTime); |
||||||
|
consumingMap.put("time_consume", timeConsume); |
||||||
|
consumingMap.put("jar_time", jarTime); |
||||||
|
consumingMap.put("version", version); |
||||||
|
|
||||||
|
return consumingMap; |
||||||
|
} |
||||||
|
|
||||||
|
private HashMap<String, Object> getProcessMap(String templateID, JTemplate jt) { |
||||||
|
HashMap<String, Object> processMap = new HashMap<>(); |
||||||
|
|
||||||
|
processMap.put("templateID", templateID); |
||||||
|
processMap.put("process", jt.getProcess()); |
||||||
|
|
||||||
|
TemplateProcessInfo info = jt.getProcessInfo(); |
||||||
|
processMap.put("report_type", info.getReportType()); |
||||||
|
processMap.put("cell_count", info.getCellCount()); |
||||||
|
processMap.put("float_count", info.getFloatCount()); |
||||||
|
processMap.put("block_count", info.getBlockCount()); |
||||||
|
processMap.put("widget_count", info.getWidgetCount()); |
||||||
|
|
||||||
|
return processMap; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 发送本地模板信息到服务器 |
||||||
|
*/ |
||||||
|
public void sendTemplateInfo() { |
||||||
|
addDayCount(); |
||||||
|
String consumingUrl = SiteCenter.getInstance().acquireUrlByKind("tempinfo.consuming") + "/single"; |
||||||
|
String processUrl = SiteCenter.getInstance().acquireUrlByKind("tempinfo.process") + "/single"; |
||||||
|
ArrayList<HashMap<String, String>> completeTemplatesInfo = getCompleteTemplatesInfo(); |
||||||
|
for (HashMap<String, String> templateInfo : completeTemplatesInfo) { |
||||||
|
String jsonConsumingMap = templateInfo.get("jsonConsumingMap"); |
||||||
|
String jsonProcessMap = templateInfo.get("jsonProcessMap"); |
||||||
|
if (sendSingleTemplateInfo(consumingUrl, jsonConsumingMap) && sendSingleTemplateInfo(processUrl, jsonProcessMap)) { |
||||||
|
// 清空记录
|
||||||
|
FRLogger.getLogger().info("successfully send " + templateInfo.get("templateID")); |
||||||
|
removeFromTemplateInfoList(templateInfo.get("templateID")); |
||||||
|
} else { |
||||||
|
FRLogger.getLogger().info("send template info failed, will try next time, " + templateInfo.get("templateID")); |
||||||
|
} |
||||||
|
} |
||||||
|
saveInfo(); |
||||||
|
} |
||||||
|
|
||||||
|
private boolean sendSingleTemplateInfo(String url, String content) { |
||||||
|
HashMap<String, String> para = new HashMap<>(); |
||||||
|
String date = new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime()); |
||||||
|
para.put("token", CodeUtils.md5Encode(date, "", "MD5")); |
||||||
|
para.put("content", content); |
||||||
|
HttpClient httpClient = new HttpClient(url, para, true); |
||||||
|
httpClient.setTimeout(5000); |
||||||
|
httpClient.asGet(); |
||||||
|
|
||||||
|
if (!httpClient.isServerAlive()) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
String res = httpClient.getResponseText(); |
||||||
|
boolean success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success"); |
||||||
|
return success; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 返回已完成的模板信息 |
||||||
|
*/ |
||||||
|
@SuppressWarnings("unchecked") |
||||||
|
private ArrayList<HashMap<String, String>> getCompleteTemplatesInfo() { |
||||||
|
ArrayList<HashMap<String, String>> completeTemplatesInfo = new ArrayList<>(); |
||||||
|
ArrayList<String> testTemplateKeys = new ArrayList<>(); // 保存测试模板的key
|
||||||
|
for (String key : templateInfoList.keySet()) { |
||||||
|
HashMap<String, Object> templateInfo = templateInfoList.get(key); |
||||||
|
if ((int)templateInfo.get("day_count") <= COMPLETE_DAY_COUNT) { // 未完成模板
|
||||||
|
continue; |
||||||
|
} |
||||||
|
if (isTestTemplate(templateInfo)) { |
||||||
|
testTemplateKeys.add(key); |
||||||
|
continue; |
||||||
|
} |
||||||
|
HashMap<String, Object> consumingMap = (HashMap<String, Object>) templateInfo.get("consumingMap"); |
||||||
|
HashMap<String, Object> processMap = (HashMap<String, Object>) templateInfo.get("processMap"); |
||||||
|
String jsonConsumingMap = new JSONObject(consumingMap).toString(); |
||||||
|
String jsonProcessMap = new JSONObject(processMap).toString(); |
||||||
|
HashMap<String, String> jsonTemplateInfo = new HashMap<>(); |
||||||
|
jsonTemplateInfo.put("jsonConsumingMap", jsonConsumingMap); |
||||||
|
jsonTemplateInfo.put("jsonProcessMap", jsonProcessMap); |
||||||
|
jsonTemplateInfo.put("templateID", key); |
||||||
|
completeTemplatesInfo.add(jsonTemplateInfo); |
||||||
|
} |
||||||
|
// 删除测试模板
|
||||||
|
for (String key : testTemplateKeys) { |
||||||
|
removeFromTemplateInfoList(key); |
||||||
|
} |
||||||
|
return completeTemplatesInfo; |
||||||
|
} |
||||||
|
|
||||||
|
private void removeFromTemplateInfoList(String key) { |
||||||
|
templateInfoList.remove(key); |
||||||
|
FRLogger.getLogger().info(key + " is removed..."); |
||||||
|
} |
||||||
|
|
||||||
|
@SuppressWarnings("unchecked") |
||||||
|
private boolean isTestTemplate(HashMap<String, Object> templateInfo) { |
||||||
|
HashMap<String, Object> processMap = (HashMap<String, Object>) templateInfo.get("processMap"); |
||||||
|
int reportType = (int)processMap.get("report_type"); |
||||||
|
int cellCount = (int)processMap.get("cell_count"); |
||||||
|
int floatCount = (int)processMap.get("float_count"); |
||||||
|
int blockCount = (int)processMap.get("block_count"); |
||||||
|
int widgetCount = (int)processMap.get("widget_count"); |
||||||
|
boolean isTestTemplate = false; |
||||||
|
if (reportType == 0) { // 普通报表
|
||||||
|
isTestTemplate = cellCount <= VALID_CELL_COUNT && floatCount <= 1 && widgetCount <= VALID_WIDGET_COUNT; |
||||||
|
} else if (reportType == 1) { // 聚合报表
|
||||||
|
isTestTemplate = blockCount <= 1 && widgetCount <= VALID_WIDGET_COUNT; |
||||||
|
} else { // 表单(reportType == 2)
|
||||||
|
isTestTemplate = widgetCount <= 1; |
||||||
|
} |
||||||
|
return isTestTemplate; |
||||||
|
} |
||||||
|
|
||||||
|
public static void main(String[] args) { |
||||||
|
TemplateInfoCollector tic = TemplateInfoCollector.getInstance(); |
||||||
|
tic.sendTemplateInfo(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,26 @@ |
|||||||
|
package com.fr.design.mainframe.templateinfo; |
||||||
|
|
||||||
|
import com.fr.base.io.IOFile; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by plough on 2017/3/17. |
||||||
|
*/ |
||||||
|
public abstract class TemplateProcessInfo<T extends IOFile> { |
||||||
|
|
||||||
|
protected T template; |
||||||
|
|
||||||
|
public TemplateProcessInfo(T template) { |
||||||
|
this.template = template; |
||||||
|
} |
||||||
|
|
||||||
|
// 获取模板类型。0 代表普通报表,1 代表聚合报表,2 代表表单
|
||||||
|
public abstract int getReportType(); |
||||||
|
// 获取模板格子数
|
||||||
|
public abstract int getCellCount(); |
||||||
|
// 获取模板悬浮元素个数
|
||||||
|
public abstract int getFloatCount(); |
||||||
|
// 获取模板聚合块个数
|
||||||
|
public abstract int getBlockCount(); |
||||||
|
// 获取模板控件数
|
||||||
|
public abstract int getWidgetCount(); |
||||||
|
} |
@ -1 +1,72 @@ |
|||||||
package com.fr.design.parameter;
import com.fr.base.Parameter;
import com.fr.base.parameter.ParameterUI;
import com.fr.design.mainframe.AuthorityEditPane;
import javax.swing.*;
import java.awt.*;
/**
* 参数设计界面接口
*/
public interface ParameterDesignerProvider {
public void addListener(ParaDefinitePane paraDefinitePane);
public Component createWrapper();
public void setDesignHeight(int height);
public Dimension getDesignSize();
public Dimension getPreferredSize();
public void populate(ParameterUI p);
public void refreshAllNameWidgets();
public void refresh4TableData(String oldName, String newName);
public void refreshParameter(ParaDefinitePane paraDefinitePane);
public boolean isWithQueryButton();
public java.util.List<String> getAllXCreatorNameList();
public boolean isWithoutParaXCreator(Parameter[] ps);
public boolean isBlank();
public ParameterUI getParaTarget();
public boolean addingParameter2Editor(Parameter parameter, int index);
public boolean addingParameter2EditorWithQueryButton(Parameter parameter, int index);
public void addingAllParameter2Editor(Parameter[] parameterArray, int currentIndex);
public JPanel[] toolbarPanes4Form();
public JComponent[] toolBarButton4Form();
public void initBeforeUpEdit();
public void populateParameterPropertyPane(ParaDefinitePane p);
public void initWidgetToolbarPane();
public AuthorityEditPane getAuthorityEditPane();
public JPanel getEastUpPane();
public JPanel getEastDownPane();
public boolean isSupportAuthority();
public void removeSelection();
public ParameterBridge getParaComponent();
} |
package com.fr.design.parameter; |
||||||
|
|
||||||
|
import com.fr.base.Parameter; |
||||||
|
import com.fr.base.parameter.ParameterUI; |
||||||
|
import com.fr.design.mainframe.AuthorityEditPane; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 参数设计界面接口 |
||||||
|
*/ |
||||||
|
public interface ParameterDesignerProvider { |
||||||
|
|
||||||
|
void addListener(ParaDefinitePane paraDefinitePane); |
||||||
|
|
||||||
|
Component createWrapper(); |
||||||
|
|
||||||
|
void setDesignHeight(int height); |
||||||
|
|
||||||
|
Dimension getDesignSize(); |
||||||
|
|
||||||
|
Dimension getPreferredSize(); |
||||||
|
|
||||||
|
void populate(ParameterUI p); |
||||||
|
|
||||||
|
void refreshAllNameWidgets(); |
||||||
|
|
||||||
|
void refresh4TableData(String oldName, String newName); |
||||||
|
|
||||||
|
void refreshParameter(ParaDefinitePane paraDefinitePane); |
||||||
|
|
||||||
|
boolean isWithQueryButton(); |
||||||
|
|
||||||
|
java.util.List<String> getAllXCreatorNameList(); |
||||||
|
|
||||||
|
boolean isWithoutParaXCreator(Parameter[] ps); |
||||||
|
|
||||||
|
boolean isBlank(); |
||||||
|
|
||||||
|
ParameterUI getParaTarget(); |
||||||
|
|
||||||
|
boolean addingParameter2Editor(Parameter parameter, int index); |
||||||
|
|
||||||
|
boolean addingParameter2EditorWithQueryButton(Parameter parameter, int index); |
||||||
|
|
||||||
|
void addingAllParameter2Editor(Parameter[] parameterArray, int currentIndex); |
||||||
|
|
||||||
|
JPanel[] toolbarPanes4Form(); |
||||||
|
|
||||||
|
JComponent[] toolBarButton4Form(); |
||||||
|
|
||||||
|
void initBeforeUpEdit(); |
||||||
|
|
||||||
|
void populateParameterPropertyPane(ParaDefinitePane p); |
||||||
|
|
||||||
|
void initWidgetToolbarPane(); |
||||||
|
|
||||||
|
AuthorityEditPane getAuthorityEditPane(); |
||||||
|
|
||||||
|
JPanel getEastUpPane(); |
||||||
|
|
||||||
|
JPanel getEastDownPane(); |
||||||
|
|
||||||
|
boolean isSupportAuthority(); |
||||||
|
|
||||||
|
void removeSelection(); |
||||||
|
|
||||||
|
ParameterBridge getParaComponent(); |
||||||
|
|
||||||
|
} |
@ -1,151 +1,154 @@ |
|||||||
package com.fr.design.utils; |
package com.fr.design.utils; |
||||||
|
|
||||||
import com.fr.general.ComparatorUtils; |
import com.fr.general.ComparatorUtils; |
||||||
|
|
||||||
import javax.swing.*; |
import javax.swing.*; |
||||||
import java.awt.*; |
import java.awt.*; |
||||||
import java.awt.geom.Rectangle2D; |
import java.awt.geom.Rectangle2D; |
||||||
import java.util.ArrayList; |
import java.util.ArrayList; |
||||||
|
|
||||||
/** |
/** |
||||||
* 工具类,提供常用的工具方法 |
* 工具类,提供常用的工具方法 |
||||||
*/ |
*/ |
||||||
public class ComponentUtils { |
public class ComponentUtils { |
||||||
|
|
||||||
public static boolean isComponentVisible(Component comp) { |
private ComponentUtils() { |
||||||
if (!comp.isVisible() && !isRootComponent(comp)) { |
} |
||||||
return false; |
|
||||||
} |
public static boolean isComponentVisible(Component comp) { |
||||||
Component parent = comp.getParent(); |
if (!comp.isVisible() && !isRootComponent(comp)) { |
||||||
|
return false; |
||||||
return parent == null || isComponentVisible(parent); |
} |
||||||
|
Component parent = comp.getParent(); |
||||||
} |
|
||||||
|
return parent == null || isComponentVisible(parent); |
||||||
/** |
|
||||||
* 获取component所在的容器的绝对位置 |
} |
||||||
*/ |
|
||||||
public static Rectangle getRelativeBounds(Component component) { |
/** |
||||||
Rectangle bounds = new Rectangle(0, 0, component.getWidth(), component.getHeight()); |
* 获取component所在的容器的绝对位置 |
||||||
Container parent = component.getParent(); |
*/ |
||||||
|
public static Rectangle getRelativeBounds(Component component) { |
||||||
while (parent != null) { |
Rectangle bounds = new Rectangle(0, 0, component.getWidth(), component.getHeight()); |
||||||
bounds.x += component.getX(); |
Container parent = component.getParent(); |
||||||
bounds.y += component.getY(); |
|
||||||
component = parent; |
while (parent != null) { |
||||||
parent = component.getParent(); |
bounds.x += component.getX(); |
||||||
} |
bounds.y += component.getY(); |
||||||
|
component = parent; |
||||||
return bounds; |
parent = component.getParent(); |
||||||
} |
} |
||||||
|
|
||||||
/** |
return bounds; |
||||||
* 恢复双缓冲状态,dbcomponents保存着初始状态为启动双缓冲的组件 |
} |
||||||
*/ |
|
||||||
public static void resetBuffer(ArrayList<JComponent> dbcomponents) { |
/** |
||||||
for (JComponent jcomponent : dbcomponents) { |
* 恢复双缓冲状态,dbcomponents保存着初始状态为启动双缓冲的组件 |
||||||
jcomponent.setDoubleBuffered(true); |
*/ |
||||||
} |
public static void resetBuffer(ArrayList<JComponent> dbcomponents) { |
||||||
} |
for (JComponent jcomponent : dbcomponents) { |
||||||
|
jcomponent.setDoubleBuffered(true); |
||||||
/** |
} |
||||||
* 禁止双缓冲状态,并将初始状态为启动双缓冲的组件保存到dbcomponents中 |
} |
||||||
*/ |
|
||||||
public static void disableBuffer(Component comp, ArrayList<JComponent> dbcomponents) { |
/** |
||||||
if ((comp instanceof JComponent) && comp.isDoubleBuffered()) { |
* 禁止双缓冲状态,并将初始状态为启动双缓冲的组件保存到dbcomponents中 |
||||||
JComponent jcomponent = (JComponent) comp; |
*/ |
||||||
|
public static void disableBuffer(Component comp, ArrayList<JComponent> dbcomponents) { |
||||||
dbcomponents.add(jcomponent); |
if ((comp instanceof JComponent) && comp.isDoubleBuffered()) { |
||||||
jcomponent.setDoubleBuffered(false); |
JComponent jcomponent = (JComponent) comp; |
||||||
} |
|
||||||
|
dbcomponents.add(jcomponent); |
||||||
if (comp instanceof Container) { |
jcomponent.setDoubleBuffered(false); |
||||||
Container container = (Container) comp; |
} |
||||||
int count = container.getComponentCount(); |
|
||||||
|
if (comp instanceof Container) { |
||||||
if (count > 0) { |
Container container = (Container) comp; |
||||||
for (int i = 0; i < count; i++) { |
int count = container.getComponentCount(); |
||||||
Component component = container.getComponent(i); |
|
||||||
|
if (count > 0) { |
||||||
disableBuffer(component, dbcomponents); |
for (int i = 0; i < count; i++) { |
||||||
} |
Component component = container.getComponent(i); |
||||||
} |
|
||||||
} |
disableBuffer(component, dbcomponents); |
||||||
} |
} |
||||||
|
} |
||||||
public static int indexOfComponent(Container container, Component target) { |
} |
||||||
int count = container.getComponentCount(); |
} |
||||||
|
|
||||||
for (int i = 0; i < count; i++) { |
public static int indexOfComponent(Container container, Component target) { |
||||||
Component child = container.getComponent(i); |
int count = container.getComponentCount(); |
||||||
|
|
||||||
if (child == target) { |
for (int i = 0; i < count; i++) { |
||||||
return i; |
Component child = container.getComponent(i); |
||||||
} |
|
||||||
} |
if (child.equals(target)) { |
||||||
|
return i; |
||||||
return -1; |
} |
||||||
} |
} |
||||||
|
|
||||||
/** |
return -1; |
||||||
* 计算组件root相对于其顶层容器的可见区域 |
} |
||||||
*/ |
|
||||||
public static Rectangle computeVisibleRectRel2Root(Component root) { |
/** |
||||||
Container container = findAncestorScrollPane(root); |
* 计算组件root相对于其顶层容器的可见区域 |
||||||
|
*/ |
||||||
if (container == null) { |
public static Rectangle computeVisibleRectRel2Root(Component root) { |
||||||
return getRelativeBounds(root); |
Container container = findAncestorScrollPane(root); |
||||||
} else { |
|
||||||
// 如果是JScrollPane的子组件,需要计算其viewport与改组件的交叉的可见区域
|
if (container == null) { |
||||||
return getBoundsRel2Parent(root, container); |
return getRelativeBounds(root); |
||||||
} |
} else { |
||||||
} |
// 如果是JScrollPane的子组件,需要计算其viewport与改组件的交叉的可见区域
|
||||||
|
return getBoundsRel2Parent(root, container); |
||||||
/** |
} |
||||||
* 计算组件root相对于其顶层容器的可见区域 |
} |
||||||
*/ |
|
||||||
public static Rectangle computeVisibleRect(JComponent root) { |
/** |
||||||
Rectangle root_bounds = ComponentUtils.getRelativeBounds(root); |
* 计算组件root相对于其顶层容器的可见区域 |
||||||
Rectangle rect = computeVisibleRectRel2Root(root); |
*/ |
||||||
rect.x -= root_bounds.x; |
public static Rectangle computeVisibleRect(JComponent root) { |
||||||
rect.y -= root_bounds.y; |
Rectangle rootBounds = ComponentUtils.getRelativeBounds(root); |
||||||
|
Rectangle rect = computeVisibleRectRel2Root(root); |
||||||
return rect; |
rect.x -= rootBounds.x; |
||||||
} |
rect.y -= rootBounds.y; |
||||||
|
|
||||||
private static Rectangle getBoundsRel2Parent(Component child, Container parent) { |
return rect; |
||||||
Rectangle cRect = getRelativeBounds(child); |
} |
||||||
Rectangle pRect = getRelativeBounds(parent); |
|
||||||
Rectangle bounds = new Rectangle(); |
private static Rectangle getBoundsRel2Parent(Component child, Container parent) { |
||||||
Rectangle2D.intersect(cRect, pRect, bounds); |
Rectangle cRect = getRelativeBounds(child); |
||||||
|
Rectangle pRect = getRelativeBounds(parent); |
||||||
return bounds; |
Rectangle bounds = new Rectangle(); |
||||||
} |
Rectangle2D.intersect(cRect, pRect, bounds); |
||||||
|
|
||||||
public static Container findAncestorScrollPane(Component p) { |
return bounds; |
||||||
if ((p == null) || !(p instanceof Container)) { |
} |
||||||
return null; |
|
||||||
} |
public static Container findAncestorScrollPane(Component p) { |
||||||
|
if ((p == null) || !(p instanceof Container)) { |
||||||
Container c = p.getParent(); |
return null; |
||||||
|
} |
||||||
return findAncestorScrollPane(c); |
|
||||||
} |
Container c = p.getParent(); |
||||||
|
|
||||||
public static boolean isRootComponent(Component root) { |
return findAncestorScrollPane(c); |
||||||
Container parent = root.getParent(); |
} |
||||||
return parent == null; |
|
||||||
} |
public static boolean isRootComponent(Component root) { |
||||||
|
Container parent = root.getParent(); |
||||||
public static boolean isChildOf(Component component, Class parent) { |
return parent == null; |
||||||
Container container = component.getParent(); |
} |
||||||
if (container != null) { |
|
||||||
if (ComparatorUtils.equals(container.getClass(), parent)) { |
public static boolean isChildOf(Component component, Class parent) { |
||||||
return true; |
Container container = component.getParent(); |
||||||
} else { |
if (container != null) { |
||||||
return isChildOf(container, parent); |
if (ComparatorUtils.equals(container.getClass(), parent)) { |
||||||
} |
return true; |
||||||
} |
} else { |
||||||
return false; |
return isChildOf(container, parent); |
||||||
} |
} |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
} |
} |
@ -0,0 +1,85 @@ |
|||||||
|
|
||||||
|
apply plugin: 'java' |
||||||
|
tasks.withType(JavaCompile){ |
||||||
|
options.encoding = 'UTF-8' |
||||||
|
} |
||||||
|
|
||||||
|
buildscript { |
||||||
|
repositories { |
||||||
|
maven { |
||||||
|
url "http://www.eveoh.nl/files/maven2" |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
dependencies { |
||||||
|
classpath "nl.eveoh:gradle-aspectj:1.2" |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
ext.aspectjVersion = '1.7.4' |
||||||
|
apply plugin: 'aspectj' |
||||||
|
|
||||||
|
repositories { |
||||||
|
mavenCentral() |
||||||
|
} |
||||||
|
//指定构建的jdk版本 |
||||||
|
sourceCompatibility=1.7 |
||||||
|
//指定生成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,59 @@ |
|||||||
|
package com.fr.aspectj.designerchart; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by plough on 2017/3/3. |
||||||
|
*/ |
||||||
|
import com.fr.chart.chartattr.Chart; |
||||||
|
import com.fr.design.mainframe.templateinfo.TemplateInfoCollector; |
||||||
|
import org.aspectj.lang.reflect.SourceLocation; |
||||||
|
|
||||||
|
import javax.swing.event.ListSelectionEvent; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.MouseEvent; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
public aspect TemplateProcessTracker { |
||||||
|
//声明一个pointcut,匹配你需要的方法 |
||||||
|
pointcut onMouseClicked(MouseEvent e) : |
||||||
|
execution(* mouseClicked(MouseEvent)) && args(e); |
||||||
|
pointcut onMousePressed(MouseEvent e) : |
||||||
|
execution(* mousePressed(MouseEvent)) && args(e); |
||||||
|
pointcut onMouseReleased(MouseEvent e) : |
||||||
|
execution(* mouseReleased(MouseEvent)) && args(e); |
||||||
|
pointcut onActionPerformed(ActionEvent e) : |
||||||
|
execution(* actionPerformed(ActionEvent)) && args(e); |
||||||
|
pointcut onChartUpdate(Chart c) : |
||||||
|
execution(* update(Chart)) && args(c); |
||||||
|
|
||||||
|
//before表示之前的意思 |
||||||
|
//这整个表示在MouseAdapter的public void mouseXXX(MouseEvent)方法调用之前,你想要执行的代码 |
||||||
|
before(MouseEvent e) : onMouseClicked(e) || onMousePressed(e) || onMouseReleased(e) { |
||||||
|
SourceLocation sl = thisJoinPoint.getSourceLocation();//切面对应的代码位置 |
||||||
|
|
||||||
|
//String log = String.format("%s:\n%s\n%s\n%s\n\n", new Date(), sl, e, e.getSource()); |
||||||
|
String log = ""; |
||||||
|
TemplateInfoCollector.appendProcess(log); |
||||||
|
} |
||||||
|
//同上 |
||||||
|
before(ActionEvent e) : onActionPerformed(e) { |
||||||
|
SourceLocation sl = thisJoinPoint.getSourceLocation(); |
||||||
|
// !within(LogHandlerBar) 没用, 手动过滤 |
||||||
|
if (e.getSource().toString().contains("javax.swing.Timer")) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
//String log = String.format("%s:\n%s\n%s\n%s\n\n", new Date(), sl, e, e.getSource()); |
||||||
|
String log = ""; |
||||||
|
TemplateInfoCollector.appendProcess(log); |
||||||
|
|
||||||
|
} |
||||||
|
//同上 |
||||||
|
before(Chart c) : onChartUpdate(c) { |
||||||
|
SourceLocation sl = thisJoinPoint.getSourceLocation(); |
||||||
|
//String log = String.format("%s:\n%s\n插入新图表:%s\n\n", new Date(), sl, c.getChartName()); |
||||||
|
String log = ""; |
||||||
|
TemplateInfoCollector.appendProcess(log); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,59 @@ |
|||||||
|
package com.fr.aspectj.designerform; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by plough on 2017/3/3. |
||||||
|
*/ |
||||||
|
import com.fr.design.mainframe.templateinfo.TemplateInfoCollector; |
||||||
|
import org.aspectj.lang.reflect.SourceLocation; |
||||||
|
|
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.MouseEvent; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
public aspect TemplateProcessTracker { |
||||||
|
//声明一个pointcut,匹配你需要的方法 |
||||||
|
pointcut onMouseClicked(MouseEvent e) : |
||||||
|
execution(* mouseClicked(MouseEvent)) && args(e); |
||||||
|
pointcut onMousePressed(MouseEvent e) : |
||||||
|
execution(* mousePressed(MouseEvent)) && args(e); |
||||||
|
pointcut onMouseReleased(MouseEvent e) : |
||||||
|
execution(* mouseReleased(MouseEvent)) && args(e); |
||||||
|
pointcut onActionPerformed(ActionEvent e) : |
||||||
|
execution(* actionPerformed(ActionEvent)) && args(e); |
||||||
|
pointcut onSetValueAt(Object v, int r, int c) : |
||||||
|
execution(* setValueAt(java.lang.Object, int, int)) && args(v, r, c); |
||||||
|
|
||||||
|
//before表示之前的意思 |
||||||
|
//这整个表示在MouseAdapter的public void mouseXXX(MouseEvent)方法调用之前,你想要执行的代码 |
||||||
|
before(MouseEvent e) : onMouseClicked(e) || onMousePressed(e) || onMouseReleased(e) { |
||||||
|
SourceLocation sl = thisJoinPoint.getSourceLocation();//切面对应的代码位置 |
||||||
|
|
||||||
|
//String log = String.format("%s:\n%s\n%s\n%s\n\n", new Date(), sl, e, e.getSource()); |
||||||
|
String log = ""; |
||||||
|
TemplateInfoCollector.appendProcess(log); |
||||||
|
} |
||||||
|
//同上 |
||||||
|
before(ActionEvent e) : onActionPerformed(e) { |
||||||
|
SourceLocation sl = thisJoinPoint.getSourceLocation(); |
||||||
|
// !within(LogHandlerBar) 没用, 手动过滤 |
||||||
|
if (e.getSource().toString().contains("javax.swing.Timer")) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
//String log = String.format("%s:\n%s\n%s\n%s\n\n", new Date(), sl, e, e.getSource()); |
||||||
|
String log = ""; |
||||||
|
TemplateInfoCollector.appendProcess(log); |
||||||
|
|
||||||
|
} |
||||||
|
//同上 |
||||||
|
before(Object v, int r, int c) : onSetValueAt(v, r, c) { |
||||||
|
SourceLocation sl = thisJoinPoint.getSourceLocation(); |
||||||
|
|
||||||
|
//String log = String.format("%s:\n%s\nset value: %s at (%d, %d)\n\n", new Date(), sl, v, r, c); |
||||||
|
String log = ""; |
||||||
|
TemplateInfoCollector.appendProcess(log); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -1,85 +1,94 @@ |
|||||||
package com.fr.design.designer.beans; |
package com.fr.design.designer.beans; |
||||||
|
|
||||||
import com.fr.design.beans.GroupModel; |
import com.fr.design.beans.GroupModel; |
||||||
import com.fr.design.designer.creator.XCreator; |
import com.fr.design.designer.creator.XCreator; |
||||||
|
|
||||||
/** |
/** |
||||||
* 该接口是LayoutManager的BeanInfo类。标准Java平台没有提供布局管理器的BeanInfo类, |
* 该接口是LayoutManager的BeanInfo类。标准Java平台没有提供布局管理器的BeanInfo类, |
||||||
* 对于界面设计工具来说还需一些特殊的行为。 |
* 对于界面设计工具来说还需一些特殊的行为。 |
||||||
* @since 6.5.3 |
* |
||||||
*/ |
* @since 6.5.3 |
||||||
public interface LayoutAdapter { |
*/ |
||||||
|
public interface LayoutAdapter { |
||||||
/** |
|
||||||
* 在添加组件状态时,当鼠标移动到某个容器上方时,如果该容器有布局管理器,则会调用该布局 |
/** |
||||||
* 管理适配器的accept来决定当前位置是否可以放置,并提供特殊的标识,比如红色区域标识。比 |
* 在添加组件状态时,当鼠标移动到某个容器上方时,如果该容器有布局管理器,则会调用该布局 |
||||||
* 如在BorderLayout中,如果某个方位已经放置了组件,则此时应该返回false标识该区域不可以 |
* 管理适配器的accept来决定当前位置是否可以放置,并提供特殊的标识,比如红色区域标识。比 |
||||||
* 放置。 |
* 如在BorderLayout中,如果某个方位已经放置了组件,则此时应该返回false标识该区域不可以 |
||||||
*@param creator 组件 |
* 放置。 |
||||||
*@param x 添加的位置x,该位置是相对于container的 |
* |
||||||
*@param y 添加的位置y,该位置是相对于container的 |
* @param creator 组件 |
||||||
*@return 是否可以放置 |
* @param x 添加的位置x,该位置是相对于container的 |
||||||
*/ |
* @param y 添加的位置y,该位置是相对于container的 |
||||||
boolean accept(XCreator creator, int x, int y); |
* @return 是否可以放置 |
||||||
|
*/ |
||||||
/** |
boolean accept(XCreator creator, int x, int y); |
||||||
* 有的控件在拖拽调整大小后需要根据自身内容重新计算下当前的尺寸是否合适,如果不合适,就需要重新fix一下 |
|
||||||
* @param creator 组件 |
/** |
||||||
*/ |
* 有的控件在拖拽调整大小后需要根据自身内容重新计算下当前的尺寸是否合适,如果不合适,就需要重新fix一下 |
||||||
void fix(XCreator creator); |
* |
||||||
|
* @param creator 组件 |
||||||
/** |
*/ |
||||||
* 组件的ComponentAdapter在添加组件时,如果发现布局管理器不为空,会继而调用该布局管理器的 |
void fix(XCreator creator); |
||||||
* addComp方法来完成组件的具体添加。在该方法内,布局管理器可以提供额外的功能。 |
|
||||||
* @param creator 被添加的新组件 |
/** |
||||||
* @param x 添加的位置x,该位置是相对于container的 |
* 组件的ComponentAdapter在添加组件时,如果发现布局管理器不为空,会继而调用该布局管理器的 |
||||||
* @param y 添加的位置y,该位置是相对于container的 |
* addComp方法来完成组件的具体添加。在该方法内,布局管理器可以提供额外的功能。 |
||||||
* @return 是否添加成功,成功返回true,否则false |
* |
||||||
*/ |
* @param creator 被添加的新组件 |
||||||
boolean addBean(XCreator creator, int x, int y); |
* @param x 添加的位置x,该位置是相对于container的 |
||||||
|
* @param y 添加的位置y,该位置是相对于container的 |
||||||
/** |
* @return 是否添加成功,成功返回true,否则false |
||||||
* 返回该布局管理适配器的Painter,为容器提供放置位置的标识。 |
*/ |
||||||
*/ |
boolean addBean(XCreator creator, int x, int y); |
||||||
HoverPainter getPainter(); |
|
||||||
|
/** |
||||||
/** |
* 返回该布局管理适配器的Painter,为容器提供放置位置的标识。 |
||||||
* 显示parent的字组件child,解决CardLayout中显示某个非显示组件的特殊情况 |
*/ |
||||||
* @param child 组件 |
HoverPainter getPainter(); |
||||||
*/ |
|
||||||
void showComponent(XCreator child); |
/** |
||||||
|
* 显示parent的字组件child,解决CardLayout中显示某个非显示组件的特殊情况 |
||||||
void addNextComponent(XCreator dragged); |
* |
||||||
|
* @param child 组件 |
||||||
/** |
*/ |
||||||
* 组件叠放顺序前插入 |
void showComponent(XCreator child); |
||||||
* @param target 目标组件 |
|
||||||
* @param added 插入组件 |
void addNextComponent(XCreator dragged); |
||||||
*/ |
|
||||||
void addBefore(XCreator target, XCreator added); |
/** |
||||||
|
* 组件叠放顺序前插入 |
||||||
/** |
* |
||||||
* 组件叠放顺序后插入 |
* @param target 目标组件 |
||||||
* @param target 目标组件 |
* @param added 插入组件 |
||||||
* @param added 放置组件 |
*/ |
||||||
*/ |
void addBefore(XCreator target, XCreator added); |
||||||
void addAfter(XCreator target, XCreator added); |
|
||||||
|
/** |
||||||
/** |
* 组件叠放顺序后插入 |
||||||
* 能否放置更多组件 |
* |
||||||
* @return 能则返回true |
* @param target 目标组件 |
||||||
*/ |
* @param added 放置组件 |
||||||
boolean canAcceptMoreComponent(); |
*/ |
||||||
|
void addAfter(XCreator target, XCreator added); |
||||||
ConstraintsGroupModel getLayoutConstraints(XCreator creator); |
|
||||||
|
/** |
||||||
GroupModel getLayoutProperties(); |
* 能否放置更多组件 |
||||||
|
* |
||||||
/** |
* @return 能则返回true |
||||||
* 删除组件 |
*/ |
||||||
* @param creator 组件 |
boolean canAcceptMoreComponent(); |
||||||
* @param initWidth 组件之前宽度 |
|
||||||
* @param initHeight 组件之前高度 |
ConstraintsGroupModel getLayoutConstraints(XCreator creator); |
||||||
*/ |
|
||||||
void removeBean(XCreator creator, int initWidth, int initHeight); |
GroupModel getLayoutProperties(); |
||||||
|
|
||||||
|
/** |
||||||
|
* 删除组件 |
||||||
|
* |
||||||
|
* @param creator 组件 |
||||||
|
* @param initWidth 组件之前宽度 |
||||||
|
* @param initHeight 组件之前高度 |
||||||
|
*/ |
||||||
|
void removeBean(XCreator creator, int initWidth, int initHeight); |
||||||
} |
} |
@ -1,31 +1,30 @@ |
|||||||
package com.fr.design.designer.beans.actions; |
package com.fr.design.designer.beans.actions; |
||||||
|
|
||||||
import java.awt.event.InputEvent; |
import com.fr.base.BaseUtils; |
||||||
import java.awt.event.KeyEvent; |
import com.fr.design.mainframe.FormDesigner; |
||||||
|
import com.fr.general.Inter; |
||||||
import javax.swing.KeyStroke; |
|
||||||
|
import javax.swing.*; |
||||||
import com.fr.base.BaseUtils; |
import java.awt.event.InputEvent; |
||||||
import com.fr.general.Inter; |
import java.awt.event.KeyEvent; |
||||||
import com.fr.design.mainframe.FormDesigner; |
|
||||||
|
public class CopyAction extends FormEditAction { |
||||||
public class CopyAction extends FormEditAction { |
|
||||||
|
public CopyAction(FormDesigner t) { |
||||||
public CopyAction(FormDesigner t) { |
super(t); |
||||||
super(t); |
this.setName(Inter.getLocText("M_Edit-Copy")); |
||||||
this.setName(Inter.getLocText("M_Edit-Copy")); |
this.setMnemonic('C'); |
||||||
this.setMnemonic('C'); |
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/copy.png")); |
||||||
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/copy.png")); |
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK)); |
||||||
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK)); |
} |
||||||
} |
|
||||||
|
@Override |
||||||
@Override |
public boolean executeActionReturnUndoRecordNeeded() { |
||||||
public boolean executeActionReturnUndoRecordNeeded() { |
FormDesigner tc = getEditingComponent(); |
||||||
FormDesigner tc = getEditingComponent(); |
if (tc != null) { |
||||||
if (tc != null) { |
tc.copy(); |
||||||
tc.copy(); |
} |
||||||
} |
return false; |
||||||
return false; |
} |
||||||
} |
|
||||||
|
|
||||||
} |
} |
@ -1,174 +1,189 @@ |
|||||||
package com.fr.design.designer.beans.adapters.layout; |
package com.fr.design.designer.beans.adapters.layout; |
||||||
|
|
||||||
import java.awt.LayoutManager; |
import com.fr.design.beans.GroupModel; |
||||||
|
import com.fr.design.designer.beans.ConstraintsGroupModel; |
||||||
import com.fr.general.ComparatorUtils; |
import com.fr.design.designer.beans.HoverPainter; |
||||||
import com.fr.design.beans.GroupModel; |
import com.fr.design.designer.beans.LayoutAdapter; |
||||||
import com.fr.design.designer.beans.ConstraintsGroupModel; |
import com.fr.design.designer.beans.painters.NullPainter; |
||||||
import com.fr.design.designer.beans.HoverPainter; |
import com.fr.design.designer.creator.XCreator; |
||||||
import com.fr.design.designer.beans.LayoutAdapter; |
import com.fr.design.designer.creator.XLayoutContainer; |
||||||
import com.fr.design.designer.beans.painters.NullPainter; |
import com.fr.design.designer.creator.XWidgetCreator; |
||||||
import com.fr.design.designer.creator.XCreator; |
import com.fr.design.utils.ComponentUtils; |
||||||
import com.fr.design.designer.creator.XLayoutContainer; |
import com.fr.design.utils.gui.LayoutUtils; |
||||||
import com.fr.design.designer.creator.XWidgetCreator; |
import com.fr.general.ComparatorUtils; |
||||||
import com.fr.design.utils.ComponentUtils; |
|
||||||
import com.fr.design.utils.gui.LayoutUtils; |
import java.awt.*; |
||||||
|
|
||||||
public abstract class AbstractLayoutAdapter implements LayoutAdapter { |
public abstract class AbstractLayoutAdapter implements LayoutAdapter { |
||||||
|
|
||||||
protected XLayoutContainer container; |
protected XLayoutContainer container; |
||||||
protected LayoutManager layout; |
protected LayoutManager layout; |
||||||
|
|
||||||
public AbstractLayoutAdapter(XLayoutContainer container) { |
public AbstractLayoutAdapter(XLayoutContainer container) { |
||||||
this.container = container; |
this.container = container; |
||||||
this.layout = container.getLayout(); |
this.layout = container.getLayout(); |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 是否使用控件备份大小 |
* 是否使用控件备份大小 |
||||||
* @param xCreator 控件 |
* |
||||||
* @return 所在容器相同,且支持备份的话返回true |
* @param xCreator 控件 |
||||||
*/ |
* @return 所在容器相同,且支持备份的话返回true |
||||||
public boolean whetherUseBackupSize(XCreator xCreator) { |
*/ |
||||||
Class clazz = container.getClass(); |
public boolean whetherUseBackupSize(XCreator xCreator) { |
||||||
Class bkClazz = null; |
Class clazz = container.getClass(); |
||||||
if(xCreator.getBackupParent() != null) { |
Class bkClazz = null; |
||||||
bkClazz = xCreator.getBackupParent().getClass(); |
if (xCreator.getBackupParent() != null) { |
||||||
} |
bkClazz = xCreator.getBackupParent().getClass(); |
||||||
return ComparatorUtils.equals(bkClazz, clazz) |
} |
||||||
&& supportBackupSize(); |
return ComparatorUtils.equals(bkClazz, clazz) |
||||||
} |
&& supportBackupSize(); |
||||||
|
} |
||||||
/** |
|
||||||
* 是否支持用备份大小 |
/** |
||||||
* @return 否 |
* 是否支持用备份大小 |
||||||
*/ |
* |
||||||
public boolean supportBackupSize() { |
* @return 否 |
||||||
return false; |
*/ |
||||||
} |
public boolean supportBackupSize() { |
||||||
|
return false; |
||||||
/** |
} |
||||||
* 有的控件在拖拽调整大小后需要根据自身内容重新计算下当前的尺寸是否合适,如果不合适,就需要重新fix一下 |
|
||||||
* @param creator 组件 |
/** |
||||||
*/ |
* 有的控件在拖拽调整大小后需要根据自身内容重新计算下当前的尺寸是否合适,如果不合适,就需要重新fix一下 |
||||||
public void fix(XCreator creator) { |
* |
||||||
} |
* @param creator 组件 |
||||||
|
*/ |
||||||
/** |
public void fix(XCreator creator) { |
||||||
* 显示parent的字组件child,解决CardLayout中显示某个非显示组件的特殊情况 |
} |
||||||
* @param child 组件 |
|
||||||
*/ |
/** |
||||||
@Override |
* 显示parent的字组件child,解决CardLayout中显示某个非显示组件的特殊情况 |
||||||
public void showComponent(XCreator child) { |
* |
||||||
child.setVisible(true); |
* @param child 组件 |
||||||
} |
*/ |
||||||
|
@Override |
||||||
/** |
public void showComponent(XCreator child) { |
||||||
* 组件的ComponentAdapter在添加组件时,如果发现布局管理器不为空,会继而调用该布局管理器的 |
child.setVisible(true); |
||||||
* addComp方法来完成组件的具体添加。在该方法内,布局管理器可以提供额外的功能。 |
} |
||||||
* @param creator 被添加的新组件 |
|
||||||
* @param x 添加的位置x,该位置是相对于container的 |
/** |
||||||
* @param y 添加的位置y,该位置是相对于container的 |
* 组件的ComponentAdapter在添加组件时,如果发现布局管理器不为空,会继而调用该布局管理器的 |
||||||
* @return 是否添加成功,成功返回true,否则false |
* addComp方法来完成组件的具体添加。在该方法内,布局管理器可以提供额外的功能。 |
||||||
*/ |
* |
||||||
@Override |
* @param creator 被添加的新组件 |
||||||
public boolean addBean(XCreator creator, int x, int y) { |
* @param x 添加的位置x,该位置是相对于container的 |
||||||
if (!accept(creator, x, y)) { |
* @param y 添加的位置y,该位置是相对于container的 |
||||||
return false; |
* @return 是否添加成功,成功返回true,否则false |
||||||
} |
*/ |
||||||
addComp(creator, x, y); |
@Override |
||||||
((XWidgetCreator) creator).recalculateChildrenSize(); |
public boolean addBean(XCreator creator, int x, int y) { |
||||||
return true; |
if (!accept(creator, x, y)) { |
||||||
} |
return false; |
||||||
|
} |
||||||
/** |
addComp(creator, x, y); |
||||||
* 删除组件 |
((XWidgetCreator) creator).recalculateChildrenSize(); |
||||||
* @param creator 组件 |
return true; |
||||||
* @param initWidth 组件之前宽度 |
} |
||||||
* @param initHeight 组件之前高度 |
|
||||||
*/ |
/** |
||||||
public void removeBean(XCreator creator, int creatorWidth, int creatorHeight) { |
* 删除组件 |
||||||
delete(creator, creatorWidth, creatorHeight); |
* |
||||||
} |
* @param creator 组件 |
||||||
|
* @param creatorWidth |
||||||
protected void delete(XCreator creator, int creatorWidth, int creatorHeight) { |
* @param creatorHeight |
||||||
} |
*/ |
||||||
|
public void removeBean(XCreator creator, int creatorWidth, int creatorHeight) { |
||||||
protected abstract void addComp(XCreator creator, int x, int y); |
delete(creator, creatorWidth, creatorHeight); |
||||||
|
} |
||||||
/** |
|
||||||
* 增加下一个组件 |
protected void delete(XCreator creator, int creatorWidth, int creatorHeight) { |
||||||
* @param dragged 组件 |
} |
||||||
*/ |
|
||||||
@Override |
protected abstract void addComp(XCreator creator, int x, int y); |
||||||
public void addNextComponent(XCreator dragged) { |
|
||||||
container.add(dragged); |
/** |
||||||
LayoutUtils.layoutRootContainer(container); |
* 增加下一个组件 |
||||||
} |
* |
||||||
|
* @param dragged 组件 |
||||||
/** |
*/ |
||||||
* 目标控件位置插入组件 |
@Override |
||||||
* @param target 目标 |
public void addNextComponent(XCreator dragged) { |
||||||
* @param added 增加组件 |
container.add(dragged); |
||||||
*/ |
LayoutUtils.layoutRootContainer(container); |
||||||
@Override |
} |
||||||
public void addBefore(XCreator target, XCreator added) { |
|
||||||
int index = ComponentUtils.indexOfComponent(container, target); |
/** |
||||||
|
* 目标控件位置插入组件 |
||||||
if (index == -1) { |
* |
||||||
container.add(added, 0); |
* @param target 目标 |
||||||
} else { |
* @param added 增加组件 |
||||||
container.add(added, index); |
*/ |
||||||
} |
@Override |
||||||
|
public void addBefore(XCreator target, XCreator added) { |
||||||
LayoutUtils.layoutRootContainer(container); |
int index = ComponentUtils.indexOfComponent(container, target); |
||||||
} |
|
||||||
|
if (index == -1) { |
||||||
/** |
container.add(added, 0); |
||||||
* 插在目标组件后面 |
} else { |
||||||
* @param target 目标 |
container.add(added, index); |
||||||
* @param added 增加组件 |
} |
||||||
*/ |
|
||||||
@Override |
LayoutUtils.layoutRootContainer(container); |
||||||
public void addAfter(XCreator target, XCreator added) { |
} |
||||||
int index = ComponentUtils.indexOfComponent(container, target); |
|
||||||
|
/** |
||||||
if (index == -1) { |
* 插在目标组件后面 |
||||||
container.add(added); |
* |
||||||
} else { |
* @param target 目标 |
||||||
index++; |
* @param added 增加组件 |
||||||
|
*/ |
||||||
if (index >= container.getComponentCount()) { |
@Override |
||||||
container.add(added); |
public void addAfter(XCreator target, XCreator added) { |
||||||
} else { |
int index = ComponentUtils.indexOfComponent(container, target); |
||||||
container.add(added, index); |
|
||||||
} |
if (index == -1) { |
||||||
} |
container.add(added); |
||||||
|
} else { |
||||||
LayoutUtils.layoutRootContainer(container); |
index++; |
||||||
} |
|
||||||
|
if (index >= container.getComponentCount()) { |
||||||
@Override |
container.add(added); |
||||||
public HoverPainter getPainter() { |
} else { |
||||||
return new NullPainter(container); |
container.add(added, index); |
||||||
} |
} |
||||||
|
} |
||||||
/** |
|
||||||
* 是否能接收更多的组件 |
LayoutUtils.layoutRootContainer(container); |
||||||
* @return 能则返回true |
} |
||||||
*/ |
|
||||||
@Override |
@Override |
||||||
public boolean canAcceptMoreComponent() { |
public HoverPainter getPainter() { |
||||||
return true; |
return new NullPainter(container); |
||||||
} |
} |
||||||
|
|
||||||
@Override |
/** |
||||||
public ConstraintsGroupModel getLayoutConstraints(XCreator creator) { |
* 是否能接收更多的组件 |
||||||
return null; |
* |
||||||
} |
* @return 能则返回true |
||||||
|
*/ |
||||||
@Override |
@Override |
||||||
public GroupModel getLayoutProperties() { |
public boolean canAcceptMoreComponent() { |
||||||
return null; |
return true; |
||||||
} |
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public ConstraintsGroupModel getLayoutConstraints(XCreator creator) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public GroupModel getLayoutProperties() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public XLayoutContainer getContainer() { |
||||||
|
return this.container; |
||||||
|
} |
||||||
} |
} |
@ -1,108 +1,105 @@ |
|||||||
/** |
/** |
||||||
* |
* |
||||||
*/ |
*/ |
||||||
package com.fr.design.designer.beans.adapters.layout; |
package com.fr.design.designer.beans.adapters.layout; |
||||||
|
|
||||||
|
|
||||||
import com.fr.design.beans.GroupModel; |
import com.fr.design.beans.GroupModel; |
||||||
import com.fr.design.designer.creator.XCreator; |
import com.fr.design.designer.creator.XCreator; |
||||||
import com.fr.design.designer.creator.XLayoutContainer; |
import com.fr.design.designer.creator.XLayoutContainer; |
||||||
import com.fr.design.designer.creator.XWParameterLayout; |
import com.fr.design.designer.creator.XWParameterLayout; |
||||||
import com.fr.design.designer.creator.XWidgetCreator; |
import com.fr.design.designer.creator.XWidgetCreator; |
||||||
import com.fr.design.designer.creator.cardlayout.XWCardLayout; |
import com.fr.design.designer.creator.cardlayout.XWCardLayout; |
||||||
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; |
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; |
||||||
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; |
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; |
||||||
import com.fr.design.designer.properties.FRTabFitLayoutPropertiesGroupModel; |
import com.fr.design.designer.properties.FRTabFitLayoutPropertiesGroupModel; |
||||||
import com.fr.design.utils.ComponentUtils; |
import com.fr.design.mainframe.widget.editors.ParameterEditor; |
||||||
import com.fr.form.ui.LayoutBorderStyle; |
import com.fr.design.utils.ComponentUtils; |
||||||
import com.fr.form.ui.container.WBorderLayout; |
import com.fr.form.ui.LayoutBorderStyle; |
||||||
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; |
import com.fr.form.ui.container.WBorderLayout; |
||||||
import com.fr.general.ComparatorUtils; |
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; |
||||||
|
import com.fr.general.ComparatorUtils; |
||||||
import java.awt.*; |
|
||||||
|
import java.awt.*; |
||||||
/** |
|
||||||
* tab布局tabFit适配器 |
/** |
||||||
* |
* tab布局tabFit适配器 |
||||||
* @author focus |
* |
||||||
* @date 2014-6-24 |
* @author focus |
||||||
*/ |
* @date 2014-6-24 |
||||||
public class FRTabFitLayoutAdapter extends FRFitLayoutAdapter { |
*/ |
||||||
//标题栏高度对tab布局内部组件的y坐标造成了偏移
|
public class FRTabFitLayoutAdapter extends FRFitLayoutAdapter { |
||||||
private static int TAB_HEIGHT = 40; |
|
||||||
|
/** |
||||||
/** |
* 构造函数 |
||||||
* 构造函数 |
* |
||||||
* |
* @param container XWTabFitLayout容器 |
||||||
* @param container XWTabFitLayout容器 |
*/ |
||||||
*/ |
public FRTabFitLayoutAdapter(XLayoutContainer container) { |
||||||
public FRTabFitLayoutAdapter(XLayoutContainer container) { |
super(container); |
||||||
super(container); |
} |
||||||
} |
|
||||||
|
/** |
||||||
/** |
* 返回布局自身属性,方便一些特有设置在layout刷新时处理 |
||||||
* 返回布局自身属性,方便一些特有设置在layout刷新时处理 |
*/ |
||||||
*/ |
@Override |
||||||
@Override |
public GroupModel getLayoutProperties() { |
||||||
public GroupModel getLayoutProperties() { |
XWTabFitLayout xfl = (XWTabFitLayout) container; |
||||||
XWTabFitLayout xfl = (XWTabFitLayout) container; |
return new FRTabFitLayoutPropertiesGroupModel(xfl); |
||||||
return new FRTabFitLayoutPropertiesGroupModel(xfl); |
} |
||||||
} |
|
||||||
|
/** |
||||||
/** |
* 组件的ComponentAdapter在添加组件时,如果发现布局管理器不为空,会继而调用该布局管理器的 |
||||||
* 组件的ComponentAdapter在添加组件时,如果发现布局管理器不为空,会继而调用该布局管理器的 |
* addComp方法来完成组件的具体添加。在该方法内,布局管理器可以提供额外的功能。 |
||||||
* addComp方法来完成组件的具体添加。在该方法内,布局管理器可以提供额外的功能。 |
* |
||||||
* |
* @param creator 被添加的新组件 |
||||||
* @param creator 被添加的新组件 |
* @param x 添加的位置x,该位置是相对于container的 |
||||||
* @param x 添加的位置x,该位置是相对于container的 |
* @param y 添加的位置y,该位置是相对于container的 |
||||||
* @param y 添加的位置y,该位置是相对于container的 |
* @return 是否添加成功,成功返回true,否则false |
||||||
* @return 是否添加成功,成功返回true,否则false |
*/ |
||||||
*/ |
@Override |
||||||
@Override |
public boolean addBean(XCreator creator, int x, int y) { |
||||||
public boolean addBean(XCreator creator, int x, int y) { |
// 经过accept判断后,container会被改变,先备份
|
||||||
// 经过accept判断后,container会被改变,先备份
|
XLayoutContainer backUpContainer = container; |
||||||
XLayoutContainer backUpContainer = container; |
Rectangle rect = ComponentUtils.getRelativeBounds(container); |
||||||
Rectangle rect = ComponentUtils.getRelativeBounds(container); |
int posX = x - rect.x; |
||||||
|
int posY = y - rect.y; |
||||||
int posX = x - rect.x; |
if (!accept(creator, posX, posY)) { |
||||||
int posY = y - rect.y; |
return false; |
||||||
if (!accept(creator, posX, posY)) { |
} |
||||||
return false; |
// posX,posY是新拖入组件相对于容器的位置,若在tab布局的边缘,则需要把新组件添加到l
|
||||||
} |
// 父层自适应布局中,这时候的添加位置就是tab布局所在的位置
|
||||||
// posX,posY是新拖入组件相对于容器的位置,若在tab布局的边缘,则需要把新组件添加到
|
if (this.intersectsEdge(posX, posY, backUpContainer)) { |
||||||
// 父层自适应布局中,这时候的添加位置就是tab布局所在的位置
|
if (!ComparatorUtils.equals(backUpContainer.getOuterLayout(), backUpContainer.getBackupParent())) { |
||||||
if (this.intersectsEdge(posX, posY, backUpContainer)) { |
XWTabFitLayout tabLayout = (XWTabFitLayout) backUpContainer; |
||||||
if (!ComparatorUtils.equals(backUpContainer.getOuterLayout(), backUpContainer.getBackupParent())) { |
y = adjustY(y, tabLayout); |
||||||
XWTabFitLayout tabLayout = (XWTabFitLayout) backUpContainer; |
} |
||||||
y = adjustY(y, tabLayout); |
addComp(creator, x, y); |
||||||
} |
((XWidgetCreator) creator).recalculateChildrenSize(); |
||||||
addComp(creator, x, y); |
return true; |
||||||
((XWidgetCreator) creator).recalculateChildrenSize(); |
} |
||||||
return true; |
// 如果不在边缘,容器为本自适应布局,增加组件的位置就是相对于容器的位置
|
||||||
} |
addComp(creator, posX, posY); |
||||||
// 如果不在边缘,容器为本自适应布局,增加组件的位置就是相对于容器的位置
|
((XWidgetCreator) creator).recalculateChildrenSize(); |
||||||
addComp(creator, posX, posY); |
return true; |
||||||
((XWidgetCreator) creator).recalculateChildrenSize(); |
} |
||||||
return true; |
|
||||||
} |
// tab布局的纵坐标受到tab高度以及参数面板高度的影响,判断的上边界取得是里面XWTabFitLayout的上边界,
|
||||||
|
// 实际计算的时候的纵坐标用了外层的CardMainBorerLayout,需要将tab高度和参数面板高度减掉
|
||||||
// tab布局的纵坐标受到tab高度的影响,判断的上边界取得是里面XWTabFitLayout的上边界,
|
// 将y值变为相对坐标以实现获取到鼠标drop位置的控件
|
||||||
// 实际计算的时候的纵坐标用了外层的CardMainBorerLayout,需要将tab高度减掉
|
// TODO 可以直接在这边将x,y都变成相对坐标,这样在后面判断拖进来的新控件放置方式的时候就不用再判断了
|
||||||
//将y值变为相对坐标以实现获取到鼠标drop位置的控件
|
private int adjustY(int y, XWTabFitLayout tabLayout) { |
||||||
//TODO 可以直接在这边将x,y都变成相对坐标,这样在后面判断拖进来的新控件放置方式的时候就不用再判断了
|
XWCardLayout cardLayout = (XWCardLayout) tabLayout.getBackupParent(); |
||||||
private int adjustY(int y, XWTabFitLayout tabLayout) { |
LayoutBorderStyle style = cardLayout.toData().getBorderStyle(); |
||||||
XWCardLayout cardLayout = (XWCardLayout) tabLayout.getBackupParent(); |
y = y - this.getParaEditorYOffset(); |
||||||
LayoutBorderStyle style = cardLayout.toData().getBorderStyle(); |
if (ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)) { |
||||||
if (container.getLocation().y == WBorderLayout.DEFAULT_SIZE) { |
y = y - WCardMainBorderLayout.TAB_HEIGHT; |
||||||
y = y - WBorderLayout.DEFAULT_SIZE; |
} |
||||||
} |
return y; |
||||||
if (ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)) { |
} |
||||||
y = y - WCardMainBorderLayout.TAB_HEIGHT; |
|
||||||
} |
protected Rectangle getLayoutBound(XWCardMainBorderLayout mainLayout) { |
||||||
return y; |
return ComponentUtils.getRelativeBounds(mainLayout); |
||||||
} |
} |
||||||
|
|
||||||
protected Rectangle getLayoutBound(XWCardMainBorderLayout mainLayout) { |
|
||||||
return ComponentUtils.getRelativeBounds(mainLayout); |
|
||||||
} |
|
||||||
} |
} |
@ -1,328 +1,461 @@ |
|||||||
package com.fr.design.designer.beans.models; |
package com.fr.design.designer.beans.models; |
||||||
|
|
||||||
import java.awt.LayoutManager; |
import com.fr.design.designer.beans.AdapterBus; |
||||||
import java.awt.Rectangle; |
import com.fr.design.designer.beans.LayoutAdapter; |
||||||
import java.awt.Toolkit; |
import com.fr.design.designer.beans.events.DesignerEvent; |
||||||
import java.awt.event.MouseEvent; |
import com.fr.design.designer.beans.location.Direction; |
||||||
import java.util.ArrayList; |
import com.fr.design.designer.beans.location.Location; |
||||||
|
import com.fr.design.designer.creator.*; |
||||||
import com.fr.design.designer.beans.AdapterBus; |
import com.fr.design.designer.creator.cardlayout.XWCardLayout; |
||||||
import com.fr.design.designer.beans.LayoutAdapter; |
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; |
||||||
import com.fr.design.designer.beans.events.DesignerEvent; |
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; |
||||||
import com.fr.design.designer.beans.location.Direction; |
import com.fr.design.form.util.XCreatorConstants; |
||||||
import com.fr.design.designer.beans.location.Location; |
import com.fr.design.mainframe.FormDesigner; |
||||||
import com.fr.design.designer.creator.XCreator; |
import com.fr.design.mainframe.FormSelection; |
||||||
import com.fr.design.designer.creator.XCreatorUtils; |
import com.fr.design.mainframe.FormSelectionUtils; |
||||||
import com.fr.design.designer.creator.XLayoutContainer; |
import com.fr.design.utils.ComponentUtils; |
||||||
import com.fr.design.designer.creator.XWFitLayout; |
import com.fr.design.utils.gui.LayoutUtils; |
||||||
import com.fr.design.designer.creator.XWParameterLayout; |
import com.fr.stable.ArrayUtils; |
||||||
import com.fr.design.form.util.XCreatorConstants; |
|
||||||
import com.fr.design.mainframe.FormDesigner; |
import java.awt.*; |
||||||
import com.fr.design.mainframe.FormSelection; |
import java.awt.event.MouseEvent; |
||||||
import com.fr.design.mainframe.FormSelectionUtils; |
import java.util.ArrayList; |
||||||
import com.fr.design.utils.gui.LayoutUtils; |
|
||||||
import com.fr.stable.ArrayUtils; |
/** |
||||||
|
* 该model保存当前选择的组件和剪切版信息 |
||||||
/** |
*/ |
||||||
* 该model保存当前选择的组件和剪切版信息 |
public class SelectionModel { |
||||||
*/ |
//被粘贴组件在所选组件位置处往下、往右各错开20像素。执行多次粘贴时,在上一次粘贴的位置处错开20像素。
|
||||||
public class SelectionModel { |
private static final int DELTA_X_Y = 20; //粘贴时候的偏移距离
|
||||||
private static final int DELTA_X_Y = 20; //粘贴时候的偏移距离
|
private static final double OFFSET_RELATIVE = 0.80; |
||||||
private static FormSelection CLIP_BOARD = new FormSelection(); |
private static FormSelection clipboard = new FormSelection(); |
||||||
private FormDesigner designer; |
private FormDesigner designer; |
||||||
private FormSelection selection; |
private FormSelection selection; |
||||||
private Rectangle hotspot_bounds; |
private Rectangle hotspotBounds; |
||||||
|
|
||||||
public SelectionModel(FormDesigner designer) { |
public SelectionModel(FormDesigner designer) { |
||||||
this.designer = designer; |
this.designer = designer; |
||||||
selection = new FormSelection(); |
selection = new FormSelection(); |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 重置。清空formSelction以及选择区域 |
* 重置。清空formSelction以及选择区域 |
||||||
*/ |
*/ |
||||||
public void reset() { |
public void reset() { |
||||||
selection.reset(); |
selection.reset(); |
||||||
hotspot_bounds = null; |
hotspotBounds = null; |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* formSelction是否为空 |
* formSelction是否为空 |
||||||
* @return 是否为空 |
* |
||||||
*/ |
* @return 是否为空 |
||||||
public static boolean isEmpty(){ |
*/ |
||||||
return CLIP_BOARD.isEmpty(); |
public static boolean isEmpty() { |
||||||
} |
return clipboard.isEmpty(); |
||||||
|
} |
||||||
/** |
|
||||||
* 鼠标点击一下,所选中的单个组件。按下Ctrl或者shift键时鼠标可以进行多选 |
/** |
||||||
* @param e 鼠标事件 |
* 鼠标点击一下,所选中的单个组件。按下Ctrl或者shift键时鼠标可以进行多选 |
||||||
*/ |
* |
||||||
public void selectACreatorAtMouseEvent(MouseEvent e) { |
* @param e 鼠标事件 |
||||||
if (!e.isControlDown() && !e.isShiftDown()) { |
*/ |
||||||
// 如果Ctrl或者Shift键盘没有按下,则清除已经选择的组件
|
public void selectACreatorAtMouseEvent(MouseEvent e) { |
||||||
selection.reset(); |
if (!e.isControlDown() && !e.isShiftDown()) { |
||||||
} |
// 如果Ctrl或者Shift键盘没有按下,则清除已经选择的组件
|
||||||
|
selection.reset(); |
||||||
// 获取e所在的组件
|
} |
||||||
XCreator comp = designer.getComponentAt(e); |
// 获取e所在的组件
|
||||||
|
XCreator comp = designer.getComponentAt(e); |
||||||
//布局组件的顶层布局如不可编辑,要获取其顶层布局
|
|
||||||
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer(comp).getTopLayout(); |
//布局组件的顶层布局如不可编辑,要获取其顶层布局
|
||||||
if(topLayout != null && !topLayout.isEditable()){ |
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer(comp).getTopLayout(); |
||||||
comp = topLayout; |
if (topLayout != null && !topLayout.isEditable()) { |
||||||
} |
comp = topLayout; |
||||||
|
} |
||||||
// 如果父层是scale和title两个专属容器,返回其父层,组件本身是不让被选中的
|
|
||||||
if (comp != designer.getRootComponent() && comp != designer.getParaComponent()) { |
// 如果父层是scale和title两个专属容器,返回其父层,组件本身是不让被选中的
|
||||||
XCreator parentContainer = (XCreator) comp.getParent(); |
if (comp != designer.getRootComponent() && comp != designer.getParaComponent()) { |
||||||
comp = parentContainer.isDedicateContainer() ? parentContainer : comp; |
XCreator parentContainer = (XCreator) comp.getParent(); |
||||||
} |
comp = parentContainer.isDedicateContainer() ? parentContainer : comp; |
||||||
if (selection.removeSelectedCreator(comp) || selection.addSelectedCreator(comp)) { |
} |
||||||
designer.getEditListenerTable().fireCreatorModified(comp, DesignerEvent.CREATOR_SELECTED); |
if (selection.removeSelectedCreator(comp) || selection.addSelectedCreator(comp)) { |
||||||
designer.repaint(); |
designer.getEditListenerTable().fireCreatorModified(comp, DesignerEvent.CREATOR_SELECTED); |
||||||
} |
designer.repaint(); |
||||||
} |
} |
||||||
|
} |
||||||
/** |
|
||||||
* 将所选组件剪切到剪切板上 |
/** |
||||||
*/ |
* 将所选组件剪切到剪切板上 |
||||||
public void cutSelectedCreator2ClipBoard() { |
*/ |
||||||
if (hasSelectionComponent()) { |
public void cutSelectedCreator2ClipBoard() { |
||||||
selection.cut2ClipBoard(CLIP_BOARD); |
if (hasSelectionComponent()) { |
||||||
designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_CUTED); |
selection.cut2ClipBoard(clipboard); |
||||||
designer.repaint(); |
designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_CUTED); |
||||||
} |
designer.repaint(); |
||||||
} |
} |
||||||
|
} |
||||||
/** |
|
||||||
* 复制当前选中的组件到剪切板 |
/** |
||||||
*/ |
* 复制当前选中的组件到剪切板 |
||||||
public void copySelectedCreator2ClipBoard() { |
*/ |
||||||
if (!selection.isEmpty()) { |
public void copySelectedCreator2ClipBoard() { |
||||||
selection.copy2ClipBoard(CLIP_BOARD); |
if (!selection.isEmpty()) { |
||||||
} |
selection.copy2ClipBoard(clipboard); |
||||||
} |
} |
||||||
|
} |
||||||
/** |
|
||||||
* 从剪切板粘帖组件 |
/** |
||||||
* @return 否 |
* 从剪切板粘帖组件 |
||||||
*/ |
* |
||||||
public boolean pasteFromClipBoard() { |
* @return 否 |
||||||
if (!CLIP_BOARD.isEmpty()) { |
*/ |
||||||
XLayoutContainer parent = null; |
public boolean pasteFromClipBoard() { |
||||||
if (!hasSelectionComponent()) { |
if (!clipboard.isEmpty()) { |
||||||
FormSelectionUtils.paste2Container(designer, designer.getRootComponent(),CLIP_BOARD, DELTA_X_Y, DELTA_X_Y); |
if (!hasSelectedPasteSource()) { |
||||||
} else { |
//未选
|
||||||
parent = XCreatorUtils.getParentXLayoutContainer(selection.getSelectedCreator()); |
unselectedPaste(); |
||||||
if (parent != null) { |
} else { |
||||||
Rectangle rec = selection.getSelctionBounds(); |
//已选
|
||||||
FormSelectionUtils.paste2Container(designer, parent,CLIP_BOARD, rec.x + DELTA_X_Y, rec.y + DELTA_X_Y); |
selectedPaste(); |
||||||
} |
} |
||||||
} |
} else { |
||||||
} else { |
Toolkit.getDefaultToolkit().beep(); |
||||||
Toolkit.getDefaultToolkit().beep(); |
} |
||||||
} |
return false; |
||||||
return false; |
} |
||||||
} |
|
||||||
|
public FormSelection getSelection() { |
||||||
public FormSelection getSelection() { |
return selection; |
||||||
return selection; |
} |
||||||
} |
|
||||||
|
/** |
||||||
/** |
* 粘贴时未选择组件 |
||||||
* 删除当前所有选择的组件 |
*/ |
||||||
*/ |
private void unselectedPaste() { |
||||||
public void deleteSelection() { |
if (designer.getClass().equals(FormDesigner.class)) { |
||||||
XCreator[] roots = selection.getSelectedCreators(); |
if (selection.getSelectedCreator() instanceof XWFitLayout) { |
||||||
|
if (selection.getSelectedCreator().getClass().equals(XWTabFitLayout.class)) { |
||||||
if (roots.length > 0) { |
XLayoutContainer container = (XLayoutContainer) selection.getSelectedCreator(); |
||||||
for (XCreator creator : roots) { |
//tab布局编辑器内部左上角第一个坐标点
|
||||||
if(creator.acceptType(XWParameterLayout.class)){ |
int leftUpX = container.toData().getMargin().getLeft() + 1; |
||||||
designer.removeParaComponent(); |
int leftUpY = container.toData().getMargin().getTop() + 1; |
||||||
} |
//选中第一个坐标点坐在的组件
|
||||||
|
selection.setSelectedCreator((XCreator) container.getComponentAt(leftUpX, leftUpY)); |
||||||
removeCreatorFromContainer(creator, creator.getWidth(), creator.getHeight()); |
Rectangle rectangle = selection.getRelativeBounds(); |
||||||
creator.removeAll(); |
if (hasSelectedPasteSource()) { |
||||||
// 清除被选中的组件
|
selectedPaste(); |
||||||
selection.reset(); |
} else { |
||||||
} |
FormSelectionUtils.paste2Container(designer, container, clipboard, |
||||||
setSelectedCreator(designer.getRootComponent()); |
rectangle.x + rectangle.width / 2, |
||||||
// 触发事件
|
rectangle.y + DELTA_X_Y); |
||||||
designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_DELETED); |
} |
||||||
designer.repaint(); |
} else { |
||||||
} |
//自适应布局编辑器内部左上角第一个坐标点
|
||||||
} |
int leftUpX = designer.getRootComponent().toData().getMargin().getLeft() + 1; |
||||||
|
int leftUpY = designer.getRootComponent().toData().getMargin().getTop() + 1; |
||||||
/** |
//选中第一个坐标点坐在的组件
|
||||||
* 从选择组件中删除某组件 |
selection.setSelectedCreator((XCreator) designer.getRootComponent().getComponentAt(leftUpX, leftUpY)); |
||||||
* |
Rectangle rectangle = selection.getRelativeBounds(); |
||||||
* @param creator 组件 |
if (hasSelectedPasteSource()) { |
||||||
* @param creatorWidth 组件之前宽度 |
selectedPaste(); |
||||||
* @param creatorHeight 组件之前高度 |
} else { |
||||||
*/ |
FormSelectionUtils.paste2Container(designer, designer.getRootComponent(), |
||||||
public void removeCreator(XCreator creator, int creatorWidth, int creatorHeight) { |
clipboard, |
||||||
selection.removeCreator(creator); |
rectangle.x + rectangle.width / 2, |
||||||
removeCreatorFromContainer(creator, creatorWidth, creatorHeight); |
rectangle.y + DELTA_X_Y); |
||||||
designer.repaint(); |
} |
||||||
} |
} |
||||||
|
} else { |
||||||
/** |
//绝对布局
|
||||||
* 设置选择区域 |
//编辑器外面还有两层容器,使用designer.getRootComponent()获取到的是编辑器中层的容器,不是编辑器表层
|
||||||
*/ |
//当前选择的就是编辑器表层
|
||||||
public void setHotspotBounds(Rectangle rect) { |
FormSelectionUtils.paste2Container(designer, (XLayoutContainer) selection.getSelectedCreator(), |
||||||
hotspot_bounds = rect; |
clipboard, |
||||||
} |
DELTA_X_Y, |
||||||
|
DELTA_X_Y); |
||||||
/** |
} |
||||||
* 获得当前选择区域 |
} else { |
||||||
*/ |
//cpt本地组件复用,编辑器就一层,是最底层,使用designer.getRootComponent()就可以获取到
|
||||||
public Rectangle getHotspotBounds() { |
//使用selection.getSelectedCreator()也应该是可以获取到的。
|
||||||
return hotspot_bounds; |
FormSelectionUtils.paste2Container(designer, designer.getRootComponent(), |
||||||
} |
clipboard, |
||||||
|
DELTA_X_Y, |
||||||
private void removeCreatorFromContainer(XCreator creator, int creatorWidth, int creatorHeight) { |
DELTA_X_Y); |
||||||
XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(creator); |
} |
||||||
if (parent == null) { |
} |
||||||
return; |
|
||||||
} |
/** |
||||||
boolean changeCreator = creator.shouldScaleCreator() || creator.hasTitleStyle(); |
* 粘贴时选择组件 |
||||||
if (parent.acceptType(XWFitLayout.class) && changeCreator) { |
*/ |
||||||
creator = (XCreator) creator.getParent(); |
private void selectedPaste() { |
||||||
} |
XLayoutContainer container = null; |
||||||
parent.getLayoutAdapter().removeBean(creator, creatorWidth, creatorHeight); |
//获取到编辑器的表层容器(已选的组件的父容器就是表层容器)
|
||||||
// 删除其根组件,同时就删除了同时被选择的叶子组件
|
container = XCreatorUtils.getParentXLayoutContainer(selection.getSelectedCreator()); |
||||||
parent.remove(creator); |
if (container != null && selection.getSelectedCreator().getParent() instanceof XWFitLayout) { |
||||||
LayoutManager layout = parent.getLayout(); |
//自适应布局
|
||||||
|
|
||||||
if (layout != null) { |
Rectangle selectionRec = selection.getRelativeBounds(); |
||||||
// 刷新组件容器的布局
|
//获取父容器位置,补充因参数面板高度导致的位置坐标计算偏移
|
||||||
LayoutUtils.layoutContainer(parent); |
Rectangle containerRec = ComponentUtils.getRelativeBounds(container); |
||||||
} |
int positionX, positionY; |
||||||
} |
|
||||||
|
if (container.getClass().equals(XWTabFitLayout.class)) { |
||||||
/** |
//tab内部粘贴不补充高度偏移
|
||||||
* 是否有组件被选择。如果所选组件是最底层容器,也视为无选择 |
//且不计算参数面板造成的影响,因为在
|
||||||
* @return 是则返回true |
//@see com.fr.design.designer.beans.adapters.layout.FRTabFitLayoutAdapter#addBean中做了
|
||||||
*/ |
positionX = selectionRec.x + selectionRec.width / 2; |
||||||
public boolean hasSelectionComponent() { |
positionY = (int) (selectionRec.y + selectionRec.height * OFFSET_RELATIVE); |
||||||
return !selection.isEmpty() && selection.getSelectedCreator().getParent() != null; |
} else { |
||||||
} |
//计算自适应布局位置
|
||||||
|
positionX = selectionRec.x - containerRec.x + selectionRec.width / 2; |
||||||
/** |
positionY = (int) (selectionRec.y - containerRec.y + selectionRec.height * OFFSET_RELATIVE); |
||||||
* 移动组件至指定位置 |
} |
||||||
* @param x 坐标x |
FormSelectionUtils.paste2Container(designer, container, clipboard, positionX, positionY); |
||||||
* @param y 坐标y |
} else if (container != null && selection.getSelectedCreator().getParent() instanceof XWAbsoluteLayout) { |
||||||
*/ |
//绝对布局
|
||||||
public void move(int x, int y) { |
Rectangle rec = selection.getSelctionBounds(); |
||||||
for (XCreator creator : selection.getSelectedCreators()) { |
FormSelectionUtils.paste2Container(designer, container, clipboard, rec.x + DELTA_X_Y, rec.y + DELTA_X_Y); |
||||||
creator.setLocation(creator.getX() + x, creator.getY() + y); |
} |
||||||
LayoutAdapter layoutAdapter = AdapterBus.searchLayoutAdapter(designer, creator); |
} |
||||||
if (layoutAdapter != null) { |
|
||||||
layoutAdapter.fix(creator); |
/** |
||||||
} |
* 删除当前所有选择的组件 |
||||||
} |
*/ |
||||||
designer.getEditListenerTable().fireCreatorModified(selection.getSelectedCreator(), |
public void deleteSelection() { |
||||||
DesignerEvent.CREATOR_SELECTED); |
XCreator[] roots = selection.getSelectedCreators(); |
||||||
} |
|
||||||
|
if (roots.length > 0) { |
||||||
/** |
for (XCreator creator : roots) { |
||||||
* 释放捕获 |
if (creator.acceptType(XWParameterLayout.class)) { |
||||||
*/ |
designer.removeParaComponent(); |
||||||
public void releaseDragging() { |
} |
||||||
designer.setPainter(null); |
removeCreatorFromContainer(creator, creator.getWidth(), creator.getHeight()); |
||||||
selection.fixCreator(designer); |
creator.removeAll(); |
||||||
designer.getEditListenerTable().fireCreatorModified(selection.getSelectedCreator(), |
// 清除被选中的组件
|
||||||
DesignerEvent.CREATOR_RESIZED); |
selection.reset(); |
||||||
} |
} |
||||||
|
setSelectedCreator(designer.getRootComponent()); |
||||||
public Direction getDirectionAt(MouseEvent e) { |
FormSelectionUtils.rebuildSelection(designer); |
||||||
Direction dir; |
// 触发事件
|
||||||
if (e.isControlDown() || e.isShiftDown()) { |
designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_DELETED); |
||||||
XCreator creator = designer.getComponentAt(e.getX(), e.getY(), selection.getSelectedCreators()); |
designer.repaint(); |
||||||
if (creator != designer.getRootComponent() && selection.addedable(creator)) { |
} |
||||||
return Location.add; |
} |
||||||
} |
|
||||||
} |
/** |
||||||
if (hasSelectionComponent()) { |
* 从选择组件中删除某组件 |
||||||
int x = e.getX() + designer.getArea().getHorizontalValue(); |
* |
||||||
int y = e.getY() + designer.getArea().getVerticalValue(); |
* @param creator 组件 |
||||||
dir = getDirection(selection.getRelativeBounds(), x, y); |
* @param creatorWidth 组件之前宽度 |
||||||
if (selection.size() == 1) { |
* @param creatorHeight 组件之前高度 |
||||||
if (!ArrayUtils.contains(selection.getSelectedCreator().getDirections(), dir.getActual())) { |
*/ |
||||||
dir = Location.outer; |
public void removeCreator(XCreator creator, int creatorWidth, int creatorHeight) { |
||||||
} |
selection.removeCreator(creator); |
||||||
} |
removeCreatorFromContainer(creator, creatorWidth, creatorHeight); |
||||||
} else { |
designer.repaint(); |
||||||
dir = Location.outer; |
} |
||||||
} |
|
||||||
|
/** |
||||||
if (designer.getDesignerMode().isFormParameterEditor() && dir == Location.outer) { |
* 设置选择区域 |
||||||
dir = designer.getLoc2Root(e); |
*/ |
||||||
} |
public void setHotspotBounds(Rectangle rect) { |
||||||
return dir; |
hotspotBounds = rect; |
||||||
} |
} |
||||||
|
|
||||||
private Direction getDirection(Rectangle bounds, int x, int y) { |
/** |
||||||
if (x < (bounds.x - XCreatorConstants.RESIZE_BOX_SIZ)) { |
* 获得当前选择区域 |
||||||
return Location.outer; |
*/ |
||||||
} else if ((x >= (bounds.x - XCreatorConstants.RESIZE_BOX_SIZ)) && (x <= bounds.x)) { |
public Rectangle getHotspotBounds() { |
||||||
if (y < (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) { |
return hotspotBounds; |
||||||
return Location.outer; |
} |
||||||
} else if ((y >= (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) && (y <= bounds.y)) { |
|
||||||
return Location.left_top; |
private void removeCreatorFromContainer(XCreator creator, int creatorWidth, int creatorHeight) { |
||||||
} else if ((y > bounds.y) && (y < (bounds.y + bounds.height))) { |
XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(creator); |
||||||
return Location.left; |
if (parent == null) { |
||||||
} else if ((y >= (bounds.y + bounds.height)) |
return; |
||||||
&& (y <= (bounds.y + bounds.height + XCreatorConstants.RESIZE_BOX_SIZ))) { |
} |
||||||
return Location.left_bottom; |
boolean changeCreator = creator.shouldScaleCreator() || creator.hasTitleStyle(); |
||||||
} else { |
if (parent.acceptType(XWFitLayout.class) && changeCreator) { |
||||||
return Location.outer; |
creator = (XCreator) creator.getParent(); |
||||||
} |
} |
||||||
} else if ((x > bounds.x) && (x < (bounds.x + bounds.width))) { |
parent.getLayoutAdapter().removeBean(creator, creatorWidth, creatorHeight); |
||||||
if (y < (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) { |
// 删除其根组件,同时就删除了同时被选择的叶子组件
|
||||||
return Location.outer; |
parent.remove(creator); |
||||||
} else if ((y >= (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) && (y <= bounds.y)) { |
LayoutManager layout = parent.getLayout(); |
||||||
return Location.top; |
|
||||||
} else if ((y > bounds.y) && (y < (bounds.y + bounds.height))) { |
if (layout != null) { |
||||||
return Location.inner; |
// 刷新组件容器的布局
|
||||||
} else if ((y >= (bounds.y + bounds.height)) |
LayoutUtils.layoutContainer(parent); |
||||||
&& (y <= (bounds.y + bounds.height + XCreatorConstants.RESIZE_BOX_SIZ))) { |
} |
||||||
return Location.bottom; |
} |
||||||
} else { |
|
||||||
return Location.outer; |
/** |
||||||
} |
* 是否有组件被选择。如果所选组件是最底层容器,也视为无选择 |
||||||
} else if ((x >= (bounds.x + bounds.width)) |
* |
||||||
&& (x <= (bounds.x + bounds.width + XCreatorConstants.RESIZE_BOX_SIZ))) { |
* @return 是则返回true |
||||||
if (y < (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) { |
* yaoh.wu 不应该通过判断是否是最底层容器来判断是否选择了组件 |
||||||
return Location.outer; |
* 而是应该判断选择的容器是否是编辑器的最表层容器,也就是点击空白地方选择的容器 |
||||||
} else if ((y >= (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) && (y <= bounds.y)) { |
* 但是直接判断选择的容器是否是编辑器最表层类型又会引发拖动时选不上的情况, |
||||||
return Location.right_top; |
* 因此通过判断父容器来实现 |
||||||
} else if ((y > bounds.y) && (y < (bounds.y + bounds.height))) { |
* <p> |
||||||
return Location.right; |
* 举例:frm组件复用 绝对布局情况下,不选择时有三层容器: |
||||||
} else if ((y >= (bounds.y + bounds.height)) |
* 底层@see {@link com.fr.design.designer.creator.XWBorderLayout} |
||||||
&& (y <= (bounds.y + bounds.height + XCreatorConstants.RESIZE_BOX_SIZ))) { |
* 中层@see {@link XWFitLayout} |
||||||
return Location.right_bottom; |
* 表层@see {@link com.fr.design.designer.creator.XWAbsoluteBodyLayout} |
||||||
} else { |
* <p> |
||||||
return Location.outer; |
* 但是编辑窗口的最外层其实是表层@see {@link com.fr.design.designer.creator.XWAbsoluteBodyLayout}, |
||||||
} |
* 其他两层不是靠添加组件就可以编辑的。 |
||||||
} else { |
*/ |
||||||
return Location.outer; |
public boolean hasSelectedPasteSource() { |
||||||
} |
XCreator selectionXCreator = selection.getSelectedCreator(); |
||||||
} |
if (designer.getClass().equals(FormDesigner.class)) { |
||||||
|
//frm本地组件复用
|
||||||
private void fireCreatorSelected() { |
if (selectionXCreator != null) { |
||||||
designer.getEditListenerTable().fireCreatorModified(selection.getSelectedCreator(), |
//选中的是否是tab布局编辑器本身
|
||||||
DesignerEvent.CREATOR_SELECTED); |
boolean tabEditor = selectionXCreator.getClass().equals(XWCardMainBorderLayout.class) |
||||||
} |
|| selectionXCreator.getClass().equals(XWCardLayout.class) |
||||||
|
|| selectionXCreator.getClass().equals(XWTabFitLayout.class); |
||||||
public void setSelectedCreator(XCreator rootComponent) { |
//选中的是否是frm绝对布局编辑器本身
|
||||||
selection.setSelectedCreator(rootComponent); |
boolean absoluteEditor = selectionXCreator.getClass().equals(XWAbsoluteBodyLayout.class); |
||||||
fireCreatorSelected(); |
//选中是否是frm绝对画布块编辑器本身
|
||||||
} |
boolean absoluteCanvas = selectionXCreator.getClass().equals(XWAbsoluteLayout.class); |
||||||
|
//选中的是否是相对布局编辑器本身
|
||||||
public void setSelectedCreators(ArrayList<XCreator> rebuildSelection) { |
boolean relativeEditor = selectionXCreator.getClass().equals(XWFitLayout.class); |
||||||
selection.setSelectedCreators(rebuildSelection); |
|
||||||
fireCreatorSelected(); |
return !(tabEditor || absoluteEditor || absoluteCanvas || relativeEditor); |
||||||
} |
} else { |
||||||
|
return false; |
||||||
|
} |
||||||
|
} else { |
||||||
|
//cpt本地组件复用,selection.getSelectedCreator().getParent()=@XWParameterLayout instanceof @XWAbsoluteLayout
|
||||||
|
return selectionXCreator != null && selectionXCreator.getParent() != null; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 是否有组件被选择。如果所选组件是最底层容器,也视为无选择 |
||||||
|
* |
||||||
|
* @return 是则返回true |
||||||
|
*/ |
||||||
|
public boolean hasSelectionComponent() { |
||||||
|
return !selection.isEmpty() && selection.getSelectedCreator().getParent() != null; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 移动组件至指定位置 |
||||||
|
* |
||||||
|
* @param x 坐标x |
||||||
|
* @param y 坐标y |
||||||
|
*/ |
||||||
|
public void move(int x, int y) { |
||||||
|
for (XCreator creator : selection.getSelectedCreators()) { |
||||||
|
creator.setLocation(creator.getX() + x, creator.getY() + y); |
||||||
|
LayoutAdapter layoutAdapter = AdapterBus.searchLayoutAdapter(designer, creator); |
||||||
|
if (layoutAdapter != null) { |
||||||
|
layoutAdapter.fix(creator); |
||||||
|
} |
||||||
|
} |
||||||
|
designer.getEditListenerTable().fireCreatorModified(selection.getSelectedCreator(), |
||||||
|
DesignerEvent.CREATOR_SELECTED); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 释放捕获 |
||||||
|
*/ |
||||||
|
public void releaseDragging() { |
||||||
|
designer.setPainter(null); |
||||||
|
selection.fixCreator(designer); |
||||||
|
designer.getEditListenerTable().fireCreatorModified(selection.getSelectedCreator(), |
||||||
|
DesignerEvent.CREATOR_RESIZED); |
||||||
|
} |
||||||
|
|
||||||
|
public Direction getDirectionAt(MouseEvent e) { |
||||||
|
Direction dir; |
||||||
|
if (e.isControlDown() || e.isShiftDown()) { |
||||||
|
XCreator creator = designer.getComponentAt(e.getX(), e.getY(), selection.getSelectedCreators()); |
||||||
|
if (creator != designer.getRootComponent() && selection.addedable(creator)) { |
||||||
|
return Location.add; |
||||||
|
} |
||||||
|
} |
||||||
|
if (hasSelectionComponent()) { |
||||||
|
int x = e.getX() + designer.getArea().getHorizontalValue(); |
||||||
|
int y = e.getY() + designer.getArea().getVerticalValue(); |
||||||
|
dir = getDirection(selection.getRelativeBounds(), x, y); |
||||||
|
if (selection.size() == 1 && !ArrayUtils.contains(selection.getSelectedCreator().getDirections(), dir |
||||||
|
.getActual())) { |
||||||
|
dir = Location.outer; |
||||||
|
} |
||||||
|
} else { |
||||||
|
dir = Location.outer; |
||||||
|
} |
||||||
|
|
||||||
|
if (designer.getDesignerMode().isFormParameterEditor() && dir == Location.outer) { |
||||||
|
dir = designer.getLoc2Root(e); |
||||||
|
} |
||||||
|
return dir; |
||||||
|
} |
||||||
|
|
||||||
|
private Direction getDirection(Rectangle bounds, int x, int y) { |
||||||
|
if (x < (bounds.x - XCreatorConstants.RESIZE_BOX_SIZ)) { |
||||||
|
return Location.outer; |
||||||
|
} else if ((x >= (bounds.x - XCreatorConstants.RESIZE_BOX_SIZ)) && (x <= bounds.x)) { |
||||||
|
if (y < (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) { |
||||||
|
return Location.outer; |
||||||
|
} else if ((y >= (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) && (y <= bounds.y)) { |
||||||
|
return Location.left_top; |
||||||
|
} else if ((y > bounds.y) && (y < (bounds.y + bounds.height))) { |
||||||
|
return Location.left; |
||||||
|
} else if ((y >= (bounds.y + bounds.height)) |
||||||
|
&& (y <= (bounds.y + bounds.height + XCreatorConstants.RESIZE_BOX_SIZ))) { |
||||||
|
return Location.left_bottom; |
||||||
|
} else { |
||||||
|
return Location.outer; |
||||||
|
} |
||||||
|
} else if ((x > bounds.x) && (x < (bounds.x + bounds.width))) { |
||||||
|
if (y < (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) { |
||||||
|
return Location.outer; |
||||||
|
} else if ((y >= (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) && (y <= bounds.y)) { |
||||||
|
return Location.top; |
||||||
|
} else if ((y > bounds.y) && (y < (bounds.y + bounds.height))) { |
||||||
|
return Location.inner; |
||||||
|
} else if ((y >= (bounds.y + bounds.height)) |
||||||
|
&& (y <= (bounds.y + bounds.height + XCreatorConstants.RESIZE_BOX_SIZ))) { |
||||||
|
return Location.bottom; |
||||||
|
} else { |
||||||
|
return Location.outer; |
||||||
|
} |
||||||
|
} else if ((x >= (bounds.x + bounds.width)) |
||||||
|
&& (x <= (bounds.x + bounds.width + XCreatorConstants.RESIZE_BOX_SIZ))) { |
||||||
|
if (y < (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) { |
||||||
|
return Location.outer; |
||||||
|
} else if ((y >= (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) && (y <= bounds.y)) { |
||||||
|
return Location.right_top; |
||||||
|
} else if ((y > bounds.y) && (y < (bounds.y + bounds.height))) { |
||||||
|
return Location.right; |
||||||
|
} else if ((y >= (bounds.y + bounds.height)) |
||||||
|
&& (y <= (bounds.y + bounds.height + XCreatorConstants.RESIZE_BOX_SIZ))) { |
||||||
|
return Location.right_bottom; |
||||||
|
} else { |
||||||
|
return Location.outer; |
||||||
|
} |
||||||
|
} else { |
||||||
|
return Location.outer; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void fireCreatorSelected() { |
||||||
|
designer.getEditListenerTable().fireCreatorModified(selection.getSelectedCreator(), |
||||||
|
DesignerEvent.CREATOR_SELECTED); |
||||||
|
} |
||||||
|
|
||||||
|
public void setSelectedCreator(XCreator rootComponent) { |
||||||
|
selection.setSelectedCreator(rootComponent); |
||||||
|
fireCreatorSelected(); |
||||||
|
} |
||||||
|
|
||||||
|
public void setSelectedCreators(ArrayList<XCreator> rebuildSelection) { |
||||||
|
selection.setSelectedCreators(rebuildSelection); |
||||||
|
fireCreatorSelected(); |
||||||
|
} |
||||||
} |
} |
@ -1,446 +1,476 @@ |
|||||||
package com.fr.design.designer.beans.models; |
package com.fr.design.designer.beans.models; |
||||||
|
|
||||||
import java.awt.Component; |
|
||||||
import java.awt.Cursor; |
|
||||||
import java.awt.Graphics; |
|
||||||
import java.awt.Point; |
|
||||||
import java.awt.Rectangle; |
|
||||||
import java.awt.Toolkit; |
|
||||||
import java.awt.event.MouseEvent; |
|
||||||
import java.util.ArrayList; |
|
||||||
|
|
||||||
import com.fr.design.beans.location.Absorptionline; |
import com.fr.design.beans.location.Absorptionline; |
||||||
import com.fr.design.mainframe.FormDesigner; |
|
||||||
import com.fr.design.mainframe.FormSelectionUtils; |
|
||||||
import com.fr.design.designer.beans.AdapterBus; |
import com.fr.design.designer.beans.AdapterBus; |
||||||
import com.fr.design.designer.beans.HoverPainter; |
import com.fr.design.designer.beans.HoverPainter; |
||||||
import com.fr.design.designer.beans.LayoutAdapter; |
import com.fr.design.designer.beans.LayoutAdapter; |
||||||
import com.fr.design.designer.beans.events.DesignerEvent; |
import com.fr.design.designer.beans.events.DesignerEvent; |
||||||
import com.fr.design.designer.beans.location.Direction; |
import com.fr.design.designer.beans.location.Direction; |
||||||
import com.fr.design.designer.beans.location.Location; |
import com.fr.design.designer.beans.location.Location; |
||||||
import com.fr.design.designer.creator.XConnector; |
import com.fr.design.designer.creator.*; |
||||||
import com.fr.design.designer.creator.XCreator; |
import com.fr.design.mainframe.FormDesigner; |
||||||
import com.fr.design.designer.creator.XCreatorUtils; |
import com.fr.design.mainframe.FormSelectionUtils; |
||||||
import com.fr.design.designer.creator.XLayoutContainer; |
|
||||||
import com.fr.design.designer.creator.XWAbsoluteLayout; |
|
||||||
import com.fr.design.utils.ComponentUtils; |
import com.fr.design.utils.ComponentUtils; |
||||||
|
|
||||||
|
import java.awt.*; |
||||||
|
import java.awt.event.MouseEvent; |
||||||
|
import java.util.ArrayList; |
||||||
|
|
||||||
/** |
/** |
||||||
* 普通模式下的状态model |
* 普通模式下的状态model |
||||||
*/ |
*/ |
||||||
public class StateModel { |
public class StateModel { |
||||||
// 对应的selection model
|
// 对应的selection model
|
||||||
|
|
||||||
private SelectionModel selectionModel; |
private SelectionModel selectionModel; |
||||||
// 当前鼠标进入拖拽区域的位置类型
|
// 当前鼠标进入拖拽区域的位置类型
|
||||||
private Direction driection; |
private Direction driection; |
||||||
|
|
||||||
// 当前拖拽的起始位置
|
// 当前拖拽的起始位置
|
||||||
private int current_x; |
private int currentX; |
||||||
private int current_y; |
private int currentY; |
||||||
|
|
||||||
private Point startPoint = new Point(); |
//拖拽组件原始位置大小备份
|
||||||
private Point currentPoint = new Point(); |
private Rectangle selectedPositionBackup; |
||||||
|
|
||||||
private Absorptionline lineInX; |
private Point startPoint = new Point(); |
||||||
private Absorptionline lineInY; |
private Point currentPoint = new Point(); |
||||||
//等距线
|
|
||||||
private Absorptionline lineEquidistant; |
private Absorptionline lineInX; |
||||||
|
private Absorptionline lineInY; |
||||||
// 当前是否处于拖拽选择状态
|
//等距线
|
||||||
private boolean selecting; |
private Absorptionline lineEquidistant; |
||||||
private boolean dragging; |
|
||||||
|
// 当前是否处于拖拽选择状态
|
||||||
private boolean addable; |
private boolean selecting; |
||||||
|
private boolean dragging; |
||||||
private FormDesigner designer; |
|
||||||
|
private boolean addable; |
||||||
public StateModel(FormDesigner designer) { |
|
||||||
this.designer = designer; |
private FormDesigner designer; |
||||||
selectionModel = designer.getSelectionModel(); |
|
||||||
} |
public StateModel(FormDesigner designer) { |
||||||
|
this.designer = designer; |
||||||
/** |
selectionModel = designer.getSelectionModel(); |
||||||
* 返回direction |
} |
||||||
* @return direction方向 |
|
||||||
*/ |
|
||||||
public Direction getDirection() { |
|
||||||
return driection; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 是否有组件正被选中 |
|
||||||
* |
|
||||||
* @return true 如果至少一个组件被选中 |
|
||||||
*/ |
|
||||||
public boolean isSelecting() { |
|
||||||
return selecting; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
/** |
||||||
*是否能拖拽 |
* 返回direction |
||||||
|
* |
||||||
|
* @return direction方向 |
||||||
|
*/ |
||||||
|
public Direction getDirection() { |
||||||
|
return driection; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 是否有组件正被选中 |
||||||
|
* |
||||||
|
* @return true 如果至少一个组件被选中 |
||||||
|
*/ |
||||||
|
public boolean isSelecting() { |
||||||
|
return selecting; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 是否能拖拽 |
||||||
|
* |
||||||
* @return 非outer且选中为空 |
* @return 非outer且选中为空 |
||||||
*/ |
*/ |
||||||
public boolean dragable() { |
public boolean dragable() { |
||||||
return ((driection != Location.outer) && !selecting); |
return ((driection != Location.outer) && !selecting); |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 拖拽中是否可以转换为添加模式: |
* 拖拽中是否可以转换为添加模式: |
||||||
* 如果拖拽组件只有一个,鼠标当前所在位置的最底层表单容器与这个组件的容器不同; |
* 如果拖拽组件只有一个,鼠标当前所在位置的最底层表单容器与这个组件的容器不同; |
||||||
* 如果拖拽组件为多个,鼠标当前所在位置的最底层表单容器除了要求要跟这些组件的容器不同外,还必须是绝对定位布局 |
* 如果拖拽组件为多个,鼠标当前所在位置的最底层表单容器除了要求要跟这些组件的容器不同外,还必须是绝对定位布局 |
||||||
*/ |
*/ |
||||||
private void checkAddable(MouseEvent e) { |
private void checkAddable(MouseEvent e) { |
||||||
addable = false; |
addable = false; |
||||||
designer.setPainter(null); |
designer.setPainter(null); |
||||||
|
|
||||||
if (driection != Location.inner) { |
if (driection != Location.inner) { |
||||||
return; |
return; |
||||||
} |
} |
||||||
|
|
||||||
XCreator comp = designer.getComponentAt(e.getX(), e.getY(), selectionModel.getSelection().getSelectedCreators()); |
XCreator comp = designer.getComponentAt(e.getX(), e.getY(), selectionModel.getSelection().getSelectedCreators()); |
||||||
XLayoutContainer container = XCreatorUtils.getHotspotContainer(comp); |
XLayoutContainer container = XCreatorUtils.getHotspotContainer(comp); |
||||||
XCreator creator = selectionModel.getSelection().getSelectedCreator(); |
XCreator creator = selectionModel.getSelection().getSelectedCreator(); |
||||||
Component creatorContainer = XCreatorUtils.getParentXLayoutContainer(creator); |
Component creatorContainer = XCreatorUtils.getParentXLayoutContainer(creator); |
||||||
if (creatorContainer != null && creatorContainer != container |
if (creatorContainer != null && creatorContainer != container |
||||||
&& (selectionModel.getSelection().size() == 1 || container instanceof XWAbsoluteLayout)) { |
&& (selectionModel.getSelection().size() == 1 || container instanceof XWAbsoluteLayout)) { |
||||||
HoverPainter painter = AdapterBus.getContainerPainter(designer, container); |
HoverPainter painter = AdapterBus.getContainerPainter(designer, container); |
||||||
designer.setPainter(painter); |
designer.setPainter(painter); |
||||||
if (painter != null) { |
if (painter != null) { |
||||||
Rectangle rect = ComponentUtils.getRelativeBounds(container); |
Rectangle rect = ComponentUtils.getRelativeBounds(container); |
||||||
rect.x -= designer.getArea().getHorizontalValue(); |
rect.x -= designer.getArea().getHorizontalValue(); |
||||||
rect.y -= designer.getArea().getVerticalValue(); |
rect.y -= designer.getArea().getVerticalValue(); |
||||||
painter.setRenderingBounds(rect); |
painter.setRenderingBounds(rect); |
||||||
painter.setHotspot(new Point(e.getX(), e.getY())); |
painter.setHotspot(new Point(e.getX(), e.getY())); |
||||||
painter.setCreator(creator); |
painter.setCreator(creator); |
||||||
} |
} |
||||||
addable = true; |
addable = true; |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
private boolean addBean(XLayoutContainer container, int x, int y) { |
/** |
||||||
LayoutAdapter adapter = container.getLayoutAdapter(); |
* @param container 容器 |
||||||
Rectangle r = ComponentUtils.getRelativeBounds(container); |
* @param mouseX 鼠标释放位置X |
||||||
if (selectionModel.getSelection().size() == 1) { |
* @param mouseY 鼠标释放位置Y |
||||||
return adapter.addBean(selectionModel.getSelection().getSelectedCreator(), x |
* @return 是否成功 |
||||||
+ designer.getArea().getHorizontalValue() - r.x, y + designer.getArea().getVerticalValue() - r.y); |
*/ |
||||||
} |
private boolean addBean(XLayoutContainer container, int mouseX, int mouseY) { |
||||||
for (XCreator creator : selectionModel.getSelection().getSelectedCreators()) { |
LayoutAdapter adapter = container.getLayoutAdapter(); |
||||||
adapter.addBean(creator, x + designer.getArea().getHorizontalValue() - r.x, y + designer.getArea().getVerticalValue()- r.y); |
Rectangle rectangleContainer = ComponentUtils.getRelativeBounds(container); |
||||||
} |
if (selectionModel.getSelection().size() == 1) { |
||||||
return true; |
return adapter.addBean(selectionModel.getSelection().getSelectedCreator(), |
||||||
} |
mouseX + designer.getArea().getHorizontalValue() - rectangleContainer.x, |
||||||
|
mouseY + designer.getArea().getVerticalValue() - rectangleContainer.y); |
||||||
private void adding(int x, int y) { |
} |
||||||
|
for (XCreator creator : selectionModel.getSelection().getSelectedCreators()) { |
||||||
|
adapter.addBean(creator, |
||||||
|
mouseX + designer.getArea().getHorizontalValue() - rectangleContainer.x, |
||||||
|
mouseY + designer.getArea().getVerticalValue() - rectangleContainer.y); |
||||||
|
} |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @param mouseReleasedX 鼠标释放位置X |
||||||
|
* @param mouseReleasedY 鼠标释放位置Y |
||||||
|
*/ |
||||||
|
private void adding(int mouseReleasedX, int mouseReleasedY) { |
||||||
// 当前鼠标所在的组件
|
// 当前鼠标所在的组件
|
||||||
XCreator hoveredComponent = designer.getComponentAt(x, y, selectionModel.getSelection().getSelectedCreators()); |
XCreator hoveredComponent = designer.getComponentAt(mouseReleasedX, mouseReleasedY, selectionModel.getSelection().getSelectedCreators()); |
||||||
|
|
||||||
// 获取该组件所在的焦点容器
|
// 获取该组件所在的焦点容器
|
||||||
XLayoutContainer container = XCreatorUtils.getHotspotContainer(hoveredComponent); |
XLayoutContainer container = XCreatorUtils.getHotspotContainer(hoveredComponent); |
||||||
|
|
||||||
boolean success = false; |
boolean success = false; |
||||||
|
|
||||||
if (container != null) { |
if (container != null) { |
||||||
// 如果是容器,则调用其acceptComponent接受组件
|
// 如果是容器,则调用其acceptComponent接受组件
|
||||||
success = addBean(container, x, y); |
success = addBean(container, mouseReleasedX, mouseReleasedY); |
||||||
} |
} |
||||||
|
|
||||||
if (success) { |
if (success) { |
||||||
FormSelectionUtils.rebuildSelection(designer); |
FormSelectionUtils.rebuildSelection(designer); |
||||||
designer.getEditListenerTable().fireCreatorModified( |
designer.getEditListenerTable().fireCreatorModified( |
||||||
selectionModel.getSelection().getSelectedCreator(), DesignerEvent.CREATOR_ADDED); |
selectionModel.getSelection().getSelectedCreator(), DesignerEvent.CREATOR_ADDED); |
||||||
} else { |
} else { |
||||||
Toolkit.getDefaultToolkit().beep(); |
selectionModel.getSelection().setSelectionBounds(selectedPositionBackup, designer); |
||||||
} |
Toolkit.getDefaultToolkit().beep(); |
||||||
|
} |
||||||
// 取消提示
|
// 取消提示
|
||||||
designer.setPainter(null); |
designer.setPainter(null); |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
*是否拖拽 |
* 是否拖拽 |
||||||
|
* |
||||||
* @return dragging状态 |
* @return dragging状态 |
||||||
*/ |
*/ |
||||||
public boolean isDragging() { |
public boolean isDragging() { |
||||||
return dragging; |
return dragging; |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
*是否可以开始画线 |
* 是否可以开始画线 |
||||||
|
* |
||||||
* @return startPoint不为空返回true |
* @return startPoint不为空返回true |
||||||
*/ |
*/ |
||||||
public boolean prepareForDrawLining() { |
public boolean prepareForDrawLining() { |
||||||
return startPoint != null; |
return startPoint != null; |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
*设置开始位置 |
* 设置开始位置 |
||||||
|
* |
||||||
* @param p point位置 |
* @param p point位置 |
||||||
*/ |
*/ |
||||||
public void setStartPoint(Point p) { |
public void setStartPoint(Point p) { |
||||||
this.startPoint = p; |
this.startPoint = p; |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
*返回开始位置 |
* 返回开始位置 |
||||||
|
* |
||||||
* @return 点位置 |
* @return 点位置 |
||||||
*/ |
*/ |
||||||
public Point getStartPoint() { |
public Point getStartPoint() { |
||||||
return startPoint; |
return startPoint; |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
*返回当前点位置 |
* 返回当前点位置 |
||||||
|
* |
||||||
* @return 点位置 |
* @return 点位置 |
||||||
*/ |
*/ |
||||||
public Point getEndPoint() { |
public Point getEndPoint() { |
||||||
return currentPoint; |
return currentPoint; |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
*当前选中组件 |
* 当前选中组件 |
||||||
|
* |
||||||
* @param e 鼠标事件 |
* @param e 鼠标事件 |
||||||
*/ |
*/ |
||||||
public void startSelecting(MouseEvent e) { |
public void startSelecting(MouseEvent e) { |
||||||
selecting = true; |
selecting = true; |
||||||
selectionModel.setHotspotBounds(new Rectangle()); |
selectionModel.setHotspotBounds(new Rectangle()); |
||||||
current_x = getMouseXY(e).x; |
currentX = getMouseXY(e).x; |
||||||
current_y = getMouseXY(e).y; |
currentY = getMouseXY(e).y; |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
*当前鼠标的xy |
* 当前鼠标的xy |
||||||
|
* |
||||||
* @param e 鼠标事件 |
* @param e 鼠标事件 |
||||||
*/ |
*/ |
||||||
public void startResizing(MouseEvent e) { |
public void startResizing(MouseEvent e) { |
||||||
if (!selectionModel.getSelection().isEmpty()) { |
if (!selectionModel.getSelection().isEmpty()) { |
||||||
driection.backupBounds(designer); |
driection.backupBounds(designer); |
||||||
} |
} |
||||||
current_x = getMouseXY(e).x; |
currentX = getMouseXY(e).x; |
||||||
current_y = getMouseXY(e).y; |
currentY = getMouseXY(e).y; |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
*起始点开始DrawLine |
* 起始点开始DrawLine |
||||||
|
* |
||||||
* @param p 点位置 |
* @param p 点位置 |
||||||
*/ |
*/ |
||||||
public void startDrawLine(Point p) { |
public void startDrawLine(Point p) { |
||||||
this.startPoint = p; |
this.startPoint = p; |
||||||
if(p != null) { |
if (p != null) { |
||||||
try { |
try { |
||||||
designer.setCursor(XConnector.connectorCursor); |
designer.setCursor(XConnector.connectorCursor); |
||||||
} catch (Exception e) { |
} catch (Exception e) { |
||||||
} |
} |
||||||
} else { |
} else { |
||||||
designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
*鼠标释放时所在的区域及圈中的组件 |
* 鼠标释放时所在的区域及圈中的组件 |
||||||
|
* |
||||||
* @param e 鼠标事件 |
* @param e 鼠标事件 |
||||||
*/ |
*/ |
||||||
public void selectCreators(MouseEvent e) { |
public void selectCreators(MouseEvent e) { |
||||||
int x = getMouseXY(e).x; |
int x = getMouseXY(e).x; |
||||||
int y = getMouseXY(e).y; |
int y = getMouseXY(e).y; |
||||||
|
|
||||||
Rectangle bounds = createCurrentBounds(x, y); |
Rectangle bounds = createCurrentBounds(x, y); |
||||||
|
|
||||||
if ((x != current_x) || (y != current_y)) { |
if ((x != currentX) || (y != currentY)) { |
||||||
selectionModel.setSelectedCreators(getHotspotCreators(bounds, designer.getRootComponent())); |
selectionModel.setSelectedCreators(getHotspotCreators(bounds, designer.getRootComponent())); |
||||||
} |
} |
||||||
selectionModel.setHotspotBounds(null); |
selectionModel.setHotspotBounds(null); |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
*画所在区域线 |
* 画所在区域线 |
||||||
|
* |
||||||
* @param e 鼠标事件 |
* @param e 鼠标事件 |
||||||
*/ |
*/ |
||||||
public void drawLine(MouseEvent e) { |
public void drawLine(MouseEvent e) { |
||||||
designer.getDrawLineHelper().setDrawLine(true); |
designer.getDrawLineHelper().setDrawLine(true); |
||||||
Point p = designer.getDrawLineHelper().getNearWidgetPoint(e); |
Point p = designer.getDrawLineHelper().getNearWidgetPoint(e); |
||||||
if (p != null) { |
if (p != null) { |
||||||
currentPoint = p; |
currentPoint = p; |
||||||
} else { |
} else { |
||||||
currentPoint.x = e.getX() + designer.getArea().getHorizontalValue(); |
currentPoint.x = e.getX() + designer.getArea().getHorizontalValue(); |
||||||
currentPoint.y = e.getY() + designer.getArea().getVerticalValue(); |
currentPoint.y = e.getY() + designer.getArea().getVerticalValue(); |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
private Rectangle createCurrentBounds(int x, int y) { |
private Rectangle createCurrentBounds(int x, int y) { |
||||||
Rectangle bounds = new Rectangle(); |
Rectangle bounds = new Rectangle(); |
||||||
|
|
||||||
bounds.x = Math.min(x, current_x); |
bounds.x = Math.min(x, currentX); |
||||||
bounds.y = Math.min(y, current_y); |
bounds.y = Math.min(y, currentY); |
||||||
bounds.width = Math.max(x, current_x) - bounds.x; |
bounds.width = Math.max(x, currentX) - bounds.x; |
||||||
bounds.height = Math.max(y, current_y) - bounds.y; |
bounds.height = Math.max(y, currentY) - bounds.y; |
||||||
|
|
||||||
return bounds; |
return bounds; |
||||||
} |
} |
||||||
|
|
||||||
private ArrayList<XCreator> getHotspotCreators(Rectangle selection, XCreator root) { |
private ArrayList<XCreator> getHotspotCreators(Rectangle selection, XCreator root) { |
||||||
ArrayList<XCreator> creators = new ArrayList<XCreator>(); |
ArrayList<XCreator> creators = new ArrayList<>(); |
||||||
|
|
||||||
if (!root.isVisible() && !designer.isRoot(root)) { |
if (!root.isVisible() && !designer.isRoot(root)) { |
||||||
return creators; |
return creators; |
||||||
} |
} |
||||||
|
|
||||||
if (root instanceof XLayoutContainer) { |
if (root instanceof XLayoutContainer) { |
||||||
XLayoutContainer container = (XLayoutContainer) root; |
XLayoutContainer container = (XLayoutContainer) root; |
||||||
int count = container.getXCreatorCount(); |
int count = container.getXCreatorCount(); |
||||||
Rectangle clipped = new Rectangle(selection); |
Rectangle clipped = new Rectangle(selection); |
||||||
|
|
||||||
for (int i = count - 1; i >= 0; i--) { |
for (int i = count - 1; i >= 0; i--) { |
||||||
XCreator child = container.getXCreator(i); |
XCreator child = container.getXCreator(i); |
||||||
|
|
||||||
if (selection.contains(child.getBounds())) { |
if (selection.contains(child.getBounds())) { |
||||||
creators.add(child); |
creators.add(child); |
||||||
} else { |
} else { |
||||||
clipped.x = selection.x - child.getX(); |
clipped.x = selection.x - child.getX(); |
||||||
clipped.y = selection.y - child.getY(); |
clipped.y = selection.y - child.getY(); |
||||||
creators.addAll(getHotspotCreators(clipped, child)); |
creators.addAll(getHotspotCreators(clipped, child)); |
||||||
} |
} |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
return creators; |
return creators; |
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
/** |
/** |
||||||
*重置model |
* 重置model |
||||||
*/ |
*/ |
||||||
public void resetModel() { |
public void resetModel() { |
||||||
dragging = false; |
dragging = false; |
||||||
selecting = false; |
selecting = false; |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
*重置 |
* 重置 |
||||||
*/ |
*/ |
||||||
public void reset() { |
public void reset() { |
||||||
driection = Location.outer; |
driection = Location.outer; |
||||||
dragging = false; |
dragging = false; |
||||||
selecting = false; |
selecting = false; |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
*取消拖拽 |
* 取消拖拽 |
||||||
*/ |
*/ |
||||||
public void draggingCancel() { |
public void draggingCancel() { |
||||||
designer.repaint(); |
designer.repaint(); |
||||||
reset(); |
reset(); |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
*设置可拉伸方向 |
* 设置可拉伸方向 |
||||||
|
* |
||||||
* @param dir 拉伸方向 |
* @param dir 拉伸方向 |
||||||
*/ |
*/ |
||||||
public void setDirection(Direction dir) { |
public void setDirection(Direction dir) { |
||||||
if(driection != dir) { |
if (driection != dir) { |
||||||
this.driection = dir; |
this.driection = dir; |
||||||
driection.updateCursor(designer); |
driection.updateCursor(designer); |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
*x吸附线赋值 |
* x吸附线赋值 |
||||||
|
* |
||||||
* @param line 线 |
* @param line 线 |
||||||
*/ |
*/ |
||||||
public void setXAbsorptionline(Absorptionline line) { |
public void setXAbsorptionline(Absorptionline line) { |
||||||
this.lineInX = line; |
this.lineInX = line; |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
*y吸附线赋值 |
* y吸附线赋值 |
||||||
|
* |
||||||
|
* @param line 线 |
||||||
|
*/ |
||||||
|
public void setYAbsorptionline(Absorptionline line) { |
||||||
|
this.lineInY = line; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 等距线赋值 |
||||||
|
* |
||||||
* @param line 线 |
* @param line 线 |
||||||
*/ |
*/ |
||||||
public void setYAbsorptionline(Absorptionline line) { |
public void setEquidistantLine(Absorptionline line) { |
||||||
this.lineInY = line; |
this.lineEquidistant = line; |
||||||
} |
} |
||||||
|
|
||||||
/** |
|
||||||
* 等距线赋值 |
|
||||||
* @param line 线 |
|
||||||
*/ |
|
||||||
public void setEquidistantLine(Absorptionline line){ |
|
||||||
this.lineEquidistant = line; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
/** |
||||||
*画吸附线 |
* 画吸附线 |
||||||
|
* |
||||||
* @param g Graphics类 |
* @param g Graphics类 |
||||||
*/ |
*/ |
||||||
public void paintAbsorptionline(Graphics g) { |
public void paintAbsorptionline(Graphics g) { |
||||||
if(lineInX != null) { |
if (lineInX != null) { |
||||||
lineInX.paint(g,designer.getArea()); |
lineInX.paint(g, designer.getArea()); |
||||||
} |
} |
||||||
if(lineInY != null) { |
if (lineInY != null) { |
||||||
lineInY.paint(g,designer.getArea()); |
lineInY.paint(g, designer.getArea()); |
||||||
} |
} |
||||||
if(lineEquidistant != null){ |
if (lineEquidistant != null) { |
||||||
lineEquidistant.paint(g,designer.getArea()); |
lineEquidistant.paint(g, designer.getArea()); |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
*拖拽 |
* 拖拽 |
||||||
|
* |
||||||
* @param e 鼠标事件 |
* @param e 鼠标事件 |
||||||
*/ |
*/ |
||||||
public void dragging(MouseEvent e) { |
public void dragging(MouseEvent e) { |
||||||
checkAddable(e); |
//进入dragging状态时备份组件大小和位置
|
||||||
setDependLinePainter(e); |
if (!dragging) { |
||||||
driection.drag(getMouseXY(e).x-current_x, getMouseXY(e).y-current_y, designer); |
selectedPositionBackup = selectionModel.getSelection().getRelativeBounds(); |
||||||
this.dragging = true; |
} |
||||||
} |
checkAddable(e); |
||||||
|
setDependLinePainter(e); |
||||||
// 拖拽时画依附线用到的painter
|
driection.drag(getMouseXY(e).x - currentX, getMouseXY(e).y - currentY, designer); |
||||||
private void setDependLinePainter(MouseEvent e){ |
this.dragging = true; |
||||||
XCreator comp = designer.getComponentAt(e.getX(), e.getY(), selectionModel.getSelection().getSelectedCreators()); |
} |
||||||
XLayoutContainer container = XCreatorUtils.getHotspotContainer(comp); |
|
||||||
XCreator creator = selectionModel.getSelection().getSelectedCreator(); |
// 拖拽时画依附线用到的painter
|
||||||
HoverPainter painter = AdapterBus.getContainerPainter(designer, container); |
private void setDependLinePainter(MouseEvent e) { |
||||||
designer.setPainter(painter); |
XCreator comp = designer.getComponentAt(e.getX(), e.getY(), selectionModel.getSelection().getSelectedCreators()); |
||||||
if (painter != null) { |
XLayoutContainer container = XCreatorUtils.getHotspotContainer(comp); |
||||||
painter.setHotspot(new Point(e.getX(), e.getY())); |
XCreator creator = selectionModel.getSelection().getSelectedCreator(); |
||||||
painter.setCreator(creator); |
HoverPainter painter = AdapterBus.getContainerPainter(designer, container); |
||||||
} |
designer.setPainter(painter); |
||||||
} |
if (painter != null) { |
||||||
|
painter.setHotspot(new Point(e.getX(), e.getY())); |
||||||
|
painter.setCreator(creator); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
/** |
/** |
||||||
*释放捕获 |
* 释放捕获 |
||||||
|
* |
||||||
* @param e 鼠标事件 |
* @param e 鼠标事件 |
||||||
*/ |
*/ |
||||||
public void releaseDragging(MouseEvent e) { |
public void releaseDragging(MouseEvent e) { |
||||||
this.dragging = false; |
this.dragging = false; |
||||||
if (addable) { |
if (addable) { |
||||||
adding(e.getX(), e.getY()); |
adding(e.getX(), e.getY()); |
||||||
} else if (!selectionModel.getSelection().isEmpty()) { |
} else if (!selectionModel.getSelection().isEmpty()) { |
||||||
selectionModel.releaseDragging(); |
selectionModel.releaseDragging(); |
||||||
} |
} |
||||||
designer.repaint(); |
designer.repaint(); |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
*改变选择区域 |
* 改变选择区域 |
||||||
* |
* |
||||||
* @param e 鼠标事件 |
* @param e 鼠标事件 |
||||||
*/ |
*/ |
||||||
public void changeSelection(MouseEvent e) { |
public void changeSelection(MouseEvent e) { |
||||||
Rectangle bounds = createCurrentBounds(getMouseXY(e).x, getMouseXY(e).y); |
Rectangle bounds = createCurrentBounds(getMouseXY(e).x, getMouseXY(e).y); |
||||||
selectionModel.setHotspotBounds(bounds); |
selectionModel.setHotspotBounds(bounds); |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
*返回鼠标所在的x、y 考虑滚动条的值 |
* 返回鼠标所在的x、y 考虑滚动条的值 |
||||||
* |
* |
||||||
* @param e 鼠标事件 |
* @param e 鼠标事件 |
||||||
* @return xy值 |
* @return xy值 |
||||||
*/ |
*/ |
||||||
public Point getMouseXY(MouseEvent e) { |
public Point getMouseXY(MouseEvent e) { |
||||||
Point p1 = new Point(e.getX() + designer.getArea().getHorizontalValue(), e.getY() |
Point p1 = new Point(e.getX() + designer.getArea().getHorizontalValue(), e.getY() |
||||||
+ designer.getArea().getVerticalValue()); |
+ designer.getArea().getVerticalValue()); |
||||||
return p1; |
return p1; |
||||||
} |
} |
||||||
|
|
||||||
} |
} |
@ -1,88 +1,96 @@ |
|||||||
/** |
/** |
||||||
* |
* |
||||||
*/ |
*/ |
||||||
package com.fr.design.designer.creator; |
package com.fr.design.designer.creator; |
||||||
|
|
||||||
import com.fr.form.ui.container.WLayout; |
import com.fr.form.ui.container.WLayout; |
||||||
|
|
||||||
import java.awt.*; |
import java.awt.*; |
||||||
import java.beans.IntrospectionException; |
import java.beans.IntrospectionException; |
||||||
import java.util.ArrayList; |
import java.util.ArrayList; |
||||||
|
|
||||||
/** |
/** |
||||||
* 一些控件专属的容器,如标题容器,sclae容器 |
* 一些控件专属的容器,如标题容器,sclae容器 |
||||||
* @author jim |
* |
||||||
* @date 2014-11-7 |
* @author jim |
||||||
*/ |
* @date 2014-11-7 |
||||||
public abstract class DedicateLayoutContainer extends XLayoutContainer { |
*/ |
||||||
|
public abstract class DedicateLayoutContainer extends XLayoutContainer { |
||||||
public DedicateLayoutContainer(WLayout widget, Dimension initSize) { |
|
||||||
super(widget, initSize); |
public DedicateLayoutContainer(WLayout widget, Dimension initSize) { |
||||||
} |
super(widget, initSize); |
||||||
|
} |
||||||
/** |
|
||||||
* 得到属性名 |
/** |
||||||
* @return 属性名 |
* 得到属性名 |
||||||
* @throws IntrospectionException |
* |
||||||
*/ |
* @return 属性名 |
||||||
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { |
* @throws IntrospectionException |
||||||
return new CRPropertyDescriptor[0]; |
*/ |
||||||
} |
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { |
||||||
|
return new CRPropertyDescriptor[0]; |
||||||
/** |
} |
||||||
* 返回容器图标 |
|
||||||
* |
/** |
||||||
* @return |
* 返回容器图标 |
||||||
*/ |
* |
||||||
@Override |
* @return |
||||||
public String getIconPath() { |
*/ |
||||||
if(this.getXCreator(XWScaleLayout.INDEX) != null){ |
@Override |
||||||
return this.getXCreator(XWScaleLayout.INDEX).getIconPath(); |
public String getIconPath() { |
||||||
} |
if (this.getXCreator(XWScaleLayout.INDEX) != null) { |
||||||
return "/com/fr/web/images/form/resources/text_field_16.png"; |
return this.getXCreator(XWScaleLayout.INDEX).getIconPath(); |
||||||
} |
} |
||||||
|
return "/com/fr/web/images/form/resources/text_field_16.png"; |
||||||
|
} |
||||||
/** |
|
||||||
* 控件树不显示此组件 |
|
||||||
* @param path 控件树list |
/** |
||||||
*/ |
* 控件树不显示此组件 |
||||||
public void notShowInComponentTree(ArrayList<Component> path) { |
* |
||||||
path.remove(path.size()-1); |
* @param path 控件树list |
||||||
} |
*/ |
||||||
|
public void notShowInComponentTree(ArrayList<Component> path) { |
||||||
/** |
path.remove(path.size() - 1); |
||||||
* 重置组件的名称 |
} |
||||||
* @param name 名称 |
|
||||||
*/ |
/** |
||||||
public void resetCreatorName(String name) { |
* 重置组件的名称 |
||||||
super.resetCreatorName(name); |
* |
||||||
XCreator child = getXCreator(XWScaleLayout.INDEX); |
* @param name 名称 |
||||||
child.toData().setWidgetName(name); |
*/ |
||||||
} |
public void resetCreatorName(String name) { |
||||||
|
super.resetCreatorName(name); |
||||||
/** |
XCreator child = getXCreator(XWScaleLayout.INDEX); |
||||||
* 返回对应属性表的组件,scale和title返回其子组件 |
//实现WTitleLayout的SetWidgetName
|
||||||
* @return 组件 |
child.toData().setWidgetName(name); |
||||||
*/ |
} |
||||||
public XCreator getPropertyDescriptorCreator() { |
|
||||||
return getXCreator(XWScaleLayout.INDEX); |
/** |
||||||
} |
* 返回对应属性表的组件,scale和title返回其子组件 |
||||||
|
* |
||||||
/** |
* @return 组件 |
||||||
* 是否作为控件树的叶子节点 |
*/ |
||||||
* @return 是则返回true |
public XCreator getPropertyDescriptorCreator() { |
||||||
*/ |
return getXCreator(XWScaleLayout.INDEX); |
||||||
public boolean isComponentTreeLeaf() { |
} |
||||||
return true; |
|
||||||
} |
/** |
||||||
|
* 是否作为控件树的叶子节点 |
||||||
/** |
* |
||||||
* 是否为sclae和title专属容器 |
* @return 是则返回true |
||||||
* @return 是则返回true |
*/ |
||||||
*/ |
public boolean isComponentTreeLeaf() { |
||||||
public boolean isDedicateContainer() { |
return true; |
||||||
return true; |
} |
||||||
} |
|
||||||
|
/** |
||||||
|
* 是否为sclae和title专属容器 |
||||||
|
* |
||||||
|
* @return 是则返回true |
||||||
|
*/ |
||||||
|
public boolean isDedicateContainer() { |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
} |
} |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,481 @@ |
|||||||
|
package com.fr.design.mainframe; |
||||||
|
|
||||||
|
import com.fr.design.actions.UpdateAction; |
||||||
|
import com.fr.design.dialog.BasicDialog; |
||||||
|
import com.fr.design.dialog.BasicPane; |
||||||
|
import com.fr.design.dialog.DialogActionAdapter; |
||||||
|
import com.fr.design.gui.ibutton.UIButton; |
||||||
|
import com.fr.design.gui.icheckbox.UICheckBox; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.gui.itextfield.UITextField; |
||||||
|
import com.fr.design.gui.itoolbar.UIToolbar; |
||||||
|
import com.fr.design.javascript.JavaScriptActionPane; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.layout.TableLayout; |
||||||
|
import com.fr.design.layout.TableLayoutHelper; |
||||||
|
import com.fr.design.menu.ToolBarDef; |
||||||
|
import com.fr.design.style.background.BackgroundPane; |
||||||
|
import com.fr.design.utils.gui.GUICoreUtils; |
||||||
|
import com.fr.design.widget.IconDefinePane; |
||||||
|
import com.fr.form.ui.*; |
||||||
|
import com.fr.form.ui.Button; |
||||||
|
import com.fr.form.web.button.Export; |
||||||
|
import com.fr.general.Background; |
||||||
|
import com.fr.general.IOUtils; |
||||||
|
import com.fr.general.Inter; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import javax.swing.event.ListSelectionEvent; |
||||||
|
import javax.swing.event.ListSelectionListener; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.ActionListener; |
||||||
|
import java.util.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by harry on 2017-3-2. |
||||||
|
*/ |
||||||
|
public class FormEditToolBar extends BasicPane { |
||||||
|
|
||||||
|
private JList list; |
||||||
|
private DefaultListModel listModel; |
||||||
|
private JPanel right; |
||||||
|
private CardLayout card; |
||||||
|
private ButtonPane bp; |
||||||
|
private FormToolBarButton lastButton; |
||||||
|
private Background background = null; |
||||||
|
private UICheckBox defaultCheckBox; |
||||||
|
|
||||||
|
private ListSelectionListener listSelectionListener = new ListSelectionListener() { |
||||||
|
public void valueChanged(ListSelectionEvent evt) { |
||||||
|
if (lastButton != null) { |
||||||
|
lastButton.setWidget(bp.update()); |
||||||
|
} |
||||||
|
if (list.getSelectedValue() instanceof FormToolBarButton) { |
||||||
|
lastButton = (FormToolBarButton) list.getSelectedValue(); |
||||||
|
if (lastButton.getWidget() instanceof Button) { |
||||||
|
card.show(right, "button"); |
||||||
|
bp.populate(lastButton.getWidget()); |
||||||
|
} else { |
||||||
|
bp.populate(lastButton.getWidget()); |
||||||
|
card.show(right, "none"); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
private ActionListener actioner = new ActionListener() { |
||||||
|
/** |
||||||
|
* |
||||||
|
*/ |
||||||
|
public void actionPerformed(ActionEvent arg0) { |
||||||
|
final BackgroundPane backgroundPane = new BackgroundPane(); |
||||||
|
BasicDialog dialog = backgroundPane.showWindow(DesignerContext.getDesignerFrame()); |
||||||
|
backgroundPane.populate(FormEditToolBar.this.background); |
||||||
|
dialog.addDialogActionListener(new DialogActionAdapter() { |
||||||
|
public void doOk() { |
||||||
|
FormEditToolBar.this.background = backgroundPane.update(); |
||||||
|
if (FormEditToolBar.this.background != null) { |
||||||
|
FormEditToolBar.this.defaultCheckBox.setSelected(false); |
||||||
|
} |
||||||
|
} |
||||||
|
}); |
||||||
|
dialog.setVisible(true); |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
public FormEditToolBar() { |
||||||
|
initComponent(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 初始化 |
||||||
|
*/ |
||||||
|
public void initComponent() { |
||||||
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
JPanel left = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
listModel = new DefaultListModel(); |
||||||
|
list = new JList(listModel); |
||||||
|
list.setCellRenderer(render); |
||||||
|
left.add(new JScrollPane(list), BorderLayout.CENTER); |
||||||
|
if (listModel.getSize() > 0) { |
||||||
|
list.setSelectedIndex(0); |
||||||
|
} |
||||||
|
|
||||||
|
ToolBarDef toolbarDef = new ToolBarDef(); |
||||||
|
toolbarDef.addShortCut(new MoveUpItemAction()); |
||||||
|
toolbarDef.addShortCut(new MoveDownItemAction()); |
||||||
|
toolbarDef.addShortCut(new RemoveAction()); |
||||||
|
UIToolbar toolBar = ToolBarDef.createJToolBar(); |
||||||
|
toolbarDef.updateToolBar(toolBar); |
||||||
|
left.add(toolBar, BorderLayout.NORTH); |
||||||
|
|
||||||
|
right = FRGUIPaneFactory.createCardLayout_S_Pane(); |
||||||
|
card = new CardLayout(); |
||||||
|
right.setLayout(card); |
||||||
|
bp = new ButtonPane(); |
||||||
|
right.add("none", FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane()); |
||||||
|
right.add("button", bp); |
||||||
|
|
||||||
|
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, left, right); |
||||||
|
// splitPane.setDividerLocation(left.getMinimumSize().width);
|
||||||
|
splitPane.setDividerLocation(120); |
||||||
|
this.add(splitPane); |
||||||
|
list.addListSelectionListener(listSelectionListener); |
||||||
|
JPanel backgroundPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); |
||||||
|
UIButton bgButton = new UIButton(Inter.getLocText("FR-Designer-Output_Background_Set")); |
||||||
|
defaultCheckBox = new UICheckBox(Inter.getLocText("FR-Designer-Output_Default_Background")); |
||||||
|
bgButton.addActionListener(actioner); |
||||||
|
backgroundPane.add(defaultCheckBox); |
||||||
|
backgroundPane.add(bgButton); |
||||||
|
backgroundPane.setBorder(BorderFactory.createTitledBorder(Inter.getLocText("FR-Designer-Output_Background_Set"))); |
||||||
|
this.add(backgroundPane, BorderLayout.SOUTH); |
||||||
|
} |
||||||
|
|
||||||
|
ListCellRenderer render = new DefaultListCellRenderer() { |
||||||
|
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
||||||
|
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
||||||
|
|
||||||
|
if (value instanceof FormToolBarButton) { |
||||||
|
FormToolBarButton button = (FormToolBarButton) value; |
||||||
|
this.setText(button.getNameOption().optionName()); |
||||||
|
this.setIcon(button.getNameOption().optionIcon()); |
||||||
|
} |
||||||
|
return this; |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return Inter.getLocText("FR-Designer_Edit"); |
||||||
|
} |
||||||
|
|
||||||
|
public void populate(FormToolBar ftoolbar) { |
||||||
|
this.populate(ftoolbar, null); |
||||||
|
} |
||||||
|
|
||||||
|
public void populate(FormToolBar ftoolbar, FormToolBarButton button) { |
||||||
|
if (ftoolbar == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
for (int i = 0; i < ftoolbar.getButtonlist().size(); i++) { |
||||||
|
listModel.addElement(ftoolbar.getButtonlist().get(i)); |
||||||
|
} |
||||||
|
this.list.validate(); |
||||||
|
this.list.repaint(); |
||||||
|
if (ftoolbar.getButtonlist().size() > 0) { |
||||||
|
this.list.setSelectedIndex(0); |
||||||
|
} |
||||||
|
if (button != null) { |
||||||
|
this.list.setSelectedValue(button, true); |
||||||
|
} |
||||||
|
this.background = ftoolbar.getBackground(); |
||||||
|
|
||||||
|
this.defaultCheckBox.setSelected(ftoolbar.isDefault() ? true : false); |
||||||
|
} |
||||||
|
|
||||||
|
public FormToolBar update() { |
||||||
|
if (this.list.getSelectedIndex() > -1) { |
||||||
|
for (int i = 0; i < listModel.getSize(); i++) { |
||||||
|
this.list.setSelectedIndex(i); |
||||||
|
FormToolBarButton toolBarButton = (FormToolBarButton) this.list.getSelectedValue(); |
||||||
|
Widget widget = this.bp.update(); |
||||||
|
toolBarButton.setWidget(widget); |
||||||
|
if (widget instanceof Button) { |
||||||
|
String iconname = ((Button) widget).getIconName(); |
||||||
|
if (StringUtils.isNotBlank(iconname)) { |
||||||
|
Image iimage = WidgetManager.getProviderInstance().getIconManager().getIconImage(iconname); |
||||||
|
toolBarButton.setIcon(new ImageIcon(iimage)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
java.util.List<FormToolBarButton> list = new ArrayList<FormToolBarButton>(); |
||||||
|
for (int i = 0; i < listModel.size(); i++) { |
||||||
|
list.add((FormToolBarButton) listModel.get(i)); |
||||||
|
} |
||||||
|
FormToolBar ftoolBar = new FormToolBar(); |
||||||
|
ftoolBar.setButtonlist(list); |
||||||
|
|
||||||
|
ftoolBar.setDefault(this.defaultCheckBox.isSelected()); |
||||||
|
if (!ftoolBar.isDefault()) { |
||||||
|
ftoolBar.setBackground(this.background); |
||||||
|
} |
||||||
|
return ftoolBar; |
||||||
|
} |
||||||
|
|
||||||
|
private class MoveUpItemAction extends UpdateAction { |
||||||
|
public MoveUpItemAction() { |
||||||
|
this.setName(Inter.getLocText("Utils-Move_Up")); |
||||||
|
this.setMnemonic('U'); |
||||||
|
this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/control/up.png")); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* |
||||||
|
*/ |
||||||
|
public void actionPerformed(ActionEvent evt) { |
||||||
|
int selectedIndex = list.getSelectedIndex(); |
||||||
|
if (selectedIndex == -1) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
// 上移
|
||||||
|
if (selectedIndex > 0) { |
||||||
|
DefaultListModel listModel = (DefaultListModel) list.getModel(); |
||||||
|
|
||||||
|
Object selecteObj1 = listModel.get(selectedIndex - 1); |
||||||
|
listModel.set(selectedIndex - 1, listModel.get(selectedIndex)); |
||||||
|
listModel.set(selectedIndex, selecteObj1); |
||||||
|
|
||||||
|
list.setSelectedIndex(selectedIndex - 1); |
||||||
|
list.ensureIndexIsVisible(selectedIndex - 1); |
||||||
|
list.validate(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private class MoveDownItemAction extends UpdateAction { |
||||||
|
public MoveDownItemAction() { |
||||||
|
this.setName(Inter.getLocText("Utils-Move_Down")); |
||||||
|
this.setMnemonic('D'); |
||||||
|
this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/control/down.png")); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* |
||||||
|
*/ |
||||||
|
public void actionPerformed(ActionEvent evt) { |
||||||
|
int selectedIndex = list.getSelectedIndex(); |
||||||
|
if (selectedIndex == -1) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
// 下移
|
||||||
|
if (selectedIndex == -1) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
if (selectedIndex < list.getModel().getSize() - 1) { |
||||||
|
DefaultListModel listModel = (DefaultListModel) list.getModel(); |
||||||
|
|
||||||
|
Object selecteObj1 = listModel.get(selectedIndex + 1); |
||||||
|
listModel.set(selectedIndex + 1, listModel.get(selectedIndex)); |
||||||
|
listModel.set(selectedIndex, selecteObj1); |
||||||
|
|
||||||
|
list.setSelectedIndex(selectedIndex + 1); |
||||||
|
list.ensureIndexIsVisible(selectedIndex + 1); |
||||||
|
list.validate(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public class RemoveAction extends UpdateAction { |
||||||
|
public RemoveAction() { |
||||||
|
this.setName(Inter.getLocText("FR-Designer_Delete")); |
||||||
|
this.setSmallIcon(IOUtils.readIcon("/com/fr/base/images/cell/control/remove.png")); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 动作 |
||||||
|
* @param e 事件 |
||||||
|
*/ |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
int i = list.getSelectedIndex(); |
||||||
|
if (i < 0 || !(listModel.getElementAt(i) instanceof FormToolBarButton)) { |
||||||
|
return; |
||||||
|
} |
||||||
|
int val = JOptionPane.showConfirmDialog(FormEditToolBar.this, Inter.getLocText("FR-Designer_Are_You_Sure_To_Delete_The_Data") + "?", "Message", JOptionPane.YES_NO_OPTION); |
||||||
|
if (val != JOptionPane.YES_OPTION) { |
||||||
|
return; |
||||||
|
} |
||||||
|
listModel.removeElementAt(i); |
||||||
|
list.validate(); |
||||||
|
if (listModel.size() > 0) { |
||||||
|
list.setSelectedIndex(0); |
||||||
|
} else { |
||||||
|
card.show(right, "none"); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public class ButtonPane extends BasicPane { |
||||||
|
private CardLayout card; |
||||||
|
private JPanel centerPane; |
||||||
|
private UICheckBox icon, text, excelP, excelO; |
||||||
|
private Widget widget; |
||||||
|
private UITextField nameField; |
||||||
|
private IconDefinePane iconPane; |
||||||
|
private UIButton button; |
||||||
|
private JavaScriptActionPane javaScriptPane; |
||||||
|
|
||||||
|
public ButtonPane() { |
||||||
|
this.initComponents(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 初始化元素 |
||||||
|
*/ |
||||||
|
public void initComponents() { |
||||||
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
JPanel north = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
icon = new UICheckBox(Inter.getLocText("FR-Designer_Show_Icon")); |
||||||
|
text = new UICheckBox(Inter.getLocText("FR-Designer_Show_Text")); |
||||||
|
|
||||||
|
north.add(icon, BorderLayout.NORTH); |
||||||
|
north.add(text, BorderLayout.CENTER); |
||||||
|
|
||||||
|
nameField = new UITextField(8); |
||||||
|
iconPane = new IconDefinePane(); |
||||||
|
javaScriptPane = JavaScriptActionPane.createDefault(); |
||||||
|
|
||||||
|
double p = TableLayout.PREFERRED; |
||||||
|
double rowSize[] = {p, p}; |
||||||
|
double columnSize[] = {p, p}; |
||||||
|
|
||||||
|
Component[][] coms = new Component[][]{{new UILabel(Inter.getLocText(new String[]{"Widget", "Printer-Alias"}) + ":"), nameField}, {new UILabel(Inter.getLocText(new String[]{"Widget", "Icon"}) + ":"), iconPane}}; |
||||||
|
|
||||||
|
JPanel nameIconPane = TableLayoutHelper.createTableLayoutPane(coms, rowSize, columnSize); |
||||||
|
|
||||||
|
north.add(nameIconPane, BorderLayout.SOUTH); |
||||||
|
|
||||||
|
north.setBorder(BorderFactory.createTitledBorder(Inter.getLocText(new String[]{"Form-Button", "Property", "Set"}))); |
||||||
|
this.add(north, BorderLayout.NORTH); |
||||||
|
JPanel none = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); |
||||||
|
centerPane = FRGUIPaneFactory.createCardLayout_S_Pane(); |
||||||
|
card = new CardLayout(); |
||||||
|
centerPane.setLayout(card); |
||||||
|
centerPane.add("custom", getCustomPane()); |
||||||
|
centerPane.add("export", getExport()); |
||||||
|
centerPane.add("none", none); |
||||||
|
|
||||||
|
this.add(centerPane, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private JPanel getCustomPane() { |
||||||
|
JPanel customPane = FRGUIPaneFactory.createCenterFlowInnerContainer_S_Pane(); |
||||||
|
|
||||||
|
button = new UIButton(Inter.getLocText("FR-Designer_User_Defined_Event")); |
||||||
|
customPane.add(button); |
||||||
|
customPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("FR-Designer_Edit") + "JS", null)); |
||||||
|
button.addActionListener(l); |
||||||
|
return customPane; |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel getExport() { |
||||||
|
JPanel export = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); |
||||||
|
// export.setLayout(new BoxLayout(export, BoxLayout.Y_AXIS));
|
||||||
|
excelP = new UICheckBox(Inter.getLocText("FR-Designer-Output_Excel_Page")); |
||||||
|
excelO = new UICheckBox(Inter.getLocText("FR-Designer-Output_Excel_Simple")); |
||||||
|
export.add(excelP); |
||||||
|
export.add(Box.createVerticalStrut(2)); |
||||||
|
export.add(excelO); |
||||||
|
export.add(Box.createVerticalStrut(2)); |
||||||
|
|
||||||
|
export.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText(new String[]{"Form-Button", "Property", "Set"}), null)); |
||||||
|
return export; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return "Button"; |
||||||
|
} |
||||||
|
|
||||||
|
ActionListener l = new ActionListener() { |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
if (!(widget instanceof CustomToolBarButton)) { |
||||||
|
return; |
||||||
|
} |
||||||
|
if (javaScriptPane == null || ((CustomToolBarButton)widget).getJSImpl() == null) { |
||||||
|
javaScriptPane = JavaScriptActionPane.createDefault(); |
||||||
|
} |
||||||
|
javaScriptPane.setPreferredSize(new Dimension(750, 500)); |
||||||
|
BasicDialog dialog = javaScriptPane.showWindow(SwingUtilities.getWindowAncestor(ButtonPane.this)); |
||||||
|
dialog.addDialogActionListener(new DialogActionAdapter() { |
||||||
|
@Override |
||||||
|
public void doOk() { |
||||||
|
((CustomToolBarButton) widget).setJSImpl(javaScriptPane.updateBean()); |
||||||
|
} |
||||||
|
}); |
||||||
|
dialog.setVisible(true); |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* 更新 |
||||||
|
* @param widget 对应组件 |
||||||
|
*/ |
||||||
|
public void populate(Widget widget) { |
||||||
|
this.widget = widget; |
||||||
|
card.show(centerPane, "none"); |
||||||
|
if (widget instanceof Button) { |
||||||
|
populateDefault(); |
||||||
|
} |
||||||
|
if (widget instanceof Export) { |
||||||
|
populateExport(); |
||||||
|
} else if (widget instanceof CustomToolBarButton) { |
||||||
|
populateCustomToolBarButton(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void populateExport(){ |
||||||
|
card.show(centerPane, "export"); |
||||||
|
Export export = (Export) widget; |
||||||
|
this.excelP.setSelected(export.isExcelPAvailable()); |
||||||
|
this.excelO.setSelected(export.isExcelOAvailable()); |
||||||
|
} |
||||||
|
|
||||||
|
private void populateCustomToolBarButton(){ |
||||||
|
card.show(centerPane, "custom"); |
||||||
|
CustomToolBarButton customToolBarButton = (CustomToolBarButton) widget; |
||||||
|
if (customToolBarButton.getJSImpl() != null) { |
||||||
|
this.javaScriptPane.populateBean(customToolBarButton.getJSImpl()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void populateDefault(){ |
||||||
|
Button button = (Button) widget; |
||||||
|
this.icon.setSelected(button.isShowIcon()); |
||||||
|
this.text.setSelected(button.isShowText()); |
||||||
|
this.nameField.setText(button.getText()); |
||||||
|
this.iconPane.populate(((Button) widget).getIconName()); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 更新 |
||||||
|
* |
||||||
|
* @return 对应组件 |
||||||
|
*/ |
||||||
|
public Widget update() { |
||||||
|
if (widget instanceof Export) { |
||||||
|
updateExport(); |
||||||
|
} else if (widget instanceof CustomToolBarButton) { |
||||||
|
((CustomToolBarButton) widget).setJSImpl(this.javaScriptPane.updateBean()); |
||||||
|
} |
||||||
|
if (widget instanceof Button) { |
||||||
|
updateDefault(); |
||||||
|
} |
||||||
|
|
||||||
|
return widget; |
||||||
|
} |
||||||
|
|
||||||
|
private void updateDefault(){ |
||||||
|
((Button) widget).setShowIcon(this.icon.isSelected()); |
||||||
|
((Button) widget).setShowText(this.text.isSelected()); |
||||||
|
((Button) widget).setText(this.nameField.getText()); |
||||||
|
((Button) widget).setIconName(this.iconPane.update()); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private void updateExport(){ |
||||||
|
Export export = (Export) widget; |
||||||
|
export.setExcelPAvailable(this.excelP.isSelected()); |
||||||
|
export.setExcelOAvailable(this.excelO.isSelected()); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -1,126 +1,253 @@ |
|||||||
package com.fr.design.mainframe; |
package com.fr.design.mainframe; |
||||||
|
|
||||||
import java.awt.Component; |
import com.fr.base.FRContext; |
||||||
import java.awt.Rectangle; |
import com.fr.design.designer.beans.LayoutAdapter; |
||||||
import java.awt.Toolkit; |
import com.fr.design.designer.beans.adapters.layout.AbstractLayoutAdapter; |
||||||
import java.util.ArrayList; |
import com.fr.design.designer.beans.adapters.layout.FRTabFitLayoutAdapter; |
||||||
import java.util.Arrays; |
import com.fr.design.designer.beans.events.DesignerEvent; |
||||||
import java.util.List; |
import com.fr.design.designer.creator.*; |
||||||
|
import com.fr.design.utils.ComponentUtils; |
||||||
import com.fr.base.FRContext; |
import com.fr.form.ui.Widget; |
||||||
import com.fr.general.ComparatorUtils; |
import com.fr.form.ui.container.WTitleLayout; |
||||||
import com.fr.design.designer.beans.LayoutAdapter; |
import com.fr.general.ComparatorUtils; |
||||||
import com.fr.design.designer.beans.events.DesignerEvent; |
import com.fr.general.Inter; |
||||||
import com.fr.design.designer.creator.XCreator; |
|
||||||
import com.fr.design.designer.creator.XCreatorUtils; |
import java.awt.*; |
||||||
import com.fr.design.designer.creator.XLayoutContainer; |
import java.util.ArrayList; |
||||||
import com.fr.design.designer.creator.XWAbsoluteLayout; |
import java.util.Arrays; |
||||||
import com.fr.form.main.ClonedWidgetCreator; |
import java.util.List; |
||||||
import com.fr.form.ui.Widget; |
|
||||||
|
public class FormSelectionUtils { |
||||||
public class FormSelectionUtils { |
|
||||||
|
//组件复制时坐标偏移
|
||||||
public static void paste2Container(FormDesigner designer, XLayoutContainer parent, FormSelection selection, int x, |
private static final int DELAY_X_Y = 20; |
||||||
int y) { |
|
||||||
LayoutAdapter adapter = parent.getLayoutAdapter(); |
//组件重命名后缀
|
||||||
if (selection.size() == 1) { |
private static final String POSTFIX = "_c"; |
||||||
try { |
|
||||||
XCreator creator = selection.getSelectedCreator(); |
private FormSelectionUtils() { |
||||||
Widget cloned = new ClonedWidgetCreator(designer.getTarget()).clonedWidgetWithNoRepeatName(creator |
|
||||||
.toData()); |
} |
||||||
XCreator clondCreator = XCreatorUtils.createXCreator(cloned, creator.getSize()); |
|
||||||
if (adapter.addBean(clondCreator, x + clondCreator.getWidth() / 2, y + clondCreator.getHeight() / 2)) { |
/** |
||||||
designer.getSelectionModel().getSelection().setSelectedCreator(clondCreator); |
* 粘贴到容器 |
||||||
designer.getEditListenerTable().fireCreatorModified(clondCreator, DesignerEvent.CREATOR_PASTED); |
*/ |
||||||
return; |
public static void paste2Container(FormDesigner designer, XLayoutContainer parent, |
||||||
} |
FormSelection clipboard, int x, int y) { |
||||||
} catch (CloneNotSupportedException e) { |
LayoutAdapter adapter = parent.getLayoutAdapter(); |
||||||
FRContext.getLogger().error(e.getMessage(), e); |
if (parent instanceof XWAbsoluteLayout) { |
||||||
} |
//绝对布局
|
||||||
} else if (selection.size() > 1) { |
absolutePaste(designer, clipboard, adapter, x, y); |
||||||
if (parent instanceof XWAbsoluteLayout) { |
return; |
||||||
designer.getSelectionModel().getSelection().reset(); |
} else if (parent instanceof XWFitLayout) { |
||||||
Rectangle rec = selection.getSelctionBounds(); |
//相对布局
|
||||||
for (XCreator creator : selection.getSelectedCreators()) { |
relativePaste(designer, clipboard, adapter, x, y); |
||||||
try { |
return; |
||||||
Widget cloned = new ClonedWidgetCreator(designer.getTarget()) |
} |
||||||
.clonedWidgetWithNoRepeatName(creator.toData()); |
Toolkit.getDefaultToolkit().beep(); |
||||||
XCreator clondCreator = XCreatorUtils.createXCreator(cloned, creator.getSize()); |
} |
||||||
// 设置位置,移动20x20,防止被粘帖的组件重叠,照顾表单布局情况下
|
|
||||||
adapter.addBean(clondCreator, x + creator.getX() - rec.x + clondCreator.getWidth() / 2, y |
/** |
||||||
+ creator.getY() - rec.y + clondCreator.getHeight() / 2); |
* 绝对布局粘贴 |
||||||
designer.getSelectionModel().getSelection().addSelectedCreator(clondCreator); |
*/ |
||||||
} catch (CloneNotSupportedException e) { |
private static void absolutePaste(FormDesigner designer, FormSelection clipboard, LayoutAdapter adapter, int x, int y) { |
||||||
FRContext.getLogger().error(e.getMessage(), e); |
|
||||||
} |
designer.getSelectionModel().getSelection().reset(); |
||||||
} |
Rectangle rec = clipboard.getSelctionBounds(); |
||||||
designer.getEditListenerTable().fireCreatorModified( |
for (XCreator creator : clipboard.getSelectedCreators()) { |
||||||
designer.getSelectionModel().getSelection().getSelectedCreator(), DesignerEvent.CREATOR_PASTED); |
try { |
||||||
return; |
Widget copied = copyWidget(designer, creator); |
||||||
} |
XCreator copiedCreator = XCreatorUtils.createXCreator(copied, creator.getSize()); |
||||||
} |
// 获取位置
|
||||||
Toolkit.getDefaultToolkit().beep(); |
Point point = getPasteLocation((AbstractLayoutAdapter) adapter, |
||||||
} |
copiedCreator, |
||||||
|
x + creator.getX() - rec.x + copiedCreator.getWidth() / 2, |
||||||
public static void rebuildSelection(FormDesigner designer) { |
y + creator.getY() - rec.y + copiedCreator.getHeight() / 2); |
||||||
ArrayList<XCreator> newSelection = new ArrayList<XCreator>(); |
if (!adapter.accept(copiedCreator, point.x, point.y)) { |
||||||
List<Widget> widgetList = new ArrayList<Widget>(); |
designer.showMessageDialog(Inter.getLocText("FR-Designer_Too_Large_To_Paste")); |
||||||
for (XCreator comp : designer.getSelectionModel().getSelection().getSelectedCreators()) { |
return; |
||||||
widgetList.add(comp.toData()); |
} |
||||||
} |
boolean addSuccess = adapter.addBean(copiedCreator, point.x, point.y); |
||||||
designer.getSelectionModel().setSelectedCreators( |
if (addSuccess) { |
||||||
rebuildSelection(designer.getRootComponent(), widgetList, newSelection)); |
designer.getSelectionModel().getSelection().addSelectedCreator(copiedCreator); |
||||||
} |
} |
||||||
|
} catch (CloneNotSupportedException e) { |
||||||
public static ArrayList<XCreator> rebuildSelection(XCreator rootComponent, Widget[] selectWidgets) { |
FRContext.getLogger().error(e.getMessage(), e); |
||||||
List<Widget> selectionWidget = new ArrayList<Widget>(); |
} |
||||||
if(selectWidgets != null){ |
} |
||||||
selectionWidget.addAll(Arrays.asList(selectWidgets)); |
rebuildSelection(designer); |
||||||
} |
designer.getEditListenerTable().fireCreatorModified( |
||||||
return FormSelectionUtils.rebuildSelection(rootComponent, selectionWidget, new ArrayList<XCreator>()); |
designer.getSelectionModel().getSelection().getSelectedCreator(), DesignerEvent.CREATOR_PASTED); |
||||||
} |
|
||||||
|
} |
||||||
private static ArrayList<XCreator> rebuildSelection(XCreator rootComponent, List<Widget> selectionWidget, |
|
||||||
ArrayList<XCreator> newSelection) { |
/** |
||||||
FormSelectionUtils._rebuild(rootComponent, selectionWidget, newSelection); |
* 相对布局粘贴 |
||||||
if (newSelection.isEmpty()) { |
*/ |
||||||
newSelection.add(rootComponent); |
private static void relativePaste(FormDesigner designer, FormSelection clipboard, LayoutAdapter adapter, int x, int y) { |
||||||
} |
|
||||||
return newSelection; |
//@see FRTabFitLayoutAdapter
|
||||||
} |
Rectangle tabContainerRect = ComponentUtils.getRelativeBounds(designer.getSelectionModel().getSelection() |
||||||
|
.getSelectedCreator().getParent()); |
||||||
private static void _rebuild(XCreator root, List<Widget> selectionWidget, List<XCreator> newSelection) { |
|
||||||
if (selectionWidget.isEmpty()) { |
designer.getSelectionModel().getSelection().reset(); |
||||||
return; |
for (XCreator creator : clipboard.getSelectedCreators()) { |
||||||
} |
try { |
||||||
for (Widget x : selectionWidget) { |
Widget copied = copyWidget(designer, creator); |
||||||
if (ComparatorUtils.equals(x, root.toData())) { |
XCreator copiedCreator = XCreatorUtils.createXCreator(copied, creator.getSize()); |
||||||
if (!newSelection.contains(root)) { |
if (adapter.getClass().equals(FRTabFitLayoutAdapter.class)) { |
||||||
newSelection.add(root); |
if (!adapter.accept(copiedCreator, x - tabContainerRect.x, y - tabContainerRect.y)) { |
||||||
selectionWidget.remove(x); |
designer.showMessageDialog(Inter.getLocText("FR-Designer_Too_Small_To_Paste")); |
||||||
} |
return; |
||||||
break; |
} |
||||||
} |
} else { |
||||||
} |
if (!adapter.accept(copiedCreator, x, y)) { |
||||||
|
designer.showMessageDialog(Inter.getLocText("FR-Designer_Too_Small_To_Paste")); |
||||||
int count = root.getComponentCount(); |
return; |
||||||
for (int i = 0; i < count && !selectionWidget.isEmpty(); i++) { |
} |
||||||
Component c = root.getComponent(i); |
} |
||||||
if (c instanceof XCreator) { |
boolean addSuccess = adapter.addBean(copiedCreator, x, y); |
||||||
XCreator creator = (XCreator) c; |
if (addSuccess) { |
||||||
for (Widget x : selectionWidget) { |
designer.getSelectionModel().getSelection().addSelectedCreator(copiedCreator); |
||||||
if (ComparatorUtils.equals(x, creator.toData())) { |
} |
||||||
newSelection.add(creator); |
} catch (CloneNotSupportedException e) { |
||||||
selectionWidget.remove(x); |
FRContext.getLogger().error(e.getMessage(), e); |
||||||
break; |
} |
||||||
} |
} |
||||||
} |
rebuildSelection(designer); |
||||||
if (c instanceof XLayoutContainer) { |
designer.getEditListenerTable().fireCreatorModified( |
||||||
_rebuild((XLayoutContainer) c, selectionWidget, newSelection); |
designer.getSelectionModel().getSelection().getSelectedCreator(), DesignerEvent.CREATOR_PASTED); |
||||||
} else { |
} |
||||||
continue; |
|
||||||
} |
/** |
||||||
} |
* 组件复用绝对布局获取粘贴组件位置 |
||||||
} |
*/ |
||||||
} |
private static Point getPasteLocation(AbstractLayoutAdapter layoutAdapter, XCreator copiedCreator, int x, int y) { |
||||||
|
//当宽度为奇数时 设置偏移
|
||||||
|
int xoffset = (copiedCreator.getWidth() & 1) == 1 ? 1 : 0; |
||||||
|
//当高度为奇数时 设置偏移
|
||||||
|
int yoffset = (copiedCreator.getHeight() & 1) == 1 ? 1 : 0; |
||||||
|
|
||||||
|
if (!layoutAdapter.accept(copiedCreator, x, y)) { |
||||||
|
XLayoutContainer container = layoutAdapter.getContainer(); |
||||||
|
boolean xOut = x < 0 || x + copiedCreator.getWidth() / 2 + xoffset > container.getWidth(); |
||||||
|
boolean yOut = y < 0 || y + copiedCreator.getHeight() / 2 + yoffset > container.getHeight(); |
||||||
|
/* |
||||||
|
* 组件原始位置位于布局的右下角, |
||||||
|
* 和布局右下边界线紧挨, |
||||||
|
* 粘贴时组件在原始位置向左错开20像素。 |
||||||
|
* x,y同时越界 |
||||||
|
*/ |
||||||
|
if (xOut && yOut) { |
||||||
|
//向左偏移
|
||||||
|
x = container.getWidth() - copiedCreator.getWidth() / 2 - DELAY_X_Y - xoffset; |
||||||
|
//紧贴下边界
|
||||||
|
y = container.getHeight() - copiedCreator.getHeight() / 2 - yoffset; |
||||||
|
return new Point(x, y); |
||||||
|
} |
||||||
|
/* |
||||||
|
* 组件原始位置与布局边界距离小于20像素(下边界&右边界同时小于或者任意一个边界小于), |
||||||
|
* 则粘贴时距离小于20像素一侧直接贴近布局边界, |
||||||
|
* 距离大于20像素的一侧正常错开。 |
||||||
|
* x,y中只有一个越界 |
||||||
|
*/ |
||||||
|
if ((xOut || yOut)) { |
||||||
|
x = xOut ? container.getWidth() - copiedCreator.getWidth() / 2 - xoffset : x; |
||||||
|
y = yOut ? container.getHeight() - copiedCreator.getHeight() / 2 - yoffset : y; |
||||||
|
return new Point(x, y); |
||||||
|
} |
||||||
|
} |
||||||
|
return new Point(x, y); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 拷贝组件 |
||||||
|
*/ |
||||||
|
private static Widget copyWidget(FormDesigner formDesigner, XCreator xCreator) throws |
||||||
|
CloneNotSupportedException { |
||||||
|
ArrayList<String> nameSpace = new ArrayList<>(); |
||||||
|
Widget copied = (Widget) xCreator.toData().clone(); |
||||||
|
//重命名拷贝的组件
|
||||||
|
String name = getCopiedName(formDesigner, copied, nameSpace); |
||||||
|
if (copied instanceof WTitleLayout) { |
||||||
|
XWTitleLayout xwTitleLayout = new XWTitleLayout((WTitleLayout) copied, xCreator.getSize()); |
||||||
|
xwTitleLayout.resetCreatorName(name); |
||||||
|
} else { |
||||||
|
copied.setWidgetName(name); |
||||||
|
} |
||||||
|
return copied; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 组件拷贝命名规则 |
||||||
|
*/ |
||||||
|
private static String getCopiedName(FormDesigner formDesigner, Widget copied, ArrayList<String> nameSpace) { |
||||||
|
StringBuilder name = new StringBuilder(copied.getWidgetName()); |
||||||
|
do { |
||||||
|
name.append(POSTFIX); |
||||||
|
} while (formDesigner.getTarget().isNameExist(name.toString()) || nameSpace.contains(name.toString())); |
||||||
|
nameSpace.add(name.toString()); |
||||||
|
return name.toString(); |
||||||
|
} |
||||||
|
|
||||||
|
public static void rebuildSelection(FormDesigner designer) { |
||||||
|
ArrayList<XCreator> newSelection = new ArrayList<>(); |
||||||
|
List<Widget> widgetList = new ArrayList<>(); |
||||||
|
for (XCreator comp : designer.getSelectionModel().getSelection().getSelectedCreators()) { |
||||||
|
widgetList.add(comp.toData()); |
||||||
|
} |
||||||
|
designer.getSelectionModel().setSelectedCreators( |
||||||
|
rebuildSelection(designer.getRootComponent(), widgetList, newSelection)); |
||||||
|
} |
||||||
|
|
||||||
|
public static ArrayList<XCreator> rebuildSelection(XCreator rootComponent, Widget[] selectWidgets) { |
||||||
|
List<Widget> selectionWidget = new ArrayList<>(); |
||||||
|
if (selectWidgets != null) { |
||||||
|
selectionWidget.addAll(Arrays.asList(selectWidgets)); |
||||||
|
} |
||||||
|
return FormSelectionUtils.rebuildSelection(rootComponent, selectionWidget, new ArrayList<XCreator>()); |
||||||
|
} |
||||||
|
|
||||||
|
private static ArrayList<XCreator> rebuildSelection(XCreator rootComponent, List<Widget> selectionWidget, |
||||||
|
ArrayList<XCreator> newSelection) { |
||||||
|
FormSelectionUtils.rebuild(rootComponent, selectionWidget, newSelection); |
||||||
|
if (newSelection.isEmpty()) { |
||||||
|
newSelection.add(rootComponent); |
||||||
|
} |
||||||
|
return newSelection; |
||||||
|
} |
||||||
|
|
||||||
|
private static void rebuild(XCreator root, List<Widget> selectionWidget, List<XCreator> newSelection) { |
||||||
|
if (selectionWidget.isEmpty()) { |
||||||
|
return; |
||||||
|
} |
||||||
|
for (Widget x : selectionWidget) { |
||||||
|
if (ComparatorUtils.equals(x, root.toData())) { |
||||||
|
if (!newSelection.contains(root)) { |
||||||
|
newSelection.add(root); |
||||||
|
selectionWidget.remove(x); |
||||||
|
} |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
int count = root.getComponentCount(); |
||||||
|
for (int i = 0; i < count && !selectionWidget.isEmpty(); i++) { |
||||||
|
Component c = root.getComponent(i); |
||||||
|
if (c instanceof XCreator) { |
||||||
|
XCreator creator = (XCreator) c; |
||||||
|
for (Widget x : selectionWidget) { |
||||||
|
if (ComparatorUtils.equals(x, creator.toData())) { |
||||||
|
newSelection.add(creator); |
||||||
|
selectionWidget.remove(x); |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
if (c instanceof XLayoutContainer) { |
||||||
|
rebuild((XLayoutContainer) c, selectionWidget, newSelection); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
} |
} |
@ -0,0 +1,84 @@ |
|||||||
|
package com.fr.design.mainframe; |
||||||
|
|
||||||
|
import com.fr.design.dialog.BasicDialog; |
||||||
|
import com.fr.design.dialog.DialogActionAdapter; |
||||||
|
import com.fr.design.gui.ibutton.UIButton; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.utils.gui.GUICoreUtils; |
||||||
|
import com.fr.general.IOUtils; |
||||||
|
import com.fr.general.Inter; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.ActionListener; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by harry on 2017-3-2. |
||||||
|
*/ |
||||||
|
public class FormSettingToolBar extends JPanel { |
||||||
|
private Icon setIcon = IOUtils.readIcon("com/fr/design/images/toolbarbtn/toolbarbtnsetting.png"); |
||||||
|
private Icon delIcon = IOUtils.readIcon("com/fr/design/images/toolbarbtn/toolbarbtnclear.png"); |
||||||
|
private UIButton setButton; |
||||||
|
private UIButton delButton; |
||||||
|
private FormToolBarPane toolBarPane; |
||||||
|
|
||||||
|
public FormSettingToolBar(String name, FormToolBarPane toolBarPane) { |
||||||
|
super(); |
||||||
|
this.setBackground(Color.lightGray); |
||||||
|
this.add(new UILabel(name)); |
||||||
|
this.toolBarPane = toolBarPane; |
||||||
|
setButton = GUICoreUtils.createTransparentButton(setIcon, setIcon, setIcon); |
||||||
|
setButton.setToolTipText(Inter.getLocText("FR-Designer_Edit_Button_ToolBar")); |
||||||
|
setButton.setAction(new SetAction()); |
||||||
|
delButton = GUICoreUtils.createTransparentButton(delIcon, delIcon, delIcon); |
||||||
|
delButton.setToolTipText(Inter.getLocText("FR-Designer_Remove_Button_ToolBar")); |
||||||
|
delButton.setAction(new DelAction()); |
||||||
|
this.add(setButton); |
||||||
|
this.add(delButton); |
||||||
|
} |
||||||
|
|
||||||
|
public void setEnabled(boolean b) { |
||||||
|
setButton.setEnabled(b); |
||||||
|
delButton.setEnabled(b); |
||||||
|
} |
||||||
|
|
||||||
|
public void addActionListener(ActionListener l){ |
||||||
|
setButton.addActionListener(l); |
||||||
|
delButton.addActionListener(l); |
||||||
|
} |
||||||
|
|
||||||
|
private class SetAction extends AbstractAction { |
||||||
|
|
||||||
|
public SetAction() { |
||||||
|
this.putValue(Action.SMALL_ICON, setIcon); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent arg0) { |
||||||
|
final FormEditToolBar tb = new FormEditToolBar(); |
||||||
|
tb.populate(toolBarPane.getFToolBar()); |
||||||
|
BasicDialog dialog = tb.showWindow(DesignerContext.getDesignerFrame()); |
||||||
|
dialog.addDialogActionListener(new DialogActionAdapter() { |
||||||
|
public void doOk() { |
||||||
|
toolBarPane.setFToolBar(tb.update()); |
||||||
|
} |
||||||
|
}); |
||||||
|
dialog.setVisible(true); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private class DelAction extends AbstractAction { |
||||||
|
|
||||||
|
public DelAction() { |
||||||
|
this.putValue(Action.SMALL_ICON, delIcon); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent arg0) { |
||||||
|
toolBarPane.removeAll(); |
||||||
|
toolBarPane.removeButtonList(); |
||||||
|
toolBarPane.repaint(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,68 @@ |
|||||||
|
package com.fr.design.mainframe; |
||||||
|
|
||||||
|
import com.fr.form.ui.ToolBar; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.general.Background; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by harry on 2017-3-2. |
||||||
|
*/ |
||||||
|
public class FormToolBar { |
||||||
|
private List<FormToolBarButton> buttonlist = new ArrayList<FormToolBarButton>(); |
||||||
|
private Background background = null; |
||||||
|
private boolean isDefault = true; |
||||||
|
|
||||||
|
public List<FormToolBarButton> getButtonlist() { |
||||||
|
return buttonlist; |
||||||
|
} |
||||||
|
|
||||||
|
public void setButtonlist(List<FormToolBarButton> buttonlist) { |
||||||
|
if (buttonlist == null || buttonlist.size() < 0) { |
||||||
|
this.buttonlist = new ArrayList<FormToolBarButton>(); |
||||||
|
} else { |
||||||
|
this.buttonlist = buttonlist; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void addButton(FormToolBarButton toolBarButton) { |
||||||
|
this.buttonlist.add(toolBarButton); |
||||||
|
} |
||||||
|
|
||||||
|
public void removeButton(FormToolBarButton toolBarButton) { |
||||||
|
this.buttonlist.remove(toolBarButton); |
||||||
|
} |
||||||
|
|
||||||
|
public void clearButton() { |
||||||
|
this.buttonlist.clear(); |
||||||
|
} |
||||||
|
|
||||||
|
public Background getBackground() { |
||||||
|
return background; |
||||||
|
} |
||||||
|
|
||||||
|
public void setBackground(Background background) { |
||||||
|
this.background = background; |
||||||
|
} |
||||||
|
|
||||||
|
public boolean isDefault() { |
||||||
|
return isDefault; |
||||||
|
} |
||||||
|
|
||||||
|
public void setDefault(boolean isDefault) { |
||||||
|
this.isDefault = isDefault; |
||||||
|
} |
||||||
|
|
||||||
|
public ToolBar getToolBar() { |
||||||
|
Widget[] widgets = new Widget[this.getButtonlist().size()]; |
||||||
|
for (int j = 0; j < this.getButtonlist().size(); j++) { |
||||||
|
widgets[j] = this.getButtonlist().get(j).getWidget(); |
||||||
|
} |
||||||
|
ToolBar toolBar = new ToolBar(widgets); |
||||||
|
toolBar.setBackground(this.background); |
||||||
|
toolBar.setDefault(this.isDefault); |
||||||
|
return toolBar; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,164 @@ |
|||||||
|
package com.fr.design.mainframe; |
||||||
|
|
||||||
|
import com.fr.base.BaseUtils; |
||||||
|
import com.fr.design.dialog.BasicDialog; |
||||||
|
import com.fr.design.dialog.DialogActionAdapter; |
||||||
|
import com.fr.design.gui.core.WidgetOption; |
||||||
|
import com.fr.design.roleAuthority.ReportAndFSManagePane; |
||||||
|
import com.fr.design.utils.gui.GUIPaintUtils; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.form.ui.WidgetManager; |
||||||
|
import com.fr.stable.Constants; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.event.MouseEvent; |
||||||
|
import java.awt.event.MouseListener; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by harry on 2017-3-2. |
||||||
|
*/ |
||||||
|
public class FormToolBarButton extends JButton implements MouseListener { |
||||||
|
private Widget widget; |
||||||
|
private WidgetOption widgetOption; |
||||||
|
|
||||||
|
public FormToolBarButton(Icon icon, Widget widget) { |
||||||
|
this(null, icon, widget); |
||||||
|
} |
||||||
|
|
||||||
|
public FormToolBarButton(String text, Icon icon, Widget widget) { |
||||||
|
super(text, icon); |
||||||
|
setBackground(null); |
||||||
|
setRolloverEnabled(true); |
||||||
|
this.widget = widget; |
||||||
|
if (widget instanceof com.fr.form.ui.Button) { |
||||||
|
com.fr.form.ui.Button button = (com.fr.form.ui.Button) widget; |
||||||
|
String iconName = button.getIconName(); |
||||||
|
if (StringUtils.isNotEmpty(iconName)) { |
||||||
|
Image iimage = WidgetManager.getProviderInstance().getIconManager().getIconImage(iconName); |
||||||
|
if (iimage != null) { |
||||||
|
setIcon(new ImageIcon(iimage)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
this.addMouseListener(this); |
||||||
|
setMargin(new Insets(0, 0, 0, 0)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 改变按钮的权限细粒度状态 |
||||||
|
* |
||||||
|
* @param selectedRole 选择的角色 |
||||||
|
* @param isVisible 是否可见 |
||||||
|
*/ |
||||||
|
public void changeAuthorityState(String selectedRole, boolean isVisible) { |
||||||
|
this.widget.changeOnlyVisibleAuthorityState(selectedRole, isVisible); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 是都做过权限细粒度 |
||||||
|
* |
||||||
|
* @param role 选择的角色 |
||||||
|
* @return 若是对应的该角色做过权限细粒度,则返回true |
||||||
|
*/ |
||||||
|
public boolean isDoneAuthorityEdited(String role) { |
||||||
|
return this.widget.isDoneVisibleAuthority(role); |
||||||
|
} |
||||||
|
|
||||||
|
public Widget getWidget() { |
||||||
|
return this.widget; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public void setWidget(Widget widget) { |
||||||
|
this.widget = widget; |
||||||
|
} |
||||||
|
|
||||||
|
public WidgetOption getNameOption() { |
||||||
|
return this.widgetOption; |
||||||
|
} |
||||||
|
|
||||||
|
public void setNameOption(WidgetOption widgetOption) { |
||||||
|
this.widgetOption = widgetOption; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
protected void paintBorder(Graphics g) { |
||||||
|
paintBorder(g, this); |
||||||
|
} |
||||||
|
|
||||||
|
protected void paintBorder(Graphics g, FormToolBarButton b) { |
||||||
|
String selectedRoles = ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName(); |
||||||
|
GUIPaintUtils.drawBorder((Graphics2D) g, 0, 0, b.getWidth(), b.getHeight(), true, Constants.NULL, b.isDoneAuthorityEdited(selectedRoles)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 处理鼠标点击事件 |
||||||
|
* |
||||||
|
* @param e 鼠标点击事件 |
||||||
|
*/ |
||||||
|
public void mouseClicked(MouseEvent e) { |
||||||
|
//该button只在报表块工具栏中使用,
|
||||||
|
//parent只有FormToolBarPane一种,故可以直接强转
|
||||||
|
final FormToolBarPane toolBarPane = (FormToolBarPane) this.getParent(); |
||||||
|
if (BaseUtils.isAuthorityEditing()) { |
||||||
|
auhtorityMouseAction(); |
||||||
|
return; |
||||||
|
} |
||||||
|
if (e.getClickCount() >= 2) { |
||||||
|
final FormEditToolBar editToolBar = new FormEditToolBar(); |
||||||
|
editToolBar.populate(toolBarPane.getFToolBar(), this); |
||||||
|
BasicDialog dialog = editToolBar.showWindow(DesignerContext.getDesignerFrame()); |
||||||
|
dialog.addDialogActionListener(new DialogActionAdapter() { |
||||||
|
public void doOk() { |
||||||
|
toolBarPane.setFToolBar(editToolBar.update()); |
||||||
|
} |
||||||
|
}); |
||||||
|
dialog.setVisible(true); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private void auhtorityMouseAction() { |
||||||
|
if (this.isEnabled()) { |
||||||
|
this.setSelected(!this.isSelected()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 鼠标进入事件 |
||||||
|
* |
||||||
|
* @param e 鼠标进入事件 |
||||||
|
*/ |
||||||
|
public void mouseEntered(MouseEvent e) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 鼠标退出事件 |
||||||
|
* |
||||||
|
* @param e 鼠标退出事件 |
||||||
|
*/ |
||||||
|
public void mouseExited(MouseEvent e) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 鼠标按下事件 |
||||||
|
* |
||||||
|
* @param e 鼠标事件 |
||||||
|
*/ |
||||||
|
public void mousePressed(MouseEvent e) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 鼠标释放事件 |
||||||
|
* |
||||||
|
* @param e 鼠标事件 |
||||||
|
*/ |
||||||
|
public void mouseReleased(MouseEvent e) { |
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,233 @@ |
|||||||
|
package com.fr.design.mainframe; |
||||||
|
|
||||||
|
import com.fr.design.beans.BasicBeanPane; |
||||||
|
import com.fr.design.dialog.BasicDialog; |
||||||
|
import com.fr.design.dialog.DialogActionAdapter; |
||||||
|
import com.fr.design.gui.core.WidgetOption; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.form.ui.ToolBar; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.datatransfer.DataFlavor; |
||||||
|
import java.awt.datatransfer.UnsupportedFlavorException; |
||||||
|
import java.awt.event.MouseAdapter; |
||||||
|
import java.awt.event.MouseEvent; |
||||||
|
import java.awt.event.MouseListener; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by harry on 2017-3-2. |
||||||
|
*/ |
||||||
|
public class FormToolBarPane extends BasicBeanPane<ToolBar> { |
||||||
|
|
||||||
|
private FormToolBar ftoolbar = new FormToolBar(); |
||||||
|
|
||||||
|
public FormToolBarPane() { |
||||||
|
super(); |
||||||
|
this.initComponent(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 添加鼠标监听 |
||||||
|
* |
||||||
|
* @param mouselistener 鼠标监听 |
||||||
|
*/ |
||||||
|
public void addAuthorityListener(MouseListener mouselistener) { |
||||||
|
List<FormToolBarButton> list = ftoolbar.getButtonlist(); |
||||||
|
for (int i = 0; i < list.size(); i++) { |
||||||
|
list.get(i).addMouseListener(mouselistener); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public FormToolBarPane(FormToolBarButton button) { |
||||||
|
super(); |
||||||
|
this.initComponent(); |
||||||
|
this.add(button); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 初始化组件 |
||||||
|
*/ |
||||||
|
public void initComponent() { |
||||||
|
this.addMouseListener(listener); |
||||||
|
this.setLayout(FRGUIPaneFactory.createBoxFlowLayout()); |
||||||
|
this.setTransferHandler(new ToolBarHandler(TransferHandler.COPY)); |
||||||
|
this.setBorder(BorderFactory.createTitledBorder("")); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 删除鼠标事件 |
||||||
|
*/ |
||||||
|
public void removeDefaultMouseListener() { |
||||||
|
this.removeMouseListener(listener); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return "Toolbar"; |
||||||
|
} |
||||||
|
|
||||||
|
public void setSelectedButton(FormToolBarButton button) { |
||||||
|
this.ftoolbar.addButton(button); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 添加组件 |
||||||
|
* |
||||||
|
* @param comp 组件 |
||||||
|
* |
||||||
|
* @return 被添加的组件 |
||||||
|
*/ |
||||||
|
public Component add(Component comp) { |
||||||
|
if (comp instanceof FormToolBarButton) { |
||||||
|
this.ftoolbar.addButton((FormToolBarButton) comp); |
||||||
|
} |
||||||
|
return super.add(comp); |
||||||
|
} |
||||||
|
|
||||||
|
private Component addComp(Component comp) { |
||||||
|
return super.add(comp); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public void removeButtonList() { |
||||||
|
this.ftoolbar.clearButton(); |
||||||
|
} |
||||||
|
|
||||||
|
protected void setFToolBar(FormToolBar ftoolbar) { |
||||||
|
if (ftoolbar == null) { |
||||||
|
ftoolbar = new FormToolBar(); |
||||||
|
} |
||||||
|
this.ftoolbar = ftoolbar; |
||||||
|
this.setToolBar(this.ftoolbar.getButtonlist()); |
||||||
|
} |
||||||
|
|
||||||
|
public List<FormToolBarButton> getToolBarButtons() { |
||||||
|
return ftoolbar.getButtonlist(); |
||||||
|
} |
||||||
|
|
||||||
|
protected FormToolBar getFToolBar() { |
||||||
|
return this.ftoolbar; |
||||||
|
} |
||||||
|
|
||||||
|
public boolean isEmpty() { |
||||||
|
return this.ftoolbar.getButtonlist().size() <= 0; |
||||||
|
} |
||||||
|
|
||||||
|
private void setToolBar(List<FormToolBarButton> list) { |
||||||
|
if (list == null || list.size() < 0) { |
||||||
|
return; |
||||||
|
} |
||||||
|
this.removeAll(); |
||||||
|
for (int i = 0; i < list.size(); i++) { |
||||||
|
this.addComp(list.get(i)); |
||||||
|
} |
||||||
|
this.validate(); |
||||||
|
this.repaint(); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(ToolBar toolbar) { |
||||||
|
this.removeAll(); |
||||||
|
this.getFToolBar().clearButton(); |
||||||
|
for (int j = 0; j < toolbar.getWidgetSize(); j++) { |
||||||
|
Widget widget = toolbar.getWidget(j); |
||||||
|
WidgetOption no = WidgetOption.getToolBarButton(widget.getClass()); |
||||||
|
if (no == null){ |
||||||
|
//如果装了什么插件, 放到了工具栏上, 后来删除了插件, 模板里还存着之前的控件
|
||||||
|
continue; |
||||||
|
} |
||||||
|
|
||||||
|
FormToolBarButton button = new FormToolBarButton(no.optionIcon(), widget); |
||||||
|
button.setNameOption(no); |
||||||
|
this.add(button); |
||||||
|
this.validate(); |
||||||
|
this.repaint(); |
||||||
|
} |
||||||
|
this.getFToolBar().setBackground(toolbar.getBackground()); |
||||||
|
this.getFToolBar().setDefault(toolbar.isDefault()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public ToolBar updateBean() { |
||||||
|
return this.ftoolbar.getToolBar(); |
||||||
|
} |
||||||
|
|
||||||
|
MouseListener listener = new MouseAdapter() { |
||||||
|
@Override |
||||||
|
public void mouseClicked(MouseEvent e) { |
||||||
|
if (e.getClickCount() >= 2 && !SwingUtilities.isRightMouseButton(e)) { |
||||||
|
final FormEditToolBar tb = new FormEditToolBar(); |
||||||
|
tb.populate(getFToolBar()); |
||||||
|
BasicDialog dialog = tb.showWindow(SwingUtilities.getWindowAncestor(FormToolBarPane.this)); |
||||||
|
dialog.addDialogActionListener(new DialogActionAdapter() { |
||||||
|
@Override |
||||||
|
public void doOk() { |
||||||
|
FormToolBarPane.this.setFToolBar(tb.update()); |
||||||
|
} |
||||||
|
}); |
||||||
|
dialog.setVisible(true); |
||||||
|
} |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
/* |
||||||
|
* 拖拽属性设置 |
||||||
|
*/ |
||||||
|
private class ToolBarHandler extends TransferHandler { |
||||||
|
private int action; |
||||||
|
|
||||||
|
public ToolBarHandler(int action) { |
||||||
|
this.action = action; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean canImport(TransferHandler.TransferSupport support) { |
||||||
|
if (!support.isDrop()) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
if (!support.isDataFlavorSupported(DataFlavor.stringFlavor)) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
boolean actionSupported = (action & support.getSourceDropActions()) == action; |
||||||
|
if (actionSupported) { |
||||||
|
support.setDropAction(action); |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean importData(TransferHandler.TransferSupport support) { |
||||||
|
if (!canImport(support)) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
WidgetOption data; |
||||||
|
try { |
||||||
|
data = (WidgetOption) support.getTransferable().getTransferData(DataFlavor.stringFlavor); |
||||||
|
} catch (UnsupportedFlavorException e) { |
||||||
|
return false; |
||||||
|
} catch (java.io.IOException e) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
Widget widget = data.createWidget(); |
||||||
|
FormToolBarButton btn = new FormToolBarButton(data.optionIcon(), widget); |
||||||
|
btn.setNameOption(data); |
||||||
|
FormToolBarPane.this.add(btn); |
||||||
|
FormToolBarPane.this.validate(); |
||||||
|
FormToolBarPane.this.repaint(); |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,54 @@ |
|||||||
|
package com.fr.design.mainframe; |
||||||
|
|
||||||
|
import com.fr.design.gui.core.WidgetOption; |
||||||
|
import com.fr.design.gui.core.WidgetOptionFactory; |
||||||
|
import com.fr.form.ui.CustomToolBarButton; |
||||||
|
import com.fr.form.web.button.ExcelO; |
||||||
|
import com.fr.form.web.button.ExcelP; |
||||||
|
import com.fr.form.web.button.Export; |
||||||
|
import com.fr.form.web.button.page.*; |
||||||
|
import com.fr.general.IOUtils; |
||||||
|
import com.fr.general.Inter; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by harry on 2017-3-3. |
||||||
|
*/ |
||||||
|
public class FormWebWidgetConstants { |
||||||
|
|
||||||
|
private FormWebWidgetConstants() { |
||||||
|
} |
||||||
|
|
||||||
|
public static WidgetOption[] getFormElementCaseToolBarInstance() { |
||||||
|
return new WidgetOption[]{FIRST, PREVIOUS, PAGENAVI, NEXT, LAST, EXPORT, EXCELP, EXCELO, CUSTOM_BUTTON}; |
||||||
|
} |
||||||
|
|
||||||
|
// 当前页/总页数
|
||||||
|
public static final WidgetOption PAGENAVI = WidgetOptionFactory.createByWidgetClass(Inter.getLocText(new String[]{"HJS-Current_Page", "HF-Number_of_Page"}, new String[]{"/", ""}), |
||||||
|
IOUtils.readIcon("/com/fr/web/images/pageNumber.png"), PageNavi.class); |
||||||
|
// 首页
|
||||||
|
public static final WidgetOption FIRST = WidgetOptionFactory.createByWidgetClass(Inter.getLocText("FR-Engine_ReportServerP-First"), IOUtils.readIcon("/com/fr/web/images/first.png"), |
||||||
|
First.class); |
||||||
|
// 末页
|
||||||
|
public static final WidgetOption LAST = WidgetOptionFactory.createByWidgetClass(Inter.getLocText("FR-Engine_ReportServerP-Last"), IOUtils.readIcon("/com/fr/web/images/last.png"), |
||||||
|
Last.class); |
||||||
|
// 前一页
|
||||||
|
public static final WidgetOption PREVIOUS = WidgetOptionFactory.createByWidgetClass(Inter.getLocText("FR-Engine_ReportServerP-Previous"), |
||||||
|
IOUtils.readIcon("/com/fr/web/images/previous.png"), Previous.class); |
||||||
|
// 后一页
|
||||||
|
public static final WidgetOption NEXT = WidgetOptionFactory.createByWidgetClass(Inter.getLocText("FR-Engine_ReportServerP-Next"), IOUtils.readIcon("/com/fr/web/images/next.png"), |
||||||
|
Next.class); |
||||||
|
|
||||||
|
// 导出成Excel 分页导出
|
||||||
|
public static final WidgetOption EXCELP = WidgetOptionFactory.createByWidgetClass(Inter.getLocText(new String[]{"Excel", "FR-Designer_Export_Excel_Page"}, new String[]{"(", ")"}), |
||||||
|
IOUtils.readIcon("/com/fr/web/images/excel.png"), ExcelP.class); |
||||||
|
// 导出成Excel 原样导出
|
||||||
|
public static final WidgetOption EXCELO = WidgetOptionFactory.createByWidgetClass(Inter.getLocText(new String[]{"Excel", "FR-Designer_Export_Excel_Simple"}, new String[]{"(", ")"}), |
||||||
|
IOUtils.readIcon("/com/fr/web/images/excel.png"), ExcelO.class); |
||||||
|
// 导出
|
||||||
|
public static final WidgetOption EXPORT = WidgetOptionFactory |
||||||
|
.createByWidgetClass(Inter.getLocText("FR-Engine_Export"), IOUtils.readIcon("/com/fr/web/images/export.png"), Export.class); |
||||||
|
|
||||||
|
public static final WidgetOption CUSTOM_BUTTON = WidgetOptionFactory |
||||||
|
.createByWidgetClass(Inter.getLocText(new String[]{"Custom", "Form-Button"}), CustomToolBarButton.class); |
||||||
|
|
||||||
|
} |
File diff suppressed because it is too large
Load Diff
@ -1,346 +1,348 @@ |
|||||||
package com.fr.design.mainframe; |
package com.fr.design.mainframe; |
||||||
|
|
||||||
import java.awt.*; |
import java.awt.*; |
||||||
import java.awt.event.MouseAdapter; |
import java.awt.event.MouseAdapter; |
||||||
import java.awt.event.MouseEvent; |
import java.awt.event.MouseEvent; |
||||||
import java.util.List; |
import java.util.List; |
||||||
|
|
||||||
import javax.swing.BorderFactory; |
import javax.swing.BorderFactory; |
||||||
import javax.swing.JLabel; |
import javax.swing.JLabel; |
||||||
import javax.swing.JTable; |
import javax.swing.JTable; |
||||||
import javax.swing.ListSelectionModel; |
import javax.swing.ListSelectionModel; |
||||||
import javax.swing.table.*; |
import javax.swing.table.*; |
||||||
|
|
||||||
import com.fr.design.designer.creator.XCreator; |
import com.fr.design.designer.creator.XCreator; |
||||||
import com.fr.design.gui.ilable.UILabel; |
import com.fr.design.gui.ilable.UILabel; |
||||||
import com.fr.design.gui.itable.GroupRenderer; |
import com.fr.design.gui.itable.GroupRenderer; |
||||||
import com.fr.form.ui.Widget; |
import com.fr.form.ui.Widget; |
||||||
import com.fr.form.ui.container.*; |
import com.fr.form.ui.container.*; |
||||||
import com.fr.general.ComparatorUtils; |
import com.fr.general.ComparatorUtils; |
||||||
import com.fr.general.Inter; |
import com.fr.general.Inter; |
||||||
import com.fr.stable.StringUtils; |
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
/** |
/** |
||||||
* MobileWidgetTable类主要显示各种容器的控件列表(body,tab,绝对布局快,不包括参数面板) |
* MobileWidgetTable类主要显示各种容器的控件列表(body,tab,绝对布局快,不包括参数面板) |
||||||
* Created with IntelliJ IDEA. |
* Created with IntelliJ IDEA. |
||||||
* User: zx |
* User: zx |
||||||
* Date: 14-9-15 |
* Date: 14-9-15 |
||||||
* Time: 下午4:52 |
* Time: 下午4:52 |
||||||
* Modified by fanglei at 2017/01/23 |
* Modified by fanglei at 2017/01/23 |
||||||
*/ |
*/ |
||||||
public class MobileWidgetTable extends JTable { |
public class MobileWidgetTable extends JTable { |
||||||
|
|
||||||
private FormDesigner designer; |
private FormDesigner designer; |
||||||
private String[][] cellData; |
private String[][] cellData; |
||||||
private String[] headers = {Inter.getLocText("Form-Widget_Name")}; |
private String[] headers = {Inter.getLocText("Form-Widget_Name")}; |
||||||
private static final int WIDGET_TABLE_ROW_HEIGHT = 22; |
private static final int WIDGET_TABLE_ROW_HEIGHT = 22; |
||||||
private UILabel moveComponent = new UILabel(); // 作为拖动时候随鼠标移动的那个半透明控件
|
private UILabel moveComponent = new UILabel(); // 作为拖动时候随鼠标移动的那个半透明控件
|
||||||
private int selectedRow = -1; |
private int selectedRow = -1; |
||||||
private int GAP = 11; |
private static final int GAP = 11; |
||||||
private boolean draging = false; |
private boolean draging = false; |
||||||
private boolean collapsed = false; // 控件列表是否折叠
|
private boolean collapsed = false; // 控件列表是否折叠
|
||||||
|
|
||||||
@Override |
@Override |
||||||
public TableCellRenderer getCellRenderer(int row, int column) { |
public TableCellRenderer getCellRenderer(int row, int column) { |
||||||
//第一行渲染成为标题的样子
|
//第一行渲染成为标题的样子
|
||||||
if (row == 0) { |
if (row == 0) { |
||||||
return new GroupRenderer(); |
return new GroupRenderer(); |
||||||
} |
} |
||||||
return super.getCellRenderer(row, column); |
return super.getCellRenderer(row, column); |
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
public MobileWidgetTable(FormDesigner designer) { |
public MobileWidgetTable(FormDesigner designer) { |
||||||
this.designer = designer; |
this.designer = designer; |
||||||
cellData = getData(); |
cellData = getData(); |
||||||
this.setTableProperties(); |
this.setTableProperties(); |
||||||
TableModel defaultModel = new BeanTableModel(); |
TableModel defaultModel = new BeanTableModel(); |
||||||
this.setModel(defaultModel); |
this.setModel(defaultModel); |
||||||
this.repaint(); |
this.repaint(); |
||||||
this.setDefaultRenderer(Object.class,new DefaultTableCellRenderer()); |
this.setDefaultRenderer(Object.class, new DefaultTableCellRenderer()); |
||||||
refreshData(); |
refreshData(); |
||||||
this.addMouseListener(mouseAdapter); |
this.addMouseListener(mouseAdapter); |
||||||
this.addMouseMotionListener(mouseAdapter); |
this.addMouseMotionListener(mouseAdapter); |
||||||
add(moveComponent); |
add(moveComponent); |
||||||
} |
} |
||||||
|
|
||||||
private void setTableProperties() { |
private void setTableProperties() { |
||||||
JTableHeader header = getTableHeader(); |
JTableHeader header = getTableHeader(); |
||||||
header.setReorderingAllowed(false); |
header.setReorderingAllowed(false); |
||||||
header.setPreferredSize(new Dimension(0, 0)); // 隐藏表头
|
header.setPreferredSize(new Dimension(0, 0)); // 隐藏表头
|
||||||
GroupRenderer headerRenderer = new GroupRenderer(); |
GroupRenderer headerRenderer = new GroupRenderer(); |
||||||
headerRenderer.setPreferredSize(new Dimension(0, 0)); //这行代码隐藏表头。因为要实现折叠效果,表头不好监听事件
|
headerRenderer.setPreferredSize(new Dimension(0, 0)); //这行代码隐藏表头。因为要实现折叠效果,表头不好监听事件
|
||||||
headerRenderer.setHorizontalAlignment(JLabel.LEFT); |
headerRenderer.setHorizontalAlignment(JLabel.LEFT); |
||||||
header.setDefaultRenderer(headerRenderer); |
header.setDefaultRenderer(headerRenderer); |
||||||
|
|
||||||
this.setRowHeight(WIDGET_TABLE_ROW_HEIGHT); |
this.setRowHeight(WIDGET_TABLE_ROW_HEIGHT); |
||||||
this.setGridColor(new Color(212, 208, 200)); |
this.setGridColor(new Color(212, 208, 200)); |
||||||
this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
||||||
this.setColumnSelectionAllowed(false); |
this.setColumnSelectionAllowed(false); |
||||||
this.setRowSelectionAllowed(false); |
this.setRowSelectionAllowed(false); |
||||||
this.setFillsViewportHeight(false); |
this.setFillsViewportHeight(false); |
||||||
this.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); |
this.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); |
||||||
} |
} |
||||||
|
|
||||||
private MouseAdapter mouseAdapter = new MouseAdapter() { |
private MouseAdapter mouseAdapter = new MouseAdapter() { |
||||||
/** |
/** |
||||||
* 鼠标按下时处理的事件(设置当前选中的行列) |
* 鼠标按下时处理的事件(设置当前选中的行列) |
||||||
* @param e |
* @param e |
||||||
*/ |
*/ |
||||||
@Override |
@Override |
||||||
public void mousePressed(MouseEvent e) { |
public void mousePressed(MouseEvent e) { |
||||||
getInstance().setCellSelected(); |
getInstance().setCellSelected(); |
||||||
if (selectedRow == 0 && !e.isPopupTrigger() && e.getClickCount() == 1 && e.getX() < WIDGET_TABLE_ROW_HEIGHT / 2){ // 如果是点击在第一行
|
if (selectedRow == 0 && !e.isPopupTrigger() && e.getClickCount() == 1 && e.getX() < WIDGET_TABLE_ROW_HEIGHT / 2) { // 如果是点击在第一行
|
||||||
toggleCollapse(); |
toggleCollapse(); |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 鼠标放开时处理的事件(如果是正在拖动则执行换位操作,重新绘制属性表,如果不是则什么也不做) |
* 鼠标放开时处理的事件(如果是正在拖动则执行换位操作,重新绘制属性表,如果不是则什么也不做) |
||||||
* 所谓的换行就是简单的重新拿到一次表格数据然后重新绘制表格 |
* 所谓的换行就是简单的重新拿到一次表格数据然后重新绘制表格 |
||||||
* @param e |
* @param e |
||||||
*/ |
*/ |
||||||
@Override |
@Override |
||||||
public void mouseReleased(MouseEvent e) { |
public void mouseReleased(MouseEvent e) { |
||||||
if(!draging){ |
if (!draging) { |
||||||
return; |
return; |
||||||
} |
} |
||||||
draging = false; |
draging = false; |
||||||
moveComponent.setVisible(false); |
moveComponent.setVisible(false); |
||||||
int toIndex = e.getY() < GAP ? 0 : (int)Math.rint((e.getY() - GAP)/WIDGET_TABLE_ROW_HEIGHT) + 1; |
int toIndex = e.getY() < GAP ? 0 : (int) Math.rint((e.getY() - GAP) / WIDGET_TABLE_ROW_HEIGHT) + 1; |
||||||
//当鼠标放开时,将选中的容器调整至新的顺序
|
//当鼠标放开时,将选中的容器调整至新的顺序
|
||||||
((WSortLayout)designer.getSelectionModel().getSelection().getSelectedCreator().toData()).adjustOrder(selectedRow - 1, toIndex - 1); |
((WSortLayout) designer.getSelectionModel().getSelection().getSelectedCreator().toData()).adjustOrder(selectedRow - 1, toIndex - 1); |
||||||
//拿取排序后表格数据,然后重绘表格
|
//拿取排序后表格数据,然后重绘表格
|
||||||
getInstance().refreshData(); |
getInstance().refreshData(); |
||||||
getInstance().repaint(); |
getInstance().repaint(); |
||||||
designer.fireTargetModified(); |
designer.fireTargetModified(); |
||||||
getInstance().setCellSelected(); |
getInstance().setCellSelected(); |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 设置鼠标在属性表区域移动时候的事件 |
* 设置鼠标在属性表区域移动时候的事件 |
||||||
* @param e |
* @param e |
||||||
*/ |
*/ |
||||||
@Override |
@Override |
||||||
public void mouseMoved(MouseEvent e) { |
public void mouseMoved(MouseEvent e) { |
||||||
int overRow = 0; |
int overRow = 0; |
||||||
for (int i = 0;i < getRowCount();i++) { |
for (int i = 0; i < getRowCount(); i++) { |
||||||
if (e.getY() > i * WIDGET_TABLE_ROW_HEIGHT && e.getY() <= (i + 1) * WIDGET_TABLE_ROW_HEIGHT){ |
if (e.getY() > i * WIDGET_TABLE_ROW_HEIGHT && e.getY() <= (i + 1) * WIDGET_TABLE_ROW_HEIGHT) { |
||||||
overRow = i; //判断鼠标在哪一行
|
overRow = i; //判断鼠标在哪一行
|
||||||
} |
} |
||||||
} |
} |
||||||
//如果鼠标移动到当前选中的行上面的时候
|
//如果鼠标移动到当前选中的行上面的时候
|
||||||
if (overRow == selectedRow && selectedRow > 0) { |
if (overRow == selectedRow && selectedRow > 0) { |
||||||
//把当前选中的那一行的光标改成(除了第一列)移动样式MOVE_CURSOR
|
//把当前选中的那一行的光标改成(除了第一列)移动样式MOVE_CURSOR
|
||||||
setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); |
setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); |
||||||
} else { |
} else { |
||||||
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 鼠标拖动事件(如果鼠标当前是<code>MOVE_CURSOR</code>状态则执行开始拖动的代码, |
* 鼠标拖动事件(如果鼠标当前是<code>MOVE_CURSOR</code>状态则执行开始拖动的代码, |
||||||
* 绘制一个<code>moveComponent</code>来跟随鼠标移动) |
* 绘制一个<code>moveComponent</code>来跟随鼠标移动) |
||||||
* @param e |
* @param e |
||||||
*/ |
*/ |
||||||
@Override |
@Override |
||||||
public void mouseDragged(MouseEvent e) { |
public void mouseDragged(MouseEvent e) { |
||||||
int width = getColumnModel().getColumn(0).getWidth(); |
int width = getColumnModel().getColumn(0).getWidth(); |
||||||
//如果当前选中的行的范围是合理的话,就可以拖动
|
//如果当前选中的行的范围是合理的话,就可以拖动
|
||||||
if (selectedRow < getRowCount() && selectedRow > 0){ |
if (selectedRow < getRowCount() && selectedRow > 0) { |
||||||
setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); |
setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); |
||||||
draging = true; |
draging = true; |
||||||
moveComponent.setText(getValueAt(selectedRow,0).toString()); |
moveComponent.setText(getValueAt(selectedRow, 0).toString()); |
||||||
moveComponent.setLocation(0, e.getY() - GAP); |
moveComponent.setLocation(0, e.getY() - GAP); |
||||||
moveComponent.setSize(new Dimension(width, WIDGET_TABLE_ROW_HEIGHT)); |
moveComponent.setSize(new Dimension(width, WIDGET_TABLE_ROW_HEIGHT)); |
||||||
moveComponent.setVisible(true); |
moveComponent.setVisible(true); |
||||||
moveComponent.setForeground(Color.lightGray); |
moveComponent.setForeground(Color.lightGray); |
||||||
moveComponent.setBorder(BorderFactory.createLineBorder(Color.lightGray)); |
moveComponent.setBorder(BorderFactory.createLineBorder(Color.lightGray)); |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 设置鼠标单击时处理的事件(单击控件列表进入控件属性表) |
* 设置鼠标单击时处理的事件(单击控件列表进入控件属性表) |
||||||
* @param e |
* @param e |
||||||
*/ |
*/ |
||||||
@Override |
@Override |
||||||
public void mouseClicked(MouseEvent e) { |
public void mouseClicked(MouseEvent e) { |
||||||
if(selectedRow > 0){ |
if (selectedRow > 0) { |
||||||
//当前点击的控件的名字
|
//当前点击的控件的名字
|
||||||
String widgetName = cellData[selectedRow][0]; |
String widgetName = cellData[selectedRow][0]; |
||||||
if (StringUtils.isNotEmpty(widgetName)){ |
if (StringUtils.isNotEmpty(widgetName)) { |
||||||
//当前选择的容器
|
//当前选择的容器
|
||||||
XCreator selectedContainer = designer.getSelectionModel().getSelection().getSelectedCreator(); |
XCreator selectedContainer = designer.getSelectionModel().getSelection().getSelectedCreator(); |
||||||
WLayout selectedWidget = (WLayout)selectedContainer.toData(); |
WLayout selectedWidget = (WLayout) selectedContainer.toData(); |
||||||
//当前选择的容器中的控件数量
|
//当前选择的容器中的控件数量
|
||||||
int count = selectedWidget.getWidgetCount(); |
int count = selectedWidget.getWidgetCount(); |
||||||
for (int i = 0;i < count ;i++){ |
for (int i = 0; i < count; i++) { |
||||||
XCreator xCreator = (XCreator) selectedContainer.getComponent(i); |
XCreator xCreator = (XCreator) selectedContainer.getComponent(i); |
||||||
Widget widget = xCreator.toData(); |
Widget widget = xCreator.toData(); |
||||||
if (ComparatorUtils.equals(widgetName, widget.getWidgetName())) { |
if (ComparatorUtils.equals(widgetName, widget.getWidgetName())) { |
||||||
getEditingDesigner().getSelectionModel().setSelectedCreator(xCreator); |
getEditingDesigner().getSelectionModel().setSelectedCreator(xCreator); |
||||||
} |
} |
||||||
} |
} |
||||||
} |
} |
||||||
} else if (selectedRow == 0){ // 如果是点击在第一行
|
} else if (selectedRow == 0) { // 如果是点击在第一行
|
||||||
if (!e.isPopupTrigger() && e.getClickCount() > 1) { |
if (!e.isPopupTrigger() && e.getClickCount() > 1) { |
||||||
toggleCollapse(); |
toggleCollapse(); |
||||||
} |
} |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 鼠标离开属性表区域事件 |
* 鼠标离开属性表区域事件 |
||||||
* @param e |
* @param e |
||||||
*/ |
*/ |
||||||
public void mouseExited(MouseEvent e) { |
public void mouseExited(MouseEvent e) { |
||||||
draging = false; |
draging = false; |
||||||
moveComponent.setVisible(false); |
moveComponent.setVisible(false); |
||||||
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
||||||
} |
} |
||||||
}; |
}; |
||||||
|
|
||||||
public MobileWidgetTable getInstance(){ |
public MobileWidgetTable getInstance() { |
||||||
return this; |
return this; |
||||||
} |
} |
||||||
|
|
||||||
public FormDesigner getEditingDesigner(){ |
public FormDesigner getEditingDesigner() { |
||||||
return designer; |
return designer; |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 设置当前get到的行列的单元格为选中状态 |
* 设置当前get到的行列的单元格为选中状态 |
||||||
*/ |
*/ |
||||||
private void setCellSelected() { |
private void setCellSelected() { |
||||||
selectedRow = getSelectedRow(); |
selectedRow = getSelectedRow(); |
||||||
if (selectedRow != -1) { |
if (selectedRow != -1) { |
||||||
this.setRowSelectionInterval(selectedRow, selectedRow); |
this.setRowSelectionInterval(selectedRow, selectedRow); |
||||||
this.setColumnSelectionInterval(0, 0); |
this.setColumnSelectionInterval(0, 0); |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 切换属性组折叠属性true/false |
* 切换属性组折叠属性true/false |
||||||
*/ |
*/ |
||||||
private void toggleCollapse() { |
private void toggleCollapse() { |
||||||
this.setCollapsed(!this.isCollapsed()); |
this.setCollapsed(!this.isCollapsed()); |
||||||
//这里获取表格的父控件是为了当表格被折叠了后,装表格的父控件也要相应的重新布局一下
|
//这里获取表格的父控件是为了当表格被折叠了后,装表格的父控件也要相应的重新布局一下
|
||||||
//比如折叠之后表格行数应该比原来的少,占用父容器空间应该小点,不重新布局父容器,表格大小不会改变
|
//比如折叠之后表格行数应该比原来的少,占用父容器空间应该小点,不重新布局父容器,表格大小不会改变
|
||||||
Container parent = MobileWidgetTable.this.getParent(); |
Container parent = MobileWidgetTable.this.getParent(); |
||||||
if (parent != null) { |
if (parent != null) { |
||||||
parent.revalidate(); |
parent.revalidate(); |
||||||
} |
} |
||||||
repaint(); |
repaint(); |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 重新get排序后的数据 |
* 重新get排序后的数据 |
||||||
*/ |
*/ |
||||||
public void refreshData(){ |
public void refreshData() { |
||||||
cellData = getData(); |
cellData = getData(); |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 获取选中控件的控件列表 |
* 获取选中控件的控件列表 |
||||||
* |
* |
||||||
* @return String[][] 二维数组,[0][0]widgetName |
* @return String[][] 二维数组,[0][0]widgetName |
||||||
*/ |
*/ |
||||||
private String[][] getData(){ |
private String[][] getData() { |
||||||
if(designer.isFormParaDesigner()){ |
if (designer.isFormParaDesigner()) { |
||||||
return new String[0][0]; |
return new String[0][0]; |
||||||
} |
} |
||||||
|
|
||||||
//选择的控件
|
//选择的控件
|
||||||
Widget selectedModel = designer.getSelectionModel().getSelection().getSelectedCreator().toData(); |
XCreator selectedCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); |
||||||
|
Widget selectedModel = selectedCreator != null ? selectedCreator.toData() : null; |
||||||
if(selectedModel == null){ |
|
||||||
return new String[0][0]; |
if (selectedModel == null) { |
||||||
} |
return new String[0][0]; |
||||||
|
} |
||||||
// 选择的控件有两种类型,一种是WLayout,代表容器,一种是Widget,代表控件
|
|
||||||
if (selectedModel.acceptType(WSortLayout.class)) { |
// 选择的控件有两种类型,一种是WLayout,代表容器,一种是Widget,代表控件
|
||||||
List<String> mobileWidgetList = ((WSortLayout)selectedModel).getOrderedMobileWidgetList(); |
if (selectedModel.acceptType(WSortLayout.class)) { |
||||||
String[][] widgetName = new String[mobileWidgetList.size() + 1][1]; |
List<String> mobileWidgetList = ((WSortLayout) selectedModel).getOrderedMobileWidgetList(); |
||||||
widgetName[0][0] = Inter.getLocText("FR-Designer_WidgetOrder"); |
String[][] widgetName = new String[mobileWidgetList.size() + 1][1]; |
||||||
for (int i = 0; i < mobileWidgetList.size(); i++) { |
widgetName[0][0] = Inter.getLocText("FR-Designer_WidgetOrder"); |
||||||
widgetName[i + 1][0] = mobileWidgetList.get(i); |
for (int i = 0; i < mobileWidgetList.size(); i++) { |
||||||
} |
widgetName[i + 1][0] = mobileWidgetList.get(i); |
||||||
return widgetName; |
} |
||||||
} else { |
return widgetName; |
||||||
return new String[0][0]; |
} else { |
||||||
} |
return new String[0][0]; |
||||||
} |
} |
||||||
|
} |
||||||
public boolean isCollapsed() { |
|
||||||
return collapsed; |
public boolean isCollapsed() { |
||||||
} |
return collapsed; |
||||||
|
} |
||||||
public void setCollapsed(boolean collapsed) { |
|
||||||
this.collapsed = collapsed; |
public void setCollapsed(boolean collapsed) { |
||||||
} |
this.collapsed = collapsed; |
||||||
|
} |
||||||
/** |
|
||||||
* 自定义的tableEditor类 |
/** |
||||||
*/ |
* 自定义的tableEditor类 |
||||||
public class BeanTableModel extends DefaultTableModel { |
*/ |
||||||
public BeanTableModel() { |
public class BeanTableModel extends DefaultTableModel { |
||||||
super(cellData,headers); |
public BeanTableModel() { |
||||||
} |
super(cellData, headers); |
||||||
|
} |
||||||
@Override |
|
||||||
public int getRowCount() { |
@Override |
||||||
if (isCollapsed()) { |
public int getRowCount() { |
||||||
return 1; |
if (isCollapsed()) { |
||||||
} |
return 1; |
||||||
return cellData.length; |
} |
||||||
} |
return cellData.length; |
||||||
|
} |
||||||
@Override |
|
||||||
public int getColumnCount() { |
@Override |
||||||
return 1; |
public int getColumnCount() { |
||||||
} |
return 1; |
||||||
|
} |
||||||
|
|
||||||
@Override |
|
||||||
public Object getValueAt(int row, int column) { |
@Override |
||||||
if (row >= getRowCount() || column >= getColumnCount()) { |
public Object getValueAt(int row, int column) { |
||||||
return null; |
if (row >= getRowCount() || column >= getColumnCount()) { |
||||||
} |
return null; |
||||||
if (row == 0) { |
} |
||||||
return (isCollapsed()? "+" : "-") + cellData[row][0]; |
if (row == 0) { |
||||||
} |
return (isCollapsed() ? "+" : "-") + cellData[row][0]; |
||||||
|
} |
||||||
return cellData[row][0]; |
|
||||||
} |
return cellData[row][0]; |
||||||
|
} |
||||||
@Override |
|
||||||
public String getColumnName(int column) { |
@Override |
||||||
return headers[0]; |
public String getColumnName(int column) { |
||||||
} |
return headers[0]; |
||||||
|
} |
||||||
|
|
||||||
@Override |
|
||||||
public void setValueAt(Object aValue, int row, int column) { |
@Override |
||||||
if (row >= getRowCount() || column >= getColumnCount()) { |
public void setValueAt(Object aValue, int row, int column) { |
||||||
return; |
if (row >= getRowCount() || column >= getColumnCount()) { |
||||||
} |
return; |
||||||
if (aValue == null) { |
} |
||||||
cellData[row] = null; |
if (aValue == null) { |
||||||
return; |
cellData[row] = null; |
||||||
} |
return; |
||||||
cellData[row][0] = aValue.toString(); |
} |
||||||
} |
cellData[row][0] = aValue.toString(); |
||||||
|
} |
||||||
/** |
|
||||||
* 是否可编辑 |
/** |
||||||
* @param row 行号 |
* 是否可编辑 |
||||||
* @param column 列号 |
* |
||||||
* @return 是否可编辑 |
* @param row 行号 |
||||||
*/ |
* @param column 列号 |
||||||
public boolean isCellEditable(int row, int column) { |
* @return 是否可编辑 |
||||||
return false; |
*/ |
||||||
} |
public boolean isCellEditable(int row, int column) { |
||||||
|
return false; |
||||||
} |
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
} |
} |
@ -1,366 +1,372 @@ |
|||||||
package com.fr.design.mainframe; |
package com.fr.design.mainframe; |
||||||
|
|
||||||
import com.fr.base.BaseUtils; |
import com.fr.base.BaseUtils; |
||||||
import com.fr.design.ExtraDesignClassManager; |
import com.fr.design.ExtraDesignClassManager; |
||||||
import com.fr.design.designer.beans.events.DesignerEditListener; |
import com.fr.design.designer.beans.events.DesignerEditListener; |
||||||
import com.fr.design.designer.beans.events.DesignerEvent; |
import com.fr.design.designer.beans.events.DesignerEvent; |
||||||
import com.fr.design.designer.creator.XCreator; |
import com.fr.design.designer.creator.XCreator; |
||||||
import com.fr.design.designer.creator.XCreatorUtils; |
import com.fr.design.designer.creator.XCreatorUtils; |
||||||
import com.fr.design.designer.creator.XLayoutContainer; |
import com.fr.design.designer.creator.XLayoutContainer; |
||||||
import com.fr.design.designer.creator.XWParameterLayout; |
import com.fr.design.designer.creator.XWParameterLayout; |
||||||
import com.fr.design.designer.properties.EventPropertyTable; |
import com.fr.design.designer.properties.EventPropertyTable; |
||||||
import com.fr.design.designer.properties.WidgetPropertyTable; |
import com.fr.design.designer.properties.WidgetPropertyTable; |
||||||
import com.fr.design.fun.WidgetPropertyUIProvider; |
import com.fr.design.fun.WidgetPropertyUIProvider; |
||||||
import com.fr.design.gui.frpane.UITabbedPane; |
import com.fr.design.gui.frpane.UITabbedPane; |
||||||
import com.fr.design.gui.icontainer.UIScrollPane; |
import com.fr.design.gui.icontainer.UIScrollPane; |
||||||
import com.fr.design.gui.itable.AbstractPropertyTable; |
import com.fr.design.gui.itable.AbstractPropertyTable; |
||||||
import com.fr.design.layout.FRGUIPaneFactory; |
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
import com.fr.form.ui.Widget; |
import com.fr.form.ui.Widget; |
||||||
import com.fr.general.Inter; |
import com.fr.general.Inter; |
||||||
import com.fr.stable.ArrayUtils; |
import com.fr.stable.ArrayUtils; |
||||||
|
|
||||||
import javax.swing.*; |
import javax.swing.*; |
||||||
import javax.swing.border.LineBorder; |
import javax.swing.border.LineBorder; |
||||||
import javax.swing.table.JTableHeader; |
import javax.swing.table.JTableHeader; |
||||||
import java.awt.*; |
import java.awt.*; |
||||||
import java.util.ArrayList; |
import java.util.ArrayList; |
||||||
import java.util.List; |
import java.util.List; |
||||||
import java.util.Set; |
import java.util.Set; |
||||||
|
|
||||||
/** |
/** |
||||||
* 控件属性表绘制 |
* 控件属性表绘制 |
||||||
* Modified by fanglei |
* Modified by fanglei |
||||||
*/ |
*/ |
||||||
public class WidgetPropertyPane extends FormDockView implements BaseWidgetPropertyPane { |
public class WidgetPropertyPane extends FormDockView implements BaseWidgetPropertyPane { |
||||||
|
|
||||||
private static final String PARA = "para"; |
private static final String PARA = "para"; |
||||||
private static final String BODY = "body"; |
private static final String BODY = "body"; |
||||||
private WidgetPropertyTable propertyTable; // 控件的属性表
|
private WidgetPropertyTable propertyTable; // 控件的属性表
|
||||||
private EventPropertyTable eventTable; // 控件的事件表
|
private EventPropertyTable eventTable; // 控件的事件表
|
||||||
private List<AbstractPropertyTable> widgetPropertyTables; // 这个变量应该是保存控件拓展的属性tab
|
private List<AbstractPropertyTable> widgetPropertyTables; // 这个变量应该是保存控件拓展的属性tab
|
||||||
private FormDesigner designer; // 当前designer
|
private FormDesigner designer; // 当前designer
|
||||||
private UIScrollPane psp; // 用来装载属性表table的容器
|
private UIScrollPane psp; // 用来装载属性表table的容器
|
||||||
private UIScrollPane esp; //用来装载事件table的容器
|
private UIScrollPane esp; //用来装载事件table的容器
|
||||||
private JPanel wsp; // 装载移动端tab的容器,包括移动端属性表和控件拓展的移动端属性表
|
private JPanel wsp; // 装载移动端tab的容器,包括移动端属性表和控件拓展的移动端属性表
|
||||||
private MobileParaWidgetTable mobileParaWidgetTable; // 参数面板的移动端属性tab(和body的移动端属性tab区别是没有标签名column)
|
private MobileParaWidgetTable mobileParaWidgetTable; // 参数面板的移动端属性tab(和body的移动端属性tab区别是没有标签名column)
|
||||||
private MobileWidgetTable mobileWidgetTable; // body的移动端属性tab
|
private MobileWidgetTable mobileWidgetTable; // body的移动端属性tab
|
||||||
private UIScrollPane downPanel; // 这个滚动容器是用于装载centerPane的
|
private UIScrollPane downPanel; // 这个滚动容器是用于装载centerPane的
|
||||||
private JPanel centerPane; // 此centerPane采用的是cardLayout布局,装载着mobileWidgetTable和mobileBodyWidgetTable
|
private JPanel centerPane; // 此centerPane采用的是cardLayout布局,装载着mobileWidgetTable和mobileBodyWidgetTable
|
||||||
private CardLayout cardLayout; // 卡片布局,选中参数面板时显示mobileWidgetTable,选中body时显示mobileBodyWidgetTable
|
private CardLayout cardLayout; // 卡片布局,选中参数面板时显示mobileWidgetTable,选中body时显示mobileBodyWidgetTable
|
||||||
private JTableHeader header;//把表头单独get出来作为一个组件
|
private JTableHeader header;//把表头单独get出来作为一个组件
|
||||||
|
|
||||||
public static WidgetPropertyPane getInstance() { |
public static WidgetPropertyPane getInstance() { |
||||||
if (HOLDER.singleton == null) { |
if (HOLDER.singleton == null) { |
||||||
HOLDER.singleton = new WidgetPropertyPane(); |
HOLDER.singleton = new WidgetPropertyPane(); |
||||||
} |
} |
||||||
return HOLDER.singleton; |
return HOLDER.singleton; |
||||||
} |
} |
||||||
|
|
||||||
public static WidgetPropertyPane getInstance(FormDesigner formEditor) { |
public static WidgetPropertyPane getInstance(FormDesigner formEditor) { |
||||||
HOLDER.singleton.setEditingFormDesigner(formEditor); |
HOLDER.singleton.setEditingFormDesigner(formEditor); |
||||||
HOLDER.singleton.refreshDockingView(); |
HOLDER.singleton.refreshDockingView(); |
||||||
return HOLDER.singleton; |
return HOLDER.singleton; |
||||||
} |
} |
||||||
|
|
||||||
private static class HOLDER { |
private static class HOLDER { |
||||||
private static WidgetPropertyPane singleton = new WidgetPropertyPane(); |
private static WidgetPropertyPane singleton = new WidgetPropertyPane(); |
||||||
} |
} |
||||||
|
|
||||||
private WidgetPropertyPane() { |
private WidgetPropertyPane() { |
||||||
setLayout(FRGUIPaneFactory.createBorderLayout()); |
setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
public String getViewTitle() { |
public String getViewTitle() { |
||||||
return Inter.getLocText("Form-Widget_Property_Table"); |
return Inter.getLocText("Form-Widget_Property_Table"); |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
public Icon getViewIcon() { |
public Icon getViewIcon() { |
||||||
return BaseUtils.readIcon("/com/fr/design/images/m_report/attributes.png"); |
return BaseUtils.readIcon("/com/fr/design/images/m_report/attributes.png"); |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
/** |
/** |
||||||
* 绘制属性表tab |
* 绘制属性表tab |
||||||
*/ |
*/ |
||||||
public void refreshDockingView() { |
public void refreshDockingView() { |
||||||
designer = this.getEditingFormDesigner(); |
designer = this.getEditingFormDesigner(); |
||||||
removeAll(); |
removeAll(); |
||||||
if (designer == null) { |
if (designer == null) { |
||||||
clearDockingView(); |
clearDockingView(); |
||||||
return; |
return; |
||||||
} |
} |
||||||
widgetPropertyTables = new ArrayList<AbstractPropertyTable>(); |
widgetPropertyTables = new ArrayList<AbstractPropertyTable>(); |
||||||
|
|
||||||
//依次创建属性表、事件表、移动端表,再将它们整合到TabPane中去
|
//依次创建属性表、事件表、移动端表,再将它们整合到TabPane中去
|
||||||
this.createPropertyTable(); |
this.createPropertyTable(); |
||||||
this.createEventTable(); |
this.createEventTable(); |
||||||
this.createMobileWidgetTable(); |
this.createMobileWidgetTable(); |
||||||
this.createTabPane(); |
this.createTabPane(); |
||||||
|
|
||||||
this.initTables(); |
this.initTables(); |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 初始化属性表,事件表,移动端拓展的属性表 |
* 初始化属性表,事件表,移动端拓展的属性表 |
||||||
*/ |
*/ |
||||||
private void initTables() { |
private void initTables() { |
||||||
propertyTable.initPropertyGroups(null); |
propertyTable.initPropertyGroups(null); |
||||||
eventTable.refresh(); |
eventTable.refresh(); |
||||||
for (AbstractPropertyTable propertyTable : widgetPropertyTables) { |
for (AbstractPropertyTable propertyTable : widgetPropertyTables) { |
||||||
propertyTable.initPropertyGroups(designer); |
propertyTable.initPropertyGroups(designer); |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 创建属性表table |
* 创建属性表table |
||||||
*/ |
*/ |
||||||
private void createPropertyTable() { |
private void createPropertyTable() { |
||||||
propertyTable = new WidgetPropertyTable(designer); |
propertyTable = new WidgetPropertyTable(designer); |
||||||
designer.addDesignerEditListener(new WidgetPropertyDesignerAdapter(propertyTable)); |
designer.addDesignerEditListener(new WidgetPropertyDesignerAdapter(propertyTable)); |
||||||
propertyTable.setBorder(null); |
propertyTable.setBorder(null); |
||||||
psp = new UIScrollPane(propertyTable); // 用来装载属性表table
|
psp = new UIScrollPane(propertyTable); // 用来装载属性表table
|
||||||
psp.setBorder(null); |
psp.setBorder(null); |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 创建事件表(事件选项卡不是JTable) |
* 创建事件表(事件选项卡不是JTable) |
||||||
*/ |
*/ |
||||||
private void createEventTable() { |
private void createEventTable() { |
||||||
eventTable = new EventPropertyTable(designer); |
eventTable = new EventPropertyTable(designer); |
||||||
designer.addDesignerEditListener(new EventPropertyDesignerAdapter(eventTable)); |
designer.addDesignerEditListener(new EventPropertyDesignerAdapter(eventTable)); |
||||||
eventTable.setBorder(null); |
eventTable.setBorder(null); |
||||||
esp = new UIScrollPane(eventTable); //用来装载事件table
|
esp = new UIScrollPane(eventTable); //用来装载事件table
|
||||||
esp.setBorder(null); |
esp.setBorder(null); |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 创建移动端控件列表 |
* 创建移动端控件列表 |
||||||
*/ |
*/ |
||||||
private void createMobileWidgetTable() { |
private void createMobileWidgetTable() { |
||||||
//加上表头后,这里不再使用borderLayout布局,而采用BoxLayout布局
|
//加上表头后,这里不再使用borderLayout布局,而采用BoxLayout布局
|
||||||
wsp = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); |
wsp = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); |
||||||
wsp.setBorder(null); |
wsp.setBorder(null); |
||||||
mobileParaWidgetTable = new MobileParaWidgetTable(designer); |
mobileParaWidgetTable = new MobileParaWidgetTable(designer); |
||||||
mobileWidgetTable = new MobileWidgetTable(designer); |
mobileWidgetTable = new MobileWidgetTable(designer); |
||||||
designer.addDesignerEditListener(new mobileWidgetDesignerAdapter()); |
designer.addDesignerEditListener(new mobileWidgetDesignerAdapter()); |
||||||
centerPane = FRGUIPaneFactory.createCardLayout_S_Pane(); |
centerPane = FRGUIPaneFactory.createCardLayout_S_Pane(); |
||||||
cardLayout = (CardLayout) centerPane.getLayout(); |
cardLayout = (CardLayout) centerPane.getLayout(); |
||||||
centerPane.add(mobileParaWidgetTable, PARA);// 采用卡片布局的容器必须指定卡片名字,如果没有卡片名字
|
centerPane.add(mobileParaWidgetTable, PARA); |
||||||
// 就会出现:Exception in thread "main" java.lang.IllegalArgumentException:
|
// 采用卡片布局的容器必须指定卡片名字,如果没有卡片名字
|
||||||
// cannot add to layout: constraint must be a string
|
// 就会出现:Exception in thread "main" java.lang.IllegalArgumentException:
|
||||||
// 第二个参数代表卡片的名字。后来show方法调用时通过名字找到要显示的卡片
|
// cannot add to layout: constraint must be a string
|
||||||
centerPane.add(mobileWidgetTable, BODY); //这两句代码,是把JTable放到一个JPanel中去了,表头不会显示,
|
// 第二个参数代表卡片的名字。后来show方法调用时通过名字找到要显示的卡片
|
||||||
//只有放到JScrollPanel中去表头才能正常显示,这就是MobileWidgetTable中定义了表头却没有显示的原因!
|
centerPane.add(mobileWidgetTable, BODY); //这两句代码,是把JTable放到一个JPanel中去了,表头不会显示,
|
||||||
//解决方案:MobileWidgetTable实在无法直接放到JScrollPanel中去的时候,应该把表头get出来单独作为一个组件显示
|
//只有放到JScrollPanel中去表头才能正常显示,这就是MobileWidgetTable中定义了表头却没有显示的原因!
|
||||||
|
//解决方案:MobileWidgetTable实在无法直接放到JScrollPanel中去的时候,应该把表头get出来单独作为一个组件显示
|
||||||
if(hasSelectParaPane(designer)){ |
|
||||||
cardLayout.show(centerPane,PARA); |
if (hasSelectParaPane(designer)) { |
||||||
header = mobileParaWidgetTable.getTableHeader(); |
cardLayout.show(centerPane, PARA); |
||||||
} else { |
header = mobileParaWidgetTable.getTableHeader(); |
||||||
cardLayout.show(centerPane,BODY); |
} else { |
||||||
header = mobileWidgetTable.getTableHeader(); |
cardLayout.show(centerPane, BODY); |
||||||
} |
header = mobileWidgetTable.getTableHeader(); |
||||||
downPanel = new UIScrollPane(centerPane); |
} |
||||||
downPanel.setBorder(new LineBorder(Color.GRAY)); |
downPanel = new UIScrollPane(centerPane); |
||||||
|
downPanel.setBorder(new LineBorder(Color.GRAY)); |
||||||
//获取拓展移动端属性tab
|
|
||||||
WidgetPropertyUIProvider[] widgetAttrProviders = getExtraPropertyUIProviders(); |
//获取拓展移动端属性tab
|
||||||
|
WidgetPropertyUIProvider[] widgetAttrProviders = getExtraPropertyUIProviders(); |
||||||
addWidgetAttr(widgetAttrProviders); |
|
||||||
} |
addWidgetAttr(widgetAttrProviders); |
||||||
|
} |
||||||
/** |
|
||||||
* 将属性表,事件表,移动端控件列表整合到TabPane里面去 |
/** |
||||||
*/ |
* 将属性表,事件表,移动端控件列表整合到TabPane里面去 |
||||||
private void createTabPane() { |
*/ |
||||||
UITabbedPane tabbedPane = new UITabbedPane(); // tab选项卡容器
|
private void createTabPane() { |
||||||
initTabPane(tabbedPane); |
UITabbedPane tabbedPane = new UITabbedPane(); // tab选项卡容器
|
||||||
add(tabbedPane, BorderLayout.CENTER); |
initTabPane(tabbedPane); |
||||||
} |
add(tabbedPane, BorderLayout.CENTER); |
||||||
|
} |
||||||
/** |
|
||||||
* 获取当前控件扩展的属性tab |
/** |
||||||
* 来源有两个: |
* 获取当前控件扩展的属性tab |
||||||
* 1, 各个控件从各自的Xcreator里扩展(例如手机重布局的tab就是从Xcreator中扩展的); |
* 来源有两个: |
||||||
* 2, 所有的控件从插件里扩展. |
* 1, 各个控件从各自的Xcreator里扩展(例如手机重布局的tab就是从Xcreator中扩展的); |
||||||
* |
* 2, 所有的控件从插件里扩展. |
||||||
* @return 扩展的tab |
* |
||||||
*/ |
* @return 扩展的tab |
||||||
private WidgetPropertyUIProvider[] getExtraPropertyUIProviders() { |
*/ |
||||||
FormSelection selection = designer.getSelectionModel().getSelection(); |
private WidgetPropertyUIProvider[] getExtraPropertyUIProviders() { |
||||||
WidgetPropertyUIProvider[] embeddedPropertyUIProviders = null; |
FormSelection selection = designer.getSelectionModel().getSelection(); |
||||||
if (selection != null && selection.getSelectedCreator() != null) { |
WidgetPropertyUIProvider[] embeddedPropertyUIProviders = null; |
||||||
embeddedPropertyUIProviders = selection.getSelectedCreator().getWidgetPropertyUIProviders(); |
if (selection != null && selection.getSelectedCreator() != null) { |
||||||
} |
embeddedPropertyUIProviders = selection.getSelectedCreator().getWidgetPropertyUIProviders(); |
||||||
Set<WidgetPropertyUIProvider> set = ExtraDesignClassManager.getInstance().getArray(WidgetPropertyUIProvider.XML_TAG); |
} |
||||||
return ArrayUtils.addAll(embeddedPropertyUIProviders, set.toArray(new WidgetPropertyUIProvider[set.size()])); |
Set<WidgetPropertyUIProvider> set = ExtraDesignClassManager.getInstance().getArray(WidgetPropertyUIProvider.XML_TAG); |
||||||
} |
return ArrayUtils.addAll(embeddedPropertyUIProviders, set.toArray(new WidgetPropertyUIProvider[set.size()])); |
||||||
|
} |
||||||
/** |
|
||||||
* 判断是将拓展的tab放入属性表还是将原来的tab放入属性表 |
/** |
||||||
* @param widgetAttrProviders 拓展的tab |
* 判断是将拓展的tab放入属性表还是将原来的tab放入属性表 |
||||||
*/ |
* |
||||||
private void addWidgetAttr(WidgetPropertyUIProvider[] widgetAttrProviders) { |
* @param widgetAttrProviders 拓展的tab |
||||||
if (widgetAttrProviders.length == 0) { // 判断有没有拓展的tab,没有就使用原来的
|
*/ |
||||||
wsp.add(header); |
private void addWidgetAttr(WidgetPropertyUIProvider[] widgetAttrProviders) { |
||||||
wsp.add(downPanel); |
if (widgetAttrProviders.length == 0) { // 判断有没有拓展的tab,没有就使用原来的
|
||||||
} else { |
wsp.add(header); |
||||||
for (WidgetPropertyUIProvider widgetAttrProvider : widgetAttrProviders) { |
wsp.add(downPanel); |
||||||
AbstractPropertyTable propertyTable = widgetAttrProvider.createWidgetAttrTable(); |
} else { |
||||||
widgetPropertyTables.add(propertyTable); |
for (WidgetPropertyUIProvider widgetAttrProvider : widgetAttrProviders) { |
||||||
designer.addDesignerEditListener(new WidgetPropertyDesignerAdapter(propertyTable)); |
AbstractPropertyTable propertyTable = widgetAttrProvider.createWidgetAttrTable(); |
||||||
UIScrollPane uiScrollPane = new UIScrollPane(getExtraBodyTable(propertyTable)); |
widgetPropertyTables.add(propertyTable); |
||||||
wsp.add(uiScrollPane); |
designer.addDesignerEditListener(new WidgetPropertyDesignerAdapter(propertyTable)); |
||||||
} |
UIScrollPane uiScrollPane = new UIScrollPane(getExtraBodyTable(propertyTable)); |
||||||
} |
wsp.add(uiScrollPane); |
||||||
} |
} |
||||||
|
} |
||||||
/** |
} |
||||||
* 如果是body的拓展属性表,那么要额外加上一张控件顺序表 |
|
||||||
* @return |
/** |
||||||
*/ |
* 如果是body的拓展属性表,那么要额外加上一张控件顺序表 |
||||||
private Component getExtraBodyTable(AbstractPropertyTable abstractPropertyTable) { |
* |
||||||
Widget selection = designer.getSelectionModel().getSelection().getSelectedCreator().toData(); |
* @return |
||||||
if (selection.getWidgetName().equals("body")) { |
*/ |
||||||
JPanel jPanel = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); |
private Component getExtraBodyTable(AbstractPropertyTable abstractPropertyTable) { |
||||||
jPanel.add(abstractPropertyTable); |
Widget selection = designer.getSelectionModel().getSelection().getSelectedCreator().toData(); |
||||||
MobileWidgetTable mobileWidgetTable = new MobileWidgetTable(designer); |
if (selection.getWidgetName().equals("body")) { |
||||||
jPanel.add(mobileWidgetTable.getTableHeader()); |
JPanel jPanel = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); |
||||||
jPanel.add(mobileWidgetTable); |
jPanel.add(abstractPropertyTable); |
||||||
return jPanel; |
MobileWidgetTable mobileWidgetTable = new MobileWidgetTable(designer); |
||||||
} |
jPanel.add(mobileWidgetTable.getTableHeader()); |
||||||
return abstractPropertyTable; |
jPanel.add(mobileWidgetTable); |
||||||
} |
return jPanel; |
||||||
|
} |
||||||
private void initTabPane(UITabbedPane tabbedPane) { |
return abstractPropertyTable; |
||||||
tabbedPane.setOpaque(true); |
} |
||||||
tabbedPane.setBorder(null); |
|
||||||
tabbedPane.setTabPlacement(SwingConstants.BOTTOM); |
private void initTabPane(UITabbedPane tabbedPane) { |
||||||
tabbedPane.addTab(Inter.getLocText("FR-Designer_Properties"), psp); |
tabbedPane.setOpaque(true); |
||||||
tabbedPane.addTab(Inter.getLocText("FR-Designer_Event"), esp); |
tabbedPane.setBorder(null); |
||||||
tabbedPane.addTab(Inter.getLocText("FR-Widget_Mobile_Terminal"), wsp); |
tabbedPane.setTabPlacement(SwingConstants.BOTTOM); |
||||||
} |
tabbedPane.addTab(Inter.getLocText("FR-Designer_Properties"), psp); |
||||||
|
tabbedPane.addTab(Inter.getLocText("FR-Designer_Event"), esp); |
||||||
//
|
tabbedPane.addTab(Inter.getLocText("FR-Widget_Mobile_Terminal"), wsp); |
||||||
/** |
} |
||||||
* 选中的组件是否在参数面板里 |
|
||||||
* @param designer 设计器 |
|
||||||
* @return 是则返回true |
/** |
||||||
*/ |
* 选中的组件是否在参数面板里 |
||||||
public boolean hasSelectParaPane(FormDesigner designer){ |
* |
||||||
XCreator xCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); |
* @param designer 设计器 |
||||||
if(xCreator == null){ |
* @return 是则返回true |
||||||
xCreator = designer.getRootComponent(); |
*/ |
||||||
} |
public boolean hasSelectParaPane(FormDesigner designer) { |
||||||
XLayoutContainer container = XCreatorUtils.getHotspotContainer(xCreator); |
XCreator xCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); |
||||||
return xCreator.acceptType(XWParameterLayout.class) || container.acceptType(XWParameterLayout.class); |
if (xCreator == null) { |
||||||
} |
xCreator = designer.getRootComponent(); |
||||||
|
} |
||||||
public void setEditingFormDesigner(BaseFormDesigner editor) { |
XLayoutContainer container = XCreatorUtils.getHotspotContainer(xCreator); |
||||||
FormDesigner fd = (FormDesigner) editor; |
//TODO container可能为空,引发空指针异常
|
||||||
super.setEditingFormDesigner(fd); |
return xCreator.acceptType(XWParameterLayout.class) || container.acceptType(XWParameterLayout.class); |
||||||
} |
} |
||||||
|
|
||||||
private void clearDockingView() { |
public void setEditingFormDesigner(BaseFormDesigner editor) { |
||||||
propertyTable = null; |
FormDesigner fd = (FormDesigner) editor; |
||||||
eventTable = null; |
super.setEditingFormDesigner(fd); |
||||||
if (widgetPropertyTables != null) { |
} |
||||||
widgetPropertyTables.clear(); |
|
||||||
} |
private void clearDockingView() { |
||||||
JScrollPane psp = new JScrollPane(); |
propertyTable = null; |
||||||
psp.setBorder(null); |
eventTable = null; |
||||||
this.add(psp, BorderLayout.CENTER); |
if (widgetPropertyTables != null) { |
||||||
} |
widgetPropertyTables.clear(); |
||||||
|
} |
||||||
/** |
JScrollPane psp = new JScrollPane(); |
||||||
* 属性表监听界面事件(编辑,删除,选中,改变大小) |
psp.setBorder(null); |
||||||
*/ |
this.add(psp, BorderLayout.CENTER); |
||||||
private class WidgetPropertyDesignerAdapter implements DesignerEditListener { |
} |
||||||
AbstractPropertyTable propertyTable; |
|
||||||
|
/** |
||||||
WidgetPropertyDesignerAdapter(AbstractPropertyTable propertyTable) { |
* 属性表监听界面事件(编辑,删除,选中,改变大小) |
||||||
this.propertyTable = propertyTable; |
*/ |
||||||
} |
private class WidgetPropertyDesignerAdapter implements DesignerEditListener { |
||||||
|
AbstractPropertyTable propertyTable; |
||||||
@Override |
|
||||||
public void fireCreatorModified(DesignerEvent evt) { |
WidgetPropertyDesignerAdapter(AbstractPropertyTable propertyTable) { |
||||||
if (evt.getCreatorEventID() == DesignerEvent.CREATOR_EDITED |
this.propertyTable = propertyTable; |
||||||
|| evt.getCreatorEventID() == DesignerEvent.CREATOR_DELETED |
} |
||||||
|| evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) { |
|
||||||
propertyTable.initPropertyGroups(designer); |
@Override |
||||||
} else if (evt.getCreatorEventID() == DesignerEvent.CREATOR_RESIZED) { |
public void fireCreatorModified(DesignerEvent evt) { |
||||||
repaint(); |
if (evt.getCreatorEventID() == DesignerEvent.CREATOR_EDITED |
||||||
} |
|| evt.getCreatorEventID() == DesignerEvent.CREATOR_DELETED |
||||||
} |
|| evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) { |
||||||
|
propertyTable.initPropertyGroups(designer); |
||||||
@Override |
} else if (evt.getCreatorEventID() == DesignerEvent.CREATOR_RESIZED) { |
||||||
public boolean equals(Object o) { |
repaint(); |
||||||
return o instanceof WidgetPropertyDesignerAdapter && ((WidgetPropertyDesignerAdapter) o).propertyTable == this.propertyTable; |
} |
||||||
} |
} |
||||||
} |
|
||||||
|
@Override |
||||||
/** |
public boolean equals(Object o) { |
||||||
* 事件表监听界面事件(编辑,选中) |
return o instanceof WidgetPropertyDesignerAdapter && ((WidgetPropertyDesignerAdapter) o).propertyTable == this.propertyTable; |
||||||
*/ |
} |
||||||
private class EventPropertyDesignerAdapter implements DesignerEditListener { |
} |
||||||
EventPropertyTable propertyTable; |
|
||||||
|
/** |
||||||
EventPropertyDesignerAdapter(EventPropertyTable eventTable) { |
* 事件表监听界面事件(编辑,选中) |
||||||
this.propertyTable = eventTable; |
*/ |
||||||
} |
private class EventPropertyDesignerAdapter implements DesignerEditListener { |
||||||
|
EventPropertyTable propertyTable; |
||||||
@Override |
|
||||||
public void fireCreatorModified(DesignerEvent evt) { |
EventPropertyDesignerAdapter(EventPropertyTable eventTable) { |
||||||
if (evt.getCreatorEventID() == DesignerEvent.CREATOR_EDITED |
this.propertyTable = eventTable; |
||||||
|| evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) { |
} |
||||||
propertyTable.refresh(); |
|
||||||
} |
@Override |
||||||
} |
public void fireCreatorModified(DesignerEvent evt) { |
||||||
|
if (evt.getCreatorEventID() == DesignerEvent.CREATOR_EDITED |
||||||
@Override |
|| evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) { |
||||||
public boolean equals(Object o) { |
propertyTable.refresh(); |
||||||
return o instanceof EventPropertyDesignerAdapter; |
} |
||||||
} |
} |
||||||
} |
|
||||||
|
@Override |
||||||
/** |
public boolean equals(Object o) { |
||||||
* 移动端属性表监听界面事件(改变大小,编辑,选中,增加控件) |
return o instanceof EventPropertyDesignerAdapter; |
||||||
*/ |
} |
||||||
private class mobileWidgetDesignerAdapter implements DesignerEditListener { |
} |
||||||
|
|
||||||
mobileWidgetDesignerAdapter() { |
/** |
||||||
} |
* 移动端属性表监听界面事件(改变大小,编辑,选中,增加控件) |
||||||
|
*/ |
||||||
/** |
private class mobileWidgetDesignerAdapter implements DesignerEditListener { |
||||||
* 响应界面改变事件 |
|
||||||
* @param evt 事件 |
mobileWidgetDesignerAdapter() { |
||||||
*/ |
} |
||||||
public void fireCreatorModified(DesignerEvent evt) { |
|
||||||
if (evt.getCreatorEventID() == DesignerEvent.CREATOR_RESIZED |
/** |
||||||
|| evt.getCreatorEventID() == DesignerEvent.CREATOR_EDITED |
* 响应界面改变事件 |
||||||
|| evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED |
* |
||||||
|| evt.getCreatorEventID() == DesignerEvent.CREATOR_ADDED) { |
* @param evt 事件 |
||||||
int value = downPanel.getVerticalScrollBar().getValue(); |
*/ |
||||||
if(hasSelectParaPane(getEditingFormDesigner())){ |
public void fireCreatorModified(DesignerEvent evt) { |
||||||
cardLayout.show(centerPane,PARA); |
if (evt.getCreatorEventID() == DesignerEvent.CREATOR_RESIZED |
||||||
mobileParaWidgetTable.refreshData(); |
|| evt.getCreatorEventID() == DesignerEvent.CREATOR_EDITED |
||||||
} else { |
|| evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED |
||||||
cardLayout.show(centerPane,BODY); |
|| evt.getCreatorEventID() == DesignerEvent.CREATOR_ADDED) { |
||||||
mobileWidgetTable.refreshData(); |
int value = downPanel.getVerticalScrollBar().getValue(); |
||||||
} |
if (hasSelectParaPane(getEditingFormDesigner())) { |
||||||
//出现滚动条
|
cardLayout.show(centerPane, PARA); |
||||||
downPanel.doLayout(); |
mobileParaWidgetTable.refreshData(); |
||||||
//控件列表选中某组件,触发表单中选中控件,选中事件又触发列表刷新,滚动条回到0
|
} else { |
||||||
//此处设置滚动条值为刷新前
|
cardLayout.show(centerPane, BODY); |
||||||
downPanel.getVerticalScrollBar().setValue(value); |
mobileWidgetTable.refreshData(); |
||||||
} |
} |
||||||
} |
//出现滚动条
|
||||||
} |
downPanel.doLayout(); |
||||||
|
//控件列表选中某组件,触发表单中选中控件,选中事件又触发列表刷新,滚动条回到0
|
||||||
@Override |
//此处设置滚动条值为刷新前
|
||||||
public Location preferredLocation() { |
downPanel.getVerticalScrollBar().setValue(value); |
||||||
return Location.WEST_BELOW; |
} |
||||||
} |
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Location preferredLocation() { |
||||||
|
return Location.WEST_BELOW; |
||||||
|
} |
||||||
} |
} |
@ -0,0 +1,42 @@ |
|||||||
|
package com.fr.design.mainframe.templateinfo; |
||||||
|
|
||||||
|
import com.fr.form.main.Form; |
||||||
|
import com.fr.form.ui.container.WLayout; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by plough on 2017/3/17. |
||||||
|
*/ |
||||||
|
public class JFormProcessInfo extends TemplateProcessInfo<Form> { |
||||||
|
public JFormProcessInfo(Form form) { |
||||||
|
super(form); |
||||||
|
} |
||||||
|
|
||||||
|
// 获取模板类型
|
||||||
|
public int getReportType() { |
||||||
|
return 2; |
||||||
|
} |
||||||
|
|
||||||
|
// 获取模板格子数
|
||||||
|
public int getCellCount() { |
||||||
|
return 0; |
||||||
|
} |
||||||
|
// 获取模板悬浮元素个数
|
||||||
|
public int getFloatCount() { |
||||||
|
return 0; |
||||||
|
} |
||||||
|
// 获取模板聚合块个数
|
||||||
|
public int getBlockCount() { |
||||||
|
return 0; |
||||||
|
} |
||||||
|
// 获取模板控件数
|
||||||
|
public int getWidgetCount() { |
||||||
|
int widgetCount = 0; |
||||||
|
for (int i = 0; i < template.getContainer().getWidgetCount(); i++) { |
||||||
|
WLayout wl = (WLayout) template.getContainer().getWidget(i); |
||||||
|
widgetCount += wl.getWidgetCount(); |
||||||
|
} |
||||||
|
int a = 1; |
||||||
|
int b = 2; |
||||||
|
return widgetCount; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,57 @@ |
|||||||
|
package com.fr.design.mainframe.widget.accessibles; |
||||||
|
|
||||||
|
import com.fr.design.dialog.BasicDialog; |
||||||
|
import com.fr.design.dialog.DialogActionAdapter; |
||||||
|
import com.fr.design.gui.core.WidgetOption; |
||||||
|
import com.fr.design.mainframe.FormWebWidgetConstants; |
||||||
|
import com.fr.design.mainframe.widget.editors.ElementCaseToolBarPane; |
||||||
|
import com.fr.design.mainframe.widget.wrappers.ElementCaseToolBarWrapper; |
||||||
|
import com.fr.form.web.FormToolBarManager; |
||||||
|
import com.fr.stable.ArrayUtils; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.Arrays; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by harry on 2017-2-23. |
||||||
|
*/ |
||||||
|
public class AccessibleElementCaseToolBarEditor extends UneditableAccessibleEditor { |
||||||
|
private ElementCaseToolBarPane pane; |
||||||
|
|
||||||
|
public AccessibleElementCaseToolBarEditor() { |
||||||
|
super(new ElementCaseToolBarWrapper()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void showEditorPane() { |
||||||
|
if (pane == null) { |
||||||
|
pane = new ElementCaseToolBarPane(); |
||||||
|
pane.setDefaultToolBar(getDefaultToolBarManager(), getToolBarInstance()); |
||||||
|
} |
||||||
|
BasicDialog dlg = pane.showToolBarWindow(SwingUtilities.getWindowAncestor(this), new DialogActionAdapter() { |
||||||
|
|
||||||
|
@Override |
||||||
|
public void doOk() { |
||||||
|
setValue(pane.updateBean()); |
||||||
|
fireStateChanged(); |
||||||
|
} |
||||||
|
}); |
||||||
|
FormToolBarManager[] managers = (FormToolBarManager[]) getValue(); |
||||||
|
pane.setCheckBoxSelected(ArrayUtils.isNotEmpty(managers)); |
||||||
|
pane.populateBean((FormToolBarManager[]) getValue()); |
||||||
|
dlg.setVisible(true); |
||||||
|
} |
||||||
|
|
||||||
|
private FormToolBarManager getDefaultToolBarManager() { |
||||||
|
return FormToolBarManager.createDefaultToolBar(); |
||||||
|
} |
||||||
|
|
||||||
|
private WidgetOption[] getToolBarInstance() { |
||||||
|
List<WidgetOption> defaultOptions = Arrays.asList(FormWebWidgetConstants.getFormElementCaseToolBarInstance()); |
||||||
|
List<WidgetOption> options = new ArrayList<WidgetOption>(); |
||||||
|
options.addAll(defaultOptions); |
||||||
|
return options.toArray(new WidgetOption[options.size()]); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,13 @@ |
|||||||
|
package com.fr.design.mainframe.widget.editors; |
||||||
|
|
||||||
|
import com.fr.design.mainframe.widget.accessibles.AccessibleElementCaseToolBarEditor; |
||||||
|
import com.fr.design.mainframe.widget.accessibles.AccessiblePropertyEditor; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by harry on 2017-2-23. |
||||||
|
*/ |
||||||
|
public class ElementCaseToolBarEditor extends AccessiblePropertyEditor { |
||||||
|
public ElementCaseToolBarEditor() { |
||||||
|
super(new AccessibleElementCaseToolBarEditor()); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,304 @@ |
|||||||
|
package com.fr.design.mainframe.widget.editors; |
||||||
|
|
||||||
|
import com.fr.design.beans.BasicBeanPane; |
||||||
|
import com.fr.design.gui.core.WidgetOption; |
||||||
|
import com.fr.design.gui.ibutton.UIButton; |
||||||
|
import com.fr.design.gui.icheckbox.UICheckBox; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.mainframe.DesignerContext; |
||||||
|
import com.fr.design.mainframe.FormSettingToolBar; |
||||||
|
import com.fr.design.mainframe.FormToolBarButton; |
||||||
|
import com.fr.design.mainframe.FormToolBarPane; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.form.web.FormToolBarManager; |
||||||
|
import com.fr.form.web.Location; |
||||||
|
import com.fr.general.IOUtils; |
||||||
|
import com.fr.general.Inter; |
||||||
|
import com.fr.stable.ArrayUtils; |
||||||
|
import com.fr.stable.Constants; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import javax.swing.table.DefaultTableCellRenderer; |
||||||
|
import javax.swing.table.DefaultTableModel; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.ActionListener; |
||||||
|
import java.awt.event.MouseAdapter; |
||||||
|
import java.awt.event.MouseEvent; |
||||||
|
import java.awt.image.ImageObserver; |
||||||
|
import java.util.*; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by harry on 2017-2-23. |
||||||
|
*/ |
||||||
|
public class ElementCaseToolBarPane extends BasicBeanPane<FormToolBarManager[]> { |
||||||
|
private static final int COLUMN = 2; |
||||||
|
private int row = 6; |
||||||
|
private DefaultTableModel toolbarButtonTableModel; |
||||||
|
private JTable layoutTable; |
||||||
|
private UICheckBox isUseToolBarCheckBox = new UICheckBox(Inter.getLocText("FR-Designer_Use_ToolBar") + ":"); // 是否使用工具栏
|
||||||
|
|
||||||
|
private FormToolBarPane northToolBar; |
||||||
|
private FormToolBarPane southToolBar; |
||||||
|
private FormToolBarManager defaultToolBar; |
||||||
|
|
||||||
|
|
||||||
|
public ElementCaseToolBarPane() { |
||||||
|
toolbarButtonTableModel = new TableModel(row ,COLUMN); |
||||||
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
JPanel north = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
UIButton defaultButton = new UIButton(Inter.getLocText("FR-Designer_Restore_Default")); |
||||||
|
// 恢复默认按钮
|
||||||
|
defaultButton.addActionListener(new ActionListener() { |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
northToolBar.removeButtonList(); |
||||||
|
northToolBar.removeAll(); |
||||||
|
southToolBar.removeButtonList(); |
||||||
|
southToolBar.removeAll(); |
||||||
|
if (defaultToolBar == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
FormToolBarManager toolBarManager = defaultToolBar; |
||||||
|
toolBarManager.setToolBarLocation(Location.createTopEmbedLocation()); |
||||||
|
FormToolBarManager[] tbm = new FormToolBarManager[] { toolBarManager }; |
||||||
|
populateBean(tbm); |
||||||
|
ElementCaseToolBarPane.this.repaint(); |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
north.add(isUseToolBarCheckBox, BorderLayout.WEST); |
||||||
|
JPanel aa = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); |
||||||
|
aa.add(defaultButton); |
||||||
|
north.add(aa, BorderLayout.CENTER); |
||||||
|
this.add(north, BorderLayout.NORTH); |
||||||
|
|
||||||
|
northToolBar = new FormToolBarPane(); |
||||||
|
northToolBar.setPreferredSize(new Dimension(ImageObserver.WIDTH, 26)); |
||||||
|
northToolBar.setBackground(Color.lightGray); |
||||||
|
|
||||||
|
UIButton topButton = new UIButton(IOUtils.readIcon("com/fr/design/images/arrow/arrow_up.png")); |
||||||
|
topButton.setBorder(null); |
||||||
|
topButton.setOpaque(false); |
||||||
|
topButton.setContentAreaFilled(false); |
||||||
|
topButton.setFocusPainted(false); |
||||||
|
topButton.setRequestFocusEnabled(false); |
||||||
|
topButton.addActionListener(new ActionListener() { |
||||||
|
|
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
if (isSelectedtable()) { |
||||||
|
WidgetOption no = (WidgetOption)layoutTable.getValueAt(layoutTable.getSelectedRow(), layoutTable.getSelectedColumn()); |
||||||
|
Widget widget = no.createWidget(); |
||||||
|
FormToolBarButton tb = new FormToolBarButton(no.optionIcon(), widget); |
||||||
|
tb.setNameOption(no); |
||||||
|
northToolBar.add(tb); |
||||||
|
northToolBar.validate(); |
||||||
|
northToolBar.repaint(); |
||||||
|
} else { |
||||||
|
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Designer_ChooseOneButton")); |
||||||
|
} |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
UIButton downButton = new UIButton(IOUtils.readIcon("com/fr/design/images/arrow/arrow_down.png")); |
||||||
|
downButton.setBorder(null); |
||||||
|
downButton.setMargin(null); |
||||||
|
downButton.setOpaque(false); |
||||||
|
downButton.setContentAreaFilled(false); |
||||||
|
downButton.setFocusPainted(false); |
||||||
|
downButton.setRequestFocusEnabled(false); |
||||||
|
downButton.addActionListener(new ActionListener() { |
||||||
|
|
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
if (isSelectedtable()) { |
||||||
|
WidgetOption no = (WidgetOption)layoutTable.getValueAt(layoutTable.getSelectedRow(), layoutTable.getSelectedColumn()); |
||||||
|
Widget widget = no.createWidget(); |
||||||
|
FormToolBarButton tb = new FormToolBarButton(no.optionIcon(), widget); |
||||||
|
tb.setNameOption(no); |
||||||
|
southToolBar.add(tb); |
||||||
|
southToolBar.validate(); |
||||||
|
southToolBar.repaint(); |
||||||
|
} else { |
||||||
|
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Designer_ChooseOneButton")); |
||||||
|
} |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
initLayoutTable(); |
||||||
|
|
||||||
|
JPanel center = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
center.setBackground(Color.white); |
||||||
|
center.add(topButton, BorderLayout.NORTH); |
||||||
|
JPanel small = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
small.setBackground(Color.white); |
||||||
|
small.add(new UILabel(StringUtils.BLANK), BorderLayout.NORTH); |
||||||
|
small.add(layoutTable, BorderLayout.CENTER); |
||||||
|
center.add(small, BorderLayout.CENTER); |
||||||
|
center.add(downButton, BorderLayout.SOUTH); |
||||||
|
southToolBar = new FormToolBarPane(); |
||||||
|
southToolBar.setPreferredSize(new Dimension(ImageObserver.WIDTH, 26)); |
||||||
|
southToolBar.setBackground(Color.lightGray); |
||||||
|
JPanel movePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
JPanel northContentPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
FormSettingToolBar top = new FormSettingToolBar(Inter.getLocText("FR-Designer_ToolBar_Top"), northToolBar); |
||||||
|
northContentPane.add(top, BorderLayout.EAST); |
||||||
|
northContentPane.add(northToolBar, BorderLayout.CENTER); |
||||||
|
northContentPane.setBackground(Color.lightGray); |
||||||
|
|
||||||
|
JPanel southContentPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
FormSettingToolBar bottom = new FormSettingToolBar(Inter.getLocText("FR-Designer_ToolBar_Bottom"), southToolBar); |
||||||
|
southContentPane.add(bottom, BorderLayout.EAST); |
||||||
|
southContentPane.add(southToolBar, BorderLayout.CENTER); |
||||||
|
southContentPane.setBackground(Color.lightGray); |
||||||
|
|
||||||
|
movePane.add(northContentPane, BorderLayout.NORTH); |
||||||
|
movePane.add(center, BorderLayout.CENTER); |
||||||
|
movePane.add(southContentPane, BorderLayout.SOUTH); |
||||||
|
|
||||||
|
this.add(new JScrollPane(movePane), BorderLayout.CENTER); |
||||||
|
|
||||||
|
isUseToolBarCheckBox.setSelected(false); |
||||||
|
} |
||||||
|
|
||||||
|
private void initLayoutTable() { |
||||||
|
layoutTable = new JTable(toolbarButtonTableModel); |
||||||
|
layoutTable.setDefaultRenderer(Object.class, tableRenderer); |
||||||
|
layoutTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
||||||
|
layoutTable.setColumnSelectionAllowed(false); |
||||||
|
layoutTable.setRowSelectionAllowed(false); |
||||||
|
layoutTable.setBackground(Color.white); |
||||||
|
int columnWidth = Integer.parseInt(Inter.getLocText("FR-Designer_LayoutTable_Column_Width")); |
||||||
|
for (int i = 0; i < layoutTable.getColumnModel().getColumnCount(); i++) { |
||||||
|
layoutTable.getColumnModel().getColumn(i).setPreferredWidth(columnWidth); |
||||||
|
} |
||||||
|
layoutTable.addMouseListener(new MouseAdapter() { |
||||||
|
public void mouseClicked(MouseEvent e) { |
||||||
|
if (e.getClickCount() > 1 && !SwingUtilities.isRightMouseButton(e)) { |
||||||
|
WidgetOption no = (WidgetOption)layoutTable.getValueAt(layoutTable.getSelectedRow(), layoutTable.getSelectedColumn()); |
||||||
|
Widget widget = no.createWidget(); |
||||||
|
FormToolBarButton tb = new FormToolBarButton(no.optionIcon(), widget); |
||||||
|
tb.setNameOption(no); |
||||||
|
northToolBar.add(tb); |
||||||
|
northToolBar.validate(); |
||||||
|
northToolBar.repaint(); |
||||||
|
} |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
private boolean isSelectedtable() { |
||||||
|
for (int i = 0; i < layoutTable.getColumnCount(); i++) { |
||||||
|
if (layoutTable.isColumnSelected(i)) { |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 是否被选中 |
||||||
|
* @return 同上 |
||||||
|
*/ |
||||||
|
public boolean isUseToolbar() { |
||||||
|
return this.isUseToolBarCheckBox.isSelected(); |
||||||
|
} |
||||||
|
|
||||||
|
public void setDefaultToolBar(FormToolBarManager defaultToolBar, WidgetOption[] buttonArray) { |
||||||
|
this.defaultToolBar = defaultToolBar; |
||||||
|
if (buttonArray != null) { |
||||||
|
for (int i = 0; i < buttonArray.length; i++) { |
||||||
|
toolbarButtonTableModel.setValueAt(buttonArray[i], i % row, i / row); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
DefaultTableCellRenderer tableRenderer = new DefaultTableCellRenderer() { |
||||||
|
@Override |
||||||
|
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { |
||||||
|
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); |
||||||
|
|
||||||
|
if (value instanceof WidgetOption) { |
||||||
|
WidgetOption nameOption = (WidgetOption)value; |
||||||
|
this.setText(nameOption.optionName()); |
||||||
|
|
||||||
|
Icon icon = nameOption.optionIcon(); |
||||||
|
if (icon != null) { |
||||||
|
this.setIcon(icon); |
||||||
|
} |
||||||
|
} |
||||||
|
if (value == null) { |
||||||
|
this.setText(StringUtils.EMPTY); |
||||||
|
this.setIcon(null); |
||||||
|
} |
||||||
|
return this; |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return Inter.getLocText(new String[]{"Form-EC_toolbar", "Set"}); |
||||||
|
} |
||||||
|
|
||||||
|
public void setCheckBoxSelected(boolean b) { |
||||||
|
this.isUseToolBarCheckBox.setSelected(b); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(FormToolBarManager[] toolBarManager) { |
||||||
|
if (ArrayUtils.isEmpty(toolBarManager)) { |
||||||
|
defaultToolBar.setToolBarLocation(Location.createTopEmbedLocation()); |
||||||
|
toolBarManager = new FormToolBarManager[] { defaultToolBar }; |
||||||
|
} |
||||||
|
if (ArrayUtils.isEmpty(toolBarManager)) { |
||||||
|
return; |
||||||
|
} |
||||||
|
for (int i = 0; i < toolBarManager.length; i++) { |
||||||
|
Location location = toolBarManager[i].getToolBarLocation(); |
||||||
|
if (location instanceof Location.Embed) { |
||||||
|
if (((Location.Embed)location).getPosition() == Constants.TOP) { |
||||||
|
northToolBar.populateBean(toolBarManager[i].getToolBar()); |
||||||
|
} else if (((Location.Embed)location).getPosition() == Constants.BOTTOM) { |
||||||
|
southToolBar.populateBean(toolBarManager[i].getToolBar()); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public FormToolBarManager[] updateBean() { |
||||||
|
if(!isUseToolbar()){ |
||||||
|
return new FormToolBarManager[0]; |
||||||
|
} |
||||||
|
List<FormToolBarManager> toolBarManagerList = new ArrayList<FormToolBarManager>(); |
||||||
|
if (!northToolBar.isEmpty()) { |
||||||
|
FormToolBarManager north = new FormToolBarManager(); |
||||||
|
north.setToolBar(northToolBar.updateBean()); |
||||||
|
north.setToolBarLocation(Location.createTopEmbedLocation()); |
||||||
|
toolBarManagerList.add(north); |
||||||
|
} |
||||||
|
|
||||||
|
if (!southToolBar.isEmpty()) { |
||||||
|
FormToolBarManager south = new FormToolBarManager(); |
||||||
|
south.setToolBar(southToolBar.updateBean()); |
||||||
|
south.setToolBarLocation(Location.createBottomEmbedLocation()); |
||||||
|
toolBarManagerList.add(south); |
||||||
|
} |
||||||
|
return toolBarManagerList.toArray(new FormToolBarManager[toolBarManagerList.size()]); |
||||||
|
} |
||||||
|
|
||||||
|
private class TableModel extends DefaultTableModel { |
||||||
|
public TableModel(int i, int j) { |
||||||
|
super(i, j); |
||||||
|
} |
||||||
|
|
||||||
|
// 禁止jtable的双击编辑功能
|
||||||
|
public boolean isCellEditable(int row, int column) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,34 @@ |
|||||||
|
package com.fr.design.mainframe.widget.wrappers; |
||||||
|
|
||||||
|
import com.fr.design.Exception.ValidationException; |
||||||
|
import com.fr.design.designer.properties.Decoder; |
||||||
|
import com.fr.design.designer.properties.Encoder; |
||||||
|
import com.fr.form.web.FormToolBarManager; |
||||||
|
import com.fr.general.Inter; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by harry on 2017-3-1. |
||||||
|
*/ |
||||||
|
public class ElementCaseToolBarWrapper implements Encoder, Decoder { |
||||||
|
@Override |
||||||
|
public Object decode(String txt) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void validate(String txt) throws ValidationException { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String encode(Object v) { |
||||||
|
if (v == null) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
FormToolBarManager[] toolBarManager = (FormToolBarManager[])v; |
||||||
|
if (toolBarManager.length != 0) { |
||||||
|
return Inter.getLocText("FR-Designer_Open"); |
||||||
|
} |
||||||
|
return Inter.getLocText("FR-Designer_Close"); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue