Adds property to hide account selection when single option is available.

cusax-fix
Damian Minkov 14 years ago
parent 38542d5142
commit 29ef48fb65

@ -912,6 +912,10 @@ private Component createChatTransportSelectorBox()
chatPanel,
chatPanel.getChatSession(),
chatPanel.getChatSession().getCurrentChatTransport());
if(ConfigurationManager.isHideAccountSelectionWhenPossibleEnabled()
&& transportSelectorBox.getMenu().getItemCount() <= 1)
transportSelectorBox.setVisible(false);
}
return transportSelectorBox;
@ -956,7 +960,15 @@ public void setTransportSelectorBoxVisible(boolean isVisible)
}
else
{
transportSelectorBox.setVisible(true);
if( ConfigurationManager
.isHideAccountSelectionWhenPossibleEnabled()
&& transportSelectorBox.getMenu().getItemCount() <= 1)
{
transportSelectorBox.setVisible(false);
}
{
transportSelectorBox.setVisible(true);
}
centerPanel.repaint();
}
}
@ -1002,7 +1014,20 @@ public void run()
public void addChatTransport(ChatTransport chatTransport)
{
if (transportSelectorBox != null)
{
transportSelectorBox.addChatTransport(chatTransport);
// it was hidden cause we wanted to hide when there is only one
// provider
if(!transportSelectorBox.isVisible()
&& ConfigurationManager
.isHideAccountSelectionWhenPossibleEnabled()
&& transportSelectorBox.getMenu().getItemCount() > 1)
{
transportSelectorBox.setVisible(true);
}
}
}
/**
@ -1035,6 +1060,12 @@ public void removeChatTransport(ChatTransport chatTransport)
{
if (transportSelectorBox != null)
transportSelectorBox.removeChatTransport(chatTransport);
if(transportSelectorBox.getMenu().getItemCount() == 1
&& ConfigurationManager.isHideAccountSelectionWhenPossibleEnabled())
{
transportSelectorBox.setVisible(false);
}
}
/**

@ -163,12 +163,19 @@ private void init()
TransparentPanel fieldsPanel
= new TransparentPanel(new GridLayout(0, 1, 5, 5));
labelsPanel.add(accountLabel);
fieldsPanel.add(accountCombo);
initAccountCombo();
accountCombo.setRenderer(new AccountComboRenderer());
// we have an empty choice and one account
if(accountCombo.getItemCount() > 2
|| (accountCombo.getItemCount() == 2
&& !ConfigurationManager
.isHideAccountSelectionWhenPossibleEnabled()))
{
labelsPanel.add(accountLabel);
fieldsPanel.add(accountCombo);
}
labelsPanel.add(groupLabel);
fieldsPanel.add(groupCombo);
@ -210,7 +217,11 @@ public void removeUpdate(DocumentEvent e)
this.getContentPane().add(mainPanel, BorderLayout.CENTER);
this.setPreferredSize(new Dimension(450, 250));
if(ConfigurationManager.isHideAccountSelectionWhenPossibleEnabled())
this.setPreferredSize(new Dimension(450, 205));
else
this.setPreferredSize(new Dimension(450, 250));
this.setResizable(false);
this.addWindowFocusListener(this);

@ -214,6 +214,12 @@ public class ConfigurationManager
*/
private static boolean routeVideoAndDesktopUsingPhoneNumber = false;
/**
* Indicates that when we have a single account we can hide the select
* account option when possible.
*/
private static boolean hideAccountSelectionWhenPossible = false;
/**
* Loads all user interface configurations.
*/
@ -607,6 +613,19 @@ public static void loadGuiConfigurations()
if(routeVideoAndDesktopUsingPhoneNumberDefault != null)
routeVideoAndDesktopUsingPhoneNumber = Boolean.parseBoolean(
routeVideoAndDesktopUsingPhoneNumberDefault);
String hideAccountMenuProperty
= "impl.gui.HIDE_SELECTION_ON_SINGLE_ACCOUNT";
String hideAccountMenuDefaultValue = GuiActivator.getResources()
.getSettingsString(hideAccountMenuProperty);
if(hideAccountMenuDefaultValue != null)
hideAccountSelectionWhenPossible = Boolean.parseBoolean(
hideAccountMenuDefaultValue);
hideAccountSelectionWhenPossible = configService.getBoolean(
hideAccountMenuProperty,
hideAccountSelectionWhenPossible);
}
/**
@ -1103,6 +1122,17 @@ public static boolean isRouteVideoAndDesktopUsingPhoneNumberEnabled()
return routeVideoAndDesktopUsingPhoneNumber;
}
/**
* Whether allow user to select account when only a single
* account is available.
* @return whether allow user to select account when only a single
* account is available.
*/
public static boolean isHideAccountSelectionWhenPossibleEnabled()
{
return hideAccountSelectionWhenPossible;
}
/**
* Sets the transparency value for all transparent windows.
*

@ -767,8 +767,10 @@ private void requestDiscoveryInfo(final String entityID,
}
catch(XMPPException ex)
{
logger.error("Error requesting discover info for " + entityID,
ex);
// print discovery info errors only when trace is enabled
if(logger.isTraceEnabled())
logger.error("Error requesting discover info for "
+ entityID, ex);
}
}

Loading…
Cancel
Save