@ -6,16 +6,19 @@
* /
package net.java.sip.communicator.impl.gui.main.contactlist ;
import java.awt.* ;
import java.awt.event.* ;
import java.util. * ;
import java.util. List ;
import javax.swing.* ;
import javax.swing.text.* ;
import net.java.sip.communicator.impl.gui.* ;
import net.java.sip.communicator.impl.gui.main.* ;
import net.java.sip.communicator.impl.gui.main.call.* ;
import net.java.sip.communicator.service.protocol.* ;
import net.java.sip.communicator.util.swing.* ;
import net.java.sip.communicator.util.swing.event.* ;
/ * *
* The < tt > UnknownContactPanel < / tt > replaces the contact list , when a
@ -27,6 +30,7 @@
* /
public class UnknownContactPanel
extends TransparentPanel
implements TextFieldChangeListener
{
private final JButton addContact = new JButton (
GuiActivator . getResources ( ) . getI18NString ( "service.gui.ADD_CONTACT" ) ,
@ -38,6 +42,8 @@ public class UnknownContactPanel
GuiActivator . getResources ( )
. getImage ( "service.gui.icons.CALL_16x16_ICON" ) ) ;
private final JTextPane textArea = new JTextPane ( ) ;
/ * *
* The main application window .
* /
@ -61,6 +67,9 @@ public UnknownContactPanel(MainFrame window)
callContact . setMnemonic ( GuiActivator . getResources ( )
. getI18nMnemonic ( "service.gui.CALL_CONTACT" ) ) ;
initTextArea ( parentWindow . getCurrentSearchText ( ) ) ;
this . add ( textArea ) ;
this . add ( addContact ) ;
this . add ( callContact ) ;
@ -123,4 +132,61 @@ public void addUnknownContact()
{
addContact . doClick ( ) ;
}
/ * *
* Invoked when any text is inserted in the search field .
* /
public void textInserted ( )
{
updateTextArea ( parentWindow . getCurrentSearchText ( ) ) ;
}
/ * *
* Invoked when any text is removed from the search field .
* /
public void textRemoved ( )
{
updateTextArea ( parentWindow . getCurrentSearchText ( ) ) ;
}
/ * *
* Creates the text area .
* @param searchText the searched text
* /
private void initTextArea ( String searchText )
{
textArea . setText ( GuiActivator . getResources ( )
. getI18NString ( "service.gui.NO_CONTACTS_FOUND" ,
new String [ ] { '"' + searchText + '"' } ) ) ;
textArea . setOpaque ( false ) ;
StyledDocument doc = textArea . getStyledDocument ( ) ;
MutableAttributeSet standard = new SimpleAttributeSet ( ) ;
StyleConstants . setAlignment ( standard , StyleConstants . ALIGN_CENTER ) ;
StyleConstants . setFontFamily ( standard , textArea . getFont ( ) . getFamily ( ) ) ;
StyleConstants . setFontSize ( standard , 12 ) ;
doc . setParagraphAttributes ( 0 , 0 , standard , true ) ;
textArea . setPreferredSize (
new Dimension ( parentWindow . getWidth ( ) - 40 , 70 ) ) ;
textArea . setMinimumSize (
new Dimension ( parentWindow . getWidth ( ) - 40 , 70 ) ) ;
textArea . setMaximumSize (
new Dimension ( parentWindow . getWidth ( ) - 40 , 70 ) ) ;
parentWindow . addSearchFieldListener ( this ) ;
}
/ * *
* Updates the text area to take into account the new search text .
* @param searchText the search text to update
* /
private void updateTextArea ( String searchText )
{
textArea . setText ( GuiActivator . getResources ( )
. getI18NString ( "service.gui.NO_CONTACTS_FOUND" ,
new String [ ] { '"' + searchText + '"' } ) ) ;
this . revalidate ( ) ;
this . repaint ( ) ;
}
}