Revision 33725
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/PackagesTablePanel.java | ||
---|---|---|
1 | 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 |
*/ |
|
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 | 22 |
|
23 | 23 |
/* |
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2010 {Prodevelop} {Task} |
|
26 |
*/ |
|
27 |
|
|
24 |
* AUTHORS (In addition to CIT):
|
|
25 |
* 2010 {Prodevelop} {Task}
|
|
26 |
*/
|
|
27 |
|
|
28 | 28 |
package org.gvsig.installer.swing.impl.execution.panel; |
29 | 29 |
|
30 | 30 |
import java.awt.GridBagConstraints; |
... | ... | |
49 | 49 |
/** |
50 | 50 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a> |
51 | 51 |
*/ |
52 |
public class PackagesTablePanel extends JPanel implements ListSelectionListener{ |
|
53 |
protected DefaultSwingInstallerManager swingInstallerManager = null; |
|
54 |
private JScrollPane descriptionScrollPane; |
|
52 |
public class PackagesTablePanel extends JPanel implements ListSelectionListener { |
|
53 |
|
|
54 |
/** |
|
55 |
* |
|
56 |
*/ |
|
57 |
private static final long serialVersionUID = 1202119227054423264L; |
|
58 |
protected DefaultSwingInstallerManager swingInstallerManager = null; |
|
59 |
private JScrollPane descriptionScrollPane; |
|
55 | 60 |
private JTextArea descriptionTextArea; |
56 | 61 |
private JScrollPane pluginsScrollPane; |
57 | 62 |
private JTable pluginsTable; |
58 |
|
|
63 |
|
|
59 | 64 |
public PackagesTablePanel(SelectPackagesPanel 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); |
|
65 |
super(); |
|
66 |
swingInstallerManager = |
|
67 |
(DefaultSwingInstallerManager) SwingInstallerLocator |
|
68 |
.getSwingInstallerManager(); |
|
69 |
initComponents(); |
|
70 |
pluginsTable.getSelectionModel().addListSelectionListener(this); |
|
71 |
pluginsTable.setDefaultRenderer(Boolean.class, |
|
72 |
new PackagesTableCellRenderer(selectPluginsPanel)); |
|
73 |
pluginsTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); |
|
66 | 74 |
} |
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 | 75 |
|
84 |
public boolean isPackageSelected(){ |
|
85 |
return ((PackagesTableModel)pluginsTable.getModel()).isPackageSelected(); |
|
86 |
} |
|
87 |
|
|
76 |
public void setTableModel(PackagesTableModel pluginsTableModel) { |
|
77 |
pluginsTable.setModel(pluginsTableModel); |
|
78 |
TableColumnModel tableColumnModel = pluginsTable.getColumnModel(); |
|
79 |
tableColumnModel.getColumn(0).setPreferredWidth(25); |
|
80 |
tableColumnModel.getColumn(1).setPreferredWidth(150); |
|
81 |
tableColumnModel.getColumn(2).setPreferredWidth(70); |
|
82 |
tableColumnModel.getColumn(3).setPreferredWidth(75); |
|
83 |
tableColumnModel.getColumn(4).setPreferredWidth(75); |
|
84 |
tableColumnModel.getColumn(5).setPreferredWidth(50); |
|
85 |
} |
|
86 |
|
|
87 |
public void addPackageInfosToInstall(List<PackageInfo> packageInfosToInstall) { |
|
88 |
((PackagesTableModel) pluginsTable.getModel()) |
|
89 |
.addPackageInfosToInstall(packageInfosToInstall); |
|
90 |
} |
|
91 |
|
|
92 |
public boolean isPackageSelected() { |
|
93 |
return ((PackagesTableModel) pluginsTable.getModel()) |
|
94 |
.isPackageSelected(); |
|
95 |
} |
|
96 |
|
|
88 | 97 |
private void initComponents() { |
89 |
java.awt.GridBagConstraints gridBagConstraints;
|
|
98 |
java.awt.GridBagConstraints gridBagConstraints;
|
|
90 | 99 |
|
91 |
pluginsScrollPane = new JScrollPane();
|
|
92 |
pluginsTable = new JTable();
|
|
93 |
descriptionScrollPane = new JScrollPane();
|
|
94 |
descriptionTextArea = new JTextArea();
|
|
100 |
pluginsScrollPane = new JScrollPane(); |
|
101 |
pluginsTable = new JTable(); |
|
102 |
descriptionScrollPane = new JScrollPane(); |
|
103 |
descriptionTextArea = new JTextArea(); |
|
95 | 104 |
|
96 |
setLayout(new GridBagLayout());
|
|
105 |
setLayout(new GridBagLayout()); |
|
97 | 106 |
|
98 |
pluginsScrollPane.setViewportView(pluginsTable);
|
|
107 |
pluginsScrollPane.setViewportView(pluginsTable); |
|
99 | 108 |
|
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); |
|
109 |
gridBagConstraints = new GridBagConstraints(); |
|
110 |
gridBagConstraints.fill = GridBagConstraints.BOTH; |
|
111 |
gridBagConstraints.weightx = 1.0; |
|
112 |
gridBagConstraints.weighty = 0.75; |
|
113 |
gridBagConstraints.insets = new Insets(2, 2, 2, 2); |
|
114 |
add(pluginsScrollPane, gridBagConstraints); |
|
111 | 115 |
|
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); |
|
116 |
descriptionTextArea.setEditable(false); |
|
117 |
descriptionTextArea.setColumns(20); |
|
118 |
descriptionTextArea.setRows(5); |
|
119 |
descriptionScrollPane.setViewportView(descriptionTextArea); |
|
120 |
|
|
121 |
gridBagConstraints = new GridBagConstraints(); |
|
122 |
gridBagConstraints.gridx = 0; |
|
123 |
gridBagConstraints.gridy = 1; |
|
124 |
gridBagConstraints.fill = GridBagConstraints.BOTH; |
|
125 |
gridBagConstraints.weightx = 1.0; |
|
126 |
gridBagConstraints.weighty = 0.25; |
|
127 |
gridBagConstraints.insets = new Insets(2, 2, 2, 2); |
|
128 |
add(descriptionScrollPane, gridBagConstraints); |
|
120 | 129 |
} |
121 | 130 |
|
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 |
} |
|
131 |
public void valueChanged(ListSelectionEvent e) { |
|
132 |
int row = pluginsTable.getSelectedRow(); |
|
133 |
if (row != -1) { |
|
134 |
descriptionTextArea.setText(((PackagesTableModel) pluginsTable |
|
135 |
.getModel()).getDescriptionAt(row)); |
|
136 |
} |
|
137 |
} |
|
128 | 138 |
} |
129 |
|
Also available in: Unified diff