use of com.revolsys.swing.field.TextArea in project com.revolsys.open by revolsys.
the class FieldCalculator method initFieldPanel.
@Override
protected JPanel initFieldPanel() {
final FieldDefinition fieldDefinition = this.getFieldDefinition();
final String fieldName = fieldDefinition.getName();
final JPanel fieldPanel = new JPanel(new VerticalLayout());
final ToolBar toolBar = new ToolBar();
fieldPanel.add(toolBar);
this.expressionField = new TextArea("script", 8, 1);
fieldPanel.add(new JScrollPane(this.expressionField));
this.expressionField.getDocument().addDocumentListener(this);
final AbstractRecordLayer layer = getLayer();
final List<String> fieldNames = layer.getFieldNames();
final ComboBox<String> fieldNamesField = ComboBox.newComboBox("fieldNames", fieldNames, (final Object name) -> {
return layer.getFieldTitle((String) name);
});
toolBar.addComponent("fieldName", fieldNamesField);
toolBar.add(fieldNamesField);
fieldNamesField.setMaximumSize(new Dimension(250, 30));
final Runnable addFieldAction = () -> {
final String selectedFieldName = fieldNamesField.getFieldValue();
insertText(selectedFieldName);
};
toolBar.addButton("fieldName", "Add field name", "add", addFieldAction);
for (final String text : Arrays.asList("+", "-", "*", "/")) {
addTextButton("operators", toolBar, text, text);
}
addTextButton("condition", toolBar, "if", "if (expression) {\n newValue;\n} else {\n " + fieldName + ";\n}");
addTextButton("codeTable", toolBar, "Code ID", "codeId('codeFieldName', codeValue)");
addTextButton("codeTable", toolBar, "Code Value", "codeValue('codeFieldName', codeValue)");
return fieldPanel;
}
use of com.revolsys.swing.field.TextArea in project com.revolsys.open by revolsys.
the class FieldCalculator method initErrorsPanel.
@Override
protected JComponent initErrorsPanel() {
final Color background = new JPanel().getBackground();
this.errorsField = new TextArea("errors", 5, 1);
this.errorsField.setEditable(false);
this.errorsField.setForeground(WebColors.Red);
this.errorsField.setBackground(background);
final JScrollPane errorScroll = new JScrollPane(this.errorsField);
errorScroll.setBorder(BorderFactory.createTitledBorder("Errors"));
errorScroll.setBackground(background);
return errorScroll;
}
Aggregations