diff options
author | Lyubomir Marinov <lyubomir.marinov@jitsi.org> | 2009-02-17 01:37:01 +0000 |
---|---|---|
committer | Lyubomir Marinov <lyubomir.marinov@jitsi.org> | 2009-02-17 01:37:01 +0000 |
commit | 65f31038bda9e2bd35376e0e2f5a8afac5b5fecc (patch) | |
tree | ed67dcbb61394da2109d08bf52674dac15b2db76 | |
parent | e83fd664294391ee8a8ac66e21386ef159741a7e (diff) | |
download | jitsi-65f31038bda9e2bd35376e0e2f5a8afac5b5fecc.zip jitsi-65f31038bda9e2bd35376e0e2f5a8afac5b5fecc.tar.gz jitsi-65f31038bda9e2bd35376e0e2f5a8afac5b5fecc.tar.bz2 |
Removes unnecessary allocations, explicit boxing and unboxing, simplifies code.
7 files changed, 58 insertions, 75 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/DefaultContactEventHandler.java b/src/net/java/sip/communicator/impl/gui/DefaultContactEventHandler.java index f592416..26f57b1 100644 --- a/src/net/java/sip/communicator/impl/gui/DefaultContactEventHandler.java +++ b/src/net/java/sip/communicator/impl/gui/DefaultContactEventHandler.java @@ -20,9 +20,10 @@ import net.java.sip.communicator.service.protocol.*; * * @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 class DefaultContactEventHandler implements ContactEventHandler * * @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 class DefaultContactEventHandler implements ContactEventHandler */ public void run() { - ChatPanel chatPanel; - ChatWindowManager chatWindowManager = GuiActivator.getUIService().getChatWindowManager(); - chatPanel = chatWindowManager + ChatPanel chatPanel = chatWindowManager .getContactChat(metaContact, protocolContact); chatWindowManager.openChat(chatPanel, true); diff --git a/src/net/java/sip/communicator/impl/gui/PopupDialogImpl.java b/src/net/java/sip/communicator/impl/gui/PopupDialogImpl.java index 3e19538..2d44a1b 100644 --- a/src/net/java/sip/communicator/impl/gui/PopupDialogImpl.java +++ b/src/net/java/sip/communicator/impl/gui/PopupDialogImpl.java @@ -67,7 +67,7 @@ public class PopupDialogImpl public String showInputPopupDialog(Object message, String title, int messageType) { - return (String) showInputDialog(null, message, title, + return showInputDialog(null, message, title, popupDialog2JOptionPaneMessageType(messageType)); } diff --git a/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java b/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java index bf2e39b..43f58e3 100644 --- a/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java +++ b/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java @@ -170,8 +170,6 @@ public class UIServiceImpl * * @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 class UIServiceImpl MetaContact metaContact = mainFrame.getContactList() .findMetaContactByContact(contact); - ChatPanel chatPanel - = chatWindowManager.getContactChat(metaContact); - - return chatPanel; + return chatWindowManager.getContactChat(metaContact); } /** @@ -565,10 +560,7 @@ public class UIServiceImpl */ public ChatPanel getChat(ChatRoom chatRoom) { - ChatPanel chatPanel - = chatWindowManager.getMultiChat(chatRoom); - - return chatPanel; + return chatWindowManager.getMultiChat(chatRoom); } /** @@ -807,10 +799,9 @@ public class UIServiceImpl // 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 class UIServiceImpl String isTransparentString = (String) evt.getNewValue(); boolean isTransparentWindowEnabled - = new Boolean(isTransparentString).booleanValue(); + = Boolean.parseBoolean(isTransparentString); try { @@ -958,7 +949,7 @@ public class UIServiceImpl Font font = new Font( fontName, Font.BOLD, - new Integer(titleFontSize).intValue()); + Integer.parseInt(titleFontSize)); for (int i = 0; i < layeredPane.getComponentCount(); i++) { diff --git a/src/net/java/sip/communicator/impl/gui/main/MainFrame.java b/src/net/java/sip/communicator/impl/gui/main/MainFrame.java index d9f57c7..c27d138 100755 --- a/src/net/java/sip/communicator/impl/gui/main/MainFrame.java +++ b/src/net/java/sip/communicator/impl/gui/main/MainFrame.java @@ -182,7 +182,7 @@ public class MainFrame 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 @@ public class MainFrame 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 class MainFrame + protocolProvider.getAccountID().getAccountAddress()); this.protocolProviders.put(protocolProvider, - new Integer(initiateProviderIndex(protocolProvider))); + initiateProviderIndex(protocolProvider)); this.addProtocolSupportedOperationSets(protocolProvider); @@ -453,7 +453,7 @@ public class MainFrame { Integer o = protocolProviders.get(protocolProvider); - return (o != null) ? o.intValue() : 0; + return (o != null) ? o : 0; } /** @@ -690,16 +690,13 @@ public class MainFrame 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 @@ public class MainFrame //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 @@ public class MainFrame && !pps.equals(protocolProvider)) { - int index = protocolProviders.get(pps).intValue(); + int index = protocolProviders.get(pps); if (accountIndex < index) accountIndex = index; @@ -770,7 +762,7 @@ public class MainFrame accountIndex++; configService.setProperty( accountRootPropName + ".accountIndex", - new Integer(accountIndex)); + accountIndex); return accountIndex; } @@ -803,7 +795,7 @@ public class MainFrame } 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 @@ public class MainFrame configService.setProperty( rootPropName + ".accountIndex", - new Integer(0)); + 0); } } } @@ -1045,7 +1037,7 @@ public class MainFrame else { String pluginConstraints = c.getConstraints(); - Object constraints = null; + Object constraints; if (pluginConstraints != null) constraints = @@ -1076,7 +1068,7 @@ public class MainFrame || pluginContainer.equals(Container.CONTAINER_STATUS_BAR)) { String pluginConstraints = pluginComponent.getConstraints(); - Object constraints = null; + Object constraints; if (pluginConstraints != null) constraints = @@ -1527,18 +1519,18 @@ public class MainFrame } }); - 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); } } } diff --git a/src/net/java/sip/communicator/impl/gui/main/call/FullScreenLayout.java b/src/net/java/sip/communicator/impl/gui/main/call/FullScreenLayout.java index fcda9a0..7f20fb3 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/FullScreenLayout.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/FullScreenLayout.java @@ -103,9 +103,9 @@ public class FullScreenLayout implements LayoutManager 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 class FullScreenLayout implements LayoutManager 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)
diff --git a/src/net/java/sip/communicator/impl/gui/main/call/HoldButton.java b/src/net/java/sip/communicator/impl/gui/main/call/HoldButton.java index a55357d..c3e2053 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/HoldButton.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/HoldButton.java @@ -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 */ diff --git a/src/net/java/sip/communicator/impl/gui/main/call/MuteButton.java b/src/net/java/sip/communicator/impl/gui/main/call/MuteButton.java index 636d9bc..8d2b5f7 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/MuteButton.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/MuteButton.java @@ -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 @@ public class MuteButton * 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) |