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