Search in sources :

Example 21 with LayeredIcon

use of com.intellij.ui.LayeredIcon in project intellij-community by JetBrains.

the class ElementBase method createLayeredIcon.

@NotNull
public static RowIcon createLayeredIcon(@NotNull Iconable instance, Icon icon, int flags) {
    List<Icon> layersFromProviders = new SmartList<>();
    for (IconLayerProvider provider : Extensions.getExtensions(IconLayerProvider.EP_NAME)) {
        final Icon layerIcon = provider.getLayerIcon(instance, BitUtil.isSet(flags, FLAGS_LOCKED));
        if (layerIcon != null) {
            layersFromProviders.add(layerIcon);
        }
    }
    if (flags != 0 || !layersFromProviders.isEmpty()) {
        List<Icon> iconLayers = new SmartList<>();
        for (IconLayer l : ourIconLayers) {
            if (BitUtil.isSet(flags, l.flagMask)) {
                iconLayers.add(l.icon);
            }
        }
        iconLayers.addAll(layersFromProviders);
        LayeredIcon layeredIcon = new LayeredIcon(1 + iconLayers.size());
        layeredIcon.setIcon(icon, 0);
        for (int i = 0; i < iconLayers.size(); i++) {
            Icon icon1 = iconLayers.get(i);
            layeredIcon.setIcon(icon1, i + 1);
        }
        icon = layeredIcon;
    }
    RowIcon baseIcon = new RowIcon(2);
    baseIcon.setIcon(icon, 0);
    return baseIcon;
}
Also used : IconLayerProvider(com.intellij.ide.IconLayerProvider) LayeredIcon(com.intellij.ui.LayeredIcon) RowIcon(com.intellij.ui.RowIcon) EmptyIcon(com.intellij.util.ui.EmptyIcon) LayeredIcon(com.intellij.ui.LayeredIcon) RowIcon(com.intellij.ui.RowIcon) NotNull(org.jetbrains.annotations.NotNull)

Example 22 with LayeredIcon

use of com.intellij.ui.LayeredIcon in project intellij-community by JetBrains.

the class ToolWindowImpl method setIcon.

@Override
public final void setIcon(final Icon icon) {
    ApplicationManager.getApplication().assertIsDispatchThread();
    final Icon oldIcon = getIcon();
    if (!EventLog.LOG_TOOL_WINDOW_ID.equals(getId())) {
        if (oldIcon != icon && icon != null && !(icon instanceof LayeredIcon) && (icon.getIconHeight() != Math.floor(JBUI.scale(13f)) || icon.getIconWidth() != Math.floor(JBUI.scale(13f)))) {
            LOG.warn("ToolWindow icons should be 13x13. Please fix ToolWindow (ID:  " + getId() + ") or icon " + icon);
        }
    }
    //getSelectedContent().setIcon(icon);
    myIcon = icon;
    myChangeSupport.firePropertyChange(PROP_ICON, oldIcon, icon);
}
Also used : LayeredIcon(com.intellij.ui.LayeredIcon) LayeredIcon(com.intellij.ui.LayeredIcon)

Example 23 with LayeredIcon

use of com.intellij.ui.LayeredIcon in project intellij-community by JetBrains.

the class XDebuggerEditorBase method setExpression.

public void setExpression(@Nullable XExpression text) {
    if (text == null) {
        text = getMode() == EvaluationMode.EXPRESSION ? XExpressionImpl.EMPTY_EXPRESSION : XExpressionImpl.EMPTY_CODE_FRAGMENT;
    }
    Language language = text.getLanguage();
    if (language == null) {
        if (myContext != null) {
            language = myContext.getLanguage();
        }
        if (language == null && mySourcePosition != null) {
            language = LanguageUtil.getFileLanguage(mySourcePosition.getFile());
        }
        if (language == null) {
            language = LanguageUtil.getFileTypeLanguage(getEditorsProvider().getFileType());
        }
        text = new XExpressionImpl(text.getExpression(), language, text.getCustomInfo(), text.getMode());
    }
    Collection<Language> languages = getSupportedLanguages();
    boolean many = languages.size() > 1;
    if (language != null) {
        myChooseFactory.setVisible(many);
    }
    myChooseFactory.setVisible(myChooseFactory.isVisible() || many);
    if (language != null && language.getAssociatedFileType() != null) {
        LayeredIcon icon = JBUI.scale(new LayeredIcon(2));
        icon.setIcon(language.getAssociatedFileType().getIcon(), 0);
        icon.setIcon(AllIcons.General.Dropdown, 1, 3, 0);
        myChooseFactory.setIcon(icon);
        myChooseFactory.setDisabledIcon(IconLoader.getDisabledIcon(icon));
    }
    doSetText(text);
}
Also used : LayeredIcon(com.intellij.ui.LayeredIcon) Language(com.intellij.lang.Language) XExpressionImpl(com.intellij.xdebugger.impl.breakpoints.XExpressionImpl)

Example 24 with LayeredIcon

use of com.intellij.ui.LayeredIcon in project intellij-community by JetBrains.

the class IdeNotificationArea method createIconWithNotificationCount.

@NotNull
public static LayeredIcon createIconWithNotificationCount(JComponent component, NotificationType type, int size) {
    LayeredIcon icon = new LayeredIcon(2);
    icon.setIcon(getPendingNotificationsIcon(AllIcons.Ide.Notification.NoEvents, type), 0);
    if (size > 0) {
        //noinspection UseJBColor
        Color textColor = type == NotificationType.ERROR ? new JBColor(Color.white, new Color(0xF2F2F2)) : new Color(0x333333);
        icon.setIcon(new TextIcon(component, size < 10 ? String.valueOf(size) : "9+", textColor), 1);
    }
    return icon;
}
Also used : LayeredIcon(com.intellij.ui.LayeredIcon) JBColor(com.intellij.ui.JBColor) JBColor(com.intellij.ui.JBColor) NotNull(org.jetbrains.annotations.NotNull)

Example 25 with LayeredIcon

use of com.intellij.ui.LayeredIcon in project intellij-community by JetBrains.

the class ServersTreeStructure method getServerNodeIcon.

public static Icon getServerNodeIcon(@NotNull Icon itemIcon, @Nullable Icon statusIcon) {
    if (statusIcon == null) {
        return itemIcon;
    }
    LayeredIcon icon = new LayeredIcon(2);
    icon.setIcon(itemIcon, 0);
    icon.setIcon(statusIcon, 1, itemIcon.getIconWidth() - statusIcon.getIconWidth(), itemIcon.getIconHeight() - statusIcon.getIconHeight());
    return icon;
}
Also used : LayeredIcon(com.intellij.ui.LayeredIcon)

Aggregations

LayeredIcon (com.intellij.ui.LayeredIcon)26 CompositeAppearance (com.intellij.openapi.roots.ui.util.CompositeAppearance)6 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)5 RowIcon (com.intellij.ui.RowIcon)5 NotNull (org.jetbrains.annotations.NotNull)5 EmptyIcon (com.intellij.util.ui.EmptyIcon)4 PsiClass (com.intellij.psi.PsiClass)3 ItemPresentation (com.intellij.navigation.ItemPresentation)2 PsiElement (com.intellij.psi.PsiElement)2 PsiFile (com.intellij.psi.PsiFile)2 DartClass (com.jetbrains.lang.dart.psi.DartClass)2 Nullable (org.jetbrains.annotations.Nullable)2 LookupElement (com.intellij.codeInsight.lookup.LookupElement)1 LookupElementBuilder (com.intellij.codeInsight.lookup.LookupElementBuilder)1 IconLayerProvider (com.intellij.ide.IconLayerProvider)1 UISettings (com.intellij.ide.ui.UISettings)1 AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)1 Language (com.intellij.lang.Language)1 StructureViewTestUtil.getIcon (com.intellij.lang.javascript.StructureViewTestUtil.getIcon)1 JSNamedElement (com.intellij.lang.javascript.psi.JSNamedElement)1