/** * Selects the specified object in this tree's model. If the given object has no representation in the tree, the * current selection will not be changed. * * @param toSelect the object whose representation in the tree will be selected. */ public void select(Object toSelect) { final TreePath path = getModel().getTreePath(toSelect); if (path != null) { setSelectionPath(path); } }
public void expand(Object toExpand) { final TreePath path = getModel().getTreePath(toExpand); if (path != null) { makeVisible(path); } }
/** * Sets the <code>TreeModel</code> that will provide the data. * * @param newModel the <code>TreeModel</code> that is to provide the data. Must be an * instance of {@link org.esa.beam.framework.ui.product.tree.ProductTreeModel}. * description: The TreeModel that will provide the data. */ @Override public void setModel(TreeModel newModel) { if (newModel != null && !(newModel instanceof ProductTreeModel)) { throw new IllegalStateException("newModel must be instance of ProductTreeModel"); } if (getModel() != null) { ProductManager productManager = getModel().getProductManager(); productManager.removeListener(productManagerListener); getModel().removeTreeModelListener(productTreeModelListener); } if (newModel != null) { ProductTreeModel ptm = (ProductTreeModel) newModel; ptm.getProductManager().addListener(productManagerListener); ptm.addTreeModelListener(productTreeModelListener); } super.setModel(newModel); }
ProductManager productManager = getModel().getProductManager(); if (!isProductAlreadyOpen(file, productManager)) { final Product product = ProductIO.readProduct(file);
@Override public void productAdded(ProductManager.Event event) { fireProductAdded(event.getProduct()); TreePath treePath = getModel().getTreePath(event.getProduct()); expandPath(treePath); Rectangle bounds = getPathBounds(treePath); if (bounds != null) { bounds.setRect(0, bounds.y, bounds.width, bounds.height); scrollRectToVisible(bounds); } }