use of com.intellij.ui.DocumentAdapter in project intellij-community by JetBrains.
the class SshSettingsPanel method init.
private void init() {
register(myPasswordChoice, SvnConfiguration.SshConnectionType.PASSWORD);
register(myPrivateKeyChoice, SvnConfiguration.SshConnectionType.PRIVATE_KEY);
register(mySubversionConfigChoice, SvnConfiguration.SshConnectionType.SUBVERSION_CONFIG);
ItemListener connectionTypeChangedListener = e -> {
if (e.getStateChange() == ItemEvent.SELECTED) {
enableOptions(e.getSource());
}
};
myPasswordChoice.addItemListener(connectionTypeChangedListener);
myPrivateKeyChoice.addItemListener(connectionTypeChangedListener);
mySubversionConfigChoice.addItemListener(connectionTypeChangedListener);
enableOptions(mySubversionConfigChoice);
registerBrowseDialog(myExecutablePathField, SvnBundle.message("ssh.settings.browse.executable.dialog.title"));
registerBrowseDialog(myPrivateKeyPathField, SvnBundle.message("ssh.settings.browse.private.key.dialog.title"));
mySshTunnelField.getEmptyText().setText(SshTunnelRuntimeModule.DEFAULT_SSH_TUNNEL_VALUE);
mySshTunnelField.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
updateSshTunnelDependentValues(mySshTunnelField.getText());
}
});
myUpdateTunnelButton.addActionListener(e -> {
String tunnel = mySshTunnelField.getText();
mySvnConfiguration.setSshTunnelSetting(StringUtil.nullize(tunnel));
setSshTunnelSetting(mySvnConfiguration.getSshTunnelSetting());
});
}
use of com.intellij.ui.DocumentAdapter in project intellij-community by JetBrains.
the class DependsOnGroupsInspection method createOptionsPanel.
@Override
@Nullable
public JComponent createOptionsPanel() {
final LabeledComponent<JTextField> definedGroups = new LabeledComponent<>();
definedGroups.setText("&Defined Groups");
final JTextField textField = new JTextField(StringUtil.join(ArrayUtil.toStringArray(groups), ","));
textField.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(final DocumentEvent e) {
groups.clear();
String text = textField.getText();
if (!StringUtil.isEmptyOrSpaces(text)) {
ContainerUtil.addAll(groups, text.split("[, ]"));
}
}
});
definedGroups.setComponent(textField);
final JPanel optionsPanel = new JPanel(new BorderLayout());
optionsPanel.add(definedGroups, BorderLayout.NORTH);
return optionsPanel;
}
use of com.intellij.ui.DocumentAdapter in project intellij-community by JetBrains.
the class ModuleNameLocationComponent method bindModuleSettings.
public void bindModuleSettings(final NamePathComponent namePathComponent) {
namePathComponent.getNameComponent().getDocument().addDocumentListener(new DocumentAdapter() {
protected void textChanged(final DocumentEvent e) {
if (!myModuleNameChangedByUser) {
setModuleName(namePathComponent.getNameValue());
}
}
});
myModuleContentRoot.addBrowseFolderListener(ProjectBundle.message("project.new.wizard.module.content.root.chooser.title"), ProjectBundle.message("project.new.wizard.module.content.root.chooser.description"), myWizardContext.getProject(), BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR);
namePathComponent.getPathComponent().getDocument().addDocumentListener(new DocumentAdapter() {
protected void textChanged(final DocumentEvent e) {
if (!myContentRootChangedByUser) {
setModuleContentRoot(namePathComponent.getPath());
}
}
});
myModuleName.getDocument().addDocumentListener(new DocumentAdapter() {
protected void textChanged(final DocumentEvent e) {
if (!myUpdatePathsWhenNameIsChanged) {
return;
}
if (myModuleNameDocListenerEnabled) {
myModuleNameChangedByUser = true;
}
String path = getDefaultBaseDir(myWizardContext, namePathComponent);
final String moduleName = getModuleName();
if (path.length() > 0 && !Comparing.strEqual(moduleName, namePathComponent.getNameValue())) {
path += "/" + moduleName;
}
if (!myContentRootChangedByUser) {
final boolean f = myModuleNameChangedByUser;
myModuleNameChangedByUser = true;
setModuleContentRoot(path);
myModuleNameChangedByUser = f;
}
if (!myImlLocationChangedByUser) {
setImlFileLocation(path);
}
}
});
myModuleContentRoot.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
protected void textChanged(final DocumentEvent e) {
if (myContentRootDocListenerEnabled) {
myContentRootChangedByUser = true;
}
if (!myImlLocationChangedByUser) {
setImlFileLocation(getModuleContentRoot());
}
if (!myModuleNameChangedByUser) {
final String path = FileUtil.toSystemIndependentName(getModuleContentRoot());
final int idx = path.lastIndexOf("/");
boolean f = myContentRootChangedByUser;
myContentRootChangedByUser = true;
boolean i = myImlLocationChangedByUser;
myImlLocationChangedByUser = true;
setModuleName(idx >= 0 ? path.substring(idx + 1) : "");
myContentRootChangedByUser = f;
myImlLocationChangedByUser = i;
}
}
});
myModuleFileLocation.addBrowseFolderListener(ProjectBundle.message("project.new.wizard.module.file.chooser.title"), ProjectBundle.message("project.new.wizard.module.file.description"), myWizardContext.getProject(), BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR);
myModuleFileLocation.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
protected void textChanged(final DocumentEvent e) {
if (myImlLocationDocListenerEnabled) {
myImlLocationChangedByUser = true;
}
}
});
namePathComponent.getPathComponent().getDocument().addDocumentListener(new DocumentAdapter() {
protected void textChanged(final DocumentEvent e) {
if (!myImlLocationChangedByUser) {
setImlFileLocation(namePathComponent.getPath());
}
}
});
myUpdatePathsWhenNameIsChanged = true;
if (myWizardContext.isCreatingNewProject()) {
setModuleName(namePathComponent.getNameValue());
setModuleContentRoot(namePathComponent.getPath());
setImlFileLocation(namePathComponent.getPath());
} else {
final Project project = myWizardContext.getProject();
assert project != null;
VirtualFile baseDir = project.getBaseDir();
if (baseDir != null) {
//e.g. was deleted
final String baseDirPath = baseDir.getPath();
String moduleName = ProjectWizardUtil.findNonExistingFileName(baseDirPath, "untitled", "");
String contentRoot = baseDirPath + "/" + moduleName;
if (!Comparing.strEqual(project.getName(), myWizardContext.getProjectName()) && !myWizardContext.isCreatingNewProject() && myWizardContext.getProjectName() != null) {
moduleName = ProjectWizardUtil.findNonExistingFileName(myWizardContext.getProjectFileDirectory(), myWizardContext.getProjectName(), "");
contentRoot = myWizardContext.getProjectFileDirectory();
myUpdatePathsWhenNameIsChanged = !myWizardContext.isProjectFileDirectorySetExplicitly();
}
setModuleName(moduleName);
setModuleContentRoot(contentRoot);
setImlFileLocation(contentRoot);
myModuleName.select(0, moduleName.length());
}
}
}
use of com.intellij.ui.DocumentAdapter in project intellij-community by JetBrains.
the class NamePathComponent method addChangeListener.
public void addChangeListener(final Runnable callback) {
DocumentAdapter adapter = new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
callback.run();
}
};
myTfName.getDocument().addDocumentListener(adapter);
myTfPath.getDocument().addDocumentListener(adapter);
}
use of com.intellij.ui.DocumentAdapter in project intellij-community by JetBrains.
the class WrapReturnValueDialog method createCenterPanel.
protected JComponent createCenterPanel() {
sourceMethodTextField.setEditable(false);
final DocumentListener docListener = new DocumentAdapter() {
protected void textChanged(final DocumentEvent e) {
validateButtons();
}
};
classNameField.getDocument().addDocumentListener(docListener);
myFieldsCombo.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
validateButtons();
}
});
myInnerClassNameTextField.getDocument().addDocumentListener(docListener);
final PsiFile file = sourceMethod.getContainingFile();
if (file instanceof PsiJavaFile) {
final String packageName = ((PsiJavaFile) file).getPackageName();
packageTextField.setText(packageName);
}
final PsiClass containingClass = sourceMethod.getContainingClass();
assert containingClass != null : sourceMethod;
final String containingClassName = containingClass instanceof PsiAnonymousClass ? "Anonymous " + ((PsiAnonymousClass) containingClass).getBaseClassType().getClassName() : containingClass.getName();
final String sourceMethodName = sourceMethod.getName();
sourceMethodTextField.setText(containingClassName + '.' + sourceMethodName);
final ButtonGroup buttonGroup = new ButtonGroup();
buttonGroup.add(useExistingClassButton);
buttonGroup.add(createNewClassButton);
buttonGroup.add(myCreateInnerClassButton);
createNewClassButton.setSelected(true);
final ActionListener enableListener = new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
toggleRadioEnablement();
}
};
useExistingClassButton.addActionListener(enableListener);
createNewClassButton.addActionListener(enableListener);
myCreateInnerClassButton.addActionListener(enableListener);
toggleRadioEnablement();
final DefaultComboBoxModel model = new DefaultComboBoxModel();
myFieldsCombo.setModel(model);
myFieldsCombo.setRenderer(new ListCellRendererWrapper() {
@Override
public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
if (value instanceof PsiField) {
final PsiField field = (PsiField) value;
setText(field.getName());
setIcon(field.getIcon(Iconable.ICON_FLAG_VISIBILITY));
}
}
});
existingClassField.getChildComponent().getDocument().addDocumentListener(new com.intellij.openapi.editor.event.DocumentAdapter() {
@Override
public void documentChanged(com.intellij.openapi.editor.event.DocumentEvent e) {
final JavaPsiFacade facade = JavaPsiFacade.getInstance(myProject);
final PsiClass currentClass = facade.findClass(existingClassField.getText(), GlobalSearchScope.allScope(myProject));
if (currentClass != null) {
model.removeAllElements();
final PsiType returnType = sourceMethod.getReturnType();
assert returnType != null;
for (PsiField field : currentClass.getFields()) {
final PsiType fieldType = field.getType();
if (TypeConversionUtil.isAssignable(fieldType, returnType)) {
model.addElement(field);
} else {
if (WrapReturnValueProcessor.getInferredType(fieldType, returnType, currentClass, sourceMethod) != null) {
model.addElement(field);
}
}
}
}
}
});
return myWholePanel;
}
Aggregations