Skip to content

Commit

Permalink
Formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
dkocher committed Dec 22, 2024
1 parent faff1e9 commit 4c94d76
Showing 1 changed file with 53 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,11 @@ public abstract class BrowserTableDataSource extends ProxyController implements
private final IconCache<NSImage> icons = IconCacheFactory.get();
private final FileDescriptor descriptor = FileDescriptorFactory.get();
private final Preferences preferences = PreferencesFactory.get();
private final LRUCache<Item, NSAttributedString> attributed = LRUCache.build(preferences.getInteger("browser.model.cache.size")
private final LRUCache<Item, NSAttributedString> attributed = LRUCache.build(
preferences.getInteger("browser.model.cache.size")
);
private final LRUCache<Path, AttributedList<Path>> filtered = LRUCache.build(preferences.getInteger("browser.model.cache.size")
private final LRUCache<Path, AttributedList<Path>> filtered = LRUCache.build(
preferences.getInteger("browser.model.cache.size")
);
protected final BrowserController controller;
protected final Cache<Path> cache;
Expand Down Expand Up @@ -225,52 +227,87 @@ protected NSObject objectValueForItem(final Path item, final String identifier)
}
log.trace("Lookup failed for {} in cache", key);
if(identifier.equals(BrowserColumn.filename.name())) {
value = NSAttributedString.attributedStringWithAttributes(item.getName(), TableCellAttributes.browserFontLeftAlignment());
value = NSAttributedString.attributedStringWithAttributes(
item.getName(),
TableCellAttributes.browserFontLeftAlignment());
}
else if(identifier.equals(BrowserColumn.size.name())) {
value = NSAttributedString.attributedStringWithAttributes(sizeFormatter.format(item.attributes().getSize()), TableCellAttributes.browserFontRightAlignment());
value = NSAttributedString.attributedStringWithAttributes(
sizeFormatter.format(item.attributes().getSize()),
TableCellAttributes.browserFontRightAlignment());
}
else if(identifier.equals(BrowserColumn.modified.name())) {
value = NSAttributedString.attributedStringWithAttributes(dateFormatter.getShortFormat(item.attributes().getModificationDate(), preferences.getBoolean("browser.date.natural")), TableCellAttributes.browserFontLeftAlignment()
value = NSAttributedString.attributedStringWithAttributes(
dateFormatter.getShortFormat(item.attributes().getModificationDate(),
preferences.getBoolean("browser.date.natural")),
TableCellAttributes.browserFontLeftAlignment()
);
}
else if(identifier.equals(BrowserColumn.owner.name())) {
value = NSAttributedString.attributedStringWithAttributes(StringUtils.isBlank(item.attributes().getOwner()) ? LocaleFactory.localizedString("Unknown") : item.attributes().getOwner(), TableCellAttributes.browserFontLeftAlignment());
value = NSAttributedString.attributedStringWithAttributes(
StringUtils.isBlank(item.attributes().getOwner()) ?
LocaleFactory.localizedString("Unknown") : item.attributes().getOwner(),
TableCellAttributes.browserFontLeftAlignment());
}
else if(identifier.equals(BrowserColumn.group.name())) {
value = NSAttributedString.attributedStringWithAttributes(StringUtils.isBlank(item.attributes().getGroup()) ? LocaleFactory.localizedString("Unknown") : item.attributes().getGroup(), TableCellAttributes.browserFontLeftAlignment());
value = NSAttributedString.attributedStringWithAttributes(
StringUtils.isBlank(item.attributes().getGroup()) ?
LocaleFactory.localizedString("Unknown") : item.attributes().getGroup(),
TableCellAttributes.browserFontLeftAlignment());
}
else if(identifier.equals(BrowserColumn.permission.name())) {
final Acl acl = item.attributes().getAcl();
if(!Acl.EMPTY.equals(acl)) {
final StringBuilder s = new StringBuilder();
for(Map.Entry<Acl.User, Set<Acl.Role>> entry : acl.entrySet()) {
s.append(String.format("%s%s:%s", s.length() == 0 ? StringUtils.EMPTY : ", ", entry.getKey().getDisplayName(), entry.getValue()));
s.append(String.format("%s%s:%s", s.length() == 0 ? StringUtils.EMPTY : ", ",
entry.getKey().getDisplayName(), entry.getValue()));
}
value = NSAttributedString.attributedStringWithAttributes(s.toString(), TableCellAttributes.browserFontLeftAlignment());
value = NSAttributedString.attributedStringWithAttributes(s.toString(),
TableCellAttributes.browserFontLeftAlignment());
}
else {
final Permission permission = item.attributes().getPermission();
value = NSAttributedString.attributedStringWithAttributes(permission.toString(), TableCellAttributes.browserFontLeftAlignment());
value = NSAttributedString.attributedStringWithAttributes(
permission.toString(),
TableCellAttributes.browserFontLeftAlignment());
}
}
else if(identifier.equals(BrowserColumn.kind.name())) {
value = NSAttributedString.attributedStringWithAttributes(descriptor.getKind(item), TableCellAttributes.browserFontLeftAlignment());
value = NSAttributedString.attributedStringWithAttributes(
descriptor.getKind(item),
TableCellAttributes.browserFontLeftAlignment());
}
else if(identifier.equals(BrowserColumn.extension.name())) {
value = NSAttributedString.attributedStringWithAttributes(item.isFile() ? StringUtils.isNotBlank(item.getExtension()) ? item.getExtension() : LocaleFactory.localizedString("None") : LocaleFactory.localizedString("None"), TableCellAttributes.browserFontLeftAlignment());
value = NSAttributedString.attributedStringWithAttributes(
item.isFile() ? StringUtils.isNotBlank(item.getExtension()) ? item.getExtension() :
LocaleFactory.localizedString("None") : LocaleFactory.localizedString("None"),
TableCellAttributes.browserFontLeftAlignment());
}
else if(identifier.equals(BrowserColumn.region.name())) {
value = NSAttributedString.attributedStringWithAttributes(StringUtils.isNotBlank(item.attributes().getRegion()) ? item.attributes().getRegion() : LocaleFactory.localizedString("Unknown"), TableCellAttributes.browserFontLeftAlignment());
value = NSAttributedString.attributedStringWithAttributes(
StringUtils.isNotBlank(item.attributes().getRegion()) ? item.attributes().getRegion() :
LocaleFactory.localizedString("Unknown"),
TableCellAttributes.browserFontLeftAlignment());
}
else if(identifier.equals(BrowserColumn.version.name())) {
value = NSAttributedString.attributedStringWithAttributes(StringUtils.isNotBlank(item.attributes().getVersionId()) ? item.attributes().getVersionId() : LocaleFactory.localizedString("None"), TableCellAttributes.browserFontLeftAlignment());
value = NSAttributedString.attributedStringWithAttributes(
StringUtils.isNotBlank(item.attributes().getVersionId()) ? item.attributes().getVersionId() :
LocaleFactory.localizedString("None"),
TableCellAttributes.browserFontLeftAlignment());
}
else if(identifier.equals(BrowserColumn.checksum.name())) {
value = NSAttributedString.attributedStringWithAttributes(!Checksum.NONE.equals(item.attributes().getChecksum()) ? item.attributes().getChecksum().hash : StringUtils.isNotBlank(item.attributes().getETag()) ? item.attributes().getETag() : LocaleFactory.localizedString("None"), TableCellAttributes.browserFontLeftAlignment());
value = NSAttributedString.attributedStringWithAttributes(
!Checksum.NONE.equals(item.attributes().getChecksum()) ? item.attributes().getChecksum().hash :
StringUtils.isNotBlank(item.attributes().getETag()) ? item.attributes().getETag() : LocaleFactory.localizedString("None"),
TableCellAttributes.browserFontLeftAlignment());
}
else if(identifier.equals(BrowserColumn.storageclass.name())) {
value = NSAttributedString.attributedStringWithAttributes(StringUtils.isNotBlank(item.attributes().getStorageClass()) ? LocaleFactory.localizedString(item.attributes().getStorageClass(), "S3") : LocaleFactory.localizedString("None"), TableCellAttributes.browserFontLeftAlignment());
value = NSAttributedString.attributedStringWithAttributes(
StringUtils.isNotBlank(item.attributes().getStorageClass()) ?
LocaleFactory.localizedString(item.attributes().getStorageClass(), "S3") :
LocaleFactory.localizedString("None"),
TableCellAttributes.browserFontLeftAlignment());
}
else {
throw new IllegalArgumentException(String.format("Unknown identifier %s", identifier));
Expand Down

0 comments on commit 4c94d76

Please sign in to comment.