Removes unnecessary allocations, explicit boxing and unboxing, simplifies code.

cusax-fix
Lyubomir Marinov 17 years ago
parent e83fd66429
commit 65f31038bd

@ -20,9 +20,10 @@
*
* @author Yana Stamcheva
*/
public class DefaultContactEventHandler implements ContactEventHandler
public class DefaultContactEventHandler
implements ContactEventHandler
{
private MainFrame mainFrame;
private final MainFrame mainFrame;
/**
* Creates an instance of <tt>DefaultContactEventHandler</tt>.
@ -64,11 +65,12 @@ public void contactClicked(Contact contact, int clickCount)
*
* @author Yana Stamcheva
*/
public class RunMessageWindow implements Runnable
public static class RunMessageWindow
implements Runnable
{
private MetaContact metaContact;
private final MetaContact metaContact;
private Contact protocolContact;
private final Contact protocolContact;
/**
* Creates a chat window
@ -88,12 +90,10 @@ public RunMessageWindow(MetaContact metaContact,
*/
public void run()
{
ChatPanel chatPanel;
ChatWindowManager chatWindowManager
= GuiActivator.getUIService().getChatWindowManager();
chatPanel = chatWindowManager
ChatPanel chatPanel = chatWindowManager
.getContactChat(metaContact, protocolContact);
chatWindowManager.openChat(chatPanel, true);

@ -67,7 +67,7 @@ public String showInputPopupDialog(Object message,
public String showInputPopupDialog(Object message, String title,
int messageType)
{
return (String) showInputDialog(null, message, title,
return showInputDialog(null, message, title,
popupDialog2JOptionPaneMessageType(messageType));
}

@ -170,8 +170,6 @@ public Iterator<Container> getSupportedContainers()
*
* @param pluginComponent the plugin component that is added to the
* container.
* @param containerID the containerID that corresponds to the container
* where the component is added.
* @param eventID one of the PLUGIN_COMPONENT_XXX static fields indicating
* the nature of the event.
*/
@ -550,10 +548,7 @@ public ChatPanel getChat(Contact contact)
MetaContact metaContact = mainFrame.getContactList()
.findMetaContactByContact(contact);
ChatPanel chatPanel
= chatWindowManager.getContactChat(metaContact);
return chatPanel;
return chatWindowManager.getContactChat(metaContact);
}
/**
@ -565,10 +560,7 @@ public ChatPanel getChat(Contact contact)
*/
public ChatPanel getChat(ChatRoom chatRoom)
{
ChatPanel chatPanel
= chatWindowManager.getMultiChat(chatRoom);
return chatPanel;
return chatWindowManager.getMultiChat(chatRoom);
}
/**
@ -807,10 +799,9 @@ private void setDefaultThemePack()
// appropriate
// default decoration.
boolean isDecorated =
new Boolean(GuiActivator.getResources()
Boolean.parseBoolean(GuiActivator.getResources()
.getSettingsString(
"impl.gui.IS_LOOK_AND_FEEL_DECORATED"))
.booleanValue();
"impl.gui.IS_LOOK_AND_FEEL_DECORATED"));
if (isDecorated)
{
@ -912,7 +903,7 @@ public void propertyChange(PropertyChangeEvent evt)
String isTransparentString = (String) evt.getNewValue();
boolean isTransparentWindowEnabled
= new Boolean(isTransparentString).booleanValue();
= Boolean.parseBoolean(isTransparentString);
try
{
@ -958,7 +949,7 @@ private void initCustomFonts()
Font font = new Font( fontName,
Font.BOLD,
new Integer(titleFontSize).intValue());
Integer.parseInt(titleFontSize));
for (int i = 0; i < layeredPane.getComponentCount(); i++)
{

@ -182,7 +182,7 @@ private void init()
getSettingsString("impl.gui.IS_TOOLBAR_EXTENDED");
boolean isToolBarExtended
= new Boolean(isToolbarExtendedString).booleanValue();
= Boolean.parseBoolean(isToolbarExtendedString);
JPanel menusPanel = new JPanel(new BorderLayout());
@ -261,7 +261,7 @@ private void initTitleFont()
Font font = new Font( fontName,
Font.BOLD,
new Integer(titleFontSize).intValue());
Integer.parseInt(titleFontSize));
final int componentCount = layeredPane.getComponentCount();
for (int i = 0; i < componentCount; i++)
@ -429,7 +429,7 @@ public void addProtocolProvider(ProtocolProviderService protocolProvider)
+ protocolProvider.getAccountID().getAccountAddress());
this.protocolProviders.put(protocolProvider,
new Integer(initiateProviderIndex(protocolProvider)));
initiateProviderIndex(protocolProvider));
this.addProtocolSupportedOperationSets(protocolProvider);
@ -453,7 +453,7 @@ public int getProviderIndex(ProtocolProviderService protocolProvider)
{
Integer o = protocolProviders.get(protocolProvider);
return (o != null) ? o.intValue() : 0;
return (o != null) ? o : 0;
}
/**
@ -690,16 +690,13 @@ private int initiateProviderIndex(
List<String> accounts = configService
.getPropertyNamesByPrefix(prefix, true);
boolean savedAccount = false;
for (String accountRootPropName : accounts) {
String accountUID
= configService.getString(accountRootPropName);
if(accountUID.equals(protocolProvider
.getAccountID().getAccountUniqueID())) {
savedAccount = true;
.getAccountID().getAccountUniqueID()))
{
String index = configService.getString(
accountRootPropName + ".accountIndex");
@ -708,35 +705,30 @@ private int initiateProviderIndex(
//return this index
return Integer.parseInt(index);
}
else {
else
{
//if there's no stored accountIndex for this protocol
//provider, calculate the index, set it in the configuration
//service and return it.
int accountIndex = createAccountIndex(protocolProvider,
return createAccountIndex(protocolProvider,
accountRootPropName);
return accountIndex;
}
}
}
if(!savedAccount) {
String accNodeName
= "acc" + Long.toString(System.currentTimeMillis());
String accountPackage
= "net.java.sip.communicator.impl.gui.accounts."
+ accNodeName;
String accNodeName
= "acc" + Long.toString(System.currentTimeMillis());
configService.setProperty(accountPackage,
protocolProvider.getAccountID().getAccountUniqueID());
String accountPackage
= "net.java.sip.communicator.impl.gui.accounts."
+ accNodeName;
int accountIndex = createAccountIndex(protocolProvider,
accountPackage);
configService.setProperty(accountPackage,
protocolProvider.getAccountID().getAccountUniqueID());
return accountIndex;
}
return -1;
return createAccountIndex(protocolProvider,
accountPackage);
}
/**
@ -761,7 +753,7 @@ private int createAccountIndex(ProtocolProviderService protocolProvider,
&& !pps.equals(protocolProvider))
{
int index = protocolProviders.get(pps).intValue();
int index = protocolProviders.get(pps);
if (accountIndex < index)
accountIndex = index;
@ -770,7 +762,7 @@ private int createAccountIndex(ProtocolProviderService protocolProvider,
accountIndex++;
configService.setProperty(
accountRootPropName + ".accountIndex",
new Integer(accountIndex));
accountIndex);
return accountIndex;
}
@ -803,7 +795,7 @@ private void updateProvidersIndexes(ProtocolProviderService removedProvider)
}
if(sameProtocolProvidersCount < 2 && currentProvider != null) {
protocolProviders.put(currentProvider, new Integer(0));
protocolProviders.put(currentProvider, 0);
List<String> accounts = configService
.getPropertyNamesByPrefix(prefix, true);
@ -817,7 +809,7 @@ private void updateProvidersIndexes(ProtocolProviderService removedProvider)
configService.setProperty(
rootPropName + ".accountIndex",
new Integer(0));
0);
}
}
}
@ -1045,7 +1037,7 @@ private void initPluginComponents()
else
{
String pluginConstraints = c.getConstraints();
Object constraints = null;
Object constraints;
if (pluginConstraints != null)
constraints =
@ -1076,7 +1068,7 @@ public void pluginComponentAdded(PluginComponentEvent event)
|| pluginContainer.equals(Container.CONTAINER_STATUS_BAR))
{
String pluginConstraints = pluginComponent.getConstraints();
Object constraints = null;
Object constraints;
if (pluginConstraints != null)
constraints =
@ -1527,18 +1519,18 @@ public void propertyChange(PropertyChangeEvent e)
}
});
rootPane.setGlassPane(glassPane);
glassPane.setVisible(true);
}
else if (!glassPane.isVisible())
{
// we re-set the same glasspane in the root pane otherwise
// we are not guaranteed it will be painted in some case
rootPane.setGlassPane(glassPane);
glassPane.setVisible(true);
}
else
glassPane.setVisible(false);
rootPane.setGlassPane(glassPane);
glassPane.setVisible(true);
}
else if (!glassPane.isVisible())
{
// we re-set the same glasspane in the root pane otherwise
// we are not guaranteed it will be painted in some case
rootPane.setGlassPane(glassPane);
glassPane.setVisible(true);
}
else
glassPane.setVisible(false);
}
}
}

@ -103,9 +103,9 @@ public Dimension minimumLayoutSize(Container parent)
Component[] components = getLayoutComponents();
Dimension size = new Dimension(0, 0);
for (int i = 0; i < components.length; i++)
for (Component component : components)
{
Dimension componentSize = components[i].getMinimumSize();
Dimension componentSize = component.getMinimumSize();
size.width = Math.max(size.width, componentSize.width);
if (overlay)
@ -121,9 +121,9 @@ public Dimension preferredLayoutSize(Container parent)
Component[] components = getLayoutComponents();
Dimension size = new Dimension(0, 0);
for (int i = 0; i < components.length; i++)
for (Component component : components)
{
Dimension componentSize = components[i].getPreferredSize();
Dimension componentSize = component.getPreferredSize();
size.width = Math.max(size.width, componentSize.width);
if (overlay)

@ -29,7 +29,7 @@ public class HoldButton
* Initializes a new <tt>HoldButton</tt> instance which is to put a specific
* <tt>CallParticipant</tt> on/off hold.
*
* @param callParticipant the <tt>CallParticipant</tt> to be associated with
* @param call the <tt>Call</tt> to be associated with
* the new instance and to be put on/off hold upon performing its
* action
*/

@ -29,7 +29,7 @@ public class MuteButton
* Initializes a new <tt>MuteButton</tt> instance which is to mute the audio
* stream to a specific <tt>CallParticipant</tt>.
*
* @param callParticipant the <tt>CallParticipant</tt> to be associated with
* @param call the <tt>Call</tt> to be associated with
* the new instance and to have the audio stream sent to muted
*/
public MuteButton(Call call)
@ -63,7 +63,7 @@ private static class MuteButtonModel
* Initializes a new <tt>MuteButtonModel</tt> instance to represent the
* state of a specific <tt>CallParticipant</tt> as a toggle button.
*
* @param callParticipant the <tt>CallParticipant</tt> whose state is to
* @param call the <tt>Call</tt> whose state is to
* be represented as a toggle button
*/
public MuteButtonModel(Call call)

Loading…
Cancel
Save