Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Progress extension #5176

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ cache:
- packages/preferences/node_modules
- packages/preview/node_modules
- packages/process/node_modules
- packages/progress-monitor/node_modules
- packages/python/node_modules
- packages/scm/node_modules
- packages/search-in-workspace/node_modules
Expand Down
1 change: 1 addition & 0 deletions examples/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"@theia/preferences": "^0.7.0",
"@theia/preview": "^0.7.0",
"@theia/process": "^0.7.0",
"@theia/progress-monitor": "^0.7.0",
"@theia/python": "^0.7.0",
"@theia/scm": "^0.7.0",
"@theia/search-in-workspace": "^0.7.0",
Expand Down
1 change: 1 addition & 0 deletions examples/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"@theia/preview": "^0.7.0",
"@theia/process": "^0.7.0",
"@theia/python": "^0.7.0",
"@theia/progress-monitor": "^0.7.0",
"@theia/search-in-workspace": "^0.7.0",
"@theia/task": "^0.7.0",
"@theia/terminal": "^0.7.0",
Expand Down
12 changes: 12 additions & 0 deletions packages/core/src/browser/status-bar/status-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ export interface StatusBar {
setColor(color?: string): Promise<void>;
setElement(id: string, entry: StatusBarEntry): Promise<void>;
removeElement(id: string): Promise<void>;
hasElement(id: string): Promise<boolean>;
getElementByClass(className: string): Promise<HTMLCollectionOf<Element>>;
}

@injectable()
Expand Down Expand Up @@ -95,12 +97,22 @@ export class StatusBarImpl extends ReactWidget implements StatusBar {
this.update();
}

async hasElement(id: string): Promise<boolean> {
await this.ready;
return this.entries.has(id);
}

async removeElement(id: string): Promise<void> {
await this.ready;
this.entries.delete(id);
this.update();
}

async getElementByClass(className: string) {
await this.ready;
return Object.assign({}, this.node.getElementsByClassName(className));
}

async setBackgroundColor(color?: string): Promise<void> {
await this.ready;
this.internalSetBackgroundColor(color);
Expand Down
1 change: 1 addition & 0 deletions packages/git/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"@theia/editor": "^0.7.0",
"@theia/filesystem": "^0.7.0",
"@theia/languages": "^0.7.0",
"@theia/progress-monitor": "^0.7.0",
"@theia/navigator": "^0.7.0",
"@theia/scm": "^0.7.0",
"@theia/workspace": "^0.7.0",
Expand Down
20 changes: 19 additions & 1 deletion packages/git/src/browser/git-quick-open-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { QuickOpenService, QuickOpenOptions } from '@theia/core/lib/browser/quic
import { Git, Repository, Branch, BranchType, Tag, Remote, StashEntry } from '../common';
import { GitRepositoryProvider } from './git-repository-provider';
import { MessageService } from '@theia/core/lib/common/message-service';
import { ProgressService } from '@theia/progress-monitor/lib/browser/progress-service';
import URI from '@theia/core/lib/common/uri';
import { WorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
import { FileSystem } from '@theia/filesystem/lib/common';
Expand All @@ -45,6 +46,7 @@ export class GitQuickOpenService {
@inject(GitRepositoryProvider) protected readonly repositoryProvider: GitRepositoryProvider,
@inject(QuickOpenService) protected readonly quickOpenService: QuickOpenService,
@inject(MessageService) protected readonly messageService: MessageService,
@inject(ProgressService) protected readonly progressService: ProgressService,
@inject(WorkspaceService) protected readonly workspaceService: WorkspaceService,
@inject(FileSystem) protected readonly fileSystem: FileSystem
) { }
Expand Down Expand Up @@ -77,11 +79,27 @@ export class GitQuickOpenService {
dynamicItems.push(new SingleStringInputOpenItem(
`Clone the Git repository: ${lookFor}. ${suffix}`,
async () => {
const progressReport = {
id: `git-clone-${lookFor}`,
task: 'Cloning git repositories',
location: lookFor,
totalWork: 1,
workDone: 0,
complete: false
};
gitQuickOpenService.progressService.addOrUpdateContribution(progressReport);
try {
await gitQuickOpenService.git.clone(lookFor, { localUri: await gitQuickOpenService.buildDefaultProjectPath(gitCloneLocalTargetFolder, lookFor) });
const progressCallback = (progress: Git.CloneProgress) => {
progressReport.workDone = progress.value;
};
const localUri = await gitQuickOpenService.buildDefaultProjectPath(gitCloneLocalTargetFolder, lookFor);
await gitQuickOpenService.git.clone(lookFor, { localUri }, progressCallback);
progressReport.workDone = progressReport.totalWork;
} catch (error) {
gitQuickOpenService.gitErrorHandler.handleError(error);
}
progressReport.complete = true;
gitQuickOpenService.progressService.addOrUpdateContribution(progressReport);
}
));
}
Expand Down
14 changes: 13 additions & 1 deletion packages/git/src/common/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ export const Git = Symbol('Git');

export namespace Git {

export interface CloneProgress {
readonly kind: 'clone';
/**
* The progress of the operation, represented as a fraction between 0 and 1.
*/
readonly value: number;
/**
* An informative text for user consumption indicating the current operation state.
*/
readonly title: string;
}

/**
* Options for various Git commands.
*/
Expand Down Expand Up @@ -597,7 +609,7 @@ export interface Git extends Disposable {
* @param remoteUrl the URL of the remote.
* @param options the clone options.
*/
clone(remoteUrl: string, options: Git.Options.Clone): Promise<Repository>;
clone(remoteUrl: string, options: Git.Options.Clone, progressCallback?: (progress: Git.CloneProgress) => void): Promise<Repository>;

/**
* Resolves to an array of repositories discovered in the workspace given with the workspace root URI.
Expand Down
4 changes: 2 additions & 2 deletions packages/git/src/node/dugite-git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,11 @@ export class DugiteGit implements Git {
this.gitInit.dispose();
}

async clone(remoteUrl: string, options: Git.Options.Clone): Promise<Repository> {
async clone(remoteUrl: string, options: Git.Options.Clone, progressCallback?: (progress: Git.CloneProgress) => void): Promise<Repository> {
await this.ready.promise;
const { localUri, branch } = options;
const [exec, env] = await Promise.all([this.execProvider.exec(), this.gitEnv.promise]);
await clone(remoteUrl, this.getFsPath(localUri), { branch }, { exec, env });
await clone(remoteUrl, this.getFsPath(localUri), { branch }, { exec, env }, progressCallback);
return { localUri };
}

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.7.0",
"@theia/languages": "^0.7.0",
"@theia/monaco": "^0.7.0",
"@theia/progress-monitor": "^0.7.0",
"@types/glob": "^5.0.30",
"@types/tar": "4.0.0",
"glob": "^7.1.2",
Expand Down
14 changes: 12 additions & 2 deletions packages/java/src/browser/java-client-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import {
LanguageClientOptions
} from '@theia/languages/lib/browser';
import { JAVA_LANGUAGE_ID, JAVA_LANGUAGE_NAME, JavaStartParams } from '../common';
import { ProgressReportNotification } from './java-protocol';
import { ProgressReport, ProgressService } from '@theia/progress-monitor/lib/browser';
import {
ActionableNotification,
ActionableMessage,
Expand Down Expand Up @@ -60,7 +62,8 @@ export class JavaClientContribution extends BaseLanguageClientContribution {
@inject(Window) protected readonly window: Window,
@inject(CommandService) protected readonly commandService: CommandService,
@inject(StatusBar) protected readonly statusBar: StatusBar,
@inject(SemanticHighlightingService) protected readonly semanticHighlightingService: SemanticHighlightingService
@inject(SemanticHighlightingService) protected readonly semanticHighlightingService: SemanticHighlightingService,
@inject(ProgressService) protected readonly progressMonitorService: ProgressService
) {
super(workspace, languages, languageClientFactory);
}
Expand All @@ -81,6 +84,7 @@ export class JavaClientContribution extends BaseLanguageClientContribution {
languageClient.onNotification(ActionableNotification.type, this.showActionableMessage.bind(this));
languageClient.onNotification(StatusNotification.type, this.showStatusMessage.bind(this));
languageClient.onRequest(ExecuteClientCommand.type, params => this.commandService.executeCommand(params.command, ...params.arguments));
languageClient.onNotification(ProgressReportNotification.type, this.showProgressReportNotifications.bind(this));
super.onReady(languageClient);
}

Expand All @@ -107,6 +111,11 @@ export class JavaClientContribution extends BaseLanguageClientContribution {
}, 500);
}

protected showProgressReportNotifications(progressReport: ProgressReport) {
const javaProgressReport = Object.assign(progressReport, { location: 'Java' });
this.progressMonitorService.addOrUpdateContribution(javaProgressReport);
}

protected showActionableMessage(message: ActionableMessage): void {
const items = message.commands || [];
this.window.showMessage(message.severity, message.message, ...items).then(command => {
Expand All @@ -121,7 +130,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, ExecuteCommandParams } from '@theia/languages/lib/browser';
import { ProgressReport } from '@theia/progress-monitor/lib/browser';

export interface StatusReport {
message: string;
Expand Down Expand Up @@ -56,3 +57,7 @@ export namespace CompileWorkspaceRequest {
export namespace ExecuteClientCommand {
export const type = new RequestType<ExecuteCommandParams, undefined, void, void>('workspace/executeClientCommand');
}

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

Contributes an progress monitor widget to Theia that allows users to show status of long running processes.
This status can come from either the backend i.e. language servers or from the front end.

See [here](https://github.com/theia-ide/theia) for a detailed documentation on 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",
"version": "0.7.0",
"description": "Theia - Progress Monitor",
"dependencies": {
"@theia/core": "^0.7.0",
"@theia/editor": "^0.7.0"
},
"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.7.0"
},
"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';
Loading