Ejemplo n.º 1
0
  private boolean checkReferencedRastersIncluded() {
    final Set<String> notIncludedNames = new TreeSet<String>();
    final List<String> includedNodeNames = Arrays.asList(productSubsetDef.getNodeNames());
    for (final String nodeName : includedNodeNames) {
      final RasterDataNode rasterDataNode = product.getRasterDataNode(nodeName);
      if (rasterDataNode != null) {
        collectNotIncludedReferences(rasterDataNode, notIncludedNames);
      }
    }

    boolean ok = true;
    if (!notIncludedNames.isEmpty()) {
      StringBuilder nameListText = new StringBuilder();
      for (String notIncludedName : notIncludedNames) {
        nameListText.append("  '").append(notIncludedName).append("'\n");
      }

      final String pattern =
          "The following dataset(s) are referenced but not included\n"
              + "in your current subset definition:\n"
              + "{0}\n"
              + "If you do not include these dataset(s) into your selection,\n"
              + "you might get unexpected results while working with the\n"
              + "resulting product.\n\n"
              + "Do you wish to include the referenced dataset(s) into your\n"
              + "subset definition?\n"; /*I18N*/
      final MessageFormat format = new MessageFormat(pattern);
      int status =
          JOptionPane.showConfirmDialog(
              getJDialog(),
              format.format(new Object[] {nameListText.toString()}),
              "Incomplete Subset Definition", /*I18N*/
              JOptionPane.YES_NO_CANCEL_OPTION);
      if (status == JOptionPane.YES_OPTION) {
        final String[] nodenames = notIncludedNames.toArray(new String[notIncludedNames.size()]);
        productSubsetDef.addNodeNames(nodenames);
        ok = true;
      } else if (status == JOptionPane.NO_OPTION) {
        ok = true;
      } else if (status == JOptionPane.CANCEL_OPTION) {
        ok = false;
      }
    }
    return ok;
  }