Java Code Examples for org.openide.windows.TopComponent#isShowing()

The following examples show how to use org.openide.windows.TopComponent#isShowing() . 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: HierarchyTopComponent.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void actionPerformed(ActionEvent e) {
    if (refreshButton == e.getSource()) {
        final JTextComponent lastFocusedComponent = EditorRegistry.lastFocusedComponent();
        if (lastFocusedComponent != null) {
            final JavaSource js = JavaSource.forDocument(Utilities.getDocument(lastFocusedComponent));
            if (js != null) {
                setContext(js, lastFocusedComponent);
            }
        }
    } else if (jdocButton == e.getSource()) {
        final TopComponent win = JavadocTopComponent.findInstance();
        if (win != null && !win.isShowing()) {
            win.open();
            win.requestVisible();
            jdocTask.schedule(NOW);
        }
    } else if (historyCombo == e.getSource()) {
        refresh();
    } else if (viewTypeCombo == e.getSource()) {
        refresh();
    }
}
 
Example 2
Source File: SlideOperationImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private boolean isHeavyWeightShowing() {
    for( TopComponent tc : TopComponent.getRegistry().getOpened() ) {
        if( !tc.isShowing() )
            continue;
        if( containsHeavyWeightChild( tc ) )
            return true;
    }
    return false;
}
 
Example 3
Source File: PaletteSwitch.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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 4
Source File: PaletteSwitch.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private ArrayList<TopComponent> findShowingTCs() {
    ArrayList<TopComponent> res = new ArrayList<TopComponent>( 3 );
    for( TopComponent tc : TopComponent.getRegistry().getOpened() ) {
        if( tc.isShowing() )
            res.add( tc );
    }
    return res;
}
 
Example 5
Source File: CurrentEditorScanningScope.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private FileObject getFileFromTopComponent( final TopComponent tc ) {
    if( null == tc || !tc.isShowing() )
        return null;
    if( WindowManager.getDefault().isOpenedEditorTopComponent( tc ) ) {
        DataObject dob = tc.getLookup().lookup( DataObject.class );
        if( null != dob ) {
            return dob.getPrimaryFile();
        }
    }
    return null;
}
 
Example 6
Source File: PaletteSwitch.java    From netbeans with Apache License 2.0 4 votes vote down vote up
PaletteController getPaletteFromTopComponent( TopComponent tc, boolean mustBeShowing, boolean isOpened ) {
        if( null == tc || (!tc.isShowing() && mustBeShowing) )
            return null;
        
        PaletteController pc = (PaletteController)tc.getLookup().lookup( PaletteController.class );
        //#231997 - TopComponent.getSubComponents() can be called from EDT only
        //The only drawback of commenting out the code below is that a split view of
        //a form designer showing source and design hides the palette window
        //when the source split is the active one and some other TopComponent is activated
//	if (pc == null && isOpened) {
//	    TopComponent.SubComponent[] subComponents = tc.getSubComponents();
//	    for (int i = 0; i < subComponents.length; i++) {
//		TopComponent.SubComponent subComponent = subComponents[i];
//		Lookup subComponentLookup = subComponent.getLookup();
//		if (subComponentLookup != null) {
//		    pc = (PaletteController) subComponentLookup.lookup(PaletteController.class);
//		    if (pc != null && (subComponent.isActive() || subComponent.isShowing())) {
//			break;
//		    }
//		}
//	    }
//	}
        if( null == pc && isOpened ) {
            //check if there's any palette assigned to TopComponent's mime type
            Node[] activeNodes = tc.getActivatedNodes();
            if( null != activeNodes && activeNodes.length > 0 ) {
                DataObject dob = activeNodes[0].getLookup().lookup( DataObject.class );
                if( null != dob ) {
                    while( dob instanceof DataShadow ) {
                        dob = ((DataShadow)dob).getOriginal();
                    }
                    FileObject fo = dob.getPrimaryFile();
                    if( !fo.isVirtual() ) {
                        String mimeType = fo.getMIMEType();
                        pc = getPaletteFromMimeType( mimeType );
                    }
                }
            }
        }
        return pc;
    }