Java Code Examples for com.intellij.util.containers.Convertor#convert()
The following examples show how to use
com.intellij.util.containers.Convertor#convert() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VfsUtilCore.java From consulo with Apache License 2.0 | 6 votes |
public static void processFilesRecursively(@Nonnull VirtualFile root, @Nonnull Processor<VirtualFile> processor, @Nonnull Convertor<VirtualFile, Boolean> directoryFilter) { if (!processor.process(root)) return; if (root.isDirectory() && directoryFilter.convert(root)) { final LinkedList<VirtualFile[]> queue = new LinkedList<VirtualFile[]>(); queue.add(root.getChildren()); do { final VirtualFile[] files = queue.removeFirst(); for (VirtualFile file : files) { if (!processor.process(file)) return; if (file.isDirectory() && directoryFilter.convert(file)) { queue.add(file.getChildren()); } } } while (!queue.isEmpty()); } }
Example 2
Source File: ObjectUtils.java From consulo with Apache License 2.0 | 5 votes |
@Nullable public static <T, S> S doIfCast(@Nullable Object obj, @Nonnull Class<T> clazz, final Convertor<T, S> convertor) { if (clazz.isInstance(obj)) { //noinspection unchecked return convertor.convert((T)obj); } return null; }
Example 3
Source File: ObjectUtil.java From consulo with Apache License 2.0 | 5 votes |
@Nullable public static <T, S> S doIfCast(@Nullable Object obj, @Nonnull Class<T> clazz, final Convertor<T, S> convertor) { if (clazz.isInstance(obj)) { //noinspection unchecked return convertor.convert((T)obj); } return null; }
Example 4
Source File: ObjectsConvertor.java From consulo with Apache License 2.0 | 5 votes |
public static <T,U, S extends U> List<S> convert(@Nonnull final Collection<T> in, final Convertor<T,S> convertor, @Nullable final NotNullFunction<U, Boolean> outFilter) { final List<S> out = new ArrayList<S>(); for (T t : in) { final S converted = convertor.convert(t); if ((outFilter != null) && (! Boolean.TRUE.equals(outFilter.fun(converted)))) continue; out.add(converted); } return out; }
Example 5
Source File: OptionsAndConfirmations.java From consulo with Apache License 2.0 | 5 votes |
private void restoreReadConfirm(final VcsConfiguration.StandardConfirmation confirm, final Convertor<String, VcsShowConfirmationOption.Value> initOptions) { final VcsShowConfirmationOption.Value initValue = initOptions.convert(confirm.getId()); if (initValue != null) { getConfirmation(confirm).setValue(initValue); } }
Example 6
Source File: ColumnFilteringStrategy.java From consulo with Apache License 2.0 | 5 votes |
public <T> void addNext(final Collection<T> values, final Convertor<T, String> convertor) { final TreeSet<String> set = new TreeSet<String>(Arrays.asList(myValues)); for (T value : values) { final String converted = convertor.convert(value); if (converted != null) { // also works as filter set.add(converted); } } myValues = ArrayUtil.toStringArray(set); fireContentsChanged(this, 0, myValues.length); }
Example 7
Source File: TreeModelBuilder.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull protected ChangesBrowserNode getParentNodeFor(@Nonnull StaticFilePath nodePath, @Nonnull ChangesBrowserNode subtreeRoot, @Nonnull Convertor<StaticFilePath, ChangesBrowserNode> nodeBuilder) { if (myShowFlatten) { return subtreeRoot; } ChangesGroupingPolicy policy = myGroupingPoliciesCache.get(subtreeRoot); if (policy != null) { ChangesBrowserNode nodeFromPolicy = policy.getParentNodeFor(nodePath, subtreeRoot); if (nodeFromPolicy != null) { return nodeFromPolicy; } } StaticFilePath parentPath = nodePath.getParent(); while (parentPath != null) { ChangesBrowserNode oldParentNode = getFolderCache(subtreeRoot).get(parentPath.getKey()); if (oldParentNode != null) return oldParentNode; ChangesBrowserNode parentNode = nodeBuilder.convert(parentPath); if (parentNode != null) { ChangesBrowserNode grandPa = getParentNodeFor(parentPath, subtreeRoot, nodeBuilder); myModel.insertNodeInto(parentNode, grandPa, grandPa.getChildCount()); getFolderCache(subtreeRoot).put(parentPath.getKey(), parentNode); return parentNode; } parentPath = parentPath.getParent(); } return subtreeRoot; }
Example 8
Source File: FavoritesManager.java From consulo with Apache License 2.0 | 5 votes |
private <T> boolean findListToRemoveFrom(@Nonnull String name, @Nonnull final List<T> elements, final Convertor<T, AbstractUrl> convertor) { Collection<TreeItem<Pair<AbstractUrl, String>>> list = getFavoritesListRootUrls(name); if (elements.size() > 1) { final List<T> sublist = elements.subList(0, elements.size() - 1); for (T obj : sublist) { AbstractUrl objUrl = convertor.convert(obj); final TreeItem<Pair<AbstractUrl, String>> item = findNextItem(objUrl, list); if (item == null || item.getChildren() == null) return false; list = item.getChildren(); } } TreeItem<Pair<AbstractUrl, String>> found = null; AbstractUrl url = convertor.convert(elements.get(elements.size() - 1)); if (url == null) return false; for (TreeItem<Pair<AbstractUrl, String>> pair : list) { if (url.equals(pair.getData().getFirst())) { found = pair; break; } } if (found != null) { list.remove(found); rootsChanged(); return true; } return false; }
Example 9
Source File: TableSpeedSearch.java From consulo with Apache License 2.0 | 4 votes |
public TableSpeedSearch(JTable table, final Convertor<Object, String> toStringConvertor) { this(table, (o, c) -> toStringConvertor.convert(o)); }