@Reference(service = DataExplorerViewFactory.class, cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC, unbind = "removeDataExplorer") void addDataExplorer(DataExplorerViewFactory factory) { String className1 = BundleTools.SYSTEM_PREFERENCES.getProperty(factory.getClass().getName()); if (!StringUtil.hasText(className1) || Boolean.valueOf(className1)) { GuiExecutor.instance().execute(() -> registerDataExplorer(factory.createDataExplorerView(null))); } }
void removeDataExplorer(DataExplorerViewFactory factory) { GuiExecutor.instance().execute(() -> { final DataExplorerView explorer = factory.createDataExplorerView(null); if (UIManager.EXPLORER_PLUGINS.contains(explorer)) { Optional.ofNullable(explorer.getDataExplorerModel()) .ifPresent(e -> e.removePropertyChangeListener(this)); UIManager.EXPLORER_PLUGINS.remove(explorer); // Update toolbar List<Toolbar> tb = mainWindow.getToolbarContainer().getRegisteredToolBars(); tb.removeIf(b -> b.getComponent().getAttachedInsertable() == explorer); mainWindow.getToolbarContainer().registerToolBar(tb); UIManager.VIEWER_PLUGINS .forEach(v -> v.getToolBar().removeIf(b -> b.getComponent().getAttachedInsertable() == explorer)); explorer.dispose(); LOGGER.info("Unregister data explorer Plug-in: {}", explorer.getUIName()); //$NON-NLS-1$ } }); }