dockview-core
Version:
Zero dependency layout manager supporting tabs, groups, grids and splitviews for vanilla TypeScript
64 lines (63 loc) • 1.93 kB
JavaScript
import { defineModule } from './modules';
export class EdgeGroupService {
constructor() {
this._edgeGroups = new Map();
this._edgeGroupDisposables = new Map();
}
// No constructor needed — the host is currently unused. The
// IEdgeGroupServiceHost slot stays for symmetry with the other modules
// and to leave room for future host callbacks.
add(position, group, autoCollapseDisposable) {
this._edgeGroups.set(position, group);
this._edgeGroupDisposables.set(position, autoCollapseDisposable);
}
remove(position) {
var _a;
(_a = this._edgeGroupDisposables.get(position)) === null || _a === void 0 ? void 0 : _a.dispose();
this._edgeGroupDisposables.delete(position);
this._edgeGroups.delete(position);
}
get(position) {
return this._edgeGroups.get(position);
}
has(position) {
return this._edgeGroups.has(position);
}
hasAny() {
return this._edgeGroups.size > 0;
}
entries() {
return this._edgeGroups.entries();
}
includes(group) {
for (const edgeGroup of this._edgeGroups.values()) {
if (edgeGroup === group) {
return true;
}
}
return false;
}
findPositionOf(group) {
for (const [position, edgeGroup] of this._edgeGroups) {
if (edgeGroup === group) {
return position;
}
}
return undefined;
}
disposeAll() {
for (const disposable of this._edgeGroupDisposables.values()) {
disposable.dispose();
}
this._edgeGroupDisposables.clear();
this._edgeGroups.clear();
}
dispose() {
this.disposeAll();
}
}
export const EdgeGroupModule = defineModule({
name: 'EdgeGroup',
serviceKey: 'edgeGroupService',
create: () => new EdgeGroupService(),
});