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.util.MessageManager;
25 import java.awt.BorderLayout;
26 import java.awt.event.ActionEvent;
27 import java.awt.event.ActionListener;
28 import java.awt.event.ItemEvent;
29 import java.awt.event.ItemListener;
31 import javax.swing.JButton;
32 import javax.swing.JCheckBox;
33 import javax.swing.JPanel;
35 @SuppressWarnings("serial")
36 public abstract class GAlignExportSettings extends JPanel
38 protected JPanel hiddenRegionConfPanel = new JPanel();
40 protected JPanel complexExportPanel = new JPanel();
42 protected JPanel optionsPanel = new JPanel();
44 protected JPanel actionPanel = new JPanel();
46 protected BorderLayout hiddenRegionLayout = new BorderLayout();
48 protected BorderLayout complexExportLayout = new BorderLayout();
50 protected BorderLayout mainLayout = new BorderLayout();
52 protected JCheckBox chkAll = new JCheckBox();
54 protected JCheckBox chkHiddenSeqs = new JCheckBox();
56 protected JCheckBox chkHiddenCols = new JCheckBox();
58 protected JCheckBox chkExportAnnots = new JCheckBox();
60 protected JCheckBox chkExportFeats = new JCheckBox();
62 protected JCheckBox chkExportGrps = new JCheckBox();
64 JButton btnOk = new JButton();
66 JButton btnCancel = new JButton();
68 private boolean hasHiddenSeq, hasHiddenCols, isComplexAlignFile,
71 public GAlignExportSettings(boolean hasHiddenSeq, boolean hasHiddenCols,
72 String alignFileFormat)
74 this.hasHiddenSeq = hasHiddenSeq;
75 this.hasHiddenCols = hasHiddenCols;
76 String[] complexFormats = { "JSON", "HTML" };
78 for (String format : complexFormats)
80 if (format.equalsIgnoreCase(alignFileFormat))
82 this.isComplexAlignFile = true;
86 if (this.hasHiddenCols || this.hasHiddenSeq || this.isComplexAlignFile)
88 this.showDialog = true;
95 chkHiddenSeqs.setText(MessageManager
96 .getString("action.export_hidden_sequences"));
97 chkHiddenCols.setText(MessageManager
98 .getString("action.export_hidden_columns"));
99 chkExportAnnots.setText(MessageManager
100 .getString("action.export_annotations"));
101 chkExportFeats.setText(MessageManager
102 .getString("action.export_features"));
103 chkExportGrps.setText(MessageManager.getString("action.export_groups"));
104 btnOk.setText(MessageManager.getString("action.ok"));
105 btnCancel.setText(MessageManager.getString("action.cancel"));
106 chkAll.setText(MessageManager.getString("action.select_all"));
108 hiddenRegionConfPanel.setLayout(hiddenRegionLayout);
109 complexExportPanel.setLayout(complexExportLayout);
110 setLayout(mainLayout);
112 chkAll.addItemListener(new ItemListener()
114 public void itemStateChanged(ItemEvent e)
120 btnOk.addActionListener(new ActionListener()
122 public void actionPerformed(ActionEvent e)
124 ok_actionPerformed(e);
128 btnCancel.addActionListener(new ActionListener()
130 public void actionPerformed(ActionEvent e)
132 cancel_actionPerformed(e);
136 // hiddenRegionConfPanel.add(chkAll, BorderLayout.NORTH);
137 hiddenRegionConfPanel.add(chkHiddenSeqs, BorderLayout.CENTER);
138 hiddenRegionConfPanel.add(chkHiddenCols, BorderLayout.SOUTH);
139 chkHiddenSeqs.setEnabled(hasHiddenSeq);
140 chkHiddenCols.setEnabled(hasHiddenCols);
142 complexExportPanel.add(chkExportAnnots, BorderLayout.NORTH);
143 complexExportPanel.add(chkExportFeats, BorderLayout.CENTER);
144 complexExportPanel.add(chkExportGrps, BorderLayout.SOUTH);
146 actionPanel.add(chkAll);
148 if (this.isComplexAlignFile)
150 optionsPanel.add(complexExportPanel);
153 if (hasHiddenSeq || hasHiddenCols)
155 optionsPanel.add(hiddenRegionConfPanel);
158 actionPanel.add(btnCancel);
159 actionPanel.add(btnOk);
161 add(optionsPanel, BorderLayout.NORTH);
162 add(actionPanel, BorderLayout.SOUTH);
166 private void checkAllAction()
168 boolean isSelected = chkAll.isSelected();
169 chkHiddenSeqs.setSelected(chkHiddenSeqs.isEnabled() && isSelected);
170 chkHiddenCols.setSelected(chkHiddenCols.isEnabled() && isSelected);
171 chkExportAnnots.setSelected(isComplexAlignFile
172 && chkExportAnnots.isEnabled() && isSelected);
173 chkExportFeats.setSelected(isComplexAlignFile
174 && chkExportFeats.isEnabled() && isSelected);
175 chkExportGrps.setSelected(isComplexAlignFile
176 && chkExportGrps.isEnabled() && isSelected);
179 public boolean isShowDialog()
184 public void setShowDialog(boolean showDialog)
186 this.showDialog = showDialog;
189 public abstract void ok_actionPerformed(ActionEvent e);
191 public abstract void cancel_actionPerformed(ActionEvent e);