Examples of PartialExportTableModel


Examples of mydatagenerator.gui.custom.table.model.PartialExportTableModel

    confirmPartialExportButton = new JButton("Partial Export");
    confirmPartialExportButton.addActionListener(this);   
   
    /* An EDITABLE table where the user can choose the table(s) to include in the export and if it want all the table content or only part of it */
    tableSelectionGrid = new JTable();    
    tableSelectionGrid.setModel(new PartialExportTableModel());
    
    //necessary to use user defined column width
    tableSelectionGrid.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    tableSelectionGrid.setCellSelectionEnabled(true);
   
View Full Code Here

Examples of mydatagenerator.gui.custom.table.model.PartialExportTableModel

                   
                    //only the table list that the user want export
                    final List<TableInfoPartialExportBean> filteredTableToExport = new ArrayList<TableInfoPartialExportBean>();
                   
                    //---- Get the table model to obtain the user choice: ie the table to export  
                    PartialExportTableModel tableModel = (PartialExportTableModel)this.getPartialDatabaseExportPanel().getTableSelectionGrid().getModel();
                    List<TableInfoPartialExportBean> fullTableList = tableModel.getRowList();
                   
                    for(int i=0;i<fullTableList.size();i++)
                    {
                      if(fullTableList.get(i).isIncludeTable())
                      {                       
                       TableInfoPartialExportBean tableInfoPartialExport = new TableInfoPartialExportBean();
                       tableInfoPartialExport.setTableName(fullTableList.get(i).getTableName());
                       tableInfoPartialExport.setExportQuery(fullTableList.get(i).getExportQuery());
                      
                       filteredTableToExport.add(tableInfoPartialExport);                     
                      }
                    }         
                    //-------------
                  
                   //The exporting operation can be a long task: open a separate Thread           
             Thread partialExportDatabaseThread = new Thread() {
                               
              public void run() {                                
                   
                  try{                                
                      // Export the DB content as DBunit dataset
                      DatabaseExporter databaseExporter = new DatabaseExporter();  
                      databaseExporter.partialExport(destinationFolder, filteredTableToExport)
                    
                      // stop and hide the animation
                      busyLabelPanel.getJxBusyLabel().setBusy(false);
                      busyLabelPanel.getJxBusyLabel().setVisible(false);
                                     
                      operationResultLabel.setText("Operation Executed Successfully");
                      operationResultLabel.setFont(new Font("Serif", Font.BOLD, 15));
                      operationResultLabel.setForeground(Color.GREEN);
                              
                     }catch (Exception ex) {
                      
                      if(Log4jManager.IS_LOGGING_CONFIGURED)          
                        logger.fatal("Error executing the partial DB export, cause: ",ex)
                      
                  // stop and hide the animation
                  busyLabelPanel.getJxBusyLabel().setBusy(false);
                     busyLabelPanel.getJxBusyLabel().setVisible(false)
                    
                     operationResultLabel.setText("Error during the export operation: "+ex.getMessage());
                     operationResultLabel.setFont(new Font("Serif", Font.BOLD, 15));
                     operationResultLabel.setForeground(Color.RED);                    
                     }
                       }
             };
                           
          partialExportDatabaseThread.start();
          }
        }
     
      /**
       * Choose the destination folder for DB export
       */
      if (e.getActionCommand().equals("Choose"))
        {       
        destinationFolderChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        destinationFolderChooser.setFileFilter(new FolderFileFilter());
        destinationFolderChooser.setDialogTitle("Choose a Destination Folder");           
               
              int value = destinationFolderChooser.showOpenDialog(this);
              
              // Return value if approved (ie yes, ok) is chosen.
              if (value == JFileChooser.APPROVE_OPTION)
              {
                 // The file name is equal at the DB name to export
                 File  destinationFolder = destinationFolderChooser.getSelectedFile();               
                 String  pathDestinationFolder = destinationFolder.getAbsolutePath();
                   //set the file path in the textField
                 this.exportFolderValue.setText(pathDestinationFolder);
            }
        } 
       
        /* The event intercepted by the sub-panel (ie PartialExportPanel) and forwarded at this listener */
        if (e.getActionCommand().equals("Load Tables"))
        {
          final PartialExportTableModel tableModel = (PartialExportTableModel)this.getPartialDatabaseExportPanel().getTableSelectionGrid().getModel();
         
          tableModel.setRowList(new ArrayList<TableInfoPartialExportBean>());
          //initialize the table model with an empty list of data
          tableModel.fireTableDataChanged();
         
          adjustTableWidth();
         
          final PartialExportPanel partialExpPanel = this.getPartialDatabaseExportPanel();
        
          if (!busyLabelPanel.getJxBusyLabel().isEnabled())
             {
                busyLabelPanel.getJxBusyLabel().setEnabled(true);              
             }
            
             if (busyLabelPanel.getJxBusyLabel().isBusy()) {     //true if task is finished        
                 busyLabelPanel.getJxBusyLabel().setBusy(false);
                 busyLabelPanel.getJxBusyLabel().setVisible(false);               
               
             }else{               
                 busyLabelPanel.getJxBusyLabel().setBusy(true);
                 busyLabelPanel.getJxBusyLabel().setVisible(true);
                
                 // Loading the ordered table name list can take some time: create a dedicated Thread to perform it                 
            Thread cleanDatabaseThread = new Thread() {
                             
             public void run() {                              
                 
                 try {                              
                     DatabaseTableUtils databaseTableUtils = new DatabaseTableUtils();
                     List<String> tableNames = databaseTableUtils.getTableNamesOrdered();                    
                    
                     List<TableInfoPartialExportBean> tableInfoPartialExporterList = new ArrayList<TableInfoPartialExportBean>();
                    
                     for(int i=0; i<tableNames.size(); i++)
                     {                    
                        TableInfoPartialExportBean tableInfo = new TableInfoPartialExportBean()
                        tableInfo.setExportQuery("select * from "+tableNames.get(i)); //the default query to export full content
                        tableInfo.setIncludeTable(false);
                        tableInfo.setTableName(tableNames.get(i));
                      
                        tableInfoPartialExporterList.add(tableInfo);                      
                     }
                    
                     tableModel.setRowList(tableInfoPartialExporterList);
                     tableModel.fireTableDataChanged(); //reload the showed data
                    
                     adjustTableWidth();
                  
                    //stop and hide the animation
                    busyLabelPanel.getJxBusyLabel().setBusy(false);
                      busyLabelPanel.getJxBusyLabel().setVisible(false);
                     
                      //show operation result
                      operationResultLabel.setFont(new Font("Serif", Font.BOLD, 15));
                      operationResultLabel.setForeground(Color.GREEN);
                      operationResultLabel.setText("Operation executed successfully, loaded "+tableNames.size()+" tables");
                     
                      //when the tables are loaded the mark/unmark button must be enabled
                   partialExpPanel.getSelectAllTablebutton().setEnabled(true);
                            
                     } catch (Exception ex) {
                      
                       if(Log4jManager.IS_LOGGING_CONFIGURED)          
                        logger.info("Error loading the DB table names, cause: ",ex)
                 
                  //stop and hide the animation
                  busyLabelPanel.getJxBusyLabel().setBusy(false);
                       busyLabelPanel.getJxBusyLabel().setVisible(false);
                      
                       operationResultLabel.setText("Error loading tables: "+ex.getMessage());
                     operationResultLabel.setFont(new Font("Serif", Font.BOLD, 15));
                     operationResultLabel.setForeground(Color.RED);
                     }
                     }         
           };
                         
          cleanDatabaseThread.start();         
            }     
            
       } 
       /* Select all the listed tables */
       if (e.getActionCommand().equals("Check All"))
       {
         PartialExportTableModel tableModel = (PartialExportTableModel)this.getPartialDatabaseExportPanel().getTableSelectionGrid().getModel();
                List<TableInfoPartialExportBean> fullTableList = tableModel.getRowList();
               
                for(int i=0;i<fullTableList.size();i++){
                 fullTableList.get(i).setIncludeTable(true);                 
                }
                tableModel.fireTableDataChanged();
       }
       /* De-Select all the listed tables */  
       if (e.getActionCommand().equals("Uncheck All"))
       {
         PartialExportTableModel tableModel = (PartialExportTableModel)this.getPartialDatabaseExportPanel().getTableSelectionGrid().getModel();
                List<TableInfoPartialExportBean> fullTableList = tableModel.getRowList();
               
                for(int i=0;i<fullTableList.size();i++){
                 fullTableList.get(i).setIncludeTable(false);                 
                }
                tableModel.fireTableDataChanged();
       }
     
        /* Close the application */
      if (e.getActionCommand().equals("Close"))
        {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.