use of java.awt.event.ItemEvent in project android by JetBrains.
the class AndroidLogcatView method createSearchComponent.
@NotNull
public final JPanel createSearchComponent() {
final JPanel panel = new JPanel();
final ComboBox editFiltersCombo = new ComboBox();
myFilterComboBoxModel = new DefaultComboBoxModel();
myFilterComboBoxModel.addElement(myNoFilter);
myFilterComboBoxModel.addElement(EDIT_FILTER_CONFIGURATION);
updateDefaultFilters(null);
updateUserFilters();
String selectName = AndroidLogcatPreferences.getInstance(myProject).TOOL_WINDOW_CONFIGURED_FILTER;
if (StringUtil.isEmpty(selectName)) {
selectName = myDeviceContext != null ? SELECTED_APP_FILTER : NO_FILTERS;
}
selectFilterByName(selectName);
editFiltersCombo.setModel(myFilterComboBoxModel);
applySelectedFilter();
// note: the listener is added after the initial call to populate the combo
// boxes in the above call to updateConfiguredFilters
editFiltersCombo.addItemListener(new ItemListener() {
@Nullable
private AndroidLogcatFilter myLastSelected;
@Override
public void itemStateChanged(ItemEvent e) {
Object item = e.getItem();
if (e.getStateChange() == ItemEvent.DESELECTED) {
if (item instanceof AndroidLogcatFilter) {
myLastSelected = (AndroidLogcatFilter) item;
}
} else if (e.getStateChange() == ItemEvent.SELECTED) {
if (item instanceof AndroidLogcatFilter) {
applySelectedFilter();
} else {
assert EDIT_FILTER_CONFIGURATION.equals(item);
final EditLogFilterDialog dialog = new EditLogFilterDialog(AndroidLogcatView.this, myLastSelected == null ? null : myLastSelected.getName());
dialog.setTitle(AndroidBundle.message("android.logcat.new.filter.dialog.title"));
if (dialog.showAndGet()) {
final PersistentAndroidLogFilters.FilterData filterData = dialog.getActiveFilter();
updateUserFilters();
if (filterData != null) {
selectFilterByName(filterData.getName());
}
} else {
editFiltersCombo.setSelectedItem(myLastSelected);
}
}
}
}
});
editFiltersCombo.setRenderer(new ColoredListCellRenderer<Object>() {
@Override
protected void customizeCellRenderer(@NotNull JList list, Object value, int index, boolean selected, boolean hasFocus) {
if (value instanceof AndroidLogcatFilter) {
setBorder(null);
append(((AndroidLogcatFilter) value).getName());
} else {
setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM));
append(value.toString());
}
}
});
panel.add(editFiltersCombo);
final JPanel searchComponent = new JPanel();
searchComponent.setLayout(new BoxLayout(searchComponent, X_AXIS));
searchComponent.add(myLogConsole.getSearchComponent());
searchComponent.add(panel);
return searchComponent;
}
use of java.awt.event.ItemEvent in project intellij-community by JetBrains.
the class IdeaJdkConfigurable method createComponent.
public JComponent createComponent() {
mySandboxHome.setHistorySize(5);
JPanel wholePanel = new JPanel(new GridBagLayout());
wholePanel.add(mySandboxHomeLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.emptyInsets(), 0, 0));
wholePanel.add(GuiUtils.constructFieldWithBrowseButton(mySandboxHome, new ActionListener() {
public void actionPerformed(ActionEvent e) {
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
descriptor.setTitle(DevKitBundle.message("sandbox.home"));
descriptor.setDescription(DevKitBundle.message("sandbox.purpose"));
VirtualFile file = FileChooser.chooseFile(descriptor, mySandboxHome, null, null);
if (file != null) {
mySandboxHome.setText(FileUtil.toSystemDependentName(file.getPath()));
}
myModified = true;
}
}), new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, JBUI.insets(0, 30, 0, 0), 0, 0));
wholePanel.add(myInternalJreLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0, 1, GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.emptyInsets(), 0, 0));
wholePanel.add(myInternalJres, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1, 1, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, JBUI.insets(0, 30, 0, 0), 0, 0));
myInternalJres.setRenderer(new ListCellRendererWrapper() {
@Override
public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
if (value instanceof Sdk) {
setText(((Sdk) value).getName());
}
}
});
myInternalJres.addItemListener(new ItemListener() {
public void itemStateChanged(final ItemEvent e) {
if (myFreeze)
return;
final Sdk javaJdk = (Sdk) e.getItem();
for (OrderRootType type : OrderRootType.getAllTypes()) {
if (!((SdkType) javaJdk.getSdkType()).isRootTypeApplicable(type)) {
continue;
}
final VirtualFile[] internalRoots = javaJdk.getSdkModificator().getRoots(type);
final VirtualFile[] configuredRoots = mySdkModificator.getRoots(type);
for (VirtualFile file : internalRoots) {
if (e.getStateChange() == ItemEvent.DESELECTED) {
mySdkModificator.removeRoot(file, type);
} else {
if (ArrayUtil.find(configuredRoots, file) == -1) {
mySdkModificator.addRoot(file, type);
}
}
}
}
}
});
mySandboxHome.addDocumentListener(new DocumentAdapter() {
protected void textChanged(DocumentEvent e) {
myModified = true;
}
});
mySandboxHome.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
myModified = true;
}
});
mySandboxHome.setText("");
myModified = true;
return wholePanel;
}
use of java.awt.event.ItemEvent in project intellij-community by JetBrains.
the class ParameterNameHintsConfigurable method initLanguageCombo.
private void initLanguageCombo(Language selected, List<Language> languages) {
ListComboBoxModel<Language> model = new ListComboBoxModel<>(languages);
myCurrentLanguageCombo = new ComboBox<>(model);
myCurrentLanguageCombo.setSelectedItem(selected);
myCurrentLanguageCombo.setRenderer(new ListCellRendererWrapper<Language>() {
@Override
public void customize(JList list, Language value, int index, boolean selected, boolean hasFocus) {
setText(value.getDisplayName());
}
});
myCurrentLanguageCombo.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
Language language = (Language) e.getItem();
if (e.getStateChange() == ItemEvent.SELECTED) {
showLanguagePanel(language);
}
}
});
}
use of java.awt.event.ItemEvent in project intellij-community by JetBrains.
the class PullUpDialogBase method createNorthPanel.
protected JComponent createNorthPanel() {
JPanel panel = new JPanel();
panel.setLayout(new GridBagLayout());
GridBagConstraints gbConstraints = new GridBagConstraints();
gbConstraints.insets = new Insets(4, 0, 4, 8);
gbConstraints.weighty = 1;
gbConstraints.weightx = 1;
gbConstraints.gridy = 0;
gbConstraints.gridwidth = GridBagConstraints.REMAINDER;
gbConstraints.fill = GridBagConstraints.BOTH;
gbConstraints.anchor = GridBagConstraints.WEST;
final JLabel classComboLabel = new JLabel();
panel.add(classComboLabel, gbConstraints);
myClassCombo = new JComboBox(mySuperClasses.toArray());
initClassCombo(myClassCombo);
classComboLabel.setText(RefactoringBundle.message("pull.up.members.to", UsageViewUtil.getLongName(myClass)));
classComboLabel.setLabelFor(myClassCombo);
final Class preselection = getPreselection();
int indexToSelect = 0;
if (preselection != null) {
indexToSelect = mySuperClasses.indexOf(preselection);
}
myClassCombo.setSelectedIndex(indexToSelect);
myClassCombo.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
updateMemberInfo();
}
}
});
gbConstraints.gridy++;
panel.add(myClassCombo, gbConstraints);
return panel;
}
use of java.awt.event.ItemEvent in project intellij-community by JetBrains.
the class ExtractSuperBaseDialog method createActionComponent.
protected JComponent createActionComponent() {
Box box = Box.createHorizontalBox();
final String s = StringUtil.decapitalize(getEntityName());
myRbExtractSuperclass = new JRadioButton();
myRbExtractSuperclass.setText(RefactoringBundle.message("extractSuper.extract", s));
myRbExtractSubclass = new JRadioButton();
myRbExtractSubclass.setText(RefactoringBundle.message("extractSuper.rename.original.class", s));
myRbExtractSubclass.setEnabled(isPossibleToRenameOriginal());
box.add(myRbExtractSuperclass);
box.add(myRbExtractSubclass);
box.add(Box.createHorizontalGlue());
final ButtonGroup buttonGroup = new ButtonGroup();
buttonGroup.add(myRbExtractSuperclass);
buttonGroup.add(myRbExtractSubclass);
customizeRadiobuttons(box, buttonGroup);
myRbExtractSuperclass.setSelected(true);
ItemListener listener = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
updateDialog();
}
};
myRbExtractSuperclass.addItemListener(listener);
myRbExtractSubclass.addItemListener(listener);
return box;
}
Aggregations