Browse Source

Merge pull request #1709 in BA/design from ~XIAOXIA/design:feature/10.0 to feature/10.0

* commit 'c25a814af8b1a853f729e85a03a704bf8f8ba754':
  代码质量
  rt
  分离marketconfig
master
superman 7 years ago
parent
commit
f780ef4c89
  1. 4
      designer/src/com/fr/design/mainframe/ActiveKeyGenerator.java
  2. 8
      designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  3. 195
      designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java
  4. 305
      designer/src/com/fr/design/mainframe/bbs/UserInfoPane.java
  5. 5
      designer/src/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java
  6. 40
      designer_base/src/com/fr/design/bbs/BBSLoginUtils.java
  7. 50
      designer_base/src/com/fr/design/extra/LoginWebBridge.java
  8. 23
      designer_base/src/com/fr/design/extra/PluginFromStorePane.java
  9. 4
      designer_base/src/com/fr/design/extra/PluginOperateUtils.java
  10. 21
      designer_base/src/com/fr/design/extra/PluginUpdatePane.java
  11. 6
      designer_base/src/com/fr/design/extra/PluginWebBridge.java
  12. 152
      designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java

4
designer/src/com/fr/design/mainframe/ActiveKeyGenerator.java

@ -1,5 +1,5 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.config.ServerConfig; import com.fr.config.MarketConfig;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.general.SiteCenter; import com.fr.general.SiteCenter;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
@ -101,7 +101,7 @@ public class ActiveKeyGenerator {
HashMap<String, String> para = new HashMap<String, String>(); HashMap<String, String> para = new HashMap<String, String>();
para.put("uuid", envManager.getUUID()); para.put("uuid", envManager.getUUID());
para.put("key", key); para.put("key", key);
para.put("username", ServerConfig.getInstance().getBbsUsername()); para.put("username", MarketConfig.getInstance().getBbsUsername());
HttpClient hc = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("verify.code"), para); HttpClient hc = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("verify.code"), para);
if (timeout != -1) { if (timeout != -1) {
hc.setTimeout(timeout); hc.setTimeout(timeout);

8
designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java

@ -2,7 +2,7 @@ package com.fr.design.mainframe.alphafine.component;
import com.bulenkov.iconloader.IconLoader; import com.bulenkov.iconloader.IconLoader;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.config.ServerConfig; import com.fr.config.MarketConfig;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; import com.fr.design.actions.help.alphafine.AlphaFineConfigManager;
import com.fr.design.dialog.UIDialog; import com.fr.design.dialog.UIDialog;
@ -26,8 +26,8 @@ import com.fr.design.mainframe.alphafine.preview.PluginPreviewPane;
import com.fr.design.mainframe.alphafine.search.manager.impl.ActionSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.ActionSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.DocumentSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.DocumentSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.FileSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.FileSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.RecentSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.PluginSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.PluginSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.RecentSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.RecommendSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.RecommendSearchManager;
import com.fr.form.main.Form; import com.fr.form.main.Form;
import com.fr.form.main.FormIO; import com.fr.form.main.FormIO;
@ -402,6 +402,7 @@ public class AlphaFineDialog extends UIDialog {
/** /**
* 处理搜索字符串 * 处理搜索字符串
*
* @param searchText * @param searchText
*/ */
private void dealWithSearchText(String searchText) { private void dealWithSearchText(String searchText) {
@ -422,6 +423,7 @@ public class AlphaFineDialog extends UIDialog {
/** /**
* 截取字符串中关键词 * 截取字符串中关键词
*
* @param searchText * @param searchText
* @return * @return
*/ */
@ -775,7 +777,7 @@ public class AlphaFineDialog extends UIDialog {
*/ */
private void sendDataToServer(String searchKey, AlphaCellModel cellModel) { private void sendDataToServer(String searchKey, AlphaCellModel cellModel) {
if (cellModel.isNeedToSendToServer()) { if (cellModel.isNeedToSendToServer()) {
String username = ServerConfig.getInstance().getBbsUsername(); String username = MarketConfig.getInstance().getBbsUsername();
String uuid = DesignerEnvManager.getEnvManager().getUUID(); String uuid = DesignerEnvManager.getEnvManager().getUUID();
String activityKey = DesignerEnvManager.getEnvManager().getActivationKey(); String activityKey = DesignerEnvManager.getEnvManager().getActivationKey();
String createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(Calendar.getInstance().getTime()); String createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(Calendar.getInstance().getTime());

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

@ -4,7 +4,7 @@
package com.fr.design.mainframe.bbs; package com.fr.design.mainframe.bbs;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.config.ServerConfig; import com.fr.config.MarketConfig;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.bbs.BBSLoginUtils; import com.fr.design.bbs.BBSLoginUtils;
import com.fr.design.extra.LoginContextListener; import com.fr.design.extra.LoginContextListener;
@ -71,56 +71,59 @@ public class UserInfoLabel extends UILabel {
private UserInfoPane userInfoPane; private UserInfoPane userInfoPane;
private BBSLoginDialog bbsLoginDialog; private BBSLoginDialog bbsLoginDialog;
private MouseAdapter userInfoAdapter = new MouseAdapter() {
public UserInfoPane getUserInfoPane() { @Override
return userInfoPane; public void mouseEntered(MouseEvent e) {
} UserInfoLabel.this.setCursor(new Cursor(Cursor.HAND_CURSOR));
}
public void setUserInfoPane(UserInfoPane userInfoPane) { @Override
this.userInfoPane = userInfoPane; public void mouseClicked(MouseEvent e) {
} userName = MarketConfig.getInstance().getBbsUsername();
if (StringUtils.isNotEmpty(userName)) {
UIPopupMenu menu = new UIPopupMenu();
menu.setOnlyText(true);
menu.setPopupSize(userInfoPane.getWidth(), userInfoPane.getHeight() * 3);
public BBSLoginDialog getBbsLoginDialog() { //私人消息
return bbsLoginDialog; UIMenuItem priviteMessage = new UIMenuItem(Inter.getLocText("FR-Designer-BBSLogin_Privite-Message"));
} priviteMessage.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
if (StringUtils.isNotEmpty(userName)) {
try {
String loginUrl = SiteCenter.getInstance().acquireUrlByKind("bbs.default");
Desktop.getDesktop().browse(new URI(loginUrl));
} catch (Exception exp) {
FRContext.getLogger().info(exp.getMessage());
}
}
}
public void setBbsLoginDialog(BBSLoginDialog bbsLoginDialog) { });
this.bbsLoginDialog = bbsLoginDialog; //切换账号
} UIMenuItem closeOther = new UIMenuItem(Inter.getLocText("FR-Designer-BBSLogin_Switch-Account"));
closeOther.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
BBSLoginUtils.bbsLogout();
UserLoginContext.fireLoginContextListener();
}
});
menu.add(priviteMessage);
menu.add(closeOther);
GUICoreUtils.showPopupMenu(menu, UserInfoLabel.this, 0, MENU_HEIGHT);
} else {
UserLoginContext.fireLoginContextListener();
}
}
};
public UserInfoLabel(UserInfoPane userInfoPane) { public UserInfoLabel(UserInfoPane userInfoPane) {
init(userInfoPane); init(userInfoPane);
} }
private void init(UserInfoPane userInfoPane) {
this.userInfoPane = userInfoPane;
this.addMouseListener(userInfoAdapter);
this.setHorizontalAlignment(SwingConstants.CENTER);
if (StableUtils.getMajorJavaVersion() == VERSION_8) {
LoginWebBridge.getHelper().setUILabel(UserInfoLabel.this);
PluginWebBridge.getHelper().setUILabel(UserInfoLabel.this);
}
UserLoginContext.addLoginContextListener(new LoginContextListener() {
@Override
public void showLoginContext() {
WebViewDlgHelper.createLoginDialog();
clearLoginInformation();
updateInfoPane();
}
});
}
private void clearLoginInformation() {
BBSLoginUtils.bbsLogout();
}
private void updateInfoPane() {
userInfoPane.markUnSignIn();
}
/** /**
* showBBSDialog 弹出BBS资讯框 * showBBSDialog 弹出BBS资讯框
*/ */
@ -170,6 +173,51 @@ public class UserInfoLabel extends UILabel {
}); });
} }
public UserInfoPane getUserInfoPane() {
return userInfoPane;
}
public void setUserInfoPane(UserInfoPane userInfoPane) {
this.userInfoPane = userInfoPane;
}
public BBSLoginDialog getBbsLoginDialog() {
return bbsLoginDialog;
}
public void setBbsLoginDialog(BBSLoginDialog bbsLoginDialog) {
this.bbsLoginDialog = bbsLoginDialog;
}
private void init(UserInfoPane userInfoPane) {
this.userInfoPane = userInfoPane;
this.addMouseListener(userInfoAdapter);
this.setHorizontalAlignment(SwingConstants.CENTER);
if (StableUtils.getMajorJavaVersion() == VERSION_8) {
LoginWebBridge.getHelper().setUILabel(UserInfoLabel.this);
PluginWebBridge.getHelper().setUILabel(UserInfoLabel.this);
}
UserLoginContext.addLoginContextListener(new LoginContextListener() {
@Override
public void showLoginContext() {
WebViewDlgHelper.createLoginDialog();
clearLoginInformation();
updateInfoPane();
}
});
}
private void clearLoginInformation() {
BBSLoginUtils.bbsLogout();
}
private void updateInfoPane() {
userInfoPane.markUnSignIn();
}
private void sleep(long millis) { private void sleep(long millis) {
try { try {
Thread.sleep(millis); Thread.sleep(millis);
@ -182,13 +230,6 @@ public class UserInfoLabel extends UILabel {
return userName; return userName;
} }
/**
* 重置当前用户名
*/
public void resetUserName() {
this.userName = StringUtils.EMPTY;
}
public void setUserName(String userName) { public void setUserName(String userName) {
if (StringUtils.isEmpty(userName)) { if (StringUtils.isEmpty(userName)) {
return; return;
@ -197,6 +238,13 @@ public class UserInfoLabel extends UILabel {
this.userName = userName; this.userName = userName;
} }
/**
* 重置当前用户名
*/
public void resetUserName() {
this.userName = StringUtils.EMPTY;
}
private String encode(String str) { private String encode(String str) {
try { try {
return URLEncoder.encode(str, EncodeConstants.ENCODING_UTF_8); return URLEncoder.encode(str, EncodeConstants.ENCODING_UTF_8);
@ -228,53 +276,4 @@ public class UserInfoLabel extends UILabel {
//更新面板Text //更新面板Text
this.setText(sb); this.setText(sb);
} }
private MouseAdapter userInfoAdapter = new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
UserInfoLabel.this.setCursor(new Cursor(Cursor.HAND_CURSOR));
}
@Override
public void mouseClicked(MouseEvent e) {
userName = ServerConfig.getInstance().getBbsUsername();
if (StringUtils.isNotEmpty(userName)) {
UIPopupMenu menu = new UIPopupMenu();
menu.setOnlyText(true);
menu.setPopupSize(userInfoPane.getWidth(), userInfoPane.getHeight() * 3);
//私人消息
UIMenuItem priviteMessage = new UIMenuItem(Inter.getLocText("FR-Designer-BBSLogin_Privite-Message"));
priviteMessage.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
if (StringUtils.isNotEmpty(userName)) {
try {
String loginUrl = SiteCenter.getInstance().acquireUrlByKind("bbs.default");
Desktop.getDesktop().browse(new URI(loginUrl));
} catch (Exception exp) {
FRContext.getLogger().info(exp.getMessage());
}
}
}
});
//切换账号
UIMenuItem closeOther = new UIMenuItem(Inter.getLocText("FR-Designer-BBSLogin_Switch-Account"));
closeOther.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
BBSLoginUtils.bbsLogout();
UserLoginContext.fireLoginContextListener();
}
});
menu.add(priviteMessage);
menu.add(closeOther);
GUICoreUtils.showPopupMenu(menu, UserInfoLabel.this, 0, MENU_HEIGHT);
} else {
UserLoginContext.fireLoginContextListener();
}
}
};
} }

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

@ -1,11 +1,11 @@
/** /**
* *
*/ */
package com.fr.design.mainframe.bbs; package com.fr.design.mainframe.bbs;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.config.DBEnv; import com.fr.config.DBEnv;
import com.fr.config.ServerConfig; import com.fr.config.MarketConfig;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
@ -28,159 +28,156 @@ import java.util.Date;
/** /**
* @author neil * @author neil
*
* @date: 2015-3-5-上午11:19:50 * @date: 2015-3-5-上午11:19:50
*/ */
public class UserInfoPane extends BasicPane{ public class UserInfoPane extends BasicPane {
//默认未登录颜色 //默认未登录颜色
private static final Color UN_LOGIN_BACKGROUND = UIConstants.TEMPLATE_TAB_PANE_BACKGROUND; private static final Color UN_LOGIN_BACKGROUND = UIConstants.TEMPLATE_TAB_PANE_BACKGROUND;
private static final Color LOGIN_BACKGROUND = new Color(184, 220, 242); private static final Color LOGIN_BACKGROUND = new Color(184, 220, 242);
private static final int WIDTH = 104; private static final int WIDTH = 104;
private static final int HEIGHT = 24; private static final int HEIGHT = 24;
//登录成功 //登录成功
private static final String LOGININ = "0"; private static final String LOGININ = "0";
// 登录框弹出间隔时间 // 登录框弹出间隔时间
private static final int LOGIN_DIFF_DAY = 7; private static final int LOGIN_DIFF_DAY = 7;
// 等待国际化等相关初始化工作完成之后再弹出登录框 // 等待国际化等相关初始化工作完成之后再弹出登录框
private static final int WAIT_TIME = 10000; private static final int WAIT_TIME = 10000;
private UserInfoLabel userInfoLabel; private UserInfoLabel userInfoLabel;
public UserInfoLabel getUserInfoLabel() { /**
return userInfoLabel; * 构造函数
} */
public UserInfoPane() {
public void setUserInfoLabel(UserInfoLabel userInfoLabel) { this.setPreferredSize(new Dimension(WIDTH, HEIGHT));
this.userInfoLabel = userInfoLabel; this.setLayout(new BorderLayout());
}
this.userInfoLabel = new UserInfoLabel(this);
/** this.markUnSignIn();
* 构造函数 addEnvChangedListener();
*/ autoPushLoginDialog();
public UserInfoPane() {
this.setPreferredSize(new Dimension(WIDTH,HEIGHT)); this.add(userInfoLabel, BorderLayout.CENTER);
this.setLayout(new BorderLayout()); }
this.userInfoLabel = new UserInfoLabel(this); public UserInfoLabel getUserInfoLabel() {
return userInfoLabel;
this.markUnSignIn(); }
addEnvChangedListener();
autoPushLoginDialog(); public void setUserInfoLabel(UserInfoLabel userInfoLabel) {
this.userInfoLabel = userInfoLabel;
this.add(userInfoLabel, BorderLayout.CENTER); }
}
private void addEnvChangedListener() {
private void addEnvChangedListener(){ GeneralContext.addEnvChangedListener(new EnvChangedListener() {
GeneralContext.addEnvChangedListener(new EnvChangedListener() { @Override
@Override public void envChanged() {
public void envChanged() { if (DBEnv.isDBEnvAvailable()) {
if (DBEnv.isDBEnvAvailable()) { String username = MarketConfig.getInstance().getBbsUsername();
String username = ServerConfig.getInstance().getBbsUsername(); if (StringUtils.isEmpty(username)) {
if (StringUtils.isEmpty(username)){ markUnSignIn();
markUnSignIn(); } else {
} else { markSignIn(username);
markSignIn(username); }
} }
} }
} });
}); }
}
// 计算xml保存的上次弹框时间和当前时间的时间差
// 计算xml保存的上次弹框时间和当前时间的时间差 private int getDiffFromLastLogin() {
private int getDiffFromLastLogin(){ String lastBBSTime = DesignerEnvManager.getEnvManager().getLastShowBBSTime();
String lastBBSTime = DesignerEnvManager.getEnvManager().getLastShowBBSTime(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date lastBBSDate = null;
Date lastBBSDate = null; try {
try { if (lastBBSTime != null) {
if(lastBBSTime != null){ synchronized (this) {
synchronized (this) { lastBBSDate = sdf.parse(lastBBSTime);
lastBBSDate = sdf.parse(lastBBSTime); }
} Calendar calender = Calendar.getInstance();
Calendar calender = Calendar.getInstance(); calender.setTime(lastBBSDate);
calender.setTime(lastBBSDate); int dayOld = calender.get(Calendar.DAY_OF_YEAR);
int dayOld = calender.get(Calendar.DAY_OF_YEAR); calender.setTime(new Date());
calender.setTime(new Date()); int dayNew = calender.get(Calendar.DAY_OF_YEAR);
int dayNew = calender.get(Calendar.DAY_OF_YEAR); return dayNew - dayOld;
return dayNew - dayOld; }
} } catch (ParseException e) {
} catch (ParseException e) { FRLogger.getLogger().error(e.getMessage());
FRLogger.getLogger().error(e.getMessage()); }
} return 1;
return 1; }
}
private void autoPushLoginDialog() {
private void autoPushLoginDialog(){ Thread showBBSThread = new Thread(new Runnable() {
Thread showBBSThread = new Thread(new Runnable() {
@Override
@Override public void run() {
public void run() { try {
try { // 等国际化等加载完毕再启动线程弹出登录框
// 等国际化等加载完毕再启动线程弹出登录框 Thread.sleep(WAIT_TIME);
Thread.sleep(WAIT_TIME); if (!FRContext.isChineseEnv()) {
if(!FRContext.isChineseEnv()){ return;
return; }
}
//七天弹一次, 如果xml中和当前时间相差小于7天, 就不弹了
//七天弹一次, 如果xml中和当前时间相差小于7天, 就不弹了 if (getDiffFromLastLogin() < LOGIN_DIFF_DAY) {
if(getDiffFromLastLogin() < LOGIN_DIFF_DAY){ return;
return; }
}
} catch (InterruptedException e) {
} catch (InterruptedException e) { FRContext.getLogger().error(e.getMessage());
FRContext.getLogger().error(e.getMessage()); }
}
String userName = MarketConfig.getInstance().getBbsUsername();
String userName = ServerConfig.getInstance().getBbsUsername(); if (StringUtils.isNotEmpty(userName)) {
if(StringUtils.isNotEmpty(userName)){ return;
return; }
}
BBSLoginDialog bbsLoginDialog = userInfoLabel.getBbsLoginDialog();
BBSLoginDialog bbsLoginDialog = userInfoLabel.getBbsLoginDialog(); if (bbsLoginDialog == null) {
if(bbsLoginDialog == null){ bbsLoginDialog = new BBSLoginDialog(DesignerContext.getDesignerFrame(), userInfoLabel);
bbsLoginDialog = new BBSLoginDialog(DesignerContext.getDesignerFrame(),userInfoLabel); userInfoLabel.setBbsLoginDialog(bbsLoginDialog);
userInfoLabel.setBbsLoginDialog(bbsLoginDialog); }
}
bbsLoginDialog.showWindow();
bbsLoginDialog.showWindow(); DesignerEnvManager.getEnvManager().setLastShowBBSTime(DateUtils.DATEFORMAT2.format(new Date()));
DesignerEnvManager.getEnvManager().setLastShowBBSTime(DateUtils.DATEFORMAT2.format(new Date())); }
}
});
}); showBBSThread.start();
showBBSThread.start(); }
}
/**
/** * 标志未登录状态, 面板设置为灰色
* 标志未登录状态, 面板设置为灰色 */
* public void markUnSignIn() {
*/ this.userInfoLabel.setText(Inter.getLocText("FR-Base_UnSignIn"));
public void markUnSignIn(){ this.userInfoLabel.setOpaque(true);
this.userInfoLabel.setText(Inter.getLocText("FR-Base_UnSignIn")); this.userInfoLabel.setBackground(UN_LOGIN_BACKGROUND);
this.userInfoLabel.setOpaque(true); this.userInfoLabel.resetUserName();
this.userInfoLabel.setBackground(UN_LOGIN_BACKGROUND); }
this.userInfoLabel.resetUserName();
} /**
* 标志登陆状态, 面包设置为蓝色
/** *
* 标志登陆状态, 面包设置为蓝色 * @param userName 用户名
* @param userName 用户名 */
* public void markSignIn(String userName) {
*/ this.userInfoLabel.setText(userName);
public void markSignIn(String userName){ this.userInfoLabel.setUserName(userName);
this.userInfoLabel.setText(userName); this.userInfoLabel.setOpaque(true);
this.userInfoLabel.setUserName(userName); this.userInfoLabel.setBackground(LOGIN_BACKGROUND);
this.userInfoLabel.setOpaque(true); }
this.userInfoLabel.setBackground(LOGIN_BACKGROUND);
} @Override
protected String title4PopupWindow() {
@Override return StringUtils.EMPTY;
protected String title4PopupWindow() { }
return StringUtils.EMPTY;
}
} }

5
designer/src/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java

@ -3,9 +3,8 @@ package com.fr.design.mainframe.errorinfo;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.io.IOFile; import com.fr.base.io.IOFile;
import com.fr.base.io.XMLReadHelper; import com.fr.base.io.XMLReadHelper;
import com.fr.config.ServerConfig; import com.fr.config.MarketConfig;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.general.FRLogLevel;
import com.fr.general.FRLogManager; import com.fr.general.FRLogManager;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.general.LogDuration; import com.fr.general.LogDuration;
@ -39,7 +38,7 @@ public class ErrorInfoLogAppender extends AppenderSkeleton {
this.layout = new com.fr.third.apache.log4j.PatternLayout("%d{HH:mm:ss} %t %p [%c] %m%n"); this.layout = new com.fr.third.apache.log4j.PatternLayout("%d{HH:mm:ss} %t %p [%c] %m%n");
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
this.username = ServerConfig.getInstance().getBbsUsername(); this.username = MarketConfig.getInstance().getBbsUsername();
this.uuid = envManager.getUUID(); this.uuid = envManager.getUUID();
this.activekey = envManager.getActivationKey(); this.activekey = envManager.getActivationKey();
} }

40
designer_base/src/com/fr/design/bbs/BBSLoginUtils.java

@ -1,7 +1,7 @@
package com.fr.design.bbs; package com.fr.design.bbs;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.config.ServerConfig; import com.fr.config.MarketConfig;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import java.util.List; import java.util.List;
@ -11,36 +11,36 @@ import java.util.List;
*/ */
public class BBSLoginUtils { public class BBSLoginUtils {
public static void bbsLogin(String username, String password){ public static void bbsLogin(String username, String password) {
try{ try {
ServerConfig.getInstance().setBbsUsername(username); MarketConfig.getInstance().setBbsUsername(username);
ServerConfig.getInstance().setBbsPassword(password); MarketConfig.getInstance().setBbsPassword(password);
}catch (Exception e){ } catch (Exception e) {
FRContext.getLogger().error(e.getMessage()); FRContext.getLogger().error(e.getMessage());
} }
} }
public static void bbsLogin(List<String> list){ public static void bbsLogin(List<String> list) {
try{ try {
String uid = list.get(0); String uid = list.get(0);
String username = list.get(1); String username = list.get(1);
String password = list.get(2); String password = list.get(2);
ServerConfig.getInstance().setBbsUsername(username); MarketConfig.getInstance().setBbsUsername(username);
ServerConfig.getInstance().setBbsPassword(password); MarketConfig.getInstance().setBbsPassword(password);
ServerConfig.getInstance().setBbsUid(Integer.parseInt(uid)); MarketConfig.getInstance().setBbsUid(Integer.parseInt(uid));
ServerConfig.getInstance().setInShowBBsName(username); MarketConfig.getInstance().setInShowBBsName(username);
}catch (Exception e){ } catch (Exception e) {
FRContext.getLogger().error(e.getMessage()); FRContext.getLogger().error(e.getMessage());
} }
} }
public static void bbsLogout(){ public static void bbsLogout() {
try{ try {
ServerConfig.getInstance().setBbsUsername(StringUtils.EMPTY); MarketConfig.getInstance().setBbsUsername(StringUtils.EMPTY);
ServerConfig.getInstance().setBbsPassword(StringUtils.EMPTY); MarketConfig.getInstance().setBbsPassword(StringUtils.EMPTY);
ServerConfig.getInstance().setBbsUid(0); MarketConfig.getInstance().setBbsUid(0);
ServerConfig.getInstance().setInShowBBsName(StringUtils.EMPTY); MarketConfig.getInstance().setInShowBBsName(StringUtils.EMPTY);
}catch (Exception e){ } catch (Exception e) {
FRContext.getLogger().error(e.getMessage()); FRContext.getLogger().error(e.getMessage());
} }
} }

50
designer_base/src/com/fr/design/extra/LoginWebBridge.java

@ -1,7 +1,7 @@
package com.fr.design.extra; package com.fr.design.extra;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.config.ServerConfig; import com.fr.config.MarketConfig;
import com.fr.design.bbs.BBSLoginUtils; import com.fr.design.bbs.BBSLoginUtils;
import com.fr.design.dialog.UIDialog; import com.fr.design.dialog.UIDialog;
import com.fr.design.extra.exe.PluginLoginExecutor; import com.fr.design.extra.exe.PluginLoginExecutor;
@ -20,7 +20,8 @@ import netscape.javascript.JSObject;
import javax.swing.JDialog; import javax.swing.JDialog;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import java.awt.*; import java.awt.Color;
import java.awt.Desktop;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URI; import java.net.URI;
import java.net.URLEncoder; import java.net.URLEncoder;
@ -38,8 +39,6 @@ public class LoginWebBridge {
private static final String SUCCESS_MESSAGE_STATUS = "ok"; private static final String SUCCESS_MESSAGE_STATUS = "ok";
//数据通讯失败 //数据通讯失败
private static final String FAILED_MESSAGE_STATUS = "error"; private static final String FAILED_MESSAGE_STATUS = "error";
//消息条数
private int messageCount;
//最低消息的条数 //最低消息的条数
private static final int MIN_MESSAGE_COUNT = 0; private static final int MIN_MESSAGE_COUNT = 0;
//登录成功 //登录成功
@ -58,8 +57,9 @@ public class LoginWebBridge {
private static final String LOGIN_SUCCESS = "ok"; private static final String LOGIN_SUCCESS = "ok";
private static final String LOGIN_FAILED = "failed"; private static final String LOGIN_FAILED = "failed";
private static final Color LOGIN_BACKGROUND = new Color(184, 220, 242); private static final Color LOGIN_BACKGROUND = new Color(184, 220, 242);
private static LoginWebBridge helper; private static LoginWebBridge helper;
//消息条数
private int messageCount;
private UIDialog uiDialog; private UIDialog uiDialog;
private UIDialog qqDialog; private UIDialog qqDialog;
private UILabel uiLabel; private UILabel uiLabel;
@ -94,6 +94,26 @@ public class LoginWebBridge {
return messageCount; return messageCount;
} }
/**
* 设置获取的消息长度并设置显示
*
* @param count
*/
public void setMessageCount(int count) {
if (count == MIN_MESSAGE_COUNT) {
uiLabel.setText(MarketConfig.getInstance().getBbsUsername());
MarketConfig.getInstance().setInShowBBsName(MarketConfig.getInstance().getBbsUsername());
return;
}
this.messageCount = count;
StringBuilder sb = new StringBuilder();
sb.append(StringUtils.BLANK).append(MarketConfig.getInstance().getBbsUsername())
.append("(").append(this.messageCount)
.append(")").append(StringUtils.BLANK);
MarketConfig.getInstance().setInShowBBsName(sb.toString());
uiLabel.setText(sb.toString());
}
public void setQQDialog(UIDialog qqDialog) { public void setQQDialog(UIDialog qqDialog) {
closeQQWindow(); closeQQWindow();
this.qqDialog = qqDialog; this.qqDialog = qqDialog;
@ -118,26 +138,6 @@ public class LoginWebBridge {
return client.isServerAlive(); return client.isServerAlive();
} }
/**
* 设置获取的消息长度并设置显示
*
* @param count
*/
public void setMessageCount(int count) {
if (count == MIN_MESSAGE_COUNT) {
uiLabel.setText(ServerConfig.getInstance().getBbsUsername());
ServerConfig.getInstance().setInShowBBsName(ServerConfig.getInstance().getBbsUsername());
return;
}
this.messageCount = count;
StringBuilder sb = new StringBuilder();
sb.append(StringUtils.BLANK).append(ServerConfig.getInstance().getBbsUsername())
.append("(").append(this.messageCount)
.append(")").append(StringUtils.BLANK);
ServerConfig.getInstance().setInShowBBsName(sb.toString());
uiLabel.setText(sb.toString());
}
private String encode(String str) { private String encode(String str) {
try { try {
return URLEncoder.encode(str, EncodeConstants.ENCODING_UTF_8); return URLEncoder.encode(str, EncodeConstants.ENCODING_UTF_8);

23
designer_base/src/com/fr/design/extra/PluginFromStorePane.java

@ -1,7 +1,7 @@
package com.fr.design.extra; package com.fr.design.extra;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.config.ServerConfig; import com.fr.config.MarketConfig;
import com.fr.design.extra.tradition.callback.UpdateOnlineCallback; import com.fr.design.extra.tradition.callback.UpdateOnlineCallback;
import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
@ -14,7 +14,12 @@ import com.fr.plugin.manage.control.PluginTaskResult;
import com.fr.plugin.manage.control.ProgressCallback; import com.fr.plugin.manage.control.ProgressCallback;
import com.fr.plugin.view.PluginView; import com.fr.plugin.view.PluginView;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.*;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.filechooser.FileNameExtensionFilter;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
@ -25,13 +30,12 @@ import java.util.List;
* @since 8.0 * @since 8.0
*/ */
public class PluginFromStorePane extends PluginAbstractLoadingViewPane<List<PluginView>, Void> { public class PluginFromStorePane extends PluginAbstractLoadingViewPane<List<PluginView>, Void> {
private static final int LISTNUM1 = 1;
private static final int LISTNUM100 = 100;
private UILabel errorMsgLabel; private UILabel errorMsgLabel;
private UITabbedPane tabbedPane; private UITabbedPane tabbedPane;
private PluginControlPane controlPane; private PluginControlPane controlPane;
private static final int LISTNUM1 = 1;
private static final int LISTNUM100 = 100;
public PluginFromStorePane(final UITabbedPane tabbedPane) { public PluginFromStorePane(final UITabbedPane tabbedPane) {
super(tabbedPane); super(tabbedPane);
@ -180,7 +184,8 @@ public class PluginFromStorePane extends PluginAbstractLoadingViewPane<List<Plug
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Install_Successful")); JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Install_Successful"));
} else { } else {
JOptionPane.showMessageDialog(null, PluginUtils.getMessageByErrorCode(result.errorCode()), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(null, PluginUtils.getMessageByErrorCode(result.errorCode()), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
} } }
}
}); });
} catch (Exception e1) { } catch (Exception e1) {
JOptionPane.showMessageDialog(PluginFromStorePane.this, e1.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(PluginFromStorePane.this, e1.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
@ -188,10 +193,10 @@ public class PluginFromStorePane extends PluginAbstractLoadingViewPane<List<Plug
} }
private void doUpdateOnline(final PluginStatusCheckCompletePane pane) { private void doUpdateOnline(final PluginStatusCheckCompletePane pane) {
if (!StringUtils.isNotEmpty(ServerConfig.getInstance().getBbsUsername())) { if (!StringUtils.isNotEmpty(MarketConfig.getInstance().getBbsUsername())) {
LoginCheckContext.fireLoginCheckListener(); LoginCheckContext.fireLoginCheckListener();
} }
if (StringUtils.isNotEmpty(ServerConfig.getInstance().getBbsUsername())) { if (StringUtils.isNotEmpty(MarketConfig.getInstance().getBbsUsername())) {
PluginView plugin = controlPane.getSelectedPlugin(); PluginView plugin = controlPane.getSelectedPlugin();
String id = null; String id = null;
if (plugin != null) { if (plugin != null) {
@ -201,7 +206,7 @@ public class PluginFromStorePane extends PluginAbstractLoadingViewPane<List<Plug
try { try {
PluginMarker pluginMarker = PluginMarker.create(id, plugin.getVersion()); PluginMarker pluginMarker = PluginMarker.create(id, plugin.getVersion());
JSONObject latestPluginInfo = PluginUtils.getLatestPluginInfo(id); JSONObject latestPluginInfo = PluginUtils.getLatestPluginInfo(id);
String latestPluginVersion = (String)latestPluginInfo.get("version"); String latestPluginVersion = (String) latestPluginInfo.get("version");
PluginMarker toPluginMarker = PluginMarker.create(id, latestPluginVersion); PluginMarker toPluginMarker = PluginMarker.create(id, latestPluginVersion);
PluginManager.getController().download(pluginMarker, new UpdateOnlineCallback(pluginMarker, toPluginMarker, pane)); PluginManager.getController().download(pluginMarker, new UpdateOnlineCallback(pluginMarker, toPluginMarker, pane));
} catch (Exception e) { } catch (Exception e) {

4
designer_base/src/com/fr/design/extra/PluginOperateUtils.java

@ -1,7 +1,7 @@
package com.fr.design.extra; package com.fr.design.extra;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.config.ServerConfig; import com.fr.config.MarketConfig;
import com.fr.design.extra.exe.callback.InstallFromDiskCallback; import com.fr.design.extra.exe.callback.InstallFromDiskCallback;
import com.fr.design.extra.exe.callback.InstallOnlineCallback; import com.fr.design.extra.exe.callback.InstallOnlineCallback;
import com.fr.design.extra.exe.callback.JSCallback; import com.fr.design.extra.exe.callback.JSCallback;
@ -167,7 +167,7 @@ public class PluginOperateUtils {
} }
public static void getLoginInfo(JSCallback jsCallback, UILabel uiLabel) { public static void getLoginInfo(JSCallback jsCallback, UILabel uiLabel) {
String username = ServerConfig.getInstance().getBbsUsername(); String username = MarketConfig.getInstance().getBbsUsername();
if (StringUtils.isEmpty(username)) { if (StringUtils.isEmpty(username)) {
jsCallback.execute(StringUtils.EMPTY); jsCallback.execute(StringUtils.EMPTY);
uiLabel.setText(Inter.getLocText("FR-Base_UnSignIn")); uiLabel.setText(Inter.getLocText("FR-Base_UnSignIn"));

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

@ -1,6 +1,6 @@
package com.fr.design.extra; package com.fr.design.extra;
import com.fr.config.ServerConfig; import com.fr.config.MarketConfig;
import com.fr.design.extra.tradition.callback.UpdateOnlineCallback; import com.fr.design.extra.tradition.callback.UpdateOnlineCallback;
import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
@ -14,7 +14,12 @@ import com.fr.plugin.manage.control.ProgressCallback;
import com.fr.plugin.view.PluginView; import com.fr.plugin.view.PluginView;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.filechooser.FileNameExtensionFilter;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
@ -26,12 +31,11 @@ import java.util.List;
*/ */
public class PluginUpdatePane extends PluginAbstractLoadingViewPane<List<PluginView>, Void> { public class PluginUpdatePane extends PluginAbstractLoadingViewPane<List<PluginView>, Void> {
private static final int PERSENT = 100;
private PluginControlPane controlPane; private PluginControlPane controlPane;
private JLabel errorMsgLabel; private JLabel errorMsgLabel;
private UITabbedPane tabbedPane; private UITabbedPane tabbedPane;
private static final int PERSENT = 100;
public PluginUpdatePane(UITabbedPane tabbedPane) { public PluginUpdatePane(UITabbedPane tabbedPane) {
super(tabbedPane); super(tabbedPane);
this.tabbedPane = tabbedPane; this.tabbedPane = tabbedPane;
@ -171,18 +175,19 @@ public class PluginUpdatePane extends PluginAbstractLoadingViewPane<List<PluginV
} }
private void doUpdateOnline(final PluginStatusCheckCompletePane pane) { private void doUpdateOnline(final PluginStatusCheckCompletePane pane) {
if (!StringUtils.isNotEmpty(ServerConfig.getInstance().getBbsUsername())) { if (!StringUtils.isNotEmpty(MarketConfig.getInstance().getBbsUsername())) {
LoginCheckContext.fireLoginCheckListener(); LoginCheckContext.fireLoginCheckListener();
} }
if (StringUtils.isNotEmpty(ServerConfig.getInstance().getBbsUsername())) { if (StringUtils.isNotEmpty(MarketConfig.getInstance().getBbsUsername())) {
try{ try {
PluginView plugin = controlPane.getSelectedPlugin(); PluginView plugin = controlPane.getSelectedPlugin();
PluginMarker pluginMarker = PluginMarker.create(plugin.getID(), plugin.getVersion()); PluginMarker pluginMarker = PluginMarker.create(plugin.getID(), plugin.getVersion());
JSONObject latestPluginInfo = PluginUtils.getLatestPluginInfo(pluginMarker.getPluginID()); JSONObject latestPluginInfo = PluginUtils.getLatestPluginInfo(pluginMarker.getPluginID());
String latestPluginVersion = (String) latestPluginInfo.get("version"); String latestPluginVersion = (String) latestPluginInfo.get("version");
PluginMarker toPluginMarker = PluginMarker.create(pluginMarker.getPluginID(), latestPluginVersion); PluginMarker toPluginMarker = PluginMarker.create(pluginMarker.getPluginID(), latestPluginVersion);
PluginManager.getController().download(pluginMarker, new UpdateOnlineCallback(pluginMarker, toPluginMarker, pane)); PluginManager.getController().download(pluginMarker, new UpdateOnlineCallback(pluginMarker, toPluginMarker, pane));
}catch (Exception e){} } catch (Exception e) {
}
} }

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

@ -1,7 +1,7 @@
package com.fr.design.extra; package com.fr.design.extra;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.config.ServerConfig; import com.fr.config.MarketConfig;
import com.fr.design.RestartHelper; import com.fr.design.RestartHelper;
import com.fr.design.bbs.BBSLoginUtils; import com.fr.design.bbs.BBSLoginUtils;
import com.fr.design.dialog.UIDialog; import com.fr.design.dialog.UIDialog;
@ -422,7 +422,7 @@ public class PluginWebBridge {
*/ */
public String getLoginInfo(final JSObject callback) { public String getLoginInfo(final JSObject callback) {
registerLoginInfo(callback); registerLoginInfo(callback);
return ServerConfig.getInstance().getBbsUsername(); return MarketConfig.getInstance().getBbsUsername();
} }
/** /**
@ -557,7 +557,7 @@ public class PluginWebBridge {
* 清除用户信息 * 清除用户信息
*/ */
public void clearUserInfo() { public void clearUserInfo() {
ServerConfig.getInstance().setInShowBBsName(StringUtils.EMPTY); MarketConfig.getInstance().setInShowBBsName(StringUtils.EMPTY);
BBSLoginUtils.bbsLogout(); BBSLoginUtils.bbsLogout();
uiLabel.setText(Inter.getLocText("FR-Base_UnSignIn")); uiLabel.setText(Inter.getLocText("FR-Base_UnSignIn"));
} }

152
designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java

@ -2,39 +2,59 @@ package com.fr.design.mainframe.templateinfo;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.io.IOFile; import com.fr.base.io.IOFile;
import com.fr.config.ServerConfig; import com.fr.config.MarketConfig;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.SiteCenterToken; import com.fr.design.mainframe.SiteCenterToken;
import com.fr.env.RemoteEnv; import com.fr.env.RemoteEnv;
import com.fr.general.*; import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.general.GeneralUtils;
import com.fr.general.IOUtils;
import com.fr.general.SiteCenter;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.stable.*;
import com.fr.stable.xml.*;
import com.fr.third.javax.xml.stream.XMLStreamException;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.stable.EncodeConstants;
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.XMLReadable;
import com.fr.stable.xml.XMLTools;
import com.fr.stable.xml.XMLWriter;
import com.fr.stable.xml.XMLableReader;
import com.fr.third.javax.xml.stream.XMLStreamException;
import java.io.*; import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.ObjectInputStream;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
/** /**
* 做模板的过程和耗时收集辅助类 * 做模板的过程和耗时收集辅助类
* Created by plough on 2017/2/21. * Created by plough on 2017/2/21.
*/ */
public class TemplateInfoCollector<T extends IOFile> implements Serializable, XMLReadable, XMLWriter { public class TemplateInfoCollector<T extends IOFile> implements Serializable, XMLReadable, XMLWriter {
static final long serialVersionUID = 2007L;
private static final String FILE_NAME = "tpl.info"; private static final String FILE_NAME = "tpl.info";
private static final String OBJECT_FILE_NAME = "tplInfo.ser"; private static final String OBJECT_FILE_NAME = "tplInfo.ser";
private static TemplateInfoCollector instance;
private Map<String, HashMap<String, Object>> templateInfoList;
private String designerOpenDate; //设计器最近一次打开日期
private static final int VALID_CELL_COUNT = 5; // 有效报表模板的格子数 private static final int VALID_CELL_COUNT = 5; // 有效报表模板的格子数
private static final int VALID_WIDGET_COUNT = 5; // 有效报表模板的控件数 private static final int VALID_WIDGET_COUNT = 5; // 有效报表模板的控件数
private static final int COMPLETE_DAY_COUNT = 15; // 判断模板是否完成的天数 private static final int COMPLETE_DAY_COUNT = 15; // 判断模板是否完成的天数
private static final int ONE_THOUSAND = 1000; private static final int ONE_THOUSAND = 1000;
static final long serialVersionUID = 2007L;
private static final String XML_DESIGNER_OPEN_DATE = "DesignerOpenDate"; private static final String XML_DESIGNER_OPEN_DATE = "DesignerOpenDate";
private static final String XML_TEMPLATE_INFO_LIST = "TemplateInfoList"; private static final String XML_TEMPLATE_INFO_LIST = "TemplateInfoList";
private static final String XML_TEMPLATE_INFO = "TemplateInfo"; private static final String XML_TEMPLATE_INFO = "TemplateInfo";
@ -57,6 +77,9 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM
private static final String ATTR_USERNAME = "username"; private static final String ATTR_USERNAME = "username";
private static final String JSON_CONSUMING_MAP = "jsonConsumingMap"; private static final String JSON_CONSUMING_MAP = "jsonConsumingMap";
private static final String JSON_PROCESS_MAP = "jsonProcessMap"; private static final String JSON_PROCESS_MAP = "jsonProcessMap";
private static TemplateInfoCollector instance;
private Map<String, HashMap<String, Object>> templateInfoList;
private String designerOpenDate; //设计器最近一次打开日期
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -65,21 +88,6 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM
setDesignerOpenDate(); 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);
}
/** /**
* 获取缓存文件存放路径 * 获取缓存文件存放路径
*/ */
@ -108,7 +116,7 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM
return instance; return instance;
} }
private static void readXMLFile(XMLReadable xmlReadable, File xmlFile){ private static void readXMLFile(XMLReadable xmlReadable, File xmlFile) {
if (xmlFile == null || !xmlFile.exists()) { if (xmlFile == null || !xmlFile.exists()) {
return; return;
} }
@ -133,11 +141,31 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM
} }
private static String getFileContent(File xmlFile) throws FileNotFoundException, UnsupportedEncodingException{ private static String getFileContent(File xmlFile) throws FileNotFoundException, UnsupportedEncodingException {
InputStream is = new FileInputStream(xmlFile); InputStream is = new FileInputStream(xmlFile);
return IOUtils.inputStream2String(is); return IOUtils.inputStream2String(is);
} }
public static void main(String[] args) {
TemplateInfoCollector tic = TemplateInfoCollector.getInstance();
tic.sendTemplateInfo();
}
/**
* 把设计器最近打开日期设定为当前日期
*/
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 boolean shouldCollectInfo() { private boolean shouldCollectInfo() {
if (FRContext.getCurrentEnv() instanceof RemoteEnv) { // 远程设计不收集数据 if (FRContext.getCurrentEnv() instanceof RemoteEnv) { // 远程设计不收集数据
return false; return false;
@ -161,7 +189,7 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public String loadProcess(T t) { public String loadProcess(T t) {
HashMap<String, Object> processMap = (HashMap<String, Object>) templateInfoList.get(t.getTemplateID()).get(XML_PROCESS_MAP); HashMap<String, Object> processMap = (HashMap<String, Object>) templateInfoList.get(t.getTemplateID()).get(XML_PROCESS_MAP);
return (String)processMap.get(ATTR_PROCESS); return (String) processMap.get(ATTR_PROCESS);
} }
/** /**
@ -190,7 +218,7 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM
if (designerOpenFirstTime()) { if (designerOpenFirstTime()) {
for (String key : templateInfoList.keySet()) { for (String key : templateInfoList.keySet()) {
HashMap<String, Object> templateInfo = templateInfoList.get(key); HashMap<String, Object> templateInfo = templateInfoList.get(key);
int dayCount = (int)templateInfo.get(ATTR_DAY_COUNT) + 1; int dayCount = (int) templateInfo.get(ATTR_DAY_COUNT) + 1;
templateInfo.put(ATTR_DAY_COUNT, dayCount); templateInfo.put(ATTR_DAY_COUNT, dayCount);
} }
setDesignerOpenDate(); setDesignerOpenDate();
@ -216,10 +244,9 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM
templateInfo = templateInfoList.get(t.getTemplateID()); templateInfo = templateInfoList.get(t.getTemplateID());
// 更新 conusmingMap // 更新 conusmingMap
HashMap<String, Object> consumingMap = (HashMap<String, Object>) templateInfo.get(XML_CONSUMING_MAP); HashMap<String, Object> consumingMap = (HashMap<String, Object>) templateInfo.get(XML_CONSUMING_MAP);
timeConsume += (long)consumingMap.get(ATTR_TIME_CONSUME); // 加上之前的累计编辑时间 timeConsume += (long) consumingMap.get(ATTR_TIME_CONSUME); // 加上之前的累计编辑时间
consumingMap.put(ATTR_TIME_CONSUME, timeConsume); consumingMap.put(ATTR_TIME_CONSUME, timeConsume);
} } else { // 新增
else { // 新增
templateInfo = new HashMap<>(); templateInfo = new HashMap<>();
templateInfo.put(XML_CONSUMING_MAP, getNewConsumingMap(templateID, openTime, timeConsume)); templateInfo.put(XML_CONSUMING_MAP, getNewConsumingMap(templateID, openTime, timeConsume));
} }
@ -238,7 +265,7 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM
private HashMap<String, Object> getNewConsumingMap(String templateID, long openTime, long timeConsume) { private HashMap<String, Object> getNewConsumingMap(String templateID, long openTime, long timeConsume) {
HashMap<String, Object> consumingMap = new HashMap<>(); HashMap<String, Object> consumingMap = new HashMap<>();
String username = ServerConfig.getInstance().getBbsUsername(); String username = MarketConfig.getInstance().getBbsUsername();
String uuid = DesignerEnvManager.getEnvManager().getUUID(); String uuid = DesignerEnvManager.getEnvManager().getUUID();
String activitykey = DesignerEnvManager.getEnvManager().getActivationKey(); String activitykey = DesignerEnvManager.getEnvManager().getActivationKey();
String createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(Calendar.getInstance().getTime()); String createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(Calendar.getInstance().getTime());
@ -303,7 +330,7 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM
return false; return false;
} }
String res = httpClient.getResponseText(); String res = httpClient.getResponseText();
boolean success; boolean success;
try { try {
success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success"); success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success");
@ -322,7 +349,7 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM
ArrayList<String> testTemplateKeys = new ArrayList<>(); // 保存测试模板的key ArrayList<String> testTemplateKeys = new ArrayList<>(); // 保存测试模板的key
for (String key : templateInfoList.keySet()) { for (String key : templateInfoList.keySet()) {
HashMap<String, Object> templateInfo = templateInfoList.get(key); HashMap<String, Object> templateInfo = templateInfoList.get(key);
if ((int)templateInfo.get(ATTR_DAY_COUNT) <= COMPLETE_DAY_COUNT) { // 未完成模板 if ((int) templateInfo.get(ATTR_DAY_COUNT) <= COMPLETE_DAY_COUNT) { // 未完成模板
continue; continue;
} }
if (isTestTemplate(templateInfo)) { if (isTestTemplate(templateInfo)) {
@ -353,11 +380,11 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private boolean isTestTemplate(HashMap<String, Object> templateInfo) { private boolean isTestTemplate(HashMap<String, Object> templateInfo) {
HashMap<String, Object> processMap = (HashMap<String, Object>) templateInfo.get(XML_PROCESS_MAP); HashMap<String, Object> processMap = (HashMap<String, Object>) templateInfo.get(XML_PROCESS_MAP);
int reportType = (int)processMap.get(ATTR_REPORT_TYPE); int reportType = (int) processMap.get(ATTR_REPORT_TYPE);
int cellCount = (int)processMap.get(ATTR_CELL_COUNT); int cellCount = (int) processMap.get(ATTR_CELL_COUNT);
int floatCount = (int)processMap.get(ATTR_FLOAT_COUNT); int floatCount = (int) processMap.get(ATTR_FLOAT_COUNT);
int blockCount = (int)processMap.get(ATTR_BLOCK_COUNT); int blockCount = (int) processMap.get(ATTR_BLOCK_COUNT);
int widgetCount = (int)processMap.get(ATTR_WIDGET_COUNT); int widgetCount = (int) processMap.get(ATTR_WIDGET_COUNT);
boolean isTestTemplate = false; boolean isTestTemplate = false;
if (reportType == 0) { // 普通报表 if (reportType == 0) { // 普通报表
isTestTemplate = cellCount <= VALID_CELL_COUNT && floatCount <= 1 && widgetCount <= VALID_WIDGET_COUNT; isTestTemplate = cellCount <= VALID_CELL_COUNT && floatCount <= 1 && widgetCount <= VALID_WIDGET_COUNT;
@ -377,7 +404,7 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM
String name = reader.getTagName(); String name = reader.getTagName();
if (XML_DESIGNER_OPEN_DATE.equals(name)) { if (XML_DESIGNER_OPEN_DATE.equals(name)) {
this.designerOpenDate = reader.getElementValue(); this.designerOpenDate = reader.getElementValue();
} else if(XML_TEMPLATE_INFO_LIST.equals(name)){ } else if (XML_TEMPLATE_INFO_LIST.equals(name)) {
readTemplateInfoList(reader); readTemplateInfoList(reader);
} }
} catch (Exception ex) { } catch (Exception ex) {
@ -411,7 +438,7 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM
writer.end(); writer.end();
} }
private void writeTemplateInfoList(XMLPrintWriter writer){ private void writeTemplateInfoList(XMLPrintWriter writer) {
//启停 //启停
writer.startTAG(XML_TEMPLATE_INFO_LIST); writer.startTAG(XML_TEMPLATE_INFO_LIST);
for (String templateID : templateInfoList.keySet()) { for (String templateID : templateInfoList.keySet()) {
@ -429,13 +456,14 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public TemplateInfo(HashMap<String, Object> templateInfo) { public TemplateInfo(HashMap<String, Object> templateInfo) {
this.dayCount = (int)templateInfo.get(ATTR_DAY_COUNT); this.dayCount = (int) templateInfo.get(ATTR_DAY_COUNT);
this.processMap = (HashMap<String, Object>) templateInfo.get(XML_PROCESS_MAP); this.processMap = (HashMap<String, Object>) templateInfo.get(XML_PROCESS_MAP);
this.consumingMap = (HashMap<String, Object>) templateInfo.get(XML_CONSUMING_MAP); this.consumingMap = (HashMap<String, Object>) templateInfo.get(XML_CONSUMING_MAP);
this.templateID = (String) processMap.get(ATTR_TEMPLATE_ID); this.templateID = (String) processMap.get(ATTR_TEMPLATE_ID);
} }
public TemplateInfo() {} public TemplateInfo() {
}
public String getTemplateID() { public String getTemplateID() {
return templateID; return templateID;
@ -465,24 +493,24 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM
private void writeProcessMap(XMLPrintWriter writer) { private void writeProcessMap(XMLPrintWriter writer) {
writer.startTAG(XML_PROCESS_MAP); writer.startTAG(XML_PROCESS_MAP);
writer.attr(ATTR_PROCESS, (String)processMap.get(ATTR_PROCESS)); writer.attr(ATTR_PROCESS, (String) processMap.get(ATTR_PROCESS));
writer.attr(ATTR_FLOAT_COUNT, (int)processMap.get(ATTR_FLOAT_COUNT)); writer.attr(ATTR_FLOAT_COUNT, (int) processMap.get(ATTR_FLOAT_COUNT));
writer.attr(ATTR_WIDGET_COUNT, (int)processMap.get(ATTR_WIDGET_COUNT)); writer.attr(ATTR_WIDGET_COUNT, (int) processMap.get(ATTR_WIDGET_COUNT));
writer.attr(ATTR_CELL_COUNT, (int)processMap.get(ATTR_CELL_COUNT)); writer.attr(ATTR_CELL_COUNT, (int) processMap.get(ATTR_CELL_COUNT));
writer.attr(ATTR_BLOCK_COUNT, (int)processMap.get(ATTR_BLOCK_COUNT)); writer.attr(ATTR_BLOCK_COUNT, (int) processMap.get(ATTR_BLOCK_COUNT));
writer.attr(ATTR_REPORT_TYPE, (int)processMap.get(ATTR_REPORT_TYPE)); writer.attr(ATTR_REPORT_TYPE, (int) processMap.get(ATTR_REPORT_TYPE));
writer.end(); writer.end();
} }
private void writeConsumingMap(XMLPrintWriter writer) { private void writeConsumingMap(XMLPrintWriter writer) {
writer.startTAG(XML_CONSUMING_MAP); writer.startTAG(XML_CONSUMING_MAP);
writer.attr(ATTR_ACTIVITYKEY, (String)consumingMap.get(ATTR_ACTIVITYKEY)); writer.attr(ATTR_ACTIVITYKEY, (String) consumingMap.get(ATTR_ACTIVITYKEY));
writer.attr(ATTR_JAR_TIME, (String)consumingMap.get(ATTR_JAR_TIME)); writer.attr(ATTR_JAR_TIME, (String) consumingMap.get(ATTR_JAR_TIME));
writer.attr(ATTR_CREATE_TIME, (String)consumingMap.get(ATTR_CREATE_TIME)); writer.attr(ATTR_CREATE_TIME, (String) consumingMap.get(ATTR_CREATE_TIME));
writer.attr(ATTR_UUID, (String)consumingMap.get(ATTR_UUID)); writer.attr(ATTR_UUID, (String) consumingMap.get(ATTR_UUID));
writer.attr(ATTR_TIME_CONSUME, (long)consumingMap.get(ATTR_TIME_CONSUME)); writer.attr(ATTR_TIME_CONSUME, (long) consumingMap.get(ATTR_TIME_CONSUME));
writer.attr(ATTR_VERSION, (String)consumingMap.get(ATTR_VERSION)); writer.attr(ATTR_VERSION, (String) consumingMap.get(ATTR_VERSION));
writer.attr(ATTR_USERNAME, (String)consumingMap.get(ATTR_USERNAME)); writer.attr(ATTR_USERNAME, (String) consumingMap.get(ATTR_USERNAME));
writer.end(); writer.end();
} }
@ -501,7 +529,7 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM
processMap.put(ATTR_BLOCK_COUNT, reader.getAttrAsInt(ATTR_BLOCK_COUNT, 0)); processMap.put(ATTR_BLOCK_COUNT, reader.getAttrAsInt(ATTR_BLOCK_COUNT, 0));
processMap.put(ATTR_REPORT_TYPE, reader.getAttrAsInt(ATTR_REPORT_TYPE, 0)); processMap.put(ATTR_REPORT_TYPE, reader.getAttrAsInt(ATTR_REPORT_TYPE, 0));
processMap.put(ATTR_TEMPLATE_ID, templateID); processMap.put(ATTR_TEMPLATE_ID, templateID);
} else if(XML_CONSUMING_MAP.equals(name)){ } else if (XML_CONSUMING_MAP.equals(name)) {
consumingMap.put(ATTR_ACTIVITYKEY, reader.getAttrAsString(ATTR_ACTIVITYKEY, StringUtils.EMPTY)); consumingMap.put(ATTR_ACTIVITYKEY, reader.getAttrAsString(ATTR_ACTIVITYKEY, StringUtils.EMPTY));
consumingMap.put(ATTR_JAR_TIME, reader.getAttrAsString(ATTR_JAR_TIME, StringUtils.EMPTY)); consumingMap.put(ATTR_JAR_TIME, reader.getAttrAsString(ATTR_JAR_TIME, StringUtils.EMPTY));
consumingMap.put(ATTR_CREATE_TIME, reader.getAttrAsString(ATTR_CREATE_TIME, StringUtils.EMPTY)); consumingMap.put(ATTR_CREATE_TIME, reader.getAttrAsString(ATTR_CREATE_TIME, StringUtils.EMPTY));
@ -518,10 +546,4 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM
} }
} }
public static void main(String[] args) {
TemplateInfoCollector tic = TemplateInfoCollector.getInstance();
tic.sendTemplateInfo();
}
} }

Loading…
Cancel
Save