diff --git a/designer/src/com/fr/design/mainframe/ActiveKeyGenerator.java b/designer/src/com/fr/design/mainframe/ActiveKeyGenerator.java index a653cf6850..3aa4534ce2 100644 --- a/designer/src/com/fr/design/mainframe/ActiveKeyGenerator.java +++ b/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 para = new HashMap(); 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); diff --git a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java index 37fe5f3000..59237baadb 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java +++ b/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()); diff --git a/designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java b/designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java index 65e6dea54d..386ebf0d3d 100644 --- a/designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java +++ b/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,56 +71,59 @@ public class UserInfoLabel extends UILabel { private UserInfoPane userInfoPane; private BBSLoginDialog bbsLoginDialog; + private MouseAdapter userInfoAdapter = new MouseAdapter() { - public UserInfoPane getUserInfoPane() { - return userInfoPane; - } + @Override + public void mouseEntered(MouseEvent e) { + UserInfoLabel.this.setCursor(new Cursor(Cursor.HAND_CURSOR)); + } - public void setUserInfoPane(UserInfoPane userInfoPane) { - this.userInfoPane = userInfoPane; - } + @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 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) { 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资讯框 */ @@ -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(); - } - } - }; } diff --git a/designer/src/com/fr/design/mainframe/bbs/UserInfoPane.java b/designer/src/com/fr/design/mainframe/bbs/UserInfoPane.java index 0b16bbfaba..63267b1e03 100644 --- a/designer/src/com/fr/design/mainframe/bbs/UserInfoPane.java +++ b/designer/src/com/fr/design/mainframe/bbs/UserInfoPane.java @@ -1,11 +1,11 @@ /** - * + * */ 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,159 +28,156 @@ import java.util.Date; /** * @author neil - * * @date: 2015-3-5-上午11:19:50 */ -public class UserInfoPane extends BasicPane{ - - //默认未登录颜色 - 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 int WIDTH = 104; - private static final int HEIGHT = 24; - - //登录成功 - private static final String LOGININ = "0"; - - // 登录框弹出间隔时间 - private static final int LOGIN_DIFF_DAY = 7; - // 等待国际化等相关初始化工作完成之后再弹出登录框 - private static final int WAIT_TIME = 10000; - - 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.setLayout(new BorderLayout()); - - this.userInfoLabel = new UserInfoLabel(this); - - this.markUnSignIn(); - addEnvChangedListener(); - autoPushLoginDialog(); - - this.add(userInfoLabel, BorderLayout.CENTER); - } - - private void addEnvChangedListener(){ - GeneralContext.addEnvChangedListener(new EnvChangedListener() { - @Override - public void envChanged() { - if (DBEnv.isDBEnvAvailable()) { - String username = ServerConfig.getInstance().getBbsUsername(); - if (StringUtils.isEmpty(username)){ - markUnSignIn(); - } else { - markSignIn(username); - } - } - } - }); - } - - - // 计算xml保存的上次弹框时间和当前时间的时间差 - private int getDiffFromLastLogin(){ - String lastBBSTime = DesignerEnvManager.getEnvManager().getLastShowBBSTime(); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - Date lastBBSDate = null; - try { - if(lastBBSTime != null){ - synchronized (this) { - lastBBSDate = sdf.parse(lastBBSTime); - } - Calendar calender = Calendar.getInstance(); - calender.setTime(lastBBSDate); - int dayOld = calender.get(Calendar.DAY_OF_YEAR); - calender.setTime(new Date()); - int dayNew = calender.get(Calendar.DAY_OF_YEAR); - return dayNew - dayOld; - } - } catch (ParseException e) { - FRLogger.getLogger().error(e.getMessage()); - } - return 1; - } - - private void autoPushLoginDialog(){ - Thread showBBSThread = new Thread(new Runnable() { - - @Override - public void run() { - try { - // 等国际化等加载完毕再启动线程弹出登录框 - Thread.sleep(WAIT_TIME); - if(!FRContext.isChineseEnv()){ - return; - } - - //七天弹一次, 如果xml中和当前时间相差小于7天, 就不弹了 - if(getDiffFromLastLogin() < LOGIN_DIFF_DAY){ - return; - } - - } catch (InterruptedException e) { - FRContext.getLogger().error(e.getMessage()); - } - - String userName = ServerConfig.getInstance().getBbsUsername(); - if(StringUtils.isNotEmpty(userName)){ - return; - } - - BBSLoginDialog bbsLoginDialog = userInfoLabel.getBbsLoginDialog(); - if(bbsLoginDialog == null){ - bbsLoginDialog = new BBSLoginDialog(DesignerContext.getDesignerFrame(),userInfoLabel); - userInfoLabel.setBbsLoginDialog(bbsLoginDialog); - } - - bbsLoginDialog.showWindow(); - DesignerEnvManager.getEnvManager().setLastShowBBSTime(DateUtils.DATEFORMAT2.format(new Date())); - } - - }); - showBBSThread.start(); - } - - /** - * 标志未登录状态, 面板设置为灰色 - * - */ - public void markUnSignIn(){ - this.userInfoLabel.setText(Inter.getLocText("FR-Base_UnSignIn")); - this.userInfoLabel.setOpaque(true); - this.userInfoLabel.setBackground(UN_LOGIN_BACKGROUND); - this.userInfoLabel.resetUserName(); - } - - /** - * 标志登陆状态, 面包设置为蓝色 - * @param userName 用户名 - * - */ - public void markSignIn(String userName){ - this.userInfoLabel.setText(userName); - this.userInfoLabel.setUserName(userName); - this.userInfoLabel.setOpaque(true); - this.userInfoLabel.setBackground(LOGIN_BACKGROUND); - } - - @Override - protected String title4PopupWindow() { - return StringUtils.EMPTY; - } +public class UserInfoPane extends BasicPane { + + //默认未登录颜色 + 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 int WIDTH = 104; + private static final int HEIGHT = 24; + + //登录成功 + private static final String LOGININ = "0"; + + // 登录框弹出间隔时间 + private static final int LOGIN_DIFF_DAY = 7; + // 等待国际化等相关初始化工作完成之后再弹出登录框 + private static final int WAIT_TIME = 10000; + + private UserInfoLabel userInfoLabel; + + + /** + * 构造函数 + */ + public UserInfoPane() { + this.setPreferredSize(new Dimension(WIDTH, HEIGHT)); + this.setLayout(new BorderLayout()); + + this.userInfoLabel = new UserInfoLabel(this); + + this.markUnSignIn(); + addEnvChangedListener(); + autoPushLoginDialog(); + + this.add(userInfoLabel, BorderLayout.CENTER); + } + + 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 = MarketConfig.getInstance().getBbsUsername(); + if (StringUtils.isEmpty(username)) { + markUnSignIn(); + } else { + markSignIn(username); + } + } + } + }); + } + + + // 计算xml保存的上次弹框时间和当前时间的时间差 + private int getDiffFromLastLogin() { + String lastBBSTime = DesignerEnvManager.getEnvManager().getLastShowBBSTime(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date lastBBSDate = null; + try { + if (lastBBSTime != null) { + synchronized (this) { + lastBBSDate = sdf.parse(lastBBSTime); + } + Calendar calender = Calendar.getInstance(); + calender.setTime(lastBBSDate); + int dayOld = calender.get(Calendar.DAY_OF_YEAR); + calender.setTime(new Date()); + int dayNew = calender.get(Calendar.DAY_OF_YEAR); + return dayNew - dayOld; + } + } catch (ParseException e) { + FRLogger.getLogger().error(e.getMessage()); + } + return 1; + } + + private void autoPushLoginDialog() { + Thread showBBSThread = new Thread(new Runnable() { + + @Override + public void run() { + try { + // 等国际化等加载完毕再启动线程弹出登录框 + Thread.sleep(WAIT_TIME); + if (!FRContext.isChineseEnv()) { + return; + } + + //七天弹一次, 如果xml中和当前时间相差小于7天, 就不弹了 + if (getDiffFromLastLogin() < LOGIN_DIFF_DAY) { + return; + } + + } catch (InterruptedException e) { + FRContext.getLogger().error(e.getMessage()); + } + + String userName = MarketConfig.getInstance().getBbsUsername(); + if (StringUtils.isNotEmpty(userName)) { + return; + } + + BBSLoginDialog bbsLoginDialog = userInfoLabel.getBbsLoginDialog(); + if (bbsLoginDialog == null) { + bbsLoginDialog = new BBSLoginDialog(DesignerContext.getDesignerFrame(), userInfoLabel); + userInfoLabel.setBbsLoginDialog(bbsLoginDialog); + } + + bbsLoginDialog.showWindow(); + DesignerEnvManager.getEnvManager().setLastShowBBSTime(DateUtils.DATEFORMAT2.format(new Date())); + } + + }); + showBBSThread.start(); + } + + /** + * 标志未登录状态, 面板设置为灰色 + */ + public void markUnSignIn() { + this.userInfoLabel.setText(Inter.getLocText("FR-Base_UnSignIn")); + this.userInfoLabel.setOpaque(true); + this.userInfoLabel.setBackground(UN_LOGIN_BACKGROUND); + this.userInfoLabel.resetUserName(); + } + + /** + * 标志登陆状态, 面包设置为蓝色 + * + * @param userName 用户名 + */ + public void markSignIn(String userName) { + this.userInfoLabel.setText(userName); + this.userInfoLabel.setUserName(userName); + this.userInfoLabel.setOpaque(true); + this.userInfoLabel.setBackground(LOGIN_BACKGROUND); + } + + @Override + protected String title4PopupWindow() { + return StringUtils.EMPTY; + } } \ No newline at end of file diff --git a/designer/src/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java b/designer/src/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java index 59a5a95e3a..ef2c627304 100644 --- a/designer/src/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java +++ b/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(); } diff --git a/designer_base/src/com/fr/design/bbs/BBSLoginUtils.java b/designer_base/src/com/fr/design/bbs/BBSLoginUtils.java index ce98acdb62..8e8b5bd568 100644 --- a/designer_base/src/com/fr/design/bbs/BBSLoginUtils.java +++ b/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 list){ - try{ + public static void bbsLogin(List 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()); } } diff --git a/designer_base/src/com/fr/design/extra/LoginWebBridge.java b/designer_base/src/com/fr/design/extra/LoginWebBridge.java index 07114d3945..30f90d13c1 100644 --- a/designer_base/src/com/fr/design/extra/LoginWebBridge.java +++ b/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); diff --git a/designer_base/src/com/fr/design/extra/PluginFromStorePane.java b/designer_base/src/com/fr/design/extra/PluginFromStorePane.java index 17d13eb699..fe8b2a9dd3 100644 --- a/designer_base/src/com/fr/design/extra/PluginFromStorePane.java +++ b/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, 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, 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 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> 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 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> templateInfoList; + private String designerOpenDate; //设计器最近一次打开日期 @SuppressWarnings("unchecked") @@ -65,21 +88,6 @@ public class TemplateInfoCollector 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 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 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 implements Serializable, XM @SuppressWarnings("unchecked") public String loadProcess(T t) { HashMap processMap = (HashMap) 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 implements Serializable, XM if (designerOpenFirstTime()) { for (String key : templateInfoList.keySet()) { HashMap 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 implements Serializable, XM templateInfo = templateInfoList.get(t.getTemplateID()); // 更新 conusmingMap HashMap consumingMap = (HashMap) 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 implements Serializable, XM private HashMap getNewConsumingMap(String templateID, long openTime, long timeConsume) { HashMap 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()); @@ -303,7 +330,7 @@ public class TemplateInfoCollector implements Serializable, XM return false; } - String res = httpClient.getResponseText(); + String res = httpClient.getResponseText(); boolean success; try { success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success"); @@ -322,7 +349,7 @@ public class TemplateInfoCollector implements Serializable, XM ArrayList testTemplateKeys = new ArrayList<>(); // 保存测试模板的key for (String key : templateInfoList.keySet()) { HashMap 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 implements Serializable, XM @SuppressWarnings("unchecked") private boolean isTestTemplate(HashMap templateInfo) { HashMap processMap = (HashMap) 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 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 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 implements Serializable, XM @SuppressWarnings("unchecked") public TemplateInfo(HashMap templateInfo) { - this.dayCount = (int)templateInfo.get(ATTR_DAY_COUNT); + this.dayCount = (int) templateInfo.get(ATTR_DAY_COUNT); this.processMap = (HashMap) templateInfo.get(XML_PROCESS_MAP); this.consumingMap = (HashMap) 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 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 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 implements Serializable, XM } } - - - public static void main(String[] args) { - TemplateInfoCollector tic = TemplateInfoCollector.getInstance(); - tic.sendTemplateInfo(); - } }