@Override public void buildPanel(final InputPanel<P, W> inputPanel, final Module module) throws ModuleException { final Iterable<ModuleItem<?>> inputs = module.getInfo().inputs(); final ArrayList<WidgetModel> models = new ArrayList<>(); for (final ModuleItem<?> item : inputs) { final WidgetModel model = addInput(inputPanel, module, item); if (model != null) models.add(model); } // mark all models as initialized for (final WidgetModel model : models) model.setInitialized(true); // compute initial preview module.preview(); }
@Override public void buildPanel(final InputPanel<P, W> inputPanel, final Module module) throws ModuleException { final Iterable<ModuleItem<?>> inputs = module.getInfo().inputs(); final ArrayList<WidgetModel> models = new ArrayList<>(); for (final ModuleItem<?> item : inputs) { final WidgetModel model = addInput(inputPanel, module, item); if (model != null) models.add(model); } // mark all models as initialized for (final WidgetModel model : models) model.setInitialized(true); // compute initial preview module.preview(); }
@Override public void setValue(final Object value) { final String name = item.getName(); if (Objects.equals(item.getValue(module), value)) return; // no change // Check if a converted value is present Object convertedInput = convertedObjects.get(value); if (convertedInput != null && Objects.equals(item.getValue(module), convertedInput)) { return; // no change } // Pass the value through the convertService convertedInput = convertService.convert(value, item.getType()); // If we get a different (converted) value back, cache it weakly. if (convertedInput != value) { convertedObjects.put(value, convertedInput); } module.setInput(name, convertedInput); if (initialized) { threadService.queue(() -> { callback(); inputPanel.refresh(); // must be on AWT thread? module.preview(); }); } }
@Override public void setValue(final Object value) { final String name = item.getName(); if (Objects.equals(item.getValue(module), value)) return; // no change // Check if a converted value is present Object convertedInput = convertedObjects.get(value); if (convertedInput != null && Objects.equals(item.getValue(module), convertedInput)) { return; // no change } // Pass the value through the convertService convertedInput = convertService.convert(value, item.getType()); // If we get a different (converted) value back, cache it weakly. if (convertedInput != value) { convertedObjects.put(value, convertedInput); } module.setInput(name, convertedInput); if (initialized) { threadService.queue(() -> { callback(); inputPanel.refresh(); // must be on AWT thread? module.preview(); }); } }