public static boolean isDapNode(Object value) { if (value instanceof DefaultMutableTreeNode) { final Object userObject = ((DefaultMutableTreeNode) value).getUserObject(); return (userObject instanceof OpendapLeaf) && ((OpendapLeaf) userObject).isDapAccess(); } return false; }
private void collectURIs() { final TreePath[] selectionPaths = ((JTree) catalogTree.getComponent()).getSelectionModel().getSelectionPaths(); if (selectionPaths == null || selectionPaths.length <= 0) { return; } for (TreePath selectionPath : selectionPaths) { final DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) selectionPath.getLastPathComponent(); if (CatalogTreeUtils.isDapNode(treeNode) || CatalogTreeUtils.isFileNode(treeNode)) { final OpendapLeaf leaf = (OpendapLeaf) treeNode.getUserObject(); if (leaf.isDapAccess()) { dapURIs.put(leaf.getDapUri(), leaf.getFileSize() >= 2 * 1024 * 1024); } else if (leaf.isFileAccess()) { fileURIs.add(leaf.getFileUri()); } } } }
@Override public void valueChanged(TreeSelectionEvent e) { final TreePath[] paths = e.getPaths(); for (TreePath path : paths) { final DefaultMutableTreeNode lastPathComponent = (DefaultMutableTreeNode) path.getLastPathComponent(); final Object userObject = lastPathComponent.getUserObject(); if (!(userObject instanceof OpendapLeaf)) { continue; } final OpendapLeaf dapObject = (OpendapLeaf) userObject; leafSelectionListener.leafSelectionChanged(e.isAddedPath(path), dapObject); } TreePath path = e.getPath(); final DefaultMutableTreeNode lastPathComponent = (DefaultMutableTreeNode) path.getLastPathComponent(); final Object userObject = lastPathComponent.getUserObject(); if (!(userObject instanceof OpendapLeaf)) { return; } OpendapLeaf opendapLeaf = (OpendapLeaf) userObject; if (opendapLeaf.isDapAccess()) { leafSelectionListener.dapLeafSelected(opendapLeaf); } else if (opendapLeaf.isFileAccess()) { leafSelectionListener.fileLeafSelected(opendapLeaf); } } });
private void setMetadataText(int componentIndex, OpendapLeaf leaf) { String text = null; try { if (leaf.isDapAccess()) { if (metaInfoArea.getSelectedIndex() == DDS_AREA_INDEX) { text = OpendapUtils.getResponse(leaf.getDdsUri()); } else if (metaInfoArea.getSelectedIndex() == DAS_AREA_INDEX) { text = OpendapUtils.getResponse(leaf.getDasUri()); } } else if (leaf.isFileAccess()) { if (metaInfoArea.getSelectedIndex() == DDS_AREA_INDEX) { text = "No DDS information for file '" + leaf.getName() + "'."; } else if (metaInfoArea.getSelectedIndex() == DAS_AREA_INDEX) { text = "No DAS information for file '" + leaf.getName() + "'."; } } } catch (IOException e) { BeamLogManager.getSystemLogger().warning("Unable to retrieve meta information for file '" + leaf.getName() + "'."); } setResponseText(componentIndex, text); }