Пример #1
0
 private void updateTargetProductFields() {
   TargetProductSelectorModel model = targetProductSelector.getModel();
   Property property = propertySet.getProperty(ToolAdapterConstants.TOOL_TARGET_PRODUCT_FILE);
   if (!operatorDescriptor.isHandlingOutputName()) {
     Object value = property.getValue();
     if (value != null) {
       File file = operatorDescriptor.resolveVariables(new File(property.getValueAsText()));
       String productName = FileUtils.getFilenameWithoutExtension(file);
       if (fileExtension == null) {
         fileExtension = FileUtils.getExtension(file);
       }
       model.setProductName(productName);
     }
   } else {
     try {
       model.setProductName("Output Product");
       if (property != null) {
         property.setValue(null);
       }
     } catch (ValidationException e) {
       Logger.getLogger(ToolExecutionForm.class.getName()).severe(e.getMessage());
     }
   }
   model.setSaveToFileSelected(false);
   targetProductSelector.getProductDirTextField().setEnabled(false);
 }
Пример #2
0
  public ToolExecutionForm(
      AppContext appContext,
      ToolAdapterOperatorDescriptor descriptor,
      PropertySet propertySet,
      TargetProductSelector targetProductSelector) {
    this.appContext = appContext;
    this.operatorDescriptor = descriptor;
    this.propertySet = propertySet;
    this.targetProductSelector = targetProductSelector;

    // before executing, the sourceProduct and sourceProductFile must be removed from the list,
    // since they cannot be edited
    Property sourceProperty =
        this.propertySet.getProperty(ToolAdapterConstants.TOOL_SOURCE_PRODUCT_FILE);
    if (sourceProperty != null) {
      this.propertySet.removeProperty(sourceProperty);
    }
    sourceProperty = this.propertySet.getProperty(ToolAdapterConstants.TOOL_SOURCE_PRODUCT_ID);
    if (sourceProperty != null) {
      this.propertySet.removeProperty(sourceProperty);
    }
    // if the tool is handling by itself the output product name, then remove targetProductFile from
    // the list,
    // since it may bring only confusion in this case
    if (operatorDescriptor.isHandlingOutputName()) {
      sourceProperty = this.propertySet.getProperty(ToolAdapterConstants.TOOL_TARGET_PRODUCT_FILE);
      if (sourceProperty != null) {
        this.propertySet.removeProperty(sourceProperty);
      }
    }

    // initialise the target product's directory to the working directory
    final TargetProductSelectorModel targetProductSelectorModel = targetProductSelector.getModel();
    targetProductSelectorModel.setProductDir(
        operatorDescriptor.resolveVariables(operatorDescriptor.getWorkingDir()));

    ioParamPanel = createIOParamTab();
    addTab("I/O Parameters", ioParamPanel);
    JPanel processingParamPanel = new JPanel(new SpringLayout());
    checkDisplayOutput = new JCheckBox("Display execution output");
    processingParamPanel.add(checkDisplayOutput);
    processingParamPanel.add(createProcessingParamTab());
    SpringUtilities.makeCompactGrid(processingParamPanel, 2, 1, 2, 2, 2, 2);
    addTab("Processing Parameters", processingParamPanel);
    updateTargetProductFields();
  }