Skip to content

Commit

Permalink
TreeView plugin API
Browse files Browse the repository at this point in the history
Signed-off-by: Vitaliy Gulyy <vgulyy@redhat.com>
  • Loading branch information
vitaliy-guliy authored and Vitaliy Gulyy committed Oct 24, 2018
1 parent 233802d commit ed44327
Show file tree
Hide file tree
Showing 12 changed files with 1,091 additions and 101 deletions.
48 changes: 47 additions & 1 deletion packages/plugin-ext/src/api/plugin-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ export interface QuickOpenMain {
export interface WorkspaceMain {
$pickWorkspaceFolder(options: WorkspaceFolderPickOptionsMain): Promise<theia.WorkspaceFolder | undefined>;
$startFileSearch(includePattern: string, excludePatternOrDisregardExcludes: string | false,
maxResults: number | undefined, token: theia.CancellationToken): PromiseLike<UriComponents[]>;
maxResults: number | undefined, token: theia.CancellationToken): PromiseLike<UriComponents[]>;

}

Expand All @@ -326,6 +326,50 @@ export interface DialogsMain {
$showSaveDialog(options: SaveDialogOptionsMain): Promise<string | undefined>;
}

export interface TreeViewsMain {
$registerTreeDataProvider(treeViewId: string): void;
$refresh(treeViewId: string): void;
$reveal(treeViewId: string): void;
}

export interface TreeViewsExt {
$getChildren(treeViewId: string, treeItemId: string | undefined): Promise<TreeViewItem[] | undefined>;
$setExpanded(treeViewId: string, treeItemId: string, expanded: boolean): Promise<any>;
$setSelection(treeViewId: string, treeItemId: string): Promise<any>;
}

export class TreeViewItem {

id: string;

label: string;

icon?: string;

tooltip?: string;

collapsibleState?: TreeViewItemCollapsibleState;

}

/**
* Collapsible state of the tree item
*/
export enum TreeViewItemCollapsibleState {
/**
* Determines an item can be neither collapsed nor expanded. Implies it has no children.
*/
None = 0,
/**
* Determines an item is collapsed
*/
Collapsed = 1,
/**
* Determines an item is expanded
*/
Expanded = 2
}

export interface WindowStateExt {
$onWindowStateChanged(focus: boolean): void;
}
Expand Down Expand Up @@ -694,6 +738,7 @@ export const PLUGIN_RPC_CONTEXT = {
STATUS_BAR_MESSAGE_REGISTRY_MAIN: <ProxyIdentifier<StatusBarMessageRegistryMain>>createProxyIdentifier<StatusBarMessageRegistryMain>('StatusBarMessageRegistryMain'),
ENV_MAIN: createProxyIdentifier<EnvMain>('EnvMain'),
TERMINAL_MAIN: createProxyIdentifier<TerminalServiceMain>('TerminalServiceMain'),
TREE_VIEWS_MAIN: createProxyIdentifier<TreeViewsMain>('TreeViewsMain'),
PREFERENCE_REGISTRY_MAIN: createProxyIdentifier<PreferenceRegistryMain>('PreferenceRegistryMain'),
OUTPUT_CHANNEL_REGISTRY_MAIN: <ProxyIdentifier<OutputChannelRegistryMain>>createProxyIdentifier<OutputChannelRegistryMain>('OutputChannelRegistryMain'),
LANGUAGES_MAIN: createProxyIdentifier<LanguagesMain>('LanguagesMain'),
Expand All @@ -709,6 +754,7 @@ export const MAIN_RPC_CONTEXT = {
EDITORS_AND_DOCUMENTS_EXT: createProxyIdentifier<EditorsAndDocumentsExt>('EditorsAndDocumentsExt'),
DOCUMENTS_EXT: createProxyIdentifier<DocumentsExt>('DocumentsExt'),
TERMINAL_EXT: createProxyIdentifier<TerminalServiceExt>('TerminalServiceExt'),
TREE_VIEWS_EXT: createProxyIdentifier<TreeViewsExt>('TreeViewsExt'),
PREFERENCE_REGISTRY_EXT: createProxyIdentifier<PreferenceRegistryExt>('PreferenceRegistryExt'),
LANGUAGES_EXT: createProxyIdentifier<LanguagesExt>('LanguagesExt'),
};
6 changes: 5 additions & 1 deletion packages/plugin-ext/src/main/browser/main-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { OutputChannelRegistryMainImpl } from './output-channel-registry-main';
import { TerminalServiceMainImpl } from './terminal-main';
import { LanguagesMainImpl } from './languages-main';
import { DialogsMainImpl } from './dialogs-main';
import { TreeViewsMainImpl } from './view/tree-views-main';

export function setUpPluginApi(rpc: RPCProtocol, container: interfaces.Container): void {
const commandRegistryMain = new CommandRegistryMainImpl(rpc, container);
Expand Down Expand Up @@ -60,9 +61,12 @@ export function setUpPluginApi(rpc: RPCProtocol, container: interfaces.Container
const envMain = new EnvMainImpl(rpc, container);
rpc.set(PLUGIN_RPC_CONTEXT.ENV_MAIN, envMain);

const terminalMain = new TerminalServiceMainImpl(container, rpc);
const terminalMain = new TerminalServiceMainImpl(rpc, container);
rpc.set(PLUGIN_RPC_CONTEXT.TERMINAL_MAIN, terminalMain);

const treeViewsMain = new TreeViewsMainImpl(rpc, container);
rpc.set(PLUGIN_RPC_CONTEXT.TREE_VIEWS_MAIN, treeViewsMain);

const outputChannelRegistryMain = new OutputChannelRegistryMainImpl(container);
rpc.set(PLUGIN_RPC_CONTEXT.OUTPUT_CHANNEL_REGISTRY_MAIN, outputChannelRegistryMain);

Expand Down
32 changes: 27 additions & 5 deletions packages/plugin-ext/src/main/browser/style/view-registry.css
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@
box-sizing: border-box;
}

.theia-views-container-section-control[role='opened']:before {
.theia-views-container-section-control[opened='true']:before {
font-family: FontAwesome;
font-size: calc(var(--theia-content-font-size) * 0.8);
content: "\F0D7";
}

.theia-views-container-section-control[role='closed']:before {
.theia-views-container-section-control[opened='false']:before {
font-family: FontAwesome;
font-size: calc(var(--theia-content-font-size) * 0.8);
content: "\F0DA";
Expand All @@ -95,12 +95,34 @@

.theia-views-container-section-content {
min-height: 30px;
text-align: center;
color: var(--theia-ui-font-color3);
font-size: var(--theia-ui-font-size3);
padding: 20px 0px;
position: relative;

width: 100%;
height: 300px;
}

.theia-views-container-section-content[role='closed'] {
.theia-views-container-section-content[opened='false'] {
display: none;
}

.theia-views-container-section-content > div {
position: absolute;
width: 100%;
height: 100%;
}

.theia-views-container-section-content .tree-view-icon {
max-height: calc(var(--theia-content-font-size) * 0.8);
line-height: 0.8em;

}

.theia-views-container-section-content .tree-view-icon:before {
font-size: calc(var(--theia-content-font-size) * 0.8);
text-align: center;
margin-right: 4px;
top: -1px;
position: relative;
}
2 changes: 1 addition & 1 deletion packages/plugin-ext/src/main/browser/terminal-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class TerminalServiceMainImpl implements TerminalServiceMain {
private terminalNumber = 0;
private readonly TERM_ID_PREFIX = 'plugin-terminal-';

constructor(container: interfaces.Container, rpc: RPCProtocol) {
constructor(rpc: RPCProtocol, container: interfaces.Container) {
this.terminalService = container.get(TerminalService);
this.shell = container.get(ApplicationShell);
this.extProxy = rpc.getProxy(MAIN_RPC_CONTEXT.TERMINAL_EXT);
Expand Down
Loading

0 comments on commit ed44327

Please sign in to comment.