Java 类com.intellij.util.containers.Convertor 实例源码

项目:intellij-ce-playground    文件:SvnTestInteractiveAuthentication.java   
@Override
public SVNAuthentication requestClientAuthentication(String kind,
                                                     SVNURL url,
                                                     String realm,
                                                     SVNErrorMessage errorMessage,
                                                     SVNAuthentication previousAuth,
                                                     boolean authMayBeStored) {
  authMayBeStored = authMayBeStored && mySaveData;
  Convertor<SVNURL, SVNAuthentication> convertor = myData.get(kind);
  SVNAuthentication result = convertor == null ? null : convertor.convert(url);
  if (result == null) {
    if (ISVNAuthenticationManager.USERNAME.equals(kind)) {
      result = new SVNUserNameAuthentication("username", authMayBeStored);
    } else if (ISVNAuthenticationManager.PASSWORD.equals(kind)) {
      result = new SVNPasswordAuthentication("username", "abc", authMayBeStored, url, false);
    } else if (ISVNAuthenticationManager.SSH.equals(kind)) {
      result = new SVNSSHAuthentication("username", "abc", -1, authMayBeStored, url, false);
    } else if (ISVNAuthenticationManager.SSL.equals(kind)) {
      result = new SVNSSLAuthentication(new File("aaa"), "abc", authMayBeStored, url, false);
    }
  }
  if (! ISVNAuthenticationManager.USERNAME.equals(kind)) {
    myManager.requested(ProviderType.interactive, url, realm, kind, result == null);
  }
  return result;
}
项目:intellij-ce-playground    文件:Configuration.java   
private int importPlaces(final List<BaseInjection> injections) {
  final Map<String, Set<BaseInjection>> map = ContainerUtil.classify(injections.iterator(), new Convertor<BaseInjection, String>() {
    @Override
    public String convert(final BaseInjection o) {
      return o.getSupportId();
    }
  });
  List<BaseInjection> originalInjections = new ArrayList<BaseInjection>();
  List<BaseInjection> newInjections = new ArrayList<BaseInjection>();
  for (String supportId : InjectorUtils.getActiveInjectionSupportIds()) {
    final Set<BaseInjection> importingInjections = map.get(supportId);
    if (importingInjections == null) continue;
    importInjections(getInjections(supportId), importingInjections, originalInjections, newInjections);
  }
  if (!newInjections.isEmpty()) configurationModified();
  replaceInjections(newInjections, originalInjections, true);
  return newInjections.size();
}
项目:intellij-ce-playground    文件:StepIntersection.java   
public StepIntersection(Convertor<Data, TextRange> dataConvertor,
                        Convertor<Area, TextRange> areasConvertor,
                        final List<Area> areas,
                        Getter<String> debugDocumentTextGetter) {
  myAreas = areas;
  myDebugDocumentTextGetter = debugDocumentTextGetter;
  myAreaIndex = 0;
  myDataConvertor = dataConvertor;
  myAreasConvertor = areasConvertor;
  myHackSearch = new HackSearch<Data, Area, TextRange>(myDataConvertor, myAreasConvertor, new Comparator<TextRange>() {
    @Override
    public int compare(TextRange o1, TextRange o2) {
      return o1.intersects(o2) ? 0 : o1.getStartOffset() < o2.getStartOffset() ? -1 : 1;
    }
  });
}
项目:intellij-ce-playground    文件:HackSearch.java   
public HackSearch(Convertor<T, Z> TZConvertor, Convertor<S, Z> SZConvertor, Comparator<Z> zComparator) {
  myTZConvertor = TZConvertor;
  mySZConvertor = SZConvertor;
  myZComparator = zComparator;
  myComparator = new Comparator<S>() {
  @Override
  public int compare(S o1, S o2) {
    Z z1 = mySZConvertor.convert(o1);
    Z z2 = mySZConvertor.convert(o2);
    if (o1 == myFake) {
      z1 = myFakeConverted;
    } else if (o2 == myFake) {
      z2 = myFakeConverted;
    }
    return myZComparator.compare(z1, z2);
  }
};
}
项目:intellij-ce-playground    文件:ExistingTemplatesComponent.java   
private static Tree createTree(TreeModel treeModel) {
  final Tree tree = new Tree(treeModel);

  tree.setRootVisible(false);
  tree.setShowsRootHandles(true);
  tree.setDragEnabled(false);
  tree.setEditable(false);
  tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);


  final TreeSpeedSearch speedSearch = new TreeSpeedSearch(
    tree,
    new Convertor<TreePath, String>() {
      public String convert(TreePath object) {
        final Object userObject = ((DefaultMutableTreeNode)object.getLastPathComponent()).getUserObject();
        return (userObject instanceof Configuration) ? ((Configuration)userObject).getName() : userObject.toString();
      }
    }
  );
  tree.setCellRenderer(new ExistingTemplatesTreeCellRenderer(speedSearch));

  return tree;
}
项目:intellij-ce-playground    文件:MergeFromTheirsResolver.java   
@Override
public void run(ContinuationContext context) {
  final Project project = myVcs.getProject();
  final List<FilePatch> patches;
  try {
    patches = IdeaTextPatchBuilder.buildPatch(project, myTheirsChanges, myBaseForPatch.getPath(), false);
    myTextPatches = ObjectsConvertor.convert(patches, new Convertor<FilePatch, TextFilePatch>() {
      @Override
      public TextFilePatch convert(FilePatch o) {
        return (TextFilePatch)o;
      }
    });
  }
  catch (VcsException e) {
    context.handleException(e, true);
  }
}
项目:intellij-ce-playground    文件:BreakpointsCheckboxTree.java   
@Override
protected void installSpeedSearch() {
  new TreeSpeedSearch(this, new Convertor<TreePath, String>() {
    @Override
    public String convert(TreePath path) {
      Object node = path.getLastPathComponent();
      if (node instanceof BreakpointItemNode) {
        return ((BreakpointItemNode)node).getBreakpointItem().speedSearchText();
      }
      else if (node instanceof BreakpointsGroupNode) {
        return ((BreakpointsGroupNode)node).getGroup().getName();
      }
      return "";
    }
  });
}
项目:intellij-ce-playground    文件:NewMappings.java   
public List<VirtualFile> getDefaultRoots() {
  synchronized (myLock) {
    final String defaultVcs = haveDefaultMapping();
    if (defaultVcs == null) return Collections.emptyList();
    final List<VirtualFile> list = new ArrayList<VirtualFile>();
    myDefaultVcsRootPolicy.addDefaultVcsRoots(this, defaultVcs, list);
    if (StringUtil.isEmptyOrSpaces(defaultVcs)) {
      return AbstractVcs.filterUniqueRootsDefault(list, Convertor.SELF);
    }
    else {
      final AbstractVcs<?> vcs = AllVcses.getInstance(myProject).getByName(defaultVcs);
      if (vcs == null) {
        return AbstractVcs.filterUniqueRootsDefault(list, Convertor.SELF);
      }
      return vcs.filterUniqueRoots(list, Convertor.SELF);
    }
  }
}
项目:intellij-ce-playground    文件:OptionsAndConfirmations.java   
public void init(final Convertor<String, VcsShowConfirmationOption.Value> initOptions) {
  createSettingFor(VcsConfiguration.StandardOption.ADD);
  createSettingFor(VcsConfiguration.StandardOption.REMOVE);
  createSettingFor(VcsConfiguration.StandardOption.CHECKOUT);
  createSettingFor(VcsConfiguration.StandardOption.UPDATE);
  createSettingFor(VcsConfiguration.StandardOption.STATUS);
  createSettingFor(VcsConfiguration.StandardOption.EDIT);

  myConfirmations.put(VcsConfiguration.StandardConfirmation.ADD.getId(), new VcsShowConfirmationOptionImpl(
    VcsConfiguration.StandardConfirmation.ADD.getId(),
    VcsBundle.message("label.text.when.files.created.with.idea", ApplicationNamesInfo.getInstance().getProductName()),
    VcsBundle.message("radio.after.creation.do.not.add"), VcsBundle.message("radio.after.creation.show.options"),
    VcsBundle.message("radio.after.creation.add.silently")));

  myConfirmations.put(VcsConfiguration.StandardConfirmation.REMOVE.getId(), new VcsShowConfirmationOptionImpl(
    VcsConfiguration.StandardConfirmation.REMOVE.getId(),
    VcsBundle.message("label.text.when.files.are.deleted.with.idea", ApplicationNamesInfo.getInstance().getProductName()),
    VcsBundle.message("radio.after.deletion.do.not.remove"), VcsBundle.message("radio.after.deletion.show.options"),
    VcsBundle.message("radio.after.deletion.remove.silently")));

  restoreReadConfirm(VcsConfiguration.StandardConfirmation.ADD, initOptions);
  restoreReadConfirm(VcsConfiguration.StandardConfirmation.REMOVE, initOptions);
}
项目:intellij-ce-playground    文件:IssueLinkHtmlRenderer.java   
@SuppressWarnings({"HardCodedStringLiteral"})
public static String formatTextWithLinks(final Project project, final String c, final Convertor<String, String> convertor) {
  if (c == null) return "";
  String comment = XmlTagUtilBase.escapeString(c, false);

  StringBuilder commentBuilder = new StringBuilder();
  IssueNavigationConfiguration config = IssueNavigationConfiguration.getInstance(project);
  final List<IssueNavigationConfiguration.LinkMatch> list = config.findIssueLinks(comment);
  int pos = 0;
  for(IssueNavigationConfiguration.LinkMatch match: list) {
    TextRange range = match.getRange();
    commentBuilder.append(convertor.convert(comment.substring(pos, range.getStartOffset()))).append("<a href=\"").append(match.getTargetUrl()).append("\">");
    commentBuilder.append(range.substring(comment)).append("</a>");
    pos = range.getEndOffset();
  }
  commentBuilder.append(convertor.convert(comment.substring(pos)));
  comment = commentBuilder.toString();

  return comment.replace("\n", "<br>");
}
项目:intellij-ce-playground    文件:RepositoryBrowserComponent.java   
private void createComponent() {
  setLayout(new BorderLayout());
  myRepositoryTree = new Tree();
  myRepositoryTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  myRepositoryTree.setRootVisible(false);
  myRepositoryTree.setShowsRootHandles(true);
  JScrollPane scrollPane =
    ScrollPaneFactory.createScrollPane(myRepositoryTree, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
  add(scrollPane, BorderLayout.CENTER);
  myRepositoryTree.setCellRenderer(new SvnRepositoryTreeCellRenderer());
  TreeSpeedSearch search = new TreeSpeedSearch(myRepositoryTree, new Convertor<TreePath, String>() {
    @Override
    public String convert(TreePath o) {
      Object component = o.getLastPathComponent();
      if (component instanceof RepositoryTreeNode) {
        return ((RepositoryTreeNode)component).getURL().toDecodedString();
      }
      return null;
    }
  });
  search.setComparator(new SpeedSearchComparator(false, true));

  EditSourceOnDoubleClickHandler.install(myRepositoryTree);
}
项目:intellij-ce-playground    文件:LiveTemplateTree.java   
@Override
protected void installSpeedSearch() {
  new TreeSpeedSearch(this, new Convertor<TreePath, String>() {
    @Override
    public String convert(TreePath o) {
      Object object = ((DefaultMutableTreeNode)o.getLastPathComponent()).getUserObject();
      if (object instanceof TemplateGroup) {
        return ((TemplateGroup)object).getName();
      }
      if (object instanceof TemplateImpl) {
        TemplateImpl template = (TemplateImpl)object;
        return StringUtil.notNullize(template.getGroupName()) + " " +
               StringUtil.notNullize(template.getKey()) + " " +
               StringUtil.notNullize(template.getDescription()) + " " +
               template.getTemplateText();
      }
      return "";
    }
  }, true);
}
项目:intellij-ce-playground    文件:ConfigurationSettingsEditor.java   
private <T> SettingsEditor<RunnerAndConfigurationSettings> wrapEditor(SettingsEditor<T> editor,
                                                                      Convertor<RunnerAndConfigurationSettings, T> convertor,
                                                                      ProgramRunner runner) {
  SettingsEditor<RunnerAndConfigurationSettings> wrappedEditor
    = new SettingsEditorWrapper<RunnerAndConfigurationSettings, T>(editor, convertor);

  List<SettingsEditor> unwrappedEditors = myRunner2UnwrappedEditors.get(runner);
  if (unwrappedEditors == null) {
    unwrappedEditors = new ArrayList<SettingsEditor>();
    myRunner2UnwrappedEditors.put(runner, unwrappedEditors);
  }
  unwrappedEditors.add(editor);

  myRunnerEditors.add(wrappedEditor);
  Disposer.register(this, wrappedEditor);

  return wrappedEditor;
}
项目:intellij-ce-playground    文件:StructureViewComponent.java   
private void installTree() {
  getTree().getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
  myAutoScrollToSourceHandler.install(getTree());
  myAutoScrollFromSourceHandler.install();

  TreeUtil.installActions(getTree());

  new TreeSpeedSearch(getTree(), new Convertor<TreePath, String>() {
    @Override
    public String convert(final TreePath treePath) {
      final DefaultMutableTreeNode node = (DefaultMutableTreeNode)treePath.getLastPathComponent();
      final Object userObject = node.getUserObject();
      if (userObject != null) {
        return FileStructurePopup.getSpeedSearchText(userObject);
      }
      return null;
    }
  });

  addTreeKeyListener();
  addTreeMouseListeners();
  restoreState();
}
项目:intellij-ce-playground    文件:MemberChooser.java   
protected void installSpeedSearch() {
  final TreeSpeedSearch treeSpeedSearch = new TreeSpeedSearch(myTree, new Convertor<TreePath, String>() {
    @Override
    @Nullable
    public String convert(TreePath path) {
      final ElementNode lastPathComponent = (ElementNode)path.getLastPathComponent();
      if (lastPathComponent == null) return null;
      String text = lastPathComponent.getDelegate().getText();
      if (text != null) {
        text = convertElementText(text);
      }
      return text;
    }
  });
  treeSpeedSearch.setComparator(getSpeedSearchComparator());
}
项目:intellij-ce-playground    文件:ScopeChooserConfigurable.java   
@Override
protected void initTree() {
  myTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
    @Override
    public void valueChanged(TreeSelectionEvent e) {
      final TreePath path = e.getOldLeadSelectionPath();
      if (path != null) {
        final MyNode node = (MyNode)path.getLastPathComponent();
        final NamedConfigurable namedConfigurable = node.getConfigurable();
        if (namedConfigurable instanceof ScopeConfigurable) {
          ((ScopeConfigurable)namedConfigurable).cancelCurrentProgress();
        }
      }
    }
  });
  super.initTree();
  myTree.setShowsRootHandles(false);
  new TreeSpeedSearch(myTree, new Convertor<TreePath, String>() {
    @Override
    public String convert(final TreePath treePath) {
      return ((MyNode)treePath.getLastPathComponent()).getDisplayName();
    }
  }, true);

  myTree.getEmptyText().setText(IdeBundle.message("scopes.no.scoped"));
}
项目:intellij-ce-playground    文件:DirectoryChooserModuleTreeView.java   
public DirectoryChooserModuleTreeView(@NotNull Project project) {
  myRootNode = new DefaultMutableTreeNode();
  myTree = new Tree(myRootNode);
  myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  myFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
  myProject = project;
  myTree.setRootVisible(false);
  myTree.setShowsRootHandles(true);
  myTree.setCellRenderer(new MyTreeCellRenderer());
  new TreeSpeedSearch(myTree, new Convertor<TreePath, String>() {
    @Override
    public String convert(final TreePath o) {
      final Object userObject = ((DefaultMutableTreeNode)o.getLastPathComponent()).getUserObject();
      if (userObject instanceof Module) {
        return ((Module)userObject).getName();
      }
      else {
        if (userObject == null) return "";
        return userObject.toString();
      }
    }
  }, true);
}
项目:intellij-ce-playground    文件:XmlConstraintsTest.java   
private Map<String, XmlElementDescriptor> configure(String... files) {
  myFixture.configureByFiles(files);
  XmlTag tag = ((XmlFile)getFile()).getRootTag();
  assertNotNull(tag);
  XmlElementDescriptor descriptor = tag.getDescriptor();
  assertNotNull(descriptor);
  XmlElementDescriptor[] descriptors = descriptor.getElementsDescriptors(tag);
  Map<String, XmlElementDescriptor> map =
    ContainerUtil.newMapFromValues(Arrays.asList(descriptors).iterator(), new Convertor<XmlElementDescriptor, String>() {
      @Override
      public String convert(XmlElementDescriptor o) {
        return o.getName();
      }
    });
  map.put(tag.getName(), tag.getDescriptor());
  return map;
}
项目:intellij-ce-playground    文件:ConfigFilesTreeBuilder.java   
public static void installSearch(JTree tree) {
  new TreeSpeedSearch(tree, new Convertor<TreePath, String>() {
    @Override
    public String convert(final TreePath treePath) {
      final Object object = ((DefaultMutableTreeNode)treePath.getLastPathComponent()).getUserObject();
      if (object instanceof Module) {
        return ((Module)object).getName();
      }
      else if (object instanceof PsiFile) {
        return ((PsiFile)object).getName();
      }
      else if (object instanceof VirtualFile) {
        return ((VirtualFile)object).getName();
      }
      else {
        return "";
      }
    }
  });
}
项目:intellij-ce-playground    文件:GithubSelectForkDialog.java   
public GithubSelectForkDialog(@NotNull Project project,
                              @Nullable List<GithubFullPath> forks,
                              @NotNull Convertor<String, ForkInfo> checkFork) {
  super(project);
  myProject = project;
  myCheckFork = checkFork;

  myPanel = new GithubSelectForkPanel();

  if (forks != null) {
    myPanel.setUsers(ContainerUtil.map(forks, new Function<GithubFullPath, String>() {
      @Override
      public String fun(GithubFullPath path) {
        return path.getUser();
      }
    }));
  }

  setTitle("Select Base Fork Repository");
  init();
}
项目:intellij-ce-playground    文件:GithubUrlUtilTest.java   
public void testRemoveTrailingSlash() throws Throwable {
  TestCase<String> tests = new TestCase<String>();

  tests.add("http://github.com/", "http://github.com");
  tests.add("http://github.com", "http://github.com");

  tests.add("http://github.com/user/repo/", "http://github.com/user/repo");
  tests.add("http://github.com/user/repo", "http://github.com/user/repo");

  runTestCase(tests, new Convertor<String, String>() {
    @Override
    public String convert(String in) {
      return removeTrailingSlash(in);
    }
  });
}
项目:intellij-ce-playground    文件:GitVcs.java   
@Override
public <S> List<S> filterUniqueRoots(final List<S> in, final Convertor<S, VirtualFile> convertor) {
  Collections.sort(in, new ComparatorDelegate<S, VirtualFile>(convertor, FilePathComparator.getInstance()));

  for (int i = 1; i < in.size(); i++) {
    final S sChild = in.get(i);
    final VirtualFile child = convertor.convert(sChild);
    final VirtualFile childRoot = GitUtil.gitRootOrNull(child);
    if (childRoot == null) {
      // non-git file actually, skip it
      continue;
    }
    for (int j = i - 1; j >= 0; --j) {
      final S sParent = in.get(j);
      final VirtualFile parent = convertor.convert(sParent);
      // the method check both that parent is an ancestor of the child and that they share common git root
      if (VfsUtilCore.isAncestor(parent, child, false) && VfsUtilCore.isAncestor(childRoot, parent, false)) {
        in.remove(i);
        //noinspection AssignmentToForLoopParameter
        --i;
        break;
      }
    }
  }
  return in;
}
项目:intellij-ce-playground    文件:GitOutgoingChangesProvider.java   
public Pair<VcsRevisionNumber, List<CommittedChangeList>> getOutgoingChanges(final VirtualFile vcsRoot, final boolean findRemote)
  throws VcsException {
  LOG.debug("getOutgoingChanges root: " + vcsRoot.getPath());
  final GitBranchesSearcher searcher = new GitBranchesSearcher(myProject, vcsRoot, findRemote);
  if (searcher.getLocal() == null || searcher.getRemote() == null) {
    return new Pair<VcsRevisionNumber, List<CommittedChangeList>>(null, Collections.<CommittedChangeList>emptyList());
  }
  final GitRevisionNumber base = getMergeBase(myProject, vcsRoot, searcher.getLocal(), searcher.getRemote());
  if (base == null) {
    return new Pair<VcsRevisionNumber, List<CommittedChangeList>>(null, Collections.<CommittedChangeList>emptyList());
  }
  final List<GitCommittedChangeList> lists = GitUtil.getLocalCommittedChanges(myProject, vcsRoot, new Consumer<GitSimpleHandler>() {
    public void consume(final GitSimpleHandler handler) {
      handler.addParameters(base.asString() + "..HEAD");
    }
  });
  return new Pair<VcsRevisionNumber, List<CommittedChangeList>>(base, ObjectsConvertor.convert(lists, new Convertor<GitCommittedChangeList, CommittedChangeList>() {
    @Override
    public CommittedChangeList convert(GitCommittedChangeList o) {
      return o;
    }
  }));
}
项目:intellij-ce-playground    文件:HgVcs.java   
@Override
public <S> List<S> filterUniqueRoots(final List<S> in, final Convertor<S, VirtualFile> convertor) {
  Collections.sort(in, new ComparatorDelegate<S, VirtualFile>(convertor, FilePathComparator.getInstance()));

  for (int i = 1; i < in.size(); i++) {
    final S sChild = in.get(i);
    final VirtualFile child = convertor.convert(sChild);
    final VirtualFile childRoot = HgUtil.getHgRootOrNull(myProject, child);
    if (childRoot == null) {
      continue;
    }
    for (int j = i - 1; j >= 0; --j) {
      final S sParent = in.get(j);
      final VirtualFile parent = convertor.convert(sParent);
      // if the parent is an ancestor of the child and that they share common root, the child is removed
      if (VfsUtilCore.isAncestor(parent, child, false) && VfsUtilCore.isAncestor(childRoot, parent, false)) {
        in.remove(i);
        //noinspection AssignmentToForLoopParameter
        --i;
        break;
      }
    }
  }
  return in;
}
项目:intellij-ce-playground    文件:LayoutTree.java   
@Override
protected void configureUiHelper(TreeUIHelper helper) {
  final Convertor<TreePath, String> convertor = new Convertor<TreePath, String>() {
    @Override
    public String convert(final TreePath path) {
      final SimpleNode node = getNodeFor(path);
      if (node instanceof PackagingElementNode) {
        return ((PackagingElementNode<?>)node).getElementPresentation().getSearchName();
      }
      return "";
    }
  };
  new TreeSpeedSearch(this, convertor, true);
}
项目:intellij-ce-playground    文件:FrameworksTree.java   
@Override
protected void installSpeedSearch() {
  new TreeSpeedSearch(this, new Convertor<TreePath, String>() {
    @Override
    public String convert(TreePath path) {
      final Object node = path.getLastPathComponent();
      if (node instanceof FrameworkSupportNodeBase) {
        return ((FrameworkSupportNodeBase)node).getTitle();
      }
      return "";
    }
  });
}
项目:intellij-ce-playground    文件:RemoteServerListConfigurable.java   
@Override
protected void initTree() {
  super.initTree();
  new TreeSpeedSearch(myTree, new Convertor<TreePath, String>() {
    @Override
    public String convert(final TreePath treePath) {
      return ((MyNode)treePath.getLastPathComponent()).getDisplayName();
    }
  }, true);
}
项目:intellij-ce-playground    文件:SettingsEditorWrapper.java   
public SettingsEditorWrapper(SettingsEditor<Dst> wrapped, Convertor<Src, Dst> convertor) {
  mySrcToDstConvertor = convertor;
  myWrapped = wrapped;
  myListener = new SettingsEditorListener<Dst>() {
    public void stateChanged(SettingsEditor<Dst> settingsEditor) {
      fireEditorStateChanged();
    }
  };
  myWrapped.addSettingsEditorListener(myListener);
}
项目:intellij-ce-playground    文件:VfsUtil.java   
public static void processFileRecursivelyWithoutIgnored(@NotNull final VirtualFile root, @NotNull final Processor<VirtualFile> processor) {
  final FileTypeManager ftm = FileTypeManager.getInstance();
  processFilesRecursively(root, processor, new Convertor<VirtualFile, Boolean>() {
    public Boolean convert(final VirtualFile vf) {
      return ! ftm.isFileIgnored(vf);
    }
  });
}
项目:intellij-ce-playground    文件:CoverageSuiteChooserDialog.java   
public CoverageSuiteChooserDialog(Project project) {
  super(project, true);
  myProject = project;
  myCoverageManager = CoverageDataManager.getInstance(project);

  myRootNode = new CheckedTreeNode("");
  initTree();
  mySuitesTree = new CheckboxTree(new SuitesRenderer(), myRootNode) {
    protected void installSpeedSearch() {
      new TreeSpeedSearch(this, new Convertor<TreePath, String>() {
        public String convert(TreePath path) {
          final DefaultMutableTreeNode component = (DefaultMutableTreeNode)path.getLastPathComponent();
          final Object userObject = component.getUserObject();
          if (userObject instanceof CoverageSuite) {
            return ((CoverageSuite)userObject).getPresentableName();
          }
          return userObject.toString();
        }
      });
    }
  };
  mySuitesTree.getEmptyText().appendText("No coverage suites configured.");
  mySuitesTree.setRootVisible(false);
  mySuitesTree.setShowsRootHandles(false);
  TreeUtil.installActions(mySuitesTree);
  TreeUtil.expandAll(mySuitesTree);
  TreeUtil.selectFirstNode(mySuitesTree);
  mySuitesTree.setMinimumSize(new Dimension(25, -1));
  setOKButtonText("Show selected");
  init();
  setTitle("Choose Coverage Suite to Display");
}
项目:intellij-ce-playground    文件:TodoForRanges.java   
public List<Pair<TextRange, TextAttributes>> execute() {
  final TodoItemData[] todoItems = getTodoItems();

  final StepIntersection<TodoItemData, TextRange> stepIntersection =
    new StepIntersection<TodoItemData, TextRange>(new Convertor<TodoItemData, TextRange>() {
      @Override
      public TextRange convert(TodoItemData o) {
        return o.getTextRange();
      }
    }, Convertor.SELF, myRanges, new Getter<String>() {
      @Override
      public String get() {
        return "";
      }
    }
    );
  final List<TodoItemData> filtered = stepIntersection.process(Arrays.asList(todoItems));
  final List<Pair<TextRange, TextAttributes>> result = new ArrayList<Pair<TextRange, TextAttributes>>(filtered.size());
  int offset = 0;
  for (TextRange range : myRanges) {
    Iterator<TodoItemData> iterator = filtered.iterator();
    while (iterator.hasNext()) {
      TodoItemData item = iterator.next();
      if (range.contains(item.getTextRange())) {
        TextRange todoRange = new TextRange(offset - range.getStartOffset() + item.getTextRange().getStartOffset(),
                                            offset - range.getStartOffset() + item.getTextRange().getEndOffset());
        result.add(Pair.create(todoRange, item.getPattern().getAttributes().getTextAttributes()));
        iterator.remove();
      } else {
        break;
      }
    }
    offset += range.getLength() + 1 + myAdditionalOffset;
  }
  return result;
}
项目:intellij-ce-playground    文件:MergePanel2.java   
public void setDiffRequest(DiffRequest data) {
  setTitle(data.getWindowTitle());
  disposeMergeList();
  for (int i = 0; i < EDITORS_COUNT; i++) {
    getEditorPlace(i).setDocument(null);
  }
  LOG.assertTrue(!myDuringCreation);
  myDuringCreation = true;
  myProvider.putData(data.getGenericData());
  try {
    myData = data;
    String[] titles = myData.getContentTitles();
    for (int i = 0; i < myEditorsPanels.length; i++) {
      LabeledComponent editorsPanel = myEditorsPanels[i];
      editorsPanel.getLabel().setText(titles[i].isEmpty() ? " " : titles[i]);
    }
    createMergeList();
    data.customizeToolbar(myPanel.resetToolbar());
    myPanel.registerToolbarActions();
    if ( data instanceof MergeRequestImpl && myBuilder != null){
      Convertor<DialogWrapper, Boolean> preOkHook = new Convertor<DialogWrapper, Boolean>() {
        @Override
        public Boolean convert(DialogWrapper dialog) {
          ChangeCounter counter = ChangeCounter.getOrCreate(myMergeList);
          int changes = counter.getChangeCounter();
          int conflicts = counter.getConflictCounter();
          if (changes == 0 && conflicts == 0) return true;
          return Messages.showYesNoDialog(dialog.getRootPane(),
                                          DiffBundle.message("merge.dialog.apply.partially.resolved.changes.confirmation.message", changes, conflicts),
                                          DiffBundle.message("apply.partially.resolved.merge.dialog.title"),
                                          Messages.getQuestionIcon()) == Messages.YES;
        }
      };
      ((MergeRequestImpl)data).setActions(myBuilder, this, preOkHook);
    }
  }
  finally {
    myDuringCreation = false;
  }
}
项目:intellij-ce-playground    文件:MergeRequestImpl.java   
public void setActions(final DialogBuilder builder, MergePanel2 mergePanel, final Convertor<DialogWrapper, Boolean> preOkHook) {
  builder.removeAllActions(); // otherwise dialog will get default actions (OK, Cancel)

  if (myOkButtonPresentation != null) {
    if (builder.getOkAction() == null) {
      builder.addOkAction();
    }

    configureAction(builder, builder.getOkAction(), myOkButtonPresentation);
    builder.setOkOperation(new Runnable() {
      @Override
      public void run() {
        if (preOkHook != null && !preOkHook.convert(builder.getDialogWrapper())) return;
        myOkButtonPresentation.run(builder.getDialogWrapper());
      }
    });
  }

  if (myCancelButtonPresentation != null) {
    if (builder.getCancelAction() == null) {
      builder.addCancelAction();
    }

    configureAction(builder, builder.getCancelAction(), myCancelButtonPresentation);
    builder.setCancelOperation(new Runnable() {
      @Override
      public void run() {
        myCancelButtonPresentation.run(builder.getDialogWrapper());
      }
    });
  }

  if (getMergeContent() != null && mergePanel.getMergeList() != null) {
    new AllResolvedListener(mergePanel, builder.getDialogWrapper());
  }
}
项目:intellij-ce-playground    文件:ListSpeedSearch.java   
public ListSpeedSearch(final JList component, final Function<Object, String> convertor) {
  this(component, new Convertor<Object, String>() {
    @Override
    public String convert(Object o) {
      return convertor.fun(o);
    }
  });
}
项目:intellij-ce-playground    文件:FileUtil.java   
/**
 * @param removeProcessor parent, child
 */
public static <T> Collection<T> removeAncestors(final Collection<T> files,
                                                final Convertor<T, String> convertor,
                                                final PairProcessor<T, T> removeProcessor) {
  if (files.isEmpty()) return files;
  final TreeMap<String, T> paths = new TreeMap<String, T>();
  for (T file : files) {
    final String path = convertor.convert(file);
    assert path != null;
    final String canonicalPath = toCanonicalPath(path);
    paths.put(canonicalPath, file);
  }
  final List<Map.Entry<String, T>> ordered = new ArrayList<Map.Entry<String, T>>(paths.entrySet());
  final List<T> result = new ArrayList<T>(ordered.size());
  result.add(ordered.get(0).getValue());
  for (int i = 1; i < ordered.size(); i++) {
    final Map.Entry<String, T> entry = ordered.get(i);
    final String child = entry.getKey();
    boolean parentNotFound = true;
    for (int j = i - 1; j >= 0; j--) {
      // possible parents
      final String parent = ordered.get(j).getKey();
      if (parent == null) continue;
      if (startsWith(child, parent) && removeProcessor.process(ordered.get(j).getValue(), entry.getValue())) {
        parentNotFound = false;
        break;
      }
    }
    if (parentNotFound) {
      result.add(entry.getValue());
    }
  }
  return result;
}
项目:intellij-ce-playground    文件:ObjectUtils.java   
@Nullable
public static <T, S> S doIfCast(@Nullable Object obj, @NotNull Class<T> clazz, final Convertor<T, S> convertor) {
  if (clazz.isInstance(obj)) {
    //noinspection unchecked
    return convertor.convert((T)obj);
  }
  return null;
}
项目:intellij-ce-playground    文件:FileUtilLightTest.java   
@Test
public void testRemoveAncestors() {
  List<String> data = Arrays.asList("/a/b/c", "/a", "/a/b", "/d/e", "/b/c", "/a/d", "/b/c/ttt", "/a/ewq.euq");
  String[] expected = {"/a","/b/c","/d/e"};
  @SuppressWarnings("unchecked") Collection<String> result = FileUtil.removeAncestors(data, Convertor.SELF, PairProcessor.TRUE);
  assertArrayEquals(expected, ArrayUtil.toStringArray(result));
}
项目:intellij-ce-playground    文件:IdeaTextPatchBuilder.java   
public static List<BeforeAfter<AirContentRevision>> revisionsConvertor(final Project project, final List<Change> changes) throws VcsException {
  final List<BeforeAfter<AirContentRevision>> result = new ArrayList<BeforeAfter<AirContentRevision>>(changes.size());

  final Convertor<Change, FilePath> beforePrefferingConvertor = new Convertor<Change, FilePath>() {
    public FilePath convert(Change o) {
      final FilePath before = ChangesUtil.getBeforePath(o);
      return before == null ? ChangesUtil.getAfterPath(o) : before;
    }
  };
  final MultiMap<VcsRoot,Change> byRoots = new SortByVcsRoots<Change>(project, beforePrefferingConvertor).sort(changes);

  for (VcsRoot root : byRoots.keySet()) {
    final Collection<Change> rootChanges = byRoots.get(root);
    if (root.getVcs() == null || root.getVcs().getOutgoingChangesProvider() == null) {
      addConvertChanges(rootChanges, result);
      continue;
    }
    final VcsOutgoingChangesProvider<?> provider = root.getVcs().getOutgoingChangesProvider();
    final Collection<Change> basedOnLocal = provider.filterLocalChangesBasedOnLocalCommits(rootChanges, root.getPath());
    rootChanges.removeAll(basedOnLocal);
    addConvertChanges(rootChanges, result);

    for (Change change : basedOnLocal) {
      // dates are here instead of numbers
      result.add(new BeforeAfter<AirContentRevision>(convertRevision(change.getBeforeRevision(), provider),
                                                     convertRevision(change.getAfterRevision(), provider)));
    }
  }
  return result;
}
项目:intellij-ce-playground    文件:TestTreeView.java   
protected void installHandlers() {
  EditSourceOnDoubleClickHandler.install(this);
  new TreeSpeedSearch(this, new Convertor<TreePath, String>() {
    public String convert(final TreePath path) {
      final AbstractTestProxy testProxy = getSelectedTest(path);
      if (testProxy == null) return null;
      return testProxy.getName();
    }
  });
  TreeUtil.installActions(this);
  PopupHandler.installPopupHandler(this, IdeActions.GROUP_TESTTREE_POPUP, ActionPlaces.TESTTREE_VIEW_POPUP);
}