Browse Source

Merge remote-tracking branch 'origin/feature/10.0' into feature/10.0

master
RichieJi 7 years ago
parent
commit
9c7cbd52ef
  1. 4
      designer/src/com/fr/design/mainframe/ActiveKeyGenerator.java
  2. 8
      designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  3. 181
      designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java
  4. 55
      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. 150
      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;
import com.fr.config.ServerConfig;
import com.fr.config.MarketConfig;
import com.fr.design.DesignerEnvManager;
import com.fr.general.SiteCenter;
import com.fr.general.http.HttpClient;
@ -101,7 +101,7 @@ public class ActiveKeyGenerator {
HashMap<String, String> para = new HashMap<String, String>();
para.put("uuid", envManager.getUUID());
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);
if (timeout != -1) {
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.fr.base.FRContext;
import com.fr.config.ServerConfig;
import com.fr.config.MarketConfig;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.help.alphafine.AlphaFineConfigManager;
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.DocumentSearchManager;
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.RecentSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.RecommendSearchManager;
import com.fr.form.main.Form;
import com.fr.form.main.FormIO;
@ -402,6 +402,7 @@ public class AlphaFineDialog extends UIDialog {
/**
* 处理搜索字符串
*
* @param searchText
*/
private void dealWithSearchText(String searchText) {
@ -422,6 +423,7 @@ public class AlphaFineDialog extends UIDialog {
/**
* 截取字符串中关键词
*
* @param searchText
* @return
*/
@ -775,7 +777,7 @@ public class AlphaFineDialog extends UIDialog {
*/
private void sendDataToServer(String searchKey, AlphaCellModel cellModel) {
if (cellModel.isNeedToSendToServer()) {
String username = ServerConfig.getInstance().getBbsUsername();
String username = MarketConfig.getInstance().getBbsUsername();
String uuid = DesignerEnvManager.getEnvManager().getUUID();
String activityKey = DesignerEnvManager.getEnvManager().getActivationKey();
String createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(Calendar.getInstance().getTime());

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

@ -4,7 +4,7 @@
package com.fr.design.mainframe.bbs;
import com.fr.base.FRContext;
import com.fr.config.ServerConfig;
import com.fr.config.MarketConfig;
import com.fr.design.DesignerEnvManager;
import com.fr.design.bbs.BBSLoginUtils;
import com.fr.design.extra.LoginContextListener;
@ -71,54 +71,57 @@ public class UserInfoLabel extends UILabel {
private UserInfoPane userInfoPane;
private BBSLoginDialog bbsLoginDialog;
private MouseAdapter userInfoAdapter = new MouseAdapter() {
public UserInfoPane getUserInfoPane() {
return userInfoPane;
}
public void setUserInfoPane(UserInfoPane userInfoPane) {
this.userInfoPane = userInfoPane;
@Override
public void mouseEntered(MouseEvent e) {
UserInfoLabel.this.setCursor(new Cursor(Cursor.HAND_CURSOR));
}
public BBSLoginDialog getBbsLoginDialog() {
return bbsLoginDialog;
}
@Override
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 void setBbsLoginDialog(BBSLoginDialog bbsLoginDialog) {
this.bbsLoginDialog = 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 UserInfoLabel(UserInfoPane 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() {
});
//切换账号
UIMenuItem closeOther = new UIMenuItem(Inter.getLocText("FR-Designer-BBSLogin_Switch-Account"));
closeOther.addMouseListener(new MouseAdapter() {
@Override
public void showLoginContext() {
WebViewDlgHelper.createLoginDialog();
clearLoginInformation();
updateInfoPane();
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();
}
private void clearLoginInformation() {
BBSLoginUtils.bbsLogout();
}
};
private void updateInfoPane() {
userInfoPane.markUnSignIn();
public UserInfoLabel(UserInfoPane userInfoPane) {
init(userInfoPane);
}
/**
@ -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) {
try {
Thread.sleep(millis);
@ -182,13 +230,6 @@ public class UserInfoLabel extends UILabel {
return userName;
}
/**
* 重置当前用户名
*/
public void resetUserName() {
this.userName = StringUtils.EMPTY;
}
public void setUserName(String userName) {
if (StringUtils.isEmpty(userName)) {
return;
@ -197,6 +238,13 @@ public class UserInfoLabel extends UILabel {
this.userName = userName;
}
/**
* 重置当前用户名
*/
public void resetUserName() {
this.userName = StringUtils.EMPTY;
}
private String encode(String str) {
try {
return URLEncoder.encode(str, EncodeConstants.ENCODING_UTF_8);
@ -228,53 +276,4 @@ public class UserInfoLabel extends UILabel {
//更新面板Text
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();
}
}
};
}

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

@ -5,7 +5,7 @@ package com.fr.design.mainframe.bbs;
import com.fr.base.FRContext;
import com.fr.config.DBEnv;
import com.fr.config.ServerConfig;
import com.fr.config.MarketConfig;
import com.fr.design.DesignerEnvManager;
import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.BasicPane;
@ -28,10 +28,9 @@ import java.util.Date;
/**
* @author neil
*
* @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;
@ -50,20 +49,11 @@ public class UserInfoPane extends BasicPane{
private UserInfoLabel userInfoLabel;
public UserInfoLabel getUserInfoLabel() {
return userInfoLabel;
}
public void setUserInfoLabel(UserInfoLabel userInfoLabel) {
this.userInfoLabel = userInfoLabel;
}
/**
* 构造函数
*/
public UserInfoPane() {
this.setPreferredSize(new Dimension(WIDTH,HEIGHT));
this.setPreferredSize(new Dimension(WIDTH, HEIGHT));
this.setLayout(new BorderLayout());
this.userInfoLabel = new UserInfoLabel(this);
@ -75,13 +65,21 @@ public class UserInfoPane extends BasicPane{
this.add(userInfoLabel, BorderLayout.CENTER);
}
private void addEnvChangedListener(){
public UserInfoLabel getUserInfoLabel() {
return userInfoLabel;
}
public void setUserInfoLabel(UserInfoLabel userInfoLabel) {
this.userInfoLabel = userInfoLabel;
}
private void addEnvChangedListener() {
GeneralContext.addEnvChangedListener(new EnvChangedListener() {
@Override
public void envChanged() {
if (DBEnv.isDBEnvAvailable()) {
String username = ServerConfig.getInstance().getBbsUsername();
if (StringUtils.isEmpty(username)){
String username = MarketConfig.getInstance().getBbsUsername();
if (StringUtils.isEmpty(username)) {
markUnSignIn();
} else {
markSignIn(username);
@ -93,12 +91,12 @@ public class UserInfoPane extends BasicPane{
// 计算xml保存的上次弹框时间和当前时间的时间差
private int getDiffFromLastLogin(){
private int getDiffFromLastLogin() {
String lastBBSTime = DesignerEnvManager.getEnvManager().getLastShowBBSTime();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date lastBBSDate = null;
try {
if(lastBBSTime != null){
if (lastBBSTime != null) {
synchronized (this) {
lastBBSDate = sdf.parse(lastBBSTime);
}
@ -115,7 +113,7 @@ public class UserInfoPane extends BasicPane{
return 1;
}
private void autoPushLoginDialog(){
private void autoPushLoginDialog() {
Thread showBBSThread = new Thread(new Runnable() {
@Override
@ -123,12 +121,12 @@ public class UserInfoPane extends BasicPane{
try {
// 等国际化等加载完毕再启动线程弹出登录框
Thread.sleep(WAIT_TIME);
if(!FRContext.isChineseEnv()){
if (!FRContext.isChineseEnv()) {
return;
}
//七天弹一次, 如果xml中和当前时间相差小于7天, 就不弹了
if(getDiffFromLastLogin() < LOGIN_DIFF_DAY){
if (getDiffFromLastLogin() < LOGIN_DIFF_DAY) {
return;
}
@ -136,14 +134,14 @@ public class UserInfoPane extends BasicPane{
FRContext.getLogger().error(e.getMessage());
}
String userName = ServerConfig.getInstance().getBbsUsername();
if(StringUtils.isNotEmpty(userName)){
String userName = MarketConfig.getInstance().getBbsUsername();
if (StringUtils.isNotEmpty(userName)) {
return;
}
BBSLoginDialog bbsLoginDialog = userInfoLabel.getBbsLoginDialog();
if(bbsLoginDialog == null){
bbsLoginDialog = new BBSLoginDialog(DesignerContext.getDesignerFrame(),userInfoLabel);
if (bbsLoginDialog == null) {
bbsLoginDialog = new BBSLoginDialog(DesignerContext.getDesignerFrame(), userInfoLabel);
userInfoLabel.setBbsLoginDialog(bbsLoginDialog);
}
@ -157,9 +155,8 @@ public class UserInfoPane extends BasicPane{
/**
* 标志未登录状态, 面板设置为灰色
*
*/
public void markUnSignIn(){
public void markUnSignIn() {
this.userInfoLabel.setText(Inter.getLocText("FR-Base_UnSignIn"));
this.userInfoLabel.setOpaque(true);
this.userInfoLabel.setBackground(UN_LOGIN_BACKGROUND);
@ -168,10 +165,10 @@ public class UserInfoPane extends BasicPane{
/**
* 标志登陆状态, 面包设置为蓝色
* @param userName 用户名
*
* @param userName 用户名
*/
public void markSignIn(String userName){
public void markSignIn(String userName) {
this.userInfoLabel.setText(userName);
this.userInfoLabel.setUserName(userName);
this.userInfoLabel.setOpaque(true);

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.io.IOFile;
import com.fr.base.io.XMLReadHelper;
import com.fr.config.ServerConfig;
import com.fr.config.MarketConfig;
import com.fr.design.DesignerEnvManager;
import com.fr.general.FRLogLevel;
import com.fr.general.FRLogManager;
import com.fr.general.Inter;
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");
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
this.username = ServerConfig.getInstance().getBbsUsername();
this.username = MarketConfig.getInstance().getBbsUsername();
this.uuid = envManager.getUUID();
this.activekey = envManager.getActivationKey();
}

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

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

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

@ -1,7 +1,7 @@
package com.fr.design.extra;
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.dialog.UIDialog;
import com.fr.design.extra.exe.PluginLoginExecutor;
@ -20,7 +20,8 @@ import netscape.javascript.JSObject;
import javax.swing.JDialog;
import javax.swing.SwingUtilities;
import java.awt.*;
import java.awt.Color;
import java.awt.Desktop;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URLEncoder;
@ -38,8 +39,6 @@ public class LoginWebBridge {
private static final String SUCCESS_MESSAGE_STATUS = "ok";
//数据通讯失败
private static final String FAILED_MESSAGE_STATUS = "error";
//消息条数
private int messageCount;
//最低消息的条数
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_FAILED = "failed";
private static final Color LOGIN_BACKGROUND = new Color(184, 220, 242);
private static LoginWebBridge helper;
//消息条数
private int messageCount;
private UIDialog uiDialog;
private UIDialog qqDialog;
private UILabel uiLabel;
@ -94,6 +94,26 @@ public class LoginWebBridge {
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) {
closeQQWindow();
this.qqDialog = qqDialog;
@ -118,26 +138,6 @@ public class LoginWebBridge {
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) {
try {
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;
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.gui.frpane.UITabbedPane;
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.view.PluginView;
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 java.io.File;
import java.util.List;
@ -25,13 +30,12 @@ import java.util.List;
* @since 8.0
*/
public class PluginFromStorePane extends PluginAbstractLoadingViewPane<List<PluginView>, Void> {
private static final int LISTNUM1 = 1;
private static final int LISTNUM100 = 100;
private UILabel errorMsgLabel;
private UITabbedPane tabbedPane;
private PluginControlPane controlPane;
private static final int LISTNUM1 = 1;
private static final int LISTNUM100 = 100;
public PluginFromStorePane(final UITabbedPane tabbedPane) {
super(tabbedPane);
@ -180,7 +184,8 @@ public class PluginFromStorePane extends PluginAbstractLoadingViewPane<List<Plug
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Install_Successful"));
} else {
JOptionPane.showMessageDialog(null, PluginUtils.getMessageByErrorCode(result.errorCode()), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
} }
}
}
});
} catch (Exception e1) {
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) {
if (!StringUtils.isNotEmpty(ServerConfig.getInstance().getBbsUsername())) {
if (!StringUtils.isNotEmpty(MarketConfig.getInstance().getBbsUsername())) {
LoginCheckContext.fireLoginCheckListener();
}
if (StringUtils.isNotEmpty(ServerConfig.getInstance().getBbsUsername())) {
if (StringUtils.isNotEmpty(MarketConfig.getInstance().getBbsUsername())) {
PluginView plugin = controlPane.getSelectedPlugin();
String id = null;
if (plugin != null) {
@ -201,7 +206,7 @@ public class PluginFromStorePane extends PluginAbstractLoadingViewPane<List<Plug
try {
PluginMarker pluginMarker = PluginMarker.create(id, plugin.getVersion());
JSONObject latestPluginInfo = PluginUtils.getLatestPluginInfo(id);
String latestPluginVersion = (String)latestPluginInfo.get("version");
String latestPluginVersion = (String) latestPluginInfo.get("version");
PluginMarker toPluginMarker = PluginMarker.create(id, latestPluginVersion);
PluginManager.getController().download(pluginMarker, new UpdateOnlineCallback(pluginMarker, toPluginMarker, pane));
} catch (Exception e) {

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

@ -1,7 +1,7 @@
package com.fr.design.extra;
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.InstallOnlineCallback;
import com.fr.design.extra.exe.callback.JSCallback;
@ -167,7 +167,7 @@ public class PluginOperateUtils {
}
public static void getLoginInfo(JSCallback jsCallback, UILabel uiLabel) {
String username = ServerConfig.getInstance().getBbsUsername();
String username = MarketConfig.getInstance().getBbsUsername();
if (StringUtils.isEmpty(username)) {
jsCallback.execute(StringUtils.EMPTY);
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;
import com.fr.config.ServerConfig;
import com.fr.config.MarketConfig;
import com.fr.design.extra.tradition.callback.UpdateOnlineCallback;
import com.fr.design.gui.frpane.UITabbedPane;
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.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 java.io.File;
import java.util.List;
@ -26,12 +31,11 @@ import java.util.List;
*/
public class PluginUpdatePane extends PluginAbstractLoadingViewPane<List<PluginView>, Void> {
private static final int PERSENT = 100;
private PluginControlPane controlPane;
private JLabel errorMsgLabel;
private UITabbedPane tabbedPane;
private static final int PERSENT = 100;
public PluginUpdatePane(UITabbedPane tabbedPane) {
super(tabbedPane);
this.tabbedPane = tabbedPane;
@ -171,18 +175,19 @@ public class PluginUpdatePane extends PluginAbstractLoadingViewPane<List<PluginV
}
private void doUpdateOnline(final PluginStatusCheckCompletePane pane) {
if (!StringUtils.isNotEmpty(ServerConfig.getInstance().getBbsUsername())) {
if (!StringUtils.isNotEmpty(MarketConfig.getInstance().getBbsUsername())) {
LoginCheckContext.fireLoginCheckListener();
}
if (StringUtils.isNotEmpty(ServerConfig.getInstance().getBbsUsername())) {
try{
if (StringUtils.isNotEmpty(MarketConfig.getInstance().getBbsUsername())) {
try {
PluginView plugin = controlPane.getSelectedPlugin();
PluginMarker pluginMarker = PluginMarker.create(plugin.getID(), plugin.getVersion());
JSONObject latestPluginInfo = PluginUtils.getLatestPluginInfo(pluginMarker.getPluginID());
String latestPluginVersion = (String) latestPluginInfo.get("version");
PluginMarker toPluginMarker = PluginMarker.create(pluginMarker.getPluginID(), latestPluginVersion);
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;
import com.fr.base.FRContext;
import com.fr.config.ServerConfig;
import com.fr.config.MarketConfig;
import com.fr.design.RestartHelper;
import com.fr.design.bbs.BBSLoginUtils;
import com.fr.design.dialog.UIDialog;
@ -422,7 +422,7 @@ public class PluginWebBridge {
*/
public String getLoginInfo(final JSObject callback) {
registerLoginInfo(callback);
return ServerConfig.getInstance().getBbsUsername();
return MarketConfig.getInstance().getBbsUsername();
}
/**
@ -557,7 +557,7 @@ public class PluginWebBridge {
* 清除用户信息
*/
public void clearUserInfo() {
ServerConfig.getInstance().setInShowBBsName(StringUtils.EMPTY);
MarketConfig.getInstance().setInShowBBsName(StringUtils.EMPTY);
BBSLoginUtils.bbsLogout();
uiLabel.setText(Inter.getLocText("FR-Base_UnSignIn"));
}

150
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.io.IOFile;
import com.fr.config.ServerConfig;
import com.fr.config.MarketConfig;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.SiteCenterToken;
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.stable.*;
import com.fr.stable.xml.*;
import com.fr.third.javax.xml.stream.XMLStreamException;
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.util.*;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
/**
* 做模板的过程和耗时收集辅助类
* Created by plough on 2017/2/21.
*/
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 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_WIDGET_COUNT = 5; // 有效报表模板的控件数
private static final int COMPLETE_DAY_COUNT = 15; // 判断模板是否完成的天数
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_TEMPLATE_INFO_LIST = "TemplateInfoList";
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 JSON_CONSUMING_MAP = "jsonConsumingMap";
private static final String JSON_PROCESS_MAP = "jsonProcessMap";
private static TemplateInfoCollector instance;
private Map<String, HashMap<String, Object>> templateInfoList;
private String designerOpenDate; //设计器最近一次打开日期
@SuppressWarnings("unchecked")
@ -65,21 +88,6 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM
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;
}
private static void readXMLFile(XMLReadable xmlReadable, File xmlFile){
private static void readXMLFile(XMLReadable xmlReadable, File xmlFile) {
if (xmlFile == null || !xmlFile.exists()) {
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);
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() {
if (FRContext.getCurrentEnv() instanceof RemoteEnv) { // 远程设计不收集数据
return false;
@ -161,7 +189,7 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM
@SuppressWarnings("unchecked")
public String loadProcess(T t) {
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()) {
for (String key : templateInfoList.keySet()) {
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);
}
setDesignerOpenDate();
@ -216,10 +244,9 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM
templateInfo = templateInfoList.get(t.getTemplateID());
// 更新 conusmingMap
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);
}
else { // 新增
} else { // 新增
templateInfo = new HashMap<>();
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) {
HashMap<String, Object> consumingMap = new HashMap<>();
String username = ServerConfig.getInstance().getBbsUsername();
String username = MarketConfig.getInstance().getBbsUsername();
String uuid = DesignerEnvManager.getEnvManager().getUUID();
String activitykey = DesignerEnvManager.getEnvManager().getActivationKey();
String createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(Calendar.getInstance().getTime());
@ -322,7 +349,7 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM
ArrayList<String> testTemplateKeys = new ArrayList<>(); // 保存测试模板的key
for (String key : templateInfoList.keySet()) {
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;
}
if (isTestTemplate(templateInfo)) {
@ -353,11 +380,11 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM
@SuppressWarnings("unchecked")
private boolean isTestTemplate(HashMap<String, Object> templateInfo) {
HashMap<String, Object> processMap = (HashMap<String, Object>) templateInfo.get(XML_PROCESS_MAP);
int reportType = (int)processMap.get(ATTR_REPORT_TYPE);
int cellCount = (int)processMap.get(ATTR_CELL_COUNT);
int floatCount = (int)processMap.get(ATTR_FLOAT_COUNT);
int blockCount = (int)processMap.get(ATTR_BLOCK_COUNT);
int widgetCount = (int)processMap.get(ATTR_WIDGET_COUNT);
int reportType = (int) processMap.get(ATTR_REPORT_TYPE);
int cellCount = (int) processMap.get(ATTR_CELL_COUNT);
int floatCount = (int) processMap.get(ATTR_FLOAT_COUNT);
int blockCount = (int) processMap.get(ATTR_BLOCK_COUNT);
int widgetCount = (int) processMap.get(ATTR_WIDGET_COUNT);
boolean isTestTemplate = false;
if (reportType == 0) { // 普通报表
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();
if (XML_DESIGNER_OPEN_DATE.equals(name)) {
this.designerOpenDate = reader.getElementValue();
} else if(XML_TEMPLATE_INFO_LIST.equals(name)){
} else if (XML_TEMPLATE_INFO_LIST.equals(name)) {
readTemplateInfoList(reader);
}
} catch (Exception ex) {
@ -411,7 +438,7 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM
writer.end();
}
private void writeTemplateInfoList(XMLPrintWriter writer){
private void writeTemplateInfoList(XMLPrintWriter writer) {
//启停
writer.startTAG(XML_TEMPLATE_INFO_LIST);
for (String templateID : templateInfoList.keySet()) {
@ -429,13 +456,14 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM
@SuppressWarnings("unchecked")
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.consumingMap = (HashMap<String, Object>) templateInfo.get(XML_CONSUMING_MAP);
this.templateID = (String) processMap.get(ATTR_TEMPLATE_ID);
}
public TemplateInfo() {}
public TemplateInfo() {
}
public String getTemplateID() {
return templateID;
@ -465,24 +493,24 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM
private void writeProcessMap(XMLPrintWriter writer) {
writer.startTAG(XML_PROCESS_MAP);
writer.attr(ATTR_PROCESS, (String)processMap.get(ATTR_PROCESS));
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_CELL_COUNT, (int)processMap.get(ATTR_CELL_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_PROCESS, (String) processMap.get(ATTR_PROCESS));
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_CELL_COUNT, (int) processMap.get(ATTR_CELL_COUNT));
writer.attr(ATTR_BLOCK_COUNT, (int) processMap.get(ATTR_BLOCK_COUNT));
writer.attr(ATTR_REPORT_TYPE, (int) processMap.get(ATTR_REPORT_TYPE));
writer.end();
}
private void writeConsumingMap(XMLPrintWriter writer) {
writer.startTAG(XML_CONSUMING_MAP);
writer.attr(ATTR_ACTIVITYKEY, (String)consumingMap.get(ATTR_ACTIVITYKEY));
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_UUID, (String)consumingMap.get(ATTR_UUID));
writer.attr(ATTR_TIME_CONSUME, (long)consumingMap.get(ATTR_TIME_CONSUME));
writer.attr(ATTR_VERSION, (String)consumingMap.get(ATTR_VERSION));
writer.attr(ATTR_USERNAME, (String)consumingMap.get(ATTR_USERNAME));
writer.attr(ATTR_ACTIVITYKEY, (String) consumingMap.get(ATTR_ACTIVITYKEY));
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_UUID, (String) consumingMap.get(ATTR_UUID));
writer.attr(ATTR_TIME_CONSUME, (long) consumingMap.get(ATTR_TIME_CONSUME));
writer.attr(ATTR_VERSION, (String) consumingMap.get(ATTR_VERSION));
writer.attr(ATTR_USERNAME, (String) consumingMap.get(ATTR_USERNAME));
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_REPORT_TYPE, reader.getAttrAsInt(ATTR_REPORT_TYPE, 0));
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_JAR_TIME, reader.getAttrAsString(ATTR_JAR_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