Java 类com.intellij.openapi.fileTypes.UIBasedFileType 实例源码

项目:intellij-ce-playground    文件:CompositeDiffTool.java   
@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;
}
项目:tools-idea    文件:CompositeDiffTool.java   
@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;
}
项目:consulo    文件:CompositeDiffTool.java   
@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;
}
项目:intellij-ce-playground    文件:BinaryEditorHolder.java   
@Override
public boolean wantShowContent(@NotNull DiffContent content, @NotNull DiffContext context) {
  if (content instanceof FileContent) {
    if (content.getContentType() == null) return false;
    if (content.getContentType().isBinary()) return true;
    if (content.getContentType() instanceof UIBasedFileType) return true;
    return false;
  }
  return false;
}
项目:intellij-ce-playground    文件:BinaryContent.java   
@Override
@Nullable
public VirtualFile getFile() {
  if (myFileType instanceof UIBasedFileType) {
    final VirtualFile file = findVirtualFile();
    if (file != null) {
      final LightVirtualFile lightFile = new LightVirtualFile(file, new String(myBytes), 1);
      lightFile.setOriginalFile(file);
      return lightFile;
    }
  }
  return null;
}
项目:tools-idea    文件:BinaryContent.java   
@Nullable
public VirtualFile getFile() {
  if (myFileType instanceof UIBasedFileType) {
    final VirtualFile file = LocalFileSystem.getInstance().findFileByIoFile(new File(myFilePath));
    if (file != null) {
      final LightVirtualFile lightFile = new LightVirtualFile(file, new String(myBytes), 1);
      lightFile.setOriginalFile(file);
      return lightFile;
    }
  }
  return null;
}
项目:consulo    文件:BinaryEditorHolder.java   
@Override
public boolean wantShowContent(@Nonnull DiffContent content, @Nonnull DiffContext context) {
  if (content instanceof FileContent) {
    if (content.getContentType() == null) return false;
    if (content.getContentType().isBinary()) return true;
    if (content.getContentType() instanceof UIBasedFileType) return true;
    return false;
  }
  return false;
}
项目:consulo    文件:BinaryContent.java   
@Override
@Nullable
public VirtualFile getFile() {
  if (myFileType instanceof UIBasedFileType) {
    final VirtualFile file = findVirtualFile();
    if (file != null) {
      final LightVirtualFile lightFile = new LightVirtualFile(file, new String(myBytes), 1);
      lightFile.setOriginalFile(file);
      return lightFile;
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:BinaryDiffTool.java   
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);
  }
}
项目:tools-idea    文件:BinaryDiffTool.java   
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);
  }
}
项目:consulo    文件:BinaryDiffTool.java   
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";
          }

          @Nonnull
          @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);
  }
}