-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Hofstetter Benjamin (extern)
committed
Apr 6, 2023
1 parent
2245c2e
commit 0f7915c
Showing
13 changed files
with
136 additions
and
123 deletions.
There are no files selected for viewing
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/extension/sparql-connection-menu/endpoint-configuration.model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
export interface EndpointConfiguration { | ||
name: string; | ||
endpointURL: string; | ||
user: string; | ||
passwordKey: string; | ||
} |
33 changes: 33 additions & 0 deletions
33
src/extension/sparql-connection-menu/endpoint-connection-list-item.class.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import * as vscode from "vscode"; | ||
import * as path from "path"; | ||
import { EndpointConfiguration } from "./endpoint-configuration.model"; | ||
|
||
|
||
export class EndpointConnectionListItem extends vscode.TreeItem { | ||
constructor( | ||
public readonly config: EndpointConfiguration, | ||
public readonly isActive: boolean, | ||
public readonly collapsibleState: vscode.TreeItemCollapsibleState, | ||
public readonly command?: vscode.Command | ||
) { | ||
super(config.name, collapsibleState); | ||
|
||
if (isActive) { | ||
this.iconPath = { | ||
dark: path.join(assetsPath, "dark", "endpoint-connected.svg"), | ||
light: path.join(assetsPath, "light", "endpoint-connected.svg"), | ||
}; | ||
this.description = "Connected"; | ||
} else { | ||
this.iconPath = { | ||
dark: path.join(assetsPath, "dark", "endpoint.svg"), | ||
light: path.join(assetsPath, "light", "endpoint.svg"), | ||
}; | ||
console.log(this.iconPath) | ||
this.description = "Inactive"; | ||
} | ||
this.contextValue = "database"; | ||
} | ||
} | ||
|
||
export const assetsPath = path.join(__filename, "..", "..", "assets"); |
63 changes: 63 additions & 0 deletions
63
src/extension/sparql-connection-menu/endpoint-connections.class.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import * as vscode from "vscode"; | ||
import { storageKey } from "../extension"; | ||
|
||
import { EndpointConfiguration } from "./endpoint-configuration.model"; | ||
import { EndpointConnectionListItem } from "./endpoint-connection-list-item.class"; | ||
|
||
export class EndpointConnections | ||
implements vscode.TreeDataProvider<EndpointConnectionListItem | vscode.TreeItem> | ||
{ | ||
private _onDidChangeTreeData: vscode.EventEmitter< | ||
EndpointConnectionListItem | undefined | void | ||
> = new vscode.EventEmitter<EndpointConnectionListItem | undefined | void>(); | ||
readonly onDidChangeTreeData: vscode.Event< | ||
EndpointConnectionListItem | undefined | void | ||
> = this._onDidChangeTreeData.event; | ||
|
||
constructor(public readonly context: vscode.ExtensionContext) { | ||
this.refresh(); | ||
this.activeConn = null; | ||
} | ||
|
||
refresh(): void { | ||
this._onDidChangeTreeData.fire(); | ||
} | ||
|
||
getTreeItem(element: EndpointConnectionListItem): vscode.TreeItem { | ||
return element; | ||
} | ||
|
||
public setActive(connName: string | null) { | ||
this.activeConn = connName; | ||
this.refresh(); | ||
} | ||
private activeConn: string | null; | ||
|
||
getChildren(element?: EndpointConnectionListItem): Thenable<vscode.TreeItem[]> { | ||
if (element) { | ||
return Promise.resolve([ | ||
new vscode.TreeItem( | ||
`EndPointURL: ${element.config.endpointURL}`, | ||
vscode.TreeItemCollapsibleState.None | ||
), | ||
new vscode.TreeItem( | ||
`User: ${element.config.user}`, | ||
vscode.TreeItemCollapsibleState.None | ||
), | ||
]); | ||
} | ||
const connections = | ||
this.context.globalState.get<EndpointConfiguration[] | null>(storageKey) ?? []; | ||
|
||
return Promise.resolve( | ||
connections.map( | ||
(config) => | ||
new EndpointConnectionListItem( | ||
config, | ||
config.name === this.activeConn, | ||
vscode.TreeItemCollapsibleState.Collapsed | ||
) | ||
) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// barrel file for sparql endpoint connection menu | ||
export { EndpointConfiguration } from './endpoint-configuration.model'; | ||
export { EndpointConnectionListItem } from "./endpoint-connection-list-item.class"; | ||
export { EndpointConnections } from "./endpoint-connections.class"; |