()
| 947 | } |
| 948 | |
| 949 | public final void doImport() { |
| 950 | |
| 951 | FileDialog dialog = new FileDialog(this, |
| 952 | "Import Annotations File...", |
| 953 | FileDialog.LOAD); |
| 954 | |
| 955 | dialog.setVisible(true); |
| 956 | if (dialog.getFile() != null) { |
| 957 | File file = new File(dialog.getDirectory(), dialog.getFile()); |
| 958 | |
| 959 | try { |
| 960 | Map<AnnotationDefinition, Map<Taxon, Object>> annotations = importAnnotationsFromFile(file); |
| 961 | |
| 962 | treeViewer.setTaxonAnnotations(annotations); |
| 963 | |
| 964 | // Hack to show tips states... |
| 965 | // String[] annotationNames = new String[annotations.keySet().size()]; |
| 966 | // DiscreteColourDecorator[] decorators = new DiscreteColourDecorator[annotations.keySet().size()]; |
| 967 | // |
| 968 | // int i = 0; |
| 969 | // for (AnnotationDefinition definition: annotations.keySet()) { |
| 970 | // Map<Taxon, Object> annotation = annotations.get(definition); |
| 971 | // annotationNames[i] = definition.getName(); |
| 972 | // decorators[i] = new HSBDiscreteColourDecorator(annotationNames[i], annotation.keySet()); |
| 973 | // i++; |
| 974 | // } |
| 975 | // treeViewer.setTipLabelPainter(new StatesPainter(annotationNames, decorators)); |
| 976 | |
| 977 | |
| 978 | } catch (FileNotFoundException fnfe) { |
| 979 | JOptionPane.showMessageDialog(this, "Unable to open file: File not found", |
| 980 | "Unable to open file", |
| 981 | JOptionPane.ERROR_MESSAGE); |
| 982 | } catch (IOException ioe) { |
| 983 | JOptionPane.showMessageDialog(this, "Unable to read file: " + ioe.getMessage(), |
| 984 | "Unable to read file", |
| 985 | JOptionPane.ERROR_MESSAGE); |
| 986 | } |
| 987 | } |
| 988 | |
| 989 | } |
| 990 | |
| 991 | protected Map<AnnotationDefinition, Map<Taxon, Object>> importAnnotationsFromFile(File file) throws IOException { |
| 992 |
no test coverage detected