use of javax.swing.event.DocumentEvent in project intellij-community by JetBrains.
the class TerminalSettingsPanel method createPanel.
public JComponent createPanel(@NotNull TerminalOptionsProvider provider, @NotNull TerminalProjectOptionsProvider projectOptionsProvider) {
myOptionsProvider = provider;
myProjectOptionsProvider = projectOptionsProvider;
myProjectSettingsPanel.setBorder(IdeBorderFactory.createTitledBorder("Project settings"));
myGlobalSettingsPanel.setBorder(IdeBorderFactory.createTitledBorder("Application settings"));
FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false);
myShellPathField.addBrowseFolderListener("", "Shell executable path", null, fileChooserDescriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT);
fileChooserDescriptor = new FileChooserDescriptor(false, true, false, false, false, false);
myStartDirectoryField.addBrowseFolderListener("", "Starting directory", null, fileChooserDescriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT);
myShellPathField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
myShellPathField.getTextField().setForeground(StringUtil.equals(myShellPathField.getText(), myProjectOptionsProvider.getDefaultShellPath()) ? getDefaultValueColor() : getChangedValueColor());
}
});
myStartDirectoryField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
myStartDirectoryField.getTextField().setForeground(StringUtil.equals(myStartDirectoryField.getText(), myProjectOptionsProvider.getDefaultStartingDirectory()) ? getDefaultValueColor() : getChangedValueColor());
}
});
for (LocalTerminalCustomizer c : LocalTerminalCustomizer.EP_NAME.getExtensions()) {
UnnamedConfigurable configurable = c.getConfigurable(projectOptionsProvider.getProject());
if (configurable != null) {
myConfigurables.add(configurable);
JComponent component = configurable.createComponent();
if (component != null) {
myConfigurablesPanel.add(component, BorderLayout.CENTER);
}
}
}
return myWholePanel;
}
use of javax.swing.event.DocumentEvent in project intellij-community by JetBrains.
the class AddNamespaceDialog method addUpdateListener.
private void addUpdateListener(ComboBox comboBox) {
final ComboBoxEditor boxEditor = comboBox.getEditor();
if (boxEditor != null) {
final Component component = boxEditor.getEditorComponent();
if (component instanceof JTextField) {
((JTextField) component).getDocument().addDocumentListener(new DocumentAdapter() {
protected void textChanged(DocumentEvent e) {
updateOkAction();
}
});
}
}
comboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
updateOkAction();
}
});
}
use of javax.swing.event.DocumentEvent in project intellij-community by JetBrains.
the class BaseIntroduceDialog method init.
protected void init(XPathExpression expression, int numberOfExpressions, String title) {
setModal(true);
setTitle(title);
final JLabel jLabel = getTypeLabel();
jLabel.setText(expression.getType().getName());
final JCheckBox jCheckBox = getReplaceAll();
if (numberOfExpressions > 1) {
jCheckBox.setText(MessageFormat.format(jCheckBox.getText(), String.valueOf(numberOfExpressions)));
} else {
jCheckBox.setVisible(false);
}
getNameField().addDocumentListener(new DocumentAdapter() {
protected void textChanged(DocumentEvent e) {
getOKAction().setEnabled(myInputValidator.checkInput(getName()));
}
});
getOKAction().setEnabled(false);
init();
}
use of javax.swing.event.DocumentEvent in project intellij-community by JetBrains.
the class RequiredAttributesInspection method createOptionsPanel.
@Override
@Nullable
public JComponent createOptionsPanel() {
JPanel panel = new JPanel(new BorderLayout());
FieldPanel additionalAttributesPanel = new FieldPanel(InspectionsBundle.message("inspection.javadoc.html.not.required.label.text"), InspectionsBundle.message("inspection.javadoc.html.not.required.dialog.title"), null, null);
panel.add(additionalAttributesPanel, BorderLayout.NORTH);
additionalAttributesPanel.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
final Document document = e.getDocument();
try {
final String text = document.getText(0, document.getLength());
if (text != null) {
myAdditionalRequiredHtmlAttributes = text.trim();
}
} catch (BadLocationException e1) {
LOG.error(e1);
}
}
});
additionalAttributesPanel.setText(myAdditionalRequiredHtmlAttributes);
return panel;
}
use of javax.swing.event.DocumentEvent in project intellij-community by JetBrains.
the class EmmetAbbreviationBalloon method show.
public void show(@NotNull final CustomTemplateCallback customTemplateCallback) {
if (ApplicationManager.getApplication().isUnitTestMode()) {
if (ourTestingAbbreviation == null) {
throw new RuntimeException("Testing abbreviation is not set. See EmmetAbbreviationBalloon#setTestingAbbreviation");
}
myCallback.onEnter(ourTestingAbbreviation);
return;
}
final TextFieldWithStoredHistory field = new TextFieldWithStoredHistory(myAbbreviationsHistoryKey);
final Dimension fieldPreferredSize = field.getPreferredSize();
field.setPreferredSize(new Dimension(Math.max(220, fieldPreferredSize.width), fieldPreferredSize.height));
field.setHistorySize(10);
final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
final BalloonImpl balloon = (BalloonImpl) popupFactory.createDialogBalloonBuilder(field, myTitle).setCloseButtonEnabled(false).setBlockClicksThroughBalloon(true).setAnimationCycle(0).setHideOnKeyOutside(true).setHideOnClickOutside(true).createBalloon();
final DocumentAdapter documentListener = new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
if (!isValid(customTemplateCallback)) {
balloon.hide();
return;
}
validateTemplateKey(field, balloon, field.getText(), customTemplateCallback);
}
};
field.addDocumentListener(documentListener);
final KeyAdapter keyListener = new KeyAdapter() {
@Override
public void keyPressed(@NotNull KeyEvent e) {
if (!field.isPopupVisible()) {
if (!isValid(customTemplateCallback)) {
balloon.hide();
return;
}
switch(e.getKeyCode()) {
case KeyEvent.VK_ENTER:
final String abbreviation = field.getText();
if (validateTemplateKey(field, balloon, abbreviation, customTemplateCallback)) {
myCallback.onEnter(abbreviation);
PropertiesComponent.getInstance().setValue(myLastAbbreviationKey, abbreviation);
field.addCurrentTextToHistory();
balloon.hide();
}
break;
case KeyEvent.VK_ESCAPE:
balloon.hide(false);
break;
}
}
}
};
field.addKeyboardListener(keyListener);
balloon.addListener(new JBPopupListener.Adapter() {
@Override
public void beforeShown(LightweightWindowEvent event) {
field.setText(PropertiesComponent.getInstance().getValue(myLastAbbreviationKey, ""));
}
@Override
public void onClosed(LightweightWindowEvent event) {
field.removeKeyListener(keyListener);
field.removeDocumentListener(documentListener);
super.onClosed(event);
}
});
balloon.show(popupFactory.guessBestPopupLocation(customTemplateCallback.getEditor()), Balloon.Position.below);
final IdeFocusManager focusManager = IdeFocusManager.getInstance(customTemplateCallback.getProject());
focusManager.doWhenFocusSettlesDown(() -> {
focusManager.requestFocus(field, true);
field.selectText();
});
}
Aggregations