Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.gui
Class UIServiceImpl

java.lang.Object
  extended by net.java.sip.communicator.impl.gui.UIServiceImpl
All Implemented Interfaces:
PropertyChangeListener, EventListener, UIService, ShutdownService, org.osgi.framework.ServiceListener

public class UIServiceImpl
extends Object
implements UIService, ShutdownService, org.osgi.framework.ServiceListener, PropertyChangeListener

An implementation of the UIService that gives access to other bundles to this particular swing ui implementation.

Author:
Yana Stamcheva, Lubomir Marinov, Dmitri Melnikov, Adam Netocny

Constructor Summary
UIServiceImpl()
          Creates an instance of UIServiceImpl.
 
Method Summary
 void addChatListener(ChatListener listener)
          Registers a NewChatListener to be informed when new Chats are created.
 void addPluginComponentListener(PluginComponentListener l)
          Adds the given PluginComponentListener to the list of component listeners registered in this UIService implementation.
 void addWindowListener(WindowListener l)
          Adds the given WindowListener to the main application window.
 void beginShutdown()
          Implements ShutdownService#beginShutdown().
 void bringToFront()
          Brings the focus to the main application window.
 WizardContainer getAccountRegWizardContainer()
          Implements the UIService.getAccountRegWizardContainer method.
 Collection<Chat> getAllChats()
          Provides all currently instantiated Chats.
static Object getBorderLayoutConstraintsFromContainer(Object containerConstraints)
          Returns the corresponding BorderLayout constraint from the given Container constraint.
 ChatPanel getChat(ChatRoom chatRoom)
          Returns the Chat corresponding to the given ChatRoom.
 ChatPanel getChat(Contact contact)
          Implements UIService.getChat(Contact).
 MetaContact getChatContact(Chat chat)
          Get the MetaContact corresponding to the chat.
 List<Chat> getChats()
          Returns a list containing all open Chats
 ChatWindowManager getChatWindowManager()
          Returns the chat window manager.
 ConferenceChatManager getConferenceChatManager()
          Returns the chat conference manager.
 ConfigurationContainer getConfigurationContainer()
          Returns the ConfigurationContainer associated with this UIService.
 CreateAccountWindow getCreateAccountWindow()
          Returns the create account window.
 ChatPanel getCurrentChat()
          Returns the selected Chat.
 String getCurrentPhoneNumber()
          Returns the phone number currently entered in the phone number field.
 SecurityAuthority getDefaultSecurityAuthority(ProtocolProviderService protocolProvider)
          Returns a default implementation of the SecurityAuthority interface that can be used by non-UI components that would like to launch the registration process for a protocol provider.
 boolean getExitOnMainWindowClose()
          Implements UIService.getExitOnMainWindowClose().
 ExportedWindow getExportedWindow(WindowID windowID)
          Implements the getExportedWindow in the UIService interface.
 ExportedWindow getExportedWindow(WindowID windowID, Object[] params)
          Implements the getExportedWindow in the UIService interface.
 HistoryWindowManager getHistoryWindowManager()
          Returns the HistoryWindowManager.
 Point getLocation()
          Returns the current location of the main application window.
 LoginManager getLoginManager()
          Returns the LoginManager.
 MainFrame getMainFrame()
          Returns the MainFrame.
 PopupDialog getPopupDialog()
          Implements getPopupDialog in the UIService interface.
 SingleWindowContainer getSingleWindowContainer()
          Returns the single window container if such one is available (i.e.
 Dimension getSize()
          Returns the size of the main application window.
 Iterator<Container> getSupportedContainers()
          Implements UISercie.getSupportedContainers.
 Iterator<WindowID> getSupportedExportedWindows()
          Implements getSupportedExportedWindows in the UIService interface.
 void initExportedWindows()
          Adds all ExportedWindows to the list of application windows, which could be used from other bundles.
 boolean isContainerSupported(Container containderID)
          Implements the UIService.isContainerSupported method.
 boolean isExportedWindowSupported(WindowID windowID)
          Implements the UIService.isExportedWindowSupported method.
 boolean isVisible()
          Implements isVisible in the UIService interface.
(package private)  void loadApplicationGui()
          Initializes all frames and panels and shows the GUI.
 void maximize()
          Implements maximize in the UIService interface.
 void minimize()
          Implements minimize in the UIService interface.
 void move(int x, int y)
          Implements move in the UIService interface.
 void propertyChange(PropertyChangeEvent evt)
          Indicates that a PropertyChangeEvent has occurred.
 void registerExportedWindow(ExportedWindow window)
          Registers the given ExportedWindow to the list of windows that could be accessed from other bundles.
 void removeChatListener(ChatListener listener)
          Removes the registration of a NewChatListener.
 void removePluginComponentListener(PluginComponentListener l)
          Removes the given PluginComponentListener from the list of component listeners registered in this UIService implementation.
 void removeWindowListener(WindowListener l)
          Removes the given WindowListener from the main application window.
 void repaintUI()
          Repaints and revalidates the whole UI Tree.
 void resize(int width, int height)
          Implements resize in the UIService interface.
 void restore()
          Implements restore in the UIService interface.
 void serviceChanged(org.osgi.framework.ServiceEvent event)
          Notifies all plugin containers of a PluginComponent registration.
 void setConfigurationWindowVisible(boolean visible)
          Implements UIService#setConfigurationWindowVisible(boolean).
 void setCurrentPhoneNumber(String phoneNumber)
          Changes the phone number currently entered in the phone number field.
 void setExitOnMainWindowClose(boolean exitOnMainWindowClose)
          Implements UIService.setExitOnMainWindowClose(boolean).
 void setLocation(int x, int y)
          Locates the main application window to the new x and y coordinates.
 void setSize(int width, int height)
          Sets the size of the main application window.
 void setVisible(boolean isVisible)
          Implements setVisible in the UIService interface.
 void unregisterExportedWindow(ExportedWindow window)
          Unregisters the given ExportedWindow from the list of windows that could be accessed from other bundles.
 boolean useMacOSXScreenMenuBar()
          Implements UIService#useMacOSXScreenMenuBar().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UIServiceImpl

public UIServiceImpl()
Creates an instance of UIServiceImpl.

Method Detail

loadApplicationGui

void loadApplicationGui()
Initializes all frames and panels and shows the GUI.


getSupportedContainers

public Iterator<Container> getSupportedContainers()
Implements UISercie.getSupportedContainers. Returns the list of supported containers by this implementation .

Specified by:
getSupportedContainers in interface UIService
Returns:
an Iterator over all supported containers.
See Also:
UIService.getSupportedContainers()

isVisible

public boolean isVisible()
Implements isVisible in the UIService interface. Checks if the main application window is visible.

Specified by:
isVisible in interface UIService
Returns:
true if main application window is visible, false otherwise
See Also:
UIService.isVisible()

setVisible

public void setVisible(boolean isVisible)
Implements setVisible in the UIService interface. Shows or hides the main application window depending on the parameter visible.

Specified by:
setVisible in interface UIService
Parameters:
isVisible - true if we are to show the main application frame and false otherwise.
See Also:
UIService.setVisible(boolean)

setLocation

public void setLocation(int x,
                        int y)
Locates the main application window to the new x and y coordinates.

Specified by:
setLocation in interface UIService
Parameters:
x - The new x coordinate.
y - The new y coordinate.

getLocation

public Point getLocation()
Returns the current location of the main application window. The returned point is the top left corner of the window.

Specified by:
getLocation in interface UIService
Returns:
The top left corner coordinates of the main application window.

getSize

public Dimension getSize()
Returns the size of the main application window.

Specified by:
getSize in interface UIService
Returns:
the size of the main application window.

setSize

public void setSize(int width,
                    int height)
Sets the size of the main application window.

Specified by:
setSize in interface UIService
Parameters:
width - The width of the window.
height - The height of the window.

minimize

public void minimize()
Implements minimize in the UIService interface. Minimizes the main application window.

Specified by:
minimize in interface UIService
See Also:
UIService.minimize()

maximize

public void maximize()
Implements maximize in the UIService interface. Maximizes the main application window.

Specified by:
maximize in interface UIService
See Also:
UIService.maximize()

restore

public void restore()
Implements restore in the UIService interface. Restores the main application window.

Specified by:
restore in interface UIService
See Also:
UIService.restore()

resize

public void resize(int width,
                   int height)
Implements resize in the UIService interface. Resizes the main application window.

Specified by:
resize in interface UIService
Parameters:
height - the new height of tha main application frame.
width - the new width of the main application window.
See Also:
UIService.resize(int, int)

move

public void move(int x,
                 int y)
Implements move in the UIService interface. Moves the main application window to the point with coordinates - x, y.

Specified by:
move in interface UIService
Parameters:
x - the value of X where the main application frame is to be placed.
y - the value of Y where the main application frame is to be placed.
See Also:
UIService.move(int, int)

bringToFront

public void bringToFront()
Brings the focus to the main application window.

Specified by:
bringToFront in interface UIService

setExitOnMainWindowClose

public void setExitOnMainWindowClose(boolean exitOnMainWindowClose)
Implements UIService.setExitOnMainWindowClose(boolean). Sets the boolean property which indicates whether the application should be exited when the main application window is closed.

Specified by:
setExitOnMainWindowClose in interface UIService
Parameters:
exitOnMainWindowClose - true if closing the main application window should also be exiting the application; otherwise, false

getExitOnMainWindowClose

public boolean getExitOnMainWindowClose()
Implements UIService.getExitOnMainWindowClose(). Gets the boolean property which indicates whether the application should be exited when the main application window is closed.

Specified by:
getExitOnMainWindowClose in interface UIService
Returns:
determines whether the UI impl would exit the application when the main application window is closed.

initExportedWindows

public void initExportedWindows()
Adds all ExportedWindows to the list of application windows, which could be used from other bundles. Once registered in the UIService this window could be obtained through the getExportedWindow(WindowID) method and could be shown, hidden, resized, moved, etc.


registerExportedWindow

public void registerExportedWindow(ExportedWindow window)
Registers the given ExportedWindow to the list of windows that could be accessed from other bundles.

Parameters:
window - the window to be exported

unregisterExportedWindow

public void unregisterExportedWindow(ExportedWindow window)
Unregisters the given ExportedWindow from the list of windows that could be accessed from other bundles.

Parameters:
window - the window to no longer be exported

addPluginComponentListener

public void addPluginComponentListener(PluginComponentListener l)
Adds the given PluginComponentListener to the list of component listeners registered in this UIService implementation.

Parameters:
l - the PluginComponentListener to add

removePluginComponentListener

public void removePluginComponentListener(PluginComponentListener l)
Removes the given PluginComponentListener from the list of component listeners registered in this UIService implementation.

Parameters:
l - the PluginComponentListener to remove

getSupportedExportedWindows

public Iterator<WindowID> getSupportedExportedWindows()
Implements getSupportedExportedWindows in the UIService interface. Returns an iterator over a set of all windows exported by this implementation.

Specified by:
getSupportedExportedWindows in interface UIService
Returns:
an Iterator over all windows exported by this implementation of the UI service.
See Also:
UIService.getSupportedExportedWindows()

getExportedWindow

public ExportedWindow getExportedWindow(WindowID windowID,
                                        Object[] params)
Implements the getExportedWindow in the UIService interface. Returns the window corresponding to the given WindowID.

Specified by:
getExportedWindow in interface UIService
Parameters:
windowID - the id of the window we'd like to retrieve.
params - the params to be passed to the returned window.
Returns:
a reference to the ExportedWindow instance corresponding to windowID.
See Also:
UIService.getExportedWindow(WindowID)

getExportedWindow

public ExportedWindow getExportedWindow(WindowID windowID)
Implements the getExportedWindow in the UIService interface. Returns the window corresponding to the given WindowID.

Specified by:
getExportedWindow in interface UIService
Parameters:
windowID - the id of the window we'd like to retrieve.
Returns:
a reference to the ExportedWindow instance corresponding to windowID.
See Also:
UIService.getExportedWindow(WindowID)

isExportedWindowSupported

public boolean isExportedWindowSupported(WindowID windowID)
Implements the UIService.isExportedWindowSupported method. Checks if there's an exported component for the given WindowID.

Specified by:
isExportedWindowSupported in interface UIService
Parameters:
windowID - the id of the window that we're making the query for.
Returns:
true if a window with the corresponding windowID is exported by the UI service implementation and false otherwise.
See Also:
UIService.isExportedWindowSupported(WindowID)

getPopupDialog

public PopupDialog getPopupDialog()
Implements getPopupDialog in the UIService interface. Returns a PopupDialog that could be used to show simple messages, warnings, errors, etc.

Specified by:
getPopupDialog in interface UIService
Returns:
a PopupDialog that could be used to show simple messages, warnings, errors, etc.
See Also:
UIService.getPopupDialog()

getChat

public ChatPanel getChat(Contact contact)
Implements UIService.getChat(Contact). If a chat for the given contact exists already, returns it; otherwise, creates a new one.

Specified by:
getChat in interface UIService
Parameters:
contact - the contact that we'd like to retrieve a chat window for.
Returns:
the Chat corresponding to the specified contact.
See Also:
UIService.getChat(Contact)

getChat

public ChatPanel getChat(ChatRoom chatRoom)
Returns the Chat corresponding to the given ChatRoom.

Specified by:
getChat in interface UIService
Parameters:
chatRoom - the ChatRoom for which the searched chat is about.
Returns:
the Chat corresponding to the given ChatRoom.

getCurrentChat

public ChatPanel getCurrentChat()
Returns the selected Chat.

Specified by:
getCurrentChat in interface UIService
Returns:
the selected Chat.

getCurrentPhoneNumber

public String getCurrentPhoneNumber()
Returns the phone number currently entered in the phone number field.

Specified by:
getCurrentPhoneNumber in interface UIService
Returns:
the phone number currently entered in the phone number field.

setCurrentPhoneNumber

public void setCurrentPhoneNumber(String phoneNumber)
Changes the phone number currently entered in the phone number field.

Specified by:
setCurrentPhoneNumber in interface UIService
Parameters:
phoneNumber - the phone number to enter in the phone number field.

isContainerSupported

public boolean isContainerSupported(Container containderID)
Implements the UIService.isContainerSupported method. Checks if the plugable container with the given Container is supported by this implementation.

Specified by:
isContainerSupported in interface UIService
Parameters:
containderID - the id of the container that we're making the query for.
Returns:
true if the container with the specified id is exported by the implementation of the UI service and false otherwise.
See Also:
UIService.isContainerSupported(Container)

getAccountRegWizardContainer

public WizardContainer getAccountRegWizardContainer()
Implements the UIService.getAccountRegWizardContainer method. Returns the current implementation of the AccountRegistrationWizardContainer.

Specified by:
getAccountRegWizardContainer in interface UIService
Returns:
a reference to the currently valid instance of AccountRegistrationWizardContainer.
See Also:
UIService.getAccountRegWizardContainer()

getDefaultSecurityAuthority

public SecurityAuthority getDefaultSecurityAuthority(ProtocolProviderService protocolProvider)
Returns a default implementation of the SecurityAuthority interface that can be used by non-UI components that would like to launch the registration process for a protocol provider. Initially this method was meant for use by the systray bundle and the protocol URI handlers.

Specified by:
getDefaultSecurityAuthority in interface UIService
Parameters:
protocolProvider - the ProtocolProviderService for which the authentication window is about.
Returns:
a default implementation of the SecurityAuthority interface that can be used by non-UI components that would like to launch the registration process for a protocol provider.

getLoginManager

public LoginManager getLoginManager()
Returns the LoginManager.

Returns:
the LoginManager

getConferenceChatManager

public ConferenceChatManager getConferenceChatManager()
Returns the chat conference manager.

Returns:
the chat conference manager.

getChatWindowManager

public ChatWindowManager getChatWindowManager()
Returns the chat window manager.

Returns:
the chat window manager.

getHistoryWindowManager

public HistoryWindowManager getHistoryWindowManager()
Returns the HistoryWindowManager.

Returns:
the HistoryWindowManager

getMainFrame

public MainFrame getMainFrame()
Returns the MainFrame. This is the class defining the main application window.

Returns:
the MainFrame

serviceChanged

public void serviceChanged(org.osgi.framework.ServiceEvent event)
Notifies all plugin containers of a PluginComponent registration.

Specified by:
serviceChanged in interface org.osgi.framework.ServiceListener
Parameters:
event - the ServiceEvent that notified us

getBorderLayoutConstraintsFromContainer

public static Object getBorderLayoutConstraintsFromContainer(Object containerConstraints)
Returns the corresponding BorderLayout constraint from the given Container constraint.

Parameters:
containerConstraints - constraints defined in the Container
Returns:
the corresponding BorderLayout constraint from the given Container constraint.

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Indicates that a PropertyChangeEvent has occurred.

Specified by:
propertyChange in interface PropertyChangeListener
Parameters:
evt - the PropertyChangeEvent that notified us

useMacOSXScreenMenuBar

public boolean useMacOSXScreenMenuBar()
Implements UIService#useMacOSXScreenMenuBar(). Indicates that the Mac OS X screen menu bar is to be used on Mac OS X and the Windows-like per-window menu bars are to be used on non-Mac OS X operating systems.

Specified by:
useMacOSXScreenMenuBar in interface UIService
Returns:
true to indicate that MacOSX screen menu bar should be used, false - otherwise

beginShutdown

public void beginShutdown()
Implements ShutdownService#beginShutdown(). Disposes of the mainFrame (if it exists) and then instructs Felix to start shutting down the bundles so that the application can gracefully quit.

Specified by:
beginShutdown in interface ShutdownService

setConfigurationWindowVisible

public void setConfigurationWindowVisible(boolean visible)
Implements UIService#setConfigurationWindowVisible(boolean). Makes sure there is only one ConfigurationFrame instance visible at one and the same time.

Specified by:
setConfigurationWindowVisible in interface UIService
Parameters:
visible - true to show the configuration frame, false - otherwise

getConfigurationContainer

public ConfigurationContainer getConfigurationContainer()
Returns the ConfigurationContainer associated with this UIService.

Specified by:
getConfigurationContainer in interface UIService
Returns:
the ConfigurationContainer associated with this UIService

getChats

public List<Chat> getChats()
Returns a list containing all open Chats

Specified by:
getChats in interface UIService
Returns:
A list of all open Chats.

getChatContact

public MetaContact getChatContact(Chat chat)
Get the MetaContact corresponding to the chat. The chat must correspond to a one on one conversation, otherwise this method will return null.

Specified by:
getChatContact in interface UIService
Parameters:
chat - The chat to get the MetaContact from
Returns:
The MetaContact corresponding to the chat or null in case it is a chat with more then one person.

addWindowListener

public void addWindowListener(WindowListener l)
Adds the given WindowListener to the main application window.

Specified by:
addWindowListener in interface UIService
Parameters:
l - the WindowListener to add

removeWindowListener

public void removeWindowListener(WindowListener l)
Removes the given WindowListener from the main application window.

Specified by:
removeWindowListener in interface UIService
Parameters:
l - the WindowListener to remove

getAllChats

public Collection<Chat> getAllChats()
Provides all currently instantiated Chats.

Specified by:
getAllChats in interface UIService
Returns:
all active Chats.

getSingleWindowContainer

public SingleWindowContainer getSingleWindowContainer()
Returns the single window container if such one is available (i.e. we're in a single window mode).

Returns:
the single window container if such one is available, otherwise returns null

addChatListener

public void addChatListener(ChatListener listener)
Registers a NewChatListener to be informed when new Chats are created.

Specified by:
addChatListener in interface UIService
Parameters:
listener - listener to be registered

removeChatListener

public void removeChatListener(ChatListener listener)
Removes the registration of a NewChatListener.

Specified by:
removeChatListener in interface UIService
Parameters:
listener - listener to be unregistered

repaintUI

public void repaintUI()
Repaints and revalidates the whole UI Tree. Calls SwingUtilities.updateComponentTreeUI(Component c) for every window owned by the application which cause UI skin and layout repaint.

Specified by:
repaintUI in interface UIService

getCreateAccountWindow

public CreateAccountWindow getCreateAccountWindow()
Returns the create account window.

Specified by:
getCreateAccountWindow in interface UIService
Returns:
the create account window

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.