svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / project / documents / gui / projectpanel / ProjectDocumentsPanelPageView.java @ 44502
History | View | Annotate | Download (10.1 KB)
1 | 43913 | jjdelcerro | package org.gvsig.app.project.documents.gui.projectpanel; |
---|---|---|---|
2 | |||
3 | import com.jeta.forms.components.separator.TitledSeparator; |
||
4 | import com.jeta.open.i18n.I18NUtils; |
||
5 | import com.jgoodies.forms.layout.CellConstraints; |
||
6 | import com.jgoodies.forms.layout.FormLayout; |
||
7 | import java.awt.BorderLayout; |
||
8 | import java.awt.Color; |
||
9 | import java.awt.ComponentOrientation; |
||
10 | import java.awt.Container; |
||
11 | import java.awt.Dimension; |
||
12 | 44502 | omartinez | import java.awt.event.WindowAdapter; |
13 | import java.awt.event.WindowEvent; |
||
14 | 43913 | jjdelcerro | import javax.swing.Box; |
15 | import javax.swing.ImageIcon; |
||
16 | import javax.swing.JButton; |
||
17 | import javax.swing.JFrame; |
||
18 | import javax.swing.JLabel; |
||
19 | import javax.swing.JList; |
||
20 | import javax.swing.JPanel; |
||
21 | import javax.swing.JScrollPane; |
||
22 | import javax.swing.JTextField; |
||
23 | |||
24 | |||
25 | public class ProjectDocumentsPanelPageView extends JPanel |
||
26 | { |
||
27 | TitledSeparator lblDocumentTypes = new TitledSeparator();
|
||
28 | TitledSeparator lblDocument = new TitledSeparator();
|
||
29 | TitledSeparator lblSessionProperties = new TitledSeparator();
|
||
30 | JList lstDocuments = new JList(); |
||
31 | JButton btnDocumentNew = new JButton(); |
||
32 | JButton btnDocumentOpen = new JButton(); |
||
33 | JButton btnDocumentRename = new JButton(); |
||
34 | JButton btnDocumentDelete = new JButton(); |
||
35 | JButton btnDocumentProperties = new JButton(); |
||
36 | JLabel lblSessionName = new JLabel(); |
||
37 | JLabel lblSavedIn = new JLabel(); |
||
38 | JLabel lblCreationDate = new JLabel(); |
||
39 | JTextField txtSessionName = new JTextField(); |
||
40 | JTextField txtSavedIn = new JTextField(); |
||
41 | JTextField txtCreationDate = new JTextField(); |
||
42 | JButton btnProjectProperties = new JButton(); |
||
43 | JPanel documentTypesContainer = new JPanel(); |
||
44 | |||
45 | /**
|
||
46 | * Default constructor
|
||
47 | */
|
||
48 | public ProjectDocumentsPanelPageView()
|
||
49 | { |
||
50 | initializePanel(); |
||
51 | } |
||
52 | |||
53 | /**
|
||
54 | 44502 | omartinez | * Main method for panel
|
55 | */
|
||
56 | public static void main(String[] args) |
||
57 | { |
||
58 | JFrame frame = new JFrame(); |
||
59 | frame.setSize(600, 400); |
||
60 | frame.setLocation(100, 100); |
||
61 | frame.getContentPane().add(new ProjectDocumentsPanelPageView());
|
||
62 | frame.setVisible(true);
|
||
63 | |||
64 | frame.addWindowListener( new WindowAdapter() |
||
65 | { |
||
66 | public void windowClosing( WindowEvent evt ) |
||
67 | { |
||
68 | System.exit(0); |
||
69 | } |
||
70 | }); |
||
71 | } |
||
72 | |||
73 | /**
|
||
74 | 43913 | jjdelcerro | * Adds fill components to empty cells in the first row and first column of the grid.
|
75 | * This ensures that the grid spacing will be the same as shown in the designer.
|
||
76 | * @param cols an array of column indices in the first row where fill components should be added.
|
||
77 | * @param rows an array of row indices in the first column where fill components should be added.
|
||
78 | */
|
||
79 | void addFillComponents( Container panel, int[] cols, int[] rows ) |
||
80 | { |
||
81 | Dimension filler = new Dimension(10,10); |
||
82 | |||
83 | boolean filled_cell_11 = false; |
||
84 | CellConstraints cc = new CellConstraints();
|
||
85 | if ( cols.length > 0 && rows.length > 0 ) |
||
86 | { |
||
87 | if ( cols[0] == 1 && rows[0] == 1 ) |
||
88 | { |
||
89 | /** add a rigid area */
|
||
90 | panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
||
91 | filled_cell_11 = true;
|
||
92 | } |
||
93 | } |
||
94 | |||
95 | for( int index = 0; index < cols.length; index++ ) |
||
96 | { |
||
97 | if ( cols[index] == 1 && filled_cell_11 ) |
||
98 | { |
||
99 | continue;
|
||
100 | } |
||
101 | panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
||
102 | } |
||
103 | |||
104 | for( int index = 0; index < rows.length; index++ ) |
||
105 | { |
||
106 | if ( rows[index] == 1 && filled_cell_11 ) |
||
107 | { |
||
108 | continue;
|
||
109 | } |
||
110 | panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
||
111 | } |
||
112 | |||
113 | } |
||
114 | |||
115 | /**
|
||
116 | * Helper method to load an image file from the CLASSPATH
|
||
117 | * @param imageName the package and name of the file to load relative to the CLASSPATH
|
||
118 | * @return an ImageIcon instance with the specified image file
|
||
119 | * @throws IllegalArgumentException if the image resource cannot be loaded.
|
||
120 | */
|
||
121 | public ImageIcon loadImage( String imageName ) |
||
122 | { |
||
123 | try
|
||
124 | { |
||
125 | ClassLoader classloader = getClass().getClassLoader();
|
||
126 | java.net.URL url = classloader.getResource( imageName ); |
||
127 | if ( url != null ) |
||
128 | { |
||
129 | ImageIcon icon = new ImageIcon( url ); |
||
130 | return icon;
|
||
131 | } |
||
132 | } |
||
133 | catch( Exception e ) |
||
134 | { |
||
135 | e.printStackTrace(); |
||
136 | } |
||
137 | throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
||
138 | } |
||
139 | |||
140 | /**
|
||
141 | * Method for recalculating the component orientation for
|
||
142 | * right-to-left Locales.
|
||
143 | * @param orientation the component orientation to be applied
|
||
144 | */
|
||
145 | public void applyComponentOrientation( ComponentOrientation orientation ) |
||
146 | { |
||
147 | // Not yet implemented...
|
||
148 | // I18NUtils.applyComponentOrientation(this, orientation);
|
||
149 | super.applyComponentOrientation(orientation);
|
||
150 | } |
||
151 | |||
152 | public JPanel createPanel() |
||
153 | { |
||
154 | JPanel jpanel1 = new JPanel(); |
||
155 | 44502 | omartinez | FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:115PX:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE"); |
156 | 43913 | jjdelcerro | CellConstraints cc = new CellConstraints();
|
157 | jpanel1.setLayout(formlayout1); |
||
158 | |||
159 | lblDocumentTypes.setName("lblDocumentTypes");
|
||
160 | lblDocumentTypes.setText("tipos_de_documentos");
|
||
161 | jpanel1.add(lblDocumentTypes,cc.xy(2,2)); |
||
162 | |||
163 | lblDocument.setName("lblDocument");
|
||
164 | lblDocument.setText("documentos_existentes");
|
||
165 | jpanel1.add(lblDocument,cc.xy(2,6)); |
||
166 | |||
167 | lblSessionProperties.setName("lblSessionProperties");
|
||
168 | lblSessionProperties.setText("propiedades_sesion");
|
||
169 | jpanel1.add(lblSessionProperties,cc.xy(2,10)); |
||
170 | |||
171 | jpanel1.add(createPanel1(),cc.xy(2,8)); |
||
172 | jpanel1.add(createPanel3(),cc.xy(2,12)); |
||
173 | documentTypesContainer.setName("documentTypesContainer");
|
||
174 | jpanel1.add(documentTypesContainer,cc.xy(2,4)); |
||
175 | |||
176 | addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13 }); |
||
177 | return jpanel1;
|
||
178 | } |
||
179 | |||
180 | public JPanel createPanel1() |
||
181 | { |
||
182 | JPanel jpanel1 = new JPanel(); |
||
183 | FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","FILL:DEFAULT:GROW(1.0)"); |
||
184 | CellConstraints cc = new CellConstraints();
|
||
185 | jpanel1.setLayout(formlayout1); |
||
186 | |||
187 | lstDocuments.setName("lstDocuments");
|
||
188 | JScrollPane jscrollpane1 = new JScrollPane(); |
||
189 | jscrollpane1.setViewportView(lstDocuments); |
||
190 | jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||
191 | jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||
192 | jpanel1.add(jscrollpane1,cc.xy(1,1)); |
||
193 | |||
194 | jpanel1.add(createPanel2(),cc.xy(3,1)); |
||
195 | addFillComponents(jpanel1,new int[]{ 2,3 },new int[0]); |
||
196 | return jpanel1;
|
||
197 | } |
||
198 | |||
199 | public JPanel createPanel2() |
||
200 | { |
||
201 | JPanel jpanel1 = new JPanel(); |
||
202 | FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE"); |
||
203 | CellConstraints cc = new CellConstraints();
|
||
204 | jpanel1.setLayout(formlayout1); |
||
205 | |||
206 | btnDocumentNew.setActionCommand("JButton");
|
||
207 | btnDocumentNew.setName("btnDocumentNew");
|
||
208 | btnDocumentNew.setText("nuevo");
|
||
209 | jpanel1.add(btnDocumentNew,cc.xy(1,1)); |
||
210 | |||
211 | btnDocumentOpen.setActionCommand("JButton");
|
||
212 | btnDocumentOpen.setName("btnDocumentOpen");
|
||
213 | btnDocumentOpen.setText("abrir");
|
||
214 | jpanel1.add(btnDocumentOpen,cc.xy(1,3)); |
||
215 | |||
216 | btnDocumentRename.setActionCommand("JButton");
|
||
217 | btnDocumentRename.setName("btnDocumentRename");
|
||
218 | btnDocumentRename.setText("renombrar");
|
||
219 | jpanel1.add(btnDocumentRename,cc.xy(1,5)); |
||
220 | |||
221 | btnDocumentDelete.setActionCommand("JButton");
|
||
222 | btnDocumentDelete.setName("btnDocumentDelete");
|
||
223 | btnDocumentDelete.setText("borrar");
|
||
224 | jpanel1.add(btnDocumentDelete,cc.xy(1,7)); |
||
225 | |||
226 | btnDocumentProperties.setActionCommand("JButton");
|
||
227 | btnDocumentProperties.setName("btnDocumentProperties");
|
||
228 | btnDocumentProperties.setText("propiedades");
|
||
229 | jpanel1.add(btnDocumentProperties,cc.xy(1,9)); |
||
230 | |||
231 | addFillComponents(jpanel1,new int[0],new int[]{ 2,4,6,8 }); |
||
232 | return jpanel1;
|
||
233 | } |
||
234 | |||
235 | public JPanel createPanel3() |
||
236 | { |
||
237 | JPanel jpanel1 = new JPanel(); |
||
238 | FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0)","CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE"); |
||
239 | CellConstraints cc = new CellConstraints();
|
||
240 | jpanel1.setLayout(formlayout1); |
||
241 | |||
242 | lblSessionName.setName("lblSessionName");
|
||
243 | lblSessionName.setText("nombre_sesion");
|
||
244 | jpanel1.add(lblSessionName,cc.xy(1,1)); |
||
245 | |||
246 | lblSavedIn.setName("lblSavedIn");
|
||
247 | lblSavedIn.setText("guardado");
|
||
248 | jpanel1.add(lblSavedIn,cc.xy(1,3)); |
||
249 | |||
250 | lblCreationDate.setName("lblCreationDate");
|
||
251 | lblCreationDate.setText("creation_date");
|
||
252 | jpanel1.add(lblCreationDate,cc.xy(1,5)); |
||
253 | |||
254 | txtSessionName.setBackground(new Color(236,233,216)); |
||
255 | txtSessionName.setEditable(false);
|
||
256 | txtSessionName.setName("txtSessionName");
|
||
257 | jpanel1.add(txtSessionName,cc.xy(3,1)); |
||
258 | |||
259 | txtSavedIn.setBackground(new Color(236,233,216)); |
||
260 | txtSavedIn.setEditable(false);
|
||
261 | txtSavedIn.setName("txtSavedIn");
|
||
262 | jpanel1.add(txtSavedIn,cc.xy(3,3)); |
||
263 | |||
264 | txtCreationDate.setBackground(new Color(236,233,216)); |
||
265 | txtCreationDate.setEditable(false);
|
||
266 | txtCreationDate.setName("txtCreationDate");
|
||
267 | jpanel1.add(txtCreationDate,cc.xy(3,5)); |
||
268 | |||
269 | btnProjectProperties.setActionCommand("JButton");
|
||
270 | btnProjectProperties.setName("btnProjectProperties");
|
||
271 | btnProjectProperties.setText("propiedades");
|
||
272 | jpanel1.add(btnProjectProperties,new CellConstraints(3,7,1,1,CellConstraints.RIGHT,CellConstraints.DEFAULT)); |
||
273 | |||
274 | addFillComponents(jpanel1,new int[]{ 2 },new int[]{ 2,4,6,7 }); |
||
275 | return jpanel1;
|
||
276 | } |
||
277 | |||
278 | /**
|
||
279 | * Initializer
|
||
280 | */
|
||
281 | protected void initializePanel() |
||
282 | { |
||
283 | setLayout(new BorderLayout()); |
||
284 | add(createPanel(), BorderLayout.CENTER);
|
||
285 | } |
||
286 | |||
287 | |||
288 | } |