Java Code Examples for javax.swing.text.JTextComponent#isShowing()

The following examples show how to use javax.swing.text.JTextComponent#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: WebBeansActionHelper.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static boolean isEnabled() {
    JTextComponent c = EditorRegistry.lastFocusedComponent();
    if (c == null || !c.isShowing())
    {
        return false;
    }
    if ( OpenProjects.getDefault().getOpenProjects().length == 0 ){
        return false;
    }
    final FileObject fileObject = NbEditorUtilities.getFileObject(c.getDocument());
    return isEnabled( fileObject );
    /*WebModule webModule = WebModule.getWebModule(fileObject);
    if ( webModule == null ){
        return false;
    }
    Profile profile = webModule.getJ2eeProfile();
    return Profile.JAVA_EE_6_WEB.equals( profile) || 
        Profile.JAVA_EE_6_FULL.equals( profile );*/
}
 
Example 2
Source File: EditorUI.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void showPopupMenu(int x, int y) {
    // First call the build-popup-menu action to possibly rebuild the popup menu
    JTextComponent c = getComponent();
    if (c != null) {
        BaseKit kit = Utilities.getKit(c);
        if (kit != null) {
            Action a = kit.getActionByName(ExtKit.buildPopupMenuAction);
            if (a != null) {
                a.actionPerformed(new ActionEvent(c, 0, "")); // NOI18N
            }
        }

        JPopupMenu pm = getPopupMenu();
        if (pm != null) {
            if (c.isShowing()) { // fix of #18808
                if (!c.isFocusOwner()) {
                    c.requestFocus();
                }
                pm.show(c, x, y);
            }
        }
    }
}
 
Example 3
Source File: ShowMembersAtCaretAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isEnabled() {
    final JTextComponent tc = EditorRegistry.lastFocusedComponent();
    if (tc == null || !tc.isShowing() || getContext(tc) == null) {
         return false;
    }
    return OpenProjects.getDefault().getOpenProjects().length > 0;
}
 
Example 4
Source File: ShowHierarchyAtCaretAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isEnabled() {
    final JTextComponent tc = EditorRegistry.lastFocusedComponent();
    if (tc == null || !tc.isShowing() || getContext(tc) == null) {
         return false;
    }
    return OpenProjects.getDefault().getOpenProjects().length > 0;
}
 
Example 5
Source File: StatusLineFactories.java    From netbeans with Apache License 2.0 5 votes vote down vote up
static void refreshStatusLine() {
    LOG.fine("StatusLineFactories.refreshStatusLine()\n");
    List<? extends JTextComponent> componentList = EditorRegistry.componentList();
    for (JTextComponent component : componentList) {
        boolean underMainWindow = (SwingUtilities.isDescendingFrom(component,
                WindowManager.getDefault().getMainWindow()));
        EditorUI editorUI = Utilities.getEditorUI(component);
        if (LOG.isLoggable(Level.FINE)) {
            String componentDesc = component.toString();
            Document doc = component.getDocument();
            Object streamDesc;
            if (doc != null && ((streamDesc = doc.getProperty(Document.StreamDescriptionProperty)) != null)) {
                componentDesc = streamDesc.toString();
            }
            LOG.fine("  underMainWindow=" + underMainWindow + // NOI18N
                    ", text-component: " + componentDesc + "\n");
        }
        if (editorUI != null) {
            StatusBar statusBar = editorUI.getStatusBar();
            statusBar.setVisible(!underMainWindow);
            boolean shouldUpdateGlobal = underMainWindow && component.isShowing();
            if (shouldUpdateGlobal) {
                statusBar.updateGlobal();
                LOG.fine("  end of refreshStatusLine() - found main window component\n\n"); // NOI18N
                return; // First non-docked one found and updated -> quit
            }
        }
    }
    clearStatusLine();
    LOG.fine("  end of refreshStatusLine() - no components - status line cleared\n\n"); // NOI18N
}