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());
}
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);
}
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());
}
}
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();
}
}
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;
}
Aggregations