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


Java ProgressIndicator.checkCanceled方法代码示例

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


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

示例1: getAnalysisOutput

import com.intellij.openapi.progress.ProgressIndicator; //导入方法依赖的package包/类
@NotNull
private String getAnalysisOutput(@NotNull final ProgressIndicator progressIndicator) throws Exception {
    final List<String> gradlewCommand = System.getProperty("os.name").startsWith("Windows")
            ? Arrays.asList("cmd", "/c", "gradlew.bat", "staticAnalys")
            : Arrays.asList("./gradlew", "staticAnalys");
    gradlewProcess = new ProcessBuilder(gradlewCommand)
            .directory(new File(project.getBasePath()))
            .redirectErrorStream(true)
            .start();
    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(gradlewProcess.getInputStream()));
    StringBuilder analysisOutputBuilder = new StringBuilder();

    String outputLine;
    while ((outputLine = bufferedReader.readLine()) != null) {
        progressIndicator.setText2(outputLine);
        progressIndicator.checkCanceled();
        analysisOutputBuilder.append(outputLine);
        analysisOutputBuilder.append('\n');
    }

    return analysisOutputBuilder.toString();
}
 
开发者ID:arso8,项目名称:StAnalysisRunner,代码行数:23,代码来源:AnalysisTask.java

示例2: highlightTodos

import com.intellij.openapi.progress.ProgressIndicator; //导入方法依赖的package包/类
static void highlightTodos(@NotNull PsiFile file,
                           @NotNull CharSequence text,
                           int startOffset,
                           int endOffset,
                           @NotNull ProgressIndicator progress,
                           @NotNull ProperTextRange priorityRange,
                           @NotNull Collection<HighlightInfo> insideResult,
                           @NotNull Collection<HighlightInfo> outsideResult) {
  PsiTodoSearchHelper helper = PsiTodoSearchHelper.SERVICE.getInstance(file.getProject());
  if (helper == null) return;
  TodoItem[] todoItems = helper.findTodoItems(file, startOffset, endOffset);
  if (todoItems.length == 0) return;

  for (TodoItem todoItem : todoItems) {
    progress.checkCanceled();
    TextRange range = todoItem.getTextRange();
    String description = text.subSequence(range.getStartOffset(), range.getEndOffset()).toString();
    TextAttributes attributes = todoItem.getPattern().getAttributes().getTextAttributes();
    HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(HighlightInfoType.TODO).range(range);
    builder.textAttributes(attributes);
    builder.descriptionAndTooltip(description);
    HighlightInfo info = builder.createUnconditionally();
    (priorityRange.containsRange(info.getStartOffset(), info.getEndOffset()) ? insideResult : outsideResult).add(info);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:GeneralHighlightingPass.java

示例3: run

import com.intellij.openapi.progress.ProgressIndicator; //导入方法依赖的package包/类
public void run(@NotNull ProgressIndicator indicator) {
  indicator.setIndeterminate(true);
  indicator.setText2(VcsBundle.message("commit.wait.util.synched.text"));
  synchronized (myLock) {
    if (myStarted) {
      LOG.error("Waiter running under progress being started again.");
      return;
    }
    myStarted = true;
    while (! myDone) {
      try {
        // every second check whether we are canceled
        myLock.wait(500);
      }
      catch (InterruptedException e) {
        // ok
      }
      indicator.checkCanceled();
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:Waiter.java

示例4: waitForProcess

import com.intellij.openapi.progress.ProgressIndicator; //导入方法依赖的package包/类
protected void waitForProcess() {
  if (myHandler != null) {
    ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
    while (!myHandler.waitFor(50)) {
      try {
        if (indicator != null) {
          indicator.checkCanceled();
        }
      }
      catch (ProcessCanceledException pce) {
        myHandler.destroyProcess();
        throw pce;
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:GitTextHandler.java

示例5: processTextOccurrences

import com.intellij.openapi.progress.ProgressIndicator; //导入方法依赖的package包/类
public static boolean processTextOccurrences(@NotNull CharSequence text,
                                             int startOffset,
                                             int endOffset,
                                             @NotNull StringSearcher searcher,
                                             @Nullable ProgressIndicator progress,
                                             @NotNull TIntProcedure processor) {
  if (endOffset > text.length()) {
    throw new AssertionError("end>length");
  }
  for (int index = startOffset; index < endOffset; index++) {
    if (progress != null) progress.checkCanceled();
    //noinspection AssignmentToForLoopParameter
    index = searcher.scan(text, index, endOffset);
    if (index < 0) break;
    if (checkJavaIdentifier(text, startOffset, endOffset, searcher, index)) {
      if (!processor.execute(index)) return false;
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:LowLevelSearchUtil.java

示例6: postLesson

import com.intellij.openapi.progress.ProgressIndicator; //导入方法依赖的package包/类
public static int postLesson(@NotNull final Project project, @NotNull final Lesson lesson) {
  if (!checkIfAuthorized(project, "postLesson")) return -1;

  final HttpPost request = new HttpPost(EduStepicNames.STEPIC_API_URL + "/lessons");

  String requestBody = new Gson().toJson(new StepicWrappers.LessonWrapper(lesson));
  request.setEntity(new StringEntity(requestBody, ContentType.APPLICATION_JSON));

  try {
    final CloseableHttpClient client = EduStepicAuthorizedClient.getHttpClient();
    if (client == null) return -1;
    final CloseableHttpResponse response = client.execute(request);
    final HttpEntity responseEntity = response.getEntity();
    final String responseString = responseEntity != null ? EntityUtils.toString(responseEntity) : "";
    final StatusLine line = response.getStatusLine();
    EntityUtils.consume(responseEntity);
    if (line.getStatusCode() != HttpStatus.SC_CREATED) {
      final String message = FAILED_TITLE + "lesson ";
      LOG.error(message + responseString);
      showErrorNotification(project, message, responseString);
      return 0;
    }
    final Lesson postedLesson = new Gson().fromJson(responseString, RemoteCourse.class).getLessons(true).get(0);
    lesson.setId(postedLesson.getId());
    for (Task task : lesson.getTaskList()) {
      final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
      if (indicator != null) {
        indicator.checkCanceled();
      }
      postTask(project, task, postedLesson.getId());
    }
    return postedLesson.getId();
  }
  catch (IOException e) {
    LOG.error(e.getMessage());
  }
  return -1;
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:39,代码来源:CCStepicConnector.java

示例7: copyStreamContent

import com.intellij.openapi.progress.ProgressIndicator; //导入方法依赖的package包/类
/**
 * @param indicator           Progress indicator.
 * @param inputStream         source stream
 * @param outputStream        destination stream
 * @param expectedContentSize expected content size, used in progress indicator (negative means unknown length)
 * @return bytes copied
 * @throws IOException              if IO error occur
 * @throws ProcessCanceledException if process was canceled.
 */
public static int copyStreamContent(@Nullable ProgressIndicator indicator,
                                    @NotNull InputStream inputStream,
                                    @NotNull OutputStream outputStream,
                                    int expectedContentSize) throws IOException, ProcessCanceledException {
  if (indicator != null) {
    indicator.checkCanceled();
    if (expectedContentSize < 0) {
      indicator.setIndeterminate(true);
    }
  }

  final byte[] buffer = new byte[8 * 1024];
  int count;
  int total = 0;
  while ((count = inputStream.read(buffer)) > 0) {
    outputStream.write(buffer, 0, count);
    total += count;

    if (indicator != null) {
      indicator.checkCanceled();

      if (expectedContentSize > 0) {
        indicator.setFraction((double)total / expectedContentSize);
      }
    }
  }

  if (indicator != null) {
    indicator.checkCanceled();
  }

  if (total < expectedContentSize) {
    throw new IOException(String.format("Connection closed at byte %d. Expected %d bytes.", total, expectedContentSize));
  }

  return total;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:47,代码来源:NetUtils.java

示例8: delegateCommitToVcsThread

import com.intellij.openapi.progress.ProgressIndicator; //导入方法依赖的package包/类
private void delegateCommitToVcsThread(final GeneralCommitProcessor processor) {
  final ProgressIndicator indicator = new DelegatingProgressIndicator();

  final Semaphore endSemaphore = new Semaphore();
  endSemaphore.down();

  ChangeListManagerImpl.getInstanceImpl(myProject).executeOnUpdaterThread(new Runnable() {
    @Override
    public void run() {
      indicator.setText("Performing VCS commit...");
      try {
        ProgressManager.getInstance().runProcess(new Runnable() {
          @Override
          public void run() {
            indicator.checkCanceled();
            generalCommit(processor);
          }
        }, indicator);
      }
      finally {
        endSemaphore.up();
      }
    }
  });

  indicator.setText("Waiting for VCS background tasks to finish...");
  while (!endSemaphore.waitFor(20)) {
    indicator.checkCanceled();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:CommitHelper.java

示例9: collectAndShowDuplicates

import com.intellij.openapi.progress.ProgressIndicator; //导入方法依赖的package包/类
private static void collectAndShowDuplicates(final Project project) {
  final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
  if (indicator != null && !indicator.isCanceled()) {
    indicator.setText("Collecting project images...");
    indicator.setIndeterminate(false);
    final List<VirtualFile> images = new ArrayList<VirtualFile>();
    for (String ext : IMAGE_EXTENSIONS) {
      images.addAll(FilenameIndex.getAllFilesByExt(project, ext));
    }

    final Map<Long, Set<VirtualFile>> duplicates = new HashMap<Long, Set<VirtualFile>>();
    final Map<Long, VirtualFile> all = new HashMap<Long, VirtualFile>();
    for (int i = 0; i < images.size(); i++) {
      indicator.setFraction((double)(i + 1) / (double)images.size());
      final VirtualFile file = images.get(i);
      if (!(file.getFileSystem() instanceof LocalFileSystem)) continue;
      final long length = file.getLength();
      if (all.containsKey(length)) {
        if (!duplicates.containsKey(length)) {
          final HashSet<VirtualFile> files = new HashSet<VirtualFile>();
          files.add(all.get(length));
          duplicates.put(length, files);
        }
        duplicates.get(length).add(file);
      } else {
        all.put(length, file);
      }
      indicator.checkCanceled();
    }
    showResults(project, images, duplicates, all);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:ShowImageDuplicatesAction.java

示例10: optimizeImportsOnTheFlyLater

import com.intellij.openapi.progress.ProgressIndicator; //导入方法依赖的package包/类
private void optimizeImportsOnTheFlyLater(@NotNull final ProgressIndicator progress) {
  if ((myHasRedundantImports || myHasMissortedImports) && !progress.isCanceled()) {
    // schedule optimise action at the time of session disposal, which is after all applyInformation() calls
    Disposable invokeFixLater = new Disposable() {
      @Override
      public void dispose() {
        // later because should invoke when highlighting is finished
        ApplicationManager.getApplication().invokeLater(new Runnable() {
          @Override
          public void run() {
            if (myProject.isDisposed() || !myFile.isValid() || !myFile.isWritable()) return;
            IntentionAction optimizeImportsFix = QuickFixFactory.getInstance().createOptimizeImportsFix(true);
            if (optimizeImportsFix.isAvailable(myProject, null, myFile)) {
              optimizeImportsFix.invoke(myProject, null, myFile);
            }
          }
        });
      }
    };
    Disposer.register((DaemonProgressIndicator)progress, invokeFixLater);
    if (progress.isCanceled()) {
      Disposer.dispose(invokeFixLater);
      Disposer.dispose((DaemonProgressIndicator)progress);
      progress.checkCanceled();
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:PostHighlightingVisitor.java

示例11: take

import com.intellij.openapi.progress.ProgressIndicator; //导入方法依赖的package包/类
@Nullable
public FileContent take(@NotNull ProgressIndicator indicator) throws ProcessCanceledException {
  final FileContent content = doTake();
  if (content == null) {
    return null;
  }
  final long length = content.getLength();
  while (true) {
    try {
      indicator.checkCanceled();
    }
    catch (ProcessCanceledException e) {
      pushback(content);
      throw e;
    }

    synchronized (myProceedWithProcessingLock) {
      final boolean requestingLargeSize = length > LARGE_SIZE_REQUEST_THRESHOLD;
      if (requestingLargeSize) {
        myLargeSizeRequested = true;
      }
      try {
        if (myLargeSizeRequested && !requestingLargeSize ||
            myBytesBeingProcessed + length > Math.max(PROCESSED_FILE_BYTES_THRESHOLD, length)) {
          myProceedWithProcessingLock.wait(300);
        }
        else {
          myBytesBeingProcessed += length;
          if (requestingLargeSize) {
            myLargeSizeRequested = false;
          }
          return content;
        }
      }
      catch (InterruptedException ignore) {
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:FileContentQueue.java

示例12: processElementsContainingWordInElement

import com.intellij.openapi.progress.ProgressIndicator; //导入方法依赖的package包/类
public static boolean processElementsContainingWordInElement(@NotNull final TextOccurenceProcessor processor,
                                                             @NotNull final PsiElement scope,
                                                             @NotNull final StringSearcher searcher,
                                                             final boolean processInjectedPsi,
                                                             final ProgressIndicator progress) {
  if (progress != null) progress.checkCanceled();

  PsiFile file = scope.getContainingFile();
  FileViewProvider viewProvider = file.getViewProvider();
  final CharSequence buffer = viewProvider.getContents();

  TextRange range = scope.getTextRange();
  if (range == null) {
    LOG.error("Element " + scope + " of class " + scope.getClass() + " has null range");
    return true;
  }

  final int scopeStart = range.getStartOffset();
  final int startOffset = scopeStart;
  int endOffset = range.getEndOffset();
  if (endOffset > buffer.length()) {
    diagnoseInvalidRange(scope, file, viewProvider, buffer, range);
    return true;
  }

  final Project project = file.getProject();
  final TreeElement[] lastElement = {null};
  return processTextOccurrences(buffer, startOffset, endOffset, searcher, progress, new TIntProcedure() {
    @Override
    public boolean execute(int offset) {
      if (progress != null) progress.checkCanceled();
      lastElement[0] = processTreeUp(project, processor, scope, searcher, offset - scopeStart, processInjectedPsi, progress,
                                     lastElement[0]);
      return lastElement[0] != null;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:LowLevelSearchUtil.java

示例13: addHighlightsFromResults

import com.intellij.openapi.progress.ProgressIndicator; //导入方法依赖的package包/类
private void addHighlightsFromResults(@NotNull List<HighlightInfo> outInfos, @NotNull ProgressIndicator indicator) {
  InspectionProfile inspectionProfile = InspectionProjectProfileManager.getInstance(myProject).getInspectionProfile();
  PsiDocumentManager documentManager = PsiDocumentManager.getInstance(myProject);
  InjectedLanguageManager ilManager = InjectedLanguageManager.getInstance(myProject);
  Set<Pair<TextRange, String>> emptyActionRegistered = new THashSet<Pair<TextRange, String>>();

  for (Map.Entry<PsiFile, List<InspectionResult>> entry : result.entrySet()) {
    indicator.checkCanceled();
    PsiFile file = entry.getKey();
    Document documentRange = documentManager.getDocument(file);
    if (documentRange == null) continue;
    List<InspectionResult> resultList = entry.getValue();
    synchronized (resultList) {
      for (InspectionResult inspectionResult : resultList) {
        indicator.checkCanceled();
        LocalInspectionToolWrapper tool = inspectionResult.tool;
        HighlightSeverity severity = inspectionProfile.getErrorLevel(HighlightDisplayKey.find(tool.getShortName()), file).getSeverity();
        for (ProblemDescriptor descriptor : inspectionResult.foundProblems) {
          indicator.checkCanceled();
          PsiElement element = descriptor.getPsiElement();
          if (element != null) {
            createHighlightsForDescriptor(outInfos, emptyActionRegistered, ilManager, file, documentRange, tool, severity, descriptor, element);
          }
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:LocalInspectionsPass.java

示例14: diff

import com.intellij.openapi.progress.ProgressIndicator; //导入方法依赖的package包/类
@NotNull
public static <T> FairDiffIterable diff(@NotNull T[] data1, @NotNull T[] data2, @NotNull ProgressIndicator indicator) {
  indicator.checkCanceled();

  try {
    // TODO: use ProgressIndicator inside
    Diff.Change change = Diff.buildChanges(data1, data2);
    return fair(create(change, data1.length, data2.length));
  }
  catch (FilesTooBigForDiffException e) {
    throw new DiffTooBigException();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:DiffIterableUtil.java

示例15: download

import com.intellij.openapi.progress.ProgressIndicator; //导入方法依赖的package包/类
private static void download(@NotNull String url, @NotNull File destination, @NotNull ProgressIndicator indicator) throws IOException {
  indicator.setText(String.format("Downloading %s", destination.getName()));
  HttpURLConnection connection = HttpConfigurable.getInstance().openHttpConnection(url);
  int contentLength = connection.getContentLength();
  if (contentLength <= 0) {
    indicator.setIndeterminate(true);
  }
  InputStream readStream = null;
  OutputStream stream = null;
  try {
    readStream = connection.getInputStream();
    //noinspection IOResourceOpenedButNotSafelyClosed
    stream = new BufferedOutputStream(new FileOutputStream(destination));
    byte[] buffer = new byte[2 * 1024 * 1024];
    int read;
    int totalRead = 0;
    final long startTime = System.currentTimeMillis();
    for (read = readStream.read(buffer); read > 0; read = readStream.read(buffer)) {
      totalRead += read;
      stream.write(buffer, 0, read);
      long duration = System.currentTimeMillis() - startTime; // Duration is in ms
      long downloadRate = duration == 0 ? 0 : (totalRead / duration);
      String message =
        String.format("Downloading %1$s (%2$s/s)", destination.getName(), WelcomeUIUtils.getSizeLabel(downloadRate * 1000));
      indicator.setText(message);
      if (contentLength > 0) {
        indicator.setFraction(((double)totalRead) / contentLength);
      }
      indicator.checkCanceled();
    }
  }
  finally {
    if (stream != null) {
      stream.close();
    }
    if (readStream != null) {
      readStream.close();
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:41,代码来源:DownloadOperation.java


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