close

Filter

loading table of contents...

Studio Developer Manual / Version 2304

Table Of Contents

9.17.6 Customizing the Work Area Tab Context Menu

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<any> 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.

import Config from "@jangaroo/runtime/Config";
import StudioPlugin from "@coremedia/studio-client.main.editor-components/configuration/StudioPlugin";
import WorkAreaTabProxiesContextMenu from "@coremedia/studio-client.main.editor-components/sdk/desktop/reusability/WorkAreaTabProxiesContextMenu";
import AddItemsPlugin from "@coremedia/studio-client.ext.ui-components/plugins/AddItemsPlugin";
import Separator from "@jangaroo/ext-ts/toolbar/Separator";
import Item from "@jangaroo/ext-ts/menu/Item";
import CheckInAllContentTabsAction from "./CheckInAllContentTabsAction";

Config(StudioPlugin, {
  rules: [
    //...
    Config(WorkAreaTabProxiesContextMenu, {
      plugins: [
        Config(AddItemsPlugin, {
          items: [
            Config(Separator),
            Config(Item, {
              baseAction: new CheckInAllContentTabsAction({
                text: "Check in all contents",
              }),
            }),
          ],
        }),
      ],
    }),
    //...
  ]
});
import Config from "@jangaroo/runtime/Config";
import Content from "@coremedia/studio-client.cap-rest-client/content/Content";
import AbstractTabContextMenuContentAction from "./AbstractTabContextMenuContentAction";

class CheckInAllContentTabsAction extends AbstractTabContextMenuContentAction {
  constructor(config: Config<AbstractTabContextMenuContentAction>) {
    super(config);
    this.setHandler(this.#doCheckin, this);
  }

  #doCheckin():void {
    this.getContextClickedContents()
      .forEach((content:Content) => {
      if (content.isCheckedOutByCurrentSession()) {
        content.checkIn();
      }
    });
  }

  protected override checkDisabled():boolean {
    var atLeastOneContentTabInEditMode:Boolean = false;
    this.getContextClickedContents()
      .forEach((content:Content) => {
      if (content.isCheckedOutByCurrentSession()) {
        atLeastOneContentTabInEditMode = true;
      }
    });
    return !atLeastOneContentTabInEditMode;
  }
}

export default CheckInAllContentTabsAction;

Search Results

Table Of Contents
warning

Your Internet Explorer is no longer supported.

Please use Mozilla Firefox, Google Chrome, or Microsoft Edge.