2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.jbgui;
23 import jalview.io.FileFormatI;
24 import jalview.util.MessageManager;
26 import java.awt.BorderLayout;
27 import java.awt.event.ActionEvent;
28 import java.awt.event.ActionListener;
29 import java.awt.event.ItemEvent;
30 import java.awt.event.ItemListener;
32 import javax.swing.JButton;
33 import javax.swing.JCheckBox;
34 import javax.swing.JPanel;
36 @SuppressWarnings("serial")
37 public abstract class GAlignExportSettings extends JPanel
39 protected JPanel hiddenRegionConfPanel = new JPanel();
41 protected JPanel complexExportPanel = new JPanel();
43 protected JPanel optionsPanel = new JPanel();
45 protected JPanel actionPanel = new JPanel();
47 protected BorderLayout hiddenRegionLayout = new BorderLayout();
49 protected BorderLayout complexExportLayout = new BorderLayout();
51 protected BorderLayout mainLayout = new BorderLayout();
53 protected JCheckBox chkAll = new JCheckBox();
55 protected JCheckBox chkHiddenSeqs = new JCheckBox();
57 protected JCheckBox chkHiddenCols = new JCheckBox();
59 protected JCheckBox chkExportAnnots = new JCheckBox();
61 protected JCheckBox chkExportFeats = new JCheckBox();
63 protected JCheckBox chkExportGrps = new JCheckBox();
65 JButton btnOk = new JButton();
67 JButton btnCancel = new JButton();
69 private boolean hasHiddenSeq, hasHiddenCols, isComplexAlignFile,
72 public GAlignExportSettings(boolean hasHiddenSeq, boolean hasHiddenCols,
75 this.hasHiddenSeq = hasHiddenSeq;
76 this.hasHiddenCols = hasHiddenCols;
77 this.isComplexAlignFile = format.isComplexAlignFile();
78 if (this.hasHiddenCols || this.hasHiddenSeq || this.isComplexAlignFile)
80 this.showDialog = true;
87 chkHiddenSeqs.setText(
88 MessageManager.getString("action.export_hidden_sequences"));
89 chkHiddenCols.setText(
90 MessageManager.getString("action.export_hidden_columns"));
92 .setText(MessageManager.getString("action.export_annotations"));
94 .setText(MessageManager.getString("action.export_features"));
95 chkExportGrps.setText(MessageManager.getString("action.export_groups"));
96 btnOk.setText(MessageManager.getString("action.ok"));
97 btnCancel.setText(MessageManager.getString("action.cancel"));
98 chkAll.setText(MessageManager.getString("action.select_all"));
100 hiddenRegionConfPanel.setLayout(hiddenRegionLayout);
101 complexExportPanel.setLayout(complexExportLayout);
102 setLayout(mainLayout);
104 chkAll.addItemListener(new ItemListener()
107 public void itemStateChanged(ItemEvent e)
113 btnOk.addActionListener(new ActionListener()
116 public void actionPerformed(ActionEvent e)
118 ok_actionPerformed(e);
122 btnCancel.addActionListener(new ActionListener()
125 public void actionPerformed(ActionEvent e)
127 cancel_actionPerformed(e);
131 // hiddenRegionConfPanel.add(chkAll, BorderLayout.NORTH);
132 hiddenRegionConfPanel.add(chkHiddenSeqs, BorderLayout.CENTER);
133 hiddenRegionConfPanel.add(chkHiddenCols, BorderLayout.SOUTH);
134 chkHiddenSeqs.setEnabled(hasHiddenSeq);
135 chkHiddenCols.setEnabled(hasHiddenCols);
137 complexExportPanel.add(chkExportAnnots, BorderLayout.NORTH);
138 complexExportPanel.add(chkExportFeats, BorderLayout.CENTER);
139 complexExportPanel.add(chkExportGrps, BorderLayout.SOUTH);
141 actionPanel.add(chkAll);
143 if (this.isComplexAlignFile)
145 optionsPanel.add(complexExportPanel);
148 if (hasHiddenSeq || hasHiddenCols)
150 optionsPanel.add(hiddenRegionConfPanel);
153 actionPanel.add(btnCancel);
154 actionPanel.add(btnOk);
156 add(optionsPanel, BorderLayout.NORTH);
157 add(actionPanel, BorderLayout.SOUTH);
161 private void checkAllAction()
163 boolean isSelected = chkAll.isSelected();
164 chkHiddenSeqs.setSelected(chkHiddenSeqs.isEnabled() && isSelected);
165 chkHiddenCols.setSelected(chkHiddenCols.isEnabled() && isSelected);
166 chkExportAnnots.setSelected(isComplexAlignFile
167 && chkExportAnnots.isEnabled() && isSelected);
168 chkExportFeats.setSelected(
169 isComplexAlignFile && chkExportFeats.isEnabled() && isSelected);
170 chkExportGrps.setSelected(
171 isComplexAlignFile && chkExportGrps.isEnabled() && isSelected);
174 public boolean isShowDialog()
179 public void setShowDialog(boolean showDialog)
181 this.showDialog = showDialog;
184 public abstract void ok_actionPerformed(ActionEvent e);
186 public abstract void cancel_actionPerformed(ActionEvent e);