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.view.interaction.InteractionCommand;
14  import com.jsql.view.swing.util.MediatorHelper;
15  
16  import javax.swing.*;
17  
18  /**
19   * Create a new tab for the file.
20   */
21  public class CreateFileTab extends CreateTabHelper implements InteractionCommand {
22      
23      /**
24       * Name of the file.
25       */
26      private final String label;
27  
28      /**
29       * Content of the file.
30       */
31      private final String content;
32  
33      /**
34       * Full path of the file.
35       */
36      private final String path;
37  
38      /**
39       * @param interactionParams Name, content and path of the file
40       */
41      public CreateFileTab(Object[] interactionParams) {
42          this.label = (String) interactionParams[0];
43          this.content = (String) interactionParams[1];
44          this.path = (String) interactionParams[2];
45      }
46  
47      @Override
48      public void execute() {
49          SwingUtilities.invokeLater(() -> MediatorHelper.tabResults().addFileTab(this.label, this.content, this.path));
50      }
51  }