コード例 #1
0
  constructor(onConnect) {
    this.onConnectClicked = onConnect;

    this.loadedConnections = [];
    this.placeholderUrlPart = '://user:pass@localhost/db-name';
    this.supportedDbs = DbFactory.getSupportedDatabases();

    this.state = {
      selectedProtocol: this.supportedDbs[0].prefix,
      defaultPort: this.supportedDbs[0].port
    };

    etch.createElement(this);
    this.registerListeners();

    this.subscriptions = new CompositeDisposable();
    this.subscriptions.add(
      atom.commands.add(this.element, {
      'core:close': () => { this.close(); },
      'core:cancel': () => { this.close(); }
    }));

    DbFactory.loadConnections(connections => {
      this.loadedConnections = connections;
      etch.updateElement(this);
    });
  }
コード例 #2
0
ファイル: table-view.js プロジェクト: raulcesar/data-atom
  constructor({columns, rows}) {
    this.state = {
      columns: columns,
      rows: rows,
      currentStart: 0,
      currentEnd: 200,
      selectedItems: [],
      dragSelectRow: false,
      dragSelectCell: false,
      dragSelectFunc: event => { this.dragSelect(event); },
      columnResizeStartFunc: event => { this.columnResizeStart(event); },
      columnResizeMoveFunc: event => { this.columnResizeMove(event); },
      columnResizeEndFunc: event => { this.columnResizeEnd(event); },
      columnToResize: null
    };
    etch.createElement(this);

    atom.commands.add(this.element, {
      'core:copy': () => {
        let str = this.state.selectedItems.map(ele => ele.innerText).join('\n');
        Clipboard.writeText(str);
      }
    })

    let listener = new DOMListener(this.element);
    listener.add('.result-cell', 'mousedown', event => this.cellDragStart(event));
    listener.add('.result-cell', 'mouseup', event => this.selectDragEnd(event));
    listener.add('.result-row', 'mousedown', event => this.rowDragStart(event));
    listener.add('th', 'mouseup', event => this.selectDragEnd(event));
    listener.add('tr', 'mouseup', event => this.selectDragEnd(event));
    listener.add('.col-header', 'mousemove', event => this.columnResizeCheck(event));
    this.refs.tableHeader.addEventListener('click', () => this.selectTable());
  }