Search in sources :

Example 1 with GitRepositoryComboboxListCellRenderer

use of git4idea.ui.GitRepositoryComboboxListCellRenderer in project intellij-community by JetBrains.

the class GitBranchIsNotFullyMergedDialog method createNorthPanel.

@Override
protected JComponent createNorthPanel() {
    JBLabel descriptionLabel = new JBLabel(makeDescription(myInitialRepository));
    JComboBox repositorySelector = new JComboBox(ArrayUtil.toObjectArray(myRepositories, GitRepository.class));
    repositorySelector.setRenderer(new GitRepositoryComboboxListCellRenderer(repositorySelector));
    repositorySelector.setSelectedItem(myInitialRepository);
    repositorySelector.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            GitRepository selectedRepo = (GitRepository) repositorySelector.getSelectedItem();
            descriptionLabel.setText(makeDescription(selectedRepo));
            myCommitListWithDiffPanel.setCommits(myCommits.get(selectedRepo));
        }
    });
    JPanel repoSelectorPanel = new JPanel(new BorderLayout());
    JBLabel label = new JBLabel("Repository: ");
    label.setLabelFor(repoSelectorPanel);
    repoSelectorPanel.add(label, BorderLayout.WEST);
    repoSelectorPanel.add(repositorySelector);
    if (myRepositories.size() < 2) {
        repoSelectorPanel.setVisible(false);
    }
    JPanel northPanel = new JPanel(new BorderLayout());
    northPanel.add(descriptionLabel);
    northPanel.add(repoSelectorPanel, BorderLayout.SOUTH);
    return northPanel;
}
Also used : GitRepository(git4idea.repo.GitRepository) GitRepositoryComboboxListCellRenderer(git4idea.ui.GitRepositoryComboboxListCellRenderer) ActionListener(java.awt.event.ActionListener) JBLabel(com.intellij.ui.components.JBLabel) ActionEvent(java.awt.event.ActionEvent)

Example 2 with GitRepositoryComboboxListCellRenderer

use of git4idea.ui.GitRepositoryComboboxListCellRenderer in project intellij-community by JetBrains.

the class GitCompareBranchesLogPanel method createNorthPanel.

private JComponent createNorthPanel() {
    final JComboBox repoSelector = new JComboBox(ArrayUtil.toObjectArray(myCompareInfo.getRepositories(), GitRepository.class));
    repoSelector.setRenderer(new GitRepositoryComboboxListCellRenderer(repoSelector));
    repoSelector.setSelectedItem(myInitialRepo);
    repoSelector.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            GitRepository selectedRepo = (GitRepository) repoSelector.getSelectedItem();
            myHeadToBranchListPanel.setCommits(getHeadToBranchCommits(selectedRepo));
            myBranchToHeadListPanel.setCommits(getBranchToHeadCommits(selectedRepo));
        }
    });
    JPanel repoSelectorPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    JBLabel label = new JBLabel("Repository: ");
    label.setLabelFor(repoSelectorPanel);
    label.setDisplayedMnemonic(KeyEvent.VK_R);
    repoSelectorPanel.add(label);
    repoSelectorPanel.add(repoSelector);
    if (myCompareInfo.getRepositories().size() < 2) {
        repoSelectorPanel.setVisible(false);
    }
    return repoSelectorPanel;
}
Also used : GitRepository(git4idea.repo.GitRepository) GitRepositoryComboboxListCellRenderer(git4idea.ui.GitRepositoryComboboxListCellRenderer) ActionListener(java.awt.event.ActionListener) JBLabel(com.intellij.ui.components.JBLabel) ActionEvent(java.awt.event.ActionEvent)

Aggregations

JBLabel (com.intellij.ui.components.JBLabel)2 GitRepository (git4idea.repo.GitRepository)2 GitRepositoryComboboxListCellRenderer (git4idea.ui.GitRepositoryComboboxListCellRenderer)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2