-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented Toolbar support for sidepanels and changed sidepanel tabs.
Every sidepanel has an header now where the title and a toolbar is shown (if tools are registered for that widget). As an example the control buttons of search in workspace extension are moved to the toolbar. Additionally the tabs of sidebars don't show labels anymore but icons. Fixes #3864
- Loading branch information
Showing
22 changed files
with
383 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/******************************************************************************** | ||
* Copyright (C) 2018 TypeFox 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, Title } from "@phosphor/widgets"; | ||
import { TabBarToolbar, TabBarToolbarRegistry } from "@theia/core/src/browser/shell/tab-bar-toolbar"; | ||
import { Message } from "@phosphor/messaging"; | ||
|
||
export class SidePanelToolbar extends Widget { | ||
|
||
protected titleContainer: HTMLElement | undefined; | ||
private _toolbarTitle: Title<Widget> | undefined; | ||
protected toolbar: TabBarToolbar | undefined; | ||
|
||
constructor( | ||
protected readonly tabBarToolbarRegistry: TabBarToolbarRegistry, | ||
protected readonly tabBarToolbarFactory: () => TabBarToolbar, | ||
protected readonly side: 'left' | 'right') { | ||
super(); | ||
this.init(); | ||
} | ||
|
||
protected onAfterAttach(msg: Message): void { | ||
if (this.toolbar) { | ||
if (this.toolbar.isAttached) { | ||
Widget.detach(this.toolbar); | ||
} | ||
Widget.attach(this.toolbar, this.node); | ||
} | ||
super.onAfterAttach(msg); | ||
} | ||
|
||
protected onBeforeDetach(msg: Message): void { | ||
if (this.titleContainer) { | ||
this.node.removeChild(this.titleContainer); | ||
} | ||
if (this.toolbar && this.toolbar.isAttached) { | ||
Widget.detach(this.toolbar); | ||
} | ||
super.onBeforeDetach(msg); | ||
} | ||
|
||
protected onUpdateRequest(msg: Message): void { | ||
super.onUpdateRequest(msg); | ||
this.updateToolbar(); | ||
} | ||
|
||
protected updateToolbar(): void { | ||
if (!this.toolbar) { | ||
return; | ||
} | ||
const current = this._toolbarTitle; | ||
const widget = current && current.owner || undefined; | ||
|
||
const items = widget ? this.tabBarToolbarRegistry.visibleItems(widget) : []; | ||
items.forEach(i => i.onDidChange && i.onDidChange(() => { | ||
this.update(); | ||
})); | ||
this.toolbar.updateItems(items, widget); | ||
} | ||
|
||
protected init(): void { | ||
this.titleContainer = document.createElement('div'); | ||
this.titleContainer.classList.add('theia-sidepanel-title'); | ||
this.node.appendChild(this.titleContainer); | ||
this.node.classList.add('theia-sidepanel-toolbar'); | ||
this.node.classList.add(`theia-${this.side}-side-panel`); | ||
this.toolbar = this.tabBarToolbarFactory(); | ||
this.update(); | ||
} | ||
|
||
set toolbarTitle(title: Title<Widget> | undefined) { | ||
if (this.titleContainer && title) { | ||
this._toolbarTitle = title; | ||
this.titleContainer.innerHTML = this._toolbarTitle.label; | ||
this.update(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.