"Clsing a window shortly after a new msg should trigger a warning"

cusax-fix
Yana Stamcheva 21 years ago
parent 0cf34baea7
commit ff839d3d66

@ -11,7 +11,7 @@ call=Call
callList=Call list
cancel=Cancel
close=Close
closeChatAfterNewMsg=You have received a message in last 5 seconds. Are you sure you want to close this chat?
closeChatAfterNewMsg=You have received new message in last 2 seconds. Are you sure you want to close this chat?
configure=Configure
connectionFailed=Connection failed
connectionFailedMessage=The connection could not be established due to a network \n connection problem. Please check your network configuration.

@ -11,6 +11,9 @@
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.Date;
import java.util.Enumeration;
import java.util.Hashtable;
@ -81,6 +84,11 @@ public ChatWindow (MainFrame mainFrame){
this.init();
this.enableKeyActions();
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
close();
}
});
}
/**
@ -138,32 +146,7 @@ private void enableKeyActions(){
{
public void actionPerformed(ActionEvent e)
{
if(!getCurrentChatWritePanel().isEmpty()){
int answer = JOptionPane.showConfirmDialog(ChatWindow.this,
Messages.getString("nonEmptyChatWindowClose"),
Messages.getString("warning"),
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.WARNING_MESSAGE);
if(answer == JOptionPane.YES_OPTION){
closeChat();
}
}
else if(System.currentTimeMillis() - getCurrentConversationPanel()
.getLastIncomingMsgTimestamp().getTime() < 3*1000){
int answer = JOptionPane.showConfirmDialog(ChatWindow.this,
Messages.getString("closeChatAfterNewMsg"),
Messages.getString("warning"),
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.WARNING_MESSAGE);
if(answer == JOptionPane.YES_OPTION){
closeChat();
}
}
else{
closeChat();
}
close();
}
};
@ -212,6 +195,39 @@ public void actionPerformed(ActionEvent e)
(KeyEvent.VK_LEFT, KeyEvent.ALT_DOWN_MASK), "changeTabBackword");
}
/**
* Closes the current chat, triggering warnings to the user
* when there are non-sent messages or a message is received
* in last 2 seconds.
*/
private void close(){
if(!getCurrentChatWritePanel().isEmpty()){
int answer = JOptionPane.showConfirmDialog(ChatWindow.this,
Messages.getString("nonEmptyChatWindowClose"),
Messages.getString("warning"),
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.WARNING_MESSAGE);
if(answer == JOptionPane.YES_OPTION){
closeChat();
}
}
else if(System.currentTimeMillis() - getCurrentConversationPanel()
.getLastIncomingMsgTimestamp().getTime() < 2*1000){
int answer = JOptionPane.showConfirmDialog(ChatWindow.this,
Messages.getString("closeChatAfterNewMsg"),
Messages.getString("warning"),
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.WARNING_MESSAGE);
if(answer == JOptionPane.YES_OPTION){
closeChat();
}
}
else{
closeChat();
}
}
/**
* Closes the selected chat tab or the window if there
* are no tabs.

Loading…
Cancel
Save