use of com.intellij.ui.DocumentAdapter in project intellij-community by JetBrains.
the class ProjectSettingsStepBase method registerValidators.
protected void registerValidators() {
final DocumentAdapter documentAdapter = new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
checkValid();
}
};
myLocationField.getTextField().getDocument().addDocumentListener(documentAdapter);
Disposer.register(this, () -> myLocationField.getTextField().getDocument().removeDocumentListener(documentAdapter));
if (myProjectGenerator instanceof WebProjectTemplate && !((WebProjectTemplate) myProjectGenerator).postponeValidation()) {
checkValid();
}
}
use of com.intellij.ui.DocumentAdapter in project intellij-community by JetBrains.
the class AbstractExtractMethodDialog method init.
@Override
protected void init() {
super.init();
// Set default name and select it
myMethodNameTextField.setText(myDefaultName);
myMethodNameTextField.setSelectionStart(0);
myMethodNameTextField.setSelectionStart(myDefaultName.length());
myMethodNameTextField.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
updateOutputVariables();
updateSignature();
updateOkStatus();
}
});
myVariableData = createVariableDataByNames(myArguments);
myVariablesMap = createVariableMap(myVariableData);
myParametersPanel.init(myVariableData);
updateOutputVariables();
updateSignature();
updateOkStatus();
}
use of com.intellij.ui.DocumentAdapter in project intellij-community by JetBrains.
the class EditContractIntention method invoke.
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
final PsiMethod method = getTargetMethod(project, editor, file);
assert method != null;
Contract existingAnno = AnnotationUtil.findAnnotationInHierarchy(method, Contract.class);
String oldContract = existingAnno == null ? null : existingAnno.value();
boolean oldPure = existingAnno != null && existingAnno.pure();
JBTextField contractText = new JBTextField(oldContract);
JCheckBox pureCB = createPureCheckBox(oldPure);
DialogBuilder builder = createDialog(project, contractText, pureCB);
contractText.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
String error = getErrorMessage(contractText.getText(), method);
builder.setOkActionEnabled(error == null);
builder.setErrorText(error, contractText);
}
});
if (builder.showAndGet()) {
updateContract(method, contractText.getText(), pureCB.isSelected());
}
}
use of com.intellij.ui.DocumentAdapter in project intellij-community by JetBrains.
the class SourcePathsStep method createComponentForEmptyRootCase.
private JComponent createComponentForEmptyRootCase() {
final JPanel panel = new JPanel(new GridBagLayout());
final String text = IdeBundle.message("prompt.please.specify.java.sources.directory");
final JLabel label = new JLabel(text);
label.setUI(new MultiLineLabelUI());
panel.add(label, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, JBUI.insets(8, 10, 0, 10), 0, 0));
myRbCreateSource = new JRadioButton(IdeBundle.message("radio.create.source.directory"), true);
panel.add(myRbCreateSource, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, JBUI.insets(8, 10, 0, 10), 0, 0));
myTfSourceDirectoryName = new JTextField(suggestSourceDirectoryName());
final JLabel srcPathLabel = new JLabel(IdeBundle.message("prompt.enter.relative.path.to.module.content.root", File.separator));
panel.add(srcPathLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, JBUI.insets(8, 30, 0, 0), 0, 0));
final FileChooserDescriptor chooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
chooserDescriptor.withTreeRootVisible(true);
final FieldPanel fieldPanel = createFieldPanel(myTfSourceDirectoryName, null, new BrowsePathListener(myTfSourceDirectoryName, chooserDescriptor));
panel.add(fieldPanel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, JBUI.insets(8, 30, 0, 10), 0, 0));
myRbNoSource = new JRadioButton(IdeBundle.message("radio.do.not.create.source.directory"), true);
panel.add(myRbNoSource, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, JBUI.insets(8, 10, 0, 10), 0, 0));
final JLabel fullPathLabel = new JLabel(IdeBundle.message("label.source.directory"));
panel.add(fullPathLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE, JBUI.insets(8, 10, 0, 10), 0, 0));
myTfFullPath = new JTextField();
myTfFullPath.setEditable(false);
myTfFullPath.setOpaque(false);
final Insets borderInsets = myTfFullPath.getBorder().getBorderInsets(myTfFullPath);
myTfFullPath.setBorder(BorderFactory.createEmptyBorder(borderInsets.top, borderInsets.left, borderInsets.bottom, borderInsets.right));
panel.add(myTfFullPath, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.SOUTHWEST, GridBagConstraints.HORIZONTAL, JBUI.insets(8, 10), 0, 0));
ButtonGroup group = new ButtonGroup();
group.add(myRbCreateSource);
group.add(myRbNoSource);
myTfSourceDirectoryName.getDocument().addDocumentListener(new DocumentAdapter() {
public void textChanged(DocumentEvent event) {
updateFullPathField();
}
});
myRbCreateSource.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
final boolean enabled = e.getStateChange() == ItemEvent.SELECTED;
srcPathLabel.setEnabled(enabled);
fieldPanel.setEnabled(enabled);
fullPathLabel.setVisible(enabled);
myTfFullPath.setVisible(enabled);
if (enabled) {
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
IdeFocusManager.getGlobalInstance().requestFocus(myTfSourceDirectoryName, true);
});
}
}
});
return panel;
}
use of com.intellij.ui.DocumentAdapter in project intellij-community by JetBrains.
the class CloneDvcsDialog method initListeners.
/**
* Init components
*/
private void initListeners() {
FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFolderDescriptor();
fcd.setShowFileSystemRoots(true);
fcd.setTitle(DvcsBundle.getString("clone.destination.directory.title"));
fcd.setDescription(DvcsBundle.getString("clone.destination.directory.description"));
fcd.setHideIgnored(false);
myParentDirectory.addActionListener(new ComponentWithBrowseButton.BrowseFolderActionListener<JTextField>(fcd.getTitle(), fcd.getDescription(), myParentDirectory, myProject, fcd, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT) {
@Override
protected VirtualFile getInitialFile() {
// suggest project base directory only if nothing is typed in the component.
String text = getComponentText();
if (text.length() == 0) {
VirtualFile file = myProject.getBaseDir();
if (file != null) {
return file;
}
}
return super.getInitialFile();
}
});
final DocumentListener updateOkButtonListener = new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
updateButtons();
}
};
myParentDirectory.getChildComponent().getDocument().addDocumentListener(updateOkButtonListener);
String parentDir = getRememberedInputs().getCloneParentDir();
if (StringUtil.isEmptyOrSpaces(parentDir)) {
parentDir = ProjectUtil.getBaseDir();
}
myParentDirectory.setText(parentDir);
myDirectoryName.getDocument().addDocumentListener(updateOkButtonListener);
myTestButton.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
test();
}
});
setOKActionEnabled(false);
myTestButton.setEnabled(false);
}
Aggregations