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 / creation / panel / DefaultOutputPanel.java @ 37607
History | View | Annotate | Download (6.88 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.creation.panel; |
29 |
|
30 |
import java.awt.BorderLayout; |
31 |
import java.awt.GridBagConstraints; |
32 |
import java.awt.GridBagLayout; |
33 |
import java.awt.event.ActionEvent; |
34 |
import java.awt.event.ActionListener; |
35 |
import java.io.File; |
36 |
import java.net.MalformedURLException; |
37 |
import java.net.URL; |
38 |
|
39 |
import javax.swing.JCheckBox; |
40 |
import javax.swing.JLabel; |
41 |
import javax.swing.JOptionPane; |
42 |
import javax.swing.JPanel; |
43 |
import javax.swing.JTextField; |
44 |
|
45 |
import org.gvsig.gui.beans.openfile.FileTextField; |
46 |
import org.gvsig.installer.swing.api.SwingInstallerLocator; |
47 |
import org.gvsig.installer.swing.api.creation.JOutputPanel; |
48 |
import org.gvsig.installer.swing.impl.DefaultSwingInstallerManager; |
49 |
|
50 |
/**
|
51 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a>
|
52 |
*/
|
53 |
public class DefaultOutputPanel extends JOutputPanel { |
54 |
|
55 |
private static final long serialVersionUID = 1219577194134960697L; |
56 |
|
57 |
protected DefaultSwingInstallerManager swingInstallerManager = null; |
58 |
private JLabel fileLabel; |
59 |
protected FileTextField fileTextField;
|
60 |
private JLabel createPackageIndexLabel; |
61 |
private JCheckBox createPackageIndexCheckBox; |
62 |
private JLabel packageURLLabel; |
63 |
protected JTextField packageURLTextField; |
64 |
private JLabel indexFileLabel; |
65 |
protected FileTextField indexFileTextField;
|
66 |
private javax.swing.JPanel northPanel;
|
67 |
|
68 |
public DefaultOutputPanel() {
|
69 |
super();
|
70 |
swingInstallerManager = (DefaultSwingInstallerManager) SwingInstallerLocator |
71 |
.getSwingInstallerManager(); |
72 |
initComponents(); |
73 |
} |
74 |
|
75 |
private void initComponents() { |
76 |
GridBagConstraints gridBagConstraints;
|
77 |
|
78 |
northPanel = new JPanel(); |
79 |
fileLabel = new JLabel(swingInstallerManager.getText("_package_file") |
80 |
+ ":");
|
81 |
fileTextField = new FileTextField("package.file"); |
82 |
indexFileLabel = new JLabel(swingInstallerManager |
83 |
.getText("_package_index_file")
|
84 |
+ ":");
|
85 |
|
86 |
packageURLLabel = new JLabel(swingInstallerManager |
87 |
.getText("_download_url")
|
88 |
+ ":");
|
89 |
packageURLTextField = new JTextField(); |
90 |
packageURLTextField.setEnabled(false);
|
91 |
|
92 |
indexFileTextField = new FileTextField("package.index.file"); |
93 |
indexFileTextField.setEnabled(false);
|
94 |
createPackageIndexLabel = new JLabel(swingInstallerManager |
95 |
.getText("_create_package_index")
|
96 |
+ ":");
|
97 |
createPackageIndexCheckBox = new JCheckBox(); |
98 |
createPackageIndexCheckBox.addActionListener(new ActionListener() { |
99 |
|
100 |
public void actionPerformed(ActionEvent e) { |
101 |
if (createPackageIndexCheckBox.isSelected()) {
|
102 |
packageURLTextField.setEnabled(true);
|
103 |
indexFileTextField.setEnabled(true);
|
104 |
} else {
|
105 |
packageURLTextField.setEnabled(false);
|
106 |
indexFileTextField.setEnabled(false);
|
107 |
} |
108 |
|
109 |
} |
110 |
}); |
111 |
|
112 |
setLayout(new BorderLayout()); |
113 |
|
114 |
northPanel.setLayout(new GridBagLayout()); |
115 |
|
116 |
// Package file
|
117 |
gridBagConstraints = new GridBagConstraints(); |
118 |
gridBagConstraints.gridx = 0;
|
119 |
gridBagConstraints.gridy = 0;
|
120 |
gridBagConstraints.anchor = GridBagConstraints.EAST;
|
121 |
northPanel.add(fileLabel, gridBagConstraints); |
122 |
|
123 |
gridBagConstraints.gridx = 1;
|
124 |
gridBagConstraints.gridy = 0;
|
125 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
126 |
gridBagConstraints.weightx = 1.0;
|
127 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
128 |
northPanel.add(fileTextField, gridBagConstraints); |
129 |
|
130 |
// Package index check
|
131 |
gridBagConstraints = new GridBagConstraints(); |
132 |
gridBagConstraints.gridx = 0;
|
133 |
gridBagConstraints.gridy = 1;
|
134 |
gridBagConstraints.anchor = GridBagConstraints.EAST;
|
135 |
northPanel.add(createPackageIndexLabel, gridBagConstraints); |
136 |
|
137 |
gridBagConstraints.gridx = 1;
|
138 |
gridBagConstraints.gridy = 1;
|
139 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
140 |
createPackageIndexCheckBox.setAlignmentX(LEFT_ALIGNMENT); |
141 |
northPanel.add(createPackageIndexCheckBox, gridBagConstraints); |
142 |
|
143 |
// Package download URL
|
144 |
gridBagConstraints = new GridBagConstraints(); |
145 |
gridBagConstraints.gridx = 0;
|
146 |
gridBagConstraints.gridy = 2;
|
147 |
gridBagConstraints.anchor = GridBagConstraints.EAST;
|
148 |
northPanel.add(packageURLLabel, gridBagConstraints); |
149 |
|
150 |
gridBagConstraints.gridx = 1;
|
151 |
gridBagConstraints.gridy = 2;
|
152 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
153 |
gridBagConstraints.weightx = 1.0;
|
154 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
155 |
northPanel.add(packageURLTextField, gridBagConstraints); |
156 |
|
157 |
// Package index file
|
158 |
gridBagConstraints = new GridBagConstraints(); |
159 |
gridBagConstraints.gridx = 0;
|
160 |
gridBagConstraints.gridy = 3;
|
161 |
gridBagConstraints.anchor = GridBagConstraints.EAST;
|
162 |
northPanel.add(indexFileLabel, gridBagConstraints); |
163 |
|
164 |
gridBagConstraints.gridx = 1;
|
165 |
gridBagConstraints.gridy = 3;
|
166 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
167 |
gridBagConstraints.weightx = 1.0;
|
168 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
169 |
northPanel.add(indexFileTextField, gridBagConstraints); |
170 |
|
171 |
add(northPanel, BorderLayout.NORTH);
|
172 |
} |
173 |
|
174 |
@Override
|
175 |
public File getPackageFile() { |
176 |
return fileTextField.getSelectedFile();
|
177 |
} |
178 |
|
179 |
@Override
|
180 |
public void setPackageFile(File selectedFile) { |
181 |
fileTextField.setSelectedFile(selectedFile); |
182 |
} |
183 |
|
184 |
@Override
|
185 |
public boolean isCreatePackageIndex() { |
186 |
return createPackageIndexCheckBox.isSelected();
|
187 |
} |
188 |
|
189 |
@Override
|
190 |
public void setCreatePackageIndex(boolean create) { |
191 |
createPackageIndexCheckBox.setSelected(create); |
192 |
} |
193 |
|
194 |
@Override
|
195 |
public File getPackageIndexFile() { |
196 |
if (isCreatePackageIndex()) {
|
197 |
return indexFileTextField.getSelectedFile();
|
198 |
} else {
|
199 |
return null; |
200 |
} |
201 |
} |
202 |
|
203 |
@Override
|
204 |
public void setPackageIndexFile(File selectedIndexFile) { |
205 |
indexFileTextField.setSelectedFile(selectedIndexFile); |
206 |
} |
207 |
|
208 |
@Override
|
209 |
public URL getDownloadURL() { |
210 |
if (isCreatePackageIndex()) {
|
211 |
try {
|
212 |
return new URL(packageURLTextField.getText()); |
213 |
} catch (MalformedURLException e) { |
214 |
JOptionPane.showMessageDialog(null, swingInstallerManager |
215 |
.getText("" + "_invalid_download_url" + ": " |
216 |
+ packageURLTextField.getText())); |
217 |
return null; |
218 |
} |
219 |
} else {
|
220 |
return null; |
221 |
} |
222 |
} |
223 |
|
224 |
@Override
|
225 |
public void setDownloadURL(URL downloadURL) { |
226 |
packageURLTextField.setText(downloadURL.toString()); |
227 |
} |
228 |
} |