/** * Called when the document is about to be closed. * The default implementation makes an attempt to close this window by * calling {@code DocumentWindowManager.getDefault().closeWindow(this)}. */ @Override public void documentClosing() { DocumentWindowManager.getDefault().closeWindow(this); }
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)); }
WindowUtilities.getOpened(DocumentWindow.class) .filter(dw -> (dw.getDocument() instanceof ProductNode) && ((ProductNode) dw.getDocument()).getProduct() == product) .forEach(dw -> DocumentWindowManager.getDefault().closeWindow(dw)); SnapApp.getDefault().getProductManager().removeProduct(product);