1f91b35798688aa2e89e63dba9b8d9a3396ca5a5
[jalview.git] / src / jalview / jbgui / FurtherActionPanel.java
1 package jalview.jbgui;
2
3 import jalview.gui.AnnotationColumnChooser;
4 import jalview.gui.JvSwingUtils;
5
6 import java.awt.Color;
7 import java.awt.event.ActionEvent;
8 import java.awt.event.ActionListener;
9
10 import javax.swing.ButtonGroup;
11 import javax.swing.JPanel;
12 import javax.swing.JRadioButton;
13
14 @SuppressWarnings("serial")
15 public class FurtherActionPanel extends JPanel
16 {
17   private AnnotationColumnChooser aColChooser;
18
19   private JRadioButton hideOption = new JRadioButton();
20
21   private JRadioButton selectOption = new JRadioButton();
22
23   private ButtonGroup optionsGroup = new ButtonGroup();
24
25   public FurtherActionPanel(AnnotationColumnChooser aColChooser)
26   {
27
28     this.aColChooser = aColChooser;
29
30
31     getSelectOption().setBackground(Color.white);
32     getSelectOption().setFont(JvSwingUtils.getLabelFont());
33     getSelectOption().setText("Select");
34     getSelectOption().addActionListener(new ActionListener()
35     {
36       @Override
37       public void actionPerformed(ActionEvent actionEvent)
38       {
39         selectRadioAction(actionEvent);
40       }
41     });
42
43     getHideOption().setBackground(Color.white);
44     getHideOption().setFont(JvSwingUtils.getLabelFont());
45     getHideOption().setText("Hide");
46     getHideOption().addActionListener(new ActionListener()
47     {
48       @Override
49       public void actionPerformed(ActionEvent actionEvent)
50       {
51         hideRadioAction(actionEvent);
52       }
53     });
54
55     getOptionsGroup().add(getSelectOption());
56     getOptionsGroup().add(getHideOption());
57     getOptionsGroup().setSelected(getSelectOption().getModel(), true);
58
59     this.setBackground(Color.white);
60     this.setFont(JvSwingUtils.getLabelFont());
61     syncState();
62
63     this.add(getSelectOption());
64     this.add(getHideOption());
65   }
66
67   public void selectRadioAction(ActionEvent actionEvent)
68   {
69     aColChooser.setCurrentFutherActionPanel(this);
70     aColChooser.select_action(actionEvent);
71   }
72
73   public void hideRadioAction(ActionEvent actionEvent)
74   {
75     aColChooser.setCurrentFutherActionPanel(this);
76     aColChooser.hide_action(actionEvent);
77   }
78
79   // public abstract void selectRadioAction(ActionEvent actionEvent);
80   //
81   // public abstract void hideRadioAction(ActionEvent actionEvent);
82
83   public JRadioButton getHideOption()
84   {
85     return hideOption;
86   }
87
88   public void setHideOption(JRadioButton hideOption)
89   {
90     this.hideOption = hideOption;
91   }
92
93   public JRadioButton getSelectOption()
94   {
95     return selectOption;
96   }
97
98   public void setSelectOption(JRadioButton selectOption)
99   {
100     this.selectOption = selectOption;
101   }
102
103   public ButtonGroup getOptionsGroup()
104   {
105     return optionsGroup;
106   }
107
108   public void setOptionsGroup(ButtonGroup optionsGroup)
109   {
110     this.optionsGroup = optionsGroup;
111   }
112
113   public void syncState()
114   {
115     // FurtherActionPanel fap = aColChooser.getCurrentFutherActionPanel();
116     // if (fap != null)
117     // {
118     //
119     // // description.setEnabled(sp.getDescription().isEnabled());
120     // // description.setSelected(sp.getDescription().isSelected());
121     // //
122     // // displayName.setEnabled(sp.getDisplayName().isEnabled());
123     // // displayName.setSelected(sp.getDisplayName().isSelected());
124     // //
125     // // searchBox.setText(sp.getSearchBox().getText());
126     // }
127
128     if (aColChooser.getActionOption() == AnnotationColumnChooser.ACTION_OPTION_HIDE)
129     {
130       this.getOptionsGroup().setSelected(this.getHideOption().getModel(),
131               true);
132     }
133     else
134     {
135       this.getOptionsGroup().setSelected(this.getSelectOption().getModel(),
136               true);
137     }
138   }
139 }