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

History | View | Annotate | Download (4.89 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.JPanel;
36
import javax.swing.JScrollPane;
37
import javax.swing.JTable;
38
import javax.swing.JTextArea;
39
import javax.swing.event.ListSelectionEvent;
40
import javax.swing.event.ListSelectionListener;
41
import javax.swing.table.TableColumnModel;
42

    
43
import org.gvsig.installer.lib.api.PackageInfo;
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.PackagesTableCellRenderer;
47
import org.gvsig.installer.swing.impl.execution.model.PackagesTableModel;
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(SelectPluginsPanel selectPluginsPanel) {
60
                super();
61
                swingInstallerManager = (DefaultSwingInstallerManager)SwingInstallerLocator.getSwingInstallerManager();
62
                initComponents();
63
                pluginsTable.getSelectionModel().addListSelectionListener(this);
64
                pluginsTable.setDefaultRenderer(Boolean.class, new PackagesTableCellRenderer(selectPluginsPanel));
65
                pluginsTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); 
66
    }
67
    
68
    public void setTableModel(PackagesTableModel pluginsTableModel){
69
            pluginsTable.setModel(pluginsTableModel);      
70
            TableColumnModel tableColumnModel = pluginsTable.getColumnModel();
71
            tableColumnModel.getColumn(0).setPreferredWidth(25);
72
            tableColumnModel.getColumn(1).setPreferredWidth(150);
73
            tableColumnModel.getColumn(2).setPreferredWidth(70);
74
            tableColumnModel.getColumn(3).setPreferredWidth(75);
75
            tableColumnModel.getColumn(4).setPreferredWidth(75);
76
            tableColumnModel.getColumn(5).setPreferredWidth(50);
77
    }   
78
    
79
    
80
    public void addPackageInfosToInstall(List<PackageInfo> packageInfosToInstall){
81
            ((PackagesTableModel)pluginsTable.getModel()).addPackageInfosToInstall(packageInfosToInstall);              
82
        }    
83

    
84
        public boolean isPackageSelected(){
85
                return ((PackagesTableModel)pluginsTable.getModel()).isPackageSelected();              
86
        }
87
    
88
    private void initComponents() {
89
             java.awt.GridBagConstraints gridBagConstraints;
90

    
91
         pluginsScrollPane = new JScrollPane();
92
         pluginsTable = new JTable();
93
         descriptionScrollPane = new JScrollPane();
94
         descriptionTextArea = new JTextArea();
95

    
96
         setLayout(new GridBagLayout());
97

    
98
         pluginsScrollPane.setViewportView(pluginsTable);
99

    
100
         gridBagConstraints = new GridBagConstraints();
101
         gridBagConstraints.fill = GridBagConstraints.BOTH;
102
         gridBagConstraints.weightx = 1.0;
103
         gridBagConstraints.weighty = 0.75;
104
         gridBagConstraints.insets = new Insets(2, 2, 2, 2);
105
         add(pluginsScrollPane, gridBagConstraints);
106
         
107
         descriptionTextArea.setEditable(false);
108
         descriptionTextArea.setColumns(20);
109
         descriptionTextArea.setRows(5);
110
         descriptionScrollPane.setViewportView(descriptionTextArea);
111

    
112
         gridBagConstraints = new GridBagConstraints();
113
         gridBagConstraints.gridx = 0;
114
         gridBagConstraints.gridy = 1;
115
         gridBagConstraints.fill = GridBagConstraints.BOTH;
116
         gridBagConstraints.weightx = 1.0;
117
         gridBagConstraints.weighty = 0.25;
118
         gridBagConstraints.insets = new Insets(2, 2, 2, 2);
119
         add(descriptionScrollPane, gridBagConstraints);            
120
    }
121

    
122
        public void valueChanged(ListSelectionEvent e) {
123
                int row = pluginsTable.getSelectedRow();
124
                if (row != -1){
125
                        descriptionTextArea.setText(((PackagesTableModel)pluginsTable.getModel()).getDescriptionAt(row));                        
126
                }                
127
        }        
128
}
129