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