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. 181
      designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java
  4. 27
      designer/src/com/fr/design/mainframe/bbs/UserInfoPane.java
  5. 5
      designer/src/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java
  6. 22
      designer_base/src/com/fr/design/bbs/BBSLoginUtils.java
  7. 50
      designer_base/src/com/fr/design/extra/LoginWebBridge.java
  8. 21
      designer_base/src/com/fr/design/extra/PluginFromStorePane.java
  9. 4
      designer_base/src/com/fr/design/extra/PluginOperateUtils.java
  10. 19
      designer_base/src/com/fr/design/extra/PluginUpdatePane.java
  11. 6
      designer_base/src/com/fr/design/extra/PluginWebBridge.java
  12. 94
      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();
}
}
};
}

27
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,7 +28,6 @@ import java.util.Date;
/**
* @author neil
*
* @date: 2015-3-5-上午11:19:50
*/
public class UserInfoPane extends BasicPane {
@ -50,15 +49,6 @@ public class UserInfoPane extends BasicPane{
private UserInfoLabel userInfoLabel;
public UserInfoLabel getUserInfoLabel() {
return userInfoLabel;
}
public void setUserInfoLabel(UserInfoLabel userInfoLabel) {
this.userInfoLabel = userInfoLabel;
}
/**
* 构造函数
*/
@ -75,12 +65,20 @@ public class UserInfoPane extends BasicPane{
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 = ServerConfig.getInstance().getBbsUsername();
String username = MarketConfig.getInstance().getBbsUsername();
if (StringUtils.isEmpty(username)) {
markUnSignIn();
} else {
@ -136,7 +134,7 @@ public class UserInfoPane extends BasicPane{
FRContext.getLogger().error(e.getMessage());
}
String userName = ServerConfig.getInstance().getBbsUsername();
String userName = MarketConfig.getInstance().getBbsUsername();
if (StringUtils.isNotEmpty(userName)) {
return;
}
@ -157,7 +155,6 @@ public class UserInfoPane extends BasicPane{
/**
* 标志未登录状态, 面板设置为灰色
*
*/
public void markUnSignIn() {
this.userInfoLabel.setText(Inter.getLocText("FR-Base_UnSignIn"));
@ -168,8 +165,8 @@ public class UserInfoPane extends BasicPane{
/**
* 标志登陆状态, 面包设置为蓝色
* @param userName 用户名
*
* @param userName 用户名
*/
public void markSignIn(String userName) {
this.userInfoLabel.setText(userName);

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();
}

22
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;
@ -13,8 +13,8 @@ public class BBSLoginUtils {
public static void bbsLogin(String username, String password) {
try {
ServerConfig.getInstance().setBbsUsername(username);
ServerConfig.getInstance().setBbsPassword(password);
MarketConfig.getInstance().setBbsUsername(username);
MarketConfig.getInstance().setBbsPassword(password);
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage());
}
@ -25,10 +25,10 @@ public class BBSLoginUtils {
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);
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());
}
@ -36,10 +36,10 @@ public class BBSLoginUtils {
public static void bbsLogout() {
try {
ServerConfig.getInstance().setBbsUsername(StringUtils.EMPTY);
ServerConfig.getInstance().setBbsPassword(StringUtils.EMPTY);
ServerConfig.getInstance().setBbsUid(0);
ServerConfig.getInstance().setInShowBBsName(StringUtils.EMPTY);
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);

21
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) {

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"));

19
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,10 +175,10 @@ 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())) {
if (StringUtils.isNotEmpty(MarketConfig.getInstance().getBbsUsername())) {
try {
PluginView plugin = controlPane.getSelectedPlugin();
PluginMarker pluginMarker = PluginMarker.create(plugin.getID(), plugin.getVersion());
@ -182,7 +186,8 @@ public class PluginUpdatePane extends PluginAbstractLoadingViewPane<List<PluginV
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"));
}

94
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);
}
/**
* 获取缓存文件存放路径
*/
@ -138,6 +146,26 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM
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;
@ -218,8 +246,7 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM
HashMap<String, Object> consumingMap = (HashMap<String, Object>) templateInfo.get(XML_CONSUMING_MAP);
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());
@ -435,7 +462,8 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM
this.templateID = (String) processMap.get(ATTR_TEMPLATE_ID);
}
public TemplateInfo() {}
public TemplateInfo() {
}
public String getTemplateID() {
return templateID;
@ -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