diff options
Diffstat (limited to 'src')
15 files changed, 302 insertions, 272 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/GuiActivator.java b/src/net/java/sip/communicator/impl/gui/GuiActivator.java index 6afe6a2..ef06792 100644 --- a/src/net/java/sip/communicator/impl/gui/GuiActivator.java +++ b/src/net/java/sip/communicator/impl/gui/GuiActivator.java @@ -92,7 +92,7 @@ public class GuiActivator implements BundleActivator private static List<ContactSourceService> contactSources; - private static List<CustomContactActionsService> contactActionsServices; + private static List<CustomContactActionsService<?>> contactActionsServices; private static SecurityAuthority securityAuthority; @@ -708,17 +708,15 @@ public class GuiActivator implements BundleActivator * @param providers the list of protocol providers * @return an array of wrapped protocol providers */ - public static Object[] getAccounts(List<ProtocolProviderService> providers) + public static Account[] getAccounts(List<ProtocolProviderService> providers) { - ArrayList<Account> accounts = new ArrayList<Account>(); Iterator<ProtocolProviderService> accountsIter = providers.iterator(); + List<Account> accounts = new ArrayList<Account>(); while (accountsIter.hasNext()) - { accounts.add(new Account(accountsIter.next())); - } - return accounts.toArray(); + return accounts.toArray(new Account[accounts.size()]); } /** diff --git a/src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommSmartComboBox.java b/src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommSmartComboBox.java index 1e521be..0f88cfd 100644 --- a/src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommSmartComboBox.java +++ b/src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommSmartComboBox.java @@ -24,8 +24,8 @@ import net.java.sip.communicator.util.skin.*; * @author Yana Stamcheva * @author Adam Netocny */ -public class SIPCommSmartComboBox - extends JComboBox +public class SIPCommSmartComboBox<E> + extends JComboBox<E> { private static final long serialVersionUID = 0L; @@ -34,7 +34,7 @@ public class SIPCommSmartComboBox */ public SIPCommSmartComboBox() { - setModel(new FilterableComboBoxModel()); + setModel(new FilterableComboBoxModel<E>()); setEditor(new CallComboEditor()); setEditable(true); setFocusable(true); @@ -44,19 +44,22 @@ public class SIPCommSmartComboBox * The data model used for this combo box. Filters the contents of the * combo box popup according to the user input. */ - public static class FilterableComboBoxModel - extends AbstractListModel - implements MutableComboBoxModel + public static class FilterableComboBoxModel<E> + extends AbstractListModel<E> + implements MutableComboBoxModel<E> { - private final List<Object> items; private Filter filter; - private final List<Object> filteredItems; + + private final List<E> filteredItems; + + private final List<E> items; + private Object selectedItem; public FilterableComboBoxModel() { - this.items = new ArrayList<Object>(); - this.filteredItems = new ArrayList<Object>(this.items.size()); + items = new ArrayList<E>(); + filteredItems = new ArrayList<E>(items.size()); updateFilteredItems(); } @@ -66,13 +69,13 @@ public class SIPCommSmartComboBox return items.contains(obj); } - public void addElement( Object obj ) + public void addElement(E obj) { items.add(obj); updateFilteredItems(); } - public void removeElement( Object obj ) + public void removeElement(Object obj) { items.remove(obj); updateFilteredItems(); @@ -84,7 +87,7 @@ public class SIPCommSmartComboBox updateFilteredItems(); } - public void insertElementAt( Object obj, int index ) + public void insertElementAt(E obj, int index) { items.add(index, obj); updateFilteredItems(); @@ -107,7 +110,7 @@ public class SIPCommSmartComboBox } else { - for (Object item : items) + for (E item : items) if (filter.accept(item)) filteredItems.add(item); } @@ -119,7 +122,7 @@ public class SIPCommSmartComboBox return filteredItems.size(); } - public Object getElementAt(int index) + public E getElementAt(int index) { return filteredItems.get(index); } @@ -247,13 +250,11 @@ public class SIPCommSmartComboBox filtering = true; - Filter filter = null; - if (text.getText().length() > 0) - { - filter = new StartsWithFilter(text.getText()); - } + String prefix = text.getText(); + Filter filter + = (prefix.length() > 0) ? new StartsWithFilter(prefix) : null; - ((FilterableComboBoxModel) getModel()).setFilter(filter); + ((FilterableComboBoxModel<?>) getModel()).setFilter(filter); setPopupVisible(false); diff --git a/src/net/java/sip/communicator/impl/gui/main/account/AccountListModel.java b/src/net/java/sip/communicator/impl/gui/main/account/AccountListModel.java index d35351ec..ea54f0f 100644 --- a/src/net/java/sip/communicator/impl/gui/main/account/AccountListModel.java +++ b/src/net/java/sip/communicator/impl/gui/main/account/AccountListModel.java @@ -18,7 +18,7 @@ import net.java.sip.communicator.service.protocol.*; * @author Yana Stamcheva */ public class AccountListModel - extends DefaultListModel + extends DefaultListModel<Account> { /** * Indicates that the data model content has changed. @@ -40,13 +40,14 @@ public class AccountListModel { if(!SwingUtilities.isEventDispatchThread()) { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - addAccount(account); - } - }); + SwingUtilities.invokeLater( + new Runnable() + { + public void run() + { + addAccount(account); + } + }); return; } @@ -58,12 +59,12 @@ public class AccountListModel } boolean isAccountAdded = false; - Enumeration<?> accounts = elements(); + Enumeration<Account> accounts = elements(); // If we already have other accounts. while (accounts.hasMoreElements()) { - Account a = (Account) accounts.nextElement(); + Account a = accounts.nextElement(); int accountIndex = indexOf(a); @@ -105,13 +106,14 @@ public class AccountListModel { if(!SwingUtilities.isEventDispatchThread()) { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - removeAccount(account); - } - }); + SwingUtilities.invokeLater( + new Runnable() + { + public void run() + { + removeAccount(account); + } + }); return; } @@ -128,12 +130,12 @@ public class AccountListModel */ public Account getAccount(AccountID accountID) { - Enumeration<?> accounts = elements(); + Enumeration<Account> accounts = elements(); // If we already have other accounts. while (accounts.hasMoreElements()) { - Account account = (Account) accounts.nextElement(); + Account account = accounts.nextElement(); if (account.getAccountID().equals(accountID)) return account; diff --git a/src/net/java/sip/communicator/impl/gui/main/call/PreCallDialog.java b/src/net/java/sip/communicator/impl/gui/main/call/PreCallDialog.java index 11417ca..498f5c0 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/PreCallDialog.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/PreCallDialog.java @@ -11,6 +11,7 @@ import java.awt.event.*; import javax.swing.*; import net.java.sip.communicator.impl.gui.*; +import net.java.sip.communicator.impl.gui.main.account.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.plugin.desktoputil.*; import net.java.sip.communicator.util.skin.*; @@ -92,7 +93,7 @@ public abstract class PreCallDialog /** * The combo box containing a list of accounts to choose from. */ - private JComboBox accountsCombo; + private JComboBox<Account> accountsCombo; /** * The window handling received calls. @@ -130,7 +131,7 @@ public abstract class PreCallDialog * @param text the text to show * @param accounts the list of accounts to choose from */ - public PreCallDialog(String title, String text, Object[] accounts) + public PreCallDialog(String title, String text, Account[] accounts) { this(title, text, accounts, false, false); } @@ -145,7 +146,7 @@ public abstract class PreCallDialog * @param video if it is a video call * @param existingCall true to answer call in an existing call */ - public PreCallDialog(String title, String text, Object[] accounts, + public PreCallDialog(String title, String text, Account[] accounts, boolean video, boolean existingCall) { preCallWindow = createPreCallWindow(title, text, accounts); @@ -180,7 +181,7 @@ public abstract class PreCallDialog */ private Window createPreCallWindow( String title, String text, - Object[] accounts) + Account[] accounts) { Window receivedCallWindow = null; @@ -203,7 +204,7 @@ public abstract class PreCallDialog { accountsCombo = HudWidgetFactory.createHudComboBox( - new DefaultComboBoxModel(accounts)); + new DefaultComboBoxModel<Account>(accounts)); } } else @@ -219,7 +220,7 @@ public abstract class PreCallDialog callLabelImage = new JLabel(); if (accounts != null) - accountsCombo = new JComboBox(accounts); + accountsCombo = new JComboBox<Account>(accounts); } if (text != null) @@ -387,7 +388,7 @@ public abstract class PreCallDialog * * @return the accounts combo box contained in this dialog */ - public JComboBox getAccountsCombo() + public JComboBox<Account> getAccountsCombo() { return accountsCombo; } diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatContactListModel.java b/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatContactListModel.java index 695b3f6..9479574 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatContactListModel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatContactListModel.java @@ -19,18 +19,18 @@ import net.java.sip.communicator.service.protocol.event.*; * the <tt>ChatContact</tt>s according to their member roles and in alphabetical
* order according to their names.
*
- * @author Lubomir Marinov
+ * @author Lyubomir Marinov
*/
public class ChatContactListModel
- extends AbstractListModel
+ extends AbstractListModel<ChatContact<?>>
{
/**
* The backing store of this <tt>AbstractListModel</tt> listing the
* <tt>ChatContact</tt>s.
*/
- private final List<ChatContact<?>> chatContacts =
- new ArrayList<ChatContact<?>>();
+ private final List<ChatContact<?>> chatContacts
+ = new ArrayList<ChatContact<?>>();
/**
* The implementation of the sorting rules - the <tt>ChatContact</tt>s are
@@ -38,45 +38,43 @@ public class ChatContactListModel * privileges and then they are sorted according to their names in
* alphabetical order.
*/
- private final Comparator<ChatContact<?>> sorter =
- new Comparator<ChatContact<?>>()
- {
- public int compare(ChatContact<?> chatContact0,
- ChatContact<?> chatContact1)
+ private final Comparator<ChatContact<?>> sorter
+ = new Comparator<ChatContact<?>>()
{
-
- /*
- * Place ChatMembers with more privileges at the beginning of the
- * list.
- */
- if (chatContact0 instanceof ConferenceChatContact)
+ public int compare(ChatContact<?> chatContact0, ChatContact<?> chatContact1)
{
- if (chatContact1 instanceof ConferenceChatContact)
+ /*
+ * Place ChatMembers with more privileges at the beginning of
+ * the list.
+ */
+ if (chatContact0 instanceof ConferenceChatContact)
{
- int role0
- = ((ConferenceChatContact) chatContact0).getRole()
- .getRoleIndex();
- int role1
- = ((ConferenceChatContact) chatContact1).getRole()
- .getRoleIndex();
-
- if (role0 > role1)
+ if (chatContact1 instanceof ConferenceChatContact)
+ {
+ int role0
+ = ((ConferenceChatContact) chatContact0).getRole()
+ .getRoleIndex();
+ int role1
+ = ((ConferenceChatContact) chatContact1).getRole()
+ .getRoleIndex();
+
+ if (role0 > role1)
+ return -1;
+ else if (role0 < role1)
+ return 1;
+ }
+ else
return -1;
- else if (role0 < role1)
- return 1;
}
- else
- return -1;
- }
- else if (chatContact1 instanceof ConferenceChatContact)
- return 1;
+ else if (chatContact1 instanceof ConferenceChatContact)
+ return 1;
- /* By default, sort the ChatContacts in alphabetical order. */
- return
- chatContact0.getName().compareToIgnoreCase(
- chatContact1.getName());
- }
- };
+ /* By default, sort the ChatContacts in alphabetical order. */
+ return
+ chatContact0.getName().compareToIgnoreCase(
+ chatContact1.getName());
+ }
+ };
/**
* Creates the model.
@@ -84,33 +82,45 @@ public class ChatContactListModel */
public ChatContactListModel(ChatSession chatSession)
{
- // when something like rename on a member change
- // update the UI to reflect it
- if(chatSession.getDescriptor() instanceof ChatRoomWrapper)
- {
- ((ChatRoomWrapper)chatSession.getDescriptor()).getChatRoom()
- .addMemberPropertyChangeListener(
- new ChatRoomMemberPropertyChangeListener()
- {
- public void chatRoomPropertyChanged(
- ChatRoomMemberPropertyChangeEvent event)
- {
- // find the index and fire
- // that content has changed
- int chatContactCount = chatContacts.size();
+ // when something like rename on a member change update the UI to
+ // reflect it
+ Object descriptor = chatSession.getDescriptor();
- for (int i = 0; i < chatContactCount; i++)
- {
- ChatContact<?> containedChatContact = chatContacts.get(i);
-
- if(containedChatContact.getDescriptor().equals(
- event.getSourceChatRoomMember()))
+ if(descriptor instanceof ChatRoomWrapper)
+ {
+ ((ChatRoomWrapper) descriptor)
+ .getChatRoom()
+ .addMemberPropertyChangeListener(
+ new ChatRoomMemberPropertyChangeListener()
{
- fireContentsChanged(containedChatContact, i, i);
- }
- }
- }
- });
+ public void chatRoomPropertyChanged(
+ ChatRoomMemberPropertyChangeEvent ev)
+ {
+ // Translate into
+ // ListDataListener.contentsChanged.
+ int chatContactCount = chatContacts.size();
+
+ for (int i = 0; i < chatContactCount; i++)
+ {
+ ChatContact<?> chatContact
+ = chatContacts.get(i);
+
+ if(chatContact.getDescriptor().equals(
+ ev.getSourceChatRoomMember()))
+ {
+ fireContentsChanged(
+ chatContact,
+ i, i);
+ /*
+ * TODO Can ev.sourceChatRoomMember
+ * equal more than one chatContacts
+ * element? If it cannot, it will be
+ * more efficient to break here.
+ */
+ }
+ }
+ }
+ });
}
}
@@ -157,7 +167,7 @@ public class ChatContactListModel }
/* Implements ListModel#getElementAt(int). */
- public Object getElementAt(int index)
+ public ChatContact<?> getElementAt(int index)
{
synchronized(chatContacts)
{
diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomListModel.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomListModel.java index 3c2e1bf..56b386d 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomListModel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomListModel.java @@ -14,17 +14,56 @@ import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.main.chat.conference.*; /** + * * @author Yana Stamcheva */ public class ChatRoomListModel - extends AbstractListModel + extends AbstractListModel<Object> { private final ChatRoomList chatRoomList; public ChatRoomListModel() { - chatRoomList = GuiActivator.getUIService() - .getConferenceChatManager().getChatRoomList(); + chatRoomList + = GuiActivator + .getUIService() + .getConferenceChatManager() + .getChatRoomList(); + } + + /** + * Informs interested listeners that new cells are added from startIndex to + * endIndex. + * + * @param startIndex The start index of the range . + * @param endIndex The end index of the range. + */ + public void contentAdded(int startIndex, int endIndex) + { + fireIntervalAdded(this, startIndex, endIndex); + } + + /** + * Informs interested listeners that the content has changed of the cells + * given by the range from startIndex to endIndex. + * + * @param startIndex The start index of the range . + * @param endIndex The end index of the range. + */ + public void contentChanged(int startIndex, int endIndex) + { + fireContentsChanged(this, startIndex, endIndex); + } + + /** + * Informs interested listeners that a range of cells is removed. + * + * @param startIndex The start index of the range. + * @param endIndex The end index of the range. + */ + public void contentRemoved(int startIndex, int endIndex) + { + fireIntervalAdded(this, startIndex, endIndex); } public Object getElementAt(int index) @@ -69,10 +108,9 @@ public class ChatRoomListModel public int getSize() { - int size = 0; - Iterator<ChatRoomProviderWrapper> chatRoomProviders = chatRoomList.getChatRoomProviders(); + int size = 0; while (chatRoomProviders.hasNext()) { @@ -88,8 +126,8 @@ public class ChatRoomListModel { Iterator<ChatRoomProviderWrapper> chatRoomProviders = chatRoomList.getChatRoomProviders(); + int index = 0; - int currentIndex = 0; while(chatRoomProviders.hasNext()) { ChatRoomProviderWrapper provider = chatRoomProviders.next(); @@ -98,7 +136,7 @@ public class ChatRoomListModel { // the current index is the index of the group so if this is the // searched index we return the group - return currentIndex; + return index; } else { @@ -107,50 +145,13 @@ public class ChatRoomListModel int i = provider.indexOf((ChatRoomWrapper) o); if (i != -1) - { - return currentIndex + i + 1; - } + return index + i + 1; } - currentIndex += provider.countChatRooms() + 1; + index += provider.countChatRooms() + 1; } } return -1; } - - /** - * Informs interested listeners that the content has changed of the cells - * given by the range from startIndex to endIndex. - * - * @param startIndex The start index of the range . - * @param endIndex The end index of the range. - */ - public void contentChanged(int startIndex, int endIndex) - { - fireContentsChanged(this, startIndex, endIndex); - } - - /** - * Informs interested listeners that new cells are added from startIndex to - * endIndex. - * - * @param startIndex The start index of the range . - * @param endIndex The end index of the range. - */ - public void contentAdded(int startIndex, int endIndex) - { - fireIntervalAdded(this, startIndex, endIndex); - } - - /** - * Informs interested listeners that a range of cells is removed. - * - * @param startIndex The start index of the range. - * @param endIndex The end index of the range. - */ - public void contentRemoved(int startIndex, int endIndex) - { - fireIntervalAdded(this, startIndex, endIndex); - } } diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListModel.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListModel.java index 1ecdb50..1d09c57 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListModel.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListModel.java @@ -19,10 +19,10 @@ import net.java.sip.communicator.util.*; * display it in <tt>ContactList</tt> as a list instead of a tree. * * @author Yana Stamcheva - * @author Lubomir Marinov + * @author Lyubomir Marinov */ public class ContactListModel - extends AbstractListModel + extends AbstractListModel<Object> { private final MetaContactListService contactList; diff --git a/src/net/java/sip/communicator/impl/neomedia/CallRecordingConfigForm.java b/src/net/java/sip/communicator/impl/neomedia/CallRecordingConfigForm.java index 0330d13..24eb663 100644 --- a/src/net/java/sip/communicator/impl/neomedia/CallRecordingConfigForm.java +++ b/src/net/java/sip/communicator/impl/neomedia/CallRecordingConfigForm.java @@ -60,7 +60,7 @@ public class CallRecordingConfigForm * Directory choose dialog. */ private final SipCommFileChooser dirChooser; - private JComboBox formatsComboBox; + private JComboBox<String> formatsComboBox; private JCheckBox saveCallsToCheckBox; /** * Directory where calls are stored. Default is SC_HOME/calls. @@ -184,10 +184,10 @@ public class CallRecordingConfigForm */ private Component createFormatsComboBox() { - ComboBoxModel formatsComboBoxModel - = new DefaultComboBoxModel(RecorderImpl.SUPPORTED_FORMATS); + ComboBoxModel<String> formatsComboBoxModel + = new DefaultComboBoxModel<String>(RecorderImpl.SUPPORTED_FORMATS); - formatsComboBox = new JComboBox(); + formatsComboBox = new JComboBox<String>(); formatsComboBox.setPreferredSize(new Dimension(200, 30)); formatsComboBox.setModel(formatsComboBoxModel); diff --git a/src/net/java/sip/communicator/impl/neomedia/DeviceConfigurationComboBoxModel.java b/src/net/java/sip/communicator/impl/neomedia/DeviceConfigurationComboBoxModel.java index d52eec5..c4dd0bb 100644 --- a/src/net/java/sip/communicator/impl/neomedia/DeviceConfigurationComboBoxModel.java +++ b/src/net/java/sip/communicator/impl/neomedia/DeviceConfigurationComboBoxModel.java @@ -27,7 +27,7 @@ import org.jitsi.service.neomedia.*; * @author Damian Minkov
*/
public class DeviceConfigurationComboBoxModel
- implements ComboBoxModel,
+ implements ComboBoxModel<Object>,
PropertyChangeListener
{
/**
diff --git a/src/net/java/sip/communicator/impl/neomedia/codec/video/h264/ConfigurationPanel.java b/src/net/java/sip/communicator/impl/neomedia/codec/video/h264/ConfigurationPanel.java index 36892b3..ff29288 100644 --- a/src/net/java/sip/communicator/impl/neomedia/codec/video/h264/ConfigurationPanel.java +++ b/src/net/java/sip/communicator/impl/neomedia/codec/video/h264/ConfigurationPanel.java @@ -56,7 +56,8 @@ public class ConfigurationPanel gridBagConstraints.gridy = 0; contentPanel.add(defaultProfileLabel, gridBagConstraints); - JComboBox defaultProfileComboBox = new JComboBox(); + JComboBox<NameValuePair> defaultProfileComboBox + = new JComboBox<NameValuePair>(); defaultProfileComboBox.setEditable(false); defaultProfileComboBox.addItem( new NameValuePair( @@ -85,7 +86,8 @@ public class ConfigurationPanel gridBagConstraints.gridy = 1; contentPanel.add(preferredKeyFrameRequesterLabel, gridBagConstraints); - JComboBox preferredKeyFrameRequesterComboBox = new JComboBox(); + JComboBox<NameValuePair> preferredKeyFrameRequesterComboBox + = new JComboBox<NameValuePair>(); preferredKeyFrameRequesterComboBox.setEditable(false); preferredKeyFrameRequesterComboBox.addItem( new NameValuePair( @@ -116,7 +118,8 @@ public class ConfigurationPanel gridBagConstraints.gridy = 2; contentPanel.add(presetLabel, gridBagConstraints); - JComboBox presetComboBox = new JComboBox(); + JComboBox<NameValuePair> presetComboBox + = new JComboBox<NameValuePair>(); presetComboBox.setEditable(false); for(String presetSetting : JNIEncoder.AVAILABLE_PRESETS) { @@ -173,7 +176,7 @@ public class ConfigurationPanel * to set the value of */ private void addActionListener( - final JComboBox comboBox, + final JComboBox<NameValuePair> comboBox, final String property) { comboBox.addActionListener( @@ -201,14 +204,15 @@ public class ConfigurationPanel * @param value the value of the <tt>NameValuePair</tt> to set as the * selected item of <tt>comboBox</tt> */ - private void setSelectedNameValuePair(JComboBox comboBox, String value) + private void setSelectedNameValuePair( + JComboBox<NameValuePair> comboBox, + String value) { int itemCount = comboBox.getItemCount(); for (int itemIndex = 0; itemIndex < itemCount; itemIndex++) { - NameValuePair nameValuePair - = (NameValuePair) comboBox.getItemAt(itemIndex); + NameValuePair nameValuePair = comboBox.getItemAt(itemIndex); if (nameValuePair.value.equals(value)) { diff --git a/src/net/java/sip/communicator/plugin/dictaccregwizz/StrategiesList.java b/src/net/java/sip/communicator/plugin/dictaccregwizz/StrategiesList.java index d7dd6c4..b373241 100755 --- a/src/net/java/sip/communicator/plugin/dictaccregwizz/StrategiesList.java +++ b/src/net/java/sip/communicator/plugin/dictaccregwizz/StrategiesList.java @@ -20,7 +20,7 @@ import net.java.dict4j.*; * @author ROTH Damien */ public class StrategiesList - extends JList + extends JList<Strategy> { /** * Serial version UID. @@ -114,21 +114,21 @@ public class StrategiesList * @author ROTH Damien */ static class ListModel - extends AbstractListModel + extends AbstractListModel<Strategy> { /** * Serial version UID. */ private static final long serialVersionUID = 0L; - List<Strategy> data; + private List<Strategy> data; /** * Create an instance of <tt>ListModel</tt> */ public ListModel() { - this.data = new ArrayList<Strategy>(); + data = new ArrayList<Strategy>(); } /** @@ -137,8 +137,8 @@ public class StrategiesList */ public void setStrategies(List<Strategy> strategies) { - this.data = strategies; - fireContentsChanged(this, 0, this.data.size()); + data = strategies; + fireContentsChanged(this, 0, data.size()); } /** @@ -146,15 +146,15 @@ public class StrategiesList */ public void clear() { - this.data.clear(); + data.clear(); } /** * Implements <tt>ListModel.getElementAt</tt> */ - public Object getElementAt(int row) + public Strategy getElementAt(int row) { - return this.data.get(row); + return data.get(row); } /** @@ -162,22 +162,21 @@ public class StrategiesList */ public int getSize() { - return this.data.size(); + return data.size(); } /** - * Find the index of a strategie + * Find the index of a strategy. + * * @param strategyCode the code of the strategy * @return the index of the strategy */ public int indexOf(String strategyCode) { - for (int i=0; i<this.data.size(); i++) + for (int i = 0, size = data.size(); i < size; i++) { - if (this.data.get(i).getCode().equals(strategyCode)) - { + if (data.get(i).getCode().equals(strategyCode)) return i; - } } return -1; } @@ -190,7 +189,7 @@ public class StrategiesList */ static class CellRenderer extends JLabel - implements ListCellRenderer + implements ListCellRenderer<Strategy> { /** * Serial version UID. @@ -200,11 +199,14 @@ public class StrategiesList /** * implements <tt>ListCellRenderer.getListCellRendererComponent</tt> */ - public Component getListCellRendererComponent(JList list, Object value, - int index, boolean isSelected, boolean cellHasFocus) + public Component getListCellRendererComponent( + JList<? extends Strategy> list, + Strategy value, + int index, + boolean isSelected, + boolean cellHasFocus) { - Strategy strategy = (Strategy) value; - this.setText(strategy.getName()); + setText(value.getName()); if (isSelected) { diff --git a/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationPanel.java b/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationPanel.java index 7721f18..92d57c1 100644 --- a/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationPanel.java +++ b/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationPanel.java @@ -448,25 +448,28 @@ public class GeneralConfigurationPanel sendMessageLabel.setText( Resources.getString("plugin.generalconfig.SEND_MESSAGES_WITH")); - ComboBoxModel sendMessageComboBoxModel = - new DefaultComboBoxModel( - new String[] { - ConfigurationUtils.ENTER_COMMAND, - ConfigurationUtils.CTRL_ENTER_COMMAND }); - final JComboBox sendMessageComboBox = new JComboBox(); + ComboBoxModel<String> sendMessageComboBoxModel + = new DefaultComboBoxModel<String>( + new String[] + { + ConfigurationUtils.ENTER_COMMAND, + ConfigurationUtils.CTRL_ENTER_COMMAND + }); + final JComboBox<String> sendMessageComboBox = new JComboBox<String>(); sendMessagePanel.add(sendMessageComboBox); sendMessageComboBox.setModel(sendMessageComboBoxModel); sendMessageComboBox.setSelectedItem( ConfigurationUtils.getSendMessageCommand()); - sendMessageComboBox.addItemListener(new ItemListener() - { - public void itemStateChanged(ItemEvent arg0) - { - ConfigurationUtils.setSendMessageCommand( - (String)sendMessageComboBox.getSelectedItem()); - } - }); + sendMessageComboBox.addItemListener( + new ItemListener() + { + public void itemStateChanged(ItemEvent ev) + { + ConfigurationUtils.setSendMessageCommand( + (String) sendMessageComboBox.getSelectedItem()); + } + }); return sendMessagePanel; } diff --git a/src/net/java/sip/communicator/plugin/sipaccregwizz/ConnectionPanel.java b/src/net/java/sip/communicator/plugin/sipaccregwizz/ConnectionPanel.java index 3210db7..adfd9ea 100644 --- a/src/net/java/sip/communicator/plugin/sipaccregwizz/ConnectionPanel.java +++ b/src/net/java/sip/communicator/plugin/sipaccregwizz/ConnectionPanel.java @@ -48,33 +48,30 @@ public class ConnectionPanel private final JCheckBox proxyAutoCheckBox; - private final JComboBox certificate = new JComboBox(); + private final JComboBox<Object> certificate = new JComboBox<Object>(); - private JComboBox transportCombo = new JComboBox(new Object[] - { "UDP", "TCP", "TLS" }); + private JComboBox<String> transportCombo + = new JComboBox<String>(new String[] { "UDP", "TCP", "TLS" }); - private JComboBox keepAliveMethodBox - = new JComboBox(new Object [] - { - "NONE", - "REGISTER", - "OPTIONS" - }); + private JComboBox<String> keepAliveMethodBox + = new JComboBox<String>( + new String[] { "NONE", "REGISTER", "OPTIONS" }); private JTextField keepAliveIntervalValue = new JTextField(); - private JComboBox dtmfMethodBox - = new JComboBox(new Object [] - { - Resources.getString( - "plugin.sipaccregwizz.DTMF_AUTO"), - Resources.getString( - "plugin.sipaccregwizz.DTMF_RTP"), - Resources.getString( - "plugin.sipaccregwizz.DTMF_SIP_INFO"), - Resources.getString( - "plugin.sipaccregwizz.DTMF_INBAND") - }); + private JComboBox<String> dtmfMethodBox + = new JComboBox<String>( + new String[] + { + Resources.getString( + "plugin.sipaccregwizz.DTMF_AUTO"), + Resources.getString( + "plugin.sipaccregwizz.DTMF_RTP"), + Resources.getString( + "plugin.sipaccregwizz.DTMF_SIP_INFO"), + Resources.getString( + "plugin.sipaccregwizz.DTMF_INBAND") + }); private final JCheckBox mwiCheckBox; @@ -268,10 +265,12 @@ public class ConnectionPanel { certificate.removeAllItems(); certificate.insertItemAt( - Resources.getString("plugin.sipaccregwizz.NO_CERTIFICATE"), 0); + Resources.getString("plugin.sipaccregwizz.NO_CERTIFICATE"), + 0); certificate.setSelectedIndex(0); - for(CertificateConfigEntry e : SIPAccRegWizzActivator - .getCertificateService().getClientAuthCertificateConfigs()) + for(CertificateConfigEntry e + : SIPAccRegWizzActivator.getCertificateService() + .getClientAuthCertificateConfigs()) { certificate.addItem(e); if(e.getId().equals(id)) @@ -524,10 +523,13 @@ public class ConnectionPanel */ String getCertificateId() { - if(certificate.getSelectedItem() != null - && certificate.getSelectedItem() instanceof CertificateConfigEntry) - return ((CertificateConfigEntry)certificate.getSelectedItem()) - .getId(); + Object selectedItem = certificate.getSelectedItem(); + + if((selectedItem != null) + && (selectedItem instanceof CertificateConfigEntry)) + { + return ((CertificateConfigEntry) selectedItem).getId(); + } return null; } diff --git a/src/net/java/sip/communicator/plugin/skinmanager/SkinSelector.java b/src/net/java/sip/communicator/plugin/skinmanager/SkinSelector.java index 87148dd..13d65d5 100644 --- a/src/net/java/sip/communicator/plugin/skinmanager/SkinSelector.java +++ b/src/net/java/sip/communicator/plugin/skinmanager/SkinSelector.java @@ -98,14 +98,15 @@ public class SkinSelector selectActiveSkin(); - SwingUtilities.invokeLater(new Runnable() - { - public void run() + SwingUtilities.invokeLater( + new Runnable() { - if(listener != null) - listener.suppressAction(false); - } - }); + public void run() + { + if(listener != null) + listener.suppressAction(false); + } + }); } /** diff --git a/src/net/java/sip/communicator/plugin/spellcheck/LanguageMenuBar.java b/src/net/java/sip/communicator/plugin/spellcheck/LanguageMenuBar.java index 4366994..4cb9684 100644 --- a/src/net/java/sip/communicator/plugin/spellcheck/LanguageMenuBar.java +++ b/src/net/java/sip/communicator/plugin/spellcheck/LanguageMenuBar.java @@ -10,6 +10,7 @@ import java.awt.event.*; import java.awt.image.*; import java.io.*; import java.util.*; +import java.util.List; import javax.swing.*; import javax.swing.event.*; @@ -68,13 +69,13 @@ public class LanguageMenuBar private final SIPCommMenu menu = new SelectorMenu(); - private final ArrayList<Parameters.Locale> localeList = - new ArrayList<Parameters.Locale>(); + private final List<Parameters.Locale> localeList + = new ArrayList<Parameters.Locale>(); private final SIPCommTextButton removeItem = new SIPCommTextButton( Resources.getString("plugin.spellcheck.UNINSTALL_DICTIONARY")); - public final JList list; + public final JList<Parameters.Locale> list; /** * Provides instance of this class associated with a spell checker. If ones @@ -121,14 +122,14 @@ public class LanguageMenuBar this.menu.setOpaque(false); this.setOpaque(false); - final DefaultListModel model = new DefaultListModel(); - list = new JList(model); + final DefaultListModel<Parameters.Locale> model + = new DefaultListModel<Parameters.Locale>(); + list = new JList<Parameters.Locale>(model); this.languageSelectionRenderer = new LanguageListRenderer(); for (Parameters.Locale locale : Parameters.getLocales()) { - if (!localeAvailabilityCache.containsKey(locale)) { localeAvailabilityCache.put(locale, @@ -466,26 +467,27 @@ public class LanguageMenuBar * * @param model the model whose elements are to be set */ - private void setModelElements(DefaultListModel model) + private void setModelElements(DefaultListModel<Parameters.Locale> model) { synchronized (model) { model.clear(); - Collections.sort(localeList, new Comparator<Parameters.Locale>() - { - public int compare(Locale o1, Locale o2) - { - boolean b1 = spellChecker.isLocaleAvailable(o1); - boolean b2 = spellChecker.isLocaleAvailable(o2); - - if (b1 == b2) - return 0; + Collections.sort( + localeList, + new Comparator<Parameters.Locale>() + { + public int compare(Locale o1, Locale o2) + { + boolean b1 = spellChecker.isLocaleAvailable(o1); + boolean b2 = spellChecker.isLocaleAvailable(o2); - return (b1 ? -1 : 1); - } + if (b1 == b2) + return 0; - }); + return (b1 ? -1 : 1); + } + }); for (Parameters.Locale loc : localeList) model.addElement(loc); @@ -509,12 +511,12 @@ public class LanguageMenuBar { private final Parameters.Locale locale; - private final JList sourceList; + private final JList<Parameters.Locale> sourceList; private boolean skipFiring = false; public SetSpellChecker( Parameters.Locale locale, - JList sourceList) + JList<Parameters.Locale> sourceList) { this.locale = locale; this.sourceList = sourceList; @@ -567,7 +569,9 @@ public class LanguageMenuBar sourceList.removeListSelectionListener(sourceList .getListSelectionListeners()[0]); - setModelElements((DefaultListModel) sourceList.getModel()); + setModelElements( + (DefaultListModel<Parameters.Locale>) + sourceList.getModel()); sourceList.setSelectedValue(locale, true); removeItem.setEnabled(!spellChecker.getLocale().getIsoCode() .equals(Parameters.getDefault(Parameters.Default.LOCALE))); @@ -638,7 +642,7 @@ public class LanguageMenuBar */ private static final long serialVersionUID = 0L; - public Component getListCellRendererComponent(JList list, + public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { @@ -674,9 +678,10 @@ public class LanguageMenuBar { if (!e.getValueIsAdjusting()) { - final JList source = (JList) e.getSource(); - final Parameters.Locale locale = - (Parameters.Locale) source.getSelectedValue(); + @SuppressWarnings("unchecked") + JList<Parameters.Locale> source + = (JList<Parameters.Locale>) e.getSource(); + Parameters.Locale locale = source.getSelectedValue(); source.setEnabled(false); |