diff --git a/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java b/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java index cd4d0d091..90654590d 100644 --- a/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java +++ b/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java @@ -167,7 +167,7 @@ public Iterator getSupportedContainers() * Creates the corresponding PluginComponentEvent and notifies all * ContainerPluginListeners that a plugin component is added or * removed from the container. - * + * * @param pluginComponent the plugin component that is added to the * container. * @param containerID the containerID that corresponds to the container @@ -469,7 +469,7 @@ public Iterator getSupportedExportedWindows() /** * Implements the getExportedWindow in the UIService interface. * Returns the window corresponding to the given WindowID. - * + * * @param windowID the id of the window we'd like to retrieve. * @param params the params to be passed to the returned window. * @return a reference to the ExportedWindow instance corresponding @@ -671,7 +671,7 @@ public LoginManager getLoginManager() /** * Returns the chat conference manager. - * + * * @return the chat conference manager. */ public ConferenceChatManager getConferenceChatManager() @@ -681,7 +681,7 @@ public ConferenceChatManager getConferenceChatManager() /** * Returns the chat window manager. - * + * * @return the chat window manager. */ public ChatWindowManager getChatWindowManager() @@ -797,7 +797,8 @@ private void setDefaultThemePack() // default decoration. boolean isDecorated = new Boolean(GuiActivator.getResources() - .getSettingsString("impl.gui.IS_LOOK_AND_FEEL_DECORATED")) + .getSettingsString( + "impl.gui.IS_LOOK_AND_FEEL_DECORATED")) .booleanValue(); if (isDecorated) @@ -958,7 +959,8 @@ public boolean useMacOSXScreenMenuBar() { String osName = System.getProperty("os.name"); return (osName != null) - && ((osName.indexOf("Mac OS X") != -1) || (osName.indexOf("Darwin") != -1)); + && ((osName.indexOf("Mac OS X") != -1) + || (osName.indexOf("Darwin") != -1)); } public void beginShutdown() 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 8395d1529..ddc6a8d32 100644 --- a/src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommSmartComboBox.java +++ b/src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommSmartComboBox.java @@ -19,13 +19,13 @@ /** * SIPCommSmartComboBox is an editable combo box which selects an item * according to user input. - * + * * @author Yana Stamcheva */ public class SIPCommSmartComboBox extends JComboBox { private ArrayList historyList = new ArrayList(); - + /** * Creates an instance of SIPCommSmartComboBox. */ @@ -36,10 +36,10 @@ public SIPCommSmartComboBox() setEditable(true); setFocusable(true); } - + /** * The data model used for this combo box. Filters the contents of the - * combo box popup according to the user input. + * combo box popup according to the user input. */ public class FilterableComboBoxModel extends AbstractListModel @@ -50,7 +50,7 @@ public class FilterableComboBoxModel private Filter filter; private List filteredItems; private Object selectedItem; - + public FilterableComboBoxModel(List items) { this.items = new ArrayList(items); @@ -76,18 +76,19 @@ public void removeElement( Object obj ) } public void removeElementAt(int index) - { + { items.remove(index); updateFilteredItems(); } - public void insertElementAt( Object obj, int index ) { + public void insertElementAt( Object obj, int index ) + { items.add(index, obj); updateFilteredItems(); } public void setFilter(Filter filter) - { + { this.filter = filter; updateFilteredItems(); } @@ -98,10 +99,13 @@ protected void updateFilteredItems() filteredItems.clear(); if (filter == null) + { filteredItems.addAll(items); - else { + } + else + { for (Iterator iterator = items.iterator(); iterator.hasNext();) { - + Object item = iterator.next(); if (filter.accept(item)) @@ -125,48 +129,49 @@ public Object getSelectedItem() { return selectedItem; } - + public void setSelectedItem(Object val) { if ((selectedItem == null) && (val == null)) return; - + if ((selectedItem != null) && selectedItem.equals(val)) return; - + if ((val != null) && val.equals(selectedItem)) return; - + selectedItem = val; fireContentsChanged(this, -1, -1); } } - + public static interface Filter { public boolean accept(Object obj); } - + class StartsWithFilter implements Filter { private String prefix; - + public StartsWithFilter(String prefix) - { + { this.prefix = prefix.toLowerCase(); } - + public boolean accept(Object o) { - if(o != null) { - String objectString = o.toString().toLowerCase(); + if(o != null) + { + String objectString = o.toString().toLowerCase(); return (objectString.indexOf(prefix) >= 0) ? true : false; } - + return false; } } - + public class CallComboEditor implements ComboBoxEditor, DocumentListener @@ -174,7 +179,7 @@ public class CallComboEditor private JTextField text; private volatile boolean filtering = false; private volatile boolean setting = false; - + public CallComboEditor() { text = new JTextField(15); @@ -201,48 +206,48 @@ public void setItem(Object item) text.setText(newText); setting = false; } - + public Object getItem() { return text.getText(); } - + public void selectAll() { text.selectAll(); } - + public void addActionListener(ActionListener l) { text.addActionListener(l); } - + public void removeActionListener(ActionListener l) { text.removeActionListener(l); } - + public void insertUpdate(DocumentEvent e) { handleChange(); } public void removeUpdate(DocumentEvent e) { handleChange(); } public void changedUpdate(DocumentEvent e) { } - + protected void handleChange() { if (setting) return; - + filtering = true; - + Filter filter = null; if (text.getText().length() > 0) { filter = new StartsWithFilter(text.getText()); } - + ((FilterableComboBoxModel) getModel()).setFilter(filter); - + setPopupVisible(false); - + if(getModel().getSize() > 0) setPopupVisible(true); - + filtering = false; } } diff --git a/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommTextFieldUI.java b/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommTextFieldUI.java index 8c6721c78..ec65b59a7 100644 --- a/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommTextFieldUI.java +++ b/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommTextFieldUI.java @@ -1,6 +1,6 @@ /* * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. - * + * * Distributable under LGPL license. See terms of license at gnu.org. */ package net.java.sip.communicator.impl.gui.lookandfeel; @@ -19,7 +19,7 @@ /** * SIPCommTextFieldUI implementation. - * + * * @author Yana Stamcheva */ public class SIPCommTextFieldUI @@ -60,9 +60,9 @@ public SIPCommTextFieldUI() } /** - * Returns true if the delete buttons is enabled and false - + * Returns true if the delete buttons is enabled and false - * otherwise. - * @return true if the delete buttons is enabled and false - + * @return true if the delete buttons is enabled and false - * otherwise */ public boolean isDeleteButtonEnabled() @@ -72,7 +72,7 @@ public boolean isDeleteButtonEnabled() /** * Updates the isDeleteButtonEnabled field. - * + * * @param isDeleteButtonEnabled indicates if the delete buttons is enabled * or not */ @@ -98,7 +98,7 @@ protected void installListeners() /** * Creates the UI. - * + * * @param c the component associated with this UI implementation. * @return an instance of this UI implementation */ @@ -144,12 +144,14 @@ protected void paintBackground(Graphics g) * Updates the delete icon, changes the cursor and deletes the content of * the associated text component when the mouse is pressed over the delete * icon. - * - * @param x the x coordinate of the mouse event - * @param y the y coordinate of the mouse event + * + * @param evt the mouse event that has prompted us to update the delete + * icon. */ - protected void updateDeleteIcon(int x, int y) + protected void updateDeleteIcon(MouseEvent evt) { + int x = evt.getX(); + int y = evt.getY(); if (!isDeleteButtonEnabled) return; @@ -160,7 +162,7 @@ protected void updateDeleteIcon(int x, int y) mouseOver = true; getComponent().setCursor(Cursor.getDefaultCursor()); - if (mousePressed) + if (evt.getID() == MouseEvent.MOUSE_CLICKED) getComponent().setText(""); } else @@ -175,7 +177,7 @@ protected void updateDeleteIcon(int x, int y) /** * Calculates the delete button rectangle. - * + * * @return the delete button rectangle */ protected Rectangle getDeleteButtonRect() @@ -194,7 +196,7 @@ protected Rectangle getDeleteButtonRect() /** * If we are in the case of disabled delete button, we simply call the * parent implementation of this method, otherwise we recalculate the editor - * rectangle in order to leave place for the delete button. + * rectangle in order to leave place for the delete button. */ protected Rectangle getVisibleEditorRect() { @@ -229,30 +231,26 @@ protected Rectangle getVisibleEditorRect() protected class TextFieldMouseListener implements MouseListener { public void mouseClicked(MouseEvent e) - {} + { + updateDeleteIcon(e); + } public void mouseEntered(MouseEvent e) { - updateDeleteIcon(e.getX(), e.getY()); + updateDeleteIcon(e); } public void mouseExited(MouseEvent e) { - updateDeleteIcon(e.getX(), e.getY()); + updateDeleteIcon(e); } public void mousePressed(MouseEvent e) { - mousePressed = true; - - updateDeleteIcon(e.getX(), e.getY()); } public void mouseReleased(MouseEvent e) { - mousePressed = false; - - updateDeleteIcon(e.getX(), e.getY()); } } @@ -264,12 +262,12 @@ protected class TextFieldMouseMotionListener implements MouseMotionListener { public void mouseDragged(MouseEvent e) { - updateDeleteIcon(e.getX(), e.getY()); + updateDeleteIcon(e); } public void mouseMoved(MouseEvent e) { - updateDeleteIcon(e.getX(), e.getY()); + updateDeleteIcon(e); } } }