Skip to content

Commit

Permalink
#6214 fix after move
Browse files Browse the repository at this point in the history
  • Loading branch information
piorek committed Feb 6, 2018
1 parent b261251 commit 96d92bb
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 120 deletions.
2 changes: 1 addition & 1 deletion js/notebook/src/tree/Models/DefaultOptionsModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import DefaultOptionsWidgetInterface from "../JVMOptions/DefaultOptionsWidgetInterface";
import DefaultOptionsWidgetInterface from "../Widgets/JVMOptions/DefaultOptionsWidgetInterface";
import { IDefaultJVMOptions } from "../Types/IJVMOptions";

export default class DefaultOptionsModel {
Expand Down
6 changes: 3 additions & 3 deletions js/notebook/src/tree/Models/JVMOptionsModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
import IJVMOptions, { IDefaultJVMOptions, IOtherJVMOptions, IPropertiesJVMOptions } from "../Types/IJVMOptions";
import DefaultOptionsModel from "./DefaultOptionsModel";
import PropertiesModel from "./PropertiesModel";
import DefaultOptionsWidgetInterface from "../JVMOptions/DefaultOptionsWidgetInterface";
import PropertiesWidgetInterface from "../JVMOptions/PropertiesWidgetInterface";
import OtherOptionsWidgetInterface from "../JVMOptions/OtherOptionsWidgetInterface";
import DefaultOptionsWidgetInterface from "../Widgets/JVMOptions/DefaultOptionsWidgetInterface";
import PropertiesWidgetInterface from "../Widgets/JVMOptions/PropertiesWidgetInterface";
import OtherOptionsWidgetInterface from "../Widgets/JVMOptions/OtherOptionsWidgetInterface";
import OtherOptionsModel from "./OtherOptionsModel";

export default class JVMOptionsModel {
Expand Down
2 changes: 1 addition & 1 deletion js/notebook/src/tree/Models/OtherOptionsModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import OtherOptionsWidgetInterface from "../JVMOptions/OtherOptionsWidgetInterface";
import OtherOptionsWidgetInterface from "../Widgets/JVMOptions/OtherOptionsWidgetInterface";
import { IOtherJVMOptions } from "../Types/IJVMOptions";

export default class OtherOptionsModel {
Expand Down
2 changes: 1 addition & 1 deletion js/notebook/src/tree/Models/PropertiesModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import PropertiesWidgetInterface from "../JVMOptions/PropertiesWidgetInterface";
import PropertiesWidgetInterface from "../Widgets/JVMOptions/PropertiesWidgetInterface";
import { IPropertiesJVMOptions } from "../Types/IJVMOptions";

export default class PropertiesModel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ import * as $ from "jquery";
import * as _ from "underscore";
import { Widget } from "@phosphor/widgets";
import { MessageLoop } from "@phosphor/messaging";
import { Messages } from "./Messages";
import DefaultOptionsWidgetInterface from "./DefaultOptionsWidgetInterface";
import HeapGBValidator from "../../Utils/HeapGBValidator";
import { Messages } from "../../Messages";

export class DefaultOptionsWidget extends Widget {
export default class DefaultOptionsWidget extends Widget implements DefaultOptionsWidgetInterface {

public readonly HEAP_GB_SELECTOR = '#heap_GB';

Expand Down Expand Up @@ -80,43 +82,3 @@ export class DefaultOptionsWidget extends Widget {

}

export class DefaultOptionsModel {

constructor(private widget: DefaultOptionsWidget) {

}

public update(options: { heap_GB: number }) {
this.widget.setHeapGB(options.heap_GB);
}

public static normaliseHeapSize(heap_GB: number): string {
if (heap_GB % 1 === 0) {
return `${heap_GB}g`;
}
return parseInt(`${heap_GB * 1024}`) + 'm';
}
}

class HeapGBValidator {

/**
* @throws Error
* @param value
*/
public static validate(value: any): void {
if ('' === value) {
return;
}
let parsedVal = parseFloat(value);
if (
isNaN(parsedVal)
|| false === isFinite(value)
|| parsedVal <= 0
) {
throw new Error('Heap Size must be a positive decimal number.');
}
return;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import * as $ from "jquery";
import * as _ from "underscore";
import { Widget } from "@phosphor/widgets";
import { MessageLoop, Message } from "@phosphor/messaging";
import { Messages } from "../Messages";
import { IOtherJVMOptions } from "../Types/IJVMOptions";
import OtherOptionsWidgetInterface from "./OtherOptionsWidgetInterface";
import { IOtherJVMOptions } from "../../Types/IJVMOptions";
import { Messages } from "../../Messages";

export default class OtherOptionsWidget extends Widget implements OtherOptionsWidgetInterface {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { IOtherJVMOptions } from "../Types/IJVMOptions";
import { IOtherJVMOptions } from "../../Types/IJVMOptions";

export default interface OtherOptionsWidgetInterface {
onLoad: (other: IOtherJVMOptions) => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ import * as _ from "underscore";

import { Widget } from "@phosphor/widgets";
import { MessageLoop, Message } from "@phosphor/messaging";
import { Messages } from "./Messages";
import PropertiesOptionsChangedMessage = Messages.PropertiesOptionsChangedMessage;
import { IPropertiesJVMOptions } from "../BeakerXApi";
import {IPropertiesJVMOptions} from "../../Types/IJVMOptions";
import {Messages} from "../../Messages";

export class PropertiesWidget extends Widget {
export default class PropertiesWidget extends Widget {

public readonly ADD_BUTTON_SELECTOR: string = '#add_property_jvm_sett';
public readonly PROPERTIES_PANEL_SELECTOR: string = '#properties_property';
Expand Down Expand Up @@ -172,7 +171,7 @@ export class PropertiesWidget extends Widget {
}

private propertiesChanged() {
let msg = new PropertiesOptionsChangedMessage(this.collectProperties());
let msg = new Messages.PropertiesOptionsChangedMessage(this.collectProperties());
MessageLoop.sendMessage(this.parent, msg);
}

Expand All @@ -191,15 +190,6 @@ export class PropertiesWidget extends Widget {
}
}

export class PropertiesModel {
constructor(private widget: PropertiesWidget) {

}

update(properties: IPropertiesJVMOptions) {
this.widget.onLoad(properties);
}
}


namespace Private {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { IPropertiesJVMOptions } from "../Types/IJVMOptions";
import { IPropertiesJVMOptions } from "../../Types/IJVMOptions";

export default interface PropertiesWidgetInterface {
onLoad: (properties: IPropertiesJVMOptions) => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@
import * as $ from "jquery";
import { Panel } from "@phosphor/widgets";
import { Message, MessageLoop } from "@phosphor/messaging";
import { DefaultOptionsModel, DefaultOptionsWidget } from "./JVMOptions/DefaultOptionsWidget";
import { OtherOptionsModel, OtherOptionsWidget } from "./JVMOptions/OtherOptionsWidget";
import { PropertiesModel, PropertiesWidget } from "./JVMOptions/PropertiesWidget";
import BeakerXApi, {
IDefaultJVMOptions, IJVMOptions, IOtherJVMOptions, IPropertiesJVMOptions
} from "./BeakerXApi";
import { Messages } from "./JVMOptions/Messages";
import JVMOptionsChangedMessage = Messages.JVMOptionsChangedMessage;

import { Messages } from "../Messages";

import JVMOptionsModel from "../Models/JVMOptionsModel";
import DefaultOptionsWidget from "./JVMOptions/DefaultOptionsWidget";
import OtherOptionsWidget from "./JVMOptions/OtherOptionsWidget";
import PropertiesWidget from "./JVMOptions/PropertiesWidget";


export default class JVMOptionsWidget extends Panel {

public readonly HTML_ELEMENT_TEMPLATE = `
<style>
#beakerx-tree label {
Expand All @@ -53,15 +54,15 @@ export default class JVMOptionsWidget extends Panel {
switch (msg.type) {
case Messages.TYPE_DEFAULT_JVM_OPTIONS_CHANGED:
this._model.setDefaultOptions((msg as Messages.DefaultOptionsChangedMessage).values);
this.sendMessageToParent(new JVMOptionsChangedMessage(this._model.options));
this.sendMessageToParent(new Messages.JVMOptionsChangedMessage(this._model.options));
break;
case Messages.TYPE_OTHER_JVM_OPTIONS_CHANGED:
this._model.setOtherOptions((msg as Messages.OtherOptionsChangedMessage).options);
this.sendMessageToParent(new JVMOptionsChangedMessage(this._model.options));
this.sendMessageToParent(new Messages.JVMOptionsChangedMessage(this._model.options));
break;
case Messages.TYPE_PROPERTIES_JVM_OPTIONS_CHANGED:
this._model.setPropertiesOptions((msg as Messages.PropertiesOptionsChangedMessage).properties);
this.sendMessageToParent(new JVMOptionsChangedMessage(this._model.options));
this.sendMessageToParent(new Messages.JVMOptionsChangedMessage(this._model.options));
break;
case Messages.TYPE_JVM_OPTIONS_ERROR:
MessageLoop.sendMessage(this.parent, msg);
Expand All @@ -72,6 +73,10 @@ export default class JVMOptionsWidget extends Panel {
}
}

get model(): JVMOptionsModel {
return this._model;
}

private _model: JVMOptionsModel;

private createWidgetStylesElement(): void {
Expand All @@ -96,9 +101,9 @@ export default class JVMOptionsWidget extends Panel {

private createModel(defaultOptionsWidget: DefaultOptionsWidget, propertiesWidget: PropertiesWidget, otherOptionsWidget: OtherOptionsWidget) {
return new JVMOptionsModel(
new DefaultOptionsModel(defaultOptionsWidget),
new PropertiesModel(propertiesWidget),
new OtherOptionsModel(otherOptionsWidget),
defaultOptionsWidget,
propertiesWidget,
otherOptionsWidget,
);
}

Expand All @@ -107,42 +112,3 @@ export default class JVMOptionsWidget extends Panel {
}

}

export class JVMOptionsModel {

private _options: IJVMOptions

constructor(
private defaultOptionsModel: DefaultOptionsModel,
private propertiesOptionsModel: PropertiesModel,
private otherOptionsModel: OtherOptionsModel,
) {
}

public get options(): IJVMOptions {
return this._options;
}

public update(options: IJVMOptions) {
this._options = options;

this.defaultOptionsModel
.update({ heap_GB: options.heap_GB });
this.propertiesOptionsModel
.update(options.properties);
this.otherOptionsModel
.update(options.other);
}

public setDefaultOptions(values: IDefaultJVMOptions) {
this._options.heap_GB = values.heap_GB;
}

public setOtherOptions(options: IOtherJVMOptions) {
this._options.other = options;
}

public setPropertiesOptions(properties: IPropertiesJVMOptions) {
this._options.properties = properties;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import * as $ from "jquery";
import { Widget } from "@phosphor/widgets";

export class SyncIndicatorWidget extends Widget {
export default class SyncIndicatorWidget extends Widget {

public readonly HTML_ELEMENT_TEMPLATE = `
<style>
Expand Down

0 comments on commit 96d92bb

Please sign in to comment.