/** * Gets extra actions, e.g. for floating a docked window or group into a workspace. * * @param topComponent The document window. * @return The extra actions. */ public static Action[] getExtraActions(TopComponent topComponent) { return new Action[]{ new FloatIntoWorkspaceAction(topComponent), new FloatGroupIntoWorkspaceAction(topComponent) }; }
private void notifyClosed(TopComponent topComponent) { NotifiableComponent.get(topComponent).componentClosed(); if (topComponent instanceof DocumentWindow) { DocumentWindowManager.getDefault().removeOpenedWindow((DocumentWindow) topComponent); } }
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)); }
@Override public void requestSelected() { if (isOpened()) { requestActive(); } else { requestVisible(); DocumentWindowManager.getDefault().requestSelected(this); } }
private void notifyOpened(TopComponent topComponent) { NotifiableComponent.get(topComponent).componentOpened(); if (topComponent instanceof DocumentWindow) { DocumentWindowManager.getDefault().addOpenedWindow((DocumentWindow) topComponent); } }
private void notifyActivated(TopComponent topComponent) { NotifiableComponent.get(topComponent).componentActivated(); if (topComponent instanceof DocumentWindow) { DocumentWindowManager.getDefault().setSelectedWindow((DocumentWindow) topComponent); } }
/** * 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); }
@Override public void actionPerformed(ActionEvent e) { WorkspaceTopComponent workspaceTopComponent = promptForWorkspaces(); if (workspaceTopComponent != null) { workspaceTopComponent.requestActive(); workspaceTopComponent.addTopComponent(window); } }
/** * Adds a document window listener for any document type. * * @param listener The listener. */ public final void addListener(Listener listener) { //noinspection unchecked addListener(Predicate.any(), listener); }
void setSelectedWindow(DocumentWindow newValue) { DocumentWindow oldValue = this.selectedDocumentWindow; if (oldValue != newValue) { this.selectedDocumentWindow = newValue; if (oldValue != null) { oldValue.componentDeselected(); fireWindowEvent(Event.Type.WINDOW_DESELECTED, oldValue); } if (newValue != null) { newValue.componentSelected(); fireWindowEvent(Event.Type.WINDOW_SELECTED, newValue); } } }
@Override protected void componentHidden() { for (JInternalFrame internalFrame : desktopPane.getAllFrames()) { NotifiableComponent.get(getTopComponent(internalFrame)).componentHidden(); } }
/** * @return A predicate that applies to document windows with the given {@code docType}. */ static <D> Predicate<D, Object> doc(Class<D> docType) { return new DefaultPredicate<>(docType, Object.class); }
/** * Called when this component was selected. * <p> * Default implementation simply calls {@link #updateSelectedState}. */ @Override public void componentSelected() { updateSelectedState(); }
/** * Does anything that indicates the selected state of this component. The default implementation * simply calls {@link #repaint()}. */ protected void updateSelectedState() { repaint(); } }
/** * @return A predicate that applies to document windows with the given {@code docType} and {@code viewType}. */ static <D, V> Predicate<D, V> docView(Class<D> docType, Class<V> viewType) { return new DefaultPredicate<>(docType, viewType); } }
/** * Called when this component was deselected. * <p> * Default implementation simply calls {@link #updateSelectedState}. */ @Override public void componentDeselected() { updateSelectedState(); }