From ac3cf52ac1e36373e0d2464ed311ca89aa8124ee Mon Sep 17 00:00:00 2001 From: Yana Stamcheva Date: Fri, 7 Nov 2008 11:20:54 +0000 Subject: [PATCH] Patch provided by Sebastien Mazy, that enables parameter passing to exported windows in user interface. --- .../impl/gui/PopupDialogImpl.java | 5 ++++ .../communicator/impl/gui/UIServiceImpl.java | 25 ++++++++++++++++--- .../communicator/impl/gui/main/MainFrame.java | 6 +++++ .../main/configforms/ConfigurationFrame.java | 4 +++ .../AddContactWizardExportedWindow.java | 5 ++++ .../gui/main/login/AuthenticationWindow.java | 5 ++++ .../impl/gui/main/menus/AboutWindow.java | 11 ++++++++ .../plugin/branding/AboutWindow.java | 5 ++++ .../service/gui/ExportedWindow.java | 10 ++++++++ .../communicator/service/gui/UIService.java | 19 ++++++++++++-- 10 files changed, 90 insertions(+), 5 deletions(-) diff --git a/src/net/java/sip/communicator/impl/gui/PopupDialogImpl.java b/src/net/java/sip/communicator/impl/gui/PopupDialogImpl.java index 0fccbb435..1c36a52dd 100644 --- a/src/net/java/sip/communicator/impl/gui/PopupDialogImpl.java +++ b/src/net/java/sip/communicator/impl/gui/PopupDialogImpl.java @@ -486,4 +486,9 @@ public Object getSource() { return this; } + + /** + * Implementation of {@link ExportedWindow#setParams(Object[])}. + */ + public void setParams(Object[] windowParams) {} } diff --git a/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java b/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java index c6cc2961c..137bc77f5 100644 --- a/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java +++ b/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java @@ -477,20 +477,39 @@ public Iterator getSupportedExportedWindows() * WindowID. * * @param windowID the id of the window we'd like to retrieve. - * + * @param params the params to be passed to the returned window. * @return a reference to the ExportedWindow instance corresponding * to windowID. * @see UIService#getExportedWindow(WindowID) */ - public ExportedWindow getExportedWindow(WindowID windowID) + public ExportedWindow getExportedWindow(WindowID windowID, Object[] params) { if (exportedWindows.containsKey(windowID)) { - return (ExportedWindow) exportedWindows.get(windowID); + ExportedWindow win = (ExportedWindow) exportedWindows.get(windowID); + win.setParams(params); + + return win; } return null; } + /** + * Implements the getExportedWindow in the UIService + * interface. Returns the window corresponding to the given + * WindowID. + * + * @param windowID the id of the window we'd like to retrieve. + * + * @return a reference to the ExportedWindow instance corresponding + * to windowID. + * @see UIService#getExportedWindow(WindowID) + */ + public ExportedWindow getExportedWindow(WindowID windowID) + { + return getExportedWindow(windowID, null); + } + /** * Implements the UIService.isExportedWindowSupported method. * Checks if there's an exported component for the given 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 7305f63c4..ae2ed67f6 100755 --- a/src/net/java/sip/communicator/impl/gui/main/MainFrame.java +++ b/src/net/java/sip/communicator/impl/gui/main/MainFrame.java @@ -1521,4 +1521,10 @@ public MainContentPane() borderSize)); } } + + /** + * Implementation of {@link ExportedWindow#setParams(Object[])}. + */ + public void setParams(Object[] windowParams) {} + } \ No newline at end of file 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 e510bd406..872159108 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 @@ -285,4 +285,8 @@ private void removeConfigurationForm(ConfigurationForm configForm) this.configList.removeConfigForm(configForm); } + /** + * Implementation of {@link ExportedWindow#setParams(Object[])}. + */ + public void setParams(Object[] windowParams) {} } diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizardExportedWindow.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizardExportedWindow.java index 47f654464..9ae671717 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizardExportedWindow.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizardExportedWindow.java @@ -117,4 +117,9 @@ public void setVisible(boolean isVisible) { getWizard().setVisible(isVisible); } + + /** + * Implementation of {@link ExportedWindow#setParams(Object[])}. + */ + public void setParams(Object[] windowParams) {} } diff --git a/src/net/java/sip/communicator/impl/gui/main/login/AuthenticationWindow.java b/src/net/java/sip/communicator/impl/gui/main/login/AuthenticationWindow.java index 6e8a19119..17963aa4e 100644 --- a/src/net/java/sip/communicator/impl/gui/main/login/AuthenticationWindow.java +++ b/src/net/java/sip/communicator/impl/gui/main/login/AuthenticationWindow.java @@ -387,4 +387,9 @@ public Object getSource() { return this; } + + /** + * Implementation of {@link ExportedWindow#setParams(Object[])}. + */ + public void setParams(Object[] windowParams) {} } diff --git a/src/net/java/sip/communicator/impl/gui/main/menus/AboutWindow.java b/src/net/java/sip/communicator/impl/gui/main/menus/AboutWindow.java index 380e224aa..8f71124a2 100644 --- a/src/net/java/sip/communicator/impl/gui/main/menus/AboutWindow.java +++ b/src/net/java/sip/communicator/impl/gui/main/menus/AboutWindow.java @@ -1,3 +1,9 @@ +/* + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ package net.java.sip.communicator.impl.gui.main.menus; import java.awt.*; @@ -165,4 +171,9 @@ public Object getSource() { return this; } + + /** + * Implementation of {@link ExportedWindow#setParams(Object[])}. + */ + public void setParams(Object[] windowParams) {} } diff --git a/src/net/java/sip/communicator/plugin/branding/AboutWindow.java b/src/net/java/sip/communicator/plugin/branding/AboutWindow.java index 6719b7809..8683fbf7a 100644 --- a/src/net/java/sip/communicator/plugin/branding/AboutWindow.java +++ b/src/net/java/sip/communicator/plugin/branding/AboutWindow.java @@ -253,4 +253,9 @@ public Object getSource() { return this; } + + /** + * Implementation of {@link ExportedWindow#setParams(Object[])}. + */ + public void setParams(Object[] windowParams) {} } diff --git a/src/net/java/sip/communicator/service/gui/ExportedWindow.java b/src/net/java/sip/communicator/service/gui/ExportedWindow.java index d96cded2e..c2a40804a 100644 --- a/src/net/java/sip/communicator/service/gui/ExportedWindow.java +++ b/src/net/java/sip/communicator/service/gui/ExportedWindow.java @@ -101,4 +101,14 @@ public interface ExportedWindow * @return the source of the window */ public Object getSource(); + + /** + * This method can be called to pass any params to the exported window. This + * method will be automatically called by + * {@link UIService#getExportedWindow(WindowID, Object[])} in order to set + * the parameters passed. + * + * @param windowParams the parameters to pass. + */ + public void setParams(Object[] windowParams); } diff --git a/src/net/java/sip/communicator/service/gui/UIService.java b/src/net/java/sip/communicator/service/gui/UIService.java index 344cfc901..311b433a8 100644 --- a/src/net/java/sip/communicator/service/gui/UIService.java +++ b/src/net/java/sip/communicator/service/gui/UIService.java @@ -162,12 +162,27 @@ public interface UIService * @throws IllegalArgumentException if the specified windowID * is not recognized by the implementation (note that implementations * MUST properly handle all WINDOW_XXX ID-s. - * @return the window to be shown - * @see #getSupportedExportedWindows() + * @return the window to be shown. */ public ExportedWindow getExportedWindow(WindowID windowID) throws IllegalArgumentException; + /** + * Returns an exported window given by the WindowID. + * This could be for example the "Add contact" window or any other window + * within the application. The windowID should be one of the + * WINDOW_XXX obtained by the getSupportedExportedWindows method. + * + * @param windowID One of the WINDOW_XXX WindowID-s. + * @param params The parameters to be passed to the returned exported window. + * @throws IllegalArgumentException if the specified windowID + * is not recognized by the implementation (note that implementations + * MUST properly handle all WINDOW_XXX ID-s. + * @return the window to be shown. + */ + public ExportedWindow getExportedWindow(WindowID windowID, Object[] params) + throws IllegalArgumentException; + /** * Returns a configurable popup dialog, that could be used to show either * a warning message, error message, information message, etc. or to prompt