protected JLabel createActionLabel( final AnAction anAction, final String anActionName, final Color fg, final Color bg, final Icon icon) { final LayeredIcon layeredIcon = new LayeredIcon(2); layeredIcon.setIcon(EMPTY_ICON, 0); if (icon != null && icon.getIconWidth() <= EMPTY_ICON.getIconWidth() && icon.getIconHeight() <= EMPTY_ICON.getIconHeight()) { layeredIcon.setIcon( icon, 1, (-icon.getIconWidth() + EMPTY_ICON.getIconWidth()) / 2, (EMPTY_ICON.getIconHeight() - icon.getIconHeight()) / 2); } final Shortcut[] shortcutSet = KeymapManager.getInstance().getActiveKeymap().getShortcuts(getActionId(anAction)); final String actionName = anActionName + (shortcutSet != null && shortcutSet.length > 0 ? " (" + KeymapUtil.getShortcutText(shortcutSet[0]) + ")" : ""); final JLabel actionLabel = new JLabel(actionName, layeredIcon, SwingConstants.LEFT); actionLabel.setBackground(bg); actionLabel.setForeground(fg); return actionLabel; }
private static LayeredIcon wrapIconWithWarningDecorator(Icon icon) { final LayeredIcon layered = new LayeredIcon(2); layered.setIcon(icon, 0); // TODO: Create a separate invalid SDK overlay icon (DSGN-497) final Icon overlay = AllIcons.Actions.Cancel; layered.setIcon(overlay, 1); return layered; }
@Nullable public Icon getIcon(int flags) { Icon superIcon = JetgroovyIcons.Groovy.Field; if (!isProperty()) return superIcon; LayeredIcon rowIcon = new LayeredIcon(2); rowIcon.setIcon(superIcon, 0); rowIcon.setIcon(JetgroovyIcons.Groovy.Def, 1); return rowIcon; }
public final boolean update() { boolean changes = super.update(); if (getPsiElement() == null) { final String invalidPrefix = IdeBundle.message("node.hierarchy.invalid"); if (!myHighlightedText.getText().startsWith(invalidPrefix)) { myHighlightedText .getBeginning() .addText(invalidPrefix, HierarchyNodeDescriptor.getInvalidPrefixAttributes()); } return true; } if (changes && myIsBase) { final LayeredIcon icon = new LayeredIcon(2); icon.setIcon(getIcon(), 0); icon.setIcon(AllIcons.Hierarchy.Base, 1, -AllIcons.Hierarchy.Base.getIconWidth() / 2, 0); setIcon(icon); } final PsiElement psiElement = getPsiClass(); final CompositeAppearance oldText = myHighlightedText; myHighlightedText = new CompositeAppearance(); TextAttributes classNameAttributes = null; if (myColor != null) { classNameAttributes = new TextAttributes(myColor, null, null, null, Font.PLAIN); } if (psiElement instanceof PsiClass) { myHighlightedText .getEnding() .addText( ClassPresentationUtil.getNameForClass((PsiClass) psiElement, false), classNameAttributes); myHighlightedText .getEnding() .addText( " (" + JavaHierarchyUtil.getPackageName((PsiClass) psiElement) + ")", HierarchyNodeDescriptor.getPackageNameAttributes()); } else if (psiElement instanceof PsiFunctionalExpression) { myHighlightedText .getEnding() .addText( ClassPresentationUtil.getFunctionalExpressionPresentation( ((PsiFunctionalExpression) psiElement), false)); } myName = myHighlightedText.getText(); if (!Comparing.equal(myHighlightedText, oldText)) { changes = true; } return changes; }
protected Component renderIn(JLabel label, boolean selected, boolean hasFocus) { if (myVFile.isWritable()) { label.setIcon(getIconByExtension()); } else { LayeredIcon layeredIcon = new LayeredIcon(2); layeredIcon.setIcon(getIconByExtension(), 0); layeredIcon.setIcon(AllIcons.Nodes.Locked, 1); label.setIcon(layeredIcon); } return label; }
private void setIcon(@Nullable final Icon icon, int layer) { LayeredIcon layeredIcon = getLayeredIcon(); layeredIcon.setIcon(icon, layer); if (hasIcons()) { myLabel.setIcon(layeredIcon); } else { myLabel.setIcon(null); } invalidateIfNeeded(); }
private boolean hasIcons() { LayeredIcon layeredIcon = getLayeredIcon(); boolean hasIcons = false; Icon[] layers = layeredIcon.getAllLayers(); for (Icon layer1 : layers) { if (layer1 != null) { hasIcons = true; break; } } return hasIcons; }
public static Icon getEvenIcon(Icon icon) { LayeredIcon layeredIcon = new LayeredIcon(2); layeredIcon.setIcon(EMPTY_ICON, 0); if (icon != null && icon.getIconHeight() <= EMPTY_ICON.getIconHeight() && icon.getIconWidth() <= EMPTY_ICON.getIconWidth()) { layeredIcon.setIcon( icon, 1, (-icon.getIconWidth() + EMPTY_ICON.getIconWidth()) / 2, (EMPTY_ICON.getIconHeight() - icon.getIconHeight()) / 2); } return layeredIcon; }
public static Icon augmentIcon(@Nullable Icon icon, @NotNull Icon standard) { if (icon == null) { return standard; } if (icon.getIconHeight() < standard.getIconHeight() || icon.getIconWidth() < standard.getIconWidth()) { final LayeredIcon layeredIcon = new LayeredIcon(2); layeredIcon.setIcon(icon, 0, 0, (standard.getIconHeight() - icon.getIconHeight()) / 2); layeredIcon.setIcon(standard, 1); return layeredIcon; } return icon; }
@Override public void setIcon(Icon icon) { Icon oldValue = getIcon(); myIcon = icon; myLayeredIcon = LayeredIcon.create(myIcon, AllIcons.Nodes.PinToolWindow); myChangeSupport.firePropertyChange(PROP_ICON, oldValue, getIcon()); }
private void setAttractionIcon(@Nullable Icon icon) { if (myIcon.getIcon(0) == null) { setIcon(null, 1); myOverlayedIcon = icon; } else { setIcon(icon, 1); myOverlayedIcon = null; } }
public static Icon getConfigurationIcon( final RunnerAndConfigurationSettings settings, final boolean invalid) { Icon icon = getRawIcon(settings); final Icon configurationIcon = settings.isTemporary() ? getTemporaryIcon(icon) : icon; if (invalid) { return LayeredIcon.create( configurationIcon, AllIcons.RunConfigurations.InvalidConfigurationLayer); } return configurationIcon; }
static { STRUTS_CONFIG_FILE.setIcon(StdFileTypes.XML.getIcon(), 0); STRUTS_CONFIG_FILE.setIcon(Struts2Icons.Action_small, 1, 0, OVERLAY_Y_OFFSET); VALIDATION_CONFIG_FILE.setIcon(StdFileTypes.XML.getIcon(), 0); VALIDATION_CONFIG_FILE.setIcon(Struts2Icons.Edit_small, 1, 0, OVERLAY_Y_OFFSET); ACTION_CLASS.setIcon(AllIcons.Nodes.Class, 0); ACTION_CLASS.setIcon(Struts2Icons.Action_small, 1, 0, OVERLAY_Y_OFFSET); STRUTS_VARIABLE.setIcon(AllIcons.Nodes.Variable, 0); STRUTS_VARIABLE.setIcon(Struts2Icons.Action_small, 1, 0, OVERLAY_Y_OFFSET); STRUTS_PACKAGE.setIcon(AllIcons.Nodes.Folder, 0); STRUTS_PACKAGE.setIcon(Struts2Icons.Action_small, 1, 0, OVERLAY_Y_OFFSET); createGlobalIcon(GLOBAL_RESULT, AllIcons.Vcs.Arrow_right); createGlobalIcon(GLOBAL_EXCEPTION_MAPPING, AllIcons.Nodes.ExceptionClass); createDefaultIcon(DEFAULT_ACTION_REF, Struts2Icons.Action); createDefaultIcon(DEFAULT_CLASS_REF, AllIcons.Nodes.Class); createDefaultIcon(DEFAULT_INTERCEPTOR_REF, AllIcons.Nodes.Plugin); createDefaultIcon(RESULT_TYPE_DEFAULT, AllIcons.Debugger.Console); }
@Override public final boolean update() { CompositeAppearance oldText = myHighlightedText; Icon oldIcon = getIcon(); int flags = Iconable.ICON_FLAG_VISIBILITY; if (isMarkReadOnly()) { flags |= Iconable.ICON_FLAG_READ_STATUS; } boolean changes = super.update(); PsiElement targetElement = getTargetElement(); String elementText = renderElement(targetElement); if (elementText == null) { String invalidPrefix = IdeBundle.message("node.hierarchy.invalid"); if (!myHighlightedText.getText().startsWith(invalidPrefix)) { myHighlightedText .getBeginning() .addText(invalidPrefix, HierarchyNodeDescriptor.getInvalidPrefixAttributes()); } return true; } Icon newIcon = targetElement.getIcon(flags); if (changes && myIsBase) { LayeredIcon icon = new LayeredIcon(2); icon.setIcon(newIcon, 0); icon.setIcon(AllIcons.Hierarchy.Base, 1, -AllIcons.Hierarchy.Base.getIconWidth() / 2, 0); newIcon = icon; } setIcon(newIcon); myHighlightedText = new CompositeAppearance(); TextAttributes mainTextAttributes = null; if (myColor != null) { mainTextAttributes = new TextAttributes(myColor, null, null, null, Font.PLAIN); } String packageName = null; if (targetElement instanceof JetElement) { packageName = JetPsiUtil.getPackageName((JetElement) targetElement); } else { PsiClass enclosingClass = PsiTreeUtil.getParentOfType(targetElement, PsiClass.class, false); if (enclosingClass != null) { packageName = JavaHierarchyUtil.getPackageName(enclosingClass); } } myHighlightedText.getEnding().addText(elementText, mainTextAttributes); if (usageCount > 1) { myHighlightedText .getEnding() .addText( IdeBundle.message("node.call.hierarchy.N.usages", usageCount), HierarchyNodeDescriptor.getUsageCountPrefixAttributes()); } if (packageName == null) { packageName = ""; } myHighlightedText .getEnding() .addText(" (" + packageName + ")", HierarchyNodeDescriptor.getPackageNameAttributes()); myName = myHighlightedText.getText(); if (!(Comparing.equal(myHighlightedText, oldText) && Comparing.equal(getIcon(), oldIcon))) { changes = true; } return changes; }
public void setIcon(Icon icon) { Icon oldValue = getIcon(); myIcon = icon; myLayeredIcon = LayeredIcon.create(myIcon, getPinIcon()); myChangeSupport.firePropertyChange(PROP_ICON, oldValue, getIcon()); }
private static void createGlobalIcon(final LayeredIcon icon, final Icon baseIcon) { icon.setIcon(baseIcon, 0); icon.setIcon(AllIcons.General.Web, 1, OVERLAY_X_OFFSET, OVERLAY_Y_OFFSET); }
private static void createDefaultIcon(final LayeredIcon icon, final Icon baseIcon) { icon.setIcon(baseIcon, 0); icon.setIcon(OVERLAY_DEFAULT, 1, OVERLAY_X_OFFSET, OVERLAY_Y_OFFSET); }