Search in sources :

Example 1 with CheckoutCommitAction

use of com.oxygenxml.git.view.history.actions.CheckoutCommitAction in project oxygen-git-client-addon by oxygenxml.

the class HistoryViewContextualMenuPresenter method populateActions4SingleSelection.

/**
 * Contributes the contextual actions for the given file, at the given revision/commit.
 *
 * @param jPopupMenu            Contextual menu in which to put the actions.
 * @param filePath              File path.
 * @param commitCharacteristics Revision/commit data.
 *
 * @throws IOException If it fails.
 * @throws GitAPIException If it fails.
 */
private void populateActions4SingleSelection(JPopupMenu jPopupMenu, String filePath, CommitCharacteristics commitCharacteristics) throws IOException, GitAPIException {
    if (filePath != null) {
        Optional<FileStatus> fileStatusOptional = getFileStatus(filePath, commitCharacteristics);
        fileStatusOptional.ifPresent(fileStatus -> populateContextActionsForFile(jPopupMenu, fileStatus, commitCharacteristics, true));
    }
    if (filePath != null) {
        jPopupMenu.addSeparator();
    }
    String commitId = commitCharacteristics.getCommitId();
    if (!GitAccess.UNCOMMITED_CHANGES.getCommitId().equals(commitId)) {
        jPopupMenu.add(new CreateBranchFromCommitAction(commitId));
        jPopupMenu.add(new CreateTagAction(commitId));
        jPopupMenu.add(new CheckoutCommitAction(commitCharacteristics.getPlotCommit()));
        jPopupMenu.addSeparator();
        jPopupMenu.add(new RevertCommitAction(commitCharacteristics));
        jPopupMenu.add(new ResetBranchToCommitAction(commitCharacteristics));
    }
}
Also used : RevertCommitAction(com.oxygenxml.git.view.history.actions.RevertCommitAction) FileStatus(com.oxygenxml.git.service.entities.FileStatus) CheckoutCommitAction(com.oxygenxml.git.view.history.actions.CheckoutCommitAction) ResetBranchToCommitAction(com.oxygenxml.git.view.history.actions.ResetBranchToCommitAction) CreateTagAction(com.oxygenxml.git.view.history.actions.CreateTagAction) CreateBranchFromCommitAction(com.oxygenxml.git.view.history.actions.CreateBranchFromCommitAction)

Example 2 with CheckoutCommitAction

use of com.oxygenxml.git.view.history.actions.CheckoutCommitAction in project oxygen-git-client-addon by oxygenxml.

the class TagsDialog method createTagsPanel.

/**
 * Creates a JPanel with the
 *
 * @return a JPanel for the tags
 *
 * @throws GitAPIException
 * @throws NoRepositorySelected
 * @throws IOException
 */
private JPanel createTagsPanel() throws GitAPIException, NoRepositorySelected, IOException {
    // add the table
    JPanel tagsPanel = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    createTagsTable();
    tagsTable.getTableHeader().setReorderingAllowed(false);
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weighty = 1;
    gbc.weightx = 1;
    gbc.gridwidth = 1;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets = new Insets(0, 0, 0, 0);
    tagsPanel.add(new JScrollPane(tagsTable), gbc);
    // add a panel with buttons
    JPanel buttonsPanel = new JPanel(new GridBagLayout());
    GridBagConstraints buttonsGridBagConstraints = new GridBagConstraints();
    buttonsGridBagConstraints.gridx = 0;
    buttonsGridBagConstraints.gridy = 0;
    buttonsGridBagConstraints.anchor = GridBagConstraints.SOUTHEAST;
    buttonsGridBagConstraints.fill = GridBagConstraints.NONE;
    buttonsGridBagConstraints.insets = new Insets(UIConstants.INDENT_5PX, 0, UIConstants.INDENT_5PX, UIConstants.INDENT_5PX);
    checkoutButton = new JButton(TRANSLATOR.getTranslation(Tags.CHECKOUT) + "...");
    checkoutButton.addActionListener(e -> {
        int selectedRow = (tagsTable.getSelectedRow());
        if (selectedRow >= 0) {
            GitTag tag = ((TagsTableModel) tagsTable.getModel()).getItemAt(selectedRow);
            String tagID = tag.getTagID();
            Action action = new CheckoutCommitAction(tagID);
            action.actionPerformed(e);
        }
    });
    checkoutButton.setEnabled(false);
    buttonsPanel.add(checkoutButton, buttonsGridBagConstraints);
    pushButton = new JButton(TRANSLATOR.getTranslation(Tags.PUSH));
    pushButton.addActionListener(createPushListener());
    pushButton.setEnabled(false);
    buttonsGridBagConstraints.gridx++;
    buttonsPanel.add(pushButton, buttonsGridBagConstraints);
    deleteButton = new JButton(TRANSLATOR.getTranslation(Tags.DELETE));
    deleteButton.addActionListener(createDeleteListener());
    deleteButton.setEnabled(false);
    buttonsGridBagConstraints.gridx++;
    buttonsGridBagConstraints.insets = new Insets(UIConstants.INDENT_5PX, 0, UIConstants.INDENT_5PX, 0);
    buttonsPanel.add(deleteButton, buttonsGridBagConstraints);
    gbc.gridx = 0;
    gbc.gridy++;
    gbc.gridwidth = 1;
    gbc.weighty = 0;
    gbc.weightx = 0;
    gbc.insets = new Insets(0, 0, UIConstants.LAST_LINE_COMPONENT_BOTTOM_PADDING, 0);
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.SOUTHEAST;
    tagsPanel.add(buttonsPanel, gbc);
    getOkButton().setVisible(false);
    getCancelButton().setText(TRANSLATOR.getTranslation(Tags.CLOSE));
    return tagsPanel;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Action(javax.swing.Action) CheckoutCommitAction(com.oxygenxml.git.view.history.actions.CheckoutCommitAction) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JButton(javax.swing.JButton) CheckoutCommitAction(com.oxygenxml.git.view.history.actions.CheckoutCommitAction) Point(java.awt.Point)

Aggregations

CheckoutCommitAction (com.oxygenxml.git.view.history.actions.CheckoutCommitAction)2 FileStatus (com.oxygenxml.git.service.entities.FileStatus)1 CreateBranchFromCommitAction (com.oxygenxml.git.view.history.actions.CreateBranchFromCommitAction)1 CreateTagAction (com.oxygenxml.git.view.history.actions.CreateTagAction)1 ResetBranchToCommitAction (com.oxygenxml.git.view.history.actions.ResetBranchToCommitAction)1 RevertCommitAction (com.oxygenxml.git.view.history.actions.RevertCommitAction)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 Point (java.awt.Point)1 Action (javax.swing.Action)1 JButton (javax.swing.JButton)1 JPanel (javax.swing.JPanel)1 JScrollPane (javax.swing.JScrollPane)1