Skip to content

Commit

Permalink
Added progress extension
Browse files Browse the repository at this point in the history
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
  • Loading branch information
JPinkney committed Jul 30, 2018
1 parent 322e930 commit 245a325
Show file tree
Hide file tree
Showing 17 changed files with 576 additions and 4 deletions.
3 changes: 2 additions & 1 deletion examples/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"@theia/typescript": "^0.3.13",
"@theia/userstorage": "^0.3.13",
"@theia/variable-resolver": "^0.3.13",
"@theia/workspace": "^0.3.13"
"@theia/workspace": "^0.3.13",
"@theia/progress-monitor-extension": "^0.3.13"
},
"scripts": {
"prepare": "yarn run clean && yarn build",
Expand Down
1 change: 1 addition & 0 deletions packages/java/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"@theia/editor": "^0.3.13",
"@theia/languages": "^0.3.13",
"@theia/monaco": "^0.3.13",
"@theia/progress-monitor-extension": "^0.3.13",
"@types/glob": "^5.0.30",
"@types/tar": "4.0.0",
"glob": "^7.1.2",
Expand Down
15 changes: 12 additions & 3 deletions packages/java/src/browser/java-client-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ import {
Window, ILanguageClient, BaseLanguageClientContribution, Workspace, Languages, LanguageClientFactory, LanguageClientOptions
} from '@theia/languages/lib/browser';
import { JAVA_LANGUAGE_ID, JAVA_LANGUAGE_NAME } from '../common';
import { ActionableNotification, ActionableMessage, StatusReport, StatusNotification } from "./java-protocol";
import { ActionableNotification, ActionableMessage, StatusReport, StatusNotification, ProgressReportNotification } from "./java-protocol";
import { StatusBar, StatusBarEntry, StatusBarAlignment } from "@theia/core/lib/browser";
import { ProgressReport, ProgressMonitorService } from '@theia/progress-monitor-extension/lib/browser';

@injectable()
export class JavaClientContribution extends BaseLanguageClientContribution {
Expand All @@ -37,7 +38,8 @@ export class JavaClientContribution extends BaseLanguageClientContribution {
@inject(LanguageClientFactory) protected readonly languageClientFactory: LanguageClientFactory,
@inject(Window) protected readonly window: Window,
@inject(CommandService) protected readonly commandService: CommandService,
@inject(StatusBar) protected readonly statusBar: StatusBar
@inject(StatusBar) protected readonly statusBar: StatusBar,
@inject(ProgressMonitorService) protected readonly progressMonitorService: ProgressMonitorService
) {
super(workspace, languages, languageClientFactory);
}
Expand All @@ -53,6 +55,7 @@ export class JavaClientContribution extends BaseLanguageClientContribution {
protected onReady(languageClient: ILanguageClient): void {
languageClient.onNotification(ActionableNotification.type, this.showActionableMessage.bind(this));
languageClient.onNotification(StatusNotification.type, this.showStatusMessage.bind(this));
languageClient.onNotification(ProgressReportNotification.type, this.showProgressReportNotifications.bind(this));
super.onReady(languageClient);
}

Expand All @@ -73,6 +76,11 @@ export class JavaClientContribution extends BaseLanguageClientContribution {
}, 5000);
}

protected showProgressReportNotifications(progressReport: ProgressReport) {
progressReport.location = "Java";
this.progressMonitorService.addOrUpdateContribution(progressReport);
}

protected showActionableMessage(message: ActionableMessage): void {
const items = message.commands || [];
this.window.showMessage(message.severity, message.message, ...items).then(command => {
Expand All @@ -87,7 +95,8 @@ export class JavaClientContribution extends BaseLanguageClientContribution {
const options = super.createOptions();
options.initializationOptions = {
extendedClientCapabilities: {
classFileContentsSupport: true
classFileContentsSupport: true,
progressReportProvider: true
}
};
return options;
Expand Down
5 changes: 5 additions & 0 deletions packages/java/src/browser/java-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import { RequestType, NotificationType } from 'vscode-jsonrpc';
import { TextDocumentIdentifier, Command, MessageType } from "@theia/languages/lib/common";
import { ProgressReport } from '@theia/progress-monitor-extension/lib/browser';

export interface StatusReport {
message: string;
Expand All @@ -40,3 +41,7 @@ export namespace ClassFileContentsRequest {
export namespace ActionableNotification {
export const type = new NotificationType<ActionableMessage, void>('language/actionableNotification');
}

export namespace ProgressReportNotification {
export const type = new NotificationType<ProgressReport, void>('language/progressReport');
}
8 changes: 8 additions & 0 deletions packages/progress-monitor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Theia - Progress Monitor Extension

Contributes a progress widget to Theia.

## License

- [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
- [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
10 changes: 10 additions & 0 deletions packages/progress-monitor/compile.tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../configs/base.tsconfig.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "lib"
},
"include": [
"src"
]
}
47 changes: 47 additions & 0 deletions packages/progress-monitor/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "@theia/progress-monitor-extension",
"version": "0.3.13",
"description": "Theia - Progress Monitor Extension",
"dependencies": {
"@theia/core": "^0.3.13",
"@theia/editor": "^0.3.13"
},
"publishConfig": {
"access": "public"
},
"theiaExtensions": [
{
"frontend": "lib/browser/progress-monitor-frontend-module"
}
],
"keywords": [
"theia-extension"
],
"license": "EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0",
"repository": {
"type": "git",
"url": "https://github.com/theia-ide/theia.git"
},
"bugs": {
"url": "https://github.com/theia-ide/theia/issues"
},
"homepage": "https://github.com/theia-ide/theia",
"files": [
"lib",
"src"
],
"scripts": {
"prepare": "yarn run clean && yarn run build",
"clean": "theiaext clean",
"build": "theiaext build",
"watch": "theiaext watch",
"test": "theiaext test",
"docs": "theiaext docs"
},
"devDependencies": {
"@theia/ext-scripts": "^0.3.12"
},
"nyc": {
"extends": "../../configs/nyc.json"
}
}
17 changes: 17 additions & 0 deletions packages/progress-monitor/src/browser/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/********************************************************************************
* Copyright (C) 2018 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 * from './progress-service';
export * from './progress-protocol';
81 changes: 81 additions & 0 deletions packages/progress-monitor/src/browser/progress-dialog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/********************************************************************************
* Copyright (C) 2018 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
********************************************************************************/

import { injectable, inject } from "inversify";
import { Message } from '@phosphor/messaging';
import { Disposable } from "@theia/core";
import { Widget, BaseWidget, Key } from "@theia/core/lib/browser";
import { ProgressWidget } from "./progress-widget";

@injectable()
export class ProgressDialog extends BaseWidget {

protected readonly contentNode: HTMLDivElement;

protected isOpen: boolean = false;

constructor(
@inject(ProgressWidget) readonly widget: ProgressWidget
) {
super();

this.contentNode = document.createElement("div");
this.contentNode.classList.add('theia-ProgressContent');

this.node.classList.add('theia-ProgressWidgetDialog');

this.node.appendChild(this.contentNode);

this.toDispose.push(widget);

this.update();
}

protected onUpdateRequest(msg: Message): void {
super.onUpdateRequest(msg);
this.widget.update();
}

protected onAfterAttach(msg: Message): void {
super.onAfterAttach(msg);
Widget.attach(this.widget, this.contentNode);
this.toDisposeOnDetach.push(Disposable.create(() =>
Widget.detach(this.widget)
));

this.addKeyListener(document.body, Key.ESCAPE, e => {
this.close();
this.isOpen = false;
});
}

protected onActivateRequest(msg: Message): void {
super.onActivateRequest(msg);
this.widget.activate();
}

async toggleOpen(): Promise<void> {
if (this.isOpen) {
this.close();
} else {
const thisStatusBarItem = document.getElementsByClassName("theia-ProgressStatusBar").item(0) as HTMLElement;
Widget.attach(this, thisStatusBarItem);
this.activate();
}
this.isOpen = !this.isOpen;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/********************************************************************************
* Copyright (C) 2018 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
********************************************************************************/

import { ContainerModule, interfaces } from "inversify";
import { WidgetFactory, FrontendApplicationContribution } from "@theia/core/lib/browser";
import { ProgressMonitorService } from "./progress-service";
import { ProgressDialog } from "./progress-dialog";
import { ProgressStatusBar } from "./progress-status-bar";
import { ProgressWidget } from "./progress-widget";

export default new ContainerModule((bind: interfaces.Bind, unbind: interfaces.Unbind, isBound: interfaces.IsBound, rebind: interfaces.Rebind) => {

bind(ProgressDialog).toSelf();

bind(ProgressStatusBar).toSelf().inSingletonScope();
bind(FrontendApplicationContribution).toDynamicValue(ctx => ctx.container.get(ProgressStatusBar)).inSingletonScope();

bind(ProgressMonitorService).toSelf().inSingletonScope();

bind(ProgressWidget).toSelf();
bind(WidgetFactory).toDynamicValue(ctx => ({
id: "progress-monitor-extension",
createWidget: () => ctx.container.get(ProgressWidget)
}));

});
24 changes: 24 additions & 0 deletions packages/progress-monitor/src/browser/progress-protocol.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/********************************************************************************
* Copyright (C) 2018 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 interface ProgressReport {
location: string; // Location denoting what part of theia this item is coming from
id: string;
task: string;
workDone: number;
totalWork: number;
complete: boolean;
}
31 changes: 31 additions & 0 deletions packages/progress-monitor/src/browser/progress-service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/********************************************************************************
* Copyright (C) 2018 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
********************************************************************************/

import { injectable } from "inversify";
import { Emitter, Event } from "@theia/core/lib/common";
import { ProgressReport } from "./progress-protocol";

@injectable()
export class ProgressMonitorService {

protected readonly onContributionAddedOrUpdatedEmitter = new Emitter<ProgressReport>();
public onContributionAdded: Event<ProgressReport> = this.onContributionAddedOrUpdatedEmitter.event;

addOrUpdateContribution(progressContribution: ProgressReport): void {
this.onContributionAddedOrUpdatedEmitter.fire(progressContribution);
}

}
Loading

0 comments on commit 245a325

Please sign in to comment.