當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript commands.CommandRegistry類代碼示例

本文整理匯總了TypeScript中@phosphor/commands.CommandRegistry的典型用法代碼示例。如果您正苦於以下問題:TypeScript CommandRegistry類的具體用法?TypeScript CommandRegistry怎麽用?TypeScript CommandRegistry使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了CommandRegistry類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

      it('should restore the widgets in a tracker', done => {
        let tracker = new InstanceTracker<Widget>({
          namespace: 'foo-widget',
          shell: new ApplicationShell()
        });
        let registry = new CommandRegistry();
        let state = new StateDB({ namespace: NAMESPACE });
        let ready = new PromiseDelegate<void>();
        let restorer = new LayoutRestorer({
          first: ready.promise, registry, state
        });
        let called = false;
        let key = `${tracker.namespace}:${tracker.namespace}`;

        registry.addCommand(tracker.namespace, {
          execute: () => { called = true; }
        });
        state.save(key, { data: null }).then(() => {
          return restorer.restore(tracker, {
            args: () => null,
            name: () => tracker.namespace,
            command: tracker.namespace
          });
        }).catch(done);
        ready.resolve(void 0);
        restorer.restored.then(() => { expect(called).to.be(true); })
          .then(() => state.remove(key))
          .then(() => { done(); })
          .catch(done);
      });
開發者ID:charnpreetsingh185,項目名稱:jupyterlab,代碼行數:30,代碼來源:layoutrestorer.spec.ts

示例2: it

      it('should connect a node to a command', () => {
        let called = false;
        const command = 'commandlinker:connect-node';
        const commands = new CommandRegistry();
        const linker = new CommandLinker({ commands });
        let node: HTMLElement;
        let vnode: VirtualNode;
        const disposable = commands.addCommand(command, {
          execute: () => {
            called = true;
          }
        });

        vnode = h.div({ dataset: linker.populateVNodeDataset(command, null) });
        node = VirtualDOM.realize(vnode);
        document.body.appendChild(node);

        expect(called).to.equal(false);
        simulate(node, 'click');
        expect(called).to.equal(true);

        document.body.removeChild(node);
        linker.dispose();
        disposable.dispose();
      });
開發者ID:AlbertHilb,項目名稱:jupyterlab,代碼行數:25,代碼來源:commandlinker.spec.ts

示例3: it

      it('should disconnect a node from a command', () => {
        let called = false;
        let command = 'commandlinker:disconnect-node';
        let commands =new CommandRegistry();
        let linker = new CommandLinker({ commands });
        let node = document.createElement('div');
        let disposable = commands.addCommand(command, {
          execute: () => { called = true; }
        });

        document.body.appendChild(node);
        linker.connectNode(node, command, null);

        // Make sure connection is working.
        expect(called).to.be(false);
        simulate(node, 'click');
        expect(called).to.be(true);

        // Reset flag.
        called = false;

        // Make sure disconnection is working.
        linker.disconnectNode(node);
        expect(called).to.be(false);
        simulate(node, 'click');
        expect(called).to.be(false);

        document.body.removeChild(node);
        linker.dispose();
        disposable.dispose();
      });
開發者ID:rlugojr,項目名稱:jupyterlab,代碼行數:31,代碼來源:commandlinker.spec.ts

示例4: before

  before(() => {
    commands = new CommandRegistry();
    bkoMenu = new BkoMenu({ commands });

    commands.addCommand('test', { execute: () => {} });
    bkoMenu.addItem({command: 'test', submenu: bkoMenu, type: 'submenu'});
  });
開發者ID:twosigma,項目名稱:beaker-notebook,代碼行數:7,代碼來源:BkoMenu.spec.ts

示例5: it

      it('should restore the widgets in a tracker', async () => {
        const tracker = new InstanceTracker<Widget>({
          namespace: 'foo-widget'
        });
        const registry = new CommandRegistry();
        const state = new StateDB({ namespace: NAMESPACE });
        const ready = new PromiseDelegate<void>();
        const restorer = new LayoutRestorer({
          first: ready.promise,
          registry,
          state
        });
        let called = false;
        const key = `${tracker.namespace}:${tracker.namespace}`;

        registry.addCommand(tracker.namespace, {
          execute: () => {
            called = true;
          }
        });
        await state.save(key, { data: null });
        ready.resolve(undefined);
        await restorer.restore(tracker, {
          args: () => null,
          name: () => tracker.namespace,
          command: tracker.namespace
        });
        await restorer.restored;
        expect(called).to.equal(true);
      });
開發者ID:afshin,項目名稱:jupyterlab,代碼行數:30,代碼來源:layoutrestorer.spec.ts

示例6: it

 it('should be a new array', () => {
   registry.addCommand('test0', NULL_COMMAND);
   registry.addCommand('test1', NULL_COMMAND);
   let cmds = registry.listCommands();
   cmds.push('test2');
   expect(registry.listCommands()).to.deep.equal(['test0', 'test1']);
 });
開發者ID:afshin,項目名稱:phosphor,代碼行數:7,代碼來源:index.spec.ts

示例7: render

      it('should update the node content on command change event', async () => {
        const id = 'to-be-removed';
        let iconClassValue: string | null = null;
        const cmd = commands.addCommand(id, {
          execute: () => {
            /* no op */
          },
          label: 'Label-only button',
          iconClass: () => iconClassValue
        });
        const button = new CommandToolbarButton({
          commands,
          id
        });
        await render(button);
        const buttonNode = button.node.firstChild as HTMLButtonElement;
        expect(buttonNode.textContent).to.equal('Label-only button');
        expect(buttonNode.classList.contains(iconClassValue)).to.equal(false);

        iconClassValue = 'updated-icon-class';
        commands.notifyCommandChanged(id);
        await render(button);
        const wrapperNode = buttonNode.firstChild as HTMLElement;
        const iconNode = wrapperNode.firstChild as HTMLElement;
        expect(iconNode.classList.contains(iconClassValue)).to.equal(true);

        cmd.dispose();
      });
開發者ID:afshin,項目名稱:jupyterlab,代碼行數:28,代碼來源:toolbar.spec.ts

示例8: it

      it('should stop routing if returned by a routed command', done => {
        const wanted = ['a', 'b'];
        const recorded: string[] = [];

        commands.addCommand('a', {
          execute: () => {
            recorded.push('a');
          }
        });
        commands.addCommand('b', {
          execute: () => {
            recorded.push('b');
          }
        });
        commands.addCommand('c', { execute: () => router.stop });
        commands.addCommand('d', {
          execute: () => {
            recorded.push('d');
          }
        });

        router.register({ command: 'a', pattern: /.*/, rank: 10 });
        router.register({ command: 'b', pattern: /.*/, rank: 20 });
        router.register({ command: 'c', pattern: /.*/, rank: 30 });
        router.register({ command: 'd', pattern: /.*/, rank: 40 });

        router.routed.connect(() => {
          expect(recorded).to.deep.equal(wanted);
          done();
        });
        router.route();
      });
開發者ID:dalejung,項目名稱:jupyterlab,代碼行數:32,代碼來源:router.spec.ts


注:本文中的@phosphor/commands.CommandRegistry類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。