当前位置: 首页>>代码示例>>Java>>正文


Java Consumer类代码示例

本文整理汇总了Java中com.intellij.util.Consumer的典型用法代码示例。如果您正苦于以下问题:Java Consumer类的具体用法?Java Consumer怎么用?Java Consumer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Consumer类属于com.intellij.util包,在下文中一共展示了Consumer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createSdkOfType

import com.intellij.util.Consumer; //导入依赖的package包/类
protected static Sdk createSdkOfType(final SdkModel sdkModel,
                                final SdkType sdkType,
                                final Consumer<Sdk> sdkCreatedCallback) {
  final Ref<Sdk> result = new Ref<Sdk>(null);
  SdkConfigurationUtil.selectSdkHome(sdkType, new Consumer<String>() {
    @Override
    public void consume(final String home) {
      String newSdkName = SdkConfigurationUtil.createUniqueSdkName(sdkType, home, Arrays.asList(sdkModel.getSdks()));
      final ProjectJdkImpl newJdk = new ProjectJdkImpl(newSdkName, sdkType);
      newJdk.setHomePath(home);

      sdkCreatedCallback.consume(newJdk);
      result.set(newJdk);
    }
  });
  return result.get();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:DependentSdkType.java

示例2: createMergeRequest

import com.intellij.util.Consumer; //导入依赖的package包/类
@NotNull
public static MergeRequest createMergeRequest(@Nullable Project project,
                                              @NotNull Document document,
                                              @Nullable VirtualFile file,
                                              @NotNull List<String> contents,
                                              @Nullable String windowTitle,
                                              @NotNull List<String> titles,
                                              @Nullable Consumer<MergeResult> callback)
  throws InvalidDiffRequestException {
  assert contents.size() == 3;
  assert titles.size() == 3;

  if (windowTitle == null) windowTitle = getPatchTitle(file);

  String localTitle = StringUtil.notNullize(titles.get(0), VcsBundle.message("patch.apply.conflict.local.version"));
  String baseTitle = StringUtil.notNullize(titles.get(1), VcsBundle.message("patch.apply.conflict.merged.version"));
  String patchedTitle = StringUtil.notNullize(titles.get(2), VcsBundle.message("patch.apply.conflict.patched.version"));

  List<String> actualTitles = ContainerUtil.list(localTitle, baseTitle, patchedTitle);

  FileType fileType = file != null ? file.getFileType() : null;
  return DiffRequestFactory.getInstance().createMergeRequest(project, fileType, document, contents, windowTitle, actualTitles, callback);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:PatchDiffRequestFactory.java

示例3: readAllHashes

import com.intellij.util.Consumer; //导入依赖的package包/类
@NotNull
@Override
public LogData readAllHashes(@NotNull VirtualFile root, @NotNull Consumer<TimedVcsCommit> commitConsumer) throws VcsException {
  LOG.debug("readAllHashes");
  try {
    myFullLogSemaphore.acquire();
  }
  catch (InterruptedException e) {
    throw new RuntimeException(e);
  }
  LOG.debug("readAllHashes passed the semaphore");
  assertRoot(root);
  for (TimedVcsCommit commit : myCommits) {
    commitConsumer.consume(commit);
  }
  return new LogDataImpl(myRefs, Collections.<VcsUser>emptySet());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:TestVcsLogProvider.java

示例4: showNotify

import com.intellij.util.Consumer; //导入依赖的package包/类
public final void showNotify() {
  if (myWasEverShown) return;

  try {
    findParentDisposable().doWhenDone(new Consumer<Disposable>() {
      public void consume(Disposable parent) {
        Project project = null;
        if (ApplicationManager.getApplication() != null) {
          project = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext());
        }
        initialize(parent, myChild, project);
        Disposer.register(parent, myChild);
      }
    });
  }
  finally {
    myWasEverShown = true;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:LazyUiDisposable.java

示例5: getOutgoingChanges

import com.intellij.util.Consumer; //导入依赖的package包/类
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;
    }
  }));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:GitOutgoingChangesProvider.java

示例6: showLocalCommit

import com.intellij.util.Consumer; //导入依赖的package包/类
private void showLocalCommit() {
  final Collection<FilePath> files = gatherChangedPaths();

  // for changes to be detected, we need switch to background change list manager update thread and back to dispatch thread
  // so callback is used; ok to be called after VCS update markup closed: no remote operations
  final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
  changeListManager.invokeAfterUpdate(new Runnable() {
    public void run() {
      Collection<Change> changes = new ArrayList<Change>();
      for (FilePath file : files) {
        ContainerUtil.addIfNotNull(changes, changeListManager.getChange(file));
      }

      CommitChangeListDialog.commitChanges(myProject, changes, null, null, myMerger.getComment());
      prepareAndShowResults();
    }
  }, InvokeAfterUpdateMode.SYNCHRONOUS_CANCELLABLE, myTitle,
    new Consumer<VcsDirtyScopeManager>() {
      public void consume(final VcsDirtyScopeManager vcsDirtyScopeManager) {
        vcsDirtyScopeManager.filePathsDirty(files, null);
      }
    }, null);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:SvnIntegrateChangesTask.java

示例7: getClickConsumer

import com.intellij.util.Consumer; //导入依赖的package包/类
public Consumer<MouseEvent> getClickConsumer() {
  return new Consumer<MouseEvent>() {
    public void consume(MouseEvent mouseEvent) {
      final Project project = getProject();
      if (project == null) return;
      final Editor editor = getEditor();
      if (editor == null) return;
      final CommandProcessor processor = CommandProcessor.getInstance();
      processor.executeCommand(
        project, new Runnable() {
          public void run() {
            final GotoLineNumberDialog dialog = new GotoLineNumberDialog(project, editor);
            dialog.show();
            IdeDocumentHistory.getInstance(project).includeCurrentCommandAsNavigation();
          }
        },
        UIBundle.message("go.to.line.command.name"),
        null
      );
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:PositionPanel.java

示例8: getClickConsumer

import com.intellij.util.Consumer; //导入依赖的package包/类
@Override
public Consumer<MouseEvent> getClickConsumer() {
  return new Consumer<MouseEvent>() {
    @Override
    public void consume(final MouseEvent e) {
      Point point = new Point(0, 0);
      final PsiFile file = getCurrentFile();
      if (file != null) {
        if (!DaemonCodeAnalyzer.getInstance(file.getProject()).isHighlightingAvailable(file)) return;
        final HectorComponent component = new HectorComponent(file);
        final Dimension dimension = component.getPreferredSize();
        point = new Point(point.x - dimension.width, point.y - dimension.height);
        component.showComponent(new RelativePoint(e.getComponent(), point));
      }
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:TogglePopupHintsPanel.java

示例9: actionPerformed

import com.intellij.util.Consumer; //导入依赖的package包/类
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
  final Project project = e.getProject();
  final boolean showFiles = project != null || PlatformProjectOpenProcessor.getInstanceIfItExists() != null;
  final FileChooserDescriptor descriptor = showFiles ? new ProjectOrFileChooserDescriptor() : new ProjectOnlyFileChooserDescriptor();
  descriptor.putUserData(PathChooserDialog.PREFER_LAST_OVER_EXPLICIT, showFiles);

  FileChooser.chooseFiles(descriptor, project, VfsUtil.getUserHomeDir(), new Consumer<List<VirtualFile>>() {
    @Override
    public void consume(final List<VirtualFile> files) {
      for (VirtualFile file : files) {
        if (!descriptor.isFileSelectable(file)) {
          String message = IdeBundle.message("error.dir.contains.no.project", file.getPresentableUrl());
          Messages.showInfoMessage(project, message, IdeBundle.message("title.cannot.open.project"));
          return;
        }
      }
      doOpenFile(project, files);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:OpenFileAction.java

示例10: addListMultipleSelectionListener

import com.intellij.util.Consumer; //导入依赖的package包/类
public void addListMultipleSelectionListener(final @NotNull Consumer<List<Change>> listener) {
  myTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(final ListSelectionEvent e) {
      List<GitCommit> commits = myTable.getSelectedObjects();

      final List<Change> changes = new ArrayList<Change>();
      // We need changes in asc order for zipChanges, and they are in desc order in Table
      ListIterator<GitCommit> iterator = commits.listIterator(commits.size());
      while (iterator.hasPrevious()) {
        changes.addAll(iterator.previous().getChanges());
      }

      listener.consume(CommittedChangesTreeBrowser.zipChanges(changes));
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:GitCommitListPanel.java

示例11: getFacade

import com.intellij.util.Consumer; //导入依赖的package包/类
/**
 * @return gradle api facade to use
 * @throws Exception    in case of inability to return the facade
 */
@NotNull
public RemoteExternalSystemFacade getFacade(@Nullable Project project,
                                            @NotNull String externalProjectPath,
                                            @NotNull ProjectSystemId externalSystemId) throws Exception
{
  if (project == null) {
    project = ProjectManager.getInstance().getDefaultProject();
  }
  IntegrationKey key = new IntegrationKey(project, externalSystemId, externalProjectPath);
  final RemoteExternalSystemFacade facade = myFacadeWrappers.get(key);
  if (facade == null) {
    final RemoteExternalSystemFacade newFacade = (RemoteExternalSystemFacade)Proxy.newProxyInstance(
      ExternalSystemFacadeManager.class.getClassLoader(), new Class[]{RemoteExternalSystemFacade.class, Consumer.class},
      new MyHandler(key)
    );
    myFacadeWrappers.putIfAbsent(key, newFacade);
  }
  return myFacadeWrappers.get(key);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:ExternalSystemFacadeManager.java

示例12: wrapAsVoid

import com.intellij.util.Consumer; //导入依赖的package包/类
@NotNull
public static Promise<Void> wrapAsVoid(@NotNull ActionCallback asyncResult) {
  final AsyncPromise<Void> promise = new AsyncPromise<Void>();
  asyncResult.doWhenDone(new Runnable() {
    @Override
    public void run() {
      promise.setResult(null);
    }
  }).doWhenRejected(new Consumer<String>() {
    @Override
    public void consume(String error) {
      promise.setError(createError(error == null ? "Internal error" : error));
    }
  });
  return promise;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:Promise.java

示例13: createContentEntry

import com.intellij.util.Consumer; //导入依赖的package包/类
protected void createContentEntry(@NotNull final Module module, @NotNull final VirtualFile srcRoot) {
  updateModel(module, new Consumer<ModifiableRootModel>() {
    @Override
    public void consume(ModifiableRootModel model) {
      Sdk sdk = getSdk();
      if (sdk != null) {
        model.setSdk(sdk);
      }

      ContentEntry contentEntry = model.addContentEntry(srcRoot);
      contentEntry.addSourceFolder(srcRoot, false);

      configureModule(module, model, contentEntry);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:LightProjectDescriptor.java

示例14: updateAuxModuleStructure

import com.intellij.util.Consumer; //导入依赖的package包/类
public static void updateAuxModuleStructure(Module auxModule, Collection<VirtualFile> pluginDirs, MvcFramework framework) {
  final MvcProjectStructure structure = framework.createProjectStructure(auxModule, true);
  final List<Consumer<ModifiableRootModel>> actions = getUpdateProjectStructureActions(pluginDirs, structure);
  for (final ContentEntry root : ModuleRootManager.getInstance(auxModule).getContentEntries()) {
    if (!pluginDirs.contains(root.getFile())) {
      actions.add(removeStaleContentEntries(pluginDirs));
      break;
    }
  }

  if (!actions.isEmpty()) {
    actions.add(exportDefaultLibrary(structure.getUserLibraryName()));
  }

  if (!actions.isEmpty()) {
    final ModifiableRootModel model = ModuleRootManager.getInstance(auxModule).getModifiableModel();
    for (final Consumer<ModifiableRootModel> pluginsUpdateAction : actions) {
      pluginsUpdateAction.consume(model);
    }
    model.commit();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:MvcModuleStructureUtil.java

示例15: getVariantsFromContributors

import com.intellij.util.Consumer; //导入依赖的package包/类
/**
 * Run all contributors until any of them returns false or the list is exhausted. If from parameter is not null, contributors
 * will be run starting from the next one after that.
 * @param parameters
 * @param from
 * @param consumer
 * @return
 */
public void getVariantsFromContributors(final CompletionParameters parameters,
                                        @Nullable final CompletionContributor from,
                                        final Consumer<CompletionResult> consumer) {
  final List<CompletionContributor> contributors = CompletionContributor.forParameters(parameters);

  for (int i = contributors.indexOf(from) + 1; i < contributors.size(); i++) {
    final CompletionContributor contributor = contributors.get(i);

    final CompletionResultSet result = createResultSet(parameters, consumer, contributor);
    contributor.fillCompletionVariants(parameters, result);
    if (result.isStopped()) {
      return;
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:CompletionService.java


注:本文中的com.intellij.util.Consumer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。