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

Java AsyncResult类代码示例

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

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



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

示例1: finish

import com.intellij.openapi.util.AsyncResult; //导入依赖的package包/类
public AsyncResult<SwitchTarget> finish(final boolean fadeAway) {
  myAlarm.cancelAllRequests();

  final AsyncResult<SwitchTarget> result = new AsyncResult<SwitchTarget>();
  final SwitchTarget selection = getSelection();
  if (selection != null) {
    selection.switchTo(true).doWhenDone(new Runnable() {
      public void run() {
        myManager.disposeCurrentSession(fadeAway);
        result.setDone(selection);
      }
    }).notifyWhenRejected(result);
  } else {
    Disposer.dispose(this);
    result.setDone();
  }

  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:SwitchingSession.java


示例2: findDisposable

import com.intellij.openapi.util.AsyncResult; //导入依赖的package包/类
private static AsyncResult<Disposable> findDisposable(Disposable defaultValue, final DataKey<? extends Disposable> key) {
  if (defaultValue == null) {
    if (ApplicationManager.getApplication() != null) {
      final AsyncResult<Disposable> result = new AsyncResult<Disposable>();
      DataManager.getInstance().getDataContextFromFocus().doWhenDone(new Consumer<DataContext>() {
        public void consume(DataContext context) {
          Disposable disposable = key.getData(context);
          if (disposable == null) {
            disposable = Disposer.get("ui");
          }
          result.setDone(disposable);
        }
      });
      return result;
    }
    else {
      return null;
    }
  }
  else {
    return new AsyncResult.Done<Disposable>(defaultValue);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:LazyUiDisposable.java


示例3: wrap

import com.intellij.openapi.util.AsyncResult; //导入依赖的package包/类
@NotNull
public static <T> Promise<T> wrap(@NotNull AsyncResult<T> asyncResult) {
  final AsyncPromise<T> promise = new AsyncPromise<T>();
  asyncResult.doWhenDone(new Consumer<T>() {
    @Override
    public void consume(T result) {
      promise.setResult(result);
    }
  }).doWhenRejected(new Consumer<String>() {
    @Override
    public void consume(String error) {
      promise.setError(error);
    }
  });
  return promise;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:Promise.java


示例4: printFocus

import com.intellij.openapi.util.AsyncResult; //导入依赖的package包/类
public static AsyncResult<String> printFocus(final PlaybackContext context) {
  final AsyncResult result = new AsyncResult<String>();

  getUiReady(context).doWhenProcessed(new Runnable() {
    @Override
    public void run() {
      final LinkedHashMap<String, String> focusInfo = getFocusInfo();
      if (focusInfo == null) {
        result.setRejected("No component focused");
        return;
      }

      StringBuffer text = new StringBuffer();
      for (Iterator<String> iterator = focusInfo.keySet().iterator(); iterator.hasNext(); ) {
        String key = iterator.next();
        text.append(key + "=" + focusInfo.get(key));
        if (iterator.hasNext()) {
          text.append("|");
        }
      }
      result.setDone(text.toString());
    }
  });

  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:WindowSystemPlaybackCall.java


示例5: findProject

import com.intellij.openapi.util.AsyncResult; //导入依赖的package包/类
public static AsyncResult<Project> findProject() {
  final AsyncResult<Project> project = new AsyncResult<Project>();
  final IdeFocusManager fm = IdeFocusManager.getGlobalInstance();
  fm.doWhenFocusSettlesDown(new Runnable() {
    @Override
    public void run() {
      Component parent = UIUtil.findUltimateParent(fm.getFocusOwner());
      if (parent instanceof IdeFrame) {
        IdeFrame frame = (IdeFrame)parent;
        if (frame.getProject() != null) {
          project.setDone(frame.getProject());
          return;
        }
      }

      project.setRejected();
    }
  });

  return project;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:WindowSystemPlaybackCall.java


示例6: createUpdater

import com.intellij.openapi.util.AsyncResult; //导入依赖的package包/类
@Override
protected final AbstractTreeUpdater createUpdater() {
  return new AbstractTreeUpdater(this) {
    @Override
    protected ActionCallback beforeUpdate(final TreeUpdatePass pass) {
      if (!myDirtyFileSet.isEmpty()) { // suppress redundant cache validations
        final AsyncResult callback = new AsyncResult();
        DumbService.getInstance(myProject).runWhenSmart(new Runnable() {
          @Override
          public void run() {
            try {
              validateCache();
              getTodoTreeStructure().validateCache();
            }
            finally {
              callback.setDone();
            }
          }
        });
        return callback;
      }

      return ActionCallback.DONE;
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:TodoTreeBuilder.java


示例7: createStructureView

import com.intellij.openapi.util.AsyncResult; //导入依赖的package包/类
@Override
@NotNull
public StructureView createStructureView(final FileEditor fileEditor, @NotNull final Project project) {
  return new StructureViewComponent(fileEditor, createStructureViewModel(fileEditor instanceof TextEditor ? ((TextEditor)fileEditor).getEditor() : null), project, true) {
    @Override
    public AsyncResult<AbstractTreeNode> expandPathToElement(final Object element) {
      if (element instanceof XmlElement && ((XmlElement)element).isValid()) {
        final XmlElement xmlElement = (XmlElement)element;
        XmlTag tag = PsiTreeUtil.getParentOfType(xmlElement, XmlTag.class, false);
        while (tag != null) {
          final DomElement domElement = DomManager.getDomManager(xmlElement.getProject()).getDomElement(tag);
          if (domElement != null) {
            for (DomElement curElement = domElement; curElement != null; curElement = curElement.getParent()) {
              if (myDescriptor.fun(curElement) == DomService.StructureViewMode.SHOW) {
                return super.expandPathToElement(curElement.getXmlElement());
              }
            }
          }
          tag = PsiTreeUtil.getParentOfType(tag, XmlTag.class, true);
        }

      }
      return super.expandPathToElement(element);
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:DomStructureViewBuilder.java


示例8: downloadArtifacts

import com.intellij.openapi.util.AsyncResult; //导入依赖的package包/类
protected MavenArtifactDownloader.DownloadResult downloadArtifacts(Collection<MavenProject> projects,
                                                                   List<MavenArtifact> artifacts) {
  final MavenArtifactDownloader.DownloadResult[] unresolved = new MavenArtifactDownloader.DownloadResult[1];

  AsyncResult<MavenArtifactDownloader.DownloadResult> result = new AsyncResult<MavenArtifactDownloader.DownloadResult>();
  result.doWhenDone(new Consumer<MavenArtifactDownloader.DownloadResult>() {
    @Override
    public void consume(MavenArtifactDownloader.DownloadResult unresolvedArtifacts) {
      unresolved[0] = unresolvedArtifacts;
    }
  });

  myProjectsManager.scheduleArtifactsDownloading(projects, artifacts, true, true, result);
  myProjectsManager.waitForArtifactsDownloadingCompletion();

  return unresolved[0];
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:MavenImportingTestCase.java


示例9: doFix

import com.intellij.openapi.util.AsyncResult; //导入依赖的package包/类
@Override
public void doFix(final Project project, final ProblemDescriptor descriptor) {
  final PsiElement nameIdentifier = descriptor.getPsiElement();
  final PsiElement elementToRename = nameIdentifier.getParent();
  if (m_targetName == null) {
    final AsyncResult<DataContext> contextFromFocus = DataManager.getInstance().getDataContextFromFocus();
    contextFromFocus.doWhenDone(new Consumer<DataContext>() {
      @Override
      public void consume(DataContext context) {
        final RenameHandler renameHandler = RenameHandlerRegistry.getInstance().getRenameHandler(context);
        if (renameHandler == null) {
          return;
        }
        renameHandler.invoke(project, new PsiElement[]{elementToRename}, context);
      }
    });
  }
  else {
    final RefactoringFactory factory = RefactoringFactory.getInstance(project);
    final RenameRefactoring renameRefactoring =
      factory.createRename(elementToRename, m_targetName, m_searchInStrings, m_searchInNonJavaFiles);
    renameRefactoring.run();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:RenameFix.java


示例10: doFix

import com.intellij.openapi.util.AsyncResult; //导入依赖的package包/类
@Override
protected void doFix(@NotNull final Project project, ProblemDescriptor descriptor) throws IncorrectOperationException {
  final PsiElement location = descriptor.getPsiElement();
  final PsiMethod method = (PsiMethod)location.getParent();
  final RefactoringActionHandler moveHandler = RefactoringActionHandlerFactory.getInstance().createMoveHandler();
  final AsyncResult<DataContext> result = DataManager.getInstance().getDataContextFromFocus();
  result.doWhenDone(new Consumer<DataContext>() {
    @Override
    public void consume(final DataContext originalContext) {
      final DataContext dataContext = new DataContext() {
        @Override
        public Object getData(@NonNls String name) {
          if (LangDataKeys.TARGET_PSI_ELEMENT.is(name)) {
            return usageClass.getElement();
          }
          return originalContext.getData(name);
        }
      };
      moveHandler.invoke(project, new PsiElement[]{method}, dataContext);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:StaticMethodOnlyUsedInOneClassInspection.java


示例11: applySwitch

import com.intellij.openapi.util.AsyncResult; //导入依赖的package包/类
public ActionCallback applySwitch() {
  final ActionCallback result = new ActionCallback();
  if (isSessionActive()) {
    final boolean showSpots = mySession.isShowspots();
    mySession.finish(false).doWhenDone(new AsyncResult.Handler<SwitchTarget>() {
      public void run(final SwitchTarget switchTarget) {
        mySession = null;
        IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(new Runnable() {
          public void run() {
            tryToInitSessionFromFocus(switchTarget, showSpots).doWhenProcessed(result.createSetDoneRunnable());
          }
        });
      }
    });
  }
  else {
    result.setDone();
  }

  return result;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:22,代码来源:SwitchManager.java


示例12: showNotify

import com.intellij.openapi.util.AsyncResult; //导入依赖的package包/类
public final void showNotify() {
  if (myWasEverShown) return;

  try {
    findParentDisposable().doWhenDone(new AsyncResult.Handler<Disposable>() {
      public void run(Disposable parent) {
        Project project = null;
        if (ApplicationManager.getApplication() != null) {
          project = PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext());
        }
        initialize(parent, myChild, project);
        Disposer.register(parent, myChild);
      }
    });
  }
  finally {
    myWasEverShown = true;
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:LazyUiDisposable.java


示例13: findDisposable

import com.intellij.openapi.util.AsyncResult; //导入依赖的package包/类
private static AsyncResult<Disposable> findDisposable(Disposable defaultValue, final DataKey<? extends Disposable> key) {
  if (defaultValue == null) {
    if (ApplicationManager.getApplication() != null) {
      final AsyncResult<Disposable> result = new AsyncResult<Disposable>();
      DataManager.getInstance().getDataContextFromFocus().doWhenDone(new AsyncResult.Handler<DataContext>() {
        public void run(DataContext context) {
          Disposable disposable = key.getData(context);
          if (disposable == null) {
            disposable = Disposer.get("ui");
          }
          result.setDone(disposable);
        }
      });
      return result;
    }
    else {
      return null;
    }
  }
  else {
    return new AsyncResult.Done<Disposable>(defaultValue);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:LazyUiDisposable.java


示例14: createUpdater

import com.intellij.openapi.util.AsyncResult; //导入依赖的package包/类
@Override
protected final AbstractTreeUpdater createUpdater() {
  return new AbstractTreeUpdater(this) {
    @Override
    protected ActionCallback beforeUpdate(final TreeUpdatePass pass) {
      if (!myDirtyFileSet.isEmpty()) { // suppress redundant cache validations
        final AsyncResult callback = new AsyncResult();
        DumbService.getInstance(myProject).runWhenSmart(new Runnable() {
          @Override
          public void run() {
            try {
              validateCache();
              getTodoTreeStructure().validateCache();
            }
            finally {
              callback.setDone();
            }
          }
        });
        return callback;
      }

      return new ActionCallback.Done();
    }
  };
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:27,代码来源:TodoTreeBuilder.java


示例15: queueRevalidate

import com.intellij.openapi.util.AsyncResult; //导入依赖的package包/类
private void queueRevalidate(@Nullable final Runnable after) {
  queue(new AfterModelUpdate(ID.REVALIDATE) {
    @Override
    protected void after() {
      final LightweightHint hint = myPanel.getHint();
      if (hint != null) {
        myPanel.getHintContainerShowPoint().doWhenDone(new AsyncResult.Handler<RelativePoint>() {
          @Override
          public void run(final RelativePoint relativePoint) {
            hint.setSize(myPanel.getPreferredSize());
            hint.setLocation(relativePoint);
            if (after != null) {
              after.run();
            }
          }
        });
      }
      else {
        if (after != null) {
          after.run();
        }
      }
    }
  });
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:26,代码来源:NavBarUpdateQueue.java


示例16: selectInNavBar

import com.intellij.openapi.util.AsyncResult; //导入依赖的package包/类
private static void selectInNavBar() {
  DataManager.getInstance().getDataContextFromFocus()
    .doWhenDone(new AsyncResult.Handler<DataContext>() {
      @Override
      public void run(DataContext context) {
        final IdeFrame frame = IdeFrame.KEY.getData(context);
        if (frame != null) {
          final IdeRootPaneNorthExtension navBarExt = frame.getNorthExtension(NavBarRootPaneExtension.NAV_BAR);
          if (navBarExt != null) {
            final JComponent c = navBarExt.getComponent();
            final NavBarPanel panel = (NavBarPanel)c.getClientProperty("NavBarPanel");
            panel.rebuildAndSelectTail(true);
          }
        }
      }
    });
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:SelectInNavBarTarget.java


示例17: createStructureView

import com.intellij.openapi.util.AsyncResult; //导入依赖的package包/类
@Override
@NotNull
public StructureView createStructureView(final FileEditor fileEditor, final Project project) {
  return new StructureViewComponent(fileEditor, createStructureViewModel(fileEditor instanceof TextEditor ? ((TextEditor)fileEditor).getEditor() : null), project) {
    @Override
    public AsyncResult<AbstractTreeNode> expandPathToElement(final Object element) {
      if (element instanceof XmlElement) {
        final XmlElement xmlElement = (XmlElement)element;
        XmlTag tag = PsiTreeUtil.getParentOfType(xmlElement, XmlTag.class, false);
        while (tag != null) {
          final DomElement domElement = DomManager.getDomManager(xmlElement.getProject()).getDomElement(tag);
          if (domElement != null) {
            for (DomElement curElement = domElement; curElement != null; curElement = curElement.getParent()) {
              if (myDescriptor.fun(curElement) == DomService.StructureViewMode.SHOW) {
                return super.expandPathToElement(curElement.getXmlElement());
              }
            }
          }
          tag = PsiTreeUtil.getParentOfType(tag, XmlTag.class, true);
        }

      }
      return super.expandPathToElement(element);
    }
  };
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:27,代码来源:DomStructureViewBuilder.java


示例18: downloadArtifacts

import com.intellij.openapi.util.AsyncResult; //导入依赖的package包/类
protected MavenArtifactDownloader.DownloadResult downloadArtifacts(Collection<MavenProject> projects,
                                                                   List<MavenArtifact> artifacts) {
  final MavenArtifactDownloader.DownloadResult[] unresolved = new MavenArtifactDownloader.DownloadResult[1];

  AsyncResult<MavenArtifactDownloader.DownloadResult> result = new AsyncResult<MavenArtifactDownloader.DownloadResult>();
  result.doWhenDone(new AsyncResult.Handler<MavenArtifactDownloader.DownloadResult>() {
    @Override
    public void run(MavenArtifactDownloader.DownloadResult unresolvedArtifacts) {
      unresolved[0] = unresolvedArtifacts;
    }
  });

  myProjectsManager.scheduleArtifactsDownloading(projects, artifacts, true, true, result);
  myProjectsManager.waitForArtifactsDownloadingCompletion();

  return unresolved[0];
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:MavenImportingTestCase.java


示例19: doFix

import com.intellij.openapi.util.AsyncResult; //导入依赖的package包/类
@Override
public void doFix(final Project project, final ProblemDescriptor descriptor) {
  final PsiElement nameIdentifier = descriptor.getPsiElement();
  final PsiElement elementToRename = nameIdentifier.getParent();
  if (m_targetName == null) {
    final AsyncResult<DataContext> contextFromFocus = DataManager.getInstance().getDataContextFromFocus();
    contextFromFocus.doWhenDone(new AsyncResult.Handler<DataContext>() {
      @Override
      public void run(DataContext context) {
        final RenameHandler renameHandler = RenameHandlerRegistry.getInstance().getRenameHandler(context);
        if (renameHandler == null) {
          return;
        }
        renameHandler.invoke(project, new PsiElement[]{elementToRename}, context);
      }
    });
  }
  else {
    final RefactoringFactory factory = RefactoringFactory.getInstance(project);
    final RenameRefactoring renameRefactoring =
      factory.createRename(elementToRename, m_targetName, m_searchInStrings, m_searchInNonJavaFiles);
    renameRefactoring.run();
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:RenameFix.java


示例20: doFix

import com.intellij.openapi.util.AsyncResult; //导入依赖的package包/类
@Override
protected void doFix(@NotNull final Project project, ProblemDescriptor descriptor) throws IncorrectOperationException {
  final PsiElement location = descriptor.getPsiElement();
  final PsiMethod method = (PsiMethod)location.getParent();
  final RefactoringActionHandler moveHandler = RefactoringActionHandlerFactory.getInstance().createMoveHandler();
  final AsyncResult<DataContext> result = DataManager.getInstance().getDataContextFromFocus();
  result.doWhenDone(new AsyncResult.Handler<DataContext>() {
    @Override
    public void run(final DataContext originalContext) {
      final DataContext dataContext = new DataContext() {
        @Override
        public Object getData(@NonNls String name) {
          if (LangDataKeys.TARGET_PSI_ELEMENT.is(name)) {
            return usageClass.getElement();
          }
          return originalContext.getData(name);
        }
      };
      moveHandler.invoke(project, new PsiElement[]{method}, dataContext);
    }
  });
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:StaticMethodOnlyUsedInOneClassInspection.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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