/** * 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 preferenceChange(PreferenceChangeEvent evt) { if (PROPERTY_KEY_AUTO_SYNC_CURSORS.equals(evt.getKey())) { if (isActive()) { initPsvOverlayMap(); DocumentWindowManager.getDefault().addListener(SCENE_VIEW_PREDICATE, psvOverlayMapUpdater); } else { DocumentWindowManager.getDefault().removeListener(SCENE_VIEW_PREDICATE, psvOverlayMapUpdater); clearPsvOverlayMap(); } } }
private static DocumentWindowManager getDefaultInstance() { if (defaultInstance == null) { defaultInstance = new DocumentWindowManager(); } return defaultInstance; }
@Override public final boolean isSelected() { return DocumentWindowManager.getDefault().getSelectedWindow() == this; }
public void openView(final VectorDataNode vectorDataNode) { final PlacemarkViewTopComponent placemarkViewTopComponent = new PlacemarkViewTopComponent(vectorDataNode); DocumentWindowManager.getDefault().openWindow(placemarkViewTopComponent); placemarkViewTopComponent.requestSelected(); } }
public PixelPosStatusLineElementProvider() { DocumentWindowManager.getDefault().addListener(DocumentWindowManager.Predicate.view(ProductSceneView.class), this); SnapApp.getDefault().getPreferences().addPreferenceChangeListener(this); updateSettings(); pixelPosLabel = new JLabel(); pixelPosLabel.setPreferredSize(new Dimension(120, 20)); pixelPosLabel.setHorizontalAlignment(SwingConstants.CENTER); geoPosLabel = new JLabel(); geoPosLabel.setPreferredSize(new Dimension(200, 20)); geoPosLabel.setHorizontalAlignment(SwingConstants.CENTER); zoomLevelLabel = new JLabel(); zoomLevelLabel.setPreferredSize(new Dimension(150, 20)); zoomLevelLabel.setHorizontalAlignment(SwingConstants.CENTER); panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS)); panel.add(Box.createHorizontalGlue()); panel.add(new JSeparator(SwingConstants.VERTICAL)); panel.add(pixelPosLabel); panel.add(new JSeparator(SwingConstants.VERTICAL)); panel.add(geoPosLabel); panel.add(new JSeparator(SwingConstants.VERTICAL)); panel.add(zoomLevelLabel); }
private void notifyClosed(TopComponent topComponent) { NotifiableComponent.get(topComponent).componentClosed(); if (topComponent instanceof DocumentWindow) { DocumentWindowManager.getDefault().removeOpenedWindow((DocumentWindow) topComponent); } }
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); } }
@Override public void requestSelected() { if (isOpened()) { requestActive(); } else { requestVisible(); DocumentWindowManager.getDefault().requestSelected(this); } }
@Override public void run() { getDefault(); } }
boolean removeOpenedWindow(DocumentWindow documentWindow) { if (openDocumentWindows.remove(documentWindow)) { if (getSelectedWindow() == documentWindow) { setSelectedWindow(null); } boolean isClosed = documentWindow.getTopComponent().close(); if (isClosed) { fireWindowEvent(Event.Type.WINDOW_CLOSED, documentWindow); } return isClosed; } return false; }
@Override public void propertyChange(PropertyChangeEvent evt) { if (TopComponent.Registry.PROP_ACTIVATED.equals(evt.getPropertyName())) { Object newValue = evt.getNewValue(); if (newValue instanceof DocumentWindow) { setSelectedWindow((DocumentWindow) newValue); } } else if (TopComponent.Registry.PROP_TC_OPENED.equals(evt.getPropertyName())) { Object newValue = evt.getNewValue(); if (newValue instanceof DocumentWindow) { addOpenedWindow((DocumentWindow) newValue); } } else if (TopComponent.Registry.PROP_TC_CLOSED.equals(evt.getPropertyName())) { Object newValue = evt.getNewValue(); if (newValue instanceof DocumentWindow) { removeOpenedWindow((DocumentWindow) newValue); } } } }
/** * 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 addOpenedWindow(DocumentWindow documentWindow) { if (openDocumentWindows.add(documentWindow)) { fireWindowEvent(Event.Type.WINDOW_OPENED, documentWindow); } }
/** * Gets the {@code DocumentWindowManager}'s default implementation. It does this by * <pre> * DocumentWindowManager instance = Lookup.getDefault().lookup(DocumentWindowManager.class); * return (instance != null) ? instance : getDefaultInstance(); * </pre> * * @return the default implementation */ public static DocumentWindowManager getDefault() { DocumentWindowManager instance = Lookup.getDefault().lookup(DocumentWindowManager.class); return (instance != null) ? instance : getDefaultInstance(); }
/** * Constructor. */ protected DocumentWindowManager() { listeners = new LinkedHashMap<>(); openDocumentWindows = new LinkedHashSet<>(); captureCurrentState(); WindowManager.getDefault().getRegistry().addPropertyChangeListener(new RegistryPropertyChangeDelegate()); }
private MetadataViewTopComponent openDocumentWindow(final MetadataElement element) { final MetadataViewTopComponent metadataViewTopComponent = new MetadataViewTopComponent(element); DocumentWindowManager.getDefault().openWindow(metadataViewTopComponent); metadataViewTopComponent.requestSelected(); return metadataViewTopComponent; } }
/** * Gets SNAP's global document window manager. Use it to open your own document windows, or register a listener to * be notified on window events such as opening, closing, selection, deselection. * * @return SNAP's global document window manager. */ public DocumentWindowManager getDocumentWindowManager() { return DocumentWindowManager.getDefault(); }
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); } } }