Skip to content

Commit

Permalink
Merge branch 'master' of github.com:theia-ide/theia into theia-4103
Browse files Browse the repository at this point in the history
  • Loading branch information
vinokurig committed Feb 8, 2019
2 parents a5213df + ba4c62a commit a35aaf7
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 14 deletions.
24 changes: 23 additions & 1 deletion packages/core/src/browser/preferences/preference-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,32 @@ export class PreferenceSchemaProvider extends PreferenceProvider {
}
}
for (const property of props) {
this.preferences[property] = this.combinedSchema.properties[property].default;
this.preferences[property] = this.getDefaultValue(this.combinedSchema.properties[property]);
}
}

protected getDefaultValue(property: PreferenceDataProperty): any {
if (property.default) {
return property.default;
}
const type = Array.isArray(property.type) ? property.type[0] : property.type;
switch (type) {
case 'boolean':
return false;
case 'integer':
case 'number':
return 0;
case 'string':
return '';
case 'array':
return [];
case 'object':
return {};
}
// tslint:disable-next-line:no-null-keyword
return null;
}

protected updateValidate(): void {
this.validateFunction = new Ajv().compile(this.combinedSchema);
}
Expand Down
7 changes: 4 additions & 3 deletions packages/core/src/browser/style/dialog.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@
background-color: var(--theia-ui-dialog-header-color);
color: var(--theia-ui-dialog-header-font-color);
padding: 0 calc(var(--theia-ui-padding)*2);
height: 28px;
min-height: 24px;
}

.p-Widget.dialogOverlay .dialogTitle i.closeButton {
cursor: pointer;
}
}

.p-Widget.dialogOverlay .dialogContent {
display: flex;
Expand All @@ -74,6 +74,7 @@
align-content: right;
flex-wrap: nowrap;
justify-content: flex-end;
min-height: 21px;
}

input {
Expand All @@ -98,7 +99,7 @@ input {
font-size: var(--theia-ui-font-size1);
border-radius: 0;
background: transparent;
outline: none;
outline: none;
}

.p-Widget.dialogOverlay.hidden {
Expand Down
2 changes: 1 addition & 1 deletion packages/filesystem/src/browser/style/file-dialog.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

.dialogContent .theia-NavigationPanel,
.dialogContent .theia-FiltersPanel {
height: 27px;
min-height: 27px;
}

.dialogContent .theia-FileNamePanel {
Expand Down
8 changes: 6 additions & 2 deletions packages/plugin-ext/src/api/plugin-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { QueryParameters } from '../common/env';
import { TextEditorCursorStyle } from '../common/editor-options';
import { TextEditorLineNumbersStyle, EndOfLine, OverviewRulerLane, IndentAction, FileOperationOptions } from '../plugin/types-impl';
import { UriComponents } from '../common/uri-components';
import { PreferenceChange } from '@theia/core/lib/browser';
import { ConfigurationTarget } from '../plugin/types-impl';
import {
SerializedDocumentFilter,
Expand Down Expand Up @@ -810,8 +809,13 @@ export interface PreferenceRegistryMain {
resource: any | undefined
): PromiseLike<void>;
}

export interface PreferenceChangeExt {
preferenceName: string,
newValue: any
}
export interface PreferenceRegistryExt {
$acceptConfigurationChanged(data: { [key: string]: any }, eventData: PreferenceChange): void;
$acceptConfigurationChanged(data: { [key: string]: any }, eventData: PreferenceChangeExt): void;
}

export interface OutputChannelRegistryMain {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ export class PreferenceRegistryMainImpl implements PreferenceRegistryMain {

preferenceServiceImpl.onPreferenceChanged(e => {
const data = getPreferences(this.preferenceProviderProvider);
this.proxy.$acceptConfigurationChanged(data, Object.assign({}, e));
this.proxy.$acceptConfigurationChanged(data, {
preferenceName: e.preferenceName,
newValue: e.newValue
});
});
}

Expand Down
17 changes: 11 additions & 6 deletions packages/plugin-ext/src/plugin/preference-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import {
PLUGIN_RPC_CONTEXT,
PreferenceRegistryExt,
PreferenceRegistryMain,
PreferenceData
PreferenceData,
PreferenceChangeExt
} from '../api/plugin-api';
import { RPCProtocol } from '../api/rpc-protocol';
import { isObject } from '../common/types';
import { PreferenceChange } from '@theia/core/lib/browser';
import { isObject, mixin } from '../common/types';
import { Configuration, ConfigurationModel } from './preferences/configuration';
import { WorkspaceExtImpl } from './workspace';
import cloneDeep = require('lodash.clonedeep');
Expand Down Expand Up @@ -83,7 +83,7 @@ export class PreferenceRegistryExtImpl implements PreferenceRegistryExt {
this._preferences = this.parse(data);
}

$acceptConfigurationChanged(data: PreferenceData, eventData: PreferenceChange): void {
$acceptConfigurationChanged(data: PreferenceData, eventData: PreferenceChangeExt): void {
this.init(data);
this._onDidChangeConfiguration.fire(this.toConfigurationChangeEvent(eventData));
}
Expand Down Expand Up @@ -179,7 +179,12 @@ export class PreferenceRegistryExtImpl implements PreferenceRegistryExt {
return configInspect;
}
};
return configuration;

if (typeof preferences === 'object') {
mixin(configuration, preferences, false);
}

return Object.freeze(configuration);
}

private toReadonlyValue(data: any): any {
Expand Down Expand Up @@ -237,7 +242,7 @@ export class PreferenceRegistryExtImpl implements PreferenceRegistryExt {
}, {});
}

private toConfigurationChangeEvent(eventData: PreferenceChange): theia.ConfigurationChangeEvent {
private toConfigurationChangeEvent(eventData: PreferenceChangeExt): theia.ConfigurationChangeEvent {
return Object.freeze({
affectsConfiguration: (section: string, uri?: theia.Uri): boolean => {
const tree = eventData.preferenceName
Expand Down

0 comments on commit a35aaf7

Please sign in to comment.