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;
}
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);
}
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);
}
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;
}
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;
}
Aggregations