本文整理匯總了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());
}
});
}
示例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));
}
}
示例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);
}
}
});
}
示例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);
}
示例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);
}
});
}
}
}
示例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);
}
});
}
}
示例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();
}
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}
示例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();
}
}
示例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;
}
});
}
示例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() {
}
});
}
}
示例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();
}