Java Code Examples for consulo.ui.image.Image

The following examples show how to use consulo.ui.image.Image. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: consulo-unity3d   Source File: ShaderReference.java    License: Apache License 2.0 6 votes vote down vote up
@RequiredReadAction
public static void consumeProperties(@Nonnull ShaderLabFile file, @Nonnull Consumer<LookupElement> consumer)
{
	for(ShaderProperty shaderProperty : file.getProperties())
	{
		String name = shaderProperty.getName();
		if(name == null)
		{
			continue;
		}
		LookupElementBuilder builder = LookupElementBuilder.create(name);
		builder = builder.withIcon((Image) AllIcons.Nodes.Property);
		ShaderPropertyType type = shaderProperty.getType();
		if(type != null)
		{
			builder = builder.withTypeText(type.getTargetText(), true);
		}
		consumer.consume(builder);
	}
}
 
Example 2
Source Project: consulo   Source File: NotificationsUtil.java    License: Apache License 2.0 6 votes vote down vote up
@Nonnull
public static Image getIcon(@Nonnull final Notification notification) {
  Image icon = notification.getIcon();
  if (icon != null) {
    return icon;
  }

  switch (notification.getType()) {
    case WARNING:
      return AllIcons.General.BalloonWarning;
    case ERROR:
      return AllIcons.Ide.FatalError;
    case INFORMATION:
    default:
      return AllIcons.General.BalloonInformation;
  }
}
 
Example 3
Source Project: consulo   Source File: Notification.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @param groupDisplayId this should be a human-readable, capitalized string like "Facet Detector".
 *                       It will appear in "Notifications" configurable.
 * @param icon           notification icon, if <b>null</b> used icon from type
 * @param title          notification title
 * @param subtitle       notification subtitle
 * @param content        notification content
 * @param type           notification type
 * @param listener       notification lifecycle listener
 */
public Notification(@Nonnull String groupDisplayId,
                    @Nullable Image icon,
                    @Nullable String title,
                    @Nullable String subtitle,
                    @Nullable String content,
                    @Nonnull NotificationType type,
                    @Nullable NotificationListener listener) {
  myGroupId = groupDisplayId;
  myTitle = StringUtil.notNullize(title);
  myContent = StringUtil.notNullize(content);
  myType = type;
  myListener = listener;
  myTimestamp = System.currentTimeMillis();

  myIcon = icon;
  mySubtitle = subtitle;

  assertHasTitleOrContent();
  id = calculateId(this);
}
 
Example 4
Source Project: consulo   Source File: ActionManagerImpl.java    License: Apache License 2.0 6 votes vote down vote up
private static void setIconFromClass(@Nonnull Class<?> actionClass,
                                     @Nonnull final ClassLoader classLoader,
                                     @Nonnull final String iconPath,
                                     @Nonnull Presentation presentation,
                                     final PluginId pluginId) {
  Image lazyIcon = consulo.ui.image.Image.lazy(() -> {
    //try to find icon in idea class path
    consulo.ui.image.Image icon = IconLoader.findIcon(iconPath, actionClass, true);
    if (icon == null) {
      icon = IconLoader.findIcon(iconPath, classLoader);
    }

    if (icon == null) {
      reportActionError(pluginId, "Icon cannot be found in '" + iconPath + "', action class='" + actionClass + "'");
      icon = AllIcons.Toolbar.Unknown;
    }

    return icon;
  });

  presentation.setIcon(lazyIcon);
}
 
Example 5
Source Project: consulo   Source File: UserFileType.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Image getIcon() {
  Image icon = myIcon;
  if (icon == null) {
    if (myIconPath != null) {
      icon = IconLoader.getIcon(myIconPath);
      myIcon = icon;
    }

    if (icon == null) {
      // to not load PlatformIcons on UserFileType instantiation
      icon = AllIcons.FileTypes.Custom;
    }
  }
  return icon;
}
 
Example 6
Source Project: consulo   Source File: DesktopDeferredIconImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Nonnull
public Image evaluateImage() {
  consulo.ui.image.Image result;
  try {
    result = nonNull(myEvaluator.fun(myParam));
  }
  catch (IndexNotReadyException e) {
    result = EMPTY_ICON;
  }

  if (Holder.CHECK_CONSISTENCY) {
    checkDoesntReferenceThis(result);
  }

  Icon icon = TargetAWT.to(result);

  if (getScale() != 1f && icon instanceof ScalableIcon) {
    icon = ((ScalableIcon)result).scale(getScale());
  }
  return TargetAWT.from(icon);
}
 
Example 7
Source Project: consulo   Source File: PsiElementUsageGroupBase.java    License: Apache License 2.0 5 votes vote down vote up
public PsiElementUsageGroupBase(@Nonnull T element, Image icon) {
  String myName = element.getName();
  if (myName == null) myName = "<anonymous>";
  this.myName = myName;
  myElementPointer = SmartPointerManager.getInstance(element.getProject()).createSmartPsiElementPointer(element);

  myIcon = icon;
}
 
Example 8
Source Project: consulo   Source File: NamedLibraryElementNode.java    License: Apache License 2.0 5 votes vote down vote up
private static Image getIconForLibrary(OrderEntry orderEntry) {
  if (orderEntry instanceof LibraryOrderEntry) {
    Library library = ((LibraryOrderEntry)orderEntry).getLibrary();
    if (library != null) {
      return LibraryPresentationManager.getInstance().getNamedLibraryIcon(library, null);
    }
  }
  return AllIcons.Nodes.PpLib;
}
 
Example 9
Source Project: consulo   Source File: ReopenProjectAction.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
public Image getExtensionIcon() {
  List<String> extensions = getExtensions();
  Image moduleMainIcon = Image.empty(16);
  if (!extensions.isEmpty()) {
    for (String extensionId : extensions) {
      ModuleExtensionProviderEP provider = ModuleExtensionProviders.findProvider(extensionId);
      if (provider != null) {
        moduleMainIcon = provider.getIcon();
        break;
      }
    }
  }
  return moduleMainIcon;
}
 
Example 10
Source Project: consulo   Source File: IconUtilEx.java    License: Apache License 2.0 5 votes vote down vote up
public static Image getIcon(Object object, @Iconable.IconFlags int flags, Project project) {
  if (object instanceof PsiElement) {
    return IconDescriptorUpdaters.getIcon(((PsiElement)object), flags);
  }
  if (object instanceof Module) {
    return AllIcons.Nodes.Module;
  }
  if (object instanceof VirtualFile) {
    VirtualFile file = (VirtualFile)object;
    return VfsIconUtil.getIcon(file, flags, project);
  }
  return null;
}
 
Example 11
Source Project: consulo-csharp   Source File: LambdaLineMarkerCollector.java    License: Apache License 2.0 5 votes vote down vote up
public MarkerInfo(@Nonnull PsiElement element,
		@Nonnull TextRange textRange,
		Image icon,
		int updatePass,
		@Nullable Function<? super PsiElement, String> tooltipProvider,
		@Nullable GutterIconNavigationHandler<PsiElement> navHandler,
		@Nonnull GutterIconRenderer.Alignment alignment)
{
	super(element, textRange, icon, updatePass, tooltipProvider, navHandler, alignment);
}
 
Example 12
Source Project: consulo   Source File: MergeableLineMarkerInfo.java    License: Apache License 2.0 5 votes vote down vote up
public MergeableLineMarkerInfo(@Nonnull T element,
                               @Nonnull TextRange textRange,
                               Image icon,
                               int updatePass,
                               @Nullable Function<? super T, String> tooltipProvider,
                               @Nullable GutterIconNavigationHandler<T> navHandler,
                               @Nonnull GutterIconRenderer.Alignment alignment) {
  super(element, textRange, icon, updatePass, tooltipProvider, navHandler, alignment);
}
 
Example 13
@Override
@Nonnull
public StructureViewModel createStructureViewModel(@Nullable Editor editor) {
  List<StructureViewComposite.StructureViewDescriptor> viewDescriptors = new ArrayList<>();
  PsiFile psiFile = ObjectUtils.notNull(PsiManager.getInstance(myProject).findFile(myVirtualFile));
  for (Language language : getLanguages(psiFile)) {
    StructureViewBuilder builder = getBuilder(psiFile, language);
    if (!(builder instanceof TreeBasedStructureViewBuilder)) continue;
    StructureViewModel model = ((TreeBasedStructureViewBuilder)builder).createStructureViewModel(editor);
    String title = language.getDisplayName();
    Image icon = ObjectUtils.notNull(LanguageUtil.getLanguageFileType(language), UnknownFileType.INSTANCE).getIcon();
    viewDescriptors.add(new StructureViewComposite.StructureViewDescriptor(title, model, icon));
  }
  return new StructureViewCompositeModel(psiFile, editor, viewDescriptors);
}
 
Example 14
Source Project: consulo   Source File: ModuleExtensionProviderEP.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
protected Image compute() {
  if (StringUtil.isEmpty(icon)) {
    return AllIcons.Toolbar.Unknown;
  }
  Image temp = IconLoader.findIcon(icon, getLoaderForClass());
  return temp == null ? AllIcons.Toolbar.Unknown : temp;
}
 
Example 15
Source Project: consulo   Source File: TextConfigurable.java    License: Apache License 2.0 5 votes vote down vote up
public TextConfigurable(final T object,
                        final String displayName,
                        final String bannerSlogan,
                        final String descriptionText,
                        final Image closedIcon) {
  myDisplayName = displayName;
  myBannerSlogan = bannerSlogan;
  myDescriptionText = descriptionText;
  myClosedIcon = closedIcon;
  myObject = object;
}
 
Example 16
Source Project: consulo   Source File: XLineBreakpointImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void updateIcon() {
  Image icon = calculateSpecialIcon();
  if (icon == null) {
    icon = isTemporary() ? myType.getTemporaryIcon() : myType.getEnabledIcon();
  }
  setIcon(icon);
}
 
Example 17
Source Project: consulo   Source File: IconDescriptorUpdaters.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
private static Image computeBaseIcon(@Nonnull PsiElement element) {
  PsiFile containingFile = element.getContainingFile();
  if (containingFile != null) {
    VirtualFile virtualFile = containingFile.getVirtualFile();
    if (virtualFile != null) {
      Image icon = virtualFile.getFileType().getIcon();
      if (icon != null) {
        return icon;
      }
    }
  }
  return AllIcons.Nodes.NodePlaceholder;
}
 
Example 18
Source Project: consulo   Source File: IconDescriptor.java    License: Apache License 2.0 4 votes vote down vote up
@Nullable
public Image getRightIcon() {
  return myRightIcon;
}
 
Example 19
Source Project: consulo   Source File: NewModuleContextNode.java    License: Apache License 2.0 4 votes vote down vote up
public NewModuleContextNode(@Nonnull LocalizeValue name, @Nullable Image image) {
  myName = name;
  myImage = image;
}
 
Example 20
Source Project: consulo   Source File: RunConfigurationBeforeRunProvider.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Image getTaskIcon(RunConfigurableBeforeRunTask task) {
  if (task.getSettings() == null) return null;
  return ProgramRunnerUtil.getConfigurationIcon(task.getSettings(), false);
}
 
Example 21
Source Project: consulo   Source File: SandExecutor.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Image getDisabledIcon() {
  return AllIcons.Ide.HectorOff;
}
 
Example 22
public Image getElementIcon(T element) {
  return myIconExtractor.apply(element);
}
 
Example 23
Source Project: consulo   Source File: CodeStyleSettings.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Image getIcon() {
  return null;
}
 
Example 24
Source Project: consulo   Source File: AttachToProcessActionBase.java    License: Apache License 2.0 4 votes vote down vote up
@Nullable
protected Image getIcon(@Nonnull Project project) {
  return myGroup.getItemIcon(project, myInfo, myDataHolder);
}
 
Example 25
Source Project: consulo   Source File: TestsProgressAnimator.java    License: Apache License 2.0 4 votes vote down vote up
public static Image getCurrentFrame() {
  return FRAMES[getCurrentFrameIndex()];
}
 
Example 26
Source Project: consulo   Source File: ServerActionBase.java    License: Apache License 2.0 4 votes vote down vote up
protected ServerActionBase(String text, String description, Image icon) {
  super(text, description, icon);
}
 
Example 27
Source Project: consulo   Source File: WebMenuItemImpl.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void setIcon(@Nullable Image icon) {
  Vaadin vaadinComponent = getVaadinComponent();
  vaadinComponent.getState().myImageState = icon == null ? null : WebImageUrlCache.map(icon).getState();
  vaadinComponent.markAsDirty();
}
 
Example 28
Source Project: consulo   Source File: OrderRootTypePresentation.java    License: Apache License 2.0 4 votes vote down vote up
@Nonnull
public Image getIcon() {
  return myIcon;
}
 
Example 29
Source Project: consulo   Source File: Content.java    License: Apache License 2.0 4 votes vote down vote up
@Nullable
Image getPopupIcon();
 
Example 30
Source Project: consulo-csharp   Source File: CSharpFileType.java    License: Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public Image getIcon()
{
	return CSharpIcons.FileType;
}