View Javadoc
1   /*******************************************************************************
2    * Copyhacked (H) 2012-2025.
3    * This program and the accompanying materials
4    * are made available under no term at all, use it like
5    * you want, but share and discuss it
6    * every time possible with every body.
7    * 
8    * Contributors:
9    *      ron190 at ymail dot com - initial implementation
10   ******************************************************************************/
11  package com.jsql.view.swing.interaction;
12  
13  import com.jsql.model.bean.database.AbstractElementDatabase;
14  import com.jsql.view.interaction.InteractionCommand;
15  import com.jsql.view.swing.util.MediatorHelper;
16  
17  import javax.swing.*;
18  
19  /**
20   * Create a new tab for the values.
21   */
22  public class CreateValuesTab extends CreateTabHelper implements InteractionCommand {
23      
24      private final String[] columnNames;
25      private final String[][] data;
26      private final AbstractElementDatabase table;
27  
28      /**
29       * @param interactionParams Names of columns, table's values and corresponding table
30       */
31      public CreateValuesTab(Object[] interactionParams) {
32          this.columnNames = (String[]) interactionParams[0];  // Array of column names, displayed in header table
33          this.data = (String[][]) interactionParams[1];  // 2D array of values
34          this.table = (AbstractElementDatabase) interactionParams[2];  // The table containing the data
35      }
36  
37      @Override
38      public void execute() {
39          SwingUtilities.invokeLater(() -> MediatorHelper.treeDatabase().createValuesTab(this.data, this.columnNames, this.table));
40      }
41  }