use of com.revolsys.record.Record in project com.revolsys.open by revolsys.
the class AbstractRecordQueryField method queryDo.
protected void queryDo(final int searchIndex, final String queryText) {
if (searchIndex == this.searchIndex.get()) {
Record selectedRecord = null;
final Map<String, Record> allRecords = new TreeMap<>();
for (Query query : this.queries) {
if (allRecords.size() < this.maxResults) {
query = //
query.clone().addOrderBy(this.displayField);
final Condition whereCondition = query.getWhereCondition();
if (whereCondition instanceof BinaryCondition) {
final BinaryCondition binaryCondition = (BinaryCondition) whereCondition;
if (binaryCondition.getOperator().equalsIgnoreCase("like")) {
final String likeString = "%" + queryText.toUpperCase().replaceAll("[^A-Z0-9 ]", "%") + "%";
Q.setValue(0, binaryCondition, likeString);
} else {
Q.setValue(0, binaryCondition, queryText);
}
}
query.setLimit(this.maxResults);
final List<Record> records = getRecords(query);
for (final Record record : records) {
if (allRecords.size() < this.maxResults) {
final String key = record.getString(this.displayField);
if (!allRecords.containsKey(key)) {
if (queryText.equals(key)) {
selectedRecord = record;
}
allRecords.put(key, record);
}
}
}
}
}
setSearchResults(searchIndex, allRecords.values(), selectedRecord);
}
}
use of com.revolsys.record.Record in project com.revolsys.open by revolsys.
the class AbstractRecordQueryField method valueChanged.
@Override
public void valueChanged(final ListSelectionEvent e) {
if (!e.getValueIsAdjusting() && this.eventsEnabled.isTrue()) {
try (final BaseCloseable eventsEnabled = eventsDisabled()) {
final Record record = (Record) this.list.getSelectedValue();
if (record != null) {
setSelectedRecord(record);
final Identifier identifier = record.getIdentifier();
final String label = record.getString(this.displayField);
this.idToDisplayMap.put(identifier, label);
if (!DataType.equal(label, this.searchField.getText())) {
this.searchField.setFieldValue(label);
}
super.setFieldValue(identifier);
}
this.menu.setVisible(false);
this.searchField.requestFocus();
}
}
}
use of com.revolsys.record.Record in project com.revolsys.open by revolsys.
the class LayerRecordForm method propertyChange.
@Override
public void propertyChange(final PropertyChangeEvent event) {
final String propertyName = event.getPropertyName();
final AbstractRecordLayer layer = getLayer();
if (layer != null) {
final LayerRecord record = getRecord();
if (record != null) {
final RecordState state = record.getState();
if (!state.equals(RecordState.DELETED)) {
final Object source = event.getSource();
if (this.geometryCoordinatesPanel != null && source == this.geometryCoordinatesPanel.getTable().getModel()) {
if (propertyName.equals("geometry")) {
record.setGeometryValue((Geometry) event.getNewValue());
}
} else if (source == layer) {
if (AbstractRecordLayer.RECORDS_CHANGED.equals(propertyName)) {
setRecord(record);
} else if (AbstractRecordLayer.RECORDS_DELETED.equals(propertyName)) {
@SuppressWarnings("unchecked") final List<Record> deletedRecords = (List<Record>) event.getNewValue();
if (layer.isDeleted(record) || record.contains(deletedRecords)) {
final Window window = SwingUtilities.getWindowAncestor(this);
SwingUtil.setVisible(window, false);
setRecord(record);
return;
}
} else if (AbstractRecordLayer.RECORD_UPDATED.equals(propertyName)) {
if (record.isDeleted()) {
final Window window = SwingUtilities.getWindowAncestor(this);
SwingUtil.setVisible(window, false);
setRecord(record);
}
} else if ("editable".equals(propertyName)) {
setEditable(layer.isEditable());
}
} else if (source instanceof Field) {
final Field field = (Field) source;
final String fieldName = field.getFieldName();
final Object fieldValue = field.getFieldValue();
final Object recordValue = this.record.getValue(fieldName);
if (!DataType.equal(recordValue, fieldValue)) {
boolean equal = false;
if (fieldValue instanceof String) {
final String string = (String) fieldValue;
if (!Property.hasValue(string) && recordValue == null) {
equal = true;
}
}
if (!equal && layer.isEditable() && (state == RecordState.NEW && layer.isCanAddRecords() || layer.isCanEditRecords())) {
record.setValueByPath(fieldName, fieldValue);
}
}
} else {
if (isSame(source)) {
if (getRecordDefinition().getIdFieldNames().contains(propertyName)) {
Invoke.later(() -> {
final String title = getTitle(record);
final BaseDialog dialog = (BaseDialog) SwingUtil.getWindowAncestor(this);
if (dialog != null) {
dialog.setTitle(title);
}
});
}
if (record.isDeleted()) {
final Window window = SwingUtilities.getWindowAncestor(this);
SwingUtil.setVisible(window, false);
} else if (Record.EVENT_RECORD_CHANGED.equals(propertyName)) {
setValues(record);
return;
}
final Object value = event.getNewValue();
final RecordDefinition recordDefinition = getRecordDefinition();
if ("qaMessagesUpdated".equals(propertyName)) {
updateErrors();
} else if (recordDefinition.hasField(propertyName)) {
setFieldValue(propertyName, value, isFieldValidationEnabled());
}
fireButtonPropertyChanges();
repaint();
}
}
}
}
}
}
use of com.revolsys.record.Record in project com.revolsys.open by revolsys.
the class AbstractRecordLayerRenderer method setQueryFilter.
public void setQueryFilter(final String query) {
if (this.filter instanceof RecordDefinitionSqlFilter || this.filter == Predicates.<Record>all()) {
Predicate<Record> filter;
if (Property.hasValue(query)) {
filter = new RecordDefinitionSqlFilter(this, query);
} else {
filter = Predicates.all();
}
setFilter(filter);
}
}
use of com.revolsys.record.Record in project com.revolsys.open by revolsys.
the class MergedNullValuePredicate method isHighlighted.
@Override
public boolean isHighlighted(final Component renderer, final ComponentAdapter adapter) {
try {
final int rowIndex = adapter.convertRowIndexToView(adapter.row);
final int columnIndex = adapter.convertColumnIndexToView(adapter.column);
final Record object = this.model.getRecord(rowIndex);
final Record mergedObject = this.model.getMergedRecord();
if (object != mergedObject) {
final String fieldName = this.model.getColumnFieldName(columnIndex);
final Object value = object.getValue(fieldName);
final Object mergedValue = mergedObject.getValue(fieldName);
if (value == null && mergedValue != null) {
return true;
}
}
} catch (final IndexOutOfBoundsException e) {
}
return false;
}
Aggregations