Coverage details for base.jdbs.ui.panel.NetworkConfigurationPanel

LineHitsSource
1 /*******************************************************************************
2  *InternetCafe is a software solution that helps the management of Cybercafes
3  * according with the ITALIAN DECREE LAW ON ANTI-TERROR MEASURES, 27 JULY 2005.
4  * Copyright (C) 2006 Guido Angelo Ingenito
5  
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *******************************************************************************/
20  
21 package base.jdbs.ui.panel;
22  
23 import java.awt.BorderLayout;
24 import java.awt.GridLayout;
25 import java.awt.event.ActionEvent;
26 import java.awt.event.ActionListener;
27  
28 import javax.swing.JComboBox;
29 import javax.swing.JPanel;
30 import javax.swing.border.TitledBorder;
31  
32 import org.apache.log4j.Logger;
33  
34 import base.jdbs.ConfigurationManager;
35 import base.jdbs.NetworkConnectionType;
36  
37 /**
38  * @author skunk
39  *
40  */
410@SuppressWarnings("serial")
420public class NetworkConfigurationPanel extends JPanel {
430 
440    private static final transient Logger logger = Logger
45             .getLogger(NetworkConfigurationPanel.class.getName());
46  
47     /**
48      * This is the panel where will be shown the default replication level for
49      * each created backup artifact.*
50      */
51     private JPanel replicationLevelPanel;
52  
53     private JComboBox replicationLevelComboBox;
54  
55     /**
56      * This is the defalut number of upload slots to be grant to other jdbs
57      * users.*
58      */
590    private JPanel uploadSlotPanel;
60  
61     private JComboBox uploadSlotComboBox;
620 
630    /** This is the default number of download slots to be grant to the peer.* */
640    private JPanel downloadSlotPanel;
65  
66     private JComboBox downloadSlotComboBox;
670 
680    /** This is the peer connection type, one between LAN T1, T2, 56Kb etc...* */
690    private JPanel connectionTypePanel;
700 
710    private JComboBox connectionTypeComboBox;
720 
730    public NetworkConfigurationPanel() {
740        initialize();
750    }
76  
77     protected void initialize() {
780        this.setBorder(new TitledBorder("Network Configuration Paramenters"));
790        this.setLayout(new GridLayout(4, 1));
800        this.add(this.getReplicationLevelPanel());
810        this.add(this.getUploadSlotPanel());
820        this.add(this.getDownloadSlotPanel());
830        this.add(this.getConnectionTypePanel());
840    }
85  
86     /**
87      * @return the downloadSlotComboBox
88      */
89     protected JComboBox getDownloadSlotComboBox() {
900        if (this.downloadSlotComboBox == null) {
910            this.downloadSlotComboBox = new JComboBox();
920            for (int i = 0; i < 10; i++)
930                this.downloadSlotComboBox.addItem(i);
940        }
950        return downloadSlotComboBox;
96     }
970 
98     /**
99      * @return the downloadSlotPanel
100      */
101     protected JPanel getDownloadSlotPanel() {
1020        if (this.downloadSlotPanel == null) {
1030            this.downloadSlotPanel = new JPanel();
1040            this.downloadSlotPanel.setBorder(new TitledBorder(
1050                    "Download Slots (0 = infinite)"));
1060            this.downloadSlotPanel.setLayout(new BorderLayout());
1070            this.downloadSlotPanel.add(this.getDownloadSlotComboBox());
1080        }
1090        return downloadSlotPanel;
1100    }
111  
112     /**
113      * @return the replicationLevelComboBox
114      */
115     protected JComboBox getReplicationLevelComboBox() {
1160        if (this.replicationLevelComboBox == null) {
1170            this.replicationLevelComboBox = new JComboBox();
1180            for (int i = 0; i < 10; i++)
1190                this.replicationLevelComboBox.addItem(i);
1200            this.replicationLevelComboBox.setSelectedItem(5);
1210        }
1220        return replicationLevelComboBox;
1230    }
124  
125     /**
126      * @return the replicationLevelPanel
127      */
128     protected JPanel getReplicationLevelPanel() {
1290        if (this.replicationLevelPanel == null) {
1300            this.replicationLevelPanel = new JPanel();
1310            this.replicationLevelPanel.setBorder(new TitledBorder(
1320                    "Replication Level"));
1330            this.replicationLevelPanel.setLayout(new BorderLayout());
1340            this.replicationLevelPanel.add(this.getReplicationLevelComboBox());
1350        }
1360        return replicationLevelPanel;
137     }
138  
139     /**
140      * @return the uploadSlotComboBox
141      */
1420    protected JComboBox getUploadSlotComboBox() {
1430        if (this.uploadSlotComboBox == null) {
1440            this.uploadSlotComboBox = new JComboBox();
1450            for (int i = 0; i < 10; i++)
1460                this.uploadSlotComboBox.addItem(i);
147         }
1480        return uploadSlotComboBox;
149     }
150  
151     /**
152      * @return the uploadSlotPanel
153      */
154     protected JPanel getUploadSlotPanel() {
1550        if (this.uploadSlotPanel == null) {
1560            this.uploadSlotPanel = new JPanel();
1570            this.uploadSlotPanel.setBorder(new TitledBorder(
1580                    "Upload Slots (0 = infinite)"));
1590            this.uploadSlotPanel.setLayout(new BorderLayout());
1600            this.uploadSlotPanel.add(this.getUploadSlotComboBox());
1610        }
1620        return uploadSlotPanel;
163     }
164  
165     /**
166      * @return Returns the connectionTypeComboBox.
1670     */
168     protected JComboBox getConnectionTypeComboBox() {
1690        if (this.connectionTypeComboBox == null) {
1700            this.connectionTypeComboBox = new JComboBox();
1710            for (int i = 0; i < NetworkConnectionType.type.length; i++) {
1720                this.connectionTypeComboBox
173                         .addItem(NetworkConnectionType.type[i]);
1740            }
1750            this.connectionTypeComboBox.setSelectedItem(NetworkConnectionType
1760                    .fromConnectionTypeToString(ConfigurationManager
1770                            .getInstance().getNetworkConnectionType()));
1780            this.connectionTypeComboBox.addActionListener(new ActionListener() {
179  
1800                public void actionPerformed(ActionEvent arg0) {
181                     ConfigurationManager
182                             .getInstance()
183                             .setNetworkConnectionType(
184                                     NetworkConnectionType
185                                             .fromStringToConnectionType(connectionTypeComboBox
186                                                     .getSelectedItem()
187                                                     .toString()));
188                 }
189             });
190         }
1910        return connectionTypeComboBox;
192     }
193  
194     /**
195      * @return Returns the connectionTypePanel.
196      */
197     protected JPanel getConnectionTypePanel() {
1980        if (this.connectionTypePanel == null) {
1990            this.connectionTypePanel = new JPanel();
2000            this.connectionTypePanel.setBorder(new TitledBorder(
201                     "Connection Type"));
2020            this.connectionTypePanel.setLayout(new BorderLayout());
2030            this.connectionTypePanel.add(this.getConnectionTypeComboBox(),
204                     BorderLayout.CENTER);
205         }
2060        return connectionTypePanel;
207     }
208 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.