public static DataExplorerView getExplorerplugin(String name) { if (name != null) { synchronized (EXPLORER_PLUGINS) { for (DataExplorerView view : EXPLORER_PLUGINS) { if (name.equals(view.getUIName())) { return view; } } } } return null; }
void registerDataExplorer(DataExplorerView explorer) { if (explorer != null && !UIManager.EXPLORER_PLUGINS.contains(explorer)) { UIManager.EXPLORER_PLUGINS.add(explorer); Optional.ofNullable(explorer.getDataExplorerModel()).ifPresent(e -> e.addPropertyChangeListener(this)); if (explorer instanceof DockableTool) { final DockableTool dockable = (DockableTool) explorer; dockable.showDockable(); } LOGGER.info("Register data explorer Plug-in: {}", explorer.getUIName()); //$NON-NLS-1$ } }
private void importInExplorer(List<DataExplorerView> exps, final List<File> vals, DropLocation dropLocation) { if (exps.size() == 1) { exps.get(0).importFiles(vals.toArray(new File[vals.size()]), true); } else { Point p; if (dropLocation == null) { Rectangle b = WeasisWin.this.getFrame().getBounds(); p = new Point((int) b.getCenterX(), (int) b.getCenterY()); } else { p = dropLocation.getDropPoint(); } JPopupMenu popup = new JPopupMenu(); for (final DataExplorerView dataExplorerView : exps) { JMenuItem item = new JMenuItem(dataExplorerView.getUIName(), dataExplorerView.getIcon()); item.addActionListener( e -> dataExplorerView.importFiles(vals.toArray(new File[vals.size()]), true)); popup.add(item); } popup.show(WeasisWin.this.getFrame(), p.x, p.y); } } }
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$ } }); }
if (dataExplorerView != DefaultExplorer.this) { importAction = true; JMenuItem item = new JMenuItem(new DefaultAction(dataExplorerView.getUIName(), event -> { final Path selectedDir = ((TreeNode) DefaultExplorer.this.tree.getSelectionPath().getLastPathComponent()) item = new JMenuItem(new DefaultAction(dataExplorerView.getUIName(), event -> { final Path selectedDir = ((TreeNode) DefaultExplorer.this.tree.getSelectionPath().getLastPathComponent())