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


Java Task.Backgroundable方法代码示例

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


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

示例1: 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

示例2: changeFormat

import com.intellij.openapi.progress.Task; //导入方法依赖的package包/类
private void changeFormat(@NotNull final WCInfo wcInfo, @NotNull final Collection<WorkingCopyFormat> supportedFormats) {
  ChangeFormatDialog dialog = new ChangeFormatDialog(myProject, new File(wcInfo.getPath()), false, !wcInfo.isIsWcRoot());

  dialog.setSupported(supportedFormats);
  dialog.setData(wcInfo.getFormat());
  if (!dialog.showAndGet()) {
    return;
  }
  final WorkingCopyFormat newFormat = dialog.getUpgradeMode();
  if (!wcInfo.getFormat().equals(newFormat)) {
    ApplicationManager.getApplication().saveAll();
    final Task.Backgroundable task = new SvnFormatWorker(myProject, newFormat, wcInfo) {
      @Override
      public void onSuccess() {
        super.onSuccess();
        myRefreshLabel.doClick();
      }
    };
    ProgressManager.getInstance().run(task);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:CopiesPanel.java

示例3: 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

示例4: createLoader

import com.intellij.openapi.progress.Task; //导入方法依赖的package包/类
private VcsLogRefresherImpl createLoader(Consumer<DataPack> dataPackConsumer) {
  myDataHolder = new VcsLogDataHolder(myProject, myProject, myLogProviders,
                                                     ServiceManager.getService(myProject, VcsLogSettings.class),
                                                     ServiceManager.getService(myProject, VcsLogUiProperties.class), Consumer.EMPTY_CONSUMER);
  return new VcsLogRefresherImpl(myProject, myDataHolder.getHashMap(), myLogProviders, myDataHolder.getUserRegistry(), myTopDetailsCache,
                                 dataPackConsumer, FAILING_EXCEPTION_HANDLER, RECENT_COMMITS_COUNT) {
    @Override
    protected void startNewBackgroundTask(@NotNull final Task.Backgroundable refreshTask) {
      UIUtil.invokeLaterIfNeeded(new Runnable() {
        @Override
        public void run() {
          LOG.debug("Starting a background task...");
          myStartedTasks.add(((ProgressManagerImpl)ProgressManager.getInstance()).runProcessWithProgressAsynchronously(refreshTask));
          LOG.debug(myStartedTasks.size() + " started tasks");
        }
      });
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:VcsLogRefresherTest.java

示例5: 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

示例6: loadDevelopersAsynchronously

import com.intellij.openapi.progress.Task; //导入方法依赖的package包/类
private void loadDevelopersAsynchronously() {
  Task.Backgroundable task = new Task.Backgroundable(null, "Loading Developers List", true) {
    private final Collection[] myDevelopers = new Collection[]{Collections.emptyList()};

    @Override
    public void run(@NotNull ProgressIndicator indicator) {
      try {
        myDevelopers[0] = DevelopersLoader.fetchDevelopers(indicator);
      } catch (IOException e) {
        //Notifications.Bus.register("Error reporter", NotificationDisplayType.BALLOON);
        //Notifications.Bus.notify(new Notification("Error reporter", "Communication error",
        //                                          "Unable to load developers list from server.", NotificationType.WARNING));
      }
    }

    @Override
    public void onSuccess() {
      Collection<Developer> developers = myDevelopers[0];
      myDetailsTabForm.setDevelopers(developers);
      //noinspection AssignmentToStaticFieldFromInstanceMethod
      ourDevelopersList = developers;
    }
  };
  ProgressManager.getInstance().run(task);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:IdeErrorsDialog.java

示例7: ZipAndQueue

import com.intellij.openapi.progress.Task; //导入方法依赖的package包/类
public ZipAndQueue(final Project project, final int interval, final String title, final Runnable runnable) {
  final int correctedInterval = interval <= 0 ? 300 : interval;
  myZipperUpdater = new ZipperUpdater(correctedInterval, project);
  myQueue = new BackgroundTaskQueue(project, title);
  myInZipper = new Runnable() {
    @Override
    public void run() {
      myQueue.run(myInvokedOnQueue);
    }
  };
  myInvokedOnQueue = new Task.Backgroundable(project, title, false, BackgroundFromStartOption.getInstance()) {
    @Override
    public void run(@NotNull ProgressIndicator indicator) {
      runnable.run();
    }
  };
  Disposer.register(project, new Disposable() {
    @Override
    public void dispose() {
      myZipperUpdater.stop();
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:ZipAndQueue.java

示例8: run

import com.intellij.openapi.progress.Task; //导入方法依赖的package包/类
private void run(Project project, UrlHandler handler, RemoteUrlGenerator generator)
{
    Container container     = this.container();
    Preferences preferences = container.preferences(project);
    Logger logger           = container.logger(project);

    Task.Backgroundable task = new Task.Backgroundable(project, "GitLink - Processing") {
        @Override
        public void run(@NotNull ProgressIndicator indicator) {
            try {

                URL remoteUrl = generator.generateRemoteURL();

                logger.notice(String.format("Generated URL '%s'", remoteUrl.toString()));

                for (UrlModifier urlModifier: container.urlModifiers()) {
                    if (preferences.isModifierEnabled(urlModifier)) {
                        remoteUrl = urlModifier.modify(remoteUrl);
                        logger.notice(String.format("Applied modifier '%s' - '%s'", urlModifier.name(), remoteUrl.toString()));
                    }
                }

                logger.notice(String.format("Running URL handler '%s'", handler.name()));

                handler.handle(remoteUrl);

            }  catch (GitLinkException e) {
                logger.exception(e);
            }
        }
    };

    task.queue();
}
 
开发者ID:ben-gibson,项目名称:GitLink,代码行数:35,代码来源:Runner.java

示例9: IdeaMantisConfigurable

import com.intellij.openapi.progress.Task; //导入方法依赖的package包/类
public IdeaMantisConfigurable(@NotNull Project project) {
    this.settings = ConnectionSettings.getInstance(project);
    this.manager = ToolWindowManager.getInstance(project);
    this.task = new Task.Backgroundable(project, "Load Data...") {
        @Override
        public void run(@NotNull ProgressIndicator progressIndicator) {
            try {
                settings.setHostName(txtHostName.getText());
                settings.setUserName(txtUserName.getText());
                StringBuilder buf = new StringBuilder();
                for(char ch : txtPassword.getPassword()) {
                    buf.append(ch);
                }
                settings.setPassword(buf.toString());
                int itemsPerPage;
                try {
                    itemsPerPage = Integer.parseInt(txtIssuesPerPage.getText());
                } catch (Exception ex) {
                    itemsPerPage = -1;
                }
                settings.setItemsPerPage(itemsPerPage);
                settings.setProjectID(projectID);
                ApplicationManager.getApplication().invokeLater(()->{
                    ToolWindow window = manager.getToolWindow("Show MantisBT-Issues");
                    ContentImpl content = new ContentImpl(null, "", true);
                    content.setDescription("reload comboBoxes");
                    window.getContentManager().addContent(content);
                });
                settings.setFastTrack(chkFastTrackEnabled.isSelected());
            } catch (Exception ex) {
                Helper.printException(ex);
            } finally {
                component.setCursor(Cursor.getDefaultCursor());
            }
        }
    };
}
 
开发者ID:domjos1994,项目名称:ideaMantis,代码行数:38,代码来源:IdeaMantisConfigurable.java

示例10: startNewBackgroundTask

import com.intellij.openapi.progress.Task; //导入方法依赖的package包/类
protected void startNewBackgroundTask(@NotNull final Task.Backgroundable refreshTask) {
  UIUtil.invokeLaterIfNeeded(new Runnable() {
    @Override
    public void run() {
      LOG.debug("Starting a background task...");
      ((ProgressManagerImpl)ProgressManager.getInstance()).runProcessWithProgressAsynchronously(refreshTask);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:VcsLogRefresherImpl.java

示例11: sendError

import com.intellij.openapi.progress.Task; //导入方法依赖的package包/类
public static void sendError(Project project,
                             final String login,
                             final String password,
                             final ErrorBean error,
                             final Consumer<Integer> callback,
                             final Consumer<Exception> errback) {
  if (StringUtil.isEmpty(login)) {
    return;
  }

  Task.Backgroundable task = new Task.Backgroundable(project, DiagnosticBundle.message("title.submitting.error.report")) {
    @Override
    public void run(@NotNull ProgressIndicator indicator) {
      try {
        int threadId = postNewThread(login, password, error);
        callback.consume(threadId);
      }
      catch (Exception ex) {
        errback.consume(ex);
      }
    }
  };

  if (project == null) {
    task.run(new EmptyProgressIndicator());
  }
  else {
    ProgressManager.getInstance().run(task);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:ITNProxy.java

示例12: push

import com.intellij.openapi.progress.Task; //导入方法依赖的package包/类
public void push(final boolean force) {
  Task.Backgroundable task = new Task.Backgroundable(myProject, "Pushing...", true) {
    @Override
    public void run(@NotNull ProgressIndicator indicator) {
      myPushSettings.saveExcludedRepoRoots(myExcludedRepositoryRoots);
      for (PushSupport support : myPushSupports) {
        doPush(support, force);
      }
    }
  };
  task.queue();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:PushController.java

示例13: analyze

import com.intellij.openapi.progress.Task; //导入方法依赖的package包/类
public void analyze() {
  final List<DependenciesBuilder> builders = new ArrayList<DependenciesBuilder>();

  final Task task;
  if (canStartInBackground()) {
    task = new Task.Backgroundable(myProject, getProgressTitle(), true, new PerformAnalysisInBackgroundOption(myProject)) {
      @Override
      public void run(@NotNull final ProgressIndicator indicator) {
        perform(builders);
      }

      @Override
      public void onSuccess() {
        DependenciesHandlerBase.this.onSuccess(builders);
      }
    };
  } else {
    task = new Task.Modal(myProject, getProgressTitle(), true) {
      @Override
      public void run(@NotNull ProgressIndicator indicator) {
        perform(builders);
      }

      @Override
      public void onSuccess() {
        DependenciesHandlerBase.this.onSuccess(builders);
      }
    };
  }
  ProgressManager.getInstance().run(task);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:DependenciesHandlerBase.java

示例14: filter

import com.intellij.openapi.progress.Task; //导入方法依赖的package包/类
@Override
public void filter() {
  final Task.Backgroundable task = new Task.Backgroundable(myProject, APPLYING_FILTER_TITLE) {
    @Override
    public void run(@NotNull ProgressIndicator indicator) {
      myModel.updateCustomFilter(getFilter());
    }
  };
  ProgressManager.getInstance().run(task);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:LogConsoleBase.java

示例15: runSensitiveOperation

import com.intellij.openapi.progress.Task; //导入方法依赖的package包/类
@Override
public void runSensitiveOperation(@NotNull ProgressIndicator progressIndicator, boolean cancellable, @NotNull final Runnable operation) {
  final Application application = ApplicationManager.getApplication();
  application.assertIsDispatchThread();
  if (!myCurrentProgressIndicator.compareAndSet(null, progressIndicator)) {
    throw new IllegalStateException("Submitting an operation while another is in progress.");
  }
  final JRootPane rootPane = myFrame.getRootPane();
  final JButton defaultButton = rootPane.getDefaultButton();
  rootPane.setDefaultButton(null);
  updateButtons(false, false, true, false);
  Task.Backgroundable task = new LongRunningOperationWrapper(operation, cancellable, defaultButton);
  ProgressManager.getInstance().runProcessWithProgressAsynchronously(task, progressIndicator);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:FirstRunWizardHost.java


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