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.tree.action;
12  
13  import com.jsql.model.suspendable.AbstractSuspendable;
14  import com.jsql.view.swing.tree.model.AbstractNodeModel;
15  import com.jsql.view.swing.util.MediatorHelper;
16  
17  import java.awt.event.ActionEvent;
18  import java.awt.event.ActionListener;
19  
20  /**
21   * Action to pause and unpause injection process.
22   */
23  public class ActionPauseUnpause implements ActionListener {
24      
25      private final AbstractNodeModel nodeModel;
26  
27      public ActionPauseUnpause(AbstractNodeModel nodeModel) {
28          this.nodeModel = nodeModel;
29      }
30  
31      @Override
32      public void actionPerformed(ActionEvent e) {
33          AbstractSuspendable suspendableTask = MediatorHelper.model().getMediatorUtils().getThreadUtil().get(this.nodeModel.getElementDatabase());
34          if (suspendableTask == null) {
35              return;
36          }
37          if (suspendableTask.isPaused()) {
38              suspendableTask.unpause();
39          } else {
40              suspendableTask.pause();
41          }
42      }
43  }