Studio Developer Manual / Version 2107
Table Of Contents
The context menu for work area tabs comes with several predefined actions like close
operations and options for checking in or reverting contents. In addition, the
WorkAreaTabProxiesContextMenu
is an extension point for plugging in your own actions.
It is recommended to
implement your custom actions as subclasses of AbstractTabContextMenuAction
or
AbstractTabContextMenuContentAction
. In both cases, the context-clicked tab and
tab panel can be accessed via the methods getContextClickedTab():Panel
and
getContextClickedTabPanel():TabPanel
respectively. In addition,
AbstractTabContextMenuContentAction
provides the methods
getContextClickedContent():Content
and
getContextClickedContents():Array
for obtaining the content of the
context-clicked tab and all contents of work area tabs respectively. Note that only
Premular
tabs have content other than undefined
.
Using these methods, subclasses should override the method
checkDisabled():Boolean
to decide whether the action should be disabled. In
addition, these methods should suffice to provide enough information to implement the action's
behavior.
For example, the following two code samples show how to add an action for checking in all contents of opened work area tabs.
<ui:rules> ... <editor:WorkAreaTabProxiesContextMenu> <editor:plugins> <ui:AddItemsPlugin> <ui:items> <MenuSeparator/> <MenuItem> <baseAction> <custom:CheckInAllContentTabsAction text="Check in all contents"/> </baseAction> </MenuItem> </ui:items> </ui:AddItemsPlugin> </editor:plugins> </editor:WorkAreaTabProxiesContextMenu> ... </ui:rules>
public class CheckInAllContentTabsAction extends AbstractTabContextMenuContentAction { ... private function handler():void { getContextClickedContents(). forEach(function (content:Content):void { if (content.isCheckedOutByCurrentSession()) { content.checkIn(); } } } } override protected function checkDisable():Boolean { var atLeastOneContentTabInEditMode:Boolean = false; getContextClickedContents(). forEach(function (content:Content):void { if (content.isCheckedOutByCurrentSession()) { atLeastOneContentTabInEditMode = true; } }); return !atLeastOneContentTabInEditMode; } }