GitManualPushToBranch( @NotNull Collection<GitRepository> repositories, @NotNull final Runnable performOnRefresh) { super(); myRepositories = repositories; myManualPush = new JCheckBox("Push current branch to alternative branch: ", false); myManualPush.setMnemonic('b'); myDestBranchTextField = new JTextField(20); myComment = new JBLabel("This will apply to all selected repositories", UIUtil.ComponentStyle.SMALL); myRefreshAction = new GitPushLogRefreshAction() { @Override public void actionPerformed(AnActionEvent e) { performOnRefresh.run(); } }; myRefreshButton = new ActionButton( myRefreshAction, myRefreshAction.getTemplatePresentation(), myRefreshAction.getTemplatePresentation().getText(), ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE); myRefreshButton.setFocusable(true); final ShortcutSet shortcutSet = ActionManager.getInstance().getAction(IdeActions.ACTION_REFRESH).getShortcutSet(); myRefreshAction.registerCustomShortcutSet(shortcutSet, myRefreshButton); myRemoteSelector = new RemoteSelector(getRemotesWithCommonNames(repositories)); myRemoteSelectorComponent = myRemoteSelector.createComponent(); setDefaultComponentsEnabledState(myManualPush.isSelected()); myManualPush.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean isManualPushSelected = myManualPush.isSelected(); setDefaultComponentsEnabledState(isManualPushSelected); if (isManualPushSelected) { myDestBranchTextField.requestFocus(); myDestBranchTextField.selectAll(); } } }); layoutComponents(); }
@Override public void update(final AnActionEvent e) { super.update(e); Presentation presentation = e.getPresentation(); Object property = presentation.getClientProperty(CUSTOM_COMPONENT_PROPERTY); if (property instanceof JCheckBox) { JCheckBox checkBox = (JCheckBox) property; checkBox.setText(presentation.getText()); checkBox.setToolTipText(presentation.getDescription()); checkBox.setMnemonic(presentation.getMnemonic()); checkBox.setDisplayedMnemonicIndex(presentation.getDisplayedMnemonicIndex()); checkBox.setSelected(Boolean.TRUE.equals(presentation.getClientProperty(SELECTED_PROPERTY))); checkBox.setEnabled(presentation.isEnabled()); checkBox.setVisible(presentation.isVisible()); } }