Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / extensions / org.gvsig.installer / org.gvsig.installer.swing / org.gvsig.installer.swing.impl / src / main / java / org / gvsig / installer / swing / impl / execution / panel / PluginsTablePanel.java @ 32401

History | View | Annotate | Download (4.22 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
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, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22

    
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2010 {Prodevelop}   {Task}
26
*/
27
 
28
package org.gvsig.installer.swing.impl.execution.panel;
29

    
30
import java.awt.GridBagConstraints;
31
import java.awt.GridBagLayout;
32
import java.awt.Insets;
33
import java.util.List;
34

    
35
import javax.swing.JCheckBox;
36
import javax.swing.JPanel;
37
import javax.swing.JScrollPane;
38
import javax.swing.JTable;
39
import javax.swing.JTextArea;
40
import javax.swing.event.ListSelectionEvent;
41
import javax.swing.event.ListSelectionListener;
42

    
43
import org.gvsig.installer.lib.api.InstallerInfo;
44
import org.gvsig.installer.swing.api.SwingInstallerLocator;
45
import org.gvsig.installer.swing.impl.DefaultSwingInstallerManager;
46
import org.gvsig.installer.swing.impl.execution.model.PluginsTableCellRenderer;
47
import org.gvsig.installer.swing.impl.execution.model.PluginsTableModel;
48

    
49
/**
50
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
51
 */
52
public class PluginsTablePanel extends JPanel implements ListSelectionListener{
53
        protected DefaultSwingInstallerManager swingInstallerManager = null;
54
        private JScrollPane descriptionScrollPane;
55
    private JTextArea descriptionTextArea;
56
    private JScrollPane pluginsScrollPane;
57
    private JTable pluginsTable;
58
    
59
    public PluginsTablePanel() {
60
                super();
61
                swingInstallerManager = (DefaultSwingInstallerManager)SwingInstallerLocator.getSwingInstallerManager();
62
                initComponents();
63
                pluginsTable.getSelectionModel().addListSelectionListener(this);
64
                pluginsTable.setDefaultRenderer(Boolean.class, new PluginsTableCellRenderer());
65
    }
66
    
67
    public void setTableModel(PluginsTableModel pluginsTableModel){
68
            pluginsTable.setModel(pluginsTableModel);              
69
    }
70
    
71
    public void addInstallersToExecute(List<InstallerInfo> installerInfosToInstall){
72
            ((PluginsTableModel)pluginsTable.getModel()).addInstallersToExecute(installerInfosToInstall);              
73
        }
74
    
75
    private void initComponents() {
76
             java.awt.GridBagConstraints gridBagConstraints;
77

    
78
         pluginsScrollPane = new JScrollPane();
79
         pluginsTable = new JTable();
80
         descriptionScrollPane = new JScrollPane();
81
         descriptionTextArea = new JTextArea();
82

    
83
         setLayout(new GridBagLayout());
84

    
85
         pluginsScrollPane.setViewportView(pluginsTable);
86

    
87
         gridBagConstraints = new GridBagConstraints();
88
         gridBagConstraints.fill = GridBagConstraints.BOTH;
89
         gridBagConstraints.weightx = 1.0;
90
         gridBagConstraints.weighty = 0.75;
91
         gridBagConstraints.insets = new Insets(2, 2, 2, 2);
92
         add(pluginsScrollPane, gridBagConstraints);
93
         
94
         descriptionTextArea.setEditable(false);
95
         descriptionTextArea.setColumns(20);
96
         descriptionTextArea.setRows(5);
97
         descriptionScrollPane.setViewportView(descriptionTextArea);
98

    
99
         gridBagConstraints = new GridBagConstraints();
100
         gridBagConstraints.gridx = 0;
101
         gridBagConstraints.gridy = 1;
102
         gridBagConstraints.fill = GridBagConstraints.BOTH;
103
         gridBagConstraints.weightx = 1.0;
104
         gridBagConstraints.weighty = 0.25;
105
         gridBagConstraints.insets = new Insets(2, 2, 2, 2);
106
         add(descriptionScrollPane, gridBagConstraints);            
107
    }
108

    
109
        public void valueChanged(ListSelectionEvent e) {
110
                int row = pluginsTable.getSelectedRow();
111
                if (row != -1){
112
                        descriptionTextArea.setText(((PluginsTableModel)pluginsTable.getModel()).getDescriptionAt(row));
113
                }
114
                
115
        }
116
}
117