private void bindComponents() {
    final BindingContext bc = new BindingContext(model.getValueContainer());

    bc.bind("productName", productNameTextField);
    bc.bind("saveToFileSelected", saveToFileCheckBox);
    bc.bind("openInAppSelected", openInAppCheckBox);
    bc.bind("formatName", formatNameComboBox);
    bc.bind("productDir", productDirTextField);

    model
        .getValueContainer()
        .addPropertyChangeListener(
            "productDir",
            new PropertyChangeListener() {
              @Override
              public void propertyChange(PropertyChangeEvent evt) {
                productDirTextField.setToolTipText(model.getProductDir().getPath());
              }
            });
    model
        .getValueContainer()
        .addPropertyChangeListener(
            "formatName",
            new PropertyChangeListener() {
              @Override
              public void propertyChange(PropertyChangeEvent evt) {
                updateUIState();
              }
            });
  }
    @Override
    protected void done() {
      final TargetProductSelectorModel model = getTargetProductSelector().getModel();
      try {
        final Date now = Calendar.getInstance().getTime();
        final long diff = (now.getTime() - executeStartTime.getTime()) / 1000;
        if (diff > 120) {
          final float minutes = diff / 60f;
          statusLabel.setText("Processing completed in " + minutes + " minutes");
        } else {
          statusLabel.setText("Processing completed in " + diff + " seconds");
        }

        final Product targetProduct = get();
        if (model.isOpenInAppSelected()) {
          appContext.getProductManager().addProduct(targetProduct);
          // showSaveAndOpenInAppInfo(saveTime);
        } else {
          // showSaveInfo(saveTime);
        }
      } catch (InterruptedException e) {
        // ignore
      } catch (ExecutionException e) {
        handleProcessingError(e.getCause());
      } catch (Throwable t) {
        handleProcessingError(t);
      }
    }
Beispiel #3
0
  private void bindComponents() {
    final BindingContext bc = new BindingContext(model.getValueContainer());

    bc.bind("productName", productNameTextField);
    bc.bind("productDir", productDirTextField);

    if (!alwaysWriteOutput) {
      bc.bind("saveToFileSelected", saveToFileCheckBox);
      bc.bind("openInAppSelected", openInAppCheckBox);
      bc.bind("formatName", formatNameComboBox);
    }

    model
        .getValueContainer()
        .addPropertyChangeListener(
            new PropertyChangeListener() {
              @Override
              public void propertyChange(PropertyChangeEvent evt) {
                String propertyName = evt.getPropertyName();
                if (propertyName.equals(TargetProductSelectorModel.PROPERTY_PRODUCT_DIR)) {
                  productDirTextField.setToolTipText(model.getProductDir().getPath());
                } else {
                  updateUIState();
                }
              }
            });
  }
 private void updateUIState() {
   if (model.isSaveToFileSelected()) {
     openInAppCheckBox.setEnabled(canReadOutputFormat(model.getFormatName()));
     formatNameComboBox.setEnabled(true);
     productDirLabel.setEnabled(true);
     productDirTextField.setEnabled(true);
     productDirChooserButton.setEnabled(true);
   } else {
     openInAppCheckBox.setEnabled(false);
     formatNameComboBox.setEnabled(false);
     productDirTextField.setEnabled(false);
     productDirTextField.setEnabled(false);
     productDirChooserButton.setEnabled(false);
   }
 }
  private void initComponents() {
    productNameLabel = new JLabel("Name: ");
    productNameTextField = new JTextField(25);
    saveToFileCheckBox = new JCheckBox("Save as:");
    productDirLabel = new JLabel("Directory:");
    productDirTextField = new JTextField(25);
    productDirChooserButton = new JButton(new ProductDirChooserAction());
    formatNameComboBox = new JComboBox(model.getFormatNames());
    openInAppCheckBox = new JCheckBox("Open in application");

    final Dimension size = new Dimension(26, 16);
    productDirChooserButton.setPreferredSize(size);
    productDirChooserButton.setMinimumSize(size);
    saveToFileCheckBox.addActionListener(new UIStateUpdater());
    formatNameComboBox.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            final String formatName = (String) formatNameComboBox.getSelectedItem();
            if (!canReadOutputFormat(formatName)) {
              model.setOpenInAppSelected(false);
            }
          }
        });
  }
    @Override
    protected Product doInBackground(com.bc.ceres.core.ProgressMonitor pm) throws Exception {
      final TargetProductSelectorModel model = getTargetProductSelector().getModel();
      pm.beginTask("Writing...", model.isOpenInAppSelected() ? 100 : 95);
      ProgressMonitorList.instance().add(pm); // NESTMOD
      saveTime = 0L;
      Product product = null;
      try {
        // free cache	// NESTMOD
        JAI.getDefaultInstance().getTileCache().flush();
        System.gc();

        executeStartTime = Calendar.getInstance().getTime();
        long t0 = System.currentTimeMillis();
        Operator operator = null;
        if (targetProduct.getProductReader() instanceof OperatorProductReader) {
          final OperatorProductReader opReader =
              (OperatorProductReader) targetProduct.getProductReader();
          if (opReader.getOperatorContext().getOperator() instanceof Output) {
            operator = opReader.getOperatorContext().getOperator();
          }
        }
        if (operator == null) {
          WriteOp writeOp =
              new WriteOp(targetProduct, model.getProductFile(), model.getFormatName());
          writeOp.setDeleteOutputOnFailure(true);
          writeOp.setWriteEntireTileRows(true);
          writeOp.setClearCacheAfterRowWrite(false);
          operator = writeOp;
        }
        final OperatorExecutor executor = OperatorExecutor.create(operator);
        executor.execute(SubProgressMonitor.create(pm, 95));

        saveTime = System.currentTimeMillis() - t0;
        File targetFile = model.getProductFile();
        if (model.isOpenInAppSelected() && targetFile.exists()) {
          product = ProductIO.readProduct(targetFile);
          if (product == null) {
            product = targetProduct; // todo - check - this cannot be ok!!! (nf)
          }
          pm.worked(5);
        }
      } finally {
        // free cache
        JAI.getDefaultInstance().getTileCache().flush();
        System.gc();

        pm.done();
        ProgressMonitorList.instance().remove(pm); // NESTMOD
        if (product != targetProduct) {
          targetProduct.dispose();
        }
      }
      return product;
    }
Beispiel #7
0
  private void initComponents() {
    productNameLabel = new JLabel("Name: ");
    productNameTextField = new JTextField(25);
    productDirLabel = new JLabel("Directory:");
    productDirTextField = new JTextField(25);
    productDirChooserButton = new JButton(new ProductDirChooserAction());

    final Dimension size = new Dimension(26, 16);
    productDirChooserButton.setPreferredSize(size);
    productDirChooserButton.setMinimumSize(size);

    if (!alwaysWriteOutput) {
      saveToFileCheckBox = new JCheckBox("Save as:");
      formatNameComboBox = new JComboBox<>(model.getFormatNames());
      openInAppCheckBox = new JCheckBox("Open in application");
    }
  }
Beispiel #8
0
  RadiometryDialog(String alias, AppContext appContext, String title, String helpId) {
    super(
        appContext,
        title,
        ID_APPLY_CLOSE,
        helpId,
        TargetProductSelectorModel.createEnvisatTargetProductSelectorModel());
    this.alias = alias;
    final OperatorSpi operatorSpi =
        GPF.getDefaultInstance().getOperatorSpiRegistry().getOperatorSpi(alias);

    parameterSupport = new OperatorParameterSupport(operatorSpi.getOperatorClass());
    form =
        new RadiometryForm(
            appContext, operatorSpi, parameterSupport.getPopertySet(), getTargetProductSelector());
    OperatorMenu operatorMenu =
        new OperatorMenu(
            this.getJDialog(), operatorSpi.getOperatorClass(), parameterSupport, helpId);
    getJDialog().setJMenuBar(operatorMenu.createDefaultMenu());
  }