/** * Copies the product nodes of this product node list into the specified array. The array must be big enough to hold * all the product nodes in this product node list, else an <tt>IndexOutOfBoundsException</tt> is thrown. * * @param array the array into which the product nodes get copied. * * @throws NullPointerException if the given array is null. * @throws IndexOutOfBoundsException if the given array is to small. */ public final void copyInto(T[] array) { for (T node : array) { add(node); } }
private void addAllNodes() { _nodeList.add(_attribute1); _nodeList.add(_attribute2); _nodeList.add(_attribute3); _nodeList.add(_attribute4); // final ProductNode[] children = _owner.getChildren(); // assertEquals(4, children.length); // assertSame(_attribute1, children[0]); // assertSame(_attribute2, children[1]); // assertSame(_attribute3, children[2]); // assertSame(_attribute4, children[3]); }
/** * Adds the given node to this group. * * @param index the index. * @param node the node to be added, ignored if <code>null</code> */ public void add(int index, T node) { Assert.notNull(node, "node"); nodeList.add(index, node); notifyAdded(node); }
/** * Adds the given node to this group. * * @param node the node to be added, ignored if <code>null</code> * @return true, if the node has been added */ public boolean add(T node) { Assert.notNull(node, "node"); boolean added = nodeList.add(node); if (added) { notifyAdded(node); } return added; }
/** * Creates a subset of this list using the given filter. * * @param filter the product node filter to be used, if <code>null</code> a clone of this list is created * * @return the subset */ public ProductNodeList<T> createSubset(ProductNodeFilter<T> filter) { ProductNodeList<T> list = new ProductNodeList<T>(); for (int i = 0; i < size(); i++) { T node = getAt(i); if (filter.accept(node)) { list.add(node); } } return list; }
private void openBandArithmeticDialog(final VisatApp visatApp, final String helpId) { final Product[] prods = visatApp.getProductManager().getProducts(); final ProductNodeList<Product> products = new ProductNodeList<Product>(); for (Product prod : prods) { products.add(prod); } BandMathsDialog bandMathsDialog = new BandMathsDialog(visatApp, visatApp.getSelectedProduct(), products, helpId); bandMathsDialog.show(); } }
for (String headerName : headerNames) { MetadataElement element = metadataRoot.getElement(headerName); metadataElementBackup.add(element); metadataRoot.removeElement(element); metadataElementBackup.add(element); metadataRoot.removeElement(element); if (name.endsWith("ADS") || name.endsWith("Ads") || name.endsWith("ads")) { final MetadataElement element = metadataRoot.getElement(name); metadataElementBackup.add(element); metadataRoot.removeElement(element);
/** * Adds the given product to this product manager if it does not already exists and sets it's reference number one * biger than the greatest reference number in this product manager. * * @param product the product to be added, ignored if <code>null</code> */ public void addProduct(Product product) { if (product != null) { if (contains(product)) { return; } if (productList.add(product)) { setProductManager(product); if (product.getRefNo() <= 0) { product.setRefNo(getNextRefNo() + 1); } product.addProductNodeListener(productNodeNameChangeListener); fireEvent(product, PRODUCT_ADDED); } } }
public void testAddAndRemoveAndSize() { assertEquals(_nodeList.size(), 0); _nodeList.add(_attribute1); assertEquals(_nodeList.size(), 1); _nodeList.add(_attribute2); assertEquals(_nodeList.size(), 2); _nodeList.add(_attribute3); assertEquals(_nodeList.size(), 3); _nodeList.add(_attribute4); assertEquals(_nodeList.size(), 4); _nodeList.remove(_attribute1); assertEquals(_nodeList.size(), 3); _nodeList.removeAll(); assertEquals(_nodeList.size(), 0); }
private boolean openProductSubsetDialog(Product product) { _subsetProduct = null; boolean approve = false; if (product != null) { VisatApp visatApp = VisatApp.getApp(); JFrame mainFrame = visatApp.getMainFrame(); ProductSubsetDialog productSubsetDialog = new ProductSubsetDialog(mainFrame, product); if (productSubsetDialog.show() == ProductSubsetDialog.ID_OK) { ProductNodeList<Product> products = new ProductNodeList<Product>(); products.add(product); NewProductDialog newProductDialog = new NewProductDialog(visatApp.getMainFrame(), products, 0, true); newProductDialog.setSubsetDef(productSubsetDialog.getProductSubsetDef()); if (newProductDialog.show() == NewProductDialog.ID_OK) { _subsetProduct = newProductDialog.getResultProduct(); approve = _subsetProduct != null; if (!approve && newProductDialog.getException() != null) { visatApp.showErrorDialog("The product subset could not be created:\n" + newProductDialog.getException().getMessage()); } } } } return approve; } }