svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / gui / ProjectWindow.java @ 9532
History | View | Annotate | Download (29.4 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package com.iver.cit.gvsig.project.documents.gui; |
42 |
|
43 |
import java.awt.Component; |
44 |
import java.awt.FlowLayout; |
45 |
import java.awt.GridBagConstraints; |
46 |
import java.awt.GridBagLayout; |
47 |
import java.awt.GridLayout; |
48 |
import java.awt.Insets; |
49 |
import java.beans.PropertyChangeEvent; |
50 |
import java.beans.PropertyChangeListener; |
51 |
import java.io.File; |
52 |
import java.util.ArrayList; |
53 |
import java.util.Iterator; |
54 |
|
55 |
import javax.swing.ButtonGroup; |
56 |
import javax.swing.JDialog; |
57 |
import javax.swing.JLabel; |
58 |
import javax.swing.JList; |
59 |
import javax.swing.JOptionPane; |
60 |
import javax.swing.JPanel; |
61 |
import javax.swing.JRadioButton; |
62 |
import javax.swing.JScrollPane; |
63 |
import javax.swing.border.TitledBorder; |
64 |
|
65 |
import org.gvsig.gui.beans.swing.JButton; |
66 |
|
67 |
import com.iver.andami.PluginServices; |
68 |
import com.iver.andami.messages.NotificationManager; |
69 |
import com.iver.andami.ui.mdiManager.IWindow; |
70 |
import com.iver.andami.ui.mdiManager.SingletonWindow; |
71 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
72 |
import com.iver.cit.gvsig.ProjectExtension; |
73 |
import com.iver.cit.gvsig.project.Project; |
74 |
import com.iver.cit.gvsig.project.documents.ProjectDocument; |
75 |
import com.iver.cit.gvsig.project.documents.ProjectDocumentFactory; |
76 |
import com.iver.cit.gvsig.project.documents.contextMenu.gui.DocumentContextMenu; |
77 |
import com.iver.utiles.DefaultListModel; |
78 |
import com.iver.utiles.extensionPoints.ExtensionPoint; |
79 |
import com.iver.utiles.extensionPoints.ExtensionPoints; |
80 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
81 |
|
82 |
|
83 |
/**
|
84 |
* Clase principal del proyecto donde se puede operar para crear
|
85 |
* cualquier tipo de documento.
|
86 |
*
|
87 |
* @author Vicente Caballero Navarro
|
88 |
*/
|
89 |
public class ProjectWindow extends JPanel implements PropertyChangeListener, |
90 |
IWindow, SingletonWindow { |
91 |
private JPanel jPanel = null; |
92 |
private JRadioButton[] btnsDocuments = null; |
93 |
private ButtonGroup grupo = new ButtonGroup(); |
94 |
private JPanel jPanel1 = null; |
95 |
private JList lstDocs = null; |
96 |
private JPanel jPanel2 = null; |
97 |
private JButton btnNuevo = null; |
98 |
private JButton btnPropiedades = null; |
99 |
private JButton btnAbrir = null; |
100 |
private JButton btnBorrar = null; |
101 |
private JButton btnRenombrar = null; |
102 |
private JPanel jPanel3 = null; |
103 |
private JLabel jLabel = null; |
104 |
private JLabel lblNombreSesion = null; |
105 |
private JLabel jLabel1 = null; |
106 |
private JLabel lblGuardado = null; |
107 |
private JLabel jLabel2 = null; |
108 |
private JLabel lblFecha = null; |
109 |
private JButton btnImportar = null; |
110 |
private JButton btnExportar = null; |
111 |
private JButton btnEditar = null; |
112 |
// The properties of the Project Manager window (size, position, etc):
|
113 |
private WindowInfo m_viewInfo=null; |
114 |
|
115 |
/** Proyecto representado en la vista */
|
116 |
private Project p;
|
117 |
|
118 |
private JScrollPane jScrollPane = null; |
119 |
private JPanel jPanel4 = null; |
120 |
private JScrollPane jScrollPane1 = null; |
121 |
|
122 |
/**
|
123 |
* This is the default constructor
|
124 |
*
|
125 |
* @param project Extension
|
126 |
*/
|
127 |
public ProjectWindow() {
|
128 |
super();
|
129 |
initialize(); |
130 |
refreshControls(); |
131 |
} |
132 |
|
133 |
/**
|
134 |
* Asigna el proyecto a la ventana
|
135 |
*
|
136 |
* @param p Proyecto con el que se operar? a trav?s de este di?logo
|
137 |
*/
|
138 |
public void setProject(Project p) { |
139 |
this.p = p;
|
140 |
p.addPropertyChangeListener(this);
|
141 |
refreshControls(); |
142 |
} |
143 |
|
144 |
/**
|
145 |
* Activa los botones de la botonera del medio o los desactiva en funci?n
|
146 |
* de que est? seleccionado o no un elemento de proyecto en la lista del
|
147 |
* medio
|
148 |
*/
|
149 |
private void activarBotones() { |
150 |
if (lstDocs.getSelectedIndex() != -1) { |
151 |
btnAbrir.setEnabled(true);
|
152 |
btnBorrar.setEnabled(true);
|
153 |
if (lstDocs.getSelectedIndices().length==1) { |
154 |
btnRenombrar.setEnabled(true);
|
155 |
btnPropiedades.setEnabled(true);
|
156 |
}else {
|
157 |
btnRenombrar.setEnabled(false);
|
158 |
btnPropiedades.setEnabled(false);
|
159 |
} |
160 |
} else {
|
161 |
btnAbrir.setEnabled(false);
|
162 |
btnBorrar.setEnabled(false);
|
163 |
btnRenombrar.setEnabled(false);
|
164 |
btnPropiedades.setEnabled(false);
|
165 |
} |
166 |
} |
167 |
|
168 |
/**
|
169 |
* Refresca la lista de elementos de proyecto con vistas, mapas o tablas,
|
170 |
* seg?n la opci?n activada
|
171 |
*/
|
172 |
private void refreshList() { |
173 |
if (p != null) { |
174 |
DefaultListModel model=null; |
175 |
String tituloMarco = PluginServices.getText(this, "documentos_existentes"); |
176 |
|
177 |
String doc=getDocumentSelected();
|
178 |
model = new DefaultListModel(p.getDocumentsByType(doc)); |
179 |
tituloMarco=getDocumentSelectedName(); |
180 |
|
181 |
lstDocs.setModel(model); |
182 |
((TitledBorder)getJPanel1().getBorder()).setTitle(tituloMarco);
|
183 |
getJPanel1().repaint(1);
|
184 |
activarBotones(); |
185 |
} |
186 |
} |
187 |
/**
|
188 |
* Devuelve el nombre del tipo de documento
|
189 |
* activo (el mismo que ProjectDocumentFactory.getRegisterName)
|
190 |
*
|
191 |
*
|
192 |
* @return
|
193 |
*/
|
194 |
|
195 |
public String getDocumentSelected() { |
196 |
JRadioButton btnSelected=null; |
197 |
for (int i=0;i<btnsDocuments.length;i++) { |
198 |
if (btnsDocuments[i].isSelected()) {
|
199 |
btnSelected=btnsDocuments[i]; |
200 |
return btnSelected.getName();
|
201 |
} |
202 |
} |
203 |
|
204 |
return null; |
205 |
} |
206 |
private String getDocumentSelectedName() { |
207 |
JRadioButton btnSelected=null; |
208 |
for (int i=0;i<btnsDocuments.length;i++) { |
209 |
if (btnsDocuments[i].isSelected()) {
|
210 |
btnSelected=btnsDocuments[i]; |
211 |
return btnSelected.getText();
|
212 |
} |
213 |
} |
214 |
|
215 |
return null; |
216 |
} |
217 |
/**
|
218 |
* Refresca las etiquetas con la informaci?n del proyecto
|
219 |
*/
|
220 |
private void refreshProperties() { |
221 |
if (p != null) { |
222 |
lblNombreSesion.setText(p.getName()); |
223 |
String path = ProjectExtension.getPath();
|
224 |
if (path != null) { |
225 |
File f = new File(path); |
226 |
lblGuardado.setText(f.toString()); |
227 |
} else {
|
228 |
lblGuardado.setText("");
|
229 |
} |
230 |
lblFecha.setText(p.getCreationDate()); |
231 |
} |
232 |
} |
233 |
|
234 |
/**
|
235 |
* Refresca todo el di?logo
|
236 |
*/
|
237 |
public void refreshControls() { |
238 |
refreshList(); |
239 |
refreshProperties(); |
240 |
} |
241 |
|
242 |
/**
|
243 |
* This method initializes this
|
244 |
*/
|
245 |
private void initialize() { |
246 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
247 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
248 |
gridBagConstraints.weightx = 1.0;
|
249 |
gridBagConstraints.weighty = 1.0;
|
250 |
GridBagLayout layout = new GridBagLayout(); |
251 |
setLayout(layout); |
252 |
GridBagConstraints c = new GridBagConstraints(); |
253 |
c.fill = GridBagConstraints.HORIZONTAL;
|
254 |
c.weightx = 1.0;
|
255 |
c.weighty = 0;
|
256 |
c.gridy=0;
|
257 |
c.insets = new Insets(2, 5, 2, 5); |
258 |
|
259 |
layout.setConstraints(getJPanel(),c); |
260 |
add(getJPanel(), null);
|
261 |
|
262 |
c.fill = GridBagConstraints.BOTH;
|
263 |
c.gridy=1;
|
264 |
c.weightx = 1.0;
|
265 |
c.weighty = 1.0;
|
266 |
layout.setConstraints(getJPanel1(),c); |
267 |
add(getJPanel1(), null);
|
268 |
c.fill = GridBagConstraints.HORIZONTAL;
|
269 |
c.weightx = 0;
|
270 |
c.weighty = 0;
|
271 |
c.gridy=2;
|
272 |
layout.setConstraints(getJPanel3(),c); |
273 |
add(getJPanel3(), null);
|
274 |
|
275 |
this.setSize(430, 544); |
276 |
this.setPreferredSize(new java.awt.Dimension(430, 430)); |
277 |
this.setMinimumSize(new java.awt.Dimension(430, 430)); |
278 |
this.add(getJScrollPane1(), gridBagConstraints);
|
279 |
for (int i=0;i<btnsDocuments.length;i++) { |
280 |
grupo.add(btnsDocuments[i]); |
281 |
} |
282 |
if (btnsDocuments.length>0) |
283 |
btnsDocuments[0].setSelected(true); |
284 |
} |
285 |
private ProjectDocument createDocument(String s) { |
286 |
ExtensionPoints extensionPoints = |
287 |
ExtensionPointsSingleton.getInstance(); |
288 |
|
289 |
ExtensionPoint extensionPoint =(ExtensionPoint)extensionPoints.get("Documents");
|
290 |
Iterator iterator = extensionPoint.keySet().iterator();
|
291 |
while (iterator.hasNext()) {
|
292 |
try {
|
293 |
ProjectDocumentFactory documentFactory = (ProjectDocumentFactory)extensionPoint.create((String)iterator.next());
|
294 |
if (documentFactory.getRegisterName().equals(s)) {
|
295 |
ProjectDocument document=documentFactory.createFromGUI(p); |
296 |
if (document == null) return null; |
297 |
document.setProjectDocumentFactory(documentFactory); |
298 |
p.setModified(true);
|
299 |
return document;
|
300 |
} |
301 |
} catch (InstantiationException e) { |
302 |
e.printStackTrace(); |
303 |
} catch (IllegalAccessException e) { |
304 |
e.printStackTrace(); |
305 |
} catch (ClassCastException e) { |
306 |
e.printStackTrace(); |
307 |
} |
308 |
} |
309 |
return null; |
310 |
} |
311 |
/**
|
312 |
* Crea un nuevo project element
|
313 |
*
|
314 |
* @throws Exception DOCUMENT ME!
|
315 |
*/
|
316 |
private void newProjectDocument() throws Exception { |
317 |
String s=getDocumentSelected();
|
318 |
ProjectDocument doc=createDocument(s); |
319 |
if (doc!=null) |
320 |
p.addDocument(doc); |
321 |
} |
322 |
|
323 |
/**
|
324 |
* Abre la ventana de un nuevo project element
|
325 |
*/
|
326 |
private void abrir() { |
327 |
int[] indexes = lstDocs.getSelectedIndices(); |
328 |
for (int i=indexes.length-1;i>=0;i--) { |
329 |
int index=indexes[i];
|
330 |
if (index == -1) { |
331 |
return;
|
332 |
} |
333 |
String s=getDocumentSelected();
|
334 |
ArrayList documents=p.getDocumentsByType(s);
|
335 |
ProjectDocument doc=(ProjectDocument)documents.get(index); |
336 |
IWindow window=doc.createWindow(); |
337 |
PluginServices.getMDIManager().addWindow(window); |
338 |
} |
339 |
p.setModified(true);
|
340 |
} |
341 |
|
342 |
/**
|
343 |
* Cambia el nombre de un project element
|
344 |
*/
|
345 |
private void renombrar() { |
346 |
int index = lstDocs.getSelectedIndex();
|
347 |
|
348 |
if (index == -1) { |
349 |
return;
|
350 |
} |
351 |
String s=getDocumentSelected();
|
352 |
ArrayList documents=p.getDocumentsByType(s);
|
353 |
ProjectDocument doc=(ProjectDocument)documents.get(index); |
354 |
|
355 |
if (doc.isLocked()) {
|
356 |
JOptionPane.showMessageDialog(this, PluginServices.getText(this, "locked_element_it_cannot_be_renamed")); |
357 |
return;
|
358 |
} |
359 |
|
360 |
JOptionPane pane = new JOptionPane(); |
361 |
pane.setMessage(PluginServices.getText(this, "introduce_nombre")); |
362 |
pane.setMessageType(JOptionPane.QUESTION_MESSAGE);
|
363 |
pane.setWantsInput(true);
|
364 |
pane.setInitialSelectionValue(doc.getName()); |
365 |
pane.setInputValue(doc.getName()); |
366 |
JDialog dlg = pane.createDialog((Component) PluginServices.getMainFrame(), |
367 |
PluginServices.getText(this, "renombrar")); |
368 |
dlg.setModal(true);
|
369 |
dlg.show(); |
370 |
|
371 |
String nuevoNombre = pane.getInputValue().toString().trim();
|
372 |
|
373 |
if (nuevoNombre.length() == 0) { |
374 |
return;
|
375 |
} |
376 |
|
377 |
if (nuevoNombre == null) { |
378 |
return;
|
379 |
} |
380 |
|
381 |
for (int i=0; i<lstDocs.getModel().getSize(); i++){ |
382 |
if (i==index) continue; |
383 |
if (((ProjectDocument)lstDocs.getModel().getElementAt(i)).getName().equals(nuevoNombre)){
|
384 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), PluginServices.getText(this, "elemento_ya_existe")); |
385 |
return;
|
386 |
} |
387 |
|
388 |
} |
389 |
doc.setName(nuevoNombre); |
390 |
|
391 |
refreshList(); |
392 |
p.setModified(true);
|
393 |
} |
394 |
|
395 |
/**
|
396 |
* Borra un project element
|
397 |
*/
|
398 |
private void borrar() { |
399 |
int res = JOptionPane.showConfirmDialog((Component) PluginServices.getMainFrame(), |
400 |
PluginServices.getText(this, "confirmar_borrar"), |
401 |
PluginServices.getText(this, "borrar"), |
402 |
JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE); |
403 |
|
404 |
if (res == JOptionPane.YES_OPTION) { |
405 |
int[] indexes = lstDocs.getSelectedIndices(); |
406 |
for (int i=indexes.length-1;i>=0;i--) { |
407 |
int index=indexes[i];
|
408 |
String s=getDocumentSelected();
|
409 |
ArrayList documents=p.getDocumentsByType(s);
|
410 |
ProjectDocument doc=(ProjectDocument)documents.get(index); |
411 |
if (doc.isLocked()) {
|
412 |
JOptionPane.showMessageDialog(this, PluginServices.getText(this, "locked_element_it_cannot_be_deleted")); |
413 |
return;
|
414 |
} |
415 |
PluginServices.getMDIManager().closeSingletonWindow(doc); |
416 |
p.delDocument(doc); |
417 |
} |
418 |
refreshList(); |
419 |
p.setModified(true);
|
420 |
} |
421 |
} |
422 |
|
423 |
/**
|
424 |
* Muestra el di?logo de propiedades de un project element
|
425 |
*/
|
426 |
private void propiedades() { |
427 |
int index = lstDocs.getSelectedIndex();
|
428 |
|
429 |
if (index == -1) { |
430 |
return;
|
431 |
} |
432 |
|
433 |
IWindow dlg = null;
|
434 |
String s=getDocumentSelected();
|
435 |
ArrayList documents=p.getDocumentsByType(s);
|
436 |
ProjectDocument doc=(ProjectDocument) documents.get(index); |
437 |
if (doc.isLocked()) {
|
438 |
JOptionPane.showMessageDialog(this, PluginServices.getText(this, "locked_element")); |
439 |
return;
|
440 |
} |
441 |
dlg=doc.getProperties(); |
442 |
PluginServices.getMDIManager().addWindow(dlg); |
443 |
|
444 |
refreshControls(); |
445 |
lstDocs.setSelectedIndex(index); |
446 |
p.setModified(true);
|
447 |
} |
448 |
|
449 |
/**
|
450 |
* This method initializes jPanel
|
451 |
*
|
452 |
* @return JPanel
|
453 |
*/
|
454 |
private JPanel getJPanel() { |
455 |
if (jPanel == null) { |
456 |
jPanel = new JPanel(); |
457 |
|
458 |
java.awt.FlowLayout layFlowLayout1 = new java.awt.FlowLayout();
|
459 |
layFlowLayout1.setHgap(15);
|
460 |
jPanel.setLayout(layFlowLayout1); |
461 |
JRadioButton[] btns=getBtnDocuments(); |
462 |
for (int i=0;i<btns.length;i++) { |
463 |
jPanel.add(btns[i],null);
|
464 |
} |
465 |
jPanel.setName("tipoDocPanel");
|
466 |
//jPanel.setPreferredSize(new java.awt.Dimension(700, 200));
|
467 |
jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder( |
468 |
null, PluginServices.getText(this, "tipos_de_documentos"), |
469 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
470 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
471 |
} |
472 |
|
473 |
return jPanel;
|
474 |
} |
475 |
|
476 |
/**
|
477 |
* This method initializes btnVistas
|
478 |
*
|
479 |
* @return JRadioButton
|
480 |
*/
|
481 |
private JRadioButton[] getBtnDocuments() { |
482 |
if (btnsDocuments == null) { |
483 |
ExtensionPoints extensionPoints = |
484 |
ExtensionPointsSingleton.getInstance(); |
485 |
|
486 |
ExtensionPoint extensionPoint =(ExtensionPoint)extensionPoints.get("Documents");
|
487 |
ArrayList btns=new ArrayList(); |
488 |
ArrayList priorities=new ArrayList(); |
489 |
Iterator iterator = extensionPoint.keySet().iterator();
|
490 |
while (iterator.hasNext()) {
|
491 |
try {
|
492 |
ProjectDocumentFactory documentFactory = (ProjectDocumentFactory)extensionPoint.create((String)iterator.next());
|
493 |
JRadioButton rb=new JRadioButton(); |
494 |
|
495 |
rb.setIcon(documentFactory.getButtonIcon()); |
496 |
rb.setSelectedIcon(documentFactory.getSelectedButtonIcon()); |
497 |
rb.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); |
498 |
rb.setText(documentFactory.getNameType()); |
499 |
rb.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); |
500 |
rb.setName(documentFactory.getRegisterName()); |
501 |
rb.addChangeListener(new javax.swing.event.ChangeListener() {
|
502 |
public void stateChanged(javax.swing.event.ChangeEvent e) { |
503 |
refreshList(); |
504 |
} |
505 |
}); |
506 |
// place in the right order according to list priority
|
507 |
int priority = documentFactory.getListPriority();
|
508 |
int pos;
|
509 |
for (pos=0; pos<btns.size(); pos++) { |
510 |
if (((Integer)(priorities.get(pos))).intValue() > priority) { |
511 |
priorities.add(pos, new Integer(priority)); |
512 |
btns.add(pos, rb); |
513 |
break;
|
514 |
} |
515 |
} |
516 |
if (pos >= btns.size()) {
|
517 |
priorities.add(new Integer(priority)); |
518 |
btns.add(rb); |
519 |
} |
520 |
|
521 |
} catch (InstantiationException e) { |
522 |
e.printStackTrace(); |
523 |
} catch (IllegalAccessException e) { |
524 |
e.printStackTrace(); |
525 |
} catch (ClassCastException e) { |
526 |
e.printStackTrace(); |
527 |
} |
528 |
} |
529 |
|
530 |
|
531 |
btnsDocuments=(JRadioButton[])btns.toArray(new JRadioButton[0]); |
532 |
|
533 |
} |
534 |
|
535 |
return btnsDocuments;
|
536 |
} |
537 |
|
538 |
/**
|
539 |
* This method initializes jPanel1
|
540 |
*
|
541 |
* @return JPanel
|
542 |
*/
|
543 |
private JPanel getJPanel1() { |
544 |
if (jPanel1 == null) { |
545 |
jPanel1 = new JPanel(); |
546 |
|
547 |
GridBagLayout layout2 = new GridBagLayout(); |
548 |
GridBagConstraints c = new GridBagConstraints(); |
549 |
|
550 |
jPanel1.setLayout(layout2); |
551 |
c.insets = new Insets(2, 5, 2, 5); |
552 |
c.anchor = GridBagConstraints.WEST;
|
553 |
c.fill = GridBagConstraints.BOTH;
|
554 |
c.weightx= 1.0;
|
555 |
c.weighty = 1.0;
|
556 |
layout2.setConstraints(getJScrollPane(),c); |
557 |
jPanel1.add(getJScrollPane()); |
558 |
|
559 |
c.anchor = GridBagConstraints.EAST;
|
560 |
|
561 |
|
562 |
c.fill = GridBagConstraints.NONE;
|
563 |
c.weightx= 0;
|
564 |
c.weighty = 0;
|
565 |
layout2.setConstraints(getJPanel2(),c); |
566 |
jPanel1.add(getJPanel2()); |
567 |
|
568 |
//jPanel1.setPreferredSize(new java.awt.Dimension(430,170));
|
569 |
jPanel1.setMinimumSize(new java.awt.Dimension(430,170)); |
570 |
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder( |
571 |
null,
|
572 |
PluginServices.getText(this, "documentos_existentes"), |
573 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
574 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
575 |
} |
576 |
|
577 |
return jPanel1;
|
578 |
} |
579 |
|
580 |
/**
|
581 |
* This method initializes lstDocs
|
582 |
*
|
583 |
* @return JList
|
584 |
*/
|
585 |
private JList getLstDocs() { |
586 |
if (lstDocs == null) { |
587 |
lstDocs = new JList(); |
588 |
lstDocs.addMouseListener(new java.awt.event.MouseAdapter() {
|
589 |
public ProjectDocument[] getSelecteds() { |
590 |
if (lstDocs.getSelectedIndex() < 0) { |
591 |
return new ProjectDocument[0]; |
592 |
} |
593 |
Object[] seleteds = lstDocs.getSelectedValues(); |
594 |
ProjectDocument[] returnValue = new ProjectDocument[seleteds.length]; |
595 |
System.arraycopy(seleteds,0,returnValue,0,seleteds.length); |
596 |
return returnValue;
|
597 |
} |
598 |
|
599 |
public ProjectDocument getItem(java.awt.event.MouseEvent e) {
|
600 |
if (lstDocs.getSelectedIndex() < 0) { |
601 |
return null; |
602 |
} |
603 |
Component c = lstDocs.getComponentAt(e.getPoint());
|
604 |
|
605 |
return null; |
606 |
} |
607 |
|
608 |
public void mouseClicked(java.awt.event.MouseEvent e) { |
609 |
if (e.getButton() == java.awt.event.MouseEvent.BUTTON3) {
|
610 |
/*
|
611 |
getDocumentSelected();//ProjectView
|
612 |
getDocumentSelectedName();//Vista
|
613 |
*/
|
614 |
String docType = getDocumentSelected();
|
615 |
ProjectDocument[] selecteds = this.getSelecteds(); |
616 |
|
617 |
if (selecteds == null) return; |
618 |
DocumentContextMenu menu = new DocumentContextMenu(docType,this.getItem(e),(ProjectDocument[])selecteds); |
619 |
if (menu.getActionsVisibles() < 1) return; |
620 |
lstDocs.add(menu); |
621 |
menu.show(e.getComponent(), e.getX(), e.getY()); |
622 |
return;
|
623 |
} |
624 |
|
625 |
if (e.getClickCount() == 2) { |
626 |
abrir(); |
627 |
} |
628 |
|
629 |
} |
630 |
}); |
631 |
lstDocs.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
632 |
public void valueChanged( |
633 |
javax.swing.event.ListSelectionEvent e) { |
634 |
activarBotones(); |
635 |
} |
636 |
}); |
637 |
} |
638 |
|
639 |
return lstDocs;
|
640 |
} |
641 |
|
642 |
/**
|
643 |
* This method initializes jPanel2
|
644 |
*
|
645 |
* @return JPanel
|
646 |
*/
|
647 |
private JPanel getJPanel2() { |
648 |
if (jPanel2 == null) { |
649 |
jPanel2 = new JPanel(); |
650 |
|
651 |
//FlowLayout layout = new FlowLayout();
|
652 |
GridLayout layout = new GridLayout(5,1); |
653 |
layout.setVgap(7);
|
654 |
|
655 |
jPanel2.setLayout(layout); |
656 |
jPanel2.add(getBtnNuevo(), null);
|
657 |
jPanel2.add(getBtnAbrir(), null);
|
658 |
jPanel2.add(getBtnRenombrar(), null);
|
659 |
jPanel2.add(getBtnBorrar(), null);
|
660 |
jPanel2.add(getBtnPropiedades(), null);
|
661 |
jPanel2.setPreferredSize(new java.awt.Dimension(100, 150)); |
662 |
jPanel2.setMinimumSize(new java.awt.Dimension(100, 150)); |
663 |
jPanel2.setMaximumSize(new java.awt.Dimension(100, 150)); |
664 |
} |
665 |
|
666 |
return jPanel2;
|
667 |
} |
668 |
|
669 |
/**
|
670 |
* This method initializes btnNuevo
|
671 |
*
|
672 |
* @return JButton
|
673 |
*/
|
674 |
private JButton getBtnNuevo() { |
675 |
if (btnNuevo == null) { |
676 |
btnNuevo = new JButton(); |
677 |
btnNuevo.setName("btnNuevo");
|
678 |
btnNuevo.setText(PluginServices.getText(this, "nuevo")); |
679 |
btnNuevo.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
680 |
btnNuevo.addActionListener(new java.awt.event.ActionListener() {
|
681 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
682 |
try {
|
683 |
newProjectDocument(); |
684 |
} catch (Exception e1) { |
685 |
NotificationManager.addError(e1.getLocalizedMessage(), |
686 |
e1); |
687 |
} |
688 |
} |
689 |
}); |
690 |
} |
691 |
|
692 |
return btnNuevo;
|
693 |
} |
694 |
|
695 |
/**
|
696 |
* This method initializes btnPropiedades
|
697 |
*
|
698 |
* @return JButton
|
699 |
*/
|
700 |
private JButton getBtnPropiedades() { |
701 |
if (btnPropiedades == null) { |
702 |
btnPropiedades = new JButton(); |
703 |
btnPropiedades.setText(PluginServices.getText(this, "propiedades")); |
704 |
btnPropiedades.setName("btnPropiedades");
|
705 |
btnPropiedades.setEnabled(false);
|
706 |
btnPropiedades.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
707 |
btnPropiedades.addActionListener(new java.awt.event.ActionListener() {
|
708 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
709 |
propiedades(); |
710 |
} |
711 |
}); |
712 |
} |
713 |
|
714 |
return btnPropiedades;
|
715 |
} |
716 |
|
717 |
/**
|
718 |
* This method initializes btnAbrir
|
719 |
*
|
720 |
* @return JButton
|
721 |
*/
|
722 |
private JButton getBtnAbrir() { |
723 |
if (btnAbrir == null) { |
724 |
btnAbrir = new JButton(); |
725 |
btnAbrir.setName("btnAbrir");
|
726 |
btnAbrir.setText(PluginServices.getText(this, "abrir")); |
727 |
btnAbrir.setEnabled(false);
|
728 |
btnAbrir.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
729 |
btnAbrir.addActionListener(new java.awt.event.ActionListener() {
|
730 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
731 |
abrir(); |
732 |
} |
733 |
}); |
734 |
} |
735 |
|
736 |
return btnAbrir;
|
737 |
} |
738 |
|
739 |
/**
|
740 |
* This method initializes btnBorrar
|
741 |
*
|
742 |
* @return JButton
|
743 |
*/
|
744 |
private JButton getBtnBorrar() { |
745 |
if (btnBorrar == null) { |
746 |
btnBorrar = new JButton(); |
747 |
btnBorrar.setText(PluginServices.getText(this, "borrar")); |
748 |
btnBorrar.setName("btnBorrar");
|
749 |
btnBorrar.setEnabled(false);
|
750 |
btnBorrar.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
751 |
btnBorrar.addActionListener(new java.awt.event.ActionListener() {
|
752 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
753 |
borrar(); |
754 |
} |
755 |
}); |
756 |
} |
757 |
|
758 |
return btnBorrar;
|
759 |
} |
760 |
|
761 |
/**
|
762 |
* This method initializes btnRenombrar
|
763 |
*
|
764 |
* @return JButton
|
765 |
*/
|
766 |
private JButton getBtnRenombrar() { |
767 |
if (btnRenombrar == null) { |
768 |
btnRenombrar = new JButton(); |
769 |
btnRenombrar.setName("btnRenombrar");
|
770 |
btnRenombrar.setText(PluginServices.getText(this, "renombrar")); |
771 |
btnRenombrar.setEnabled(false);
|
772 |
btnRenombrar.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
773 |
btnRenombrar.addActionListener(new java.awt.event.ActionListener() {
|
774 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
775 |
renombrar(); |
776 |
} |
777 |
}); |
778 |
} |
779 |
|
780 |
return btnRenombrar;
|
781 |
} |
782 |
|
783 |
/**
|
784 |
* This method initializes jPanel3
|
785 |
*
|
786 |
* @return JPanel
|
787 |
*/
|
788 |
private JPanel getJPanel3() { |
789 |
if (jPanel3 == null) { |
790 |
jPanel3 = new JPanel(); |
791 |
|
792 |
GridBagLayout layout3 = new GridBagLayout(); |
793 |
GridBagConstraints c = new GridBagConstraints(); |
794 |
jPanel3.setLayout(layout3); |
795 |
c.insets = new Insets(2, 5, 0, 5); |
796 |
c.anchor = GridBagConstraints.WEST;
|
797 |
c.gridx =0;
|
798 |
c.gridy =0;
|
799 |
layout3.setConstraints(getJLabel(),c); |
800 |
jPanel3.add(getJLabel(), null);
|
801 |
c.fill = GridBagConstraints.HORIZONTAL;
|
802 |
c.weightx=1.0;
|
803 |
c.gridx =1;
|
804 |
layout3.setConstraints(getLblNombreSesion(),c); |
805 |
jPanel3.add(getLblNombreSesion(), null);
|
806 |
|
807 |
c.gridx =0;
|
808 |
c.gridy =1;
|
809 |
c.fill = GridBagConstraints.NONE;
|
810 |
c.weightx=0.0;
|
811 |
layout3.setConstraints(getJLabel1(),c); |
812 |
jPanel3.add(getJLabel1(), null);
|
813 |
c.fill = GridBagConstraints.HORIZONTAL;
|
814 |
c.weightx=1.0;
|
815 |
c.gridx =1;
|
816 |
layout3.setConstraints(getLblGuardado(),c); |
817 |
jPanel3.add(getLblGuardado(), null);
|
818 |
|
819 |
c.gridx =0;
|
820 |
c.gridy =2;
|
821 |
c.fill = GridBagConstraints.NONE;
|
822 |
c.weightx=0.0;
|
823 |
layout3.setConstraints(getJLabel2(),c); |
824 |
jPanel3.add(getJLabel2(), null);
|
825 |
|
826 |
c.fill = GridBagConstraints.HORIZONTAL;
|
827 |
c.weightx=1.0;
|
828 |
c.gridx =1;
|
829 |
layout3.setConstraints(getLblFecha(),c); |
830 |
jPanel3.add(getLblFecha(), null);
|
831 |
jPanel3.setPreferredSize(new java.awt.Dimension(430, 125)); |
832 |
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder( |
833 |
null, PluginServices.getText(this, "propiedades_sesion"), |
834 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
835 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
836 |
c.gridx =1;
|
837 |
c.gridy =4;
|
838 |
c.anchor = GridBagConstraints.EAST;
|
839 |
layout3.setConstraints(getJPanel4(),c); |
840 |
jPanel3.add(getJPanel4(), null);
|
841 |
} |
842 |
|
843 |
return jPanel3;
|
844 |
} |
845 |
|
846 |
/**
|
847 |
* This method initializes jLabel
|
848 |
*
|
849 |
* @return JLabel
|
850 |
*/
|
851 |
private JLabel getJLabel() { |
852 |
if (jLabel == null) { |
853 |
jLabel = new JLabel(); |
854 |
jLabel.setText(PluginServices.getText(this, "nombre_sesion") + ":"); |
855 |
jLabel.setPreferredSize(new java.awt.Dimension(150, 16)); |
856 |
} |
857 |
|
858 |
return jLabel;
|
859 |
} |
860 |
|
861 |
/**
|
862 |
* This method initializes lblNombreSesion
|
863 |
*
|
864 |
* @return JLabel
|
865 |
*/
|
866 |
private JLabel getLblNombreSesion() { |
867 |
if (lblNombreSesion == null) { |
868 |
lblNombreSesion = new JLabel(); |
869 |
lblNombreSesion.setText("");
|
870 |
lblNombreSesion.setName("lblNombreSesion");
|
871 |
lblNombreSesion.setPreferredSize(new java.awt.Dimension(200, 16)); |
872 |
lblNombreSesion.setAutoscrolls(true);
|
873 |
} |
874 |
|
875 |
return lblNombreSesion;
|
876 |
} |
877 |
|
878 |
/**
|
879 |
* This method initializes jLabel1
|
880 |
*
|
881 |
* @return JLabel
|
882 |
*/
|
883 |
private JLabel getJLabel1() { |
884 |
if (jLabel1 == null) { |
885 |
jLabel1 = new JLabel(); |
886 |
jLabel1.setText(PluginServices.getText(this, "guardado") + ":"); |
887 |
jLabel1.setPreferredSize(new java.awt.Dimension(150, 16)); |
888 |
} |
889 |
|
890 |
return jLabel1;
|
891 |
} |
892 |
|
893 |
/**
|
894 |
* This method initializes lblGuardado
|
895 |
*
|
896 |
* @return JLabel
|
897 |
*/
|
898 |
private JLabel getLblGuardado() { |
899 |
if (lblGuardado == null) { |
900 |
lblGuardado = new JLabel(); |
901 |
lblGuardado.setText("");
|
902 |
lblGuardado.setPreferredSize(new java.awt.Dimension(200, 16)); |
903 |
lblGuardado.setAutoscrolls(true);
|
904 |
} |
905 |
|
906 |
return lblGuardado;
|
907 |
} |
908 |
|
909 |
/**
|
910 |
* This method initializes jLabel2
|
911 |
*
|
912 |
* @return JLabel
|
913 |
*/
|
914 |
private JLabel getJLabel2() { |
915 |
if (jLabel2 == null) { |
916 |
jLabel2 = new JLabel(); |
917 |
jLabel2.setText(PluginServices.getText(this, "creation_date") + |
918 |
":");
|
919 |
jLabel2.setPreferredSize(new java.awt.Dimension(150, 16)); |
920 |
} |
921 |
|
922 |
return jLabel2;
|
923 |
} |
924 |
|
925 |
/**
|
926 |
* This method initializes lblFecha
|
927 |
*
|
928 |
* @return JLabel
|
929 |
*/
|
930 |
private JLabel getLblFecha() { |
931 |
if (lblFecha == null) { |
932 |
lblFecha = new JLabel(); |
933 |
lblFecha.setText("");
|
934 |
lblFecha.setPreferredSize(new java.awt.Dimension(200, 16)); |
935 |
lblFecha.setAutoscrolls(true);
|
936 |
} |
937 |
|
938 |
return lblFecha;
|
939 |
} |
940 |
|
941 |
/**
|
942 |
* This method initializes btnImportar
|
943 |
*
|
944 |
* @return JButton
|
945 |
*/
|
946 |
private JButton getBtnImportar() { |
947 |
if (btnImportar == null) { |
948 |
btnImportar = new JButton(); |
949 |
btnImportar.setPreferredSize(new java.awt.Dimension(80, 23)); |
950 |
btnImportar.setText(PluginServices.getText(this, "importar")); |
951 |
btnImportar.setName("btnImportar");
|
952 |
btnImportar.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
953 |
// TODO implement import
|
954 |
btnImportar.setVisible(false);
|
955 |
} |
956 |
|
957 |
return btnImportar;
|
958 |
} |
959 |
|
960 |
/**
|
961 |
* This method initializes btnExportar
|
962 |
*
|
963 |
* @return JButton
|
964 |
*/
|
965 |
private JButton getBtnExportar() { |
966 |
if (btnExportar == null) { |
967 |
btnExportar = new JButton(); |
968 |
btnExportar.setPreferredSize(new java.awt.Dimension(80, 23)); |
969 |
btnExportar.setText(PluginServices.getText(this, "exportar")); |
970 |
btnExportar.setName("btnExportar");
|
971 |
btnExportar.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
972 |
// TODO implement export
|
973 |
btnExportar.setVisible(false);
|
974 |
} |
975 |
|
976 |
return btnExportar;
|
977 |
} |
978 |
|
979 |
/**
|
980 |
* This method initializes btnEditar
|
981 |
*
|
982 |
* @return JButton
|
983 |
*/
|
984 |
private JButton getBtnEditar() { |
985 |
if (btnEditar == null) { |
986 |
btnEditar = new JButton(); |
987 |
btnEditar.setPreferredSize(new java.awt.Dimension(80, 23)); |
988 |
btnEditar.setText(PluginServices.getText(this, "propiedades")); |
989 |
|
990 |
btnEditar.setName("btnEditar");
|
991 |
btnEditar.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
992 |
|
993 |
btnEditar.addActionListener(new java.awt.event.ActionListener() {
|
994 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
995 |
ProjectProperties dlg = new ProjectProperties(p);
|
996 |
PluginServices.getMDIManager().addWindow(dlg); |
997 |
refreshProperties(); |
998 |
} |
999 |
}); |
1000 |
} |
1001 |
|
1002 |
return btnEditar;
|
1003 |
} |
1004 |
|
1005 |
/**
|
1006 |
* This method initializes jScrollPane
|
1007 |
*
|
1008 |
* @return JScrollPane
|
1009 |
*/
|
1010 |
private JScrollPane getJScrollPane() { |
1011 |
if (jScrollPane == null) { |
1012 |
jScrollPane = new JScrollPane(); |
1013 |
jScrollPane.setViewportView(getLstDocs()); |
1014 |
jScrollPane.setPreferredSize(new java.awt.Dimension(200, 100)); |
1015 |
jScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
1016 |
} |
1017 |
|
1018 |
return jScrollPane;
|
1019 |
} |
1020 |
|
1021 |
/**
|
1022 |
* @see com.iver.mdiApp.ui.MDIManager.SingletonWindow#getWindowModel()
|
1023 |
*/
|
1024 |
public Object getWindowModel() { |
1025 |
return p;
|
1026 |
} |
1027 |
|
1028 |
/**
|
1029 |
* This method is used to get <strong>an initial</strong> ViewInfo object
|
1030 |
* for this Project Manager window. It is not intended to retrieve the
|
1031 |
* ViewInfo object in a later time.
|
1032 |
* <strong>Use PluginServices.getMDIManager().getViewInfo(view)
|
1033 |
* to retrieve the ViewInfo object at any time after the creation of the
|
1034 |
* object.
|
1035 |
*
|
1036 |
* @see com.iver.mdiApp.ui.MDIManager.IWindow#getWindowInfo()
|
1037 |
*/
|
1038 |
public WindowInfo getWindowInfo() {
|
1039 |
//if (m_viewInfo==null) {
|
1040 |
m_viewInfo = new WindowInfo(WindowInfo.MAXIMIZABLE);
|
1041 |
//m_viewInfo = new ViewInfo(ViewInfo.MAXIMIZABLE+ViewInfo.RESIZABLE);
|
1042 |
m_viewInfo.setWidth(this.getWidth());
|
1043 |
m_viewInfo.setHeight(this.getHeight());
|
1044 |
m_viewInfo.setNormalWidth(this.getPreferredSize().width);
|
1045 |
m_viewInfo.setNormalHeight(this.getPreferredSize().height);
|
1046 |
|
1047 |
m_viewInfo.setTitle(PluginServices.getText(this, "titulo")); |
1048 |
//}
|
1049 |
return m_viewInfo;
|
1050 |
} |
1051 |
|
1052 |
/**
|
1053 |
* @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
|
1054 |
*/
|
1055 |
public void propertyChange(PropertyChangeEvent evt) { |
1056 |
refreshControls(); |
1057 |
} |
1058 |
|
1059 |
/**
|
1060 |
* @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
|
1061 |
*/
|
1062 |
public void viewActivated() { |
1063 |
} |
1064 |
|
1065 |
/**
|
1066 |
* This method initializes jPanel4
|
1067 |
*
|
1068 |
* @return JPanel
|
1069 |
*/
|
1070 |
private JPanel getJPanel4() { |
1071 |
if (jPanel4 == null) { |
1072 |
jPanel4 = new JPanel(); |
1073 |
|
1074 |
jPanel4.setLayout(new FlowLayout(FlowLayout.RIGHT)); |
1075 |
jPanel4.setPreferredSize(new java.awt.Dimension(414, 30)); |
1076 |
jPanel4.setComponentOrientation(java.awt.ComponentOrientation.LEFT_TO_RIGHT); |
1077 |
jPanel4.add(getBtnImportar(), null);
|
1078 |
jPanel4.add(getBtnExportar(), null);
|
1079 |
jPanel4.add(getBtnEditar(), null);
|
1080 |
} |
1081 |
|
1082 |
return jPanel4;
|
1083 |
} |
1084 |
|
1085 |
/**
|
1086 |
* This method initializes jScrollPane1
|
1087 |
*
|
1088 |
* @return javax.swing.JScrollPane
|
1089 |
*/
|
1090 |
private JScrollPane getJScrollPane1() { |
1091 |
if (jScrollPane1 == null) { |
1092 |
jScrollPane1 = new JScrollPane(); |
1093 |
jScrollPane1.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_NEVER); |
1094 |
jScrollPane1.setPreferredSize(new java.awt.Dimension(433,200)); |
1095 |
jScrollPane1.setViewportView(getJPanel()); |
1096 |
} |
1097 |
return jScrollPane1;
|
1098 |
} |
1099 |
} // @jve:decl-index=0:visual-constraint="10,10"
|