import * as vscode from 'vscode' ; import { ConnectController } from './connect.controller' ; import { PLSQLConnection } from '../plsql.settings' ; import ConnectInputPanel from './connect.inputPannel' ; export default class ConnectUIController { constructor ( private context , private controller ) { } public activateConnectionsList ( ) { const me = this ; let connections ; const active = this . controller . getActive ( ) ; if ( active ) { connections = this . controller . getConnections ( ) . filter ( item => item !== active ) ; connections . unshift ( active ) ; } else connections = this . controller . getConnections ( ) ; const displayItems = connections . filter ( item => item . active || ! item . hidden ) . map ( item => { return { label : `${ item . active ? '$(check) ' : '' } ${ item . name }` , item : item , action : 'setActive' } ; } ) ; displayItems . push ( { label : '<Insert a new connection>' , item : undefined , action : 'addConnection' } ) ; displayItems . push ( { label : '<Settings>' , item : undefined , action : 'showSettings' } ) ; vscode . window . showQuickPick ( displayItems ) . then ( val => { if ( val ) { me [ val . action ] . apply ( me , [ val . item ] ) ; } } ) ; } setActive ( connection ) { this . controller . setActive ( connection , true ) ; this . controller . saveConnections ( ) ; } addConnection ( ) { ConnectInputPanel . createOrShow ( this . context . extensionPath , this . controller , false ) ; } showSettings ( ) { ConnectInputPanel . createOrShow ( this . context . extensionPath , this . controller , true ) ; } }