|
|
@ -14,6 +14,7 @@ import com.fr.general.FRFont; |
|
|
|
import com.fr.general.FRLogger; |
|
|
|
import com.fr.general.FRLogger; |
|
|
|
import com.fr.general.Inter; |
|
|
|
import com.fr.general.Inter; |
|
|
|
import com.fr.general.http.HttpClient; |
|
|
|
import com.fr.general.http.HttpClient; |
|
|
|
|
|
|
|
import com.fr.stable.EncodeConstants; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
import javax.swing.*; |
|
|
@ -24,8 +25,10 @@ import java.awt.event.ActionListener; |
|
|
|
import java.awt.event.KeyAdapter; |
|
|
|
import java.awt.event.KeyAdapter; |
|
|
|
import java.awt.event.KeyEvent; |
|
|
|
import java.awt.event.KeyEvent; |
|
|
|
import java.awt.event.KeyListener; |
|
|
|
import java.awt.event.KeyListener; |
|
|
|
|
|
|
|
import java.io.UnsupportedEncodingException; |
|
|
|
import java.net.HttpURLConnection; |
|
|
|
import java.net.HttpURLConnection; |
|
|
|
import java.net.URI; |
|
|
|
import java.net.URI; |
|
|
|
|
|
|
|
import java.net.URLEncoder; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @author richie |
|
|
|
* @author richie |
|
|
@ -38,12 +41,12 @@ public class BBSLoginDialog extends UIDialog { |
|
|
|
private static final int DIALOG_HEIGHT = 200; |
|
|
|
private static final int DIALOG_HEIGHT = 200; |
|
|
|
private static final String URL = "http://bbs.finereport.com/member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes&inajax=1"; |
|
|
|
private static final String URL = "http://bbs.finereport.com/member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes&inajax=1"; |
|
|
|
private static final String PASSWORD_RESET_URL = "http://bbs.finereport.com/portal.php?mod=topic&topicid=2"; |
|
|
|
private static final String PASSWORD_RESET_URL = "http://bbs.finereport.com/portal.php?mod=topic&topicid=2"; |
|
|
|
private static final String REGISTER_URL = "http://bbs.finereport.com/member.php?mod=register"; |
|
|
|
private static final String REGISTER_URL = "http://bbs.finereport.com/member.php?mod=register"; |
|
|
|
private static final String LOGIN_SUCCESS_FLAG = "http://bbs.finereport.com"; |
|
|
|
private static final String LOGIN_SUCCESS_FLAG = "http://bbs.finereport.com"; |
|
|
|
private static final Font DEFAULT_FONT = FRFont.getInstance(FRFont.DEFAULT_FONTNAME, 0, 14); |
|
|
|
private static final Font DEFAULT_FONT = FRFont.getInstance(FRFont.DEFAULT_FONTNAME, 0, 14); |
|
|
|
private static final String TEST_CONNECTION_URL = "http://bbs.finereport.com/member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes&inajax=1&username=test&password=123456"; |
|
|
|
private static final String TEST_CONNECTION_URL = "http://bbs.finereport.com/member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes&inajax=1&username=test&password=123456"; |
|
|
|
private static final int TIME_OUT = 10000; |
|
|
|
private static final int TIME_OUT = 10000; |
|
|
|
|
|
|
|
|
|
|
|
private static final int BUTTON_WIDTH = 90; |
|
|
|
private static final int BUTTON_WIDTH = 90; |
|
|
|
private static final int V_GAP = 20; |
|
|
|
private static final int V_GAP = 20; |
|
|
|
private static final int BUTTON_H_GAP = 155; |
|
|
|
private static final int BUTTON_H_GAP = 155; |
|
|
@ -56,212 +59,213 @@ public class BBSLoginDialog extends UIDialog { |
|
|
|
private UILabel userLabel; |
|
|
|
private UILabel userLabel; |
|
|
|
private UILabel passLabel; |
|
|
|
private UILabel passLabel; |
|
|
|
private UITextField nameField; |
|
|
|
private UITextField nameField; |
|
|
|
private UIPassWordField passField; |
|
|
|
private UIPassWordField passField; |
|
|
|
private UIButton loginButton; |
|
|
|
private UIButton loginButton; |
|
|
|
private UILabel tipLabel; |
|
|
|
private UILabel tipLabel; |
|
|
|
private BoxCenterAligmentPane passwordReset; |
|
|
|
private BoxCenterAligmentPane passwordReset; |
|
|
|
private BoxCenterAligmentPane registerLabel; |
|
|
|
private BoxCenterAligmentPane registerLabel; |
|
|
|
|
|
|
|
|
|
|
|
private KeyListener keyListener = new KeyAdapter() { |
|
|
|
private KeyListener keyListener = new KeyAdapter() { |
|
|
|
public void keyPressed(KeyEvent e){ |
|
|
|
public void keyPressed(KeyEvent e) { |
|
|
|
int code = e.getKeyCode(); |
|
|
|
int code = e.getKeyCode(); |
|
|
|
if(KeyEvent.VK_ESCAPE == code){ |
|
|
|
if (KeyEvent.VK_ESCAPE == code) { |
|
|
|
BBSLoginDialog.this.setVisible(false); |
|
|
|
BBSLoginDialog.this.setVisible(false); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(KeyEvent.VK_ENTER == code){ |
|
|
|
if (KeyEvent.VK_ENTER == code) { |
|
|
|
login(); |
|
|
|
login(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// 用户登录状态label
|
|
|
|
// 用户登录状态label
|
|
|
|
private UserInfoLabel userInfoLabel; |
|
|
|
private UserInfoLabel userInfoLabel; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public UILabel getTipLabel() { |
|
|
|
|
|
|
|
return tipLabel; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setTipLabel(UILabel tipLabel) { |
|
|
|
public UILabel getTipLabel() { |
|
|
|
this.tipLabel = tipLabel; |
|
|
|
return tipLabel; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setTipLabel(UILabel tipLabel) { |
|
|
|
|
|
|
|
this.tipLabel = tipLabel; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 构造函数 |
|
|
|
* 构造函数 |
|
|
|
* @param parent 父窗口 |
|
|
|
* |
|
|
|
* @param userInfoLabel 登录状态label |
|
|
|
* @param parent 父窗口 |
|
|
|
*/ |
|
|
|
* @param userInfoLabel 登录状态label |
|
|
|
public BBSLoginDialog(Frame parent,UserInfoLabel userInfoLabel) { |
|
|
|
*/ |
|
|
|
|
|
|
|
public BBSLoginDialog(Frame parent, UserInfoLabel userInfoLabel) { |
|
|
|
super(parent); |
|
|
|
super(parent); |
|
|
|
JPanel panel = (JPanel) getContentPane(); |
|
|
|
JPanel panel = (JPanel) getContentPane(); |
|
|
|
initComponents(panel); |
|
|
|
initComponents(panel); |
|
|
|
this.userInfoLabel = userInfoLabel; |
|
|
|
this.userInfoLabel = userInfoLabel; |
|
|
|
setSize(new Dimension(DIALOG_WIDTH,DIALOG_HEIGHT)); |
|
|
|
setSize(new Dimension(DIALOG_WIDTH, DIALOG_HEIGHT)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initComponents(JPanel contentPane) { |
|
|
|
private void initComponents(JPanel contentPane) { |
|
|
|
this.setTitle(Inter.getLocText("FR-Designer-BBSLogin_Login-Title")); |
|
|
|
this.setTitle(Inter.getLocText("FR-Designer-BBSLogin_Login-Title")); |
|
|
|
tipLabel = new UILabel(Inter.getLocText("FR-Designer-BBSLogin_Login-Failure-Tip")); |
|
|
|
tipLabel = new UILabel(Inter.getLocText("FR-Designer-BBSLogin_Login-Failure-Tip")); |
|
|
|
userLabel = new UILabel(Inter.getLocText("FR-Designer-BBSLogin_Account")+":"); |
|
|
|
userLabel = new UILabel(Inter.getLocText("FR-Designer-BBSLogin_Account") + ":"); |
|
|
|
passLabel = new UILabel(Inter.getLocText("FR-Designer-BBSLogin_Password")+":"); |
|
|
|
passLabel = new UILabel(Inter.getLocText("FR-Designer-BBSLogin_Password") + ":"); |
|
|
|
nameField = new UITextField(); |
|
|
|
nameField = new UITextField(); |
|
|
|
passField = new UIPassWordField(); |
|
|
|
passField = new UIPassWordField(); |
|
|
|
loginButton = new UIButton(Inter.getLocText("FR-Designer-BBSLogin_Login")); |
|
|
|
loginButton = new UIButton(Inter.getLocText("FR-Designer-BBSLogin_Login")); |
|
|
|
passwordReset = getURLActionLabel(PASSWORD_RESET_URL); |
|
|
|
passwordReset = getURLActionLabel(PASSWORD_RESET_URL); |
|
|
|
registerLabel = getURLActionLabel(REGISTER_URL); |
|
|
|
registerLabel = getURLActionLabel(REGISTER_URL); |
|
|
|
loginButton.addActionListener(new ActionListener() { |
|
|
|
loginButton.addActionListener(new ActionListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent arg0) { |
|
|
|
public void actionPerformed(ActionEvent arg0) { |
|
|
|
login(); |
|
|
|
login(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
nameField.addKeyListener(keyListener); |
|
|
|
nameField.addKeyListener(keyListener); |
|
|
|
passField.addKeyListener(keyListener); |
|
|
|
passField.addKeyListener(keyListener); |
|
|
|
loginButton.addKeyListener(keyListener); |
|
|
|
loginButton.addKeyListener(keyListener); |
|
|
|
|
|
|
|
|
|
|
|
userLabel.setFont(DEFAULT_FONT); |
|
|
|
userLabel.setFont(DEFAULT_FONT); |
|
|
|
passLabel.setFont(DEFAULT_FONT); |
|
|
|
passLabel.setFont(DEFAULT_FONT); |
|
|
|
this.tipLabel.setVisible(false); |
|
|
|
this.tipLabel.setVisible(false); |
|
|
|
|
|
|
|
|
|
|
|
contentPane.setLayout(new BorderLayout()); |
|
|
|
contentPane.setLayout(new BorderLayout()); |
|
|
|
|
|
|
|
|
|
|
|
JPanel mainPane = new JPanel(); |
|
|
|
JPanel mainPane = new JPanel(); |
|
|
|
mainPane.setLayout(new BorderLayout(0,V_GAP)); |
|
|
|
mainPane.setLayout(new BorderLayout(0, V_GAP)); |
|
|
|
|
|
|
|
|
|
|
|
initNorthPane(mainPane); |
|
|
|
initNorthPane(mainPane); |
|
|
|
|
|
|
|
|
|
|
|
initCenterPane(mainPane); |
|
|
|
initCenterPane(mainPane); |
|
|
|
|
|
|
|
|
|
|
|
initSouthPane(mainPane); |
|
|
|
initSouthPane(mainPane); |
|
|
|
|
|
|
|
|
|
|
|
contentPane.add(mainPane,BorderLayout.NORTH); |
|
|
|
contentPane.add(mainPane, BorderLayout.NORTH); |
|
|
|
|
|
|
|
|
|
|
|
this.setResizable(false); |
|
|
|
this.setResizable(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void login(){ |
|
|
|
private void login() { |
|
|
|
if(nameField.getText().isEmpty()){ |
|
|
|
if (nameField.getText().isEmpty()) { |
|
|
|
tipForUsernameEmpty(); |
|
|
|
tipForUsernameEmpty(); |
|
|
|
nameField.requestFocus(); |
|
|
|
nameField.requestFocus(); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if(String.valueOf(passField.getPassword()).isEmpty()){ |
|
|
|
if (String.valueOf(passField.getPassword()).isEmpty()) { |
|
|
|
tipForPasswordEmpty(); |
|
|
|
tipForPasswordEmpty(); |
|
|
|
passField.requestFocus(); |
|
|
|
passField.requestFocus(); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if(!testConnection()){ |
|
|
|
if (!testConnection()) { |
|
|
|
connectionFailue(); |
|
|
|
connectionFailue(); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if(login(nameField.getText(),String.valueOf(passField.getPassword()))){ |
|
|
|
if (login(nameField.getText(), String.valueOf(passField.getPassword()))) { |
|
|
|
loginSuccess(); |
|
|
|
loginSuccess(); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
loginFailure(); |
|
|
|
loginFailure(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean testConnection(){ |
|
|
|
private boolean testConnection() { |
|
|
|
HttpClient client = new HttpClient(TEST_CONNECTION_URL); |
|
|
|
HttpClient client = new HttpClient(TEST_CONNECTION_URL); |
|
|
|
return client.isServerAlive(); |
|
|
|
return client.isServerAlive(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initNorthPane(JPanel mainPane){ |
|
|
|
private void initNorthPane(JPanel mainPane) { |
|
|
|
JPanel northPane = new JPanel(); |
|
|
|
JPanel northPane = new JPanel(); |
|
|
|
northPane.setPreferredSize(new Dimension(DIALOG_WIDTH,NORTH_PANE_HEIGHT)); |
|
|
|
northPane.setPreferredSize(new Dimension(DIALOG_WIDTH, NORTH_PANE_HEIGHT)); |
|
|
|
northPane.add(tipLabel); |
|
|
|
northPane.add(tipLabel); |
|
|
|
mainPane.add(northPane,BorderLayout.NORTH); |
|
|
|
mainPane.add(northPane, BorderLayout.NORTH); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initCenterPane(JPanel mainPane){ |
|
|
|
private void initCenterPane(JPanel mainPane) { |
|
|
|
JPanel loginPane = new JPanel(); |
|
|
|
JPanel loginPane = new JPanel(); |
|
|
|
loginPane.setLayout(new GridLayout(2,1,0,V_GAP)); |
|
|
|
loginPane.setLayout(new GridLayout(2, 1, 0, V_GAP)); |
|
|
|
|
|
|
|
|
|
|
|
JPanel namePane = new JPanel(); |
|
|
|
JPanel namePane = new JPanel(); |
|
|
|
namePane.setLayout(new FlowLayout(FlowLayout.RIGHT,FLOWLAYOUT_H_GAP,0)); |
|
|
|
namePane.setLayout(new FlowLayout(FlowLayout.RIGHT, FLOWLAYOUT_H_GAP, 0)); |
|
|
|
namePane.add(userLabel); |
|
|
|
namePane.add(userLabel); |
|
|
|
nameField.setPreferredSize(new Dimension(FIELD_WIDTH,FIELD_HEIGHT)); |
|
|
|
nameField.setPreferredSize(new Dimension(FIELD_WIDTH, FIELD_HEIGHT)); |
|
|
|
namePane.add(nameField); |
|
|
|
namePane.add(nameField); |
|
|
|
namePane.add(passwordReset); |
|
|
|
namePane.add(passwordReset); |
|
|
|
loginPane.add(namePane); |
|
|
|
loginPane.add(namePane); |
|
|
|
|
|
|
|
|
|
|
|
JPanel passPane = new JPanel(); |
|
|
|
JPanel passPane = new JPanel(); |
|
|
|
passPane.setLayout(new FlowLayout(FlowLayout.RIGHT,FLOWLAYOUT_H_GAP,0)); |
|
|
|
passPane.setLayout(new FlowLayout(FlowLayout.RIGHT, FLOWLAYOUT_H_GAP, 0)); |
|
|
|
passPane.add(passLabel); |
|
|
|
passPane.add(passLabel); |
|
|
|
passPane.add(passField); |
|
|
|
passPane.add(passField); |
|
|
|
passField.setPreferredSize(new Dimension(FIELD_WIDTH,FIELD_HEIGHT)); |
|
|
|
passField.setPreferredSize(new Dimension(FIELD_WIDTH, FIELD_HEIGHT)); |
|
|
|
passPane.add(registerLabel); |
|
|
|
passPane.add(registerLabel); |
|
|
|
loginPane.add(passPane); |
|
|
|
loginPane.add(passPane); |
|
|
|
|
|
|
|
|
|
|
|
mainPane.add(loginPane,BorderLayout.CENTER); |
|
|
|
mainPane.add(loginPane, BorderLayout.CENTER); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initSouthPane(JPanel mainPane){ |
|
|
|
private void initSouthPane(JPanel mainPane) { |
|
|
|
JPanel southPane = new JPanel(); |
|
|
|
JPanel southPane = new JPanel(); |
|
|
|
southPane.setLayout(new FlowLayout(FlowLayout.RIGHT,BUTTON_H_GAP,0)); |
|
|
|
southPane.setLayout(new FlowLayout(FlowLayout.RIGHT, BUTTON_H_GAP, 0)); |
|
|
|
loginButton.setPreferredSize(new Dimension(BUTTON_WIDTH,FIELD_HEIGHT)); |
|
|
|
loginButton.setPreferredSize(new Dimension(BUTTON_WIDTH, FIELD_HEIGHT)); |
|
|
|
loginButton.setFont(DEFAULT_FONT); |
|
|
|
loginButton.setFont(DEFAULT_FONT); |
|
|
|
southPane.add(loginButton); |
|
|
|
southPane.add(loginButton); |
|
|
|
mainPane.add(southPane,BorderLayout.SOUTH); |
|
|
|
mainPane.add(southPane, BorderLayout.SOUTH); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 登录成功
|
|
|
|
// 登录成功
|
|
|
|
private void loginSuccess(){ |
|
|
|
private void loginSuccess() { |
|
|
|
DesignerEnvManager.getEnvManager().setBBSPassword(String.valueOf(passField.getPassword())); |
|
|
|
DesignerEnvManager.getEnvManager().setBBSPassword(String.valueOf(passField.getPassword())); |
|
|
|
userInfoLabel.setUserName(nameField.getText()); |
|
|
|
userInfoLabel.setUserName(nameField.getText()); |
|
|
|
userInfoLabel.getUserInfoPane().markSignIn(nameField.getText()); |
|
|
|
userInfoLabel.getUserInfoPane().markSignIn(nameField.getText()); |
|
|
|
userInfoLabel.getUserInfoPane().getSwitchAccountLabel().setVisible(true); |
|
|
|
userInfoLabel.getUserInfoPane().getSwitchAccountLabel().setVisible(true); |
|
|
|
BBSLoginDialog.this.setVisible(false); |
|
|
|
BBSLoginDialog.this.setVisible(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 登录失败
|
|
|
|
// 登录失败
|
|
|
|
private void loginFailure(){ |
|
|
|
private void loginFailure() { |
|
|
|
setLoginFailureTxt(Inter.getLocText("FR-Designer-BBSLogin_Login-Failure-Tip")); |
|
|
|
setLoginFailureTxt(Inter.getLocText("FR-Designer-BBSLogin_Login-Failure-Tip")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void tipForUsernameEmpty(){ |
|
|
|
private void tipForUsernameEmpty() { |
|
|
|
setLoginFailureTxt(Inter.getLocText("FR-Designer-BBSLogin_Username-Empty-Tip")); |
|
|
|
setLoginFailureTxt(Inter.getLocText("FR-Designer-BBSLogin_Username-Empty-Tip")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void showTipForDownloadPluginWithoutLogin() { |
|
|
|
public void showTipForDownloadPluginWithoutLogin() { |
|
|
|
setLoginFailureTxt(Inter.getLocText("FR-Designer-BBSLogin_Download-Unlogin-Tip")); |
|
|
|
setLoginFailureTxt(Inter.getLocText("FR-Designer-BBSLogin_Download-Unlogin-Tip")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void tipForPasswordEmpty(){ |
|
|
|
private void tipForPasswordEmpty() { |
|
|
|
setLoginFailureTxt(Inter.getLocText("FR-Designer-BBSLogin_Password-Empty-Tip")); |
|
|
|
setLoginFailureTxt(Inter.getLocText("FR-Designer-BBSLogin_Password-Empty-Tip")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void setLoginFailureTxt(String errorTxt){ |
|
|
|
private void setLoginFailureTxt(String errorTxt) { |
|
|
|
tipLabel.setText(errorTxt); |
|
|
|
tipLabel.setText(errorTxt); |
|
|
|
tipLabel.setForeground(Color.RED); |
|
|
|
tipLabel.setForeground(Color.RED); |
|
|
|
tipLabel.repaint(); |
|
|
|
tipLabel.repaint(); |
|
|
|
tipLabel.setVisible(true); |
|
|
|
tipLabel.setVisible(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 连接失败
|
|
|
|
// 连接失败
|
|
|
|
private void connectionFailue(){ |
|
|
|
private void connectionFailue() { |
|
|
|
setLoginFailureTxt(Inter.getLocText("FR-Designer-BBSLogin_Connection-Failure")); |
|
|
|
setLoginFailureTxt(Inter.getLocText("FR-Designer-BBSLogin_Connection-Failure")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 清楚登录信息 |
|
|
|
* 清楚登录信息 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void clearLoginInformation(){ |
|
|
|
public void clearLoginInformation() { |
|
|
|
tipLabel.setText(StringUtils.EMPTY); |
|
|
|
tipLabel.setText(StringUtils.EMPTY); |
|
|
|
nameField.setText(StringUtils.EMPTY); |
|
|
|
nameField.setText(StringUtils.EMPTY); |
|
|
|
passField.setText(StringUtils.EMPTY); |
|
|
|
passField.setText(StringUtils.EMPTY); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 显示登录窗口 |
|
|
|
* 显示登录窗口 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void showWindow(){ |
|
|
|
public void showWindow() { |
|
|
|
GUICoreUtils.centerWindow(this); |
|
|
|
GUICoreUtils.centerWindow(this); |
|
|
|
setVisible(true); |
|
|
|
setVisible(true); |
|
|
|
} |
|
|
|
} |
|
|
@ -273,39 +277,45 @@ public class BBSLoginDialog extends UIDialog { |
|
|
|
public void checkValid() throws Exception { |
|
|
|
public void checkValid() throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 是否登陆成功 |
|
|
|
* 是否登陆成功 |
|
|
|
|
|
|
|
* |
|
|
|
* @param username 用户名 |
|
|
|
* @param username 用户名 |
|
|
|
* @param password 密码 |
|
|
|
* @param password 密码 |
|
|
|
* @return 同上 |
|
|
|
* @return 同上 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static boolean login(String username,String password){ |
|
|
|
public static boolean login(String username, String password) { |
|
|
|
String url = URL + "&username=" + username + "&password=" + password; |
|
|
|
try { |
|
|
|
HttpClient client = new HttpClient(url); |
|
|
|
username = URLEncoder.encode(username, EncodeConstants.ENCODING_GBK); |
|
|
|
client.setTimeout(TIME_OUT); |
|
|
|
} catch (UnsupportedEncodingException e) { |
|
|
|
if(client.getResponseCodeNoException() == HttpURLConnection.HTTP_OK){ |
|
|
|
FRLogger.getLogger().error(e.getMessage()); |
|
|
|
try { |
|
|
|
} |
|
|
|
String res = client.getResponseText("GBK"); |
|
|
|
String url = URL + "&username=" + username + "&password=" + password; |
|
|
|
if(res.contains(LOGIN_SUCCESS_FLAG)){ |
|
|
|
HttpClient client = new HttpClient(url); |
|
|
|
return true; |
|
|
|
client.setTimeout(TIME_OUT); |
|
|
|
} |
|
|
|
if (client.getResponseCodeNoException() == HttpURLConnection.HTTP_OK) { |
|
|
|
} catch (Exception e) { |
|
|
|
try { |
|
|
|
FRLogger.getLogger().error(e.getMessage()); |
|
|
|
String res = client.getResponseText(EncodeConstants.ENCODING_GBK); |
|
|
|
} |
|
|
|
if (res.contains(LOGIN_SUCCESS_FLAG)) { |
|
|
|
} |
|
|
|
return true; |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
FRLogger.getLogger().error(e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private BoxCenterAligmentPane getURLActionLabel(final String url){ |
|
|
|
private BoxCenterAligmentPane getURLActionLabel(final String url) { |
|
|
|
ActionLabel actionLabel = new ActionLabel(url); |
|
|
|
ActionLabel actionLabel = new ActionLabel(url); |
|
|
|
if(ComparatorUtils.equals(url, PASSWORD_RESET_URL)){ |
|
|
|
if (ComparatorUtils.equals(url, PASSWORD_RESET_URL)) { |
|
|
|
actionLabel.setText(Inter.getLocText("FR-Designer-BBSLogin_Forgot-Password")); |
|
|
|
actionLabel.setText(Inter.getLocText("FR-Designer-BBSLogin_Forgot-Password")); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
actionLabel.setText(Inter.getLocText("FR-Designer-BBSLogin_Register-Account")); |
|
|
|
actionLabel.setText(Inter.getLocText("FR-Designer-BBSLogin_Register-Account")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
actionLabel.addActionListener(new ActionListener() { |
|
|
|
actionLabel.addActionListener(new ActionListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
try { |
|
|
|
try { |
|
|
@ -315,14 +325,14 @@ public class BBSLoginDialog extends UIDialog { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return new BoxCenterAligmentPane(actionLabel); |
|
|
|
return new BoxCenterAligmentPane(actionLabel); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class BoxCenterAligmentPane extends JPanel { |
|
|
|
class BoxCenterAligmentPane extends JPanel { |
|
|
|
|
|
|
|
|
|
|
|
private UILabel textLabel; |
|
|
|
private UILabel textLabel; |
|
|
|
|
|
|
|
|
|
|
|
public BoxCenterAligmentPane(String text) { |
|
|
|
public BoxCenterAligmentPane(String text) { |
|
|
|
this(new UILabel(text)); |
|
|
|
this(new UILabel(text)); |
|
|
|
} |
|
|
|
} |
|
|
|