Revision 37822 branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.main/src/main/java/org/gvsig/installer/main/utils/CreateBoundleFrame.java
CreateBoundleFrame.java | ||
---|---|---|
47 | 47 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a> |
48 | 48 |
*/ |
49 | 49 |
public class CreateBoundleFrame extends JFrame implements WindowListener, |
50 |
ActionListener {
|
|
50 |
ActionListener {
|
|
51 | 51 |
|
52 |
/**
|
|
52 |
/**
|
|
53 | 53 |
* |
54 | 54 |
*/ |
55 |
private static final long serialVersionUID = -2128261599641241144L;
|
|
56 |
private javax.swing.JButton executeButton;
|
|
57 |
private javax.swing.JLabel inputLabel;
|
|
58 |
private FileTextField inputText;
|
|
59 |
private javax.swing.JLabel jLabel2;
|
|
60 |
private FileTextField outputText;
|
|
55 |
private static final long serialVersionUID = -2128261599641241144L;
|
|
56 |
private javax.swing.JButton executeButton;
|
|
57 |
private javax.swing.JLabel inputLabel;
|
|
58 |
private FileTextField inputText;
|
|
59 |
private javax.swing.JLabel jLabel2;
|
|
60 |
private FileTextField outputText;
|
|
61 | 61 |
|
62 |
public CreateBoundleFrame() throws HeadlessException {
|
|
63 |
super();
|
|
64 |
initializeComponents();
|
|
65 |
this.addWindowListener(this);
|
|
66 |
executeButton.addActionListener(this);
|
|
67 |
}
|
|
62 |
public CreateBoundleFrame() throws HeadlessException {
|
|
63 |
super();
|
|
64 |
initializeComponents();
|
|
65 |
this.addWindowListener(this);
|
|
66 |
executeButton.addActionListener(this);
|
|
67 |
}
|
|
68 | 68 |
|
69 |
private void initializeComponents() {
|
|
70 |
java.awt.GridBagConstraints gridBagConstraints;
|
|
69 |
private void initializeComponents() {
|
|
70 |
java.awt.GridBagConstraints gridBagConstraints;
|
|
71 | 71 |
|
72 |
inputLabel = new javax.swing.JLabel();
|
|
73 |
executeButton = new javax.swing.JButton();
|
|
74 |
inputText = new FileTextField();
|
|
75 |
outputText = new FileTextField();
|
|
76 |
jLabel2 = new javax.swing.JLabel();
|
|
72 |
inputLabel = new javax.swing.JLabel();
|
|
73 |
executeButton = new javax.swing.JButton();
|
|
74 |
inputText = new FileTextField();
|
|
75 |
outputText = new FileTextField();
|
|
76 |
jLabel2 = new javax.swing.JLabel();
|
|
77 | 77 |
|
78 |
setLayout(new java.awt.GridBagLayout());
|
|
78 |
setLayout(new java.awt.GridBagLayout());
|
|
79 | 79 |
|
80 |
inputLabel.setText("Input directory");
|
|
81 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
|
82 |
gridBagConstraints.gridx = 0;
|
|
83 |
gridBagConstraints.gridy = 0;
|
|
84 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
|
|
85 |
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
|
|
86 |
add(inputLabel, gridBagConstraints);
|
|
80 |
inputLabel.setText("Input directory");
|
|
81 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
|
82 |
gridBagConstraints.gridx = 0;
|
|
83 |
gridBagConstraints.gridy = 0;
|
|
84 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
|
|
85 |
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
|
|
86 |
add(inputLabel, gridBagConstraints);
|
|
87 | 87 |
|
88 |
executeButton.setText("Execute");
|
|
89 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
|
90 |
gridBagConstraints.gridx = 1;
|
|
91 |
gridBagConstraints.gridy = 2;
|
|
92 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
|
|
93 |
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
|
|
94 |
add(executeButton, gridBagConstraints);
|
|
88 |
executeButton.setText("Execute");
|
|
89 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
|
90 |
gridBagConstraints.gridx = 1;
|
|
91 |
gridBagConstraints.gridy = 2;
|
|
92 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
|
|
93 |
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
|
|
94 |
add(executeButton, gridBagConstraints);
|
|
95 | 95 |
|
96 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
|
97 |
gridBagConstraints.gridx = 1;
|
|
98 |
gridBagConstraints.gridy = 0;
|
|
99 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
|
|
100 |
gridBagConstraints.ipadx = 67;
|
|
101 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
|
|
102 |
gridBagConstraints.weightx = 1.0;
|
|
103 |
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
|
|
104 |
add(inputText, gridBagConstraints);
|
|
96 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
|
97 |
gridBagConstraints.gridx = 1;
|
|
98 |
gridBagConstraints.gridy = 0;
|
|
99 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
|
|
100 |
gridBagConstraints.ipadx = 67;
|
|
101 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
|
|
102 |
gridBagConstraints.weightx = 1.0;
|
|
103 |
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
|
|
104 |
add(inputText, gridBagConstraints);
|
|
105 | 105 |
|
106 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
|
107 |
gridBagConstraints.gridx = 1;
|
|
108 |
gridBagConstraints.gridy = 1;
|
|
109 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
|
|
110 |
gridBagConstraints.ipadx = 67;
|
|
111 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
|
|
112 |
gridBagConstraints.weightx = 1.0;
|
|
113 |
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
|
|
114 |
add(outputText, gridBagConstraints);
|
|
106 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
|
107 |
gridBagConstraints.gridx = 1;
|
|
108 |
gridBagConstraints.gridy = 1;
|
|
109 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
|
|
110 |
gridBagConstraints.ipadx = 67;
|
|
111 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
|
|
112 |
gridBagConstraints.weightx = 1.0;
|
|
113 |
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
|
|
114 |
add(outputText, gridBagConstraints);
|
|
115 | 115 |
|
116 |
jLabel2.setText("Output");
|
|
117 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
|
118 |
gridBagConstraints.gridx = 0;
|
|
119 |
gridBagConstraints.gridy = 1;
|
|
120 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
|
|
121 |
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
|
|
122 |
add(jLabel2, gridBagConstraints);
|
|
116 |
jLabel2.setText("Output");
|
|
117 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
|
118 |
gridBagConstraints.gridx = 0;
|
|
119 |
gridBagConstraints.gridy = 1;
|
|
120 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
|
|
121 |
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
|
|
122 |
add(jLabel2, gridBagConstraints);
|
|
123 | 123 |
|
124 |
}
|
|
124 |
}
|
|
125 | 125 |
|
126 |
public void windowActivated(WindowEvent arg0) {
|
|
127 |
// TODO Auto-generated method stub
|
|
126 |
public void windowActivated(WindowEvent arg0) {
|
|
127 |
// TODO Auto-generated method stub
|
|
128 | 128 |
|
129 |
}
|
|
129 |
}
|
|
130 | 130 |
|
131 |
public void windowClosed(WindowEvent arg0) {
|
|
132 |
System.exit(0);
|
|
131 |
public void windowClosed(WindowEvent arg0) {
|
|
132 |
System.exit(0);
|
|
133 | 133 |
|
134 |
}
|
|
134 |
}
|
|
135 | 135 |
|
136 |
public void windowClosing(WindowEvent arg0) {
|
|
137 |
// TODO Auto-generated method stub
|
|
136 |
public void windowClosing(WindowEvent arg0) {
|
|
137 |
// TODO Auto-generated method stub
|
|
138 | 138 |
|
139 |
}
|
|
139 |
}
|
|
140 | 140 |
|
141 |
public void windowDeactivated(WindowEvent arg0) {
|
|
142 |
// TODO Auto-generated method stub
|
|
141 |
public void windowDeactivated(WindowEvent arg0) {
|
|
142 |
// TODO Auto-generated method stub
|
|
143 | 143 |
|
144 |
}
|
|
144 |
}
|
|
145 | 145 |
|
146 |
public void windowDeiconified(WindowEvent arg0) {
|
|
147 |
// TODO Auto-generated method stub
|
|
146 |
public void windowDeiconified(WindowEvent arg0) {
|
|
147 |
// TODO Auto-generated method stub
|
|
148 | 148 |
|
149 |
}
|
|
149 |
}
|
|
150 | 150 |
|
151 |
public void windowIconified(WindowEvent arg0) {
|
|
152 |
// TODO Auto-generated method stub
|
|
151 |
public void windowIconified(WindowEvent arg0) {
|
|
152 |
// TODO Auto-generated method stub
|
|
153 | 153 |
|
154 |
}
|
|
154 |
}
|
|
155 | 155 |
|
156 |
public void windowOpened(WindowEvent arg0) {
|
|
157 |
// TODO Auto-generated method stub
|
|
156 |
public void windowOpened(WindowEvent arg0) {
|
|
157 |
// TODO Auto-generated method stub
|
|
158 | 158 |
|
159 |
}
|
|
159 |
}
|
|
160 | 160 |
|
161 |
public void actionPerformed(ActionEvent arg0) {
|
|
162 |
File inputDirectory = inputText.getSelectedFile();
|
|
163 |
File outputFile = outputText.getSelectedFile();
|
|
161 |
public void actionPerformed(ActionEvent arg0) {
|
|
162 |
File inputDirectory = inputText.getSelectedFile();
|
|
163 |
File outputFile = outputText.getSelectedFile();
|
|
164 | 164 |
|
165 |
if (!inputDirectory.exists()) {
|
|
166 |
JOptionPane
|
|
167 |
.showMessageDialog(this, "Input directory doesn't exist");
|
|
168 |
return;
|
|
169 |
}
|
|
165 |
if (!inputDirectory.exists()) {
|
|
166 |
JOptionPane
|
|
167 |
.showMessageDialog(this, "Input directory doesn't exist");
|
|
168 |
return;
|
|
169 |
}
|
|
170 | 170 |
|
171 |
if (outputFile.exists()) {
|
|
172 |
outputFile.delete();
|
|
173 |
}
|
|
171 |
if (outputFile.exists()) {
|
|
172 |
outputFile.delete();
|
|
173 |
}
|
|
174 | 174 |
|
175 |
Compress compress = new Compress();
|
|
176 |
try {
|
|
177 |
File[] files = inputDirectory.listFiles();
|
|
178 |
List<File> filesArray = new ArrayList<File>();
|
|
179 |
List<String> fileNamesArray = new ArrayList<String>();
|
|
180 |
for (int i = 0; i < files.length; i++) {
|
|
181 |
if (!files[i].getName().toUpperCase().equals(".SVN")) {
|
|
182 |
filesArray.add(files[i]);
|
|
183 |
fileNamesArray.add(files[i].getName());
|
|
184 |
}
|
|
185 |
}
|
|
186 |
compress.compressPluginsAsPackageSet(filesArray, fileNamesArray,
|
|
187 |
new FileOutputStream(outputFile));
|
|
188 |
} catch (Exception e) {
|
|
189 |
JOptionPane.showMessageDialog(this, e.toString());
|
|
190 |
}
|
|
191 |
}
|
|
175 |
Compress compress = new Compress();
|
|
176 |
try {
|
|
177 |
File[] files = inputDirectory.listFiles();
|
|
178 |
List<File> filesArray = new ArrayList<File>();
|
|
179 |
List<String> fileNamesArray = new ArrayList<String>();
|
|
180 |
for (int i = 0; i < files.length; i++) {
|
|
181 |
if (!files[i].getName().toUpperCase().equals(".SVN")) {
|
|
182 |
filesArray.add(files[i]);
|
|
183 |
fileNamesArray.add(files[i].getName());
|
|
184 |
}
|
|
185 |
}
|
|
186 |
compress.compressPluginsAsPackageSet(filesArray, fileNamesArray,
|
|
187 |
new FileOutputStream(outputFile));
|
|
188 |
} catch (Exception e) {
|
|
189 |
JOptionPane.showMessageDialog(this, e.toString());
|
|
190 |
}
|
|
191 |
}
|
|
192 | 192 |
} |
Also available in: Unified diff