vscode#TreeItem TypeScript Examples

The following examples show how to use vscode#TreeItem. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: q-dict.ts    From vscode-q with MIT License 6 votes vote down vote up
constructor(namespace: string, parent: TreeItem | null) {
        super(namespace, TreeItemCollapsibleState.Collapsed);
        this._parent = parent;
        if (parent instanceof QDictTreeItem) {
            parent.appendChild(this);
        }
        this.isExpanded = false;
        setCommand(this);
        this.iconPath = {
            light: path.join(__filename, '../../assets/svg/item/dict.svg'),
            dark: path.join(__filename, '../../assets/svg/item/dict.svg')
        };
    }
Example #2
Source File: tagProvider.ts    From vscode-todo-md with MIT License 6 votes vote down vote up
export class TagTreeItem extends TreeItem {
	readonly collapsibleState = TreeItemCollapsibleState.Collapsed;

	constructor(
		readonly label: string,
		readonly tasks: TheTask[],
	) {
		super(label);
	}

	contextValue = 'tag';
}
Example #3
Source File: history.ts    From vscode-q with MIT License 6 votes vote down vote up
getChildren(e?: TreeItem): Thenable<TreeItem[]> {
        if (e instanceof HistoryTreeItem) {
            return Promise.resolve(e._children);
        } else if (e) {
            return Promise.resolve([]);
        } else {
            return Promise.resolve(this._children);
        }
    }
Example #4
Source File: projectProvider.ts    From vscode-todo-md with MIT License 6 votes vote down vote up
export class ProjectTreeItem extends TreeItem {
	readonly collapsibleState = TreeItemCollapsibleState.Collapsed;

	constructor(
		readonly label: string,
		readonly tasks: TheTask[],
	) {
		super(label);
	}

	contextValue = 'project';
}
Example #5
Source File: q-dict.ts    From vscode-q with MIT License 6 votes vote down vote up
getChildren(e?: TreeItem): Thenable<TreeItem[]> {
        if (e instanceof QDictTreeItem) {
            return Promise.resolve(e._children);
        } else if (e) {
            return Promise.resolve([]);
        } else {
            return Promise.resolve(this._children);
        }
    }
Example #6
Source File: driveTreeDataProvider.ts    From google-drive-vscode with MIT License 6 votes vote down vote up
private buildItemFromDriveFile(currentFile: DriveFile): TreeItem {
        const iconUri = Uri.parse(currentFile.iconLink);
        const collapsible = this.detectCollapsibleState(currentFile);
        const contextValue = DriveFileUtils.extractTextFromType(currentFile.type);
        return {
            iconPath: iconUri,
            label: currentFile.name,
            collapsibleState: collapsible,
            contextValue: contextValue
        };
    }
Example #7
Source File: q-server-tree.ts    From vscode-q with MIT License 6 votes vote down vote up
getChildren(e?: TreeItem): Thenable<TreeItem[]> {
        if (e instanceof QServerTree) {
            return Promise.resolve(e.getChildren());
        } else if (e instanceof QConn) {
            return Promise.resolve([]);
        } else {
            return Promise.resolve(
                this._children
            );
        }
    }
Example #8
Source File: stripeTreeViewDataProvider.ts    From vscode-stripe with MIT License 6 votes vote down vote up
public async getChildren(element?: TreeItem): Promise<TreeItem[]> {
    if (!this.treeItems) {
      this.treeItems = await this.buildTree();
    }

    if (element instanceof StripeTreeItem) {
      return element.children;
    }

    if (!element) {
      if (this.treeItems) {
        return this.treeItems;
      }
    }
    return [];
  }
Example #9
Source File: q-utils.ts    From vscode-q with MIT License 6 votes vote down vote up
export function setCommand(item: TreeItem): void {
    item.command = {
        command: 'q-explorer.click',
        title: 'click',
        arguments: [item.label]
    };
}
Example #10
Source File: CommandsTreeDataProvider.ts    From reach-ide with Eclipse Public License 2.0 6 votes vote down vote up
export class CommandsTreeDataProvider implements vscode.TreeDataProvider<TreeItem> {

	data: vscode.TreeItem[];

	constructor() {
		this.data = [
			makeTreeItem('clean', 'reach.clean'),
			makeTreeItem('compile', 'reach.compile'),
			makeTreeItem('devnet', 'reach.devnet'),
			makeTreeItem('docker-reset', 'reach.docker-reset'),
			makeTreeItem('down', 'reach.down'),
			makeTreeItem('hashes', 'reach.hashes'),
			makeTreeItem('init', 'reach.init'),
			makeTreeItem('react', 'reach.react'),
			makeTreeItem('rpc-run', 'reach.rpc-run'),
			makeTreeItem('rpc-server', 'reach.rpc-server'),
			makeTreeItem('run', 'reach.run'),
			makeTreeItem('scaffold', 'reach.scaffold'),
			makeTreeItem('update', 'reach.update'),
			makeTreeItem('upgrade', 'reach.upgrade'),
			makeTreeItem('version', 'reach.version'),
		];
	}

	getTreeItem(element: TreeItem) {
		return element;
	}

	getChildren(_?: TreeItem|undefined) {
		return this.data;
	}
}
Example #11
Source File: q-function.ts    From vscode-q with MIT License 6 votes vote down vote up
export default class QFunctionTreeItem extends TreeItem {
    contextValue = 'qfunction';
    _parent: TreeItem;
    _body: string;

    constructor(name: string, parent: QDictTreeItem, body: string) {
        super(name, TreeItemCollapsibleState.None);
        this._parent = parent;
        this._body = body;
        parent.appendChild(this);
        setCommand(this);
        const md = new MarkdownString();
        md.appendCodeblock(this._body, 'q');
        this.tooltip = md;
        this.iconPath = {
            light: path.join(__filename, '../../assets/svg/item/function.svg'),
            dark: path.join(__filename, '../../assets/svg/item/function.svg')
        };
    }

    getBody(): string {
        return this._body;
    }

    getParent(): TreeItem {
        return this._parent;
    }

    getTreeItem(e: QFunctionTreeItem): TreeItem {
        return e;
    }

}
Example #12
Source File: CommandsTreeDataProvider.ts    From reach-ide with Eclipse Public License 2.0 6 votes vote down vote up
export class DocumentationTreeDataProvider implements vscode.TreeDataProvider<TreeItem> {

	data: vscode.TreeItem[];

	constructor() {
		this.data = [
			makeLabeledTreeItem('docs', 'Open the documentation', 'reach.docs', reach_icon_red),
		];
	}

	getTreeItem(element: TreeItem) {
		return element;
	}

	getChildren(_?: TreeItem|undefined) {
		return this.data;
	}
}
Example #13
Source File: ModelTreeviewProvider.ts    From vscode-dbt-power-user with MIT License 6 votes vote down vote up
export class NodeTreeItem extends TreeItem {
  collapsibleState = TreeItemCollapsibleState.Collapsed;
  key: string;
  url: string;

  constructor(node: Node) {
    super(node.label);
    this.key = node.key;
    this.url = node.url;
    if (node.iconPath !== undefined) {
      this.iconPath = node.iconPath;
    }
    this.command = {
      command: "vscode.open",
      title: "Select Node",
      arguments: [Uri.file(node.url)],
    };
  }
}
Example #14
Source File: EngineNoteProvider.ts    From dendron with GNU Affero General Public License v3.0 6 votes vote down vote up
public getExpandableTreeItems(): TreeItem[] {
    const candidateItems = _.toArray(
      _.pickBy(this._tree, (item) => {
        const isCollapsed =
          item.collapsibleState === TreeItemCollapsibleState.Collapsed;
        const isShallow = DNodeUtils.getDepth(item.note) < 3;
        return isCollapsed && isShallow;
      })
    );
    return _.sortBy(candidateItems, (item) => {
      return DNodeUtils.getDepth(item.note);
    });
  }
Example #15
Source File: taskProvider.ts    From vscode-todo-md with MIT License 6 votes vote down vote up
export class TaskTreeItem extends TreeItem {
	collapsibleState = TreeItemCollapsibleState.None;
	contextValue = 'task';

	constructor(
		readonly label: string,
		readonly task: TheTask,
		readonly command: Command,
	) {
		super(label);
		if (task.links.length) {
			this.contextValue = 'link';
		}
		if (task.subtasks.length) {
			if (task.isCollapsed) {
				this.collapsibleState = TreeItemCollapsibleState.Collapsed;
			} else {
				this.collapsibleState = TreeItemCollapsibleState.Expanded;
			}
		}

		if (task.done) {
			this.iconPath = new ThemeIcon('pass', new ThemeColor('todomd.treeViewCompletedTaskIcon'));
		} else {
			// this.iconPath = new ThemeIcon('circle-large-outline');// TODO: maybe
		}
	}
}
Example #16
Source File: HelpFeedbackTreeview.ts    From dendron with GNU Affero General Public License v3.0 6 votes vote down vote up
getTreeItem(element: MenuItem): TreeItem {
    let iconPath: vscode.ThemeIcon;

    switch (element) {
      case MenuItem.getStarted:
        iconPath = new ThemeIcon("star");
        break;

      case MenuItem.readDocs:
        iconPath = new ThemeIcon("book");
        break;

      case MenuItem.reviewIssues:
        iconPath = new ThemeIcon("issues");
        break;

      case MenuItem.reportIssue:
        iconPath = new ThemeIcon("comment");
        break;

      case MenuItem.joinCommunity:
        iconPath = new ThemeIcon("organization");
        break;

      case MenuItem.followUs:
        iconPath = new ThemeIcon("twitter");
        break;

      default:
        assertUnreachable(element);
    }

    return {
      label: element.toString(),
      collapsibleState: TreeItemCollapsibleState.None,
      iconPath,
    };
  }
Example #17
Source File: local.ts    From cloudmusic-vscode with MIT License 6 votes vote down vote up
export class LocalLibraryTreeItem extends TreeItem {
  override readonly label!: string;

  override readonly tooltip = this.label;

  override readonly iconPath = new ThemeIcon("file-directory");

  override readonly contextValue = "LocalLibraryTreeItem";

  constructor(label: string) {
    super(label, TreeItemCollapsibleState.Collapsed);
  }
}
Example #18
Source File: NinjaTreeView.ts    From al-objid with MIT License 6 votes vote down vote up
//#region Interface implementations

    // Implements TreeDataProvider<Node>
    public getTreeItem(element: Node): TreeItem {
        const item = element.getTreeItem();

        if (element instanceof DecorableNode && element.decoration) {
            this.decorate(element, element.decoration);
        }

        if (item.id) {
            item.id = `${item.id}.${item.collapsibleState}.${this._expandCollapseController.iteration}`;
            const state = this._expandCollapseController.getState(element, element.collapsibleState);
            if (state !== undefined && item.collapsibleState !== TreeItemCollapsibleState.None) {
                item.collapsibleState = state;
            }
        }
        return item;
    }
Example #19
Source File: comment-list-entry.ts    From vscode-code-review with MIT License 6 votes vote down vote up
export class CommentListEntry extends TreeItem {
  constructor(
    public readonly id: string,
    public readonly label: string,
    public readonly text: string,
    public readonly hoverLabel: string,
    public readonly collapsibleState: TreeItemCollapsibleState,
    public readonly data: ReviewFileExportSection,
    public readonly prio?: number,
    public readonly priv?: number,
  ) {
    super(label, collapsibleState);
  }

  get tooltip(): string {
    return this.hoverLabel;
  }

  get description(): string {
    return this.text || '';
  }
}
Example #20
Source File: RangeNode.ts    From al-objid with MIT License 6 votes vote down vote up
protected override completeTreeItem(item: TreeItem): void {
        super.completeTreeItem(item);

        const ninjaRange = this._range as unknown as NinjaALRange;
        if (ninjaRange && ninjaRange.description) {
            if (this._includeLogicalNameInDescription) {
                item.description = ninjaRange.description;
            }
            if (this._includeLogicalNameInLabel) {
                item.label = `${item.label} (${ninjaRange.description})`;
            }
        }

        if (this._noConsumption) {
            item.description = `${item.description || ""} (no consumption)`.trim();
        }
    }
Example #21
Source File: radio.ts    From cloudmusic-vscode with MIT License 6 votes vote down vote up
export class RadioTreeItem extends TreeItem {
  private static readonly _set = new Map<number, RadioTreeItem>();

  override readonly label!: string;

  override readonly tooltip = `${i18n.word.description}: ${this.item.desc || ""}
${i18n.word.trackCount}: ${this.item.programCount}
${i18n.word.playCount}: ${this.item.playCount}
${i18n.word.subscribedCount}: ${this.item.subCount}`;

  override readonly iconPath = new ThemeIcon("rss");

  override readonly contextValue = "RadioTreeItem";

  constructor(readonly item: NeteaseTypings.RadioDetail, public uid: number) {
    super(item.name, TreeItemCollapsibleState.Collapsed);
  }

  override get valueOf(): number {
    return this.item.id;
  }

  static new(item: NeteaseTypings.RadioDetail, uid = 0): RadioTreeItem {
    let element = this._set.get(item.id);
    if (element) {
      element.uid = uid;
      return element;
    }
    element = new this(item, uid);
    this._set.set(item.id, element);
    return element;
  }
}
Example #22
Source File: Node.ts    From al-objid with MIT License 6 votes vote down vote up
public getTreeItem(): TreeItem {
        const item = new TreeItem(this._label, this._collapsibleState);

        if (this._description) {
            item.description = this._description;
        }

        if (this._tooltip !== undefined) {
            item.tooltip = this._tooltip;
        }

        if (this._contextValues.length > 0) {
            item.contextValue = ["", ...this._contextValues, ""].join(",");
        }

        this.completeTreeItem(item);

        return item;
    }
Example #23
Source File: user.ts    From cloudmusic-vscode with MIT License 6 votes vote down vote up
export class UserTreeItem extends TreeItem {
  private static readonly _set = new Map<number, UserTreeItem>();

  override readonly iconPath = new ThemeIcon("account");

  override readonly contextValue = "UserTreeItem";

  constructor(override readonly label: string, readonly uid: number) {
    super(label, TreeItemCollapsibleState.Collapsed);
  }

  static new(label: string, uid: number): UserTreeItem {
    let element = this._set.get(uid);
    if (element) return element;
    element = new this(label, uid);
    this._set.set(uid, element);
    return element;
  }
}
Example #24
Source File: CommandsTreeDataProvider.ts    From reach-ide with Eclipse Public License 2.0 5 votes vote down vote up
getTreeItem(element: TreeItem) {
		return element;
	}
Example #25
Source File: stripeTreeViewDataProvider.ts    From vscode-stripe with MIT License 5 votes vote down vote up
export class StripeTreeViewDataProvider implements TreeDataProvider<TreeItem> {
  private treeItems: TreeItem[] | null = null;
  private _onDidChangeTreeData: EventEmitter<TreeItem | null> = new EventEmitter<TreeItem | null>();
  readonly onDidChangeTreeData: Event<TreeItem | null> = this._onDidChangeTreeData.event;

  public refresh() {
    this.treeItems = null;
    this._onDidChangeTreeData.fire(null);
  }

  public getTreeItem(element: TreeItem): TreeItem {
    return element;
  }

  public getParent(element: TreeItem): TreeItem | null {
    if (element instanceof StripeTreeItem && element.parent) {
      return element.parent;
    }
    return null;
  }

  public async getChildren(element?: TreeItem): Promise<TreeItem[]> {
    if (!this.treeItems) {
      this.treeItems = await this.buildTree();
    }

    if (element instanceof StripeTreeItem) {
      return element.children;
    }

    if (!element) {
      if (this.treeItems) {
        return this.treeItems;
      }
    }
    return [];
  }

  buildTree(): Promise<StripeTreeItem[]> {
    return Promise.resolve([]);
  }
}
Example #26
Source File: q-var.ts    From vscode-q with MIT License 5 votes vote down vote up
_parent: TreeItem;
Example #27
Source File: contextProvider.ts    From vscode-todo-md with MIT License 5 votes vote down vote up
getTreeItem(element: ContextTreeItem | TaskTreeItem): TreeItem {
		return element;
	}
Example #28
Source File: DecorableNode.ts    From al-objid with MIT License 5 votes vote down vote up
protected override completeTreeItem(item: TreeItem) {
        item.resourceUri = this.uri;
        item.id = `${this.uri.toString()}`;
        item.iconPath = this._iconPath;
    }
Example #29
Source File: abstracNode.ts    From vscode-ssh with MIT License 5 votes vote down vote up
export default abstract class AbstractNode extends TreeItem {
    fullPath: string;
    abstract getChildren(): Promise<AbstractNode[]>;
    public copyPath() {
        Util.copyToBoard(this.fullPath)
    }
}