package jalview.jbgui; import jalview.gui.AnnotationColumnChooser; import jalview.gui.JvSwingUtils; import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.ButtonGroup; import javax.swing.JPanel; import javax.swing.JRadioButton; @SuppressWarnings("serial") public class FurtherActionPanel extends JPanel { private AnnotationColumnChooser aColChooser; private JRadioButton hideOption = new JRadioButton(); private JRadioButton selectOption = new JRadioButton(); private ButtonGroup optionsGroup = new ButtonGroup(); public FurtherActionPanel(AnnotationColumnChooser aColChooser) { this.aColChooser = aColChooser; getSelectOption().setBackground(Color.white); getSelectOption().setFont(JvSwingUtils.getLabelFont()); getSelectOption().setText("Select"); getSelectOption().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { selectRadioAction(actionEvent); } }); getHideOption().setBackground(Color.white); getHideOption().setFont(JvSwingUtils.getLabelFont()); getHideOption().setText("Hide"); getHideOption().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { hideRadioAction(actionEvent); } }); getOptionsGroup().add(getSelectOption()); getOptionsGroup().add(getHideOption()); getOptionsGroup().setSelected(getSelectOption().getModel(), true); this.setBackground(Color.white); this.setFont(JvSwingUtils.getLabelFont()); syncState(); this.add(getSelectOption()); this.add(getHideOption()); } public void selectRadioAction(ActionEvent actionEvent) { aColChooser.setCurrentFutherActionPanel(this); aColChooser.select_action(actionEvent); } public void hideRadioAction(ActionEvent actionEvent) { aColChooser.setCurrentFutherActionPanel(this); aColChooser.hide_action(actionEvent); } // public abstract void selectRadioAction(ActionEvent actionEvent); // // public abstract void hideRadioAction(ActionEvent actionEvent); public JRadioButton getHideOption() { return hideOption; } public void setHideOption(JRadioButton hideOption) { this.hideOption = hideOption; } public JRadioButton getSelectOption() { return selectOption; } public void setSelectOption(JRadioButton selectOption) { this.selectOption = selectOption; } public ButtonGroup getOptionsGroup() { return optionsGroup; } public void setOptionsGroup(ButtonGroup optionsGroup) { this.optionsGroup = optionsGroup; } public void syncState() { // FurtherActionPanel fap = aColChooser.getCurrentFutherActionPanel(); // if (fap != null) // { // // // description.setEnabled(sp.getDescription().isEnabled()); // // description.setSelected(sp.getDescription().isSelected()); // // // // displayName.setEnabled(sp.getDisplayName().isEnabled()); // // displayName.setSelected(sp.getDisplayName().isSelected()); // // // // searchBox.setText(sp.getSearchBox().getText()); // } if (aColChooser.getActionOption() == AnnotationColumnChooser.ACTION_OPTION_HIDE) { this.getOptionsGroup().setSelected(this.getHideOption().getModel(), true); } else { this.getOptionsGroup().setSelected(this.getSelectOption().getModel(), true); } } }