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


Java Pair.create方法代码示例

本文整理汇总了Java中com.intellij.openapi.util.Pair.create方法的典型用法代码示例。如果您正苦于以下问题:Java Pair.create方法的具体用法?Java Pair.create怎么用?Java Pair.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.util.Pair的用法示例。


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

示例1: countProgressAsOneTaskWithSubtasks

import com.intellij.openapi.util.Pair; //导入方法依赖的package包/类
/**
 * Counts current progress for course which consists of only on task with subtasks
 * In this case we count each subtasks as task
 * @return Pair (number of solved tasks, number of tasks) or null if lessons can't be interpreted as one task with subtasks
 */
@Nullable
private static Pair<Integer, Integer> countProgressAsOneTaskWithSubtasks(List<Lesson> lessons) {
  if (lessons.size() == 1 && lessons.get(0).getTaskList().size() == 1) {
    final Lesson lesson = lessons.get(0);
    final Task task = lesson.getTaskList().get(0);
    if (task instanceof TaskWithSubtasks) {
      final int lastSubtaskIndex = ((TaskWithSubtasks)task).getLastSubtaskIndex();
      final int activeSubtaskIndex = ((TaskWithSubtasks)task).getActiveSubtaskIndex();
      int taskNum = lastSubtaskIndex + 1;
      boolean isLastSubtaskSolved = activeSubtaskIndex == lastSubtaskIndex && task.getStatus() == StudyStatus.Solved;
      return Pair.create(isLastSubtaskSolved ? taskNum : activeSubtaskIndex, taskNum);
    }
  }
  return null;
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:21,代码来源:StudyToolWindow.java

示例2: onDownload

import com.intellij.openapi.util.Pair; //导入方法依赖的package包/类
@Override
public Pair<Boolean, List<File>> onDownload(@NotNull ClassEntity[] classEntities, @NotNull File outputFolder) {
    String newUrl = null;
    try {
        newUrl = androidOnlineSearch(classEntities[0]);
    } catch (ConnectException | UnknownHostException e1) {
        if (timeoutListener != null) {
            timeoutListener.run();
        }
    } catch (Exception e) {
        Log.e(e);
    }
    if (!Utils.isEmpty(newUrl)) {
        for (ClassEntity entity : classEntities) {
            entity.setDownloadUrl(newUrl);
        }
        Log.debug("SearchDownload => " + newUrl);
        return new XrefDownload().onDownload(classEntities, outputFolder);
    }
    return Pair.create(false, Collections.<File>emptyList());
}
 
开发者ID:pengwei1024,项目名称:AndroidSourceViewer,代码行数:22,代码来源:SearchDownload.java

示例3: findOrCreatePredecessorPass

import com.intellij.openapi.util.Pair; //导入方法依赖的package包/类
private ScheduledPass findOrCreatePredecessorPass(@NotNull FileEditor fileEditor,
                                                  @NotNull Map<Pair<FileEditor, Integer>, ScheduledPass> toBeSubmitted,
                                                  @NotNull List<TextEditorHighlightingPass> textEditorHighlightingPasses,
                                                  @NotNull List<ScheduledPass> freePasses,
                                                  @NotNull List<ScheduledPass> dependentPasses,
                                                  @NotNull DaemonProgressIndicator updateProgress,
                                                  @NotNull AtomicInteger myThreadsToStartCountdown,
                                                  final int predecessorId) {
  Pair<FileEditor, Integer> predKey = Pair.create(fileEditor, predecessorId);
  ScheduledPass predecessor = toBeSubmitted.get(predKey);
  if (predecessor == null) {
    TextEditorHighlightingPass textEditorPass = findPassById(predecessorId, textEditorHighlightingPasses);
    predecessor = textEditorPass == null ? null : createScheduledPass(fileEditor, textEditorPass, toBeSubmitted, textEditorHighlightingPasses, freePasses,
                                                                      dependentPasses, updateProgress, myThreadsToStartCountdown);
  }
  return predecessor;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PassExecutorService.java

示例4: getCellRendererAndBounds

import com.intellij.openapi.util.Pair; //导入方法依赖的package包/类
@Override
protected Pair<Component, Rectangle> getCellRendererAndBounds(Integer key) {
  int rowIndex = key.intValue();

  TreePath path = myComponent.getPathForRow(rowIndex);
  if (path == null) return null;

  Rectangle bounds = myComponent.getPathBounds(path);
  if (bounds == null) return null;

  TreeCellRenderer renderer = myComponent.getCellRenderer();
  if (renderer == null) return null;

  Object node = path.getLastPathComponent();
  Component rendererComponent = renderer.getTreeCellRendererComponent(
    myComponent,
    node,
    myComponent.isRowSelected(rowIndex),
    myComponent.isExpanded(rowIndex),
    myComponent.getModel().isLeaf(node),
    rowIndex,
    myComponent.hasFocus()
  );
  return Pair.create(rendererComponent, bounds);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:TreeExpandableItemsHandler.java

示例5: computeOptimalShape

import com.intellij.openapi.util.Pair; //导入方法依赖的package包/类
private Pair<Integer, Integer> computeOptimalShape(int availableWidth, int availableHeight, int count) {
  double aspect = pickAspectRatio();
  int bestColumns = 1;
  int bestRows = count;
  int bestSize = 0;
  for (int columns = 1; columns <= count; columns++) {
    int rows = count / columns;
    if (count % columns > 0) {
      rows++;
    }
    int width = (availableWidth - HORIZONTAL_GAP * (columns - 1)) / columns;
    int height = (int)(width / aspect);
    int requiredHeight = height * rows + VERTICAL_GAP * (rows - 1) + TITLE_HEIGHT * rows;
    if (requiredHeight > availableHeight) {
      height = (availableHeight - VERTICAL_GAP * (rows - 1) - TITLE_HEIGHT * rows) / rows;
      width = (int)(height * aspect);
    }

    if (width > bestSize) {
      bestSize = width;
      bestColumns = columns;
      bestRows = rows;
    }
  }
  return Pair.create(bestRows, bestColumns);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:PreviewTileLayout.java

示例6: supportsRunningLibraryProjects

import com.intellij.openapi.util.Pair; //导入方法依赖的package包/类
@Override
protected Pair<Boolean, String> supportsRunningLibraryProjects(@NotNull AndroidFacet facet) {
  if (!facet.isGradleProject()) {
    // Non Gradle projects always require an application
    return Pair.create(Boolean.FALSE, AndroidBundle.message("android.cannot.run.library.project.error"));
  }

  final IdeaAndroidProject project = facet.getIdeaAndroidProject();
  if (project == null) {
    return Pair.create(Boolean.FALSE, AndroidBundle.message("android.cannot.run.library.project.error"));
  }

  // Gradle only supports testing against a single build type (which could be anything, but is "debug" build type by default)
  // Currently, the only information the model exports that we can use to detect whether the current build type
  // is testable is by looking at the test task name and checking whether it is null.
  BaseArtifact testArtifact = project.findSelectedTestArtifactInSelectedVariant();
  String testTask = testArtifact != null ? testArtifact.getAssembleTaskName() : null;
  return new Pair<Boolean, String>(testTask != null, AndroidBundle.message("android.cannot.run.library.project.in.this.buildtype"));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:AndroidTestRunConfiguration.java

示例7: acquireAndClearCurrentContent

import com.intellij.openapi.util.Pair; //导入方法依赖的package包/类
@NotNull
public Pair<StoredContent, Long> acquireAndClearCurrentContent(@NotNull VirtualFile f, @Nullable Document d) {
  ContentAndTimestamps contentAndStamp = f.getUserData(SAVED_DOCUMENT_CONTENT_AND_STAMP_KEY);
  f.putUserData(SAVED_DOCUMENT_CONTENT_AND_STAMP_KEY, null);

  if (d != null && contentAndStamp != null) {
    // if previously stored content was not changed, return it
    if (d.getModificationStamp() == contentAndStamp.documentModificationStamp) {
      return Pair.create(contentAndStamp.content, contentAndStamp.registeredTimestamp);
    }
  }

  // release previously stored
  if (contentAndStamp != null) {
    contentAndStamp.content.release();
  }

  // take document's content if any
  if (d != null) {
    return Pair.create(StoredContent.acquireContent(bytesFromDocument(d)), Clock.getTime());
  }

  return Pair.create(StoredContent.acquireContent(f), f.getTimeStamp());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:IdeaGateway.java

示例8: getHighlighLevelAndInspection

import com.intellij.openapi.util.Pair; //导入方法依赖的package包/类
@Nullable
public static Pair<AndroidLintInspectionBase, HighlightDisplayLevel> getHighlighLevelAndInspection(@NotNull Project project,
                                                                                                   @NotNull Issue issue,
                                                                                                   @NotNull PsiElement context) {
  final String inspectionShortName = AndroidLintInspectionBase.getInspectionShortNameByIssue(project, issue);
  if (inspectionShortName == null) {
    return null;
  }

  final HighlightDisplayKey key = HighlightDisplayKey.find(inspectionShortName);
  if (key == null) {
    return null;
  }

  final InspectionProfile profile = InspectionProjectProfileManager.getInstance(context.getProject()).getInspectionProfile();
  if (!profile.isToolEnabled(key, context)) {
    return null;
  }

  final AndroidLintInspectionBase inspection = (AndroidLintInspectionBase)profile.getUnwrappedTool(inspectionShortName, context);
  if (inspection == null) return null;
  final HighlightDisplayLevel errorLevel = profile.getErrorLevel(key, context);
  return Pair.create(inspection,
                     errorLevel != null ? errorLevel : HighlightDisplayLevel.WARNING);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:AndroidLintUtil.java

示例9: buildCondition

import com.intellij.openapi.util.Pair; //导入方法依赖的package包/类
@Nullable
private Pair<ArrangementMatchCondition, ArrangementSettingsToken> buildCondition() {
  List<ArrangementMatchCondition> conditions = ContainerUtilRt.newArrayList();
  ArrangementSettingsToken orderType = null;
  for (ArrangementUiComponent component : myComponents.values()) {
    if (!component.isEnabled() || !component.isSelected()) {
      continue;
    }
    ArrangementSettingsToken token = component.getToken();
    if (token != null && StdArrangementTokenType.ORDER.is(token)) {
      orderType = token;
    }
    else {
      conditions.add(component.getMatchCondition());
    }
  }
  if (!conditions.isEmpty()) {
    if (orderType == null) {
      orderType = StdArrangementTokens.Order.KEEP;
    }
    return Pair.create(ArrangementUtil.combine(conditions.toArray(new ArrangementMatchCondition[conditions.size()])), orderType);
  }
  else {
    return null;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:ArrangementMatchingRuleEditor.java

示例10: onDownload

import com.intellij.openapi.util.Pair; //导入方法依赖的package包/类
@Override
public Pair<Boolean, List<File>> onDownload(@NotNull ClassEntity[] classEntities, @NotNull File outputFolder) {
    List<File> fileList = new ArrayList<File>();
    for (int i = 0; i < classEntities.length; i++) {
        String url = classEntities[i].getDownloadUrl();
        if (url == null) {
            continue;
        }
        String filename;
        if (Utils.isEmpty(classEntities[i].getSaveName())) {
            filename = url.substring(url.lastIndexOf("/") + 1);
        } else {
            filename = classEntities[i].getSaveName();
        }
        File outFile = new File(outputFolder, filename);
        if (outFile.exists()) {
            fileList.add(outFile);
            continue;
        }
        try {
            DownloadUtil.downloadAtomically(null, url, outFile);
        } catch (IOException e) {
            Log.e(e);
        }
        if (outFile.exists()) {
            fileList.add(outFile);
        }
    }
    return Pair.create(classEntities.length == fileList.size(), fileList);
}
 
开发者ID:pengwei1024,项目名称:AndroidSourceViewer,代码行数:31,代码来源:XrefDownload.java

示例11: onDownload

import com.intellij.openapi.util.Pair; //导入方法依赖的package包/类
@Override
public Pair<Boolean, List<File>> onDownload(@NotNull ClassEntity[] classEntities, @NotNull File outputFolder) {
    List<File> fileList = new ArrayList<>();
    for (ClassEntity classEntity : classEntities) {
        String version = classEntity.getVersionName();
        if (!version.contains("_r")) {
            version += "_r1";
        }
        String url = String.format(Locale.getDefault(), Constant.DOWNLOAD_GOOGLE_SOURCE,
                version, classEntity.getLocalPath());
        Log.debug("GoogleSourceDownload => " + url);
        String filename;
        if (Utils.isEmpty(classEntity.getSaveName())) {
            filename = url.substring(url.lastIndexOf("/") + 1);
        } else {
            filename = classEntity.getSaveName();
        }
        File outFile = new File(outputFolder, filename);
        try {
            if (outFile.exists() && outFile.length() > 0) {
                fileList.add(outFile);
                continue;
            }
            String content = FileUtil.downloadContent(url);
            byte[] bytes = Base64.decodeBase64(content);
            FileUtils.write(outFile, new String(bytes), false);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (outFile.exists() && outFile.length() > 0) {
            fileList.add(outFile);
        }
    }
    return Pair.create(classEntities.length == fileList.size(), fileList);
}
 
开发者ID:pengwei1024,项目名称:AndroidSourceViewer,代码行数:36,代码来源:GoogleSourceDownload.java

示例12: getSelectedTable

import com.intellij.openapi.util.Pair; //导入方法依赖的package包/类
@Nullable
final Pair<PsiElement, PsiElement> getSelectedTable(final @NotNull ImpexTableEditor editor) {
    final PsiElement elementAtCaret = getElementAtCaret(editor.getIdeaEditor());


    final PsiElement valueLineAt;
    if (elementAtCaret != null) {
        if (getNextSiblingOfType(elementAtCaret, ImpexValueLine.class) != null) {
            valueLineAt = elementAtCaret.getNextSibling();
        } else if (getPrevSiblingOfType(elementAtCaret, ImpexValueLine.class) != null) {
            valueLineAt = elementAtCaret.getPrevSibling();
        } else {
            valueLineAt = getParentOfType(
                elementAtCaret,
                ImpexValueLine.class
            );

        }
    } else {
        return null;
    }

    if (valueLineAt == null) {
        return null;
    }

    final PsiElement headerLine = scanFirstLine(elementAtCaret, valueLineAt);

    final PsiElement lastValueLine = scanLastLine(valueLineAt, headerLine);

    return Pair.create(headerLine, lastValueLine);
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:33,代码来源:AbstractOperation.java

示例13: getCopyWithAnswers

import com.intellij.openapi.util.Pair; //导入方法依赖的package包/类
static Pair<VirtualFile, TaskFile> getCopyWithAnswers(@NotNull final VirtualFile taskDir,
                                                              @NotNull final VirtualFile file,
                                                              @NotNull final TaskFile source) {
  try {
    VirtualFile answerFile = file.copy(taskDir, taskDir, file.getNameWithoutExtension() + EduNames.ANSWERS_POSTFIX + "." + file.getExtension());
    final FileDocumentManager documentManager = FileDocumentManager.getInstance();
    final Document document = documentManager.getDocument(answerFile);
    if (document != null) {
      TaskFile answerTaskFile = source.getTask().copy().getTaskFile(StudyUtils.pathRelativeToTask(file));
      if (answerTaskFile == null) {
        return null;
      }
      EduDocumentListener listener = new EduDocumentListener(answerTaskFile);
      document.addDocumentListener(listener);
      for (AnswerPlaceholder answerPlaceholder : answerTaskFile.getActivePlaceholders()) {
        final int start = answerPlaceholder.getOffset();
        final int end = start + answerPlaceholder.getRealLength();
        final String text = answerPlaceholder.getPossibleAnswer();
        document.replaceString(start, end, text);
      }
      ApplicationManager.getApplication().runWriteAction(() -> documentManager.saveDocument(document));
      return Pair.create(answerFile, answerTaskFile);
    }
  }
  catch (IOException e) {
    LOG.error(e);
  }
  return null;
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:30,代码来源:PyStudySmartChecker.java

示例14: getPlaceholderOffsets

import com.intellij.openapi.util.Pair; //导入方法依赖的package包/类
public static Pair<Integer, Integer> getPlaceholderOffsets(@NotNull final AnswerPlaceholder answerPlaceholder,
                                                           @NotNull final Document document) {
  int startOffset = answerPlaceholder.getOffset();
  int delta = 0;
  final int length = answerPlaceholder.getRealLength();
  int nonSpaceCharOffset = DocumentUtil.getFirstNonSpaceCharOffset(document, startOffset, startOffset + length);
  if (nonSpaceCharOffset != startOffset) {
    delta = startOffset - nonSpaceCharOffset;
    startOffset = nonSpaceCharOffset;
  }
  final int endOffset = startOffset + length + delta;
  return Pair.create(startOffset, endOffset);
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:14,代码来源:StudyUtils.java

示例15: countProgressWithoutSubtasks

import com.intellij.openapi.util.Pair; //导入方法依赖的package包/类
/**
 * @return Pair (number of solved tasks, number of tasks)
 */
@NotNull
private static Pair<Integer, Integer> countProgressWithoutSubtasks(List<Lesson> lessons) {
  int taskNum = 0;
  int taskSolved = 0;
  for (Lesson lesson : lessons) {
    taskNum += lesson.getTaskList().size();
    taskSolved += getSolvedTasks(lesson);
  }
  return Pair.create(taskSolved, taskNum);
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:14,代码来源:StudyToolWindow.java


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