use of javax.swing.text.JTextComponent in project jsql-injection by ron190.
the class DeleteNextCharAction method actionPerformed.
/**
* The operation to perform when this action is triggered.
*/
@Override
public void actionPerformed(ActionEvent e) {
JTextComponent target = this.getTextComponent(e);
if ((target != null) && (target.isEditable())) {
try {
Document doc = target.getDocument();
Caret caret = target.getCaret();
int dot = caret.getDot();
int mark = caret.getMark();
if (dot != mark) {
doc.remove(Math.min(dot, mark), Math.abs(dot - mark));
} else if (dot < doc.getLength()) {
int delChars = 1;
if (dot < doc.getLength() - 1) {
String dotChars = doc.getText(dot, 2);
char c0 = dotChars.charAt(0);
char c1 = dotChars.charAt(1);
if (c0 >= '\uD800' && c0 <= '\uDBFF' && c1 >= '\uDC00' && c1 <= '\uDFFF') {
delChars = 2;
}
}
doc.remove(dot, delChars);
}
} catch (BadLocationException ble) {
LOGGER.error(ble, ble);
}
}
}
use of javax.swing.text.JTextComponent in project jsql-injection by ron190.
the class SilentDeleteTextAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
JTextComponent target = this.getTextComponent(e);
if (Objects.nonNull(target) && target.isEditable()) {
Caret caret = target.getCaret();
int dot = caret.getDot();
int mark = caret.getMark();
if (DefaultEditorKit.deletePrevCharAction.equals(this.getValue(Action.NAME))) {
// @see javax/swing/text/DefaultEditorKit.java DeletePrevCharAction
if (dot == 0 && mark == 0) {
return;
}
} else {
// @see javax/swing/text/DefaultEditorKit.java DeleteNextCharAction
Document doc = target.getDocument();
if (dot == mark && doc.getLength() == dot) {
return;
}
}
}
this.deleteAction.actionPerformed(e);
}
use of javax.swing.text.JTextComponent in project flutter-intellij by flutter.
the class FlutterSettingsStepFixture method enterPackageName.
@SuppressWarnings("Duplicates")
@NotNull
public FlutterSettingsStepFixture enterPackageName(@NotNull String text) {
LabelWithEditButton editLabel = robot().finder().findByType(target(), LabelWithEditButton.class);
JButton editButton = robot().finder().findByType(editLabel, JButton.class);
robot().click(editButton);
JTextComponent textField = findTextFieldWithLabel("Package name");
replaceText(textField, text);
// click "Done"
robot().click(editButton);
return this;
}
use of javax.swing.text.JTextComponent in project flutter-intellij by flutter.
the class FlutterSettingsStepFixture method enterCompanyDomain.
@NotNull
public FlutterSettingsStepFixture enterCompanyDomain(@NotNull String text) {
JTextComponent textField = findTextFieldWithLabel("Company domain");
replaceText(textField, text);
return this;
}
use of javax.swing.text.JTextComponent in project flutter-intellij by flutter.
the class FlutterGeneratorPeer method init.
private void init() {
mySdkPathComboWithBrowse.getComboBox().setEditable(true);
FlutterSdkUtil.addKnownSDKPathsToCombo(mySdkPathComboWithBrowse.getComboBox());
mySdkPathComboWithBrowse.addBrowseFolderListener(FlutterBundle.message("flutter.sdk.browse.path.label"), null, null, FileChooserDescriptorFactory.createSingleFolderDescriptor(), TextComponentAccessor.STRING_COMBOBOX_WHOLE_TEXT);
final JTextComponent editorComponent = (JTextComponent) getSdkEditor().getEditorComponent();
editorComponent.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
validate();
}
});
// When this changes the corresponding parts of FlutterProjectStep should also be changed.
myInstallActionLink.setIcon(myInstallSdkAction.getLinkIcon());
myInstallActionLink.setDisabledIcon(IconLoader.getDisabledIcon(myInstallSdkAction.getLinkIcon()));
myInstallActionLink.setText(myInstallSdkAction.getLinkText());
// noinspection unchecked
myInstallActionLink.setListener((label, linkUrl) -> myInstallSdkAction.actionPerformed(null), null);
myProgressText.setFont(UIUtil.getLabelFont(UIUtil.FontSize.NORMAL).deriveFont(Font.ITALIC));
// Some feedback on hover.
myCancelProgressButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
myCancelProgressButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
myListener.actionCanceled();
}
});
}
Aggregations