com.intellij.openapi.progress.Task Java Examples
The following examples show how to use
com.intellij.openapi.progress.Task.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TeamServicesSettingsModel.java From azure-devops-intellij with MIT License | 6 votes |
/** * Update the auth info for each context selected */ public void updatePasswords() { final ListSelectionModel selectionModel = getTableSelectionModel(); if (!selectionModel.isSelectionEmpty()) { if (Messages.showYesNoDialog(project, TfPluginBundle.message(TfPluginBundle.KEY_SETTINGS_PASSWORD_MGT_DIALOG_UPDATE_MSG), TfPluginBundle.message(TfPluginBundle.KEY_SETTINGS_PASSWORD_MGT_DIALOG_UPDATE_TITLE), Messages.getQuestionIcon()) == Messages.YES) { final List<ServerContext> contexts = tableModel.getSelectedContexts(); final Task.Backgroundable updateAuthTask = new Task.Backgroundable(project, TfPluginBundle.message(TfPluginBundle.KEY_SETTINGS_PASSWORD_MGT_UPDATING)) { @Override public void run(final ProgressIndicator indicator) { logger.info("Updating passwords for user. Selected: " + contexts.size()); ServerContextManager.getInstance().updateServerContextsAuthInfo(contexts); populateContextTable(); } }; updateAuthTask.queue(); } } else { Messages.showWarningDialog(project, TfPluginBundle.message(TfPluginBundle.KEY_SETTINGS_PASSWORD_MGT_NO_ROWS_SELECTED), TfPluginBundle.message(TfPluginBundle.KEY_SETTINGS_PASSWORD_MGT_DIALOG_UPDATE_TITLE)); } }
Example #2
Source File: FavoriteAction.java From leetcode-editor with Apache License 2.0 | 6 votes |
@Override public void setSelected(AnActionEvent anActionEvent, boolean b) { JTree tree = WindowFactory.getDataContext(anActionEvent.getProject()).getData(DataKeys.LEETCODE_PROJECTS_TREE); Question question = ViewManager.getTreeQuestion(tree, anActionEvent.getProject()); if (question == null) { return; } ProgressManager.getInstance().run(new Task.Backgroundable(anActionEvent.getProject(),"leetcode.editor.favorite",false) { @Override public void run(@NotNull ProgressIndicator progressIndicator) { if (b) { FavoriteManager.addQuestionToFavorite(tag, question, anActionEvent.getProject()); } else { FavoriteManager.removeQuestionFromFavorite(tag, question, anActionEvent.getProject()); } } }); }
Example #3
Source File: FindTagAction.java From leetcode-editor with Apache License 2.0 | 6 votes |
@Override public void setSelected(AnActionEvent anActionEvent, boolean b) { tag.setSelect(b); JTree tree = WindowFactory.getDataContext(anActionEvent.getProject()).getData(DataKeys.LEETCODE_PROJECTS_TREE); if (tree == null) { return; } if (againLoad) { ProgressManager.getInstance().run(new Task.Backgroundable(anActionEvent.getProject(), "leetcode.editor." + tag.getName(), false) { @Override public void run(@NotNull ProgressIndicator progressIndicator) { if (b) { ViewManager.loadServiceData(tree, anActionEvent.getProject(), tag.getType()); } else { ViewManager.loadServiceData(tree, anActionEvent.getProject()); } } }); } else { ViewManager.update(tree); } }
Example #4
Source File: TreeWillListener.java From leetcode-editor with Apache License 2.0 | 6 votes |
@Override public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException { TreePath selPath = event.getPath(); DefaultMutableTreeNode node = (DefaultMutableTreeNode) selPath.getLastPathComponent(); Question question = (Question) node.getUserObject(); if (!isOneOpen(node)) { return; } else if ("lock".equals(question.getStatus())) { MessageUtils.showMsg(toolWindow.getContentManager().getComponent(), MessageType.INFO, "info", "no permissions"); throw new ExpandVetoException(event); } ProgressManager.getInstance().run(new Task.Backgroundable(project,"leetcode.editor.tree",false) { @Override public void run(@NotNull ProgressIndicator progressIndicator) { loadData(question,node,selPath,tree,toolWindow); } }); throw new ExpandVetoException(event); }
Example #5
Source File: ZipAndQueue.java From consulo with Apache License 2.0 | 6 votes |
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(@Nonnull ProgressIndicator indicator) { runnable.run(); } }; Disposer.register(project, new Disposable() { @Override public void dispose() { myZipperUpdater.stop(); } }); }
Example #6
Source File: TestExecutionState.java From buck with Apache License 2.0 | 6 votes |
private void schedulePostExecutionActions(final OSProcessHandler result, final String title) { final ProgressManager manager = ProgressManager.getInstance(); ApplicationManager.getApplication() .invokeLater( () -> { manager.run( new Task.Backgroundable(mProject, title, true) { @Override public void run(@NotNull final ProgressIndicator indicator) { try { result.waitFor(); } finally { indicator.cancel(); } BuckToolWindow buckToolWindow = BuckUIManager.getInstance(mProject).getBuckToolWindow(); if (!buckToolWindow.isRunToolWindowVisible()) { buckToolWindow.showRunToolWindow(); } } }); }); }
Example #7
Source File: LogConsoleBase.java From consulo with Apache License 2.0 | 6 votes |
@Override public JComponent getSearchComponent() { myLogFilterCombo.setModel(new DefaultComboBoxModel(myFilters.toArray(new LogFilter[myFilters.size()]))); resetLogFilter(); myLogFilterCombo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final LogFilter filter = (LogFilter)myLogFilterCombo.getSelectedItem(); final Task.Backgroundable task = new Task.Backgroundable(myProject, APPLYING_FILTER_TITLE) { @Override public void run(@Nonnull ProgressIndicator indicator) { myModel.selectFilter(filter); } }; ProgressManager.getInstance().run(task); } }); myTextFilterWrapper.removeAll(); myTextFilterWrapper.add(getTextFilterComponent()); return mySearchComponent; }
Example #8
Source File: ExtractMethodHelper.java From consulo with Apache License 2.0 | 6 votes |
public static void processDuplicates(@Nonnull final PsiElement callElement, @Nonnull final PsiElement generatedMethod, @Nonnull final List<PsiElement> scope, @Nonnull final SimpleDuplicatesFinder finder, @Nonnull final Editor editor, @Nonnull final Consumer<Pair<SimpleMatch, PsiElement>> replacer) { finder.setReplacement(callElement); if (ApplicationManager.getApplication().isUnitTestMode()) { replaceDuplicates(callElement, editor, replacer, finder.findDuplicates(scope, generatedMethod)); return; } final Project project = callElement.getProject(); ProgressManager.getInstance().run(new Task.Backgroundable(project, RefactoringBundle.message("searching.for.duplicates"), true) { public void run(@Nonnull ProgressIndicator indicator) { if (myProject == null || myProject.isDisposed()) return; final List<SimpleMatch> duplicates = ApplicationManager.getApplication().runReadAction(new Computable<List<SimpleMatch>>() { @Override public List<SimpleMatch> compute() { return finder.findDuplicates(scope, generatedMethod); } }); ApplicationManager.getApplication().invokeLater(() -> replaceDuplicates(callElement, editor, replacer, duplicates)); } }); }
Example #9
Source File: HistoryDialog.java From consulo with Apache License 2.0 | 6 votes |
protected ContentDiffRequest createDifference(final FileDifferenceModel m) { final Ref<ContentDiffRequest> requestRef = new Ref<>(); new Task.Modal(myProject, message("message.processing.revisions"), false) { public void run(@Nonnull final ProgressIndicator i) { ApplicationManager.getApplication().runReadAction(() -> { 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(); }
Example #10
Source File: ShelveChangesManager.java From consulo with Apache License 2.0 | 6 votes |
public void unshelveSilentlyAsynchronously(@Nonnull final Project project, @Nonnull final List<ShelvedChangeList> selectedChangeLists, @Nonnull final List<ShelvedChange> selectedChanges, @Nonnull final List<ShelvedBinaryFile> selectedBinaryChanges, @Nullable final LocalChangeList forcePredefinedOneChangelist) { ProgressManager.getInstance().run(new Task.Backgroundable(project, VcsBundle.message("unshelve.changes.progress.title"), true) { @Override public void run(@Nonnull ProgressIndicator indicator) { for (ShelvedChangeList changeList : selectedChangeLists) { List<ShelvedChange> changesForChangelist = ContainerUtil.newArrayList(ContainerUtil.intersection(changeList.getChanges(myProject), selectedChanges)); List<ShelvedBinaryFile> binariesForChangelist = ContainerUtil.newArrayList(ContainerUtil.intersection(changeList.getBinaryFiles(), selectedBinaryChanges)); boolean shouldUnshelveAllList = changesForChangelist.isEmpty() && binariesForChangelist.isEmpty(); unshelveChangeList(changeList, shouldUnshelveAllList ? null : changesForChangelist, shouldUnshelveAllList ? null : binariesForChangelist, forcePredefinedOneChangelist != null ? forcePredefinedOneChangelist : getChangeListUnshelveTo(changeList), true); } } }); }
Example #11
Source File: DisconnectServerAction.java From saros with GNU General Public License v2.0 | 6 votes |
@Override public void execute() { ProgressManager.getInstance() .run( new Task.Modal(project, "Disconnecting...", false) { @Override public void run(@NotNull ProgressIndicator indicator) { log.info( "Disconnecting current connection: " + connectionHandler.getConnectionID()); indicator.setIndeterminate(true); try { connectionHandler.disconnect(); } finally { indicator.stop(); } } }); }
Example #12
Source File: SymfonyWebDeploymentDownloadAction.java From idea-php-symfony2-plugin with MIT License | 6 votes |
public void actionPerformed(AnActionEvent e) { final Project project = CommonDataKeys.PROJECT.getData(e.getDataContext()); if (project == null) { return; } Deployable server = WebDeploymentDataKeys.DEPLOYABLE.getData(e.getDataContext()); if(server == null || !PublishConfig.getInstance(project).isDefault(server)) { return; } new Task.Backgroundable(project, "Symfony: Downloading Files", false) { @Override public void run(@NotNull ProgressIndicator indicator) { Symfony2ProjectComponent.getLogger().info("Running webDeployment dev download"); RemoteWebServerUtil.collectRemoteFiles(project); } }.queue(); }
Example #13
Source File: AsyncHelper.java From r2m-plugin-android with Apache License 2.0 | 6 votes |
private void runGeneration() { ProgressManager.getInstance().run(new Task.Backgroundable(project, MESSAGE_GENERATING_SERVICE, false) { public void run(@NotNull ProgressIndicator progressIndicator) { try { getGenerator().generate(progressIndicator); } catch (Exception e) { final String error = e.getMessage(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { onActionFailure(error); } }); return; } SwingUtilities.invokeLater(new Runnable() { @Override public void run() { onActionSuccess(GenerateActions.GENERATE_SUCCESS); } }); } }); }
Example #14
Source File: GitPushTagsAction.java From GitToolBox with Apache License 2.0 | 6 votes |
@Override protected void perform(@NotNull Project project, @NotNull List<VirtualFile> gitRoots, @NotNull VirtualFile defaultRoot) { GitPushTagsDialog dialog = new GitPushTagsDialog(project, gitRoots, defaultRoot); dialog.show(); if (dialog.isOK()) { final Optional<TagsPushSpec> pushSpec = dialog.getPushSpec(); if (pushSpec.isPresent()) { Task.Backgroundable task = new Task.Backgroundable(project, ResBundle.message("message.pushing"), false) { @Override public void run(@NotNull ProgressIndicator indicator) { GtPushResult result = GitTagsPusher.create(getProject(), indicator).push(pushSpec.get()); handleResult(getProject(), result); } }; GitVcs.runInBackground(task); } } }
Example #15
Source File: SkylarkDebugProcess.java From intellij with Apache License 2.0 | 6 votes |
private void waitForConnection() { ProgressManager.getInstance() .run( new Task.Backgroundable(project, "Connecting To Debugger", /* canBeCanceled= */ false) { @Override public void run(ProgressIndicator indicator) { indicator.setText("Waiting for connection..."); boolean success = transport.waitForConnection(); if (!success) { reportError("Failed to connect to the debugger"); transport.close(); getSession().stop(); return; } init(); } }); }
Example #16
Source File: Unity3dProjectImportUtil.java From consulo-unity3d with Apache License 2.0 | 6 votes |
/** * this method will called from webservice thread */ private static void syncProjectStep2(@Nonnull final Project project, @Nullable final Sdk sdk, @Nullable UnityOpenFilePostHandlerRequest requestor, final boolean runValidator, UnitySetDefines unitySetDefines) { Task.Backgroundable.queue(project, "Sync Project", indicator -> { AccessToken accessToken = HeavyProcessLatch.INSTANCE.processStarted("unity sync project"); try { importAfterDefines(project, sdk, runValidator, indicator, requestor, unitySetDefines); } finally { accessToken.finish(); } }); }
Example #17
Source File: BaseCoverageAnnotator.java From consulo with Apache License 2.0 | 6 votes |
public void renewCoverageData(@Nonnull final CoverageSuitesBundle suite, @Nonnull final CoverageDataManager dataManager) { final Runnable request = createRenewRequest(suite, dataManager); if (request != null) { if (myProject.isDisposed()) return; ProgressManager.getInstance().run(new Task.Backgroundable(myProject, "Loading coverage data...", false) { @Override public void run(@Nonnull ProgressIndicator indicator) { request.run(); } @RequiredUIAccess @Override public void onSuccess() { final CoverageView coverageView = CoverageViewManager.getInstance(myProject).getToolwindow(suite); if (coverageView != null) { coverageView.updateParentTitle(); } } }); } }
Example #18
Source File: DataWriter.java From GsonFormat with Apache License 2.0 | 6 votes |
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()); } }); }
Example #19
Source File: WorkspaceModel.java From azure-devops-intellij with MIT License | 6 votes |
public void saveWorkspace(final Project project, final String workspaceRootPath, final boolean syncFiles, final Runnable onSuccess) { final ServerContext serverContext = currentServerContext; final Workspace oldWorkspace = this.oldWorkspace; final Workspace newWorkspace = new Workspace(server, name, computer, owner, comment, mappings); // Using IntelliJ's background framework here so the user can choose to wait or continue working final Task.Backgroundable backgroundTask = new Task.Backgroundable(project, TfPluginBundle.message(TfPluginBundle.KEY_WORKSPACE_DIALOG_PROGRESS_TITLE), true, PerformInBackgroundOption.DEAF) { @Override public void run(@NotNull final ProgressIndicator indicator) { saveWorkspaceInternal(serverContext, oldWorkspace, newWorkspace, indicator, project, workspaceRootPath, syncFiles, onSuccess); } }; backgroundTask.queue(); }
Example #20
Source File: PantsProjectImportProvider.java From intellij-pants-plugin with Apache License 2.0 | 6 votes |
@Override public ModuleWizardStep[] createSteps(WizardContext context) { /** * Newer export version project sdk can be automatically discovered and configured. */ AtomicBoolean isSdkConfigured = new AtomicBoolean(true); String message = PantsBundle.message("pants.default.sdk.config.progress"); ProgressManager.getInstance().run(new Task.Modal(context.getProject(), message, !CAN_BE_CANCELLED) { @Override public void run(@NotNull ProgressIndicator indicator) { if (isSdkConfigured.get()) { isSdkConfigured.set(isJvmProject(context.getProjectFileDirectory())); } } }); if (isSdkConfigured.get()) { return super.createSteps(context); } return ArrayUtil.append(super.createSteps(context), new ProjectJdkStep(context)); }
Example #21
Source File: AsyncHelper.java From r2m-plugin-android with Apache License 2.0 | 6 votes |
private void performFileOperation() { project.save(); FileDocumentManager.getInstance().saveAllDocuments(); ProjectManagerEx.getInstanceEx().blockReloadingProjectOnExternalChanges(); ProgressManager.getInstance().run(new Task.Backgroundable(project, MESSAGE_GENERATING_SERVICE, false) { public void run(@NotNull ProgressIndicator progressIndicator) { getGenerator().makeFilePerformance(progressIndicator); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { onActionSuccess(GenerateActions.FILE_OPERATION_SUCCESS); } }); } }); }
Example #22
Source File: IdeaMMDPrintPanelAdaptor.java From netbeans-mmd-plugin with Apache License 2.0 | 6 votes |
@Override public void startBackgroundTask(@Nonnull final MMDPrintPanel source, @Nonnull final String taskName, @Nonnull final Runnable task) { final Task.Backgroundable backgroundTask = new Task.Backgroundable(this.project, taskName) { @Override public void run(@Nonnull final ProgressIndicator indicator) { try { indicator.setIndeterminate(true); task.run(); IdeaUtils.showPopup(String.format("%s has been sent to the printer", taskName), MessageType.INFO); } catch (Exception ex) { LOGGER.error("Print error", ex); IdeaUtils.showPopup("Print error! See the log!", MessageType.ERROR); } finally { indicator.stop(); } } }; ProgressManager.getInstance().run(backgroundTask); }
Example #23
Source File: AbstractRefactoringPanel.java From IntelliJDeodorant with MIT License | 6 votes |
/** * Compiles the project and runs the task only if there are no compilation errors. */ private static void runAfterCompilationCheck(ProjectInfo projectInfo, Task task) { ApplicationManager.getApplication().invokeLater(() -> { List<PsiClass> classes = projectInfo.getClasses(); if (!classes.isEmpty()) { VirtualFile[] virtualFiles = classes.stream() .map(classObject -> classObject.getContainingFile().getVirtualFile()).toArray(VirtualFile[]::new); Project project = projectInfo.getProject(); CompilerManager compilerManager = CompilerManager.getInstance(project); CompileStatusNotification callback = (aborted, errors, warnings, compileContext) -> { if (errors == 0 && !aborted) { ProgressManager.getInstance().run(task); } else { task.onCancel(); AbstractRefactoringPanel.showCompilationErrorNotification(project); } }; CompileScope compileScope = compilerManager.createFilesCompileScope(virtualFiles); compilerManager.make(compileScope, callback); } else { ProgressManager.getInstance().run(task); } }); }
Example #24
Source File: CoverageViewBuilder.java From consulo with Apache License 2.0 | 5 votes |
CoverageViewBuilder(final Project project, final JList list, final Model model, final AbstractTreeStructure treeStructure, final JBTable table) { super(project, list, model, treeStructure, AlphaComparator.INSTANCE, false); myTable = table; ProgressManager.getInstance().run(new Task.Backgroundable(project, "Building coverage report...") { @Override public void run(@Nonnull ProgressIndicator indicator) { buildRoot(); } @RequiredUIAccess @Override public void onSuccess() { ensureSelectionExist(); updateParentTitle(); } }); myFileStatusListener = new FileStatusListener() { @Override public void fileStatusesChanged() { table.repaint(); } @Override public void fileStatusChanged(@Nonnull VirtualFile virtualFile) { table.repaint(); } }; myCoverageViewExtension = ((CoverageViewTreeStructure)myTreeStructure).myData .getCoverageEngine().createCoverageViewExtension(myProject, ((CoverageViewTreeStructure)myTreeStructure).myData, ((CoverageViewTreeStructure)myTreeStructure).myStateBean); FileStatusManager.getInstance(myProject).addFileStatusListener(myFileStatusListener); }
Example #25
Source File: GraphQLConfigMigrationHelper.java From js-graphql-intellij-plugin with MIT License | 5 votes |
public static void checkGraphQLConfigJsonMigrations(Project project) { final Task.Backgroundable task = new Task.Backgroundable(project, "Verifying GraphQL Configuration", false) { @Override public void run(@NotNull ProgressIndicator indicator) { indicator.setIndeterminate(true); final GlobalSearchScope scope = GlobalSearchScope.projectScope(project); final Collection<VirtualFile> legacyConfigFiles = ApplicationManager.getApplication().runReadAction( (Computable<Collection<VirtualFile>>) () -> FilenameIndex.getVirtualFilesByName(project, "graphql.config.json", scope) ); for (VirtualFile virtualFile : legacyConfigFiles) { if (!virtualFile.isDirectory() && virtualFile.isInLocalFileSystem()) { boolean migrate = true; for (String fileName : GraphQLConfigManager.GRAPHQLCONFIG_FILE_NAMES) { if (virtualFile.getParent().findChild(fileName) != null) { migrate = false; break; } } if (migrate) { createMigrationNotification(project, virtualFile); } } } } }; ProgressManager.getInstance().run(task); }
Example #26
Source File: AbstractRefactoringPanel.java From IntelliJDeodorant with MIT License | 5 votes |
public static void runAfterCompilationCheck(Task.Backgroundable afterCompilationBackgroundable, Project project, ProjectInfo projectInfo) { final Task.Backgroundable compilationBackgroundable = new Task.Backgroundable(project, IntelliJDeodorantBundle.message("project.compiling.indicator.text"), true) { @Override public void run(@NotNull ProgressIndicator indicator) { runAfterCompilationCheck(projectInfo, afterCompilationBackgroundable); } }; ProgressManager.getInstance().run(compilationBackgroundable); }
Example #27
Source File: DependenciesHandlerBase.java From consulo with Apache License 2.0 | 5 votes |
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(@Nonnull final ProgressIndicator indicator) { perform(builders); } @RequiredUIAccess @Override public void onSuccess() { DependenciesHandlerBase.this.onSuccess(builders); } }; } else { task = new Task.Modal(myProject, getProgressTitle(), true) { @Override public void run(@Nonnull ProgressIndicator indicator) { perform(builders); } @RequiredUIAccess @Override public void onSuccess() { DependenciesHandlerBase.this.onSuccess(builders); } }; } ProgressManager.getInstance().run(task); }
Example #28
Source File: ShopwareInstallerProjectGenerator.java From idea-php-shopware-plugin with MIT License | 5 votes |
@Override public void generateProject(@NotNull final Project project, final @NotNull VirtualFile baseDir, final @NotNull ShopwareInstallerSettings settings, @NotNull Module module) { String downloadPath = settings.getVersion().getUrl(); String toDir = baseDir.getPath(); VirtualFile zipFile = PhpConfigurationUtil.downloadFile(project, null, toDir, downloadPath, "shopware.zip"); if (zipFile == null) { showErrorNotification(project, "Cannot download Shopware.zip file"); return; } // Convert files File zip = VfsUtil.virtualToIoFile(zipFile); File base = VfsUtil.virtualToIoFile(baseDir); Task.Backgroundable task = new Task.Backgroundable(project, "Extracting", true) { @Override public void run(@NotNull ProgressIndicator progressIndicator) { try { // unzip file ZipUtil.extract(zip, base, null); // Delete TMP File FileUtil.delete(zip); // Activate Plugin IdeHelper.enablePluginAndConfigure(project); } catch (IOException e) { showErrorNotification(project, "There is a error occurred"); } } }; ProgressManager.getInstance().run(task); }
Example #29
Source File: ErrorReportSender.java From consulo with Apache License 2.0 | 5 votes |
public static void sendReport(Project project, ErrorReportBean errorBean, final java.util.function.Consumer<String> callback, final Consumer<Exception> errback) { Task.Backgroundable.queue(project, DiagnosticBundle.message("title.submitting.error.report"), indicator -> { try { HttpConfigurable.getInstance().prepareURL(WebServiceApi.MAIN.buildUrl()); String id = sendAndHandleResult(errorBean); callback.accept(id); } catch (Exception ex) { errback.consume(ex); } }); }
Example #30
Source File: DecompileAndAttachAction.java From decompile-and-attach with MIT License | 5 votes |
@Override public void actionPerformed(AnActionEvent event) { Project project = event.getProject(); if (project == null) { return; } final Optional<String> baseDirPath = getBaseDirPath(project); if (!baseDirPath.isPresent()) { return; } VirtualFile[] sourceVFs = event.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY); checkState(sourceVFs != null && sourceVFs.length > 0, "event#getData(VIRTUAL_FILE_ARRAY) returned empty array"); new Task.Backgroundable(project, "Decompiling...", true) { @Override public void run(@NotNull ProgressIndicator indicator) { indicator.setFraction(0.1); Arrays.asList(sourceVFs).stream() // .filter((vf) -> "jar".equals(vf.getExtension())) // .forEach((sourceVF) -> process(project, baseDirPath.get(), sourceVF, indicator, 1D / sourceVFs.length)); indicator.setFraction(1.0); } @Override public boolean shouldStartInBackground() { return true; } }.queue(); }