package org.argeo.util.directory;
import java.util.Dictionary;
+import java.util.Locale;
/** A unit within the high-level organisational structure of a directory. */
public interface HierarchyUnit {
/** Name to use in paths. */
String getHierarchyUnitName();
+ /** Name to use in UI. */
+ String getHierarchyUnitLabel(Locale locale);
+
/**
* The parent {@link HierarchyUnit}, or <code>null</code> if a
* {@link Directory}.
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.List;
+import java.util.Locale;
import java.util.Optional;
import java.util.StringJoiner;
return getName();
}
+ @Override
+ public String getHierarchyUnitLabel(Locale locale) {
+ String key = LdapNameUtils.getLastRdn(getBaseDn()).getType();
+ Object value = LdapEntry.getLocalized(asLdapEntry().getProperties(), key, locale);
+ if (value == null)
+ value = getHierarchyUnitName();
+ assert value != null;
+ return value.toString();
+ }
+
@Override
public HierarchyUnit getParent() {
return null;
// private Attributes publishedAttributes;
// Temporarily expose the fields
- protected AttributeDictionary properties;
- protected AttributeDictionary credentials;
+ private AttributeDictionary properties;
+ private AttributeDictionary credentials;
protected DefaultLdapEntry(AbstractLdapDirectory directory, LdapName dn) {
Objects.requireNonNull(directory);
import java.util.Collection;
import java.util.Dictionary;
import java.util.List;
+import java.util.Locale;
import java.util.Set;
import java.util.StringJoiner;
import java.util.TreeSet;
currentObjectClasses.forEach((s) -> values.add(s));
properties.put(LdapAttrs.objectClasses.name(), values.toString());
}
+
+ public static Object getLocalized(Dictionary<String, Object> properties, String key, Locale locale) {
+ if (locale == null)
+ return null;
+ Object value = null;
+ value = properties.get(key + ";lang-" + locale.getLanguage() + "-" + locale.getCountry());
+ if (value == null)
+ value = properties.get(key + ";lang-" + locale.getLanguage());
+ return value;
+ }
}
package org.argeo.util.directory.ldap;
+import java.util.Locale;
+
import javax.naming.ldap.LdapName;
import javax.naming.ldap.Rdn;
return name;
}
+ @Override
+ public String getHierarchyUnitLabel(Locale locale) {
+ String key = LdapNameUtils.getLastRdn(getDn()).getType();
+ Object value = LdapEntry.getLocalized(getProperties(), key, locale);
+ if (value == null)
+ value = getHierarchyUnitName();
+ assert value != null;
+ return value.toString();
+ }
+
@Override
public String getBase() {
return getDn().toString();
import org.argeo.cms.CmsMsg;
import org.argeo.cms.swt.Selected;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
return messageLbl;
}
+ protected Point getInitialSize() {
+ if (exception != null)
+ return new Point(800, 600);
+ else
+ return new Point(600, 400);
+ }
+
protected void append(String message) {
stack.append(message);
stack.append("\n");
}
protected Point getInitialSize() {
- // if (exception != null)
- // return new Point(800, 600);
- // else
return new Point(600, 400);
}