本文整理汇总了Java中com.intellij.diff.DiffManager类的典型用法代码示例。如果您正苦于以下问题:Java DiffManager类的具体用法?Java DiffManager怎么用?Java DiffManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DiffManager类属于com.intellij.diff包,在下文中一共展示了DiffManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: diff
import com.intellij.diff.DiffManager; //导入依赖的package包/类
/**
* 调用 Android 文件对比
* @param project
* @param f1
* @param f2
*/
public static void diff(final Project project, final File f1, final File f2) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
try {
VirtualFile v1 = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(f1);
Document document1 = FileDocumentManager.getInstance().getDocument(v1);
FileDocumentContentImpl fileDocumentContent1 = new FileDocumentContentImpl(project, document1, v1);
VirtualFile v2 = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(f2);
Document document2 = FileDocumentManager.getInstance().getDocument(v2);
FileDocumentContentImpl fileDocumentContent2 = new FileDocumentContentImpl(project, document2, v2);
SimpleDiffRequest simpleDiffRequest = new SimpleDiffRequest(Constant.TITLE, fileDocumentContent1, fileDocumentContent2,
f1.getName(), f2.getName());
DiffManager.getInstance().showDiff(project, simpleDiffRequest);
} catch (Exception e) {
NotificationUtils.errorNotification("Diff Source Error:" + e.getMessage());
}
}
});
}
示例2: showDiffForFiles
import com.intellij.diff.DiffManager; //导入依赖的package包/类
private void showDiffForFiles(File remoteFile, VirtualFile localFile) {
if (remoteFile == null || localFile == null) {
return;
}
final DiffContent remoteFileContent = DiffContentFactory.getInstance().create(new String(remoteFile.getContent(), StandardCharsets.UTF_8));
final DiffContent localFileContent = DiffContentFactory.getInstance().create(project, localFile);
DiffRequest dr = new SimpleDiffRequest("NetSuite File Cabinet Compare", remoteFileContent, localFileContent, "NetSuite File Cabinet - " + remoteFile.getName(), "Local File - " + localFile.getName());
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
DiffManager.getInstance().showDiff(project, dr);
}
});
}
}, ModalityState.NON_MODAL);
}
示例3: showDiffForChange
import com.intellij.diff.DiffManager; //导入依赖的package包/类
private static void showDiffForChange(@Nullable Project project,
@NotNull List<ChangeDiffRequestProducer> presentables,
int index,
@NotNull ShowDiffContext context) {
if (presentables.isEmpty()) return;
if (index < 0 || index >= presentables.size()) index = 0;
DiffRequestChain chain = new ChangeDiffRequestChain(presentables);
chain.setIndex(index);
for (Map.Entry<Key, Object> entry : context.getChainContext().entrySet()) {
chain.putUserData(entry.getKey(), entry.getValue());
}
chain.putUserData(DiffUserDataKeys.CONTEXT_ACTIONS, context.getActions());
DiffManager.getInstance().showDiff(project, chain, context.getDialogHints());
}
示例4: showDiff
import com.intellij.diff.DiffManager; //导入依赖的package包/类
/**
* Invokes {@link com.intellij.openapi.diff.DiffManager#getDiffTool()} to show difference between the given revisions of the given file.
* @param project project under vcs control.
* @param path file which revisions are compared.
* @param revision1 first revision - 'before', to the left.
* @param revision2 second revision - 'after', to the right.
* @throws VcsException
* @throws IOException
*/
public static void showDiff(@NotNull final Project project, @NotNull FilePath path,
@NotNull VcsFileRevision revision1, @NotNull VcsFileRevision revision2,
@NotNull String title1, @NotNull String title2) throws VcsException, IOException {
final byte[] content1 = loadRevisionContent(revision1);
final byte[] content2 = loadRevisionContent(revision2);
String title = DiffRequestFactoryImpl.getContentTitle(path);
DiffContent diffContent1 = createContent(project, content1, revision1, path);
DiffContent diffContent2 = createContent(project, content2, revision2, path);
final DiffRequest request = new SimpleDiffRequest(title, diffContent1, diffContent2, title1, title2);
request.putUserData(REVISIONS_KEY, new VcsFileRevision[]{revision1, revision2});
WaitForProgressToShow.runOrInvokeLaterAboveProgress(new Runnable() {
public void run() {
DiffManager.getInstance().showDiff(project, request);
}
}, null, project);
}
示例5: showResult
import com.intellij.diff.DiffManager; //导入依赖的package包/类
@Override
protected void showResult() {
if (!success.isNull()) {
String title = SvnBundle.message("compare.with.branch.diff.title");
String title1 = remoteTitleBuilder.toString();
String title2 = myVirtualFile.getPresentableUrl();
try {
DiffContent content1 = DiffContentFactory.getInstance().createFromBytes(myProject, myVirtualFile, content.get());
DiffContent content2 = DiffContentFactory.getInstance().create(myProject, myVirtualFile);
DiffRequest request = new SimpleDiffRequest(title, content1, content2, title1, title2);
DiffManager.getInstance().showDiff(myProject, request);
}
catch (IOException e) {
reportGeneralException(e);
}
}
}
示例6: showDiffForChange
import com.intellij.diff.DiffManager; //导入依赖的package包/类
private static void showDiffForChange(@Nullable Project project,
@Nonnull List<ChangeDiffRequestProducer> presentables,
int index,
@Nonnull ShowDiffContext context) {
if (presentables.isEmpty()) return;
if (index < 0 || index >= presentables.size()) index = 0;
DiffRequestChain chain = new ChangeDiffRequestChain(presentables);
chain.setIndex(index);
for (Map.Entry<Key, Object> entry : context.getChainContext().entrySet()) {
chain.putUserData(entry.getKey(), entry.getValue());
}
chain.putUserData(DiffUserDataKeys.CONTEXT_ACTIONS, context.getActions());
DiffManager.getInstance().showDiff(project, chain, context.getDialogHints());
}
示例7: createCenterPanel
import com.intellij.diff.DiffManager; //导入依赖的package包/类
@Nullable
@Override
@RequiredDispatchThread
protected JComponent createCenterPanel()
{
final Project project = myOldMethod.getProject();
final VirtualFile file = PsiUtilCore.getVirtualFile(myOldMethod);
DiffContentFactory contentFactory = DiffContentFactory.getInstance();
DocumentContent oldContent = contentFactory.create(myOldMethod.getText() + "\n\n\nmethod call:\n " + myOldCall.getText(), file);
DocumentContent newContent = contentFactory.create(myNewMethod.getText() + "\n\n\nmethod call:\n " + myNewCall.getText(), file);
SimpleDiffRequest request = new SimpleDiffRequest(null, oldContent, newContent, "Before", "After");
DiffRequestPanel diffPanel = DiffManager.getInstance().createRequestPanel(project, getDisposable(), null);
diffPanel.putContextHints(DiffUserDataKeys.PLACE, "ExtractSignature");
diffPanel.setRequest(request);
final JPanel panel = new JPanel(new BorderLayout());
panel.add(diffPanel.getComponent(), BorderLayout.CENTER);
panel.setBorder(IdeBorderFactory.createEmptyBorder(JBUI.insetsTop(5)));
return panel;
}
示例8: showDiff
import com.intellij.diff.DiffManager; //导入依赖的package包/类
private void showDiff() {
Project project = CptUtil.getActiveProject();
CptUtil.getTemplateFile("java").ifPresent(file -> {
VirtualFile vFile = LocalFileSystem.getInstance().findFileByIoFile(file);
DocumentContent content1 = DiffContentFactory.getInstance().create(templatesText);
DocumentContent content2 = DiffContentFactory.getInstance().createDocument(project, vFile);
DiffManager.getInstance().showDiff(project, new SimpleDiffRequest("Templates Diff", content1, content2,
"Predefined plugin templates", "Your templates"));
});
}
示例9: actionPerformed
import com.intellij.diff.DiffManager; //导入依赖的package包/类
public void actionPerformed(@NotNull AnActionEvent e) {
Project project = e.getProject();
DiffRequest request = getDiffRequest(e);
if (request == null) return;
DiffManager.getInstance().showDiff(project, request);
}
示例10: actionPerformed
import com.intellij.diff.DiffManager; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
List<DiffContent> contents = myRequest.getContents();
List<String> titles = myRequest.getContentTitles();
DiffRequest request = new SimpleDiffRequest(myRequest.getTitle(),
mySide1.select(contents), mySide2.select(contents),
mySide1.select(titles), mySide2.select(titles));
DiffManager.getInstance().showDiff(myProject, request, new DiffDialogHints(null, myPanel));
}
示例11: process
import com.intellij.diff.DiffManager; //导入依赖的package包/类
@Override
public boolean process(final VirtualFile file, final Document document) {
String message = UIBundle.message("file.cache.conflict.message.text", file.getPresentableUrl());
final DialogBuilder builder = new DialogBuilder();
builder.setCenterPanel(new JLabel(message, Messages.getQuestionIcon(), SwingConstants.CENTER));
builder.addOkAction().setText(UIBundle.message("file.cache.conflict.load.fs.changes.button"));
builder.addCancelAction().setText(UIBundle.message("file.cache.conflict.keep.memory.changes.button"));
builder.addAction(new AbstractAction(UIBundle.message("file.cache.conflict.show.difference.button")) {
@Override
public void actionPerformed(ActionEvent e) {
final ProjectEx project = (ProjectEx)ProjectLocator.getInstance().guessProjectForFile(file);
FileType fileType = file.getFileType();
String fsContent = LoadTextUtil.loadText(file).toString();
DocumentContent content1 = DiffContentFactory.getInstance().create(fsContent, fileType);
DocumentContent content2 = DiffContentFactory.getInstance().create(project, document, file);
String title = UIBundle.message("file.cache.conflict.for.file.dialog.title", file.getPresentableUrl());
String title1 = UIBundle.message("file.cache.conflict.diff.content.file.system.content");
String title2 = UIBundle.message("file.cache.conflict.diff.content.memory.content");
DiffRequest request = new SimpleDiffRequest(title, content1, content2, title1, title2);
request.putUserData(DiffUserDataKeys.GO_TO_SOURCE_DISABLE, true);
DialogBuilder diffBuilder = new DialogBuilder(project);
DiffRequestPanel diffPanel = DiffManager.getInstance().createRequestPanel(project, diffBuilder, diffBuilder.getWindow());
diffPanel.setRequest(request);
diffBuilder.setCenterPanel(diffPanel.getComponent());
diffBuilder.setDimensionServiceKey("FileDocumentManager.FileCacheConflict");
diffBuilder.addOkAction().setText(UIBundle.message("file.cache.conflict.save.changes.button"));
diffBuilder.addCancelAction();
diffBuilder.setTitle(title);
if (diffBuilder.show() == DialogWrapper.OK_EXIT_CODE) {
builder.getDialogWrapper().close(DialogWrapper.CANCEL_EXIT_CODE);
}
}
});
builder.setTitle(UIBundle.message("file.cache.conflict.dialog.title"));
builder.setButtonsAlignment(SwingConstants.CENTER);
builder.setHelpId("reference.dialogs.fileCacheConflict");
return builder.show() == 0;
}
示例12: actionPerformed
import com.intellij.diff.DiffManager; //导入依赖的package包/类
public void actionPerformed(AnActionEvent e) {
DataContext context = e.getDataContext();
VirtualFile[] files = CommonDataKeys.VIRTUAL_FILE_ARRAY.getData(context);
if (files == null || files.length != 3){
return;
}
DiffRequestFactory diffRequestFactory = DiffRequestFactory.getInstance();
try {
Project project = CommonDataKeys.PROJECT.getData(context);
String title = DiffBundle.message("merge.files.dialog.title");
List<String> titles = ContainerUtil.list(files[0].getPresentableUrl(),
files[1].getPresentableUrl(),
files[2].getPresentableUrl());
VirtualFile outputFile = files[1];
List<VirtualFile> contents = ContainerUtil.list(files[0], files[1], files[2]);
MergeRequest request = diffRequestFactory.createMergeRequestFromFiles(project, outputFile, contents, title, titles, null);
request.putUserData(DiffUserDataKeys.HELP_ID, "cvs.merge");
DiffManager.getInstance().showMerge(project, request);
}
catch (InvalidDiffRequestException err) {
Messages.showErrorDialog(err.getLocalizedMessage(), DiffBundle.message("merge.files.dialog.title"));
}
}
示例13: handle
import com.intellij.diff.DiffManager; //导入依赖的package包/类
@Override
protected void handle(final Project project, final String value, XDebuggerTree tree) {
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
DiffRequest request = DiffRequestFactory.getInstance().createClipboardVsValue(value);
DiffManager.getInstance().showDiff(project, request);
}
});
}
示例14: showDiff
import com.intellij.diff.DiffManager; //导入依赖的package包/类
private void showDiff() {
if (ChangeListManager.getInstance(myProject).isFreezedWithNotification(null)) return;
if (myPatches.isEmpty() || (!myContainBasedChanges)) return;
final List<AbstractFilePatchInProgress.PatchChange> changes = getAllChanges();
Collections.sort(changes, myMyChangeComparator);
List<AbstractFilePatchInProgress.PatchChange> selectedChanges = myChangesTreeList.getSelectedChanges();
int selectedIdx = 0;
final List<DiffRequestProducer> diffRequestPresentableList = new ArrayList<DiffRequestProducer>(changes.size());
final List<Change> diffRequestChangeList = new ArrayList<Change>(changes.size());
if (selectedChanges.isEmpty()) {
selectedChanges = changes;
}
if (!selectedChanges.isEmpty()) {
final AbstractFilePatchInProgress.PatchChange c = selectedChanges.get(0);
for (AbstractFilePatchInProgress.PatchChange change : changes) {
final AbstractFilePatchInProgress patchInProgress = change.getPatchInProgress();
if (!patchInProgress.baseExistsOrAdded()) continue;
diffRequestPresentableList.add(patchInProgress.getDiffRequestProducers(myProject, myReader));
diffRequestChangeList.add(change);
if (change.equals(c)) {
selectedIdx = diffRequestPresentableList.size() - 1;
}
}
}
if (diffRequestPresentableList.isEmpty()) return;
MyDiffRequestChain chain = new MyDiffRequestChain(diffRequestPresentableList, diffRequestChangeList, selectedIdx);
DiffManager.getInstance().showDiff(myProject, chain, DiffDialogHints.DEFAULT);
}
示例15: showShelvedChangesDiff
import com.intellij.diff.DiffManager; //导入依赖的package包/类
public static void showShelvedChangesDiff(final DataContext dc) {
final Project project = CommonDataKeys.PROJECT.getData(dc);
if (project == null) return;
if (ChangeListManager.getInstance(project).isFreezedWithNotification(null)) return;
ShelvedChangeList[] changeLists = ShelvedChangesViewManager.SHELVED_CHANGELIST_KEY.getData(dc);
if (changeLists == null) changeLists = ShelvedChangesViewManager.SHELVED_RECYCLED_CHANGELIST_KEY.getData(dc);
if (changeLists == null || changeLists.length != 1) return;
final List<ShelvedChange> textChanges = changeLists[0].getChanges(project);
final List<ShelvedBinaryFile> binaryChanges = changeLists[0].getBinaryFiles();
final List<MyDiffRequestProducer> diffRequestProducers = new ArrayList<MyDiffRequestProducer>();
processTextChanges(project, textChanges, diffRequestProducers);
processBinaryFiles(project, binaryChanges, diffRequestProducers);
Collections.sort(diffRequestProducers, ChangeDiffRequestComparator.getInstance());
// selected changes inside lists
final Set<Object> selectedChanges = new HashSet<Object>();
selectedChanges.addAll(ContainerUtil.notNullize(ShelvedChangesViewManager.SHELVED_CHANGE_KEY.getData(dc)));
selectedChanges.addAll(ContainerUtil.notNullize(ShelvedChangesViewManager.SHELVED_BINARY_FILE_KEY.getData(dc)));
int index = 0;
for (int i = 0; i < diffRequestProducers.size(); i++) {
MyDiffRequestProducer producer = diffRequestProducers.get(i);
if (selectedChanges.contains(producer.getBinaryChange()) || selectedChanges.contains(producer.getTextChange())) {
index = i;
break;
}
}
MyDiffRequestChain chain = new MyDiffRequestChain(diffRequestProducers, index);
DiffManager.getInstance().showDiff(project, chain, DiffDialogHints.FRAME);
}