C# Class SIL.FieldWorks.XWorks.DTMenuHandler

DTMenuHandler provides context menus to the data tree. When the user (or test code) selects issues commands, this class also invokes the corresponding methods on the data tree. You may create subclasses to do smart things with menus.
Although XWorks doesn't sound Flex-specific, most of the menu commands handled in this file are specific to Flex.
Inheritance: IxCoreColleague
Show file Open project: sillsdev/FieldWorks Class Usage Examples

Protected Properties

Property Type Description
m_configuration System.Xml.XmlNode
m_dataEntryForm SIL.FieldWorks.Common.Framework.DetailControls.DataTree
m_mediator XCore.Mediator

Public Methods

Method Description
Create ( DataTree dataEntryForm, XmlNode configuration ) : DTMenuHandler

factory method which creates the correct subclass based on the XML parameters

Init ( XCore.Mediator mediator, XmlNode configurationParameters ) : void
OnConvertEntryIntoComplexForm ( object argument ) : bool

OnConvertEntryIntoVariant ( object argument ) : bool

OnDataTreeCopy ( object cmd ) : bool

This method is called when a user selects a Copy operation in on a slice.

OnDataTreeDelete ( object cmd ) : bool

This method is called when a user selects a Delete operation for a slice. The menu item is defined in DataTreeInclude.xml with message="DataTreeDelete"

OnDataTreeHelp ( object cmd ) : bool
OnDataTreeInsert ( object cmd ) : bool

This method is called when a user selects an Insert operation in on a slice.

OnDeleteMediaFile ( object cmd ) : bool
OnDisplayConvertEntryIntoComplexForm ( object commandObject, XCore.UIItemDisplayProperties &display ) : bool

Allow only one complex form type LexEntryRef object per LexEntry.

OnDisplayConvertEntryIntoVariant ( object commandObject, XCore.UIItemDisplayProperties &display ) : bool

Allow any number of variant type LexEntryRef objects per LexEntry.

OnDisplayDataTreeCopy ( object commandObject, XCore.UIItemDisplayProperties &display ) : bool

decide whether to display this tree copy Menu Item

OnDisplayDataTreeHelp ( object cmd, XCore.UIItemDisplayProperties display ) : bool
OnDisplayDataTreeInsert ( object commandObject, XCore.UIItemDisplayProperties &display ) : bool

decide whether to display this tree insert Menu Item

OnDisplayDeleteMediaFile ( object commandObject, XCore.UIItemDisplayProperties &display ) : bool

Check whether or not to display the "Delete This Media Link" command.

OnDisplayInsertMediaFile ( object commandObject, XCore.UIItemDisplayProperties &display ) : bool

Check whether or not to display the "Insert Sound or Movie" command.

OnDisplayInsertPicture ( object commandObject, XCore.UIItemDisplayProperties &display ) : bool

Determine whether we can insert a picture here.

OnInsertMediaFile ( object cmd ) : bool

Called by reflection based on menu item InsertSoundFile.

OnInsertPicture ( object cmd ) : bool

Called by reflection based on menu item InsertPicture.

OnLaunchGuiControl ( object commandObject ) : bool

Launch a control dynamically from the control pointed to by the 'guicontrol' id in the command object.

Protected Methods

Method Description
CanInsert ( Command command, Slice currentSlice, int &index ) : bool

Check to see if the insertion command makes sense for the current slice and its ContainingDataTree.

CanInsertFieldIntoObj ( SIL.FieldWorks.FDO.FdoCache fdoCache, string fieldName, ICmObject parentObj, int &index ) : bool

Check if the field can be inserted into the given object.

DTMenuHandler ( ) : System
ExtractInsertCommandInfo ( Command command, string &fieldName, string &className ) : void

Get the class name and field for the given insertion command.

MakeSliceContextMenu ( Slice slice, bool fHotLinkOnly ) : ContextMenu

Private Methods

Method Description
AddNewLexEntryRef ( object argument, int flidTypes ) : bool
CanInsertPictureOrMediaFile ( object cmd, int &flid ) : bool
ComponentShowsComplexForm ( ICmObject component, ILexEntry cplxForm, ILexEntryRef &cfRef ) : bool

Does this component show this complex form in the dictionary? The component can be a ILexEntry or a ILexSense. The reference to the complex form from the component is outted.

DeleteObject ( Command command ) : bool
DisplayConvertLexEntry ( object commandObject ) : bool
ExtractInsertCommandParameters ( Command command ) : XmlNode
GetFlidIfPossible ( int clid, string fieldName, IFwMetaDataCacheManaged mdc ) : int

This seems a bit clumsy, but the metadata cache now throws an exception if the class id/field name pair isn't valid for GetFieldId2(). So we check first in cases where we want a zero if not found.

GetMessageTargets ( ) : IxCoreColleague[]
GetSelectedComplexFormHvo ( Slice complexFormsSlice ) : int

Intended to get a selected complex form, but it can probably get other selections from entries or senses.

GetSelectedComponentHvo ( ) : int
GetSelectionHvoFromControls ( Slice slice ) : int

Gets the selection HVO from a slice control.

InsertMediaFile ( object cmd, string filter, string keyCaption, string defaultCaption ) : bool
OnAddComponentToPrimary ( object argument ) : bool
OnDataTreeAddReference ( object cmd ) : bool
OnDataTreeDeleteReference ( object cmd ) : bool
OnDataTreeEdit ( object cmd ) : bool
OnDataTreeMerge ( object cmd ) : bool
OnDataTreeSplit ( object cmd ) : bool
OnDisplayAddComponentToPrimary ( object commandObject, XCore.UIItemDisplayProperties &display ) : bool
OnDisplayDataTreeDelete ( object commandObject, XCore.UIItemDisplayProperties &display ) : bool
OnDisplayDataTreeDeleteReference ( object commandObject, XCore.UIItemDisplayProperties &display ) : bool
OnDisplayDataTreeEdit ( object commandObject, XCore.UIItemDisplayProperties &display ) : bool
OnDisplayDataTreeMerge ( object commandObject, XCore.UIItemDisplayProperties &display ) : bool
OnDisplayDataTreeSplit ( object commandObject, XCore.UIItemDisplayProperties &display ) : bool
OnDisplayMoveDownObjectInSequence ( object commandObject, XCore.UIItemDisplayProperties &display ) : bool
OnDisplayMoveUpObjectInSequence ( object commandObject, XCore.UIItemDisplayProperties &display ) : bool
OnDisplayVisibleComplexForm ( object commandObject, XCore.UIItemDisplayProperties &display ) : bool
OnMoveDownObjectInSequence ( object cmd ) : bool
OnMoveUpObjectInSequence ( object cmd ) : bool
OnVisibleComplexForm ( object argument ) : bool
ShowContextMenu2Id ( XmlNode caller, bool fHotLinkOnly ) : string
ShowSliceContextMenu ( object sender, SliceMenuRequestArgs e ) : ContextMenu
SliceConfiguredForField ( XmlNode node, string field ) : bool

Method Details

CanInsert() protected method

Check to see if the insertion command makes sense for the current slice and its ContainingDataTree.
protected CanInsert ( Command command, Slice currentSlice, int &index ) : bool
command Command insertion command
currentSlice Slice current selected slice on the ContainingDataTree
index int 0-based position for insert, if known, or -1
return bool

CanInsertFieldIntoObj() protected method

Check if the field can be inserted into the given object.
protected CanInsertFieldIntoObj ( SIL.FieldWorks.FDO.FdoCache fdoCache, string fieldName, ICmObject parentObj, int &index ) : bool
fdoCache SIL.FieldWorks.FDO.FdoCache
fieldName string name of the field to be inserted
parentObj ICmObject The object where the item would be inserted, if possible.
index int index (0-based) where it will be inserted. -1 if atomic or returns false
return bool

Create() public static method

factory method which creates the correct subclass based on the XML parameters
public static Create ( DataTree dataEntryForm, XmlNode configuration ) : DTMenuHandler
dataEntryForm SIL.FieldWorks.Common.Framework.DetailControls.DataTree
configuration System.Xml.XmlNode
return DTMenuHandler

DTMenuHandler() protected method

protected DTMenuHandler ( ) : System
return System

ExtractInsertCommandInfo() static protected method

Get the class name and field for the given insertion command.
static protected ExtractInsertCommandInfo ( Command command, string &fieldName, string &className ) : void
command Command insertion command
fieldName string
className string
return void

Init() public method

public Init ( XCore.Mediator mediator, XmlNode configurationParameters ) : void
mediator XCore.Mediator
configurationParameters System.Xml.XmlNode
return void

MakeSliceContextMenu() protected method

protected MakeSliceContextMenu ( Slice slice, bool fHotLinkOnly ) : ContextMenu
slice Slice
fHotLinkOnly bool
return System.Windows.Forms.ContextMenu

OnConvertEntryIntoComplexForm() public method

public OnConvertEntryIntoComplexForm ( object argument ) : bool
argument object
return bool

OnConvertEntryIntoVariant() public method

public OnConvertEntryIntoVariant ( object argument ) : bool
argument object
return bool

OnDataTreeCopy() public method

This method is called when a user selects a Copy operation in on a slice.
public OnDataTreeCopy ( object cmd ) : bool
cmd object
return bool

OnDataTreeDelete() public method

This method is called when a user selects a Delete operation for a slice. The menu item is defined in DataTreeInclude.xml with message="DataTreeDelete"
public OnDataTreeDelete ( object cmd ) : bool
cmd object
return bool

OnDataTreeHelp() public method

public OnDataTreeHelp ( object cmd ) : bool
cmd object
return bool

OnDataTreeInsert() public method

This method is called when a user selects an Insert operation in on a slice.
public OnDataTreeInsert ( object cmd ) : bool
cmd object
return bool

OnDeleteMediaFile() public method

public OnDeleteMediaFile ( object cmd ) : bool
cmd object
return bool

OnDisplayConvertEntryIntoComplexForm() public method

Allow only one complex form type LexEntryRef object per LexEntry.
public OnDisplayConvertEntryIntoComplexForm ( object commandObject, XCore.UIItemDisplayProperties &display ) : bool
commandObject object
display XCore.UIItemDisplayProperties
return bool

OnDisplayConvertEntryIntoVariant() public method

Allow any number of variant type LexEntryRef objects per LexEntry.
public OnDisplayConvertEntryIntoVariant ( object commandObject, XCore.UIItemDisplayProperties &display ) : bool
commandObject object
display XCore.UIItemDisplayProperties
return bool

OnDisplayDataTreeCopy() public method

decide whether to display this tree copy Menu Item
public OnDisplayDataTreeCopy ( object commandObject, XCore.UIItemDisplayProperties &display ) : bool
commandObject object
display XCore.UIItemDisplayProperties
return bool

OnDisplayDataTreeHelp() public method

public OnDisplayDataTreeHelp ( object cmd, XCore.UIItemDisplayProperties display ) : bool
cmd object
display XCore.UIItemDisplayProperties
return bool

OnDisplayDataTreeInsert() public method

decide whether to display this tree insert Menu Item
public OnDisplayDataTreeInsert ( object commandObject, XCore.UIItemDisplayProperties &display ) : bool
commandObject object
display XCore.UIItemDisplayProperties
return bool

OnDisplayDeleteMediaFile() public method

Check whether or not to display the "Delete This Media Link" command.
public OnDisplayDeleteMediaFile ( object commandObject, XCore.UIItemDisplayProperties &display ) : bool
commandObject object
display XCore.UIItemDisplayProperties
return bool

OnDisplayInsertMediaFile() public method

Check whether or not to display the "Insert Sound or Movie" command.
public OnDisplayInsertMediaFile ( object commandObject, XCore.UIItemDisplayProperties &display ) : bool
commandObject object
display XCore.UIItemDisplayProperties
return bool

OnDisplayInsertPicture() public method

Determine whether we can insert a picture here.
public OnDisplayInsertPicture ( object commandObject, XCore.UIItemDisplayProperties &display ) : bool
commandObject object
display XCore.UIItemDisplayProperties
return bool

OnInsertMediaFile() public method

Called by reflection based on menu item InsertSoundFile.
public OnInsertMediaFile ( object cmd ) : bool
cmd object
return bool

OnInsertPicture() public method

Called by reflection based on menu item InsertPicture.
public OnInsertPicture ( object cmd ) : bool
cmd object
return bool

OnLaunchGuiControl() public method

Launch a control dynamically from the control pointed to by the 'guicontrol' id in the command object.
public OnLaunchGuiControl ( object commandObject ) : bool
commandObject object
return bool

Property Details

m_configuration protected property

COnfiguration information.
protected XmlNode,System.Xml m_configuration
return System.Xml.XmlNode

m_dataEntryForm protected property

Tree form.
protected DataTree,SIL.FieldWorks.Common.Framework.DetailControls m_dataEntryForm
return SIL.FieldWorks.Common.Framework.DetailControls.DataTree

m_mediator protected property

Mediator that passes off messages.
protected Mediator,XCore m_mediator
return XCore.Mediator