Package com._1c.g5.v8.dt.ui.util
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.Labeleris 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
CatalogsorForms. Clients canfilterunnecessary 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 ofLabelerare stateful and not safe for use by multiple threads. - Basic object label building, such as
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Labelerfilter(Predicate<Object> filter)Filter building label path elements with the given predicate.Stringlabel()Build path label.static Stringlabel(Object object)Returns basic label for a given object.static Labelerpath(Object object, char separator)Returns label builder for the given object and path separator.static Labelerpath(Object object, String separator)Returns label builder for the given object and path separator.LabelerskipCommonNode()Skip 1C:Enterprise Navigator "Common" node.LabelerstopAfter(Class<?> stopAfter)Stop label path bulding after path element will be instance of the given class.LabelerstopAfter(Class<?> stopAfter, int fromIndex)Stop label path bulding after path element will be instance of the given class.LabelerstopAfter(Predicate<Object> stopAfter)Stop label path bulding after path element will satisfy the given predicate.LabelerstopBefore(Class<?> stopBefore)Stop label path bulding when path element will be instance of the given class.LabelerstopBefore(Predicate<Object> stopBefore)Stop label path bulding when path element will satisfy the given predicate.
-
-
-
Method Detail
-
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 benull- 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 withlabel()method.Path will be constructed in the terms of 1C:Enterprise Navigator, including Navigator container nodes, such as
CatalogsorForms. Clients canfilterunnecessary nodes and elements or define stop elements and conditions.- Parameters:
object- the object to obtain path label for, cannot benullseparator- the path separator to use, cannot benull- 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 withlabel()method.Path will be constructed in the terms of 1C:Enterprise Navigator, including Navigator container nodes, such as
CatalogsorForms. Clients canfilterunnecessary nodes and elements or define stop elements and conditions.- Parameters:
object- the object to obtain path label for, cannot benullseparator- the path separator to use, cannot benull- Returns:
- the label builder, never
null
-
filter
public Labeler filter(Predicate<Object> filter)
Filter building label path elements with the given predicate. AllLabelerfilter predicates will be combined with "and" operation.- Parameters:
filter- the filter predicate to filter path elements, cannot benull- 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. AllLabelerstop-before predicates will be combined with "or" operation.- Parameters:
stopBefore- the predicate to stop bulding path before, cannot benull- 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. AllLabelerstop-before predicates will be combined with "or" operation.- Parameters:
stopBefore- the class to stop bulding path before, cannot benull- 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. AllLabelerstop-after predicates will be combined with "or" operation.- Parameters:
stopAfter- the predicate to stop bulding path after, cannot benull- 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. AllLabelerstop-after predicates will be combined with "or" operation.- Parameters:
stopAfter- the class to stop bulding path after, cannot benull- 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. AllLabelerstop-after predicates will be combined with "or" operation.- Parameters:
stopAfter- the class to stop bulding path after, cannot benullfromIndex- the index of the occurrence of thestopAfterto 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, nevernull
-
-