Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Show codewind state in tree except when started
Browse files Browse the repository at this point in the history
remove some unneeded code and rename ProjectTree -> CodewindTree
Fix eclipse-archived/codewind#156

Signed-off-by: Tim Etchells <timetchells@ibm.com>
  • Loading branch information
Tim Etchells authored and jopit committed Sep 5, 2019
1 parent f9ee7f9 commit c2437af
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 23 deletions.
17 changes: 0 additions & 17 deletions dev/src/codewind/connection/CodewindStates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,3 @@ export enum CodewindStates {
ERR_CONNECTING = "Error Connecting",
ERR_GENERIC = "Error",
}

export const CODEWIND_STATES: {
[key in CodewindStates]: {
isErrorState: boolean;
isTransitionState: boolean;
}
} = {
Stopped: { isErrorState: false, isTransitionState: false },
Started: { isErrorState: false, isTransitionState: false },
Starting: { isErrorState: false, isTransitionState: true },
Stopping: { isErrorState: false, isTransitionState: true },
Installing: { isErrorState: false, isTransitionState: true },
"Error Connecting": { isErrorState: true, isTransitionState: false },
"Error Installing": { isErrorState: true, isTransitionState: false },
"Error Starting": { isErrorState: true, isTransitionState: false },
Error: { isErrorState: true, isTransitionState: false },
};
4 changes: 2 additions & 2 deletions dev/src/view/ProjectTree.ts → dev/src/view/CodewindTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { CWConfigurations } from "../constants/Configurations";

// const STRING_NS = StringNamespaces.TREEVIEW;

export default class ProjectTreeDataProvider implements vscode.TreeDataProvider<CodewindTreeItem> {
export default class CodewindTreeDataProvider implements vscode.TreeDataProvider<CodewindTreeItem> {

public static readonly VIEW_ID: string = "ext.cw.explorer"; // must match package.nls.json
public readonly treeView: vscode.TreeView<CodewindTreeItem>;
Expand All @@ -33,7 +33,7 @@ export default class ProjectTreeDataProvider implements vscode.TreeDataProvider<
private root: vscode.TreeItem;

constructor() {
this.treeView = vscode.window.createTreeView(ProjectTreeDataProvider.VIEW_ID, { treeDataProvider: this });
this.treeView = vscode.window.createTreeView(CodewindTreeDataProvider.VIEW_ID, { treeDataProvider: this });

CodewindManager.instance.addOnChangeListener(this.refresh);
Log.d("Finished constructing ProjectTree");
Expand Down
4 changes: 2 additions & 2 deletions dev/src/view/InitViews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

import * as vscode from "vscode";

import ProjectTreeDataProvider from "./ProjectTree";
import CodewindTreeDataProvider from "./CodewindTree";
import Log from "../Logger";

export default function createViews(): vscode.Disposable[] {
Log.d("Initializing views");

return [
(new ProjectTreeDataProvider()).treeView,
(new CodewindTreeDataProvider()).treeView,
];
}
4 changes: 2 additions & 2 deletions dev/src/view/TreeItemFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import StringNamespaces from "../constants/strings/StringNamespaces";
import Log from "../Logger";
import Commands from "../constants/Commands";
import CodewindManager from "../codewind/connection/CodewindManager";
import { CODEWIND_STATES } from "../codewind/connection/CodewindStates";

const STRING_NS = StringNamespaces.TREEVIEW;

Expand Down Expand Up @@ -71,7 +70,8 @@ namespace TreeItemFactory {
const cwStarted = CodewindManager.instance.isStarted;

let label = "Codewind";
if (CODEWIND_STATES[cwState].isErrorState || CODEWIND_STATES[cwState].isTransitionState) {
// Show state except when started (since it's obvious in that case).
if (!cwStarted) {
label += ` (${cwState})`;
}
const tooltip = (CodewindManager.instance.codewindUrl || "Stopped").toString();
Expand Down

0 comments on commit c2437af

Please sign in to comment.