提交 edeb0a3d 编写于 作者: R Rob Lourens

More settings editor changes - hide actions behind dropdown

上级 2254b1c6
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><g fill="#C5C5C5"><path d="M12.714 9.603c-.07.207-.15.407-.246.601l1.017 2.139c-.335.424-.718.807-1.142 1.143l-2.14-1.018c-.193.097-.394.176-.601.247l-.795 2.235c-.265.03-.534.05-.807.05-.272 0-.541-.02-.806-.05l-.795-2.235c-.207-.071-.408-.15-.602-.247l-2.14 1.017c-.424-.336-.807-.719-1.143-1.143l1.017-2.139c-.094-.193-.175-.393-.245-.6l-2.236-.796c-.03-.265-.05-.534-.05-.807s.02-.542.05-.807l2.236-.795c.07-.207.15-.407.246-.601l-1.016-2.139c.336-.423.719-.807 1.143-1.142l2.14 1.017c.193-.096.394-.176.602-.247l.793-2.236c.265-.03.534-.05.806-.05.273 0 .542.02.808.05l.795 2.236c.207.07.407.15.601.246l2.14-1.017c.424.335.807.719 1.142 1.142l-1.017 2.139c.096.194.176.394.246.601l2.236.795c.029.266.049.535.049.808s-.02.542-.05.807l-2.236.796zm-4.714-4.603c-1.657 0-3 1.343-3 3s1.343 3 3 3 3-1.343 3-3-1.343-3-3-3z"/><circle cx="8" cy="8" r="1.5"/></g></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><g fill="#424242"><path d="M12.714 9.603c-.07.207-.15.407-.246.601l1.017 2.139c-.335.424-.718.807-1.142 1.143l-2.14-1.018c-.193.097-.394.176-.601.247l-.795 2.235c-.265.03-.534.05-.807.05-.272 0-.541-.02-.806-.05l-.795-2.235c-.207-.071-.408-.15-.602-.247l-2.14 1.017c-.424-.336-.807-.719-1.143-1.143l1.017-2.139c-.094-.193-.175-.393-.245-.6l-2.236-.796c-.03-.265-.05-.534-.05-.807s.02-.542.05-.807l2.236-.795c.07-.207.15-.407.246-.601l-1.016-2.139c.336-.423.719-.807 1.143-1.142l2.14 1.017c.193-.096.394-.176.602-.247l.793-2.236c.265-.03.534-.05.806-.05.273 0 .542.02.808.05l.795 2.236c.207.07.407.15.601.246l2.14-1.017c.424.335.807.719 1.142 1.142l-1.017 2.139c.096.194.176.394.246.601l2.236.795c.029.266.049.535.049.808s-.02.542-.05.807l-2.236.796zm-4.714-4.603c-1.657 0-3 1.343-3 3s1.343 3 3 3 3-1.343 3-3-1.343-3-3-3z"/><circle cx="8" cy="8" r="1.5"/></g></svg>
\ No newline at end of file
......@@ -30,19 +30,6 @@
opacity: .7;
}
.settings-editor > .settings-header > .settings-advanced-customization .open-settings-button,
.settings-editor > .settings-header > .settings-advanced-customization .open-settings-button:hover,
.settings-editor > .settings-header > .settings-advanced-customization .open-settings-button:active {
padding: 0;
text-decoration: underline;
display: inline;
}
.settings-editor > .settings-header > .settings-advanced-customization {
opacity: .7;
margin-top: 8px;
}
.settings-editor > .settings-header > .settings-preview-header > .settings-preview-warning {
text-align: right;
text-transform: uppercase;
......@@ -92,15 +79,22 @@
display: flex;
}
.settings-editor > .settings-header > .settings-header-controls .settings-header-controls-right #configured-only-checkbox {
flex-shrink: 0;
.settings-editor > .settings-header > .settings-header-controls .settings-header-controls-right .toolbar-toggle-more {
display: block;
width: 16px;
height: 22px;
margin-right: 4px;
margin-left: 4px;
background-position: center;
background-repeat: no-repeat;
}
.settings-editor > .settings-header > .settings-header-controls .settings-header-controls-right .configured-only-label {
white-space: nowrap;
margin-right: 10px;
margin-left: 2px;
opacity: 0.7;
.vs .settings-editor > .settings-header > .settings-header-controls .settings-header-controls-right .toolbar-toggle-more {
background-image: url('configure.svg');
}
.vs-dark .settings-editor > .settings-header > .settings-header-controls .settings-header-controls-right .toolbar-toggle-more {
background-image: url('configure-inverse.svg');
}
.settings-editor > .settings-header > .settings-header-controls .settings-tabs-widget > .monaco-action-bar .action-item {
......@@ -138,7 +132,7 @@
.settings-editor > .settings-body .settings-toc-container {
width: 175px;
margin-right: 5px;
padding-top: 4px;
padding-top: 8px;
box-sizing: border-box;
}
......
......@@ -5,6 +5,8 @@
import * as DOM from 'vs/base/browser/dom';
import { Button } from 'vs/base/browser/ui/button/button';
import { ToolBar } from 'vs/base/browser/ui/toolbar/toolbar';
import { Action } from 'vs/base/common/actions';
import * as arrays from 'vs/base/common/arrays';
import { Delayer, ThrottledDelayer } from 'vs/base/common/async';
import { CancellationToken } from 'vs/base/common/cancellation';
......@@ -19,6 +21,7 @@ import 'vs/css!./media/settingsEditor2';
import { localize } from 'vs/nls';
import { ConfigurationTarget, IConfigurationOverrides, IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { WorkbenchTree, WorkbenchTreeController } from 'vs/platform/list/browser/listService';
......@@ -56,8 +59,7 @@ export class SettingsEditor2 extends BaseEditor {
private headerContainer: HTMLElement;
private searchWidget: SearchWidget;
private settingsTargetsWidget: SettingsTargetsWidget;
private showConfiguredSettingsOnlyCheckbox: HTMLInputElement;
private toolbar: ToolBar;
private settingsTreeContainer: HTMLElement;
private settingsTree: WorkbenchTree;
......@@ -99,7 +101,8 @@ export class SettingsEditor2 extends BaseEditor {
@IPreferencesSearchService private preferencesSearchService: IPreferencesSearchService,
@ILogService private logService: ILogService,
@IEnvironmentService private environmentService: IEnvironmentService,
@IContextKeyService contextKeyService: IContextKeyService
@IContextKeyService contextKeyService: IContextKeyService,
@IContextMenuService private contextMenuService: IContextMenuService
) {
super(SettingsEditor2.ID, telemetryService, themeService);
this.delayedFilterLogging = new Delayer<void>(1000);
......@@ -203,26 +206,13 @@ export class SettingsEditor2 extends BaseEditor {
}));
this._register(this.searchWidget.onDidChange(() => this.onSearchInputChanged()));
const advancedCustomization = DOM.append(this.headerContainer, $('.settings-advanced-customization'));
const advancedCustomizationLabel = DOM.append(advancedCustomization, $('span.settings-advanced-customization-label'));
advancedCustomizationLabel.textContent = localize('advancedCustomizationLabel', "For advanced customizations open and edit") + ' ';
const openSettingsButton = this._register(new Button(advancedCustomization, { title: true, buttonBackground: null, buttonHoverBackground: null }));
this._register(attachButtonStyler(openSettingsButton, this.themeService, {
buttonBackground: Color.transparent.toString(),
buttonHoverBackground: Color.transparent.toString(),
buttonForeground: foreground
}));
openSettingsButton.label = localize('openSettingsLabel', "settings.json");
openSettingsButton.element.classList.add('open-settings-button');
this._register(openSettingsButton.onDidClick(() => this.openSettingsFile()));
const headerControlsContainer = DOM.append(this.headerContainer, $('.settings-header-controls'));
const targetWidgetContainer = DOM.append(headerControlsContainer, $('.settings-target-container'));
this.settingsTargetsWidget = this._register(this.instantiationService.createInstance(SettingsTargetsWidget, targetWidgetContainer));
this.settingsTargetsWidget.settingsTarget = ConfigurationTarget.USER;
this.settingsTargetsWidget.onDidTargetChange(() => {
this.viewState.settingsTarget = this.settingsTargetsWidget.settingsTarget;
this.toolbar.context = this.settingsTargetsWidget.settingsTarget;
this.settingsTreeModel.update();
this.refreshTreeAndMaintainFocus();
......@@ -234,13 +224,17 @@ export class SettingsEditor2 extends BaseEditor {
private createHeaderControls(parent: HTMLElement): void {
const headerControlsContainerRight = DOM.append(parent, $('.settings-header-controls-right'));
this.showConfiguredSettingsOnlyCheckbox = DOM.append(headerControlsContainerRight, $('input#configured-only-checkbox'));
this.showConfiguredSettingsOnlyCheckbox.type = 'checkbox';
const showConfiguredSettingsOnlyLabel = <HTMLLabelElement>DOM.append(headerControlsContainerRight, $('label.configured-only-label'));
showConfiguredSettingsOnlyLabel.textContent = localize('showOverriddenOnly', "Show modified only");
showConfiguredSettingsOnlyLabel.htmlFor = 'configured-only-checkbox';
this.toolbar = new ToolBar(headerControlsContainerRight, this.contextMenuService, {
ariaLabel: localize('settingsToolbarLabel', "Settings Editor Actions"),
actionRunner: this.actionRunner
});
this._register(DOM.addDisposableListener(this.showConfiguredSettingsOnlyCheckbox, 'change', e => this.onShowConfiguredOnlyClicked()));
const actions = [
this.instantiationService.createInstance(ToggleShowModifiedOnlyAction, this, this.viewState),
this.instantiationService.createInstance(OpenSettingsAction)
];
this.toolbar.setActions([], actions)();
this.toolbar.context = this.settingsTargetsWidget.settingsTarget;
}
private revealSetting(settingName: string): void {
......@@ -444,12 +438,12 @@ export class SettingsEditor2 extends BaseEditor {
}));
}
private onShowConfiguredOnlyClicked(): void {
this.viewState.showConfiguredOnly = this.showConfiguredSettingsOnlyCheckbox.checked;
this.refreshTreeAndMaintainFocus();
this.tocTree.refresh();
this.settingsTree.setScrollPosition(0);
this.expandAll(this.settingsTree);
toggleShowModifiedOnly(): TPromise<void> {
this.viewState.showConfiguredOnly = !this.viewState.showConfiguredOnly;
return this.refreshTreeAndMaintainFocus().then(() => {
this.settingsTree.setScrollPosition(0);
this.expandAll(this.settingsTree);
});
}
private onDidChangeSetting(key: string, value: any): void {
......@@ -841,3 +835,52 @@ export class SettingsEditor2 extends BaseEditor {
this.tocTree.layout(listHeight, 175);
}
}
class OpenSettingsAction extends Action {
static readonly ID = 'settings.openSettingsJson';
static readonly LABEL = localize('openSettingsJsonLabel', "Open settings.json for advanced customizations");
constructor(
@IPreferencesService private readonly preferencesService: IPreferencesService,
) {
super(OpenSettingsAction.ID, OpenSettingsAction.LABEL, 'open-settings-json');
}
run(context?: SettingsTarget): TPromise<void> {
return this._run(context)
.then(() => { });
}
private _run(context?: SettingsTarget): TPromise<any> {
if (context === ConfigurationTarget.USER) {
return this.preferencesService.openGlobalSettings();
} else if (context === ConfigurationTarget.WORKSPACE) {
return this.preferencesService.openWorkspaceSettings();
} else if (URI.isUri(context)) {
return this.preferencesService.openFolderSettings(context);
}
return TPromise.wrap(null);
}
}
class ToggleShowModifiedOnlyAction extends Action {
static readonly ID = 'settings.toggleShowModifiedOnly';
static readonly LABEL = localize('showModifiedOnlyLabel', "Show modified settings only");
get checked(): boolean {
return this.viewState.showConfiguredOnly;
}
constructor(
private settingsEditor: SettingsEditor2,
private viewState: ISettingsEditorViewState
) {
super(ToggleShowModifiedOnlyAction.ID, ToggleShowModifiedOnlyAction.LABEL, 'show-modified-only');
}
run(): TPromise<void> {
return this.settingsEditor.toggleShowModifiedOnly();
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册