request focus in chat window configurable property

cusax-fix
Yana Stamcheva 19 years ago
parent 5ec72eb33a
commit dcc3f8dd4f

@ -12,6 +12,7 @@
import net.java.sip.communicator.impl.gui.main.*;
import net.java.sip.communicator.impl.gui.main.login.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.audionotifier.*;
import net.java.sip.communicator.service.browserlauncher.*;
import net.java.sip.communicator.service.callhistory.*;
@ -90,6 +91,7 @@ public void start(BundleContext bundleContext) throws Exception {
logger.info("UI Service ...[REGISTERED]");
ConfigurationManager.loadGuiConfigurations();
communicatorMain.showCommunicator(true);
SwingUtilities.invokeLater(new RunLogin());
}

@ -30,6 +30,7 @@ authorizationRequested=Authorization requested
authorizationRequestedInfo=The ? contact requests your authorization.
authenticationFailed=The authentication for account ? failed. The password you entered is not valid.
authorizationResponse=Authorization response
autoPopup=Autopopup new message
back=&Back
call=Call
callVia=Call via:

@ -377,18 +377,20 @@ public void messageReceived(MessageReceivedEvent evt)
if (chatWindow.getState() == JFrame.ICONIFIED) {
chatWindow.setTitle("*" + chatWindow.getTitle());
}
if (Constants.AUTO_POPUP_NEW_MESSAGE) {
if(chatWindow.isVisible()) {
if(chatWindow.isVisible())
{
if (ConfigurationManager.isAutoPopupNewMessage())
{
if(chatWindow.getState() == JFrame.ICONIFIED)
chatWindow.setState(JFrame.NORMAL);
chatWindow.toFront();
}
else
chatWindow.setVisible(true);
}
else
chatWindow.setVisible(true);
}
else {
ChatWindow msgWindow = new ChatWindow(mainFrame);
@ -405,7 +407,7 @@ public void messageReceived(MessageReceivedEvent evt)
* If there's no chat window for the contact create it and show
* it.
*/
if (Constants.AUTO_POPUP_NEW_MESSAGE) {
if (ConfigurationManager.isAutoPopupNewMessage()) {
msgWindow.addChat(chatPanel);
msgWindow.pack();
@ -445,26 +447,28 @@ public void messageReceived(MessageReceivedEvent evt)
chatPanel.processMessage(protocolContact.getDisplayName(),
date, Constants.INCOMING_MESSAGE, message.getContent());
if (Constants.AUTO_POPUP_NEW_MESSAGE) {
chatWindow.addChatTab(chatPanel);
if(chatWindow.isVisible()) {
chatWindow.addChatTab(chatPanel);
if(chatWindow.isVisible())
{
if (ConfigurationManager.isAutoPopupNewMessage())
{
if(chatWindow.getState() == JFrame.ICONIFIED)
chatWindow.setState(JFrame.NORMAL);
chatWindow.toFront();
}
else
chatWindow.setVisible(true);
}
else
chatWindow.setVisible(true);
chatPanel.setCaretToEnd();
chatPanel.setCaretToEnd();
chatWindow.getCurrentChatPanel()
.requestFocusInWriteArea();
chatWindow.getCurrentChatPanel()
.requestFocusInWriteArea();
if (chatWindow.getTabCount() > 1) {
chatWindow.highlightTab(metaContact);
}
if (chatWindow.getTabCount() > 1) {
chatWindow.highlightTab(metaContact);
}
}
else {
@ -478,7 +482,7 @@ public void messageReceived(MessageReceivedEvent evt)
chatPanel.processMessage(protocolContact.getDisplayName(),
date, Constants.INCOMING_MESSAGE, message.getContent());
if (chatWindow.getState() == JFrame.ICONIFIED) {
if (chatWindow.getTabCount() > 1) {
chatWindow.setSelectedContactTab(metaContact);
@ -495,10 +499,13 @@ public void messageReceived(MessageReceivedEvent evt)
}
if(chatWindow.isVisible())
chatWindow.toFront();
{
if(ConfigurationManager.isAutoPopupNewMessage())
chatWindow.toFront();
}
else
chatWindow.setVisible(true);
}
}
}
}
@ -618,18 +625,19 @@ else if (evt.getErrorCode()
if (chatWindow.getState() == JFrame.ICONIFIED) {
chatWindow.setTitle("*" + chatWindow.getTitle());
}
if (Constants.AUTO_POPUP_NEW_MESSAGE) {
if(chatWindow.isVisible()) {
if(chatWindow.isVisible()) {
if (ConfigurationManager.isAutoPopupNewMessage())
{
if(chatWindow.getState() == JFrame.ICONIFIED)
chatWindow.setState(JFrame.NORMAL);
chatWindow.toFront();
}
else
chatWindow.setVisible(true);
}
else
chatWindow.setVisible(true);
}
else {
ChatWindow msgWindow = new ChatWindow(mainFrame);
@ -656,7 +664,7 @@ else if (evt.getErrorCode()
* If there's no chat window for the contact create it and show
* it.
*/
if (Constants.AUTO_POPUP_NEW_MESSAGE) {
if (ConfigurationManager.isAutoPopupNewMessage()) {
msgWindow.addChat(chatPanel);
msgWindow.pack();
@ -733,28 +741,30 @@ else if (evt.getErrorCode()
Constants.ERROR_MESSAGE,
errorMsg);
if (Constants.AUTO_POPUP_NEW_MESSAGE) {
chatWindow.addChatTab(chatPanel);
chatWindow.addChatTab(chatPanel);
if(chatWindow.isVisible()) {
if(chatWindow.isVisible()) {
if (ConfigurationManager.isAutoPopupNewMessage())
{
if(chatWindow.getState() == JFrame.ICONIFIED)
chatWindow.setState(JFrame.NORMAL);
chatWindow.toFront();
}
else
chatWindow.setVisible(true);
}
else
chatWindow.setVisible(true);
chatPanel.setCaretToEnd();
chatPanel.setCaretToEnd();
chatWindow.getCurrentChatPanel()
.requestFocusInWriteArea();
chatWindow.getCurrentChatPanel()
.requestFocusInWriteArea();
if (chatWindow.getTabCount() > 1) {
chatWindow.highlightTab(metaContact);
}
if (chatWindow.getTabCount() > 1) {
chatWindow.highlightTab(metaContact);
}
}
}
}
}

@ -7,6 +7,7 @@
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.i18n.*;
import net.java.sip.communicator.impl.gui.main.message.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.configuration.*;
/**
@ -27,12 +28,18 @@ public class SettingsMenu extends SIPCommMenu
private I18NString useCtrlEnterString
= Messages.getI18NString("useCtrlEnterToSend");
private I18NString autoPopupString
= Messages.getI18NString("autoPopup");
private JCheckBoxMenuItem typingNotificationsItem
= new JCheckBoxMenuItem(typingNotifString.getText());
private JCheckBoxMenuItem sendingMessageCommandItem
= new JCheckBoxMenuItem(useCtrlEnterString.getText());
private JCheckBoxMenuItem autoPopupItem
= new JCheckBoxMenuItem(autoPopupString.getText());
private ChatWindow chatWindow;
/**
@ -48,6 +55,7 @@ public SettingsMenu(ChatWindow chatWindow){
typingNotificationsItem.setName("typingNotifications");
sendingMessageCommandItem.setName("sendingMessageCommand");
autoPopupItem.setName("autopopup");
this.setMnemonic(Messages.getI18NString("settings").getMnemonic());
@ -57,17 +65,28 @@ public SettingsMenu(ChatWindow chatWindow){
this.sendingMessageCommandItem.setMnemonic(
useCtrlEnterString.getMnemonic());
this.autoPopupItem.setMnemonic(
autoPopupString.getMnemonic());
ConfigurationService configService
= GuiActivator.getConfigurationService();
String messageCommand = configService.getString(
"net.java.sip.communicator.impl.gui.sendMessageCommand");
String autoPopup = configService.getString(
"net.java.sip.communicator.impl.gui.autoPopupNewMessage");
if(messageCommand == null || messageCommand.equalsIgnoreCase("enter"))
this.sendingMessageCommandItem.setSelected(false);
else
this.sendingMessageCommandItem.setSelected(true);
if(autoPopup == null || autoPopup.equalsIgnoreCase("yes"))
this.autoPopupItem.setSelected(true);
else
this.autoPopupItem.setSelected(false);
this.init();
}
@ -77,9 +96,11 @@ public SettingsMenu(ChatWindow chatWindow){
private void init(){
this.add(typingNotificationsItem);
this.add(sendingMessageCommandItem);
this.add(autoPopupItem);
this.typingNotificationsItem.addActionListener(this);
this.sendingMessageCommandItem.addActionListener(this);
this.autoPopupItem.addActionListener(this);
}
/**
@ -88,8 +109,8 @@ private void init(){
public void actionPerformed(ActionEvent e) {
JCheckBoxMenuItem item = (JCheckBoxMenuItem)e.getSource();
if(item.getName().equals("typingNotifications")) {
if (item.getName().equals("typingNotifications"))
{
if (item.isSelected()) {
chatWindow.enableTypingNotification(true);
}
@ -97,9 +118,13 @@ public void actionPerformed(ActionEvent e) {
chatWindow.enableTypingNotification(false);
}
}
else if(item.getName().equals("sendingMessageCommand")) {
else if (item.getName().equals("sendingMessageCommand"))
{
chatWindow.changeSendCommand(!item.isSelected());
}
else if (item.getName().equals("autopopup"))
{
ConfigurationManager.setAutoPopupNewMessage(item.isSelected());
}
}
}

@ -0,0 +1,54 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.gui.utils;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.service.configuration.*;
public class ConfigurationManager
{
/**
* Indicates whether the message automatic popup is enabled.
*/
private static boolean autoPopupNewMessage;
public static void loadGuiConfigurations()
{
ConfigurationService configService
= GuiActivator.getConfigurationService();
String autoPopup = configService.getString(
"net.java.sip.communicator.impl.gui.autoPopupNewMessage");
if(autoPopup == null || autoPopup.equalsIgnoreCase("yes"))
autoPopupNewMessage = true;
else
autoPopupNewMessage = false;
}
public static boolean isAutoPopupNewMessage()
{
return autoPopupNewMessage;
}
public static void setAutoPopupNewMessage(boolean autoPopupNewMessage)
{
ConfigurationManager.autoPopupNewMessage = autoPopupNewMessage;
ConfigurationService configService
= GuiActivator.getConfigurationService();
if(autoPopupNewMessage)
configService.setProperty(
"net.java.sip.communicator.impl.gui.autoPopupNewMessage",
"yes");
else
configService.setProperty(
"net.java.sip.communicator.impl.gui.autoPopupNewMessage",
"no");
}
}

@ -54,12 +54,7 @@ public class Constants {
* a contact.
*/
public static boolean REMOVE_GROUP_ASK = true;
/**
* Indicates whether the message automatic popup is enabled.
*/
public static boolean AUTO_POPUP_NEW_MESSAGE = true;
/**
* Indicates the number of messages to show in the chat area when a new
* chat is opened.

Loading…
Cancel
Save