Skip to content

Commit 17776e0

Browse files
committed
fix #233 and make other improvements/fixes to ObjectScript Explorer
1 parent f71cb09 commit 17776e0

File tree

7 files changed

+64
-18
lines changed

7 files changed

+64
-18
lines changed

package.json

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"onCommand:vscode-objectscript.explorer.refresh",
5858
"onCommand:vscode-objectscript.explorer.openClass",
5959
"onCommand:vscode-objectscript.explorer.openRoutine",
60+
"onCommand:vscode-objectscript.explorer.openCSPFile",
6061
"onCommand:vscode-objectscript.compileFolder",
6162
"onCommand:vscode-objectscript.importFolder",
6263
"onLanguage:objectscript",
@@ -160,11 +161,11 @@
160161
"view/item/context": [
161162
{
162163
"command": "vscode-objectscript.explorer.export",
163-
"when": "view == ObjectScriptExplorer && viewItem =~ /^dataNode:/"
164+
"when": "view == ObjectScriptExplorer && viewItem =~ /^dataNode:(?!(cspApplication|cspFileNode))/"
164165
},
165166
{
166167
"command": "vscode-objectscript.explorer.export",
167-
"when": "view == ObjectScriptExplorer && viewItem =~ /^dataRootNode:/"
168+
"when": "view == ObjectScriptExplorer && viewItem =~ /^dataRootNode:(?!cspRootNode)/"
168169
},
169170
{
170171
"command": "vscode-objectscript.explorer.delete",
@@ -185,28 +186,32 @@
185186
{
186187
"command": "vscode-objectscript.explorer.otherNamespace",
187188
"when": "view == ObjectScriptExplorer && viewItem =~ /^serverNode((?!:extra:).)*$/",
188-
"group": "inline"
189+
"group": "inline@30"
189190
},
190191
{
191192
"command": "vscode-objectscript.explorer.otherNamespaceClose",
192-
"when": "view == ObjectScriptExplorer && viewItem =~ /^serverNode:extra:/",
193-
"group": "inline"
193+
"when": "view == ObjectScriptExplorer && viewItem =~ /^serverNode.*:extra:/",
194+
"group": "inline@30"
194195
},
195196
{
196197
"command": "vscode-objectscript.explorer.showGenerated",
197-
"when": "view == ObjectScriptExplorer && viewItem =~ /^serverNode((?!:generated:).)*$/"
198+
"when": "view == ObjectScriptExplorer && viewItem =~ /^serverNode((?!:generated:).)*$/",
199+
"group": "inline@20"
198200
},
199201
{
200202
"command": "vscode-objectscript.explorer.hideGenerated",
201-
"when": "view == ObjectScriptExplorer && viewItem =~ /^serverNode.*:generated:/"
203+
"when": "view == ObjectScriptExplorer && viewItem =~ /^serverNode.*:generated:/",
204+
"group": "inline@20"
202205
},
203206
{
204207
"command": "vscode-objectscript.explorer.showSystem",
205-
"when": "view == ObjectScriptExplorer && viewItem =~ /^serverNode((?!:(%SYS|system):).)*$/"
208+
"when": "view == ObjectScriptExplorer && viewItem =~ /^serverNode((?!:(%SYS|system):).)*$/",
209+
"group": "inline@10"
206210
},
207211
{
208212
"command": "vscode-objectscript.explorer.hideSystem",
209-
"when": "view == ObjectScriptExplorer && viewItem =~ /^serverNode.*:system:/"
213+
"when": "view == ObjectScriptExplorer && viewItem =~ /^serverNode.*:system:/",
214+
"group": "inline@10"
210215
}
211216
],
212217
"editor/context": [
@@ -408,31 +413,37 @@
408413
{
409414
"command": "vscode-objectscript.explorer.otherNamespace",
410415
"title": "View Another Namespace...",
416+
"icon": "$(add)",
411417
"category": "ObjectScript"
412418
},
413419
{
414420
"command": "vscode-objectscript.explorer.showGenerated",
415-
"title": "Show Generated",
421+
"title": "Show Generated Items",
422+
"icon": "$(server-process)",
416423
"category": "ObjectScript"
417424
},
418425
{
419426
"command": "vscode-objectscript.explorer.hideGenerated",
420-
"title": "Hide Generated",
427+
"title": "Hide Generated Items",
428+
"icon": "$(server-process)",
421429
"category": "ObjectScript"
422430
},
423431
{
424432
"command": "vscode-objectscript.explorer.showSystem",
425-
"title": "Show System",
433+
"title": "Show System Items",
434+
"icon": "$(library)",
426435
"category": "ObjectScript"
427436
},
428437
{
429438
"command": "vscode-objectscript.explorer.hideSystem",
430-
"title": "Hide System",
439+
"title": "Hide System Items",
440+
"icon": "$(library)",
431441
"category": "ObjectScript"
432442
},
433443
{
434444
"command": "vscode-objectscript.explorer.otherNamespaceClose",
435445
"title": "Close Namespace",
446+
"icon": "$(remove)",
436447
"category": "ObjectScript"
437448
},
438449
{

src/explorer/explorer.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ export class ObjectScriptExplorerProvider implements vscode.TreeDataProvider<Nod
2424
.then((data) => data.result.content.namespaces)
2525
.then((data) => data.filter((ns) => ns !== api.ns && !extra4Workspace.includes(ns)))
2626
.then((data) => data.map((ns) => ({ label: ns })))
27-
.then(vscode.window.showQuickPick)
27+
.then((data) =>
28+
vscode.window.showQuickPick(data, {
29+
placeHolder: `Choose a namespace on ${api.config.host}:${api.config.port} to add to ObjectScript Explorer`,
30+
})
31+
)
2832
.then((ns) => this.showExtra4Workspace(workspaceFolder, ns.label));
2933
}
3034

src/explorer/models/cspFileNode.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import * as vscode from "vscode";
2+
import { DocumentContentProvider } from "../../providers/DocumentContentProvider";
3+
import { NodeBase, NodeOptions } from "./nodeBase";
4+
5+
export class CSPFileNode extends NodeBase {
6+
public static readonly contextValue: string = "dataNode:cspFileNode";
7+
public constructor(label: string, fullName: string, options: NodeOptions) {
8+
super(label, fullName, options);
9+
}
10+
11+
public getTreeItem(): vscode.TreeItem {
12+
const displayName: string = this.label;
13+
14+
return {
15+
collapsibleState: vscode.TreeItemCollapsibleState.None,
16+
command: {
17+
arguments: [DocumentContentProvider.getUri(this.fullName, this.workspaceFolder, this.namespace)],
18+
command: "vscode-objectscript.explorer.openCSPFile",
19+
title: "Open File",
20+
},
21+
contextValue: CSPFileNode.contextValue,
22+
label: `${displayName}`,
23+
};
24+
}
25+
}

src/explorer/models/rootNode.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { PackageNode } from "./packageNode";
55
import { RoutineNode } from "./routineNode";
66
import { AtelierAPI } from "../../api";
77
import { ClassNode } from "./classesNode";
8+
import { CSPFileNode } from "./cspFileNode";
89
import { StudioOpenDialog } from "../../queries";
910

1011
export class RootNode extends NodeBase {
@@ -119,17 +120,18 @@ export class RootNode extends NodeBase {
119120
case "9":
120121
return new PackageNode(el.Name, el.fullName, category, this.options);
121122
case "4":
122-
case "5":
123123
case "100":
124124
return new ClassNode(el.Name, el.fullName, this.options);
125+
case "5":
126+
return new CSPFileNode(el.Name, el.fullName, this.options);
125127
case "0":
126128
case "1":
127129
case "2":
128130
case "3":
129131
case "11":
130132
return new RoutineNode(el.Name, el.fullName, this.options);
131133
case "10":
132-
return new RootNode(el.Name, el.fullName, "dataNode:CSPApplication", this._category, this.options, true);
134+
return new RootNode(el.Name, el.fullName, "dataNode:cspApplication", this._category, this.options, true);
133135
default:
134136
return null;
135137
}

src/explorer/models/workspaceNode.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ export class WorkspaceNode extends NodeBase {
2222
return {
2323
collapsibleState: vscode.TreeItemCollapsibleState.Expanded,
2424
contextValue: `${this.uniqueId}${flags.join("")}`,
25-
label: `${this.label}(${this.connInfo})`,
25+
label: this.extraNode
26+
? `[${this.namespace}] on ${this.conn.host}:${this.conn.port}`
27+
: `${this.label} (${this.connInfo})`,
28+
iconPath: new vscode.ThemeIcon(this.extraNode ? "database" : "server-environment"),
2629
};
2730
}
2831

src/extension.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
574574
vscode.commands.registerCommand("vscode-objectscript.explorer.refresh", () => explorerProvider.refresh()),
575575
vscode.commands.registerCommand("vscode-objectscript.explorer.openClass", vscode.window.showTextDocument),
576576
vscode.commands.registerCommand("vscode-objectscript.explorer.openRoutine", vscode.window.showTextDocument),
577+
vscode.commands.registerCommand("vscode-objectscript.explorer.openCSPFile", vscode.window.showTextDocument),
577578
vscode.commands.registerCommand("vscode-objectscript.explorer.export", (item, items) =>
578579
exportExplorerItem(items && items.length ? items : [item])
579580
),

src/providers/DocumentContentProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ export class DocumentContentProvider implements vscode.TextDocumentContentProvid
8585
private onDidChangeEvent: vscode.EventEmitter<vscode.Uri> = new vscode.EventEmitter<vscode.Uri>();
8686

8787
public provideTextDocumentContent(uri: vscode.Uri, token: vscode.CancellationToken): vscode.ProviderResult<string> {
88-
const fileName = uri.path.split("/").slice(1).join(".");
8988
const api = new AtelierAPI(uri);
9089
const query = url.parse(decodeURIComponent(uri.toString()), true).query;
90+
const fileName = query && query.csp ? uri.path.substring(1) : uri.path.split("/").slice(1).join(".");
9191
if (query) {
9292
if (query.ns && query.ns !== "") {
9393
const namespace = query.ns.toString();

0 commit comments

Comments
 (0)