use of com.revolsys.identifier.Identifier in project com.revolsys.open by revolsys.
the class EpsgCoordinateSystems method getCodes.
@Override
public Map<Identifier, List<Object>> getCodes() {
if (this.codes == null) {
final Map<Identifier, List<Object>> codesById = new HashMap<>();
for (final CoordinateSystem coordinateSystem : coordinateSystems) {
final int coordinateSystemId = coordinateSystem.getCoordinateSystemId();
final Identifier id = Identifier.newIdentifier(coordinateSystemId);
final List<Object> code = Collections.singletonList(coordinateSystem);
codesById.put(id, code);
}
this.codes = codesById;
}
return this.codes;
}
use of com.revolsys.identifier.Identifier in project com.revolsys.open by revolsys.
the class EpsgCoordinateSystems method getIdentifiers.
@Override
public List<Identifier> getIdentifiers() {
if (this.identifiers == null) {
final List<Identifier> identifiers = new ArrayList<>();
for (final CoordinateSystem coordinateSystem : coordinateSystems) {
final int coordinateSystemId = coordinateSystem.getCoordinateSystemId();
final Identifier id = Identifier.newIdentifier(coordinateSystemId);
identifiers.add(id);
}
this.identifiers = Collections.unmodifiableList(identifiers);
}
return this.identifiers;
}
use of com.revolsys.identifier.Identifier in project com.revolsys.open by revolsys.
the class Record method isSame.
default boolean isSame(final Record record) {
if (record == null) {
return false;
} else {
if (this == record) {
return true;
} else {
synchronized (this) {
if (record.getRecordDefinition() == getRecordDefinition()) {
final Identifier id = getIdentifier();
final Identifier otherId = record.getIdentifier();
if (id == null || otherId == null) {
return false;
} else if (DataType.equal(id, otherId)) {
return true;
} else {
return false;
}
} else {
return false;
}
}
}
}
}
use of com.revolsys.identifier.Identifier in project com.revolsys.open by revolsys.
the class CodeTableValueComparator method compare.
@Override
public int compare(final Object object1, final Object object2) {
final Identifier identifier1 = Identifier.newIdentifier(object1);
final Identifier identifier2 = Identifier.newIdentifier(object2);
if (identifier1 == null) {
if (identifier2 == null) {
return 0;
} else {
return -1;
}
} else if (identifier2 == null) {
return 1;
} else if (identifier1.equals(identifier2)) {
return 0;
} else {
final Object value1 = this.codeTable.getValue(identifier1);
final Object value2 = this.codeTable.getValue(identifier2);
int compare = CompareUtil.compare(value1, value2);
if (compare == 0) {
compare = identifier1.compareTo(identifier2);
}
return compare;
}
}
use of com.revolsys.identifier.Identifier in project com.revolsys.open by revolsys.
the class SwingUtil method newComboBox.
static ComboBox<Identifier> newComboBox(final String fieldName, final CodeTable codeTable, final boolean required, final int maxLength, final boolean idSuffix) {
if (codeTable == null) {
return null;
} else {
final ComboBox<Identifier> comboBox = CodeTableComboBoxModel.newComboBox(fieldName, codeTable, !required, idSuffix);
if (comboBox.getModel().getSize() > 0) {
comboBox.setSelectedIndex(0);
}
int longestLength = -1;
for (final Entry<Identifier, List<Object>> codes : codeTable.getCodes().entrySet()) {
int length = 0;
if (idSuffix) {
final Identifier identifier = codes.getKey();
length += identifier.toString().length() + 3;
}
final List<Object> values = codes.getValue();
if (values != null && !values.isEmpty()) {
final String text = Strings.toString(values);
length += text.length();
}
if (length > longestLength) {
longestLength = length;
}
}
if (longestLength == -1) {
longestLength = 10;
}
if (maxLength > 0 && longestLength > maxLength) {
longestLength = maxLength;
}
final StringBuilder value = new StringBuilder();
for (int i = 0; i < longestLength; i++) {
value.append("W");
}
comboBox.setPrototypeDisplayValue(Identifier.newIdentifier(value));
final ComboBoxEditor editor = comboBox.getEditor();
final Component editorComponent = editor.getEditorComponent();
if (editorComponent instanceof JTextComponent) {
final JTextField textComponent = (JTextField) editorComponent;
textComponent.setColumns((int) (longestLength * 0.8));
final MenuFactory menu = MenuFactory.getPopupMenuFactory(textComponent);
MenuFactory.addToComponent(comboBox, menu);
} else {
MenuFactory.getPopupMenuFactory(comboBox);
}
return comboBox;
}
}
Aggregations