use of com.intellij.openapi.diff.DiffViewer in project intellij-community by JetBrains.
the class CompositeDiffPanel method setDiffRequest.
@Override
public void setDiffRequest(DiffRequest request) {
final Map<String, DiffRequest> requestMap = myRequest.discloseRequest(request);
HashMap<String, Pair<DiffViewer, Content>> mapCopy = new HashMap<>(myMap);
myMap.clear();
for (Map.Entry<String, DiffRequest> entry : requestMap.entrySet()) {
final String key = entry.getKey();
final DiffRequest diffRequest = entry.getValue();
diffRequest.getGenericData().put(PlatformDataKeys.COMPOSITE_DIFF_VIEWER.getName(), this);
final Pair<DiffViewer, Content> pair = mapCopy.get(key);
DiffViewer viewer = pair != null ? pair.first : null;
if (viewer != null && viewer.acceptsType(diffRequest.getType()) && viewer.canShowRequest(diffRequest)) {
viewer.setDiffRequest(diffRequest);
myMap.put(key, pair);
mapCopy.remove(key);
} else {
final DiffViewer newViewer = myRequest.viewerForRequest(myWindow, myParentDisposable, key, diffRequest);
if (newViewer == null)
continue;
final Content content = myUi.createContent(key, newViewer.getComponent(), key, null, newViewer.getPreferredFocusedComponent());
content.setCloseable(false);
content.setPinned(true);
content.setDisposer(myParentDisposable);
myUi.addContent(content);
myMap.put(key, Pair.create(newViewer, content));
if (pair != null)
myUi.removeContent(pair.second, false);
}
}
if (myMap.isEmpty()) {
final ErrorDiffViewer errorDiffViewer = new ErrorDiffViewer(myWindow, request);
final Content content = myUi.createContent(FICTIVE_KEY, errorDiffViewer.getComponent(), FICTIVE_KEY, null, errorDiffViewer.getPreferredFocusedComponent());
content.setCloseable(false);
content.setPinned(true);
content.setDisposer(myParentDisposable);
myUi.addContent(content);
myMap.put(FICTIVE_KEY, Pair.<DiffViewer, Content>create(errorDiffViewer, content));
}
for (Pair<DiffViewer, Content> pair : mapCopy.values()) {
myUi.removeContent(pair.second, false);
if (pair.first instanceof Disposable)
Disposer.dispose((Disposable) pair.first);
}
}
use of com.intellij.openapi.diff.DiffViewer in project intellij-community by JetBrains.
the class MergeTool method show.
public void show(DiffRequest data) {
if (data instanceof MergeRequestImpl) {
showDialog((MergeRequestImpl) data);
return;
}
if (LOG.isDebugEnabled()) {
LOG.debug(new Throwable("MergeTool - frame"));
}
FrameWrapper frameWrapper = new FrameWrapper(data.getProject(), data.getGroupKey());
DiffViewer mergePanel = createMergeComponent(data, null, frameWrapper);
frameWrapper.setComponent(mergePanel.getComponent());
frameWrapper.setPreferredFocusedComponent(mergePanel.getPreferredFocusedComponent());
frameWrapper.closeOnEsc();
frameWrapper.setTitle(data.getWindowTitle());
frameWrapper.setProject(data.getProject());
frameWrapper.show();
}
Aggregations