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.sql.SQLException; |
19 | |
import java.util.logging.Level; |
20 | |
import java.util.logging.Logger; |
21 | |
import net.sf.webphotos.BancoImagem; |
22 | |
import net.sf.webphotos.util.Util; |
23 | |
import net.sf.webphotos.util.legacy.CacheFTP; |
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | 0 | public class FrameWebFotos extends javax.swing.JFrame { |
31 | |
|
32 | 3 | private static final Logger log = Logger.getLogger(FrameWebFotos.class.getName()); |
33 | |
private static FrameWebFotos janela; |
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | 3 | private FrameWebFotos() { |
39 | 3 | initComponents(); |
40 | |
|
41 | |
|
42 | 3 | pack(); |
43 | 3 | setLocationRelativeTo(null); |
44 | 3 | } |
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
private void initComponents() { |
53 | |
|
54 | 3 | painelWebFotos = PainelWebFotos.getInstance(); |
55 | 3 | menuBar = new javax.swing.JMenuBar(); |
56 | 3 | fileMenu = new javax.swing.JMenu(); |
57 | 3 | openMenuItem = new javax.swing.JMenuItem(); |
58 | 3 | saveMenuItem = new javax.swing.JMenuItem(); |
59 | 3 | saveAsMenuItem = new javax.swing.JMenuItem(); |
60 | 3 | exitMenuItem = new javax.swing.JMenuItem(); |
61 | 3 | editMenu = new javax.swing.JMenu(); |
62 | 3 | cutMenuItem = new javax.swing.JMenuItem(); |
63 | 3 | copyMenuItem = new javax.swing.JMenuItem(); |
64 | 3 | pasteMenuItem = new javax.swing.JMenuItem(); |
65 | 3 | deleteMenuItem = new javax.swing.JMenuItem(); |
66 | 3 | helpMenu = new javax.swing.JMenu(); |
67 | 3 | contentsMenuItem = new javax.swing.JMenuItem(); |
68 | 3 | aboutMenuItem = new javax.swing.JMenuItem(); |
69 | |
|
70 | 3 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); |
71 | 3 | setTitle("WebPhotos"); |
72 | 3 | setName("Frame WebFotos"); |
73 | 3 | addWindowListener(new java.awt.event.WindowAdapter() { |
74 | |
public void windowClosing(java.awt.event.WindowEvent evt) { |
75 | 0 | formWindowClosing(evt); |
76 | 0 | } |
77 | |
}); |
78 | 3 | addComponentListener(new java.awt.event.ComponentAdapter() { |
79 | |
public void componentResized(java.awt.event.ComponentEvent evt) { |
80 | 0 | formComponentResized(evt); |
81 | 0 | } |
82 | |
}); |
83 | 3 | getContentPane().add(painelWebFotos, java.awt.BorderLayout.CENTER); |
84 | |
|
85 | 3 | fileMenu.setText("Arquivo"); |
86 | |
|
87 | 3 | openMenuItem.setText("Open"); |
88 | 3 | fileMenu.add(openMenuItem); |
89 | |
|
90 | 3 | saveMenuItem.setText("Save"); |
91 | 3 | fileMenu.add(saveMenuItem); |
92 | |
|
93 | 3 | saveAsMenuItem.setText("Save As ..."); |
94 | 3 | fileMenu.add(saveAsMenuItem); |
95 | |
|
96 | 3 | exitMenuItem.setText("Exit"); |
97 | 3 | exitMenuItem.addActionListener(new java.awt.event.ActionListener() { |
98 | |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
99 | 0 | exitMenuItemActionPerformed(evt); |
100 | 0 | } |
101 | |
}); |
102 | 3 | fileMenu.add(exitMenuItem); |
103 | |
|
104 | 3 | menuBar.add(fileMenu); |
105 | |
|
106 | 3 | editMenu.setText("Editar"); |
107 | |
|
108 | 3 | cutMenuItem.setText("Cut"); |
109 | 3 | editMenu.add(cutMenuItem); |
110 | |
|
111 | 3 | copyMenuItem.setText("Copy"); |
112 | 3 | editMenu.add(copyMenuItem); |
113 | |
|
114 | 3 | pasteMenuItem.setText("Paste"); |
115 | 3 | editMenu.add(pasteMenuItem); |
116 | |
|
117 | 3 | deleteMenuItem.setText("Delete"); |
118 | 3 | editMenu.add(deleteMenuItem); |
119 | |
|
120 | 3 | menuBar.add(editMenu); |
121 | |
|
122 | 3 | helpMenu.setText("Ajuda"); |
123 | |
|
124 | 3 | contentsMenuItem.setText("Contents"); |
125 | 3 | helpMenu.add(contentsMenuItem); |
126 | |
|
127 | 3 | aboutMenuItem.setText("About"); |
128 | 3 | helpMenu.add(aboutMenuItem); |
129 | |
|
130 | 3 | menuBar.add(helpMenu); |
131 | |
|
132 | 3 | setJMenuBar(menuBar); |
133 | 3 | } |
134 | |
|
135 | |
private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) { |
136 | 0 | FrameWebFotos.exit(); |
137 | 0 | } |
138 | |
|
139 | |
private void formComponentResized(java.awt.event.ComponentEvent evt) { |
140 | |
|
141 | 0 | FrameWebFotos comp = (FrameWebFotos)evt.getComponent(); |
142 | 0 | int width = comp.getSize().width; |
143 | 0 | int height = comp.getSize().height; |
144 | 0 | int minWidth = comp.getPreferredSize().width; |
145 | 0 | int minHeight = comp.getPreferredSize().height; |
146 | |
|
147 | 0 | if(width < minWidth && height < minHeight ) { |
148 | 0 | comp.setSize(minWidth, minHeight); |
149 | 0 | } else if (width < minWidth) { |
150 | 0 | comp.setSize(minWidth, height); |
151 | 0 | } else if (height < minHeight) { |
152 | 0 | comp.setSize(width, minHeight); |
153 | |
} |
154 | 0 | } |
155 | |
|
156 | |
private void formWindowClosing(java.awt.event.WindowEvent evt) { |
157 | 0 | FrameWebFotos.exit(); |
158 | 0 | } |
159 | |
|
160 | |
|
161 | |
|
162 | |
|
163 | |
|
164 | |
|
165 | |
public static FrameWebFotos getInstance() { |
166 | 3 | if(janela == null) { |
167 | 3 | janela = new FrameWebFotos(); |
168 | |
} |
169 | 3 | return janela; |
170 | |
} |
171 | |
|
172 | |
private static void exit() { |
173 | 0 | log.log(Level.FINE, "Shutting down WebPhotos"); |
174 | 0 | CacheFTP.getCache().saveFile(); |
175 | 0 | Util.setLoggingTextArea(null); |
176 | 0 | try { BancoImagem.closeConnection(); } catch (SQLException ex) { } |
177 | 0 | getInstance().dispose(); |
178 | 0 | } |
179 | |
|
180 | |
|
181 | |
|
182 | |
private static javax.swing.JMenuItem aboutMenuItem; |
183 | |
private static javax.swing.JMenuItem contentsMenuItem; |
184 | |
private static javax.swing.JMenuItem copyMenuItem; |
185 | |
private static javax.swing.JMenuItem cutMenuItem; |
186 | |
private static javax.swing.JMenuItem deleteMenuItem; |
187 | |
private static javax.swing.JMenu editMenu; |
188 | |
private static javax.swing.JMenuItem exitMenuItem; |
189 | |
private static javax.swing.JMenu fileMenu; |
190 | |
private static javax.swing.JMenu helpMenu; |
191 | |
private static javax.swing.JMenuBar menuBar; |
192 | |
private static javax.swing.JMenuItem openMenuItem; |
193 | |
private static javax.swing.JPanel painelWebFotos; |
194 | |
private static javax.swing.JMenuItem pasteMenuItem; |
195 | |
private static javax.swing.JMenuItem saveAsMenuItem; |
196 | |
private static javax.swing.JMenuItem saveMenuItem; |
197 | |
|
198 | |
|
199 | |
|
200 | |
} |