Search in sources :

Example 1 with PullType

use of com.oxygenxml.git.view.event.PullType in project oxygen-git-client-addon by oxygenxml.

the class ToolbarPanel method addPullActionsToMenu.

/**
 * Add the pull actions (pull + merge, pull + rebase, etc) to the pull menu.
 *
 * @param splitMenuButton The menu button to add to.
 */
private void addPullActionsToMenu(SplitMenuButton splitMenuButton) {
    ButtonGroup pullActionsGroup = new ButtonGroup();
    ActionListener radioMenuItemActionListener = e -> {
        if (e.getSource() instanceof JMenuItem) {
            splitMenuButton.setAction(((JMenuItem) e.getSource()).getAction());
        }
    };
    // Pull (merge)
    final JRadioButtonMenuItem pullMergeMenuItem = new JRadioButtonMenuItem(gitActionsManager.getPullMergeAction());
    pullMergeMenuItem.addActionListener(radioMenuItemActionListener);
    splitMenuButton.add(pullMergeMenuItem);
    pullActionsGroup.add(pullMergeMenuItem);
    // Pull (rebase)
    final JRadioButtonMenuItem pullRebaseMenuItem = new JRadioButtonMenuItem(gitActionsManager.getPullRebaseAction());
    pullRebaseMenuItem.addActionListener(radioMenuItemActionListener);
    splitMenuButton.add(pullRebaseMenuItem);
    pullActionsGroup.add(pullRebaseMenuItem);
    PullType defaultPullType = OptionsManager.getInstance().getDefaultPullType();
    if (defaultPullType == PullType.REBASE) {
        splitMenuButton.setAction(pullRebaseMenuItem.getAction());
        pullRebaseMenuItem.setSelected(true);
    } else if (defaultPullType != PullType.UKNOWN) {
        splitMenuButton.setAction(pullMergeMenuItem.getAction());
        pullMergeMenuItem.setSelected(true);
    }
}
Also used : LoggerFactory(org.slf4j.LoggerFactory) TextFormatUtil(com.oxygenxml.git.utils.TextFormatUtil) RepositoryState(org.eclipse.jgit.lib.RepositoryState) FileStatus(com.oxygenxml.git.service.entities.FileStatus) RepoNotInitializedException(com.oxygenxml.git.service.RepoNotInitializedException) Translator(com.oxygenxml.git.translator.Translator) PullAction(com.oxygenxml.git.view.actions.internal.PullAction) BranchInfo(com.oxygenxml.git.service.BranchInfo) Tags(com.oxygenxml.git.translator.Tags) MouseAdapter(java.awt.event.MouseAdapter) JToolBar(javax.swing.JToolBar) PullType(com.oxygenxml.git.view.event.PullType) CommitsAheadAndBehind(com.oxygenxml.git.view.history.CommitsAheadAndBehind) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) Font(java.awt.Font) Collection(java.util.Collection) OxygenUIComponentsFactory(ro.sync.exml.workspace.api.standalone.ui.OxygenUIComponentsFactory) GridBagConstraints(java.awt.GridBagConstraints) Dimension(java.awt.Dimension) List(java.util.List) Ref(org.eclipse.jgit.lib.Ref) Graphics(java.awt.Graphics) GridBagLayout(java.awt.GridBagLayout) JPanel(javax.swing.JPanel) RevCommitUtil(com.oxygenxml.git.service.RevCommitUtil) Insets(java.awt.Insets) ActionListener(java.awt.event.ActionListener) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Icons(com.oxygenxml.git.constants.Icons) GitController(com.oxygenxml.git.view.event.GitController) UIUtil(com.oxygenxml.git.view.util.UIUtil) SimpleDateFormat(java.text.SimpleDateFormat) GitActionsManager(com.oxygenxml.git.view.actions.GitActionsManager) StringUtils(org.eclipse.jgit.util.StringUtils) OptionsManager(com.oxygenxml.git.options.OptionsManager) SwingConstants(javax.swing.SwingConstants) MessageFormat(java.text.MessageFormat) SplitMenuButton(ro.sync.exml.workspace.api.standalone.ui.SplitMenuButton) SwingUtilities(javax.swing.SwingUtilities) GitAccess(com.oxygenxml.git.service.GitAccess) JMenuItem(javax.swing.JMenuItem) JToolTip(javax.swing.JToolTip) ToolbarButton(ro.sync.exml.workspace.api.standalone.ui.ToolbarButton) AbstractButton(javax.swing.AbstractButton) JButton(javax.swing.JButton) Logger(org.slf4j.Logger) ButtonGroup(javax.swing.ButtonGroup) NoRepositorySelected(com.oxygenxml.git.service.NoRepositorySelected) IOException(java.io.IOException) RepoUtil(com.oxygenxml.git.utils.RepoUtil) MouseEvent(java.awt.event.MouseEvent) FontMetrics(java.awt.FontMetrics) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) PopupMenu(ro.sync.exml.workspace.api.standalone.ui.PopupMenu) Repository(org.eclipse.jgit.lib.Repository) PullType(com.oxygenxml.git.view.event.PullType) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JMenuItem(javax.swing.JMenuItem)

Example 2 with PullType

use of com.oxygenxml.git.view.event.PullType in project oxygen-git-client-addon by oxygenxml.

the class ToolbarPanel method getPullFromTranslationTag.

/**
 * @return The translation tag for the "Pull" button tooltip text.
 */
private String getPullFromTranslationTag() {
    String pullFromTag = Tags.PULL_FROM;
    Object value = pullMenuButton.getAction().getValue(PullAction.PULL_TYPE_ACTION_PROP);
    if (value instanceof PullType) {
        PullType pt = (PullType) value;
        if (pt == PullType.REBASE) {
            pullFromTag = Tags.PULL_REBASE_FROM;
        } else if (pt != PullType.UKNOWN) {
            pullFromTag = Tags.PULL_MERGE_FROM;
        }
    }
    return pullFromTag;
}
Also used : PullType(com.oxygenxml.git.view.event.PullType)

Aggregations

PullType (com.oxygenxml.git.view.event.PullType)2 Icons (com.oxygenxml.git.constants.Icons)1 OptionsManager (com.oxygenxml.git.options.OptionsManager)1 BranchInfo (com.oxygenxml.git.service.BranchInfo)1 GitAccess (com.oxygenxml.git.service.GitAccess)1 NoRepositorySelected (com.oxygenxml.git.service.NoRepositorySelected)1 RepoNotInitializedException (com.oxygenxml.git.service.RepoNotInitializedException)1 RevCommitUtil (com.oxygenxml.git.service.RevCommitUtil)1 FileStatus (com.oxygenxml.git.service.entities.FileStatus)1 Tags (com.oxygenxml.git.translator.Tags)1 Translator (com.oxygenxml.git.translator.Translator)1 RepoUtil (com.oxygenxml.git.utils.RepoUtil)1 TextFormatUtil (com.oxygenxml.git.utils.TextFormatUtil)1 GitActionsManager (com.oxygenxml.git.view.actions.GitActionsManager)1 PullAction (com.oxygenxml.git.view.actions.internal.PullAction)1 GitController (com.oxygenxml.git.view.event.GitController)1 CommitsAheadAndBehind (com.oxygenxml.git.view.history.CommitsAheadAndBehind)1 UIUtil (com.oxygenxml.git.view.util.UIUtil)1 Dimension (java.awt.Dimension)1 Font (java.awt.Font)1