Java Code Examples for com.intellij.openapi.util.IconLoader#findIcon()

The following examples show how to use com.intellij.openapi.util.IconLoader#findIcon() . 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 File: NotificationTestAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
public Notification getNotification() {
  if (myNotification == null) {
    Image icon = null;
    if (!StringUtil.isEmpty(myGroupId)) {
      icon = IconLoader.findIcon(myGroupId);
    }
    String displayId = mySticky ? TEST_STICKY_GROUP.getDisplayId() : TEST_GROUP_ID;
    if (myToolwindow) {
      displayId = TEST_TOOLWINDOW_GROUP.getDisplayId();
    }
    String content = myContent == null ? "" : StringUtil.join(myContent, "\n");
    if (icon == null) {
      myNotification = new Notification(displayId, StringUtil.notNullize(myTitle), content, myType, getListener());
    }
    else {
      myNotification = new Notification(displayId, icon, myTitle, mySubtitle, content, myType, getListener());
    }
    if (myActions != null) {
      for (String action : myActions) {
        myNotification.addAction(new MyAnAction(action));
      }
    }
  }
  return myNotification;
}
 
Example 2
Source File: CommentNodeRenderer.java    From Crucible4IDEA with MIT License 6 votes vote down vote up
void setComment(final Comment comment) {
  String avatar = comment.getAuthor().getAvatar();
  Icon icon = AllIcons.Ide.Notification.WarningEvents;
  if (avatar != null) {
    try {
      icon = IconLoader.findIcon(new URL(avatar));
    }
    catch (MalformedURLException e) {
      LOG.warn(e);
    }
  }

  myIconLabel.setIcon(icon);
  myMessageLabel.setText(XmlStringUtil.wrapInHtml(comment.getMessage()));

  RoundedLineBorder roundedLineBorder = new RoundedLineBorder(comment.isDraft() ? DRAFT_BORDER_COLOR : COMMENT_BORDER_COLOR, 20, 2);
  Border marginBorder = BorderFactory.createEmptyBorder(0, 0, UIUtil.DEFAULT_VGAP, 0);
  myMainPanel.setBorder(BorderFactory.createCompoundBorder(marginBorder, roundedLineBorder));

  myMainPanel.setBackground(comment.isDraft() ? DRAFT_BG_COLOR : COMMENT_BG_COLOR);

  myPostLink.setVisible(comment.isDraft());
}
 
Example 3
Source File: FlutterCupertinoIcons.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static Icon getIcon(String name) {
  if (name == null) {
    return null;
  }
  final String path = icons.getProperty(name);
  if (path == null) {
    return null;
  }
  return IconLoader.findIcon(path, FlutterCupertinoIcons.class);
}
 
Example 4
Source File: DarculaLaf.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected Object parseValue(String key, @Nonnull String value) {
  if (key.endsWith("Insets") || key.endsWith("padding")) {
    final List<String> numbers = StringUtil.split(value, ",");
    return new InsetsUIResource(Integer.parseInt(numbers.get(0)),
                                Integer.parseInt(numbers.get(1)),
                                Integer.parseInt(numbers.get(2)),
                                Integer.parseInt(numbers.get(3)));
  } else if (key.endsWith(".border")) {
    try {
      return Class.forName(value).newInstance();
    } catch (Exception e) {log(e);}
  } else {
    final Color color = parseColor(value);
    final Integer invVal = getInteger(value);
    final Boolean boolVal = "true".equals(value) ? Boolean.TRUE : "false".equals(value) ? Boolean.FALSE : null;
    Icon icon = value.startsWith("AllIcons.") ? IconLoader.getIcon(value) : null;
    if (icon == null && (value.endsWith(".png") || value.endsWith(".svg"))) {
      icon = IconLoader.findIcon(value, getClass(), true);
    }
    if (color != null) {
      return  new ColorUIResource(color);
    } else if (invVal != null) {
      return invVal;
    } else if (icon != null) {
      return new IconUIResource(icon);
    } else if (boolVal != null) {
      return boolVal;
    }
  }
  return value;
}
 
Example 5
Source File: MacIntelliJIconCache.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static Icon getIcon(String name, boolean editable, boolean selected, boolean focused, boolean enabled) {
  String key = name;
  if (editable) key += "Editable";
  if (selected) key+= "Selected";
  if (focused) key+= "Focused";
  else if (!enabled) key+="Disabled";
  if (IntelliJLaf.isGraphite()) key= "graphite/" + key;
  if (IntelliJLaf.isWindowsNativeLook()) key = "win10/" + key;
  Icon icon = cache.get(key);
  if (icon == null) {
    icon = IconLoader.findIcon("/com/intellij/ide/ui/laf/icons/" + key + ".png", MacIntelliJIconCache.class, true);
    cache.put(key, icon);
  }
  return icon;
}
 
Example 6
Source File: ModernDarkLaf.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected Object parseValue(String key, @Nonnull String value) {
  if (key.endsWith("Insets")) {
    final List<String> numbers = StringUtil.split(value, ",");
    return new InsetsUIResource(Integer.parseInt(numbers.get(0)), Integer.parseInt(numbers.get(1)), Integer.parseInt(numbers.get(2)), Integer.parseInt(numbers.get(3)));
  }
  else if (key.endsWith(".border")) {
    try {
      return Class.forName(value).newInstance();
    }
    catch (Exception e) {
      log(e);
    }
  }
  else {
    final Color color = parseColor(value);
    final Integer invVal = getInteger(value);
    final Boolean boolVal = "true".equals(value) ? Boolean.TRUE : "false".equals(value) ? Boolean.FALSE : null;
    Icon icon = value.startsWith("AllIcons.") ? IconLoader.getIcon(value) : null;
    if (icon == null && value.endsWith(".png")) {
      icon = IconLoader.findIcon(value, getClass(), true);
    }
    if (color != null) {
      return new ColorUIResource(color);
    }
    else if (invVal != null) {
      return invVal;
    }
    else if (icon != null) {
      return new IconUIResource(icon);
    }
    else if (boolVal != null) {
      return boolVal;
    }
  }
  return value;
}
 
Example 7
Source File: NotificationTestAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
private MyAnAction(@Nullable String text) {
  if (text != null) {
    if (text.endsWith(".png")) {
      Icon icon = IconLoader.findIcon(text);
      if (icon != null) {
        getTemplatePresentation().setIcon(icon);
        return;
      }
    }
    getTemplatePresentation().setText(text);
  }
}
 
Example 8
Source File: ModuleExtensionProviderEP.java    From consulo with 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 9
Source File: GuiUtils.java    From nosql4idea with Apache License 2.0 5 votes vote down vote up
public static Icon loadIcon(String iconFilename, String darkIconFilename) {
    String iconPath = ICON_FOLDER;
    if (isUnderDarcula()) {
        iconPath += darkIconFilename;
    } else {
        iconPath += iconFilename;
    }
    return IconLoader.findIcon(iconPath);
}
 
Example 10
Source File: FlutterCupertinoIcons.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static Icon getIcon(String name) {
  if (name == null) {
    return null;
  }
  final String path = icons.getProperty(name);
  if (path == null) {
    return null;
  }
  return IconLoader.findIcon(path, FlutterCupertinoIcons.class);
}
 
Example 11
Source File: FlutterMaterialIcons.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static Icon getIcon(String name) {
  if (name == null) {
    return null;
  }
  final String path = icons.getProperty(name);
  if (path == null) {
    return null;
  }
  return IconLoader.findIcon(path, FlutterMaterialIcons.class);
}
 
Example 12
Source File: FlutterMaterialIcons.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static Icon getIcon(String name) {
  if (name == null) {
    return null;
  }
  final String path = icons.getProperty(name);
  if (path == null) {
    return null;
  }
  return IconLoader.findIcon(path, FlutterMaterialIcons.class);
}
 
Example 13
Source File: GuiUtils.java    From nosql4idea with Apache License 2.0 4 votes vote down vote up
public static Icon loadIcon(String iconFilename) {
    return IconLoader.findIcon(ICON_FOLDER + iconFilename);
}
 
Example 14
Source File: BeagleBoneBlackJavaModuleBuilder.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 4 votes vote down vote up
/**
 * The icon displayed in the project creator dialog
 * @return
 */
@Override
public Icon getNodeIcon() {
    return IconLoader.findIcon("/bbb.png");
}
 
Example 15
Source File: TypeIconEP.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected Image compute() {
  return IconLoader.findIcon(icon, getLoaderForClass());
}
 
Example 16
Source File: RPiJavaModuleBuilder.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 4 votes vote down vote up
/**
 * The icon displayed in the project creator dialog
 * @return
 */
@Override
public Icon getNodeIcon() {
    return IconLoader.findIcon("/pi.png");
}
 
Example 17
Source File: RPiJavaModuleBuilder.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 4 votes vote down vote up
/**
 * Big icon is Java modules
 * @return
 */
//@Override
public Icon getBigIcon() {
    return IconLoader.findIcon("/pi.png");
}
 
Example 18
Source File: LafIconLookup.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
public static Icon findLafIcon(@Nonnull String key, @Nonnull Class aClass, boolean strict) {
  return IconLoader.findIcon("/icons/" + key + ".png", aClass, true, strict);
}
 
Example 19
Source File: DesktopImageImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public DesktopImageImpl(URL url) {
  myIcon = IconLoader.findIcon(url);
}