Java Code Examples for com.intellij.util.containers.ContainerUtil#exists()

The following examples show how to use com.intellij.util.containers.ContainerUtil#exists() . 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: ApplyPatchMergeTool.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected void onChangeResolved() {
  super.onChangeResolved();

  if (!ContainerUtil.exists(getModelChanges(), (c) -> !c.isResolved())) {
    ApplicationManager.getApplication().invokeLater(() -> {
      if (isDisposed()) return;

      JComponent component = getComponent();
      int yOffset = new RelativePoint(getResultEditor().getComponent(), new Point(0, JBUI.scale(5))).getPoint(component).y;
      RelativePoint point = new RelativePoint(component, new Point(component.getWidth() / 2, yOffset));

      String message = DiffBundle.message("apply.patch.all.changes.processed.message.text");
      DiffUtil.showSuccessPopup(message, point, this, () -> {
        if (isDisposed()) return;
        myMergeContext.finishMerge(MergeResult.RESOLVED);
      });
    });
  }
}
 
Example 2
Source File: VcsLogUserFilterImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public boolean matches(@Nonnull final VcsCommitMetadata commit) {
  return ContainerUtil.exists(myUsers, name -> {
    Set<VcsUser> users = getUsers(commit.getRoot(), name);
    if (!users.isEmpty()) {
      return users.contains(commit.getAuthor());
    }
    else if (!name.equals(ME)) {
      String lowerUser = VcsUserUtil.nameToLowerCase(name);
      boolean result = VcsUserUtil.nameToLowerCase(commit.getAuthor().getName()).equals(lowerUser) ||
                       VcsUserUtil.emailToLowerCase(commit.getAuthor().getEmail()).startsWith(lowerUser + "@");
      if (result) {
        LOG.warn("Unregistered author " + commit.getAuthor() + " for commit " + commit.getId().asString() + "; search pattern " + name);
      }
      return result;
    }
    return false;
  });
}
 
Example 3
Source File: FileBasedIndexImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
@Nonnull
public AsyncFileListener.ChangeApplier prepareChange(@Nonnull List<? extends VFileEvent> events) {
  boolean shouldCleanup = ContainerUtil.exists(events, ChangedFilesCollector::memoryStorageCleaningNeeded);
  ChangeApplier superApplier = super.prepareChange(events);

  return new AsyncFileListener.ChangeApplier() {
    @Override
    public void beforeVfsChange() {
      if (shouldCleanup) {
        myManager.cleanupMemoryStorage(false);
      }
      superApplier.beforeVfsChange();
    }

    @Override
    public void afterVfsChange() {
      superApplier.afterVfsChange();
      if (myManager.myInitialized) ensureUpToDateAsync();
    }
  };
}
 
Example 4
Source File: DiffUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
public static List<JComponent> createSimpleTitles(@Nonnull ContentDiffRequest request) {
  List<DiffContent> contents = request.getContents();
  List<String> titles = request.getContentTitles();

  if (!ContainerUtil.exists(titles, Condition.NOT_NULL)) {
    return Collections.nCopies(titles.size(), null);
  }

  List<JComponent> components = new ArrayList<>(titles.size());
  for (int i = 0; i < contents.size(); i++) {
    JComponent title = createTitle(StringUtil.notNullize(titles.get(i)));
    title = createTitleWithNotifications(title, contents.get(i));
    components.add(title);
  }

  return components;
}
 
Example 5
Source File: PushController.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
private static PushTarget getCommonTarget(@Nonnull Collection<MyRepoModel<?, ?, ?>> selectedNodes) {
  final PushTarget commonTarget = ObjectUtils.assertNotNull(ContainerUtil.getFirstItem(selectedNodes)).getTarget();
  return commonTarget != null && !ContainerUtil.exists(selectedNodes, new Condition<MyRepoModel<?, ?, ?>>() {
    @Override
    public boolean value(MyRepoModel model) {
      return !commonTarget.equals(model.getTarget());
    }
  }) ? commonTarget : null;
}
 
Example 6
Source File: AnnotateVcsVirtualFileAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static boolean isAnnotated(AnActionEvent e) {
  Project project = e.getRequiredData(CommonDataKeys.PROJECT);
  VirtualFile file = e.getRequiredData(CommonDataKeys.VIRTUAL_FILE_ARRAY)[0];
  List<Editor> editors = VcsAnnotateUtil.getEditors(project, file);
  return ContainerUtil.exists(editors, new Condition<Editor>() {
    @Override
    public boolean value(Editor editor) {
      return editor.getGutter().isAnnotationsShown();
    }
  });
}
 
Example 7
Source File: PushController.java    From consulo with Apache License 2.0 5 votes vote down vote up
private boolean hasSomethingToPush(Collection<RepositoryNode> nodes) {
  return ContainerUtil.exists(nodes, new Condition<RepositoryNode>() {
    @Override
    public boolean value(@Nonnull RepositoryNode node) {
      PushTarget target = myView2Model.get(node).getTarget();
      //if node is selected target should not be null
      return node.isChecked() && target != null && target.hasSomethingToPush();
    }
  });
}
 
Example 8
Source File: DiffUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static List<JComponent> createSyncHeightComponents(@Nonnull final List<JComponent> components) {
  if (!ContainerUtil.exists(components, Condition.NOT_NULL)) return components;
  List<JComponent> result = new ArrayList<>();
  for (int i = 0; i < components.size(); i++) {
    result.add(new SyncHeightComponent(components, i));
  }
  return result;
}
 
Example 9
Source File: PushController.java    From consulo with Apache License 2.0 5 votes vote down vote up
private boolean containedInOtherNames(@Nonnull final Repository except, final String candidate) {
  return ContainerUtil.exists(myGlobalRepositoryManager.getRepositories(), new Condition<Repository>() {
    @Override
    public boolean value(Repository repository) {
      return !repository.equals(except) && repository.getRoot().getName().equals(candidate);
    }
  });
}
 
Example 10
Source File: PushController.java    From consulo with Apache License 2.0 5 votes vote down vote up
private boolean hasCheckedNodesWithContent(@Nonnull Collection<RepositoryNode> nodes, final boolean withRefs) {
  return ContainerUtil.exists(nodes, new Condition<RepositoryNode>() {
    @Override
    public boolean value(@Nonnull RepositoryNode node) {
      return node.isChecked() && (withRefs || !myView2Model.get(node).getLoadedCommits().isEmpty());
    }
  });
}
 
Example 11
Source File: PantsScalaUtil.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
public static boolean isScalaLib(final String libraryId) {
  return ContainerUtil.exists(
    scalaLibsToAdd,
    new Condition<String>() {
      @Override
      public boolean value(String libName) {
        return StringUtil.startsWith(libraryId, getFullScalaLibId(libName));
      }
    }
  );
}
 
Example 12
Source File: PushController.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static boolean hasLoadingNodes(@Nonnull Collection<RepositoryNode> nodes) {
  return ContainerUtil.exists(nodes, new Condition<RepositoryNode>() {
    @Override
    public boolean value(@Nonnull RepositoryNode node) {
      return node.isLoading();
    }
  });
}
 
Example 13
Source File: RollbackChangesDialog.java    From consulo with Apache License 2.0 4 votes vote down vote up
public RollbackChangesDialog(final Project project,
                             final List<LocalChangeList> changeLists,
                             final List<Change> changes,
                             final boolean refreshSynchronously, final Runnable afterVcsRefreshInAwt) {
  super(project, true);

  myProject = project;
  myRefreshSynchronously = refreshSynchronously;
  myAfterVcsRefreshInAwt = afterVcsRefreshInAwt;
  myInvokedFromModalContext = LaterInvocator.isInModalContext();

  myInfoCalculator = new ChangeInfoCalculator();
  myCommitLegendPanel = new CommitLegendPanel(myInfoCalculator);
  myListChangeListener = new Runnable() {
    @Override
    public void run() {
      if (myBrowser != null) {
        // We could not utilize "myBrowser.getViewer().getChanges()" here (to get all changes) as currently it is not recursive.
        List<Change> allChanges = getAllChanges(changeLists);
        Collection<Change> includedChanges = myBrowser.getViewer().getIncludedChanges();

        myInfoCalculator.update(allChanges, ContainerUtil.newArrayList(includedChanges));
        myCommitLegendPanel.update();

        boolean hasNewFiles = ContainerUtil.exists(includedChanges, new Condition<Change>() {
          @Override
          public boolean value(Change change) {
            return change.getType() == Change.Type.NEW;
          }
        });
        myDeleteLocallyAddedFiles.setEnabled(hasNewFiles);
      }
    }
  };
  myBrowser =
          new ChangesBrowser(project, changeLists, changes, null, true, true, myListChangeListener, ChangesBrowser.MyUseCase.LOCAL_CHANGES,
                             null) {
            @Nonnull
            @Override
            protected DefaultTreeModel buildTreeModel(List<Change> changes, ChangeNodeDecorator changeNodeDecorator, boolean showFlatten) {
              TreeModelBuilder builder = new TreeModelBuilder(myProject, showFlatten);
              // Currently we do not explicitly utilize passed "changeNodeDecorator" instance (which is defined by
              // "ChangesBrowser.MyUseCase.LOCAL_CHANGES" parameter passed to "ChangesBrowser"). But correct node decorator will still be set
              // in "TreeModelBuilder.setChangeLists()".
              return builder.setChangeLists(changeLists).build();
            }
          };
  Disposer.register(getDisposable(), myBrowser);

  myOperationName = operationNameByChanges(project, getAllChanges(changeLists));
  setOKButtonText(myOperationName);

  myOperationName = UIUtil.removeMnemonic(myOperationName);
  setTitle(VcsBundle.message("changes.action.rollback.custom.title", myOperationName));
  setCancelButtonText(CommonBundle.getCloseButtonText());
  myBrowser.setToggleActionTitle("&Include in " + myOperationName.toLowerCase());

  myDeleteLocallyAddedFiles = new JCheckBox(VcsBundle.message("changes.checkbox.delete.locally.added.files"));
  myDeleteLocallyAddedFiles.setSelected(PropertiesComponent.getInstance().isTrueValue(DELETE_LOCALLY_ADDED_FILES_KEY));
  myDeleteLocallyAddedFiles.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      PropertiesComponent.getInstance().setValue(DELETE_LOCALLY_ADDED_FILES_KEY, myDeleteLocallyAddedFiles.isSelected());
    }
  });

  init();
  myListChangeListener.run();
}
 
Example 14
Source File: ExternalProjectUtil.java    From intellij-pants-plugin with Apache License 2.0 4 votes vote down vote up
public static boolean isExternalProject(@NotNull Project project, ProjectSystemId id) {
  return ContainerUtil.exists(
    ModuleManager.getInstance(project).getModules(),
    module -> isExternalModule(module, id)
  );
}
 
Example 15
Source File: GotoFileItemProvider.java    From consulo with Apache License 2.0 4 votes vote down vote up
private boolean hasSuggestionsOutsideProject(@Nonnull String pattern, @Nonnull List<List<MatchResult>> groups, @Nonnull DirectoryPathMatcher dirMatcher) {
  return ContainerUtil.exists(groups, group -> !getFilesMatchingPath(FindSymbolParameters.wrap(pattern, myProject, true), group, dirMatcher, indicator).isEmpty());
}
 
Example 16
Source File: LocalHistoryUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
static boolean isLabelRevision(@Nonnull RevisionItem rev, @Nonnull LabelImpl label) {
  final long targetChangeId = label.getLabelChangeId();
  return ContainerUtil.exists(rev.labels, revision -> isChangeWithId(revision, targetChangeId));
}
 
Example 17
Source File: ProgressManagerImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean hasUnsafeProgressIndicator() {
  return super.hasUnsafeProgressIndicator() || ContainerUtil.exists(getCurrentIndicators(), ProgressManagerImpl::isUnsafeIndicator);
}
 
Example 18
Source File: RemoveChangeListAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static boolean containsActiveChangelist(@javax.annotation.Nullable ChangeList[] changeLists) {
  if (changeLists == null) return false;
  return ContainerUtil.exists(changeLists, l -> l instanceof LocalChangeList && ((LocalChangeList)l).isDefault());
}
 
Example 19
Source File: ChangeListManagerImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isIgnoredFile(@Nonnull VirtualFile file) {
  FilePath filePath = VcsUtil.getFilePath(file);
  return ContainerUtil.exists(IgnoredFileProvider.IGNORE_FILE.getExtensionList(), it -> it.isIgnoredFile(myProject, filePath));
}
 
Example 20
Source File: FileTrees.java    From consulo with Apache License 2.0 4 votes vote down vote up
private boolean hasCachedPsi() {
  Reference<StubBasedPsiElementBase>[] refToPsi = myRefToPsi;
  return refToPsi != null && ContainerUtil.exists(refToPsi, ref -> SoftReference.dereference(ref) != null);
}