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
WorkAreaTabContextMenu
is an extension point for plugging in your own actions.
The WorkAreaTabContextMenu
is a Studio IOC context provider (see
Section 7.8, “Customizing Studio using Component IoC”). However, instead of accessing the provided
context variables directly via Studio IOC 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:workAreaTabContextMenu> <plugins> <ui:addItemsPlugin> <ui:items> <menuseparator/> <menuitem> <baseAction> <custom:checkInAllContentTabsAction text="Check in all contents"/> </baseAction> </menuitem> </ui:items> </ui:addItemsPlugin> </plugins> </editor:workAreaTabContextMenu> ... </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; } }