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