Java 类com.intellij.ui.IconDeferrer 实例源码

项目:tools-idea    文件:ElementBase.java   
@Nullable
private Icon computeIcon(@Iconable.IconFlags int flags) {
  PsiElement psiElement = (PsiElement)this;
  if (!psiElement.isValid()) return null;

  if (Registry.is("psi.deferIconLoading")) {
    Icon baseIcon = LastComputedIcon.get(psiElement, flags);
    if (baseIcon == null) {
      TIntObjectHashMap<Icon> cache = getUserData(BASE_ICONS);
      if (cache == null) {
        cache = putUserDataIfAbsent(BASE_ICONS, new TIntObjectHashMap<Icon>());
      }
      synchronized (cache) {
        if (!cache.containsKey(flags)) {
          cache.put(flags, computeBaseIcon(flags));
        }
        baseIcon = cache.get(flags);
      }
    }
    return IconDeferrer.getInstance().defer(baseIcon, new ElementIconRequest(psiElement, flags), ICON_COMPUTE);
  }

  return computeIconNow(psiElement, flags);
}
项目:intellij-ce-playground    文件:PsiClassImplUtil.java   
public static Icon getClassIcon(int flags, @NotNull PsiClass aClass, @Nullable Icon symbolIcon) {
  Icon base = Iconable.LastComputedIcon.get(aClass, flags);
  if (base == null) {
    if (symbolIcon == null) {
      symbolIcon = ElementPresentationUtil.getClassIconOfKind(aClass, ElementPresentationUtil.getBasicClassKind(aClass));
    }
    RowIcon baseIcon = ElementBase.createLayeredIcon(aClass, symbolIcon, 0);
    base = ElementPresentationUtil.addVisibilityIcon(aClass, flags, baseIcon);
  }

  return IconDeferrer.getInstance().defer(base, new ClassIconRequest(aClass, flags, symbolIcon), FULL_ICON_EVALUATOR);
}
项目:intellij-ce-playground    文件:TabInfo.java   
public TabInfo setIcon(Icon icon) {
  Icon old = myIcon;
  if (!IconDeferrer.getInstance().equalIcons(old, icon)) {
    myIcon = icon;
    myChangeSupport.firePropertyChange(ICON, old, icon);
  }
  return this;
}
项目:intellij-ce-playground    文件:ElementBase.java   
@Nullable
private Icon computeIcon(@Iconable.IconFlags int flags) {
  PsiElement psiElement = (PsiElement)this;
  if (!psiElement.isValid()) return null;

  if (Registry.is("psi.deferIconLoading")) {
    Icon baseIcon = LastComputedIcon.get(psiElement, flags);
    if (baseIcon == null) {
      baseIcon = computeBaseIcon(flags);
    }
    return IconDeferrer.getInstance().defer(baseIcon, new ElementIconRequest(psiElement, flags), ICON_COMPUTE);
  }

  return computeIconNow(psiElement, flags);
}
项目:tools-idea    文件:PsiClassImplUtil.java   
public static Icon getClassIcon(int flags, @NotNull PsiClass aClass, @Nullable Icon symbolIcon) {
  Icon base = Iconable.LastComputedIcon.get(aClass, flags);
  if (base == null) {
    if (symbolIcon == null) {
      symbolIcon = ElementPresentationUtil.getClassIconOfKind(aClass, ElementPresentationUtil.getBasicClassKind(aClass));
    }
    RowIcon baseIcon = ElementBase.createLayeredIcon(aClass, symbolIcon, 0);
    base = ElementPresentationUtil.addVisibilityIcon(aClass, flags, baseIcon);
  }

  return IconDeferrer.getInstance().defer(base, new ClassIconRequest(aClass, flags, symbolIcon), FULL_ICON_EVALUATOR);
}
项目:consulo    文件:VfsIconUtil.java   
@Nullable
public static Icon getIcon(@Nonnull final VirtualFile file, @Iconable.IconFlags final int flags, @Nullable final Project project) {
  Icon icon = Iconable.LastComputedIcon.get(file, flags);
  if (icon == null) {
    icon = VirtualFilePresentation.getIcon(file);
  }

  return IconDeferrer.getInstance().defer(icon, new AnyIconKey<>(file, project, flags), ourVirtualFileIconFunc);
}
项目:consulo    文件:TabInfo.java   
public TabInfo setIcon(Icon icon) {
  Icon old = myIcon;
  if (!IconDeferrer.getInstance().equalIcons(old, icon)) {
    myIcon = icon;
    myChangeSupport.firePropertyChange(ICON, old, icon);
  }
  return this;
}
项目:consulo    文件:IconDescriptorUpdaters.java   
@Nonnull
@RequiredReadAction
public static Icon getIcon(@Nonnull final PsiElement element, @Iconable.IconFlags final int flags) {
  if (!element.isValid()) return AllIcons.Nodes.NodePlaceholder;

  Icon baseIcon = Iconable.LastComputedIcon.get(element, flags);
  if (baseIcon == null) {
    baseIcon = computeBaseIcon(element, flags);
  }
  return IconDeferrer.getInstance().defer(baseIcon, new ElementIconRequest(element, flags), ourIconCompute);
}
项目:intellij-ce-playground    文件:IconUtil.java   
public static Icon getIcon(@NotNull final VirtualFile file, @Iconable.IconFlags final int flags, @Nullable final Project project) {
  Icon lastIcon = Iconable.LastComputedIcon.get(file, flags);

  final Icon base = lastIcon != null ? lastIcon : VirtualFilePresentation.getIconImpl(file);
  return IconDeferrer.getInstance().defer(base, new FileIconKey(file, project, flags), ICON_NULLABLE_FUNCTION);
}
项目:consulo    文件:RunManagerImpl.java   
@Override
public Icon getConfigurationIcon(@Nonnull final RunnerAndConfigurationSettings settings) {
  final String uniqueID = settings.getUniqueID();
  RunnerAndConfigurationSettings selectedConfiguration = getSelectedConfiguration();
  String selectedId = selectedConfiguration != null ? selectedConfiguration.getUniqueID() : "";
  if (selectedId.equals(uniqueID)) {
    Long lastCheckTime = myIconCheckTimes.get(uniqueID);
    Long calcTime = myIconCalcTime.get(uniqueID);
    if (calcTime == null || calcTime < 150) calcTime = 150L;
    if (lastCheckTime == null || System.currentTimeMillis() - lastCheckTime > calcTime * 10) {
      myIdToIcon.remove(uniqueID);//cache has expired
    }
  }
  Icon icon = myIdToIcon.get(uniqueID);
  if (icon == null) {
    icon = IconDeferrer.getInstance().deferAutoUpdatable(settings.getConfiguration().getIcon(), myProject.hashCode() ^ settings.hashCode(), param -> {
      if (myProject.isDisposed()) return null;

      myIconCalcTime.remove(uniqueID);
      long startTime = System.currentTimeMillis();

      Icon ico;
      try {
        DumbService.getInstance(myProject).setAlternativeResolveEnabled(true);
        settings.checkSettings();
        ico = ProgramRunnerUtil.getConfigurationIcon(settings, false);
      }
      catch (IndexNotReadyException e) {
        ico = ProgramRunnerUtil.getConfigurationIcon(settings, false);
      }
      catch (RuntimeConfigurationException ignored) {
        ico = ProgramRunnerUtil.getConfigurationIcon(settings, true);
      }
      finally {
        DumbService.getInstance(myProject).setAlternativeResolveEnabled(false);
      }
      myIconCalcTime.put(uniqueID, System.currentTimeMillis() - startTime);
      return ico;
    });

    myIdToIcon.put(uniqueID, icon);
    myIconCheckTimes.put(uniqueID, System.currentTimeMillis());
  }

  return icon;
}