MCPcopy Create free account
hub / github.com/rambaut/figtree / AnnotationDialog

Class AnnotationDialog

src/figtree/treeviewer/annotations/AnnotationDialog.java:45–233  ·  view source on GitHub ↗

@author Andrew Rambaut @version $Id$ $HeadURL$ $LastChangedBy$ $LastChangedDate$ $LastChangedRevision$

Source from the content-addressed store, hash-verified

43 * $LastChangedRevision$
44 */
45public class AnnotationDialog {
46
47 public final static String CREATE_NEW = "Create new...";
48 private JFrame frame;
49 private OptionsPanel options;
50 private JComboBox annotationCombo;
51
52 private Attributable item;
53 private List<AnnotationDefinition> definitions;
54 private JComponent component = null;
55 private JComponent component2 = null;
56
57 AnnotationDefinition definition = null;
58
59 public AnnotationDialog(JFrame frame) {
60 this.frame = frame;
61 }
62
63 public int showDialog(List<AnnotationDefinition> definitions, Attributable item) {
64
65 this.definitions = definitions;
66 this.item = item;
67
68 options = new OptionsPanel(6, 6);
69
70 annotationCombo = new JComboBox(definitions.toArray());
71 // todo This requires a bit more work so has been disabled for now...
72// annotationCombo.addItem(CREATE_NEW);
73 annotationCombo.setSelectedIndex(0);
74
75 setupOptionsPanel();
76
77 JOptionPane optionPane = new JOptionPane(options,
78 JOptionPane.QUESTION_MESSAGE,
79 JOptionPane.OK_CANCEL_OPTION,
80 null,
81 null,
82 null);
83 optionPane.setBorder(new EmptyBorder(12, 12, 12, 12));
84
85 final JDialog dialog = optionPane.createDialog(frame, "Annotate Selection");
86 dialog.pack();
87
88 annotationCombo.addActionListener(new ActionListener() {
89 public void actionPerformed(ActionEvent event) {
90 setupOptionsPanel();
91 dialog.pack();
92 }});
93
94 dialog.setVisible(true);
95
96 int result = JOptionPane.CANCEL_OPTION;
97 Integer value = (Integer)optionPane.getValue();
98 if (value != null && value.intValue() != -1) {
99 result = value.intValue();
100 }
101
102 return result;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…