use of com.intellij.openapi.vcs.checkin.CheckinHandler in project intellij-community by JetBrains.
the class CommitHelper method commitCompleted.
private void commitCompleted(final List<VcsException> allExceptions, final GeneralCommitProcessor processor) {
final List<VcsException> errors = collectErrors(allExceptions);
boolean noErrors = errors.isEmpty();
boolean noWarnings = allExceptions.isEmpty();
if (noErrors) {
for (CheckinHandler handler : myHandlers) {
handler.checkinSuccessful();
}
processor.afterSuccessfulCheckIn();
if (myCustomResultHandler != null) {
myCustomResultHandler.onSuccess(myCommitMessage);
} else {
reportResult(processor);
}
if (noWarnings) {
final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
if (indicator != null) {
indicator.setText(VcsBundle.message("commit.dialog.completed.successfully"));
}
}
} else {
for (CheckinHandler handler : myHandlers) {
handler.checkinFailed(errors);
}
processor.afterFailedCheckIn();
if (myCustomResultHandler != null) {
myCustomResultHandler.onFailure();
} else {
reportResult(processor);
}
}
}
use of com.intellij.openapi.vcs.checkin.CheckinHandler in project intellij-community by JetBrains.
the class UpdateCopyrightCheckinHandlerFactory method createHandler.
@NotNull
public CheckinHandler createHandler(@NotNull final CheckinProjectPanel panel, @NotNull CommitContext commitContext) {
return new CheckinHandler() {
@Override
public RefreshableOnComponent getBeforeCheckinConfigurationPanel() {
final JCheckBox updateCopyrightCb = new JCheckBox("Update copyright");
return new RefreshableOnComponent() {
public JComponent getComponent() {
return JBUI.Panels.simplePanel().addToLeft(updateCopyrightCb);
}
public void refresh() {
}
public void saveState() {
UpdateCopyrightCheckinHandlerState.getInstance(panel.getProject()).UPDATE_COPYRIGHT = updateCopyrightCb.isSelected();
}
public void restoreState() {
updateCopyrightCb.setSelected(UpdateCopyrightCheckinHandlerState.getInstance(panel.getProject()).UPDATE_COPYRIGHT);
}
};
}
@Override
public ReturnResult beforeCheckin(@Nullable CommitExecutor executor, PairConsumer<Object, Object> additionalDataConsumer) {
if (UpdateCopyrightCheckinHandlerState.getInstance(panel.getProject()).UPDATE_COPYRIGHT) {
new UpdateCopyrightProcessor(panel.getProject(), null, getPsiFiles()).run();
FileDocumentManager.getInstance().saveAllDocuments();
}
return super.beforeCheckin();
}
private PsiFile[] getPsiFiles() {
final Collection<VirtualFile> files = panel.getVirtualFiles();
final List<PsiFile> psiFiles = new ArrayList<>();
final PsiManager manager = PsiManager.getInstance(panel.getProject());
for (final VirtualFile file : files) {
final PsiFile psiFile = manager.findFile(file);
if (psiFile != null) {
psiFiles.add(psiFile);
}
}
return PsiUtilCore.toPsiFileArray(psiFiles);
}
};
}
Aggregations