use of com.intellij.diff.requests.DiffRequest in project intellij-community by JetBrains.
the class ChangeDiffRequestProducer method loadCurrentContents.
@NotNull
protected DiffRequest loadCurrentContents(@NotNull UserDataHolder context, @NotNull ProgressIndicator indicator) throws DiffRequestProducerException {
DiffRequestProducerException wrapperException = null;
DiffRequestProducerException requestException = null;
DiffViewerWrapper wrapper = null;
try {
for (ChangeDiffViewerWrapperProvider provider : ChangeDiffViewerWrapperProvider.EP_NAME.getExtensions()) {
if (provider.canCreate(myProject, myChange)) {
wrapper = provider.process(this, context, indicator);
break;
}
}
} catch (DiffRequestProducerException e) {
wrapperException = e;
}
DiffRequest request = null;
try {
for (ChangeDiffRequestProvider provider : ChangeDiffRequestProvider.EP_NAME.getExtensions()) {
if (provider.canCreate(myProject, myChange)) {
request = provider.process(this, context, indicator);
break;
}
}
if (request == null)
request = createRequest(myProject, myChange, context, indicator);
} catch (DiffRequestProducerException e) {
requestException = e;
}
if (requestException != null && wrapperException != null) {
String message = requestException.getMessage() + "\n\n" + wrapperException.getMessage();
throw new DiffRequestProducerException(message);
}
if (requestException != null) {
request = new ErrorDiffRequest(getRequestTitle(myChange), requestException);
LOG.info("Request: " + requestException.getMessage());
}
if (wrapperException != null) {
LOG.info("Wrapper: " + wrapperException.getMessage());
}
request.putUserData(CHANGE_KEY, myChange);
request.putUserData(DiffViewerWrapper.KEY, wrapper);
for (Map.Entry<Key, Object> entry : myChangeContext.entrySet()) {
request.putUserData(entry.getKey(), entry.getValue());
}
DiffUtil.putDataKey(request, VcsDataKeys.CURRENT_CHANGE, myChange);
return request;
}
use of com.intellij.diff.requests.DiffRequest in project intellij-plugins by JetBrains.
the class DiffWindowOpener method showDiff.
public void showDiff() {
String title = "Diff for " + myVFile.getDisplayName();
String title1 = "My Version";
String title2 = myRemoteUser.getDisplayName() + "'s Version";
DiffContent content1 = DiffContentFactory.getInstance().create(myProject, myVirtualFile);
DiffContent content2 = DiffContentFactory.getInstance().create(myRemoteText, myVirtualFile.getFileType());
DiffRequest request = new SimpleDiffRequest(title, content1, content2, title1, title2);
DiffManagerEx.getInstance().showDiff(myProject, request, DiffDialogHints.NON_MODAL);
}
use of com.intellij.diff.requests.DiffRequest in project intellij-community by JetBrains.
the class ExternalDiffTool method show.
public static void show(@Nullable final Project project, @NotNull final DiffRequestChain chain, @NotNull final DiffDialogHints hints) {
try {
//noinspection unchecked
final Ref<List<DiffRequest>> requestsRef = new Ref<>();
final Ref<Throwable> exceptionRef = new Ref<>();
ProgressManager.getInstance().run(new Task.Modal(project, "Loading Requests", true) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
try {
requestsRef.set(collectRequests(project, chain, indicator));
} catch (Throwable e) {
exceptionRef.set(e);
}
}
});
if (!exceptionRef.isNull())
throw exceptionRef.get();
List<DiffRequest> showInBuiltin = new ArrayList<>();
for (DiffRequest request : requestsRef.get()) {
if (canShow(request)) {
showRequest(project, request);
} else {
showInBuiltin.add(request);
}
}
if (!showInBuiltin.isEmpty()) {
DiffManagerEx.getInstance().showDiffBuiltin(project, new SimpleDiffRequestChain(showInBuiltin), hints);
}
} catch (ProcessCanceledException ignore) {
} catch (Throwable e) {
LOG.warn(e);
Messages.showErrorDialog(project, e.getMessage(), "Can't Show Diff In External Tool");
}
}
use of com.intellij.diff.requests.DiffRequest in project intellij-community by JetBrains.
the class ExternalDiffTool method collectRequests.
@NotNull
private static List<DiffRequest> collectRequests(@Nullable Project project, @NotNull final DiffRequestChain chain, @NotNull ProgressIndicator indicator) {
List<DiffRequest> requests = new ArrayList<>();
UserDataHolderBase context = new UserDataHolderBase();
List<String> errorRequests = new ArrayList<>();
// TODO: show all changes on explicit selection
List<? extends DiffRequestProducer> producers = Collections.singletonList(chain.getRequests().get(chain.getIndex()));
for (DiffRequestProducer producer : producers) {
try {
requests.add(producer.process(context, indicator));
} catch (DiffRequestProducerException e) {
LOG.warn(e);
errorRequests.add(producer.getName());
}
}
if (!errorRequests.isEmpty()) {
new Notification("diff", "Can't load some changes", StringUtil.join(errorRequests, "<br>"), NotificationType.ERROR).notify(project);
}
return requests;
}
use of com.intellij.diff.requests.DiffRequest in project intellij-community by JetBrains.
the class DiffApplication method processCommand.
@Override
public void processCommand(@NotNull String[] args, @Nullable String currentDirectory) throws Exception {
Project project = getProject();
List<String> filePaths = Arrays.asList(args).subList(1, args.length);
List<VirtualFile> files = findFiles(filePaths, currentDirectory);
DiffRequest request;
if (files.size() == 3) {
request = DiffRequestFactory.getInstance().createFromFiles(project, files.get(0), files.get(2), files.get(1));
} else {
request = DiffRequestFactory.getInstance().createFromFiles(project, files.get(0), files.get(1));
}
DiffManagerEx.getInstance().showDiffBuiltin(project, request, DiffDialogHints.MODAL);
}
Aggregations