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

Initial contribution of property-view extension #8655

Merged
merged 1 commit into from
Mar 2, 2021
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
- [core] updated connection status service to prevent false positive alerts about offline mode [#9068](https://github.com/eclipse-theia/theia/pull/9068)
- [tasks] add support for workspace-scoped task configurations. [#8917](https://github.com/eclipse-theia/theia/pull/8917)
- [workspace] add support for configurations outside the `settings` object and add `WorkspaceSchemaUpdater` to allow configurations sections to be contributed by extensions. [#8917](https://github.com/eclipse-theia/theia/pull/8917)
- [property-view] added initial version of a selection-based property-view [#8655](https://github.com/eclipse-theia/theia/pull/8655)
- A default implementation is available for file selections (via file navigator and default editors).

<a name="breaking_changes_1.12.0">[Breaking Changes:](#breaking_changes_1.12.0)</a>

Expand Down
3 changes: 3 additions & 0 deletions configs/root-compilation.tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@
},
{
"path": "../packages/timeline/compile.tsconfig.json"
},
{
"path": "../packages/property-view/compile.tsconfig.json"
}
]
}
2 changes: 2 additions & 0 deletions examples/api-tests/src/menus.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ describe('Menus', function () {
const { OutputContribution } = require('@theia/output/lib/browser/output-contribution');
const { PluginFrontendViewContribution } = require('@theia/plugin-ext/lib/main/browser/plugin-frontend-view-contribution');
const { ProblemContribution } = require('@theia/markers/lib/browser/problem/problem-contribution');
const { PropertyViewContribution } = require('@theia/property-view/lib/browser/property-view-contribution');
const { SearchInWorkspaceFrontendContribution } = require('@theia/search-in-workspace/lib/browser/search-in-workspace-frontend-contribution');
const { HostedPluginSupport } = require('@theia/plugin-ext/lib/hosted/browser/hosted-plugin');

Expand Down Expand Up @@ -67,6 +68,7 @@ describe('Menus', function () {
container.get(OutputContribution),
container.get(PluginFrontendViewContribution),
container.get(ProblemContribution),
container.get(PropertyViewContribution),
container.get(SearchInWorkspaceFrontendContribution)
]) {
it(`should toggle '${contribution.viewLabel}' view`, async () => {
Expand Down
4 changes: 3 additions & 1 deletion examples/api-tests/src/views.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe('Views', function () {
const { ScmContribution } = require('@theia/scm/lib/browser/scm-contribution');
const { OutlineViewContribution } = require('@theia/outline-view/lib/browser/outline-view-contribution');
const { ProblemContribution } = require('@theia/markers/lib/browser/problem/problem-contribution');
const { PropertyViewContribution } = require('@theia/property-view/lib/browser/property-view-contribution');
const { HostedPluginSupport } = require('@theia/plugin-ext/lib/hosted/browser/hosted-plugin');

/** @type {import('inversify').Container} */
Expand All @@ -34,6 +35,7 @@ describe('Views', function () {
const scmContribution = container.get(ScmContribution);
const outlineContribution = container.get(OutlineViewContribution);
const problemContribution = container.get(ProblemContribution);
const propertyViewContribution = container.get(PropertyViewContribution);
const pluginService = container.get(HostedPluginSupport);

before(() => Promise.all([
Expand All @@ -44,7 +46,7 @@ describe('Views', function () {
})()
]));

for (const contribution of [navigatorContribution, scmContribution, outlineContribution, problemContribution]) {
for (const contribution of [navigatorContribution, scmContribution, outlineContribution, problemContribution, propertyViewContribution]) {
it(`should toggle ${contribution.viewLabel}`, async function () {
let view = await contribution.closeView();
if (view) {
Expand Down
1 change: 1 addition & 0 deletions examples/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"@theia/preferences": "1.11.0",
"@theia/preview": "1.11.0",
"@theia/process": "1.11.0",
"@theia/property-view": "1.11.0",
"@theia/scm": "1.11.0",
"@theia/scm-extra": "1.11.0",
"@theia/search-in-workspace": "1.11.0",
Expand Down
3 changes: 3 additions & 0 deletions examples/electron/compile.tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@
},
{
"path": "../../packages/timeline/compile.tsconfig.json"
},
{
"path": "../../packages/property-view/compile.tsconfig.json"
}
]
}
1 change: 1 addition & 0 deletions examples/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"@theia/preferences": "1.11.0",
"@theia/preview": "1.11.0",
"@theia/process": "1.11.0",
"@theia/property-view": "1.11.0",
"@theia/scm": "1.11.0",
"@theia/scm-extra": "1.11.0",
"@theia/search-in-workspace": "1.11.0",
Expand Down
10 changes: 10 additions & 0 deletions packages/property-view/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
extends: [
'../../configs/build.eslintrc.json'
],
parserOptions: {
tsconfigRootDir: __dirname,
project: 'compile.tsconfig.json'
}
};
44 changes: 44 additions & 0 deletions packages/property-view/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<div align='center'>

<br />

<img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />

<h2>ECLIPSE THEIA - PROPERTY-VIEW EXTENSION</h2>

<hr />

</div>

## Description

The `@theia/property-view` extension contributes a generic, global property view based on Theia's global selection.

The property view widget can be opened/toggled either via menu _View->Properties_ or via shortcut <kbd>Shift+Alt+P</kbd>. It is located in the bottom dock area by default.

The following two default content widgets are implemented in this extension:
- EmptyPropertyViewWidget: If no other widget can be provided, a simple message (_No properties available_) is shown.
- ResourcePropertyViewWidget: Can handle `FileSelection`s and `Navigatable` selections (which provide their resource URI) and displays the general `FileStat` information (e.g. location, name, last modified) in a TreeWidget.

To contribute a specific property view, it is necessary to implement a `PropertyViewDataService` which gathers the property data for a selection as well as a `PropertyViewWidgetProvider` which provides a suitable content widget to display the property data for a specific selection inside the property view widget.

</br>

## Additional Information

- [API documentation for `@theia/property-view`](https://eclipse-theia.github.io/theia/docs/next/modules/property_view.html)
- [Theia - GitHub](https://github.com/eclipse-theia/theia)
- [Theia - Website](https://theia-ide.org/)

## 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)

## Trademark
"Theia" is a trademark of the Eclipse Foundation
https://www.eclipse.org/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)
19 changes: 19 additions & 0 deletions packages/property-view/compile.tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": "../../configs/base.tsconfig",
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "lib"
},
"include": [
"src"
],
"references": [
{
"path": "../core/compile.tsconfig.json"
},
{
"path": "../filesystem/compile.tsconfig.json"
}
]
}
46 changes: 46 additions & 0 deletions packages/property-view/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "@theia/property-view",
"version": "1.11.0",
"description": "Theia - Property View Extension",
"dependencies": {
"@theia/core": "1.11.0",
"@theia/filesystem": "1.11.0"
},
"publishConfig": {
"access": "public"
},
"theiaExtensions": [
{
"frontend": "lib/browser/property-view-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/eclipse-theia/theia.git"
},
"bugs": {
"url": "https://github.com/eclipse-theia/theia/issues"
},
"homepage": "https://github.com/eclipse-theia/theia",
"files": [
"lib",
"src"
],
"scripts": {
"lint": "theiaext lint",
"build": "theiaext build",
"watch": "theiaext watch",
"clean": "theiaext clean",
"test": "theiaext test"
},
"devDependencies": {
"@theia/ext-scripts": "1.11.0"
},
"nyc": {
"extends": "../../configs/nyc.json"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/********************************************************************************
* Copyright (C) 2020 EclipseSource 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 { ReactWidget } from '@theia/core/lib/browser';
import { injectable } from 'inversify';
import * as React from 'react';
import { PropertyViewContentWidget } from './property-view-content-widget';
import { DefaultPropertyViewWidgetProvider } from './property-view-widget-provider';

class EmptyPropertyViewWidget extends ReactWidget implements PropertyViewContentWidget {

static readonly ID = 'theia-empty-property-view';
static readonly LABEL = 'No Properties';

constructor() {
super();
this.id = EmptyPropertyViewWidget.ID;
this.title.label = EmptyPropertyViewWidget.LABEL;
this.title.caption = EmptyPropertyViewWidget.LABEL;
this.title.closable = false;
this.node.tabIndex = 0;
}

updatePropertyViewContent(): void {
this.update();
}

protected render(): React.ReactNode {
return this.emptyComponent;
}

protected emptyComponent: JSX.Element = <div className={'theia-widget-noInfo'}>No properties available.</div>;

}

/**
* `DefaultPropertyViewWidgetProvider` is implemented to provide the PropertyViewEmptyWidget
* if the given selection is undefined or no other provider can handle the given selection.
*/
@injectable()
export class EmptyPropertyViewWidgetProvider extends DefaultPropertyViewWidgetProvider {

static readonly ID = 'no-properties';
readonly id = EmptyPropertyViewWidgetProvider.ID;
readonly label = 'DefaultPropertyViewWidgetProvider';

private emptyWidget: EmptyPropertyViewWidget;

constructor() {
super();
this.emptyWidget = new EmptyPropertyViewWidget();
}

canHandle(selection: Object | undefined): number {
return selection === undefined ? 1 : 0;
}

provideWidget(selection: Object | undefined): Promise<EmptyPropertyViewWidget> {
return Promise.resolve(this.emptyWidget);
}

updateContentWidget(selection: Object | undefined): void {
this.emptyWidget.updatePropertyViewContent();
}
}
48 changes: 48 additions & 0 deletions packages/property-view/src/browser/property-data-service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/********************************************************************************
* Copyright (C) 2020 EclipseSource 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 const PropertyDataService = Symbol('PropertyDataService');
/**
* `PropertyDataService` should be implemented to provide property data for the given selection.
*/
export interface PropertyDataService {

/**
* A unique id for this provider.
*/
readonly id: string;
/**
* A human-readable name for this provider.
*/
readonly label?: string;

/**
* Test whether this provider can provide property data for the given selection.
* Return a nonzero number if this provider can provide; otherwise it cannot.
* Never reject.
*
* A returned value indicating a priority of this provider.
*/
canHandleSelection(selection: Object | undefined): number;

/**
* Provide property data for the given selection.
* Resolve to a property view content widget.
* Never reject if `canHandle` return a positive number; otherwise should reject.
*/
providePropertyData(selection: Object | undefined): Promise<Object | undefined>;

}
22 changes: 22 additions & 0 deletions packages/property-view/src/browser/property-view-content-widget.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/********************************************************************************
* Copyright (C) 2020 EclipseSource 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 { Widget } from '@theia/core/lib/browser/widgets/widget';
import { PropertyDataService } from './property-data-service';

export interface PropertyViewContentWidget extends Widget {
updatePropertyViewContent(propertyDataService?: PropertyDataService, selection?: Object): void;
}
36 changes: 36 additions & 0 deletions packages/property-view/src/browser/property-view-contribution.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/********************************************************************************
* Copyright (C) 2020 EclipseSource 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 { AbstractViewContribution } from '@theia/core/lib/browser/shell/view-contribution';
import { injectable } from 'inversify';
import { PropertyViewWidget } from './property-view-widget';

@injectable()
export class PropertyViewContribution extends AbstractViewContribution<PropertyViewWidget> {

constructor() {
super({
widgetId: PropertyViewWidget.ID,
widgetName: PropertyViewWidget.LABEL,
defaultWidgetOptions: {
area: 'bottom'
},
toggleCommandId: 'property-view:toggle',
toggleKeybinding: 'shift+alt+p'
});
}

}
Loading