Package com._1c.g5.v8.dt.form.service
Class FormIdentifierService
- java.lang.Object
-
- com._1c.g5.v8.dt.form.service.FormIdentifierService
-
public class FormIdentifierService extends Object
ThisFormIdentifierService
calculates the available id for aFormItem
.
-
-
Field Summary
Fields Modifier and Type Field Description static FormIdentifierService
INSTANCE
FormIdentifierService
instance.
-
Constructor Summary
Constructors Constructor Description FormIdentifierService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description OptionalInt
calculateNewIdFor(FormItem item)
Calculates new identifier for the specified form item.void
clearCaches(IBmObject form)
Clears form id caches.int
getNextAttributeId(Form form)
The method generate a next form attribute id inForm
int
getNextCommandId(Form form)
The method generate a next form command id inForm
int
getNextItemId(Form form)
The method generate a next form item id inForm
boolean
hasValidId(FormItem item)
Checks whether specified form item has a valid identifier.
-
-
-
Field Detail
-
INSTANCE
public static final FormIdentifierService INSTANCE
FormIdentifierService
instance.
-
-
Method Detail
-
clearCaches
public void clearCaches(IBmObject form)
Clears form id caches.- Parameters:
form
- the form for clearing id caches, cannot benull
-
getNextItemId
public int getNextItemId(Form form)
The method generate a next form item id inForm
- Parameters:
form
- the form for get next id- Returns:
- return next an item identifier
-
getNextAttributeId
public int getNextAttributeId(Form form)
The method generate a next form attribute id inForm
- Parameters:
form
- the form for get next id- Returns:
- return next an attribte identifier
-
getNextCommandId
public int getNextCommandId(Form form)
The method generate a next form command id inForm
- Parameters:
form
- the form for get next id- Returns:
- return next an command identifier
-
hasValidId
public boolean hasValidId(FormItem item)
Checks whether specified form item has a valid identifier.FormItem.getId()
is considered to be invalid if its value is0
which is a default value forEObject.eGet(EStructuralFeature, boolean)
in case ofInteger
feature.- Negative values are not considered to be invalid. That is because such values are perfectly valid
at least for some of the cases. For example,
AutoCommandBar
might have-1
as in identifier. This can be seen in the implementation ofcom._1c.g5.v8.dt.internal.form.generator.FormGeneratorCore
. - This method does not check identifier correctness in relation with other form items. For example, all form items identifiers on a form must be unique across this form regarless of how deep they are nested. However, this method checks just the specified form item and does not try to verify if there are other form items with the same identifier.
- Parameters:
item
- Form item whose identifier is to be checked. Must not benull
.- Returns:
true
if specified item has a valid identifier.
-
calculateNewIdFor
public OptionalInt calculateNewIdFor(FormItem item)
Calculates new identifier for the specified form item. Generally,getNextItemId(Form)
is used to obtain next identifier. However, some form items have special rules for identifiers. For example,com._1c.g5.v8.dt.internal.form.generator.FormGeneratorCore
creates new forms withAutoCommandBar
that has identifier of-1
. We try to do the same here.- Parameters:
item
- Form item that needs new identifier. Most not benull
.- Returns:
- New value of identifier for the specified item or an empty holder if
unable to determine proper new identifier value (for example, if cannot determine top object
or top object is not a
Form
). - See Also:
IBmObject.bmGetTopObject()
-
-