com.intellij.ui.LayeredIcon Java Examples

The following examples show how to use com.intellij.ui.LayeredIcon. 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: FileTypeRenderer.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void customize(JList list, FileType type, int index, boolean selected, boolean hasFocus) {
  LayeredIcon layeredIcon = new LayeredIcon(2);
  layeredIcon.setIcon(EMPTY_ICON, 0);
  final Icon icon = TargetAWT.to(type.getIcon());
  if (icon != null) {
    layeredIcon.setIcon(icon, 1, (- icon.getIconWidth() + EMPTY_ICON.getIconWidth())/2, (EMPTY_ICON.getIconHeight() - icon.getIconHeight())/2);
  }

  setIcon(layeredIcon);

  String description = type.getDescription();
  String trimmedDescription = StringUtil.capitalizeWords(description.replaceAll("(?i)\\s*file(?:s)?$", ""), true);
  if (isDuplicated(description)) {
    setText(trimmedDescription + " (" + type.getName() + ")");

  }
  else {
    setText(trimmedDescription);
  }
}
 
Example #2
Source File: ExecutionUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Deprecated
@DeprecationInfo("Use #getLiveIndicatorIcon(Image)")
public static Icon getLiveIndicator(@Nullable final Icon base) {
  int width = base == null ? 13 : base.getIconWidth();
  int height = base == null ? 13 : base.getIconHeight();
  return new LayeredIcon(base, TargetAWT.to(ImageEffects.canvas(width, height, ctx -> {
    int iSize = 2;

    ctx.setFillStyle(StandardColors.GREEN);
    ctx.arc(width - iSize - 1, height - iSize - 1, iSize, 0, 2 * Math.PI);
    ctx.fill();

    ctx.setStrokeStyle(StandardColors.BLACK.withAlpha(0.4f));
    ctx.arc(width - iSize - 1, height - iSize - 1, iSize, 0, 2 * Math.PI);
    ctx.stroke();
  })));
}
 
Example #3
Source File: JsxAttributeCompletionProvider.java    From reasonml-idea-plugin with MIT License 5 votes vote down vote up
public static void addCompletions(@NotNull PsiElement element, @NotNull CompletionResultSet resultSet) {
    LOG.debug("JSX attribute completion");

    PsiTagStart tag = PsiTreeUtil.getParentOfType(element, PsiTagStart.class);
    if (tag != null) {
        List<PsiTagStart.TagProperty> attributes = tag.getUnifiedPropertyList();

        if (tag.getNameIdentifier() instanceof PsiUpperSymbol) {
            // Additional attributes for UpperSymbol => only key and ref
            attributes.add(PsiTagStartImpl.createProp("key", "string=?"));
            attributes.add(PsiTagStartImpl.createProp("ref", "Js.nullable(Dom.element) => unit=?"));
        }

        if (LOG.isDebugEnabled()) {
            LOG.debug("Tag found", tag.getName());
            LOG.debug("attributes", attributes);
        }

        // Attributes already used
        Collection<PsiTagProperty> usedAttributes = PsiTreeUtil.findChildrenOfType(tag, PsiTagProperty.class);
        List<String> usedNames = usedAttributes.stream().map(PsiTagProperty::getName).collect(toList());
        LOG.debug("used names", usedNames);

        // Now populate the dialog
        for (PsiTagStart.TagProperty attribute : attributes) {
            String attributeName = attribute.getName();
            if (attributeName != null && !usedNames.contains(attributeName)) {
                boolean mandatory = attribute.isMandatory();
                Icon icon = mandatory ? LayeredIcon.create(ORIcons.ATTRIBUTE, ORIcons.OVERLAY_MANDATORY) : ORIcons.ATTRIBUTE;
                resultSet.addElement(LookupElementBuilder.
                        create(attributeName).
                        withBoldness(mandatory).
                        withTypeText(attribute.getType(), true).
                        withIcon(icon).
                        withInsertHandler((context, item) -> insertTagAttributeHandler(context)));
            }
        }
    }
}
 
Example #4
Source File: FlutterNewProjectAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
Icon getFlutterDecoratedIcon() {
  Icon icon = AllIcons.Welcome.CreateNewProject;
  Icon badgeIcon = new OffsetIcon(0, FlutterIcons.Flutter_badge).scale(0.666f);

  LayeredIcon decorated = new LayeredIcon(2);
  decorated.setIcon(badgeIcon, 0, 7, 7);
  decorated.setIcon(icon, 1, 0, 0);
  return decorated;
}
 
Example #5
Source File: FlutterNewProjectAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
Icon getFlutterDecoratedIcon() {
  Icon icon = AllIcons.Welcome.CreateNewProject;
  Icon badgeIcon = new OffsetIcon(0, FlutterIcons.Flutter_badge).scale(0.666f);

  LayeredIcon decorated = new LayeredIcon(2);
  decorated.setIcon(badgeIcon, 0, 7, 7);
  decorated.setIcon(icon, 1, 0, 0);
  return decorated;
}
 
Example #6
Source File: IdeFatalErrorsIcon.java    From consulo with Apache License 2.0 5 votes vote down vote up
public IdeFatalErrorsIcon(ActionListener aListener) {
  myListener = aListener;
  setBorder(BorderFactory.createEmptyBorder(0, 1, 0, 1));

  new ClickListener() {
    @Override
    public boolean onClick(MouseEvent e, int clickCount) {
      if (myState != State.NoErrors) {
        myListener.actionPerformed(null);
        return true;
      }
      return false;
    }
  }.installOn(this);

  myIcon = new LayeredIcon(AllIcons.Ide.FatalError, AllIcons.Ide.FatalError_read, AllIcons.Ide.EmptyFatalError) {
    @Override
    public synchronized void paintIcon(Component c, Graphics g, int x, int y) {
      super.paintIcon(c, g, x, y);
    }

    @Override
    public synchronized void setLayerEnabled(int layer, boolean enabled) {
      super.setLayerEnabled(layer, enabled);
    }
  };
  setIcon(myIcon);
}
 
Example #7
Source File: BranchActionGroup.java    From consulo with Apache License 2.0 5 votes vote down vote up
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 #8
Source File: FindAllAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void updateTemplateIcon(@Nullable EditorSearchSession session) {
  if (session == null || getTemplatePresentation().getIcon() != null) return;

  Icon base = AllIcons.Actions.Find;
  Icon text = IconUtil.textToIcon("ALL", session.getComponent(), JBUI.scale(6F));

  LayeredIcon icon = new LayeredIcon(2);
  icon.setIcon(base, 0);
  icon.setIcon(text, 1, 0, base.getIconHeight() - text.getIconHeight());
  getTemplatePresentation().setIcon(icon);
}
 
Example #9
Source File: ReplConfigurationFactory.java    From reasonml-idea-plugin with MIT License 4 votes vote down vote up
@NotNull
@Override
public Icon getIcon() {
    return LayeredIcon.create(ORIcons.OCL_FILE, ORIcons.OVERLAY_EXECUTE);
}
 
Example #10
Source File: FastBuildRunExecutor.java    From intellij with Apache License 2.0 4 votes vote down vote up
@Override
public Icon getIcon() {
  return new LayeredIcon(AllIcons.Actions.Execute, BlazeIcons.LightningOverlay);
}
 
Example #11
Source File: FastBuildRunExecutor.java    From intellij with Apache License 2.0 4 votes vote down vote up
public Icon getDisabledIcon() {
  return new LayeredIcon(AllIconsCompat.disabledRun, BlazeIcons.LightningOverlay);
}
 
Example #12
Source File: FastBuildDebugExecutor.java    From intellij with Apache License 2.0 4 votes vote down vote up
@NotNull
@Override
public Icon getIcon() {
  return new LayeredIcon(AllIcons.Actions.StartDebugger, BlazeIcons.LightningOverlay);
}
 
Example #13
Source File: FastBuildDebugExecutor.java    From intellij with Apache License 2.0 4 votes vote down vote up
public Icon getDisabledIcon() {
  return new LayeredIcon(AllIconsCompat.disabledDebug, BlazeIcons.LightningOverlay);
}
 
Example #14
Source File: VirtualFileCellRenderer.java    From intellij-reference-diagram with Apache License 2.0 4 votes vote down vote up
private static Icon dressIcon(final VirtualFile file, final Icon baseIcon) {
    return file.isValid() && file.is(VFileProperty.SYMLINK) ? new LayeredIcon(baseIcon, PlatformIcons.SYMLINK_ICON) : baseIcon;
}
 
Example #15
Source File: IconUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static Icon addText(@Nonnull Icon base, @Nonnull String text) {
  LayeredIcon icon = new LayeredIcon(2);
  icon.setIcon(base, 0);
  icon.setIcon(textToIcon(text, new JLabel(), JBUI.scale(6f)), 1, SwingConstants.SOUTH_EAST);
  return icon;
}