Search in sources :

Example 26 with JTextComponent

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

the class DartGeneratorPeer method addSettingsStateListener.

@Override
public void addSettingsStateListener(@NotNull final WebProjectGenerator.SettingsStateListener stateListener) {
    // invalid Dartium path is not a blocking error
    final JTextComponent editorComponent = (JTextComponent) mySdkPathComboWithBrowse.getComboBox().getEditor().getEditorComponent();
    editorComponent.getDocument().addDocumentListener(new DocumentAdapter() {

        protected void textChanged(final DocumentEvent e) {
            stateListener.stateChanged(validate() == null);
        }
    });
    myCreateSampleProjectCheckBox.addActionListener(e -> stateListener.stateChanged(validate() == null));
    myTemplatesList.addListSelectionListener(e -> stateListener.stateChanged(validate() == null));
}
Also used : DocumentAdapter(com.intellij.ui.DocumentAdapter) JTextComponent(javax.swing.text.JTextComponent) DocumentEvent(javax.swing.event.DocumentEvent)

Example 27 with JTextComponent

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

the class RegistrationForm method setupFormActionsAndLF.

private void setupFormActionsAndLF() {
    myUseExisting.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            boolean useExisting = myUseExisting.isSelected();
            JComponent[] hideableFields = new JComponent[] { myNickname, myNicknameLabel, myFirstName, myFirstNameLabel, myLastName, myLastNameLabel, myPasswordAgain, myPasswordAgainLabel };
            for (JComponent hideableField : hideableFields) {
                hideableField.setVisible(!useExisting);
            }
            Window window = SwingUtilities.getWindowAncestor(myPanel);
            if (window != null) {
                window.pack();
            }
        }
    });
    UIUtil.traverse(myPanel, new UIUtil.TraverseAction() {

        public boolean executeAndContinue(Component c) {
            if (c instanceof JTextComponent) {
                JTextComponent textComponent = (JTextComponent) c;
                textComponent.getDocument().addDocumentListener(new DocumentAdapter() {

                    protected void textChanged(DocumentEvent e) {
                        myErrorLabel.setText(null);
                    }
                });
            }
            return true;
        }
    });
}
Also used : ItemEvent(java.awt.event.ItemEvent) DocumentAdapter(com.intellij.ui.DocumentAdapter) ItemListener(java.awt.event.ItemListener) JTextComponent(javax.swing.text.JTextComponent) JTextComponent(javax.swing.text.JTextComponent) DocumentEvent(javax.swing.event.DocumentEvent) UIUtil(jetbrains.communicator.util.UIUtil)

Example 28 with JTextComponent

use of javax.swing.text.JTextComponent in project jdk8u_jdk by JetBrains.

the class ParagraphView method isVisible.

/**
     * Indicates whether or not this view should be
     * displayed.  If none of the children wish to be
     * displayed and the only visible child is the
     * break that ends the paragraph, the paragraph
     * will not be considered visible.  Otherwise,
     * it will be considered visible and return true.
     *
     * @return true if the paragraph should be displayed
     */
public boolean isVisible() {
    int n = getLayoutViewCount() - 1;
    for (int i = 0; i < n; i++) {
        View v = getLayoutView(i);
        if (v.isVisible()) {
            return true;
        }
    }
    if (n > 0) {
        View v = getLayoutView(n);
        if ((v.getEndOffset() - v.getStartOffset()) == 1) {
            return false;
        }
    }
    // be visible.
    if (getStartOffset() == getDocument().getLength()) {
        boolean editable = false;
        Component c = getContainer();
        if (c instanceof JTextComponent) {
            editable = ((JTextComponent) c).isEditable();
        }
        if (!editable) {
            return false;
        }
    }
    return true;
}
Also used : JTextComponent(javax.swing.text.JTextComponent) JTextComponent(javax.swing.text.JTextComponent) View(javax.swing.text.View)

Example 29 with JTextComponent

use of javax.swing.text.JTextComponent in project jdk8u_jdk by JetBrains.

the class AquaTextFieldFormattedUI method mouseClicked.

public void mouseClicked(final MouseEvent e) {
    if (e.getClickCount() != 1)
        return;
    final JTextComponent c = getComponent();
    // apparently, focus has already been granted by the time this mouse listener fires
    //    if (c.hasFocus()) return;
    c.setCaretPosition(viewToModel(c, e.getPoint()));
}
Also used : JTextComponent(javax.swing.text.JTextComponent)

Example 30 with JTextComponent

use of javax.swing.text.JTextComponent in project jdk8u_jdk by JetBrains.

the class CInputMethod method selectedRange.

/**
     * Cocoa wants the range of characters that are currently selected.  We have to synthesize this
     * by getting the insert location and the length of the selected text. NB:  This does NOT allow
     * for the fact that the insert point in Swing can come AFTER the selected text, making this
     * potentially incorrect.
     */
private synchronized int[] selectedRange() {
    final int[] returnValue = new int[2];
    try {
        LWCToolkit.invokeAndWait(new Runnable() {

            public void run() {
                synchronized (returnValue) {
                    AttributedCharacterIterator theIterator = fIMContext.getSelectedText(null);
                    if (theIterator == null) {
                        returnValue[0] = fIMContext.getInsertPositionOffset();
                        returnValue[1] = 0;
                        return;
                    }
                    int startLocation;
                    if (fAwtFocussedComponent instanceof JTextComponent) {
                        JTextComponent theComponent = (JTextComponent) fAwtFocussedComponent;
                        startLocation = theComponent.getSelectionStart();
                    } else if (fAwtFocussedComponent instanceof TextComponent) {
                        TextComponent theComponent = (TextComponent) fAwtFocussedComponent;
                        startLocation = theComponent.getSelectionStart();
                    } else {
                        // If we don't have a Swing or AWT component, we have to guess whether the selection is before or after the input spot.
                        startLocation = fIMContext.getInsertPositionOffset() - (theIterator.getEndIndex() - theIterator.getBeginIndex());
                        // the selection.
                        if (startLocation < 0) {
                            startLocation = fIMContext.getInsertPositionOffset() + (theIterator.getEndIndex() - theIterator.getBeginIndex());
                        }
                    }
                    returnValue[0] = startLocation;
                    returnValue[1] = theIterator.getEndIndex() - theIterator.getBeginIndex();
                }
            }
        }, fAwtFocussedComponent);
    } catch (InvocationTargetException ite) {
        ite.printStackTrace();
    }
    synchronized (returnValue) {
        return returnValue;
    }
}
Also used : JTextComponent(javax.swing.text.JTextComponent) JTextComponent(javax.swing.text.JTextComponent) InvocationTargetException(java.lang.reflect.InvocationTargetException)

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