Import UI Launcher¶
Import UI Launchers are small classes that configure and launch a UI to let the user set options on the layer. Minimally this should let the user set the layer title and adjust the color.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | goog.declareModuleId('plugin.georss.GeoRSSImportUI');
import FileParserConfig from 'opensphere/src/os/parse/fileparserconfig.js';
import FileImportUI from 'opensphere/src/os/ui/im/fileimportui.js';
/**
* GeoRSS import UI.
*/
export default class GeoRSSImportUI extends FileImportUI {
/**
* Constructor.
*/
constructor() {
super();
}
/**
* @inheritDoc
*/
getTitle() {
return 'GeoRSS';
}
/**
* @inheritDoc
*/
launchUI(file, opt_config) {
super.launchUI(file, opt_config);
const config = new FileParserConfig();
// if an existing config was provided, merge it in
if (opt_config) {
this.mergeConfig(opt_config, config);
}
config['file'] = file;
config['title'] = file.getFileName();
// our config is all set up but we have no UI to launch yet!
}
}
|
Now we will register our launcher in the plugin.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | goog.declareModuleId('plugin.georss.GeoRSSPlugin');
import LayerConfigManager from 'opensphere/src/os/layer/config/layerconfigmanager.js';
import AbstractPlugin from 'opensphere/src/os/plugin/abstractplugin.js';
import PluginManager from 'opensphere/src/os/plugin/pluginmanager.js';
import ImportManager from 'opensphere/src/os/ui/im/importmanager.js';
import {ID} from './georss.js';
import GeoRSSImportUI from './georssimportui.js';
import GeoRSSLayerConfig from './georsslayerconfig.js';
import {TYPE} from './mime.js';
/**
* Provides support for the GeoRSS format.
*/
export default class GeoRSSPlugin extends AbstractPlugin {
/**
* Constructor.
*/
constructor() {
super();
this.id = ID;
this.errorMessage = null;
}
/**
* @inheritDoc
*/
init() {
const lcm = LayerConfigManager.getInstance();
lcm.registerLayerConfig(ID, GeoRSSLayerConfig);
const im = ImportManager.getInstance();
im.registerImportDetails('GeoRSS', true);
im.registerImportUI(TYPE, new GeoRSSImportUI());
}
}
// add the plugin to the application
PluginManager.getInstance().addPlugin(new GeoRSSPlugin());
|
Run the build. This gets rid of the error, but our launcher does not launch anything! Let’s fix that.