Class AbstractTreeElementType
java.lang.Object
com.amalgamasimulation.desktop.appelements.tree.AbstractTreeElementType
Type of a tree element: an icon, a name and whether the property panel has a page for it.
Each type created with a name is added to
values(), a list shared by all subclasses.
forObject(Object) searches this list for the type of an object by the predicate given
in the constructor.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanWhether the property panel has a page for this type.protected StringPath to the icon inside the bundle.protected StringName shown in the tree.Predicate thatmatches(Object)uses to check an object.protected static List<AbstractTreeElementType> All types created with a name, in order of creation. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a type without a name or icon and does not add it tovalues().protectedAbstractTreeElementType(String iconPath, String name, boolean existProperty) Creates a type and adds it tovalues().protectedAbstractTreeElementType(String iconPath, String name, boolean existProperty, Predicate<Object> suitableObject) Creates a type and adds it tovalues(). -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends AbstractTreeElementType>
TReturns the first type invalues()that the object matches, ornullif the object isnullor no type matches.Returns the path to the icon inside the bundle.Returns the icon URI for e4 model elements such as parts and menu items, or an empty string if the icon is not found.getName()Returns the name shown in the tree.booleanReturns whether the property panel has a page for this type.booleanReturns whether the object matches this type by the predicate given in the constructor.voidSets the name shown in the tree.toString()ReturnsgetName().static List<AbstractTreeElementType> values()Returns all types of all subclasses created with a name, in order of creation.
-
Field Details
-
iconPath
Path to the icon inside the bundle. -
name
Name shown in the tree. -
existProperty
protected boolean existPropertyWhether the property panel has a page for this type. -
suitableObject
Predicate thatmatches(Object)uses to check an object. -
values
All types created with a name, in order of creation.
-
-
Constructor Details
-
AbstractTreeElementType
protected AbstractTreeElementType()Creates a type without a name or icon and does not add it tovalues(). Subclasses that e4 creates only to run@PostConstructuse it. -
AbstractTreeElementType
Creates a type and adds it tovalues(). No object matches this type, soforObject(Object)never returns it.- Parameters:
iconPath- path to the icon inside the bundlename- name shown in the treeexistProperty- whether the property panel has a page for this type
-
AbstractTreeElementType
protected AbstractTreeElementType(String iconPath, String name, boolean existProperty, Predicate<Object> suitableObject) Creates a type and adds it tovalues().- Parameters:
iconPath- path to the icon inside the bundlename- name shown in the treeexistProperty- whether the property panel has a page for this typesuitableObject- predicate for objects of this type, notnull
-
-
Method Details
-
getIconPath
Returns the path to the icon inside the bundle.- Returns:
- the path to the icon inside the bundle
-
getIconURI
Returns the icon URI for e4 model elements such as parts and menu items, or an empty string if the icon is not found.- Returns:
- the icon URI, or an empty string
-
getName
Returns the name shown in the tree.- Returns:
- the name shown in the tree
-
setName
Sets the name shown in the tree.- Parameters:
name- the name shown in the tree
-
hasPropertyPage
public boolean hasPropertyPage()Returns whether the property panel has a page for this type. If not, selecting the element sends the type itself to the property panel.- Returns:
trueif the property panel has a page for this type
-
matches
Returns whether the object matches this type by the predicate given in the constructor.- Parameters:
object- the object to check- Returns:
trueif the object matches this type
-
values
Returns all types of all subclasses created with a name, in order of creation.- Returns:
- the shared list itself
-
forObject
Returns the first type invalues()that the object matches, ornullif the object isnullor no type matches.- Type Parameters:
T- expected type of the result- Parameters:
object- the object whose type is needed, may benull- Returns:
- the type of the object, or
null
-
toString
ReturnsgetName().
-