rhamt-vscode-extension
Version:
RHAMT VSCode extension
134 lines (103 loc) • 5.83 kB
text/typescript
import * as vscode from 'vscode';
import * as path from 'path';
// import { Utils } from './Utils';
// import { RhamtService } from './rhamtService';
import { RhamtView } from './explorer/rhamtView';
// import { ConfigProvider } from './configuration/configProvider';
import { ConfigurationNode } from './tree-api/ConfigurationNode';
// import { ConfigEditorManager } from './configuration/configEditorManager';
import { RhamtModelService, RhamtModel } from 'raas-core';
import { ConfigurationEditorService } from './raasView/configurationEditorService';
import { Endpoint } from './server/endpoint';
import { Server, ServerController } from './server/main';
import { EditorService } from './server/editorService';
import * as raas from 'raas-server';
let rhamtView: RhamtView;
let modelService: RhamtModelService;
let configEditorService: ConfigurationEditorService;
// let editorManager: ConfigEditorManager;
export async function activate(context: vscode.ExtensionContext) {
const endpoint = new Endpoint();
const raasServer = new raas.Server();
raasServer.start(Number(endpoint.raasPort));
// await Utils.loadPackageInfo(context);
modelService = new RhamtModelService(new RhamtModel());
configEditorService = new ConfigurationEditorService(endpoint, context);
// editorManager = new ConfigEditorManager();
// context.subscriptions.push(editorManager);
// const provider = new ConfigProvider(modelService);
// context.subscriptions.push(vscode.workspace.registerTextDocumentContentProvider("http", provider));
rhamtView = new RhamtView(context, modelService);
context.subscriptions.push(rhamtView);
// let rhamtService = new RhamtService();
context.subscriptions.push(vscode.commands.registerCommand('rhamt.startServer', async () => {
// rhamtService.startServer();
}));
context.subscriptions.push(vscode.commands.registerCommand('rhamt.stopServer', () => {
// rhamtService.stopServer();
}));
context.subscriptions.push(modelService);
const editorService = new EditorService();
// endpoint: Endpoint,
// controller: ServerController,
// modelService: RhamtModelService,
// editorService: EditorService
const controller = new ServerController(modelService);
const editorServer = new Server(endpoint, controller, modelService, editorService);
editorServer.start();
context.subscriptions.push(vscode.commands.registerCommand('rhamt.openConfiguration', async (config: ConfigurationNode) => {
const configuration = modelService.getConfiguration(config.id);
if (configuration) {
configEditorService.open(configuration);
// let port = 8083;
// let host = 'localhost';
// let path = config.id;
// let uri = vscode.Uri.parse(`http://${host}:${port}/${path}`);
// await editorManager.getEditor(configuration, modelService);
// return vscode.commands.executeCommand("vscode.previewHtml", uri, vscode.ViewColumn.One, "").then(() => {
// }, (reason) => {
// console.error(reason);
// vscode.window.showErrorMessage('Configuration editor error.');
// });
}
}));
// context.subscriptions.push({ dispose: () => rhamtService.stopServer()});
// class BrowserContentProvider implements vscode.TextDocumentContentProvider {
// provideTextDocumentContent(uri: vscode.Uri, token: vscode.CancellationToken): string {
// // TODO: detect failure to load page (e.g. google.com) and display error to user.
// return `<iframe src="${uri}" frameBorder="0" style="width: 100%; height: 100%" />`;
// }
// }
// let provider = new BrowserContentProvider();
//let registrationHTTPS = vscode.workspace.registerTextDocumentContentProvider('https', provider);
//let registrationHTTP = vscode.workspace.registerTextDocumentContentProvider('http', provider);
let analyzeWorkspaceDisposable = vscode.commands.registerCommand('rhamt.analyzeWorkspace', () => {
/*if (await Utils.checkRhamtAvailablility()) {
vscode.window.showInformationMessage('RHAMT analyzing workspace ...');
rhamtService.analyzeWorkspace();
}*/
// rhamtService.analyzeWorkspace();
// commands.executeCommand('vscode.open', Uri.parse('https://go.microsoft.com/fwlink/?linkid=839919'));
//let uri = vscode.Uri.parse('file:///Users/johnsteele/Desktop/devstudio/4_1_test/ws/demo/out/index.html');
// let uri = vscode.Uri.parse('https://www.google.com');
// vscode.commands.executeCommand('vscode.previewHtml', uri, vscode.ViewColumn.Two, 'CSS Property Preview').then((success) => {
// }, (reason) => {
// vscode.window.showErrorMessage(reason);
// });
// let uri = vscode.Uri.parse('file:///Users/johnsteele/Desktop/devstudio/4_1_test/ws/demo/out/index.html');
// return vscode.commands.executeCommand('vscode.previewHtml', uri, vscode.ViewColumn.Two).then((success) => {
// }, (reason) => {
// vscode.window.showErrorMessage(reason);
// }
// );
});
// vscode.commands.executeCommand('vscode.previewHtml', '/Users/johnsteele/Desktop/devstudio/4_1_test/ws/demo/out/index.html', vscode.ViewColumn.Two, 'CSS Property Preview').then((success) => {
// }, (reason) => {
// vscode.window.showErrorMessage(reason);
// });
context.subscriptions.push(analyzeWorkspaceDisposable);
}
export function deactivate() {
rhamtView.dispose();
modelService.save(path.join(__dirname, '..', 'data', 'model.json'));
}