1) Save the "isMinimized" property. Issue N 344

2) some enhancements on the way the ConfigurationService is accessed from the gui
cusax-fix
Yana Stamcheva 19 years ago
parent 9205a6fa3d
commit 90be1c5c58

@ -63,6 +63,8 @@ public void start(BundleContext bundleContext) throws Exception {
GuiActivator.bundleContext = bundleContext;
ConfigurationManager.loadGuiConfigurations();
this.communicatorMain = new CommunicatorMain();
MainFrame mainFrame = communicatorMain.getMainFrame();
@ -91,8 +93,9 @@ public void start(BundleContext bundleContext) throws Exception {
logger.info("UI Service ...[REGISTERED]");
ConfigurationManager.loadGuiConfigurations();
communicatorMain.showCommunicator(true);
if(ConfigurationManager.isApplicationVisible())
mainFrame.setVisible(true);
SwingUtilities.invokeLater(new RunLogin());
uiService.initExportedWindows();

@ -57,18 +57,6 @@ public void setDefaultThemePack() {
logger.error("The provided Look & Feel is not supported.", e);
}
}
/**
* Shows or hides the main application window.
*
* @param isVisible <code>true</code> to show the main application
* window, <code>false</code> to hide it.
*/
public void showCommunicator(boolean isVisible) {
this.mainFrame.loadConfigurationSettings();
this.mainFrame.setVisible(isVisible);
}
/**
* Returns the main application window.

@ -102,7 +102,7 @@ public MainFrame()
this.addWindowListener(new MainFrameWindowAdapter());
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
//this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.setInitialBounds();
this.setTitle(Messages.getI18NString("sipCommunicator").getText());
@ -645,29 +645,15 @@ public MetaContactGroup getGroupByID(String metaUID)
* through the <tt>ConfigurationService</tt>.
*/
public class MainFrameWindowAdapter extends WindowAdapter
{
public void windowClosing(WindowEvent e) {
ConfigurationService configService
= GuiActivator.getConfigurationService();
try {
configService.setProperty(
"net.java.sip.communicator.impl.gui.showCallPanel",
new Boolean(callManager.isShown()));
configService.setProperty(
"net.java.sip.communicator.impl.gui.showOffline",
new Boolean(getContactListPanel()
.getContactList().isShowOffline()));
}
catch (PropertyVetoException e1) {
logger.error("The proposed property change "
+ "represents an unacceptable value");
{
public void windowClosing(WindowEvent e)
{
if(!GuiActivator.getUIService().getExitOnMainWindowClose())
{
ConfigurationManager.setApplicationVisible(false);
}
}
public void windowClosed(WindowEvent e)
{
if(GuiActivator.getUIService().getExitOnMainWindowClose())
@ -688,33 +674,6 @@ public void windowClosed(WindowEvent e)
}
}
/**
* Sets the window size and position.
*/
public void loadConfigurationSettings() {
ConfigurationService configService
= GuiActivator.getConfigurationService();
String isCallPanelShown = configService.getString(
"net.java.sip.communicator.impl.gui.showCallPanel");
String isShowOffline = configService.getString(
"net.java.sip.communicator.impl.gui.showOffline");
if(isCallPanelShown != null && isCallPanelShown != "")
{
callManager.setShown(new Boolean(isCallPanelShown).booleanValue());
}
else {
callManager.setShown(true);
}
if(isShowOffline != null && isShowOffline != "") {
getContactListPanel().getContactList()
.setShowOffline(new Boolean(isShowOffline).booleanValue());
}
}
/**
* Saves the last status for all accounts. This information is used
* on loging. Each time user logs in he's logged with the same status

@ -84,8 +84,6 @@ public class CallManager
private Hashtable activeCalls = new Hashtable();
private boolean isShown;
private boolean isCallMetaContact;
private Hashtable removeCallTimers = new Hashtable();
@ -148,7 +146,9 @@ private void init()
this.hangupButton.setEnabled(false);
this.add(minimizeButtonPanel, BorderLayout.SOUTH);
this.add(minimizeButtonPanel, BorderLayout.SOUTH);
this.setCallPanelVisible(ConfigurationManager.isCallPanelShown());
}
@ -319,7 +319,7 @@ else if (buttonName.equalsIgnoreCase("minimize")) {
if(!hideCallPanelItem.isSelected())
hideCallPanelItem.setSelected(true);
this.hideCallPanel();
this.setCallPanelVisible(false);
}
else if (buttonName.equalsIgnoreCase("restore")) {
@ -329,43 +329,42 @@ else if (buttonName.equalsIgnoreCase("restore")) {
if(hideCallPanelItem.isSelected())
hideCallPanelItem.setSelected(false);
this.showCallPanel();
this.setCallPanelVisible(true);
}
}
/**
* Hides the panel containing call and hangup buttons.
*/
public void hideCallPanel()
public void setCallPanelVisible(boolean isVisible)
{
this.remove(comboPanel);
this.remove(buttonsPanel);
if(isVisible)
{
this.add(comboPanel, BorderLayout.NORTH);
this.add(buttonsPanel, BorderLayout.CENTER);
this.minimizeButtonPanel.removeAll();
this.minimizeButtonPanel.add(restoreButton);
this.isShown = false;
this.mainFrame.getContactListPanel()
.getContactList().requestFocus();
this.minimizeButtonPanel.removeAll();
this.minimizeButtonPanel.add(minimizeButton);
}
else
{
this.remove(comboPanel);
this.remove(buttonsPanel);
this.minimizeButtonPanel.removeAll();
this.minimizeButtonPanel.add(restoreButton);
if(mainFrame.isVisible())
this.mainFrame.getContactListPanel()
.getContactList().requestFocus();
}
if(ConfigurationManager.isCallPanelShown() != isVisible)
ConfigurationManager.setShowCallPanel(isVisible);
this.mainFrame.validate();
}
/**
* Shows the panel containing call and hangup buttons.
*/
public void showCallPanel()
{
this.add(comboPanel, BorderLayout.NORTH);
this.add(buttonsPanel, BorderLayout.CENTER);
this.minimizeButtonPanel.removeAll();
this.minimizeButtonPanel.add(minimizeButton);
this.isShown = true;
this.mainFrame.validate();
}
/**
* Adds the given call account to the list of call via accounts.
* @param pps the protocol provider service corresponding to the account
@ -468,7 +467,7 @@ public void incomingCallReceived(CallEvent event)
activeCalls.put(sourceCall, callPanel);
this.showCallPanel();
this.setCallPanelVisible(true);
}
/**
@ -617,34 +616,6 @@ public JComboBox getCallComboBox()
return phoneNumberCombo;
}
/**
* Returns TRUE if this panel is visible, FALSE otherwise.
* @return TRUE if this panel is visible, FALSE otherwise
*/
public boolean isShown()
{
return this.isShown;
}
/**
* When TRUE shows this panel, when FALSE hides it.
* @param isShown
*/
public void setShown(boolean isShown)
{
this.isShown = isShown;
if(isShown) {
this.add(comboPanel, BorderLayout.NORTH);
this.add(buttonsPanel, BorderLayout.CENTER);
this.minimizeButtonPanel.add(minimizeButton);
}
else {
this.minimizeButtonPanel.add(restoreButton);
}
}
/**
* Answers the given call.
* @param call the call to answer

@ -72,11 +72,14 @@ public SettingsMenu(ChatWindow chatWindow){
= GuiActivator.getConfigurationService();
String messageCommand = configService.getString(
"net.java.sip.communicator.impl.gui.sendMessageCommand");
"net.java.sip.communicator.impl.gui.sendMessageCommand");
String autoPopup = configService.getString(
"net.java.sip.communicator.impl.gui.autoPopupNewMessage");
String typingNotif = configService.getString(
"net.java.sip.communicator.impl.gui.autoPopupNewMessage");
if(messageCommand == null || messageCommand.equalsIgnoreCase("enter"))
this.sendingMessageCommandItem.setSelected(false);
else

@ -16,8 +16,8 @@
import javax.swing.text.*;
import net.java.sip.communicator.impl.gui.main.*;
import net.java.sip.communicator.impl.gui.main.chat.*;
import net.java.sip.communicator.impl.gui.main.chat.history.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.contactlist.*;
import net.java.sip.communicator.service.contactlist.event.*;
import net.java.sip.communicator.service.protocol.*;
@ -75,7 +75,6 @@ public class ContactList
*/
public ContactList(MainFrame mainFrame)
{
this.mainFrame = mainFrame;
this.contactList = mainFrame.getContactList();
@ -109,6 +108,8 @@ public void valueChanged(ListSelectionEvent e)
}
});
this.setShowOffline(ConfigurationManager.isShowOffline());
new ContactListRefresh().start();
}
@ -1093,16 +1094,6 @@ public GroupRightButtonMenu getGroupRightButtonMenu()
return groupRightButtonMenu;
}
/**
* Returns TRUE if the list shows offline contacts, FALSE otherwise.
*
* @return TRUE if the list shows offline contacts, FALSE otherwise
*/
public boolean isShowOffline()
{
return listModel.isShowOffline();
}
/**
* Sets the showOffline property.
*
@ -1115,6 +1106,8 @@ public void setShowOffline(boolean isShowOffline)
listModel.setShowOffline(isShowOffline);
ConfigurationManager.setShowOffline(isShowOffline);
int newListSize = listModel.getSize();
//hide offline users
@ -1138,7 +1131,7 @@ else if(isShowOffline && newListSize > 0)
}
else
listModel.contentAdded(0, newListSize - 1);
}
}
}
/**

@ -196,7 +196,6 @@ else if (buttonName.equals("config"))
}
else if (buttonName.equals("search"))
{
ContactList contactList = mainFrame.getContactListPanel()
.getContactList();
@ -209,8 +208,8 @@ else if (buttonName.equals("search"))
selectedObject
= listModel.getElementAt(currentlySelectedIndex);
}
contactList.setShowOffline(!contactList.isShowOffline());
contactList.setShowOffline(!ConfigurationManager.isShowOffline());
if (selectedObject != null) {
if (selectedObject instanceof MetaContact) {

@ -55,14 +55,8 @@ public ViewMenu(MainFrame mainFrame) {
this.mainFrame = mainFrame;
ConfigurationService configService
= GuiActivator.getConfigurationService();
String isCallPanelShown = configService.getString(
"net.java.sip.communicator.impl.gui.showCallPanel");
this.hideCallPanelItem.setSelected(
!new Boolean(isCallPanelShown).booleanValue());
!ConfigurationManager.isCallPanelShown());
this.add(hideCallPanelItem);
@ -90,12 +84,7 @@ public void actionPerformed(ActionEvent e) {
if (itemName.equals("hideCallPanel")) {
CallManager callManager = mainFrame.getCallManager();
if (hideCallPanelItem.isSelected()) {
callManager.hideCallPanel();
}
else {
callManager.showCallPanel();
}
callManager.setCallPanelVisible(!hideCallPanelItem.isSelected());
}
}

@ -16,32 +16,74 @@ public class ConfigurationManager
*/
private static boolean autoPopupNewMessage;
private static boolean isCallPanelShown;
private static boolean isShowOffline;
private static boolean isApplicationVisible;
private static ConfigurationService configService
= GuiActivator.getConfigurationService();
public static void loadGuiConfigurations()
{
ConfigurationService configService
= GuiActivator.getConfigurationService();
{
String autoPopup = configService.getString(
"net.java.sip.communicator.impl.gui.autoPopupNewMessage");
String callPanelShown = configService.getString(
"net.java.sip.communicator.impl.gui.showCallPanel");
String showOffline = configService.getString(
"net.java.sip.communicator.impl.gui.showOffline");
String isVisible = configService.getString(
"net.java.sip.communicator.impl.systray.showApplication");
if(autoPopup == null || autoPopup.equalsIgnoreCase("yes"))
autoPopupNewMessage = true;
else
autoPopupNewMessage = false;
if(callPanelShown != null && callPanelShown != "")
{
isCallPanelShown = new Boolean(callPanelShown).booleanValue();
}
if(showOffline != null && showOffline != "")
{
isShowOffline = new Boolean(showOffline).booleanValue();
}
if(isVisible != null && isVisible != "")
{
isApplicationVisible = new Boolean(isVisible).booleanValue();
}
}
public static boolean isAutoPopupNewMessage()
{
return autoPopupNewMessage;
}
public static boolean isCallPanelShown()
{
return isCallPanelShown;
}
public static boolean isShowOffline()
{
return isShowOffline;
}
public static boolean isApplicationVisible()
{
return isApplicationVisible;
}
public static void setAutoPopupNewMessage(boolean autoPopupNewMessage)
{
ConfigurationManager.autoPopupNewMessage = autoPopupNewMessage;
ConfigurationService configService
= GuiActivator.getConfigurationService();
if(autoPopupNewMessage)
configService.setProperty(
"net.java.sip.communicator.impl.gui.autoPopupNewMessage",
@ -51,4 +93,31 @@ public static void setAutoPopupNewMessage(boolean autoPopupNewMessage)
"net.java.sip.communicator.impl.gui.autoPopupNewMessage",
"no");
}
public static void setShowOffline(boolean isShowOffline)
{
ConfigurationManager.isShowOffline = isShowOffline;
configService.setProperty(
"net.java.sip.communicator.impl.gui.showOffline",
new Boolean(isShowOffline));
}
public static void setShowCallPanel(boolean isCallPanelShown)
{
ConfigurationManager.isCallPanelShown = isCallPanelShown;
configService.setProperty(
"net.java.sip.communicator.impl.gui.showCallPanel",
new Boolean(isCallPanelShown));
}
public static void setApplicationVisible(boolean isVisible)
{
isApplicationVisible = isVisible;
configService.setProperty(
"net.java.sip.communicator.impl.systray.showApplication",
new Boolean(isVisible));
}
}

@ -7,6 +7,7 @@
package net.java.sip.communicator.impl.systray;
import net.java.sip.communicator.impl.systray.jdic.*;
import net.java.sip.communicator.service.configuration.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.util.*;
@ -27,6 +28,8 @@ public class SystrayActivator
public static UIService uiService;
private static ConfigurationService configService;
private static Logger logger = Logger.getLogger(
SystrayActivator.class.getName());
@ -60,4 +63,24 @@ public void start(BundleContext bc) throws Exception
*/
public void stop(BundleContext bc) throws Exception {
}
/**
* Returns the <tt>ConfigurationService</tt> obtained from the bundle
* context.
* @return the <tt>ConfigurationService</tt> obtained from the bundle
* context
*/
public static ConfigurationService getConfigurationService()
{
if(configService == null) {
ServiceReference configReference = bundleContext
.getServiceReference(ConfigurationService.class.getName());
configService = (ConfigurationService) bundleContext
.getService(configReference);
}
return configService;
}
}

Loading…
Cancel
Save