use of com.intellij.ide.diff.DiffElement in project intellij-community by JetBrains.
the class BinaryDiffTool method show.
public void show(final DiffRequest data) {
final DiffContent current = data.getContents()[0];
final DiffContent upToDate = data.getContents()[1];
final Project project = data.getProject();
if ((current instanceof FileContent && upToDate instanceof FileContent) || (current.getContentType() instanceof UIBasedFileType && upToDate.getContentType() instanceof UIBasedFileType)) {
final VirtualFile src = current.getFile();
final VirtualFile trg = upToDate.getFile();
if (src != null && trg != null) {
final PanelCreator creator = new PanelCreator(data);
if (creator.isCanCreatePanel()) {
new DialogWrapper(data.getProject()) {
public DiffPanel myPanel;
{
setModal(false);
init();
}
@Override
protected String getDimensionServiceKey() {
return "BinaryDiffDialog";
}
@NotNull
@Override
protected Action[] createActions() {
final Action close = getCancelAction();
close.putValue(Action.NAME, "&Close");
return new Action[] { close };
}
@Override
protected JComponent createCenterPanel() {
myPanel = creator.create(getWindow(), getDisposable(), BinaryDiffTool.this);
return myPanel.getComponent();
}
}.show();
return;
} else {
final DirDiffManager diffManager = DirDiffManager.getInstance(project);
final DiffElement before = diffManager.createDiffElement(src);
final DiffElement after = diffManager.createDiffElement(trg);
if (before != null && after != null && diffManager.canShow(after, before)) {
diffManager.showDiff(before, after);
return;
}
}
}
}
try {
final boolean equal = Arrays.equals(current.getBytes(), upToDate.getBytes());
Messages.showMessageDialog(equal ? DiffBundle.message("binary.files.are.identical.message") : DiffBundle.message("binary.files.are.different.message"), equal ? DiffBundle.message("files.are.identical.dialog.title") : DiffBundle.message("files.are.different.dialog.title"), Messages.getInformationIcon());
} catch (IOException e) {
LOG.error(e);
}
}
use of com.intellij.ide.diff.DiffElement in project intellij-community by JetBrains.
the class DirDiffPanel method getNavigatableArray.
@Nullable
private Navigatable[] getNavigatableArray() {
Project project = myModel.getProject();
List<DirDiffElementImpl> elements = myModel.getSelectedElements();
List<Navigatable> navigatables = new ArrayList<>();
for (DirDiffElementImpl element : elements) {
DiffElement source = element.getSource();
DiffElement target = element.getTarget();
Navigatable navigatable1 = source != null ? source.getNavigatable(project) : null;
Navigatable navigatable2 = target != null ? target.getNavigatable(project) : null;
if (navigatable1 != null)
navigatables.add(navigatable1);
if (navigatable2 != null)
navigatables.add(navigatable2);
}
return toObjectArray(navigatables, Navigatable.class);
}
Aggregations