Skip to content

Commit

Permalink
Address review comments #2
Browse files Browse the repository at this point in the history
Signed-off-by: Nina Doschek <ndoschek@eclipsesource.com>
  • Loading branch information
ndoschek committed Jan 20, 2021
1 parent 3b6c5d6 commit 281ed4a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ class EmptyPropertyViewWidget extends ReactWidget implements PropertyViewContent
}

protected render(): React.ReactNode {
return <div className={'theia-widget-noInfo'}>{'No properties available.'}</div>;
return this.emptyComponent;
}

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

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export default new ContainerModule(bind => {
bindContributionProvider(bind, PropertyDataService);
bindContributionProvider(bind, PropertyViewWidgetProvider);

bind(PropertyViewWidgetProvider).to(EmptyPropertyViewWidgetProvider).inSingletonScope();
bind(EmptyPropertyViewWidgetProvider).toSelf().inSingletonScope();
bind(PropertyViewWidgetProvider).to(EmptyPropertyViewWidgetProvider);

bind(PropertyViewWidget).toSelf();
bind(WidgetFactory).toDynamicValue(({ container }) => ({
Expand Down
9 changes: 4 additions & 5 deletions packages/property-view/src/browser/property-view-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export class PropertyViewService {
@inject(ContributionProvider) @named(PropertyViewWidgetProvider)
private readonly contributions: ContributionProvider<PropertyViewWidgetProvider>;

@inject(EmptyPropertyViewWidgetProvider)
private readonly emptyWidgetProvider: EmptyPropertyViewWidgetProvider;

private providers: PropertyViewWidgetProvider[] = [];

@postConstruct()
Expand All @@ -41,7 +44,7 @@ export class PropertyViewService {
*/
async getProvider(selection: Object | undefined): Promise<PropertyViewWidgetProvider> {
const provider = await this.prioritize(selection);
return provider ?? this.getEmptyProvider();
return provider ?? this.emptyWidgetProvider;
}

protected async prioritize(selection: Object | undefined): Promise<PropertyViewWidgetProvider | undefined> {
Expand All @@ -55,8 +58,4 @@ export class PropertyViewService {
return prioritized.length !== 0 ? prioritized[0].value : undefined;
}

private getEmptyProvider(): PropertyViewWidgetProvider {
return this.providers.find(p => p.id === EmptyPropertyViewWidgetProvider.ID) as EmptyPropertyViewWidgetProvider;
}

}
8 changes: 6 additions & 2 deletions packages/property-view/src/browser/property-view-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,15 @@ export class PropertyViewWidget extends BaseWidget {
this.addClass('theia-property-view-widget');
this.node.tabIndex = 0;

let disposed = false;
this.toDispose.push(Disposable.create(() => disposed = true));
this.toDispose.push(this.selectionService.onSelectionChanged((selection: Object | undefined) => {
this.propertyViewService.getProvider(selection).then(provider => {
provider.provideWidget(selection).then(contentWidget => {
this.replaceContentWidget(contentWidget);
provider.updateContentWidget(selection);
if (!disposed) {
this.replaceContentWidget(contentWidget);
provider.updateContentWidget(selection);
}
});
});
}));
Expand Down

0 comments on commit 281ed4a

Please sign in to comment.