[sip-comm-cvs] CVS update: /sip-communicator/src/net/java/sip/communicator/impl/gui/

yanas at dev.java.net yanas at dev.java.net
Thu Apr 26 23:33:46 CEST 2007


User: yanas   
Date: 2007-04-26 21:33:46+0000
Modified:
   sip-communicator/src/net/java/sip/communicator/impl/gui/GuiActivator.java
   sip-communicator/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java
   sip-communicator/src/net/java/sip/communicator/impl/gui/PopupDialogImpl.java

Log:
 a method was created which is charged with the gui loading

File Changes:

Directory: /sip-communicator/src/net/java/sip/communicator/impl/gui/
====================================================================

File [changed]: GuiActivator.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/src/net/java/sip/communicator/impl/gui/GuiActivator.java?r1=1.27&r2=1.28
Delta lines:  +27 -41
---------------------
--- GuiActivator.java	2007-04-13 14:03:59+0000	1.27
+++ GuiActivator.java	2007-04-26 21:33:43+0000	1.28
@@ -36,16 +36,14 @@
 
     private static UIServiceImpl uiService = null;
 
-    private CommunicatorMain communicatorMain;
-    
-    private LoginManager loginManager;
-
     public static BundleContext bundleContext;
 
     private static ConfigurationService configService;
     
     private static MessageHistoryService msgHistoryService;
     
+    private static MetaContactListService metaCListService;
+    
     private static CallHistoryService callHistoryService;
     
     private static AudioNotifierService audioNotifierService;
@@ -65,26 +63,9 @@
         
         ConfigurationManager.loadGuiConfigurations();
         
-        this.communicatorMain = new CommunicatorMain();
-
-        MainFrame mainFrame = communicatorMain.getMainFrame();
-
-        this.loginManager = new LoginManager(mainFrame);
-
         try {
-            ServiceReference clistReference = bundleContext
-                .getServiceReference(MetaContactListService.class.getName());
-
-            MetaContactListService contactListService
-                = (MetaContactListService) bundleContext
-                    .getService(clistReference);
-
-            mainFrame.setContactList(contactListService);
-            
-            logger.logEntry();
-
-            //Create the ui service
-            this.uiService = new UIServiceImpl(mainFrame);
+            // Create the ui service
+            this.uiService = new UIServiceImpl();
 
             logger.info("UI Service...[  STARTED ]");
 
@@ -93,12 +74,9 @@
 
             logger.info("UI Service ...[REGISTERED]");
             
-            if(ConfigurationManager.isApplicationVisible())
-                mainFrame.setVisible(true);
-            
-            SwingUtilities.invokeLater(new RunLogin());
+            this.uiService.loadApplicationGui();
             
-            uiService.initExportedWindows();
+            logger.logEntry();
         }
         finally {
             logger.logExit();
@@ -120,16 +98,6 @@
     }
 
     /**
-     * The <tt>RunLogin</tt> implements the Runnable interface and is used to
-     * shows the login windows in new thread.
-     */
-    private class RunLogin implements Runnable {
-        public void run() {
-            loginManager.runLogin(communicatorMain.getMainFrame());
-        }
-    }
-
-    /**
      * Returns all <tt>ProtocolProviderFactory</tt>s obtained from the bundle
      * context.
      * @return all <tt>ProtocolProviderFactory</tt>s obtained from the bundle
@@ -225,6 +193,24 @@
     }
     
     /**
+     * Returns the <tt>MetaContactListService</tt> obtained from the bundle
+     * context.
+     * @return the <tt>MetaContactListService</tt> obtained from the bundle
+     * context
+     */
+    public static MetaContactListService getMetaContactListService() {
+        if (metaCListService == null) {
+            ServiceReference clistReference = bundleContext
+                .getServiceReference(MetaContactListService.class.getName());
+    
+            metaCListService = (MetaContactListService) bundleContext
+                    .getService(clistReference);
+        }
+
+        return metaCListService;
+    }
+    
+    /**
      * Returns the <tt>CallHistoryService</tt> obtained from the bundle
      * context.
      * @return the <tt>CallHistoryService</tt> obtained from the bundle

File [changed]: UIServiceImpl.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java?r1=1.31&r2=1.32
Delta lines:  +89 -10
---------------------
--- UIServiceImpl.java	2007-04-11 14:15:54+0000	1.31
+++ UIServiceImpl.java	2007-04-26 21:33:44+0000	1.32
@@ -15,8 +15,11 @@
 import java.util.Map;
 import java.util.Vector;
 
+import javax.swing.*;
 import javax.swing.JFrame;
 
+import net.java.sip.communicator.impl.gui.GuiActivator.*;
+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.AccountRegWizardContainerImpl;
 import net.java.sip.communicator.impl.gui.main.chat.*;
@@ -24,6 +27,7 @@
 import net.java.sip.communicator.impl.gui.main.contactlist.ContactListPanel;
 import net.java.sip.communicator.impl.gui.main.contactlist.addcontact.*;
 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.event.PluginComponentEvent;
@@ -57,12 +61,15 @@
         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);
     }
 
     private static final Hashtable exportedWindows = new Hashtable();
 
     private MainFrame mainFrame;
 
+    private LoginManager loginManager;
+    
     private ContactListPanel contactListPanel;
 
     private ConfigurationFrame configurationFrame;
@@ -74,17 +81,36 @@
      * 
      * @param mainFrame The main application window.
      */
-    public UIServiceImpl(MainFrame mainFrame)
+    public UIServiceImpl()
+    {}
+    
+    /**
+     * Initializes all frames and panels and shows the gui.
+     */
+    public void loadApplicationGui()
     {
-        this.mainFrame = mainFrame;
+        this.setDefaultThemePack();
+        
+        this.mainFrame = new MainFrame();
+        
+        this.loginManager = new LoginManager(mainFrame);
         
         this.contactListPanel = mainFrame.getContactListPanel();
 
-        this.popupDialog = new PopupDialogImpl(mainFrame);
+        this.popupDialog = new PopupDialogImpl();
 
         this.wizardContainer = new AccountRegWizardContainerImpl(mainFrame);
 
         this.configurationFrame = new ConfigurationFrame(mainFrame);        
+        
+        mainFrame.setContactList(GuiActivator.getMetaContactListService());
+        
+        if(ConfigurationManager.isApplicationVisible())
+            SwingUtilities.invokeLater(new RunApplicationGui());
+        
+        SwingUtilities.invokeLater(new RunLoginGui());
+        
+        this.initExportedWindows();
     }
 
     /**
@@ -100,10 +126,8 @@
     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.");
@@ -116,15 +140,12 @@
         }
         else
         {
-
             if (registeredPlugins.containsKey(containerID))
             {
-
                 ((Vector) registeredPlugins.get(containerID)).add(component);
             }
             else
             {
-
                 Vector plugins = new Vector();
                 plugins.add(component);
                 registeredPlugins.put(containerID, plugins);
@@ -132,7 +153,6 @@
             this.firePluginEvent(component, containerID,
                 PluginComponentEvent.PLUGIN_COMPONENT_ADDED);
         }
-
     }
 
     /**
@@ -556,4 +576,63 @@
         return new AuthenticationWindow(mainFrame, protocolProvider,
             realm, userCredentials);
     }
+
+    /**
+     * Returns the LoginManager.
+     * @return the LoginManager
+     */
+    public LoginManager getLoginManager()
+    {
+        return loginManager;
+    }
+
+    /**
+     * Returns the <tt>MainFrame</tt>. This is the class defining the main
+     * application window.
+     * 
+     * @return the <tt>MainFrame</tt>
+     */
+    public MainFrame getMainFrame()
+    {
+        return mainFrame;
+    }
+    
+    /**
+     * The <tt>RunLogin</tt> implements the Runnable interface and is used to
+     * shows the login windows in a seperate thread.
+     */
+    private class RunLoginGui implements Runnable {
+        public void run() {
+            loginManager.runLogin(mainFrame);
+        }
+    }
+    
+    /**
+     * The <tt>RunApplication</tt> implements the Runnable interface and is used to
+     * shows the main application window in a separate thread.
+     */
+    private class RunApplicationGui implements Runnable {
+        public void run() {
+            mainFrame.setVisible(true);
+        }
+    }
+
+    /**
+     * Sets the look&feel and the theme.
+     */
+    private void setDefaultThemePack() {
+
+        SIPCommLookAndFeel lf = new SIPCommLookAndFeel();
+        SIPCommLookAndFeel.setCurrentTheme(new SIPCommDefaultTheme());
+
+        // we need to set the UIDefaults class loader so that it may access
+        // resources packed inside OSGI bundles
+        UIManager.put("ClassLoader", getClass().getClassLoader());
+        try {
+            UIManager.setLookAndFeel(lf);
+        } catch (UnsupportedLookAndFeelException e) {
+            logger.error("The provided Look & Feel is not supported.", e);
+        }
+    }
+
 }

File [changed]: PopupDialogImpl.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/src/net/java/sip/communicator/impl/gui/PopupDialogImpl.java?r1=1.7&r2=1.8
Delta lines:  +15 -19
---------------------
--- PopupDialogImpl.java	2007-04-11 14:15:54+0000	1.7
+++ PopupDialogImpl.java	2007-04-26 21:33:44+0000	1.8
@@ -16,17 +16,15 @@
  * 
  * @author Yana Stamcheva
  */
-public class PopupDialogImpl extends JOptionPane
-    implements PopupDialog {
-
-    private MainFrame parentWindow;
-    
+public class PopupDialogImpl
+    extends JOptionPane
+    implements PopupDialog
+{    
     /**
      * Creates an instance of <tt>PopupDialogImpl</tt>.
-     * @param parentWindow The main application window.
      */
-    public PopupDialogImpl(MainFrame parentWindow) {
-        this.parentWindow = parentWindow;
+    public PopupDialogImpl()
+    {
     }
     
     /**
@@ -34,7 +32,7 @@
      * Invokes the corresponding <tt>JOptionPane.showInputDialog</tt> method.
      */
     public String showInputPopupDialog(Object message) {
-        return showInputDialog(parentWindow, message);
+        return showInputDialog(message);
     }
     
     /**
@@ -44,8 +42,7 @@
      */
     public String showInputPopupDialog(Object message, 
             String initialSelectionValue) {
-        return showInputDialog(parentWindow, message, 
-                initialSelectionValue);
+        return showInputDialog(message, initialSelectionValue);
     }    
     
     /**
@@ -72,8 +69,7 @@
         else {
             type = JOptionPane.PLAIN_MESSAGE;
         }
-        return (String)showInputDialog(parentWindow, message,
-                title, type);
+        return (String)showInputDialog(null, message, title, type);
     }
 
     /**
@@ -103,7 +99,7 @@
             type = JOptionPane.PLAIN_MESSAGE;
         }
         
-       return showInputDialog(parentWindow, message, title, type, 
+       return showInputDialog(null, message, title, type, 
                null, selectionValues, initialSelectionValue);
     }
 
@@ -113,7 +109,7 @@
      * <tt>JOptionPane.showMessageDialog</tt> method.
      */
     public void showMessagePopupDialog(Object message) {
-        showMessageDialog(parentWindow, message);
+        showMessageDialog(null, message);
     }
 
     /**
@@ -140,7 +136,7 @@
             type = JOptionPane.PLAIN_MESSAGE;
         }
         
-        showMessageDialog(parentWindow, message, title, type);
+        showMessageDialog(null, message, title, type);
     }
 
     /**
@@ -149,7 +145,7 @@
      * <tt>JOptionPane.showConfirmDialog</tt> method.
      */
     public int showConfirmPopupDialog(Object message) {
-        return showConfirmDialog(parentWindow, message);
+        return showConfirmDialog(null, message);
     }
 
     /**
@@ -173,7 +169,7 @@
             type = JOptionPane.DEFAULT_OPTION;
         }
         
-        return showConfirmDialog(parentWindow, message, title, type);
+        return showConfirmDialog(null, message, title, type);
     }
 
     /**
@@ -215,7 +211,7 @@
             msgType = JOptionPane.PLAIN_MESSAGE;
         }
         
-        return showConfirmDialog(parentWindow, message, title,
+        return showConfirmDialog(null, message, title,
                 optType, msgType);
     }
     




---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe at sip-communicator.dev.java.net
For additional commands, e-mail: cvs-help at sip-communicator.dev.java.net





More information about the commits mailing list