Revision 37590 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
DefaultOutputPanel.java | ||
---|---|---|
55 | 55 |
*/ |
56 | 56 |
public class DefaultOutputPanel extends JOutputPanel { |
57 | 57 |
|
58 |
private static final Logger LOG =
|
|
59 |
LoggerFactory.getLogger(DefaultOutputPanel.class);
|
|
60 |
private static final long serialVersionUID = 1219577194134960697L;
|
|
58 |
private static final Logger LOG = LoggerFactory
|
|
59 |
.getLogger(DefaultOutputPanel.class);
|
|
60 |
private static final long serialVersionUID = 1219577194134960697L;
|
|
61 | 61 |
|
62 |
protected DefaultSwingInstallerManager swingInstallerManager = null;
|
|
63 |
private JLabel fileLabel;
|
|
64 |
protected FileTextField fileTextField;
|
|
65 |
private JLabel createPackageIndexLabel;
|
|
66 |
private JCheckBox createPackageIndexCheckBox;
|
|
67 |
private JLabel packageURLLabel;
|
|
68 |
protected JTextField packageURLTextField;
|
|
69 |
private JLabel indexFileLabel;
|
|
70 |
protected FileTextField indexFileTextField;
|
|
71 |
private javax.swing.JPanel northPanel;
|
|
62 |
protected DefaultSwingInstallerManager swingInstallerManager = null;
|
|
63 |
private JLabel fileLabel;
|
|
64 |
protected FileTextField fileTextField;
|
|
65 |
private JLabel createPackageIndexLabel;
|
|
66 |
private JCheckBox createPackageIndexCheckBox;
|
|
67 |
private JLabel packageURLLabel;
|
|
68 |
protected JTextField packageURLTextField;
|
|
69 |
private JLabel indexFileLabel;
|
|
70 |
protected FileTextField indexFileTextField;
|
|
71 |
private javax.swing.JPanel northPanel;
|
|
72 | 72 |
|
73 |
public DefaultOutputPanel() { |
|
74 |
super(); |
|
75 |
swingInstallerManager = |
|
76 |
(DefaultSwingInstallerManager) SwingInstallerLocator |
|
77 |
.getSwingInstallerManager(); |
|
78 |
initComponents(); |
|
79 |
} |
|
73 |
public DefaultOutputPanel() { |
|
74 |
super(); |
|
75 |
swingInstallerManager = (DefaultSwingInstallerManager) SwingInstallerLocator |
|
76 |
.getSwingInstallerManager(); |
|
77 |
initComponents(); |
|
78 |
} |
|
80 | 79 |
|
81 |
private void initComponents() {
|
|
82 |
GridBagConstraints gridBagConstraints;
|
|
80 |
private void initComponents() {
|
|
81 |
GridBagConstraints gridBagConstraints;
|
|
83 | 82 |
|
84 |
northPanel = new JPanel();
|
|
85 |
fileLabel =
|
|
86 |
new JLabel(swingInstallerManager.getText("package_file") + ":");
|
|
87 |
fileTextField = new FileTextField("package.file");
|
|
88 |
indexFileLabel =
|
|
89 |
new JLabel(swingInstallerManager.getText("package_index_file")
|
|
90 |
+ ":");
|
|
83 |
northPanel = new JPanel();
|
|
84 |
fileLabel = new JLabel(swingInstallerManager.getText("package_file")
|
|
85 |
+ ":");
|
|
86 |
fileTextField = new FileTextField("package.file");
|
|
87 |
indexFileLabel = new JLabel(swingInstallerManager
|
|
88 |
.getText("package_index_file")
|
|
89 |
+ ":");
|
|
91 | 90 |
|
92 |
packageURLLabel = |
|
93 |
new JLabel(swingInstallerManager.getText("download_url") + ":"); |
|
94 |
packageURLTextField = new JTextField(); |
|
95 |
packageURLTextField.setEnabled(false); |
|
91 |
packageURLLabel = new JLabel(swingInstallerManager |
|
92 |
.getText("download_url") |
|
93 |
+ ":"); |
|
94 |
packageURLTextField = new JTextField(); |
|
95 |
packageURLTextField.setEnabled(false); |
|
96 | 96 |
|
97 |
indexFileTextField = new FileTextField("package.index.file");
|
|
98 |
indexFileTextField.setEnabled(false);
|
|
99 |
createPackageIndexLabel =
|
|
100 |
new JLabel(swingInstallerManager.getText("create_package_index")
|
|
101 |
+ ":");
|
|
102 |
createPackageIndexCheckBox = new JCheckBox();
|
|
103 |
createPackageIndexCheckBox.addActionListener(new ActionListener() {
|
|
97 |
indexFileTextField = new FileTextField("package.index.file");
|
|
98 |
indexFileTextField.setEnabled(false);
|
|
99 |
createPackageIndexLabel = new JLabel(swingInstallerManager
|
|
100 |
.getText("create_package_index")
|
|
101 |
+ ":");
|
|
102 |
createPackageIndexCheckBox = new JCheckBox();
|
|
103 |
createPackageIndexCheckBox.addActionListener(new ActionListener() {
|
|
104 | 104 |
|
105 |
public void actionPerformed(ActionEvent e) {
|
|
106 |
if (createPackageIndexCheckBox.isSelected()) {
|
|
107 |
packageURLTextField.setEnabled(true);
|
|
108 |
indexFileTextField.setEnabled(true);
|
|
109 |
} else {
|
|
110 |
packageURLTextField.setEnabled(false);
|
|
111 |
indexFileTextField.setEnabled(false);
|
|
112 |
}
|
|
105 |
public void actionPerformed(ActionEvent e) {
|
|
106 |
if (createPackageIndexCheckBox.isSelected()) {
|
|
107 |
packageURLTextField.setEnabled(true);
|
|
108 |
indexFileTextField.setEnabled(true);
|
|
109 |
} else {
|
|
110 |
packageURLTextField.setEnabled(false);
|
|
111 |
indexFileTextField.setEnabled(false);
|
|
112 |
}
|
|
113 | 113 |
|
114 |
}
|
|
115 |
});
|
|
114 |
}
|
|
115 |
});
|
|
116 | 116 |
|
117 |
setLayout(new BorderLayout());
|
|
117 |
setLayout(new BorderLayout());
|
|
118 | 118 |
|
119 |
northPanel.setLayout(new GridBagLayout());
|
|
119 |
northPanel.setLayout(new GridBagLayout());
|
|
120 | 120 |
|
121 |
// Package file
|
|
122 |
gridBagConstraints = new GridBagConstraints();
|
|
123 |
gridBagConstraints.gridx = 0;
|
|
124 |
gridBagConstraints.gridy = 0;
|
|
125 |
gridBagConstraints.anchor = GridBagConstraints.EAST;
|
|
126 |
northPanel.add(fileLabel, gridBagConstraints);
|
|
121 |
// Package file
|
|
122 |
gridBagConstraints = new GridBagConstraints();
|
|
123 |
gridBagConstraints.gridx = 0;
|
|
124 |
gridBagConstraints.gridy = 0;
|
|
125 |
gridBagConstraints.anchor = GridBagConstraints.EAST;
|
|
126 |
northPanel.add(fileLabel, gridBagConstraints);
|
|
127 | 127 |
|
128 |
gridBagConstraints.gridx = 1;
|
|
129 |
gridBagConstraints.gridy = 0;
|
|
130 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
|
131 |
gridBagConstraints.weightx = 1.0;
|
|
132 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
|
133 |
northPanel.add(fileTextField, gridBagConstraints);
|
|
128 |
gridBagConstraints.gridx = 1;
|
|
129 |
gridBagConstraints.gridy = 0;
|
|
130 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
|
131 |
gridBagConstraints.weightx = 1.0;
|
|
132 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
|
133 |
northPanel.add(fileTextField, gridBagConstraints);
|
|
134 | 134 |
|
135 |
// Package index check
|
|
136 |
gridBagConstraints = new GridBagConstraints();
|
|
137 |
gridBagConstraints.gridx = 0;
|
|
138 |
gridBagConstraints.gridy = 1;
|
|
139 |
gridBagConstraints.anchor = GridBagConstraints.EAST;
|
|
140 |
northPanel.add(createPackageIndexLabel, gridBagConstraints);
|
|
135 |
// Package index check
|
|
136 |
gridBagConstraints = new GridBagConstraints();
|
|
137 |
gridBagConstraints.gridx = 0;
|
|
138 |
gridBagConstraints.gridy = 1;
|
|
139 |
gridBagConstraints.anchor = GridBagConstraints.EAST;
|
|
140 |
northPanel.add(createPackageIndexLabel, gridBagConstraints);
|
|
141 | 141 |
|
142 |
gridBagConstraints.gridx = 1;
|
|
143 |
gridBagConstraints.gridy = 1;
|
|
144 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
|
145 |
createPackageIndexCheckBox.setAlignmentX(LEFT_ALIGNMENT);
|
|
146 |
northPanel.add(createPackageIndexCheckBox, gridBagConstraints);
|
|
142 |
gridBagConstraints.gridx = 1;
|
|
143 |
gridBagConstraints.gridy = 1;
|
|
144 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
|
145 |
createPackageIndexCheckBox.setAlignmentX(LEFT_ALIGNMENT);
|
|
146 |
northPanel.add(createPackageIndexCheckBox, gridBagConstraints);
|
|
147 | 147 |
|
148 |
// Package download URL
|
|
149 |
gridBagConstraints = new GridBagConstraints();
|
|
150 |
gridBagConstraints.gridx = 0;
|
|
151 |
gridBagConstraints.gridy = 2;
|
|
152 |
gridBagConstraints.anchor = GridBagConstraints.EAST;
|
|
153 |
northPanel.add(packageURLLabel, gridBagConstraints);
|
|
148 |
// Package download URL
|
|
149 |
gridBagConstraints = new GridBagConstraints();
|
|
150 |
gridBagConstraints.gridx = 0;
|
|
151 |
gridBagConstraints.gridy = 2;
|
|
152 |
gridBagConstraints.anchor = GridBagConstraints.EAST;
|
|
153 |
northPanel.add(packageURLLabel, gridBagConstraints);
|
|
154 | 154 |
|
155 |
gridBagConstraints.gridx = 1;
|
|
156 |
gridBagConstraints.gridy = 2;
|
|
157 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
|
158 |
gridBagConstraints.weightx = 1.0;
|
|
159 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
|
160 |
northPanel.add(packageURLTextField, gridBagConstraints);
|
|
155 |
gridBagConstraints.gridx = 1;
|
|
156 |
gridBagConstraints.gridy = 2;
|
|
157 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
|
158 |
gridBagConstraints.weightx = 1.0;
|
|
159 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
|
160 |
northPanel.add(packageURLTextField, gridBagConstraints);
|
|
161 | 161 |
|
162 |
// Package index file
|
|
163 |
gridBagConstraints = new GridBagConstraints();
|
|
164 |
gridBagConstraints.gridx = 0;
|
|
165 |
gridBagConstraints.gridy = 3;
|
|
166 |
gridBagConstraints.anchor = GridBagConstraints.EAST;
|
|
167 |
northPanel.add(indexFileLabel, gridBagConstraints);
|
|
162 |
// Package index file
|
|
163 |
gridBagConstraints = new GridBagConstraints();
|
|
164 |
gridBagConstraints.gridx = 0;
|
|
165 |
gridBagConstraints.gridy = 3;
|
|
166 |
gridBagConstraints.anchor = GridBagConstraints.EAST;
|
|
167 |
northPanel.add(indexFileLabel, gridBagConstraints);
|
|
168 | 168 |
|
169 |
gridBagConstraints.gridx = 1;
|
|
170 |
gridBagConstraints.gridy = 3;
|
|
171 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
|
172 |
gridBagConstraints.weightx = 1.0;
|
|
173 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
|
174 |
northPanel.add(indexFileTextField, gridBagConstraints);
|
|
169 |
gridBagConstraints.gridx = 1;
|
|
170 |
gridBagConstraints.gridy = 3;
|
|
171 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
|
172 |
gridBagConstraints.weightx = 1.0;
|
|
173 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
|
174 |
northPanel.add(indexFileTextField, gridBagConstraints);
|
|
175 | 175 |
|
176 |
add(northPanel, BorderLayout.NORTH);
|
|
177 |
}
|
|
176 |
add(northPanel, BorderLayout.NORTH);
|
|
177 |
}
|
|
178 | 178 |
|
179 |
public File getPackageFile() { |
|
180 |
return fileTextField.getSelectedFile(); |
|
181 |
} |
|
179 |
@Override |
|
180 |
public File getPackageFile() { |
|
181 |
return fileTextField.getSelectedFile(); |
|
182 |
} |
|
182 | 183 |
|
183 |
public void setPackageFile(File selectedFile) { |
|
184 |
fileTextField.setSelectedFile(selectedFile); |
|
185 |
} |
|
184 |
@Override |
|
185 |
public void setPackageFile(File selectedFile) { |
|
186 |
fileTextField.setSelectedFile(selectedFile); |
|
187 |
} |
|
186 | 188 |
|
187 |
public boolean isCreatePackageIndex() { |
|
188 |
return createPackageIndexCheckBox.isSelected(); |
|
189 |
} |
|
189 |
@Override |
|
190 |
public boolean isCreatePackageIndex() { |
|
191 |
return createPackageIndexCheckBox.isSelected(); |
|
192 |
} |
|
190 | 193 |
|
191 |
public void setCreatePackageIndex(boolean create) { |
|
192 |
createPackageIndexCheckBox.setSelected(create); |
|
193 |
} |
|
194 |
@Override |
|
195 |
public void setCreatePackageIndex(boolean create) { |
|
196 |
createPackageIndexCheckBox.setSelected(create); |
|
197 |
} |
|
194 | 198 |
|
195 |
public File getPackageIndexFile() { |
|
196 |
if (isCreatePackageIndex()) { |
|
197 |
return indexFileTextField.getSelectedFile(); |
|
198 |
} else { |
|
199 |
return null; |
|
200 |
} |
|
201 |
} |
|
199 |
@Override |
|
200 |
public File getPackageIndexFile() { |
|
201 |
if (isCreatePackageIndex()) { |
|
202 |
return indexFileTextField.getSelectedFile(); |
|
203 |
} else { |
|
204 |
return null; |
|
205 |
} |
|
206 |
} |
|
202 | 207 |
|
203 |
public void setPackageIndexFile(File selectedIndexFile) { |
|
204 |
indexFileTextField.setSelectedFile(selectedIndexFile); |
|
205 |
} |
|
208 |
@Override |
|
209 |
public void setPackageIndexFile(File selectedIndexFile) { |
|
210 |
indexFileTextField.setSelectedFile(selectedIndexFile); |
|
211 |
} |
|
206 | 212 |
|
207 |
public URL getDownloadURL() { |
|
208 |
if (isCreatePackageIndex()) { |
|
209 |
try { |
|
210 |
return new URL(packageURLTextField.getText()); |
|
211 |
} catch (MalformedURLException e) { |
|
212 |
LOG.info("Invalid download URL: " |
|
213 |
+ packageURLTextField.getText(), 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 |
// public String getDownloadURL() { |
|
225 |
// return packageURLTextField.getText(); |
|
226 |
// } |
|
213 |
@Override |
|
214 |
public URL getDownloadURL() { |
|
215 |
if (isCreatePackageIndex()) { |
|
216 |
try { |
|
217 |
return new URL(packageURLTextField.getText()); |
|
218 |
} catch (MalformedURLException e) { |
|
219 |
LOG.info("Invalid download URL: " |
|
220 |
+ packageURLTextField.getText(), e); |
|
221 |
JOptionPane.showMessageDialog(null, swingInstallerManager |
|
222 |
.getText("Invalid download URL: " |
|
223 |
+ packageURLTextField.getText())); |
|
224 |
return null; |
|
225 |
} |
|
226 |
} else { |
|
227 |
return null; |
|
228 |
} |
|
229 |
} |
|
227 | 230 |
|
228 |
public void setDownloadURL(URL downloadURL) { |
|
229 |
packageURLTextField.setText(downloadURL.toString()); |
|
230 |
} |
|
231 |
// public String getDownloadURL() { |
|
232 |
// return packageURLTextField.getText(); |
|
233 |
// } |
|
234 |
|
|
235 |
@Override |
|
236 |
public void setDownloadURL(URL downloadURL) { |
|
237 |
packageURLTextField.setText(downloadURL.toString()); |
|
238 |
} |
|
231 | 239 |
} |
Also available in: Unified diff