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