JAL-1691 avoid NPE when original split frame has been closed before the alignment...
[jalview.git] / src / jalview / gui / AlignExportSettings.java
1 package jalview.gui;
2
3 import java.awt.event.ActionEvent;
4
5 import javax.swing.JDialog;
6 import javax.swing.JInternalFrame;
7 import javax.swing.JOptionPane;
8
9 import jalview.api.AlignExportSettingI;
10 import jalview.jbgui.GAlignExportSettings;
11
12 @SuppressWarnings("serial")
13 public class AlignExportSettings extends GAlignExportSettings implements
14         AlignExportSettingI
15 {
16   protected JInternalFrame frame;
17
18   boolean cancelled = false;
19
20   private int width = 450;
21
22   private int height = 200;
23
24   JDialog dialog;
25
26   public AlignExportSettings(boolean hasHiddenSeq, boolean hasHiddenCols,
27           String alignFileFormat)
28   {
29     super(hasHiddenSeq, hasHiddenCols, alignFileFormat);
30
31     // frame = new JInternalFrame();
32     // frame.setContentPane(this);
33     // frame.setLayer(JLayeredPane.PALETTE_LAYER);
34     // Desktop.addInternalFrame(frame, "Export Settings", width, height);
35
36     JOptionPane pane = new JOptionPane(null, JOptionPane.DEFAULT_OPTION,
37             JOptionPane.DEFAULT_OPTION, null, new Object[]
38             { this });
39     dialog = pane.createDialog(Desktop.desktop, "Export Settings");
40
41     // dialog = new JDialog(Desktop.instance, true);
42     // dialog.setTitle("Export Settings");
43
44     dialog.pack();
45     dialog.setVisible(true);
46
47     dialog.setContentPane(this);
48     dialog.validate();
49
50   }
51
52   // public static void main(String[] args)
53   // {
54   // new AlignExportSettings(false, false, false);
55   // }
56
57   // public void cancel_actionPerformed(ActionEvent e)
58   // {
59     // try
60     // {
61     // frame.setClosed(true);
62     // } catch (Exception ex)
63     // {
64     // }
65   // }
66
67   public void ok_actionPerformed(ActionEvent e)
68   {
69     cancelled = false;
70     dialog.setVisible(false);
71   }
72
73   public void cancel_actionPerformed(ActionEvent e)
74   {
75     cancelled = true;
76     dialog.setVisible(false);
77   }
78
79   @Override
80   public boolean isExportHiddenSequences()
81   {
82     return chkHiddenSeqs.isSelected();
83   }
84
85   @Override
86   public boolean isExportHiddenColumns()
87   {
88     return chkHiddenCols.isSelected();
89   }
90
91   @Override
92   public boolean isExportAnnotations()
93   {
94     return chkExportAnnots.isSelected();
95   }
96
97   @Override
98   public boolean isExportFeatures()
99   {
100     return chkExportFeats.isSelected();
101   }
102
103   @Override
104   public boolean isExportGroups()
105   {
106     return chkExportGrps.isSelected();
107   }
108
109   @Override
110   public boolean isCancelled()
111   {
112     return cancelled;
113   }
114
115 }