Skip to content

Commit

Permalink
Merge branch 'master' into quickInput2
Browse files Browse the repository at this point in the history
  • Loading branch information
JPinkney authored May 20, 2019
2 parents e427d31 + f7e55b9 commit 6262da5
Show file tree
Hide file tree
Showing 18 changed files with 251 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
> [Submit a session proposal](https://docs.google.com/forms/d/1EpFRHG1duzmQ4I9TbB6hSzYpSBq03FXt3EOKBzmwXwA/edit) for Theia Developer Conference June 2019 in Stockholm, Sweden ([learn more](https://github.com/theia-ide/theia/wiki/Theia-Developer-Conference-2019))
> [Register Now!](https://theiadevcon.org#register) for TheiaDevCon June 2019 in Stockholm, Sweden ([learn more](https://theiadevcon.org))
<br/>
<div id="theia-logo" align="center">
Expand Down
4 changes: 2 additions & 2 deletions packages/mini-browser/src/browser/mini-browser-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ export class MiniBrowserContent extends BaseWidget {
clearTimeout(this.frameLoadTimeout);
this.maybeResetBackground();
this.hideLoadIndicator();
this.showErrorBar('Loading this page is taking longer than usual');
this.showErrorBar('Still loading...');
}

protected showLoadIndicator(): void {
Expand Down Expand Up @@ -657,7 +657,7 @@ export class MiniBrowserContent extends BaseWidget {
this.input.title = `Open ${url} In A New Window`;
}
clearTimeout(this.frameLoadTimeout);
this.frameLoadTimeout = window.setTimeout(this.onFrameTimeout.bind(this), 3000);
this.frameLoadTimeout = window.setTimeout(this.onFrameTimeout.bind(this), 4000);
if (showLoadIndicator) {
this.showLoadIndicator();
}
Expand Down
2 changes: 2 additions & 0 deletions packages/navigator/src/browser/navigator-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export namespace FileNavigatorCommands {
};
export const COLLAPSE_ALL: Command = {
id: 'navigator.collapse.all',
category: 'File',
label: 'Collapse Folders in Explorer',
iconClass: 'collapse-all'
};
}
Expand Down
2 changes: 2 additions & 0 deletions packages/plugin-ext/src/api/plugin-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,8 @@ export interface TasksExt {
$resolveTask(handle: number, task: TaskDto, token?: CancellationToken): Promise<TaskDto | undefined>;
$onDidStartTask(execution: TaskExecutionDto): void;
$onDidEndTask(id: number): void;
$onDidStartTaskProcess(processId: number | undefined, execution: TaskExecutionDto): void;
$onDidEndTaskProcess(exitCode: number | undefined, taskId: number): void;
}

export interface TasksMain {
Expand Down
5 changes: 4 additions & 1 deletion packages/plugin-ext/src/hosted/browser/worker/worker-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { EditorsAndDocumentsExtImpl } from '../../../plugin/editors-and-document
import { WorkspaceExtImpl } from '../../../plugin/workspace';
import { MessageRegistryExt } from '../../../plugin/message-registry';
import { WorkerEnvExtImpl } from './worker-env-ext';
import { SelectionServiceExt } from '../../../plugin/selection-provider-ext';

// tslint:disable-next-line:no-any
const ctx = self as any;
Expand Down Expand Up @@ -55,6 +56,7 @@ const messageRegistryExt = new MessageRegistryExt(rpc);
const workspaceExt = new WorkspaceExtImpl(rpc, editorsAndDocuments, messageRegistryExt);
const preferenceRegistryExt = new PreferenceRegistryExtImpl(rpc, workspaceExt);
const debugExt = createDebugExtStub(rpc);
const selectionServiceExt = new SelectionServiceExt();

const pluginManager = new PluginManagerExtImpl({
// tslint:disable-next-line:no-any
Expand Down Expand Up @@ -133,7 +135,8 @@ const apiFactory = createAPIFactory(
preferenceRegistryExt,
editorsAndDocuments,
workspaceExt,
messageRegistryExt
messageRegistryExt,
selectionServiceExt
);
let defaultApi: typeof theia;

Expand Down
5 changes: 4 additions & 1 deletion packages/plugin-ext/src/hosted/node/plugin-host-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { EditorsAndDocumentsExtImpl } from '../../plugin/editors-and-documents';
import { WorkspaceExtImpl } from '../../plugin/workspace';
import { MessageRegistryExt } from '../../plugin/message-registry';
import { EnvNodeExtImpl } from '../../plugin/node/env-node-ext';
import { SelectionServiceExt } from '../../plugin/selection-provider-ext';

/**
* Handle the RPC calls.
Expand All @@ -47,6 +48,7 @@ export class PluginHostRPC {
const messageRegistryExt = new MessageRegistryExt(this.rpc);
const workspaceExt = new WorkspaceExtImpl(this.rpc, editorsAndDocumentsExt, messageRegistryExt);
const preferenceRegistryExt = new PreferenceRegistryExtImpl(this.rpc, workspaceExt);
const selectionServiceExt = new SelectionServiceExt();
this.pluginManager = this.createPluginManager(envExt, preferenceRegistryExt, this.rpc);
this.rpc.set(MAIN_RPC_CONTEXT.HOSTED_PLUGIN_MANAGER_EXT, this.pluginManager);
this.rpc.set(MAIN_RPC_CONTEXT.EDITORS_AND_DOCUMENTS_EXT, editorsAndDocumentsExt);
Expand All @@ -61,7 +63,8 @@ export class PluginHostRPC {
preferenceRegistryExt,
editorsAndDocumentsExt,
workspaceExt,
messageRegistryExt
messageRegistryExt,
selectionServiceExt
);
}

Expand Down
15 changes: 15 additions & 0 deletions packages/plugin-ext/src/main/browser/tasks-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,21 @@ export class TasksMainImpl implements TasksMain {
this.proxy.$onDidEndTask(event.taskId);
}
});

this.taskWatcher.onDidStartTaskProcess((event: TaskInfo) => {
if (event.ctx === this.workspaceRootUri && event.processId !== undefined) {
this.proxy.$onDidStartTaskProcess(event.processId, {
id: event.taskId,
task: event.config
});
}
});

this.taskWatcher.onDidEndTaskProcess((event: TaskExitedEvent) => {
if (event.ctx === this.workspaceRootUri && event.code !== undefined) {
this.proxy.$onDidEndTaskProcess(event.code, event.taskId);
}
});
}

$registerTaskProvider(handle: number, type: string): void {
Expand Down
5 changes: 3 additions & 2 deletions packages/plugin-ext/src/plugin/command-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { CommandRegistryExt, PLUGIN_RPC_CONTEXT as Ext, CommandRegistryMain } fr
import { RPCProtocol } from '../api/rpc-protocol';
import { Disposable } from './types-impl';
import { KnownCommands } from './type-converters';
import { SelectionServiceExt } from './selection-provider-ext';

// tslint:disable-next-line:no-any
export type Handler = <T>(...args: any[]) => T | PromiseLike<T>;
Expand All @@ -29,7 +30,7 @@ export class CommandRegistryImpl implements CommandRegistryExt {
private readonly commands = new Set<string>();
private readonly handlers = new Map<string, Handler>();

constructor(rpc: RPCProtocol) {
constructor(rpc: RPCProtocol, private selectionService: SelectionServiceExt) {
this.proxy = rpc.getProxy(Ext.COMMAND_REGISTRY_MAIN);
}

Expand Down Expand Up @@ -98,7 +99,7 @@ export class CommandRegistryImpl implements CommandRegistryExt {
private executeLocalCommand<T>(id: string, ...args: any[]): PromiseLike<T> {
const handler = this.handlers.get(id);
if (handler) {
return Promise.resolve(handler(...args));
return Promise.resolve(this.selectionService.selection !== undefined ? handler(this.selectionService.selection) : handler(...args));
} else {
return Promise.reject(new Error(`Command ${id} doesn't exist`));
}
Expand Down
20 changes: 17 additions & 3 deletions packages/plugin-ext/src/plugin/plugin-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ import { TasksExtImpl } from './tasks/tasks';
import { DebugExtImpl } from './node/debug/debug';
import { FileSystemExtImpl } from './file-system';
import { QuickPick, QuickPickItem } from '@theia/plugin';
import { SelectionServiceExt } from './selection-provider-ext';

export function createAPIFactory(
rpc: RPCProtocol,
Expand All @@ -134,10 +135,11 @@ export function createAPIFactory(
preferenceRegistryExt: PreferenceRegistryExtImpl,
editorsAndDocumentsExt: EditorsAndDocumentsExtImpl,
workspaceExt: WorkspaceExtImpl,
messageRegistryExt: MessageRegistryExt
messageRegistryExt: MessageRegistryExt,
selectionServiceExt: SelectionServiceExt
): PluginAPIFactory {

const commandRegistry = rpc.set(MAIN_RPC_CONTEXT.COMMAND_REGISTRY_EXT, new CommandRegistryImpl(rpc));
const commandRegistry = rpc.set(MAIN_RPC_CONTEXT.COMMAND_REGISTRY_EXT, new CommandRegistryImpl(rpc, selectionServiceExt));
const quickOpenExt = rpc.set(MAIN_RPC_CONTEXT.QUICK_OPEN_EXT, new QuickOpenExtImpl(rpc));
const dialogsExt = new DialogsExtImpl(rpc);
const windowStateExt = rpc.set(MAIN_RPC_CONTEXT.WINDOW_STATE_EXT, new WindowStateExtImpl());
Expand All @@ -149,7 +151,7 @@ export function createAPIFactory(
const terminalExt = rpc.set(MAIN_RPC_CONTEXT.TERMINAL_EXT, new TerminalServiceExtImpl(rpc));
const outputChannelRegistryExt = new OutputChannelRegistryExt(rpc);
const languagesExt = rpc.set(MAIN_RPC_CONTEXT.LANGUAGES_EXT, new LanguagesExtImpl(rpc, documents));
const treeViewsExt = rpc.set(MAIN_RPC_CONTEXT.TREE_VIEWS_EXT, new TreeViewsExtImpl(rpc, commandRegistry));
const treeViewsExt = rpc.set(MAIN_RPC_CONTEXT.TREE_VIEWS_EXT, new TreeViewsExtImpl(rpc, commandRegistry, selectionServiceExt));
const webviewExt = rpc.set(MAIN_RPC_CONTEXT.WEBVIEWS_EXT, new WebviewsExtImpl(rpc));
const tasksExt = rpc.set(MAIN_RPC_CONTEXT.TASKS_EXT, new TasksExtImpl(rpc));
const connectionExt = rpc.set(MAIN_RPC_CONTEXT.CONNECTION_EXT, new ConnectionExtImpl(rpc));
Expand Down Expand Up @@ -350,6 +352,10 @@ export function createAPIFactory(
},
createInputBox(): theia.InputBox {
return quickOpenExt.createInputBox();
},
registerUriHandler(handler: theia.UriHandler): theia.Disposable {
// TODO Apply full implementation https://github.com/theia-ide/theia/issues/5119
return new Disposable(() => {});
}
};

Expand Down Expand Up @@ -640,6 +646,14 @@ export function createAPIFactory(

onDidEndTask(listener, thisArg?, disposables?) {
return tasksExt.onDidEndTask(listener, thisArg, disposables);
},

onDidStartTaskProcess(listener, thisArg?, disposables?) {
return tasksExt.onDidStartTaskProcess(listener, thisArg, disposables);
},

onDidEndTaskProcess(listener, thisArg?, disposables?) {
return tasksExt.onDidEndTaskProcess(listener, thisArg, disposables);
}
};

Expand Down
28 changes: 28 additions & 0 deletions packages/plugin-ext/src/plugin/selection-provider-ext.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/********************************************************************************
* Copyright (C) 2019 Red Hat, Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

export class SelectionServiceExt {

private currentSelection: Object | undefined;

get selection(): Object | undefined {
return this.currentSelection;
}

set selection(selection: Object | undefined) {
this.currentSelection = selection;
}
}
29 changes: 29 additions & 0 deletions packages/plugin-ext/src/plugin/tasks/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export class TasksExtImpl implements TasksExt {

private readonly onDidExecuteTask: Emitter<theia.TaskStartEvent> = new Emitter<theia.TaskStartEvent>();
private readonly onDidTerminateTask: Emitter<theia.TaskEndEvent> = new Emitter<theia.TaskEndEvent>();
private readonly onDidExecuteTaskProcess: Emitter<theia.TaskProcessStartEvent> = new Emitter<theia.TaskProcessStartEvent>();
private readonly onDidTerminateTaskProcess: Emitter<theia.TaskProcessEndEvent> = new Emitter<theia.TaskProcessEndEvent>();

constructor(rpc: RPCProtocol) {
this.proxy = rpc.getProxy(PLUGIN_RPC_CONTEXT.TASKS_MAIN);
Expand Down Expand Up @@ -74,6 +76,33 @@ export class TasksExtImpl implements TasksExt {
});
}

get onDidStartTaskProcess(): Event<theia.TaskProcessStartEvent> {
return this.onDidExecuteTaskProcess.event;
}

$onDidStartTaskProcess(processId: number, executionDto: TaskExecutionDto): void {
this.onDidExecuteTaskProcess.fire({
processId,
execution: this.getTaskExecution(executionDto)
});
}

get onDidEndTaskProcess(): Event<theia.TaskProcessEndEvent> {
return this.onDidTerminateTaskProcess.event;
}

$onDidEndTaskProcess(exitCode: number, taskId: number): void {
const taskExecution = this.executions.get(taskId);
if (!taskExecution) {
throw new Error(`Task execution with id ${taskId} is not found`);
}

this.onDidTerminateTaskProcess.fire({
execution: taskExecution,
exitCode
});
}

registerTaskProvider(type: string, provider: theia.TaskProvider): theia.Disposable {
const callId = this.addNewAdapter(new TaskProviderAdapter(provider));
this.proxy.$registerTaskProvider(callId, type);
Expand Down
14 changes: 10 additions & 4 deletions packages/plugin-ext/src/plugin/tree/tree-views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ import { Plugin, PLUGIN_RPC_CONTEXT, TreeViewsExt, TreeViewsMain, TreeViewItem }
import { RPCProtocol } from '../../api/rpc-protocol';
import { CommandRegistryImpl } from '../command-registry';
import { PluginPackage } from '../../common';
import { SelectionServiceExt } from '../selection-provider-ext';

export class TreeViewsExtImpl implements TreeViewsExt {

private proxy: TreeViewsMain;

private treeViews: Map<string, TreeViewExtImpl<any>> = new Map<string, TreeViewExtImpl<any>>();

constructor(rpc: RPCProtocol, private commandRegistry: CommandRegistryImpl) {
constructor(rpc: RPCProtocol, private commandRegistry: CommandRegistryImpl, private selectionService: SelectionServiceExt) {
this.proxy = rpc.getProxy(PLUGIN_RPC_CONTEXT.TREE_VIEWS_MAIN);
}

Expand All @@ -50,7 +51,7 @@ export class TreeViewsExtImpl implements TreeViewsExt {
throw new Error('Options with treeDataProvider is mandatory');
}

const treeView = new TreeViewExtImpl(plugin, treeViewId, options.treeDataProvider, this.proxy, this.commandRegistry);
const treeView = new TreeViewExtImpl(plugin, treeViewId, options.treeDataProvider, this.proxy, this.commandRegistry, this.selectionService);
this.treeViews.set(treeViewId, treeView);

return {
Expand Down Expand Up @@ -129,7 +130,8 @@ class TreeViewExtImpl<T> extends Disposable {
private treeViewId: string,
private treeDataProvider: TreeDataProvider<T>,
private proxy: TreeViewsMain,
private commandRegistry: CommandRegistryImpl) {
private commandRegistry: CommandRegistryImpl,
private selectionService: SelectionServiceExt) {

super(() => {
this.dispose();
Expand Down Expand Up @@ -288,16 +290,20 @@ class TreeViewExtImpl<T> extends Disposable {
// get element from a cache
const cachedElement: T | undefined = this.cache.get(treeItemId);

this.selectionService.selection = undefined;

if (cachedElement) {
this.selection = [cachedElement];

// Ask data provider for a tree item for the value
const treeItem = await this.treeDataProvider.getTreeItem(cachedElement);

if (!contextSelection && treeItem.command) {
this.commandRegistry.executeCommand((treeItem.command.command || treeItem.command.id)!, ...(treeItem.command.arguments || []));
await this.commandRegistry.executeCommand((treeItem.command.command || treeItem.command.id)!, ...(treeItem.command.arguments || []));
}
}

this.selectionService.selection = cachedElement;
}

}
Loading

0 comments on commit 6262da5

Please sign in to comment.