use of com.intellij.ui.NonFocusableCheckBox in project intellij-community by JetBrains.
the class IntroduceFieldCentralPanel method appendOccurrences.
public void appendOccurrences(ItemListener itemListener, GridBagConstraints gbConstraints, JPanel panel) {
if (myOccurrencesCount > 1) {
myCbReplaceAll = new NonFocusableCheckBox();
myCbReplaceAll.setText(RefactoringBundle.message("replace.all.occurrences.of.expression.0.occurrences", myOccurrencesCount));
gbConstraints.gridy++;
panel.add(myCbReplaceAll, gbConstraints);
myCbReplaceAll.addItemListener(itemListener);
if (myIsInvokedOnDeclaration) {
myCbReplaceAll.setEnabled(false);
myCbReplaceAll.setSelected(true);
}
}
}
use of com.intellij.ui.NonFocusableCheckBox 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 com.intellij.ui.NonFocusableCheckBox in project intellij-community by JetBrains.
the class IntroduceParameterSettingsUI method createDelegateCb.
protected void createDelegateCb(GridBagConstraints gbConstraints, JPanel panel) {
myCbGenerateDelegate = new NonFocusableCheckBox(RefactoringBundle.message("delegation.panel.delegate.via.overloading.method"));
panel.add(myCbGenerateDelegate, gbConstraints);
}
use of com.intellij.ui.NonFocusableCheckBox in project intellij-community by JetBrains.
the class JavaVariableInplaceIntroducer method getComponent.
@Nullable
protected JComponent getComponent() {
if (!myCantChangeFinalModifier) {
myCanBeFinalCb = new NonFocusableCheckBox("Declare final");
myCanBeFinalCb.setSelected(createFinals());
myCanBeFinalCb.setMnemonic('f');
final FinalListener finalListener = new FinalListener(myEditor);
myCanBeFinalCb.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new WriteCommandAction(myProject, getCommandName(), getCommandName()) {
@Override
protected void run(@NotNull Result result) throws Throwable {
PsiDocumentManager.getInstance(myProject).commitDocument(myEditor.getDocument());
final PsiVariable variable = getVariable();
if (variable != null) {
finalListener.perform(myCanBeFinalCb.isSelected(), variable);
}
}
}.execute();
}
});
} else {
return null;
}
final JPanel panel = new JPanel(new GridBagLayout());
panel.setBorder(null);
if (myCanBeFinalCb != null) {
panel.add(myCanBeFinalCb, new GridBagConstraints(0, 1, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, JBUI.insets(5), 0, 0));
}
panel.add(Box.createVerticalBox(), new GridBagConstraints(0, 2, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, JBUI.emptyInsets(), 0, 0));
return panel;
}
use of com.intellij.ui.NonFocusableCheckBox in project intellij-community by JetBrains.
the class IntroduceParameterDialog method createNorthPanel.
protected JComponent createNorthPanel() {
GridBagConstraints gbConstraints = new GridBagConstraints();
JPanel panel = new JPanel(new GridBagLayout());
gbConstraints.anchor = GridBagConstraints.WEST;
gbConstraints.fill = GridBagConstraints.NONE;
gbConstraints.gridx = 0;
gbConstraints.insets = JBUI.insets(4, 4, 4, 0);
gbConstraints.gridwidth = 1;
gbConstraints.weightx = 0;
gbConstraints.weighty = 0;
gbConstraints.gridy = 0;
JLabel type = new JLabel(RefactoringBundle.message("parameter.of.type"));
panel.add(type, gbConstraints);
gbConstraints.insets = JBUI.insets(4, 4, 4, 8);
gbConstraints.gridx++;
gbConstraints.weightx = 1;
gbConstraints.fill = GridBagConstraints.BOTH;
myTypeSelector = myTypeSelectorManager.getTypeSelector();
panel.add(myTypeSelector.getComponent(), gbConstraints);
gbConstraints.insets = JBUI.insets(4, 4, 4, 8);
gbConstraints.gridwidth = 1;
gbConstraints.weightx = 0;
gbConstraints.gridx = 0;
gbConstraints.gridy = 1;
gbConstraints.fill = GridBagConstraints.NONE;
myParameterNameField = new NameSuggestionsField(myProject);
final JLabel nameLabel = new JLabel(RefactoringBundle.message("name.prompt"));
nameLabel.setLabelFor(myParameterNameField.getComponent());
panel.add(nameLabel, gbConstraints);
/*
if (myNameSuggestions.length > 1) {
myParameterNameField = createComboBoxForName();
}
else {
myParameterNameField = createTextFieldForName();
}
*/
gbConstraints.gridx++;
gbConstraints.insets = JBUI.insets(4, 4, 4, 8);
gbConstraints.weightx = 1;
gbConstraints.fill = GridBagConstraints.BOTH;
panel.add(myParameterNameField.getComponent(), gbConstraints);
myParameterNameChangedListener = () -> validateButtons();
myParameterNameField.addDataChangedListener(myParameterNameChangedListener);
myNameSuggestionsManager = new NameSuggestionsManager(myTypeSelector, myParameterNameField, myNameSuggestionsGenerator);
myNameSuggestionsManager.setLabelsFor(type, nameLabel);
gbConstraints.gridx = 0;
gbConstraints.insets = JBUI.insets(4, 0, 4, 8);
gbConstraints.gridwidth = 2;
if (myOccurenceNumber > 1 && !myPanel.myIsInvokedOnDeclaration) {
gbConstraints.gridy++;
myPanel.createOccurrencesCb(gbConstraints, panel, myOccurenceNumber);
}
if (myPanel.myCbReplaceAllOccurences != null) {
gbConstraints.insets = JBUI.insets(0, 16, 4, 8);
}
JavaRefactoringSettings settings = JavaRefactoringSettings.getInstance();
myPanel.createLocalVariablePanel(gbConstraints, panel, settings);
myPanel.createRemoveParamsPanel(gbConstraints, panel);
gbConstraints.insets = JBUI.insets(4, 0, 4, 8);
gbConstraints.gridy++;
myCbDeclareFinal = new NonFocusableCheckBox(RefactoringBundle.message("declare.final"));
final Boolean settingsFinals = settings.INTRODUCE_PARAMETER_CREATE_FINALS;
myCbDeclareFinal.setSelected(settingsFinals == null ? CodeStyleSettingsManager.getSettings(myProject).GENERATE_FINAL_PARAMETERS : settingsFinals.booleanValue());
panel.add(myCbDeclareFinal, gbConstraints);
if (myMustBeFinal) {
myCbDeclareFinal.setSelected(true);
myCbDeclareFinal.setEnabled(false);
} else if (myHasWriteAccess && myPanel.isReplaceAllOccurences()) {
myCbDeclareFinal.setSelected(false);
myCbDeclareFinal.setEnabled(false);
}
gbConstraints.gridy++;
myPanel.createDelegateCb(gbConstraints, panel);
myCbCollapseToLambda = new NonFocusableCheckBox(RefactoringBundle.message("introduce.parameter.convert.lambda"));
final PsiAnonymousClass anonymClass = myExpression instanceof PsiNewExpression ? ((PsiNewExpression) myExpression).getAnonymousClass() : null;
myCbCollapseToLambda.setVisible(anonymClass != null && AnonymousCanBeLambdaInspection.canBeConvertedToLambda(anonymClass, false, Collections.emptySet()));
myCbCollapseToLambda.setSelected(PropertiesComponent.getInstance(myProject).getBoolean(INTRODUCE_PARAMETER_LAMBDA));
gbConstraints.gridy++;
panel.add(myCbCollapseToLambda, gbConstraints);
return panel;
}
Aggregations