implement ApplicationWindow getWindowID method

cusax-fix
Yana Stamcheva 19 years ago
parent 02a910731b
commit 2e7fa7d12d

@ -34,7 +34,7 @@ public class GuiActivator implements BundleActivator {
private static Logger logger = Logger.getLogger(GuiActivator.class.getName());
private static UIService uiService = null;
private static UIServiceImpl uiService = null;
private CommunicatorMain communicatorMain;
@ -94,6 +94,8 @@ public void start(BundleContext bundleContext) throws Exception {
ConfigurationManager.loadGuiConfigurations();
communicatorMain.showCommunicator(true);
SwingUtilities.invokeLater(new RunLogin());
uiService.registerExportableWindows();
}
finally {
logger.logExit();

@ -264,5 +264,10 @@ public void minimizeWindow()
{}
public void maximizeWindow()
{}
{}
public WindowID getWindowID()
{
return WINDOW_GENERAL_POPUP;
}
}

@ -17,12 +17,13 @@
import javax.swing.JFrame;
import net.java.sip.communicator.impl.gui.main.MainFrame;
import net.java.sip.communicator.impl.gui.main.*;
import net.java.sip.communicator.impl.gui.main.account.AccountRegWizardContainerImpl;
import net.java.sip.communicator.impl.gui.main.chat.*;
import net.java.sip.communicator.impl.gui.main.configforms.ConfigurationFrame;
import net.java.sip.communicator.impl.gui.main.contactlist.ContactListPanel;
import net.java.sip.communicator.service.contactlist.MetaContact;
import net.java.sip.communicator.impl.gui.main.contactlist.addcontact.*;
import net.java.sip.communicator.service.contactlist.*;
import net.java.sip.communicator.service.gui.AccountRegistrationWizardContainer;
import net.java.sip.communicator.service.gui.ApplicationWindow;
import net.java.sip.communicator.service.gui.ConfigurationWindow;
@ -37,58 +38,66 @@
import net.java.sip.communicator.util.Logger;
/**
* An implementation of the <tt>UIService</tt> that gives access to
* other bundles to this particular swing ui implementation.
* An implementation of the <tt>UIService</tt> that gives access to other
* bundles to this particular swing ui implementation.
*
* @author Yana Stamcheva
*/
public class UIServiceImpl implements UIService {
public class UIServiceImpl
implements
UIService
{
private static final Logger logger
= Logger.getLogger(UIServiceImpl.class);
private static final Logger logger = Logger.getLogger(UIServiceImpl.class);
private PopupDialogImpl popupDialog;
private AccountRegWizardContainerImpl wizardContainer;
private Map registeredPlugins = new Hashtable();
private Vector containerPluginListeners = new Vector();
private Vector pluginComponentListeners = new Vector();
private static final List supportedContainers = new ArrayList();
static {
static
{
supportedContainers.add(UIService.CONTAINER_MAIN_TOOL_BAR);
supportedContainers.add(UIService.CONTAINER_CONTACT_RIGHT_BUTTON_MENU);
supportedContainers.add(UIService.CONTAINER_GROUP_RIGHT_BUTTON_MENU);
}
private static final Hashtable exportedWindows = new Hashtable();
private MainFrame mainFrame;
private ContactListPanel contactList;
private ContactListPanel contactListPanel;
private ConfigurationFrame configurationFrame;
private boolean exitOnClose = true;
/**
* Creates an instance of <tt>UIServiceImpl</tt>.
*
* @param mainFrame The main application window.
*/
public UIServiceImpl(MainFrame mainFrame) {
public UIServiceImpl(MainFrame mainFrame)
{
this.mainFrame = mainFrame;
this.contactList = mainFrame.getContactListPanel();
this.contactListPanel = mainFrame.getContactListPanel();
this.popupDialog = new PopupDialogImpl(mainFrame);
this.wizardContainer = new AccountRegWizardContainerImpl(mainFrame);
this.configurationFrame = new ConfigurationFrame(mainFrame);
this.configurationFrame = new ConfigurationFrame(mainFrame);
}
/**
* Implements addComponent in UIService interface. Stores a plugin component
* and fires a PluginComponentEvent to inform all interested listeners
* that a plugin component has been added.
* and fires a PluginComponentEvent to inform all interested listeners that
* a plugin component has been added.
*
* @param containerID The <tt>ContainerID</tt> of the plugable container.
* @param component The component to add.
@ -96,44 +105,53 @@ public UIServiceImpl(MainFrame mainFrame) {
* @see UIService#addComponent(ContainerID, Object)
*/
public void addComponent(ContainerID containerID, Object component)
throws ClassCastException, IllegalArgumentException {
if (!supportedContainers.contains(containerID)) {
throws ClassCastException, IllegalArgumentException
{
if (!supportedContainers.contains(containerID))
{
throw new IllegalArgumentException(
"The constraint that you specified is not"
+ " supported by this UIService implementation.");
"The constraint that you specified is not"
+ " supported by this UIService implementation.");
}
else if (!(component instanceof Component)) {
else if (!(component instanceof Component))
{
throw new ClassCastException(
"The specified plugin is not a valid swing or awt component.");
} else {
if (registeredPlugins.containsKey(containerID)) {
}
else
{
if (registeredPlugins.containsKey(containerID))
{
((Vector) registeredPlugins.get(containerID)).add(component);
} else {
}
else
{
Vector plugins = new Vector();
plugins.add(component);
registeredPlugins.put(containerID, plugins);
}
this.firePluginEvent(component, containerID,
PluginComponentEvent.PLUGIN_COMPONENT_ADDED);
PluginComponentEvent.PLUGIN_COMPONENT_ADDED);
}
}
/**
* Implements <code>UIService.addComponent(ContainerID, String, Object)
* </code>. For now this method only invokes addComponent(containerID,
* component).
* </code>.
* For now this method only invokes addComponent(containerID, component).
*
* @see UIService#addComponent(ContainerID, String, Object)
*/
public void addComponent(ContainerID containerID, String constraint,
Object component) throws ClassCastException,
IllegalArgumentException {
Object component) throws ClassCastException, IllegalArgumentException
{
this.addComponent(containerID, component);
}
@ -141,68 +159,73 @@ public void addComponent(ContainerID containerID, String constraint,
*
*/
public void addComponent(ContainerID containerID,
ContactAwareComponent component)
throws ClassCastException, IllegalArgumentException
{
if (!(component instanceof Component)) {
ContactAwareComponent component) throws ClassCastException,
IllegalArgumentException
{
if (!(component instanceof Component))
{
throw new ClassCastException(
"The specified plugin is not a valid swing or awt component.");
}
this.addComponent(containerID, (Component)component);
this.addComponent(containerID, (Component) component);
}
/**
*
*/
public void addComponent(ContainerID containerID,
String constraint,
ContactAwareComponent component)
throws ClassCastException, IllegalArgumentException
public void addComponent(ContainerID containerID, String constraint,
ContactAwareComponent component) throws ClassCastException,
IllegalArgumentException
{
this.addComponent(containerID, constraint, component);
}
/**
* Implements <code>UISercie.getSupportedContainers</code>. Returns the
* list of supported containers by this implementation .
*
* @see UIService#getSupportedContainers()
*/
public Iterator getSupportedContainers() {
public Iterator getSupportedContainers()
{
return Collections.unmodifiableList(supportedContainers).iterator();
}
/**
* Implements getComponentsForConstraint in UIService interface.
*
* @see UIService#getComponentsForContainer(ContainerID)
*/
public Iterator getComponentsForContainer(ContainerID containerID)
throws IllegalArgumentException {
throws IllegalArgumentException
{
if(!supportedContainers.contains(containerID))
if (!supportedContainers.contains(containerID))
throw new IllegalArgumentException(
"The container that you specified is not "
+ "supported by this UIService implementation.");
+ "supported by this UIService implementation.");
Vector plugins = new Vector();
Object o = registeredPlugins.get(containerID);
if(o != null)
if (o != null)
{
plugins = (Vector)o;
plugins = (Vector) o;
}
return plugins.iterator();
}
/**
* Not yet implemented.
*
* @see UIService#getConstraintsForContainer(ContainerID)
*/
public Iterator getConstraintsForContainer(ContainerID containerID) {
public Iterator getConstraintsForContainer(ContainerID containerID)
{
return null;
}
@ -210,31 +233,34 @@ public Iterator getConstraintsForContainer(ContainerID containerID) {
* Creates the corresponding PluginComponentEvent and notifies all
* <tt>ContainerPluginListener</tt>s 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
* where the component is added.
* @param eventID
* one of the PLUGIN_COMPONENT_XXX static fields indicating the
* nature of the event.
* 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.
*/
private void firePluginEvent(Object pluginComponent,
ContainerID containerID, int eventID) {
ContainerID containerID, int eventID)
{
PluginComponentEvent evt = new PluginComponentEvent(pluginComponent,
containerID, eventID);
containerID, eventID);
logger.trace("Will dispatch the following plugin component event: "
+ evt);
+ evt);
synchronized (containerPluginListeners) {
Iterator listeners = this.containerPluginListeners.iterator();
synchronized (pluginComponentListeners)
{
Iterator listeners = this.pluginComponentListeners.iterator();
while (listeners.hasNext()) {
while (listeners.hasNext())
{
PluginComponentListener l = (PluginComponentListener) listeners
.next();
.next();
switch (evt.getEventID()) {
switch (evt.getEventID())
{
case PluginComponentEvent.PLUGIN_COMPONENT_ADDED:
l.pluginComponentAdded(evt);
break;
@ -249,16 +275,18 @@ private void firePluginEvent(Object pluginComponent,
}
/**
* Implements <code>isVisible</code> in the UIService interface.
* Checks if the main application window is visible.
* @return <code>true</code> if main application window is visible,
* <code>false</code> otherwise
* Implements <code>isVisible</code> in the UIService interface. Checks if
* the main application window is visible.
*
* @return <code>true</code> if main application window is visible,
* <code>false</code> otherwise
* @see UIService#isVisible()
*/
public boolean isVisible() {
if(mainFrame.isVisible())
public boolean isVisible()
{
if (mainFrame.isVisible())
{
if(mainFrame.getExtendedState() == JFrame.ICONIFIED)
if (mainFrame.getExtendedState() == JFrame.ICONIFIED)
return false;
else
return true;
@ -268,44 +296,53 @@ public boolean isVisible() {
}
/**
* Implements <code>setVisible</code> in the UIService interface.
* Shows or hides the main application window depending on the parameter
* Implements <code>setVisible</code> in the UIService interface. Shows or
* hides the main application window depending on the parameter
* <code>visible</code>.
*
* @see UIService#setVisible(boolean)
*/
public void setVisible(boolean visible) {
this.mainFrame.setVisible(visible);
public void setVisible(boolean visible)
{
this.mainFrame.setVisible(visible);
}
/**
* Implements <code>minimize</code> in the UIService interface.
* Minimizes the main application window.
* Implements <code>minimize</code> in the UIService interface. Minimizes
* the main application window.
*
* @see UIService#minimize()
*/
public void minimize() {
public void minimize()
{
this.mainFrame.setExtendedState(JFrame.ICONIFIED);
}
/**
* Implements <code>maximize</code> in the UIService interface.
* Maximizes the main application window.
* Implements <code>maximize</code> in the UIService interface. Maximizes
* the main application window.
*
* @see UIService#maximize()
*/
public void maximize() {
public void maximize()
{
this.mainFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
}
/**
* Implements <code>restore</code> in the UIService interface.
* Restores the main application window.
* Implements <code>restore</code> in the UIService interface. Restores
* the main application window.
*
* @see UIService#restore()
*/
public void restore() {
if (mainFrame.isVisible()) {
if(mainFrame.getState() == JFrame.ICONIFIED)
public void restore()
{
if (mainFrame.isVisible())
{
if (mainFrame.getState() == JFrame.ICONIFIED)
mainFrame.setState(JFrame.NORMAL);
mainFrame.toFront();
}
else
@ -313,42 +350,125 @@ public void restore() {
}
/**
* Implements <code>resize</code> in the UIService interface.
* Resizes the main application window.
* Implements <code>resize</code> in the UIService interface. Resizes the
* main application window.
*
* @see UIService#resize(int, int)
*/
public void resize(int width, int height) {
public void resize(int width, int height)
{
this.mainFrame.setSize(width, height);
}
/**
* Implements <code>move</code> in the UIService interface.
* Moves the main application window to the point with coordinates - x, y.
* Implements <code>move</code> in the UIService interface. Moves the main
* application window to the point with coordinates - x, y.
*
* @see UIService#move(int, int)
*/
public void move(int x, int y) {
public void move(int x, int y)
{
this.mainFrame.setLocation(x, y);
}
/**
* Implements <code>getApplicationWindows</code> in the UIService interface.
* Returns an iterator over a set of all windows exported by this
* Implements the <code>UIService.setExitOnMainWindowClose</code>. Sets a
* boolean property, which indicates whether the application should be
* exited when the main application window is closed.
*/
public void setExitOnMainWindowClose(boolean exitOnClose)
{
this.exitOnClose = exitOnClose;
if (exitOnClose)
mainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
else
mainFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
}
/**
* Implements the <code>UIService.getExitOnMainWindowClose</code>.
* Returns the boolean property, which indicates whether the application
* should be exited when the main application window is closed.
*/
public boolean getExitOnMainWindowClose()
{
return this.exitOnClose;
}
/**
* Adds all exportable <tt>ApplicationWindow</tt>s 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
* <tt>getApplicationWindow(WindowID)</tt> method and could be shown,
* hidden, resized, moved, etc.
*/
/**
* Adds all exportable <tt>ApplicationWindow</tt>s 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
* <tt>getApplicationWindow(WindowID)</tt> method and could be shown,
* hidden, resized, moved, etc.
*/
public void registerExportableWindows()
{
AboutWindow aboutWindow = new AboutWindow(mainFrame);
AddContactWizard addContactWizard = new AddContactWizard(mainFrame);
exportedWindows.put(aboutWindow.getWindowID(), aboutWindow);
exportedWindows.put(configurationFrame.getWindowID(), configurationFrame);
exportedWindows.put(addContactWizard.getWindowID(), addContactWizard);
}
/**
* Sets the contact list service to this UI Service implementation.
* @param contactList the MetaContactList service
*/
public void setContactList(MetaContactListService contactList)
{
this.mainFrame.setContactList(contactList);
}
public void addPluginComponentListener(PluginComponentListener l)
{
synchronized (pluginComponentListeners)
{
pluginComponentListeners.add(l);
}
}
public void removePluginComponentListener(PluginComponentListener l)
{
synchronized (pluginComponentListeners)
{
pluginComponentListeners.remove(l);
}
}
/**
* Implements <code>getApplicationWindows</code> in the UIService
* interface. Returns an iterator over a set of all windows exported by this
* implementation.
*
* @see UIService#getApplicationWindows()
*/
public Iterator getApplicationWindows() {
return Collections.unmodifiableMap(exportedWindows)
.values().iterator();
public Iterator getSupportedApplicationWindows()
{
return Collections.unmodifiableMap(exportedWindows).keySet().iterator();
}
/**
* Implements <code>getApplicationWindow</code> in the UIService interface.
* Returns the window corresponding to the given <tt>WindowID</tt>.
* Implements <code>getApplicationWindow</code> in the UIService
* interface. Returns the window corresponding to the given
* <tt>WindowID</tt>.
*
* @see UIService#getApplicationWindow(WindowID)
*/
public ApplicationWindow getApplicationWindow(WindowID dialogID) {
if (exportedWindows.contains(dialogID)) {
return (ApplicationWindow) exportedWindows.get(dialogID);
public ApplicationWindow getApplicationWindow(WindowID windowID)
{
if (exportedWindows.containsKey(windowID))
{
return (ApplicationWindow) exportedWindows.get(windowID);
}
return null;
}
@ -357,46 +477,53 @@ public ApplicationWindow getApplicationWindow(WindowID dialogID) {
* Implements <code>getPopupDialog</code> in the UIService interface.
* Returns a <tt>PopupDialog</tt> that could be used to show simple
* messages, warnings, errors, etc.
*
* @see UIService#getPopupDialog()
*/
public PopupDialog getPopupDialog() {
public PopupDialog getPopupDialog()
{
return this.popupDialog;
}
/**
* Implements <code>getChatDialog</code> in the UIService interface. If
* a chat dialog for the given contact exists already returns it,
* otherwise creates a new one.
* Implements <code>getChatDialog</code> in the UIService interface. If a
* chat dialog for the given contact exists already returns it, otherwise
* creates a new one.
*
* @see UIService#getChatWindow(Contact)
*/
public ApplicationWindow getChatWindow(Contact contact)
{
{
MetaContact metaContact = mainFrame.getContactList()
.findMetaContactByContact(contact);
ChatWindowManager chatWindowManager = mainFrame.getChatWindowManager();
ChatPanel chatPanel = chatWindowManager.getContactChat(metaContact);
return (ApplicationWindow) chatPanel;
return (ApplicationWindow) chatPanel;
}
/**
* Implements the <code>UIService.containsApplicationWindow</code> method.
* Checks if there's an exported window for the given <tt>WindowID</tt>.
*
* @see UIService#containsApplicationWindow(WindowID)
*/
public boolean containsApplicationWindow(WindowID dialogID) {
return exportedWindows.contains(dialogID);
public boolean containsApplicationWindow(WindowID windowID)
{
return exportedWindows.containsKey(windowID);
}
/**
* Implements the <code>UIService.isContainerSupported</code> method.
* Checks if the plugable container with the given ContainerID is supported
* by this implementation.
* by this implementation.
*
* @see UIService#isContainerSupported(ContainerID)
*/
public boolean isContainerSupported(ContainerID containderID) {
public boolean isContainerSupported(ContainerID containderID)
{
return supportedContainers.contains(containderID);
}
@ -404,19 +531,23 @@ public boolean isContainerSupported(ContainerID containderID) {
* Implements the <code>UIService.getAccountRegWizardContainer</code>
* method. Returns the current implementation of the
* <tt>AccountRegistrationWizardContainer</tt>.
*
* @see UIService#getAccountRegWizardContainer()
*/
public AccountRegistrationWizardContainer getAccountRegWizardContainer() {
public AccountRegistrationWizardContainer getAccountRegWizardContainer()
{
return this.wizardContainer;
}
/**
* Implements the <code>UIService.getConfigurationWindow</code>.
* Returns the current implementation of the <tt>ConfigurationWindow</tt>
* Implements the <code>UIService.getConfigurationWindow</code>. Returns
* the current implementation of the <tt>ConfigurationWindow</tt>
* interface.
*
* @see UIService#getConfigurationWindow()
*/
public ConfigurationWindow getConfigurationWindow() {
public ConfigurationWindow getConfigurationWindow()
{
return this.configurationFrame;
}
}

@ -10,11 +10,13 @@
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.i18n.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.gui.*;
public class AboutWindow
extends SIPCommDialog
implements HyperlinkListener,
ActionListener
ActionListener,
ApplicationWindow
{
private WindowBackground mainPanel
= new WindowBackground();
@ -175,4 +177,51 @@ public void actionPerformed(ActionEvent e)
{
this.dispose();
}
public WindowID getWindowID()
{
return ApplicationWindow.ABOUT_WINDOW;
}
public boolean isWindowVisible()
{
// TODO Auto-generated method stub
return false;
}
public void showWindow()
{
// TODO Auto-generated method stub
}
public void hideWindow()
{
// TODO Auto-generated method stub
}
public void resizeWindow(int width, int height)
{
// TODO Auto-generated method stub
}
public void moveWindow(int x, int y)
{
// TODO Auto-generated method stub
}
public void minimizeWindow()
{
// TODO Auto-generated method stub
}
public void maximizeWindow()
{
// TODO Auto-generated method stub
}
}

@ -64,17 +64,17 @@ public class MainFrame
private QuickMenu quickMenu;
private Hashtable protocolSupportedOperationSets = new Hashtable();
private Map protocolSupportedOperationSets = new LinkedHashMap();
private Hashtable protocolPresenceSets = new Hashtable();
private Map protocolPresenceSets = new LinkedHashMap();
private Hashtable protocolTelephonySets = new Hashtable();
private Map protocolTelephonySets = new LinkedHashMap();
private Hashtable protocolProviders = new Hashtable();
private LinkedHashMap protocolProviders = new LinkedHashMap();
private Hashtable webContactInfoOperationSets = new Hashtable();
private Map webContactInfoOperationSets = new LinkedHashMap();
private Hashtable multiUserChatOperationSets = new Hashtable();
private Map multiUserChatOperationSets = new LinkedHashMap();
private MetaContactListService contactList;
@ -323,7 +323,7 @@ public void addProtocolSupportedOperationSets(
*/
public Iterator getProtocolProviders()
{
return this.protocolProviders.keySet().iterator();
return ((LinkedHashMap)protocolProviders.clone()).keySet().iterator();
}
/**
@ -596,7 +596,7 @@ public void providerStatusChanged(ProviderPresenceStatusChangeEvent evt)
{
ProtocolProviderService pps = evt.getProvider();
getStatusPanel().updateStatus(pps);
getStatusPanel().updateStatus(pps, evt.getNewStatus());
if(callManager.containsCallAccount(pps))
{
@ -659,19 +659,23 @@ public void windowClosing(WindowEvent e) {
}
}
public void windowClosed(WindowEvent e) {
try {
GuiActivator.bundleContext.getBundle(0).stop();
} catch (BundleException ex) {
logger.error("Failed to gently shutdown Felix", ex);
System.exit(0);
public void windowClosed(WindowEvent e)
{
if(GuiActivator.getUIService().getExitOnMainWindowClose())
{
try {
GuiActivator.bundleContext.getBundle(0).stop();
} catch (BundleException ex) {
logger.error("Failed to gently shutdown Felix", ex);
System.exit(0);
}
//stopping a bundle doesn't leave the time to the felix thread to
//properly end all bundles and call their Activator.stop() methods.
//if this causes problems don't uncomment the following line but
//try and see why felix isn't exiting (suggesting: is it running
//in embedded mode?)
//System.exit(0);
}
//stopping a bundle doesn't leave the time to the felix thread to
//properly end all bundles and call their Activator.stop() methods.
//if this causes problems don't uncomment the following line but
//try and see why felix isn't exiting (suggesting: is it running
//in embedded mode?)
//System.exit(0);
}
}
@ -926,11 +930,11 @@ private int createAccountIndex(ProtocolProviderService protocolProvider,
= GuiActivator.getConfigurationService();
int accountIndex = -1;
Enumeration pproviders = protocolProviders.keys();
Iterator pproviders = protocolProviders.keySet().iterator();
ProtocolProviderService pps;
while(pproviders.hasMoreElements()) {
pps = (ProtocolProviderService)pproviders.nextElement();
while(pproviders.hasNext()) {
pps = (ProtocolProviderService)pproviders.next();
if(pps.getProtocolName().equals(
protocolProvider.getProtocolName())
@ -964,13 +968,13 @@ private void updateProvidersIndexes(ProtocolProviderService removedProvider)
String prefix = "net.java.sip.communicator.impl.gui.accounts";
Enumeration pproviders = protocolProviders.keys();
Iterator pproviders = protocolProviders.keySet().iterator();
ProtocolProviderService currentProvider = null;
int sameProtocolProvidersCount = 0;
while(pproviders.hasMoreElements()) {
while(pproviders.hasNext()) {
ProtocolProviderService pps
= (ProtocolProviderService)pproviders.nextElement();
= (ProtocolProviderService)pproviders.next();
if(pps.getProtocolName().equals(
removedProvider.getProtocolName())) {

@ -20,6 +20,7 @@
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.contactlist.*;
import net.java.sip.communicator.service.contactlist.event.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.msghistory.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*;
@ -644,4 +645,9 @@ public void run()
getChatConversationPanel().setDefaultContent();
}
}
public WindowID getWindowID()
{
return ApplicationWindow.CHAT_WINDOW;
}
}

@ -12,6 +12,7 @@
import net.java.sip.communicator.impl.gui.i18n.*;
import net.java.sip.communicator.impl.gui.main.chat.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.util.*;
@ -333,4 +334,9 @@ public void localUserStatusChanged(ChatRoomParticipantStatusChangeEvent evt)
{
}
public WindowID getWindowID()
{
return ApplicationWindow.CHAT_WINDOW;
}
}

@ -309,5 +309,10 @@ protected void close(boolean isEscaped)
{
this.closeButton.doClick();
}
public WindowID getWindowID()
{
return ApplicationWindow.CONFIGURATION_WINDOW;
}
}

@ -13,12 +13,14 @@
import net.java.sip.communicator.impl.gui.i18n.*;
import net.java.sip.communicator.impl.gui.main.*;
import net.java.sip.communicator.service.contactlist.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.*;
public class AddContactWizard
extends Wizard
implements WizardListener
implements WizardListener,
ApplicationWindow
{
private Logger logger = Logger.getLogger(AddContactWizard.class.getName());
@ -59,13 +61,6 @@ public AddContactWizard(MainFrame mainFrame)
this.setCurrentPage(AddContactWizardPage1.IDENTIFIER);
}
/**
* Overrides the Wizard.showModalDialog method.
*/
public void showDialog(boolean modal) {
super.showDialog(modal);
}
/**
* Creates a new meta contact in a separate thread.
*/
@ -159,4 +154,42 @@ public void wizardFinished(WizardEvent e)
}
}
}
public WindowID getWindowID()
{
return ApplicationWindow.ADD_CONTACT_WINDOW;
}
public boolean isWindowVisible()
{
return isVisible();
}
public void showWindow()
{
this.showDialog(false);
}
public void hideWindow()
{
this.setVisible(false);
}
public void resizeWindow(int width, int height)
{
this.setSize(width, height);
}
public void moveWindow(int x, int y)
{
this.setLocation(x, y);
}
public void minimizeWindow()
{
}
public void maximizeWindow()
{
}
}

@ -6,29 +6,34 @@
*/
package net.java.sip.communicator.impl.gui.main.contactlist.addcontact;
import java.util.*;
import java.awt.*;
import java.io.*;
import java.util.*;
import javax.imageio.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.i18n.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.impl.gui.utils.Constants;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.*;
import org.osgi.framework.*;
/**
* The <tt>SelectAccountPanel</tt> is where the user should select the account,
* where the new contact will be created.
*
* @author Yana Stamcheva
*/
public class SelectAccountPanel extends JPanel
public class SelectAccountPanel
extends JPanel
implements ServiceListener
{
private Logger logger = Logger.getLogger(SelectAccountPanel.class);
@ -41,8 +46,6 @@ public class SelectAccountPanel extends JPanel
private NewContact newContact;
private Iterator protocolProvidersList;
private JPanel labelsPanel = new JPanel(new GridLayout(0, 1));
private JPanel rightPanel = new JPanel(new BorderLayout(5, 5));
@ -66,13 +69,12 @@ public class SelectAccountPanel extends JPanel
* <tt>ProtocolProviderServices</tt>, from which the user could select.
*/
public SelectAccountPanel(NewContact newContact,
Iterator protocolProvidersList) {
Iterator protocolProvidersList)
{
super(new BorderLayout());
this.setPreferredSize(new Dimension(500, 200));
this.newContact = newContact;
this.protocolProvidersList = protocolProvidersList;
this.iconLabel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 10));
@ -90,21 +92,24 @@ public SelectAccountPanel(NewContact newContact,
this.add(rightPanel, BorderLayout.CENTER);
this.tableInit();
this.tableInit(protocolProvidersList);
GuiActivator.bundleContext.addServiceListener(this);
}
/**
* Initializes the accounts table.
*/
private void tableInit(){
private void tableInit(Iterator protocolProvidersList)
{
accountsTable.setPreferredScrollableViewportSize(new Dimension(500, 70));
tableModel.addColumn("");
tableModel.addColumn(Messages.getI18NString("account").getText());
tableModel.addColumn(Messages.getI18NString("protocol").getText());
while(protocolProvidersList.hasNext()) {
while(protocolProvidersList.hasNext())
{
ProtocolProviderService pps
= (ProtocolProviderService)protocolProvidersList.next();
@ -186,4 +191,58 @@ public void setSelectedAccounts()
}
}
}
public void serviceChanged(ServiceEvent event)
{
Object sourceService = GuiActivator.bundleContext
.getService(event.getServiceReference());
// we don't care if the source service is not a protocol provider
if (! (sourceService instanceof ProtocolProviderService))
{
return;
}
ProtocolProviderService sourcePProvider
= (ProtocolProviderService) sourceService;
if (event.getType() == ServiceEvent.REGISTERED)
{
String pName = sourcePProvider.getProtocolName();
Image protocolImage = null;
try
{
protocolImage = ImageIO.read(
new ByteArrayInputStream(sourcePProvider.getProtocolIcon()
.getIcon(ProtocolIcon.ICON_SIZE_16x16)));
}
catch (IOException e)
{
logger.error("Could not read image.", e);
}
JLabel protocolLabel = new JLabel();
protocolLabel.setText(pName);
protocolLabel.setIcon(new ImageIcon(protocolImage));
tableModel.addRow(new Object[]{new Boolean(false),
sourcePProvider, protocolLabel});
}
else if (event.getType() == ServiceEvent.UNREGISTERING)
{
for(int i = 0; i < tableModel.getRowCount(); i ++)
{
ProtocolProviderService protocolProvider
= (ProtocolProviderService) tableModel.getValueAt(i, 1);
if(protocolProvider.equals(sourcePProvider))
{
tableModel.removeRow(i);
break;
}
}
}
}
}

Loading…
Cancel
Save