View Javadoc

1   package org.sat4j.sat;
2   
3   import java.awt.BorderLayout;
4   import java.awt.event.ActionEvent;
5   import java.awt.event.ActionListener;
6   
7   import javax.swing.JButton;
8   import javax.swing.JCheckBox;
9   import javax.swing.JPanel;
10  import javax.swing.border.CompoundBorder;
11  import javax.swing.border.TitledBorder;
12  
13  public class HotSolverCommandComponent extends CommandComponent {
14  
15      /**
16       * 
17       */
18      private static final long serialVersionUID = 1L;
19  
20      private SolverController controller;
21  
22      private JCheckBox keepSolverHotCB;
23      private static final String KEEP_SOLVER_HOT = "Keep solver hot";
24      private JButton applyHotSolver;
25      private static final String HOT_APPLY = "Apply";
26  
27      public HotSolverCommandComponent(String name, SolverController controller) {
28          this.setName(name);
29          this.controller = controller;
30          createPanel();
31      }
32  
33      @Override
34      public void createPanel() {
35          createHotSolverPanel();
36      }
37  
38      public void createHotSolverPanel() {
39          this.setBorder(new CompoundBorder(new TitledBorder(null,
40                  this.getName(), TitledBorder.LEFT, TitledBorder.TOP),
41                  DetailedCommandPanel.BORDER5));
42  
43          this.setLayout(new BorderLayout());
44  
45          this.keepSolverHotCB = new JCheckBox(KEEP_SOLVER_HOT);
46          this.add(this.keepSolverHotCB, BorderLayout.CENTER);
47  
48          JPanel tmpPanel = new JPanel();
49  
50          this.applyHotSolver = new JButton(HOT_APPLY);
51          tmpPanel.add(this.applyHotSolver);
52          this.add(tmpPanel, BorderLayout.SOUTH);
53  
54          this.applyHotSolver.addActionListener(new ActionListener() {
55              public void actionPerformed(ActionEvent e) {
56                  HotSolverCommandComponent.this.controller
57                          .setKeepSolverHot(HotSolverCommandComponent.this.keepSolverHotCB
58                                  .isSelected());
59              }
60          });
61      }
62  
63      public void setKeepSolverHotPanelEnabled(boolean enabled) {
64          this.keepSolverHotCB.setEnabled(enabled);
65          this.applyHotSolver.setEnabled(enabled);
66          this.repaint();
67      }
68  
69  }