@lumino/widgets#ContextMenu TypeScript Examples

The following examples show how to use @lumino/widgets#ContextMenu. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: reactWidget.tsx    From ipyflex with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
constructor(props: IProps) {
    super(props);

    this.innerlayoutRef = {};
    this.layoutConfig = props.model.get('layout_config') as ILayoutConfig;

    const { defaultOuterModel, defaultModel } = defaultModelFactoty(
      this.layoutConfig,
      props.editable
    );

    let template_json = props.model.get('template_json') as IDict;

    if (!template_json || Object.keys(template_json).length === 0) {
      template_json = defaultOuterModel;
    } else {
      template_json = updateModelEditable(template_json, props.editable);
    }

    let flexModel: FlexLayout.Model;
    try {
      flexModel = FlexLayout.Model.fromJson(template_json as any);
    } catch (e) {
      console.error(e);
      console.warn(
        'Failed to build model with saved templated, using default template.'
      );
      flexModel = FlexLayout.Model.fromJson(defaultOuterModel as any);
    }
    this.state = {
      model: flexModel,
      defaultOuterModel,
      defaultModel,
      widgetList: Object.keys(this.props.model.get('children')),
      placeholderList: [],
      factoryDict: this.props.model.get('widget_factories'),
      editable: props.editable,
      header: props.header,
    };
    this.model = props.model;
    this.innerContextMenuCache = new Map<string, ContextMenu>();
  }
Example #2
Source File: reactWidget.tsx    From ipyflex with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
individualContextMenuFactory = (
    tabsetId: string,
    model: FlexLayout.Model,
    selector: string
  ): ContextMenu => {
    const commands = new CommandRegistry();
    commands.addCommand('hide-tab-bar', {
      execute: () => {
        model.doAction(
          FlexLayout.Actions.updateNodeAttributes(tabsetId, {
            enableTabStrip: false,
          })
        );
      },
      label: 'Hide Tab Bar',
      isEnabled: () => true,
    });
    commands.addCommand('show-tab-bar', {
      execute: () => {
        model.doAction(
          FlexLayout.Actions.updateNodeAttributes(tabsetId, {
            enableTabStrip: true,
          })
        );
      },
      label: 'Show Tab Bar',
      isEnabled: () => true,
    });
    const contextMenu = new ContextMenu({ commands });
    contextMenu.addItem({
      command: 'show-tab-bar',
      selector: this.props.editable ? selector : 'null',
      rank: 0,
    });
    contextMenu.addItem({
      command: 'hide-tab-bar',
      selector: this.props.editable ? selector : 'null',
      rank: 1,
    });
    return contextMenu;
  };
Example #3
Source File: reactWidget.tsx    From ipyflex with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private innerContextMenuCache: Map<string, ContextMenu>;