Class AbstractGotoEventHandlerHandler<T extends org.eclipse.emf.ecore.EObject>
- java.lang.Object
-
- org.eclipse.core.commands.common.EventManager
-
- org.eclipse.core.commands.AbstractHandler
-
- com._1c.g5.v8.dt.form.ui.commands.AbstractGotoEventHandlerHandler<T>
-
- Type Parameters:
T
- event owner class
- All Implemented Interfaces:
org.eclipse.core.commands.IHandler
,org.eclipse.core.commands.IHandler2
- Direct Known Subclasses:
GotoCommandEventHandlerHandler
,GotoEventHandlerHandler
public abstract class AbstractGotoEventHandlerHandler<T extends org.eclipse.emf.ecore.EObject> extends org.eclipse.core.commands.AbstractHandler
Abstract implementation of handler that checks existence of selected form element event handler and then selects and reveals it. If event handler does not exists, handler performs event handler creation.Subclasses must implement:
- How to extract event owner from selected form element.
- How to get and set event handler to it.
- How to generate handler name.
Form model
EObject
element selection is expected for handler execution.
-
-
Field Summary
Fields Modifier and Type Field Description protected IBmModelManager
bmModelManager
protected IBslModuleEventsLookup
moduleEventsLookup
-
Constructor Summary
Constructors Constructor Description AbstractGotoEventHandlerHandler()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Object
execute(org.eclipse.core.commands.ExecutionEvent event)
protected abstract T
extractEventOwner(org.eclipse.emf.ecore.EObject element, Form form, org.eclipse.core.commands.ExecutionEvent executionEvent)
Extracts event owner from given form element.protected abstract String
generateEventHandlerName(T eventOwner, org.eclipse.emf.ecore.EObject element, org.eclipse.core.commands.ExecutionEvent executionEvent)
GenerateseventOwner
event handler name.protected abstract Event
getCreatingEvent(org.eclipse.emf.ecore.EObject eventOwner, org.eclipse.core.commands.ExecutionEvent executionEvent, String handlerName)
Gets event for handler creation.protected IBmEditingContext
getEditingContext(ISelection selection, org.eclipse.emf.ecore.EObject element, org.eclipse.core.commands.ExecutionEvent event)
Returns the BM editing context from the provided to handler selection and execution event.protected abstract String
getEventHandlerName(T eventOwner, org.eclipse.emf.ecore.EObject element, org.eclipse.core.commands.ExecutionEvent executionEvent)
ReturnseventOwner
event handler name.protected Form
getForm(org.eclipse.emf.ecore.EObject element)
Returns owner form of the provided form element.protected String
getProcedureDirective(org.eclipse.swt.widgets.Shell shell, boolean isRussian, T eventOwner, org.eclipse.emf.ecore.EObject element, org.eclipse.core.commands.ExecutionEvent executionEvent)
Returns procedure directive for chosen event, or empty string if there is no procedure for creating event handler.protected boolean
isAllowedServerCall(T eventOwner, org.eclipse.emf.ecore.EObject element, org.eclipse.core.commands.ExecutionEvent executionEvent)
Returns whether creating event handler server call is allowed.protected boolean
isCommandHandler()
Returns whether creating event handler is command handler.protected boolean
isMainItem(T eventOwner, org.eclipse.emf.ecore.EObject element)
Returns whether creating event handler is for main item.protected String
openOrCreateEventHandler(org.eclipse.xtext.ui.editor.XtextEditor editor, T eventOwner, org.eclipse.emf.ecore.EObject element, org.eclipse.core.commands.ExecutionEvent executionEvent)
Navigates to event handler in form BSL module editor or create it before navigation.protected void
selectAndReveal(org.eclipse.jface.text.ITextSelection selection, org.eclipse.jface.text.ITextViewer viewer)
Selects and reveals the provided text selection on the provided text viewer.protected abstract void
setEventHandler(T eventOwner, String eventHandlerName, org.eclipse.core.commands.ExecutionEvent executionEvent)
SetseventOwner
event handler.protected boolean
shouldCreateEvent(org.eclipse.swt.widgets.Shell shell, String eventHandlerName)
Returns whether need to create event.-
Methods inherited from class org.eclipse.core.commands.AbstractHandler
addHandlerListener, dispose, fireHandlerChanged, hasListeners, isEnabled, isHandled, removeHandlerListener, setBaseEnabled, setEnabled
-
-
-
-
Field Detail
-
moduleEventsLookup
@Inject protected IBslModuleEventsLookup moduleEventsLookup
-
bmModelManager
@Inject protected IBmModelManager bmModelManager
-
-
Method Detail
-
execute
public Object execute(org.eclipse.core.commands.ExecutionEvent event) throws org.eclipse.core.commands.ExecutionException
- Throws:
org.eclipse.core.commands.ExecutionException
-
openOrCreateEventHandler
protected String openOrCreateEventHandler(org.eclipse.xtext.ui.editor.XtextEditor editor, T eventOwner, org.eclipse.emf.ecore.EObject element, org.eclipse.core.commands.ExecutionEvent executionEvent)
Navigates to event handler in form BSL module editor or create it before navigation. Returns handler name if handler was created during execution ornull
otherwise- Parameters:
editor
- the target Xtext editor to use for navigation, cannot benull
eventOwner
- the owner of event, cannot benull
element
- the currently selected form element, cannot benull
executionEvent
- the current execution event, cannot benull
- Returns:
- a handler name if handler was created during execution or
null
otherwise
-
getEditingContext
protected IBmEditingContext getEditingContext(ISelection selection, org.eclipse.emf.ecore.EObject element, org.eclipse.core.commands.ExecutionEvent event)
Returns the BM editing context from the provided to handler selection and execution event.- Parameters:
selection
- the provided to handler selection, cannot benull
element
- the selected form element, cannot benull
event
- the provided to handler execution event, cannot benull
- Returns:
- the BM editing context or
null
if none
-
getForm
protected Form getForm(org.eclipse.emf.ecore.EObject element)
Returns owner form of the provided form element.- Parameters:
element
- the selection element to get form for, cannot benull
- Returns:
- the owner form, never
null
-
getProcedureDirective
protected String getProcedureDirective(org.eclipse.swt.widgets.Shell shell, boolean isRussian, T eventOwner, org.eclipse.emf.ecore.EObject element, org.eclipse.core.commands.ExecutionEvent executionEvent)
Returns procedure directive for chosen event, or empty string if there is no procedure for creating event handler.Can return
null
if user cancelled event handler creation.- Parameters:
shell
- the parent shell to open question dialog on, cannot benull
isRussian
-true
if actual script variant is russian,false
otherwiseeventOwner
- the owner of event, cannot benull
element
- the currently selected form element, cannot benull
executionEvent
- the current execution event, cannot benull
- Returns:
- the procedure directive for chosen event, or empty string if there is no procedure for chosen event,
or
null
if user cancelled event handler creation
-
shouldCreateEvent
protected boolean shouldCreateEvent(org.eclipse.swt.widgets.Shell shell, String eventHandlerName)
Returns whether need to create event. Default impelementation returnstrue
, subclass may customize.- Parameters:
shell
- the parent shell to use for user interaction actions, cannot benull
eventHandlerName
- the event handler name, cannot benull
- Returns:
- whether need to create event
-
selectAndReveal
protected void selectAndReveal(org.eclipse.jface.text.ITextSelection selection, org.eclipse.jface.text.ITextViewer viewer)
Selects and reveals the provided text selection on the provided text viewer.- Parameters:
selection
- the text selection to reveal, cannot benull
viewer
- the target text viewer, cannot benull
-
isCommandHandler
protected boolean isCommandHandler()
Returns whether creating event handler is command handler.- Returns:
- whether creating event handler is command handler
-
isMainItem
protected boolean isMainItem(T eventOwner, org.eclipse.emf.ecore.EObject element)
Returns whether creating event handler is for main item.- Parameters:
eventOwner
- the owner of event, cannot benull
element
- the form element to extract event owner from, cannot benull
- Returns:
- whether creating event handler is for main item
-
isAllowedServerCall
protected boolean isAllowedServerCall(T eventOwner, org.eclipse.emf.ecore.EObject element, org.eclipse.core.commands.ExecutionEvent executionEvent)
Returns whether creating event handler server call is allowed.- Parameters:
eventOwner
- the owner of event, cannot benull
element
- the currently selected form element, cannot benull
executionEvent
- the current execution event, cannot benull
- Returns:
- whether creating event handler server call is allowed
-
getCreatingEvent
protected abstract Event getCreatingEvent(org.eclipse.emf.ecore.EObject eventOwner, org.eclipse.core.commands.ExecutionEvent executionEvent, String handlerName)
Gets event for handler creation.- Parameters:
eventOwner
- the owner of event, cannot benull
executionEvent
- the current execution event, cannot benull
handlerName
- the event handler name to create event with, cannot benull
- Returns:
- creating event, never
null
-
extractEventOwner
protected abstract T extractEventOwner(org.eclipse.emf.ecore.EObject element, Form form, org.eclipse.core.commands.ExecutionEvent executionEvent)
Extracts event owner from given form element.- Parameters:
element
- the form element to extract event owner from, cannot benull
form
- the owner form, cannot benull
executionEvent
- the current execution event, cannot benull
- Returns:
- the event owner, never
null
-
getEventHandlerName
protected abstract String getEventHandlerName(T eventOwner, org.eclipse.emf.ecore.EObject element, org.eclipse.core.commands.ExecutionEvent executionEvent)
ReturnseventOwner
event handler name. Can returnnull
if not provided.- Parameters:
eventOwner
- the owner of event, cannot benull
element
- the currently selected form element, cannot benull
executionEvent
- the current execution event, cannot benull
- Returns:
- the existing event handler name or
null
if none
-
generateEventHandlerName
protected abstract String generateEventHandlerName(T eventOwner, org.eclipse.emf.ecore.EObject element, org.eclipse.core.commands.ExecutionEvent executionEvent)
GenerateseventOwner
event handler name.- Parameters:
eventOwner
- the owner of event, cannot benull
element
- the currently selected form element, cannot benull
executionEvent
- the current execution event, cannot benull
- Returns:
- generated event handler name, never
null
-
setEventHandler
protected abstract void setEventHandler(T eventOwner, String eventHandlerName, org.eclipse.core.commands.ExecutionEvent executionEvent)
SetseventOwner
event handler.- Parameters:
eventOwner
- the owner of event, cannot benull
eventHandlerName
- the event handler name to set, cannot benull
executionEvent
- the current execution event, cannot benull
-
-