root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / gui / ProjectWindow.java @ 10008
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, 554)); |
277 |
this.setMinimumSize(new java.awt.Dimension(430, 554)); |
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 |
p.setModified(true);
|
322 |
} |
323 |
} |
324 |
|
325 |
/**
|
326 |
* Abre la ventana de un nuevo project element
|
327 |
*/
|
328 |
private void abrir() { |
329 |
int[] indexes = lstDocs.getSelectedIndices(); |
330 |
for (int i=indexes.length-1;i>=0;i--) { |
331 |
int index=indexes[i];
|
332 |
if (index == -1) { |
333 |
return;
|
334 |
} |
335 |
String s=getDocumentSelected();
|
336 |
ArrayList documents=p.getDocumentsByType(s);
|
337 |
ProjectDocument doc=(ProjectDocument)documents.get(index); |
338 |
IWindow window=doc.createWindow(); |
339 |
PluginServices.getMDIManager().addWindow(window); |
340 |
} |
341 |
p.setModified(true);
|
342 |
} |
343 |
|
344 |
/**
|
345 |
* Cambia el nombre de un project element
|
346 |
*/
|
347 |
private void renombrar() { |
348 |
int index = lstDocs.getSelectedIndex();
|
349 |
|
350 |
if (index == -1) { |
351 |
return;
|
352 |
} |
353 |
String s=getDocumentSelected();
|
354 |
ArrayList documents=p.getDocumentsByType(s);
|
355 |
ProjectDocument doc=(ProjectDocument)documents.get(index); |
356 |
|
357 |
if (doc.isLocked()) {
|
358 |
JOptionPane.showMessageDialog(this, PluginServices.getText(this, "locked_element_it_cannot_be_renamed")); |
359 |
return;
|
360 |
} |
361 |
|
362 |
JOptionPane pane = new JOptionPane(); |
363 |
pane.setMessage(PluginServices.getText(this, "introduce_nombre")); |
364 |
pane.setMessageType(JOptionPane.QUESTION_MESSAGE);
|
365 |
pane.setWantsInput(true);
|
366 |
pane.setInitialSelectionValue(doc.getName()); |
367 |
pane.setInputValue(doc.getName()); |
368 |
JDialog dlg = pane.createDialog((Component) PluginServices.getMainFrame(), |
369 |
PluginServices.getText(this, "renombrar")); |
370 |
dlg.setModal(true);
|
371 |
dlg.show(); |
372 |
|
373 |
String nuevoNombre = pane.getInputValue().toString().trim();
|
374 |
|
375 |
if (nuevoNombre.length() == 0) { |
376 |
return;
|
377 |
} |
378 |
|
379 |
if (nuevoNombre == null) { |
380 |
return;
|
381 |
} |
382 |
|
383 |
for (int i=0; i<lstDocs.getModel().getSize(); i++){ |
384 |
if (i==index) continue; |
385 |
if (((ProjectDocument)lstDocs.getModel().getElementAt(i)).getName().equals(nuevoNombre)){
|
386 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), PluginServices.getText(this, "elemento_ya_existe")); |
387 |
return;
|
388 |
} |
389 |
|
390 |
} |
391 |
doc.setName(nuevoNombre); |
392 |
|
393 |
refreshList(); |
394 |
p.setModified(true);
|
395 |
} |
396 |
|
397 |
/**
|
398 |
* Borra un project element
|
399 |
*/
|
400 |
private void borrar() { |
401 |
int res = JOptionPane.showConfirmDialog((Component) PluginServices.getMainFrame(), |
402 |
PluginServices.getText(this, "confirmar_borrar"), |
403 |
PluginServices.getText(this, "borrar"), |
404 |
JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE); |
405 |
|
406 |
if (res == JOptionPane.YES_OPTION) { |
407 |
int[] indexes = lstDocs.getSelectedIndices(); |
408 |
for (int i=indexes.length-1;i>=0;i--) { |
409 |
int index=indexes[i];
|
410 |
String s=getDocumentSelected();
|
411 |
ArrayList documents=p.getDocumentsByType(s);
|
412 |
ProjectDocument doc=(ProjectDocument)documents.get(index); |
413 |
if (doc.isLocked()) {
|
414 |
JOptionPane.showMessageDialog(this, PluginServices.getText(this, "locked_element_it_cannot_be_deleted")); |
415 |
return;
|
416 |
} |
417 |
PluginServices.getMDIManager().closeSingletonWindow(doc); |
418 |
p.delDocument(doc); |
419 |
} |
420 |
refreshList(); |
421 |
p.setModified(true);
|
422 |
} |
423 |
} |
424 |
|
425 |
/**
|
426 |
* Muestra el di?logo de propiedades de un project element
|
427 |
*/
|
428 |
private void propiedades() { |
429 |
int index = lstDocs.getSelectedIndex();
|
430 |
|
431 |
if (index == -1) { |
432 |
return;
|
433 |
} |
434 |
|
435 |
IWindow dlg = null;
|
436 |
String s=getDocumentSelected();
|
437 |
ArrayList documents=p.getDocumentsByType(s);
|
438 |
ProjectDocument doc=(ProjectDocument) documents.get(index); |
439 |
if (doc.isLocked()) {
|
440 |
JOptionPane.showMessageDialog(this, PluginServices.getText(this, "locked_element")); |
441 |
return;
|
442 |
} |
443 |
dlg=doc.getProperties(); |
444 |
PluginServices.getMDIManager().addWindow(dlg); |
445 |
|
446 |
refreshControls(); |
447 |
lstDocs.setSelectedIndex(index); |
448 |
p.setModified(true);
|
449 |
} |
450 |
|
451 |
/**
|
452 |
* This method initializes jPanel
|
453 |
*
|
454 |
* @return JPanel
|
455 |
*/
|
456 |
private JPanel getJPanel() { |
457 |
if (jPanel == null) { |
458 |
jPanel = new JPanel(); |
459 |
|
460 |
java.awt.FlowLayout layFlowLayout1 = new java.awt.FlowLayout();
|
461 |
layFlowLayout1.setHgap(15);
|
462 |
jPanel.setLayout(layFlowLayout1); |
463 |
JRadioButton[] btns=getBtnDocuments(); |
464 |
for (int i=0;i<btns.length;i++) { |
465 |
jPanel.add(btns[i],null);
|
466 |
} |
467 |
jPanel.setName("tipoDocPanel");
|
468 |
//jPanel.setPreferredSize(new java.awt.Dimension(700, 200));
|
469 |
jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder( |
470 |
null, PluginServices.getText(this, "tipos_de_documentos"), |
471 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
472 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
473 |
} |
474 |
|
475 |
return jPanel;
|
476 |
} |
477 |
|
478 |
/**
|
479 |
* This method initializes btnVistas
|
480 |
*
|
481 |
* @return JRadioButton
|
482 |
*/
|
483 |
private JRadioButton[] getBtnDocuments() { |
484 |
if (btnsDocuments == null) { |
485 |
ExtensionPoints extensionPoints = |
486 |
ExtensionPointsSingleton.getInstance(); |
487 |
|
488 |
ExtensionPoint extensionPoint =(ExtensionPoint)extensionPoints.get("Documents");
|
489 |
ArrayList btns=new ArrayList(); |
490 |
ArrayList priorities=new ArrayList(); |
491 |
Iterator iterator = extensionPoint.keySet().iterator();
|
492 |
while (iterator.hasNext()) {
|
493 |
try {
|
494 |
ProjectDocumentFactory documentFactory = (ProjectDocumentFactory)extensionPoint.create((String)iterator.next());
|
495 |
JRadioButton rb=new JRadioButton(); |
496 |
|
497 |
rb.setIcon(documentFactory.getButtonIcon()); |
498 |
rb.setSelectedIcon(documentFactory.getSelectedButtonIcon()); |
499 |
rb.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); |
500 |
rb.setText(documentFactory.getNameType()); |
501 |
rb.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); |
502 |
rb.setName(documentFactory.getRegisterName()); |
503 |
rb.addChangeListener(new javax.swing.event.ChangeListener() {
|
504 |
public void stateChanged(javax.swing.event.ChangeEvent e) { |
505 |
refreshList(); |
506 |
} |
507 |
}); |
508 |
// place in the right order according to list priority
|
509 |
int priority = documentFactory.getListPriority();
|
510 |
int pos;
|
511 |
for (pos=0; pos<btns.size(); pos++) { |
512 |
if (((Integer)(priorities.get(pos))).intValue() > priority) { |
513 |
priorities.add(pos, new Integer(priority)); |
514 |
btns.add(pos, rb); |
515 |
break;
|
516 |
} |
517 |
} |
518 |
if (pos >= btns.size()) {
|
519 |
priorities.add(new Integer(priority)); |
520 |
btns.add(rb); |
521 |
} |
522 |
|
523 |
} catch (InstantiationException e) { |
524 |
e.printStackTrace(); |
525 |
} catch (IllegalAccessException e) { |
526 |
e.printStackTrace(); |
527 |
} catch (ClassCastException e) { |
528 |
e.printStackTrace(); |
529 |
} |
530 |
} |
531 |
|
532 |
|
533 |
btnsDocuments=(JRadioButton[])btns.toArray(new JRadioButton[0]); |
534 |
|
535 |
} |
536 |
|
537 |
return btnsDocuments;
|
538 |
} |
539 |
|
540 |
/**
|
541 |
* This method initializes jPanel1
|
542 |
*
|
543 |
* @return JPanel
|
544 |
*/
|
545 |
private JPanel getJPanel1() { |
546 |
if (jPanel1 == null) { |
547 |
jPanel1 = new JPanel(); |
548 |
|
549 |
GridBagLayout layout2 = new GridBagLayout(); |
550 |
GridBagConstraints c = new GridBagConstraints(); |
551 |
|
552 |
jPanel1.setLayout(layout2); |
553 |
c.insets = new Insets(2, 5, 2, 5); |
554 |
c.anchor = GridBagConstraints.WEST;
|
555 |
c.fill = GridBagConstraints.BOTH;
|
556 |
c.weightx= 1.0;
|
557 |
c.weighty = 1.0;
|
558 |
layout2.setConstraints(getJScrollPane(),c); |
559 |
jPanel1.add(getJScrollPane()); |
560 |
|
561 |
c.anchor = GridBagConstraints.EAST;
|
562 |
|
563 |
|
564 |
c.fill = GridBagConstraints.NONE;
|
565 |
c.weightx= 0;
|
566 |
c.weighty = 0;
|
567 |
layout2.setConstraints(getJPanel2(),c); |
568 |
jPanel1.add(getJPanel2()); |
569 |
|
570 |
//jPanel1.setPreferredSize(new java.awt.Dimension(430,170));
|
571 |
jPanel1.setMinimumSize(new java.awt.Dimension(430,170)); |
572 |
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder( |
573 |
null,
|
574 |
PluginServices.getText(this, "documentos_existentes"), |
575 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
576 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
577 |
} |
578 |
|
579 |
return jPanel1;
|
580 |
} |
581 |
|
582 |
/**
|
583 |
* This method initializes lstDocs
|
584 |
*
|
585 |
* @return JList
|
586 |
*/
|
587 |
private JList getLstDocs() { |
588 |
if (lstDocs == null) { |
589 |
lstDocs = new JList(); |
590 |
lstDocs.addMouseListener(new java.awt.event.MouseAdapter() {
|
591 |
public ProjectDocument[] getSelecteds() { |
592 |
if (lstDocs.getSelectedIndex() < 0) { |
593 |
return new ProjectDocument[0]; |
594 |
} |
595 |
Object[] seleteds = lstDocs.getSelectedValues(); |
596 |
ProjectDocument[] returnValue = new ProjectDocument[seleteds.length]; |
597 |
System.arraycopy(seleteds,0,returnValue,0,seleteds.length); |
598 |
return returnValue;
|
599 |
} |
600 |
|
601 |
public ProjectDocument getItem(java.awt.event.MouseEvent e) {
|
602 |
if (lstDocs.getSelectedIndex() < 0) { |
603 |
return null; |
604 |
} |
605 |
Component c = lstDocs.getComponentAt(e.getPoint());
|
606 |
|
607 |
return null; |
608 |
} |
609 |
|
610 |
public void mouseClicked(java.awt.event.MouseEvent e) { |
611 |
if (e.getButton() == java.awt.event.MouseEvent.BUTTON3) {
|
612 |
/*
|
613 |
getDocumentSelected();//ProjectView
|
614 |
getDocumentSelectedName();//Vista
|
615 |
*/
|
616 |
String docType = getDocumentSelected();
|
617 |
ProjectDocument[] selecteds = this.getSelecteds(); |
618 |
|
619 |
if (selecteds == null) return; |
620 |
DocumentContextMenu menu = new DocumentContextMenu(docType,this.getItem(e),(ProjectDocument[])selecteds); |
621 |
if (menu.getActionsVisibles() < 1) return; |
622 |
lstDocs.add(menu); |
623 |
menu.show(e.getComponent(), e.getX(), e.getY()); |
624 |
return;
|
625 |
} |
626 |
|
627 |
if (e.getClickCount() == 2) { |
628 |
abrir(); |
629 |
} |
630 |
|
631 |
} |
632 |
}); |
633 |
lstDocs.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
634 |
public void valueChanged( |
635 |
javax.swing.event.ListSelectionEvent e) { |
636 |
activarBotones(); |
637 |
} |
638 |
}); |
639 |
} |
640 |
|
641 |
return lstDocs;
|
642 |
} |
643 |
|
644 |
/**
|
645 |
* This method initializes jPanel2
|
646 |
*
|
647 |
* @return JPanel
|
648 |
*/
|
649 |
private JPanel getJPanel2() { |
650 |
if (jPanel2 == null) { |
651 |
jPanel2 = new JPanel(); |
652 |
|
653 |
//FlowLayout layout = new FlowLayout();
|
654 |
GridLayout layout = new GridLayout(5,1); |
655 |
layout.setVgap(7);
|
656 |
|
657 |
jPanel2.setLayout(layout); |
658 |
jPanel2.add(getBtnNuevo(), null);
|
659 |
jPanel2.add(getBtnAbrir(), null);
|
660 |
jPanel2.add(getBtnRenombrar(), null);
|
661 |
jPanel2.add(getBtnBorrar(), null);
|
662 |
jPanel2.add(getBtnPropiedades(), null);
|
663 |
jPanel2.setPreferredSize(new java.awt.Dimension(100, 150)); |
664 |
jPanel2.setMinimumSize(new java.awt.Dimension(100, 150)); |
665 |
jPanel2.setMaximumSize(new java.awt.Dimension(100, 150)); |
666 |
} |
667 |
|
668 |
return jPanel2;
|
669 |
} |
670 |
|
671 |
/**
|
672 |
* This method initializes btnNuevo
|
673 |
*
|
674 |
* @return JButton
|
675 |
*/
|
676 |
private JButton getBtnNuevo() { |
677 |
if (btnNuevo == null) { |
678 |
btnNuevo = new JButton(); |
679 |
btnNuevo.setName("btnNuevo");
|
680 |
btnNuevo.setText(PluginServices.getText(this, "nuevo")); |
681 |
btnNuevo.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
682 |
btnNuevo.addActionListener(new java.awt.event.ActionListener() {
|
683 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
684 |
try {
|
685 |
newProjectDocument(); |
686 |
} catch (Exception e1) { |
687 |
NotificationManager.addError(e1.getLocalizedMessage(), |
688 |
e1); |
689 |
} |
690 |
} |
691 |
}); |
692 |
} |
693 |
|
694 |
return btnNuevo;
|
695 |
} |
696 |
|
697 |
/**
|
698 |
* This method initializes btnPropiedades
|
699 |
*
|
700 |
* @return JButton
|
701 |
*/
|
702 |
private JButton getBtnPropiedades() { |
703 |
if (btnPropiedades == null) { |
704 |
btnPropiedades = new JButton(); |
705 |
btnPropiedades.setText(PluginServices.getText(this, "propiedades")); |
706 |
btnPropiedades.setName("btnPropiedades");
|
707 |
btnPropiedades.setEnabled(false);
|
708 |
btnPropiedades.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
709 |
btnPropiedades.addActionListener(new java.awt.event.ActionListener() {
|
710 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
711 |
propiedades(); |
712 |
} |
713 |
}); |
714 |
} |
715 |
|
716 |
return btnPropiedades;
|
717 |
} |
718 |
|
719 |
/**
|
720 |
* This method initializes btnAbrir
|
721 |
*
|
722 |
* @return JButton
|
723 |
*/
|
724 |
private JButton getBtnAbrir() { |
725 |
if (btnAbrir == null) { |
726 |
btnAbrir = new JButton(); |
727 |
btnAbrir.setName("btnAbrir");
|
728 |
btnAbrir.setText(PluginServices.getText(this, "abrir")); |
729 |
btnAbrir.setEnabled(false);
|
730 |
btnAbrir.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
731 |
btnAbrir.addActionListener(new java.awt.event.ActionListener() {
|
732 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
733 |
abrir(); |
734 |
} |
735 |
}); |
736 |
} |
737 |
|
738 |
return btnAbrir;
|
739 |
} |
740 |
|
741 |
/**
|
742 |
* This method initializes btnBorrar
|
743 |
*
|
744 |
* @return JButton
|
745 |
*/
|
746 |
private JButton getBtnBorrar() { |
747 |
if (btnBorrar == null) { |
748 |
btnBorrar = new JButton(); |
749 |
btnBorrar.setText(PluginServices.getText(this, "borrar")); |
750 |
btnBorrar.setName("btnBorrar");
|
751 |
btnBorrar.setEnabled(false);
|
752 |
btnBorrar.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
753 |
btnBorrar.addActionListener(new java.awt.event.ActionListener() {
|
754 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
755 |
borrar(); |
756 |
} |
757 |
}); |
758 |
} |
759 |
|
760 |
return btnBorrar;
|
761 |
} |
762 |
|
763 |
/**
|
764 |
* This method initializes btnRenombrar
|
765 |
*
|
766 |
* @return JButton
|
767 |
*/
|
768 |
private JButton getBtnRenombrar() { |
769 |
if (btnRenombrar == null) { |
770 |
btnRenombrar = new JButton(); |
771 |
btnRenombrar.setName("btnRenombrar");
|
772 |
btnRenombrar.setText(PluginServices.getText(this, "renombrar")); |
773 |
btnRenombrar.setEnabled(false);
|
774 |
btnRenombrar.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
775 |
btnRenombrar.addActionListener(new java.awt.event.ActionListener() {
|
776 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
777 |
renombrar(); |
778 |
} |
779 |
}); |
780 |
} |
781 |
|
782 |
return btnRenombrar;
|
783 |
} |
784 |
|
785 |
/**
|
786 |
* This method initializes jPanel3
|
787 |
*
|
788 |
* @return JPanel
|
789 |
*/
|
790 |
private JPanel getJPanel3() { |
791 |
if (jPanel3 == null) { |
792 |
jPanel3 = new JPanel(); |
793 |
|
794 |
GridBagLayout layout3 = new GridBagLayout(); |
795 |
GridBagConstraints c = new GridBagConstraints(); |
796 |
jPanel3.setLayout(layout3); |
797 |
c.insets = new Insets(2, 5, 0, 5); |
798 |
c.anchor = GridBagConstraints.WEST;
|
799 |
c.gridx =0;
|
800 |
c.gridy =0;
|
801 |
layout3.setConstraints(getJLabel(),c); |
802 |
jPanel3.add(getJLabel(), null);
|
803 |
c.fill = GridBagConstraints.HORIZONTAL;
|
804 |
c.weightx=1.0;
|
805 |
c.gridx =1;
|
806 |
layout3.setConstraints(getLblNombreSesion(),c); |
807 |
jPanel3.add(getLblNombreSesion(), null);
|
808 |
|
809 |
c.gridx =0;
|
810 |
c.gridy =1;
|
811 |
c.fill = GridBagConstraints.NONE;
|
812 |
c.weightx=0.0;
|
813 |
layout3.setConstraints(getJLabel1(),c); |
814 |
jPanel3.add(getJLabel1(), null);
|
815 |
c.fill = GridBagConstraints.HORIZONTAL;
|
816 |
c.weightx=1.0;
|
817 |
c.gridx =1;
|
818 |
layout3.setConstraints(getLblGuardado(),c); |
819 |
jPanel3.add(getLblGuardado(), null);
|
820 |
|
821 |
c.gridx =0;
|
822 |
c.gridy =2;
|
823 |
c.fill = GridBagConstraints.NONE;
|
824 |
c.weightx=0.0;
|
825 |
layout3.setConstraints(getJLabel2(),c); |
826 |
jPanel3.add(getJLabel2(), null);
|
827 |
|
828 |
c.fill = GridBagConstraints.HORIZONTAL;
|
829 |
c.weightx=1.0;
|
830 |
c.gridx =1;
|
831 |
layout3.setConstraints(getLblFecha(),c); |
832 |
jPanel3.add(getLblFecha(), null);
|
833 |
jPanel3.setPreferredSize(new java.awt.Dimension(430, 125)); |
834 |
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder( |
835 |
null, PluginServices.getText(this, "propiedades_sesion"), |
836 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
837 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
838 |
c.gridx =1;
|
839 |
c.gridy =4;
|
840 |
c.anchor = GridBagConstraints.EAST;
|
841 |
layout3.setConstraints(getJPanel4(),c); |
842 |
jPanel3.add(getJPanel4(), null);
|
843 |
} |
844 |
|
845 |
return jPanel3;
|
846 |
} |
847 |
|
848 |
/**
|
849 |
* This method initializes jLabel
|
850 |
*
|
851 |
* @return JLabel
|
852 |
*/
|
853 |
private JLabel getJLabel() { |
854 |
if (jLabel == null) { |
855 |
jLabel = new JLabel(); |
856 |
jLabel.setText(PluginServices.getText(this, "nombre_sesion") + ":"); |
857 |
jLabel.setPreferredSize(new java.awt.Dimension(150, 16)); |
858 |
} |
859 |
|
860 |
return jLabel;
|
861 |
} |
862 |
|
863 |
/**
|
864 |
* This method initializes lblNombreSesion
|
865 |
*
|
866 |
* @return JLabel
|
867 |
*/
|
868 |
private JLabel getLblNombreSesion() { |
869 |
if (lblNombreSesion == null) { |
870 |
lblNombreSesion = new JLabel(); |
871 |
lblNombreSesion.setText("");
|
872 |
lblNombreSesion.setName("lblNombreSesion");
|
873 |
lblNombreSesion.setPreferredSize(new java.awt.Dimension(200, 16)); |
874 |
lblNombreSesion.setAutoscrolls(true);
|
875 |
} |
876 |
|
877 |
return lblNombreSesion;
|
878 |
} |
879 |
|
880 |
/**
|
881 |
* This method initializes jLabel1
|
882 |
*
|
883 |
* @return JLabel
|
884 |
*/
|
885 |
private JLabel getJLabel1() { |
886 |
if (jLabel1 == null) { |
887 |
jLabel1 = new JLabel(); |
888 |
jLabel1.setText(PluginServices.getText(this, "guardado") + ":"); |
889 |
jLabel1.setPreferredSize(new java.awt.Dimension(150, 16)); |
890 |
} |
891 |
|
892 |
return jLabel1;
|
893 |
} |
894 |
|
895 |
/**
|
896 |
* This method initializes lblGuardado
|
897 |
*
|
898 |
* @return JLabel
|
899 |
*/
|
900 |
private JLabel getLblGuardado() { |
901 |
if (lblGuardado == null) { |
902 |
lblGuardado = new JLabel(); |
903 |
lblGuardado.setText("");
|
904 |
lblGuardado.setPreferredSize(new java.awt.Dimension(200, 16)); |
905 |
lblGuardado.setAutoscrolls(true);
|
906 |
} |
907 |
|
908 |
return lblGuardado;
|
909 |
} |
910 |
|
911 |
/**
|
912 |
* This method initializes jLabel2
|
913 |
*
|
914 |
* @return JLabel
|
915 |
*/
|
916 |
private JLabel getJLabel2() { |
917 |
if (jLabel2 == null) { |
918 |
jLabel2 = new JLabel(); |
919 |
jLabel2.setText(PluginServices.getText(this, "creation_date") + |
920 |
":");
|
921 |
jLabel2.setPreferredSize(new java.awt.Dimension(150, 16)); |
922 |
} |
923 |
|
924 |
return jLabel2;
|
925 |
} |
926 |
|
927 |
/**
|
928 |
* This method initializes lblFecha
|
929 |
*
|
930 |
* @return JLabel
|
931 |
*/
|
932 |
private JLabel getLblFecha() { |
933 |
if (lblFecha == null) { |
934 |
lblFecha = new JLabel(); |
935 |
lblFecha.setText("");
|
936 |
lblFecha.setPreferredSize(new java.awt.Dimension(200, 16)); |
937 |
lblFecha.setAutoscrolls(true);
|
938 |
} |
939 |
|
940 |
return lblFecha;
|
941 |
} |
942 |
|
943 |
/**
|
944 |
* This method initializes btnImportar
|
945 |
*
|
946 |
* @return JButton
|
947 |
*/
|
948 |
private JButton getBtnImportar() { |
949 |
if (btnImportar == null) { |
950 |
btnImportar = new JButton(); |
951 |
btnImportar.setPreferredSize(new java.awt.Dimension(80, 23)); |
952 |
btnImportar.setText(PluginServices.getText(this, "importar")); |
953 |
btnImportar.setName("btnImportar");
|
954 |
btnImportar.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
955 |
// TODO implement import
|
956 |
btnImportar.setVisible(false);
|
957 |
} |
958 |
|
959 |
return btnImportar;
|
960 |
} |
961 |
|
962 |
/**
|
963 |
* This method initializes btnExportar
|
964 |
*
|
965 |
* @return JButton
|
966 |
*/
|
967 |
private JButton getBtnExportar() { |
968 |
if (btnExportar == null) { |
969 |
btnExportar = new JButton(); |
970 |
btnExportar.setPreferredSize(new java.awt.Dimension(80, 23)); |
971 |
btnExportar.setText(PluginServices.getText(this, "exportar")); |
972 |
btnExportar.setName("btnExportar");
|
973 |
btnExportar.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
974 |
// TODO implement export
|
975 |
btnExportar.setVisible(false);
|
976 |
} |
977 |
|
978 |
return btnExportar;
|
979 |
} |
980 |
|
981 |
/**
|
982 |
* This method initializes btnEditar
|
983 |
*
|
984 |
* @return JButton
|
985 |
*/
|
986 |
private JButton getBtnEditar() { |
987 |
if (btnEditar == null) { |
988 |
btnEditar = new JButton(); |
989 |
btnEditar.setPreferredSize(new java.awt.Dimension(80, 23)); |
990 |
btnEditar.setText(PluginServices.getText(this, "propiedades")); |
991 |
|
992 |
btnEditar.setName("btnEditar");
|
993 |
btnEditar.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
994 |
|
995 |
btnEditar.addActionListener(new java.awt.event.ActionListener() {
|
996 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
997 |
ProjectProperties dlg = new ProjectProperties(p);
|
998 |
PluginServices.getMDIManager().addWindow(dlg); |
999 |
refreshProperties(); |
1000 |
} |
1001 |
}); |
1002 |
} |
1003 |
|
1004 |
return btnEditar;
|
1005 |
} |
1006 |
|
1007 |
/**
|
1008 |
* This method initializes jScrollPane
|
1009 |
*
|
1010 |
* @return JScrollPane
|
1011 |
*/
|
1012 |
private JScrollPane getJScrollPane() { |
1013 |
if (jScrollPane == null) { |
1014 |
jScrollPane = new JScrollPane(); |
1015 |
jScrollPane.setViewportView(getLstDocs()); |
1016 |
jScrollPane.setPreferredSize(new java.awt.Dimension(200, 100)); |
1017 |
jScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
1018 |
} |
1019 |
|
1020 |
return jScrollPane;
|
1021 |
} |
1022 |
|
1023 |
/**
|
1024 |
* @see com.iver.mdiApp.ui.MDIManager.SingletonWindow#getWindowModel()
|
1025 |
*/
|
1026 |
public Object getWindowModel() { |
1027 |
return p;
|
1028 |
} |
1029 |
|
1030 |
/**
|
1031 |
* This method is used to get <strong>an initial</strong> ViewInfo object
|
1032 |
* for this Project Manager window. It is not intended to retrieve the
|
1033 |
* ViewInfo object in a later time.
|
1034 |
* <strong>Use PluginServices.getMDIManager().getViewInfo(view)
|
1035 |
* to retrieve the ViewInfo object at any time after the creation of the
|
1036 |
* object.
|
1037 |
*
|
1038 |
* @see com.iver.mdiApp.ui.MDIManager.IWindow#getWindowInfo()
|
1039 |
*/
|
1040 |
public WindowInfo getWindowInfo() {
|
1041 |
if (m_viewInfo==null) { |
1042 |
m_viewInfo = new WindowInfo(WindowInfo.MAXIMIZABLE);
|
1043 |
//m_viewInfo = new ViewInfo(ViewInfo.MAXIMIZABLE+ViewInfo.RESIZABLE);
|
1044 |
m_viewInfo.setWidth(this.getWidth());
|
1045 |
m_viewInfo.setHeight(this.getHeight());
|
1046 |
m_viewInfo.setNormalWidth(this.getPreferredSize().width);
|
1047 |
m_viewInfo.setNormalHeight(this.getPreferredSize().height);
|
1048 |
|
1049 |
m_viewInfo.setTitle(PluginServices.getText(this, "titulo")); |
1050 |
} |
1051 |
return m_viewInfo;
|
1052 |
} |
1053 |
|
1054 |
/**
|
1055 |
* @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
|
1056 |
*/
|
1057 |
public void propertyChange(PropertyChangeEvent evt) { |
1058 |
refreshControls(); |
1059 |
} |
1060 |
|
1061 |
/**
|
1062 |
* @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
|
1063 |
*/
|
1064 |
public void viewActivated() { |
1065 |
} |
1066 |
|
1067 |
/**
|
1068 |
* This method initializes jPanel4
|
1069 |
*
|
1070 |
* @return JPanel
|
1071 |
*/
|
1072 |
private JPanel getJPanel4() { |
1073 |
if (jPanel4 == null) { |
1074 |
jPanel4 = new JPanel(); |
1075 |
|
1076 |
jPanel4.setLayout(new FlowLayout(FlowLayout.RIGHT)); |
1077 |
jPanel4.setPreferredSize(new java.awt.Dimension(414, 30)); |
1078 |
jPanel4.setComponentOrientation(java.awt.ComponentOrientation.LEFT_TO_RIGHT); |
1079 |
jPanel4.add(getBtnImportar(), null);
|
1080 |
jPanel4.add(getBtnExportar(), null);
|
1081 |
jPanel4.add(getBtnEditar(), null);
|
1082 |
} |
1083 |
|
1084 |
return jPanel4;
|
1085 |
} |
1086 |
|
1087 |
/**
|
1088 |
* This method initializes jScrollPane1
|
1089 |
*
|
1090 |
* @return javax.swing.JScrollPane
|
1091 |
*/
|
1092 |
private JScrollPane getJScrollPane1() { |
1093 |
if (jScrollPane1 == null) { |
1094 |
jScrollPane1 = new JScrollPane(); |
1095 |
jScrollPane1.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_NEVER); |
1096 |
jScrollPane1.setPreferredSize(new java.awt.Dimension(433,200)); |
1097 |
jScrollPane1.setViewportView(getJPanel()); |
1098 |
} |
1099 |
return jScrollPane1;
|
1100 |
} |
1101 |
} // @jve:decl-index=0:visual-constraint="10,10"
|