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

yanas at dev.java.net yanas at dev.java.net
Thu Apr 26 23:34:32 CEST 2007


User: yanas   
Date: 2007-04-26 21:34:32+0000
Removed:
   sip-communicator/src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommList.java
   sip-communicator/src/net/java/sip/communicator/impl/gui/customcontrols/ListCellPanel.java
   sip-communicator/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigMenuItemPanel.java

Added:
   sip-communicator/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigFormListCellRenderer.java
   sip-communicator/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigFormList.java

Modified:
   sip-communicator/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigurationFrame.java

Log:
 ConfigurationFrame enhancements

File Changes:

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

File [removed]: SIPCommList.java

File [removed]: ListCellPanel.java

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

File [added]: ConfigFormListCellRenderer.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigFormListCellRenderer.java?rev=1.1&content-type=text/vnd.viewcvs-markup
Added lines: 157
----------------
/*
 * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

package net.java.sip.communicator.impl.gui.main.configforms;

import java.awt.*;

import javax.swing.*;

import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.gui.*;

/**
 * The <tt>ContactListCellRenderer</tt> is the custom cell renderer used in the
 * SIP-Communicator's <tt>ContactList</tt>. It extends JPanel instead of JLabel,
 * which allows adding different buttons and icons to the contact cell.
 * The cell border and background are repainted. 
 * 
 * @author Yana Stamcheva
 */
public class ConfigFormListCellRenderer extends JPanel 
    implements ListCellRenderer
{
    /**
     * The size of the gradient used for painting the selected background of
     * some components.
     */
    public static final int SELECTED_GRADIENT_SIZE = 5;

    /**
     * The start color used to paint a gradient selected background.
     */
    private static final Color SELECTED_END_COLOR
        = new Color(240, 240, 240);

    /**
     * The end color used to paint a gradient selected background.
     */
    private static final Color SELECTED_START_COLOR
        = new Color(209, 212, 225);
    
    private JLabel textLabel = new JLabel();

    private JLabel iconLabel = new JLabel();

    private boolean isSelected = false;
    
    /**
     * Initialize the panel containing the node.
     */
    public ConfigFormListCellRenderer()
    {
        this.setBackground(Color.WHITE);

        this.setOpaque(true);
        
        this.setPreferredSize(new Dimension(80, 50));

        this.setLayout(new GridLayout(0, 1));

        this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

        this.textLabel.setFont(this.getFont().deriveFont(Font.BOLD, 10));
        
        this.iconLabel.setHorizontalAlignment(JLabel.CENTER);
        
        this.textLabel.setHorizontalAlignment(JLabel.CENTER);
        
        this.add(iconLabel);

        this.add(textLabel);
    }

    /**
     * Implements the <tt>ListCellRenderer</tt> method.
     * 
     * Returns this panel that has been configured to display the meta contact
     * and meta contact group cells.
     */
    public Component getListCellRendererComponent(JList list, Object value,
            int index, boolean isSelected, boolean cellHasFocus)
    {
        ConfigurationForm configForm = (ConfigurationForm) value;
        
        byte[] configFormIcon = configForm.getIcon();
        
        if(configFormIcon != null)            
            iconLabel.setIcon(new ImageIcon(ImageLoader.getBytesInImage(
                    configFormIcon)));
        
        textLabel.setText(configForm.getTitle());
        
        this.isSelected = isSelected;

        return this;
    }
    
        
    /**
     * Paint a background for all groups and a round blue border and background
     * when a cell is selected. 
     */
    /**
     * Overrides the <code>paintComponent</code> method of <tt>JPanel</tt>
     * to provide a custom look for this panel. A gradient background is
     * painted when the panel is selected and when the mouse is over it.
     */
    public void paintComponent(Graphics g) {
        super.paintComponent(g);

        Graphics2D g2 = (Graphics2D) g;

        if (isSelected)
        {
            GradientPaint p = new GradientPaint(this.getWidth() / 2, 0,
                    SELECTED_START_COLOR, this
                            .getWidth() / 2,
                    SELECTED_GRADIENT_SIZE,
                    SELECTED_END_COLOR);

            GradientPaint p1 = new GradientPaint(this.getWidth() / 2, this
                    .getHeight()
                    - SELECTED_GRADIENT_SIZE,
                    SELECTED_END_COLOR,
                    this.getWidth() / 2, this.getHeight() - 1,
                    SELECTED_START_COLOR);

            g2.setPaint(p);
            g2.fillRect(0, 0, this.getWidth(),
                    SELECTED_GRADIENT_SIZE);

            g2.setColor(SELECTED_END_COLOR);
            g2.fillRect(0, SELECTED_GRADIENT_SIZE, this
                    .getWidth(), this.getHeight()
                    - SELECTED_GRADIENT_SIZE);

            g2.setPaint(p1);
            g2.fillRect(0, this.getHeight()
                    - SELECTED_GRADIENT_SIZE, this
                    .getWidth(), this.getHeight() - 1);

            g2.setColor(Constants.BLUE_GRAY_BORDER_DARKER_COLOR);
            g2.drawRoundRect(0, 0, this.getWidth() - 1, this.getHeight() - 1,
                    5, 5);
        }
        else
        {
            g2.setColor(SELECTED_START_COLOR);
            g2.drawLine(0, this.getHeight() - 1,
                    this.getWidth(), this.getHeight() - 1);
        }
    }
}

File [added]: ConfigFormList.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigFormList.java?rev=1.1&content-type=text/vnd.viewcvs-markup
Added lines: 69
---------------
/*
 * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

package net.java.sip.communicator.impl.gui.main.configforms;

import javax.swing.*;
import javax.swing.event.*;

import net.java.sip.communicator.service.gui.*;

/**
 * The list containing all <tt>ConfigurationForm</tt>s.
 * 
 * @author Yana Stamcheva
 */
public class ConfigFormList
    extends JList
    implements ListSelectionListener
{
    private DefaultListModel listModel = new DefaultListModel();
    
    private ConfigurationFrame configFrame;
    
    /**
     * Creates an instance of <tt>ConfigFormList</tt>
     */
    public ConfigFormList(ConfigurationFrame configFrame)
    {
        this.configFrame = configFrame;
        
        this.setCellRenderer(new ConfigFormListCellRenderer());
        this.setModel(listModel);
        
        this.addListSelectionListener(this);
    }

    /**
     * Adds a new <tt>ConfigurationForm</tt> to this list. 
     * @param configForm The <tt>ConfigurationForm</tt> to add.
     */
    public void addConfigForm(ConfigurationForm configForm)
    {
        listModel.addElement(configForm);
    }

    /**
     * Removes a <tt>ConfigurationForm</tt> from this list. 
     * @param configForm The <tt>ConfigurationForm</tt> to remove.
     */
    public void removeConfigForm(ConfigurationForm configForm)
    {
        listModel.removeElement(configForm);
    }

    public void valueChanged(ListSelectionEvent e)
    {
        if(!e.getValueIsAdjusting())
        {
            ConfigurationForm configForm
                = (ConfigurationForm) this.getSelectedValue();
            
            configFrame.showFormContent(configForm);
        }
    }
}

File [removed]: ConfigMenuItemPanel.java

File [changed]: ConfigurationFrame.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigurationFrame.java?r1=1.25&r2=1.26
Delta lines:  +51 -121
----------------------
--- ConfigurationFrame.java	2007-04-11 14:15:54+0000	1.25
+++ ConfigurationFrame.java	2007-04-26 21:34:29+0000	1.26
@@ -27,14 +27,9 @@
  */
 public class ConfigurationFrame
     extends SIPCommDialog
-    implements  ConfigurationWindow, 
-                MouseListener
+    implements  ConfigurationWindow
 {
-    private Vector configContainer = new Vector();
-
-    private JScrollPane formScrollPane = new JScrollPane();
-
-    private SIPCommList configList = new SIPCommList();
+    private ConfigFormList configList;
 
     private TitlePanel titlePanel = new TitlePanel();
 
@@ -61,14 +56,14 @@
        
         this.mainFrame = mainFrame;
 
+        this.configList = new ConfigFormList(this);
+
         this.setTitle(Messages.getI18NString("configuration").getText());
         
         this.getContentPane().setLayout(new BorderLayout());
 
         this.addDefaultForms();
 
-        this.centerPanel.add(formScrollPane, BorderLayout.CENTER);
-
         this.mainPanel.add(centerPanel, BorderLayout.CENTER);
 
         this.mainPanel.add(configList, BorderLayout.WEST);
@@ -94,9 +89,8 @@
      * Some configuration forms constructed from the ui implementation itself
      * are added here in the configuration dialog.
      */
-    public void addDefaultForms() {
-        //this.addConfigurationForm(new GeneralConfigurationForm());
-        //this.addConfigurationForm(new AppearanceConfigurationForm());
+    public void addDefaultForms()
+    {
         this.addConfigurationForm(
                 new AccountsConfigurationForm(mainFrame));
     }
@@ -110,26 +104,12 @@
      */
     public void addConfigurationForm(ConfigurationForm configForm) {
 
-        if(configForm.getForm() instanceof Component) {
-            this.configContainer.add(configForm);
-    
-            this.recalculateSize();
-            
-            Icon image = null;
-            try {
-                image = new ImageIcon(ImageIO.read(
-                        new ByteArrayInputStream(configForm.getIcon())));
-            }
-            catch (IOException e) {
-                e.printStackTrace();
-            }
-            
-            ConfigMenuItemPanel configItem = new ConfigMenuItemPanel(configForm
-                    .getTitle(), image);
+        if(configForm.getForm() instanceof Component)
+        {
+            this.configList.addConfigForm(configForm);
     
-            configItem.addMouseListener(this);
+//            this.recalculateSize();
     
-            this.configList.addCell(configItem);
         }
         else {
             throw new ClassCastException("ConfigurationFrame :"
@@ -144,90 +124,54 @@
      * dialog.
      * @see ConfigurationWindow#removeConfigurationForm(ConfigurationForm)
      */
-    public void removeConfigurationForm(ConfigurationForm configForm) {
-
-        this.configContainer.remove(configForm);
-    }
-
-    /**
-     * Calculates the size of the frame depending on the size of the largest
-     * contained form.
-     */
-    public void recalculateSize()
+    public void removeConfigurationForm(ConfigurationForm configForm)
     {
-        double width = 0;
-
-        double height = 0;
-
-        for (int i = 0; i < configContainer.size(); i++) {
-
-            ConfigurationForm configForm = (ConfigurationForm) configContainer
-                    .get(i);
-            
-            Component form = (Component)configForm.getForm();
-            if (width < form.getPreferredSize().getWidth())
-                width = form.getPreferredSize().getWidth();
-
-            if (height < form.getPreferredSize().getHeight())
-                height = form.getPreferredSize().getHeight();
-        }
-     
-        this.mainPanel.setPreferredSize(new Dimension(
-            (int) width + 150, (int) height + 100));
+        this.configList.removeConfigForm(configForm);
     }
 
-    /**
-     * Handles the <tt>MouseEvent</tt> triggered when user clicks on the left
-     * configuration dialog menu. Here we display the corresponding
-     * configuration form.
-     */
-    public void mouseClicked(MouseEvent e) {
-
-        ConfigMenuItemPanel configItemPanel = (ConfigMenuItemPanel) e
-                .getSource();
-
-        this.configList.refreshCellStatus(configItemPanel);
-
-        if ((e.getModifiers() & InputEvent.BUTTON1_MASK) 
-                == InputEvent.BUTTON1_MASK) {
-
-            for (int i = 0; i < this.configContainer.size(); i++) {
-
-                ConfigurationForm configForm 
-                    = (ConfigurationForm) this.configContainer.get(i);
-
-                if (configItemPanel.getText().equals(configForm.getTitle())) {
-
-                    this.formScrollPane.getViewport().removeAll();
-
-                    this.formScrollPane.getViewport()
-                        .add((Component)configForm.getForm());
-
-                    this.titlePanel.removeAll();
+    public void showFormContent(ConfigurationForm configForm)
+    {
+        this.centerPanel.removeAll();
 
                     this.titlePanel.setTitleText(configForm.getTitle());
 
-                    this.centerPanel.remove(titlePanel);
-
                     this.centerPanel.add(titlePanel, BorderLayout.NORTH);
 
-                    this.validate();
-                }
-            }
-        }
-    }
+        this.centerPanel.add((Component)configForm.getForm(),
+                BorderLayout.CENTER);
 
-    public void mouseEntered(MouseEvent e) {
-    }
+        this.centerPanel.revalidate();
+        this.centerPanel.repaint();
 
-    public void mouseExited(MouseEvent e) {
     }
 
-    public void mousePressed(MouseEvent e) {
-    }
 
-    public void mouseReleased(MouseEvent e) {
-    }
+    /**
+     * Calculates the size of the frame depending on the size of the largest
+     * contained form.
+     */
+//    public void recalculateSize()
+//    {
+//        double width = 0;
+//
+//        double height = 0;
+//
+//        for (int i = 0; i < configList.getSize(); i++)
+//        {
+//            ConfigurationForm configForm = (ConfigurationForm) configContainer
+//                    .get(i);
+//            
+//            Component form = (Component)configForm.getForm();
+//            if (width < form.getPreferredSize().getWidth())
+//                width = form.getPreferredSize().getWidth();
+//
+//            if (height < form.getPreferredSize().getHeight())
+//                height = form.getPreferredSize().getHeight();
+//        }
+//     
+//        this.mainPanel.setPreferredSize(new Dimension(
+//            (int) width + 150, (int) height + 100));
+//    }
 
     /**
      * Implements <code>ApplicationWindow.show</code> method.
@@ -237,21 +181,7 @@
     {
         if(isVisible)
         {
-            ConfigurationForm configForm 
-                = (ConfigurationForm) this.configContainer.get(0);
-            
-            this.formScrollPane.getViewport().removeAll();
-    
-            this.formScrollPane.getViewport()
-                .add((Component)configForm.getForm());
-    
-            this.titlePanel.removeAll();
-            
-            this.titlePanel.setTitleText(configForm.getTitle());
-    
-            this.centerPanel.remove(titlePanel);
-    
-            this.centerPanel.add(titlePanel, BorderLayout.NORTH);
+            this.configList.setSelectedIndex(0);
             
             super.setVisible(true);
             




---------------------------------------------------------------------
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