use of java.awt.event.ItemEvent in project intellij-community by JetBrains.
the class IntroduceVariableDialog method createCenterPanel.
protected JComponent createCenterPanel() {
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints gbConstraints = new GridBagConstraints();
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
gbConstraints.weightx = 1;
gbConstraints.weighty = 0;
gbConstraints.gridwidth = 1;
gbConstraints.gridx = 0;
gbConstraints.gridy = 0;
gbConstraints.insets = JBUI.emptyInsets();
if (myOccurrencesCount > 1) {
myCbReplaceAll = new NonFocusableCheckBox();
myCbReplaceAll.setText(RefactoringBundle.message("replace.all.occurences", myOccurrencesCount));
panel.add(myCbReplaceAll, gbConstraints);
myReplaceAllListener = new ItemListener() {
public void itemStateChanged(ItemEvent e) {
updateControls();
}
};
myCbReplaceAll.addItemListener(myReplaceAllListener);
if (myAnyLValueOccurences) {
myCbReplaceWrite = new StateRestoringCheckBox();
myCbReplaceWrite.setText(RefactoringBundle.message("replace.write.access.occurrences"));
gbConstraints.insets = JBUI.insetsLeft(8);
gbConstraints.gridy++;
panel.add(myCbReplaceWrite, gbConstraints);
myCbReplaceWrite.addItemListener(myReplaceAllListener);
}
}
myCbFinal = new NonFocusableCheckBox();
myCbFinal.setText(RefactoringBundle.message("declare.final"));
final Boolean createFinals = JavaRefactoringSettings.getInstance().INTRODUCE_LOCAL_CREATE_FINALS;
myCbFinalState = createFinals == null ? CodeStyleSettingsManager.getSettings(myProject).GENERATE_FINAL_LOCALS : createFinals.booleanValue();
gbConstraints.insets = JBUI.emptyInsets();
gbConstraints.gridy++;
panel.add(myCbFinal, gbConstraints);
myFinalListener = new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (myCbFinal.isEnabled()) {
myCbFinalState = myCbFinal.isSelected();
}
}
};
myCbFinal.addItemListener(myFinalListener);
updateControls();
return panel;
}
use of java.awt.event.ItemEvent in project intellij-community by JetBrains.
the class UpdateOptionsPanel method reset.
public void reset() {
CvsConfiguration config = CvsConfiguration.getInstance(myProject);
myPruneEmptyDirectories.setSelected(config.PRUNE_EMPTY_DIRECTORIES);
myDoNotMerge.setSelected(true);
myBranch.setText(config.MERGE_WITH_BRANCH1_NAME);
myBranch2.setText(config.MERGE_WITH_BRANCH2_NAME);
mySwitchToHeadRevision.setSelected(false);
myCreateNewDirectories.setSelected(config.CREATE_NEW_DIRECTORIES);
myCleanCopy.setSelected(false);
myDateOrRevisionOrTagSettings.updateFrom(config.UPDATE_DATE_OR_REVISION_SETTINGS);
for (JRadioButton jRadioButton : myMergingGroup) {
jRadioButton.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
enableBranchField();
}
});
}
enableBranchField();
}
use of java.awt.event.ItemEvent in project intellij-community by JetBrains.
the class IntroduceConstantDialog method createNorthPanel.
protected JComponent createNorthPanel() {
myTypeSelector = myTypeSelectorManager.getTypeSelector();
myTypePanel.setLayout(new BorderLayout());
myTypePanel.add(myTypeSelector.getComponent(), BorderLayout.CENTER);
if (myTypeSelector.getFocusableComponent() != null) {
myTypeLabel.setLabelFor(myTypeSelector.getFocusableComponent());
}
myNameField = new NameSuggestionsField(myProject);
myNameSuggestionPanel.setLayout(new BorderLayout());
myNameField.addDataChangedListener(new NameSuggestionsField.DataChanged() {
public void dataChanged() {
updateButtons();
}
});
myNameSuggestionPanel.add(myNameField.getComponent(), BorderLayout.CENTER);
myNameSuggestionLabel.setLabelFor(myNameField.getFocusableComponent());
Set<String> possibleClassNames = new LinkedHashSet<>();
for (final PsiExpression occurrence : myOccurrences) {
final PsiClass parentClass = new IntroduceConstantHandler().getParentClass(occurrence);
if (parentClass != null && parentClass.getQualifiedName() != null) {
possibleClassNames.add(parentClass.getQualifiedName());
}
}
myTfTargetClassName = new ReferenceEditorComboWithBrowseButton(new ChooseClassAction(), "", myProject, true, RECENTS_KEY);
myTargetClassNamePanel.setLayout(new BorderLayout());
myTargetClassNamePanel.add(myTfTargetClassName, BorderLayout.CENTER);
myTargetClassNameLabel.setLabelFor(myTfTargetClassName);
for (String possibleClassName : possibleClassNames) {
myTfTargetClassName.prependItem(possibleClassName);
}
myTfTargetClassName.getChildComponent().setSelectedItem(myParentClass.getQualifiedName());
myTfTargetClassName.getChildComponent().addDocumentListener(new DocumentAdapter() {
public void documentChanged(DocumentEvent e) {
targetClassChanged();
enableEnumDependant(introduceEnumConstant());
}
});
myIntroduceEnumConstantCb.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
enableEnumDependant(introduceEnumConstant());
}
});
final JPanel enumPanel = new JPanel(new BorderLayout());
enumPanel.add(myIntroduceEnumConstantCb, BorderLayout.EAST);
myTargetClassNamePanel.add(enumPanel, BorderLayout.SOUTH);
final String propertyName;
if (myLocalVariable != null) {
propertyName = myCodeStyleManager.variableNameToPropertyName(myLocalVariable.getName(), VariableKind.LOCAL_VARIABLE);
} else {
propertyName = null;
}
final NameSuggestionsManager nameSuggestionsManager = new NameSuggestionsManager(myTypeSelector, myNameField, createNameSuggestionGenerator(propertyName, myInitializerExpression, myCodeStyleManager, myEnteredName, myParentClass));
nameSuggestionsManager.setLabelsFor(myTypeLabel, myNameSuggestionLabel);
//////////
if (myOccurrencesCount > 1) {
myCbReplaceAll.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
updateTypeSelector();
myNameField.requestFocusInWindow();
}
});
myCbReplaceAll.setText(RefactoringBundle.message("replace.all.occurences", myOccurrencesCount));
} else {
myCbReplaceAll.setVisible(false);
}
if (myLocalVariable != null) {
if (myInvokedOnDeclaration) {
myCbDeleteVariable.setEnabled(false);
myCbDeleteVariable.setSelected(true);
} else if (myCbReplaceAll != null) {
updateCbDeleteVariable();
myCbReplaceAll.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
updateCbDeleteVariable();
}
});
}
} else {
myCbDeleteVariable.setVisible(false);
}
final PsiManager psiManager = PsiManager.getInstance(myProject);
if ((myTypeSelectorManager.isSuggestedType(CommonClassNames.JAVA_LANG_STRING) || (myLocalVariable != null && AnnotationUtil.isAnnotated(myLocalVariable, AnnotationUtil.NON_NLS, false, false))) && LanguageLevelProjectExtension.getInstance(psiManager.getProject()).getLanguageLevel().isAtLeast(LanguageLevel.JDK_1_5) && JavaPsiFacade.getInstance(psiManager.getProject()).findClass(AnnotationUtil.NON_NLS, myParentClass.getResolveScope()) != null) {
final PropertiesComponent component = PropertiesComponent.getInstance(myProject);
myCbNonNls.setSelected(component.getBoolean(NONNLS_SELECTED_PROPERTY));
myCbNonNls.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
component.setValue(NONNLS_SELECTED_PROPERTY, myCbNonNls.isSelected());
}
});
} else {
myCbNonNls.setVisible(false);
}
updateTypeSelector();
enableEnumDependant(introduceEnumConstant());
return myPanel;
}
use of java.awt.event.ItemEvent in project intellij-community by JetBrains.
the class IntroduceFieldCentralPanel method appendCheckboxes.
protected JPanel appendCheckboxes(ItemListener itemListener) {
GridBagConstraints gbConstraints = new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, JBUI.emptyInsets(), 0, 0);
JPanel panel = new JPanel(new GridBagLayout());
myCbFinal = new StateRestoringCheckBox();
myCbFinal.setFocusable(false);
myCbFinal.setText(RefactoringBundle.message("declare.final"));
myCbFinal.addItemListener(itemListener);
gbConstraints.gridy++;
panel.add(myCbFinal, gbConstraints);
appendOccurrences(itemListener, gbConstraints, panel);
if (myLocalVariable != null) {
gbConstraints.gridy++;
if (myCbReplaceAll != null) {
gbConstraints.insets = JBUI.insetsLeft(8);
}
myCbDeleteVariable = new StateRestoringCheckBox();
myCbDeleteVariable.setText(RefactoringBundle.message("delete.variable.declaration"));
panel.add(myCbDeleteVariable, gbConstraints);
if (myIsInvokedOnDeclaration) {
myCbDeleteVariable.setEnabled(false);
myCbDeleteVariable.setSelected(true);
} else if (myCbReplaceAll != null) {
updateCbDeleteVariable();
myCbReplaceAll.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
updateCbDeleteVariable();
}
});
}
}
return panel;
}
use of java.awt.event.ItemEvent in project intellij-community by JetBrains.
the class JBTabsDemo method main.
public static void main(String[] args) {
System.out.println("JBTabs.main");
IconLoader.activate();
final JFrame frame = new JFrame();
frame.getContentPane().setLayout(new BorderLayout(0, 0));
final int[] count = new int[1];
final JBTabsImpl tabs = new JBTabsImpl(null, ActionManager.getInstance(), null, Disposer.newDisposable());
tabs.setTestMode(true);
//final JPanel flow = new JPanel(new FlowLayout(FlowLayout.CENTER));
//frame.getContentPane().add(flow);
//flow.add(tabs.getComponent());
frame.getContentPane().add(tabs.getComponent(), BorderLayout.CENTER);
JPanel south = new JPanel(new FlowLayout());
south.setOpaque(true);
south.setBackground(Color.white);
final JComboBox pos = new JComboBox(new Object[] { JBTabsPosition.top, JBTabsPosition.left, JBTabsPosition.right, JBTabsPosition.bottom });
pos.setSelectedIndex(0);
south.add(pos);
pos.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
final JBTabsPosition p = (JBTabsPosition) pos.getSelectedItem();
if (p != null) {
tabs.getPresentation().setTabsPosition(p);
}
}
});
final JCheckBox bb = new JCheckBox("Buffered", true);
bb.addItemListener(new ItemListener() {
public void itemStateChanged(final ItemEvent e) {
tabs.setUseBufferedPaint(bb.isSelected());
}
});
south.add(bb);
final JCheckBox f = new JCheckBox("Focused");
f.addItemListener(new ItemListener() {
public void itemStateChanged(final ItemEvent e) {
tabs.setFocused(f.isSelected());
}
});
south.add(f);
final JCheckBox v = new JCheckBox("Vertical");
v.addItemListener(new ItemListener() {
public void itemStateChanged(final ItemEvent e) {
tabs.setSideComponentVertical(v.isSelected());
}
});
south.add(v);
final JCheckBox row = new JCheckBox("Single row", true);
row.addItemListener(new ItemListener() {
public void itemStateChanged(final ItemEvent e) {
tabs.setSingleRow(row.isSelected());
}
});
south.add(row);
final JCheckBox ghosts = new JCheckBox("Ghosts always visible", false);
ghosts.addItemListener(new ItemListener() {
public void itemStateChanged(final ItemEvent e) {
tabs.setGhostsAlwaysVisible(ghosts.isSelected());
}
});
south.add(ghosts);
final JCheckBox stealth = new JCheckBox("Stealth tab", tabs.isStealthTabMode());
stealth.addItemListener(new ItemListener() {
public void itemStateChanged(final ItemEvent e) {
tabs.setStealthTabMode(stealth.isSelected());
}
});
south.add(stealth);
final JCheckBox hide = new JCheckBox("Hide tabs", tabs.isHideTabs());
hide.addItemListener(new ItemListener() {
public void itemStateChanged(final ItemEvent e) {
tabs.setHideTabs(hide.isSelected());
}
});
south.add(hide);
frame.getContentPane().add(south, BorderLayout.SOUTH);
tabs.addListener(new TabsListener.Adapter() {
public void selectionChanged(final TabInfo oldSelection, final TabInfo newSelection) {
System.out.println("TabsWithActions.selectionChanged old=" + oldSelection + " new=" + newSelection);
}
});
final JTree someTree = new Tree() {
public void addNotify() {
//To change body of overridden methods use File | Settings | File Templates.
super.addNotify();
System.out.println("JBTabs.addNotify");
}
public void removeNotify() {
System.out.println("JBTabs.removeNotify");
//To change body of overridden methods use File | Settings | File Templates.
super.removeNotify();
}
};
//someTree.setBorder(new LineBorder(Color.cyan));
tabs.addTab(new TabInfo(someTree)).setText("Tree1").setActions(new DefaultActionGroup(), null).setIcon(AllIcons.Debugger.Frame);
final JTree component = new Tree();
final TabInfo toAnimate1 = new TabInfo(component);
//toAnimate1.setIcon(IconLoader.getIcon("/debugger/console.png"));
final JCheckBox attract1 = new JCheckBox("Attract 1");
attract1.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
if (attract1.isSelected()) {
toAnimate1.fireAlert();
} else {
toAnimate1.stopAlerting();
}
}
});
south.add(attract1);
final JCheckBox hide1 = new JCheckBox("Hide 1", toAnimate1.isHidden());
hide1.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
toAnimate1.setHidden(!toAnimate1.isHidden());
}
});
south.add(hide1);
final JCheckBox block = new JCheckBox("Block", false);
block.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
tabs.setPaintBlocked(!block.isSelected(), true);
}
});
south.add(block);
final JCheckBox fill = new JCheckBox("Tab fill in", true);
fill.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
tabs.getPresentation().setActiveTabFillIn(fill.isSelected() ? Color.white : null);
}
});
south.add(fill);
final JButton refire = new JButton("Re-fire attraction");
refire.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
toAnimate1.fireAlert();
}
});
south.add(refire);
final JEditorPane text = new JEditorPane();
text.setEditorKit(new HTMLEditorKit());
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < 50; i++) {
buffer.append("1234567890abcdefghijklmnopqrstv1234567890abcdefghijklmnopqrstv1234567890abcdefghijklmnopqrstv<br>");
}
text.setText(buffer.toString());
final JLabel tb = new JLabel("Side comp");
tb.setBorder(new LineBorder(Color.red));
tabs.addTab(new TabInfo(ScrollPaneFactory.createScrollPane(text)).setSideComponent(tb)).setText("Text text text");
tabs.addTab(toAnimate1).append("Tree2", new SimpleTextAttributes(SimpleTextAttributes.STYLE_WAVED, Color.black, Color.red));
tabs.addTab(new TabInfo(new JTable())).setText("Table 1").setActions(new DefaultActionGroup(), null);
tabs.addTab(new TabInfo(new JTable())).setText("Table 2").setActions(new DefaultActionGroup(), null);
tabs.addTab(new TabInfo(new JTable())).setText("Table 3").setActions(new DefaultActionGroup(), null);
tabs.addTab(new TabInfo(new JTable())).setText("Table 4").setActions(new DefaultActionGroup(), null);
tabs.addTab(new TabInfo(new JTable())).setText("Table 5").setActions(new DefaultActionGroup(), null);
tabs.addTab(new TabInfo(new JTable())).setText("Table 6").setActions(new DefaultActionGroup(), null);
tabs.addTab(new TabInfo(new JTable())).setText("Table 7").setActions(new DefaultActionGroup(), null);
tabs.addTab(new TabInfo(new JTable())).setText("Table 8").setActions(new DefaultActionGroup(), null);
tabs.addTab(new TabInfo(new JTable())).setText("Table 9").setActions(new DefaultActionGroup(), null);
//tabs.getComponent().setBorder(new EmptyBorder(5, 5, 5, 5));
tabs.setTabSidePaintBorder(5);
tabs.setPaintBorder(1, 1, 1, 1);
tabs.getPresentation().setActiveTabFillIn(Color.white);
tabs.setGhostsAlwaysVisible(true);
//tabs.setBorder(new LineBorder(Color.blue, 5));
tabs.setBorder(new EmptyBorder(30, 30, 30, 30));
tabs.setUiDecorator(new UiDecorator() {
public UiDecoration getDecoration() {
return new UiDecoration(null, new Insets(0, -1, 0, -1));
}
});
tabs.setStealthTabMode(true);
frame.setBounds(1400, 200, 1000, 800);
frame.show();
}
Aggregations