Revision 27691 trunk/extensions/extTableSummarize/src/org/gvsig/app/documents/table/summarize/gui/SummarizeForm.java

View differences:

SummarizeForm.java
181 181
    	
182 182
    	model.setColumnIdentifiers(newIdentifiers);
183 183
    	
184
		TableColumnModel columnModel = jXTableSeleccion.getColumnModel();
185

  
186
		columnModel.getColumn(0).setPreferredWidth(50);
187
		columnModel.getColumn(1).setPreferredWidth(50);
188
		columnModel.getColumn(2).setPreferredWidth(50);
189
		columnModel.getColumn(3).setPreferredWidth(50);
190
		columnModel.getColumn(4).setPreferredWidth(50);
191
		columnModel.getColumn(5).setPreferredWidth(60);
192
		columnModel.getColumn(6).setPreferredWidth(50);
184
//		TableColumnModel columnModel = jXTableSeleccion.getColumnModel();
185
//
186
//		columnModel.getColumn(0).setPreferredWidth(50);
187
//		columnModel.getColumn(1).setPreferredWidth(50);
188
//		columnModel.getColumn(2).setPreferredWidth(50);
189
//		columnModel.getColumn(3).setPreferredWidth(50);
190
//		columnModel.getColumn(4).setPreferredWidth(50);
191
//		columnModel.getColumn(5).setPreferredWidth(60);
192
//		columnModel.getColumn(6).setPreferredWidth(50);
193 193
		
194 194
		jXTableSeleccion.setHorizontalScrollEnabled(true);
195 195
		jXTableSeleccion.setHighlighters(new AlternateRowHighlighter());
......
240 240
	 */
241 241
	private void setTranslation() {
242 242
		jLabelDescription.setText(PluginServices.getText(this, "lbl_SummarizeForm_descripcion1"));
243
		jLabelDescription2.setText(PluginServices.getText(this, "lbl_SummarizeForm_descripcion2"));
244 243
		jLabelPunto1.setText(PluginServices.getText(this, "lbl_SummarizeForm_punto1"));
245 244
		jLabelPunto2.setText(PluginServices.getText(this, "lbl_SummarizeForm_punto2"));
246 245
		jLabelPunto3.setText(PluginServices.getText(this, "lbl_SummarizeForm_punto3"));
......
316 315
        jLabelDescription = new javax.swing.JLabel();
317 316
        jPanelMain = new javax.swing.JPanel();
318 317
        jLabelPunto1 = new javax.swing.JLabel();
319
        jComboBoxExtGroupByField = new com.iver.swingext.JComboBoxExt();
318
        jComboBoxExtGroupByField = new org.gvsig.app.documents.table.summarize.utils.JComboBoxExt();
320 319
        jLabelPunto2 = new javax.swing.JLabel();
321 320
        jScrollPaneTree = new javax.swing.JScrollPane();
322 321
        jXTableSeleccion = new org.jdesktop.swingx.JXTable();
323 322
        jLabelPunto3 = new javax.swing.JLabel();
324
        jTextFieldExtFile = new com.iver.swingext.JTextFieldExt();
323
        jTextFieldExtFile = new org.gvsig.app.documents.table.summarize.utils.JTextFieldExt();
325 324
        jButtonFileChooser = new javax.swing.JButton();
325
        jLabelLoader = new javax.swing.JLabel();
326 326
        jButtonAceptar = new javax.swing.JButton();
327 327
        jButtonCancel = new javax.swing.JButton();
328
        jLabelDescription2 = new javax.swing.JLabel();
329
        jLabelLoader = new javax.swing.JLabel();
330 328

  
331 329
        jLabelDescription.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
332 330
        jLabelDescription.setText("description1");
333
        jLabelDescription.setVerticalAlignment(javax.swing.SwingConstants.TOP);
334 331

  
335 332
        jPanelMain.setBorder(javax.swing.BorderFactory.createEtchedBorder());
336 333

  
......
406 403
            .add(jPanelMainLayout.createSequentialGroup()
407 404
                .addContainerGap()
408 405
                .add(jPanelMainLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
409
                    .add(jScrollPaneTree, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 535, Short.MAX_VALUE)
410
                    .add(jLabelPunto2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 535, Short.MAX_VALUE)
411
                    .add(jLabelPunto3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 535, Short.MAX_VALUE)
412
                    .add(jComboBoxExtGroupByField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 535, Short.MAX_VALUE)
413
                    .add(jLabelPunto1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 535, Short.MAX_VALUE)
406
                    .add(jScrollPaneTree, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 525, Short.MAX_VALUE)
407
                    .add(jLabelPunto2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 525, Short.MAX_VALUE)
408
                    .add(jLabelPunto3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 525, Short.MAX_VALUE)
409
                    .add(jComboBoxExtGroupByField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 525, Short.MAX_VALUE)
410
                    .add(jLabelPunto1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 525, Short.MAX_VALUE)
414 411
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanelMainLayout.createSequentialGroup()
415
                        .add(jTextFieldExtFile, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 484, Short.MAX_VALUE)
412
                        .add(jTextFieldExtFile, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 474, Short.MAX_VALUE)
416 413
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
417 414
                        .add(jButtonFileChooser)))
418 415
                .addContainerGap())
......
427 424
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
428 425
                .add(jLabelPunto2)
429 426
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
430
                .add(jScrollPaneTree, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 258, Short.MAX_VALUE)
427
                .add(jScrollPaneTree, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 251, Short.MAX_VALUE)
431 428
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
432 429
                .add(jLabelPunto3)
433 430
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
434 431
                .add(jPanelMainLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
435 432
                    .add(jButtonFileChooser)
436 433
                    .add(jTextFieldExtFile, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
437
                .add(19, 19, 19))
434
                .addContainerGap())
438 435
        );
439 436

  
440 437
        jButtonAceptar.setText("Aceptar");
441
        jButtonAceptar.addActionListener(new java.awt.event.ActionListener() {
442
            public void actionPerformed(java.awt.event.ActionEvent evt) {
443
                jButtonAceptarActionPerformed(evt);
444
            }
445
        });
446 438

  
447 439
        jButtonCancel.setText("Cancelar");
448
        jButtonCancel.addActionListener(new java.awt.event.ActionListener() {
449
            public void actionPerformed(java.awt.event.ActionEvent evt) {
450
                jButtonCancelActionPerformed(evt);
451
            }
452
        });
453 440

  
454
        jLabelDescription2.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
455
        jLabelDescription2.setText("description2");
456
        jLabelDescription2.setVerticalAlignment(javax.swing.SwingConstants.TOP);
457

  
458
        jLabelLoader.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/loader.gif"))); // NOI18N
459
        
460 441
        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
461 442
        this.setLayout(layout);
462 443
        layout.setHorizontalGroup(
......
465 446
                .addContainerGap()
466 447
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
467 448
                    .add(layout.createSequentialGroup()
468
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
469
                            .add(layout.createSequentialGroup()
470
                                .add(jLabelLoader)
471
                                .add(18, 18, 18)
472
                                .add(jButtonAceptar)
473
                                .add(18, 18, 18)
474
                                .add(jButtonCancel)
475
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED))
476
                            .add(org.jdesktop.layout.GroupLayout.LEADING, jPanelMain, 0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
477
                        .add(10, 10, 10))
449
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 367, Short.MAX_VALUE)
450
                        .add(jLabelLoader)
451
                        .add(192, 192, 192))
478 452
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
453
                        .add(jButtonAceptar)
454
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
455
                        .add(jButtonCancel)
456
                        .addContainerGap())
457
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
479 458
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
480
                            .add(org.jdesktop.layout.GroupLayout.LEADING, jLabelDescription, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 559, Short.MAX_VALUE)
481
                            .add(jLabelDescription2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 559, Short.MAX_VALUE))
459
                            .add(org.jdesktop.layout.GroupLayout.LEADING, jLabelDescription, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 549, Short.MAX_VALUE)
460
                            .add(jPanelMain, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
482 461
                        .addContainerGap())))
483 462
        );
484 463
        layout.setVerticalGroup(
485 464
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
486 465
            .add(layout.createSequentialGroup()
487 466
                .addContainerGap()
488
                .add(jLabelDescription)
467
                .add(jLabelDescription, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 39, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
489 468
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
490
                .add(jLabelDescription2)
491
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
492 469
                .add(jPanelMain, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
493
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
494
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
495
                    .add(jButtonCancel)
496
                    .add(jButtonAceptar)
497
                    .add(jLabelLoader))
470
                .add(6, 6, 6)
471
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
472
                    .add(jLabelLoader)
473
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
474
                        .add(jButtonCancel)
475
                        .add(jButtonAceptar)))
498 476
                .addContainerGap())
499 477
        );
500 478
    }// </editor-fold>//GEN-END:initComponents
501 479

  
502
private void jButtonAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAceptarActionPerformed
503
	
504
	//if a file has been allready selected...
505
	if(!jTextFieldExtFile.getText().equals("") && jTextFieldExtFile.getText().endsWith(".dbf")){
506

  
507
		loader = new SwingWorker() {
508
	        public Object construct() {
509
	           	jLabelLoader.setVisible(true);
510
	            return true;
511
	        }
512
	        public void finished() {
513
	        	jLabelLoader.setVisible(false);
514
	        }
515
	    };
516
	    loader.start();
517
	
518
	    //carga las operaciones escogidas por el usuario en las estructuras 
519
	    //ArrayList<String> headers, ArrayList<Integer> types y ArrayList<SelectedStatistics> operations
520
	    try {
521
	    	boolean flag = loadSelectedOperations(false);
522

  
523
	    	if(!flag) {
524
	    		JOptionPane.showMessageDialog(this, PluginServices.getText(this, "SummarizeForm_seleccionar_operaciones"));
525
	    	}
526
	    	else {
527
	    		File endFile = new File(jTextFieldExtFile.getText());
528
	    		if (endFile.exists()) {
529
	    			int returnValue = JOptionPane.showConfirmDialog(this,
530
	    					PluginServices.getText(this, "File_exists_Do_you_want_to_overwrite_it?"),
531
	    					PluginServices.getText(this, "Warning_Output_File"),
532
	    					JOptionPane.YES_NO_OPTION,
533
	    					JOptionPane.WARNING_MESSAGE);
534
	    			if (returnValue==JOptionPane.NO_OPTION) {
535
	    				return;
536
	    			}
537
	    			endFile.delete();
538
	    		}
539
	    		Summarize sumCalculator = new Summarize();
540
	    		sumCalculator.setDataSource(this.table.getModel().getModelo().getRecordset());
541
	    		sumCalculator.setGroupByField(selectedColumn);
542
	    		sumCalculator.setOperations(operations);
543
	    		sumCalculator.summarizeToDbf(endFile);
544
	    		createTableDocument(endFile.getName(), "gdbms dbf driver", endFile.getAbsolutePath());
545
	    		PluginServices.getMDIManager().closeWindow(this);
546
	    	}
547
	    }
548
	    catch (GroupByFieldNotExistsException e) {
549
	    	NotificationManager.showMessageError(
550
	    			PluginServices.getText(this, "Summarize_Group_by_field_does_not_exist"), e);
551
		} catch (ReadDriverException e) {
552
			NotificationManager.showMessageError(
553
					PluginServices.getText(this, "Summarize_Error_accessing_the_table"), e);
554
		} catch (DBFExportException e) {
555
			NotificationManager.showMessageError(
556
					PluginServices.getText(this, "Summarize_Error_saving_the_output_DBF_file"), e);
557
		} catch (GroupingErrorException e) {
558
			NotificationManager.showMessageError(
559
					PluginServices.getText(this, "Summarize_Error_calculating_the_groups"), e);
560
		} catch (FieldNotFoundException e) {
561
			NotificationManager.showMessageError(
562
	    			PluginServices.getText(this, "Summarize_Field_does_not_exist"), e);
563
		} catch (InitializationException e) {
564
			NotificationManager.showMessageError(e.getMessage(), e);
565
		} catch (SummarizeException e) {
566
			NotificationManager.showMessageError(
567
	    			PluginServices.getText(this, "Error_summarizing_table"), e);
568
		}
569
		
570
		loader.interrupt();	
571
	}else{
572
		JOptionPane.showMessageDialog(this, PluginServices.getText(this, "SummarizeForm_fichero_destino"));
573
	}
574
	
575
}//GEN-LAST:event_jButtonAceptarActionPerformed
576

  
577
private void jButtonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelActionPerformed
578
	PluginServices.getMDIManager().closeWindow(SummarizeForm.this);
579
}//GEN-LAST:event_jButtonCancelActionPerformed
580

  
581 480
private void jXTableSeleccionMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jXTableSeleccionMouseClicked
582 481
	
583 482
	int indiceFila = jXTableSeleccion.getSelectedRow();
......
698 597
    private javax.swing.JButton jButtonAceptar;
699 598
    private javax.swing.JButton jButtonCancel;
700 599
    private javax.swing.JButton jButtonFileChooser;
701
    private com.iver.swingext.JComboBoxExt jComboBoxExtGroupByField;
600
    private org.gvsig.app.documents.table.summarize.utils.JComboBoxExt jComboBoxExtGroupByField;
702 601
    private javax.swing.JLabel jLabelDescription;
703
    private javax.swing.JLabel jLabelDescription2;
704 602
    private javax.swing.JLabel jLabelLoader;
705 603
    private javax.swing.JLabel jLabelPunto1;
706 604
    private javax.swing.JLabel jLabelPunto2;
707 605
    private javax.swing.JLabel jLabelPunto3;
708 606
    private javax.swing.JPanel jPanelMain;
709 607
    private javax.swing.JScrollPane jScrollPaneTree;
710
    private com.iver.swingext.JTextFieldExt jTextFieldExtFile;
608
    private org.gvsig.app.documents.table.summarize.utils.JTextFieldExt jTextFieldExtFile;
711 609
    private org.jdesktop.swingx.JXTable jXTableSeleccion;
712 610
    // End of variables declaration//GEN-END:variables
713 611
	public WindowInfo getWindowInfo() {

Also available in: Unified diff