|
|
|
|
@ -1,8 +1,7 @@
|
|
|
|
|
/*
|
|
|
|
|
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
|
|
|
|
*
|
|
|
|
|
* Distributable under LGPL license.
|
|
|
|
|
* See terms of license at gnu.org.
|
|
|
|
|
*
|
|
|
|
|
* Distributable under LGPL license. See terms of license at gnu.org.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package net.java.sip.communicator.impl.gui.main.chat.menus;
|
|
|
|
|
@ -11,16 +10,28 @@
|
|
|
|
|
|
|
|
|
|
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.main.chat.*;
|
|
|
|
|
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.util.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The <tt>MessageWindowMenuBar</tt> is the menu bar in the chat window where
|
|
|
|
|
* The <tt>MessageWindowMenuBar</tt> is the menu bar in the chat window where
|
|
|
|
|
* all menus are added.
|
|
|
|
|
*
|
|
|
|
|
* @author Yana Stamcheva
|
|
|
|
|
*/
|
|
|
|
|
public class MessageWindowMenuBar extends JMenuBar {
|
|
|
|
|
public class MessageWindowMenuBar
|
|
|
|
|
extends JMenuBar
|
|
|
|
|
implements PluginComponentListener
|
|
|
|
|
{
|
|
|
|
|
private Logger logger = Logger.getLogger(MessageWindowMenuBar.class);
|
|
|
|
|
|
|
|
|
|
private FileMenu fileMenu;
|
|
|
|
|
|
|
|
|
|
@ -32,9 +43,11 @@ public class MessageWindowMenuBar extends JMenuBar {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates an instance of <tt>MessageWindowMenuBar</tt>.
|
|
|
|
|
*
|
|
|
|
|
* @param parentWindow The parent ChatWindow.
|
|
|
|
|
*/
|
|
|
|
|
public MessageWindowMenuBar(ChatWindow parentWindow) {
|
|
|
|
|
public MessageWindowMenuBar(ChatWindow parentWindow)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
this.parentWindow = parentWindow;
|
|
|
|
|
|
|
|
|
|
@ -45,12 +58,15 @@ public MessageWindowMenuBar(ChatWindow parentWindow) {
|
|
|
|
|
helpMenu = new HelpMenu(this.parentWindow);
|
|
|
|
|
|
|
|
|
|
this.init();
|
|
|
|
|
|
|
|
|
|
this.initPluginComponents();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Initializes the menu bar, by adding all contained menus.
|
|
|
|
|
*/
|
|
|
|
|
private void init() {
|
|
|
|
|
private void init()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
this.add(fileMenu);
|
|
|
|
|
|
|
|
|
|
@ -58,18 +74,20 @@ private void init() {
|
|
|
|
|
|
|
|
|
|
this.add(helpMenu);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the currently selected menu.
|
|
|
|
|
* Returns the currently selected menu.
|
|
|
|
|
*/
|
|
|
|
|
public SIPCommMenu getSelectedMenu()
|
|
|
|
|
{
|
|
|
|
|
int menuCount = this.getMenuCount();
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < menuCount; i ++) {
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < menuCount; i++)
|
|
|
|
|
{
|
|
|
|
|
SIPCommMenu menu = (SIPCommMenu) this.getMenu(i);
|
|
|
|
|
|
|
|
|
|
if(menu.isSelected()) {
|
|
|
|
|
|
|
|
|
|
if (menu.isSelected())
|
|
|
|
|
{
|
|
|
|
|
return menu;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -85,9 +103,70 @@ public void paintComponent(Graphics g)
|
|
|
|
|
{
|
|
|
|
|
super.paintComponent(g);
|
|
|
|
|
|
|
|
|
|
Image backgroundImage
|
|
|
|
|
= ImageLoader.getImage(ImageLoader.MENU_BACKGROUND);
|
|
|
|
|
Image backgroundImage =
|
|
|
|
|
ImageLoader.getImage(ImageLoader.MENU_BACKGROUND);
|
|
|
|
|
|
|
|
|
|
g.drawImage(backgroundImage, 0, 0, getWidth(), getHeight(), null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Initialize plugin components already registered for this container.
|
|
|
|
|
*/
|
|
|
|
|
private void initPluginComponents()
|
|
|
|
|
{
|
|
|
|
|
// Search for plugin components registered through the OSGI bundle
|
|
|
|
|
// context.
|
|
|
|
|
ServiceReference[] serRefs = null;
|
|
|
|
|
|
|
|
|
|
String osgiFilter = "("
|
|
|
|
|
+ Container.CONTAINER_ID
|
|
|
|
|
+ "="+Container.CONTAINER_CHAT_MENU_BAR.getID()+")";
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
serRefs = GuiActivator.bundleContext.getServiceReferences(
|
|
|
|
|
PluginComponent.class.getName(),
|
|
|
|
|
osgiFilter);
|
|
|
|
|
}
|
|
|
|
|
catch (InvalidSyntaxException exc)
|
|
|
|
|
{
|
|
|
|
|
logger.error("Could not obtain plugin reference.", exc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (serRefs != null)
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void pluginComponentAdded(PluginComponentEvent event)
|
|
|
|
|
{
|
|
|
|
|
PluginComponent c = event.getPluginComponent();
|
|
|
|
|
|
|
|
|
|
if (c.getContainer().equals(Container.CONTAINER_CHAT_MENU_BAR))
|
|
|
|
|
{
|
|
|
|
|
this.add((Component) c.getComponent());
|
|
|
|
|
|
|
|
|
|
this.revalidate();
|
|
|
|
|
this.repaint();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void pluginComponentRemoved(PluginComponentEvent event)
|
|
|
|
|
{
|
|
|
|
|
PluginComponent c = event.getPluginComponent();
|
|
|
|
|
|
|
|
|
|
if (c.getContainer().equals(Container.CONTAINER_CHAT_MENU_BAR))
|
|
|
|
|
{
|
|
|
|
|
this.remove((Component) c.getComponent());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|