Java Code Examples for org.openide.windows.TopComponent#Registry
The following examples show how to use
org.openide.windows.TopComponent#Registry .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShowMembersAction.java From netbeans with Apache License 2.0 | 6 votes |
private JavaSource getContext() { FileObject fo = Utilities.actionsGlobalContext().lookup(FileObject.class); if (fo == null) { final DataObject dobj = Utilities.actionsGlobalContext().lookup(DataObject.class); if (dobj != null) { fo = dobj.getPrimaryFile(); } } if (fo == null) { return null; } TopComponent.Registry regs = WindowManager.getDefault().getRegistry(); final TopComponent tc = regs.getActivated(); final MultiViewHandler h = tc == null ? null : MultiViews.findMultiViewHandler(tc); if (h != null && FORM_VIEW_ID.equals(h.getSelectedPerspective().preferredID())) { //Form view does not support Members View return null; } return JavaSource.forFileObject(fo); }
Example 2
Source File: FileSystemAction.java From netbeans with Apache License 2.0 | 6 votes |
/** Creates new instance for menu/popup presenter. * @param popup true if this should represent popup * @param arr nodes to work with or null if global one should be used */ Menu (boolean popup, Lookup lookup) { this.popup = popup; this.lookup = lookup; changeMenuItems (createMenu (popup, lookup)); if (lookup == null) { // listen only when nodes not provided TopComponent.Registry r = WindowManager.getDefault ().getRegistry (); r.addPropertyChangeListener ( WeakListeners.propertyChange (this, r) ); } }
Example 3
Source File: DocumentsAction.java From netbeans with Apache License 2.0 | 6 votes |
public DocumentsAction() { putValue(Action.NAME, NbBundle.getMessage(DocumentsAction.class, "CTL_DocumentsAction")); propListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if(TopComponent.Registry.PROP_OPENED.equals(evt.getPropertyName())) { updateState(); } } }; TopComponent.Registry registry = TopComponent.getRegistry(); registry.addPropertyChangeListener(WeakListeners.propertyChange(propListener, registry)); // #37529 WindowsAPI to be called from AWT thread only. if(SwingUtilities.isEventDispatchThread()) { updateState(); } else { SwingUtilities.invokeLater(new Runnable() { public void run() { updateState(); } }); } }
Example 4
Source File: MaximizeWindowAction.java From netbeans with Apache License 2.0 | 6 votes |
public MaximizeWindowAction() { String label = NbBundle.getMessage(MaximizeWindowAction.class, "CTL_MaximizeWindowAction"); //NOI18N putValue(Action.NAME, label); propListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { String propName = evt.getPropertyName(); if(WindowManagerImpl.PROP_MAXIMIZED_MODE.equals(propName) || WindowManagerImpl.PROP_EDITOR_AREA_STATE.equals(evt.getPropertyName()) || WindowManager.PROP_MODES.equals(evt.getPropertyName()) || WindowManagerImpl.PROP_ACTIVE_MODE.equals(evt.getPropertyName())) { updateState(); } // #64876: correctly initialize after startup if (TopComponent.Registry.PROP_ACTIVATED.equals(propName)) { updateState(); } } }; TopComponent.Registry registry = TopComponent.getRegistry(); registry.addPropertyChangeListener(WeakListeners.propertyChange(propListener, registry)); WindowManagerImpl wm = WindowManagerImpl.getInstance(); wm.addPropertyChangeListener(WeakListeners.propertyChange(propListener, wm)); updateState(); }
Example 5
Source File: CSSStylesPanel.java From netbeans with Apache License 2.0 | 6 votes |
private boolean cssFileFocused() { WindowManager manager = WindowManager.getDefault(); Frame mainWindow = manager.getMainWindow(); if (mainWindow.isActive()) { TopComponent.Registry registry = manager.getRegistry(); TopComponent activeTC = registry.getActivated(); if (activeTC != null) { if (activeTC instanceof CssStylesTC) { return true; } if (manager.isOpenedEditorTopComponent(activeTC)) { FileObject fob = activeTC.getLookup().lookup(FileObject.class); if ((fob != null) && "text/css".equals(fob.getMIMEType())) { // NOI18N return true; } } } } return false; }
Example 6
Source File: Utilities.java From netbeans with Apache License 2.0 | 6 votes |
/** * Returns the file selected in the editor. * * @return file selected in the editor. */ private static FileObject selectedEditorFile() { WindowManager manager = WindowManager.getDefault(); TopComponent.Registry registry = manager.getRegistry(); TopComponent active = registry.getActivated(); if ((active == null) || !manager.isOpenedEditorTopComponent(active)) { active = null; for (Mode mode : manager.getModes()) { if (manager.isEditorMode(mode)) { active = mode.getSelectedTopComponent(); if (active != null) { break; } } } } FileObject selectedFile = null; if (active != null) { selectedFile = active.getLookup().lookup(FileObject.class); } return selectedFile; }
Example 7
Source File: PaletteSwitch.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void run() { if( !SwingUtilities.isEventDispatchThread() ) { SwingUtilities.invokeLater( this ); return; } currentToken = new Object(); TopComponent.Registry registry = TopComponent.getRegistry(); final TopComponent activeTc = registry.getActivated(); final Set<TopComponent> opened = new HashSet<TopComponent>(registry.getOpened()); final PaletteController existingPalette = currentPalette; final boolean isMaximized = isPaletteMaximized(); final Object token = currentToken; RP.post(new Runnable() { @Override public void run() { findNewPalette(existingPalette, activeTc, opened, isMaximized, token); } }); }
Example 8
Source File: CurrentEditorScanningScope.java From netbeans with Apache License 2.0 | 6 votes |
private FileObject getCurrentFile() { TopComponent.Registry registry = TopComponent.getRegistry(); TopComponent activeTc = registry.getActivated(); FileObject newFile = getFileFromTopComponent( activeTc ); ArrayList<FileObject> availableFiles = new ArrayList<FileObject>(3); if( null == newFile ) { Collection<TopComponent> openedTcs = new ArrayList<TopComponent>( registry.getOpened()); for( Iterator i=openedTcs.iterator(); i.hasNext(); ) { TopComponent tc = (TopComponent)i.next(); FileObject file = getFileFromTopComponent( tc ); if( null != file ) { availableFiles.add( file ); } } if( null != currentFile && (availableFiles.contains( currentFile ) ) ) newFile = currentFile; else if( availableFiles.size() > 0 ) newFile = availableFiles.get( 0 ); } return newFile; }
Example 9
Source File: GlobalActionContextImpl.java From netbeans with Apache License 2.0 | 5 votes |
public GlobalActionContextImpl (TopComponent.Registry r) { this.registry = r; if (EventQueue.isDispatchThread()) { run(); } else { EventQueue.invokeLater(this); } }
Example 10
Source File: PaletteSwitch.java From netbeans with Apache License 2.0 | 5 votes |
private boolean isPaletteMaximized() { boolean isMaximized = true; TopComponent.Registry registry = TopComponent.getRegistry(); Set openedTcs = registry.getOpened(); for( Iterator i=openedTcs.iterator(); i.hasNext(); ) { TopComponent tc = (TopComponent)i.next(); if( tc.isShowing() && !(tc instanceof PaletteTopComponent) ) { //other window(s) than the Palette are showing isMaximized = false; break; } } return isMaximized; }
Example 11
Source File: DebuggerManagerListener.java From netbeans with Apache License 2.0 | 5 votes |
private void fillOpenedDebuggerComponents(Set<ComponentInitiallyOpened> componentsInitiallyOpened) { // For simplicity, add all opened components. These will not be closed when finishing the debugging session. TopComponent.Registry registry = TopComponent.getRegistry(); synchronized (registry) { for (TopComponent tc : registry.getOpened()) { componentsInitiallyOpened.add(new ComponentInitiallyOpened(tc)); } } }
Example 12
Source File: TileAction.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
protected TileAction(Lookup actionContext) { defaultTileable = Tileable.getDefault(); tileableResult = actionContext.lookupResult(Tileable.class); tileableResult.addLookupListener(WeakListeners.create(LookupListener.class, this, tileableResult)); TopComponent.Registry registry = WindowManager.getDefault().getRegistry(); registry.addPropertyChangeListener(WeakListeners.propertyChange(this, registry)); updateState(); }
Example 13
Source File: DocumentWindowManager.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
private void captureCurrentState() { TopComponent.Registry registry = WindowManager.getDefault().getRegistry(); Set<TopComponent> topComponents = registry.getOpened(); topComponents.stream() .filter(topComponent -> topComponent instanceof DocumentWindow) .forEach(topComponent -> { DocumentWindow documentWindow = (DocumentWindow) topComponent; openDocumentWindows.add(documentWindow); if (registry.getActivated() == topComponent) { selectedDocumentWindow = documentWindow; } }); }