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


Java UIUtil.invokeAndWaitIfNeeded方法代碼示例

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


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

示例1: highlightLine

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
private void highlightLine(int index, NamedTextAttr namedTextAttr) {
    UIUtil.invokeAndWaitIfNeeded((Runnable) () -> {
        try {
            MarkupModelEx markupModel = myEditor.getMarkupModel();
            final Document doc = markupModel.getDocument();
            final int lineStartOffset = doc.getLineStartOffset(index);
            final int lineEndOffset = doc.getLineEndOffset(index);
            // IDEA-53203: add ERASE_MARKER for manually defined attributes
            markupModel.addRangeHighlighter(lineStartOffset, lineEndOffset,
                    HighlighterLayer.SELECTION - 1, TextAttributes.ERASE_MARKER,
                    HighlighterTargetArea.EXACT_RANGE);
            RangeHighlighter rangeHighlight =
                    markupModel.addRangeHighlighter(lineStartOffset, lineEndOffset,
                            HighlighterLayer.SELECTION - 1, namedTextAttr,
                            HighlighterTargetArea.EXACT_RANGE);
            rangeHighlight.setErrorStripeMarkColor(namedTextAttr.getErrorStripeColor());
            rangeHighlight.setErrorStripeTooltip(namedTextAttr.getName());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    });
}
 
開發者ID:huoguangjin,項目名稱:MultiHighlight,代碼行數:23,代碼來源:ColorPreviewPanel.java

示例2: inspectCode

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
public CodeSmellInfo[] inspectCode(final String path, String fileContent) {
    final CodeSmellInfo[][] resultsWrapper = new CodeSmellInfo[1][];
    UIUtil.invokeAndWaitIfNeeded(new Runnable() {
        @Override
        public void run() {
            final PsiFile targetPsiFile = EmbeditorUtil.findTargetFile(path);
            Project project = targetPsiFile.getProject();
            if (targetPsiFile != null) {
                List<VirtualFile> virtualFiles = new ArrayList<VirtualFile>();
                virtualFiles.add(EmbeditorUtil.createDummyVirtualFile(project, fileContent, targetPsiFile));
                List<CodeSmellInfo> problems = CodeSmellDetector.getInstance(project).findCodeSmells(virtualFiles);
                resultsWrapper[0] = problems.toArray(new CodeSmellInfo[problems.size()]);
            }
        }
    });
    return resultsWrapper[0];
}
 
開發者ID:vhakulinen,項目名稱:neovim-intellij-complete,代碼行數:18,代碼來源:EmbeditorRequestHandler.java

示例3: showDialogAndGetExitCode

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
@Nullable
private PushUpdateSettings showDialogAndGetExitCode(@NotNull final Set<GitRepository> repositories,
                                                    @NotNull final PushUpdateSettings initialSettings,
                                                    final boolean rebaseOverMergeProblemDetected) {
  final Ref<PushUpdateSettings> updateSettings = Ref.create();
  UIUtil.invokeAndWaitIfNeeded(new Runnable() {
    @Override
    public void run() {
      GitRejectedPushUpdateDialog dialog = new GitRejectedPushUpdateDialog(myProject, repositories, initialSettings,
                                                                           rebaseOverMergeProblemDetected);
      DialogManager.show(dialog);
      int exitCode = dialog.getExitCode();
      if (exitCode != DialogWrapper.CANCEL_EXIT_CODE) {
        mySettings.setAutoUpdateIfPushRejected(dialog.shouldAutoUpdateInFuture());
        updateSettings.set(new PushUpdateSettings(dialog.shouldUpdateAll(), convertUpdateMethodFromDialogExitCode(exitCode)));
      }
    }
  });
  return updateSettings.get();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:GitPushOperation.java

示例4: tearDown

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
@After
public void tearDown() throws Exception {
  UIUtil.invokeAndWaitIfNeeded(new Runnable() {
    @Override
    public void run() {
      try {
        myVcsManager.unregisterVcs(myVcs);
        myVcsManager = null;
        myVcs = null;

        tearDownProject();
        if (myTempDirFixture != null) {
          myTempDirFixture.tearDown();
          myTempDirFixture = null;
        }
        FileUtil.delete(myClientRoot);
      }
      catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:24,代碼來源:IgnoredFilesTest.java

示例5: openFiles

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
public void openFiles() {
  if (mySplittersElement != null) {
    initializeProgress();
    final JPanel comp = myUIBuilder.process(mySplittersElement, getTopPanel());
    UIUtil.invokeAndWaitIfNeeded(new Runnable() {
      @Override
      public void run() {
        if (comp != null) {
          removeAll();
          add(comp, BorderLayout.CENTER);
          mySplittersElement = null;
        }
        // clear empty splitters
        for (EditorWindow window : getWindows()) {
          if (window.getEditors().length == 0) {
            for (EditorWindow sibling : window.findSiblings()) {
              sibling.unsplit(false);
            }
          }
        }
      }
    });
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:25,代碼來源:EditorsSplitters.java

示例6: run

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
@Override
public void run() {
    try {
        if (this.createTme == textFilterUpdateCreateTime) {
            UIUtil.invokeAndWaitIfNeeded((Runnable) () -> {
                try {
                    task.run();
                } catch (Exception ignored) {
                }
            });
        }
    } catch (Exception t) {
        debug(t.getMessage());
    }
}
 
開發者ID:josesamuel,項目名稱:logviewer,代碼行數:16,代碼來源:LogView.java

示例7: notifyDeviceUpdated

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
/**
 * Called when device is updated
 */
private void notifyDeviceUpdated(IDevice device) {
    UIUtil.invokeAndWaitIfNeeded((Runnable) () -> {
        if (project.isDisposed()) {
            return;
        }
        if (device != null) {
            LogSource logSource = getSource(device);
            if (logSource != selectedSource) {
                onSourceSelected(logSource);
            }
        }
    });
}
 
開發者ID:josesamuel,項目名稱:logviewer,代碼行數:17,代碼來源:LogSourceManager.java

示例8: checkLoginWorker

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
public static ThreeState checkLoginWorker(final CvsLoginWorker worker, final boolean forceCheckParam)
  throws AuthenticationException {
  boolean forceCheck = forceCheckParam;
  final Ref<Boolean> promptResult = new Ref<Boolean>();
  final Runnable prompt = new Runnable() {
    @Override
    public void run() {
      promptResult.set(worker.promptForPassword());
    }
  };
  while (true) {
    final ThreeState state = worker.silentLogin(forceCheck);
    if (ThreeState.YES.equals(state)) return ThreeState.YES;
    if (ThreeState.NO.equals(state)) return state;
    try {
      // hack: allow indeterminate progress bar time to appear before displaying login dialog.
      // otherwise progress bar without cancel button appears on top of login dialog, blocking input and hanging IDEA.
      Thread.sleep(1000L);
    }
    catch (InterruptedException ignore) {
      return ThreeState.NO;
    }
    UIUtil.invokeAndWaitIfNeeded(prompt);
    if (! Boolean.TRUE.equals(promptResult.get())) {
      return ThreeState.UNSURE; // canceled
    }
    forceCheck = true;
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:30,代碼來源:LoginPerformer.java

示例9: exec

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
protected void exec(final String command) throws InterruptedException {
  waitForReady();
  myCommandSemaphore.acquire(1);
  UIUtil.invokeAndWaitIfNeeded(new Runnable() {
    @Override
    public void run() {
      myConsoleView.executeInConsole(command);
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:11,代碼來源:PyConsoleTask.java

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

示例11: unfreezeInAwt

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
private void unfreezeInAwt() {
  RethrowingRunnable rethrowingRunnable = new RethrowingRunnable(new Runnable() {
    @Override public void run() {
      unfreeze();
    }
  });
  UIUtil.invokeAndWaitIfNeeded(rethrowingRunnable);
  rethrowingRunnable.rethrowIfHappened();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:10,代碼來源:GitFreezingProcess.java

示例12: saveAndBlockInAwt

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
private void saveAndBlockInAwt() {
  RethrowingRunnable rethrowingRunnable = new RethrowingRunnable(new Runnable() {
    @Override public void run() {
      saveAndBlock(myFacade);
    }
  });
  UIUtil.invokeAndWaitIfNeeded(rethrowingRunnable);
  rethrowingRunnable.rethrowIfHappened();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:10,代碼來源:GitFreezingProcess.java

示例13: setUp

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
@BeforeMethod
public void setUp() throws Exception {
  UIUtil.invokeAndWaitIfNeeded(new Runnable() {
    @Override
    public void run() {
      try {
        final IdeaTestFixtureFactory fixtureFactory = IdeaTestFixtureFactory.getFixtureFactory();
        final TestFixtureBuilder<IdeaProjectTestFixture> testFixtureBuilder = fixtureFactory.createFixtureBuilder(getClass().getSimpleName());
        myFixture = JavaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(testFixtureBuilder.getFixture());
        final String dataPath = PluginPathManager.getPluginHomePath("testng") + "/testData";
        myFixture.setTestDataPath(dataPath);
        final JavaModuleFixtureBuilder builder = testFixtureBuilder.addModule(JavaModuleFixtureBuilder.class);

        builder.addContentRoot(myFixture.getTempDirPath()).addSourceRoot("");
        //    builder.addContentRoot(dataPath);
        builder.setMockJdkLevel(JavaModuleFixtureBuilder.MockJdkLevel.jdk15);
        myFixture.setUp();
        final JavaPsiFacade facade = JavaPsiFacade.getInstance(myFixture.getProject());
        myLanguageLevel = LanguageLevelProjectExtension.getInstance(facade.getProject()).getLanguageLevel();
        LanguageLevelProjectExtension.getInstance(facade.getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
      }
      catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:28,代碼來源:AddTestNGJarFixTest.java

示例14: setUp

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
@BeforeMethod
@Override
protected void setUp() throws Exception {
  UIUtil.invokeAndWaitIfNeeded(new Runnable() {
    @Override
    public void run() {
      try {
        TestNGSuiteTest.super.setUp();
      }
      catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:16,代碼來源:TestNGSuiteTest.java

示例15: unblockInAwt

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
private void unblockInAwt() {
  RethrowingRunnable rethrowingRunnable = new RethrowingRunnable(new Runnable() {
    @Override public void run() {
      unblock(myFacade);
    }
  });
  UIUtil.invokeAndWaitIfNeeded(rethrowingRunnable);
  rethrowingRunnable.rethrowIfHappened();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:10,代碼來源:GitFreezingProcess.java


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