本文整理汇总了Java中com.intellij.ide.diff.DiffElement.getViewComponent方法的典型用法代码示例。如果您正苦于以下问题:Java DiffElement.getViewComponent方法的具体用法?Java DiffElement.getViewComponent怎么用?Java DiffElement.getViewComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.ide.diff.DiffElement
的用法示例。
在下文中一共展示了DiffElement.getViewComponent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}