com.intellij.openapi.vcs.CommitMessageI Java Examples

The following examples show how to use com.intellij.openapi.vcs.CommitMessageI. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CommitMessageTemplateAction.java    From intellij-commit-message-template-plugin with MIT License 6 votes vote down vote up
public void actionPerformed(AnActionEvent e) {
    final CommitMessageI checkinPanel = getCheckinPanel(e);
    if (checkinPanel == null) {
        return;
    }

    Project project = e.getRequiredData(CommonDataKeys.PROJECT);
    CommitMessageTemplateConfig config = CommitMessageTemplateConfig.getInstance(project);

    if (config != null) {
        String commitMessage = config.getCommitMessage();
        if (!commitMessage.isEmpty()) {
            checkinPanel.setCommitMessage(commitMessage);
        }
    }
}
 
Example #2
Source File: SelectWorkItemsAction.java    From azure-devops-intellij with MIT License 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
    final DataContext dc = anActionEvent.getDataContext();
    final Project project = CommonDataKeys.PROJECT.getData(dc);
    final Refreshable panel = CheckinProjectPanel.PANEL_KEY.getData(dc);
    final CommitMessageI commitMessageI = (panel instanceof CommitMessageI) ? (CommitMessageI) panel : VcsDataKeys.COMMIT_MESSAGE_CONTROL.getData(dc);

    if (commitMessageI != null && project != null) {
        String commitMessage = "";
        // Attempt to append the message instead of overwriting it
        if (commitMessageI instanceof CommitChangeListDialog) {
            commitMessage = ((CommitChangeListDialog) commitMessageI).getCommitMessage();
        }

        SelectWorkItemsDialog dialog = new SelectWorkItemsDialog(project);
        if (dialog.showAndGet()) {
            if (StringUtils.isNotEmpty(commitMessage)) {
                commitMessage += "\n" + dialog.getComment();
            } else {
                commitMessage = dialog.getComment();
            }

            commitMessageI.setCommitMessage(commitMessage);
        }
    }
}
 
Example #3
Source File: CreateCommitAction.java    From commit-template-idea-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent actionEvent) {
    final CommitMessageI commitPanel = getCommitPanel(actionEvent);
    if (commitPanel == null)
        return;

    CommitDialog dialog = new CommitDialog(actionEvent.getProject());
    dialog.show();
    if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
        commitPanel.setCommitMessage(dialog.getCommitMessage().toString());
    }
}
 
Example #4
Source File: CreateCommitAction.java    From commit-template-idea-plugin with Apache License 2.0 5 votes vote down vote up
@Nullable
private static CommitMessageI getCommitPanel(@Nullable AnActionEvent e) {
    if (e == null) {
        return null;
    }
    Refreshable data = Refreshable.PANEL_KEY.getData(e.getDataContext());
    if (data instanceof CommitMessageI) {
        return (CommitMessageI) data;
    }
    return VcsDataKeys.COMMIT_MESSAGE_CONTROL.getData(e.getDataContext());
}
 
Example #5
Source File: GetCommitMessageAction.java    From GitCommitMessage with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent actionEvent) {

    final CommitMessageI commitPanel = getCommitPanel(actionEvent);
    if (commitPanel == null) {
        return;
    }
    commitPanel.setCommitMessage(getCommitMessage(actionEvent.getProject()));
}
 
Example #6
Source File: GetCommitMessageAction.java    From GitCommitMessage with Apache License 2.0 5 votes vote down vote up
@Nullable
private static CommitMessageI getCommitPanel(@Nullable AnActionEvent e) {
    if (e == null) {
        return null;
    }

    Refreshable data = Refreshable.PANEL_KEY.getData(e.getDataContext());
    if (data instanceof CommitMessageI) {
        return (CommitMessageI) data;
    }
    return VcsDataKeys.COMMIT_MESSAGE_CONTROL.getData(e.getDataContext());
}
 
Example #7
Source File: OpenPanelAction.java    From GitCommitMessage with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent actionEvent) {

    final CommitMessageI commitPanel = getCommitPanel(actionEvent);
    if (commitPanel == null)
        return;


    PanelDialog dialog = new PanelDialog(actionEvent.getProject());
    dialog.show();
    if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
        commitPanel.setCommitMessage(dialog.getCommitMessage(actionEvent.getProject()));
    }

}
 
Example #8
Source File: OpenPanelAction.java    From GitCommitMessage with Apache License 2.0 5 votes vote down vote up
@Nullable
private static CommitMessageI getCommitPanel(@Nullable AnActionEvent e) {
    if (e == null) {
        return null;
    }
    Refreshable data = Refreshable.PANEL_KEY.getData(e.getDataContext());
    if (data instanceof CommitMessageI) {
        return (CommitMessageI) data;
    }
    return VcsDataKeys.COMMIT_MESSAGE_CONTROL.getData(e.getDataContext());
}
 
Example #9
Source File: CommitMessageTemplateAction.java    From intellij-commit-message-template-plugin with MIT License 5 votes vote down vote up
@Nullable
private static CommitMessageI getCheckinPanel(@Nullable AnActionEvent e) {
    if (e == null) {
        return null;
    }
    Refreshable data = Refreshable.PANEL_KEY.getData(e.getDataContext());
    if (data instanceof CommitMessageI) {
        return (CommitMessageI) data;
    }
    CommitMessageI commitMessageI = VcsDataKeys.COMMIT_MESSAGE_CONTROL.getData(e.getDataContext());
    if (commitMessageI != null) {
        return commitMessageI;
    }
    return null;
}
 
Example #10
Source File: CheckCommitMessageSpellingAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void setSelected(AnActionEvent e, boolean state) {
  CommitMessageI checkinPanel = getCheckinPanel(e);
  if (checkinPanel != null) {
    checkinPanel.setCheckSpelling(state);
  }
}
 
Example #11
Source File: CheckCommitMessageSpellingAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@javax.annotation.Nullable
private static CommitMessageI getCheckinPanel(@javax.annotation.Nullable AnActionEvent e) {
  if (e == null) {
    return null;
  }
  Refreshable data = e.getData(Refreshable.PANEL_KEY);
  if (data instanceof CommitMessageI) {
    return (CommitMessageI)data;
  }
  CommitMessageI commitMessageI = e.getData(VcsDataKeys.COMMIT_MESSAGE_CONTROL);
  if (commitMessageI != null) {
    return commitMessageI;
  }
  return null;
}
 
Example #12
Source File: CheckCommitMessageSpellingAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isSelected(AnActionEvent e) {
  CommitMessageI checkinPanel = getCheckinPanel(e);
  return checkinPanel != null && checkinPanel.isCheckSpelling();
}