當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。