@Override public void start(VisatApp visatApp) { visatApp.getProductManager().addListener(productManagerListener); }
public ProductTreeModel(final ProductManager manager) { this.productManager = manager; rootTN = new ProductManagerTN(productManager); productNodeListener = new ProductListener(); productManager.addListener(new ProductManagerListener()); treeModelListeners = new EventListenerList(); }
@Override protected void initComponents() { getAlternativeView().initComponents(); initParameters(); createUI(); VisatApp.getApp().getProductManager().addListener(productRemovedListener); }
public synchronized void initProducts() { productListModel.removeAllElements(); for (Product product : appContext.getProductManager().getProducts()) { addProduct(product); } final Product selectedProduct = appContext.getSelectedProduct(); if (selectedProduct != null && productFilter.accept(selectedProduct)) { productListModel.setSelectedItem(selectedProduct); } appContext.getProductManager().addListener(productManagerListener); }
/** * 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); }
private void initProductTree() { productTree = new ProductTree(); productTree.setModel(new ProductTreeModel(visatApp.getProductManager())); productTree.addProductTreeListener(new VisatPTL()); productTree.setCommandManager(visatApp.getCommandManager()); productTree.setCommandUIFactory(visatApp.getCommandUIFactory()); visatApp.getProductManager().addListener(new ProductManagerL()); visatApp.addInternalFrameListener(new SceneViewListener()); selectionContext = new ProductTreeSelectionContext(productTree); }
public void testAddProduct() { final ProductManagerListener listener = new ProductManagerListener(); _productManager.addListener(listener); _productManager.addProduct(_product1); assertEquals(1, _productManager.getProductCount()); assertSame(_product1, _productManager.getProduct(0)); assertSame(_product1, _productManager.getProduct("product1")); assertEquals(1, _product1.getRefNo()); assertSame(_productManager, _product1.getProductManager()); final Vector addedProducts = listener.getAddedProducts(); assertEquals(1, addedProducts.size()); assertSame(_product1, addedProducts.get(0)); final Vector removedProducts = listener.getRemovedProducts(); assertEquals(0, removedProducts.size()); }
VisatApp.getApp().getProductManager().addListener(new ProductManager.Listener() { @Override public void productAdded(ProductManager.Event event) {
productNodeListener = createProductNodeListener(); productManager = new ProductManager(); productManager.addListener(new ProductManager.Listener() { @Override public void productAdded(ProductManager.Event event) {
public void testRemoveAll() { addAllProducts(); final ProductManagerListener listener = new ProductManagerListener(); _productManager.addListener(listener); _productManager.removeAllProducts(); assertEquals(0, _productManager.getProductCount()); assertNull(_product1.getProductManager()); assertNull(_product2.getProductManager()); assertNull(_product3.getProductManager()); assertEquals(0, _product1.getRefNo()); assertEquals(0, _product2.getRefNo()); assertEquals(0, _product3.getRefNo()); final Vector removedProducts = listener.getRemovedProducts(); assertEquals(3, removedProducts.size()); assertSame(_product1, removedProducts.get(0)); assertSame(_product2, removedProducts.get(1)); assertSame(_product3, removedProducts.get(2)); final Vector addedProducts = listener.getAddedProducts(); assertEquals(0, addedProducts.size()); }
public void testRemoveProduct() { addAllProducts(); final ProductManagerListener listener = new ProductManagerListener(); _productManager.addListener(listener); _productManager.removeProduct(_product2); assertEquals(2, _productManager.getProductCount()); assertSame(_product1, _productManager.getProduct(0)); assertSame(_product3, _productManager.getProduct(1)); assertSame(_product1, _productManager.getProduct("product1")); assertNull(_productManager.getProduct("product2")); assertSame(_product3, _productManager.getProduct("product3")); assertEquals(1, _product1.getRefNo()); assertEquals(0, _product2.getRefNo()); assertEquals(3, _product3.getRefNo()); assertSame(_productManager, _product1.getProductManager()); assertNull(_product2.getProductManager()); assertSame(_productManager, _product3.getProductManager()); final Vector addedProducts = listener.getAddedProducts(); assertEquals(0, addedProducts.size()); final Vector removedProducts = listener.getRemovedProducts(); assertEquals(1, removedProducts.size()); assertSame(_product2, removedProducts.get(0)); }