diff --git a/package.json b/package.json index 05e7f8d..595a535 100644 --- a/package.json +++ b/package.json @@ -73,6 +73,10 @@ { "command": "metadataViewer.openValueManagerModule", "title": "%1c-metadata-viewer.openValueManagerModule.title%" + }, + { + "command": "metadataViewer.openXml", + "title": "%1c-metadata-viewer.openXml.title%" } ], "menus": { @@ -126,6 +130,11 @@ "command": "metadataViewer.openValueManagerModule", "group": "bsl", "when": "viewItem =~ /valueManager/" + }, + { + "command": "metadataViewer.openXml", + "group": "xml", + "when": "viewItem" } ] }, diff --git a/package.nls.json b/package.nls.json index 9505c53..6b9e0b3 100644 --- a/package.nls.json +++ b/package.nls.json @@ -8,5 +8,6 @@ "1c-metadata-viewer.openModule.title": "Open module", "1c-metadata-viewer.openCommandModule.title": "Open command module", "1c-metadata-viewer.openRecordSetModule.title": "Open record set module", - "1c-metadata-viewer.openValueManagerModule.title": "Open value manager module" + "1c-metadata-viewer.openValueManagerModule.title": "Open value manager module", + "1c-metadata-viewer.openXml.title": "Open XML" } \ No newline at end of file diff --git a/package.nls.ru.json b/package.nls.ru.json index 17213ce..42c893a 100644 --- a/package.nls.ru.json +++ b/package.nls.ru.json @@ -8,5 +8,6 @@ "1c-metadata-viewer.openModule.title": "Открыть модуль", "1c-metadata-viewer.openCommandModule.title": "Открыть модуль команды", "1c-metadata-viewer.openRecordSetModule.title": "Открыть модуль набора записей", - "1c-metadata-viewer.openValueManagerModule.title": "Открыть модуль менеджера значения" + "1c-metadata-viewer.openValueManagerModule.title": "Открыть модуль менеджера значения", + "1c-metadata-viewer.openXml.title": "Открыть XML" } \ No newline at end of file diff --git a/src/extension.ts b/src/extension.ts index efee1cd..bd5cc0f 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -49,6 +49,10 @@ export function activate(context: vscode.ExtensionContext) { const filePath = rootPath + '/Constants/' + node.label + '/Ext/ValueManagerModule.bsl'; OpenFile(filePath); }); + vscode.commands.registerCommand('metadataViewer.openXml', (node: TreeItem) => { + const filePath = rootPath + '/' + node.path + '.xml'; + OpenFile(filePath); + }); new MetadataView(context); } diff --git a/src/metadataView.ts b/src/metadataView.ts index 422b14a..86b5644 100644 --- a/src/metadataView.ts +++ b/src/metadataView.ts @@ -38,6 +38,7 @@ interface TreeItemParams { context?: string, command?: string, commandTitle?: string, + path?: string, children?: TreeItem[], } @@ -70,7 +71,7 @@ export class MetadataView { } const tree: TreeItem[] = [ - GetTreeItem({ $: { id: 'configuration', name: 'Конфигурация' } }, { context: 'main', children: [ + GetTreeItem({ $: { id: 'configuration', name: 'Конфигурация' } }, { path: 'Configuration', context: 'main', children: [ GetTreeItem({ $: { id: 'common', name: 'Общие' } }, { icon: 'common', children: [ GetTreeItem({ $: { id: 'subsystems', name: 'Подсистемы' } }, { icon: 'subsystem', children: [] }), GetTreeItem({ $: { id: 'commonModules', name: 'Общие модули' } }, { icon: 'commonModule', children: [] }), @@ -122,7 +123,8 @@ function CreateTreeElements(metadataFile: MetadataFile) { if (!previous.form[objectName]) { previous.form[objectName] = []; } - previous.form[objectName].push(GetTreeItem(current, { icon: 'form', context: 'form' })); + previous.form[objectName].push(GetTreeItem(current, { + icon: 'form', path: `${CreatePath(objectName)}/Forms/${current.$.name.split('.').pop()}`, context: 'form' })); } else if (current.$.name.includes('.Template.') && !current.$.name.endsWith('.Template')) { if (!previous.template[objectName]) { previous.template[objectName] = []; @@ -314,7 +316,7 @@ function GetTreeItem(element: ObjectMetadata, params?: TreeItemParams ): TreeIte if (params?.context) { treeItem.contextValue = params.context; } - treeItem.path = CreatePath(element.$.name.split('.').slice(0,2).join('.')); + treeItem.path = params?.path ?? CreatePath(element.$.name.split('.').slice(0,2).join('.')); if (params?.command && params.commandTitle) { treeItem.command = { command: params.command, title: params.commandTitle }; } @@ -337,6 +339,7 @@ function SearchTree(element: TreeItem, matchingId: string): TreeItem | null { function CreatePath(name: string): string { return name + .replace('CommonModule.', 'CommonModules/') .replace('ExchangePlan.', 'ExchangePlans/') .replace('Constant.', 'Constants/') .replace('Catalog.', 'Catalogs/')