Skip to content

Commit

Permalink
Review improvements
Browse files Browse the repository at this point in the history
- rename extension from `secondary-window-ui` to `secondary-window`
- append application and workspace name to secondary window titles
- customize open editor tree label for secondary window area to be more readable
- remove `moveWidgetToSecondaryWindow` from `application-shell` again to avoid accidental usage
- mark `SecondaryWindowHandler` and `SecondaryWindowService` as experimental

Signed-off-by: Lucas Koehler <lkoehler@eclipsesource.com>
  • Loading branch information
lucas-koehler committed Sep 2, 2022
1 parent 434690b commit 853e9db
Show file tree
Hide file tree
Showing 28 changed files with 42 additions and 41 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

## v1.30.0

- [core] Added support for moving webview-based views into a secondary window/tab for browser applications. Added new extension `secondary-window-ui` that contributes the UI integration to use this. [#11048](https://github.com/eclipse-theia/theia/pull/11048) - Contributed on behalf of ST Microelectronics and Ericsson and by ARM and EclipseSource
- [core] Added support for moving webview-based views into a secondary window for browser applications. Added new extension `secondary-window` that contributes the UI integration to use this. [#11048](https://github.com/eclipse-theia/theia/pull/11048) - Contributed on behalf of ST Microelectronics and Ericsson and by ARM and EclipseSource

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

Expand Down
2 changes: 1 addition & 1 deletion examples/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@theia/scm": "1.29.0",
"@theia/scm-extra": "1.29.0",
"@theia/search-in-workspace": "1.29.0",
"@theia/secondary-window-ui": "1.29.0",
"@theia/secondary-window": "1.29.0",
"@theia/task": "1.29.0",
"@theia/terminal": "1.29.0",
"@theia/timeline": "1.29.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/browser/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"path": "../../packages/search-in-workspace"
},
{
"path": "../../packages/secondary-window-ui"
"path": "../../packages/secondary-window"
},
{
"path": "../../packages/task"
Expand Down
2 changes: 1 addition & 1 deletion packages/core/i18n/nls.cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@
"resultSubset": "Jedná se pouze o podmnožinu všech výsledků. Pro zúžení seznamu výsledků použijte konkrétnější vyhledávací výraz.",
"searchOnEditorModification": "Prohledat aktivní editor při úpravě."
},
"secondary-window-ui": {
"secondary-window": {
"extract-widget": "Přesunutí zobrazení do sekundárního okna"
},
"task": {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/i18n/nls.de.json
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@
"resultSubset": "Dies ist nur eine Teilmenge aller Ergebnisse. Verwenden Sie einen spezifischeren Suchbegriff, um die Ergebnisliste einzugrenzen.",
"searchOnEditorModification": "Durchsucht den aktiven Editor nach Änderungen."
},
"secondary-window-ui": {
"secondary-window": {
"extract-widget": "Ansicht in sekundäres Fenster verschieben"
},
"task": {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/i18n/nls.es.json
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@
"resultSubset": "Esto es sólo un subconjunto de todos los resultados. Utilice un término de búsqueda más específico para reducir la lista de resultados.",
"searchOnEditorModification": "Busca en el editor activo cuando se modifica."
},
"secondary-window-ui": {
"secondary-window": {
"extract-widget": "Mover la vista a la ventana secundaria"
},
"task": {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/i18n/nls.fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@
"resultSubset": "Il ne s'agit que d'un sous-ensemble de tous les résultats. Utilisez un terme de recherche plus spécifique pour réduire la liste des résultats.",
"searchOnEditorModification": "Rechercher l'éditeur actif lorsqu'il est modifié."
},
"secondary-window-ui": {
"secondary-window": {
"extract-widget": "Déplacer la vue vers une fenêtre secondaire"
},
"task": {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/i18n/nls.hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@
"resultSubset": "Ez csak egy részhalmaza az összes eredménynek. A találati lista szűkítéséhez használjon konkrétabb keresési kifejezést.",
"searchOnEditorModification": "Keresés az aktív szerkesztőben, amikor módosítják."
},
"secondary-window-ui": {
"secondary-window": {
"extract-widget": "Nézet áthelyezése másodlagos ablakba"
},
"task": {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/i18n/nls.it.json
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@
"resultSubset": "Questo è solo un sottoinsieme di tutti i risultati. Usa un termine di ricerca più specifico per restringere la lista dei risultati.",
"searchOnEditorModification": "Cerca l'editor attivo quando viene modificato."
},
"secondary-window-ui": {
"secondary-window": {
"extract-widget": "Sposta la vista nella finestra secondaria"
},
"task": {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/i18n/nls.ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@
"resultSubset": "これは、すべての結果の一部に過ぎません。より具体的な検索用語を使って、結果リストを絞り込んでください。",
"searchOnEditorModification": "修正されたときにアクティブなエディタを検索します。"
},
"secondary-window-ui": {
"secondary-window": {
"extract-widget": "セカンダリーウィンドウへの表示移動"
},
"task": {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/i18n/nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@
"resultSubset": "This is only a subset of all results. Use a more specific search term to narrow down the result list.",
"searchOnEditorModification": "Search the active editor when modified."
},
"secondary-window-ui": {
"secondary-window": {
"extract-widget": "Move View to Secondary Window"
},
"task": {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/i18n/nls.pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@
"resultSubset": "To jest tylko podzbiór wszystkich wyników. Użyj bardziej szczegółowego terminu wyszukiwania, aby zawęzić listę wyników.",
"searchOnEditorModification": "Przeszukiwanie aktywnego edytora po modyfikacji."
},
"secondary-window-ui": {
"secondary-window": {
"extract-widget": "Przenieś widok do okna podrzędnego"
},
"task": {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/i18n/nls.pt-br.json
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@
"resultSubset": "Este é apenas um subconjunto de todos os resultados. Use um termo de busca mais específico para restringir a lista de resultados.",
"searchOnEditorModification": "Pesquise o editor ativo quando modificado."
},
"secondary-window-ui": {
"secondary-window": {
"extract-widget": "Mover vista para a janela secundária"
},
"task": {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/i18n/nls.pt-pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@
"resultSubset": "Este é apenas um subconjunto de todos os resultados. Use um termo de pesquisa mais específico para restringir a lista de resultados.",
"searchOnEditorModification": "Pesquisar o editor activo quando modificado."
},
"secondary-window-ui": {
"secondary-window": {
"extract-widget": "Mover vista para a janela secundária"
},
"task": {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/i18n/nls.ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@
"resultSubset": "Это только часть всех результатов. Используйте более конкретный поисковый запрос, чтобы сузить список результатов.",
"searchOnEditorModification": "Поиск активного редактора при изменении."
},
"secondary-window-ui": {
"secondary-window": {
"extract-widget": "Переместить вид в дополнительное окно"
},
"task": {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/i18n/nls.zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@
"resultSubset": "这只是所有结果的一个子集。使用一个更具体的搜索词来缩小结果列表。",
"searchOnEditorModification": "修改时搜索活动的编辑器。"
},
"secondary-window-ui": {
"secondary-window": {
"extract-widget": "将视图移至第二窗口"
},
"task": {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/browser/secondary-window-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ class SecondaryWindowRootWidget extends Widget {
* This handler manages the opened secondary windows and sets up messaging between them and the Theia main window.
* In addition, it provides access to the extracted widgets and provides notifications when widgets are added to or removed from this handler.
*
* _Note:_ This handler is used by the application shell and there should be no need for callers to directly interact with this class.
* Instead, consider using the application shell.
* @experimental The functionality provided by this handler is experimental and has known issues in Electron apps.
*/
@injectable()
export class SecondaryWindowHandler {
Expand Down Expand Up @@ -147,11 +146,12 @@ export class SecondaryWindowHandler {

this.secondaryWindows.push(newWindow);

const mainWindowTitle = document.title;
newWindow.onload = () => {
// Use the widget's title as the window title
// Even if the widget's label were malicious, this should be safe against XSS because the HTML standard defines this is inserted via a text node.
// See https://html.spec.whatwg.org/multipage/dom.html#document.title
newWindow.document.title = widget.title.label;
newWindow.document.title = `${widget.title.label}${mainWindowTitle}`;

const element = newWindow.document.getElementById('widget-host');
if (!element) {
Expand Down
5 changes: 1 addition & 4 deletions packages/core/src/browser/shell/application-shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { FrontendApplicationStateService } from '../frontend-application-state';
import { TabBarToolbarRegistry, TabBarToolbarFactory } from './tab-bar-toolbar';
import { ContextKeyService } from '../context-key-service';
import { Emitter } from '../../common/event';
import { ExtractableWidget, waitForRevealed, waitForClosed, PINNED_CLASS } from '../widgets';
import { waitForRevealed, waitForClosed, PINNED_CLASS } from '../widgets';
import { CorePreferences } from '../core-preferences';
import { BreadcrumbsRendererFactory } from '../breadcrumbs/breadcrumbs-renderer';
import { Deferred } from '../../common/promise-util';
Expand Down Expand Up @@ -1946,9 +1946,6 @@ export class ApplicationShell extends Widget {
}
}

async moveWidgetToSecondaryWindow(widget: ExtractableWidget): Promise<void> {
this.secondaryWindowHandler.moveWidgetToSecondaryWindow(widget);
}
}

/**
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/browser/window/secondary-window-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@

export const SecondaryWindowService = Symbol('SecondaryWindowService');

/** Service for opening new secondary windows to contain widgets extracted from the application shell. */
/**
* Service for opening new secondary windows to contain widgets extracted from the application shell.
*
* @experimental The functionality provided by this service and its implementation is still under development. Use with caution.
*/
export interface SecondaryWindowService {
/**
* Creates a new secondary window for a widget to be extracted from the application shell.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export class OpenEditorsModel extends FileTreeModel {
const areaNode: CompositeTreeNode & ExpandableTreeNode = {
id: `${OpenEditorsModel.AREA_NODE_ID_PREFIX}:${area}`,
parent: rootNode,
name: area,
name: area === 'secondaryWindow' ? 'in secondary window' : area,
expanded: true,
children: []
};
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

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

<h2>ECLIPSE THEIA - WIDGET-EXTRACTION-UI EXTENSION</h2>
<h2>ECLIPSE THEIA - SECONDARY WINDOW EXTENSION</h2>

<hr />

</div>

## Description

The `@theia/secondary-window-ui` extension contributes UI integration that allows moving widgets to secondary windows.
The `@theia/secondary-window` extension contributes UI integration that allows moving widgets to secondary windows.

### Limitations

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@theia/secondary-window-ui",
"name": "@theia/secondary-window",
"version": "1.29.0",
"description": "Theia - Secondary window UI contributions",
"dependencies": {
Expand All @@ -10,7 +10,7 @@
},
"theiaExtensions": [
{
"frontend": "lib/browser/secondary-window-ui-frontend-module"
"frontend": "lib/browser/secondary-window-frontend-module"
}
],
"keywords": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@
// *****************************************************************************

import { inject, injectable } from '@theia/core/shared/inversify';
import { ApplicationShell } from '@theia/core/lib/browser/shell';
import { CommandRegistry, CommandContribution, Command } from '@theia/core/lib/common/command';
import { codicon, ExtractableWidget } from '@theia/core/lib/browser/widgets';
import { TabBarToolbarContribution, TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
import { SecondaryWindowHandler } from '@theia/core/lib/browser/secondary-window-handler';

export const EXTRACT_WIDGET = Command.toLocalizedCommand({
id: 'extract-widget',
label: 'Move View to Secondary Window'
}, 'theia/secondary-window-ui/extract-widget');
}, 'theia/secondary-window/extract-widget');

/** Contributes the widget extraction command and registers it in the toolbar of extractable widgets. */
@injectable()
export class SecondaryWindowUiContribution implements CommandContribution, TabBarToolbarContribution {
export class SecondaryWindowContribution implements CommandContribution, TabBarToolbarContribution {

@inject(ApplicationShell)
protected readonly shell: ApplicationShell;
@inject(SecondaryWindowHandler)
protected readonly secondaryWindowHandler: SecondaryWindowHandler;

registerCommands(commands: CommandRegistry): void {
commands.registerCommand(EXTRACT_WIDGET, {
execute: async widget => this.shell.moveWidgetToSecondaryWindow(widget),
execute: async widget => this.secondaryWindowHandler.moveWidgetToSecondaryWindow(widget),
isVisible: widget => ExtractableWidget.is(widget),
isEnabled: widget => ExtractableWidget.is(widget)
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
// *****************************************************************************

import { ContainerModule } from '@theia/core/shared/inversify';
import { SecondaryWindowUiContribution } from './secondary-window-ui-frontend-contribution';
import { SecondaryWindowContribution } from './secondary-window-frontend-contribution';
import { CommandContribution } from '@theia/core/lib/common/command';
import { TabBarToolbarContribution } from '@theia/core/lib/browser/shell/tab-bar-toolbar';

export default new ContainerModule(bind => {
bind(SecondaryWindowUiContribution).toSelf().inSingletonScope();
bind(CommandContribution).toService(SecondaryWindowUiContribution);
bind(TabBarToolbarContribution).toService(SecondaryWindowUiContribution);
bind(SecondaryWindowContribution).toSelf().inSingletonScope();
bind(CommandContribution).toService(SecondaryWindowContribution);
bind(TabBarToolbarContribution).toService(SecondaryWindowContribution);
});

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
// *****************************************************************************

describe('secondary-window-ui package', () => {
describe('secondary-window package', () => {
it('supports code coverage statistics', () => true);
});
File renamed without changes.
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
"path": "packages/search-in-workspace"
},
{
"path": "packages/secondary-window-ui"
"path": "packages/secondary-window"
},
{
"path": "packages/task"
Expand Down

0 comments on commit 853e9db

Please sign in to comment.