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

Method annotateSelected

src/figtree/application/FigTreeFrame.java:567–613  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

565 }
566
567 private void annotateSelected() {
568 treeViewer.setToolMode(TreePaneSelector.ToolMode.SELECT);
569
570 List<AnnotationDefinition> definitions = new ArrayList<AnnotationDefinition>();
571 definitions.add(new AnnotationDefinition("Name", "!name", AnnotationDefinition.Type.STRING));
572 definitions.addAll(treeViewer.getAnnotationDefinitions().values());
573
574 if (annotationDialog == null) {
575 annotationDialog = new AnnotationDialog(this);
576 }
577
578 Set<Node> nodes = treeViewer.getSelectedNodes();
579 Set<Node> tips = treeViewer.getSelectedTips();
580
581 Attributable item = null;
582 if (nodes.size() + tips.size() == 1 ) {
583 if (nodes.size() == 1) {
584 item = nodes.iterator().next();
585 }else if (tips.size() == 1) {
586 item = tips.iterator().next();
587 }
588 } else {
589 int result = JOptionPane.showConfirmDialog(this,
590 "More than one node selected for annotation. This operation\n" +
591 "may overwrite existing annotations. Do you wish to continue?" ,
592 "Annotating Tree",
593 JOptionPane.WARNING_MESSAGE);
594 if (result == JOptionPane.CANCEL_OPTION || result == JOptionPane.CLOSED_OPTION) {
595 return;
596 }
597 }
598 if (annotationDialog.showDialog(definitions, item) != JOptionPane.CANCEL_OPTION) {
599 AnnotationDefinition newDefinition = annotationDialog.getDefinition();
600
601 List<AnnotationDefinition> defs = new ArrayList<AnnotationDefinition>(treeViewer.getAnnotationDefinitions().values());
602 if (!defs.contains(newDefinition)) {
603 defs.add(newDefinition);
604 treeViewer.setAnnotationDefinitions(defs);
605 }
606
607 String code = newDefinition.getCode();
608 Object value = annotationDialog.getValue();
609
610 treeViewer.annotateSelected(code, value);
611 setDirty();
612 }
613 }
614
615 private void copySelectedAnnotations() {
616 // todo This function is disabled as it is not completely implemented

Callers 2

actionPerformedMethod · 0.95
colourSelectedMethod · 0.45

Calls 10

getCodeMethod · 0.95
getDefinitionMethod · 0.80
setToolModeMethod · 0.45
addMethod · 0.45
getSelectedNodesMethod · 0.45
getSelectedTipsMethod · 0.45
showDialogMethod · 0.45
getValueMethod · 0.45

Tested by

no test coverage detected