com.intellij.util.ui.EmptyIcon Java Examples
The following examples show how to use
com.intellij.util.ui.EmptyIcon.
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: AdvancedSettingsAction.java From consulo with Apache License 2.0 | 6 votes |
private static int calculateCheckBoxIndent() { JCheckBox checkBox = new JCheckBox(); Icon icon = checkBox.getIcon(); int indent = 0; if (icon == null) { icon = UIManager.getIcon("CheckBox.icon"); } if (UIUtil.isUnderDarcula() || UIUtil.isUnderIntelliJLaF()) { icon = EmptyIcon.create(20, 18); } if (icon != null) { final Insets i = checkBox.getInsets(); final Rectangle r = checkBox.getBounds(); final Rectangle r1 = new Rectangle(); r1.x = i.left; r1.y = i.top; r1.width = r.width - (i.right + r1.x); r1.height = r.height - (i.bottom + r1.y); final Rectangle iconRect = new Rectangle(); SwingUtilities.layoutCompoundLabel(checkBox, checkBox.getFontMetrics(checkBox.getFont()), checkBox.getText(), icon, checkBox.getVerticalAlignment(), checkBox.getHorizontalAlignment(), checkBox.getVerticalTextPosition(), checkBox.getHorizontalTextPosition(), r1, new Rectangle(), iconRect, checkBox.getText() == null ? 0 : checkBox.getIconTextGap()); indent = iconRect.x; } return indent + checkBox.getIconTextGap(); }
Example #2
Source File: PresentationModeProgressPanel.java From consulo with Apache License 2.0 | 6 votes |
public PresentationModeProgressPanel(InlineProgressIndicator progress) { myProgress = progress; Font font = JBUI.Fonts.label(11); myText.setFont(font); myText2.setFont(font); myText.setIcon(JBUI.scale(EmptyIcon.create(1, 16))); myText2.setIcon(JBUI.scale(EmptyIcon.create(1, 16))); myUpdateQueue = new MergingUpdateQueue("Presentation Mode Progress", 100, true, null); myUpdate = new Update("Update UI") { @Override public void run() { updateImpl(); } }; myEastButtons = myProgress.createEastButtons(); myButtonPanel.add(InlineProgressIndicator.createButtonPanel(myEastButtons.map(b -> b.button))); }
Example #3
Source File: LightToolWindow.java From consulo with Apache License 2.0 | 6 votes |
public ActionButton(AnAction action) { myAction = action; Presentation presentation = action.getTemplatePresentation(); InplaceButton button = new InplaceButton(KeymapUtil.createTooltipText(presentation.getText(), action), EmptyIcon.ICON_16, this) { @Override public boolean isActive() { return LightToolWindow.this.isActive(); } }; button.setHoveringEnabled(!SystemInfo.isMac); setContent(button); Icon icon = presentation.getIcon(); Icon hoveredIcon = presentation.getHoveredIcon(); button.setIcons(icon, icon, hoveredIcon == null ? icon : hoveredIcon); }
Example #4
Source File: GtkMenuItemUI.java From consulo with Apache License 2.0 | 6 votes |
@Override public void update(final Graphics g, final JComponent c) { myHiddenItem.setSelected(menuItem.isSelected()); if (UIUtil.isMurrineBasedTheme()) { acceleratorFont = menuItem.getFont(); final Color fg = GtkPaintingUtil.getForeground(myOriginalUI, menuItem); acceleratorForeground = UIUtil.mix(fg, menuItem.getBackground(), menuItem.isSelected() ? 0.4 : 0.2); disabledForeground = fg; } if (checkIcon != null && !(checkIcon instanceof IconWrapper) && !(checkIcon instanceof EmptyIcon)) { checkIcon = new IconWrapper(checkIcon, myOriginalUI); } super.update(g, c); }
Example #5
Source File: ModernMenuUI.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void installDefaults() { super.installDefaults(); Integer integer = UIUtil.getPropertyMaxGutterIconWidth(getPropertyPrefix()); if (integer != null) { myMaxGutterIconWidth = JBUI.scale(integer.intValue()); } arrowIcon = EmptyIcon.create(myMaxGutterIconWidth); }
Example #6
Source File: LafIconLookup.java From consulo with Apache License 2.0 | 5 votes |
public static Icon getIcon(@Nonnull String name, boolean selected, boolean focused, boolean enabled, boolean editable, boolean pressed) { Icon icon = findIcon(name, selected, focused, enabled, editable, pressed, true); if (icon == null) { icon = EmptyIcon.ICON_16; } return icon; }
Example #7
Source File: SearchEverywhereUI.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void customizeCellRenderer(@Nonnull JList<?> list, Object value, int index, boolean selected, boolean hasFocus) { setPaintFocusBorder(false); setIcon(EmptyIcon.ICON_16); setFont(list.getFont()); SearchEverywhereCommandInfo command = (SearchEverywhereCommandInfo)value; append(command.getCommandWithPrefix() + " ", new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, list.getForeground())); append(command.getDefinition(), new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, JBColor.GRAY)); setBackground(UIUtil.getListBackground(selected)); }
Example #8
Source File: BookmarksFavoriteListProvider.java From consulo with Apache License 2.0 | 5 votes |
@Override public void customizeRenderer(ColoredTreeCellRenderer renderer, JTree tree, @Nonnull Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { renderer.clear(); renderer.setIcon(Bookmark.getDefaultIcon()); if (value instanceof Bookmark) { Bookmark bookmark = (Bookmark)value; BookmarkItem.setupRenderer(renderer, myProject, bookmark, selected); if (renderer.getIcon() != null) { RowIcon icon = new RowIcon(3, RowIcon.Alignment.CENTER); icon.setIcon(TargetAWT.to(bookmark.getIcon()), 0); icon.setIcon(JBUI.scale(EmptyIcon.create(1)), 1); icon.setIcon(renderer.getIcon(), 2); renderer.setIcon(icon); } else { renderer.setIcon(bookmark.getIcon()); } } else { renderer.append(getListName(myProject)); } }
Example #9
Source File: LookupActionsStep.java From consulo with Apache License 2.0 | 5 votes |
public LookupActionsStep(Collection<LookupElementAction> actions, LookupImpl lookup, LookupElement lookupElement) { super(null, new ArrayList<>(actions)); myLookup = lookup; myLookupElement = lookupElement; int w = 0, h = 0; for (LookupElementAction action : actions) { final Icon icon = action.getIcon(); if (icon != null) { w = Math.max(w, icon.getIconWidth()); h = Math.max(h, icon.getIconHeight()); } } myEmptyIcon = new EmptyIcon(w, h); }
Example #10
Source File: LookupCellRenderer.java From consulo with Apache License 2.0 | 5 votes |
int updateMaximumWidth(final LookupElementPresentation p, LookupElement item) { final Icon icon = p.getIcon(); if (icon != null && (icon.getIconWidth() > myEmptyIcon.getIconWidth() || icon.getIconHeight() > myEmptyIcon.getIconHeight())) { myEmptyIcon = EmptyIcon.create(Math.max(icon.getIconWidth(), myEmptyIcon.getIconWidth()), Math.max(icon.getIconHeight(), myEmptyIcon.getIconHeight())); } return RealLookupElementPresentation.calculateWidth(p, getRealFontMetrics(item, false), getRealFontMetrics(item, true)) + calcSpacing(myTailComponent, null) + calcSpacing(myTypeLabel, null); }
Example #11
Source File: DefaultLookupItemRenderer.java From consulo with Apache License 2.0 | 5 votes |
@Nullable private static Icon _getRawIcon(LookupElement item, boolean real) { if (item instanceof LookupItem) { Icon icon = (Icon)((LookupItem)item).getAttribute(LookupItem.ICON_ATTR); if (icon != null) return icon; } Object o = item.getObject(); if (!real) { if (item.getObject() instanceof String) { return EmptyIcon.ICON_0; } return new EmptyIcon(IconUtil.getDefaultNodeIconSize() * 2, IconUtil.getDefaultNodeIconSize()); } if (o instanceof Iconable && !(o instanceof PsiElement)) { return TargetAWT.to(((Iconable)o).getIcon(Iconable.ICON_FLAG_VISIBILITY)); } final PsiElement element = item.getPsiElement(); if (element != null && element.isValid()) { return TargetAWT.to(IconDescriptorUpdaters.getIcon(element, Iconable.ICON_FLAG_VISIBILITY)); } return null; }
Example #12
Source File: BranchActionGroup.java From consulo with Apache License 2.0 | 5 votes |
public BranchActionGroup() { super("", true); myIcon = new LayeredIcon(TargetAWT.to(DvcsImplIcons.Favorite), EmptyIcon.ICON_16); myHoveredIcon = new LayeredIcon(TargetAWT.to(DvcsImplIcons.FavoriteOnHover), TargetAWT.to(DvcsImplIcons.NotFavoriteOnHover)); getTemplatePresentation().setIcon(myIcon); getTemplatePresentation().setHoveredIcon(myHoveredIcon); updateIcons(); }
Example #13
Source File: BranchActionGroupPopup.java From consulo with Apache License 2.0 | 5 votes |
private MyToolbarButton(@Nullable String text, @Nullable Icon icon, @Nullable Icon rolloverIcon) { setBorder(JBUI.Borders.empty(0, 2)); setBorderPainted(false); setContentAreaFilled(false); setOpaque(false); setRolloverEnabled(true); Icon regularIcon = chooseNotNull(icon, EmptyIcon.ICON_0); setIcon(regularIcon); setToolTipText(text); setRolloverIcon(chooseNotNull(rolloverIcon, regularIcon)); update(); setUI(new BasicButtonUI()); }
Example #14
Source File: ShowUIDefaultsAction.java From consulo with Apache License 2.0 | 5 votes |
@Override public void paintIcon(Component c, Graphics g, int x, int y) { try { myIcon.paintIcon(c, g, x, y); } catch (Exception e) { EmptyIcon.ICON_0.paintIcon(c, g, x, y); } }
Example #15
Source File: ActionStepBuilder.java From consulo with Apache License 2.0 | 5 votes |
private void calcMaxIconSize(final ActionGroup actionGroup) { if (myPresentationFactory instanceof MenuItemPresentationFactory && ((MenuItemPresentationFactory)myPresentationFactory).shallHideIcons()) return; AnAction[] actions = actionGroup.getChildren(createActionEvent(actionGroup)); for (AnAction action : actions) { if (action == null) continue; if (action instanceof ActionGroup) { final ActionGroup group = (ActionGroup)action; if (!group.isPopup()) { calcMaxIconSize(group); continue; } } Icon icon = action.getTemplatePresentation().getIcon(); if (icon == null && action instanceof Toggleable) icon = EmptyIcon.ICON_16; if (icon != null) { final int width = icon.getIconWidth(); final int height = icon.getIconHeight(); if (myMaxIconWidth < width) { myMaxIconWidth = width; } if (myMaxIconHeight < height) { myMaxIconHeight = height; } } } }
Example #16
Source File: GtkMenuItemUI.java From consulo with Apache License 2.0 | 5 votes |
@Override public void installUI(final JComponent c) { super.installUI(c); myHiddenItem = new JCheckBoxMenuItem(); myOriginalUI.installUI(myHiddenItem); menuItem.setBorder(myHiddenItem.getBorder()); final Icon icon = getCheckIconFromContext(myOriginalUI, myHiddenItem); checkIcon = isCheckBoxItem() ? icon : EmptyIcon.create(icon); }
Example #17
Source File: ActionStepBuilder.java From consulo with Apache License 2.0 | 5 votes |
public void buildGroup(@Nonnull ActionGroup actionGroup) { calcMaxIconSize(actionGroup); myEmptyIcon = myMaxIconHeight != -1 && myMaxIconWidth != -1 ? EmptyIcon.create(myMaxIconWidth, myMaxIconHeight) : null; appendActionsFromGroup(actionGroup); if (myListModel.isEmpty()) { myListModel.add(new PopupFactoryImpl.ActionItem(Utils.EMPTY_MENU_FILLER, Utils.NOTHING_HERE, null, false, null, null, false, null)); } }
Example #18
Source File: CheckBoxList.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private static Dimension getCheckBoxDimension(@Nonnull JCheckBox checkBox) { Icon icon = null; BasicRadioButtonUI ui = ObjectUtils.tryCast(checkBox.getUI(), BasicRadioButtonUI.class); if (ui != null) { icon = ui.getDefaultIcon(); } if (icon == null) { // com.intellij.ide.ui.laf.darcula.ui.DarculaCheckBoxUI.getDefaultIcon() icon = JBUI.scale(EmptyIcon.create(20)); } Insets margin = checkBox.getMargin(); return new Dimension(margin.left + icon.getIconWidth(), margin.top + icon.getIconHeight()); }
Example #19
Source File: SimpleTree.java From consulo with Apache License 2.0 | 5 votes |
@Deprecated public Icon getEmptyHandle() { if (myEmptyHandle == null) { final Icon expand = getExpandedHandle(); myEmptyHandle = expand != null ? EmptyIcon.create(expand) : EmptyIcon.create(0); } return myEmptyHandle; }
Example #20
Source File: ActiveIcon.java From consulo with Apache License 2.0 | 4 votes |
protected void setIcons(@Nullable final Icon regular, @Nullable final Icon inactive) { myRegular = regular != null ? regular : EmptyIcon.ICON_0; myInactive = inactive != null ? inactive : myRegular; }
Example #21
Source File: DarculaRadioButtonUI.java From consulo with Apache License 2.0 | 4 votes |
@Override public Icon getDefaultIcon() { return JBUI.scale(EmptyIcon.create(20)).asUIResource(); }
Example #22
Source File: JBComboBoxTableCellEditorComponent.java From consulo with Apache License 2.0 | 4 votes |
private Icon getEmptyIcon() { if (myEmptyIcon == null) { myEmptyIcon = EmptyIcon.create(getIcon(true).getIconWidth()); } return myEmptyIcon; }
Example #23
Source File: TooltipReferencesPanel.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull private static Icon createEmptyIcon(int height) { return EmptyIcon.create(LabelIcon.getWidth(height, 2), height); }
Example #24
Source File: StructureFilterPopupComponent.java From consulo with Apache License 2.0 | 4 votes |
private SelectVisibleRootAction(@Nonnull VirtualFile root) { super(root.getName(), root.getPresentableUrl(), null); myRoot = root; myIcon = new CheckboxColorIcon(CHECKBOX_ICON_SIZE, VcsLogGraphTable.getRootBackgroundColor(myRoot, myColorManager)); getTemplatePresentation().setIcon(EmptyIcon.create(CHECKBOX_ICON_SIZE)); // see PopupFactoryImpl.calcMaxIconSize }
Example #25
Source File: StructureFilterPopupComponent.java From consulo with Apache License 2.0 | 4 votes |
private SelectFromHistoryAction(@Nonnull VcsLogStructureFilter filter) { super(getStructureActionText(filter), getTooltipTextForFilePaths(filter.getFiles(), false).replace("\n", " "), null); myFilter = filter; myIcon = new SizedIcon(PlatformIcons.CHECK_ICON_SMALL, CHECKBOX_ICON_SIZE, CHECKBOX_ICON_SIZE); myEmptyIcon = EmptyIcon.create(CHECKBOX_ICON_SIZE); }
Example #26
Source File: ParameterInfoTaskRunnerUtil.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull private static Consumer<Boolean> startProgressAndCreateStopAction(Project project, String progressTitle, AtomicReference<CancellablePromise<?>> promiseRef, Editor editor) { AtomicReference<Consumer<Boolean>> stopActionRef = new AtomicReference<>(); Consumer<Boolean> originalStopAction = (cancel) -> { stopActionRef.set(null); if (cancel) { CancellablePromise<?> promise = promiseRef.get(); if (promise != null) { promise.cancel(); } } }; if (progressTitle == null) { stopActionRef.set(originalStopAction); } else { final Disposable disposable = Disposable.newDisposable(); Disposer.register(project, disposable); JBLoadingPanel loadingPanel = new JBLoadingPanel(null, panel -> new LoadingDecorator(panel, disposable, 0, false, new AsyncProcessIcon("ShowParameterInfo")) { @Override protected NonOpaquePanel customizeLoadingLayer(JPanel parent, JLabel text, AsyncProcessIcon icon) { parent.setLayout(new FlowLayout(FlowLayout.LEFT)); final NonOpaquePanel result = new NonOpaquePanel(); result.add(icon); parent.add(result); return result; } }); loadingPanel.add(new JBLabel(EmptyIcon.ICON_18)); loadingPanel.add(new JBLabel(progressTitle)); ComponentPopupBuilder builder = JBPopupFactory.getInstance().createComponentPopupBuilder(loadingPanel, null).setProject(project).setCancelCallback(() -> { Consumer<Boolean> stopAction = stopActionRef.get(); if (stopAction != null) { stopAction.accept(true); } return true; }); JBPopup popup = builder.createPopup(); Disposer.register(disposable, popup); ScheduledFuture<?> showPopupFuture = EdtScheduledExecutorService.getInstance().schedule(() -> { if (!popup.isDisposed() && !popup.isVisible() && !editor.isDisposed()) { RelativePoint popupPosition = JBPopupFactory.getInstance().guessBestPopupLocation(editor); loadingPanel.startLoading(); popup.show(popupPosition); } }, ModalityState.defaultModalityState(), DEFAULT_PROGRESS_POPUP_DELAY_MS, TimeUnit.MILLISECONDS); stopActionRef.set((cancel) -> { try { loadingPanel.stopLoading(); originalStopAction.accept(cancel); } finally { showPopupFuture.cancel(false); UIUtil.invokeLaterIfNeeded(() -> { if (popup.isVisible()) { popup.setUiVisible(false); } Disposer.dispose(disposable); }); } }); } return stopActionRef.get(); }
Example #27
Source File: ActionButtonWithText.java From consulo with Apache License 2.0 | 4 votes |
public int iconTextSpace() { return (getIcon() instanceof EmptyIcon || getIcon() == null) ? 0 : JBUI.scale(ICON_TEXT_SPACE); }
Example #28
Source File: Injectable.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull public Icon getIcon() { return EmptyIcon.ICON_16; }
Example #29
Source File: CustomizableActionsPanel.java From consulo with Apache License 2.0 | 4 votes |
protected boolean doSetIcon(DefaultMutableTreeNode node, @Nullable String path, Component component) { if (StringUtil.isNotEmpty(path) && !new File(path).isFile()) { Messages .showErrorDialog(component, IdeBundle.message("error.file.not.found.message", path), IdeBundle.message("title.choose.action.icon")); return false; } String actionId = getActionId(node); if (actionId == null) return false; final AnAction action = ActionManager.getInstance().getAction(actionId); if (action != null && action.getTemplatePresentation() != null) { if (StringUtil.isNotEmpty(path)) { Image image = null; try { image = ImageLoader.loadFromStream(VfsUtil.convertToURL(VfsUtil.pathToUrl(path.replace(File.separatorChar, '/'))).openStream()); } catch (IOException e) { LOG.debug(e); } Icon icon = new File(path).exists() ? IconLoader.getIcon(image) : null; if (icon != null) { if (icon.getIconWidth() > EmptyIcon.ICON_18.getIconWidth() || icon.getIconHeight() > EmptyIcon.ICON_18.getIconHeight()) { Messages.showErrorDialog(component, IdeBundle.message("custom.icon.validation.message"), IdeBundle.message("title.choose.action.icon")); return false; } node.setUserObject(Pair.create(actionId, icon)); mySelectedSchema.addIconCustomization(actionId, path); } } else { node.setUserObject(Pair.create(actionId, null)); mySelectedSchema.removeIconCustomization(actionId); final DefaultMutableTreeNode nodeOnToolbar = findNodeOnToolbar(actionId); if (nodeOnToolbar != null){ editToolbarIcon(actionId, nodeOnToolbar); node.setUserObject(nodeOnToolbar.getUserObject()); } } return true; } return false; }
Example #30
Source File: FileColorSettingsTable.java From consulo with Apache License 2.0 | 3 votes |
private ColorCellRenderer(final FileColorManager manager) { setOpaque(true); myManager = manager; setIcon(EmptyIcon.ICON_16); }