本文整理匯總了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);
}
});
}
示例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];
}
示例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();
}
示例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);
}
}
});
}
示例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);
}
}
}
}
});
}
}
示例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());
}
}
示例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);
}
}
});
}
示例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;
}
}
示例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);
}
});
}
示例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"));
}
});
}
示例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();
}
示例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();
}
示例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);
}
}
});
}
示例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);
}
}
});
}
示例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();
}