public void createWindow(Project project) { jFXPanel = new JFXPanel(); ToolWindow toolWindow = ToolWindowManager.getInstance(project).registerToolWindow("Basis.js", false, ToolWindowAnchor.BOTTOM, false); toolWindow.setIcon(IconLoader.getIcon("/icons/basisjs.png")); ContentFactory contentFactory = ContentFactory.SERVICE.getInstance(); Content content = contentFactory.createContent(jFXPanel, "inspector", false); toolWindow.getContentManager().addContent(content); InspectorController sceneInspectorController = new InspectorController(); FXMLLoader fxmlLoader = new FXMLLoader(); fxmlLoader.setLocation(getClass().getResource("/com/basisjs/ui/windows/tools/inspector/InspectorScene.fxml")); fxmlLoader.setController(sceneInspectorController); Platform.setImplicitExit(false); PlatformImpl.runLater(() -> { try { Scene scene = new Scene(fxmlLoader.load()); jFXPanel.setScene(scene); webView = sceneInspectorController.webView; webView.setContextMenuEnabled(false); } catch (IOException e) { e.printStackTrace(); } }); }
@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); } } } } }
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); } } }
private Icon getIcon() { if (icon == null) { String selector; if (SystemInfo.isMac) { selector = "OSX"; } else if (SystemInfo.isWindows) { selector = "Windows"; } else { selector = "Linux"; } icon = IconLoader.getIcon("/lafs/" + selector + previewFileName + ".png"); } return icon; }
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; }
private void editToolbarIcon(String actionId, DefaultMutableTreeNode node) { final AnAction anAction = ActionManager.getInstance().getAction(actionId); if (isToolbarAction(node) && anAction.getTemplatePresentation().getIcon() == null) { final int exitCode = Messages.showOkCancelDialog(IdeBundle.message("error.adding.action.without.icon.to.toolbar"), IdeBundle.message("title.unable.to.add.action.without.icon.to.toolbar"), Messages.getInformationIcon()); if (exitCode == Messages.OK) { mySelectedSchema.addIconCustomization(actionId, null); anAction.getTemplatePresentation().setIcon(AllIcons.Toolbar.Unknown); anAction.getTemplatePresentation().setDisabledIcon(IconLoader.getDisabledIcon(AllIcons.Toolbar.Unknown)); anAction.setDefaultIcon(false); node.setUserObject(Pair.create(actionId, AllIcons.Toolbar.Unknown)); myActionsTree.repaint(); CustomActionsSchema.setCustomizationSchemaForCurrentProjects(); } } }
public static void setScaleFactor(float scale) { if (SystemProperties.has("hidpi") && !SystemProperties.is("hidpi")) { return; } if (scale < 1.25f) scale = 1.0f; else if (scale < 1.5f) scale = 1.25f; else if (scale < 1.75f) scale = 1.5f; else if (scale < 2f) scale = 1.75f; else scale = 2.0f; if (SystemInfo.isLinux && scale == 1.25f) { //Default UI font size for Unity and Gnome is 15. Scaling factor 1.25f works badly on Linux scale = 1f; } SCALE_FACTOR = scale; IconLoader.setScale(scale); }
private boolean customize(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { if (!(value instanceof DefaultMutableTreeNode)) { return false; } final DefaultMutableTreeNode node = (DefaultMutableTreeNode)value; final Object userObject = node.getUserObject(); if (!(userObject instanceof NodeDescriptor)) { return false; } final NodeDescriptor descriptor = (NodeDescriptor)userObject; final Object element = descriptor.getElement(); if (!(element instanceof FileElement)) { return false; } final FileElement fileElement = (FileElement)element; if (!isExcluded(fileElement)) { return false; } setIcon(IconLoader.getDisabledIcon(descriptor.getIcon())); final String text = tree.convertValueToText(value, selected, expanded, leaf, row, hasFocus); append(text, new SimpleTextAttributes(SimpleTextAttributes.STYLE_STRIKEOUT, tree.getForeground())); return true; }
private static Icon load(String path) { try { return IconLoader.getIcon(path, PluginIcons.class); } catch (IllegalStateException e) { return null; } }
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()); } }
public static void replaceIcons(final Class iconsClass, final String iconsRootPath) { // Iterate all fields (which hold icon locations) and patch them if necessary for (final Field field : iconsClass.getDeclaredFields()) { if (Modifier.isStatic(field.getModifiers())) { try { // Object should be some kind of javax.swing.Icon final Object value = field.get(null); final Class byClass = value.getClass(); if (byClass.getName().endsWith("$ByClass")) { StaticPatcher.setFieldValue(value, "myCallerClass", IconReplacer.class); StaticPatcher.setFieldValue(value, "myWasComputed", Boolean.FALSE); StaticPatcher.setFieldValue(value, "myIcon", null); } else if (byClass.getName().endsWith("$CachedImageIcon")) { final String newPath = patchUrlIfNeeded(value, iconsRootPath); if (newPath != null) { final Icon newIcon = IconLoader.getIcon(newPath); StaticPatcher.setFinalStatic(field, newIcon); } } } catch (final Exception e) { // suppress // e.printStackTrace(); } } } // Recurse into nested classes for (final Class subClass : iconsClass.getDeclaredClasses()) { replaceIcons(subClass, iconsRootPath); } }
/** * Load the association's icon * * @param file * @param association * @return */ private Icon loadIcon(final FileInfo file, final Association association) { Icon icon = null; try { if (association instanceof PsiElementAssociation) { icon = ((PsiElementAssociation) association).getIconForFile(file); } else { icon = IconLoader.getIcon(association.getIcon()); } } catch (Exception e) { e.printStackTrace(); } return icon; }
public static Icon load(String icon) { if (icons.containsKey(icon)) { return icons.get(icon); } try { icons.put(icon, IconLoader.findIcon("/icons/" + icon.toLowerCase() + ".png")); } catch (Exception e) { icons.put(icon, defaultIcon); } return icons.get(icon); }
@Override public void projectOpened() { Icon icon = IconLoader.getIcon(ICON_NYANDROID); ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project); ToolWindow toolWindow = toolWindowManager.getToolWindow("Logcat"); if (toolWindow != null) { toolWindow.setIcon(icon); } }
private static void patchRenderer(@NotNull ProjectJdkImpl fakeSdk, @NotNull PythonSdkChooserCombo combo) { combo.getComboBox().setRenderer(new PySdkListCellRenderer(true) { @Override public void customize(JList list, Object item, int index, boolean selected, boolean hasFocus) { super.customize(list, item, index, selected, hasFocus); if (item == fakeSdk) { setIcon(IconLoader.getTransparentIcon(PythonIcons.Python.Virtualenv)); } } }); }
private static JComponent getIconComponent() { JLabel iconPanel = new JLabel(IconLoader.getIconSnapshot(BlazeIcons.BazelLeaf)) { @Override public boolean isEnabled() { return true; } }; UiUtil.setPreferredWidth(iconPanel, 16); return iconPanel; }
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; }
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; }
@Override public Icon getIcon() { if (myIcon == null) { myIcon = IconLoader.findIcon(myIconPath, myMetaModel.getModel()); } return myIcon; }
private static Icon[] findIcons(String prefix, String maskIconPath) { Icon maskIcon = maskIconPath != null ? IconLoader.getIcon(maskIconPath) : null; Icon[] icons = new Icon[COUNT]; for (int i = 0; i <= COUNT - 1; i++) { Icon eachIcon = IconLoader.getIcon(prefix + (i + 1) + ".png"); if (maskIcon != null) { icons[i] = new ProcessIcon(maskIcon, eachIcon); } else { icons[i] = eachIcon; } } return icons; }
@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()); }
/** * Notifies all registered listeners that UI settings has been changed. */ public void fireUISettingsChanged() { incModificationCount(); myDispatcher.getMulticaster().uiSettingsChanged(this); ApplicationManager.getApplication().getMessageBus().syncPublisher(UISettingsListener.TOPIC).uiSettingsChanged(this); IconLoader.setFilter(COLOR_BLINDNESS == ColorBlindness.protanopia ? DaltonizationFilter.protanopia : COLOR_BLINDNESS == ColorBlindness.deuteranopia ? DaltonizationFilter.deuteranopia : COLOR_BLINDNESS == ColorBlindness.tritanopia ? DaltonizationFilter.tritanopia : null); }
private static JPanel createHeaderPanel() { JPanel header = new JPanel(new BorderLayout()); JLabel welcome = new JLabel("Welcome to " + ApplicationNamesInfo.getInstance().getFullProductName(), IconLoader.getIcon(ApplicationInfoEx.getInstanceEx().getWelcomeScreenLogoUrl()), SwingConstants.LEFT); welcome.setBorder(new EmptyBorder(10, 15, 10, 15)); welcome.setFont(welcome.getFont().deriveFont((float) 32)); welcome.setIconTextGap(20); welcome.setForeground(WelcomeScreenColors.WELCOME_HEADER_FOREGROUND); header.add(welcome); header.setBackground(WelcomeScreenColors.WELCOME_HEADER_BACKGROUND); header.setBorder(new BottomLineBorder()); return header; }
@Override public void paintComponent(Graphics g) { super.paintComponent(g); AnAction action = getAction(); if (action instanceof ActivateCard) { Rectangle bounds = getBounds(); Icon icon = AllIcons.Actions.Forward; //AllIcons.Icons.Ide.NextStepGrayed; int y = (bounds.height - icon.getIconHeight()) / 2; int x = bounds.width - icon.getIconWidth() - 15; if (getPopState() == POPPED) { final GraphicsConfig config = GraphicsUtil.setupAAPainting(g); g.setColor(WelcomeScreenColors.CAPTION_BACKGROUND); g.fillOval(x - 3, y - 3, icon.getIconWidth() + 6, icon.getIconHeight() + 6); g.setColor(WelcomeScreenColors.GROUP_ICON_BORDER_COLOR); g.drawOval(x - 3, y - 3, icon.getIconWidth() + 6, icon.getIconHeight() + 6); config.restore(); } else { icon = IconLoader.getDisabledIcon(icon); } icon.paintIcon(this, g, x, y); } }
void updatePresentation() { updateState(); updateText(); Icon icon = myDecorator.getToolWindow().getIcon(); setIcon(icon); setDisabledIcon(IconLoader.getDisabledIcon(icon)); }
private void updateIcon() { if (UISettings.getInstance().SHOW_ICONS_IN_MENUS) { final Presentation presentation = myPresentation; final Icon icon = presentation.getIcon(); setIcon(icon); if (presentation.getDisabledIcon() != null) { setDisabledIcon(presentation.getDisabledIcon()); } else { setDisabledIcon(IconLoader.getDisabledIcon(icon)); } } }
public void updateIcon() { myIcon = myPresentation.getIcon(); if (myPresentation.getDisabledIcon() != null) { // set disabled icon if it is specified myDisabledIcon = myPresentation.getDisabledIcon(); } else { myDisabledIcon = IconLoader.getDisabledIcon(myIcon); } }
public Splash(String imageName, final Color textColor) { super((Frame)null, false); setUndecorated(true); if (!(SystemInfo.isLinux && SystemInfo.isJavaVersionAtLeast("1.7"))) { setResizable(false); } setFocusableWindowState(false); Icon originalImage = IconLoader.getIcon(imageName); myImage = new SplashImage(originalImage, textColor); myLabel = new JLabel(myImage) { @Override protected void paintComponent(Graphics g) { super.paintComponent(g); mySplashIsVisible = true; myProgressLastPosition = 0; paintProgress(g); } }; Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); contentPane.add(myLabel, BorderLayout.CENTER); Dimension size = getPreferredSize(); setSize(size); pack(); setLocationInTheCenterOfScreen(); }
public Icon getIcon() { if (myIcon == null) { if (myIconPath == null) { return myPaletteItem == null ? null : myPaletteItem.getIcon(); } myIcon = IconLoader.findIcon(myIconPath, myModel); } return myIcon; }
public CustomizeDesktopEntryStep(String iconPath) { setLayout(new BorderLayout()); JPanel panel = createBigButtonPanel(createSmallBorderLayout(), myCreateEntryCheckBox, EmptyRunnable.INSTANCE); panel.setBorder(createSmallEmptyBorder()); JPanel buttonPanel = new JPanel(new GridBagLayout()); buttonPanel.setOpaque(false); GridBag gbc = new GridBag().setDefaultAnchor(GridBagConstraints.WEST).setDefaultFill(GridBagConstraints.HORIZONTAL).setDefaultWeightX(1); myCreateEntryCheckBox.setOpaque(false); buttonPanel.add(myCreateEntryCheckBox, gbc.nextLine()); myGlobalEntryCheckBox.setOpaque(false); gbc.nextLine().insets.left = UIUtil.PANEL_REGULAR_INSETS.left; buttonPanel.add(myGlobalEntryCheckBox, gbc); panel.add(buttonPanel, BorderLayout.NORTH); JLabel label = new JLabel(IconLoader.getIcon(iconPath)); label.setVerticalAlignment(JLabel.TOP); panel.add(label, BorderLayout.CENTER); add(panel, BorderLayout.CENTER); myCreateEntryCheckBox.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { myGlobalEntryCheckBox.setEnabled(myCreateEntryCheckBox.isSelected()); myGlobalEntryCheckBox.setSelected(myCreateEntryCheckBox.isSelected() && !PathManager.getHomePath().startsWith("/home")); } }); myCreateEntryCheckBox.setSelected(true); }
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; }
public static void uninstall() { JBColor.setDark(false); IconLoader.setUseDarkIcons(false); if (DarculaLaf.NAME.equals(EditorColorsManager.getInstance().getGlobalScheme().getName())) { final EditorColorsScheme scheme = EditorColorsManager.getInstance().getScheme(EditorColorsScheme.DEFAULT_SCHEME_NAME); if (scheme != null) { EditorColorsManager.getInstance().setGlobalScheme(scheme); } } update(); }
public static void install() { JBColor.setDark(true); IconLoader.setUseDarkIcons(true); if (!DarculaLaf.NAME.equals(EditorColorsManager.getInstance().getGlobalScheme().getName())) { final EditorColorsScheme scheme = EditorColorsManager.getInstance().getScheme(DarculaLaf.NAME); if (scheme != null) { EditorColorsManager.getInstance().setGlobalScheme(scheme); } } update(); }
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; }
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); } }
@Nullable private static Icon getAquaMenuDisabledIcon() { final Icon arrowIcon = (Icon)UIManager.get("Menu.arrowIcon"); if (arrowIcon != null) { return IconLoader.getDisabledIcon(arrowIcon); } return null; }
public static void main(String[] args) { IconLoader.activate(); final JFrame frame = new JFrame(); frame.getContentPane().setLayout(new BorderLayout()); final JPanel content = new JPanel(new BorderLayout()); final LoadingDecorator loadingTree = new LoadingDecorator(new JComboBox(), Disposer.newDisposable(), -1); content.add(loadingTree.getComponent(), BorderLayout.CENTER); final JCheckBox loadingCheckBox = new JCheckBox("Loading"); loadingCheckBox.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { if (loadingTree.isLoading()) { loadingTree.stopLoading(); } else { loadingTree.startLoading(false); } } }); content.add(loadingCheckBox, BorderLayout.SOUTH); frame.getContentPane().add(content, BorderLayout.CENTER); frame.setBounds(300, 300, 300, 300); frame.show(); }