use of com.intellij.openapi.diff.DiffContent in project intellij-community by JetBrains.
the class BaseDiffAction method actionPerformed.
public void actionPerformed(AnActionEvent e) {
DiffRequest diffData = getDiffData(e.getDataContext());
if (diffData == null)
return;
final DiffContent[] contents = diffData.getContents();
final FileDocumentManager documentManager = FileDocumentManager.getInstance();
ApplicationManager.getApplication().runWriteAction(() -> {
for (DiffContent content : contents) {
Document document = content.getDocument();
if (document != null) {
documentManager.saveDocument(document);
}
}
});
DiffManager.getInstance().getDiffTool().show(diffData);
}
use of com.intellij.openapi.diff.DiffContent in project intellij-community by JetBrains.
the class DiffSideView method getCurrentOpenFileDescriptor.
@Nullable
public OpenFileDescriptor getCurrentOpenFileDescriptor() {
final EditorEx editor = myEditorSource.getEditor();
final DiffContent content = myEditorSource.getContent();
if (content == null || editor == null) {
return null;
}
return content.getOpenFileDescriptor(editor.getCaretModel().getOffset());
}
use of com.intellij.openapi.diff.DiffContent in project intellij-community by JetBrains.
the class ExternalToolContentExternalizer method getContentFile.
public File getContentFile() throws IOException {
String extension = chooseExtension();
String name = chooseName();
if (name.length() <= 3)
name = "___" + name;
File tempFile;
try {
tempFile = FileUtil.createTempFile(name, extension);
} catch (IOException e) {
tempFile = FileUtil.createTempFile(STD_PREFIX, extension);
}
final DiffContent content = getContent();
byte[] bytes = myRequest instanceof MergeRequest ? content.getDocument().getText().getBytes() : content.getBytes();
FileUtil.writeToFile(tempFile, bytes);
return tempFile;
}
use of com.intellij.openapi.diff.DiffContent in project intellij-community by JetBrains.
the class ExternalToolContentExternalizer method chooseExtension.
private String chooseExtension() {
DiffContent content = getContent();
VirtualFile contentFile = content.getFile();
String extension;
if (contentFile != null) {
extension = "." + contentFile.getExtension();
} else {
FileType contentType = content.getContentType();
if (contentType == null)
contentType = DiffUtil.chooseContentTypes(myRequest.getContents())[myIndex];
extension = contentType != null ? "." + contentType.getDefaultExtension() : null;
}
return extension;
}
use of com.intellij.openapi.diff.DiffContent in project intellij-community by JetBrains.
the class CompositeDiffTool method chooseTool.
@Nullable
private DiffTool chooseTool(DiffRequest data) {
final DiffContent[] contents = data.getContents();
if (contents.length == 2) {
final FileType type1 = contents[0].getContentType();
final FileType type2 = contents[1].getContentType();
if (type1 == type2 && type1 instanceof UIBasedFileType) {
return BinaryDiffTool.INSTANCE;
}
//todo[kb] register or not this instance in common diff tools ?
if (type1 == type2 && type1 instanceof ArchiveFileType) {
return ArchiveDiffTool.INSTANCE;
}
}
for (DiffTool tool : myTools) {
if (tool.canShow(data))
return tool;
}
return null;
}
Aggregations