use of java.awt.event.ItemEvent in project kotlin by JetBrains.
the class MoveKotlinNestedClassesToUpperLevelDialog method init.
@Override
protected void init() {
classNameField.setText(innerClass.getName());
classNameField.selectAll();
if (innerClass instanceof KtClass && ((KtClass) innerClass).isInner()) {
passOuterClassCheckBox.setSelected(true);
passOuterClassCheckBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
parameterField.setEnabled(passOuterClassCheckBox.isSelected());
}
});
} else {
passOuterClassCheckBox.setSelected(false);
passOuterClassCheckBox.setEnabled(false);
parameterField.setEnabled(false);
}
if (passOuterClassCheckBox.isEnabled()) {
boolean thisNeeded = isThisNeeded();
passOuterClassCheckBox.setSelected(thisNeeded);
parameterField.setEnabled(thisNeeded);
}
passOuterClassCheckBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
boolean selected = passOuterClassCheckBox.isSelected();
parameterField.getComponent().setEnabled(selected);
}
});
if (!(targetContainer instanceof PsiDirectory)) {
packageNameField.setVisible(false);
packageNameLabel.setVisible(false);
}
if (innerClass instanceof KtClass && ((KtClass) innerClass).isInner()) {
KtClassBody innerClassBody = innerClass.getBody();
Function1<String, Boolean> validator = innerClassBody != null ? new NewDeclarationNameValidator(innerClassBody, (PsiElement) null, NewDeclarationNameValidator.Target.VARIABLES, Collections.<KtDeclaration>emptyList()) : new CollectingNameValidator();
List<String> suggestions = KotlinNameSuggester.INSTANCE.suggestNamesByType(getOuterInstanceType(), validator, "outer");
parameterField.setSuggestions(ArrayUtil.toStringArray(suggestions));
} else {
parameterField.getComponent().setEnabled(false);
}
FqName packageFqName = getTargetPackageFqName();
if (packageFqName != null) {
packageNameField.prependItem(packageFqName.asString());
}
KotlinRefactoringSettings settings = KotlinRefactoringSettings.getInstance();
searchForTextOccurrencesCheckBox.setSelected(settings.MOVE_TO_UPPER_LEVEL_SEARCH_FOR_TEXT);
searchInCommentsCheckBox.setSelected(settings.MOVE_TO_UPPER_LEVEL_SEARCH_IN_COMMENTS);
super.init();
}
use of java.awt.event.ItemEvent in project intellij-community by JetBrains.
the class RepositoryLibraryPropertiesEditor method initVersionsPanel.
private void initVersionsPanel() {
final int selection = getSelection(model.getVersion(), versions);
CollectionComboBoxModel<String> versionSelectorModel = new CollectionComboBoxModel<>(versions);
//noinspection unchecked
versionSelector.setModel(versionSelectorModel);
versionSelector.setSelectedIndex(selection);
setState(State.Loaded);
initVersionKindSelector();
versionSelector.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
model.setVersion(getSelectedVersion());
onChangeListener.onChange(RepositoryLibraryPropertiesEditor.this);
}
});
downloadSourcesCheckBox.setSelected(model.isDownloadSources());
downloadSourcesCheckBox.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
model.setDownloadSources(downloadSourcesCheckBox.isSelected());
onChangeListener.onChange(RepositoryLibraryPropertiesEditor.this);
}
});
downloadJavaDocsCheckBox.setSelected(model.isDownloadJavaDocs());
downloadJavaDocsCheckBox.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
model.setDownloadJavaDocs(downloadJavaDocsCheckBox.isSelected());
onChangeListener.onChange(RepositoryLibraryPropertiesEditor.this);
}
});
}
use of java.awt.event.ItemEvent in project intellij-community by JetBrains.
the class SelectMavenProjectDialog method createCenterPanel.
protected JComponent createCenterPanel() {
ComboBoxUtil.setModel(myMavenProjectsComboBox, new DefaultComboBoxModel(), myMavenDomProjectModels, model -> {
String projectName = model.getName().getStringValue();
MavenProject mavenProject = MavenDomUtil.findProject(model);
if (mavenProject != null) {
projectName = mavenProject.getDisplayName();
}
if (StringUtil.isEmptyOrSpaces(projectName)) {
projectName = "pom.xml";
}
return Pair.create(projectName, model);
});
myReplaceAllListener = new ItemListener() {
public void itemStateChanged(ItemEvent e) {
updateControls();
}
};
myMavenProjectsComboBox.addItemListener(myReplaceAllListener);
myMavenProjectsComboBox.setSelectedItem(0);
myReplaceAllCheckBox.setVisible(myHasUsagesInProjects);
myExtractExclusions.setVisible(myHasExclusions);
updateControls();
return myMainPanel;
}
use of java.awt.event.ItemEvent in project intellij-community by JetBrains.
the class EvalExpressionDialog method init.
protected void init() {
final ToolWindow findWindow = ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.FIND);
final boolean available = findWindow != null && findWindow.isAvailable();
myForm.getNewTabCheckbox().setEnabled(available);
myForm.getNewTabCheckbox().setSelected(FindSettings.getInstance().isShowResultsInSeparateView());
myForm.getHighlightCheckbox().setSelected(mySettings.HIGHLIGHT_RESULTS);
myForm.getHighlightCheckbox().addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
updateOkAction();
}
});
myForm.getUsageViewCheckbox().setSelected(mySettings.SHOW_USAGE_VIEW);
myForm.getUsageViewCheckbox().addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
myForm.getNewTabCheckbox().setEnabled(available && myForm.getUsageViewCheckbox().isSelected());
updateOkAction();
}
});
super.init();
}
use of java.awt.event.ItemEvent 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();
}
});
}
Aggregations