Browse Source

Merge pull request #587 in BA/design from ~VITO/design:master to master

* commit '86bea80f192d53f286b25b423a78d8c350a72565':
  REPORT-1181 mac10.12和javafx弹出框初始化时会有大几率卡死在native方法,这里先屏蔽一下。
master
superman 8 years ago
parent
commit
2d164d9a82
  1. 48
      designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java

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

@ -18,6 +18,7 @@ import com.fr.general.Inter;
import com.fr.general.SiteCenter; import com.fr.general.SiteCenter;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.stable.EncodeConstants; import com.fr.stable.EncodeConstants;
import com.fr.stable.OperatingSystem;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -34,10 +35,9 @@ import java.util.HashMap;
/** /**
* @author neil * @author neil
*
* @date: 2015-3-4-上午9:05:52 * @date: 2015-3-4-上午9:05:52
*/ */
public class UserInfoLabel extends UILabel{ public class UserInfoLabel extends UILabel {
//默认查询消息时间, 30s //默认查询消息时间, 30s
private static final long CHECK_MESSAGE_TIME = 30 * 1000L; private static final long CHECK_MESSAGE_TIME = 30 * 1000L;
@ -109,7 +109,7 @@ public class UserInfoLabel extends UILabel{
@Override @Override
public void showLoginContext() { public void showLoginContext() {
LoginPane managerPane = new LoginPane(); LoginPane managerPane = new LoginPane();
UIDialog qqdlg = new LoginDialog(DesignerContext.getDesignerFrame(),managerPane); UIDialog qqdlg = new LoginDialog(DesignerContext.getDesignerFrame(), managerPane);
LoginWebBridge.getHelper().setDialogHandle(qqdlg); LoginWebBridge.getHelper().setDialogHandle(qqdlg);
LoginWebBridge.getHelper().setUILabel(UserInfoLabel.this); LoginWebBridge.getHelper().setUILabel(UserInfoLabel.this);
QQLoginWebBridge.getHelper().setLoginlabel(); QQLoginWebBridge.getHelper().setLoginlabel();
@ -120,26 +120,27 @@ public class UserInfoLabel extends UILabel{
}); });
} }
private void clearLoginInformation(){ private void clearLoginInformation() {
DesignerEnvManager.getEnvManager().setBBSName(StringUtils.EMPTY); DesignerEnvManager.getEnvManager().setBBSName(StringUtils.EMPTY);
DesignerEnvManager.getEnvManager().setBBSPassword(StringUtils.EMPTY); DesignerEnvManager.getEnvManager().setBBSPassword(StringUtils.EMPTY);
DesignerEnvManager.getEnvManager().setInShowBBsName(StringUtils.EMPTY); DesignerEnvManager.getEnvManager().setInShowBBsName(StringUtils.EMPTY);
DesignerEnvManager.getEnvManager().setBbsUid(DEFAULT_BBS_UID); DesignerEnvManager.getEnvManager().setBbsUid(DEFAULT_BBS_UID);
} }
private void updateInfoPane(){ private void updateInfoPane() {
userInfoPane.markUnSignIn(); userInfoPane.markUnSignIn();
} }
/** /**
* showBBSDialog 弹出BBS资讯框 * showBBSDialog 弹出BBS资讯框
*/ */
public static void showBBSDialog(){ public static void showBBSDialog() {
Thread showBBSThread = new Thread(new Runnable() { Thread showBBSThread = new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
if(!FRContext.isChineseEnv()){ // vito:最新mac10.12和javafx弹出框初始化时会有大几率卡死在native方法,这里先屏蔽一下。
if (!FRContext.isChineseEnv() || OperatingSystem.isMacOS()) {
return; return;
} }
String lastBBSNewsTime = DesignerEnvManager.getEnvManager().getLastShowBBSNewsTime(); String lastBBSNewsTime = DesignerEnvManager.getEnvManager().getLastShowBBSNewsTime();
@ -153,11 +154,11 @@ public class UserInfoLabel extends UILabel{
FRContext.getLogger().error(e.getMessage()); FRContext.getLogger().error(e.getMessage());
} }
HttpClient hc = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("bbs.popup")); HttpClient hc = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("bbs.popup"));
if (!hc.isServerAlive()){ if (!hc.isServerAlive()) {
return; return;
} }
String res = hc.getResponseText(); String res = hc.getResponseText();
if (res.indexOf(BBSConstants.UPDATE_KEY) == -1){ if (res.indexOf(BBSConstants.UPDATE_KEY) == -1) {
return; return;
} }
try { try {
@ -171,7 +172,7 @@ public class UserInfoLabel extends UILabel{
showBBSThread.start(); showBBSThread.start();
} }
private void sleep(long millis){ private void sleep(long millis) {
try { try {
Thread.sleep(millis); Thread.sleep(millis);
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -185,18 +186,17 @@ public class UserInfoLabel extends UILabel{
/** /**
* 重置当前用户名 * 重置当前用户名
*
*/ */
public void resetUserName(){ public void resetUserName() {
this.userName = StringUtils.EMPTY; this.userName = StringUtils.EMPTY;
} }
public void setUserName(String userName) { public void setUserName(String userName) {
if(StringUtils.isEmpty(userName)){ if (StringUtils.isEmpty(userName)) {
return; return;
} }
if(StringUtils.isEmpty(this.userName)){ if (StringUtils.isEmpty(this.userName)) {
updateMessageCount(); updateMessageCount();
} }
//往designerenvmanger里写一下 //往designerenvmanger里写一下
@ -204,7 +204,7 @@ public class UserInfoLabel extends UILabel{
this.userName = userName; this.userName = userName;
} }
private void updateMessageCount(){ private void updateMessageCount() {
//启动获取消息更新的线程 //启动获取消息更新的线程
//登陆状态, 根据存起来的用户名密码, 每1分钟发起一次请求, 更新消息条数. //登陆状态, 根据存起来的用户名密码, 每1分钟发起一次请求, 更新消息条数.
Thread updateMessageThread = new Thread(new Runnable() { Thread updateMessageThread = new Thread(new Runnable() {
@ -213,12 +213,12 @@ public class UserInfoLabel extends UILabel{
public void run() { public void run() {
sleep(CHECK_MESSAGE_TIME); sleep(CHECK_MESSAGE_TIME);
//从env中获取username, 因为如果注销的话, env的里username会被清空. //从env中获取username, 因为如果注销的话, env的里username会被清空.
while(StringUtils.isNotEmpty(DesignerEnvManager.getEnvManager().getBBSName())){ while (StringUtils.isNotEmpty(DesignerEnvManager.getEnvManager().getBBSName())) {
HashMap<String, String> para = new HashMap<String, String>(); HashMap<String, String> para = new HashMap<String, String>();
para.put("username", encode(encode(userName))); para.put("username", encode(encode(userName)));
HttpClient getMessage = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("bbs.message"), para); HttpClient getMessage = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("bbs.message"), para);
getMessage.asGet(); getMessage.asGet();
if(getMessage.isServerAlive()){ if (getMessage.isServerAlive()) {
try { try {
String res = getMessage.getResponseText(); String res = getMessage.getResponseText();
if (StringUtils.isNotEmpty(res)) { if (StringUtils.isNotEmpty(res)) {
@ -234,7 +234,7 @@ public class UserInfoLabel extends UILabel{
updateMessageThread.start(); updateMessageThread.start();
} }
private String encode(String str){ private String encode(String str) {
try { try {
return URLEncoder.encode(str, EncodeConstants.ENCODING_UTF_8); return URLEncoder.encode(str, EncodeConstants.ENCODING_UTF_8);
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
@ -248,11 +248,11 @@ public class UserInfoLabel extends UILabel{
public void setMessageCount(int messageCount) { public void setMessageCount(int messageCount) {
// 当只有一条消息时,阅读之后,消息面板重置为只含用户名的状态 // 当只有一条消息时,阅读之后,消息面板重置为只含用户名的状态
if(this.messageCount == MIN_MESSAGE_COUNT && messageCount < MIN_MESSAGE_COUNT){ if (this.messageCount == MIN_MESSAGE_COUNT && messageCount < MIN_MESSAGE_COUNT) {
this.setText(this.userName); this.setText(this.userName);
return; return;
} }
if(this.messageCount == messageCount || messageCount < MIN_MESSAGE_COUNT){ if (this.messageCount == messageCount || messageCount < MIN_MESSAGE_COUNT) {
return; return;
} }
@ -271,21 +271,21 @@ public class UserInfoLabel extends UILabel{
public void mouseEntered(MouseEvent e) { public void mouseEntered(MouseEvent e) {
UserInfoLabel.this.setCursor(new Cursor(Cursor.HAND_CURSOR)); UserInfoLabel.this.setCursor(new Cursor(Cursor.HAND_CURSOR));
}; }
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
userName = DesignerEnvManager.getEnvManager().getBBSName(); userName = DesignerEnvManager.getEnvManager().getBBSName();
if(StringUtils.isNotEmpty(userName)) { if (StringUtils.isNotEmpty(userName)) {
UIPopupMenu menu = new UIPopupMenu(); UIPopupMenu menu = new UIPopupMenu();
menu.setOnlyText(true); menu.setOnlyText(true);
menu.setPopupSize(userInfoPane.getWidth(),userInfoPane.getHeight()*3); menu.setPopupSize(userInfoPane.getWidth(), userInfoPane.getHeight() * 3);
//私人消息 //私人消息
UIMenuItem priviteMessage = new UIMenuItem(Inter.getLocText("FR-Designer-BBSLogin_Privite-Message")); UIMenuItem priviteMessage = new UIMenuItem(Inter.getLocText("FR-Designer-BBSLogin_Privite-Message"));
priviteMessage.addMouseListener(new MouseAdapter() { priviteMessage.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
if(StringUtils.isNotEmpty(userName)){ if (StringUtils.isNotEmpty(userName)) {
try { try {
String loginUrl = SiteCenter.getInstance().acquireUrlByKind("bbs.default"); String loginUrl = SiteCenter.getInstance().acquireUrlByKind("bbs.default");
Desktop.getDesktop().browse(new URI(loginUrl)); Desktop.getDesktop().browse(new URI(loginUrl));

Loading…
Cancel
Save