diff --git a/vscode/client/views/configurations/treeConfigurations.ts b/vscode/client/views/configurations/treeConfigurations.ts deleted file mode 100644 index 1c431a9..0000000 --- a/vscode/client/views/configurations/treeConfigurations.ts +++ /dev/null @@ -1,109 +0,0 @@ -import * as vscode from 'vscode'; -import * as fs from 'fs'; -import { ConfigurationWebView } from './configurationWebView'; -import * as path from 'path'; - - -class Configuration extends vscode.TreeItem { - constructor( - public readonly label: string, - private version: string, - public readonly collapsibleState: vscode.TreeItemCollapsibleState - ) { - super(label, collapsibleState); - this.tooltip = `${this.label}-${this.version}`; - this.description = this.version; - } - - configId = -1; - iconPath = new vscode.ThemeIcon('symbol-method'); -} - -export class TreeConfigurationsDataProvider implements vscode.TreeDataProvider { - - //TODO FDA private? - public _onDidChangeTreeData: vscode.EventEmitter = new vscode.EventEmitter(); - readonly onDidChangeTreeData: vscode.Event = this._onDidChangeTreeData.event; - - getTreeItem(element: Configuration): vscode.TreeItem { - element.command = { command: 'odoo.openConfiguration', title: "Open Configuration", arguments: [element.configId], }; - return element; - } - - getChildren(element?: Configuration): Thenable { - if (!element) { - return Promise.resolve(this.get_all_configurations()); - } - } - - private get_all_configurations(): Configuration[] { - const configs: any = vscode.workspace.getConfiguration("Odoo").get("userDefinedConfigurations"); - const res = []; - for (const configId in configs) { - const confItem = new Configuration( - configs[configId]["name"], - "", - vscode.TreeItemCollapsibleState.None - ); - confItem.configId = configs[configId]["id"]; - res.push(confItem); - } - return res; - } - - private pathExists(p: string): boolean { - try { - fs.accessSync(p); - } catch (err) { - return false; - } - return true; - } -} - -export class ConfigurationsExplorer { - constructor(context: vscode.ExtensionContext) { - const treeDataProvider = new TreeConfigurationsDataProvider(); - //context.subscriptions.push(vscode.window.createTreeView('fileExplorer', { treeDataProvider })); - vscode.window.registerTreeDataProvider( - 'odoo-configurations', - treeDataProvider - ); - /*vscode.window.createTreeView('odoo-databases', { - treeDataProvider: new TreeConfigurationsDataProvider() - });*/ - vscode.commands.registerCommand('odoo.addConfiguration', () => { - const configs: any = vscode.workspace.getConfiguration("Odoo").get("userDefinedConfigurations"); - let freeIndex = -1; - let found = true; - while (found) { - found = false; - freeIndex ++; - if (freeIndex in Object.keys(configs)) { - found = true; - } - } - configs[freeIndex] = { - "id": freeIndex, - "name": "Configuration " + freeIndex, - "odooPath": "path/to/odoo", - "addons": [] - }; - vscode.workspace.getConfiguration("Odoo").update("userDefinedConfigurations", configs, vscode.ConfigurationTarget.Global); - treeDataProvider._onDidChangeTreeData.fire(); - }); - - vscode.commands.registerCommand('odoo.openConfiguration', (configId) => { - const configs: any = vscode.workspace.getConfiguration("Odoo").get("userDefinedConfigurations"); - const config = configs[configId]; - - // And set its HTML content - //panel.webview.html = getWebviewContent(); - ConfigurationWebView.render(context, configId); - }); - - vscode.workspace.onDidChangeConfiguration(() => { - treeDataProvider._onDidChangeTreeData.fire(); - }); - } -} \ No newline at end of file diff --git a/vscode/client/views/configurations/treeDatabases.ts b/vscode/client/views/configurations/treeDatabases.ts deleted file mode 100644 index 5e2f94f..0000000 --- a/vscode/client/views/configurations/treeDatabases.ts +++ /dev/null @@ -1,71 +0,0 @@ -import * as vscode from 'vscode'; -import * as fs from 'fs'; -import * as path from 'path'; - - -class Database extends vscode.TreeItem { - constructor( - public readonly label: string, - private version: string, - public readonly collapsibleState: vscode.TreeItemCollapsibleState - ) { - super(label, collapsibleState); - this.tooltip = `${this.label}-${this.version}`; - this.description = this.version; - } - - iconPath = new vscode.ThemeIcon('database'); -} - -export class TreeDatabasesDataProvider implements vscode.TreeDataProvider { - - getTreeItem(element: Database): vscode.TreeItem { - return element; - } - - getChildren(element?: Database): Thenable { - if (element && element.label == "Databases") { - return Promise.resolve(this.get_all_db()); - } else { - return Promise.resolve([new Database( - "Databases", - "", - vscode.TreeItemCollapsibleState.Collapsed - )]); - - - /*const packageJsonPath = path.join(this.workspaceRoot, 'package.json'); - if (this.pathExists(packageJsonPath)) { - return Promise.resolve(this.getDepsInPackageJson(packageJsonPath)); - } else { - vscode.window.showInformationMessage('Workspace has no package.json'); - return Promise.resolve([]); - }*/ - } - } - - private get_all_db(): Database[] { - /*const { Client } = require('pg'); - const client = new Client({ - user: 'sgpostgres', - host: 'SG-PostgreNoSSL-14-pgsql-master.devservers.scalegrid.io', - database: 'postgres', - password: 'password', - port: 5432, - }) - client.connect(function(err) { - if (err) throw err; - console.log("Connected!"); - });*/ - return []; - } - - private pathExists(p: string): boolean { - try { - fs.accessSync(p); - } catch (err) { - return false; - } - return true; - } -} diff --git a/vscode/package.json b/vscode/package.json index 68549f5..42288a8 100644 --- a/vscode/package.json +++ b/vscode/package.json @@ -22,17 +22,6 @@ ], "contributes": { "commands": [ - { - "command": "odoo.addConfiguration", - "title": "Add Configuration", - "category": "Odoo", - "icon": "$(add)" - }, - { - "command": "odoo.openConfiguration", - "title": "Open configuration", - "category": "Odoo" - }, { "command": "odoo.clickStatusBar", "title": "Change Configuration", @@ -73,20 +62,6 @@ "category": "Odoo", "when": "odoo.showCrashNotificationCommand" } - ], - "view/title": [ - { - "command": "odoo.addConfiguration", - "when": "view == odoo-configurations", - "group": "navigation" - } - ], - "view/item/context": [ - { - "command": "odoo.addConfiguration", - "when": "view == nodeDependencies && viewItem == dependency", - "group": "inline" - } ] }, "configuration": {