diff --git a/src/net/java/sip/communicator/impl/gui/GuiActivator.java b/src/net/java/sip/communicator/impl/gui/GuiActivator.java
index 152b8193a..77428f813 100644
--- a/src/net/java/sip/communicator/impl/gui/GuiActivator.java
+++ b/src/net/java/sip/communicator/impl/gui/GuiActivator.java
@@ -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();
diff --git a/src/net/java/sip/communicator/impl/gui/PopupDialogImpl.java b/src/net/java/sip/communicator/impl/gui/PopupDialogImpl.java
index 578891ae8..e7bb123a9 100644
--- a/src/net/java/sip/communicator/impl/gui/PopupDialogImpl.java
+++ b/src/net/java/sip/communicator/impl/gui/PopupDialogImpl.java
@@ -264,5 +264,10 @@ public void minimizeWindow()
{}
public void maximizeWindow()
- {}
+ {}
+
+ public WindowID getWindowID()
+ {
+ return WINDOW_GENERAL_POPUP;
+ }
}
diff --git a/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java b/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java
index 7d4119017..b48e3b386 100644
--- a/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java
+++ b/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java
@@ -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 UIService that gives access to
- * other bundles to this particular swing ui implementation.
+ * An implementation of the UIService 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 UIServiceImpl.
+ *
* @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 ContainerID 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 UIService.addComponent(ContainerID, String, Object)
- * . For now this method only invokes addComponent(containerID,
- * component).
+ * .
+ * 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 UISercie.getSupportedContainers. 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
* 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
- * 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 isVisible in the UIService interface.
- * Checks if the main application window is visible.
- * @return true if main application window is visible,
- * false otherwise
+ * Implements isVisible in the UIService interface. Checks if
+ * the main application window is visible.
+ *
+ * @return true if main application window is visible,
+ * false 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 setVisible in the UIService interface.
- * Shows or hides the main application window depending on the parameter
+ * Implements setVisible in the UIService interface. Shows or
+ * hides the main application window depending on the parameter
* visible.
+ *
* @see UIService#setVisible(boolean)
*/
- public void setVisible(boolean visible) {
- this.mainFrame.setVisible(visible);
+ public void setVisible(boolean visible)
+ {
+ this.mainFrame.setVisible(visible);
}
/**
- * Implements minimize in the UIService interface.
- * Minimizes the main application window.
+ * Implements minimize in the UIService interface. Minimizes
+ * the main application window.
+ *
* @see UIService#minimize()
*/
- public void minimize() {
+ public void minimize()
+ {
this.mainFrame.setExtendedState(JFrame.ICONIFIED);
}
/**
- * Implements maximize in the UIService interface.
- * Maximizes the main application window.
+ * Implements maximize 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 restore in the UIService interface.
- * Restores the main application window.
+ * Implements restore 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 resize in the UIService interface.
- * Resizes the main application window.
+ * Implements resize 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 move in the UIService interface.
- * Moves the main application window to the point with coordinates - x, y.
+ * Implements move 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 getApplicationWindows in the UIService interface.
- * Returns an iterator over a set of all windows exported by this
+ * Implements the UIService.setExitOnMainWindowClose. 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 UIService.getExitOnMainWindowClose.
+ * 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 ApplicationWindows 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
+ * getApplicationWindow(WindowID) method and could be shown,
+ * hidden, resized, moved, etc.
+ */
+ /**
+ * Adds all exportable ApplicationWindows 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
+ * getApplicationWindow(WindowID) 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 getApplicationWindows 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 getApplicationWindow in the UIService interface.
- * Returns the window corresponding to the given WindowID.
+ * Implements getApplicationWindow in the UIService
+ * interface. Returns the window corresponding to the given
+ * WindowID.
+ *
* @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 getPopupDialog in the UIService interface.
* Returns a PopupDialog that could be used to show simple
* messages, warnings, errors, etc.
+ *
* @see UIService#getPopupDialog()
*/
- public PopupDialog getPopupDialog() {
+ public PopupDialog getPopupDialog()
+ {
return this.popupDialog;
}
/**
- * Implements getChatDialog in the UIService interface. If
- * a chat dialog for the given contact exists already returns it,
- * otherwise creates a new one.
+ * Implements getChatDialog 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 UIService.containsApplicationWindow method.
* Checks if there's an exported window for the given WindowID.
+ *
* @see UIService#containsApplicationWindow(WindowID)
*/
- public boolean containsApplicationWindow(WindowID dialogID) {
- return exportedWindows.contains(dialogID);
+ public boolean containsApplicationWindow(WindowID windowID)
+ {
+ return exportedWindows.containsKey(windowID);
}
/**
* Implements the UIService.isContainerSupported 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 UIService.getAccountRegWizardContainer
* method. Returns the current implementation of the
* AccountRegistrationWizardContainer.
+ *
* @see UIService#getAccountRegWizardContainer()
*/
- public AccountRegistrationWizardContainer getAccountRegWizardContainer() {
+ public AccountRegistrationWizardContainer getAccountRegWizardContainer()
+ {
return this.wizardContainer;
}
/**
- * Implements the UIService.getConfigurationWindow.
- * Returns the current implementation of the ConfigurationWindow
+ * Implements the UIService.getConfigurationWindow. Returns
+ * the current implementation of the ConfigurationWindow
* interface.
+ *
* @see UIService#getConfigurationWindow()
*/
- public ConfigurationWindow getConfigurationWindow() {
+ public ConfigurationWindow getConfigurationWindow()
+ {
return this.configurationFrame;
}
}
diff --git a/src/net/java/sip/communicator/impl/gui/main/AboutWindow.java b/src/net/java/sip/communicator/impl/gui/main/AboutWindow.java
index 8e879dd3d..7fc498654 100644
--- a/src/net/java/sip/communicator/impl/gui/main/AboutWindow.java
+++ b/src/net/java/sip/communicator/impl/gui/main/AboutWindow.java
@@ -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
+
+ }
}
diff --git a/src/net/java/sip/communicator/impl/gui/main/MainFrame.java b/src/net/java/sip/communicator/impl/gui/main/MainFrame.java
index 0b1b25e3e..080257a26 100755
--- a/src/net/java/sip/communicator/impl/gui/main/MainFrame.java
+++ b/src/net/java/sip/communicator/impl/gui/main/MainFrame.java
@@ -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())) {
diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatPanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatPanel.java
index 53f0664d0..eabd4eba7 100644
--- a/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatPanel.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatPanel.java
@@ -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;
+ }
}
diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatPanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatPanel.java
index 3041cad00..cabcbc627 100644
--- a/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatPanel.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatPanel.java
@@ -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;
+ }
}
diff --git a/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigurationFrame.java b/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigurationFrame.java
index fed15c060..ea4df220d 100644
--- a/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigurationFrame.java
+++ b/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigurationFrame.java
@@ -309,5 +309,10 @@ protected void close(boolean isEscaped)
{
this.closeButton.doClick();
}
+
+ public WindowID getWindowID()
+ {
+ return ApplicationWindow.CONFIGURATION_WINDOW;
+ }
}
diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizard.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizard.java
index f6e0d8467..63e2ba820 100644
--- a/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizard.java
+++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizard.java
@@ -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()
+ {
+ }
}
diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/SelectAccountPanel.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/SelectAccountPanel.java
index 4b618ee96..44cc61daf 100644
--- a/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/SelectAccountPanel.java
+++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/SelectAccountPanel.java
@@ -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 SelectAccountPanel 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
* ProtocolProviderServices, 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;
+ }
+ }
+ }
+ }
}