1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package net.sf.webphotos.gui; |
17 | |
|
18 | |
import java.awt.event.KeyEvent; |
19 | |
import java.io.File; |
20 | |
import java.io.FileWriter; |
21 | |
import java.io.IOException; |
22 | |
import java.text.ParseException; |
23 | |
import java.util.logging.Level; |
24 | |
import javax.swing.*; |
25 | |
import javax.swing.event.DocumentListener; |
26 | |
import javax.swing.event.TableModelEvent; |
27 | |
import net.sf.webphotos.Album; |
28 | |
import net.sf.webphotos.BancoImagem; |
29 | |
import net.sf.webphotos.PhotoDTO; |
30 | |
import net.sf.webphotos.action.*; |
31 | |
import net.sf.webphotos.dao.jpa.CategoryDAO; |
32 | |
import net.sf.webphotos.dao.jpa.CreditsDAO; |
33 | |
import net.sf.webphotos.gui.util.TableModelAlbum; |
34 | |
import net.sf.webphotos.gui.util.TableModelFoto; |
35 | |
import net.sf.webphotos.gui.util.TableSorter; |
36 | |
import net.sf.webphotos.model.CategoryVO; |
37 | |
import net.sf.webphotos.model.CreditsVO; |
38 | |
import net.sf.webphotos.tools.Thumbnail; |
39 | |
import net.sf.webphotos.util.ApplicationContextResource; |
40 | |
import net.sf.webphotos.util.Util; |
41 | |
import net.sf.webphotos.util.legacy.CacheFTP; |
42 | |
import org.apache.log4j.Logger; |
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | 57 | public class PainelWebFotos extends javax.swing.JPanel { |
50 | |
|
51 | 3 | private static Logger log = Logger.getLogger(PainelWebFotos.class); |
52 | |
private static PainelWebFotos janela; |
53 | |
|
54 | |
|
55 | |
|
56 | |
public static final String ACAO_NOVO = "novo"; |
57 | |
|
58 | |
|
59 | |
|
60 | |
public static final String ACAO_CANCELAR = "cancelar"; |
61 | |
|
62 | |
|
63 | |
|
64 | |
public static final String ACAO_FINALIZAR = "finalizar"; |
65 | |
|
66 | |
|
67 | |
|
68 | |
public static final String ACAO_ALTERAR = "alterar"; |
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | |
public static void montagemComboPesquisa(Boolean force) { |
76 | 6 | final String[] categoriasArray = Album.getAlbum().getCategoriasArray(force); |
77 | 6 | final DefaultComboBoxModel defaultComboBoxModel = new javax.swing.DefaultComboBoxModel(categoriasArray); |
78 | 6 | final DefaultComboBoxModel defaultComboBoxModelPainelPesquisa = new javax.swing.DefaultComboBoxModel(categoriasArray); |
79 | |
|
80 | 6 | defaultComboBoxModel.insertElementAt("", 0); |
81 | 6 | defaultComboBoxModel.setSelectedItem(defaultComboBoxModel.getElementAt(0)); |
82 | |
|
83 | 6 | defaultComboBoxModelPainelPesquisa.insertElementAt("Todas as Categorias", 0); |
84 | 6 | defaultComboBoxModelPainelPesquisa.setSelectedItem(defaultComboBoxModelPainelPesquisa.getElementAt(0)); |
85 | |
|
86 | 6 | lstCategoriasAlbum.setModel(defaultComboBoxModel); |
87 | 6 | painelPesquisa.setCategoriasPesquisaComboBoxModel(defaultComboBoxModelPainelPesquisa); |
88 | 6 | } |
89 | |
|
90 | |
|
91 | |
|
92 | |
|
93 | 3 | private PainelWebFotos() { |
94 | |
|
95 | 3 | TableModelAlbum.getModel().setUltimoSQL(Util.getConfig().getString("sql1")); |
96 | |
|
97 | |
|
98 | |
try { |
99 | 3 | mascaraData = new javax.swing.text.MaskFormatter("##/##/####"); |
100 | 0 | } catch (ParseException ex) { |
101 | 0 | log.error("Parsing Problem", ex); |
102 | 3 | } |
103 | |
|
104 | 3 | initComponents(); |
105 | |
try { |
106 | 3 | rotinasExtras(); |
107 | 0 | } catch (Exception ex) { |
108 | 0 | log.error("Unexpected", ex); |
109 | 3 | } |
110 | |
|
111 | 3 | } |
112 | |
|
113 | |
|
114 | |
|
115 | |
|
116 | |
|
117 | |
|
118 | |
|
119 | |
private void initComponents() { |
120 | |
java.awt.GridBagConstraints gridBagConstraints; |
121 | |
|
122 | 3 | lstCreditosTabelaFotos = new javax.swing.JComboBox(); |
123 | 3 | menuFoto = new javax.swing.JPopupMenu(); |
124 | 3 | menuItemFotoUp = new javax.swing.JMenuItem(); |
125 | 3 | menuItemFotoDown = new javax.swing.JMenuItem(); |
126 | 3 | menuSeparadorFoto = new javax.swing.JSeparator(); |
127 | 3 | menuItemFotoRedoThumbs = new javax.swing.JMenuItem(); |
128 | 3 | menuItemFotoDelete = new javax.swing.JMenuItem(); |
129 | 3 | menuAlbum = new javax.swing.JPopupMenu(); |
130 | 3 | menuItemAlbumRedoXML = new javax.swing.JMenuItem(); |
131 | 3 | menuItemAlbumRedoJS = new javax.swing.JMenuItem(); |
132 | 3 | menuSeparadorAlbum1 = new javax.swing.JSeparator(); |
133 | 3 | menuItemAlbumUp = new javax.swing.JMenuItem(); |
134 | 3 | menuItemAlbumDown = new javax.swing.JMenuItem(); |
135 | 3 | menuSeparadorAlbum2 = new javax.swing.JSeparator(); |
136 | 3 | menuItemAlbumRedoThumbs = new javax.swing.JMenuItem(); |
137 | 3 | menuItemAlbumDelete = new javax.swing.JMenuItem(); |
138 | 3 | painelPesquisa = new net.sf.webphotos.gui.component.PainelPesquisa(); |
139 | 3 | painelAlbuns = new javax.swing.JPanel(); |
140 | 3 | scrAlbuns = new javax.swing.JScrollPane(); |
141 | 3 | tbAlbuns = new javax.swing.JTable(); |
142 | 3 | lblTabelaInfo = new javax.swing.JLabel(); |
143 | 3 | painelDadosAlbum = new javax.swing.JPanel(); |
144 | 3 | painelInfoAlbum = new javax.swing.JPanel(); |
145 | 3 | lblAlbum = new javax.swing.JLabel(); |
146 | 3 | txtTitulo = new javax.swing.JTextField(); |
147 | 3 | lblCategoria = new javax.swing.JLabel(); |
148 | 3 | lstCategoriasAlbum = new javax.swing.JComboBox(); |
149 | 3 | buttonAddCategory = new net.sf.webphotos.gui.component.BotaoIcone(); |
150 | 3 | lblData = new javax.swing.JLabel(); |
151 | 3 | txtData = new javax.swing.JFormattedTextField(); |
152 | 3 | lblDescricao = new javax.swing.JLabel(); |
153 | 3 | scrDescricao = new javax.swing.JScrollPane(); |
154 | 3 | txtDescricao = new javax.swing.JTextArea(); |
155 | 3 | scrFotos = new javax.swing.JScrollPane(); |
156 | 3 | tbFotos = new javax.swing.JTable(); |
157 | 3 | painelFormFoto = new javax.swing.JPanel(); |
158 | 3 | painelFoto = new net.sf.webphotos.gui.component.PainelFoto(); |
159 | 3 | lblLegenda = new javax.swing.JLabel(); |
160 | 3 | scrLegenda = new javax.swing.JScrollPane(); |
161 | 3 | txtLegenda = new javax.swing.JTextArea(); |
162 | 3 | lstCreditos = new javax.swing.JComboBox(); |
163 | 3 | buttonAddCredits = new net.sf.webphotos.gui.component.BotaoIcone(); |
164 | 3 | painelControle = new javax.swing.JPanel(); |
165 | 3 | scrLog = new javax.swing.JScrollPane(); |
166 | 3 | txtLog = new javax.swing.JTextArea(); |
167 | 3 | painelToolBar = new javax.swing.JPanel(); |
168 | 3 | btFTP = new net.sf.webphotos.gui.component.BotaoIcone(); |
169 | 3 | btUpload = new net.sf.webphotos.gui.component.BotaoIcone(); |
170 | 3 | btDownload = new net.sf.webphotos.gui.component.BotaoIcone(); |
171 | 3 | btAdicionarFotos = new net.sf.webphotos.gui.component.BotaoIcone(); |
172 | 3 | btAlterar = new javax.swing.JButton(); |
173 | 3 | btNovo = new javax.swing.JButton(); |
174 | |
|
175 | 3 | lstCreditosTabelaFotos.setModel(new javax.swing.DefaultComboBoxModel(net.sf.webphotos.PhotoDTO.getCreditosArray())); |
176 | |
|
177 | 3 | menuItemFotoUp.setText("Enviar Foto"); |
178 | 3 | menuItemFotoUp.addActionListener(new java.awt.event.ActionListener() { |
179 | |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
180 | 0 | menuItemFotoUpActionPerformed(evt); |
181 | 0 | } |
182 | |
}); |
183 | 3 | menuFoto.add(menuItemFotoUp); |
184 | |
|
185 | 3 | menuItemFotoDown.setText("Receber Foto"); |
186 | 3 | menuItemFotoDown.addActionListener(new java.awt.event.ActionListener() { |
187 | |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
188 | 0 | menuItemFotoDownActionPerformed(evt); |
189 | 0 | } |
190 | |
}); |
191 | 3 | menuFoto.add(menuItemFotoDown); |
192 | 3 | menuFoto.add(menuSeparadorFoto); |
193 | |
|
194 | 3 | menuItemFotoRedoThumbs.setText("Refaz Thumbs"); |
195 | 3 | menuItemFotoRedoThumbs.addActionListener(new java.awt.event.ActionListener() { |
196 | |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
197 | 0 | menuItemFotoRedoThumbsActionPerformed(evt); |
198 | 0 | } |
199 | |
}); |
200 | 3 | menuFoto.add(menuItemFotoRedoThumbs); |
201 | |
|
202 | 3 | menuItemFotoDelete.setText("Excluir Foto"); |
203 | 3 | menuItemFotoDelete.addActionListener(new java.awt.event.ActionListener() { |
204 | |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
205 | 0 | menuItemFotoDeleteActionPerformed(evt); |
206 | 0 | } |
207 | |
}); |
208 | 3 | menuFoto.add(menuItemFotoDelete); |
209 | |
|
210 | 3 | menuItemAlbumRedoXML.setText("Gerar Arquivo XML"); |
211 | 3 | menuItemAlbumRedoXML.addActionListener(new java.awt.event.ActionListener() { |
212 | |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
213 | 0 | menuItemAlbumRedoXMLActionPerformed(evt); |
214 | 0 | } |
215 | |
}); |
216 | 3 | menuAlbum.add(menuItemAlbumRedoXML); |
217 | |
|
218 | 3 | menuItemAlbumRedoJS.setText("Gerar Arquivo JS"); |
219 | 3 | menuItemAlbumRedoJS.addActionListener(new java.awt.event.ActionListener() { |
220 | |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
221 | 0 | menuItemAlbumRedoJSActionPerformed(evt); |
222 | 0 | } |
223 | |
}); |
224 | 3 | menuAlbum.add(menuItemAlbumRedoJS); |
225 | 3 | menuAlbum.add(menuSeparadorAlbum1); |
226 | |
|
227 | 3 | menuItemAlbumUp.setText("Enviar Album"); |
228 | 3 | menuItemAlbumUp.addActionListener(new java.awt.event.ActionListener() { |
229 | |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
230 | 0 | menuItemAlbumUpActionPerformed(evt); |
231 | 0 | } |
232 | |
}); |
233 | 3 | menuAlbum.add(menuItemAlbumUp); |
234 | |
|
235 | 3 | menuItemAlbumDown.setText("Receber Album"); |
236 | 3 | menuItemAlbumDown.addActionListener(new java.awt.event.ActionListener() { |
237 | |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
238 | 0 | menuItemAlbumDownActionPerformed(evt); |
239 | 0 | } |
240 | |
}); |
241 | 3 | menuAlbum.add(menuItemAlbumDown); |
242 | 3 | menuAlbum.add(menuSeparadorAlbum2); |
243 | |
|
244 | 3 | menuItemAlbumRedoThumbs.setText("Refaz Thumbs"); |
245 | 3 | menuAlbum.add(menuItemAlbumRedoThumbs); |
246 | |
|
247 | 3 | menuItemAlbumDelete.setText("Apagar Album"); |
248 | 3 | menuAlbum.add(menuItemAlbumDelete); |
249 | |
|
250 | 3 | setName("PainelWebFotos"); |
251 | 3 | setLayout(new java.awt.GridBagLayout()); |
252 | 3 | gridBagConstraints = new java.awt.GridBagConstraints(); |
253 | 3 | gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
254 | 3 | gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; |
255 | 3 | gridBagConstraints.weightx = 1.0; |
256 | 3 | add(painelPesquisa, gridBagConstraints); |
257 | 3 | painelPesquisa.addPopupMouseListener((AcaoPopup) ApplicationContextResource.getBean("acaoPopup")); |
258 | |
|
259 | 3 | painelAlbuns.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); |
260 | 3 | painelAlbuns.setPreferredSize(new java.awt.Dimension(462, 150)); |
261 | 3 | painelAlbuns.setRequestFocusEnabled(false); |
262 | 3 | painelAlbuns.setLayout(new java.awt.BorderLayout()); |
263 | |
|
264 | 3 | scrAlbuns.addComponentListener(new java.awt.event.ComponentAdapter() { |
265 | |
public void componentResized(java.awt.event.ComponentEvent evt) { |
266 | 3 | tbAlbunsChanged(evt); |
267 | 3 | } |
268 | |
}); |
269 | |
|
270 | 3 | tbAlbuns.setModel(new TableSorter(TableModelAlbum.getModel(), tbAlbuns.getTableHeader())); |
271 | 3 | tbAlbuns.setToolTipText("Use o botão direito para mais opções"); |
272 | 3 | tbAlbuns.setName("tbAlbuns"); |
273 | 3 | tbAlbuns.addMouseListener(new java.awt.event.MouseAdapter() { |
274 | |
public void mouseClicked(java.awt.event.MouseEvent evt) { |
275 | 0 | tbAlbunsMouseClicked(evt); |
276 | 0 | } |
277 | |
public void mousePressed(java.awt.event.MouseEvent evt) { |
278 | 0 | tbAlbunsPopupCalled(evt); |
279 | 0 | } |
280 | |
public void mouseReleased(java.awt.event.MouseEvent evt) { |
281 | 0 | tbAlbunsPopupCalled(evt); |
282 | 0 | } |
283 | |
}); |
284 | 3 | scrAlbuns.setViewportView(tbAlbuns); |
285 | |
|
286 | 3 | painelAlbuns.add(scrAlbuns, java.awt.BorderLayout.CENTER); |
287 | |
|
288 | 3 | lblTabelaInfo.setFont(new java.awt.Font("SansSerif", 0, 10)); |
289 | 3 | lblTabelaInfo.setText("0 álbuns encontrados"); |
290 | 3 | painelAlbuns.add(lblTabelaInfo, java.awt.BorderLayout.SOUTH); |
291 | |
|
292 | 3 | gridBagConstraints = new java.awt.GridBagConstraints(); |
293 | 3 | gridBagConstraints.gridx = 0; |
294 | 3 | gridBagConstraints.gridy = 1; |
295 | 3 | gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
296 | 3 | gridBagConstraints.weightx = 1.0; |
297 | 3 | gridBagConstraints.weighty = 1.0; |
298 | 3 | add(painelAlbuns, gridBagConstraints); |
299 | |
|
300 | 3 | painelDadosAlbum.setLayout(new javax.swing.BoxLayout(painelDadosAlbum, javax.swing.BoxLayout.LINE_AXIS)); |
301 | |
|
302 | 3 | painelInfoAlbum.setBorder(javax.swing.BorderFactory.createEmptyBorder(3, 3, 3, 3)); |
303 | 3 | painelInfoAlbum.setMinimumSize(new java.awt.Dimension(500, 250)); |
304 | 3 | painelInfoAlbum.setPreferredSize(new java.awt.Dimension(500, 300)); |
305 | 3 | painelInfoAlbum.setLayout(new java.awt.GridBagLayout()); |
306 | |
|
307 | 3 | lblAlbum.setText("Album:"); |
308 | 3 | gridBagConstraints = new java.awt.GridBagConstraints(); |
309 | 3 | gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; |
310 | 3 | gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
311 | 3 | painelInfoAlbum.add(lblAlbum, gridBagConstraints); |
312 | |
|
313 | 3 | txtTitulo.setName("txtTitulo"); |
314 | 3 | txtTitulo.setPreferredSize(new java.awt.Dimension(477, 22)); |
315 | 3 | gridBagConstraints = new java.awt.GridBagConstraints(); |
316 | 3 | gridBagConstraints.gridx = 1; |
317 | 3 | gridBagConstraints.gridy = 0; |
318 | 3 | gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; |
319 | 3 | gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
320 | 3 | gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
321 | 3 | gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
322 | 3 | painelInfoAlbum.add(txtTitulo, gridBagConstraints); |
323 | |
|
324 | 3 | lblCategoria.setText("Categoria:"); |
325 | 3 | gridBagConstraints = new java.awt.GridBagConstraints(); |
326 | 3 | gridBagConstraints.gridx = 0; |
327 | 3 | gridBagConstraints.gridy = 1; |
328 | 3 | gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; |
329 | 3 | gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
330 | 3 | painelInfoAlbum.add(lblCategoria, gridBagConstraints); |
331 | |
|
332 | 3 | lstCategoriasAlbum.setModel(new javax.swing.DefaultComboBoxModel(Album.getAlbum().getCategoriasArray())); |
333 | 3 | lstCategoriasAlbum.setName("lstCategoriasAlbum"); |
334 | 3 | gridBagConstraints = new java.awt.GridBagConstraints(); |
335 | 3 | gridBagConstraints.gridx = 1; |
336 | 3 | gridBagConstraints.gridy = 1; |
337 | 3 | gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
338 | 3 | gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
339 | 3 | gridBagConstraints.weightx = 5.0; |
340 | 3 | gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
341 | 3 | painelInfoAlbum.add(lstCategoriasAlbum, gridBagConstraints); |
342 | |
|
343 | 3 | buttonAddCategory.setIconPrefix("plus"); |
344 | 3 | buttonAddCategory.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
345 | 3 | buttonAddCategory.setName("buttonAddCategory"); |
346 | 3 | buttonAddCategory.addActionListener(new java.awt.event.ActionListener() { |
347 | |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
348 | 3 | buttonAddCategoryActionPerformed(evt); |
349 | 3 | } |
350 | |
}); |
351 | 3 | gridBagConstraints = new java.awt.GridBagConstraints(); |
352 | 3 | gridBagConstraints.gridx = 2; |
353 | 3 | gridBagConstraints.gridy = 1; |
354 | 3 | gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
355 | 3 | painelInfoAlbum.add(buttonAddCategory, gridBagConstraints); |
356 | |
|
357 | 3 | lblData.setText("Data:"); |
358 | 3 | gridBagConstraints = new java.awt.GridBagConstraints(); |
359 | 3 | gridBagConstraints.gridx = 3; |
360 | 3 | gridBagConstraints.gridy = 1; |
361 | 3 | gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; |
362 | 3 | gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
363 | 3 | painelInfoAlbum.add(lblData, gridBagConstraints); |
364 | |
|
365 | 3 | txtData.setMinimumSize(new java.awt.Dimension(11, 22)); |
366 | 3 | txtData.setPreferredSize(new java.awt.Dimension(72, 22)); |
367 | 3 | gridBagConstraints = new java.awt.GridBagConstraints(); |
368 | 3 | gridBagConstraints.gridx = 4; |
369 | 3 | gridBagConstraints.gridy = 1; |
370 | 3 | gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
371 | 3 | gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
372 | 3 | gridBagConstraints.weightx = 1.0; |
373 | 3 | gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
374 | 3 | painelInfoAlbum.add(txtData, gridBagConstraints); |
375 | |
|
376 | 3 | lblDescricao.setText("Descrição:"); |
377 | 3 | gridBagConstraints = new java.awt.GridBagConstraints(); |
378 | 3 | gridBagConstraints.gridx = 0; |
379 | 3 | gridBagConstraints.gridy = 2; |
380 | 3 | gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST; |
381 | 3 | gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
382 | 3 | painelInfoAlbum.add(lblDescricao, gridBagConstraints); |
383 | |
|
384 | 3 | scrDescricao.setAutoscrolls(true); |
385 | |
|
386 | 3 | txtDescricao.setLineWrap(true); |
387 | 3 | txtDescricao.setWrapStyleWord(true); |
388 | 3 | txtDescricao.setName("txtDescricao"); |
389 | 3 | scrDescricao.setViewportView(txtDescricao); |
390 | |
|
391 | 3 | gridBagConstraints = new java.awt.GridBagConstraints(); |
392 | 3 | gridBagConstraints.gridx = 1; |
393 | 3 | gridBagConstraints.gridy = 2; |
394 | 3 | gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; |
395 | 3 | gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
396 | 3 | gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
397 | 3 | gridBagConstraints.weighty = 5.0; |
398 | 3 | gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
399 | 3 | painelInfoAlbum.add(scrDescricao, gridBagConstraints); |
400 | |
|
401 | 3 | tbFotos.setToolTipText("Use o botão direito para mais opções"); |
402 | 3 | tbFotos.setName("tbFotos"); |
403 | 3 | tbFotos.addMouseListener(new java.awt.event.MouseAdapter() { |
404 | |
public void mousePressed(java.awt.event.MouseEvent evt) { |
405 | 0 | tbFotosPopupCalled(evt); |
406 | 0 | } |
407 | |
public void mouseReleased(java.awt.event.MouseEvent evt) { |
408 | 0 | tbFotosPopupCalled(evt); |
409 | 0 | } |
410 | |
}); |
411 | 3 | scrFotos.setViewportView(tbFotos); |
412 | |
|
413 | 3 | gridBagConstraints = new java.awt.GridBagConstraints(); |
414 | 3 | gridBagConstraints.gridx = 0; |
415 | 3 | gridBagConstraints.gridy = 3; |
416 | 3 | gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; |
417 | 3 | gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
418 | 3 | gridBagConstraints.weighty = 10.0; |
419 | 3 | gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
420 | 3 | painelInfoAlbum.add(scrFotos, gridBagConstraints); |
421 | |
|
422 | 3 | painelDadosAlbum.add(painelInfoAlbum); |
423 | |
|
424 | 3 | painelFormFoto.setBorder(javax.swing.BorderFactory.createEmptyBorder(3, 3, 3, 3)); |
425 | 3 | painelFormFoto.setMaximumSize(new java.awt.Dimension(210, 2147483647)); |
426 | 3 | painelFormFoto.setMinimumSize(new java.awt.Dimension(210, 24)); |
427 | 3 | painelFormFoto.setPreferredSize(new java.awt.Dimension(210, 24)); |
428 | 3 | painelFormFoto.setLayout(new java.awt.GridBagLayout()); |
429 | 3 | gridBagConstraints = new java.awt.GridBagConstraints(); |
430 | 3 | gridBagConstraints.gridx = 0; |
431 | 3 | gridBagConstraints.gridy = 0; |
432 | 3 | gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; |
433 | 3 | gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
434 | 3 | gridBagConstraints.weightx = 1.0; |
435 | 3 | gridBagConstraints.weighty = 5.0; |
436 | 3 | gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
437 | 3 | painelFormFoto.add(painelFoto, gridBagConstraints); |
438 | |
|
439 | 3 | lblLegenda.setText("Legenda e crédito:"); |
440 | 3 | gridBagConstraints = new java.awt.GridBagConstraints(); |
441 | 3 | gridBagConstraints.gridx = 0; |
442 | 3 | gridBagConstraints.gridy = 1; |
443 | 3 | gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; |
444 | 3 | gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
445 | 3 | gridBagConstraints.weightx = 1.0; |
446 | 3 | gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
447 | 3 | painelFormFoto.add(lblLegenda, gridBagConstraints); |
448 | |
|
449 | 3 | scrLegenda.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); |
450 | 3 | scrLegenda.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); |
451 | |
|
452 | 3 | txtLegenda.setLineWrap(true); |
453 | 3 | txtLegenda.setWrapStyleWord(true); |
454 | 3 | txtLegenda.setName("txtLegenda"); |
455 | 3 | txtLegenda.addFocusListener(new java.awt.event.FocusAdapter() { |
456 | |
public void focusGained(java.awt.event.FocusEvent evt) { |
457 | 0 | txtLegendaFocusGained(evt); |
458 | 0 | } |
459 | |
public void focusLost(java.awt.event.FocusEvent evt) { |
460 | 0 | txtLegendaFocusLost(evt); |
461 | 0 | } |
462 | |
}); |
463 | 3 | scrLegenda.setViewportView(txtLegenda); |
464 | |
|
465 | 3 | gridBagConstraints = new java.awt.GridBagConstraints(); |
466 | 3 | gridBagConstraints.gridx = 0; |
467 | 3 | gridBagConstraints.gridy = 2; |
468 | 3 | gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; |
469 | 3 | gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
470 | 3 | gridBagConstraints.weightx = 1.0; |
471 | 3 | gridBagConstraints.weighty = 3.0; |
472 | 3 | gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
473 | 3 | painelFormFoto.add(scrLegenda, gridBagConstraints); |
474 | |
|
475 | 3 | lstCreditos.setModel(new javax.swing.DefaultComboBoxModel(net.sf.webphotos.PhotoDTO.getCreditosArray())); |
476 | 3 | lstCreditos.setName("lstCreditos"); |
477 | 3 | gridBagConstraints = new java.awt.GridBagConstraints(); |
478 | 3 | gridBagConstraints.gridx = 0; |
479 | 3 | gridBagConstraints.gridy = 3; |
480 | 3 | gridBagConstraints.gridwidth = 3; |
481 | 3 | gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
482 | 3 | gridBagConstraints.weightx = 1.0; |
483 | 3 | gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
484 | 3 | painelFormFoto.add(lstCreditos, gridBagConstraints); |
485 | |
|
486 | 3 | buttonAddCredits.setIconPrefix("plus"); |
487 | 3 | buttonAddCredits.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
488 | 3 | buttonAddCredits.setName("buttonAddCredits"); |
489 | 3 | buttonAddCredits.addActionListener(new java.awt.event.ActionListener() { |
490 | |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
491 | 3 | buttonAddCreditsActionPerformed(evt); |
492 | 3 | } |
493 | |
}); |
494 | 3 | gridBagConstraints = new java.awt.GridBagConstraints(); |
495 | 3 | gridBagConstraints.gridx = 3; |
496 | 3 | gridBagConstraints.gridy = 3; |
497 | 3 | gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
498 | 3 | painelFormFoto.add(buttonAddCredits, gridBagConstraints); |
499 | |
|
500 | 3 | painelDadosAlbum.add(painelFormFoto); |
501 | |
|
502 | 3 | gridBagConstraints = new java.awt.GridBagConstraints(); |
503 | 3 | gridBagConstraints.gridx = 0; |
504 | 3 | gridBagConstraints.gridy = 2; |
505 | 3 | gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
506 | 3 | gridBagConstraints.weightx = 1.0; |
507 | 3 | gridBagConstraints.weighty = 1.5; |
508 | 3 | add(painelDadosAlbum, gridBagConstraints); |
509 | |
|
510 | 3 | painelControle.setMaximumSize(new java.awt.Dimension(32767, 73)); |
511 | 3 | painelControle.setMinimumSize(new java.awt.Dimension(710, 73)); |
512 | 3 | painelControle.setLayout(new java.awt.GridBagLayout()); |
513 | |
|
514 | 3 | scrLog.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); |
515 | 3 | scrLog.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); |
516 | 3 | scrLog.setAutoscrolls(true); |
517 | 3 | scrLog.setMaximumSize(new java.awt.Dimension(32767, 63)); |
518 | 3 | scrLog.setMinimumSize(new java.awt.Dimension(24, 63)); |
519 | 3 | scrLog.setPreferredSize(new java.awt.Dimension(22, 63)); |
520 | |
|
521 | 3 | txtLog.setFont(new java.awt.Font("Courier", 0, 11)); |
522 | 3 | scrLog.setViewportView(txtLog); |
523 | |
|
524 | 3 | gridBagConstraints = new java.awt.GridBagConstraints(); |
525 | 3 | gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
526 | 3 | gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST; |
527 | 3 | gridBagConstraints.weightx = 100.0; |
528 | 3 | gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); |
529 | 3 | painelControle.add(scrLog, gridBagConstraints); |
530 | |
|
531 | 3 | painelToolBar.setBorder(javax.swing.BorderFactory.createEmptyBorder(3, 3, 3, 3)); |
532 | 3 | painelToolBar.setLayout(new java.awt.GridBagLayout()); |
533 | |
|
534 | 3 | btFTP.setIconPrefix("ftp"); |
535 | 3 | btFTP.setToolTipText("Realiza a trasferência dos Álbuns Marcados"); |
536 | 3 | gridBagConstraints = new java.awt.GridBagConstraints(); |
537 | 3 | gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST; |
538 | 3 | gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
539 | 3 | painelToolBar.add(btFTP, gridBagConstraints); |
540 | |
|
541 | 3 | btUpload.setIconPrefix("up"); |
542 | 3 | btUpload.setToolTipText("Marca o Álbum para Upload"); |
543 | 3 | gridBagConstraints = new java.awt.GridBagConstraints(); |
544 | 3 | gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
545 | 3 | painelToolBar.add(btUpload, gridBagConstraints); |
546 | |
|
547 | 3 | btDownload.setIconPrefix("down"); |
548 | 3 | btDownload.setToolTipText("Marca o Álbum para Download"); |
549 | 3 | gridBagConstraints = new java.awt.GridBagConstraints(); |
550 | 3 | gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
551 | 3 | painelToolBar.add(btDownload, gridBagConstraints); |
552 | |
|
553 | 3 | btAdicionarFotos.setIconPrefix("camera"); |
554 | 3 | btAdicionarFotos.setName("buttonAddPhotos"); |
555 | 3 | btAdicionarFotos.setToolTipText("Adiciona uma nova foto ao Álbum"); |
556 | 3 | gridBagConstraints = new java.awt.GridBagConstraints(); |
557 | 3 | gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
558 | 3 | painelToolBar.add(btAdicionarFotos, gridBagConstraints); |
559 | |
|
560 | 3 | btAlterar.setText("alterar"); |
561 | 3 | btAlterar.setToolTipText("Efetiva as alterações do álbum"); |
562 | 3 | btAlterar.setActionCommand(ACAO_ALTERAR); |
563 | 3 | btAlterar.setEnabled(false); |
564 | 3 | gridBagConstraints = new java.awt.GridBagConstraints(); |
565 | 3 | gridBagConstraints.gridx = 0; |
566 | 3 | gridBagConstraints.gridy = 1; |
567 | 3 | gridBagConstraints.gridwidth = 2; |
568 | 3 | gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
569 | 3 | gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
570 | 3 | painelToolBar.add(btAlterar, gridBagConstraints); |
571 | |
|
572 | 3 | btNovo.setText("Adicionar"); |
573 | 3 | btNovo.setToolTipText("Criar novo álbum"); |
574 | 3 | btNovo.setActionCommand(ACAO_NOVO); |
575 | 3 | btNovo.setName("btNovo"); |
576 | 3 | gridBagConstraints = new java.awt.GridBagConstraints(); |
577 | 3 | gridBagConstraints.gridx = 2; |
578 | 3 | gridBagConstraints.gridy = 1; |
579 | 3 | gridBagConstraints.gridwidth = 2; |
580 | 3 | gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
581 | 3 | gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
582 | 3 | painelToolBar.add(btNovo, gridBagConstraints); |
583 | |
|
584 | 3 | gridBagConstraints = new java.awt.GridBagConstraints(); |
585 | 3 | gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; |
586 | 3 | gridBagConstraints.weightx = 1.0; |
587 | 3 | painelControle.add(painelToolBar, gridBagConstraints); |
588 | |
|
589 | 3 | gridBagConstraints = new java.awt.GridBagConstraints(); |
590 | 3 | gridBagConstraints.gridx = 0; |
591 | 3 | gridBagConstraints.gridy = 3; |
592 | 3 | gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
593 | 3 | gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH; |
594 | 3 | gridBagConstraints.weightx = 1.0; |
595 | 3 | add(painelControle, gridBagConstraints); |
596 | 3 | } |
597 | |
|
598 | |
|
599 | |
|
600 | |
|
601 | |
|
602 | |
private void menuItemAlbumRedoJSActionPerformed(java.awt.event.ActionEvent evt) { |
603 | |
|
604 | 0 | (new SwingWorker<Void, Object>() { |
605 | |
@Override |
606 | |
protected Void doInBackground() throws Exception { |
607 | |
String caminhoAlbum; |
608 | |
FileWriter out; |
609 | |
|
610 | 0 | setCursorWait(true); |
611 | |
|
612 | |
|
613 | |
|
614 | 0 | int albumAtual = Album.getAlbum().getAlbumID(); |
615 | 0 | int[] rowsID = tbAlbuns.getSelectedRows(); |
616 | 0 | for (int rowID : rowsID) { |
617 | 0 | log.info("Gravando arquivo JS do álbum: " + tbAlbuns.getValueAt(rowID, 0).toString()); |
618 | 0 | Album.getAlbum().loadAlbum(Integer.parseInt(tbAlbuns.getValueAt(rowID, 0).toString())); |
619 | 0 | caminhoAlbum = Util.getAlbunsRoot().getPath() + File.separator + Album.getAlbum().getAlbumID(); |
620 | |
try { |
621 | 0 | out = new FileWriter(caminhoAlbum + File.separator + Album.getAlbum().getAlbumID() + ".js"); |
622 | 0 | out.write(Album.getAlbum().toJavaScript()); |
623 | 0 | out.flush(); |
624 | 0 | out.close(); |
625 | |
|
626 | 0 | log.info("Arquivo JS gravado."); |
627 | 0 | } catch (IOException ex) { |
628 | 0 | log.error("Error trying to write a JS File", ex); |
629 | 0 | } |
630 | |
|
631 | |
} |
632 | 0 | Album.getAlbum().loadAlbum(albumAtual); |
633 | 0 | setCursorWait(false); |
634 | |
|
635 | 0 | return null; |
636 | |
} |
637 | |
}).execute(); |
638 | |
|
639 | 0 | } |
640 | |
|
641 | |
|
642 | |
|
643 | |
|
644 | |
|
645 | |
private void menuItemAlbumRedoXMLActionPerformed(java.awt.event.ActionEvent evt) { |
646 | |
|
647 | 0 | (new SwingWorker<Void, Object>() { |
648 | |
@Override |
649 | |
protected Void doInBackground() throws Exception { |
650 | |
String caminhoAlbum; |
651 | |
FileWriter out; |
652 | |
|
653 | 0 | setCursorWait(true); |
654 | |
|
655 | |
|
656 | |
|
657 | 0 | int albumAtual = Album.getAlbum().getAlbumID(); |
658 | 0 | int[] rowsID = tbAlbuns.getSelectedRows(); |
659 | 0 | for (int rowID : rowsID) { |
660 | 0 | log.info("Gravando arquivo XML do álbum: " + tbAlbuns.getValueAt(rowID, 0).toString()); |
661 | 0 | Album.getAlbum().loadAlbum(Integer.parseInt(tbAlbuns.getValueAt(rowID, 0).toString())); |
662 | 0 | caminhoAlbum = Util.getAlbunsRoot().getPath() + File.separator + Album.getAlbum().getAlbumID(); |
663 | |
try { |
664 | 0 | out = new FileWriter(caminhoAlbum + File.separator + Album.getAlbum().getAlbumID() + ".xml"); |
665 | 0 | out.write(Album.getAlbum().toXML()); |
666 | 0 | out.flush(); |
667 | 0 | out.close(); |
668 | |
|
669 | 0 | log.info("Arquivo XML gravado."); |
670 | 0 | } catch (IOException ex) { |
671 | 0 | log.error("Error trying to write a XML File", ex); |
672 | 0 | } |
673 | |
|
674 | |
} |
675 | 0 | Album.getAlbum().loadAlbum(albumAtual); |
676 | 0 | setCursorWait(false); |
677 | 0 | return null; |
678 | |
} |
679 | |
}).execute(); |
680 | |
|
681 | 0 | } |
682 | |
|
683 | |
private void menuItemAlbumDownActionPerformed(java.awt.event.ActionEvent evt) { |
684 | 0 | PainelWebFotos.marcaAlbunsFTP(2); |
685 | 0 | } |
686 | |
|
687 | |
private void menuItemAlbumUpActionPerformed(java.awt.event.ActionEvent evt) { |
688 | 0 | PainelWebFotos.marcaAlbunsFTP(1); |
689 | 0 | } |
690 | |
|
691 | |
private void tbAlbunsPopupCalled(java.awt.event.MouseEvent evt) { |
692 | 0 | if (tbAlbuns.getSelectedRowCount() <= 1) { |
693 | 0 | int selecao = tbAlbuns.rowAtPoint(evt.getPoint()); |
694 | 0 | tbAlbuns.setRowSelectionInterval(selecao, selecao); |
695 | |
} |
696 | 0 | if (evt.isPopupTrigger()) { |
697 | 0 | menuAlbum.show(evt.getComponent(), evt.getX(), evt.getY()); |
698 | |
} |
699 | 0 | } |
700 | |
|
701 | |
private void menuItemFotoDeleteActionPerformed(java.awt.event.ActionEvent evt) { |
702 | |
|
703 | 0 | } |
704 | |
|
705 | |
private void menuItemFotoRedoThumbsActionPerformed(java.awt.event.ActionEvent evt) { |
706 | |
|
707 | 0 | (new SwingWorker<Void, Object>() { |
708 | |
@Override |
709 | |
protected Void doInBackground() throws Exception { |
710 | 0 | setCursorWait(true); |
711 | 0 | int[] rowsID = tbFotos.getSelectedRows(); |
712 | 0 | for (int rowID : rowsID) { |
713 | 0 | PhotoDTO fotoSelecionada = Album.getAlbum().getFoto(Integer.parseInt(tbFotos.getValueAt(rowID, 0).toString())); |
714 | 0 | String caminhoAlbum = Util.getAlbunsRoot().getPath() + File.separator + Album.getAlbum().getAlbumID(); |
715 | 0 | String caminhoArquivo = caminhoAlbum + File.separator + fotoSelecionada.getFotoID() + ".jpg"; |
716 | 0 | log.debug("Foto: " + caminhoArquivo + " " + Integer.parseInt(tbFotos.getValueAt(tbFotos.getSelectedRow(), 0).toString())); |
717 | 0 | Thumbnail.makeThumbs(caminhoArquivo); |
718 | |
} |
719 | 0 | setCursorWait(false); |
720 | 0 | return null; |
721 | |
} |
722 | |
}).execute(); |
723 | |
|
724 | 0 | } |
725 | |
|
726 | |
private void menuItemFotoDownActionPerformed(java.awt.event.ActionEvent evt) { |
727 | 0 | PainelWebFotos.marcaFotosFTP(2); |
728 | 0 | } |
729 | |
|
730 | |
private void menuItemFotoUpActionPerformed(java.awt.event.ActionEvent evt) { |
731 | 0 | PainelWebFotos.marcaFotosFTP(1); |
732 | 0 | } |
733 | |
|
734 | |
private void txtLegendaFocusLost(java.awt.event.FocusEvent evt) { |
735 | |
PhotoDTO f; |
736 | |
String nomeArquivoNovo; |
737 | |
|
738 | |
try { |
739 | |
|
740 | 0 | int fID = Integer.parseInt(tbFotos.getModel().getValueAt(indiceFoto, 0).toString()); |
741 | 0 | f = Album.getAlbum().getFoto(fID); |
742 | 0 | } catch (Exception ex) { |
743 | |
|
744 | 0 | nomeArquivoNovo = (String) tbFotos.getModel().getValueAt(indiceFoto, 0); |
745 | 0 | f = Album.getAlbum().getFoto(nomeArquivoNovo); |
746 | 0 | } |
747 | |
|
748 | 0 | f.setLegenda(txtLegenda.getText()); |
749 | 0 | TableModelFoto.getModel().update(); |
750 | 0 | TableModelFoto.getModel().fireTableCellUpdated(indiceFoto, 1); |
751 | 0 | } |
752 | |
|
753 | |
private void txtLegendaFocusGained(java.awt.event.FocusEvent evt) { |
754 | 0 | indiceFoto = tbFotos.getSelectedRow(); |
755 | 0 | } |
756 | |
|
757 | |
private void tbFotosPopupCalled(java.awt.event.MouseEvent evt) { |
758 | 0 | if (tbFotos.getSelectedRowCount() <= 1) { |
759 | 0 | int selecao = tbFotos.rowAtPoint(evt.getPoint()); |
760 | 0 | tbFotos.setRowSelectionInterval(selecao, selecao); |
761 | |
} |
762 | 0 | if (evt.isPopupTrigger()) { |
763 | 0 | menuFoto.show(evt.getComponent(), evt.getX(), evt.getY()); |
764 | |
} |
765 | 0 | } |
766 | |
|
767 | |
private void tbAlbunsChanged(java.awt.event.ComponentEvent evt) { |
768 | 3 | Util.ajustaLargura(tbAlbuns, Util.getProperty("colunas1")); |
769 | 3 | } |
770 | |
|
771 | |
private void tbAlbunsMouseClicked(java.awt.event.MouseEvent evt) { |
772 | 0 | tbAlbunsItemSelected(); |
773 | 0 | } |
774 | |
|
775 | |
private void buttonAddCategoryActionPerformed(java.awt.event.ActionEvent evt) { |
776 | 3 | String categoryName = JOptionPane.showInputDialog(this, "Type the new category name", "New Category", JOptionPane.INFORMATION_MESSAGE); |
777 | |
|
778 | 3 | if (categoryName.isEmpty()) { |
779 | 0 | return; |
780 | |
} |
781 | |
|
782 | 3 | CategoryVO categoryVO = new CategoryVO(categoryName); |
783 | |
|
784 | 3 | CategoryDAO categoryDAO = (CategoryDAO) ApplicationContextResource.getBean("categoryDAO"); |
785 | |
try { |
786 | 3 | categoryDAO.save(categoryVO); |
787 | 0 | } catch (Exception ex) { |
788 | 0 | JOptionPane.showMessageDialog(this, "Can't add category, see aplication log for details", "Error", JOptionPane.ERROR_MESSAGE); |
789 | 0 | java.util.logging.Logger.getLogger(PainelWebFotos.class.getName()).log(Level.SEVERE, ex.getMessage(), ex); |
790 | 3 | } |
791 | 3 | PainelWebFotos.montagemComboPesquisa(Boolean.TRUE); |
792 | 3 | } |
793 | |
|
794 | |
private void buttonAddCreditsActionPerformed(java.awt.event.ActionEvent evt) { |
795 | 3 | String creditsName = JOptionPane.showInputDialog(this, "Type the new credits name", "New Credits", JOptionPane.INFORMATION_MESSAGE); |
796 | |
|
797 | 3 | if (creditsName.isEmpty()) { |
798 | 0 | return; |
799 | |
} |
800 | |
|
801 | 3 | CreditsVO creditsVO = new CreditsVO(creditsName); |
802 | |
|
803 | 3 | CreditsDAO creditsDAO = (CreditsDAO) ApplicationContextResource.getBean("creditsDAO"); |
804 | |
|
805 | |
try { |
806 | 3 | creditsDAO.save(creditsVO); |
807 | |
|
808 | |
|
809 | 3 | PhotoDTO.populaCreditos(); |
810 | 3 | populateCreditsComboBox(); |
811 | 0 | } catch (Exception ex) { |
812 | 0 | JOptionPane.showMessageDialog(this, "Can't add credits, see aplication log for details", "Error", JOptionPane.ERROR_MESSAGE); |
813 | 0 | java.util.logging.Logger.getLogger(PainelWebFotos.class.getName()).log(Level.SEVERE, ex.getMessage(), ex); |
814 | 3 | } |
815 | 3 | } |
816 | |
|
817 | |
|
818 | |
|
819 | |
|
820 | |
|
821 | |
|
822 | |
|
823 | |
public static PainelWebFotos getInstance() { |
824 | 21 | if (janela == null) { |
825 | 3 | janela = new PainelWebFotos(); |
826 | |
} |
827 | 21 | return janela; |
828 | |
} |
829 | |
|
830 | |
|
831 | |
|
832 | |
|
833 | |
|
834 | |
|
835 | |
|
836 | |
|
837 | |
|
838 | |
|
839 | |
public static void marcaFotosFTP(int comando) { |
840 | |
try { |
841 | 0 | for (int indiceFotoSelecionada : tbFotos.getSelectedRows()) { |
842 | 0 | PhotoDTO fotoSelecionada = Album.getAlbum().getFotos()[indiceFotoSelecionada]; |
843 | 0 | CacheFTP.getCache().addCommand(comando, Album.getAlbum().getAlbumID(), fotoSelecionada.getFotoID()); |
844 | |
} |
845 | 0 | } catch (Exception e) { |
846 | 0 | log.error("Error marking Photos", e); |
847 | 0 | } |
848 | 0 | } |
849 | |
|
850 | |
|
851 | |
|
852 | |
|
853 | |
|
854 | |
|
855 | |
|
856 | |
|
857 | |
|
858 | |
|
859 | |
public static void marcaAlbunsFTP(int comando) { |
860 | |
try { |
861 | 0 | for (int indiceAlbumSelecionado : tbAlbuns.getSelectedRows()) { |
862 | 0 | CacheFTP.getCache().addCommand(comando, Integer.parseInt(tbAlbuns.getValueAt(indiceAlbumSelecionado, 0).toString()), 0); |
863 | |
} |
864 | 0 | } catch (Exception e) { |
865 | 0 | log.error("Error marking Albuns", e); |
866 | 0 | } |
867 | 0 | } |
868 | |
|
869 | |
|
870 | |
|
871 | |
|
872 | |
|
873 | |
|
874 | |
private static void rotinasExtras() throws Exception { |
875 | |
|
876 | |
|
877 | |
|
878 | |
|
879 | 3 | Action acaoExcluirAlbum = (Action) ApplicationContextResource.getBean("acaoExcluirAlbum"); |
880 | 3 | tbAlbuns.registerKeyboardAction(acaoExcluirAlbum, |
881 | |
javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_DELETE, 0), |
882 | |
javax.swing.JComponent.WHEN_FOCUSED); |
883 | |
|
884 | |
|
885 | 3 | btAdicionarFotos.addActionListener(new AcaoAdicionarFoto(tbFotos, lstCreditosTabelaFotos, "Adicionar fotos no álbum")); |
886 | |
|
887 | |
|
888 | 3 | javax.swing.Action acaoExcluirFoto = new AcaoExcluirFoto(tbFotos); |
889 | 3 | tbFotos.registerKeyboardAction(acaoExcluirFoto, |
890 | |
javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_DELETE, 0), |
891 | |
javax.swing.JComponent.WHEN_FOCUSED); |
892 | |
|
893 | |
|
894 | 3 | javax.swing.Action acaoAlterarAlbum = new AcaoAlterarAlbum(btNovo, btAlterar); |
895 | 3 | btAlterar.addActionListener(acaoAlterarAlbum); |
896 | 3 | btNovo.addActionListener(acaoAlterarAlbum); |
897 | |
|
898 | |
|
899 | 3 | lstCategoriasAlbum.addItemListener(new AcaoItemListener()); |
900 | |
|
901 | |
|
902 | 3 | txtDescricao.registerKeyboardAction(null, |
903 | |
KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), JComponent.WHEN_FOCUSED); |
904 | |
|
905 | |
|
906 | |
|
907 | 3 | AcaoItemListener acaoItemListener = new AcaoItemListener(tbFotos); |
908 | 3 | lstCreditos.addItemListener(acaoItemListener); |
909 | 3 | lstCreditosTabelaFotos.addItemListener(acaoItemListener); |
910 | |
|
911 | |
|
912 | 3 | Util.setLoggingTextArea(txtLog); |
913 | 3 | Util.ajustaLargura(tbAlbuns, Util.getConfig().getString("colunas1")); |
914 | |
|
915 | |
|
916 | 3 | apresentaNumReg(); |
917 | 3 | atualizaTabelaFotos(); |
918 | 3 | montagemComboPesquisa(Boolean.FALSE); |
919 | |
|
920 | |
|
921 | 3 | DocumentListener acaoDocumentListener = (DocumentListener) ApplicationContextResource.getBean("acaoDocumentListener"); |
922 | |
|
923 | 3 | txtTitulo.getDocument().addDocumentListener(acaoDocumentListener); |
924 | 3 | txtData.getDocument().addDocumentListener(acaoDocumentListener); |
925 | 3 | txtDescricao.getDocument().addDocumentListener(acaoDocumentListener); |
926 | 3 | txtLegenda.getDocument().addDocumentListener(acaoDocumentListener); |
927 | |
|
928 | |
|
929 | 3 | mascaraData.install(txtData); |
930 | |
|
931 | |
|
932 | 3 | tbFotos.getSelectionModel().addListSelectionListener(new javax.swing.event.ListSelectionListener() { |
933 | |
@Override |
934 | |
public void valueChanged(javax.swing.event.ListSelectionEvent e) { |
935 | |
|
936 | 45 | if (e.getValueIsAdjusting()) { |
937 | 30 | return; |
938 | |
} |
939 | |
|
940 | 15 | javax.swing.ListSelectionModel lsm = |
941 | |
(javax.swing.ListSelectionModel) e.getSource(); |
942 | 15 | if (!lsm.isSelectionEmpty()) { |
943 | |
|
944 | 12 | PainelWebFotos.getInstance().carregaFoto(); |
945 | |
} |
946 | 15 | } |
947 | |
}); |
948 | |
|
949 | |
|
950 | 3 | tbFotos.getModel().addTableModelListener(new javax.swing.event.TableModelListener() { |
951 | |
@Override |
952 | |
public void tableChanged(TableModelEvent e) { |
953 | 30 | Util.ajustaLargura(tbFotos, Util.getProperty("colunas2")); |
954 | 30 | } |
955 | |
}); |
956 | |
|
957 | |
|
958 | 3 | tbAlbuns.getSelectionModel().addListSelectionListener(new javax.swing.event.ListSelectionListener() { |
959 | |
@Override |
960 | |
public void valueChanged(javax.swing.event.ListSelectionEvent e) { |
961 | |
|
962 | 0 | if (e.getValueIsAdjusting()) { |
963 | 0 | return; |
964 | |
} |
965 | |
|
966 | 0 | javax.swing.ListSelectionModel lsm = |
967 | |
(javax.swing.ListSelectionModel) e.getSource(); |
968 | 0 | if (!lsm.isSelectionEmpty()) { |
969 | |
|
970 | 0 | PainelWebFotos.getInstance().tbAlbunsItemSelected(); |
971 | |
} |
972 | 0 | } |
973 | |
}); |
974 | |
|
975 | |
|
976 | 3 | tbAlbuns.getModel().addTableModelListener(new javax.swing.event.TableModelListener() { |
977 | |
@Override |
978 | |
public void tableChanged(TableModelEvent e) { |
979 | 6 | Util.ajustaLargura(tbAlbuns, Util.getProperty("colunas1")); |
980 | 6 | } |
981 | |
}); |
982 | |
|
983 | |
|
984 | 3 | resetAlbum(); |
985 | 3 | onoffPauta(false); |
986 | 3 | } |
987 | |
|
988 | |
|
989 | |
|
990 | |
|
991 | |
|
992 | |
|
993 | |
|
994 | |
|
995 | |
public static void setCursorWait(boolean valor) { |
996 | 6 | if (valor) { |
997 | 3 | PainelWebFotos.getInstance().setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR)); |
998 | |
} else { |
999 | 3 | PainelWebFotos.getInstance().setCursor(null); |
1000 | |
} |
1001 | 6 | } |
1002 | |
|
1003 | |
|
1004 | |
|
1005 | |
|
1006 | |
|
1007 | |
|
1008 | |
public static void alteracaoFinalizada() { |
1009 | 6 | documentoAlterado = false; |
1010 | 6 | btAlterar.setEnabled(false); |
1011 | 6 | } |
1012 | |
|
1013 | |
|
1014 | |
|
1015 | |
|
1016 | |
|
1017 | |
|
1018 | |
|
1019 | |
|
1020 | |
|
1021 | |
public static void alteracaoDetectada() { |
1022 | 93 | if (controlarAlteracoes) { |
1023 | 63 | if (Album.getAlbum().getNmAlbum().equals(txtTitulo.getText()) |
1024 | |
&& Album.getAlbum().getDtInsercao().equals(txtData.getText()) |
1025 | |
&& Album.getAlbum().getDescricao().equals(txtDescricao.getText()) |
1026 | |
&& Album.getAlbum().getCategoriaID() == Album.getAlbum().getLstCategoriasID(lstCategoriasAlbum.getSelectedItem().toString()) |
1027 | |
&& Album.getAlbum().toString().equals(ultimoAlbum)) { |
1028 | 0 | alteracaoFinalizada(); |
1029 | 0 | return; |
1030 | |
} |
1031 | 63 | documentoAlterado = true; |
1032 | 63 | btAlterar.setEnabled(true); |
1033 | |
} |
1034 | 93 | } |
1035 | |
|
1036 | |
|
1037 | |
|
1038 | |
|
1039 | |
|
1040 | |
|
1041 | |
|
1042 | |
|
1043 | |
public static void detectarAlteracoes(boolean valor) { |
1044 | 6 | controlarAlteracoes = valor; |
1045 | 6 | } |
1046 | |
|
1047 | |
|
1048 | |
|
1049 | |
|
1050 | |
private void tbAlbunsItemSelected() { |
1051 | |
|
1052 | 0 | if (tbFotos.isEditing()) { |
1053 | 0 | tbFotos.removeEditor(); |
1054 | |
} |
1055 | |
|
1056 | |
|
1057 | 0 | if (btNovo.getActionCommand().equals(ACAO_FINALIZAR)) { |
1058 | 0 | Object[] opcoes = {"Retornar", "Abandonar álbum"}; |
1059 | 0 | Object valorInicial = opcoes[0]; |
1060 | |
|
1061 | 0 | int retorno = javax.swing.JOptionPane.showOptionDialog(null, |
1062 | |
"O álbum que você estava criando não foi finalizado", |
1063 | |
"Cancelar criação de álbum ?", |
1064 | |
javax.swing.JOptionPane.OK_OPTION, |
1065 | |
javax.swing.JOptionPane.QUESTION_MESSAGE, |
1066 | |
null, |
1067 | |
opcoes, |
1068 | |
valorInicial); |
1069 | |
|
1070 | 0 | if (retorno == 0) { |
1071 | 0 | tbAlbuns.setRowSelectionInterval(linhaSelecionadaAlbum, linhaSelecionadaAlbum); |
1072 | 0 | return; |
1073 | |
} else { |
1074 | 0 | botaoCancelar(); |
1075 | |
} |
1076 | |
} |
1077 | |
|
1078 | 0 | if (documentoAlterado) { |
1079 | 0 | if (checarAlteracoes() == 0) { |
1080 | 0 | tbAlbuns.setRowSelectionInterval(linhaSelecionadaAlbum, linhaSelecionadaAlbum); |
1081 | 0 | return; |
1082 | |
} |
1083 | |
} |
1084 | |
|
1085 | 0 | setCursorWait(true); |
1086 | 0 | linhaSelecionadaAlbum = tbAlbuns.getSelectedRow(); |
1087 | 0 | Object indice = tbAlbuns.getModel().getValueAt(linhaSelecionadaAlbum, 0); |
1088 | 0 | int i = Integer.parseInt(indice.toString()); |
1089 | 0 | Album.getAlbum().loadAlbum(i); |
1090 | 0 | ultimoAlbum = Album.getAlbum().toString(); |
1091 | 0 | carregaAlbum(); |
1092 | |
|
1093 | 0 | tbFotos.setRowSelectionInterval(0, 0); |
1094 | 0 | carregaFoto(); |
1095 | 0 | setCursorWait(false); |
1096 | 0 | } |
1097 | |
|
1098 | |
|
1099 | |
|
1100 | |
|
1101 | |
|
1102 | |
|
1103 | |
|
1104 | |
|
1105 | |
|
1106 | |
|
1107 | |
public static boolean atualizaAlbum() { |
1108 | 3 | Album album = Album.getAlbum(); |
1109 | 3 | PhotoDTO[] fotos = album.getFotos(); |
1110 | 3 | String titulo = txtTitulo.getText(); |
1111 | 3 | String descricao = txtDescricao.getText(); |
1112 | 3 | String data = txtData.getText(); |
1113 | 3 | int categoriaIndice = lstCategoriasAlbum.getSelectedIndex(); |
1114 | 3 | String msgErro = ""; |
1115 | 3 | java.text.SimpleDateFormat dataBR = new java.text.SimpleDateFormat("dd/MM/yy"); |
1116 | 3 | dataBR.setLenient(false); |
1117 | |
|
1118 | |
|
1119 | 3 | if (titulo.length() < 1) { |
1120 | 0 | msgErro = "\n - Álbum"; |
1121 | |
} |
1122 | 3 | if (descricao.length() < 1) { |
1123 | 0 | msgErro = msgErro + "\n - Descrição"; |
1124 | |
} |
1125 | 3 | if (categoriaIndice < 1) { |
1126 | 0 | msgErro = msgErro + "\n - Categoria"; |
1127 | |
} |
1128 | |
|
1129 | |
|
1130 | |
try { |
1131 | 3 | dataBR.parse(data); |
1132 | 0 | } catch (Exception e) { |
1133 | 0 | msgErro = "\n - Data (" + data + ") inválida"; |
1134 | 0 | Util.log("[PainelWebFotos.atualizaAlbum]/ERRO: " + e.getMessage()); |
1135 | 3 | } |
1136 | |
|
1137 | |
|
1138 | 3 | if (fotos.length == 0) { |
1139 | 0 | msgErro = msgErro + "\n - Não existem fotos cadastradas nesse álbum"; |
1140 | |
} |
1141 | 9 | for (int i = 0; i < fotos.length; i++) { |
1142 | 6 | PhotoDTO photoDTO = fotos[i]; |
1143 | 6 | final boolean creditoIDNotOk = photoDTO.getCreditoID() == 0; |
1144 | 6 | final boolean legendaNotOk = photoDTO.getLegenda().isEmpty(); |
1145 | 6 | if (creditoIDNotOk || legendaNotOk) { |
1146 | 0 | msgErro = msgErro + "\n - Informação sobre foto na linha " + (i + 1) + ": " |
1147 | |
+ (creditoIDNotOk ? "\n - Credito não foi escolhido" : "") |
1148 | |
+ (legendaNotOk ? "\n - Legenda não foi preenchida" : ""); |
1149 | |
} |
1150 | |
} |
1151 | |
|
1152 | 3 | if (msgErro.length() > 0) { |
1153 | 0 | javax.swing.JOptionPane.showMessageDialog(null, "Preencha corretamente os campos:\n" + msgErro, "Erro no preenchimento", javax.swing.JOptionPane.ERROR_MESSAGE); |
1154 | 0 | return false; |
1155 | |
} |
1156 | |
|
1157 | |
|
1158 | 3 | album.setNmAlbum(titulo); |
1159 | 3 | album.setDescricao(descricao); |
1160 | 3 | album.setDtInsercao(data); |
1161 | 3 | album.setCategoriaID(album.getLstCategoriasID(lstCategoriasAlbum.getSelectedItem().toString())); |
1162 | |
|
1163 | 3 | return true; |
1164 | |
} |
1165 | |
|
1166 | |
|
1167 | |
private void carregaAlbum() { |
1168 | |
|
1169 | 0 | controlarAlteracoes = false; |
1170 | 0 | onoffPauta(true); |
1171 | 0 | resetFoto(); |
1172 | 0 | onoffFoto(false); |
1173 | |
|
1174 | 0 | Album b = Album.getAlbum(); |
1175 | |
|
1176 | 0 | albumID = b.getAlbumID(); |
1177 | 0 | txtTitulo.setText(b.getNmAlbum()); |
1178 | 0 | txtTitulo.setCaretPosition(0); |
1179 | 0 | txtData.setText(b.getDtInsercao()); |
1180 | 0 | txtDescricao.setText(b.getDescricao()); |
1181 | 0 | txtDescricao.setCaretPosition(0); |
1182 | |
|
1183 | 0 | int i = Album.getAlbum().getLstCategoriasIndex(b.getCategoriaID()); |
1184 | 0 | lstCategoriasAlbum.setSelectedIndex(i + 1); |
1185 | |
|
1186 | |
|
1187 | 0 | atualizaTabelaFotos(); |
1188 | 0 | alteracaoFinalizada(); |
1189 | 0 | controlarAlteracoes = true; |
1190 | 0 | } |
1191 | |
|
1192 | |
private void carregaFoto() { |
1193 | |
int indiceCredito; |
1194 | 12 | Object indice = tbFotos.getModel().getValueAt(tbFotos.getSelectedRow(), 0); |
1195 | |
String caminho; |
1196 | |
PhotoDTO f; |
1197 | |
int fotoID; |
1198 | |
|
1199 | |
try { |
1200 | 12 | fotoID = Integer.parseInt(indice.toString()); |
1201 | 0 | f = Album.getAlbum().getFoto(fotoID); |
1202 | 0 | caminho = BancoImagem.getLocalPath(albumID) + File.separator + "_b" + fotoID + ".jpg"; |
1203 | 0 | indiceCredito = PhotoDTO.getLstCreditosIndex(f.getCreditoNome()) + 1; |
1204 | 12 | } catch (NumberFormatException e) { |
1205 | 12 | f = Album.getAlbum().getFoto(indice.toString()); |
1206 | 12 | caminho = f.getCaminhoArquivo(); |
1207 | |
|
1208 | 12 | if (f.getCreditoID() == 0) { |
1209 | 6 | indiceCredito = 0; |
1210 | |
} else { |
1211 | 6 | indiceCredito = PhotoDTO.getLstCreditosIndex(f.getCreditoNome()) + 1; |
1212 | |
} |
1213 | 0 | } |
1214 | |
|
1215 | 12 | if (f == null) { |
1216 | 0 | return; |
1217 | |
} |
1218 | 12 | painelFoto.loadImage(caminho); |
1219 | |
|
1220 | |
|
1221 | 12 | controlarAlteracoes = false; |
1222 | 12 | txtLegenda.setText(f.getLegenda()); |
1223 | 12 | txtLegenda.setCaretPosition(0); |
1224 | 12 | log.debug("indiceCredito: " + indiceCredito); |
1225 | |
try { |
1226 | 12 | lstCreditos.setSelectedIndex(indiceCredito); |
1227 | 0 | } catch (Exception e) { |
1228 | 0 | log.error("Contagem: " + lstCreditos.getItemCount(), e); |
1229 | 12 | } |
1230 | 12 | controlarAlteracoes = true; |
1231 | 12 | onoffFoto(true); |
1232 | |
|
1233 | 12 | painelFoto.getLblFotoInfo().setText((f.getAltura() == 0) ? "?? x ??" : f.getLargura() + "x" + f.getAltura()); |
1234 | 12 | } |
1235 | |
|
1236 | |
private int checarAlteracoes() { |
1237 | 0 | if (documentoAlterado) { |
1238 | 0 | Object[] opcoes = {"Retornar", "Abandonar alterações"}; |
1239 | 0 | Object valorInicial = opcoes[0]; |
1240 | |
|
1241 | 0 | return javax.swing.JOptionPane.showOptionDialog(null, |
1242 | |
"Houve alterações neste álbum que não foram salvas.\n\nPara salvar as alterações clique em \"Retornar\" e finalize suas alterações.\nPara prosseguir sem salvar, clique em \"Abandonar alterações\"\n", |
1243 | |
"Cancelar alterações ?", |
1244 | |
javax.swing.JOptionPane.OK_OPTION, |
1245 | |
javax.swing.JOptionPane.QUESTION_MESSAGE, |
1246 | |
null, |
1247 | |
opcoes, |
1248 | |
valorInicial); |
1249 | |
} |
1250 | 0 | return 1; |
1251 | |
} |
1252 | |
|
1253 | |
private static void onoffPauta(boolean valor) { |
1254 | 9 | txtTitulo.setEnabled(valor); |
1255 | 9 | txtData.setEnabled(valor); |
1256 | 9 | lstCategoriasAlbum.setEnabled(valor); |
1257 | 9 | txtDescricao.setEnabled(valor); |
1258 | 9 | btAdicionarFotos.setEnabled(valor); |
1259 | 9 | } |
1260 | |
|
1261 | |
private static void onoffFoto(boolean valor) { |
1262 | 27 | txtLegenda.setEnabled(valor); |
1263 | 27 | lstCreditos.setEnabled(valor); |
1264 | 27 | } |
1265 | |
|
1266 | |
|
1267 | |
|
1268 | |
|
1269 | |
|
1270 | |
public static void apresentaNumReg() { |
1271 | 3 | int numReg = TableModelAlbum.getModel().getRowCount(); |
1272 | |
String msg; |
1273 | 3 | if (numReg == 0) { |
1274 | 3 | msg = "Nenhum ábum encontrado. Para ver outros álbuns, deixe a caixa de texto \"palavra(s)\" vazia e clique em Pesquisar."; |
1275 | 0 | } else if (numReg == 1) { |
1276 | 0 | msg = "1 álbum encontrado"; |
1277 | |
} else { |
1278 | 0 | msg = (numReg + " álbuns encontrados"); |
1279 | |
} |
1280 | 3 | lblTabelaInfo.setText(msg); |
1281 | 3 | } |
1282 | |
|
1283 | |
private static void atualizaTabelaFotos() { |
1284 | 3 | TableModelFoto.getModel().update(); |
1285 | 3 | TableModelFoto.getModel().fireTableDataChanged(); |
1286 | |
|
1287 | |
|
1288 | 3 | tbFotos.setModel(new TableSorter(TableModelFoto.getModel(), tbFotos.getTableHeader())); |
1289 | |
|
1290 | |
|
1291 | 3 | tbFotos.getColumnModel().getColumn(2).setCellEditor(new javax.swing.DefaultCellEditor(lstCreditosTabelaFotos)); |
1292 | 3 | Util.ajustaLargura(tbFotos, Util.getConfig().getString("colunas2")); |
1293 | |
|
1294 | 3 | tbFotos.repaint(); |
1295 | 3 | painelFoto.clear(); |
1296 | 3 | } |
1297 | |
|
1298 | |
|
1299 | |
|
1300 | |
|
1301 | |
|
1302 | |
|
1303 | |
|
1304 | |
|
1305 | |
public static void botaoNovo() { |
1306 | 3 | detectarAlteracoes(false); |
1307 | 3 | btAlterar.setText("Cancelar"); |
1308 | 3 | btAlterar.setActionCommand(ACAO_CANCELAR); |
1309 | 3 | btAlterar.setToolTipText("Cancela a criação do álbum"); |
1310 | 3 | btNovo.setText("Finalizar"); |
1311 | 3 | btNovo.setActionCommand(ACAO_FINALIZAR); |
1312 | 3 | btNovo.setToolTipText("Adiciona o álbum ao banco de dados"); |
1313 | 3 | btAlterar.setEnabled(true); |
1314 | 3 | resetAlbum(); |
1315 | 3 | resetFoto(); |
1316 | 3 | onoffPauta(true); |
1317 | |
try { |
1318 | 3 | java.text.SimpleDateFormat dataBR = new java.text.SimpleDateFormat("dd/MM/yy"); |
1319 | 3 | txtData.setText(dataBR.format(new java.util.Date())); |
1320 | 0 | } catch (Exception e) { |
1321 | 0 | Util.log("ERRO: " + e.getMessage()); |
1322 | 3 | } |
1323 | |
|
1324 | 3 | AcaoAdicionarFoto a = new AcaoAdicionarFoto(tbFotos, lstCreditosTabelaFotos, "Criando novo álbum - Selecione os arquivos"); |
1325 | 3 | a.actionPerformed(null); |
1326 | |
|
1327 | 3 | txtTitulo.requestFocus(true); |
1328 | 3 | } |
1329 | |
|
1330 | |
|
1331 | |
|
1332 | |
|
1333 | |
|
1334 | |
public static void botaoCancelar() { |
1335 | 0 | btAlterar.setText("Alterar"); |
1336 | 0 | btAlterar.setActionCommand(ACAO_ALTERAR); |
1337 | 0 | btAlterar.setToolTipText("Efetiva as alterações do álbum"); |
1338 | 0 | btNovo.setText("Novo"); |
1339 | 0 | btNovo.setActionCommand(ACAO_NOVO); |
1340 | 0 | btNovo.setToolTipText("Criar novo álbum"); |
1341 | 0 | btAlterar.setEnabled(false); |
1342 | 0 | resetAlbum(); |
1343 | 0 | resetFoto(); |
1344 | 0 | onoffPauta(false); |
1345 | 0 | alteracaoFinalizada(); |
1346 | 0 | detectarAlteracoes(true); |
1347 | 0 | } |
1348 | |
|
1349 | |
|
1350 | |
|
1351 | |
|
1352 | |
|
1353 | |
public static void botaoFinalizar() { |
1354 | 3 | btAlterar.setText("Alterar"); |
1355 | 3 | btAlterar.setActionCommand(ACAO_ALTERAR); |
1356 | 3 | btAlterar.setToolTipText("Efetiva as alterações do álbum"); |
1357 | 3 | btNovo.setText("Novo"); |
1358 | 3 | btNovo.setActionCommand(ACAO_NOVO); |
1359 | 3 | btNovo.setToolTipText("Criar novo álbum"); |
1360 | 3 | btAlterar.setEnabled(false); |
1361 | 3 | resetAlbum(); |
1362 | 3 | resetFoto(); |
1363 | 3 | alteracaoFinalizada(); |
1364 | 3 | detectarAlteracoes(true); |
1365 | 3 | onoffPauta(false); |
1366 | 3 | } |
1367 | |
|
1368 | |
|
1369 | |
|
1370 | |
|
1371 | |
|
1372 | |
|
1373 | |
public static void resetFoto() { |
1374 | 6 | controlarAlteracoes = false; |
1375 | 6 | txtLegenda.setText(""); |
1376 | |
try { |
1377 | 6 | lstCreditos.setSelectedIndex(0); |
1378 | 0 | } catch (Exception e) { |
1379 | 0 | Util.log("[PainelWebPhotos.resetFoto()]/ERRO: " + e.getMessage()); |
1380 | 6 | } |
1381 | 6 | painelFoto.clear(); |
1382 | 6 | painelFoto.getLblFotoInfo().setText(""); |
1383 | 6 | onoffFoto(false); |
1384 | 6 | controlarAlteracoes = true; |
1385 | 6 | } |
1386 | |
|
1387 | |
|
1388 | |
|
1389 | |
|
1390 | |
public static void resetAlbum() { |
1391 | |
|
1392 | 9 | Album.getAlbum().clear(); |
1393 | 9 | txtTitulo.setText(""); |
1394 | 9 | txtData.setText(""); |
1395 | |
try { |
1396 | 9 | lstCategoriasAlbum.setSelectedIndex(0); |
1397 | 0 | } catch (Exception e) { |
1398 | 0 | Util.log("[PainelWebPhotos.resetAlbum()]/ERRO: " + e.getMessage()); |
1399 | 9 | } |
1400 | 9 | txtDescricao.setText(""); |
1401 | 9 | txtLegenda.setText(""); |
1402 | |
try { |
1403 | 9 | lstCreditos.setSelectedIndex(0); |
1404 | 3 | } catch (Exception e) { |
1405 | 3 | Util.log("[PainelWebPhotos.resetAlbum()]/ERRO: " + e.getMessage()); |
1406 | 6 | } |
1407 | |
|
1408 | 9 | TableModelFoto.getModel().update(); |
1409 | 9 | TableModelFoto.getModel().fireTableDataChanged(); |
1410 | 9 | tbFotos.setModel(new TableSorter(TableModelFoto.getModel(), tbFotos.getTableHeader())); |
1411 | |
|
1412 | 9 | tbFotos.repaint(); |
1413 | 9 | painelFoto.clear(); |
1414 | |
|
1415 | |
|
1416 | 9 | onoffFoto(false); |
1417 | 9 | } |
1418 | 3 | private static final java.util.logging.Logger LOG = java.util.logging.Logger.getLogger(PainelWebFotos.class.getName()); |
1419 | |
|
1420 | |
private static net.sf.webphotos.gui.component.BotaoIcone btAdicionarFotos; |
1421 | |
private static javax.swing.JButton btAlterar; |
1422 | |
private static net.sf.webphotos.gui.component.BotaoIcone btDownload; |
1423 | |
private static net.sf.webphotos.gui.component.BotaoIcone btFTP; |
1424 | |
private static javax.swing.JButton btNovo; |
1425 | |
private static net.sf.webphotos.gui.component.BotaoIcone btUpload; |
1426 | |
private static net.sf.webphotos.gui.component.BotaoIcone buttonAddCategory; |
1427 | |
private static net.sf.webphotos.gui.component.BotaoIcone buttonAddCredits; |
1428 | |
private static javax.swing.JLabel lblAlbum; |
1429 | |
private static javax.swing.JLabel lblCategoria; |
1430 | |
private static javax.swing.JLabel lblData; |
1431 | |
private static javax.swing.JLabel lblDescricao; |
1432 | |
private static javax.swing.JLabel lblLegenda; |
1433 | |
private static javax.swing.JLabel lblTabelaInfo; |
1434 | |
private static javax.swing.JComboBox lstCategoriasAlbum; |
1435 | |
private static javax.swing.JComboBox lstCreditos; |
1436 | |
private static javax.swing.JComboBox lstCreditosTabelaFotos; |
1437 | |
private static javax.swing.JPopupMenu menuAlbum; |
1438 | |
private static javax.swing.JPopupMenu menuFoto; |
1439 | |
private static javax.swing.JMenuItem menuItemAlbumDelete; |
1440 | |
private static javax.swing.JMenuItem menuItemAlbumDown; |
1441 | |
private static javax.swing.JMenuItem menuItemAlbumRedoJS; |
1442 | |
private static javax.swing.JMenuItem menuItemAlbumRedoThumbs; |
1443 | |
private static javax.swing.JMenuItem menuItemAlbumRedoXML; |
1444 | |
private static javax.swing.JMenuItem menuItemAlbumUp; |
1445 | |
private static javax.swing.JMenuItem menuItemFotoDelete; |
1446 | |
private static javax.swing.JMenuItem menuItemFotoDown; |
1447 | |
private static javax.swing.JMenuItem menuItemFotoRedoThumbs; |
1448 | |
private static javax.swing.JMenuItem menuItemFotoUp; |
1449 | |
private static javax.swing.JSeparator menuSeparadorAlbum1; |
1450 | |
private static javax.swing.JSeparator menuSeparadorAlbum2; |
1451 | |
private static javax.swing.JSeparator menuSeparadorFoto; |
1452 | |
private static javax.swing.JPanel painelAlbuns; |
1453 | |
private static javax.swing.JPanel painelControle; |
1454 | |
private static javax.swing.JPanel painelDadosAlbum; |
1455 | |
private static javax.swing.JPanel painelFormFoto; |
1456 | |
private static net.sf.webphotos.gui.component.PainelFoto painelFoto; |
1457 | |
private static javax.swing.JPanel painelInfoAlbum; |
1458 | |
private static net.sf.webphotos.gui.component.PainelPesquisa painelPesquisa; |
1459 | |
private static javax.swing.JPanel painelToolBar; |
1460 | |
private static javax.swing.JScrollPane scrAlbuns; |
1461 | |
private static javax.swing.JScrollPane scrDescricao; |
1462 | |
private static javax.swing.JScrollPane scrFotos; |
1463 | |
private static javax.swing.JScrollPane scrLegenda; |
1464 | |
private static javax.swing.JScrollPane scrLog; |
1465 | |
private static javax.swing.JTable tbAlbuns; |
1466 | |
private static javax.swing.JTable tbFotos; |
1467 | |
private static javax.swing.JFormattedTextField txtData; |
1468 | |
private static javax.swing.JTextArea txtDescricao; |
1469 | |
private static javax.swing.JTextArea txtLegenda; |
1470 | |
private static javax.swing.JTextArea txtLog; |
1471 | |
private static javax.swing.JTextField txtTitulo; |
1472 | |
|
1473 | |
|
1474 | |
private int albumID; |
1475 | |
|
1476 | |
private int linhaSelecionadaAlbum; |
1477 | |
private int indiceFoto; |
1478 | |
|
1479 | |
private static String ultimoAlbum; |
1480 | |
|
1481 | |
private static boolean controlarAlteracoes; |
1482 | |
private static boolean documentoAlterado; |
1483 | |
|
1484 | |
private static javax.swing.text.MaskFormatter mascaraData; |
1485 | |
|
1486 | |
|
1487 | |
|
1488 | |
|
1489 | |
|
1490 | |
|
1491 | |
public static javax.swing.JTable getTbAlbuns() { |
1492 | 3 | return tbAlbuns; |
1493 | |
} |
1494 | |
|
1495 | |
|
1496 | |
|
1497 | |
|
1498 | |
|
1499 | |
|
1500 | |
public static javax.swing.JComboBox getLstCreditos() { |
1501 | 0 | return lstCreditos; |
1502 | |
} |
1503 | |
|
1504 | |
|
1505 | |
|
1506 | |
|
1507 | |
|
1508 | |
|
1509 | |
|
1510 | |
public static javax.swing.JComboBox getLstCreditosTabelaFotos() { |
1511 | 0 | return lstCreditosTabelaFotos; |
1512 | |
} |
1513 | |
|
1514 | |
|
1515 | |
|
1516 | |
|
1517 | |
|
1518 | |
|
1519 | |
public static javax.swing.JTable getTbFotos() { |
1520 | 3 | return tbFotos; |
1521 | |
} |
1522 | |
|
1523 | |
|
1524 | |
|
1525 | |
|
1526 | |
|
1527 | |
|
1528 | |
public static javax.swing.JTextArea getTxtLegenda() { |
1529 | 6 | return txtLegenda; |
1530 | |
} |
1531 | |
|
1532 | |
|
1533 | |
|
1534 | |
|
1535 | |
|
1536 | |
|
1537 | |
public static javax.swing.JTextArea getTxtLog() { |
1538 | 0 | return txtLog; |
1539 | |
} |
1540 | |
|
1541 | |
|
1542 | |
|
1543 | |
|
1544 | |
|
1545 | |
|
1546 | |
|
1547 | |
public static javax.swing.text.MaskFormatter getMascaraData() { |
1548 | 0 | return mascaraData; |
1549 | |
} |
1550 | |
|
1551 | |
|
1552 | |
|
1553 | |
|
1554 | |
|
1555 | |
|
1556 | |
|
1557 | |
public static void setMascaraData(javax.swing.text.MaskFormatter aMascaraData) { |
1558 | 0 | mascaraData = aMascaraData; |
1559 | 0 | } |
1560 | |
|
1561 | |
private void populateCreditsComboBox() { |
1562 | 3 | final DefaultComboBoxModel defaultComboBoxModel = new DefaultComboBoxModel(PhotoDTO.getCreditosArray()); |
1563 | 3 | lstCreditos.setModel(defaultComboBoxModel); |
1564 | 3 | lstCreditosTabelaFotos.setModel(defaultComboBoxModel); |
1565 | 3 | lstCreditos.insertItemAt("", 0); |
1566 | 3 | } |
1567 | |
} |