当前位置: 首页>>代码示例>>Java>>正文


Java IconLoader.findIcon方法代码示例

本文整理汇总了Java中com.intellij.openapi.util.IconLoader.findIcon方法的典型用法代码示例。如果您正苦于以下问题:Java IconLoader.findIcon方法的具体用法?Java IconLoader.findIcon怎么用?Java IconLoader.findIcon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.util.IconLoader的用法示例。


在下文中一共展示了IconLoader.findIcon方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: customize

import com.intellij.openapi.util.IconLoader; //导入方法依赖的package包/类
@Override
public void customize(JList list, String value, int index, boolean selected, boolean hasFocus) {
    if ("Camel Icon".equals(value)) {
        this.setIcon(CAMEL_ICON);
    } else if ("Camel Badge Icon".equals(value)) {
        this.setIcon(CAMEL_BADGE_ICON);
    } else {
        String custom = textAccessor.getText();
        if (StringUtils.isNotEmpty(custom)) {
            File file = new File(custom);
            if (file.exists() && file.isFile()) {
                try {
                    URL url = new URL("file:" + custom);
                    Icon icon = IconLoader.findIcon(url, true);
                    if (icon != null) {
                        this.setIcon(icon);
                    }
                } catch (MalformedURLException e) {
                    LOG.warn("Error loading custom icon", e);
                }
            }
        }
    }
}
 
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:25,代码来源:CamelChosenIconCellRender.java

示例2: LocalArchivedTemplate

import com.intellij.openapi.util.IconLoader; //导入方法依赖的package包/类
public LocalArchivedTemplate(@NotNull URL archivePath,
                             @NotNull ClassLoader classLoader) {
  super(getTemplateName(archivePath), null);

  myArchivePath = archivePath;
  myModuleType = computeModuleType(this);
  String s = readEntry(TEMPLATE_DESCRIPTOR);
  if (s != null) {
    try {
      Element templateElement = JDOMUtil.loadDocument(s).getRootElement();
      populateFromElement(templateElement);
      String iconPath = templateElement.getChildText("icon-path");
      if (iconPath != null) {
        myIcon = IconLoader.findIcon(iconPath, classLoader);
      }
    }
    catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:LocalArchivedTemplate.java

示例3: getSmallApplicationIcon

import com.intellij.openapi.util.IconLoader; //导入方法依赖的package包/类
protected static Icon getSmallApplicationIcon() {
  if (ourSmallAppIcon == null) {
    try {
      Icon appIcon = IconLoader.findIcon(ApplicationInfoEx.getInstanceEx().getIconUrl());

      if (appIcon != null) {
        if (appIcon.getIconWidth() == JBUI.scale(16) && appIcon.getIconHeight() == JBUI.scale(16)) {
          ourSmallAppIcon = appIcon;
        } else {
          BufferedImage image = ImageUtil.toBufferedImage(IconUtil.toImage(appIcon));
          image = Scalr.resize(image, Scalr.Method.ULTRA_QUALITY, UIUtil.isRetina() ? 32 : JBUI.scale(16));
          ourSmallAppIcon = toRetinaAwareIcon(image);
        }
      }
    }
    catch (Exception e) {//
    }
    if (ourSmallAppIcon == null) {
      ourSmallAppIcon = EmptyIcon.ICON_16;
    }
  }

  return ourSmallAppIcon;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:RecentProjectsManagerBase.java

示例4: callProtractor

import com.intellij.openapi.util.IconLoader; //导入方法依赖的package包/类
private void callProtractor() {
    try {
        Config config = Config.getInstance(project);

        if (config == null) {
            return;
        }

        GeneralCommandLine command = getProtractorRunCommand(config);
        Process p = command.createProcess();

        if (project != null) {
            ToolWindowManager manager = ToolWindowManager.getInstance(project);
            String id = "Gherkin Runner";
            TextConsoleBuilderFactory factory = TextConsoleBuilderFactory.getInstance();
            TextConsoleBuilder builder = factory.createBuilder(project);
            ConsoleView view = builder.getConsole();

            ColoredProcessHandler handler = new ColoredProcessHandler(p, command.getPreparedCommandLine());
            handler.startNotify();
            view.attachToProcess(handler);

            ToolWindow window = manager.getToolWindow(id);
            Icon cucumberIcon = IconLoader.findIcon("/resources/icons/cucumber.png");

            if (window == null) {
                window = manager.registerToolWindow(id, true, ToolWindowAnchor.BOTTOM);
                window.setIcon(cucumberIcon);
            }

            ContentFactory cf = window.getContentManager().getFactory();
            Content c = cf.createContent(view.getComponent(), "Run " + (window.getContentManager().getContentCount() + 1), true);

            window.getContentManager().addContent(c);
        }
    } catch (Exception e) {
        System.out.println(e.getMessage());
    }
}
 
开发者ID:KariiO,项目名称:Gherkin-TS-Runner,代码行数:40,代码来源:GherkinIconRenderer.java

示例5: getCamelIcon

import com.intellij.openapi.util.IconLoader; //导入方法依赖的package包/类
public Icon getCamelIcon() {
    if (chosenCamelIcon.equals("Camel Icon")) {
        return CAMEL_ICON;
    } else if (chosenCamelIcon.equals("Camel Badge Icon")) {
        return CAMEL_BADGE_ICON;
    }

    if (StringUtils.isNotEmpty(customIconFilePath)) {

        // use cached current icon
        if (customIconFilePath.equals(currentCustomIconPath)) {
            return currentCustomIcon;
        }

        Icon icon = IconLoader.findIcon(customIconFilePath);
        if (icon == null) {
            File file = new File(customIconFilePath);
            if (file.exists() && file.isFile()) {
                try {
                    URL url = new URL("file:" + file.getAbsolutePath());
                    icon = IconLoader.findIcon(url, true);
                } catch (MalformedURLException e) {
                    LOG.warn("Error loading custom icon", e);
                }
            }
        }

        if (icon != null) {
            // cache current icon
            currentCustomIcon = icon;
            currentCustomIconPath = customIconFilePath;
            return currentCustomIcon;
        }
    }

    return CAMEL_ICON;
}
 
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:38,代码来源:CamelPreferenceService.java

示例6: loadIcon

import com.intellij.openapi.util.IconLoader; //导入方法依赖的package包/类
private static Icon loadIcon(@NonNls String resourceName) {
  Icon icon = IconLoader.findIcon(resourceName);
  Application application = ApplicationManager.getApplication();
  if (icon == null && application != null && application.isUnitTestMode()) {
    return new ImageIcon();
  }
  return icon;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:PropertyGroup.java

示例7: createEmptyIconLike

import com.intellij.openapi.util.IconLoader; //导入方法依赖的package包/类
@NotNull
private static Icon createEmptyIconLike(@NotNull String baseIconPath) {
  Icon baseIcon = IconLoader.findIcon(baseIconPath);
  if (baseIcon == null) {
    return EmptyIcon.ICON_16;
  }
  return new EmptyIcon(baseIcon.getIconWidth(), baseIcon.getIconHeight());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:IconUtil.java

示例8: setIconFromClass

import com.intellij.openapi.util.IconLoader; //导入方法依赖的package包/类
private static void setIconFromClass(@NotNull final Class actionClass,
                                     @NotNull final ClassLoader classLoader,
                                     @NotNull final String iconPath,
                                     @NotNull Presentation presentation,
                                     final PluginId pluginId) {
  final IconLoader.LazyIcon lazyIcon = new IconLoader.LazyIcon() {
    @Override
    protected Icon compute() {
      //try to find icon in idea class path
      Icon 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 '" + actionClass + "'");
      }

      return icon;
    }

    @Override
    public String toString() {
      return "[email protected] (path: " + iconPath + ", action class: " + actionClass + ")";
    }
  };

  if (!Registry.is("ide.lazyIconLoading")) {
    lazyIcon.load();
  }

  presentation.setIcon(lazyIcon);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:ActionManagerImpl.java

示例9: getIcon

import com.intellij.openapi.util.IconLoader; //导入方法依赖的package包/类
public static Icon getIcon(String name, boolean selected, boolean focused, boolean enabled) {
  String key = name;
  if (selected) key+= "Selected";
  if (focused) key+= "Focused";
  else if (!enabled) key+="Disabled";
  if (IntelliJLaf.isGraphite()) key= "graphite/" + 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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:MacIntelliJIconCache.java

示例10: parseValue

import com.intellij.openapi.util.IconLoader; //导入方法依赖的package包/类
protected Object parseValue(String key, @NotNull String value) {
  if ("null".equals(value)) {
    return null;
  }

  if (key.endsWith("Insets")) {
    return parseInsets(value);
  } else if (key.endsWith("Border") || key.endsWith("border")) {

    try {
      if (StringUtil.split(value, ",").size() == 4) {
        return new BorderUIResource.EmptyBorderUIResource(parseInsets(value));
      } else {
        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, DarculaLaf.class, 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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:DarculaLaf.java

示例11: paintSearchField

import com.intellij.openapi.util.IconLoader; //导入方法依赖的package包/类
protected void paintSearchField(Graphics2D g, JTextComponent c, Rectangle r) {
  g.setColor(c.getBackground());
  final boolean noBorder = c.getClientProperty("JTextField.Search.noBorderRing") == Boolean.TRUE;
  int radius = r.height-1;
  g.fillRoundRect(r.x, r.y+1, r.width, r.height - (noBorder ? 2 : 1), radius, radius);
  g.setColor(c.isEnabled() ? Gray._100 : Gray._83);
  if (!noBorder) {
    if (c.hasFocus()) {
        DarculaUIUtil.paintSearchFocusRing(g, r);
    } else {
      g.drawRoundRect(r.x, r.y, r.width, r.height-1, radius, radius);
    }
  }
  Point p = getSearchIconCoord();
  Icon searchIcon = myTextField.getClientProperty("JTextField.Search.FindPopup") instanceof JPopupMenu ? UIManager.getIcon("TextField.darcula.searchWithHistory.icon") : UIManager.getIcon("TextField.darcula.search.icon");
  if (searchIcon == null) {
    searchIcon = IconLoader.findIcon("/com/intellij/ide/ui/laf/icons/search.png", DarculaTextFieldUI.class, true);
  }
  searchIcon.paintIcon(null, g, p.x, p.y);
  if (hasText()) {
    p = getClearIconCoord();
    Icon clearIcon = UIManager.getIcon("TextField.darcula.clear.icon");
    if (clearIcon == null) {
      clearIcon = IconLoader.findIcon("/com/intellij/ide/ui/laf/icons/clear.png", DarculaTextFieldUI.class, true);
    }
    clearIcon.paintIcon(null, g, p.x, p.y);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:DarculaTextFieldUI.java

示例12: ShowHistoryAction

import com.intellij.openapi.util.IconLoader; //导入方法依赖的package包/类
public ShowHistoryAction(boolean search) {
  super((search ? "Search" : "Replace") + " History",
        (search ? "Search" : "Replace") + " history",
        IconLoader.findIcon("/com/intellij/ide/ui/laf/icons/search.png", DarculaTextFieldUI.class, true));

  myShowSearchHistory = search;

  KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_H, InputEvent.CTRL_DOWN_MASK);
  registerCustomShortcutSet(new CustomShortcutSet(new KeyboardShortcut(stroke, null)), myTextArea);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:SearchTextArea.java

示例13: getIcon

import com.intellij.openapi.util.IconLoader; //导入方法依赖的package包/类
@Nullable
private Icon getIcon(@NotNull String base) {
  Icon flagImage = myImageMap.get(base);
  if (flagImage == null) {
    // TODO: Special case locale currently running on system such
    // that the current country matches the current locale
    if (myImageMap.containsKey(base)) {
      // Already checked: there's just no image there
      return null;
    }
    @SuppressWarnings("UnnecessaryFullyQualifiedName")
    String flagFileName = base.toLowerCase(java.util.Locale.US) + ".png"; //$NON-NLS-1$
    try {
      flagImage = IconLoader.findIcon("/icons/flags/" + flagFileName, AndroidIcons.class);
    } catch (Throwable t) {
      // This shouldn't happen in production, but IconLoader.findIcon can throw exceptions
      // when IconLoader.STRICT is set to true, which is the case when running unit tests
      // or with idea.is.internal=true
    }
    if (flagImage == null) {
      flagImage = AndroidIcons.EmptyFlag;
    }
    myImageMap.put(base, flagImage);
  }

  return flagImage;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:FlagManager.java

示例14: setValue

import com.intellij.openapi.util.IconLoader; //导入方法依赖的package包/类
@Override
public void setValue(@Nullable SystemImageDescription newValue, @NotNull JBLabel component) {
  if (newValue != null) {
    String codeName = SystemImagePreview.getCodeName(newValue);
    component.setText(codeName);
    try {
      Icon icon = IconLoader.findIcon(String.format("/icons/versions/%s_32.png", codeName), AndroidIcons.class);
      component.setIcon(icon);
    }
    catch (RuntimeException e) {
      // Pass
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:ConfigureAvdOptionsStep.java

示例15: getIcon

import com.intellij.openapi.util.IconLoader; //导入方法依赖的package包/类
/**
 * @return item's icon. This icon is used to represent item at the toolbar.
 * Note, that the method never returns <code>null</code>. It returns some
 * default "unknown" icon for the items that has no specified icon in the XML.
 */
@NotNull public Icon getIcon() {
  // Check cached value first
  if(myIcon != null){
    return myIcon;
  }

  // Create new icon
  if(myIconPath != null && myIconPath.length() > 0) {
    final VirtualFile iconFile = ResourceFileUtil.findResourceFileInScope(myIconPath, myProject, GlobalSearchScope.allScope(myProject));
    if (iconFile != null) {
      try {
        myIcon = new ImageIcon(iconFile.contentsToByteArray());
      }
      catch (IOException e) {
        myIcon = null;
      }
    }
    else {
      myIcon = IconLoader.findIcon(myIconPath);
    }
  }
  if(myIcon == null){
    myIcon = UIDesignerIcons.Unknown;
   }
  LOG.assertTrue(myIcon != null);
  return myIcon;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:ComponentItem.java


注:本文中的com.intellij.openapi.util.IconLoader.findIcon方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。