diff options
author | Yana Stamcheva <yana@jitsi.org> | 2008-03-18 15:21:41 +0000 |
---|---|---|
committer | Yana Stamcheva <yana@jitsi.org> | 2008-03-18 15:21:41 +0000 |
commit | a58a2d587ea8e8c54aaf8fd629c368fab1ac9844 (patch) | |
tree | 9c0f0b86a588d4c0aba003489e5ed69540eb7337 | |
parent | 9f61ba8d4339278ee2f7a3ab065593da9153dc68 (diff) | |
download | jitsi-a58a2d587ea8e8c54aaf8fd629c368fab1ac9844.zip jitsi-a58a2d587ea8e8c54aaf8fd629c368fab1ac9844.tar.gz jitsi-a58a2d587ea8e8c54aaf8fd629c368fab1ac9844.tar.bz2 |
Change GUI plugin architecture to fit OSGI.
28 files changed, 1441 insertions, 641 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java b/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java index c05541e..4549d56 100644 --- a/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java +++ b/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java @@ -12,6 +12,9 @@ import java.util.List; import javax.swing.*; +import org.osgi.framework.*; + +import net.java.sip.communicator.impl.gui.event.*; import net.java.sip.communicator.impl.gui.lookandfeel.*; import net.java.sip.communicator.impl.gui.main.*; import net.java.sip.communicator.impl.gui.main.account.*; @@ -23,6 +26,7 @@ import net.java.sip.communicator.impl.gui.main.login.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.service.contactlist.*; import net.java.sip.communicator.service.gui.*; +import net.java.sip.communicator.service.gui.Container; import net.java.sip.communicator.service.gui.event.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; @@ -34,7 +38,8 @@ import net.java.sip.communicator.util.*; * @author Yana Stamcheva */ public class UIServiceImpl - implements UIService + implements UIService, + ServiceListener { private static final Logger logger = Logger.getLogger(UIServiceImpl.class); @@ -42,25 +47,25 @@ public class UIServiceImpl private AccountRegWizardContainerImpl wizardContainer; - private Map<ContainerID, Vector<Object>> registeredPlugins - = new Hashtable<ContainerID, Vector<Object>>(); + private Map<Container, Vector<Object>> registeredPlugins + = new Hashtable<Container, Vector<Object>>(); private Vector<PluginComponentListener> pluginComponentListeners = new Vector<PluginComponentListener>(); - private static final List<ContainerID> supportedContainers - = new ArrayList<ContainerID>(); + private static final List<Container> supportedContainers + = new ArrayList<Container>(); static { - supportedContainers.add(UIService.CONTAINER_MAIN_TOOL_BAR); - supportedContainers.add(UIService.CONTAINER_CONTACT_RIGHT_BUTTON_MENU); - supportedContainers.add(UIService.CONTAINER_GROUP_RIGHT_BUTTON_MENU); - supportedContainers.add(UIService.CONTAINER_TOOLS_MENU); - supportedContainers.add(UIService.CONTAINER_HELP_MENU); - supportedContainers.add(UIService.CONTAINER_CHAT_TOOL_BAR); - supportedContainers.add(UIService.CONTAINER_CALL_HISTORY); - supportedContainers.add(UIService.CONTAINER_MAIN_TABBED_PANE); - supportedContainers.add(UIService.CONTAINER_CHAT_HELP_MENU); + supportedContainers.add(Container.CONTAINER_MAIN_TOOL_BAR); + supportedContainers.add(Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU); + supportedContainers.add(Container.CONTAINER_GROUP_RIGHT_BUTTON_MENU); + supportedContainers.add(Container.CONTAINER_TOOLS_MENU); + supportedContainers.add(Container.CONTAINER_HELP_MENU); + supportedContainers.add(Container.CONTAINER_CHAT_TOOL_BAR); + supportedContainers.add(Container.CONTAINER_CALL_HISTORY); + supportedContainers.add(Container.CONTAINER_MAIN_TABBED_PANE); + supportedContainers.add(Container.CONTAINER_CHAT_HELP_MENU); supportedContainers.add(UIService.CONTAINER_CHAT_WINDOW_SOUTH); supportedContainers.add(UIService.CONTAINER_CONTACT_LIST_EAST); supportedContainers.add(UIService.CONTAINER_CONTACT_LIST_WEST); @@ -118,16 +123,16 @@ public class UIServiceImpl * component and fires a PluginComponentEvent to inform all interested * listeners that a plugin component has been removed. * - * @param containerID the <tt>ContainerID</tt> of the plugable container, + * @param containerID the <tt>Container</tt> of the plugable container, * where the component is stored * @param component the component to remove * - * @see UIService#removeComponent(ContainerID, Object) + * @see UIService#removeComponent(Container, Object) * * @throws java.lang.IllegalArgumentException if no component exists for * the specified container id. */ - public void removeComponent(ContainerID containerID, Object component) + public void removeComponent(Container containerID, Object component) throws IllegalArgumentException { if (!supportedContainers.contains(containerID)) @@ -142,8 +147,13 @@ public class UIServiceImpl { ((Vector) registeredPlugins.get(containerID)).remove(component); } - this.firePluginEvent(component, containerID, - PluginComponentEvent.PLUGIN_COMPONENT_REMOVED); + + DefaultPluginComponent pluginComponent + = new DefaultPluginComponent((Component) component, containerID); + + this.firePluginEvent( pluginComponent, + PluginComponentEvent + .PLUGIN_COMPONENT_REMOVED); } } @@ -152,17 +162,17 @@ public class UIServiceImpl * 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 containerID The <tt>Container</tt> of the plugable container. * @param component The component to add. * - * @see UIService#addComponent(ContainerID, Object) + * @see UIService#addComponent(Container, Object) * * @throws java.lang.ClassCastException if <tt>component</tt> is not an * instance of a java.awt.Component * @throws java.lang.IllegalArgumentException if no component exists for * the specified container id. */ - public void addComponent(ContainerID containerID, Object component) + public void addComponent(Container containerID, Object component) throws ClassCastException, IllegalArgumentException { if (!supportedContainers.contains(containerID)) @@ -173,7 +183,6 @@ public class UIServiceImpl } else if (!(component instanceof Component)) { - throw new ClassCastException( "The specified plugin is not a valid swing or awt component."); } @@ -181,7 +190,8 @@ public class UIServiceImpl { if (registeredPlugins.containsKey(containerID)) { - ((Vector) registeredPlugins.get(containerID)).add(component); + ((Vector) registeredPlugins + .get(containerID)).add(component); } else { @@ -189,39 +199,43 @@ public class UIServiceImpl plugins.add(component); registeredPlugins.put(containerID, plugins); } - this.firePluginEvent(component, containerID, - PluginComponentEvent.PLUGIN_COMPONENT_ADDED); + + DefaultPluginComponent pluginComponent + = new DefaultPluginComponent((Component) component, containerID); + + this.firePluginEvent( pluginComponent, + PluginComponentEvent.PLUGIN_COMPONENT_ADDED); } } /** - * Implements <code>UIService.addComponent(ContainerID, String, Object) + * Implements <code>UIService.addComponent(Container, String, Object) * </code>. * For now this method only invokes addComponent(containerID, component). * - * @param containerID The <tt>ContainerID</tt> of the plugable container. + * @param containerID The <tt>Container</tt> of the plugable container. * @param constraint a constraint indicating how the component should be * added to the container. * @param component the component we are adding. * - * @see UIService#addComponent(ContainerID, String, Object) + * @see UIService#addComponent(Container, String, Object) * @throws java.lang.ClassCastException if <tt>component</tt> is not an * instance of a java.awt.Component * @throws java.lang.IllegalArgumentException if no component exists for * the specified container id. */ - public void addComponent(ContainerID containerID, String constraint, + public void addComponent(Container containerID, String constraint, Object component) throws ClassCastException, IllegalArgumentException { this.addComponent(containerID, component); } /** - * Implements <code>UIService.addComponent(ContainerID, String, Object) + * Implements <code>UIService.addComponent(Container, String, Object) * </code>. * For now this method only invokes addComponent(containerID, component). * - * @param containerID The <tt>ContainerID</tt> of the plugable container. + * @param containerID The <tt>Container</tt> of the plugable container. * @param component the component we are adding. * * @throws java.lang.ClassCastException if <tt>component</tt> is not an @@ -229,7 +243,7 @@ public class UIServiceImpl * @throws java.lang.IllegalArgumentException if no component exists for * the specified container id. */ - public void addComponent(ContainerID containerID, + public void addComponent(Container containerID, ContactAwareComponent component) throws ClassCastException, IllegalArgumentException { @@ -244,11 +258,11 @@ public class UIServiceImpl } /** - * Implements <code>UIService.addComponent(ContainerID, String, Object) + * Implements <code>UIService.addComponent(Container, String, Object) * </code>. * For now this method only invokes addComponent(containerID, component). * - * @param containerID The <tt>ContainerID</tt> of the plugable container. + * @param containerID The <tt>Container</tt> of the plugable container. * @param constraint a constraint indicating how the component should be * added to the container. * @param component the component we are adding. @@ -258,7 +272,7 @@ public class UIServiceImpl * @throws java.lang.IllegalArgumentException if no component exists for * the specified container id. */ - public void addComponent(ContainerID containerID, String constraint, + public void addComponent(Container containerID, String constraint, ContactAwareComponent component) throws ClassCastException, IllegalArgumentException { @@ -282,7 +296,7 @@ public class UIServiceImpl * * @param containerID the id of the container whose components we'll be * retrieving. - * @see UIService#getComponentsForContainer(ContainerID) + * @see UIService#getComponentsForContainer(Container) * * @return an iterator over all components added in the container with ID * <tt>containerID</tt> @@ -290,7 +304,7 @@ public class UIServiceImpl * @throws java.lang.IllegalArgumentException if containerID does not * correspond to a container used in this implementation. */ - public Iterator getComponentsForContainer(ContainerID containerID) + public Iterator getComponentsForContainer(Container containerID) throws IllegalArgumentException { @@ -317,12 +331,12 @@ public class UIServiceImpl * @param containerID the ID of the container whose constraints we'll be * retrieving. * - * @see UIService#getConstraintsForContainer(ContainerID) + * @see UIService#getConstraintsForContainer(Container) * * @return Iterator an <tt>Iterator</tt> for all constraintes supported by * the container corresponding to containerID. */ - public Iterator getConstraintsForContainer(ContainerID containerID) + public Iterator getConstraintsForContainer(Container containerID) { return null; } @@ -339,11 +353,12 @@ public class UIServiceImpl * @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) + private void firePluginEvent( PluginComponent pluginComponent, + int eventID) { - PluginComponentEvent evt = new PluginComponentEvent(pluginComponent, - containerID, eventID); + PluginComponentEvent evt + = new PluginComponentEvent( pluginComponent, + eventID); logger.trace("Will dispatch the following plugin component event: " + evt); @@ -686,7 +701,7 @@ public class UIServiceImpl /** * Implements the <code>UIService.isContainerSupported</code> method. - * Checks if the plugable container with the given ContainerID is supported + * Checks if the plugable container with the given Container is supported * by this implementation. * * @param containderID the id of the container that we're making the query @@ -695,9 +710,9 @@ public class UIServiceImpl * @return true if the container with the specified id is exported by the * implementation of the UI service and false otherwise. * - * @see UIService#isContainerSupported(ContainerID) + * @see UIService#isContainerSupported(Container) */ - public boolean isContainerSupported(ContainerID containderID) + public boolean isContainerSupported(Container containderID) { return supportedContainers.contains(containderID); } @@ -820,4 +835,120 @@ public class UIServiceImpl logger.error("The provided Look & Feel is not supported.", e); } } + + /** + * Notifies all plugin containers of a <tt>PluginComponent</tt> + * registration. + */ + public void serviceChanged(ServiceEvent event) + { + Object sService = GuiActivator.bundleContext.getService( + event.getServiceReference()); + + // we don't care if the source service is not a plugin component + if (! (sService instanceof PluginComponent)) + { + return; + } + + PluginComponent pluginComponent = (PluginComponent) sService; + + if (event.getType() == ServiceEvent.REGISTERED) + { + logger + .debug("Handling registration of a new Plugin Component."); + + if(!(pluginComponent.getComponent() instanceof Component)) + { + logger.error("Plugin Component type is not supported." + + "Should provide a plugin in AWT, SWT or Swing."); + return; + } + + this.firePluginEvent( pluginComponent, + PluginComponentEvent.PLUGIN_COMPONENT_ADDED); + } + else if (event.getType() == ServiceEvent.UNREGISTERING) + { + this.firePluginEvent( pluginComponent, + PluginComponentEvent + .PLUGIN_COMPONENT_REMOVED); + } + } + + /** + * Returns the corresponding <tt>BorderLayout</tt> constraint from the given + * <tt>Container</tt> constraint. + * + * @param containerConstraint constraints defined in the <tt>Container</tt> + * @return the corresponding <tt>BorderLayout</tt> constraint from the given + * <tt>Container</tt> constraint. + */ + public static Object getBorderLayoutConstraintsFromContainer( + Object containerConstraints) + { + Object layoutConstraint = null; + if (containerConstraints.equals(Container.START)) + layoutConstraint = BorderLayout.LINE_START; + else if (containerConstraints.equals(Container.END)) + layoutConstraint = BorderLayout.LINE_END; + else if (containerConstraints.equals(Container.TOP)) + layoutConstraint = BorderLayout.NORTH; + else if (containerConstraints.equals(Container.BOTTOM)) + layoutConstraint = BorderLayout.SOUTH; + else if (containerConstraints.equals(Container.LEFT)) + layoutConstraint = BorderLayout.WEST; + else if (containerConstraints.equals(Container.RIGHT)) + layoutConstraint = BorderLayout.EAST; + + return layoutConstraint; + } + + private class DefaultPluginComponent implements PluginComponent + { + private Component component; + + private Container container; + + public DefaultPluginComponent( Component component, + Container container) + { + this.component = component; + this.container = container; + } + + public Object getComponent() + { + return component; + } + + public String getConstraints() + { + return Container.END; + } + + public Container getContainer() + { + return container; + } + + public String getName() + { + return component.getName(); + } + + public void setCurrentContact(MetaContact metaContact) + { + if (component instanceof ContactAwareComponent) + ((ContactAwareComponent) component) + .setCurrentContact(metaContact); + } + + public void setCurrentContactGroup(MetaContactGroup metaGroup) + { + if (component instanceof ContactAwareComponent) + ((ContactAwareComponent) component) + .setCurrentContactGroup(metaGroup); + } + } } 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 96748f6..75c9f69 100755 --- a/src/net/java/sip/communicator/impl/gui/main/MainFrame.java +++ b/src/net/java/sip/communicator/impl/gui/main/MainFrame.java @@ -17,6 +17,7 @@ import javax.swing.*; import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.customcontrols.*; +import net.java.sip.communicator.impl.gui.event.*; import net.java.sip.communicator.impl.gui.i18n.*; import net.java.sip.communicator.impl.gui.main.call.*; import net.java.sip.communicator.impl.gui.main.chat.*; @@ -32,6 +33,7 @@ import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.contacteventhandler.*; import net.java.sip.communicator.service.contactlist.*; import net.java.sip.communicator.service.gui.*; +import net.java.sip.communicator.service.gui.Container; import net.java.sip.communicator.service.gui.event.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; @@ -1287,27 +1289,43 @@ public class MainFrame */ public void pluginComponentAdded(PluginComponentEvent event) { - Component c = (Component) event.getSource(); + PluginComponent c = event.getPluginComponent(); - if (event.getContainerID().equals( + if (c.getContainer().equals(Container.CONTAINER_CONTACT_LIST)) + { + Object constraints = null; + + if (c.getConstraints() != null) + constraints = UIServiceImpl + .getBorderLayoutConstraintsFromContainer(c.getConstraints()); + else + constraints = BorderLayout.SOUTH; + + this.getContentPane().add((Component) c.getComponent(), constraints); + } + else if (c.getContainer().equals( UIService.CONTAINER_CONTACT_LIST_SOUTH)) { - this.getContentPane().add(c, BorderLayout.SOUTH); + this.getContentPane().add( (Component) c.getComponent(), + BorderLayout.SOUTH); } - else if (event.getContainerID().equals( + else if (c.getContainer().equals( UIService.CONTAINER_CONTACT_LIST_NORTH)) { - this.getContentPane().add(c, BorderLayout.NORTH); + this.getContentPane().add( (Component) c.getComponent(), + BorderLayout.NORTH); } - else if (event.getContainerID().equals( + else if (c.getContainer().equals( UIService.CONTAINER_CONTACT_LIST_EAST)) { - this.getContentPane().add(c, BorderLayout.EAST); + this.getContentPane().add( (Component) c.getComponent(), + BorderLayout.EAST); } - else if (event.getContainerID().equals( + else if (c.getContainer().equals( UIService.CONTAINER_CONTACT_LIST_WEST)) { - this.getContentPane().add(c, BorderLayout.WEST); + this.getContentPane().add( (Component) c.getComponent(), + BorderLayout.WEST); } this.pack(); @@ -1319,16 +1337,17 @@ public class MainFrame */ public void pluginComponentRemoved(PluginComponentEvent event) { - Component c = (Component) event.getSource(); + PluginComponent c = event.getPluginComponent(); - ContainerID containerID = event.getContainerID(); + Container containerID = c.getContainer(); - if (containerID.equals(UIService.CONTAINER_CONTACT_LIST_SOUTH) + if (containerID.equals(Container.CONTAINER_CONTACT_LIST) + || containerID.equals(UIService.CONTAINER_CONTACT_LIST_SOUTH) || containerID.equals(UIService.CONTAINER_CONTACT_LIST_NORTH) || containerID.equals(UIService.CONTAINER_CONTACT_LIST_EAST) || containerID.equals(UIService.CONTAINER_CONTACT_LIST_WEST)) { - this.getContentPane().remove(c); + this.getContentPane().remove((Component) c.getComponent()); } } diff --git a/src/net/java/sip/communicator/impl/gui/main/MainTabbedPane.java b/src/net/java/sip/communicator/impl/gui/main/MainTabbedPane.java index 6873510..6608705 100755 --- a/src/net/java/sip/communicator/impl/gui/main/MainTabbedPane.java +++ b/src/net/java/sip/communicator/impl/gui/main/MainTabbedPane.java @@ -8,17 +8,22 @@ package net.java.sip.communicator.impl.gui.main; import java.awt.*; +import java.util.*; import javax.swing.event.*; +import org.osgi.framework.*; + import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.customcontrols.*; +import net.java.sip.communicator.impl.gui.event.*; import net.java.sip.communicator.impl.gui.i18n.*; import net.java.sip.communicator.impl.gui.main.call.*; import net.java.sip.communicator.impl.gui.main.chatroomslist.*; import net.java.sip.communicator.impl.gui.main.contactlist.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.service.gui.*; +import net.java.sip.communicator.service.gui.Container; import net.java.sip.communicator.service.gui.event.*; /** @@ -133,14 +138,64 @@ public class MainTabbedPane } } - public void pluginComponentAdded(PluginComponentEvent event) + /** + * Initiates plugin components. + */ + private void initPluginComponents() { - Component c = (Component) event.getSource(); + Iterator pluginComponents = GuiActivator.getUIService() + .getComponentsForContainer( + Container.CONTAINER_MAIN_TABBED_PANE); - if(event.getContainerID() - .equals(UIService.CONTAINER_MAIN_TABBED_PANE)) + while (pluginComponents.hasNext()) { + Component c = (Component)pluginComponents.next(); + this.addTab(c.getName(), c); + } + + // Search for plugin components registered through the OSGI bundle + // context. + ServiceReference[] serRefs = null; + + String osgiFilter = "(" + + Container.CONTAINER_ID + + "="+Container.CONTAINER_MAIN_TABBED_PANE.getID()+")"; + + try + { + serRefs = GuiActivator.bundleContext.getServiceReferences( + PluginComponent.class.getName(), + osgiFilter); + } + catch (InvalidSyntaxException exc) + { + exc.printStackTrace(); + } + + if (serRefs == null) + return; + + for (int i = 0; i < serRefs.length; i ++) + { + PluginComponent component = (PluginComponent) GuiActivator + .bundleContext.getService(serRefs[i]);; + + this.addTab(component.getName(), + (Component) component.getComponent()); + } + + GuiActivator.getUIService().addPluginComponentListener(this); + } + + public void pluginComponentAdded(PluginComponentEvent event) + { + PluginComponent c = event.getPluginComponent(); + + if(c.getContainer() + .equals(Container.CONTAINER_MAIN_TABBED_PANE)) + { + this.addTab(c.getName(), (Component) c.getComponent()); this.repaint(); } @@ -148,12 +203,12 @@ public class MainTabbedPane public void pluginComponentRemoved(PluginComponentEvent event) { - Component c = (Component) event.getSource(); + PluginComponent c = event.getPluginComponent(); - if(event.getContainerID() - .equals(UIService.CONTAINER_MAIN_TABBED_PANE)) + if(c.getContainer() + .equals(Container.CONTAINER_MAIN_TABBED_PANE)) { - this.remove(c); + this.remove((Component) c.getComponent()); } } } diff --git a/src/net/java/sip/communicator/impl/gui/main/call/CallListPanel.java b/src/net/java/sip/communicator/impl/gui/main/call/CallListPanel.java index e5e6782..c81b7fd 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/CallListPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/CallListPanel.java @@ -13,14 +13,18 @@ import java.util.*; import javax.swing.*; +import org.osgi.framework.*; + import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.customcontrols.*; import net.java.sip.communicator.impl.gui.customcontrols.SIPCommSmartComboBox.*; +import net.java.sip.communicator.impl.gui.event.*; import net.java.sip.communicator.impl.gui.i18n.*; import net.java.sip.communicator.impl.gui.main.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.service.callhistory.*; import net.java.sip.communicator.service.gui.*; +import net.java.sip.communicator.service.gui.Container; import net.java.sip.communicator.service.gui.event.*; /** @@ -103,15 +107,45 @@ public class CallListPanel { Iterator pluginComponents = GuiActivator.getUIService() .getComponentsForContainer( - UIService.CONTAINER_CALL_HISTORY); - + Container.CONTAINER_CALL_HISTORY); + while (pluginComponents.hasNext()) { Component o = (Component)pluginComponents.next(); - + this.pluginPanel.add((Component)o); } - + + // Search for plugin components registered through the OSGI bundle + // context. + ServiceReference[] serRefs = null; + + String osgiFilter = "(" + + Container.CONTAINER_ID + + "="+Container.CONTAINER_CALL_HISTORY.getID()+")"; + + try + { + serRefs = GuiActivator.bundleContext.getServiceReferences( + PluginComponent.class.getName(), + osgiFilter); + } + catch (InvalidSyntaxException exc) + { + exc.printStackTrace(); + } + + if (serRefs == null) + return; + + for (int i = 0; i < serRefs.length; i ++) + { + PluginComponent component = (PluginComponent) GuiActivator + .bundleContext.getService(serRefs[i]);; + + this.pluginPanel.add((Component)component.getComponent()); + } + GuiActivator.getUIService().addPluginComponentListener(this); } @@ -128,7 +162,7 @@ public class CallListPanel Date callStartDate = callRecord.getStartTime(); - if(lastDateFromHistory == null) { + if(lastDateFromHistory == null) { callList.addItem(processDate(callStartDate)); lastDateFromHistory = callStartDate; } @@ -359,15 +393,15 @@ public class CallListPanel public void pluginComponentAdded(PluginComponentEvent event) { - Component c = (Component) event.getSource(); - + PluginComponent c = event.getPluginComponent(); + // If the container id doesn't correspond to the id of the plugin // container we're not interested. - if(!event.getContainerID() - .equals(UIService.CONTAINER_CALL_HISTORY)) + if(!c.getContainer() + .equals(Container.CONTAINER_CALL_HISTORY)) return; - - this.pluginPanel.add(c); + + this.pluginPanel.add((Component) c.getComponent()); this.revalidate(); this.repaint(); @@ -375,15 +409,15 @@ public class CallListPanel public void pluginComponentRemoved(PluginComponentEvent event) { - Component c = (Component) event.getSource(); - + PluginComponent c = event.getPluginComponent(); + // If the container id doesn't correspond to the id of the plugin // container we're not interested. - if(!event.getContainerID() - .equals(UIService.CONTAINER_CALL_HISTORY)) + if(!c.getContainer() + .equals(Container.CONTAINER_CALL_HISTORY)) return; - this.pluginPanel.remove(c); + this.pluginPanel.remove((Component) c.getComponent()); } private class ScrollPaneBackground extends JViewport diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java index 39f4f16..a0d4f70 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java @@ -7,6 +7,7 @@ package net.java.sip.communicator.impl.gui.main.chat; import java.awt.*; +import java.awt.Container; import java.awt.event.*; import java.beans.*; import java.io.*; diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java index bf5e4a8..b4f50fd 100755 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java @@ -13,15 +13,20 @@ import java.util.*; import javax.swing.*; +import org.osgi.framework.*; + import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.customcontrols.*; import net.java.sip.communicator.impl.gui.customcontrols.events.*; +import net.java.sip.communicator.impl.gui.event.*; import net.java.sip.communicator.impl.gui.main.*; import net.java.sip.communicator.impl.gui.main.MainFrame.*; import net.java.sip.communicator.impl.gui.main.chat.menus.*; import net.java.sip.communicator.impl.gui.main.chat.toolBars.*; import net.java.sip.communicator.impl.gui.utils.*; +import net.java.sip.communicator.impl.gui.utils.Constants; import net.java.sip.communicator.service.gui.*; +import net.java.sip.communicator.service.gui.Container; import net.java.sip.communicator.service.gui.event.*; import net.java.sip.communicator.util.*; @@ -652,28 +657,72 @@ public class ChatWindow this.add(o, BorderLayout.SOUTH); } + // Search for plugin components registered through the OSGI bundle + // context. + ServiceReference[] serRefs = null; + + String osgiFilter = "(" + + Container.CONTAINER_ID + + "="+Container.CONTAINER_CHAT_WINDOW.getID()+")"; + + try + { + serRefs = GuiActivator.bundleContext.getServiceReferences( + PluginComponent.class.getName(), + osgiFilter); + } + catch (InvalidSyntaxException exc) + { + logger.error("Could not obtain plugin component reference.", exc); + } + + if (serRefs == null) + return; + + for (int i = 0; i < serRefs.length; i ++) + { + PluginComponent c = (PluginComponent) GuiActivator + .bundleContext.getService(serRefs[i]); + + Object borderLayoutConstraint = UIServiceImpl + .getBorderLayoutConstraintsFromContainer(c.getConstraints()); + + this.add((Component)c.getComponent(), borderLayoutConstraint); + } + GuiActivator.getUIService().addPluginComponentListener(this); } public void pluginComponentAdded(PluginComponentEvent event) { - Component c = (Component) event.getSource(); + PluginComponent c = event.getPluginComponent(); - if (event.getContainerID().equals(UIService.CONTAINER_CHAT_WINDOW_SOUTH)) + if (c.getContainer().equals(UIService.CONTAINER_CHAT_WINDOW_SOUTH)) { - this.getContentPane().add(c, BorderLayout.SOUTH); + this.getContentPane().add( (Component) c.getComponent(), + BorderLayout.SOUTH); this.pack(); } + else if (c.getContainer().equals(Container.CONTAINER_CHAT_WINDOW)) + { + Object borderLayoutConstraints = UIServiceImpl + .getBorderLayoutConstraintsFromContainer(c.getConstraints()); + + this.add((Component) c.getComponent(), borderLayoutConstraints); + } } public void pluginComponentRemoved(PluginComponentEvent event) { - Component c = (Component) event.getSource(); + PluginComponent c = event.getPluginComponent(); - if (event.getContainerID().equals(UIService.CONTAINER_CHAT_WINDOW_SOUTH)) + if (c.getContainer().equals(UIService.CONTAINER_CHAT_WINDOW_SOUTH) + || c.getContainer().equals(Container.CONTAINER_CHAT_WINDOW)) { - this.getContentPane().remove(c); + this.getContentPane().remove((Component) c.getComponent()); + + this.pack(); } } diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/menus/HelpMenu.java b/src/net/java/sip/communicator/impl/gui/main/chat/menus/HelpMenu.java index 47d1e05..7180edf 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/menus/HelpMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/menus/HelpMenu.java @@ -9,17 +9,18 @@ package net.java.sip.communicator.impl.gui.main.chat.menus; import java.awt.*; import java.awt.event.*; -import java.util.Iterator; +import java.util.*; -import javax.swing.*; +import org.osgi.framework.*; -import net.java.sip.communicator.impl.gui.GuiActivator; +import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.customcontrols.*; +import net.java.sip.communicator.impl.gui.event.*; import net.java.sip.communicator.impl.gui.i18n.*; -import net.java.sip.communicator.impl.gui.main.*; import net.java.sip.communicator.impl.gui.main.chat.*; import net.java.sip.communicator.impl.gui.utils.*; -import net.java.sip.communicator.service.gui.UIService; +import net.java.sip.communicator.service.gui.*; +import net.java.sip.communicator.service.gui.Container; import net.java.sip.communicator.service.gui.event.*; import net.java.sip.communicator.util.*; /** @@ -63,7 +64,7 @@ public class HelpMenu private void initPluginComponents() { Iterator pluginComponents = GuiActivator.getUIService() - .getComponentsForContainer(UIService.CONTAINER_CHAT_HELP_MENU); + .getComponentsForContainer(Container.CONTAINER_CHAT_HELP_MENU); while (pluginComponents.hasNext()) { @@ -72,6 +73,36 @@ public class HelpMenu this.add(o); } + // Search for plugin components registered through the OSGI bundle + // context. + ServiceReference[] serRefs = null; + + String osgiFilter = "(" + + Container.CONTAINER_ID + + "="+Container.CONTAINER_CHAT_HELP_MENU.getID()+")"; + + try + { + serRefs = GuiActivator.bundleContext.getServiceReferences( + PluginComponent.class.getName(), + osgiFilter); + } + catch (InvalidSyntaxException exc) + { + exc.printStackTrace(); + } + + if (serRefs == null) + return; + + for (int i = 0; i < serRefs.length; i ++) + { + PluginComponent component = (PluginComponent) GuiActivator + .bundleContext.getService(serRefs[i]);; + + this.add((Component)component.getComponent()); + } + GuiActivator.getUIService().addPluginComponentListener(this); } @@ -85,11 +116,11 @@ public class HelpMenu public void pluginComponentAdded(PluginComponentEvent event) { - Component c = (Component) event.getSource(); + PluginComponent c = event.getPluginComponent(); - if (event.getContainerID().equals(UIService.CONTAINER_CHAT_HELP_MENU)) + if (c.getContainer().equals(Container.CONTAINER_CHAT_HELP_MENU)) { - this.add(c); + this.add((Component) c.getComponent()); this.revalidate(); this.repaint(); @@ -98,11 +129,11 @@ public class HelpMenu public void pluginComponentRemoved(PluginComponentEvent event) { - Component c = (Component) event.getSource(); + PluginComponent c = event.getPluginComponent(); - if (event.getContainerID().equals(UIService.CONTAINER_CHAT_HELP_MENU)) + if (c.getContainer().equals(Container.CONTAINER_CHAT_HELP_MENU)) { - this.remove(c); + this.remove((Component) c.getComponent()); } } diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/ExtendedMainToolBar.java b/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/ExtendedMainToolBar.java index 078b1cf..eb4a7e9 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/ExtendedMainToolBar.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/ExtendedMainToolBar.java @@ -13,12 +13,16 @@ import java.util.*; import javax.swing.*; +import org.osgi.framework.*; + import net.java.sip.communicator.impl.gui.*; +import net.java.sip.communicator.impl.gui.event.*; import net.java.sip.communicator.impl.gui.i18n.*; import net.java.sip.communicator.impl.gui.main.chat.*; import net.java.sip.communicator.impl.gui.main.chat.history.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.service.gui.*; +import net.java.sip.communicator.service.gui.Container; import net.java.sip.communicator.service.gui.event.*; /** @@ -360,37 +364,71 @@ public class ExtendedMainToolBar { Iterator pluginComponents = GuiActivator.getUIService() .getComponentsForContainer( - UIService.CONTAINER_CHAT_TOOL_BAR); - + Container.CONTAINER_CHAT_TOOL_BAR); + if(pluginComponents.hasNext()) this.addSeparator(); - + while (pluginComponents.hasNext()) { Component c = (Component)pluginComponents.next(); - + this.add(c); - + this.revalidate(); this.repaint(); } - + + // Search for plugin components registered through the OSGI bundle + // context. + ServiceReference[] serRefs = null; + + String osgiFilter = "(" + + Container.CONTAINER_ID + + "="+Container.CONTAINER_CHAT_TOOL_BAR.getID()+")"; + + try + { + serRefs = GuiActivator.bundleContext.getServiceReferences( + PluginComponent.class.getName(), + osgiFilter); + } + catch (InvalidSyntaxException exc) + { + exc.printStackTrace(); + } + + if (serRefs == null) + return; + + for (int i = 0; i < serRefs.length; i ++) + { + PluginComponent component = (PluginComponent) GuiActivator + .bundleContext.getService(serRefs[i]);; + + this.add((Component)component.getComponent()); + + this.revalidate(); + this.repaint(); + } + GuiActivator.getUIService().addPluginComponentListener(this); } + /** * Implements the <code>PluginComponentListener.pluginComponentAdded</code> * method. */ public void pluginComponentAdded(PluginComponentEvent event) - { - Component c = (Component) event.getSource(); + { + PluginComponent c = event.getPluginComponent(); - if(event.getContainerID().equals(UIService.CONTAINER_CHAT_TOOL_BAR)) + if(c.getContainer().equals(Container.CONTAINER_CHAT_TOOL_BAR)) { this.addSeparator(); - this.add(c); - + this.add((Component) c.getComponent()); + this.revalidate(); this.repaint(); } @@ -402,11 +440,11 @@ public class ExtendedMainToolBar */ public void pluginComponentRemoved(PluginComponentEvent event) { - Component c = (Component) event.getSource(); - - if(event.getContainerID().equals(UIService.CONTAINER_CHAT_TOOL_BAR)) + PluginComponent c = event.getPluginComponent(); + + if(c.getContainer().equals(Container.CONTAINER_CHAT_TOOL_BAR)) { - this.remove(c); + this.remove((Component) c.getComponent()); } } diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java b/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java index edcdead..7b4a71a 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java @@ -13,13 +13,17 @@ import java.util.*; import javax.swing.*; +import org.osgi.framework.*; + import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.customcontrols.*; +import net.java.sip.communicator.impl.gui.event.*; import net.java.sip.communicator.impl.gui.i18n.*; import net.java.sip.communicator.impl.gui.main.chat.*; import net.java.sip.communicator.impl.gui.main.chat.history.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.service.gui.*; +import net.java.sip.communicator.service.gui.Container; import net.java.sip.communicator.service.gui.event.*; /** @@ -363,38 +367,70 @@ public class MainToolBar { Iterator pluginComponents = GuiActivator.getUIService() .getComponentsForContainer( - UIService.CONTAINER_CHAT_TOOL_BAR); - + Container.CONTAINER_CHAT_TOOL_BAR); + if(pluginComponents.hasNext()) this.addSeparator(); - + while (pluginComponents.hasNext()) { Component c = (Component)pluginComponents.next(); - + this.add(c); - + this.revalidate(); this.repaint(); } - + + // Search for plugin components registered through the OSGI bundle + // context. + ServiceReference[] serRefs = null; + + String osgiFilter = "(" + + Container.CONTAINER_ID + + "="+Container.CONTAINER_CHAT_TOOL_BAR.getID()+")"; + + try + { + serRefs = GuiActivator.bundleContext.getServiceReferences( + PluginComponent.class.getName(), + osgiFilter); + } + catch (InvalidSyntaxException exc) + { + exc.printStackTrace(); + } + + if (serRefs == null) + return; + + for (int i = 0; i < serRefs.length; i ++) + { + PluginComponent component = (PluginComponent) GuiActivator + .bundleContext.getService(serRefs[i]);; + + this.add((Component)component.getComponent()); + + this.revalidate(); + this.repaint(); + } + GuiActivator.getUIService().addPluginComponentListener(this); } - /** * Implements the <code>PluginComponentListener.pluginComponentAdded</code> * method. */ public void pluginComponentAdded(PluginComponentEvent event) - { - Component c = (Component) event.getSource(); + { + PluginComponent c = event.getPluginComponent(); - if(event.getContainerID().equals(UIService.CONTAINER_CHAT_TOOL_BAR)) + if(c.getContainer().equals(Container.CONTAINER_CHAT_TOOL_BAR)) { this.addSeparator(); - this.add(c); - + this.add((Component) c.getComponent()); + this.revalidate(); this.repaint(); } @@ -406,11 +442,11 @@ public class MainToolBar */ public void pluginComponentRemoved(PluginComponentEvent event) { - Component c = (Component) event.getSource(); - - if(event.getContainerID().equals(UIService.CONTAINER_CHAT_TOOL_BAR)) + PluginComponent c = event.getPluginComponent(); + + if(c.getContainer().equals(Container.CONTAINER_CHAT_TOOL_BAR)) { - this.remove(c); + this.remove((Component) c.getComponent()); } } diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomCommonRightButtonMenu.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomCommonRightButtonMenu.java index 4dfc1ae..8be706d 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomCommonRightButtonMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomCommonRightButtonMenu.java @@ -14,13 +14,14 @@ import java.util.*; import javax.swing.*; import net.java.sip.communicator.impl.gui.*; +import net.java.sip.communicator.impl.gui.event.*; import net.java.sip.communicator.impl.gui.i18n.*; import net.java.sip.communicator.impl.gui.main.*; import net.java.sip.communicator.impl.gui.main.chatroomslist.createforms.*; import net.java.sip.communicator.impl.gui.main.chatroomslist.joinforms.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.service.gui.*; -import net.java.sip.communicator.service.gui.event.*; +import net.java.sip.communicator.service.gui.Container; import net.java.sip.communicator.service.protocol.*; /** @@ -98,15 +99,15 @@ public class ChatRoomCommonRightButtonMenu { Iterator pluginComponents = GuiActivator.getUIService() .getComponentsForContainer( - UIService.CONTAINER_CONTACT_RIGHT_BUTTON_MENU); - + Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU); + if(pluginComponents.hasNext()) this.addSeparator(); - + while (pluginComponents.hasNext()) { Component o = (Component)pluginComponents.next(); - + this.add(o); } } @@ -142,10 +143,10 @@ public class ChatRoomCommonRightButtonMenu */ public void pluginComponentAdded(PluginComponentEvent event) { - Component c = (Component) event.getSource(); - - this.add(c); - + PluginComponent c = event.getPluginComponent(); + + this.add((Component) c.getComponent()); + this.repaint(); } @@ -155,8 +156,8 @@ public class ChatRoomCommonRightButtonMenu */ public void pluginComponentRemoved(PluginComponentEvent event) { - Component c = (Component) event.getSource(); - - this.remove(c); + PluginComponent c = event.getPluginComponent(); + + this.remove((Component) c.getComponent()); } } diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactRightButtonMenu.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactRightButtonMenu.java index 8020374..852505a 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactRightButtonMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactRightButtonMenu.java @@ -15,15 +15,20 @@ import java.awt.image.*; import javax.swing.*; +import org.osgi.framework.*; + import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.customcontrols.*; +import net.java.sip.communicator.impl.gui.event.*; import net.java.sip.communicator.impl.gui.i18n.*; import net.java.sip.communicator.impl.gui.main.*; import net.java.sip.communicator.impl.gui.main.chat.history.*; import net.java.sip.communicator.impl.gui.main.contactlist.addcontact.*; import net.java.sip.communicator.impl.gui.utils.*; +import net.java.sip.communicator.impl.gui.utils.Constants; import net.java.sip.communicator.service.contactlist.*; import net.java.sip.communicator.service.gui.*; +import net.java.sip.communicator.service.gui.Container; import net.java.sip.communicator.service.gui.event.*; import net.java.sip.communicator.service.protocol.*; @@ -338,23 +343,57 @@ public class ContactRightButtonMenu */ private void initPluginComponents() { + // Get all plugin components added through the UIService.addComponent() + // method. Iterator pluginComponents = GuiActivator.getUIService() .getComponentsForContainer( - UIService.CONTAINER_CONTACT_RIGHT_BUTTON_MENU); - + Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU); + if(pluginComponents.hasNext()) this.addSeparator(); - + while (pluginComponents.hasNext()) { Component o = (Component)pluginComponents.next(); - + this.add(o); - + if (o instanceof ContactAwareComponent) ((ContactAwareComponent)o).setCurrentContact(contactItem); } - + + // Search for plugin components registered through the OSGI bundle + // context. + ServiceReference[] serRefs = null; + + String osgiFilter = "(" + + Container.CONTAINER_ID + + "="+Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU.getID()+")"; + + try + { + serRefs = GuiActivator.bundleContext.getServiceReferences( + PluginComponent.class.getName(), + osgiFilter); + } + catch (InvalidSyntaxException exc) + { + exc.printStackTrace(); + } + + if (serRefs == null) + return; + + for (int i = 0; i < serRefs.length; i ++) + { + PluginComponent component = (PluginComponent) GuiActivator + .bundleContext.getService(serRefs[i]);; + + component.setCurrentContact(contactItem); + + this.add((Component)component.getComponent()); + } + GuiActivator.getUIService().addPluginComponentListener(this); } @@ -802,21 +841,21 @@ public class ContactRightButtonMenu */ public void pluginComponentAdded(PluginComponentEvent event) { - Component c = (Component) event.getSource(); - - if(event.getContainerID() - .equals(UIService.CONTAINER_CONTACT_RIGHT_BUTTON_MENU)) - { - this.add(c); - - if (c instanceof ContactAwareComponent) - { - ((ContactAwareComponent)c) - .setCurrentContact(contactItem); - } - - this.repaint(); - } + PluginComponent c = event.getPluginComponent(); + + if(!c.getContainer() + .equals(Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU)) + return; + + Object constraints + = UIServiceImpl.getBorderLayoutConstraintsFromContainer( + c.getConstraints()); + + this.add((Component) c.getComponent(), constraints); + + c.setCurrentContact(contactItem); + + this.repaint(); } /** @@ -824,12 +863,12 @@ public class ContactRightButtonMenu */ public void pluginComponentRemoved(PluginComponentEvent event) { - Component c = (Component) event.getSource(); + PluginComponent c = event.getPluginComponent(); - if(event.getContainerID() - .equals(UIService.CONTAINER_CONTACT_RIGHT_BUTTON_MENU)) + if(c.getContainer() + .equals(Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU)) { - this.remove(c); + this.remove((Component) c.getComponent()); } } @@ -864,7 +903,7 @@ public class ContactRightButtonMenu ImageLoader.getBytesInImage(pps.getProtocolIcon() .getIcon(ProtocolIcon.ICON_SIZE_16x16))); } - + int index = mainFrame.getProviderIndex(pps); Image img = null; diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/GroupRightButtonMenu.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/GroupRightButtonMenu.java index 8d22e08..b4b0e3a 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/GroupRightButtonMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/GroupRightButtonMenu.java @@ -14,14 +14,19 @@ import java.awt.image.*; import javax.swing.*; +import org.osgi.framework.*; + import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.customcontrols.*; +import net.java.sip.communicator.impl.gui.event.*; import net.java.sip.communicator.impl.gui.i18n.*; import net.java.sip.communicator.impl.gui.main.*; import net.java.sip.communicator.impl.gui.main.contactlist.addcontact.*; import net.java.sip.communicator.impl.gui.utils.*; +import net.java.sip.communicator.impl.gui.utils.Constants; import net.java.sip.communicator.service.contactlist.*; import net.java.sip.communicator.service.gui.*; +import net.java.sip.communicator.service.gui.Container; import net.java.sip.communicator.service.gui.event.*; import net.java.sip.communicator.service.protocol.*; @@ -39,7 +44,7 @@ public class GroupRightButtonMenu { private I18NString addContactString = Messages.getI18NString("addContact"); - + private I18NString removeGroupString = Messages.getI18NString("removeGroup"); private I18NString renameGroupString = Messages.getI18NString("renameGroup"); @@ -125,20 +130,56 @@ public class GroupRightButtonMenu { Iterator pluginComponents = GuiActivator.getUIService() .getComponentsForContainer( - UIService.CONTAINER_GROUP_RIGHT_BUTTON_MENU); - + Container.CONTAINER_GROUP_RIGHT_BUTTON_MENU); + if(pluginComponents.hasNext()) this.addSeparator(); - + while (pluginComponents.hasNext()) { Component o = (Component)pluginComponents.next(); - + this.add(o); - + if (o instanceof ContactAwareComponent) ((ContactAwareComponent)o).setCurrentContactGroup(group); } + + // Search for plugin components registered through the OSGI bundle + // context. + ServiceReference[] serRefs = null; + + String osgiFilter = "(" + + Container.CONTAINER_ID + + "="+Container.CONTAINER_GROUP_RIGHT_BUTTON_MENU.getID()+")"; + + try + { + serRefs = GuiActivator.bundleContext.getServiceReferences( + PluginComponent.class.getName(), + osgiFilter); + } + catch (InvalidSyntaxException exc) + { + exc.printStackTrace(); + } + + if (serRefs == null) + return; + + for (int i = 0; i < serRefs.length; i ++) + { + PluginComponent component = (PluginComponent) GuiActivator + .bundleContext.getService(serRefs[i]);; + + component.setCurrentContactGroup(group); + + this.add((Component)component.getComponent()); + + this.repaint(); + } + + GuiActivator.getUIService().addPluginComponentListener(this); } /** @@ -248,31 +289,27 @@ public class GroupRightButtonMenu public void pluginComponentAdded(PluginComponentEvent event) { - Component c = (Component) event.getSource(); - - if(event.getContainerID() - .equals(UIService.CONTAINER_GROUP_RIGHT_BUTTON_MENU)) - { - this.add(c); - - if (c instanceof ContactAwareComponent) - { - ((ContactAwareComponent)c) - .setCurrentContactGroup(group); - } - - this.repaint(); - } + PluginComponent c = event.getPluginComponent(); + + if(!c.getContainer() + .equals(Container.CONTAINER_GROUP_RIGHT_BUTTON_MENU)) + return; + + this.add((Component) c.getComponent()); + + c.setCurrentContactGroup(group); + + this.repaint(); } public void pluginComponentRemoved(PluginComponentEvent event) { - Component c = (Component) event.getSource(); - - if(event.getContainerID() - .equals(UIService.CONTAINER_GROUP_RIGHT_BUTTON_MENU)) + PluginComponent c = event.getPluginComponent(); + + if(c.getContainer() + .equals(Container.CONTAINER_GROUP_RIGHT_BUTTON_MENU)) { - this.remove(c); + this.remove((Component) c.getComponent()); } } diff --git a/src/net/java/sip/communicator/impl/gui/main/menus/ExtendedQuickMenu.java b/src/net/java/sip/communicator/impl/gui/main/menus/ExtendedQuickMenu.java index 3b1c043..935bfa0 100644 --- a/src/net/java/sip/communicator/impl/gui/main/menus/ExtendedQuickMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/menus/ExtendedQuickMenu.java @@ -14,8 +14,11 @@ import java.util.*; import javax.swing.*; import javax.swing.event.*; +import org.osgi.framework.*; + import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.customcontrols.*; +import net.java.sip.communicator.impl.gui.event.*; import net.java.sip.communicator.impl.gui.i18n.*; import net.java.sip.communicator.impl.gui.main.*; import net.java.sip.communicator.impl.gui.main.contactlist.*; @@ -23,6 +26,7 @@ import net.java.sip.communicator.impl.gui.main.contactlist.addcontact.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.service.contactlist.*; import net.java.sip.communicator.service.gui.*; +import net.java.sip.communicator.service.gui.Container; import net.java.sip.communicator.service.gui.event.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; @@ -157,7 +161,7 @@ public class ExtendedQuickMenu { Iterator pluginComponents = GuiActivator.getUIService() .getComponentsForContainer( - UIService.CONTAINER_MAIN_TOOL_BAR); + Container.CONTAINER_MAIN_TOOL_BAR); if(pluginComponents.hasNext()) this.addSeparator(); @@ -188,8 +192,55 @@ public class ExtendedQuickMenu this.revalidate(); this.repaint(); } - } + // Search for plugin components registered through the OSGI bundle + // context. + ServiceReference[] serRefs = null; + + String osgiFilter = "(" + + Container.CONTAINER_ID + + "="+Container.CONTAINER_MAIN_TOOL_BAR.getID()+")"; + + try + { + serRefs = GuiActivator.bundleContext.getServiceReferences( + PluginComponent.class.getName(), + osgiFilter); + } + catch (InvalidSyntaxException exc) + { + exc.printStackTrace(); + } + + if (serRefs == null) + return; + + for (int i = 0; i < serRefs.length; i ++) + { + PluginComponent component = (PluginComponent) GuiActivator + .bundleContext.getService(serRefs[i]);; + + Object selectedValue = mainFrame.getContactListPanel() + .getContactList().getSelectedValue(); + + if(selectedValue instanceof MetaContact) + { + component.setCurrentContact((MetaContact)selectedValue); + } + else if(selectedValue instanceof MetaContactGroup) + { + component + .setCurrentContactGroup((MetaContactGroup)selectedValue); + } + + + this.add((Component)component.getComponent()); + + this.repaint(); + } + + GuiActivator.getUIService().addPluginComponentListener(this); + } /** * Handles the <tt>ActionEvent</tt> triggered when user clicks on one of * the buttons in this toolbar. @@ -334,33 +385,34 @@ public class ExtendedQuickMenu */ public void pluginComponentAdded(PluginComponentEvent event) { - Component c = (Component) event.getSource(); - + PluginComponent pluginComponent = event.getPluginComponent(); + // If the container id doesn't correspond to the id of the plugin // container we're not interested. - if(!event.getContainerID() - .equals(UIService.CONTAINER_MAIN_TOOL_BAR)) + if(!pluginComponent.getContainer() + .equals(Container.CONTAINER_MAIN_TOOL_BAR)) return; + + Object constraints = UIServiceImpl + .getBorderLayoutConstraintsFromContainer( + pluginComponent.getConstraints()); + + this.add((Component)pluginComponent.getComponent(), constraints); + + Object selectedValue = mainFrame.getContactListPanel() + .getContactList().getSelectedValue(); - this.add(c); - - if (c instanceof ContactAwareComponent) + if(selectedValue instanceof MetaContact) { - Object selectedValue = mainFrame.getContactListPanel() - .getContactList().getSelectedValue(); - - if(selectedValue instanceof MetaContact) - { - ((ContactAwareComponent)c) - .setCurrentContact((MetaContact)selectedValue); - } - else if(selectedValue instanceof MetaContactGroup) - { - ((ContactAwareComponent)c) - .setCurrentContactGroup((MetaContactGroup)selectedValue); - } + pluginComponent + .setCurrentContact((MetaContact)selectedValue); } - + else if(selectedValue instanceof MetaContactGroup) + { + pluginComponent + .setCurrentContactGroup((MetaContactGroup)selectedValue); + } + this.revalidate(); this.repaint(); } @@ -369,16 +421,17 @@ public class ExtendedQuickMenu * Implements the <code>PluginComponentListener.pluginComponentRemoved</code> * method. */ - public void pluginComponentRemoved(PluginComponentEvent event) { - Component c = (Component) event.getSource(); + public void pluginComponentRemoved(PluginComponentEvent event) + { + PluginComponent c = event.getPluginComponent(); // If the container id doesn't correspond to the id of the plugin // container we're not interested. - if(!event.getContainerID() - .equals(UIService.CONTAINER_MAIN_TOOL_BAR)) + if(!c.getContainer() + .equals(Container.CONTAINER_MAIN_TOOL_BAR)) return; - - this.remove(c); + + this.remove((Component) c.getComponent()); } public void componentHidden(ComponentEvent e) diff --git a/src/net/java/sip/communicator/impl/gui/main/menus/HelpMenu.java b/src/net/java/sip/communicator/impl/gui/main/menus/HelpMenu.java index e9cb5c9..31859c2 100644 --- a/src/net/java/sip/communicator/impl/gui/main/menus/HelpMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/menus/HelpMenu.java @@ -10,12 +10,16 @@ import java.awt.*; import java.awt.event.*; import java.util.*; +import org.osgi.framework.*; + import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.customcontrols.*; +import net.java.sip.communicator.impl.gui.event.*; import net.java.sip.communicator.impl.gui.i18n.*; import net.java.sip.communicator.impl.gui.main.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.service.gui.*; +import net.java.sip.communicator.service.gui.Container; import net.java.sip.communicator.service.gui.event.*; /** @@ -58,7 +62,7 @@ public class HelpMenu private void initPluginComponents() { Iterator pluginComponents = GuiActivator.getUIService() - .getComponentsForContainer(UIService.CONTAINER_HELP_MENU); + .getComponentsForContainer(Container.CONTAINER_HELP_MENU); while (pluginComponents.hasNext()) { @@ -67,6 +71,36 @@ public class HelpMenu this.add(o); } + // Search for plugin components registered through the OSGI bundle + // context. + ServiceReference[] serRefs = null; + + String osgiFilter = "(" + + Container.CONTAINER_ID + + "="+Container.CONTAINER_HELP_MENU.getID()+")"; + + try + { + serRefs = GuiActivator.bundleContext.getServiceReferences( + PluginComponent.class.getName(), + osgiFilter); + } + catch (InvalidSyntaxException exc) + { + exc.printStackTrace(); + } + + if (serRefs == null) + return; + + for (int i = 0; i < serRefs.length; i ++) + { + PluginComponent component = (PluginComponent) GuiActivator + .bundleContext.getService(serRefs[i]);; + + this.add((Component)component.getComponent()); + } + GuiActivator.getUIService().addPluginComponentListener(this); } @@ -80,11 +114,11 @@ public class HelpMenu public void pluginComponentAdded(PluginComponentEvent event) { - Component c = (Component) event.getSource(); + PluginComponent c = event.getPluginComponent(); - if (event.getContainerID().equals(UIService.CONTAINER_HELP_MENU)) + if (c.getContainer().equals(Container.CONTAINER_HELP_MENU)) { - this.add(c); + this.add((Component) c.getComponent()); this.revalidate(); this.repaint(); @@ -93,11 +127,11 @@ public class HelpMenu public void pluginComponentRemoved(PluginComponentEvent event) { - Component c = (Component) event.getSource(); + PluginComponent c = event.getPluginComponent(); - if (event.getContainerID().equals(UIService.CONTAINER_HELP_MENU)) + if (c.getContainer().equals(Container.CONTAINER_HELP_MENU)) { - this.remove(c); + this.remove((Component) c.getComponent()); } } diff --git a/src/net/java/sip/communicator/impl/gui/main/menus/QuickMenu.java b/src/net/java/sip/communicator/impl/gui/main/menus/QuickMenu.java index c16c9e9..7bc75b8 100755 --- a/src/net/java/sip/communicator/impl/gui/main/menus/QuickMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/menus/QuickMenu.java @@ -16,6 +16,7 @@ import javax.swing.event.*; import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.customcontrols.*; +import net.java.sip.communicator.impl.gui.event.*; import net.java.sip.communicator.impl.gui.i18n.*; import net.java.sip.communicator.impl.gui.main.*; import net.java.sip.communicator.impl.gui.main.contactlist.*; @@ -23,10 +24,12 @@ import net.java.sip.communicator.impl.gui.main.contactlist.addcontact.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.service.contactlist.*; import net.java.sip.communicator.service.gui.*; -import net.java.sip.communicator.service.gui.event.*; +import net.java.sip.communicator.service.gui.Container; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; +import org.osgi.framework.*; + /** * The <tt>QuickMenu</tt> is the toolbar on the top of the main * application window. It provides quick access to the "User info" window, the @@ -46,7 +49,6 @@ public class QuickMenu ComponentListener, ListSelectionListener { - private Logger logger = Logger.getLogger(QuickMenu.class.getName()); private JButton infoButton = new JButton(new ImageIcon(ImageLoader @@ -62,7 +64,8 @@ public class QuickMenu .getImage(ImageLoader.QUICK_MENU_ADD_ICON))); private JButton soundButton = new JButton( - new ImageIcon(ImageLoader.getImage(ImageLoader.QUICK_MENU_SOUND_ON_ICON))); + new ImageIcon(ImageLoader.getImage( + ImageLoader.QUICK_MENU_SOUND_ON_ICON))); private static int BUTTON_HEIGHT = SizeProperties.getSize("mainToolbarButtonHeight"); @@ -154,22 +157,22 @@ public class QuickMenu { Iterator pluginComponents = GuiActivator.getUIService() .getComponentsForContainer( - UIService.CONTAINER_MAIN_TOOL_BAR); - + Container.CONTAINER_MAIN_TOOL_BAR); + if(pluginComponents.hasNext()) this.addSeparator(); - + while (pluginComponents.hasNext()) { Component c = (Component)pluginComponents.next(); - + this.add(c); - + if (c instanceof ContactAwareComponent) { Object selectedValue = mainFrame.getContactListPanel() .getContactList().getSelectedValue(); - + if(selectedValue instanceof MetaContact) { ((ContactAwareComponent)c) @@ -185,6 +188,54 @@ public class QuickMenu this.revalidate(); this.repaint(); } + + // Search for plugin components registered through the OSGI bundle + // context. + ServiceReference[] serRefs = null; + + String osgiFilter = "(" + + Container.CONTAINER_ID + + "="+Container.CONTAINER_MAIN_TOOL_BAR.getID()+")"; + + try + { + serRefs = GuiActivator.bundleContext.getServiceReferences( + PluginComponent.class.getName(), + osgiFilter); + } + catch (InvalidSyntaxException exc) + { + exc.printStackTrace(); + } + + if (serRefs == null) + return; + + for (int i = 0; i < serRefs.length; i ++) + { + PluginComponent component = (PluginComponent) GuiActivator + .bundleContext.getService(serRefs[i]);; + + Object selectedValue = mainFrame.getContactListPanel() + .getContactList().getSelectedValue(); + + if(selectedValue instanceof MetaContact) + { + component.setCurrentContact((MetaContact)selectedValue); + } + else if(selectedValue instanceof MetaContactGroup) + { + component + .setCurrentContactGroup((MetaContactGroup)selectedValue); + } + + + this.add((Component)component.getComponent()); + + this.repaint(); + } + + GuiActivator.getUIService().addPluginComponentListener(this); } /** @@ -305,33 +356,34 @@ public class QuickMenu */ public void pluginComponentAdded(PluginComponentEvent event) { - Component c = (Component) event.getSource(); - + PluginComponent pluginComponent = event.getPluginComponent(); + // If the container id doesn't correspond to the id of the plugin // container we're not interested. - if(!event.getContainerID() - .equals(UIService.CONTAINER_MAIN_TOOL_BAR)) + if(!pluginComponent.getContainer() + .equals(Container.CONTAINER_MAIN_TOOL_BAR)) return; + + Object constraints = UIServiceImpl + .getBorderLayoutConstraintsFromContainer( + pluginComponent.getConstraints()); + + this.add((Component)pluginComponent.getComponent(), constraints); + + Object selectedValue = mainFrame.getContactListPanel() + .getContactList().getSelectedValue(); - this.add(c); - - if (c instanceof ContactAwareComponent) + if(selectedValue instanceof MetaContact) { - Object selectedValue = mainFrame.getContactListPanel() - .getContactList().getSelectedValue(); - - if(selectedValue instanceof MetaContact) - { - ((ContactAwareComponent)c) - .setCurrentContact((MetaContact)selectedValue); - } - else if(selectedValue instanceof MetaContactGroup) - { - ((ContactAwareComponent)c) - .setCurrentContactGroup((MetaContactGroup)selectedValue); - } + pluginComponent + .setCurrentContact((MetaContact)selectedValue); } - + else if(selectedValue instanceof MetaContactGroup) + { + pluginComponent + .setCurrentContactGroup((MetaContactGroup)selectedValue); + } + this.revalidate(); this.repaint(); } @@ -340,16 +392,17 @@ public class QuickMenu * Implements the <code>PluginComponentListener.pluginComponentRemoved</code> * method. */ - public void pluginComponentRemoved(PluginComponentEvent event) { - Component c = (Component) event.getSource(); + public void pluginComponentRemoved(PluginComponentEvent event) + { + PluginComponent c = event.getPluginComponent(); // If the container id doesn't correspond to the id of the plugin // container we're not interested. - if(!event.getContainerID() - .equals(UIService.CONTAINER_MAIN_TOOL_BAR)) + if(!c.getContainer() + .equals(Container.CONTAINER_MAIN_TOOL_BAR)) return; - - this.remove(c); + + this.remove((Component) c.getComponent()); } public void componentHidden(ComponentEvent e) @@ -399,13 +452,13 @@ public class QuickMenu while (pluginComponents.hasNext()) { Component c = (Component)pluginComponents.next(); - + if(!(c instanceof ContactAwareComponent)) continue; - + Object selectedValue = mainFrame.getContactListPanel() .getContactList().getSelectedValue(); - + if(selectedValue instanceof MetaContact) { ((ContactAwareComponent)c) diff --git a/src/net/java/sip/communicator/impl/gui/main/menus/ToolsMenu.java b/src/net/java/sip/communicator/impl/gui/main/menus/ToolsMenu.java index f8550f8..77de96b 100644 --- a/src/net/java/sip/communicator/impl/gui/main/menus/ToolsMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/menus/ToolsMenu.java @@ -15,12 +15,15 @@ import javax.swing.*; import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.customcontrols.*; +import net.java.sip.communicator.impl.gui.event.*; import net.java.sip.communicator.impl.gui.i18n.*; import net.java.sip.communicator.impl.gui.main.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.service.gui.*; -import net.java.sip.communicator.service.gui.event.*; +import net.java.sip.communicator.service.gui.Container; import net.java.sip.communicator.util.*; + +import org.osgi.framework.*; /** * The <tt>FileMenu</tt> is a menu in the main application menu bar that * contains "New account". @@ -75,7 +78,7 @@ public class ToolsMenu { Iterator pluginComponents = GuiActivator.getUIService() .getComponentsForContainer( - UIService.CONTAINER_TOOLS_MENU); + Container.CONTAINER_TOOLS_MENU); if(pluginComponents.hasNext()) this.addSeparator(); @@ -87,6 +90,36 @@ public class ToolsMenu this.add(o); } + // Search for plugin components registered through the OSGI bundle + // context. + ServiceReference[] serRefs = null; + + String osgiFilter = "(" + + Container.CONTAINER_ID + + "="+Container.CONTAINER_TOOLS_MENU.getID()+")"; + + try + { + serRefs = GuiActivator.bundleContext.getServiceReferences( + PluginComponent.class.getName(), + osgiFilter); + } + catch (InvalidSyntaxException exc) + { + exc.printStackTrace(); + } + + if (serRefs == null) + return; + + for (int i = 0; i < serRefs.length; i ++) + { + PluginComponent component = (PluginComponent) GuiActivator + .bundleContext.getService(serRefs[i]);; + + this.add((Component)component.getComponent()); + } + GuiActivator.getUIService().addPluginComponentListener(this); } @@ -107,12 +140,12 @@ public class ToolsMenu public void pluginComponentAdded(PluginComponentEvent event) { - Component c = (Component) event.getSource(); - - if(event.getContainerID().equals(UIService.CONTAINER_TOOLS_MENU)) + PluginComponent c = event.getPluginComponent(); + + if(c.getContainer().equals(Container.CONTAINER_TOOLS_MENU)) { - this.add(c); - + this.add((Component) c.getComponent()); + this.revalidate(); this.repaint(); } @@ -120,11 +153,11 @@ public class ToolsMenu public void pluginComponentRemoved(PluginComponentEvent event) { - Component c = (Component) event.getSource(); - - if(event.getContainerID().equals(UIService.CONTAINER_TOOLS_MENU)) + PluginComponent c = event.getPluginComponent(); + + if(c.getContainer().equals(Container.CONTAINER_TOOLS_MENU)) { - this.remove(c); + this.remove((Component) c.getComponent()); } } } diff --git a/src/net/java/sip/communicator/plugin/branding/BrandingActivator.java b/src/net/java/sip/communicator/plugin/branding/BrandingActivator.java index 9ebc777..fe35df5 100644 --- a/src/net/java/sip/communicator/plugin/branding/BrandingActivator.java +++ b/src/net/java/sip/communicator/plugin/branding/BrandingActivator.java @@ -7,23 +7,25 @@ package net.java.sip.communicator.plugin.branding; import java.awt.event.*; +import java.util.*; -import javax.swing.JMenuItem; +import javax.swing.*; -import net.java.sip.communicator.service.gui.UIService; +import net.java.sip.communicator.service.gui.*; +import net.java.sip.communicator.util.*; import org.osgi.framework.*; -public class BrandingActivator implements BundleActivator, BundleListener +public class BrandingActivator + implements BundleActivator, + BundleListener { + private Logger logger = Logger.getLogger(BrandingActivator.class); + private WelcomeWindow welcomeWindow; private static BundleContext bundleContext; - private JMenuItem aboutEntry; - - private JMenuItem chatAboutEntry; - public void start(BundleContext bc) throws Exception { bundleContext = bc; @@ -37,7 +39,6 @@ public class BrandingActivator implements BundleActivator, BundleListener public void stop(BundleContext arg0) throws Exception { - unRegisterMenuEntry(); } public void bundleChanged(BundleEvent evt) @@ -75,84 +76,29 @@ public class BrandingActivator implements BundleActivator, BundleListener private void registerMenuEntry(ServiceReference uiServiceRef) { - final UIService uiService = (UIService) bundleContext - .getService(uiServiceRef); + // Register the about window plugin component in the main help menu. + Hashtable<String, String> helpMenuFilter + = new Hashtable<String, String>(); + helpMenuFilter.put( Container.CONTAINER_ID, + Container.CONTAINER_HELP_MENU.getID()); - // add menu entry to file menu - // Add your menu item to the help menu + bundleContext.registerService( PluginComponent.class.getName(), + new AboutWindowPluginComponent(), + helpMenuFilter); - aboutEntry - = new JMenuItem(Resources.getString("aboutMenuEntry")); + logger.info("ABOUT WINDOW ... [REGISTERED]"); - aboutEntry.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - AboutWindow aboutWindow = new AboutWindow(null); - aboutWindow.setVisible(true); - } - }); + // Register the about window plugin component in the chat help menu. + Hashtable<String, String> chatHelpMenuFilter + = new Hashtable<String, String>(); + chatHelpMenuFilter.put( Container.CONTAINER_ID, + Container.CONTAINER_CHAT_HELP_MENU.getID()); - chatAboutEntry - = new JMenuItem(Resources.getString("aboutMenuEntry")); + bundleContext.registerService( PluginComponent.class.getName(), + new AboutWindowPluginComponent(), + chatHelpMenuFilter); - chatAboutEntry.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - AboutWindow aboutWindow = new AboutWindow(null); - aboutWindow.setVisible(true); - } - }); - - // Check if the help menu is a supported container. - if (uiService.isContainerSupported(UIService.CONTAINER_HELP_MENU)) - { - uiService.addComponent(UIService.CONTAINER_HELP_MENU, aboutEntry); - } - - // Check if the help menu is a supported container. - if (uiService.isContainerSupported(UIService.CONTAINER_CHAT_HELP_MENU)) - { - uiService.addComponent(UIService.CONTAINER_CHAT_HELP_MENU, - chatAboutEntry); - } - } - - private void unRegisterMenuEntry() - { - // Obtain the UI Service - ServiceReference uiServiceRef = bundleContext - .getServiceReference(UIService.class.getName()); - - if (uiServiceRef == null - || uiServiceRef.getBundle().getState() != Bundle.ACTIVE) - { - return; - } - - UIService uiService = (UIService) bundleContext - .getService(uiServiceRef); - - // Check if the tools menu is a supported container and remove the about - // entry added before. - if (uiService.isContainerSupported(UIService.CONTAINER_HELP_MENU)) - { - // add menu entry to file menu - // Add your menu item to the help menu - uiService.removeComponent( - UIService.CONTAINER_HELP_MENU, aboutEntry); - } - - // Check if the chat menu is a supported container and remove the about - // entry added before. - if (uiService.isContainerSupported(UIService.CONTAINER_CHAT_HELP_MENU)) - { - // add menu entry to file menu - // Add your menu item to the help menu - uiService.removeComponent( - UIService.CONTAINER_CHAT_HELP_MENU, chatAboutEntry); - } + logger.info("CHAT ABOUT WINDOW ... [REGISTERED]"); } static BundleContext getBundleContext() diff --git a/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoActivator.java b/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoActivator.java index 0b1c88d..2d758f8 100644 --- a/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoActivator.java +++ b/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoActivator.java @@ -1,7 +1,10 @@ package net.java.sip.communicator.plugin.contactinfo;
+import java.util.*;
+
import net.java.sip.communicator.service.browserlauncher.*;
import net.java.sip.communicator.service.gui.*;
+import net.java.sip.communicator.util.*;
import org.osgi.framework.*;
@@ -13,6 +16,8 @@ import org.osgi.framework.*; */
public class ContactInfoActivator implements BundleActivator
{
+ private Logger logger = Logger.getLogger(ContactInfoActivator.class);
+
private static BrowserLauncherService browserLauncherService;
private static BundleContext bundleContext;
@@ -24,25 +29,19 @@ public class ContactInfoActivator implements BundleActivator {
bundleContext = bc;
- ServiceReference uiServiceRef
- = bc.getServiceReference(UIService.class.getName());
+ ContactInfoMenuItem cinfoMenuItem = new ContactInfoMenuItem();
- UIService uiService
- = (UIService) bc.getService(uiServiceRef);
+ Hashtable<String, String> containerFilter
+ = new Hashtable<String, String>();
+ containerFilter.put(
+ Container.CONTAINER_ID,
+ Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU.getID());
- // Check if the desired place, where we would like to add
- // our menu item is supported from the current UIService implementation.
- if (uiService.isContainerSupported(
- UIService.CONTAINER_CONTACT_RIGHT_BUTTON_MENU))
- {
- ContactInfoMenuItem cinfoMenuItem = new ContactInfoMenuItem();
+ bundleContext.registerService( PluginComponent.class.getName(),
+ cinfoMenuItem,
+ containerFilter);
- // We add the example plugin menu item in the right button menu
- // for a contact.
- uiService.addComponent(
- UIService.CONTAINER_CONTACT_RIGHT_BUTTON_MENU,
- cinfoMenuItem);
- }
+ logger.info("CONTACT INFO... [REGISTERED]");
}
public void stop(BundleContext bc) throws Exception
diff --git a/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoMenuItem.java b/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoMenuItem.java index dbddc90..a321d6c 100644 --- a/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoMenuItem.java +++ b/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoMenuItem.java @@ -13,16 +13,20 @@ import javax.swing.*; import net.java.sip.communicator.service.contactlist.*;
import net.java.sip.communicator.service.gui.*;
+import net.java.sip.communicator.service.gui.Container;
/**
*
* @author Adam Goldstein
*/
public class ContactInfoMenuItem
- extends JMenuItem
- implements ContactAwareComponent,
+ implements PluginComponent,
ActionListener
{
+ private JMenuItem menuItem
+ = new JMenuItem(Resources.getString("contactInfo"),
+ Resources.getImage("infoIcon"));
+
private MetaContact metaContact;
/**
@@ -30,10 +34,7 @@ public class ContactInfoMenuItem */
public ContactInfoMenuItem()
{
- super( Resources.getString("contactInfo"),
- Resources.getImage("infoIcon"));
-
- this.addActionListener(this);
+ menuItem.addActionListener(this);
}
/**
@@ -64,4 +65,24 @@ public class ContactInfoMenuItem cinfoDialog.setVisible(true);
}
+
+ public Object getComponent()
+ {
+ return menuItem;
+ }
+
+ public String getConstraints()
+ {
+ return null;
+ }
+
+ public Container getContainer()
+ {
+ return Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU;
+ }
+
+ public String getName()
+ {
+ return menuItem.getText();
+ }
}
\ No newline at end of file diff --git a/src/net/java/sip/communicator/plugin/extendedcallhistorysearch/ExtendedCallHistorySearchActivator.java b/src/net/java/sip/communicator/plugin/extendedcallhistorysearch/ExtendedCallHistorySearchActivator.java index 80ccb97..9dd5efa 100644 --- a/src/net/java/sip/communicator/plugin/extendedcallhistorysearch/ExtendedCallHistorySearchActivator.java +++ b/src/net/java/sip/communicator/plugin/extendedcallhistorysearch/ExtendedCallHistorySearchActivator.java @@ -7,8 +7,11 @@ package net.java.sip.communicator.plugin.extendedcallhistorysearch; +import java.util.*; + import net.java.sip.communicator.service.callhistory.*; import net.java.sip.communicator.service.gui.*; +import net.java.sip.communicator.util.*; import org.osgi.framework.*; @@ -20,24 +23,29 @@ import org.osgi.framework.*; public class ExtendedCallHistorySearchActivator implements BundleActivator { + private Logger logger + = Logger.getLogger(ExtendedCallHistorySearchActivator.class); + private static BundleContext context; public void start(BundleContext bc) throws Exception { context = bc; - ServiceReference uiServiceRef = bc.getServiceReference( - UIService.class.getName()); - UIService uiService = (UIService) bc.getService(uiServiceRef); + ExtendedCallHistorySearchItem extendedSearch + = new ExtendedCallHistorySearchItem(); + + Hashtable<String, String> containerFilter + = new Hashtable<String, String>(); + containerFilter.put( + Container.CONTAINER_ID, + Container.CONTAINER_TOOLS_MENU.getID()); - if (uiService.isContainerSupported(UIService.CONTAINER_TOOLS_MENU)) - { - ExtendedCallHistorySearchItem extendedSearch - = new ExtendedCallHistorySearchItem(); + context.registerService( PluginComponent.class.getName(), + extendedSearch, + containerFilter); - uiService.addComponent(UIService.CONTAINER_TOOLS_MENU, - extendedSearch); - } + logger.info("EXTENDED CALL HISTORY SEARCH... [REGISTERED]"); } public void stop(BundleContext bc) throws Exception diff --git a/src/net/java/sip/communicator/plugin/extendedcallhistorysearch/ExtendedCallHistorySearchItem.java b/src/net/java/sip/communicator/plugin/extendedcallhistorysearch/ExtendedCallHistorySearchItem.java index af097ed..d79d017 100644 --- a/src/net/java/sip/communicator/plugin/extendedcallhistorysearch/ExtendedCallHistorySearchItem.java +++ b/src/net/java/sip/communicator/plugin/extendedcallhistorysearch/ExtendedCallHistorySearchItem.java @@ -12,6 +12,10 @@ import java.awt.event.*; import javax.swing.*; +import net.java.sip.communicator.service.contactlist.*; +import net.java.sip.communicator.service.gui.*; +import net.java.sip.communicator.service.gui.Container; + /** * The <tt>ExtendedCallHistorySearchButton</tt> is the button that will be * added in the Call List panel and from which the user would be able to access @@ -20,10 +24,12 @@ import javax.swing.*; * @author Bourdon Maxime & Meyer Thomas */ public class ExtendedCallHistorySearchItem - extends JMenuItem - implements - ActionListener + implements ActionListener, + PluginComponent { + private JMenuItem historyMenuItem + = new JMenuItem(Resources.getString("advancedCallHistorySearch")); + private ExtendedCallHistorySearchDialog callHistorySearchDialog = null; /** @@ -31,10 +37,9 @@ public class ExtendedCallHistorySearchItem */ public ExtendedCallHistorySearchItem() { - super(Resources.getString("advancedCallHistorySearch")); - - this.setMnemonic(Resources.getMnemonic("advancedCallHistorySearch")); - this.addActionListener(this); + this.historyMenuItem.setMnemonic( + Resources.getMnemonic("advancedCallHistorySearch")); + this.historyMenuItem.addActionListener(this); } /** @@ -49,11 +54,39 @@ public class ExtendedCallHistorySearchItem .getScreenSize().width / 2 - callHistorySearchDialog.getWidth() / 2, Toolkit .getDefaultToolkit().getScreenSize().height - / 2 - callHistorySearchDialog.getHeight() / 2); + / 2 - callHistorySearchDialog.getHeight() / 2); } - + callHistorySearchDialog.loadHistoryCalls(); - + callHistorySearchDialog.setVisible(true); } + + public Object getComponent() + { + return historyMenuItem; + } + + public String getConstraints() + { + return null; + } + + public Container getContainer() + { + return Container.CONTAINER_TOOLS_MENU; + } + + public String getName() + { + return historyMenuItem.getText(); + } + + public void setCurrentContact(MetaContact metaContact) + { + } + + public void setCurrentContactGroup(MetaContactGroup metaGroup) + { + } } diff --git a/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardActivator.java b/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardActivator.java index 18f3aa3..1bd01ad 100644 --- a/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardActivator.java +++ b/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardActivator.java @@ -39,23 +39,21 @@ public class WhiteboardActivator implements BundleActivator { bundleContext = bc; - ServiceReference uiServiceRef - = bc.getServiceReference (UIService.class.getName ()); + session = new WhiteboardSessionManager (); - uiService = (UIService) bc.getService (uiServiceRef); + WhiteboardMenuItem whiteboardPlugin = new WhiteboardMenuItem (session); - session = new WhiteboardSessionManager (); + Hashtable<String, String> containerFilter + = new Hashtable<String, String>(); + containerFilter.put( + Container.CONTAINER_ID, + Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU.getID()); - if(uiService.isContainerSupported ( - UIService.CONTAINER_CONTACT_RIGHT_BUTTON_MENU)) - { - WhiteboardMenuItem whiteboardPlugin = - new WhiteboardMenuItem (session); + bundleContext.registerService( PluginComponent.class.getName(), + whiteboardPlugin, + containerFilter); - uiService.addComponent ( - UIService.CONTAINER_CONTACT_RIGHT_BUTTON_MENU, - whiteboardPlugin); - } + logger.info("WHITEBOARD... [REGISTERED]"); } /** diff --git a/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardMenuItem.java b/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardMenuItem.java index b2d06d3..ebd0d02 100644 --- a/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardMenuItem.java +++ b/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardMenuItem.java @@ -21,10 +21,12 @@ import net.java.sip.communicator.service.protocol.*; * @author Julien Waechter */ public class WhiteboardMenuItem - extends JMenu - implements ContactAwareComponent, + implements PluginComponent, ActionListener { + private JMenu whiteboardMenu + = new JMenu(Resources.getString("whiteboardMenuItemText")); + /** * The current meta contact */ @@ -42,9 +44,8 @@ public class WhiteboardMenuItem */ public WhiteboardMenuItem (WhiteboardSessionManager session) { - super (Resources.getString("whiteboardMenuItemText")); this.session = session; - this.setIcon (Resources.getImage ("mpenIcon")); + this.whiteboardMenu.setIcon (Resources.getImage ("mpenIcon")); } /** @@ -56,7 +57,7 @@ public class WhiteboardMenuItem { this.metaContact = metaContact; - this.removeAll(); + this.whiteboardMenu.removeAll(); Iterator iter = metaContact.getContacts(); while (iter.hasNext()) @@ -83,7 +84,7 @@ public class WhiteboardMenuItem Resources.getString("whiteboardMenuItemNotSupportedTooltip")); } - this.add(contactItem); + this.whiteboardMenu.add(contactItem); } } @@ -117,4 +118,24 @@ public class WhiteboardMenuItem session.initWhiteboard (contact); } } + + public String getConstraints() + { + return null; + } + + public Container getContainer() + { + return Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU; + } + + public Object getComponent() + { + return whiteboardMenu; + } + + public String getName() + { + return whiteboardMenu.getText(); + } }
\ No newline at end of file diff --git a/src/net/java/sip/communicator/service/gui/Container.java b/src/net/java/sip/communicator/service/gui/Container.java new file mode 100644 index 0000000..8d55610 --- /dev/null +++ b/src/net/java/sip/communicator/service/gui/Container.java @@ -0,0 +1,199 @@ +/* + * 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.service.gui; + +/** + * The <tt>Container</tt> wraps a string which is meant to point + * to a plugin container. The plugin container is a GUI container that contains + * plugin components. + * + * @author Yana Stamcheva + */ +public class Container +{ + public static final String CONTAINER_ID = "CONTAINER_ID"; + + /** + * Main application window "file menu" container. + */ + public static final Container CONTAINER_FILE_MENU + = new Container("CONTAINER_FILE_MENU"); + /** + * Main application window "tools menu" container. + */ + public static final Container CONTAINER_TOOLS_MENU + = new Container("CONTAINER_TOOLS_MENU"); + /** + * Main application window "view menu" container. + */ + public static final Container CONTAINER_VIEW_MENU + = new Container("CONTAINER_VIEW_MENU"); + /** + * Main application window "help menu" container. + */ + public static final Container CONTAINER_HELP_MENU + = new Container("CONTAINER_HELP_MENU"); + /** + * Main application window "settings menu" container. + */ + public static final Container CONTAINER_SETTINGS_MENU + = new Container("CONTAINER_SETTINGS_MENU"); + /** + * Main application window main toolbar container. + */ + public static final Container CONTAINER_MAIN_TOOL_BAR + = new Container("CONTAINER_MAIN_TOOL_BAR"); + /** + * Main application window main tabbedpane container. + */ + public static final Container CONTAINER_MAIN_TABBED_PANE + = new Container("CONTAINER_MAIN_TABBED_PANE"); + /** + * Chat window toolbar container. + */ + public static final Container CONTAINER_CHAT_TOOL_BAR + = new Container("CONTAINER_CHAT_TOOL_BAR"); + /** + * Main application window "right button menu" over a contact container. + */ + public static final Container CONTAINER_CONTACT_RIGHT_BUTTON_MENU + = new Container("CONTAINER_CONTACT_RIGHT_BUTTON_MENU"); + + /** + * Main application window "right button menu" over a group container. + */ + public static final Container CONTAINER_GROUP_RIGHT_BUTTON_MENU + = new Container("CONTAINER_GROUP_RIGHT_BUTTON_MENU"); + + /** + * Chat window "menu bar" container. + */ + public static final Container CONTAINER_CHAT_MENU_BAR + = new Container("CONTAINER_CHAT_MENU_BAR"); + /** + * Chat window "file menu" container. + */ + public static final Container CONTAINER_CHAT_FILE_MENU + = new Container("CONTAINER_CHAT_FILE_MENU"); + /** + * Chat window "edit menu" container. + */ + public static final Container CONTAINER_CHAT_EDIT_MENU + = new Container("CONTAINER_CHAT_EDIT_MENU"); + /** + * Chat window "settings menu" container. + */ + public static final Container CONTAINER_CHAT_SETTINGS_MENU + = new Container("CONTAINER_CHAT_SETTINGS_MENU"); + + /** + * Chat window "help menu" container. + */ + public static final Container CONTAINER_CHAT_HELP_MENU + = new Container("CONTAINER_CHAT_HELP_MENU"); + + /** + * Chat window "south area" container. + */ + public static final Container CONTAINER_CHAT_WINDOW + = new Container("CONTAINER_CHAT_WINDOW"); + + /** + * The contact list panel. + */ + public static final Container CONTAINER_CONTACT_LIST + = new Container("CONTAINER_CONTACT_LIST"); + /** + * Call history panel container. + */ + public static final Container CONTAINER_CALL_HISTORY + = new Container("CONTAINER_CALL_HISTORY"); + + /* + * Constraints + */ + /** + * Indicates the most left/top edge of a container. + */ + public static final String START = "Start"; + /** + * Indicates the most right/bottom edge of a container. + */ + public static final String END = "End"; + /** + * Indicates the top edge of a container. + */ + public static final String TOP = "Top"; + /** + * Indicates the bottom edge of a container. + */ + public static final String BOTTOM = "Bottom"; + /** + * Indicates the left edge of a container. + */ + public static final String LEFT = "Left"; + /** + * Indicates the right edge of a container. + */ + public static final String RIGHT = "Right"; + + /** + * The name of the container. + */ + private String containerName; + + /** + * Creates a <tt>Container</tt> from the given container name. + * + * @param containerName the name of the container. + */ + public Container(String containerName) + { + this.containerName = containerName; + } + + /** + * Returns the String identifier of this <tt>Container</tt>. + * + * @return the String identifier of this <tt>Container</tt>. + */ + public String getID() + { + return this.containerName; + } + + /** + * Indicates whether some other object is "equal to" this one which in terms + * of containers translates to having equal identifiers. If the given object + * is a String we'll compare it directly to the identifier of our container. + * <p> + * @param obj the reference object with which to compare. + * @return <code>true</code> if this container has the same id as that of + * the <code>obj</code> argument or if the object argument is the id of this + * container. + */ + public boolean equals(Object obj) + { + if (obj == null) + return false; + + if (obj instanceof Container) + { + Container container = (Container) obj; + + return this.getID().equals(container.getID()); + } + else if (obj instanceof String) + { + String containerID = (String) obj; + + return this.getID().equals(containerID); + } + else + return false; + } +} diff --git a/src/net/java/sip/communicator/service/gui/ContainerID.java b/src/net/java/sip/communicator/service/gui/ContainerID.java deleted file mode 100644 index e6a5e2d..0000000 --- a/src/net/java/sip/communicator/service/gui/ContainerID.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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.service.gui; - -/** - * The <tt>ContainerID</tt> wraps a string which is meant to point - * to a container which could contain plugin components. - * - * @author Yana Stamcheva - */ -public class ContainerID{ - - private String containerName; - - public ContainerID(String containerName) - { - this.containerName = containerName; - } - - public String getID() - { - return this.containerName; - } - -} diff --git a/src/net/java/sip/communicator/service/gui/UIService.java b/src/net/java/sip/communicator/service/gui/UIService.java index 29b136f..3ebc165 100644 --- a/src/net/java/sip/communicator/service/gui/UIService.java +++ b/src/net/java/sip/communicator/service/gui/UIService.java @@ -9,6 +9,7 @@ package net.java.sip.communicator.service.gui; import java.util.*; import net.java.sip.communicator.service.protocol.*; + /** * The <tt>UIService</tt> offers generic access to the graphical user interface * for all modules that would like to interact with the user. @@ -16,7 +17,7 @@ import net.java.sip.communicator.service.protocol.*; * Through the <tt>UIService</tt> all modules can add their own components in * different menus, toolbars, etc. within the ui. Each <tt>UIService</tt> * implementation should export its supported "plugable" containers - a set of - * <tt>ContainerID</tt>s corresponding to different "places" in the application, + * <tt>Container</tt>s corresponding to different "places" in the application, * where a module can add a component. * <p> * The <tt>UIService</tt> provides also methods that would allow to other @@ -42,149 +43,183 @@ import net.java.sip.communicator.service.protocol.*; */ public interface UIService { - /* - * ContainerID-s - */ /** * Main application window "file menu" container. + * @deprecated replaced by {@link Container#CONTAINER_FILE_MENU} */ - public static final ContainerID CONTAINER_FILE_MENU - = new ContainerID("File"); + public static final Container CONTAINER_FILE_MENU + = new Container("File"); /** * Main application window "tools menu" container. + * @deprecated replaced by {@link Container#CONTAINER_TOOLS_MENU} */ - public static final ContainerID CONTAINER_TOOLS_MENU - = new ContainerID("Tools"); + public static final Container CONTAINER_TOOLS_MENU + = new Container("Tools"); /** * Main application window "view menu" container. + * @deprecated replaced by {@link Container#CONTAINER_VIEW_MENU} */ - public static final ContainerID CONTAINER_VIEW_MENU - = new ContainerID("View"); + public static final Container CONTAINER_VIEW_MENU + = new Container("View"); /** * Main application window "help menu" container. + * @deprecated replaced by {@link Container#CONTAINER_HELP_MENU} */ - public static final ContainerID CONTAINER_HELP_MENU - = new ContainerID("Help"); + public static final Container CONTAINER_HELP_MENU + = new Container("Help"); /** * Main application window "settings menu" container. + * @deprecated replaced by {@link Container#CONTAINER_SETTINGS_MENU} */ - public static final ContainerID CONTAINER_SETTINGS_MENU - = new ContainerID("Settings"); + public static final Container CONTAINER_SETTINGS_MENU + = new Container("Settings"); /** * Main application window main toolbar container. + * @deprecated replaced by {@link Container#CONTAINER_MAIN_TOOL_BAR} */ - public static final ContainerID CONTAINER_MAIN_TOOL_BAR - = new ContainerID("MainToolBar"); + public static final Container CONTAINER_MAIN_TOOL_BAR + = new Container("MainToolBar"); /** * Main application window main tabbedpane container. + * @deprecated replaced by {@link Container#CONTAINER_MAIN_TABBED_PANE} */ - public static final ContainerID CONTAINER_MAIN_TABBED_PANE - = new ContainerID("MainTabbedPane"); + public static final Container CONTAINER_MAIN_TABBED_PANE + = new Container("MainTabbedPane"); /** * Chat window toolbar container. + * @deprecated replaced by {@link Container#CONTAINER_CHAT_TOOL_BAR} */ - public static final ContainerID CONTAINER_CHAT_TOOL_BAR - = new ContainerID("ChatToolBar"); + public static final Container CONTAINER_CHAT_TOOL_BAR + = new Container("ChatToolBar"); /** * Main application window "right button menu" over a contact container. + * @deprecated replaced by {@link Container#CONTAINER_CONTACT_RIGHT_BUTTON_MENU} */ - public static final ContainerID CONTAINER_CONTACT_RIGHT_BUTTON_MENU - = new ContainerID("ContactRightButtonMenu"); + public static final Container CONTAINER_CONTACT_RIGHT_BUTTON_MENU + = new Container("ContactRightButtonMenu"); /** * Main application window "right button menu" over a group container. + * @deprecated replaced by {@link Container#CONTAINER_GROUP_RIGHT_BUTTON_MENU} */ - public static final ContainerID CONTAINER_GROUP_RIGHT_BUTTON_MENU - = new ContainerID("GroupRightButtonMenu"); + public static final Container CONTAINER_GROUP_RIGHT_BUTTON_MENU + = new Container("GroupRightButtonMenu"); /** * Chat window "menu bar" container. + * @deprecated replaced by {@link Container#CONTAINER_CHAT_MENU_BAR} */ - public static final ContainerID CONTAINER_CHAT_MENU_BAR - = new ContainerID("ChatMenuBar"); + public static final Container CONTAINER_CHAT_MENU_BAR + = new Container("ChatMenuBar"); /** * Chat window "file menu" container. + * @deprecated replaced by {@link Container#CONTAINER_CHAT_FILE_MENU} */ - public static final ContainerID CONTAINER_CHAT_FILE_MENU - = new ContainerID("ChatFileMenu"); + public static final Container CONTAINER_CHAT_FILE_MENU + = new Container("ChatFileMenu"); /** * Chat window "edit menu" container. + * @deprecated replaced by {@link Container#CONTAINER_CHAT_EDIT_MENU} */ - public static final ContainerID CONTAINER_CHAT_EDIT_MENU - = new ContainerID("ChatEditMenu"); + public static final Container CONTAINER_CHAT_EDIT_MENU + = new Container("ChatEditMenu"); /** * Chat window "settings menu" container. + * @deprecated replaced by {@link Container#CONTAINER_CHAT_SETTINGS_MENU} */ - public static final ContainerID CONTAINER_CHAT_SETTINGS_MENU - = new ContainerID("ChatSettingsMenu"); + public static final Container CONTAINER_CHAT_SETTINGS_MENU + = new Container("ChatSettingsMenu"); /** * Chat window "help menu" container. + * @deprecated replaced by {@link Container#CONTAINER_CHAT_HELP_MENU} */ - public static final ContainerID CONTAINER_CHAT_HELP_MENU - = new ContainerID("ChatHelpMenu"); + public static final Container CONTAINER_CHAT_HELP_MENU + = new Container("ChatHelpMenu"); /** * Chat window "south area" container. + * @deprecated replaced by {@link Container#CONTAINER_CHAT_WINDOW} + * The south location is now indicated with the help of the constraints, + * defined in the <tt>Container<tt>. */ - public static final ContainerID CONTAINER_CHAT_WINDOW_SOUTH - = new ContainerID("ChatWindowSouth"); + public static final Container CONTAINER_CHAT_WINDOW_SOUTH + = new Container("ChatWindowSouth"); /** * Indicates the west area on the left of the contact list. + * @deprecated replaced by {@link Container#CONTAINER_CONTACT_LIST} + * The west location is now indicated with the help of the constraints, + * defined in the <tt>Container<tt>. */ - public static final ContainerID CONTAINER_CONTACT_LIST_WEST - = new ContainerID("ContactListWest"); + public static final Container CONTAINER_CONTACT_LIST_WEST + = new Container("ContactListWest"); /** * Indicates the east area on the right of the contact list. + * @deprecated replaced by {@link Container#CONTAINER_CONTACT_LIST} + * The east location is now indicated with the help of the constraints, + * defined in the <tt>Container<tt>. */ - public static final ContainerID CONTAINER_CONTACT_LIST_EAST - = new ContainerID("ContactListEast"); + public static final Container CONTAINER_CONTACT_LIST_EAST + = new Container("ContactListEast"); /** * Indicates the north area on the top of the contact list. + * @deprecated replaced by {@link Container#CONTAINER_CONTACT_LIST} + * The north location is now indicated with the help of the constraints, + * defined in the <tt>Container<tt>. */ - public static final ContainerID CONTAINER_CONTACT_LIST_NORTH - = new ContainerID("ContactListNorth"); + public static final Container CONTAINER_CONTACT_LIST_NORTH + = new Container("ContactListNorth"); /** * Indicates the south area on the bottom of the contact list. + * @deprecated replaced by {@link Container#CONTAINER_CONTACT_LIST} + * The south location is now indicated with the help of the constraints, + * defined in the <tt>Container<tt>. */ - public static final ContainerID CONTAINER_CONTACT_LIST_SOUTH - = new ContainerID("ContactListSouth"); + public static final Container CONTAINER_CONTACT_LIST_SOUTH + = new Container("ContactListSouth"); /** * Call history panel container. + * @deprecated replaced by {@link Container#CONTAINER_CALL_HISTORY} */ - public static final ContainerID CONTAINER_CALL_HISTORY - = new ContainerID("CallHistoryPanel"); + public static final Container CONTAINER_CALL_HISTORY + = new Container("CallHistoryPanel"); /* * Constraints */ /** * Indicates the most left/top edge of a container. + * @deprecated replaced by {@link Container#START} */ public static final String START = "Start"; /** * Indicates the most right/bottom edge of a container. + * @deprecated replaced by {@link Container#END} */ public static final String END = "End"; /** * Indicates the top edge of a container. + * @deprecated replaced by {@link Container#TOP} */ public static final String TOP = "Top"; /** * Indicates the bottom edge of a container. + * @deprecated replaced by {@link Container#BOTTOM} */ public static final String BOTTOM = "Bottom"; /** * Indicates the left edge of a container. + * @deprecated replaced by {@link Container#LEFT} */ public static final String LEFT = "Left"; /** * Indicates the right edge of a container. + * @deprecated replaced by {@link Container#RIGHT} */ public static final String RIGHT = "Right"; @@ -393,7 +428,7 @@ public interface UIService public AccountRegistrationWizardContainer getAccountRegWizardContainer(); /** - * Adds the specified UI component to the container given by ContainerID. + * Adds the specified UI component to the container given by Container. * The method is meant to be used by plugins or bundles that would like to * add components to the user interface. The <tt>containerID</tt> is used * by the implementation to determine the place where the component should @@ -403,13 +438,13 @@ public interface UIService * library used by it. If this is not the case and adding the requested * object would not be possible the implementation MUST through a * ClassCastException exception. Implementations of this service MUST - * understand and know how to handle all ContainerID-s defined by this + * understand and know how to handle all Container-s defined by this * interface, they MAY also define additional constraints. In case the * addComponent method is called with a <tt>containerID</tt> that the * implementation does not understand it MUST through a * java.lang.IllegalArgumentException. * <br> - * @param containerID One of the CONTAINER_XXX ContainerID-s. + * @param containerID One of the CONTAINER_XXX Container-s. * @param component The component to be added. * @throws ClassCastException if <tt>component</tt> is not an * instance of a class supported by the service implementation. An SWT impl @@ -418,12 +453,19 @@ public interface UIService * @throws IllegalArgumentException if the specified <tt>containerID</tt> * is not recognized by the implementation (note that implementations * MUST properly handle all CONTAINER_XXX containerID-s. - */ - public void addComponent(ContainerID containerID, Object component) + * + * @deprecated replaced by {@link PluginComponent} + * This method should not be used anymore. Instead plugin + * components should implement the <tt>PluginComponent</tt> interface and + * should register their implementations of this interface through the OSGI + * bundle context. + * @see PluginComponent + */ + public void addComponent(Container containerID, Object component) throws ClassCastException, IllegalArgumentException; /** - * Adds the specified UI component to the container given by ContainerID. + * Adds the specified UI component to the container given by Container. * The method is meant to be used by plugins or bundles that would like to * add components to the user interface. The <tt>containerID</tt> is used * by the implementation to determine the place where the component should @@ -434,12 +476,12 @@ public interface UIService * is interested of the current meta contact in the container. * <br> * Implementations of this service MUST understand and know how to handle - * all ContainerID-s defined by this interface, they MAY also define + * all Container-s defined by this interface, they MAY also define * additional constraints. In case the addComponent method is called with a * <tt>containerID</tt> that the implementation does not understand it MUST * through a java.lang.IllegalArgumentException. * <br> - * @param containerID One of the CONTAINER_XXX ContainerID-s. + * @param containerID One of the CONTAINER_XXX Container-s. * @param component The component to be added. * @throws ClassCastException if <tt>component</tt> is not an * instance of a class supported by the service implementation. An SWT impl @@ -448,8 +490,15 @@ public interface UIService * @throws IllegalArgumentException if the specified <tt>containerID</tt> * is not recognized by the implementation (note that implementations * MUST properly handle all CONTAINER_XXX containerID-s. - */ - public void addComponent(ContainerID containerID, + * + * @deprecated replaced by {@link PluginComponent} + * This method should not be used anymore. Instead plugin + * components should implement the <tt>PluginComponent</tt> interface and + * should register their implementations of this interface through the OSGI + * bundle context. + * @see PluginComponent + */ + public void addComponent(Container containerID, ContactAwareComponent component) throws ClassCastException, IllegalArgumentException; @@ -471,12 +520,12 @@ public interface UIService * this is not the case and adding the requested object would not be * possible the implementation MUST through a ClassCastException exception. * Implementations of this service MUST understand and know how to handle - * all ContainerID-s defined by this interface, they MAY also define + * all Container-s defined by this interface, they MAY also define * additional constraints. In case the addComponent method is called with a * <tt>containerID</tt> that the implementation does not understand it MUST * through a java.lang.IllegalArgumentException * <br> - * @param containerID One of the CONTAINER_XXX ContainerID-s. + * @param containerID One of the CONTAINER_XXX Container-s. * @param constraint One of the START, END, BOTTOM, etc. String constants. * @param component The component to be added. * @throws ClassCastException if <tt>component</tt> is not an @@ -486,8 +535,15 @@ public interface UIService * @throws IllegalArgumentException if the specified <tt>containerID</tt> * is not recognized by the implementation (note that implementations * MUST properly handle all CONTAINER_XXX containerID-s. - */ - public void addComponent(ContainerID containerID, + * + * @deprecated replaced by {@link PluginComponent} + * This method should not be used anymore. Instead plugin + * components should implement the <tt>PluginComponent</tt> interface and + * should register their implementations of this interface through the OSGI + * bundle context. + * @see PluginComponent + */ + public void addComponent(Container containerID, String constraint, Object component) throws ClassCastException, IllegalArgumentException; @@ -506,7 +562,7 @@ public interface UIService * The <tt>ContactAwareComponent</tt> is a plugin component that * is interested of the current meta contact in the container. * <br> - * @param containerID One of the CONTAINER_XXX ContainerID-s. + * @param containerID One of the CONTAINER_XXX Container-s. * @param constraint One of the START, END, BOTTOM, etc. String constants. * @param component The component to be added. * @throws ClassCastException if <tt>component</tt> is not an @@ -516,8 +572,15 @@ public interface UIService * @throws IllegalArgumentException if the specified <tt>containerID</tt> * is not recognized by the implementation (note that implementations * MUST properly handle all CONTAINER_XXX containerID-s. - */ - public void addComponent(ContainerID containerID, + * + * @deprecated replaced by {@link PluginComponent} + * This method should not be used anymore. Instead plugin + * components should implement the <tt>PluginComponent</tt> interface and + * should register their implementations of this interface through the OSGI + * bundle context. + * @see PluginComponent + */ + public void addComponent(Container containerID, String constraint, ContactAwareComponent component) throws ClassCastException, IllegalArgumentException; @@ -532,13 +595,20 @@ public interface UIService * implementation to verify that the <tt>component</tt> is really contained * in the specified container. If this is not the case nothing will happen. * <br> - * @param containerID one of the CONTAINER_XXX ContainerID-s + * @param containerID one of the CONTAINER_XXX Container-s * @param component the component to remove * @throws IllegalArgumentException if the specified <tt>containerID</tt> * is not recognized by the implementation (note that implementations * MUST properly handle all CONTAINER_XXX containerID-s. - */ - public void removeComponent(ContainerID containerID, Object component) + * + * @deprecated replaced by {@link PluginComponent} + * This method should not be used anymore. Instead plugin + * components should implement the <tt>PluginComponent</tt> interface and + * should register their implementations of this interface through the OSGI + * bundle context. + * @see PluginComponent + */ + public void removeComponent(Container containerID, Object component) throws IllegalArgumentException; /** @@ -548,24 +618,24 @@ public interface UIService * be used by plugins or bundles that would like to add components to the * user interface. Before adding any component they should use this method * to obtain all possible places, which could contain external components, - * like different menus, toolbars, etc. - * + * like different menus, toolbars, etc. + * * @return Iterator An iterator to a set containing containerID-s * representing all containers supported by the current UI implementation. */ public Iterator getSupportedContainers(); - + /** - * Chechks if the container with the given <tt>ContainerID</tt> is supported + * Chechks if the container with the given <tt>Container</tt> is supported * from the current UI implementation. * - * @param containderID One of the CONTAINER_XXX ContainerID-s. + * @param containderID One of the CONTAINER_XXX Container-s. * @return <code>true</code> if the contaner with the given - * <tt>ContainerID</tt> is supported from the current UI implementation, + * <tt>Container</tt> is supported from the current UI implementation, * <code>false</code> otherwise. */ - public boolean isContainerSupported(ContainerID containderID); - + public boolean isContainerSupported(Container containderID); + /** * Returns an iterator over a set of all constraints supported by the * given <tt>containerID</tt>. Each constraint in the set is one of the @@ -576,8 +646,8 @@ public interface UIService * @return Iterator An iterator to a set containing all component * constraints */ - public Iterator getConstraintsForContainer(ContainerID containerID); - + public Iterator getConstraintsForContainer(Container containerID); + /** * Returns an Iterator over a set of all components added to a given * constraint. Meant to be called in the process of initialization of the @@ -589,6 +659,6 @@ public interface UIService * @return An Iterator to a set containing all components added to a given * constraint. */ - public Iterator getComponentsForContainer(ContainerID containerID) + public Iterator getComponentsForContainer(Container containerID) throws IllegalArgumentException; } diff --git a/src/net/java/sip/communicator/service/gui/event/PluginComponentEvent.java b/src/net/java/sip/communicator/service/gui/event/PluginComponentEvent.java deleted file mode 100644 index feb2295..0000000 --- a/src/net/java/sip/communicator/service/gui/event/PluginComponentEvent.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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.service.gui.event; - -import java.util.*; - -import net.java.sip.communicator.service.gui.*; - -/** - * The <tt>PluginComponentEvent</tt> - * @author Yana Stamcheva - */ -public class PluginComponentEvent - extends EventObject -{ - - private int eventID = -1; - - /** - * Indicates that the PluginComponentEvent instance was triggered by - * adding a plugin component. - */ - public static final int PLUGIN_COMPONENT_ADDED = 1; - - /** - * Indicates that the MetaContactEvent instance was triggered by the - * removal of an existing MetaContact. - */ - public static final int PLUGIN_COMPONENT_REMOVED = 2; - - /** - * The identifier of the container to which or from which the plugin - * component is added or removed. - */ - private ContainerID containerID; - - /** - * Creates a new PluginComponentEvent according to the specified - * parameters. - * @param source The pluginComponent that is added to the container. - * @param containerID The containerID pointing to the container where the - * component is added. - * @param eventID one of the PLUGIN_COMPONENT_XXX static fields indicating - * the nature of the event. - */ - public PluginComponentEvent(Object source, ContainerID containerID, - int eventID) - { - super(source); - this.eventID = eventID; - this.containerID = containerID; - } - - /** - * Returns an event id specifying whether the type of this event - * (PLUGIN_COMPONENT_ADDED or PLUGIN_COMPONENT_REMOVED) - * @return one of the PLUGIN_COMPONENT_XXX int fields of this class. - */ - public int getEventID(){ - return eventID; - } - - /** - * Returns the identifier of the container, where the plugin component, which - * is the source of this event is added or removed. - * - * @return the identifier of the plugin container - */ - public ContainerID getContainerID() - { - return containerID; - } -} diff --git a/src/net/java/sip/communicator/service/gui/event/PluginComponentListener.java b/src/net/java/sip/communicator/service/gui/event/PluginComponentListener.java deleted file mode 100644 index 15565f7..0000000 --- a/src/net/java/sip/communicator/service/gui/event/PluginComponentListener.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.service.gui.event; - -import java.util.*; -/** - * Listens for all events caused by adding or removing of a plugin component. - * - * @author Yana Stamcheva - */ -public interface PluginComponentListener - extends EventListener { - - /** - * Indicates that a plugin component has been successfully added - * to the container. - * @param event the PluginComponentEvent containing the corresponding - * plugin component - */ - public void pluginComponentAdded(PluginComponentEvent event); - - /** - * Indicates that a plugin component has been successfully removed - * from the container. - * @param event the PluginComponentEvent containing the corresponding - * plugin component - */ - public void pluginComponentRemoved(PluginComponentEvent event); -} |