Java源码示例:com.intellij.util.ui.EmptyIcon

示例1
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)));
}
 
示例2
@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);
}
 
示例3
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);
}
 
示例4
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();
}
 
示例5
@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());
}
 
示例6
@Deprecated
public Icon getEmptyHandle() {
  if (myEmptyHandle == null) {
    final Icon expand = getExpandedHandle();
    myEmptyHandle = expand != null ? EmptyIcon.create(expand) : EmptyIcon.create(0);
  }
  return myEmptyHandle;
}
 
示例7
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));
  }
}
 
示例8
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;
      }
    }
  }
}
 
示例9
@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);
  }
}
 
示例10
@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);
}
 
示例11
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());
}
 
示例12
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();
}
 
示例13
@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;
}
 
示例14
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);
}
 
示例15
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);
}
 
示例16
@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));
  }
}
 
示例17
@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));
}
 
示例18
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;
}
 
示例19
@Override
protected void installDefaults() {
  super.installDefaults();
  Integer integer = UIUtil.getPropertyMaxGutterIconWidth(getPropertyPrefix());
  if (integer != null) {
    myMaxGutterIconWidth = JBUI.scale(integer.intValue());
  }
  arrowIcon = EmptyIcon.create(myMaxGutterIconWidth);
}
 
示例20
protected void setIcons(@Nullable final Icon regular, @Nullable final Icon inactive) {
  myRegular = regular != null ? regular : EmptyIcon.ICON_0;
  myInactive = inactive != null ? inactive : myRegular;
}
 
示例21
private Icon getEmptyIcon() {
  if (myEmptyIcon == null) {
    myEmptyIcon = EmptyIcon.create(getIcon(true).getIconWidth());
  }
  return myEmptyIcon;
}
 
示例22
@Nonnull
private static Icon createEmptyIcon(int height) {
  return EmptyIcon.create(LabelIcon.getWidth(height, 2), height);
}
 
示例23
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
}
 
示例24
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);
}
 
示例25
public int iconTextSpace() {
  return (getIcon() instanceof EmptyIcon || getIcon() == null) ? 0 : JBUI.scale(ICON_TEXT_SPACE);
}
 
示例26
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;
}
 
示例27
@Nonnull
public Icon getIcon() {
  return EmptyIcon.ICON_16;
}
 
示例28
@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();
}
 
示例29
@Override
public Icon getDefaultIcon() {
  return JBUI.scale(EmptyIcon.create(20)).asUIResource();
}
 
示例30
private ColorCellRenderer(final FileColorManager manager) {
  setOpaque(true);

  myManager = manager;

  setIcon(EmptyIcon.ICON_16);
}