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.
23 import jalview.api.AlignExportSettingI;
24 import jalview.api.AlignViewportI;
25 import jalview.bin.Jalview;
26 import jalview.datamodel.AlignExportSettingBeanI;
27 import jalview.datamodel.AlignmentExportData;
28 import jalview.datamodel.AlignmentI;
29 import jalview.datamodel.HiddenSequences;
30 import jalview.io.FileFormatI;
31 import jalview.jbgui.GAlignExportSettings;
32 import jalview.util.MessageManager;
33 import jalview.util.dialogrunner.RunResponse;
35 import java.awt.event.ActionEvent;
36 import java.awt.event.ActionListener;
38 import javax.swing.JOptionPane;
40 @SuppressWarnings("serial")
41 public class AlignExportSettings extends GAlignExportSettings
42 implements AlignExportSettingI
44 boolean cancelled = false;
48 AlignmentPanel alignPanel;
51 * settings provided at construction override the GUI
53 AlignExportSettingBeanI override=null;
55 public AlignExportSettings(AlignmentPanel alignmentPanel,
56 FileFormatI format, AlignExportSettingBeanI exportSettings)
58 super(alignmentPanel.getAlignViewport().hasHiddenRows(),
59 alignmentPanel.getAlignViewport().hasHiddenColumns(), format);
60 this.alignPanel = alignmentPanel;
61 override = exportSettings;
66 * @return a bean with data for export
69 public AlignmentExportData getAlignExportData()
71 // settings.isExportAnnotations();
73 AlignmentI alignmentToExport = null;
74 String[] omitHidden = null;
75 AlignViewportI viewport = alignPanel.getAlignViewport();
77 alignmentToExport = viewport.getAlignment();
79 if (viewport.hasHiddenColumns() && !isExportHiddenColumns())
81 omitHidden = viewport.getViewAsString(false,
82 isExportHiddenSequences());
85 int[] alignmentStartEnd = new int[2];
86 if (viewport.hasHiddenRows() && isExportHiddenSequences())
88 alignmentToExport = viewport.getAlignment().getHiddenSequences()
93 alignmentToExport = viewport.getAlignment();
95 alignmentStartEnd = viewport.getAlignment().getHiddenColumns()
96 .getVisibleStartAndEndIndex(alignmentToExport.getWidth());
97 AlignmentExportData ed = new AlignmentExportData(alignmentToExport,
98 omitHidden, alignmentStartEnd, this);
103 public void ok_actionPerformed(ActionEvent e)
109 public void cancel_actionPerformed(ActionEvent e)
115 public boolean isExportHiddenSequences()
117 return override!=null ? override.isExportHiddenSequences() : chkHiddenSeqs.isSelected();
121 public boolean isExportHiddenColumns()
123 return override!=null ? override.isExportHiddenColumns() : chkHiddenCols.isSelected();
127 public boolean isExportAnnotations()
129 return override!=null ? override.isExportAnnotations() : chkExportAnnots.isSelected();
133 public boolean isExportFeatures()
135 return override!=null ? override.isExportFeatures() : chkExportFeats.isSelected();
139 public boolean isExportGroups()
141 return override!=null ? override.isExportGroups() : chkExportGrps.isSelected();
145 public boolean isCancelled()
147 return override!=null ? override.isCancelled() : cancelled;
150 ActionListener afterShownAction = null;
153 public void addActionListener(ActionListener actionListener)
155 afterShownAction = actionListener;
159 public void doShowSettings()
161 if (!Jalview.isHeadlessMode() && override==null && isShowDialog())
164 dialog = JvOptionPane.newOptionDialog(alignPanel);
166 dialog.response(new RunResponse(JvOptionPane.OK_OPTION)
170 ok_actionPerformed(null);
171 afterShownAction.actionPerformed(null);
173 }).defaultResponse(new Runnable()
179 afterShownAction.actionPerformed(null);
182 String ok = MessageManager.getString("action.ok"),
183 cancel = MessageManager.getString("action.cancel");
184 dialog.showInternalDialog(this,
185 MessageManager.getString("label.export_settings"),
186 JOptionPane.DEFAULT_OPTION, JvOptionPane.DEFAULT_OPTION, null,
192 afterShownAction.actionPerformed(null);