private void addParameters() { final PropertySet propertySet = parameterSupport.getPropertySet(); final List<SourceProductSelector> sourceProductSelectorList = ioParametersPanel.getSourceProductSelectorList();
private void initialize(ToolAdapterOperatorDescriptor descriptor) { //this.operatorDescriptor = new ToolAdapterOperatorDescriptor(descriptor); this.operatorDescriptor = descriptor; //add paraeters of template parameters artificiallyAddedParams = new ArrayList<>(); Arrays.stream(this.operatorDescriptor.getToolParameterDescriptors().toArray()).filter(p -> ((ToolParameterDescriptor)p).isTemplateParameter()). forEach(p -> artificiallyAddedParams.addAll(((TemplateParameterDescriptor)p).getParameterDescriptors())); this.operatorDescriptor.getToolParameterDescriptors().addAll(artificiallyAddedParams); this.parameterSupport = new OperatorParameterSupport(this.operatorDescriptor); Arrays.stream(this.operatorDescriptor.getToolParameterDescriptors().toArray()). filter(p -> ToolAdapterConstants.FOLDER_PARAM_MASK.equals(((ToolParameterDescriptor)p).getParameterType())). forEach(p -> parameterSupport.getPropertySet().getProperty(((ToolParameterDescriptor)p).getName()).getDescriptor().setAttribute("directory", true)); form = new ToolExecutionForm(appContext, this.operatorDescriptor, parameterSupport.getPropertySet(), getTargetProductSelector()); OperatorMenu operatorMenu = new OperatorMenu(this.getJDialog(), this.operatorDescriptor, parameterSupport, appContext, descriptor.getHelpID() != null ? descriptor.getHelpID() : helpID); getJDialog().setJMenuBar(operatorMenu.createDefaultMenu()); EscapeAction.register(getJDialog()); this.getJDialog().addWindowListener(new WindowAdapter() { public void windowOpened(WindowEvent e) {form.refreshDimension();} }); this.getJDialog().addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent e) {form.refreshDimension();} }); this.getJDialog().setMinimumSize(new Dimension(250, 250)); }
final PropertySet propertySet = parameterSupport.getPropertySet(); bindingContext = new BindingContext(propertySet);
final PropertySet propertySet = parameterSupport.getPropertySet(); bindingContext = new BindingContext(propertySet);
@Override public JComponent CreateOpTab(String operatorName, Map<String, Object> parameterMap, AppContext appContext) { OperatorSpi operatorSpi = GPF.getDefaultInstance().getOperatorSpiRegistry().getOperatorSpi(operatorName); if (operatorSpi == null) { throw new IllegalArgumentException("No SPI found for operator name '" + operatorName + "'"); } operatorDescriptor = operatorSpi.getOperatorDescriptor(); parameterSupport = new OperatorParameterSupport(operatorDescriptor); final PropertySet propertySet = parameterSupport.getPropertySet(); bindingContext = new BindingContext(propertySet); if (sourceProducts != null) { for (Band band : sourceProducts[0].getBands()) { listBands.add(band.getName()); } } initializeOperatorUI(operatorName, parameterMap); final JComponent panel = createPanel(); initParameters(); return new JScrollPane(panel); }
public ForestCoverChangeTargetProductDialog(String operatorName, AppContext appContext, String title, String helpID) { super(appContext, title, ID_APPLY_CLOSE, helpID); this.operatorName = operatorName; this.targetProductNameSuffix = ""; final TargetProductSelector selector = getTargetProductSelector(); selector.getModel().setSaveToFileSelected(false); selector.getSaveToFileCheckBox().setEnabled(true); processAnnotationsRec(ForestCoverChangeOp.class); this.operatorDescriptor = new OperatorDescriptorClass( this.parameterDescriptors.toArray(new ParameterDescriptor[0]), this.sourceProductDescriptors.toArray(new SourceProductDescriptor[0])); this.ioParametersPanel = new DefaultIOParametersPanel(getAppContext(), this.operatorDescriptor, getTargetProductSelector(), true); this.parameterSupport = new OperatorParameterSupport(this.operatorDescriptor); ArrayList<SourceProductSelector> sourceProductSelectorList = this.ioParametersPanel.getSourceProductSelectorList(); PropertySet propertySet = this.parameterSupport.getPropertySet(); this.bindingContext = new BindingContext(propertySet); SelectionChangeListener currentListenerProduct = new SelectionChangeListener() { public void selectionChanged(SelectionChangeEvent event) { Product product = sourceProductSelectorList.get(CURRENT_PRODUCT).getSelectedProduct(); if (product != null) { updateTargetProductName(product); } } public void selectionContextChanged(SelectionChangeEvent event) { } }; sourceProductSelectorList.get(CURRENT_PRODUCT).addSelectionChangeListener(currentListenerProduct); }
public CollocationDialog(AppContext appContext) { super(appContext, "Collocation", ID_APPLY_CLOSE, HELP_ID); final OperatorSpi operatorSpi = GPF.getDefaultInstance().getOperatorSpiRegistry().getOperatorSpi(CollocateOp.Spi.class.getName()); parameterSupport = new OperatorParameterSupport(operatorSpi.getOperatorDescriptor()); OperatorMenu operatorMenu = new OperatorMenu(this.getJDialog(), operatorSpi.getOperatorDescriptor(), parameterSupport, appContext, HELP_ID); getJDialog().setJMenuBar(operatorMenu.createDefaultMenu()); form = new CollocationForm(parameterSupport.getPropertySet(), getTargetProductSelector(), appContext); }
public SpectralUnmixingDialog(AppContext appContext) { super(appContext, TITLE, ID_APPLY_CLOSE, HELP_ID); ParameterUpdater parameterUpdater = new ParameterUpdater() { @Override public void handleParameterSaveRequest(Map<String, Object> parameterMap) { updateParameterMap(parameterMap); } @Override public void handleParameterLoadRequest(Map<String, Object> parameterMap) { updateEndmemberFormModel(parameterMap); } }; final OperatorSpi operatorSpi = GPF.getDefaultInstance().getOperatorSpiRegistry().getOperatorSpi(SpectralUnmixingOp.Spi.class.getName()); parameterSupport = new OperatorParameterSupport(operatorSpi.getOperatorDescriptor(), null, null, parameterUpdater); form = new SpectralUnmixingForm(appContext, parameterSupport.getPropertySet(), getTargetProductSelector()); OperatorMenu operatorMenu = new OperatorMenu(this.getJDialog(), operatorSpi.getOperatorDescriptor(), parameterSupport, appContext, HELP_ID); getJDialog().setJMenuBar(operatorMenu.createDefaultMenu()); }
@Test public void testStoreAndLoadParameterWhenNotAllParamsAreGiven() throws IOException, ValidationException, ConversionException { final OperatorParameterSupport support = new OperatorParameterSupport(new TestOpSpi().getOperatorDescriptor()); PropertySet container = support.getPropertySet(); container.setValue("paramDouble", 0.42); final DomElement domElement = support.toDomElement(); // change container container.setValue("paramDouble", 23.67); container.setValue("paramString", "Another String"); container.setValue("paramComplex", new Complex(17)); support.fromDomElement(domElement); assertEquals(0.42, (double)support.getPropertySet().getValue("paramDouble"), 1.0e-6); assertEquals(null, support.getPropertySet().getValue("paramString")); assertEquals(null, support.getPropertySet().getValue("paramComplex")); }
PropertySet propertySet = new OperatorParameterSupport(operator).getPropertySet();
for (Property property : parameterSupport.getPropertySet().getProperties()) { op.setParameter(property.getName(), property.getValue());
final PropertySet propertySet = parameterSupport.getPropertySet(); bindingContext = new BindingContext(propertySet); final Property referenceBandNameProperty = bindingContext.getPropertySet().getProperty(REFERENCE_BAND_NAME_PROPERTY_NAME);
@Test public void testStoreAndLoadParameter() throws IOException, ValidationException, ConversionException { final OperatorParameterSupport support = new OperatorParameterSupport(new TestOpSpi().getOperatorDescriptor()); PropertySet container = support.getPropertySet(); container.setValue("paramDouble", 0.42); container.setValue("paramString", "A String!"); container.setValue("paramComplex", new Complex(25)); final DomElement domElement = support.toDomElement(); assertEquals("parameters", domElement.getName()); assertEquals(3, domElement.getChildCount()); assertNotNull(domElement.getChild("paramDouble")); assertEquals("0.42", domElement.getChild("paramDouble").getValue()); assertNotNull(domElement.getChild("paramString")); assertEquals("A String!", domElement.getChild("paramString").getValue()); assertNotNull(domElement.getChild("paramComplex")); assertNotNull(domElement.getChild("paramComplex").getChild("complexInt")); assertEquals("25", domElement.getChild("paramComplex").getChild("complexInt").getValue()); // change container container.setValue("paramDouble", 23.67); container.setValue("paramString", "Another String"); container.setValue("paramComplex", new Complex(17)); support.fromDomElement(domElement); assertEquals(0.42, (double)support.getPropertySet().getValue("paramDouble"), 1.0e-6); assertEquals("A String!", support.getPropertySet().getValue("paramString")); assertEquals(new Complex(25), support.getPropertySet().getValue("paramComplex")); }