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