Skip to content

Commit

Permalink
multi select in explorer view for mass export
Browse files Browse the repository at this point in the history
  • Loading branch information
daimor committed Mar 23, 2020
1 parent b17c479 commit b627874
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 17 deletions.
12 changes: 5 additions & 7 deletions src/commands/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ import fs = require("fs");
import path = require("path");
import * as vscode from "vscode";
import { AtelierAPI } from "../api";
import { ClassNode } from "../explorer/models/classesNode";
import { PackageNode } from "../explorer/models/packageNode";
import { RootNode } from "../explorer/models/rootNode";
import { RoutineNode } from "../explorer/models/routineNode";
import { config } from "../extension";
import { mkdirSyncRecursive, notNull, outputChannel, workspaceFolderUri } from "../utils";
import { NodeBase } from "../explorer/models/nodeBase";

const filesFilter = (file: any) => {
if (file.cat === "CSP" || file.name.startsWith("%") || file.name.startsWith("INFORMATION.")) {
Expand Down Expand Up @@ -189,8 +186,9 @@ export async function exportAll(workspaceFolder?: string): Promise<any> {
});
}

export async function exportExplorerItem(node: RootNode | PackageNode | ClassNode | RoutineNode): Promise<any> {
export async function exportExplorerItem(nodes: NodeBase[]): Promise<any> {
const origNamespace = config("conn").ns;
const node = nodes[0];
if (origNamespace !== node.namespace) {
const answer = await vscode.window.showWarningMessage(
`
Expand All @@ -206,7 +204,7 @@ Would you like to continue?`,
}
}
const { workspaceFolder, namespace } = node;
return node.getItems4Export().then(items => {
return exportList(items, workspaceFolder, namespace);
return Promise.all(nodes.map(node => node.getItems4Export())).then(items => {
return exportList(items.flat(), workspaceFolder, namespace);
});
}
2 changes: 1 addition & 1 deletion src/commands/studio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class StudioActions {
}
}

private userAction(action, afterUserAction = false, answer: string = "", msg: string = ""): Thenable<void> {
private userAction(action, afterUserAction = false, answer = "", msg = ""): Thenable<void> {
if (!action) {
return;
}
Expand Down
4 changes: 1 addition & 3 deletions src/commands/xml2doc.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import * as vscode from "vscode";
import { config, OBJECTSCRIPTXML_FILE_SCHEMA } from "../extension";
import { XmlContentProvider } from "../providers/XmlContentProvider";
import { config, OBJECTSCRIPTXML_FILE_SCHEMA, xmlContentProvider } from "../extension";

export async function xml2doc(context: vscode.ExtensionContext, textEditor: vscode.TextEditor): Promise<void> {
const xmlContentProvider: XmlContentProvider = context.workspaceState.get("xmlContentProvider");
if (!config("conn").active) {
return;
}
Expand Down
17 changes: 12 additions & 5 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export let extensionContext: vscode.ExtensionContext;
export let panel: vscode.StatusBarItem;
export let posPanel: vscode.StatusBarItem;
export let terminal: vscode.Terminal;
export let xmlContentProvider: XmlContentProvider;

import TelemetryReporter from "vscode-extension-telemetry";
import { CodeActionProvider } from "./providers/CodeActionProvider";
Expand Down Expand Up @@ -214,13 +215,17 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
extensionContext = context;
workspaceState.update("workspaceFolder", "");

explorerProvider = new ObjectScriptExplorerProvider();
documentContentProvider = new DocumentContentProvider();
const xmlContentProvider = new XmlContentProvider();
context.workspaceState.update("xmlContentProvider", xmlContentProvider);
xmlContentProvider = new XmlContentProvider();
fileSystemProvider = new FileSystemProvider();

vscode.window.registerTreeDataProvider("ObjectScriptExplorer", explorerProvider);
explorerProvider = new ObjectScriptExplorerProvider();
// vscode.window.registerTreeDataProvider("ObjectScriptExplorer", explorerProvider);
vscode.window.createTreeView("ObjectScriptExplorer", {
treeDataProvider: explorerProvider,
showCollapseAll: true,
canSelectMany: true,
});

posPanel = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 0);
posPanel.show();
Expand Down Expand Up @@ -366,7 +371,9 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
vscode.commands.registerCommand("vscode-objectscript.explorer.refresh", () => explorerProvider.refresh()),
vscode.commands.registerCommand("vscode-objectscript.explorer.openClass", vscode.window.showTextDocument),
vscode.commands.registerCommand("vscode-objectscript.explorer.openRoutine", vscode.window.showTextDocument),
vscode.commands.registerCommand("vscode-objectscript.explorer.export", exportExplorerItem),
vscode.commands.registerCommand("vscode-objectscript.explorer.export", (item, items) =>
exportExplorerItem(items && items.length ? items : [item])
),
vscode.commands.registerCommand("vscode-objectscript.explorer.delete", deleteItem),
vscode.commands.registerCommand("vscode-objectscript.explorer.compile", compileExplorerItem),
vscode.commands.registerCommand("vscode-objectscript.explorer.showGenerated", (workspaceNode: WorkspaceNode) => {
Expand Down
5 changes: 4 additions & 1 deletion src/languageConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ export const WORD_PATTERN = /((?<=(class|extends|as|of) )(%?\b[a-z0-9]+(\.[a-z0-
export function getLanguageConfiguration(lang: string): LanguageConfiguration {
return {
wordPattern: WORD_PATTERN,
brackets: [["{", "}"], ["(", ")"], ['"', '"']],
brackets: [
["{", "}"],
["(", ")"],
],
comments: {
lineComment: lang === "class" ? "//" : "#;",
blockComment: ["/*", "*/"],
Expand Down

0 comments on commit b627874

Please sign in to comment.