Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions python/jupytergis_qgis/src/modelfactory.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { IJupyterGISDoc, JupyterGISModel } from '@jupytergis/schema';
import {
IJupyterGISDoc,
JupyterGISModel,
IAnnotationModel
} from '@jupytergis/schema';
import { DocumentRegistry } from '@jupyterlab/docregistry';
import { Contents } from '@jupyterlab/services';

Expand All @@ -8,6 +12,10 @@ import { Contents } from '@jupyterlab/services';
export class JupyterGISModelFactoryBase
implements DocumentRegistry.IModelFactory<JupyterGISModel>
{
constructor(options: JupyterGISModelFactoryBase.IOptions) {
this._annotationModel = options.annotationModel;
}

/**
* Whether the model is collaborative or not.
*/
Expand Down Expand Up @@ -77,14 +85,22 @@ export class JupyterGISModelFactoryBase
): JupyterGISModel {
const model = new JupyterGISModel({
sharedModel: options.sharedModel,
languagePreference: options.languagePreference
languagePreference: options.languagePreference,
annotationModel: this._annotationModel
});
return model;
}

private _annotationModel: IAnnotationModel;
private _disposed = false;
}

export namespace JupyterGISModelFactoryBase {
export interface IOptions {
annotationModel: IAnnotationModel;
}
}

export class QGZModelFactory extends JupyterGISModelFactoryBase {
/**
* The name of the model.
Expand Down
12 changes: 8 additions & 4 deletions python/jupytergis_qgis/src/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import {
IJGISExternalCommandRegistryToken,
JupyterGISDoc,
IJupyterGISDocTracker,
IJupyterGISWidget
IJupyterGISWidget,
IAnnotationModel,
IAnnotationToken
} from '@jupytergis/schema';
import {
JupyterFrontEnd,
Expand Down Expand Up @@ -75,6 +77,7 @@ const activate = async (
editorServices: IEditorServices,
rendermime: IRenderMimeRegistry,
consoleTracker: IConsoleTracker,
annotationModel: IAnnotationModel,
commandPalette: ICommandPalette | null
): Promise<void> => {
const fcCheck = await requestAPI<{ installed: boolean }>(
Expand Down Expand Up @@ -130,8 +133,8 @@ const activate = async (
app.docRegistry.addWidgetFactory(QGZWidgetFactory);

// Creating and registering the model factory for our custom DocumentModel
app.docRegistry.addModelFactory(new QGSModelFactory());
app.docRegistry.addModelFactory(new QGZModelFactory());
app.docRegistry.addModelFactory(new QGSModelFactory({ annotationModel }));
app.docRegistry.addModelFactory(new QGZModelFactory({ annotationModel }));
// register the filetype
app.docRegistry.addFileType({
name: 'QGS',
Expand Down Expand Up @@ -307,7 +310,8 @@ export const qgisplugin: JupyterFrontEndPlugin<void> = {
ConsolePanel.IContentFactory,
IEditorServices,
IRenderMimeRegistry,
IConsoleTracker
IConsoleTracker,
IAnnotationToken
],
optional: [ICommandPalette],
autoStart: true,
Expand Down
Loading