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(); }
@NotNull GitRemote getSelectedRemote() { return myRemoteSelector.getSelectedValue(); }
public void selectRemote(String remoteName) { myRemoteSelector.selectRemote(remoteName); }
private void setDefaultComponentsEnabledState(boolean selected) { myDestBranchTextField.setEnabled(selected); myComment.setEnabled(selected); myRemoteSelector.setEnabled(selected); }