@Override public int getChildCount() { return manager.getProductCount(); }
/** * Returns an array of all products currently managed. * * @return an array containing the products, never <code>null</code>, but the array can have zero length */ public Product[] getProducts() { return productList.toArray(new Product[getProductCount()]); }
private boolean isProductAlreadyOpen(File file, ProductManager productManager) { for (int i = 0; i < productManager.getProductCount(); i++) { final Product product = productManager.getProduct(i); final File productFile = product.getFileLocation(); if (file.equals(productFile)) { return true; } } return false; }
/** * Returns the next reference number for products in this manager. * * @return the next highest reference number */ private int getNextRefNo() { final int numProducts = getProductCount(); int highestRefNo = 0; for (int i = 0; i < numProducts; i++) { final int refNo = getProduct(i).getRefNo(); if (refNo > highestRefNo) { highestRefNo = refNo; } } return highestRefNo; }
/** * Finds the product associated with the given file. * * @param file the file * @return the product associated with the given file. or <code>null</code> if no such exists. */ public Product getOpenProduct(final File file) { final ProductManager productManager = getProductManager(); for (int i = 0; i < productManager.getProductCount(); i++) { final Product product = productManager.getProduct(i); final File productFile = product.getFileLocation(); if (file.equals(productFile)) { return product; } } return null; }
@Override public void updateState(final CommandEvent event) { setEnabled(VisatApp.getApp().getProductManager().getProductCount() > 0); } }
@Override public void updateState(final CommandEvent event) { setEnabled(VisatApp.getApp().getProductManager().getProductCount() > 0); } }
@Override public final void updateState(final CommandEvent event) { setEnabled(VisatApp.getApp().getProductManager().getProductCount() > 0); }
@Override public void updateState(final CommandEvent event) { final VisatApp app = VisatApp.getApp(); setEnabled(app.getProductManager().getProductCount() > 0 || app.getSessionFile() != null); } }
@Override public void updateState(final CommandEvent event) { final int n = VisatApp.getApp().getProductManager().getProductCount(); setEnabled(n > 0 && VisatApp.getApp().getSelectedProduct() != null); }
public void testGetNumProducts() { assertEquals(0, _productManager.getProductCount()); addAllProducts(); assertEquals(3, _productManager.getProductCount()); _productManager.removeProduct(_product1); assertEquals(2, _productManager.getProductCount()); _productManager.removeProduct(_product2); assertEquals(1, _productManager.getProductCount()); _productManager.removeProduct(_product2); assertEquals(1, _productManager.getProductCount()); _productManager.removeProduct(null); assertEquals(1, _productManager.getProductCount()); _productManager.removeProduct(_product3); assertEquals(0, _productManager.getProductCount()); }
@Override void updateState() { setEnabled(getMaskForm().isInManagementMode() && getMaskForm().getSelectedRowCount() > 0 && VisatApp.getApp().getProductManager().getProductCount() > 1); }
/** * Returns the currently selected product. * * @return the selected product, which can be <code>null</code> */ @Override public Product getSelectedProduct() { if (selectedNode instanceof Product) { return (Product) selectedNode; } else if (selectedNode != null) { return selectedNode.getProduct(); } else if (getSelectedProductSceneView() != null) { return getSelectedProductSceneView().getProduct(); } else if (getSelectedProductMetadataView() != null) { return getSelectedProductMetadataView().getProduct(); } else if (getProductManager().getProductCount() == 1) { return getProductManager().getProduct(0); } else { return null; } }
void updateUIState(final boolean productSelected, int numPins, final int numSelectedPins) { boolean pinsAvailable = numPins > 0; boolean hasSelectedPins = numSelectedPins > 0; boolean hasActivePin = numSelectedPins == 1; newButton.setEnabled(productSelected); copyButton.setEnabled(hasActivePin); editButton.setEnabled(hasActivePin); removeButton.setEnabled(hasSelectedPins); zoomToPlacemarkButton.setEnabled(hasActivePin); transferPlacemarkButton.setEnabled(pinsAvailable && VisatApp.getApp().getProductManager().getProductCount() > 1); importButton.setEnabled(productSelected); exportButton.setEnabled(pinsAvailable); exportTableButton.setEnabled(pinsAvailable); filterButton.setEnabled(productSelected); }
private Product newProductImpl() { if (getProductManager().getProductCount() == 0) { return null; } final ProductNodeList<Product> products = new ProductNodeList<>(); products.copyInto(getProductManager().getProducts()); final Product selectedProduct = getSelectedProduct(); if (selectedProduct == null) { return null; } final int selectedSourceIndex = products.indexOf(selectedProduct); final NewProductDialog dialog = new NewProductDialog(getMainFrame(), products, selectedSourceIndex, false); if (dialog.show() != NewProductDialog.ID_OK) { return null; } final Product product = dialog.getResultProduct(); if (product != null) { addProduct(product); updateState(); } else if (dialog.getException() != null) { showErrorDialog("The product subset could not be created:\n" + dialog.getException().getMessage()); } return product; }
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()); }
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 testGetProductByDisplayName() { final Product product1 = new Product("name", "t", 1, 1); final Product product2 = new Product("name", "t", 1, 1); final Product product3 = new Product("name", "t", 1, 1); _productManager.addProduct(product1); _productManager.addProduct(product2); _productManager.addProduct(product3); assertEquals(3, _productManager.getProductCount()); assertSame(product1, _productManager.getProductByDisplayName("[1] name")); assertSame(product2, _productManager.getProductByDisplayName("[2] name")); assertSame(product3, _productManager.getProductByDisplayName("[3] name")); }
public void testAddProductsWithTheSameName() { final Product product1 = new Product("name", "t", 1, 1); final Product product2 = new Product("name", "t", 1, 1); final Product product3 = new Product("name", "t", 1, 1); _productManager.addProduct(product1); _productManager.addProduct(product2); _productManager.addProduct(product3); assertEquals(3, _productManager.getProductCount()); assertSame(product1, _productManager.getProduct(0)); assertSame(product2, _productManager.getProduct(1)); assertSame(product3, _productManager.getProduct(2)); }
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)); }