private void initPsvOverlayMap() { WindowUtilities.getOpened(ProductSceneViewTopComponent.class) .map(ProductSceneViewTopComponent::getView) .forEach(this::addPPL); }
private void updateDisplayName() { setDisplayName(WindowUtilities.getUniqueTitle(getDocument().getDisplayName(), MetadataViewTopComponent.class)); }
private void updateDisplayName() { setDisplayName(WindowUtilities.getUniqueTitle(getDocument().getDisplayName(), PlacemarkViewTopComponent.class)); }
private void initPsvOverlayMap() { WindowUtilities.getOpened(ProductSceneViewTopComponent.class) .map(ProductSceneViewTopComponent::getView) .forEach(this::addPPL); }
private void updateDisplayName() { setDisplayName(WindowUtilities.getUniqueTitle(getView().getSceneName(), ProductSceneViewTopComponent.class)); }
public static List<WorkspaceTopComponent> findShowingInstances() { return WindowUtilities.getOpened(WorkspaceTopComponent.class).filter(Component::isShowing).collect(Collectors.toList()); }
@Override public void actionPerformed(ActionEvent e) { String defaultName = WindowUtilities.getUniqueTitle(Bundle.VAL_NewWorkspaceActionValue(), WorkspaceTopComponent.class); NotifyDescriptor.InputLine d = new NotifyDescriptor.InputLine(Bundle.LBL_NewWorkspaceActionName(), Bundle.CTL_NewWorkspaceActionName()); d.setInputText(defaultName); Object result = DialogDisplayer.getDefault().notify(d); if (NotifyDescriptor.OK_OPTION.equals(result)) { WorkspaceTopComponent workspaceTopComponent = new WorkspaceTopComponent(d.getInputText()); Mode editor = WindowManager.getDefault().findMode("editor"); Assert.notNull(editor, "editor"); editor.dockInto(workspaceTopComponent); workspaceTopComponent.open(); workspaceTopComponent.requestActive(); } }
public static boolean isNodeExpanded(Node node) { final ProductExplorerTopComponent topComponent = WindowUtilities.getOpened(ProductExplorerTopComponent.class).findFirst().orElse(null); if (topComponent != null) { return topComponent.isNodeExpanded(node); } return false; }
public static void expandNode(Node node) { final ProductExplorerTopComponent topComponent = WindowUtilities.getOpened(ProductExplorerTopComponent.class).findFirst().orElse(null); if (topComponent != null) { topComponent.expandNode(node); } }
/** * Gets a unique window title. * * @param titleBase The title base. * @param windowType The window type. * @return A unique window title. */ public static String getUniqueTitle(String titleBase, Class<? extends TopComponent> windowType) { List<String> titles = getOpened(windowType).map(TopComponent::getDisplayName).collect(Collectors.toList()); if (titles.isEmpty()) { return titleBase; } if (!titles.contains(titleBase)) { return titleBase; } for (int i = 2; ; i++) { final String title = String.format("%s (%d)", titleBase, i); if (!titles.contains(title)) { return title; } } }
private ProductSceneViewTopComponent getProductSceneViewTopComponent(RasterDataNode raster) { return WindowUtilities.getOpened(ProductSceneViewTopComponent.class) .filter(topComponent -> raster == topComponent.getView().getRaster()) .findFirst() .orElse(null); }
private ProductSceneViewTopComponent getProductSceneViewTopComponent(RasterDataNode raster) { return WindowUtilities.getOpened(ProductSceneViewTopComponent.class) .filter(topComponent -> raster == topComponent.getView().getRaster()) .findFirst() .orElse(null); }
public static void updateProductSceneViewImages(final RasterDataNode[] rasters, ProductSceneViewImageUpdater updateMethod) { List<ProductSceneView> views = WindowUtilities.getOpened(ProductSceneViewTopComponent.class).map(ProductSceneViewTopComponent::getView).collect(Collectors.toList()); for (ProductSceneView view : views) { boolean updateView = false; for (int j = 0; j < rasters.length && !updateView; j++) { final RasterDataNode raster = rasters[j]; for (int k = 0; k < view.getNumRasters() && !updateView; k++) { if (view.getRaster(k) == raster) { updateView = true; } } } if (updateView) { SwingUtilities.invokeLater(() -> updateMethod.updateView(view)); } } }
public static ProductSceneViewTopComponent getProductSceneViewTopComponent(RasterDataNode raster) { return WindowUtilities.getOpened(ProductSceneViewTopComponent.class) .filter(topComponent -> topComponent.getView().getNumRasters() == 1 && raster == topComponent.getView().getRaster()) .findFirst() .orElse(null); }
public boolean accept(ProductNode node) { if (node instanceof RasterDataNode) { final RasterDataNode rasterDataNode = (RasterDataNode) node; if (showOnlyLoadedOrDisplayedBands) { return rasterDataNode.hasRasterData() || WindowUtilities.getOpened(ProductSceneViewTopComponent.class).anyMatch( topComponent -> rasterDataNode == topComponent.getView().getRaster()); } } return true; } }
private void synchronizeCompatibleProductViews() { final ProductSceneView currentView = getCurrentView(); if (currentView == null) { return; } WindowUtilities.getOpened(ProductSceneViewTopComponent.class).forEach(productSceneViewTopComponent -> { final ProductSceneView view = productSceneViewTopComponent.getView(); if (view != currentView) { currentView.synchronizeViewportIfPossible(view); } }); }
private void syncImageViews(ProductSceneView currentSceneView) { if (isActive()) { WindowUtilities.getOpened(ProductSceneViewTopComponent.class).forEach(topComponent -> { ProductSceneView oldSceneView = topComponent.getView(); if (oldSceneView != currentSceneView) { currentSceneView.synchronizeViewportIfPossible(oldSceneView); } }); } }
private static <T extends ProductNode> void closeDocumentWindow(T productNode) { WindowUtilities.getOpened(DocumentWindow.class) .filter(dw -> (dw.getDocument() instanceof ProductNode) && (dw.getDocument() == productNode)) .forEach(dw -> DocumentWindowManager.getDefault().closeWindow(dw)); }
/** * Closes a document window. * * @param documentWindow The document window to be closed. * @return {@code true} on success */ public boolean closeWindow(DocumentWindow documentWindow) { Optional<WorkspaceTopComponent> anyWorkspace = WindowUtilities .getOpened(WorkspaceTopComponent.class) .filter(tc -> tc.getTopComponents().contains(documentWindow.getTopComponent())).findAny(); if (anyWorkspace.isPresent()) { return anyWorkspace.get().removeTopComponent(documentWindow.getTopComponent()); } else { return removeOpenedWindow(documentWindow); } }
static WorkspaceTopComponent promptForWorkspaces() { List<WorkspaceTopComponent> workspaces = WindowUtilities.getOpened(WorkspaceTopComponent.class).collect(Collectors.toList()); WorkspaceTopComponent workspaceTopComponent = null; if (workspaces.size() == 1) {