Search in sources :

Example 16 with JTextComponent

use of javax.swing.text.JTextComponent in project intellij-community by JetBrains.

the class FocusWatcher method focusGained.

@Override
public final void focusGained(final FocusEvent e) {
    final Component component = e.getComponent();
    if (e.isTemporary() || !component.isShowing()) {
        return;
    }
    if (component instanceof JTextComponent) {
        UIUtil.addUndoRedoActions((JTextComponent) component);
    }
    setFocusedComponentImpl(component, e);
    setNearestFocusableComponent(component.getParent());
}
Also used : JTextComponent(javax.swing.text.JTextComponent) JTextComponent(javax.swing.text.JTextComponent)

Example 17 with JTextComponent

use of javax.swing.text.JTextComponent in project intellij-community by JetBrains.

the class MacUtil method adjustFocusTraversal.

public static void adjustFocusTraversal(@NotNull Disposable disposable) {
    if (!SystemInfo.isMacOSSnowLeopard)
        return;
    final AWTEventListener listener = new AWTEventListener() {

        @Override
        public void eventDispatched(AWTEvent event) {
            if (event instanceof KeyEvent && ((KeyEvent) event).getKeyCode() == KeyEvent.VK_TAB && (!(event.getSource() instanceof JTextComponent)) && (!(event.getSource() instanceof JList)) && !isFullKeyboardAccessEnabled())
                ((KeyEvent) event).consume();
        }
    };
    Disposer.register(disposable, new Disposable() {

        @Override
        public void dispose() {
            Toolkit.getDefaultToolkit().removeAWTEventListener(listener);
        }
    });
    Toolkit.getDefaultToolkit().addAWTEventListener(listener, AWTEvent.KEY_EVENT_MASK);
}
Also used : KeyEvent(java.awt.event.KeyEvent) Disposable(com.intellij.openapi.Disposable) AWTEventListener(java.awt.event.AWTEventListener) JTextComponent(javax.swing.text.JTextComponent)

Example 18 with JTextComponent

use of javax.swing.text.JTextComponent in project intellij-community by JetBrains.

the class MacIntelliJTextFieldUI method showSearchPopup.

public void showSearchPopup() {
    final Object value = myTextField.getClientProperty("JTextField.Search.FindPopup");
    final JTextComponent editor = getComponent();
    if (editor != null && value instanceof JPopupMenu) {
        final JPopupMenu popup = (JPopupMenu) value;
        popup.show(editor, getSearchIconCoord().x, editor.getHeight());
    }
}
Also used : JTextComponent(javax.swing.text.JTextComponent)

Example 19 with JTextComponent

use of javax.swing.text.JTextComponent in project intellij-community by JetBrains.

the class WinIntelliJTextBorder method paintBorder.

@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    if (TextFieldWithPopupHandlerUI.isSearchField(c))
        return;
    Graphics2D g2 = (Graphics2D) g.create();
    try {
        g2.translate(x, y);
        boolean editable = !(c instanceof JTextComponent) || ((JTextComponent) c).isEditable();
        Object eop = ((JComponent) c).getClientProperty("JComponent.error.outline");
        if (Registry.is("ide.inplace.errors.outline") && Boolean.parseBoolean(String.valueOf(eop))) {
            DarculaUIUtil.paintErrorBorder(g2, width, height, c.hasFocus());
        } else {
            int d = JBUI.scale(1);
            int dd = JBUI.scale(2);
            if (c.hasFocus()) {
                g2.setColor(getBorderColor(c.isEnabled() && editable, true));
                Area s1 = new Area(new Rectangle2D.Float(d, d, width - 2 * d, height - 2 * d));
                Area s2 = new Area(new Rectangle2D.Float(d + dd, d + dd, width - 2 * d - 2 * dd, height - 2 * d - 2 * dd));
                s1.subtract(s2);
                g2.fill(s1);
            } else {
                g2.setColor(getBorderColor(c.isEnabled() && editable, false));
                g2.drawRect(d, d, width - 2 * d, height - 2 * d);
            }
        }
    } finally {
        g2.dispose();
    }
}
Also used : Area(java.awt.geom.Area) Rectangle2D(java.awt.geom.Rectangle2D) JTextComponent(javax.swing.text.JTextComponent)

Example 20 with JTextComponent

use of javax.swing.text.JTextComponent in project intellij-community by JetBrains.

the class TextComponentEditorAction method getEditorFromContext.

@Nullable
public static Editor getEditorFromContext(@NotNull DataContext dataContext) {
    final Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
    if (editor != null)
        return editor;
    final Project project = CommonDataKeys.PROJECT.getData(dataContext);
    final Object data = PlatformDataKeys.CONTEXT_COMPONENT.getData(dataContext);
    if (data instanceof JTextComponent) {
        return new TextComponentEditorImpl(project, (JTextComponent) data);
    }
    if (data instanceof JComponent) {
        final JTextField field = findActiveSpeedSearchTextField((JComponent) data);
        if (field != null) {
            return new TextComponentEditorImpl(project, field);
        }
    }
    return null;
}
Also used : Project(com.intellij.openapi.project.Project) TextComponentEditorImpl(com.intellij.openapi.editor.textarea.TextComponentEditorImpl) JTextComponent(javax.swing.text.JTextComponent) Editor(com.intellij.openapi.editor.Editor) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

JTextComponent (javax.swing.text.JTextComponent)82 NotNull (org.jetbrains.annotations.NotNull)9 Component (java.awt.Component)6 DocumentEvent (javax.swing.event.DocumentEvent)6 DocumentAdapter (com.intellij.ui.DocumentAdapter)5 Disposable (com.intellij.openapi.Disposable)3 JButton (javax.swing.JButton)3 Project (com.intellij.openapi.project.Project)2 GraphicsConfig (com.intellij.openapi.ui.GraphicsConfig)2 FocusEvent (java.awt.event.FocusEvent)2 KeyEvent (java.awt.event.KeyEvent)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Accessible (javax.accessibility.Accessible)2 Action (javax.swing.Action)2 JComboBox (javax.swing.JComboBox)2 JFrame (javax.swing.JFrame)2 JLabel (javax.swing.JLabel)2 JMenuItem (javax.swing.JMenuItem)2 JPopupMenu (javax.swing.JPopupMenu)2