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));
}
}
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;
}
Aggregations