jeo
5 years ago
51 changed files with 1785 additions and 447 deletions
@ -0,0 +1,130 @@ |
|||||||
|
package com.fr.design.mainframe.burying.point; |
||||||
|
|
||||||
|
import com.fr.base.FRContext; |
||||||
|
import com.fr.base.io.XMLReadHelper; |
||||||
|
import com.fr.design.DesignerEnvManager; |
||||||
|
import com.fr.design.mainframe.template.info.SendHelper; |
||||||
|
import com.fr.log.FineLoggerFactory; |
||||||
|
import com.fr.stable.xml.XMLPrintWriter; |
||||||
|
import com.fr.stable.xml.XMLTools; |
||||||
|
import com.fr.stable.xml.XMLableReader; |
||||||
|
import com.fr.third.javax.xml.stream.XMLStreamException; |
||||||
|
import com.fr.third.org.apache.commons.io.FileUtils; |
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream; |
||||||
|
import java.io.File; |
||||||
|
import java.io.FileInputStream; |
||||||
|
import java.io.FileNotFoundException; |
||||||
|
import java.io.IOException; |
||||||
|
import java.io.InputStream; |
||||||
|
import java.nio.charset.StandardCharsets; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
import java.util.concurrent.ConcurrentHashMap; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Bjorn |
||||||
|
* @version 10.0 |
||||||
|
* Created by Bjorn on 2020-02-21 |
||||||
|
*/ |
||||||
|
public abstract class AbstractPointCollector<T extends AbstractPointInfo> implements BasePointCollector { |
||||||
|
|
||||||
|
protected Map<String, T> pointInfoMap; |
||||||
|
|
||||||
|
private static final int MAX_SIZE = 512 * 1024 * 1024; |
||||||
|
|
||||||
|
public AbstractPointCollector() { |
||||||
|
pointInfoMap = new ConcurrentHashMap<>(); |
||||||
|
loadFromFile(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取是否满足触发埋点的要求 |
||||||
|
*/ |
||||||
|
protected boolean shouldCollectInfo() { |
||||||
|
return FileUtils.sizeOf(getInfoFile()) <= MAX_SIZE && DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void sendPointInfo() { |
||||||
|
|
||||||
|
addIdleDayCount(); |
||||||
|
|
||||||
|
List<String> removeList = new ArrayList<>(); |
||||||
|
List<String> sendList = new ArrayList<>(); |
||||||
|
|
||||||
|
for (String key : pointInfoMap.keySet()) { |
||||||
|
AbstractPointInfo pointInfo = pointInfoMap.get(key); |
||||||
|
pointInfo.selectPoint(removeList, sendList); |
||||||
|
} |
||||||
|
|
||||||
|
// 发送记录
|
||||||
|
for (String key : sendList) { |
||||||
|
if(SendHelper.sendPointInfo(pointInfoMap.get(key))){ |
||||||
|
removeList.add(key); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// 清空记录
|
||||||
|
for (String key : removeList) { |
||||||
|
pointInfoMap.remove(key); |
||||||
|
} |
||||||
|
|
||||||
|
saveInfo(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 从文件中读取埋点信息 |
||||||
|
*/ |
||||||
|
protected void loadFromFile() { |
||||||
|
if (!getInfoFile().exists()) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
XMLableReader reader = null; |
||||||
|
try (InputStream in = new FileInputStream(getInfoFile())) { |
||||||
|
// XMLableReader 还是应该考虑实现 Closable 接口的,这样就能使用 try-with 语句了
|
||||||
|
reader = XMLReadHelper.createXMLableReader(in, XMLPrintWriter.XML_ENCODER); |
||||||
|
if (reader == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
reader.readXMLObject(this); |
||||||
|
} catch (FileNotFoundException e) { |
||||||
|
// do nothing
|
||||||
|
} catch (XMLStreamException | IOException e) { |
||||||
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||||
|
} finally { |
||||||
|
try { |
||||||
|
if (reader != null) { |
||||||
|
reader.close(); |
||||||
|
} |
||||||
|
} catch (XMLStreamException e) { |
||||||
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 保存埋点信息到文件中 |
||||||
|
*/ |
||||||
|
protected void saveInfo() { |
||||||
|
try { |
||||||
|
ByteArrayOutputStream out = new ByteArrayOutputStream(); |
||||||
|
XMLTools.writeOutputStreamXML(this, out); |
||||||
|
out.flush(); |
||||||
|
out.close(); |
||||||
|
String fileContent = new String(out.toByteArray(), StandardCharsets.UTF_8); |
||||||
|
FileUtils.writeStringToFile(getInfoFile(), fileContent, StandardCharsets.UTF_8); |
||||||
|
} catch (Exception ex) { |
||||||
|
FineLoggerFactory.getLogger().error(ex.getMessage()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取缓存文件存放路径 |
||||||
|
*/ |
||||||
|
protected abstract File getInfoFile(); |
||||||
|
|
||||||
|
protected abstract void addIdleDayCount(); |
||||||
|
} |
@ -0,0 +1,55 @@ |
|||||||
|
package com.fr.design.mainframe.burying.point; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Bjorn |
||||||
|
* @version 10.0 |
||||||
|
* Created by Bjorn on 2020-02-21 |
||||||
|
*/ |
||||||
|
public abstract class AbstractPointInfo implements BasePointInfo { |
||||||
|
|
||||||
|
protected int idleDayCount; // 到现在为止,埋点闲置的天数
|
||||||
|
|
||||||
|
@Override |
||||||
|
public void resetIdleDayCount() { |
||||||
|
this.idleDayCount = 0; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void addIdleDayCountByOne() { |
||||||
|
this.idleDayCount += 1; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 上传前判断该埋点,是否需要被上传,或者删除,或者什么都不做。 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void selectPoint(List<String> removeList, List<String> sendList) { |
||||||
|
//埋点还未完成,直接返回
|
||||||
|
if (!isComplete()) { |
||||||
|
return; |
||||||
|
} |
||||||
|
//属于测试模板,直接删除,否则发送信息
|
||||||
|
if (isTestTemplate()) { |
||||||
|
removeList.add(key()); |
||||||
|
} else { |
||||||
|
sendList.add(key()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 是否为测试模板 |
||||||
|
*/ |
||||||
|
protected abstract boolean isTestTemplate(); |
||||||
|
|
||||||
|
/** |
||||||
|
* 是否已经制作完成 |
||||||
|
*/ |
||||||
|
protected abstract boolean isComplete(); |
||||||
|
|
||||||
|
/** |
||||||
|
* 埋点记录的主键 |
||||||
|
*/ |
||||||
|
protected abstract String key(); |
||||||
|
} |
@ -0,0 +1,23 @@ |
|||||||
|
package com.fr.design.mainframe.burying.point; |
||||||
|
|
||||||
|
import com.fr.design.mainframe.template.info.TemplateProcessInfo; |
||||||
|
import com.fr.stable.xml.XMLReadable; |
||||||
|
import com.fr.stable.xml.XMLWriter; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Bjorn |
||||||
|
* @version 10.0 |
||||||
|
* Created by Bjorn on 2020-02-21 |
||||||
|
*/ |
||||||
|
public interface BasePointCollector extends XMLReadable, XMLWriter { |
||||||
|
|
||||||
|
/** |
||||||
|
* 发送埋点信息到服务器 |
||||||
|
*/ |
||||||
|
public void sendPointInfo(); |
||||||
|
|
||||||
|
/** |
||||||
|
* 保存埋点的信息到本地 |
||||||
|
*/ |
||||||
|
public void collectInfo(String templateID, String originID, TemplateProcessInfo processInfo, int timeConsume); |
||||||
|
} |
@ -0,0 +1,35 @@ |
|||||||
|
package com.fr.design.mainframe.burying.point; |
||||||
|
|
||||||
|
import com.fr.stable.xml.XMLReadable; |
||||||
|
import com.fr.stable.xml.XMLWriter; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Bjorn |
||||||
|
* @version 10.0 |
||||||
|
* Created by Bjorn on 2020-02-21 |
||||||
|
*/ |
||||||
|
public interface BasePointInfo extends XMLReadable, XMLWriter { |
||||||
|
|
||||||
|
/** |
||||||
|
* 重置埋点的未编辑天数 |
||||||
|
*/ |
||||||
|
void resetIdleDayCount(); |
||||||
|
|
||||||
|
/** |
||||||
|
* 增加一天埋点的未编辑天数 |
||||||
|
*/ |
||||||
|
void addIdleDayCountByOne(); |
||||||
|
|
||||||
|
/** |
||||||
|
* 上传前判断该埋点,是否需要被上传,或者删除,或者什么都不做。 |
||||||
|
*/ |
||||||
|
void selectPoint(List<String> removeList, List<String> sendList); |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取要上传的内容,key→上传路径,value→上传内容 |
||||||
|
*/ |
||||||
|
Map<String, String> getSendInfo(); |
||||||
|
} |
@ -0,0 +1,250 @@ |
|||||||
|
package com.fr.design.mainframe.chart.info; |
||||||
|
|
||||||
|
import com.fr.base.io.BaseBook; |
||||||
|
import com.fr.config.MarketConfig; |
||||||
|
import com.fr.design.DesignModelAdapter; |
||||||
|
import com.fr.design.DesignerEnvManager; |
||||||
|
import com.fr.design.file.HistoryTemplateListCache; |
||||||
|
import com.fr.design.mainframe.burying.point.AbstractPointInfo; |
||||||
|
import com.fr.general.CloudCenter; |
||||||
|
import com.fr.general.GeneralUtils; |
||||||
|
import com.fr.json.JSONObject; |
||||||
|
import com.fr.stable.ProductConstants; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
import com.fr.stable.xml.XMLPrintWriter; |
||||||
|
import com.fr.stable.xml.XMLableReader; |
||||||
|
import com.fr.third.joda.time.DateTime; |
||||||
|
|
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Bjorn |
||||||
|
* @version 10.0 |
||||||
|
* Created by Bjorn on 2020-02-17 |
||||||
|
*/ |
||||||
|
public class ChartInfo extends AbstractPointInfo { |
||||||
|
public static final String XML_TAG = "ChartInfo"; |
||||||
|
private static final String CHART_CONSUMING_URL = CloudCenter.getInstance().acquireUrlByKind("chartinfo.consuming") + "/single"; |
||||||
|
|
||||||
|
|
||||||
|
private static final String XML_CHART_CONSUMING_MAP = "chartConsumingMap"; |
||||||
|
private static final String ATTR_TEST_TEMPLATE = "testTemplate"; |
||||||
|
private static final String ATTR_DAY_COUNT = "day_count"; |
||||||
|
private static final String ATTR_USERNAME = "username"; |
||||||
|
private static final String ATTR_UUID = "uuid"; |
||||||
|
private static final String ATTR_ACTIVITYKEY = "activityKey"; |
||||||
|
private static final String ATTR_TEMPLATE_ID = "templateID"; |
||||||
|
private static final String ATTR_REPORT_TYPE = "type"; |
||||||
|
private static final String ATTR_CHART_ID = "chartId"; |
||||||
|
private static final String ATTR_CHART_TYPE = "chartType"; |
||||||
|
private static final String ATTR_CHART_CREATE_TIME = "chartCreateTime"; |
||||||
|
private static final String ATTR_CHART_TYPE_TIME = "chartTypeTime"; |
||||||
|
private static final String ATTR_CHART_PROPERTY_FIRST_TIME = "chartPropertyFirstTime"; |
||||||
|
private static final String ATTR_CHART_PROPERTY_END_TIME = "chartPropertyEndTime"; |
||||||
|
private static final String ATTR_JAR_TIME = "jarTime"; |
||||||
|
private static final String ATTR_VERSION = "version"; |
||||||
|
|
||||||
|
private static final int COMPLETE_DAY_COUNT = 3; // 判断图表是否可以上传的天数
|
||||||
|
|
||||||
|
private String chartId = StringUtils.EMPTY; |
||||||
|
|
||||||
|
private String templateId = StringUtils.EMPTY; |
||||||
|
|
||||||
|
private Map<String, String> chartConsumingMap = new HashMap<>(); |
||||||
|
|
||||||
|
private BaseBook book; |
||||||
|
|
||||||
|
private boolean testTemplate; |
||||||
|
|
||||||
|
private ChartInfo() { |
||||||
|
} |
||||||
|
|
||||||
|
private ChartInfo(String chartId, String templateId, BaseBook book) { |
||||||
|
this.chartId = chartId; |
||||||
|
this.templateId = templateId; |
||||||
|
this.book = book; |
||||||
|
} |
||||||
|
|
||||||
|
public String getChartId() { |
||||||
|
return chartId; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String key() { |
||||||
|
return chartId; |
||||||
|
} |
||||||
|
|
||||||
|
public String getTemplateId() { |
||||||
|
return templateId; |
||||||
|
} |
||||||
|
|
||||||
|
public void setTemplateId(String templateId) { |
||||||
|
this.templateId = templateId; |
||||||
|
this.chartConsumingMap.put(ATTR_TEMPLATE_ID, templateId); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public BaseBook getBook() { |
||||||
|
return book; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isTestTemplate() { |
||||||
|
return testTemplate; |
||||||
|
} |
||||||
|
|
||||||
|
public void setTestTemplate(boolean testTemplate) { |
||||||
|
this.testTemplate = testTemplate; |
||||||
|
} |
||||||
|
|
||||||
|
static ChartInfo newInstanceByRead(XMLableReader reader) { |
||||||
|
ChartInfo chartInfo = new ChartInfo(); |
||||||
|
reader.readXMLObject(chartInfo); |
||||||
|
return chartInfo; |
||||||
|
} |
||||||
|
|
||||||
|
public static ChartInfo newInstance(String chartId, String chartType) { |
||||||
|
return newInstance(chartId, chartType, null); |
||||||
|
} |
||||||
|
|
||||||
|
public static ChartInfo newInstance(String chartId, String chartType, String createTime) { |
||||||
|
HashMap<String, String> chartConsumingMap = new HashMap<>(); |
||||||
|
|
||||||
|
String username = MarketConfig.getInstance().getBbsUsername(); |
||||||
|
String uuid = DesignerEnvManager.getEnvManager().getUUID(); |
||||||
|
String activityKey = DesignerEnvManager.getEnvManager().getActivationKey(); |
||||||
|
|
||||||
|
BaseBook book = DesignModelAdapter.getCurrentModelAdapter().getBook(); |
||||||
|
String templateId = book.getTemplateID(); |
||||||
|
int reportType = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getProcessInfo().getReportType(); |
||||||
|
|
||||||
|
String typeTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss"); |
||||||
|
|
||||||
|
createTime = createTime == null ? typeTime : createTime; |
||||||
|
|
||||||
|
String jarTime = GeneralUtils.readBuildNO(); |
||||||
|
String version = ProductConstants.VERSION; |
||||||
|
chartConsumingMap.put(ATTR_USERNAME, username); |
||||||
|
chartConsumingMap.put(ATTR_UUID, uuid); |
||||||
|
chartConsumingMap.put(ATTR_ACTIVITYKEY, activityKey); |
||||||
|
chartConsumingMap.put(ATTR_TEMPLATE_ID, templateId); |
||||||
|
chartConsumingMap.put(ATTR_REPORT_TYPE, String.valueOf(reportType)); |
||||||
|
chartConsumingMap.put(ATTR_CHART_ID, chartId); |
||||||
|
chartConsumingMap.put(ATTR_CHART_TYPE, chartType); |
||||||
|
chartConsumingMap.put(ATTR_CHART_CREATE_TIME, createTime); |
||||||
|
chartConsumingMap.put(ATTR_CHART_TYPE_TIME, typeTime); |
||||||
|
chartConsumingMap.put(ATTR_CHART_PROPERTY_FIRST_TIME, ""); |
||||||
|
chartConsumingMap.put(ATTR_CHART_PROPERTY_END_TIME, ""); |
||||||
|
chartConsumingMap.put(ATTR_JAR_TIME, jarTime); |
||||||
|
chartConsumingMap.put(ATTR_VERSION, version); |
||||||
|
|
||||||
|
ChartInfo chartInfo = new ChartInfo(chartId, templateId, book); |
||||||
|
chartInfo.chartConsumingMap = chartConsumingMap; |
||||||
|
|
||||||
|
return chartInfo; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void writeXML(XMLPrintWriter writer) { |
||||||
|
writer.startTAG(XML_TAG); |
||||||
|
if (StringUtils.isNotEmpty(chartId)) { |
||||||
|
writer.attr(ATTR_CHART_ID, this.chartId); |
||||||
|
} |
||||||
|
if (StringUtils.isNotEmpty(templateId)) { |
||||||
|
writer.attr(ATTR_TEMPLATE_ID, this.templateId); |
||||||
|
} |
||||||
|
if (idleDayCount >= 0) { |
||||||
|
writer.attr(ATTR_DAY_COUNT, this.idleDayCount); |
||||||
|
} |
||||||
|
writer.attr(ATTR_TEST_TEMPLATE, this.testTemplate); |
||||||
|
writer.startTAG(XML_CHART_CONSUMING_MAP); |
||||||
|
writer.attr(ATTR_USERNAME, chartConsumingMap.get(ATTR_USERNAME)); |
||||||
|
writer.attr(ATTR_UUID, chartConsumingMap.get(ATTR_UUID)); |
||||||
|
writer.attr(ATTR_ACTIVITYKEY, chartConsumingMap.get(ATTR_ACTIVITYKEY)); |
||||||
|
writer.attr(ATTR_REPORT_TYPE, chartConsumingMap.get(ATTR_REPORT_TYPE)); |
||||||
|
writer.attr(ATTR_CHART_TYPE, chartConsumingMap.get(ATTR_CHART_TYPE)); |
||||||
|
writer.attr(ATTR_CHART_CREATE_TIME, chartConsumingMap.get(ATTR_CHART_CREATE_TIME)); |
||||||
|
writer.attr(ATTR_CHART_TYPE_TIME, chartConsumingMap.get(ATTR_CHART_TYPE_TIME)); |
||||||
|
writer.attr(ATTR_CHART_PROPERTY_FIRST_TIME, chartConsumingMap.get(ATTR_CHART_PROPERTY_FIRST_TIME)); |
||||||
|
writer.attr(ATTR_CHART_PROPERTY_END_TIME, chartConsumingMap.get(ATTR_CHART_PROPERTY_END_TIME)); |
||||||
|
writer.attr(ATTR_JAR_TIME, chartConsumingMap.get(ATTR_JAR_TIME)); |
||||||
|
writer.attr(ATTR_VERSION, chartConsumingMap.get(ATTR_VERSION)); |
||||||
|
writer.end(); |
||||||
|
writer.end(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void readXML(XMLableReader reader) { |
||||||
|
|
||||||
|
if (!reader.isChildNode()) { |
||||||
|
idleDayCount = reader.getAttrAsInt(ATTR_DAY_COUNT, 0); |
||||||
|
chartId = reader.getAttrAsString(ATTR_CHART_ID, StringUtils.EMPTY); |
||||||
|
templateId = reader.getAttrAsString(ATTR_TEMPLATE_ID, StringUtils.EMPTY); |
||||||
|
testTemplate = reader.getAttrAsBoolean(ATTR_TEST_TEMPLATE, true); |
||||||
|
} else { |
||||||
|
String name = reader.getTagName(); |
||||||
|
if (XML_CHART_CONSUMING_MAP.equals(name)) { |
||||||
|
chartConsumingMap.put(ATTR_USERNAME, reader.getAttrAsString(ATTR_USERNAME, StringUtils.EMPTY)); |
||||||
|
chartConsumingMap.put(ATTR_UUID, reader.getAttrAsString(ATTR_UUID, StringUtils.EMPTY)); |
||||||
|
chartConsumingMap.put(ATTR_ACTIVITYKEY, reader.getAttrAsString(ATTR_ACTIVITYKEY, StringUtils.EMPTY)); |
||||||
|
chartConsumingMap.put(ATTR_TEMPLATE_ID, templateId); |
||||||
|
chartConsumingMap.put(ATTR_REPORT_TYPE, reader.getAttrAsString(ATTR_REPORT_TYPE, "0")); |
||||||
|
chartConsumingMap.put(ATTR_CHART_ID, chartId); |
||||||
|
chartConsumingMap.put(ATTR_CHART_TYPE, reader.getAttrAsString(ATTR_CHART_TYPE, StringUtils.EMPTY)); |
||||||
|
chartConsumingMap.put(ATTR_CHART_CREATE_TIME, reader.getAttrAsString(ATTR_CHART_CREATE_TIME, StringUtils.EMPTY)); |
||||||
|
chartConsumingMap.put(ATTR_CHART_TYPE_TIME, reader.getAttrAsString(ATTR_CHART_TYPE_TIME, StringUtils.EMPTY)); |
||||||
|
chartConsumingMap.put(ATTR_CHART_PROPERTY_FIRST_TIME, reader.getAttrAsString(ATTR_CHART_PROPERTY_FIRST_TIME, StringUtils.EMPTY)); |
||||||
|
chartConsumingMap.put(ATTR_CHART_PROPERTY_END_TIME, reader.getAttrAsString(ATTR_CHART_PROPERTY_END_TIME, StringUtils.EMPTY)); |
||||||
|
chartConsumingMap.put(ATTR_JAR_TIME, reader.getAttrAsString(ATTR_JAR_TIME, StringUtils.EMPTY)); |
||||||
|
chartConsumingMap.put(ATTR_VERSION, reader.getAttrAsString(ATTR_VERSION, "8.0")); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isComplete() { |
||||||
|
// 连续3天打开了设计器但是没有编辑
|
||||||
|
return idleDayCount > COMPLETE_DAY_COUNT; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Map<String, String> getSendInfo() { |
||||||
|
Map<String, String> sendMap = new HashMap<>(); |
||||||
|
sendMap.put(CHART_CONSUMING_URL, new JSONObject(chartConsumingMap).toString()); |
||||||
|
return sendMap; |
||||||
|
} |
||||||
|
|
||||||
|
public void updatePropertyTime() { |
||||||
|
String propertyTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss"); |
||||||
|
|
||||||
|
if (StringUtils.isEmpty(chartConsumingMap.get(ATTR_CHART_PROPERTY_FIRST_TIME))) { |
||||||
|
chartConsumingMap.put(ATTR_CHART_PROPERTY_FIRST_TIME, propertyTime); |
||||||
|
} |
||||||
|
chartConsumingMap.put(ATTR_CHART_PROPERTY_END_TIME, propertyTime); |
||||||
|
} |
||||||
|
|
||||||
|
public void updateChartType(String chartType) { |
||||||
|
String typeTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss"); |
||||||
|
|
||||||
|
chartConsumingMap.put(ATTR_CHART_TYPE_TIME, typeTime); |
||||||
|
chartConsumingMap.put(ATTR_CHART_TYPE, chartType); |
||||||
|
chartConsumingMap.put(ATTR_CHART_PROPERTY_FIRST_TIME, ""); |
||||||
|
chartConsumingMap.put(ATTR_CHART_PROPERTY_END_TIME, ""); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public ChartInfo clone() { |
||||||
|
ChartInfo chartInfo = new ChartInfo(); |
||||||
|
chartInfo.chartId = this.chartId; |
||||||
|
chartInfo.idleDayCount = this.idleDayCount; |
||||||
|
chartInfo.templateId = this.templateId; |
||||||
|
chartInfo.testTemplate = this.testTemplate; |
||||||
|
Map<String, String> chartConsumingMap = new HashMap<>(); |
||||||
|
for (Map.Entry<String, String> entry : this.chartConsumingMap.entrySet()) { |
||||||
|
chartConsumingMap.put(entry.getKey(), entry.getValue()); |
||||||
|
} |
||||||
|
chartInfo.chartConsumingMap = chartConsumingMap; |
||||||
|
return chartInfo; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,248 @@ |
|||||||
|
package com.fr.design.mainframe.chart.info; |
||||||
|
|
||||||
|
import com.fr.base.io.BaseBook; |
||||||
|
import com.fr.chartx.attr.ChartProvider; |
||||||
|
import com.fr.design.mainframe.burying.point.AbstractPointCollector; |
||||||
|
import com.fr.design.mainframe.template.info.TemplateInfo; |
||||||
|
import com.fr.design.mainframe.template.info.TemplateProcessInfo; |
||||||
|
import com.fr.general.ComparatorUtils; |
||||||
|
import com.fr.log.FineLoggerFactory; |
||||||
|
import com.fr.plugin.chart.vanchart.VanChart; |
||||||
|
import com.fr.stable.ProductConstants; |
||||||
|
import com.fr.stable.StableUtils; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
import com.fr.stable.xml.XMLPrintWriter; |
||||||
|
import com.fr.stable.xml.XMLableReader; |
||||||
|
import com.fr.third.joda.time.DateTime; |
||||||
|
|
||||||
|
import java.io.File; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Bjorn |
||||||
|
* @version 10.0 |
||||||
|
* Created by Bjorn on 2020-02-18 |
||||||
|
*/ |
||||||
|
public class ChartInfoCollector extends AbstractPointCollector<ChartInfo> { |
||||||
|
private static final String XML_TAG = "ChartInfoCollector"; |
||||||
|
private static final String XML_LAST_EDIT_DAY = "lastEditDay"; |
||||||
|
|
||||||
|
private static final String XML_CHART_INFO_LIST = "ChartInfoList"; |
||||||
|
private static final String XML_FILE_NAME = "chart.info"; |
||||||
|
|
||||||
|
private static ChartInfoCollector instance; |
||||||
|
|
||||||
|
private Map<String, ChartInfo> chartInfoCacheMap; |
||||||
|
|
||||||
|
private String lastEditDay; |
||||||
|
|
||||||
|
private ChartInfoCollector() { |
||||||
|
init(); |
||||||
|
} |
||||||
|
|
||||||
|
private void init() { |
||||||
|
chartInfoCacheMap = new HashMap<>(); |
||||||
|
} |
||||||
|
|
||||||
|
public static ChartInfoCollector getInstance() { |
||||||
|
if (instance == null) { |
||||||
|
instance = new ChartInfoCollector(); |
||||||
|
} |
||||||
|
return instance; |
||||||
|
} |
||||||
|
|
||||||
|
public void collection(ChartProvider chartProvider, String createTime) { |
||||||
|
if (chartProvider instanceof VanChart) { |
||||||
|
VanChart vanChart = (VanChart) chartProvider; |
||||||
|
collection(vanChart.getUuid(), vanChart.getID(), createTime); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 新建图表,保存状态 |
||||||
|
*/ |
||||||
|
public void collection(String chartId, String chartType, String createTime) { |
||||||
|
if (!shouldCollectInfo()) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
ChartInfo chartInfo = ChartInfo.newInstance(chartId, chartType, createTime); |
||||||
|
chartInfoCacheMap.put(chartId, chartInfo); |
||||||
|
} |
||||||
|
|
||||||
|
public void updateChartPropertyTime(ChartProvider chartProvider) { |
||||||
|
if (chartProvider instanceof VanChart) { |
||||||
|
VanChart vanChart = (VanChart) chartProvider; |
||||||
|
updateChartPropertyTime(vanChart.getUuid(), vanChart.getID()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 图表编辑,更新编辑时间 |
||||||
|
*/ |
||||||
|
public void updateChartPropertyTime(String chartId, String chartType) { |
||||||
|
if (!shouldCollectInfo()) { |
||||||
|
return; |
||||||
|
} |
||||||
|
ChartInfo chartInfo = getOrCreateChartInfo(chartId, chartType); |
||||||
|
|
||||||
|
//更新编辑时间
|
||||||
|
chartInfo.updatePropertyTime(); |
||||||
|
|
||||||
|
//重置计数
|
||||||
|
chartInfo.resetIdleDayCount(); |
||||||
|
} |
||||||
|
|
||||||
|
public void updateChartTypeTime(ChartProvider chartProvider) { |
||||||
|
if (chartProvider instanceof VanChart) { |
||||||
|
VanChart vanChart = (VanChart) chartProvider; |
||||||
|
updateChartTypeTime(vanChart.getUuid(), vanChart.getID()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 图表类型变化,更新类型和类型确认时间 |
||||||
|
*/ |
||||||
|
public void updateChartTypeTime(String chartId, String chartType) { |
||||||
|
if (!shouldCollectInfo()) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
ChartInfo chartInfo = getOrCreateChartInfo(chartId, chartType); |
||||||
|
|
||||||
|
//更新类型确认时间和类型
|
||||||
|
chartInfo.updateChartType(chartType); |
||||||
|
|
||||||
|
//重置计数
|
||||||
|
chartInfo.resetIdleDayCount(); |
||||||
|
} |
||||||
|
|
||||||
|
private ChartInfo getOrCreateChartInfo(String chartId, String chartType) { |
||||||
|
//缓存中有从缓存中拿
|
||||||
|
if (chartInfoCacheMap.containsKey(chartId)) { |
||||||
|
return chartInfoCacheMap.get(chartId); |
||||||
|
} |
||||||
|
//缓存中没有从文件中读取的信息中拷贝到缓存
|
||||||
|
if (pointInfoMap.containsKey(chartId)) { |
||||||
|
ChartInfo chartInfo = pointInfoMap.get(chartId).clone(); |
||||||
|
chartInfoCacheMap.put(chartId, chartInfo); |
||||||
|
return chartInfo; |
||||||
|
} |
||||||
|
//都有的话创建一个并加入到缓存中
|
||||||
|
ChartInfo chartInfo = ChartInfo.newInstance(chartId, chartType); |
||||||
|
chartInfoCacheMap.put(chartId, chartInfo); |
||||||
|
return chartInfo; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 保存模板的时候将该模板中的图表埋点信息保存 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void collectInfo(String templateId, String originID, TemplateProcessInfo processInfo, int timeConsume) { |
||||||
|
if (!shouldCollectInfo()) { |
||||||
|
return; |
||||||
|
} |
||||||
|
if (StringUtils.isEmpty(originID)) { |
||||||
|
originID = templateId; |
||||||
|
} |
||||||
|
boolean testTemplate = isTestTemplate(processInfo); |
||||||
|
|
||||||
|
for (ChartInfo chartInfo : pointInfoMap.values()) { |
||||||
|
if (originID.equals(chartInfo.getTemplateId())) { |
||||||
|
chartInfo.setTemplateId(templateId); |
||||||
|
chartInfo.setTestTemplate(testTemplate); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
for (ChartInfo chartInfo : chartInfoCacheMap.values()) { |
||||||
|
BaseBook book = chartInfo.getBook(); |
||||||
|
if ((book != null && templateId.equals(book.getTemplateID())) || |
||||||
|
originID.equals(chartInfo.getTemplateId())) { |
||||||
|
chartInfo.setTemplateId(templateId); |
||||||
|
chartInfo.setTestTemplate(testTemplate); |
||||||
|
pointInfoMap.put(chartInfo.getChartId(), chartInfo); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// 每次更新之后,都同步到暂存文件中
|
||||||
|
saveInfo(); |
||||||
|
} |
||||||
|
|
||||||
|
private boolean isTestTemplate(TemplateProcessInfo processInfo) { |
||||||
|
int reportType = processInfo.getReportType(); |
||||||
|
int cellCount = processInfo.getCellCount(); |
||||||
|
int floatCount = processInfo.getFloatCount(); |
||||||
|
int blockCount = processInfo.getBlockCount(); |
||||||
|
int widgetCount = processInfo.getWidgetCount(); |
||||||
|
|
||||||
|
return TemplateInfo.isTestTemplate(reportType, cellCount, floatCount, blockCount, widgetCount); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 更新 day_count:打开设计器却未编辑图表的连续日子 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
protected void addIdleDayCount() { |
||||||
|
// 判断今天是否第一次打开设计器,为了防止同一天内,多次 addIdleDayCount
|
||||||
|
String today = DateTime.now().toString("yyyy-MM-dd"); |
||||||
|
if (ComparatorUtils.equals(today, lastEditDay)) { |
||||||
|
return; |
||||||
|
} |
||||||
|
for (ChartInfo chartInfo : pointInfoMap.values()) { |
||||||
|
chartInfo.addIdleDayCountByOne(); |
||||||
|
} |
||||||
|
lastEditDay = today; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 获取缓存文件存放路径 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
protected File getInfoFile() { |
||||||
|
File file = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), XML_FILE_NAME)); |
||||||
|
try { |
||||||
|
if (!file.exists()) { |
||||||
|
file.createNewFile(); |
||||||
|
} |
||||||
|
} catch (Exception ex) { |
||||||
|
FineLoggerFactory.getLogger().error(ex.getMessage(), ex); |
||||||
|
} |
||||||
|
return file; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void readXML(XMLableReader reader) { |
||||||
|
if (reader.isChildNode()) { |
||||||
|
try { |
||||||
|
String name = reader.getTagName(); |
||||||
|
if (ChartInfo.XML_TAG.equals(name)) { |
||||||
|
ChartInfo chartInfo = ChartInfo.newInstanceByRead(reader); |
||||||
|
pointInfoMap.put(chartInfo.getChartId(), chartInfo); |
||||||
|
} else if (XML_LAST_EDIT_DAY.equals(name)) { |
||||||
|
lastEditDay = reader.getElementValue(); |
||||||
|
} |
||||||
|
} catch (Exception ex) { |
||||||
|
// 什么也不做,使用默认值
|
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void writeXML(XMLPrintWriter writer) { |
||||||
|
writer.startTAG(XML_TAG); |
||||||
|
|
||||||
|
writer.startTAG(XML_LAST_EDIT_DAY); |
||||||
|
writer.textNode(lastEditDay); |
||||||
|
writer.end(); |
||||||
|
|
||||||
|
writer.startTAG(XML_CHART_INFO_LIST); |
||||||
|
for (ChartInfo chartInfo : pointInfoMap.values()) { |
||||||
|
chartInfo.writeXML(writer); |
||||||
|
} |
||||||
|
writer.end(); |
||||||
|
|
||||||
|
writer.end(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,72 @@ |
|||||||
|
package com.fr.design.mainframe.mobile.ui; |
||||||
|
|
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.gui.ispinner.UISpinner; |
||||||
|
import com.fr.design.gui.itextfield.UIIntNumberField; |
||||||
|
import com.fr.design.gui.itextfield.UINumberField; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.mainframe.widget.UITitleSplitLine; |
||||||
|
import com.fr.form.ui.mobile.MobileCollapsedStyle; |
||||||
|
import com.fr.form.ui.mobile.MobileFormCollapsedStyle; |
||||||
|
|
||||||
|
import javax.swing.JPanel; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.awt.Dimension; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hades |
||||||
|
* @version 10.0 |
||||||
|
* Created by hades on 2020/2/13 |
||||||
|
*/ |
||||||
|
public class MobileCollapsedStyleExpandPane extends MobileCollapsedStylePane { |
||||||
|
|
||||||
|
private static final Dimension DEFAULT_SPINNER_SIZE = new Dimension(60, 24); |
||||||
|
|
||||||
|
private UISpinner rowSpinner; |
||||||
|
|
||||||
|
public MobileCollapsedStyleExpandPane() { |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
protected JPanel createLinePane() { |
||||||
|
UITitleSplitLine splitLine = new UITitleSplitLine(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Line_Number"), 520); |
||||||
|
splitLine.setPreferredSize(new Dimension(520, 20)); |
||||||
|
this.rowSpinner = new UISpinner(1, Integer.MAX_VALUE, 1, 1) { |
||||||
|
@Override |
||||||
|
protected UINumberField initNumberField(){ |
||||||
|
return new UIIntNumberField(); |
||||||
|
} |
||||||
|
}; |
||||||
|
rowSpinner.setPreferredSize(DEFAULT_SPINNER_SIZE); |
||||||
|
JPanel panel = new JPanel(); |
||||||
|
panel.setLayout(FRGUIPaneFactory.createBoxFlowLayout()); |
||||||
|
panel.add(new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Start_From"))); |
||||||
|
panel.add(rowSpinner); |
||||||
|
panel.add(new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Row_To_Fold"))); |
||||||
|
JPanel linePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
linePane.add(splitLine, BorderLayout.NORTH); |
||||||
|
linePane.add(panel, BorderLayout.CENTER); |
||||||
|
return linePane; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(MobileCollapsedStyle ob) { |
||||||
|
super.populateBean(ob); |
||||||
|
rowSpinner.setValue(((MobileFormCollapsedStyle) ob).getLineAttr().getNumber()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public MobileCollapsedStyle updateBean() { |
||||||
|
MobileCollapsedStyle style = super.updateBean(); |
||||||
|
((MobileFormCollapsedStyle) style).getLineAttr().setNumber((int) rowSpinner.getValue()); |
||||||
|
return style; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected MobileCollapsedStyle updateDiffBean() { |
||||||
|
return new MobileFormCollapsedStyle(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,145 @@ |
|||||||
|
package com.fr.design.mainframe.mobile.ui; |
||||||
|
|
||||||
|
import com.fr.design.beans.BasicBeanPane; |
||||||
|
import com.fr.design.constants.LayoutConstants; |
||||||
|
import com.fr.design.designer.IntervalConstants; |
||||||
|
import com.fr.design.gui.ibutton.ModeButtonGroup; |
||||||
|
import com.fr.design.gui.ibutton.UIRadioButton; |
||||||
|
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.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.layout.TableLayout; |
||||||
|
import com.fr.design.layout.TableLayoutHelper; |
||||||
|
import com.fr.design.layout.VerticalFlowLayout; |
||||||
|
import com.fr.design.mainframe.widget.UITitleSplitLine; |
||||||
|
import com.fr.design.style.color.NewColorSelectBox; |
||||||
|
import com.fr.design.utils.gui.GUICoreUtils; |
||||||
|
import com.fr.form.ui.mobile.CollapseState; |
||||||
|
import com.fr.form.ui.mobile.MobileChartCollapsedStyle; |
||||||
|
import com.fr.form.ui.mobile.MobileCollapsedStyle; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import javax.swing.border.TitledBorder; |
||||||
|
import javax.swing.event.ChangeEvent; |
||||||
|
import javax.swing.event.ChangeListener; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.awt.Component; |
||||||
|
import java.awt.Dimension; |
||||||
|
import java.awt.FlowLayout; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hades |
||||||
|
* @version 10.0 |
||||||
|
* Created by hades on 2020/2/13 |
||||||
|
*/ |
||||||
|
public class MobileCollapsedStylePane extends BasicBeanPane<MobileCollapsedStyle> { |
||||||
|
|
||||||
|
private UICheckBox showButtonCheck; |
||||||
|
private NewColorSelectBox buttonColorBox; |
||||||
|
private UITextField foldedTextFiled; |
||||||
|
private UITextField unfoldedTextFiled; |
||||||
|
private ModeButtonGroup<CollapseState> buttonGroup; |
||||||
|
|
||||||
|
|
||||||
|
public MobileCollapsedStylePane() { |
||||||
|
TitledBorder titledBorder = GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set"), null); |
||||||
|
VerticalFlowLayout layout = new VerticalFlowLayout(FlowLayout.LEADING, 0, 10); |
||||||
|
layout.setAlignLeft(true); |
||||||
|
this.setBorder(titledBorder); |
||||||
|
this.setLayout(layout); |
||||||
|
this.add(createLinePane()); |
||||||
|
this.add(createSettingPane()); |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel createSettingPane() { |
||||||
|
JPanel settingPane = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 0); |
||||||
|
UITitleSplitLine splitLine = new UITitleSplitLine(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Button"), 520); |
||||||
|
splitLine.setPreferredSize(new Dimension(520, 20)); |
||||||
|
UILabel showButtonLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Show_Button")); |
||||||
|
showButtonCheck = new UICheckBox(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Show_Button_On_Right")); |
||||||
|
showButtonCheck.setPreferredSize(new Dimension(140, 24)); |
||||||
|
UILabel buttonColorLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Button_Color")); |
||||||
|
buttonColorBox = new NewColorSelectBox(137); |
||||||
|
UILabel foldedLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Folded_Hint")); |
||||||
|
foldedTextFiled = new UITextField(); |
||||||
|
UILabel unfoldedLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_UnFolded_Hint")); |
||||||
|
unfoldedTextFiled = new UITextField(); |
||||||
|
UILabel defaultStateLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Default_State")); |
||||||
|
buttonGroup = new ModeButtonGroup<>(); |
||||||
|
UIRadioButton foldedButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Fold")); |
||||||
|
foldedButton.setSelected(true); |
||||||
|
UIRadioButton unfoldedButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Unfold")); |
||||||
|
buttonGroup.put(CollapseState.FOLDED, foldedButton); |
||||||
|
buttonGroup.put(CollapseState.UNFOLDED, unfoldedButton); |
||||||
|
JPanel flowLeftPane = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); |
||||||
|
flowLeftPane.add(foldedButton); |
||||||
|
flowLeftPane.add(unfoldedButton); |
||||||
|
Component[][] northComponents = new Component[][] { |
||||||
|
new Component[] {showButtonLabel, showButtonCheck} |
||||||
|
}; |
||||||
|
Component[][] southComponents = new Component[][] { |
||||||
|
new Component[] {defaultStateLabel, flowLeftPane} |
||||||
|
}; |
||||||
|
double f = TableLayout.FILL; |
||||||
|
double p = TableLayout.PREFERRED; |
||||||
|
double[] rowSize = {p, p, p, p, p}; |
||||||
|
double[] colSize = {p, f}; |
||||||
|
int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}}; |
||||||
|
Component[][] centerComponents = new Component[][] { |
||||||
|
new Component[] {buttonColorLabel, buttonColorBox}, |
||||||
|
new Component[] {foldedLabel, foldedTextFiled}, |
||||||
|
new Component[] {unfoldedLabel, unfoldedTextFiled}, |
||||||
|
}; |
||||||
|
JPanel northPane = TableLayoutHelper.createGapTableLayoutPane(northComponents, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W2, IntervalConstants.INTERVAL_L1); |
||||||
|
JPanel southPane = TableLayoutHelper.createGapTableLayoutPane(southComponents, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); |
||||||
|
final JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(centerComponents, rowSize, colSize, rowCount, LayoutConstants.HGAP_LARGE, LayoutConstants.VGAP_SMALL); |
||||||
|
JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
panel.add(northPane, BorderLayout.NORTH); |
||||||
|
panel.add(centerPane, BorderLayout.CENTER); |
||||||
|
panel.add(southPane, BorderLayout.SOUTH); |
||||||
|
settingPane.add(splitLine); |
||||||
|
settingPane.add(panel); |
||||||
|
showButtonCheck.addChangeListener(new ChangeListener() { |
||||||
|
@Override |
||||||
|
public void stateChanged(ChangeEvent e) { |
||||||
|
centerPane.setVisible(showButtonCheck.isSelected()); |
||||||
|
} |
||||||
|
}); |
||||||
|
return settingPane; |
||||||
|
} |
||||||
|
|
||||||
|
protected JPanel createLinePane() { |
||||||
|
return FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(MobileCollapsedStyle ob) { |
||||||
|
showButtonCheck.setSelected(ob.getCollapseButton().isShowButton()); |
||||||
|
buttonColorBox.setSelectObject(ob.getCollapseButton().getButtonColor()); |
||||||
|
foldedTextFiled.setText(ob.getCollapseButton().getFoldedHint()); |
||||||
|
unfoldedTextFiled.setText(ob.getCollapseButton().getUnfoldedHint()); |
||||||
|
buttonGroup.setSelectButton(ob.getCollapseButton().getDefaultState()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public MobileCollapsedStyle updateBean() { |
||||||
|
MobileCollapsedStyle style = updateDiffBean(); |
||||||
|
style.getCollapseButton().setShowButton(showButtonCheck.isSelected()); |
||||||
|
style.getCollapseButton().setButtonColor(buttonColorBox.getSelectObject()); |
||||||
|
style.getCollapseButton().setFoldedHint(foldedTextFiled.getText()); |
||||||
|
style.getCollapseButton().setUnfoldedHint(unfoldedTextFiled.getText()); |
||||||
|
style.getCollapseButton().setDefaultState(buttonGroup.getCurrentSelected()); |
||||||
|
return style; |
||||||
|
} |
||||||
|
|
||||||
|
protected MobileCollapsedStyle updateDiffBean() { |
||||||
|
return new MobileChartCollapsedStyle(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return Toolkit.i18nText("Fine-Design_Mobile_Collapse_Expand"); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,100 @@ |
|||||||
|
package com.fr.design.mainframe.mobile.ui; |
||||||
|
|
||||||
|
import com.fr.design.dialog.BasicDialog; |
||||||
|
import com.fr.design.dialog.BasicPane; |
||||||
|
import com.fr.design.dialog.DialogActionAdapter; |
||||||
|
import com.fr.design.file.HistoryTemplateListCache; |
||||||
|
import com.fr.design.gui.icombobox.UIComboBox; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.form.ui.mobile.MobileCollapsedStyle; |
||||||
|
import com.fr.general.ComparatorUtils; |
||||||
|
|
||||||
|
import javax.swing.SwingUtilities; |
||||||
|
import java.awt.Dimension; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.ActionListener; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hades |
||||||
|
* @version 10.0 |
||||||
|
* Created by hades on 2020/2/13 |
||||||
|
*/ |
||||||
|
public class MobileComboBoxDialogEditor extends BasicPane { |
||||||
|
|
||||||
|
private static final Dimension DEFAULT_DIMENSION = new Dimension(600, 400); |
||||||
|
private static final Dimension COMBOX_DIMENSION = new Dimension(135,20); |
||||||
|
private static final String NONE = Toolkit.i18nText("Fine-Design_Mobile_Collapse_None"); |
||||||
|
private static final String CUSTOM = Toolkit.i18nText("Fine-Design_Mobile_Collapse_Custom"); |
||||||
|
|
||||||
|
|
||||||
|
private MobileCollapsedStyle style; |
||||||
|
private MobileCollapsedStylePane stylePane; |
||||||
|
private UIComboBox comboBox; |
||||||
|
private ActionListener listener; |
||||||
|
|
||||||
|
public MobileComboBoxDialogEditor(MobileCollapsedStylePane stylePane) { |
||||||
|
this.stylePane = stylePane; |
||||||
|
this.comboBox = new UIComboBox(new Object[] {NONE, CUSTOM}); |
||||||
|
this.comboBox.setPreferredSize(COMBOX_DIMENSION); |
||||||
|
this.comboBox.setSelectedItem(NONE); |
||||||
|
listener = new ActionListener() { |
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
if (ComparatorUtils.equals(MobileComboBoxDialogEditor.this.comboBox.getSelectedItem(), CUSTOM)) { |
||||||
|
showEditorPane(); |
||||||
|
} |
||||||
|
} |
||||||
|
}; |
||||||
|
this.comboBox.addActionListener(listener); |
||||||
|
this.add(comboBox); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public boolean isSelectedCustom() { |
||||||
|
return ComparatorUtils.equals(CUSTOM, this.comboBox.getSelectedItem()); |
||||||
|
} |
||||||
|
|
||||||
|
public void setSelected(boolean selectedCustom) { |
||||||
|
this.comboBox.removeActionListener(listener); |
||||||
|
this.comboBox.setSelectedItem(selectedCustom ? CUSTOM : NONE); |
||||||
|
this.comboBox.addActionListener(listener); |
||||||
|
} |
||||||
|
|
||||||
|
private void showEditorPane() { |
||||||
|
stylePane.setPreferredSize(DEFAULT_DIMENSION); |
||||||
|
BasicDialog dialog = stylePane.showWindow(SwingUtilities.getWindowAncestor(this)); |
||||||
|
dialog.addDialogActionListener(new DialogActionAdapter() { |
||||||
|
@Override |
||||||
|
public void doOk() { |
||||||
|
MobileCollapsedStyle style = stylePane.updateBean(); |
||||||
|
style.setCollapsedWork(true); |
||||||
|
setStyle(style); |
||||||
|
MobileComboBoxDialogEditor.this.firePropertyChanged(); |
||||||
|
} |
||||||
|
}); |
||||||
|
stylePane.populateBean(getStyle()); |
||||||
|
dialog.setVisible(true); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
protected void firePropertyChanged() { |
||||||
|
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(); |
||||||
|
} |
||||||
|
|
||||||
|
public MobileCollapsedStyle getStyle() { |
||||||
|
return style; |
||||||
|
} |
||||||
|
|
||||||
|
public void setStyle(MobileCollapsedStyle style) { |
||||||
|
this.style = style; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
package com.fr.design.os.impl; |
||||||
|
|
||||||
|
import com.fr.general.GeneralContext; |
||||||
|
import junit.framework.TestCase; |
||||||
|
import org.junit.Assert; |
||||||
|
import org.junit.Test; |
||||||
|
|
||||||
|
import java.util.Locale; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hades |
||||||
|
* @version 10.0 |
||||||
|
* Created by hades on 2020/1/16 |
||||||
|
*/ |
||||||
|
public class SupportOSImplTest extends TestCase { |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testAutoPush() { |
||||||
|
Assert.assertTrue(SupportOSImpl.AUTOPUSHUPDATE.support()); |
||||||
|
GeneralContext.setLocale(Locale.TAIWAN); |
||||||
|
Assert.assertFalse(SupportOSImpl.AUTOPUSHUPDATE.support()); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,36 @@ |
|||||||
|
package com.fr.design.designer.properties.mobile; |
||||||
|
|
||||||
|
import com.fr.design.designer.creator.XCreator; |
||||||
|
import com.fr.design.dialog.BasicPane; |
||||||
|
import com.fr.design.fun.impl.AbstractWidgetPropertyUIProvider; |
||||||
|
import com.fr.design.gui.itable.AbstractPropertyTable; |
||||||
|
import com.fr.design.widget.ui.designer.mobile.MobileBookMarkDefinePane; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hades |
||||||
|
* @version 10.0 |
||||||
|
* Created by hades on 2020/2/12 |
||||||
|
*/ |
||||||
|
public class MobileBooKMarkUsePropertyUI extends AbstractWidgetPropertyUIProvider { |
||||||
|
|
||||||
|
private XCreator xCreator; |
||||||
|
|
||||||
|
public MobileBooKMarkUsePropertyUI(XCreator xCreator) { |
||||||
|
this.xCreator = xCreator; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public AbstractPropertyTable createWidgetAttrTable() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public BasicPane createWidgetAttrPane() { |
||||||
|
return new MobileBookMarkDefinePane(xCreator); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String tableTitle() { |
||||||
|
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Mobile_Attr"); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,62 @@ |
|||||||
|
package com.fr.design.widget.ui.designer.mobile; |
||||||
|
|
||||||
|
import com.fr.design.designer.creator.XCreator; |
||||||
|
import com.fr.design.foldablepane.UIExpandablePane; |
||||||
|
import com.fr.design.gui.frpane.AttributeChangeListener; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.mainframe.FormDesigner; |
||||||
|
import com.fr.design.widget.ui.designer.mobile.component.MobileBookMarkUsePane; |
||||||
|
|
||||||
|
import javax.swing.JPanel; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hades |
||||||
|
* @version 10.0 |
||||||
|
* Created by hades on 2020/2/12 |
||||||
|
*/ |
||||||
|
public class MobileBookMarkDefinePane extends MobileWidgetDefinePane { |
||||||
|
|
||||||
|
private XCreator xCreator; |
||||||
|
private MobileBookMarkUsePane mobileBookMarkUsePane; |
||||||
|
|
||||||
|
public MobileBookMarkDefinePane(XCreator xCreator) { |
||||||
|
this.xCreator = xCreator; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void initPropertyGroups(Object source) { |
||||||
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
this.mobileBookMarkUsePane = new MobileBookMarkUsePane(); |
||||||
|
UIExpandablePane uiExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, mobileBookMarkUsePane); |
||||||
|
panel.add(uiExpandablePane); |
||||||
|
this.add(panel, BorderLayout.NORTH); |
||||||
|
} |
||||||
|
|
||||||
|
private void bindListeners2Widgets() { |
||||||
|
reInitAllListeners(); |
||||||
|
AttributeChangeListener changeListener = new AttributeChangeListener() { |
||||||
|
@Override |
||||||
|
public void attributeChange() { |
||||||
|
update(); |
||||||
|
} |
||||||
|
}; |
||||||
|
this.addAttributeChangeListener(changeListener); |
||||||
|
} |
||||||
|
|
||||||
|
private void reInitAllListeners() { |
||||||
|
initListener(this); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populate(FormDesigner designer) { |
||||||
|
this.mobileBookMarkUsePane.populate(xCreator); |
||||||
|
this.bindListeners2Widgets(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void update() { |
||||||
|
this.mobileBookMarkUsePane.update(xCreator); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,86 @@ |
|||||||
|
package com.fr.design.widget.ui.designer.mobile.component; |
||||||
|
|
||||||
|
import com.fr.design.designer.IntervalConstants; |
||||||
|
import com.fr.design.designer.creator.XCreator; |
||||||
|
import com.fr.design.dialog.BasicPane; |
||||||
|
import com.fr.design.gui.icheckbox.UICheckBox; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.layout.TableLayout; |
||||||
|
import com.fr.design.layout.TableLayoutHelper; |
||||||
|
import com.fr.form.ui.container.WLayout; |
||||||
|
|
||||||
|
import javax.swing.BorderFactory; |
||||||
|
import javax.swing.JPanel; |
||||||
|
import javax.swing.event.ChangeEvent; |
||||||
|
import javax.swing.event.ChangeListener; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.awt.Color; |
||||||
|
import java.awt.Component; |
||||||
|
import java.awt.event.MouseAdapter; |
||||||
|
import java.awt.event.MouseEvent; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author hades |
||||||
|
* @version 10.0 |
||||||
|
* Created by hades on 2020/2/12 |
||||||
|
*/ |
||||||
|
public class MobileBookMarkUsePane extends BasicPane { |
||||||
|
|
||||||
|
private UICheckBox showHierarchicalBookmarksCheck; |
||||||
|
|
||||||
|
public MobileBookMarkUsePane() { |
||||||
|
initComponent(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private void initComponent() { |
||||||
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
this.showHierarchicalBookmarksCheck = new UICheckBox( |
||||||
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Show_BookMark"), true) { |
||||||
|
@Override |
||||||
|
protected void initListener() { |
||||||
|
this.addMouseListener(new MouseAdapter() { |
||||||
|
@Override |
||||||
|
public void mouseClicked(MouseEvent e) { |
||||||
|
attributeChange(); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
}; |
||||||
|
UILabel hintLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Show_BookMark_Hint")); |
||||||
|
hintLabel.setForeground(Color.GRAY); |
||||||
|
double f = TableLayout.FILL; |
||||||
|
double p = TableLayout.PREFERRED; |
||||||
|
double[] rowSize = {p, p}; |
||||||
|
double[] columnSize = {f}; |
||||||
|
int[][] rowCount = {{1}, {1}}; |
||||||
|
Component[][] components = new Component[][]{ |
||||||
|
new Component[]{this.showHierarchicalBookmarksCheck}, |
||||||
|
new Component[]{hintLabel} |
||||||
|
}; |
||||||
|
JPanel wrapPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
JPanel showBookMarkPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, |
||||||
|
IntervalConstants.INTERVAL_L1, |
||||||
|
IntervalConstants.INTERVAL_L1); |
||||||
|
showBookMarkPane.setBorder( |
||||||
|
BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, IntervalConstants.INTERVAL_L1, 0)); |
||||||
|
wrapPane.add(showBookMarkPane, BorderLayout.CENTER); |
||||||
|
this.add(showBookMarkPane, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
public void populate(XCreator xCreator) { |
||||||
|
WLayout wLayout = ((WLayout) xCreator.toData()); |
||||||
|
this.showHierarchicalBookmarksCheck.setSelected(wLayout.isShowBookmarks()); |
||||||
|
} |
||||||
|
|
||||||
|
public void update(XCreator xCreator) { |
||||||
|
WLayout wLayout = ((WLayout) xCreator.toData()); |
||||||
|
wLayout.setShowBookmarks(showHierarchicalBookmarksCheck.isSelected()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return "MobileBookMarkUsePane"; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue