本文整理汇总了Java中com.intellij.ide.diff.DiffElement类的典型用法代码示例。如果您正苦于以下问题:Java DiffElement类的具体用法?Java DiffElement怎么用?Java DiffElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DiffElement类属于com.intellij.ide.diff包,在下文中一共展示了DiffElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addChild
import com.intellij.ide.diff.DiffElement; //导入依赖的package包/类
public DTree addChild(@NotNull DiffElement element, boolean source) {
init();
myChildrenList = null;
final DTree node;
final String name = element.getName();
if (myChildren.containsKey(name)) {
node = myChildren.get(name);
} else {
node = new DTree(this, name, element.isContainer());
myChildren.put(name, node);
}
if (source) {
node.setSource(element);
} else {
node.setTarget(element);
}
return node;
}
示例2: addChild
import com.intellij.ide.diff.DiffElement; //导入依赖的package包/类
public DTree addChild(@Nonnull DiffElement element, boolean source) {
init();
myChildrenList = null;
final DTree node;
final String name = element.getName();
if (myChildren.containsKey(name)) {
node = myChildren.get(name);
} else {
node = new DTree(this, name, element.isContainer());
myChildren.put(name, node);
}
if (source) {
node.setSource(element);
} else {
node.setTarget(element);
}
return node;
}
示例3: getOpenFileDescriptor
import com.intellij.ide.diff.DiffElement; //导入依赖的package包/类
@Nullable
private OpenFileDescriptor getOpenFileDescriptor() {
Project project = myModel.getProject();
List<DirDiffElementImpl> elements = myModel.getSelectedElements();
if (elements.isEmpty()) return null;
DirDiffElement element = elements.get(0);
DiffElement source = element.getSource();
DiffElement target = element.getTarget();
OpenFileDescriptor descriptor1 = source != null ? source.getOpenFileDescriptor(project) : null;
OpenFileDescriptor descriptor2 = target != null ? target.getOpenFileDescriptor(project) : null;
return descriptor2 != null ? descriptor2 : descriptor1;
}
示例4: getOpenFileDescriptorsArray
import com.intellij.ide.diff.DiffElement; //导入依赖的package包/类
@Nullable
private OpenFileDescriptor[] getOpenFileDescriptorsArray() {
Project project = myModel.getProject();
List<DirDiffElementImpl> elements = myModel.getSelectedElements();
List<OpenFileDescriptor> descriptors = new ArrayList<OpenFileDescriptor>();
for (DirDiffElementImpl element : elements) {
DiffElement source = element.getSource();
DiffElement target = element.getTarget();
OpenFileDescriptor descriptor1 = source != null ? source.getOpenFileDescriptor(project) : null;
OpenFileDescriptor descriptor2 = target != null ? target.getOpenFileDescriptor(project) : null;
if (descriptor1 != null) descriptors.add(descriptor1);
if (descriptor2 != null) descriptors.add(descriptor2);
}
return ContainerUtil.toArray(descriptors, new OpenFileDescriptor[descriptors.size()]);
}
示例5: isEqual
import com.intellij.ide.diff.DiffElement; //导入依赖的package包/类
private static boolean isEqual(DiffElement file1, DiffElement file2) {
if (file1.isContainer() || file2.isContainer()) return false;
if (file1.getSize() != file2.getSize()) return false;
try {
return Arrays.equals(file1.getContent(), file2.getContent());
}
catch (IOException e) {
return false;
}
}
示例6: getNavigatableArray
import com.intellij.ide.diff.DiffElement; //导入依赖的package包/类
@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);
}
示例7: loadRequest
import com.intellij.ide.diff.DiffElement; //导入依赖的package包/类
@Nonnull
@Override
protected DiffRequest loadRequest(@Nonnull ElementWrapper element, @Nonnull ProgressIndicator indicator)
throws ProcessCanceledException, DiffRequestProducerException {
final Project project = myModel.getProject();
DiffElement sourceElement = element.sourceElement;
DiffElement targetElement = element.targetElement;
DiffContent sourceContent = sourceElement != null ? sourceElement.createDiffContent(project, indicator) :
DiffContentFactory.getInstance().createEmpty();
DiffContent targetContent = targetElement != null ? targetElement.createDiffContent(project, indicator) :
DiffContentFactory.getInstance().createEmpty();
return new SimpleDiffRequest(null, sourceContent, targetContent, null, null);
}
示例8: update
import com.intellij.ide.diff.DiffElement; //导入依赖的package包/类
public void update(boolean force) {
final Project project = myModel.getProject();
final DirDiffElementImpl element = myModel.getElementAt(myTable.getSelectedRow());
if (element == null) {
clearDiffPanel();
return;
}
if (!force
&& myCurrentElement != null
&& (myCurrentElement == element.getSource() || myCurrentElement == element.getTarget())) {
return;
}
clearDiffPanel();
if (element.getType() == DiffType.CHANGED) {
try {
myDiffPanelComponent = element.getSource().getDiffComponent(element.getTarget(), project, myDiffWindow.getWindow(), myModel);
}
catch (FilesTooBigForDiffException e) {
// todo KB: check
myDiffPanelComponent = null;
myErrorLabel = new JLabel("Can not build diff for file " + element.getTarget().getPath() + ". File is too big and there are too many changes.");
}
if (myDiffPanelComponent != null) {
myDiffPanel.add(myDiffPanelComponent, BorderLayout.CENTER);
myCurrentElement = element.getSource();
} else {
myDiffPanel.add(getErrorLabel(), BorderLayout.CENTER);
}
} else {
final DiffElement object;
final DiffElement target;
if (element.getType() == DiffType.ERROR) {
object = element.getSource() == null ? element.getTarget() : element.getSource();
target = element.getSource() == null ? element.getSource() : element.getTarget();
} else {
object = element.isSource() ? element.getSource() : element.getTarget();
target = element.isSource() ? element.getTarget() : element.getSource();
}
myViewComponent = object.getViewComponent(project, target, myModel);
if (myViewComponent != null) {
myCurrentElement = object;
myDiffPanel.add(myViewComponent, BorderLayout.CENTER);
DataProvider dataProvider = myCurrentElement.getDataProvider(project);
if (dataProvider != null) {
DataManager.registerDataProvider(myDiffPanel, dataProvider);
}
else {
DataManager.removeDataProvider(myDiffPanel);
}
} else {
myDiffPanel.add(getErrorLabel(), BorderLayout.CENTER);
}
}
myDiffPanel.revalidate();
myDiffPanel.repaint();
}
示例9: getSource
import com.intellij.ide.diff.DiffElement; //导入依赖的package包/类
public DiffElement<?> getSource() {
return mySource;
}
示例10: setSource
import com.intellij.ide.diff.DiffElement; //导入依赖的package包/类
public void setSource(DiffElement<?> source) {
mySource = source;
}
示例11: getTarget
import com.intellij.ide.diff.DiffElement; //导入依赖的package包/类
public DiffElement<?> getTarget() {
return myTarget;
}
示例12: setTarget
import com.intellij.ide.diff.DiffElement; //导入依赖的package包/类
public void setTarget(DiffElement<?> target) {
myTarget = target;
}
示例13: DirDiffViewer
import com.intellij.ide.diff.DiffElement; //导入依赖的package包/类
public DirDiffViewer(@NotNull DiffContext context, @NotNull ContentDiffRequest request) {
myContext = context;
myRequest = request;
List<DiffContent> contents = request.getContents();
DiffElement element1 = createDiffElement(contents.get(0));
DiffElement element2 = createDiffElement(contents.get(1));
Project project = context.getProject();
if (project == null) project = DefaultProjectFactory.getInstance().getDefaultProject();
DirDiffTableModel model = new DirDiffTableModel(project, element1, element2, new DirDiffSettings());
myDirDiffPanel = new DirDiffPanel(model, new DirDiffWindow((DirDiffFrame)null) {
@Override
public Window getWindow() {
return null;
}
@Override
public Disposable getDisposable() {
return DirDiffViewer.this;
}
@Override
public void setTitle(String title) {
}
});
myPanel = new JPanel(new BorderLayout());
myPanel.add(myDirDiffPanel.getPanel(), BorderLayout.CENTER);
DataManager.registerDataProvider(myPanel, new DataProvider() {
@Override
public Object getData(@NonNls String dataId) {
if (PlatformDataKeys.HELP_ID.is(dataId)) {
return "reference.dialogs.diff.folder";
}
return myDirDiffPanel.getData(dataId);
}
});
}
示例14: createDiffElement
import com.intellij.ide.diff.DiffElement; //导入依赖的package包/类
@NotNull
private static DiffElement createDiffElement(@NotNull DiffContent content) {
if (content instanceof EmptyContent) {
return new DiffElement() {
@Override
public String getPath() {
return "";
}
@NotNull
@Override
public String getName() {
return "Nothing";
}
@Override
public long getSize() {
return -1;
}
@Override
public long getTimeStamp() {
return -1;
}
@Override
public boolean isContainer() {
return true;
}
@Override
public DiffElement[] getChildren() throws IOException {
return EMPTY_ARRAY;
}
@Nullable
@Override
public byte[] getContent() throws IOException {
return null;
}
@Override
public Object getValue() {
return null;
}
};
}
if (content instanceof DirectoryContent) {
return new VirtualFileDiffElement(((DirectoryContent)content).getFile());
}
if (content instanceof FileContent && content.getContentType() instanceof ArchiveFileType) {
return new JarFileDiffElement(((FileContent)content).getFile());
}
throw new IllegalArgumentException(content.getClass() + " " + content.getContentType());
}
示例15: createDiffElement
import com.intellij.ide.diff.DiffElement; //导入依赖的package包/类
@Nullable
public abstract DiffElement createDiffElement(Object obj);