separate title and name for table designer editor (#17600)

This commit is contained in:
Alan Ren
2021-11-05 11:09:17 -07:00
committed by GitHub
parent f5b1e7feb8
commit 1fe3f38c14

View File

@@ -19,6 +19,7 @@ const NewTable: string = localize('tableDesigner.newTable', "New Table");
export class TableDesignerInput extends EditorInput { export class TableDesignerInput extends EditorInput {
public static ID: string = 'workbench.editorinputs.tableDesignerInput'; public static ID: string = 'workbench.editorinputs.tableDesignerInput';
private _designerComponentInput: TableDesignerComponentInput; private _designerComponentInput: TableDesignerComponentInput;
private _title: string;
private _name: string; private _name: string;
constructor( constructor(
@@ -33,18 +34,18 @@ export class TableDesignerInput extends EditorInput {
this._onDidChangeDirty.fire(); this._onDidChangeDirty.fire();
} }
})); }));
const existingNames = editorService.editors.map(editor => editor.getName());
if (this._tableInfo.isNewTable) { if (this._tableInfo.isNewTable) {
const existingNames = editorService.editors.map(editor => editor.getName());
// Find the next available unique name for the new table designer // Find the next available unique name for the new table designer
let idx = 1; let idx = 1;
do { do {
this._name = `${this._tableInfo.server}.${this._tableInfo.database} - ${NewTable} ${idx}`; this._name = `${NewTable} ${idx}`;
idx++; idx++;
} while (existingNames.indexOf(this._name) !== -1); } while (existingNames.indexOf(this._name) !== -1);
} else { } else {
this._name = `${this._tableInfo.server}.${this._tableInfo.database} - ${this._tableInfo.schema}.${this._tableInfo.name}`; this._name = `${this._tableInfo.schema}.${this._tableInfo.name}`;
} }
this._title = `${this._tableInfo.server}.${this._tableInfo.database} - ${this._name}`;
} }
get typeId(): string { get typeId(): string {
@@ -63,6 +64,10 @@ export class TableDesignerInput extends EditorInput {
return this._name; return this._name;
} }
override getTitle(): string {
return this._title;
}
override isDirty(): boolean { override isDirty(): boolean {
return this._designerComponentInput.dirty; return this._designerComponentInput.dirty;
} }