Package com._1c.g5.v8.dt.form.model.util
Class ModelUtils
- java.lang.Object
-
- com._1c.g5.v8.dt.form.model.util.ModelUtils
-
public class ModelUtils extends Object
Static utility methods to work with model.
-
-
Field Summary
Fields Modifier and Type Field Description static Comparator<FormCommandInterfaceItem>
COMMAND_INTERFACE_COMPARATOR
Compares theFormCommandInterfaceItem
objects usingindex
feature.
-
Constructor Summary
Constructors Constructor Description ModelUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addCommandHandler(FormCommand command, String handlerName, ExtendedMethodCallType callType)
Adds a command handler to the provided form command.static void
addEventHandler(EventHandler handler, List<EventHandler> handlers)
Adds the provided possibly new handler to the handler collection with respect to existing handlers with the same evet: if handlers collection already contains handler for the same event, it will be replaced with the provided handler.static Optional<CommandHandlerExtension>
findCommandHandler(FormCommand command, ExtendedMethodCallType callType)
Finds and returns a handler for the provided form command with the provided call type.static Optional<EventHandler>
findEventHanlder(Event event, Collection<EventHandler> handlers)
Finds and returns a handler for the provided event in the provided handler collection.static Optional<EventHandler>
findEventHanlder(String eventName, ExtendedMethodCallType callType, Collection<EventHandler> handlers)
Finds and returns a handler for the provided event in the provided handler collection.static Optional<EventHandler>
findEventHanlder(String eventName, Collection<EventHandler> handlers)
Finds and returns a handler for the provided event english name in the provided handler collection.static CommandGroupCategory
getCategory(CommandGroup group)
static FormStandardCommandSource
getCommandBarCommandSource(org.eclipse.emf.ecore.EObject object)
ObtainsFormStandardCommandSource
for command bars.static List<CommandHandler>
getCommandHandlers(FormCommand command)
Returns the command handler collection for the provided command.static ContextMenu
getContextMenu(FormVisualEntity item)
static ExtendedTooltip
getExtendedTooltip(FormVisualEntity item)
Gets theExtendedTooltip
Is defined forFormGroup
,FormField
,Button
,Table
,Decoration
,Addition
; otherwise.static List<FormItem>
getFormItemChildItems(FormVisualEntity parent)
Gets the list of the children FormItem.static CommandGroup
getGroup(FormCommandInterfaceItem record)
Gets the command group of the specifiedFormCommandInterfaceItem
.
ReturnsFormCommandInterfaceItem.getGroup()
if notnull
, otherwise -- TODO: Not implemented --static Collection<CommandGroup>
getMdCommandGroups(Configuration configuration, CommandGroupCategory category)
Filters the configuration command groups usingcategory
.static EventHandler
newEventHandler(String name, Event event)
Creates and returns the new form event handler with the provided handler name.static EventHandlerExtension
newEventHandler(String name, Event event, ExtendedMethodCallType callType)
Creates and returns the new form extension event handler with the provided handler name and method call type.static void
setCommandHandler(FormCommand command, String handlerName)
Sets the new form command handler with the provided handler name.
-
-
-
Field Detail
-
COMMAND_INTERFACE_COMPARATOR
public static final Comparator<FormCommandInterfaceItem> COMMAND_INTERFACE_COMPARATOR
Compares theFormCommandInterfaceItem
objects usingindex
feature.- See Also:
Comparator
-
-
Method Detail
-
newEventHandler
public static EventHandler newEventHandler(String name, Event event)
Creates and returns the new form event handler with the provided handler name.- Parameters:
name
- the name of the form event handler, cannot benull
event
- the event to create handler for, cannot benull
- Returns:
- the new form event handler with the provided name, never
null
-
newEventHandler
public static EventHandlerExtension newEventHandler(String name, Event event, ExtendedMethodCallType callType)
Creates and returns the new form extension event handler with the provided handler name and method call type.- Parameters:
name
- the name of the form event handler, cannot benull
event
- the event to create handler for, cannot benull
callType
- the method call type, cannot benull
- Returns:
- the new form event whandler ith the provided name and method call type, never
null
-
findEventHanlder
public static Optional<EventHandler> findEventHanlder(String eventName, Collection<EventHandler> handlers)
Finds and returns a handler for the provided event english name in the provided handler collection. If there are more than one handler for the provided event then result will be unpredictable.- Parameters:
eventName
- the event english name to find handler for, cannot benull
handlers
- the handler collection to find in, cannot benull
- Returns:
- a handler for the provided event in the provided handler collection, never
null
-
findEventHanlder
public static Optional<EventHandler> findEventHanlder(Event event, Collection<EventHandler> handlers)
Finds and returns a handler for the provided event in the provided handler collection. If there are more than one handler for the provided event then result will be unpredictable.- Parameters:
event
- the event to find handler for, cannot benull
handlers
- the handler collection to find in, cannot benull
- Returns:
- a handler for the provided event in the provided handler collection, never
null
-
findEventHanlder
public static Optional<EventHandler> findEventHanlder(String eventName, ExtendedMethodCallType callType, Collection<EventHandler> handlers)
Finds and returns a handler for the provided event in the provided handler collection. If there are more than one handler for the provided event and call type then result will be unpredictable.- Parameters:
eventName
- the event english name to find handler for, cannot benull
callType
- the method call type, cannot benull
handlers
- the handler collection to find in, cannot benull
- Returns:
- a handler for the provided event in the provided handler collection, never
null
-
addEventHandler
public static void addEventHandler(EventHandler handler, List<EventHandler> handlers)
Adds the provided possibly new handler to the handler collection with respect to existing handlers with the same evet: if handlers collection already contains handler for the same event, it will be replaced with the provided handler.- Parameters:
handler
- the handler to add, cannot benull
handlers
- the collection to add to, cannot benull
-
setCommandHandler
public static void setCommandHandler(FormCommand command, String handlerName)
Sets the new form command handler with the provided handler name.- Parameters:
command
- the form command to set handler for, cannot benull
handlerName
- the name of the form command handler, cannot benull
-
getCommandHandlers
public static List<CommandHandler> getCommandHandlers(FormCommand command)
Returns the command handler collection for the provided command.- Parameters:
command
- the form command to get handler collection for, cannot benull
- Returns:
- the command handler collection for the provided command, never
null
-
findCommandHandler
public static Optional<CommandHandlerExtension> findCommandHandler(FormCommand command, ExtendedMethodCallType callType)
Finds and returns a handler for the provided form command with the provided call type. If there are more than one handler for the provided command and call type then result will be unpredictable.- Parameters:
command
- the form command to find handler for, cannot benull
callType
- the method call type, cannot benull
- Returns:
- a handler for the provided command with the provided call type, never
null
-
addCommandHandler
public static void addCommandHandler(FormCommand command, String handlerName, ExtendedMethodCallType callType)
Adds a command handler to the provided form command.- Parameters:
command
- the form command to add handler for, cannot benull
handlerName
- the handler name to add, cannot benull
callType
- the method call type, cannot benull
-
getFormItemChildItems
public static List<FormItem> getFormItemChildItems(FormVisualEntity parent)
Gets the list of the children FormItem. Is defined forGroup
,Table
,MainItem
; Empty list otherwise.- Parameters:
parent
- a parentFormItem
- Returns:
- a list of the children FormItem.
-
getCategory
public static CommandGroupCategory getCategory(CommandGroup group)
- Parameters:
group
- a owner- Returns:
- a
CommandGroupCategory
-
getContextMenu
public static ContextMenu getContextMenu(FormVisualEntity item)
- Parameters:
item
- a owner- Returns:
- a
ContextMenu
-
getExtendedTooltip
public static ExtendedTooltip getExtendedTooltip(FormVisualEntity item)
Gets theExtendedTooltip
Is defined forFormGroup
,FormField
,Button
,Table
,Decoration
,Addition
; otherwise.- Parameters:
item
- a owner- Returns:
- a
ExtendedTooltip
-
getGroup
public static CommandGroup getGroup(FormCommandInterfaceItem record)
Gets the command group of the specifiedFormCommandInterfaceItem
.
ReturnsFormCommandInterfaceItem.getGroup()
if notnull
, otherwise -- TODO: Not implemented --- Parameters:
record
- - a FormCommandInterfaceItem instance- Returns:
- - a command group of the specified
FormCommandInterfaceItem
.
-
getMdCommandGroups
public static Collection<CommandGroup> getMdCommandGroups(Configuration configuration, CommandGroupCategory category)
Filters the configuration command groups usingcategory
.- Parameters:
configuration
- - a command groups providercategory
- - a filter- Returns:
- a filtered command groups collection
-
getCommandBarCommandSource
public static FormStandardCommandSource getCommandBarCommandSource(org.eclipse.emf.ecore.EObject object)
ObtainsFormStandardCommandSource
for command bars.- Parameters:
object
-FormGroup
with typeManagedFormGroupType.COMMAND_BAR
orAutoCommandBar
.- Returns:
FormStandardCommandSource
for command bar ornull
if no command source available.
-
-