Debian Codegraph @

src/dr/app/beauti/priorspanel/DefaultPriorTableDialog.java

raw symbols SCIP
1 /*
2 * DefaultPriorTableDialog.java
3 *
4 * Copyright (c) 2002-2015 Alexei Drummond, Andrew Rambaut and Marc Suchard
5 *
6 * This file is part of BEAST.
7 * See the NOTICE file distributed with this work for additional
8 * information regarding copyright ownership and licensing.
9 *
10 * BEAST is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as
12 * published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * BEAST is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with BEAST; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 * Boston, MA 02110-1301 USA
24 */
25
26 package dr.app.beauti.priorspanel;
27
28 import dr.app.beauti.options.BeautiOptions;
29 import dr.app.beauti.BeautiFrame;
30
31 import javax.swing.*;
32 import javax.swing.border.EmptyBorder;
33 import java.awt.*;
34
35
36 /**
37 * A dialog box that shows a table of priors that are still set to their default values. Intended
38 * for review before generating the XML.
39 * @author Andrew Rambaut
40 * @author Alexei Drummond
41 * @author Walter Xie
42 * @version $Id: PriorDialog.java,v 1.4 2006/09/05 13:29:34 rambaut Exp $
43 */
44 public class DefaultPriorTableDialog {
45
46 private BeautiFrame frame;
47 private PriorsPanel priorsPanel;
48
49 public DefaultPriorTableDialog(BeautiFrame frame) {
50 this.frame = frame;
51 priorsPanel = new PriorsPanel(frame, true);
52 }
53
54 public JButton findButton(String label, Container container) {
55 for (Component comp : container.getComponents()) {
56 if (comp instanceof JButton) {
57 JButton button = (JButton)comp;
58 if (button.getText().equals(label)) {
59 return button;
60 }
61 } else if (comp instanceof Container) {
62 JButton button = findButton(label, (Container) comp);
63 if (button != null) {
64 return button;
65 }
66 }
67
68 }
69 return null;
70 }
71
72 public boolean showDialog(BeautiOptions options) {
73 priorsPanel.setParametersList(options);
74
75 Object[] buttons;
76 JOptionPane optionPane;
77
78 String title;
79
80 if (priorsPanel.hasUndefinedPrior) {
81 title = "Undefined Priors";
82 } else {
83 title = "Unchanged Default Priors";
84 }
85 buttons = new String[] {"Continue", "Cancel"};
86 optionPane = new JOptionPane(priorsPanel,
87 JOptionPane.PLAIN_MESSAGE,
88 JOptionPane.OK_CANCEL_OPTION,
89 null,
90 buttons,
91 buttons[0]);
92
93 JButton button = findButton("Continue", optionPane);
94 if (button != null) {
95 priorsPanel.setContinueButton(button);
96 }
97
98 // if (priorspanel.hasUndefinedPrior) {
99 // buttons = new String[] {"OK"};
100 // title = "Undefined Priors";
101 // optionPane = new JOptionPane(priorspanel,
102 // JOptionPane.ERROR_MESSAGE,
103 // JOptionPane.OK_OPTION,
104 // null,
105 // buttons,
106 // buttons[0]);
107 // } else {
108 // buttons = new String[] {"Continue", "Cancel"};
109 // title = "Unchanged Default Priors";
110 // optionPane = new JOptionPane(priorspanel,
111 // JOptionPane.PLAIN_MESSAGE,
112 // JOptionPane.OK_CANCEL_OPTION,
113 // null,
114 // buttons,
115 // buttons[0]);
116 // }
117
118 optionPane.setBorder(new EmptyBorder(12, 12, 12, 12));
119 optionPane.setPreferredSize(new java.awt.Dimension(800, 600));
120
121 final JDialog dialog = optionPane.createDialog(frame, title);
122 dialog.pack();
123 dialog.setResizable(true);
124 dialog.setVisible(true);
125
126 return optionPane.getValue() != null && optionPane.getValue().equals("Continue");
127 }
128 }