@Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { final JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value instanceof ProductLocation) { final ProductLocation location = (ProductLocation) value; String path = location.getPath(); if (location.getProductLocationType() != ProductLocationType.FILE) { if (!path.endsWith(File.separator)) { path += File.separator; } } if (location.getProductLocationType() == ProductLocationType.DIRECTORY) { path += "*"; } if (location.getProductLocationType() == ProductLocationType.DIRECTORY_REC) { path += "**"; } label.setText(path); } return label; } });
final Logger logger = BeamLogManager.getSystemLogger(); final ProductLocationType type = productLocation.getProductLocationType(); final String path = productLocation.getPath(); logger.log(Level.INFO, "Try to load product location type: '" + type + "' at path: '" + path + "'"); addProductLocationMetadata(productLocation);
@Override public void removeProductLocation(ProductLocation productLocation) { // remove metadata final MetadataElement timeSeriesRootElement = tsProduct.getMetadataRoot().getElement(TIME_SERIES_ROOT_NAME); MetadataElement productLocationsElement = timeSeriesRootElement.getElement(PRODUCT_LOCATIONS); removeAttributeWithValue(PL_PATH, productLocation.getPath(), productLocationsElement); // remove variables for this productLocation updateAutoGrouping(); // TODO ??? final Band[] bands = tsProduct.getBands(); final MetadataElement sourceProductPaths = timeSeriesRootElement.getElement(SOURCE_PRODUCT_PATHS); for (Map.Entry<String, Product> productEntry : productLocation.getProducts(ProgressMonitor.NULL).entrySet()) { final Product product = productEntry.getValue(); removeAttributeWithValue(PL_PATH, productEntry.getKey(), sourceProductPaths); String timeString = formatTimeString(product); productTimeMap.remove(timeString); for (Band band : bands) { if (band.getName().endsWith(timeString)) { tsProduct.removeBand(band); } } } productLocation.closeProducts(); productLocationList.remove(productLocation); fireChangeEvent(new TimeSeriesChangeEvent(TimeSeriesChangeEvent.PROPERTY_PRODUCT_LOCATIONS, productLocationList, this)); }
private void addProductLocationMetadata(ProductLocation productLocation) { MetadataElement productLocationsElement = tsProduct.getMetadataRoot(). getElement(TIME_SERIES_ROOT_NAME). getElement(PRODUCT_LOCATIONS); // @todo - nur produkt pfade, keine Verzeichnisse ProductData productPath = ProductData.createInstance(productLocation.getPath()); ProductData productType = ProductData.createInstance(productLocation.getProductLocationType().toString()); int length = productLocationsElement.getElements().length + TimeSeriesChangeEvent.BAND_TO_BE_REMOVED; MetadataElement elem = new MetadataElement( String.format("%s.%s", PRODUCT_LOCATIONS, Integer.toString(length))); elem.addAttribute(new MetadataAttribute(PL_PATH, productPath, true)); elem.addAttribute(new MetadataAttribute(PL_TYPE, productType, true)); productLocationsElement.addElement(elem); }