private static JCheckBox buildOptionCheckBox(final PropertiesComponent propertiesComponent, final SelectorOption selectorOption) { final InnerBuilderOption option = selectorOption.getOption(); final JCheckBox optionCheckBox = new NonFocusableCheckBox(selectorOption.getCaption()); optionCheckBox.setMnemonic(selectorOption.getMnemonic()); optionCheckBox.setToolTipText(selectorOption.getToolTip()); final String optionProperty = option.getProperty(); optionCheckBox.setSelected(propertiesComponent.isTrueValue(optionProperty)); optionCheckBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(final ItemEvent event) { propertiesComponent.setValue(optionProperty, Boolean.toString(optionCheckBox.isSelected())); } }); return optionCheckBox; }
protected JComponent createNorthPanel() { myNameField = new NameSuggestionsField(myProject); FormBuilder formBuilder = FormBuilder.createFormBuilder() .addLabeledComponent(RefactoringBundle.message("anonymousToInner.class.name.label.text"), myNameField); if(!myShowCanBeStatic) { myCbMakeStatic = new NonFocusableCheckBox(RefactoringBundle.message("anonymousToInner.make.class.static.checkbox.text")); myCbMakeStatic.setSelected(true); formBuilder.addComponent(myCbMakeStatic); } return formBuilder.getPanel(); }
public ExtractMethodDialog(Project project, PsiClass targetClass, final InputVariables inputVariables, PsiType returnType, PsiTypeParameterList typeParameterList, PsiType[] exceptions, boolean isStatic, boolean canBeStatic, final boolean canBeChainedConstructor, String title, String helpId, Nullness nullness, final PsiElement[] elementsToExtract) { super(project, true); myProject = project; myTargetClass = targetClass; myReturnType = returnType; myTypeParameterList = typeParameterList; myExceptions = exceptions; myStaticFlag = isStatic; myCanBeStatic = canBeStatic; myNullness = nullness; myElementsToExtract = elementsToExtract; myVariableData = inputVariables; myHelpId = helpId; mySignature = new MethodSignatureComponent("", project, JavaFileType.INSTANCE); mySignature.setPreferredSize(JBUI.size(500, 100)); mySignature.setMinimumSize(JBUI.size(500, 100)); setTitle(title); myNameField = new NameSuggestionsField(suggestMethodNames(), myProject); myMakeStatic = new NonFocusableCheckBox(); myMakeStatic.setText(RefactoringBundle.message("declare.static.checkbox")); if (canBeChainedConstructor) { myCbChainedConstructor = new NonFocusableCheckBox(RefactoringBundle.message("extract.chained.constructor.checkbox")); } init(); }
protected void createOccurrencesCb(GridBagConstraints gbConstraints, JPanel panel, final int occurenceNumber) { myCbReplaceAllOccurences = new NonFocusableCheckBox(); myCbReplaceAllOccurences.setText(RefactoringBundle.message("replace.all.occurences", occurenceNumber)); panel.add(myCbReplaceAllOccurences, gbConstraints); myCbReplaceAllOccurences.setSelected(false); }
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); } } }
@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, new Insets(5, 5, 5, 5), 0, 0)); } panel.add(Box.createVerticalBox(), new GridBagConstraints(0, 2, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0,0,0,0), 0,0)); return panel; }
@Override @Nullable public RefreshableOnComponent getBeforeCheckinConfigurationPanel() { final JCheckBox optimizeBox = new NonFocusableCheckBox(VcsBundle.message("checkbox.checkin.options.optimize.imports")); CheckinHandlerUtil.disableWhenDumb(myProject, optimizeBox, "Impossible until indices are up-to-date"); return new RefreshableOnComponent() { @Override public JComponent getComponent() { final JPanel panel = new JPanel(new GridLayout(1, 0)); panel.add(optimizeBox); return panel; } @Override public void refresh() { } @Override public void saveState() { getSettings().OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT = optimizeBox.isSelected(); } @Override public void restoreState() { optimizeBox.setSelected(getSettings().OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT); } }; }
@Override public RefreshableOnComponent getBeforeCheckinConfigurationPanel() { final JCheckBox cleanupCodeCb = new NonFocusableCheckBox(VcsBundle.message("before.checkin.cleanup.code")); return new RefreshableOnComponent() { @Override public JComponent getComponent() { final JPanel cbPanel = new JPanel(new BorderLayout()); cbPanel.add(cleanupCodeCb, BorderLayout.WEST); CheckinHandlerUtil .disableWhenDumb(myProject, cleanupCodeCb, "Code analysis is impossible until indices are up-to-date"); return cbPanel; } @Override public void refresh() { } @Override public void saveState() { VcsConfiguration.getInstance(myProject).CHECK_CODE_CLEANUP_BEFORE_PROJECT_COMMIT = cleanupCodeCb.isSelected(); } @Override public void restoreState() { cleanupCodeCb.setSelected(VcsConfiguration.getInstance(myProject).CHECK_CODE_CLEANUP_BEFORE_PROJECT_COMMIT); } }; }
@Override @Nullable public RefreshableOnComponent getBeforeCheckinConfigurationPanel() { final JCheckBox reformatBox = new NonFocusableCheckBox(VcsBundle.message("checkbox.checkin.options.reformat.code")); return new RefreshableOnComponent() { @Override public JComponent getComponent() { final JPanel panel = new JPanel(new GridLayout(1, 0)); panel.add(reformatBox); return panel; } @Override public void refresh() { } @Override public void saveState() { getSettings().REFORMAT_BEFORE_PROJECT_COMMIT = reformatBox.isSelected(); } @Override public void restoreState() { reformatBox.setSelected(getSettings().REFORMAT_BEFORE_PROJECT_COMMIT); } }; }
@Override @Nullable public RefreshableOnComponent getBeforeCheckinConfigurationPanel() { final JCheckBox rearrangeBox = new NonFocusableCheckBox(VcsBundle.message("checkbox.checkin.options.rearrange.code")); CheckinHandlerUtil.disableWhenDumb(myProject, rearrangeBox, "Impossible until indices are up-to-date"); return new RefreshableOnComponent() { @Override public JComponent getComponent() { final JPanel panel = new JPanel(new GridLayout(1, 0)); panel.add(rearrangeBox); return panel; } @Override public void refresh() { } @Override public void saveState() { getSettings().REARRANGE_BEFORE_PROJECT_COMMIT = rearrangeBox.isSelected(); } @Override public void restoreState() { rearrangeBox.setSelected(getSettings().REARRANGE_BEFORE_PROJECT_COMMIT); } }; }
@Override @Nullable public RefreshableOnComponent getBeforeCheckinConfigurationPanel() { final JCheckBox checkBox = new NonFocusableCheckBox(VcsBundle.message("before.checkin.standard.options.check.smells")); return new RefreshableOnComponent() { @Override public JComponent getComponent() { JPanel panel = new JPanel(new BorderLayout()); panel.add(checkBox); CheckinHandlerUtil.disableWhenDumb(myProject, checkBox, "Code analysis is impossible until indices are up-to-date"); return panel; } @Override public void refresh() { } @Override public void saveState() { getSettings().CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT = checkBox.isSelected(); } @Override public void restoreState() { checkBox.setSelected(getSettings().CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT); } }; }
@Override protected void createCheckboxes(JPanel panel, GridBagConstraints gbConstraints) { gbConstraints.insets = new Insets(0, 0, 4, 0); gbConstraints.gridwidth = 1; gbConstraints.gridx = 0; gbConstraints.weighty = 0; gbConstraints.weightx = 1; gbConstraints.fill = GridBagConstraints.BOTH; myCbSearchForReferences = new NonFocusableCheckBox(RefactoringBundle.message("search.for.references")); myCbSearchForReferences.setSelected(getSearchForReferences()); panel.add(myCbSearchForReferences, gbConstraints); super.createCheckboxes(panel, gbConstraints); }
@Override protected JComponent getComponent() { myCanBeFinalCb = new NonFocusableCheckBox("Declare final"); myCanBeFinalCb.setSelected(false); myCanBeFinalCb.setMnemonic('f'); final GrFinalListener finalListener = new GrFinalListener(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 GrVariable variable = getVariable(); if (variable != null) { finalListener.perform(myCanBeFinalCb.isSelected(), variable); } } }.execute(); } }); 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, new Insets(5, 5, 5, 5), 0, 0)); } panel.add(Box.createVerticalBox(), new GridBagConstraints(0, 2, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); return panel; }
private InstanceofOptionStep() { final JCheckBox checkbox = new NonFocusableCheckBox(CodeInsightBundle.message("generate.equals.hashcode.accept.sublcasses")); checkbox.setSelected(CodeInsightSettings.getInstance().USE_INSTANCEOF_ON_EQUALS_PARAMETER); checkbox.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { CodeInsightSettings.getInstance().USE_INSTANCEOF_ON_EQUALS_PARAMETER = checkbox.isSelected(); } }); myPanel = new JPanel(new VerticalFlowLayout()); myPanel.add(checkbox); myPanel.add(new JLabel(CodeInsightBundle.message("generate.equals.hashcode.accept.sublcasses.explanation"))); }
public ExtractMethodDialog(Project project, PsiClass targetClass, final InputVariables inputVariables, PsiType returnType, PsiTypeParameterList typeParameterList, PsiType[] exceptions, boolean isStatic, boolean canBeStatic, final boolean canBeChainedConstructor, String initialMethodName, String title, String helpId, final PsiElement[] elementsToExtract) { super(project); myProject = project; myTargetClass = targetClass; myReturnType = returnType; myTypeParameterList = typeParameterList; myExceptions = exceptions; myStaticFlag = isStatic; myCanBeStatic = canBeStatic; myElementsToExtract = elementsToExtract; myVariableData = inputVariables; myHelpId = helpId; mySignature = new MethodSignatureComponent("", project, JavaFileType.INSTANCE); mySignature.setPreferredSize(new Dimension(500, 100)); mySignature.setMinimumSize(new Dimension(500, 100)); setTitle(title); // Create UI components myNameField = createNameField(initialMethodName); int height = myVariableData.getInputVariables().size() + 2; if (myExceptions.length > 0) { height += myExceptions.length + 1; } myMakeStatic = new NonFocusableCheckBox(); myMakeStatic.setText(RefactoringBundle.message("declare.static.checkbox")); if (canBeChainedConstructor) { myCbChainedConstructor = new NonFocusableCheckBox(RefactoringBundle.message("extract.chained.constructor.checkbox")); } init(); }
@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(com.intellij.openapi.application.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, new Insets(5, 5, 5, 5), 0, 0)); } panel.add(Box.createVerticalBox(), new GridBagConstraints(0, 2, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0,0,0,0), 0,0)); return panel; }
@Override protected JComponent createNorthPanel() { myNameLabel = JBLabelDecorator.createJBLabelDecorator().setBold(true); myTargetDirectoryField = new TextFieldWithHistoryWithBrowseButton(); final List<String> recentEntries = RecentsManager.getInstance(myProject).getRecentEntries(RECENT_KEYS); if (recentEntries != null) { myTargetDirectoryField.getChildComponent().setHistory(recentEntries); } final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); myTargetDirectoryField.addBrowseFolderListener(RefactoringBundle.message("select.target.directory"), RefactoringBundle.message("the.file.will.be.moved.to.this.directory"), myProject, descriptor, TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT); final JTextField textField = myTargetDirectoryField.getChildComponent().getTextEditor(); FileChooserFactory.getInstance().installFileCompletion(textField, descriptor, true, getDisposable()); textField.getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { validateOKButton(); } }); myTargetDirectoryField.setTextFieldPreferredWidth(CopyFilesOrDirectoriesDialog.MAX_PATH_LENGTH); Disposer.register(getDisposable(), myTargetDirectoryField); String shortcutText = KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction(IdeActions.ACTION_CODE_COMPLETION)); myCbSearchForReferences = new NonFocusableCheckBox(RefactoringBundle.message("search.for.references")); myCbSearchForReferences.setSelected(RefactoringSettings.getInstance().MOVE_SEARCH_FOR_REFERENCES_FOR_FILE); return FormBuilder.createFormBuilder().addComponent(myNameLabel) .addLabeledComponent(RefactoringBundle.message("move.files.to.directory.label"), myTargetDirectoryField, UIUtil.LARGE_VGAP) .addTooltip(RefactoringBundle.message("path.completion.shortcut", shortcutText)) .addComponentToRightColumn(myCbSearchForReferences, UIUtil.LARGE_VGAP).getPanel(); }
@Nullable @Override protected JComponent getComponent() { myCanBeFinalCb = new NonFocusableCheckBox("Declare final"); myCanBeFinalCb.setSelected(false); myCanBeFinalCb.setMnemonic('f'); final GrFinalListener finalListener = new GrFinalListener(myEditor); myCanBeFinalCb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { new WriteCommandAction(myProject, getCommandName(), getCommandName()) { @Override protected void run(Result result) throws Throwable { PsiDocumentManager.getInstance(myProject).commitDocument(myEditor.getDocument()); final GrVariable variable = getVariable(); if (variable != null) { finalListener.perform(myCanBeFinalCb.isSelected(), variable); } } }.execute(); } }); 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, new Insets(5, 5, 5, 5), 0, 0)); } panel.add(Box.createVerticalBox(), new GridBagConstraints(0, 2, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0,0,0,0), 0,0)); return panel; }
protected void showBalloon() { NonFocusableCheckBox checkBox = new NonFocusableCheckBox(RefactoringBundle.message("delegation.panel.delegate.via.overloading.method")); checkBox.addActionListener(e -> { myDelegate = checkBox.isSelected(); updateCurrentInfo(); }); JPanel content = new JPanel(new BorderLayout()); content.add(new JBLabel("Performed signature modifications:"), BorderLayout.NORTH); content.add(myPreview.getComponent(), BorderLayout.CENTER); updateMethodSignature(myStableChange); content.add(checkBox, BorderLayout.SOUTH); final BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createDialogBalloonBuilder(content, null).setSmallVariant(true); myBalloon = balloonBuilder.createBalloon(); myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE); myBalloon.show(new PositionTracker<Balloon>(myEditor.getContentComponent()) { @Override public RelativePoint recalculateLocation(Balloon object) { int offset = myStableChange.getMethod().getTextOffset(); VisualPosition visualPosition = myEditor.offsetToVisualPosition(offset); Point point = myEditor.visualPositionToXY(new VisualPosition(visualPosition.line, visualPosition.column)); return new RelativePoint(myEditor.getContentComponent(), point); } }, Balloon.Position.above); Disposer.register(myBalloon, () -> { EditorFactory.getInstance().releaseEditor(myPreview); myPreview = null; }); }
@Override protected void appendOwnOptions(List<JComponent> jComponentList) { super.appendOwnOptions(jComponentList); if(mode == GenerationMode.GETTERS || mode == GenerationMode.GETTERS_AND_SETTERS || mode == GenerationMode.SETTERS) { if(!ApplicationManager.getApplication().isUnitTestMode()) { myCreateBindableProperties = new NonFocusableCheckBox(JavaScriptBundle.message("generate.getter.fields.bindable.properties")); jComponentList.add(myCreateBindableProperties); } } }
private static JCheckBox createPureCheckBox(boolean selected) { JCheckBox pureCB = new NonFocusableCheckBox("Method is pure (has no side effects)"); pureCB.setMnemonic('p'); pureCB.setSelected(selected); return pureCB; }
protected void createDelegateCb(GridBagConstraints gbConstraints, JPanel panel) { myCbGenerateDelegate = new NonFocusableCheckBox(RefactoringBundle.message("delegation.panel.delegate.via.overloading.method")); panel.add(myCbGenerateDelegate, gbConstraints); }
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 = new Insets(0, 0, 0, 0); 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 = new Insets(0, 8, 0, 0); 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 = new Insets(0, 0, 0, 0); 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; }
protected void createCheckboxes(JPanel panel, GridBagConstraints gbConstraints) { gbConstraints.insets = new Insets(0, 0, 4, 0); gbConstraints.gridwidth = 1; gbConstraints.gridx = 0; gbConstraints.weighty = 0; gbConstraints.weightx = 1; gbConstraints.fill = GridBagConstraints.BOTH; myCbSearchInComments = new NonFocusableCheckBox(); myCbSearchInComments.setText(RefactoringBundle.getSearchInCommentsAndStringsText()); myCbSearchInComments.setSelected(true); panel.add(myCbSearchInComments, gbConstraints); gbConstraints.insets = new Insets(0, 0, 4, 0); gbConstraints.gridwidth = GridBagConstraints.REMAINDER; gbConstraints.gridx = 1; gbConstraints.weightx = 1; gbConstraints.fill = GridBagConstraints.BOTH; myCbSearchTextOccurences = new NonFocusableCheckBox(); myCbSearchTextOccurences.setText(RefactoringBundle.getSearchForTextOccurrencesText()); myCbSearchTextOccurences.setSelected(true); panel.add(myCbSearchTextOccurences, gbConstraints); if (!TextOccurrencesUtil.isSearchTextOccurencesEnabled(myPsiElement)) { myCbSearchTextOccurences.setEnabled(false); myCbSearchTextOccurences.setSelected(false); myCbSearchTextOccurences.setVisible(false); } for(AutomaticRenamerFactory factory: Extensions.getExtensions(AutomaticRenamerFactory.EP_NAME)) { if (factory.isApplicable(myPsiElement) && factory.getOptionName() != null) { gbConstraints.insets = new Insets(0, 0, 4, 0); gbConstraints.gridwidth = myAutomaticRenamers.size() % 2 == 0 ? 1 : GridBagConstraints.REMAINDER; gbConstraints.gridx = myAutomaticRenamers.size() % 2; gbConstraints.weightx = 1; gbConstraints.fill = GridBagConstraints.BOTH; JCheckBox checkBox = new NonFocusableCheckBox(); checkBox.setText(factory.getOptionName()); checkBox.setSelected(factory.isEnabled()); panel.add(checkBox, gbConstraints); myAutomaticRenamers.put(factory, checkBox); } } }
@Override protected JComponent createNorthPanel() { myNameLabel = JBLabelDecorator.createJBLabelDecorator().setBold(true); myTargetDirectoryField = new TextFieldWithHistoryWithBrowseButton(); final List<String> recentEntries = RecentsManager.getInstance(myProject).getRecentEntries(RECENT_KEYS); if (recentEntries != null) { myTargetDirectoryField.getChildComponent().setHistory(recentEntries); } final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); myTargetDirectoryField.addBrowseFolderListener(RefactoringBundle.message("select.target.directory"), RefactoringBundle.message("the.file.will.be.moved.to.this.directory"), myProject, descriptor, TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT); final JTextField textField = myTargetDirectoryField.getChildComponent().getTextEditor(); FileChooserFactory.getInstance().installFileCompletion(textField, descriptor, true, getDisposable()); textField.getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { validateOKButton(); } }); myTargetDirectoryField.setTextFieldPreferredWidth(CopyFilesOrDirectoriesDialog.MAX_PATH_LENGTH); Disposer.register(getDisposable(), myTargetDirectoryField); String shortcutText = KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction(IdeActions.ACTION_CODE_COMPLETION)); myCbSearchForReferences = new NonFocusableCheckBox(RefactoringBundle.message("search.for.references")); myCbSearchForReferences.setSelected(RefactoringSettings.getInstance().MOVE_SEARCH_FOR_REFERENCES_FOR_FILE); myOpenInEditorCb = new NonFocusableCheckBox("Open moved files in editor"); myOpenInEditorCb.setSelected(isOpenInEditor()); return FormBuilder.createFormBuilder().addComponent(myNameLabel) .addLabeledComponent(RefactoringBundle.message("move.files.to.directory.label"), myTargetDirectoryField, UIUtil.LARGE_VGAP) .addTooltip(RefactoringBundle.message("path.completion.shortcut", shortcutText)) .addComponentToRightColumn(myCbSearchForReferences, UIUtil.LARGE_VGAP) .addComponentToRightColumn(myOpenInEditorCb, UIUtil.LARGE_VGAP) .getPanel(); }
/** * A constructor * * @param project * @param roots */ GitCheckinOptions(Project project, Collection<VirtualFile> roots) { myPanel = new JPanel(new GridBagLayout()); final Insets insets = new Insets(2, 2, 2, 2); // add authors drop down GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.anchor = GridBagConstraints.WEST; c.insets = insets; final JLabel authorLabel = new JLabel(GitBundle.message("commit.author")); myPanel.add(authorLabel, c); c = new GridBagConstraints(); c.anchor = GridBagConstraints.CENTER; c.insets = insets; c.gridx = 1; c.gridy = 0; c.weightx = 1; c.fill = GridBagConstraints.HORIZONTAL; final List<String> usersList = getUsersList(project, roots); final Set<String> authors = usersList == null ? new HashSet<String>() : new HashSet<String>(usersList); ContainerUtil.addAll(authors, mySettings.getCommitAuthors()); List<String> list = new ArrayList<String>(authors); Collections.sort(list); list = ObjectsConvertor.convert(list, new Convertor<String, String>() { @Override public String convert(String o) { return StringUtil.shortenTextWithEllipsis(o, 30, 0); } }); myAuthor = new JComboBox(ArrayUtil.toObjectArray(list)); myAuthor.insertItemAt("", 0); myAuthor.setSelectedItem(""); myAuthor.setEditable(true); authorLabel.setLabelFor(myAuthor); myAuthor.setToolTipText(GitBundle.getString("commit.author.tooltip")); myPanel.add(myAuthor, c); // add amend checkbox c = new GridBagConstraints(); c.gridx = 0; c.gridy = 1; c.gridwidth = 2; c.anchor = GridBagConstraints.CENTER; c.insets = insets; c.weightx = 1; c.fill = GridBagConstraints.HORIZONTAL; myAmend = new NonFocusableCheckBox(GitBundle.getString("commit.amend")); myAmend.setMnemonic('m'); myAmend.setSelected(false); myAmend.setToolTipText(GitBundle.getString("commit.amend.tooltip")); myPanel.add(myAmend, c); }