public static void addPromptSupport(JComponent component, Property property) { addPromptSupport(component, property, null); }
public static JTextField addTextField(JPanel parent, TextFieldEditor textEditor, String labelText, PropertyContainer propertyContainer, BindingContext bindingContext, String propertyName, boolean isRequired) { parent.add(new JLabel(labelText)); PropertyDescriptor propertyDescriptor = propertyContainer.getDescriptor(propertyName); if (isRequired) { propertyDescriptor.setValidator(new NotEmptyValidator()); } JComponent editorComponent = textEditor.createEditorComponent(propertyDescriptor, bindingContext); UIUtils.addPromptSupport(editorComponent, "enter " + labelText.toLowerCase().replace(":", "") + " here"); UIUtils.enableUndoRedo(editorComponent); parent.add(editorComponent); return (JTextField) editorComponent; }
JComponent addValidatedTextField(JPanel parent, TextFieldEditor textEditor, String labelText, String propertyName, String validatorRegex) { if(validatorRegex == null || validatorRegex.isEmpty()){ return addTextField(parent, textEditor, labelText, propertyName, false, null); } else { JLabel jLabel = new JLabel(labelText); parent.add(jLabel); PropertyDescriptor propertyDescriptor = propertyContainer.getDescriptor(propertyName); propertyDescriptor.setValidator(new PatternValidator(Pattern.compile(validatorRegex))); JComponent editorComponent = textEditor.createEditorComponent(propertyDescriptor, bindingContext); UIUtils.addPromptSupport(editorComponent, "enter " + labelText.toLowerCase().replace(":", "") + " here"); editorComponent.setPreferredSize(new Dimension(editorComponent.getPreferredSize().width, controlHeight)); editorComponent.setMaximumSize(new Dimension(editorComponent.getMaximumSize().width, controlHeight)); jLabel.setLabelFor(editorComponent); parent.add(editorComponent); return editorComponent; } }
JComponent addTextField(JPanel parent, TextFieldEditor textEditor, String labelText, String propertyName, boolean isRequired, String[] excludedChars) { JLabel jLabel = new JLabel(labelText); Dimension size = jLabel.getPreferredSize(); parent.add(jLabel); PropertyDescriptor propertyDescriptor = propertyContainer.getDescriptor(propertyName); if (isRequired) { propertyDescriptor.setValidator(new DecoratedNotEmptyValidator(jLabel, excludedChars)); jLabel.setMaximumSize(new Dimension(size.width + 20, size.height)); } JComponent editorComponent = textEditor.createEditorComponent(propertyDescriptor, bindingContext); UIUtils.addPromptSupport(editorComponent, "enter " + labelText.toLowerCase().replace(":", "") + " here"); UIUtils.enableUndoRedo(editorComponent); editorComponent.setPreferredSize(new Dimension(editorComponent.getPreferredSize().width, controlHeight)); editorComponent.setMaximumSize(new Dimension(editorComponent.getMaximumSize().width, controlHeight)); jLabel.setLabelFor(editorComponent); parent.add(editorComponent); return editorComponent; }
outFileName.setPreferredSize( new Dimension(filePathComponent.getPreferredSize().width + label.getPreferredSize().width - jLabel.getPreferredSize().width, 25)); org.esa.snap.utils.UIUtils.addPromptSupport(outFileName, "Enter the name of transformed file here"); outFilePanel.add(outFileName); topPanel.add(outFilePanel, BorderLayout.WEST);
for (Property property : propertyContainer.getProperties()) { Arrays.stream(parametersPane.getBindingContext().getBinding(property.getName()).getComponents()) .forEach(c -> UIUtils.addPromptSupport(c, property)); if (this.annotatedFields.containsKey(property.getName())) { Optional<Annotation> annotation = Arrays.stream(this.annotatedFields.get(property.getName()))