Class Labeler

java.lang.Object
com._1c.g5.v8.dt.ui.util.Labeler

public class Labeler extends Object
Support class to build UI-representable labels for metadata objects or metadata object features. Supports:
  • Basic object label building, such as Catalog.
  • Path object label building, such as Catalogs.Catalog1.Forms.Form1. Labeler is aware of current DT IDE locale and produce nodes with appropriate language.

Path will be constructed in the terms of 1C:Enterprise Navigator, including Navigator container nodes, such as Catalogs or Forms. Clients can filter unnecessary nodes and elements or define stop elements and conditions.

Example of usage:

 String pathLabel = Labeler.path(form, '.').skipCommonNode().stopBefore(IProject.class)
     .stopBefore(Configuration.class).label();
 // pathLabel will be like "Catalogs.Catalog1.Forms.Form1"

 String basicLabel = Labeler.label(form);
 // basicLabel will be like "Form1"
 
Instances of of Labeler are stateful and not safe for use by multiple threads.
  • Method Details

    • label

      public static String label(Object object)
      Returns basic label for a given object. Supports metadata objects, metadata object features or 1C:Enterprise Navigator nodes.
      Parameters:
      object - the object to obtain label for, cannot be null
      Returns:
      obtained label or empty string if object has no label, never null
    • path

      public static Labeler path(Object object, char separator)
      Returns label builder for the given object and path separator. Clients can configure label builder and build label with label() method.

      Path will be constructed in the terms of 1C:Enterprise Navigator, including Navigator container nodes, such as Catalogs or Forms. Clients can filter unnecessary nodes and elements or define stop elements and conditions.

      Parameters:
      object - the object to obtain path label for, cannot be null
      separator - the path separator to use, cannot be null
      Returns:
      the label builder, never null
    • path

      public static Labeler path(Object object, String separator)
      Returns label builder for the given object and path separator. Clients can configure label builder and build label with label() method.

      Path will be constructed in the terms of 1C:Enterprise Navigator, including Navigator container nodes, such as Catalogs or Forms. Clients can filter unnecessary nodes and elements or define stop elements and conditions.

      Parameters:
      object - the object to obtain path label for, cannot be null
      separator - the path separator to use, cannot be null
      Returns:
      the label builder, never null
    • filter

      public Labeler filter(Predicate<Object> filter)
      Filter building label path elements with the given predicate. All Labeler filter predicates will be combined with "and" operation.
      Parameters:
      filter - the filter predicate to filter path elements, cannot be null
      Returns:
      a reference to this label builder, never null
    • stopBefore

      public Labeler stopBefore(Predicate<Object> stopBefore)
      Stop label path bulding when path element will satisfy the given predicate. All Labeler stop-before predicates will be combined with "or" operation.
      Parameters:
      stopBefore - the predicate to stop bulding path before, cannot be null
      Returns:
      a reference to this label builder, never null
    • stopBefore

      public Labeler stopBefore(Class<?> stopBefore)
      Stop label path bulding when path element will be instance of the given class. All Labeler stop-before predicates will be combined with "or" operation.
      Parameters:
      stopBefore - the class to stop bulding path before, cannot be null
      Returns:
      a reference to this label builder, never null
    • stopAfter

      public Labeler stopAfter(Predicate<Object> stopAfter)
      Stop label path bulding after path element will satisfy the given predicate. All Labeler stop-after predicates will be combined with "or" operation.
      Parameters:
      stopAfter - the predicate to stop bulding path after, cannot be null
      Returns:
      a reference to this label builder, never null
    • stopAfter

      public Labeler stopAfter(Class<?> stopAfter)
      Stop label path bulding after path element will be instance of the given class. All Labeler stop-after predicates will be combined with "or" operation.
      Parameters:
      stopAfter - the class to stop bulding path after, cannot be null
      Returns:
      a reference to this label builder, never null
    • stopAfter

      public Labeler stopAfter(Class<?> stopAfter, int fromIndex)
      Stop label path bulding after path element will be instance of the given class. All Labeler stop-after predicates will be combined with "or" operation.
      Parameters:
      stopAfter - the class to stop bulding path after, cannot be null
      fromIndex - the index of the occurrence of the stopAfter to use to stop, must be positive
      Returns:
      a reference to this label builder, never null
    • skipCommonNode

      public Labeler skipCommonNode()
      Skip 1C:Enterprise Navigator "Common" node.
      Returns:
      a reference to this label builder, never null
    • label

      public String label()
      Build path label. Result may be used in UI representation.
      Returns:
      the path label as String, never null