yaoh.wu
8 years ago
70 changed files with 9770 additions and 6791 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 +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,325 @@
|
||||
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.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 Set<String> removedTemplates; // 已经从 templateInfoList 中删除过的 id 列表,防止重复收集数据
|
||||
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; |
||||
|
||||
@SuppressWarnings("unchecked") |
||||
private TemplateInfoCollector() { |
||||
templateInfoList = new HashMap<>(); |
||||
removedTemplates = new ListSet<>(); |
||||
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 (Exception ex) { |
||||
FRLogger.getLogger().error(ex.getMessage(), ex); |
||||
} |
||||
} |
||||
return instance; |
||||
} |
||||
|
||||
private boolean shouldCollectInfo(T t) { |
||||
if (t.getTemplateID() == null || instance.removedTemplates.contains(t.getTemplateID())) { // 旧模板
|
||||
return false; |
||||
} |
||||
return DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv(); |
||||
} |
||||
|
||||
public void appendProcess(T t, String log) { |
||||
if (!shouldCollectInfo(t)) { |
||||
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(t)) { |
||||
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")); |
||||
} |
||||
} |
||||
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); |
||||
removedTemplates.add(key); |
||||
FRLogger.getLogger().info(key + " is removed..."); |
||||
FRLogger.getLogger().info("removedTemplates: " + removedTemplates); |
||||
} |
||||
|
||||
@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(); |
||||
|
||||
} |
@ -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); |
||||
|
||||
} |
||||
|
||||
|
||||
} |
@ -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()); |
||||
} |
||||
} |
||||
} |
@ -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); |
||||
|
||||
} |
@ -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