• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TransactionGuard类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: prefetchProjectFiles

import com.intellij.openapi.application.TransactionGuard; //导入依赖的package包/类
private static void prefetchProjectFiles(Project project) {
  if (!Blaze.isBlazeProject(project)) {
    return;
  }
  BlazeProjectData projectData = getBlazeProjectData(project);
  ProjectViewSet projectViewSet = ProjectViewManager.getInstance(project).getProjectViewSet();
  if (projectViewSet == null) {
    return;
  }
  long start = System.currentTimeMillis();
  ListenableFuture<?> future =
      PrefetchService.getInstance().prefetchProjectFiles(project, projectViewSet, projectData);
  TransactionGuard.submitTransaction(
      project,
      () -> {
        DumbService.getInstance(project).queueTask(new PrefetchTask(future, start));
      });
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:19,代码来源:PrefetchProjectInitializer.java


示例2: refactor

import com.intellij.openapi.application.TransactionGuard; //导入依赖的package包/类
private void refactor(String currentStepText, String newStepText, TransactionId contextTransaction, CompileContext context, RefactorStatusCallback refactorStatusCallback) {
    refactorStatusCallback.onStatusChange("Refactoring...");
    Module module = GaugeUtil.moduleForPsiElement(file);
    TransactionGuard.getInstance().submitTransaction(() -> {
    }, contextTransaction, () -> {
        Api.PerformRefactoringResponse response = null;
        FileDocumentManager.getInstance().saveAllDocuments();
        FileDocumentManager.getInstance().saveDocumentAsIs(editor.getDocument());
        GaugeService gaugeService = Gauge.getGaugeService(module, true);
        try {
            response = gaugeService.getGaugeConnection().sendPerformRefactoringRequest(currentStepText, newStepText);
        } catch (Exception e) {
            refactorStatusCallback.onFinish(new RefactoringStatus(false, String.format("Could not execute refactor command: %s", e.toString())));
            return;
        }
        new UndoHandler(response.getFilesChangedList(), module.getProject(), "Refactoring").handle();
        if (!response.getSuccess()) {
            showMessage(response, context, refactorStatusCallback);
            return;
        }
        refactorStatusCallback.onFinish(new RefactoringStatus(true));
    });
}
 
开发者ID:getgauge,项目名称:Intellij-Plugin,代码行数:24,代码来源:GaugeRefactorHandler.java


示例3: updateRouteList

import com.intellij.openapi.application.TransactionGuard; //导入依赖的package包/类
/**
 * Updates route list. The method starts task that call 'rake routes' and parses result after complete.
 * After routes are parsed, Routes panel is updated.
 *
 * @return True if update task is started, false if new task is not started because routes update is in progress.
 */
public boolean updateRouteList() {
    if (isUpdating())
        return false;

    setState(UPDATING);

    // Save all documents to make sure that requestMethods will be collected using actual files.
    TransactionGuard.submitTransaction(ApplicationManager.getApplication(), () -> {
        FileDocumentManager.getInstance().saveAllDocuments();

        // Start background task.
        (new UpdateRoutesTask()).queue();
    });

    return true;
}
 
开发者ID:basgren,项目名称:railways,代码行数:23,代码来源:RoutesManager.java


示例4: performActionDumbAware

import com.intellij.openapi.application.TransactionGuard; //导入依赖的package包/类
public static void performActionDumbAware(AnAction action, AnActionEvent e) {
  Runnable runnable = new Runnable() {
    @Override
    public void run() {
      try {
        action.actionPerformed(e);
      }
      catch (IndexNotReadyException e1) {
        showDumbModeWarning(e);
      }
    }

    @Override
    public String toString() {
      return action + " of " + action.getClass();
    }
  };

  if (action.startInTransaction()) {
    TransactionGuard.getInstance().submitTransactionAndWait(runnable);
  }
  else {
    runnable.run();
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:26,代码来源:ActionUtil.java


示例5: run

import com.intellij.openapi.application.TransactionGuard; //导入依赖的package包/类
public void run(boolean newConfigFolder) {
  try {
    ApplicationEx app = ApplicationManagerEx.getApplicationEx();
    app.load(PathManager.getOptionsPath());

    if (myPostStarter.needStartInTransaction()) {
      ((TransactionGuardImpl)TransactionGuard.getInstance()).performUserActivity(() -> myPostStarter.main(newConfigFolder, myArgs));
    }
    else {
      myPostStarter.main(newConfigFolder, myArgs);
    }

    myPostStarter = null;

    ourLoaded = true;
  }
  catch (Exception e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:21,代码来源:ApplicationStarter.java


示例6: afterItemInsertion

import com.intellij.openapi.application.TransactionGuard; //导入依赖的package包/类
public static void afterItemInsertion(final CompletionProgressIndicator indicator, final Runnable laterRunnable) {
  if (laterRunnable != null) {
    ActionTracker tracker = new ActionTracker(indicator.getEditor(), indicator);
    Runnable wrapper = () -> {
      if (!indicator.getProject().isDisposed() && !tracker.hasAnythingHappened()) {
        laterRunnable.run();
      }
      indicator.disposeIndicator();
    };
    if (ApplicationManager.getApplication().isUnitTestMode()) {
      wrapper.run();
    }
    else {
      TransactionGuard.getInstance().submitTransactionLater(indicator, wrapper);
    }
  }
  else {
    indicator.disposeIndicator();
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:21,代码来源:CodeCompletionHandlerBase.java


示例7: chooseActionAndInvoke

import com.intellij.openapi.application.TransactionGuard; //导入依赖的package包/类
static boolean chooseActionAndInvoke(@Nonnull PsiFile hostFile,
                                     @Nullable final Editor hostEditor,
                                     @Nonnull final IntentionAction action,
                                     @Nonnull String text,
                                     @Nonnull final Project project) {
  FeatureUsageTracker.getInstance().triggerFeatureUsed("codeassists.quickFix");
  ((FeatureUsageTrackerImpl)FeatureUsageTracker.getInstance()).getFixesStats().registerInvocation();

  PsiDocumentManager.getInstance(project).commitAllDocuments();

  Pair<PsiFile, Editor> pair = chooseFileForAction(hostFile, hostEditor, action);
  if (pair == null) return false;

  CommandProcessor.getInstance()
          .executeCommand(project, () -> TransactionGuard.getInstance().submitTransactionAndWait(() -> invokeIntention(action, pair.second, pair.first)),
                          text, null);
  return true;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:19,代码来源:ShowIntentionActionsHandler.java


示例8: reloadPsi

import com.intellij.openapi.application.TransactionGuard; //导入依赖的package包/类
private static void reloadPsi(final VirtualFile file, final Project project) {
  final FileManagerImpl fileManager = (FileManagerImpl)((PsiManagerEx)PsiManager.getInstance(project)).getFileManager();
  if (fileManager.findCachedViewProvider(file) != null) {
    Runnable runnable = new Runnable() {
      @Override
      public void run() {
        WriteAction.run(new ThrowableRunnable<RuntimeException>() {
          @Override
          public void run() throws RuntimeException {
            fileManager.forceReload(file);
          }
        });
      }
    };
    if (ApplicationManager.getApplication().isDispatchThread()) {
      runnable.run();
    } else {
      TransactionGuard.submitTransaction(project, runnable);
    }
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:22,代码来源:PushedFilePropertiesUpdaterImpl.java


示例9: openOptionOrPerformAction

import com.intellij.openapi.application.TransactionGuard; //导入依赖的package包/类
public static void openOptionOrPerformAction(@Nonnull Object element,
                                             final String enteredText,
                                             @Nullable final Project project,
                                             Component component,
                                             @Nullable AnActionEvent e) {
  if (element instanceof OptionDescription) {
    final String configurableId = ((OptionDescription)element).getConfigurableId();
    TransactionGuard.getInstance().submitTransactionLater(project != null ? project : ApplicationManager.getApplication(), new Runnable() {
      @Override
      public void run() {
        ShowSettingsUtilImpl.showSettingsDialog(project, configurableId, enteredText);
      }
    });
  }
  else {
    performAction(element, component, e);
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:19,代码来源:GotoActionAction.java


示例10: doDrop

import com.intellij.openapi.application.TransactionGuard; //导入依赖的package包/类
private void doDrop(TreeNode targetNode, PsiElement[] sourceElements) {
  final PsiElement targetElement = getPsiElement(targetNode);
  if (targetElement == null) return;

  if (DumbService.isDumb(myProject)) {
    Messages.showMessageDialog(myProject, "Copy refactoring is not available while indexing is in progress", "Indexing", null);
    return;
  }

  final PsiDirectory psiDirectory;
  if (targetElement instanceof PsiDirectoryContainer) {
    final PsiDirectoryContainer directoryContainer = (PsiDirectoryContainer)targetElement;
    final PsiDirectory[] psiDirectories = directoryContainer.getDirectories();
    psiDirectory = psiDirectories.length != 0 ? psiDirectories[0] : null;
  }
  else if (targetElement instanceof PsiDirectory) {
    psiDirectory = (PsiDirectory)targetElement;
  }
  else {
    final PsiFile containingFile = targetElement.getContainingFile();
    LOG.assertTrue(containingFile != null);
    psiDirectory = containingFile.getContainingDirectory();
  }
  TransactionGuard.getInstance().submitTransactionAndWait(() -> CopyHandler.doCopy(sourceElements, psiDirectory));
}
 
开发者ID:consulo,项目名称:consulo,代码行数:26,代码来源:ProjectViewDropTarget.java


示例11: restartAnalysis

import com.intellij.openapi.application.TransactionGuard; //导入依赖的package包/类
protected void restartAnalysis(final Project project, final AnalysisScope scope)
{
	TransactionGuard guard = TransactionGuard.getInstance();
	TransactionId id = guard.getContextTransaction();
	DumbService.getInstance(project).smartInvokeLater(() -> TransactionGuard.getInstance().submitTransaction(project, id, () ->
	{
		if(DumbService.isDumb(project))
		{
			restartAnalysis(project, scope);
		}
		else
		{
			analyze(project, scope);
		}
	}));
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:17,代码来源:InferNullityAnnotationsAction.java


示例12: openProject

import com.intellij.openapi.application.TransactionGuard; //导入依赖的package包/类
@Nullable
private static Project openProject(@NotNull String projectPath) {
  final Project[] project = {null};
  ApplicationManager.getApplication().invokeAndWait(() -> {
    TransactionGuard.getInstance().submitTransactionAndWait(() ->
      project[0] = ProjectUtil.openProject(projectPath, null, true));
    requestFocus(project[0]);
  });
  return project[0];
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:11,代码来源:EduBuiltInServerUtils.java


示例13: rebuildSymbols

import com.intellij.openapi.application.TransactionGuard; //导入依赖的package包/类
private static void rebuildSymbols(Project project) {
  TransactionGuard.getInstance()
      .submitTransactionLater(
          project,
          () ->
              ApplicationManager.getApplication().runReadAction(() -> doRebuildSymbols(project)));
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:8,代码来源:BlazeNdkSupportEnabler.java


示例14: rebuildSymbols

import com.intellij.openapi.application.TransactionGuard; //导入依赖的package包/类
private static void rebuildSymbols(Project project, OCWorkspace workspace) {
  TransactionGuard.submitTransaction(
      project,
      () ->
          ApplicationManager.getApplication()
              .runReadAction(
                  () ->
                      OCWorkspaceModificationTrackersCompatUtils.getTrackers(project)
                          .getBuildSettingsChangesTracker()
                          .incModificationCount()));
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:12,代码来源:StubOCWorkspaceManager.java


示例15: compileAndRefactor

import com.intellij.openapi.application.TransactionGuard; //导入依赖的package包/类
void compileAndRefactor(String currentStepText, String newStepText, @Nullable RefactorStatusCallback refactorStatusCallback) {
    refactorStatusCallback.onStatusChange("Compiling...");
    TransactionId contextTransaction = TransactionGuard.getInstance().getContextTransaction();
    CompilerManager.getInstance(project).make((aborted, errors, warnings, context) -> {
        if (errors > 0) {
            refactorStatusCallback.onFinish(new RefactoringStatus(false, "Please fix all errors before refactoring."));
            return;
        }
        refactor(currentStepText, newStepText, contextTransaction, context, refactorStatusCallback);
    });
}
 
开发者ID:getgauge,项目名称:Intellij-Plugin,代码行数:12,代码来源:GaugeRefactorHandler.java


示例16: createGotToOptionsListener

import com.intellij.openapi.application.TransactionGuard; //导入依赖的package包/类
@Nonnull
private HyperlinkListener createGotToOptionsListener(@Nonnull final UsageTarget[] targets) {
  return new HyperlinkAdapter() {
    @Override
    protected void hyperlinkActivated(HyperlinkEvent e) {
      if (e.getDescription().equals(FIND_OPTIONS_HREF_TARGET)) {
        TransactionGuard.getInstance().submitTransactionAndWait(() -> FindManager.getInstance(myProject).showSettingsAndFindUsages(targets));
      }
    }
  };
}
 
开发者ID:consulo,项目名称:consulo,代码行数:12,代码来源:SearchForUsagesRunnable.java


示例17: createSearchInProjectListener

import com.intellij.openapi.application.TransactionGuard; //导入依赖的package包/类
@Nonnull
private HyperlinkListener createSearchInProjectListener() {
  return new HyperlinkAdapter() {
    @Override
    protected void hyperlinkActivated(HyperlinkEvent e) {
      if (e.getDescription().equals(SEARCH_IN_PROJECT_HREF_TARGET)) {
        PsiElement psiElement = getPsiElement(mySearchFor);
        if (psiElement != null) {
          TransactionGuard.getInstance().submitTransactionAndWait(
                  () -> FindManager.getInstance(myProject).findUsagesInScope(psiElement, GlobalSearchScope.projectScope(myProject)));
        }
      }
    }
  };
}
 
开发者ID:consulo,项目名称:consulo,代码行数:16,代码来源:SearchForUsagesRunnable.java


示例18: saveDocument

import com.intellij.openapi.application.TransactionGuard; //导入依赖的package包/类
public void saveDocument(@Nonnull final Document document, final boolean explicit) {
  ApplicationManager.getApplication().assertIsDispatchThread();
  ((TransactionGuardImpl)TransactionGuard.getInstance()).assertWriteActionAllowed();

  if (!myUnsavedDocuments.contains(document)) return;

  try {
    doSaveDocument(document, explicit);
  }
  catch (IOException e) {
    handleErrorsOnSave(Collections.singletonMap(document, e));
  }
  catch (SaveVetoException ignored) {
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:16,代码来源:FileDocumentManagerImpl.java


示例19: createChangeCharsetProcessor

import com.intellij.openapi.application.TransactionGuard; //导入依赖的package包/类
private static Processor<VirtualFile> createChangeCharsetProcessor() {
  return file -> {
    if (!(file instanceof VirtualFileSystemEntry)) return false;
    Document cachedDocument = FileDocumentManager.getInstance().getCachedDocument(file);
    if (cachedDocument == null) return true;
    ProgressManager.progress("Reloading files...", file.getPresentableUrl());
    TransactionGuard.submitTransaction(ApplicationManager.getApplication(), () -> clearAndReload(file));
    return true;
  };
}
 
开发者ID:consulo,项目名称:consulo,代码行数:11,代码来源:EncodingProjectManagerImpl.java


示例20: reloadAllFilesUnder

import com.intellij.openapi.application.TransactionGuard; //导入依赖的package包/类
private void reloadAllFilesUnder(@Nullable final VirtualFile root) {
  tryStartReloadWithProgress(() -> processSubFiles(root, file -> {
    if (!(file instanceof VirtualFileSystemEntry)) return true;
    Document cachedDocument = FileDocumentManager.getInstance().getCachedDocument(file);
    if (cachedDocument != null) {
      ProgressManager.progress("Reloading file...", file.getPresentableUrl());
      TransactionGuard.submitTransaction(myProject, () -> reload(file));
    }
    // for not loaded files deep under project, reset encoding to give them chance re-detect the right one later
    else if (file.isCharsetSet() && !file.equals(root)) {
      file.setCharset(null);
    }
    return true;
  }));
}
 
开发者ID:consulo,项目名称:consulo,代码行数:16,代码来源:EncodingProjectManagerImpl.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DefaultArtifactVersion类代码示例发布时间:2022-05-23
下一篇:
Java MemoryUnit类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap