当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript spring-flo.EditorComponent类代码示例

本文整理汇总了TypeScript中spring-flo.EditorComponent的典型用法代码示例。如果您正苦于以下问题:TypeScript EditorComponent类的具体用法?TypeScript EditorComponent怎么用?TypeScript EditorComponent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了EditorComponent类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: describe

describe('Task RenderService', () => {

  const loggerService = new LoggerService();
  const METAMODEL_SERVICE = new MetamodelService(new MockSharedAppService(), loggerService, new MockToolsService());
  const RENDER_SERVICE = new RenderService(METAMODEL_SERVICE, null, null, null, null);
  const EDITOR_SERVICE = new EditorService(null);

  let METAMODEL: Map<string, Map<string, Flo.ElementMetadata>>;
  let component: EditorComponent;
  let fixture: ComponentFixture<EditorComponent>;
  let flo: Flo.EditorContext;

  beforeEach(async(() => {
    METAMODEL_SERVICE.load().then(metamodel => METAMODEL = metamodel);
    TestBed.configureTestingModule({
      imports: [
        FloModule
      ],
      providers: [
        { provide: MetamodelService, useValue: METAMODEL_SERVICE },
        { provide: RenderService, useValue: RENDER_SERVICE },
        { provide: EditorService, useValue: EDITOR_SERVICE }
      ]
    })
      .compileComponents();
  }));

  beforeEach(() => {
    fixture = TestBed.createComponent(EditorComponent);
    component = fixture.componentInstance;
    component.metamodel = METAMODEL_SERVICE;
    component.renderer = RENDER_SERVICE;
    component.editor = EDITOR_SERVICE;
    const subscription = component.floApi.subscribe((f) => {
      subscription.unsubscribe();
      flo = f;
    });
    // FF needs flo editor to have size otherwise `TypeError: a.getScreenCTM(...) is null`
    const floViewElemnt = $('#flow-view');
    floViewElemnt.css({
      'height': '800px'
    });
    fixture.detectChanges();
  });

  function dropNodeFromPaletteOnCanvas(metadata: Flo.ElementMetadata, location?: dia.Point): dia.Element {
    const node = flo.createNode(metadata, null, location);
    component.setDragDescriptor({
      sourceComponent: Constants.PALETTE_CONTEXT,
      source: {
        view: flo.getPaper().findViewByModel(node)
      }
    });
    component.handleNodeDropping();
    return node;
  }

  function dropNodeFromPaletteOnCanvasLink(metadata: Flo.ElementMetadata, target: dia.Link): dia.Element {
    const node = flo.createNode(metadata, null);
    component.setDragDescriptor({
      sourceComponent: Constants.PALETTE_CONTEXT,
      source: {
        view: flo.getPaper().findViewByModel(node)
      },
      target: {
        view: flo.getPaper().findViewByModel(target),
      }
    });
    component.handleNodeDropping();
    return node;
  }

  function createLink(from: dia.Element, to: dia.Element): dia.Link {
    return flo.createLink({
      'id': from.id, 'port': 'output', 'selector': '.output-port'
    }, {
      'id': to.id, 'port': 'input', 'selector': '.input-port'
    });
  }


  it('default content', () => {
    EDITOR_SERVICE.setDefaultContent(flo, METAMODEL);
    const nodes = flo.getGraph().getElements();
    expect(nodes.length).toBe(2);
    expect(nodes[0].attr('metadata/name')).toBe('START');
    expect(nodes[1].attr('metadata/name')).toBe('END');
    expect(flo.getGraph().getLinks().length).toBe(0);
  });

  it('create handles for task', () => {
    const taskA = flo.createNode(METAMODEL.get('task').get('a'));
    const taskAView = flo.getPaper().findViewByModel(taskA);
    EDITOR_SERVICE.createHandles(flo,
      (owner, kind, action, location) => component.createHandle(owner, kind, action, location),
      taskAView);
    const embeds = taskA.getEmbeddedCells();
    expect(embeds.length).toBe(2);
    const deleteHandle = embeds[0];
    expect(deleteHandle.attr('./kind')).toBe(Constants.REMOVE_HANDLE_TYPE);
//.........这里部分代码省略.........
开发者ID:BoykoAlex,项目名称:spring-cloud-dataflow-ui,代码行数:101,代码来源:editor.service.spec.ts

示例2: describe

describe('editor.service : Auto-Link', () => {
  let component: EditorComponent;
  let fixture: ComponentFixture<EditorComponent>;
  const metamodelService = new MetamodelService(new MockSharedAppService());
  const renderService = new RenderService(metamodelService);
  const editorService = new EditorService(null);
  let metamodel: Map<string, Map<string, Flo.ElementMetadata>>;

  let flo: Flo.EditorContext;

  beforeEach(async(() => {
    metamodelService.load().then(data => metamodel = data);
    TestBed.configureTestingModule({
      imports: [
        FloModule
      ],
      providers: [
        {provide: MetamodelService, useValue: metamodelService},
        {provide: RenderService, useValue: renderService},
        {provide: EditorService, useValue: editorService}
      ]
    })
      .compileComponents();
  }));

  beforeEach(() => {
    fixture = TestBed.createComponent(EditorComponent);
    component = fixture.componentInstance;
    component.metamodel = metamodelService;
    component.renderer = renderService;
    component.editor = editorService;
    const subscription = component.floApi.subscribe((f) => {
      subscription.unsubscribe();
      flo = f;
    });
    // FF needs flo editor to have size otherwise `TypeError: a.getScreenCTM(...) is null`
    const floViewElemnt = $('#flow-view');
    floViewElemnt.css({
      'height': '800px'
    });
    fixture.detectChanges();
  });

  function dropOnCanvas(metadata: Flo.ElementMetadata, location?: dia.Point): void {
    const node = flo.createNode(metadata, null, location);
    component.setDragDescriptor({
      sourceComponent: Constants.PALETTE_CONTEXT,
      source: {
        view: flo.getPaper().findViewByModel(node)
      }
    });
    component.handleNodeDropping();
  }

  it('DnD on empty canvas', () => {
    dropOnCanvas(metamodel.get('source').get('http'));
    expect(flo.getGraph().getElements().length).toEqual(1);
    expect(flo.getGraph().getElements()[0].attr('metadata/name')).toEqual('http');
  });

  it('Auto-Link: OFF. Drop processor with available source port', () => {
    flo.createNode(metamodel.get('source').get('http'));
    expect(flo.getGraph().getElements().length).toEqual(1);
    dropOnCanvas(metamodel.get('processor').get('filter'));
    expect(flo.getGraph().getElements().length).toEqual(2);
    expect(flo.getGraph().getLinks().length).toEqual(0);
  });

  it('Auto-Link: ON. Drop processor with available source port', () => {
    flo.autolink = true;
    flo.createNode(metamodel.get('source').get('http'));
    expect(flo.getGraph().getElements().length).toEqual(1);
    dropOnCanvas(metamodel.get('processor').get('filter'));
    expect(flo.getGraph().getElements().length).toEqual(2);
    expect(flo.getGraph().getLinks().length).toEqual(1);
  });

  it('Auto-Link: ON. Drop processor with sink on canvas', () => {
    flo.autolink = true;
    const sinkNode = flo.createNode(metamodel.get('sink').get('null'));
    expect(flo.getGraph().getElements().length).toEqual(1);
    dropOnCanvas(metamodel.get('processor').get('filter'));
    expect(flo.getGraph().getElements().length).toEqual(2);
    expect(flo.getGraph().getLinks().length).toEqual(1);
    const l = flo.getGraph().getLinks()[0];
    expect(l.get('target').id).toEqual(sinkNode.id);
    expect(l.get('target').port).toEqual('input');
  });

  it('Auto-Link: ON. Drop processor but no available ports', () => {
    flo.autolink = true;
    const httpNode = flo.createNode(metamodel.get('source').get('http'));
    const nullNode = flo.createNode(metamodel.get('sink').get('null'));
    flo.createLink({
      id: httpNode.id,
      selector: '.output-port',
      port: 'output'
    }, {
      id: nullNode.id,
      selector: '.input-port',
//.........这里部分代码省略.........
开发者ID:BoykoAlex,项目名称:spring-cloud-dataflow-ui,代码行数:101,代码来源:editor.service.spec.ts

示例3: dropOnCanvas

 function dropOnCanvas(metadata: Flo.ElementMetadata, location?: dia.Point): void {
   const node = flo.createNode(metadata, null, location);
   component.setDragDescriptor({
     sourceComponent: Constants.PALETTE_CONTEXT,
     source: {
       view: flo.getPaper().findViewByModel(node)
     }
   });
   component.handleNodeDropping();
 }
开发者ID:BoykoAlex,项目名称:spring-cloud-dataflow-ui,代码行数:10,代码来源:editor.service.spec.ts

示例4: dropNodeFromPaletteOnCanvasLink

 function dropNodeFromPaletteOnCanvasLink(metadata: Flo.ElementMetadata, target: dia.Link): dia.Element {
   const node = flo.createNode(metadata, null);
   component.setDragDescriptor({
     sourceComponent: Constants.PALETTE_CONTEXT,
     source: {
       view: flo.getPaper().findViewByModel(node)
     },
     target: {
       view: flo.getPaper().findViewByModel(target),
     }
   });
   component.handleNodeDropping();
   return node;
 }
开发者ID:BoykoAlex,项目名称:spring-cloud-dataflow-ui,代码行数:14,代码来源:editor.service.spec.ts

示例5:

 (owner, kind, action, location) => component.createHandle(owner, kind, action, location),
开发者ID:BoykoAlex,项目名称:spring-cloud-dataflow-ui,代码行数:1,代码来源:editor.service.spec.ts


注:本文中的spring-flo.EditorComponent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。