-
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.
[#7268] Adjust behavior of all close tab commands so that they respec…
…t the widget.title.closable propertySigned-off-by: Vivien Jovet <vivien.jovet@gmail.com>
- Loading branch information
Showing
6 changed files
with
137 additions
and
28 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
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
45 changes: 45 additions & 0 deletions
45
examples/api-samples/src/browser/view/sample-uncloable-view-contribution.ts
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,45 @@ | ||
/******************************************************************************** | ||
* Copyright (C) 2020 TORO Limited 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, bindViewContribution, WidgetFactory } from '@theia/core/lib/browser'; | ||
import { SampleViewUnclosableView } from './sample-unclosable-view'; | ||
import { injectable, interfaces } from 'inversify'; | ||
|
||
@injectable() | ||
export class SampleUnclosableViewContribution extends AbstractViewContribution<SampleViewUnclosableView> { | ||
|
||
static readonly SAMPLE_UNCLOSABLE_VIEW_TOGGLE_COMMAND_ID = 'sampleUnclosableView:toggle'; | ||
|
||
constructor() { | ||
super({ | ||
widgetId: SampleViewUnclosableView.ID, | ||
widgetName: 'Sample Unclosable View', | ||
toggleCommandId: SampleUnclosableViewContribution.SAMPLE_UNCLOSABLE_VIEW_TOGGLE_COMMAND_ID, | ||
defaultWidgetOptions: { | ||
area: 'main' | ||
} | ||
}); | ||
} | ||
} | ||
|
||
export const bindSampleUnclosableView = (bind: interfaces.Bind) => { | ||
bindViewContribution(bind, SampleUnclosableViewContribution); | ||
bind(SampleViewUnclosableView).toSelf(); | ||
bind(WidgetFactory).toDynamicValue(ctx => ({ | ||
id: SampleViewUnclosableView.ID, | ||
createWidget: () => ctx.container.get<SampleViewUnclosableView>(SampleViewUnclosableView) | ||
})); | ||
}; |
46 changes: 46 additions & 0 deletions
46
examples/api-samples/src/browser/view/sample-unclosable-view.tsx
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,46 @@ | ||
/******************************************************************************** | ||
* Copyright (C) 2020 TORO Limited 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, postConstruct } from 'inversify'; | ||
import * as React from 'react'; | ||
|
||
/** | ||
* This sample view is used to demo the behavior of "Widget.title.closable". | ||
*/ | ||
@injectable() | ||
export class SampleViewUnclosableView extends ReactWidget { | ||
static readonly ID = 'sampleUnclosableView'; | ||
|
||
@postConstruct() | ||
init(): void { | ||
this.id = SampleViewUnclosableView.ID; | ||
this.title.caption = 'Sample'; | ||
this.title.label = 'Sample'; | ||
this.title.iconClass = 'fa fa-window-maximize'; | ||
this.title.closable = false; | ||
this.update(); | ||
} | ||
|
||
protected render(): React.ReactNode { | ||
return ( | ||
<div> | ||
Closable | ||
<input type="checkbox" defaultChecked={this.title.closable} onChange={e => this.title.closable = e.target.checked} /> | ||
</div> | ||
); | ||
} | ||
} |
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