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


Java Task类代码示例

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


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

示例1: execute

import com.intellij.openapi.progress.Task; //导入依赖的package包/类
public void execute(ClassEntity targetClass) {
        this.targetClass = targetClass;
        ProgressManager.getInstance().run(new Task.Backgroundable(project, "GsonFormat") {

            @Override
            public void run(@NotNull ProgressIndicator progressIndicator) {
                progressIndicator.setIndeterminate(true);
                long currentTimeMillis = System.currentTimeMillis();
                execute();
                progressIndicator.setIndeterminate(false);
                progressIndicator.setFraction(1.0);
                StringBuffer sb = new StringBuffer();
                sb.append("GsonFormat [" + (System.currentTimeMillis() - currentTimeMillis) + " ms]\n");
//                sb.append("generate class : ( "+generateClassList.size()+" )\n");
//                for (String item: generateClassList) {
//                    sb.append("    at "+item+"\n");
//                }
//                sb.append("  \n");
//                NotificationCenter.info(sb.toString());
                Toast.make(project, MessageType.INFO, sb.toString());
            }
        });
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:DataWriter.java

示例2: asyncScanAndUpdateResults

import com.intellij.openapi.progress.Task; //导入依赖的package包/类
/**
 * Launch async dependency scan.
 */
public void asyncScanAndUpdateResults(boolean quickScan, @Nullable Collection<DataNode<LibraryDependencyData>> libraryDependencies) {
    Task.Backgroundable scanAndUpdateTask = new Task.Backgroundable(project, "Xray: Scanning for Vulnerabilities...") {
        @Override
        public void run(@NotNull ProgressIndicator indicator) {
            scanAndUpdate(quickScan, indicator, libraryDependencies);
            indicator.finishNonCancelableSection();
        }
    };
    // The progress manager is only good for foreground threads.
    if (SwingUtilities.isEventDispatchThread()) {
        ProgressManager.getInstance().run(scanAndUpdateTask);
    } else {
        // Run the scan task when the thread is in the foreground.
        SwingUtilities.invokeLater(() -> ProgressManager.getInstance().run(scanAndUpdateTask));
    }
}
 
开发者ID:JFrogDev,项目名称:jfrog-idea-plugin,代码行数:20,代码来源:ScanManager.java

示例3: OnResult

import com.intellij.openapi.progress.Task; //导入依赖的package包/类
@Override
public void OnResult(String result) {
    int extPos = result.lastIndexOf('/');
    if (extPos < 0 && extPos != result.length() - 1) {
        return;
    }
    String fileName = result.substring(extPos + 1);
    String title = "Download:" + fileName;
    File downloadFile = new File(Constant.CACHE_PATH + "search/" + fileName);
    ProgressManager.getInstance().run(new Task.Backgroundable(project, title) {
        @Override
        public void run(@NotNull ProgressIndicator progressIndicator) {
            try {
                DownloadUtil.downloadAtomically(null, result, downloadFile);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (downloadFile.exists()) {
                Utils.openFileInPanel(downloadFile.getPath(), project);
            }
        }
    });

}
 
开发者ID:pengwei1024,项目名称:AndroidSourceViewer,代码行数:25,代码来源:GlobalSearchAction.java

示例4: ReactionButtonPanel

import com.intellij.openapi.progress.Task; //导入依赖的package包/类
public ReactionButtonPanel(@NotNull final String text,
                           @NotNull final String enabledTooltip,
                           int reaction) {
  com.jetbrains.edu.learning.courseFormat.tasks.Task task = StudyUtils.getTaskFromSelectedEditor(myProject);
  final boolean isEnabled = task != null && task.getStatus() != StudyStatus.Solved;

  myLabel = new JLabel(text);

  myButtonPanel = new JPanel();
  myButtonPanel.setLayout(new BoxLayout(myButtonPanel, BoxLayout.PAGE_AXIS));
  myButtonPanel.setToolTipText(isEnabled && task.getStatus() == StudyStatus.Solved ? enabledTooltip : SOLVED_TASK_TOOLTIP);
  myButtonPanel.add(Box.createVerticalStrut(5));
  myButtonPanel.add(myLabel);
  myButtonPanel.add(Box.createVerticalStrut(5));

  setEnabledRecursive(isEnabled);

  setLayout(new GridBagLayout());
  setBorder(BorderFactory.createEtchedBorder());
  add(myButtonPanel);
  addMouseListener(reaction);
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:23,代码来源:StepicAdaptiveReactionsPanel.java

示例5: mouseClicked

import com.intellij.openapi.progress.Task; //导入依赖的package包/类
@Override
public void mouseClicked(MouseEvent e) {
  if (e.getClickCount() == 1 && isEnabled()) {
    final com.jetbrains.edu.learning.courseFormat.tasks.Task task = StudyUtils.getCurrentTask(myProject);
    if (task != null && task.getStatus() != StudyStatus.Solved) {
      final ProgressIndicatorBase progress = new ProgressIndicatorBase();
      progress.setText(EduAdaptiveStepicConnector.LOADING_NEXT_RECOMMENDATION);
      ProgressManager.getInstance().run(new Task.Backgroundable(myProject,
                                                                EduAdaptiveStepicConnector.LOADING_NEXT_RECOMMENDATION) {
        @Override
        public void run(@NotNull ProgressIndicator indicator) {
          StepicAdaptiveReactionsPanel.this.setEnabledRecursive(false);
          ApplicationManager.getApplication().invokeLater(()->setBackground(UIUtil.getLabelBackground()));
          EduAdaptiveStepicConnector.addNextRecommendedTask(StepicAdaptiveReactionsPanel.this.myProject, task.getLesson(), indicator,
                                                            myReaction);
          StepicAdaptiveReactionsPanel.this.setEnabledRecursive(true);
        }
      });
    }
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:22,代码来源:StepicAdaptiveReactionsPanel.java

示例6: actionPerformed

import com.intellij.openapi.progress.Task; //导入依赖的package包/类
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
  final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
  final Project project = e.getData(CommonDataKeys.PROJECT);
  if (view == null || project == null) {
    return;
  }
  final String courseId = Messages.showInputDialog("Please, enter course id", "Get Course From Stepik", null);
  if (StringUtil.isNotEmpty(courseId)) {
    ProgressManager.getInstance().run(new Task.Modal(project, "Creating Course", true) {
      @Override
      public void run(@NotNull final ProgressIndicator indicator) {
        createCourse(project, courseId);
      }
    });
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:18,代码来源:CCGetCourseFromStepic.java

示例7: actionPerformed

import com.intellij.openapi.progress.Task; //导入依赖的package包/类
@Override
protected void actionPerformed(@NotNull final HgRepository repository, @NotNull VcsFullCommitDetails commit) {
  final Hash revisionHash = commit.getId();
  final Project project = repository.getProject();
  FileDocumentManager.getInstance().saveAllDocuments();
  String shortHash = revisionHash.toShortString();
  final String name = getNewBranchNameFromUser(repository, "Create New Branch From " + shortHash);
  if (name != null) {
    new Task.Backgroundable(project, HgVcsMessages.message("hg4idea.progress.updatingTo", shortHash)) {
      @Override
      public void run(@NotNull ProgressIndicator indicator) {
        if (HgUpdateCommand.updateRepoToInCurrentThread(project, repository.getRoot(), revisionHash.asString(), false)) {
          new HgBranchPopupActions.HgNewBranchAction(project, Collections.singletonList(repository), repository)
            .createNewBranch(name);
        }
      }
    }.queue();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:HgCreateNewBranchFromLogAction.java

示例8: execute

import com.intellij.openapi.progress.Task; //导入依赖的package包/类
@Override
protected void execute(@NotNull final Project project,
                       @NotNull Collection<HgRepository> repositories,
                       @Nullable final HgRepository selectedRepo) {

  new Task.Backgroundable(project, "Abort Rebasing...") {
    @Override
    public void run(@NotNull ProgressIndicator indicator) {
      if (selectedRepo != null) {
        HgRebaseCommand rebaseCommand = new HgRebaseCommand(project, selectedRepo);
        HgCommandResult result = rebaseCommand.abortRebase();
        if (HgErrorUtil.isAbort(result)) {
          new HgCommandResultNotifier(project).notifyError(result, "Hg Error", "Couldn't abort rebasing");
        }
        HgErrorUtil.markDirtyAndHandleErrors(project, selectedRepo.getRoot());
      }
    }
  }.queue();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:HgAbortRebaseAction.java

示例9: doSearchAndShow

import com.intellij.openapi.progress.Task; //导入依赖的package包/类
private UsageView doSearchAndShow(@NotNull final UsageTarget[] searchFor,
                                  @NotNull final Factory<UsageSearcher> searcherFactory,
                                  @NotNull final UsageViewPresentation presentation,
                                  @NotNull final FindUsagesProcessPresentation processPresentation,
                                  @Nullable final UsageViewStateListener listener) {
  final SearchScope searchScopeToWarnOfFallingOutOf = getMaxSearchScopeToWarnOfFallingOutOf(searchFor);
  final AtomicReference<UsageViewImpl> usageViewRef = new AtomicReference<UsageViewImpl>();

  Task.Backgroundable task = new Task.Backgroundable(myProject, getProgressTitle(presentation), true, new SearchInBackgroundOption()) {
    @Override
    public void run(@NotNull final ProgressIndicator indicator) {
      new SearchForUsagesRunnable(UsageViewManagerImpl.this, UsageViewManagerImpl.this.myProject, usageViewRef, presentation, searchFor, searcherFactory,
                                  processPresentation, searchScopeToWarnOfFallingOutOf, listener).run();
    }

    @Override
    @Nullable
    public NotificationInfo getNotificationInfo() {
      String notification = usageViewRef.get() != null ? usageViewRef.get().getUsagesCount() + " Usage(s) Found" : "No Usages Found";
      return new NotificationInfo("Find Usages", "Find Usages Finished", notification);
    }
  };
  ProgressManager.getInstance().run(task);
  return usageViewRef.get();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:UsageViewManagerImpl.java

示例10: createDifference

import com.intellij.openapi.progress.Task; //导入依赖的package包/类
protected ContentDiffRequest createDifference(final FileDifferenceModel m) {
  final Ref<ContentDiffRequest> requestRef = new Ref<ContentDiffRequest>();

  new Task.Modal(myProject, message("message.processing.revisions"), false) {
    public void run(@NotNull final ProgressIndicator i) {
      ApplicationManager.getApplication().runReadAction(new Runnable() {
        @Override
        public void run() {
          RevisionProcessingProgressAdapter p = new RevisionProcessingProgressAdapter(i);
          p.processingLeftRevision();
          DiffContent left = m.getLeftDiffContent(p);

          p.processingRightRevision();
          DiffContent right = m.getRightDiffContent(p);

          requestRef.set(new SimpleDiffRequest(m.getTitle(), left, right, m.getLeftTitle(p), m.getRightTitle(p)));
        }
      });
    }
  }.queue();

  return requestRef.get();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:HistoryDialog.java

示例11: scheduleMissingFileForDeletion

import com.intellij.openapi.progress.Task; //导入依赖的package包/类
public List<VcsException> scheduleMissingFileForDeletion(List<FilePath> files) {
  final List<HgFile> filesWithRoots = new ArrayList<HgFile>();
  for (FilePath filePath : files) {
    VirtualFile vcsRoot = VcsUtil.getVcsRootFor(myProject, filePath);
    if (vcsRoot == null) {
      continue;
    }
    filesWithRoots.add(new HgFile(vcsRoot, filePath));
  }
  new Task.Backgroundable(myProject, "Removing files...") {
    @Override
    public void run(@NotNull ProgressIndicator indicator) {
      HgRemoveCommand command = new HgRemoveCommand(myProject);
      command.execute(filesWithRoots);
    }
  }.queue();
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:HgCheckinEnvironment.java

示例12: actionPerformed

import com.intellij.openapi.progress.Task; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
  final Project project = e.getData(CommonDataKeys.PROJECT);
  for (int i = 0; i < 100; i++) {
    new Task.Backgroundable(project, "Test Process", true, PerformInBackgroundOption.ALWAYS_BACKGROUND) {
      public void run(@NotNull final ProgressIndicator indicator) {
        for (int j = 0; j < 10000; j++) {
          TimeoutUtil.sleep(1);
          indicator.setText("foo " + j);
        }
      }
    }.queue();

  }

}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:AddManyTestProcesses.java

示例13: updateAndShowResult

import com.intellij.openapi.progress.Task; //导入依赖的package包/类
/**
 * For manual update checks (Help | Check for Updates, Settings | Updates | Check Now)
 * (the latter action may pass customised update settings).
 */
public static void updateAndShowResult(@Nullable Project project, @Nullable UpdateSettings customSettings) {
  final UpdateSettings settings = customSettings != null ? customSettings : UpdateSettings.getInstance();
  final boolean fromSettings = customSettings != null;

  ProgressManager.getInstance().run(new Task.Backgroundable(project, IdeBundle.message("updates.checking.progress"), true) {
    @Override
    public void run(@NotNull ProgressIndicator indicator) {
      doUpdateAndShowResult(getProject(), fromSettings, true, settings, indicator, null);
    }

    @Override
    public boolean isConditionalModal() {
      return fromSettings;
    }

    @Override
    public boolean shouldStartInBackground() {
      return !fromSettings;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:UpdateChecker.java

示例14: BackgroundableProcessIndicator

import com.intellij.openapi.progress.Task; //导入依赖的package包/类
public BackgroundableProcessIndicator(@NotNull Task.Backgroundable task) {
  this(task.getProject(), task, task);

  myDumbModeAction = task.getDumbModeAction();
  if (myDumbModeAction == DumbModeAction.CANCEL) {
    task.getProject().getMessageBus().connect(this).subscribe(DumbService.DUMB_MODE, new DumbService.DumbModeListener() {

      @Override
      public void enteredDumbMode() {
        cancel();
      }

      @Override
      public void exitDumbMode() {
      }
    });
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:BackgroundableProcessIndicator.java

示例15: execute

import com.intellij.openapi.progress.Task; //导入依赖的package包/类
@Override
protected void execute(@NotNull final Project project,
                       @NotNull Collection<HgRepository> repositories,
                       @Nullable final HgRepository selectedRepo) {

  new Task.Backgroundable(project, "Continue Rebasing...") {
    @Override
    public void run(@NotNull ProgressIndicator indicator) {
      if (selectedRepo != null) {
        HgRebaseCommand rebaseCommand = new HgRebaseCommand(project, selectedRepo);
        HgCommandResult result = rebaseCommand.continueRebase();
        if (HgErrorUtil.isAbort(result)) {
          new HgCommandResultNotifier(project).notifyError(result, "Hg Error", "Couldn't continue rebasing");
        }
        HgErrorUtil.markDirtyAndHandleErrors(project, selectedRepo.getRoot());
      }
    }
  }.queue();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:HgContinueRebaseAction.java


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