當前位置: 首頁>>代碼示例>>Java>>正文


Java UIUtil.dispatchAllInvocationEvents方法代碼示例

本文整理匯總了Java中com.intellij.util.ui.UIUtil.dispatchAllInvocationEvents方法的典型用法代碼示例。如果您正苦於以下問題:Java UIUtil.dispatchAllInvocationEvents方法的具體用法?Java UIUtil.dispatchAllInvocationEvents怎麽用?Java UIUtil.dispatchAllInvocationEvents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.util.ui.UIUtil的用法示例。


在下文中一共展示了UIUtil.dispatchAllInvocationEvents方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testRemoveLibrary

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
public void testRemoveLibrary() throws IOException {
    CamelService service = ServiceManager.getService(myProject, CamelService.class);
    assertEquals(0, service.getLibraries().size());

    VirtualFile camelCoreVirtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(createTestArchive("camel-core-2.19.0.jar"));
    VirtualFile camelSpringVirtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(createTestArchive("camel-spring-2.19.0.jar"));

    final LibraryTable projectLibraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(myProject);

    Library springLibrary = addLibraryToModule(camelSpringVirtualFile, projectLibraryTable, "Maven: org.apache.camel:camel-spring:2.19.0-snapshot");
    Library coreLibrary = addLibraryToModule(camelCoreVirtualFile, projectLibraryTable, "Maven: org.apache.camel:camel-core:2.19.0-snapshot");

    UIUtil.dispatchAllInvocationEvents();
    assertEquals(2, service.getLibraries().size());
    assertEquals(true, service.isCamelPresent());

    ApplicationManager.getApplication().runWriteAction(() -> projectLibraryTable.removeLibrary(springLibrary));

    UIUtil.dispatchAllInvocationEvents();
    assertEquals(1, service.getLibraries().size());
}
 
開發者ID:camel-idea-plugin,項目名稱:camel-idea-plugin,代碼行數:22,代碼來源:CamelProjectComponentTestIT.java

示例2: doTest

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
protected void doTest(final boolean shouldSucceed) throws Exception {
  final String filePath = getTestFilePath();
  configureByFile(filePath);
  final PsiElement targetElement = TargetElementUtil.findTargetElement(getEditor(), TargetElementUtil.ELEMENT_NAME_ACCEPTED);
  assertTrue("<caret> is not on method name", targetElement instanceof PsiMember);
  final PsiMember psiMethod = (PsiMember)targetElement;

  try {
    MethodDuplicatesHandler.invokeOnScope(getProject(), psiMethod, new AnalysisScope(getFile()));
  }
  catch (RuntimeException e) {
    if (shouldSucceed) {
      fail("duplicates were not found");
    }
    return;
  }
  UIUtil.dispatchAllInvocationEvents();
  if (shouldSucceed) {
    checkResultByFile(filePath + ".after");
  }
  else {
    fail("duplicates found");
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:25,代碼來源:FindMethodDuplicatesBaseTest.java

示例3: doIntentionTest

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
@TestOnly
public static void doIntentionTest(@NotNull final CodeInsightTestFixture fixture, @NonNls final String action,
                                   @NotNull final String before, @NotNull final String after) {
  fixture.configureByFile(before);
  List<IntentionAction> availableIntentions = fixture.getAvailableIntentions();
  final IntentionAction intentionAction = findIntentionByText(availableIntentions, action);
  if (intentionAction == null) {
    Assert.fail("Action not found: " + action + " in place: " + fixture.getElementAtCaret() + " among " + availableIntentions);
  }
  new WriteCommandAction(fixture.getProject()) {
    @Override
    protected void run(@NotNull Result result) {
      fixture.launchAction(intentionAction);
    }
  }.execute();
  UIUtil.dispatchAllInvocationEvents();
  fixture.checkResultByFile(after, false);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:CodeInsightTestUtil.java

示例4: createProjectFromTemplate

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
protected Project createProjectFromTemplate(@NotNull String group, @Nullable String name, @Nullable Consumer<Step> adjuster) throws IOException {
  runWizard(group, name, null, adjuster);
  try {
    myCreatedProject = NewProjectUtil.createFromWizard(myWizard, null);
  }
  catch (Throwable e) {
    myCreatedProject = ContainerUtil.find(myProjectManager.getOpenProjects(), new Condition<Project>() {
      @Override
      public boolean value(Project project) {
        return myWizard.getProjectName().equals(project.getName());
      }
    });
    throw new RuntimeException(e);
  }
  assertNotNull(myCreatedProject);
  UIUtil.dispatchAllInvocationEvents();

  Project[] projects = myProjectManager.getOpenProjects();
  assertEquals(Arrays.asList(projects).toString(), 2, projects.length);
  return myCreatedProject;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:ProjectWizardTestCase.java

示例5: testRenamedPropertiesToUnknownAndBack

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
public void testRenamedPropertiesToUnknownAndBack() throws Exception {
  FileType propFileType = myFileTypeManager.getFileTypeByFileName("xx.properties");
  assertEquals("Properties", propFileType.getName());
  File file = createTempFile("xx.properties", "xx=yy");
  VirtualFile vFile = getVirtualFile(file);
  assertEquals(propFileType, myFileTypeManager.getFileTypeByFile(vFile));

  rename(vFile, "xx.zxmcnbzmxnbc");
  UIUtil.dispatchAllInvocationEvents();
  assertEquals(PlainTextFileType.INSTANCE, myFileTypeManager.getFileTypeByFile(vFile));

  rename(vFile, "xx.properties");
  myFileTypeManager.drainReDetectQueue();
  for (int i=0; i<100;i++) {
    PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
    UIUtil.dispatchAllInvocationEvents();

    assertEquals(propFileType, myFileTypeManager.getFileTypeByFile(vFile));
    assertEmpty(myFileTypeManager.dumpReDetectQueue());
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:FileTypesTest.java

示例6: testAllTheseConcurrentThreadsDoNotCrashAnything

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
public void testAllTheseConcurrentThreadsDoNotCrashAnything() throws Exception {
  long time = System.currentTimeMillis();
  for (int i = 0; i < 20/*00000*/; i++) {
    //System.out.println("i = " + i);
    getPsiManager().dropResolveCaches();
    ((PsiManagerEx)getPsiManager()).getFileManager().cleanupForNextTest();
    DaemonCodeAnalyzer.getInstance(getProject()).restart();

    configureFromFileText("Stress.java", text);
    List<HighlightInfo> infos = doHighlighting();
    assertEmpty(DaemonAnalyzerTestCase.filter(infos, HighlightSeverity.ERROR));
    UIUtil.dispatchAllInvocationEvents();
    FileEditorManagerEx.getInstanceEx(getProject()).closeAllFiles();
  }
  System.out.println(System.currentTimeMillis() - time+"ms");
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:HighlightStressTest.java

示例7: testText

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
public void testText() throws Exception {
  doTest("Text.txt");
  Charset ascii = CharsetToolkit.forName("US-ASCII");
  VirtualFile myVFile = myFile.getVirtualFile();
  FileDocumentManager.getInstance().saveAllDocuments();
  EncodingManager.getInstance().setEncoding(myVFile, ascii);
  UIUtil.dispatchAllInvocationEvents(); // wait for reload requests to bubble up
  assertEquals(ascii, myVFile.getCharset());
  int start = myEditor.getCaretModel().getOffset();
  type((char)0x445);
  type((char)0x438);
  int end = myEditor.getCaretModel().getOffset();

  Collection<HighlightInfo> infos = doHighlighting();
  HighlightInfo info = assertOneElement(infos);
  assertEquals("Unsupported characters for the charset 'US-ASCII'", info.getDescription());
  assertEquals(start, info.startOffset);
  assertEquals(end, info.endOffset);

  backspace();
  backspace();

  doDoTest(true, false);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:25,代碼來源:LossyEncodingTest.java

示例8: testBreakNameAttribute

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
public void testBreakNameAttribute() throws Exception {
  resetScanCounter();
  VirtualFile file1 = myFixture.copyFileToProject(VALUES1, "res/values/myvalues.xml");
  PsiFile psiFile1 = PsiManager.getInstance(getProject()).findFile(file1);
  assertNotNull(psiFile1);
  final ResourceFolderRepository resources = createRepository();
  assertNotNull(resources);
  assertTrue(resources.hasResourceItem(ResourceType.STRING, "app_name"));

  final long generation = resources.getModificationCount();
  final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(getProject());
  final Document document = documentManager.getDocument(psiFile1);
  assertNotNull(document);

  final int offset = document.getText().indexOf("name=\"app_name\">");
  WriteCommandAction.runWriteCommandAction(null, new Runnable() {
    @Override
    public void run() {
      document.replaceString(offset + 2, offset + 3, "o"); // name => nome
      documentManager.commitDocument(document);
    }
  });

  assertTrue(resources.isScanPending(psiFile1));
  UIUtil.dispatchAllInvocationEvents();
  UIUtil.invokeAndWaitIfNeeded(new Runnable() {
    @Override
    public void run() {
      ensureSingleScan();
      assertTrue(generation < resources.getModificationCount());
      assertFalse(resources.hasResourceItem(ResourceType.STRING, "app_name"));
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:35,代碼來源:ResourceFolderRepositoryTest.java

示例9: testChangeType

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
public void testChangeType() throws Exception {
  resetScanCounter();
  VirtualFile file1 = myFixture.copyFileToProject(VALUES1, "res/values/myvalues.xml");
  PsiFile psiFile1 = PsiManager.getInstance(getProject()).findFile(file1);
  assertNotNull(psiFile1);
  final ResourceFolderRepository resources = createRepository();
  assertNotNull(resources);
  assertTrue(resources.hasResourceItem(ResourceType.ID, "action_next"));
  assertFalse(resources.hasResourceItem(ResourceType.DIMEN, "action_next"));

  final long generation = resources.getModificationCount();
  final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(getProject());
  final Document document = documentManager.getDocument(psiFile1);
  assertNotNull(document);

  final int offset = document.getText().indexOf("\"id\" name=\"action_next\" />") + 1;
  WriteCommandAction.runWriteCommandAction(null, new Runnable() {
    @Override
    public void run() {
      document.replaceString(offset, offset + 2, "dimen");
      documentManager.commitDocument(document);
    }
  });
  assertTrue(resources.isScanPending(psiFile1));
  UIUtil.dispatchAllInvocationEvents();
  UIUtil.invokeAndWaitIfNeeded(new Runnable() {
    @Override
    public void run() {
      ensureSingleScan();
      assertTrue(generation < resources.getModificationCount());
      assertFalse(resources.hasResourceItem(ResourceType.ID, "action_next"));
      assertTrue(resources.hasResourceItem(ResourceType.DIMEN, "action_next"));
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:36,代碼來源:ResourceFolderRepositoryTest.java

示例10: testAutoImportCaretLocation2

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
public void testAutoImportCaretLocation2() throws Throwable {
  boolean old = CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY;
  try {
    CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = true;
    configureByText(StdFileTypes.JAVA, "class X { <caret>ArrayList c = new ArrayList(); }");
    ((UndoManagerImpl)UndoManager.getInstance(getProject())).flushCurrentCommandMerger();
    ((UndoManagerImpl)UndoManager.getInstance(getProject())).clearUndoRedoQueueInTests(getFile().getVirtualFile());
    type(" ");
    backspace();

    assertEquals(2, highlightErrors().size());
    UIUtil.dispatchAllInvocationEvents();

    int offset = myEditor.getCaretModel().getOffset();
    PsiReference ref = myFile.findReferenceAt(offset);
    assertTrue(ref instanceof PsiJavaCodeReferenceElement);

    ImportClassFixBase.Result result = new ImportClassFix((PsiJavaCodeReferenceElement)ref).doFix(getEditor(), true, false);
    assertEquals(ImportClassFixBase.Result.CLASS_AUTO_IMPORTED, result);
    UIUtil.dispatchAllInvocationEvents();

    assertEmpty(highlightErrors());
  }
  finally {
    CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = old;
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:28,代碼來源:ImportHelperTest.java

示例11: setUp

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
@Override
protected void setUp() throws Exception {
    super.setUp();
    File[] mavenArtifacts = getMavenArtifacts(CAMEL_CORE_MAVEN_ARTIFACT);
    VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(mavenArtifacts[0]);
    final LibraryTable projectLibraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(myModule.getProject());
    ApplicationManager.getApplication().runWriteAction(() -> {
        Library library = projectLibraryTable.createLibrary("Maven: " + CAMEL_CORE_MAVEN_ARTIFACT);
        final Library.ModifiableModel libraryModifiableModel = library.getModifiableModel();
        libraryModifiableModel.addRoot(virtualFile, OrderRootType.CLASSES);
        libraryModifiableModel.commit();
        ModuleRootModificationUtil.addDependency(myModule, library);
    });
    UIUtil.dispatchAllInvocationEvents();
}
 
開發者ID:camel-idea-plugin,項目名稱:camel-idea-plugin,代碼行數:16,代碼來源:CamelInspectXmlSimpleTestIT.java

示例12: ensureNotCalled

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
private static void ensureNotCalled(final Ref<Boolean> called1, final Ref<Boolean> called2) {
  UIUtil.dispatchAllInvocationEvents();
  UIUtil.invokeAndWaitIfNeeded(new Runnable() {
    @Override
    public void run() {
      assertFalse(called1.get());
      assertFalse(called2.get());
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:11,代碼來源:ResourceNotificationManagerTest.java

示例13: _testHugeFile

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
public void _testHugeFile() throws Exception {
  @NonNls String filePath =  "/psi/resolve/Thinlet.java";
  configureByFile(filePath);
  doHighlighting();

  int N = 42;
  long[] time = new long[N];
  for (int i = 0; i < N; i++) {
    DaemonCodeAnalyzer.getInstance(getProject()).restart();

    long start = System.currentTimeMillis();
    doHighlighting();
    long end = System.currentTimeMillis();
    time[i] = end - start;
    System.out.println("i = " + i + "; time= "+(end-start));

    UIUtil.dispatchAllInvocationEvents();
  }
  System.out.println("Average among the N/3 median times: " + ArrayUtil.averageAmongMedians(time, 3) + "ms");

  //System.out.println("JobLauncher.COUNT   = " + JobLauncher.COUNT);
  //System.out.println("JobLauncher.TINY    = " + JobLauncher.TINY_COUNT);
  //System.out.println("JobLauncher.LENGTH  = " + JobLauncher.LENGTH);
  //System.out.println("JobLauncher.ELAPSED = " + JobLauncher.ELAPSED);
  //System.out.println("Ave length : "+(JobLauncher.LENGTH.get()/1.0/JobLauncher.COUNT.get()));
  //System.out.println("Ave elapsed: "+(JobLauncher.ELAPSED.get()/1.0/JobLauncher.COUNT.get()));
  //
  //JobLauncher.lengths.sort();
  //System.out.println("Lengths: "+JobLauncher.lengths);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:31,代碼來源:HighlightStressTest.java

示例14: setUp

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
@Override
protected void setUp() throws Exception {
  super.setUp();
  if (ourTestCase != null) {
    String message = "Previous test " + ourTestCase + " hasn't called tearDown(). Probably overridden without super call.";
    ourTestCase = null;
    fail(message);
  }
  IdeaLogger.ourErrorsOccurred = null;

  LOG.info(getClass().getName() + ".setUp()");

  initApplication();

  myEditorListenerTracker = new EditorListenerTracker();
  myThreadTracker = new ThreadTracker();

  setUpProject();

  storeSettings();
  ourTestCase = this;
  if (myProject != null) {
    ProjectManagerEx.getInstanceEx().openTestProject(myProject);
    CodeStyleSettingsManager.getInstance(myProject).setTemporarySettings(new CodeStyleSettings());
    InjectedLanguageManagerImpl.pushInjectors(getProject());
  }

  DocumentCommitThread.getInstance().clearQueue();
  UIUtil.dispatchAllInvocationEvents();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:31,代碼來源:PlatformTestCase.java

示例15: refreshVFS

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
private static void refreshVFS() {
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    @Override
    public void run() {
      VirtualFileManager.getInstance().syncRefresh();
    }
  });
  UIUtil.dispatchAllInvocationEvents();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:10,代碼來源:VirtualFilePointerTest.java


注:本文中的com.intellij.util.ui.UIUtil.dispatchAllInvocationEvents方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。