UIServiceImpl work in progress

cusax-fix
Yana Stamcheva 20 years ago
parent ec24075095
commit 4ef36087d3

@ -1,83 +0,0 @@
package net.java.sip.communicator.impl.gui;
import javax.swing.SwingUtilities;
import net.java.sip.communicator.impl.gui.main.CommunicatorMain;
import net.java.sip.communicator.impl.gui.main.login.LoginManager;
import net.java.sip.communicator.service.contactlist.MetaContactListService;
import net.java.sip.communicator.service.gui.UIService;
import net.java.sip.communicator.util.Logger;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
public class Activator implements BundleActivator
{
private Logger logger = Logger.getLogger(Activator.class.getName());
private UIService uiService = null;
private CommunicatorMain communicatorMain = new CommunicatorMain();
private LoginManager loginManager;
public void start(BundleContext bundleContext) throws Exception
{
this.loginManager = new LoginManager(bundleContext);
this.loginManager.setMainFrame(communicatorMain.getMainFrame());
try
{
ServiceReference clistReference
= bundleContext.getServiceReference
(MetaContactListService.class.getName());
MetaContactListService contactListService
= (MetaContactListService)bundleContext
.getService(clistReference);
logger.logEntry();
//Create the ui service
this.uiService =
new UIServiceImpl();
logger.info("UI Service...[ STARTED ]");
bundleContext.registerService(
UIService.class.getName(), this.uiService, null);
logger.info("UI Service ...[REGISTERED]");
this.communicatorMain.getMainFrame()
.setContactList(contactListService);
this.communicatorMain.showCommunicator();
SwingUtilities.invokeLater(new RunLogin());
}
finally
{
logger.logExit();
}
}
public void stop(BundleContext bundleContext) throws Exception
{
logger.info("UI Service ...[STOPED]");
}
private class RunLogin implements Runnable {
public void run() {
loginManager.showLoginWindows(communicatorMain.getMainFrame());
}
}
}

@ -1,8 +1,13 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.gui;
import javax.swing.SwingUtilities;
import net.java.sip.communicator.impl.gui.main.CommunicatorMain;
import net.java.sip.communicator.impl.gui.main.WelcomeWindow;
import net.java.sip.communicator.impl.gui.main.login.LoginManager;
import net.java.sip.communicator.service.contactlist.MetaContactListService;
import net.java.sip.communicator.service.gui.UIService;
@ -12,7 +17,6 @@
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
public class GuiActivator implements BundleActivator
{
private Logger logger = Logger.getLogger(GuiActivator.class.getName());
@ -56,10 +60,17 @@ public void start(BundleContext bundleContext) throws Exception
this.communicatorMain.getMainFrame()
.setContactList(contactListService);
this.communicatorMain.showCommunicator();
SwingUtilities.invokeLater(new RunLogin());
/*
* TO BE UNCOMMENTED when the welcome window is removed.
* this.uiService.setVisible(true);
* SwingUtilities.invokeLater(new RunLogin());
*/
WelcomeWindow welcomeWindow
= new WelcomeWindow(communicatorMain, loginManager);
welcomeWindow.showWindow();
}
finally
{

@ -1,81 +1,143 @@
package net.java.sip.communicator.impl.gui;
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
import java.util.Iterator;
package net.java.sip.communicator.impl.gui;
import net.java.sip.communicator.service.gui.ConfigurationContainer;
import net.java.sip.communicator.service.gui.UIService;
import net.java.sip.communicator.service.protocol.Call;
import net.java.sip.communicator.service.protocol.ProtocolProviderService;
import java.awt.Component;
import java.util.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.gui.event.*;
import net.java.sip.communicator.util.Logger;
public class UIServiceImpl implements UIService {
public UIServiceImpl(){
}
public void registerProvider(ProtocolProviderService provider) {
// TODO Auto-generated method stub
}
public void setVisible(boolean visible) {
// TODO Auto-generated method stub
}
public Call[] getActiveCalls() {
// TODO Auto-generated method stub
return null;
}
public String getUiLibName() {
// TODO Auto-generated method stub
return null;
}
public String[] getSupportedUiLibNames() {
// TODO Auto-generated methodUIServiceImpl stub
return null;
}
public void addMenuItem(String parent, Object menuItem)
throws ClassCastException, IllegalArgumentException {
// TODO Auto-generated method stub
}
public void addComponent(Object component, String constraint)
throws ClassCastException, IllegalArgumentException {
// TODO Auto-generated method stub
}
public void addUserActionListener() {
// TODO Auto-generated method stub
}
public void requestAuthentication(String realm, String userName,
char[] password) {
// TODO Auto-generated method stub
private static final Logger logger = Logger
.getLogger(UIServiceImpl.class);
private Map registeredPlugins = new Hashtable();
private Vector containerPluginListeners = new Vector();
private static final List supportedContainers = new ArrayList();
static{
supportedContainers.add(UIService.CONTAINER_MAIN_TOOL_BAR);
supportedContainers.add(UIService.CONTAINER_CHAT_TOOL_BAR);
supportedContainers.add(UIService.CONTAINER_CHAT_NEW_TOOL_BAR);
}
/**
* Implements addComponent in UIService interface.
* @see UIService#addComponent(ContainerID, Object)
*/
public void addComponent(ContainerID containerID, Object component)
throws ClassCastException, IllegalArgumentException {
if(!supportedContainers.contains(containerID))
throw new IllegalArgumentException
("The constraint that you specified is not"
+ " supported by this UIService implementation.");
else if(!(component instanceof Component)){
throw new ClassCastException
("The specified plugin is not a valid swing or awt component.");
}
else{
if(registeredPlugins.containsKey(containerID)){
((Vector)registeredPlugins.get(containerID)).add(component);
}
else{
Vector plugins = new Vector();
plugins.add(component);
registeredPlugins.put(containerID, plugins);
}
this.firePluginEvent(component, containerID,
PluginComponentEvent.PLUGIN_COMPONENT_ADDED);
}
}
}
/**
* Implements getSupportedConstraints in UIService interface.
* @see UIService#getSupportedConstraints()
*/
public Iterator getSupportedContainers() {
return Collections.unmodifiableList(supportedContainers).iterator();
}
public String getAuthenticationUserName() {
// TODO Auto-generated method stub
return null;
}
/**
* Implements getComponentsForConstraint in UIService interface.
* @see UIService#getComponentsForConstraint(String)
*/
public Iterator getComponentsForContainer(ContainerID containerID)
throws IllegalArgumentException {
Vector plugins = (Vector)this.registeredPlugins.get(containerID);
if(plugins != null)
return plugins.iterator();
else
throw new IllegalArgumentException("The container that you specified is not "
+ "supported by this UIService implementation.");
}
public ConfigurationContainer getConfigurationContainer() {
return null;
}
/**
* For now this method only invokes addComponent(containerID, component).
*/
public void addComponent(ContainerID containerID, String constraint, Object component)
throws ClassCastException, IllegalArgumentException {
this.addComponent(containerID, component);
}
public Iterator getSupportedConstraints() {
// TODO Auto-generated method stub
/**
* Not yet implemented.
*/
public Iterator getConstraintsForContainer(ContainerID containerID) {
return null;
}
/**
* Creates the corresponding PluginComponentEvent and notifies all
* <tt>ContainerPluginListener</tt>s that a plugin component is added or
* removed from the container.
*
* @param pluginComponent the plugin component that is added to the
* container.
* @param containerID the containerID that corresponds to the container where
* the component is added.
* @param eventID
* one of the PLUGIN_COMPONENT_XXX static fields indicating the
* nature of the event.
*/
private void firePluginEvent(Object pluginComponent, ContainerID containerID,
int eventID)
{
PluginComponentEvent evt
= new PluginComponentEvent(pluginComponent, containerID, eventID);
logger.trace("Will dispatch the following plugin component event: " + evt);
synchronized (containerPluginListeners)
{
Iterator listeners = this.containerPluginListeners.iterator();
while (listeners.hasNext())
{
ContainerPluginListener l = (ContainerPluginListener) listeners.next();
switch (evt.getEventID())
{
case PluginComponentEvent.PLUGIN_COMPONENT_ADDED:
l.pluginComponentAdded(evt);
break;
case PluginComponentEvent.PLUGIN_COMPONENT_REMOVED:
l.pluginComponentRemoved(evt);
break;
default:
logger.error("Unknown event type " + evt.getEventID());
}
}
}
}
}

Loading…
Cancel
Save