@NotNull private JButton getDeleteButton(final JPanel view, SearchActionWrapper wrapper) { JButton btnDelete = new JButton(IconUtil.getRemoveIcon()); btnDelete.addMouseListener(new ClickListener() { @Override public void mouseClicked(MouseEvent e) { actionsPanel.remove(btnDelete); actionsPanel.remove(view); customPath.getListSearchAction().remove(wrapper.getAction()); wrappers.remove(wrapper); actionsPanel.revalidate(); } }); return btnDelete; }
@Override @Nullable protected ArrayList<AnAction> createActions(final boolean fromPopup) { if (myProjectJdksModel == null) { return null; } final ArrayList<AnAction> actions = new ArrayList<AnAction>(); DefaultActionGroup group = new DefaultActionGroup(ProjectBundle.message("add.new.jdk.text"), true); group.getTemplatePresentation().setIcon(IconUtil.getAddIcon()); myProjectJdksModel.createAddActions(group, myTree, new Consumer<Sdk>() { @Override public void consume(final Sdk projectJdk) { addNode(new MyNode(new JdkConfigurable(((ProjectJdkImpl)projectJdk), myProjectJdksModel, TREE_UPDATER, myHistory, myProject), false), myRoot); selectNodeInTree(findNodeByObject(myRoot, projectJdk)); } }); actions.add(new MyActionGroupWrapper(group)); actions.add(new MyDeleteAction(Conditions.<Object[]>alwaysTrue())); return actions; }
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 static void setConfigurationIcon(final Presentation presentation, final RunnerAndConfigurationSettings settings, final Project project) { try { Icon icon = RunManagerEx.getInstanceEx(project).getConfigurationIcon(settings); ExecutionManagerImpl executionManager = ExecutionManagerImpl.getInstance(project); List<RunContentDescriptor> runningDescriptors = executionManager.getRunningDescriptors(new Condition<RunnerAndConfigurationSettings>() { @Override public boolean value(RunnerAndConfigurationSettings s) { return s == settings; } }); if (runningDescriptors.size() == 1) { icon = ExecutionUtil.getLiveIndicator(icon); } if (runningDescriptors.size() > 1) { icon = IconUtil.addText(icon, String.valueOf(runningDescriptors.size())); } presentation.setIcon(icon); } catch (IndexNotReadyException ignored) { } }
@Override protected ArrayList<AnAction> createActions(final boolean fromPopup) { final ArrayList<AnAction> result = new ArrayList<AnAction>(); result.add(new MyAddAction(fromPopup)); result.add(new MyDeleteAction(forAll(new Condition<Object>() { @Override public boolean value(final Object o) { if (o instanceof MyNode) { final NamedConfigurable namedConfigurable = ((MyNode)o).getConfigurable(); final Object editableObject = namedConfigurable != null ? namedConfigurable.getEditableObject() : null; return editableObject instanceof NamedScope; } return false; } }))); result.add(new MyCopyAction()); result.add(new MySaveAsAction()); result.add(new MyMoveAction(ExecutionBundle.message("move.up.action.name"), IconUtil.getMoveUpIcon(), -1)); result.add(new MyMoveAction(ExecutionBundle.message("move.down.action.name"), IconUtil.getMoveDownIcon(), 1)); return result; }
private void initializeHeaderPanel(@NotNull DeveloperServiceMetadata developerServiceMetadata) { HtmlBuilder htmlBuilder = new HtmlBuilder(); htmlBuilder.openHtmlBody(); htmlBuilder.addBold(developerServiceMetadata.getName()).newline(); htmlBuilder.add(developerServiceMetadata.getDescription()); htmlBuilder.closeHtmlBody(); myHeaderLabel.setText(htmlBuilder.getHtml()); myIcon.setIcon(IconUtil.toSize(developerServiceMetadata.getIcon(), myIcon.getWidth(), myIcon.getHeight())); URI learnMoreLink = developerServiceMetadata.getLearnMoreLink(); if (learnMoreLink != null) { addToLinkPanel("Learn More", learnMoreLink); } URI apiLink = developerServiceMetadata.getApiLink(); if (apiLink != null) { addToLinkPanel("API Documentation", apiLink); } }
private void createUIComponents() { myOrientationToggle = new ASGallery<ScreenOrientation>(JBList.createDefaultListModel(ScreenOrientation.PORTRAIT, ScreenOrientation.LANDSCAPE), new Function<ScreenOrientation, Image>() { @Override public Image apply(ScreenOrientation input) { return IconUtil.toImage(ORIENTATIONS.get(input).myIcon); } }, new Function<ScreenOrientation, String>() { @Override public String apply(ScreenOrientation input) { return ORIENTATIONS.get(input).myName; } }, new Dimension(50, 50)); myOrientationToggle.setCellMargin(new Insets(3, 5, 3, 5)); myOrientationToggle.setBackground(JBColor.background()); myOrientationToggle.setForeground(JBColor.foreground()); myScalingComboBox = new ComboBox(new EnumComboBoxModel<AvdScaleFactor>(AvdScaleFactor.class)); myHardwareSkinHelpLabel = new HyperlinkLabel("How do I create a custom hardware skin?"); myHardwareSkinHelpLabel.setHyperlinkTarget(AvdWizardConstants.CREATE_SKIN_HELP_LINK); mySkinComboBox = new SkinChooser(getProject()); }
@NotNull private Object[] variantsViaQuery(@NotNull final Query<PsiClass> query, @Nullable final PsiClass exclude) { final List<LookupElement> variants = new LinkedList<LookupElement>(); final Project project = getElement().getProject(); final String qnameOfExclude = exclude == null ? null : exclude.getQualifiedName(); for(final PsiClass klass : query.findAll()) { if(klass == null || (qnameOfExclude != null && qnameOfExclude.equals(klass.getQualifiedName()))) { continue; } try { variants.add( LookupElementBuilder.create(klass). withInsertHandler(QualifiedClassNameInsertHandler.INSTANCE). withIcon(IconUtil.getIcon(klass.getContainingFile().getVirtualFile(), 0, project)). withTypeText(klass.getContainingFile().getName()) ); } catch(final PsiInvalidElementAccessException invalidElementAccess) { LOG.error(invalidElementAccess); } } return variants.toArray(new Object[variants.size()]); }
@NotNull private Object[] variantsViaQuery(@NotNull final Query<PsiClass> query) { final List<LookupElement> variants = new LinkedList<LookupElement>(); final Project project = getElement().getProject(); for(final PsiClass klass : query.findAll()) { if(klass == null) { continue; } try { variants.add( LookupElementBuilder.create(klass). withInsertHandler(QualifiedClassNameInsertHandler.INSTANCE). withIcon(IconUtil.getIcon(klass.getContainingFile().getVirtualFile(), 0, project)). withTypeText(klass.getContainingFile().getName())); } catch(final PsiInvalidElementAccessException invalidElementAccess) { LOG.error(invalidElementAccess); } } return variants.toArray(new Object[variants.size()]); }
@Override @Nullable protected ArrayList<AnAction> createActions(final boolean fromPopup) { final ArrayList<AnAction> actions = new ArrayList<AnAction>(); DefaultActionGroup group = new DefaultActionGroup(ProjectBundle.message("add.new.jdk.text"), true); group.getTemplatePresentation().setIcon(IconUtil.getAddIcon()); myProjectJdksModel.createAddActions(group, myTree, new Consumer<Sdk>() { @Override public void consume(final Sdk projectJdk) { addNode(new MyNode(new JdkConfigurable(((ProjectJdkImpl)projectJdk), myProjectJdksModel, TREE_UPDATER, myHistory, myProject), false), myRoot); selectNodeInTree(findNodeByObject(myRoot, projectJdk)); } }); actions.add(new MyActionGroupWrapper(group)); actions.add(new MyDeleteAction(Conditions.<Object[]>alwaysTrue())); return actions; }
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); Icon image = getBackgroundImage(); if (image != null) { final int w = image.getIconWidth(); final int h = image.getIconHeight(); int x = 0; int y = 0; while (w > 0 && x < getWidth()) { while (h > 0 && y < getHeight()) { image.paintIcon(this, g, x, y); y+=h; } y=0; x+=w; } } Icon centerImage = getCenterImage(); if (centerImage != null) { IconUtil.paintInCenterOf(this, g, centerImage); } }
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) { if (value instanceof VirtualFile) { VirtualFile virtualFile = (VirtualFile)value; String name = virtualFile.getPresentableName(); setIcon(IconUtil.getIcon(virtualFile, Iconable.ICON_FLAG_READ_STATUS, myProject)); FileStatus fileStatus = FileStatusManager.getInstance(myProject).getStatus(virtualFile); TextAttributes attributes = new TextAttributes(fileStatus.getColor(), null , null, EffectType.LINE_UNDERSCORE, Font.PLAIN); append(name, SimpleTextAttributes.fromTextAttributes(attributes)); if (!selected && FileEditorManager.getInstance(myProject).isFileOpen(virtualFile)) { setBackground(LightColors.SLIGHTLY_GREEN); } } }
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) { if (value instanceof FileInfo) { VirtualFile virtualFile = ((FileInfo)value).getFirst(); String name = virtualFile instanceof VirtualFilePathWrapper ? ((VirtualFilePathWrapper)virtualFile).getPresentablePath() : UISettings.getInstance().SHOW_DIRECTORY_FOR_NON_UNIQUE_FILENAMES ? UniqueVFilePathBuilder.getInstance().getUniqueVirtualFilePath(myProject, virtualFile) : virtualFile.getName(); setIcon(IconUtil.getIcon(virtualFile, Iconable.ICON_FLAG_READ_STATUS, myProject)); FileStatus fileStatus = FileStatusManager.getInstance(myProject).getStatus(virtualFile); open = FileEditorManager.getInstance(myProject).isFileOpen(virtualFile); TextAttributes attributes = new TextAttributes(fileStatus.getColor(), null , null, EffectType.LINE_UNDERSCORE, Font.PLAIN); append(name, SimpleTextAttributes.fromTextAttributes(attributes)); // calc color the same way editor tabs do this, i.e. including extensions Color color = EditorTabbedContainer.calcTabColor(myProject, virtualFile); if (!selected && color != null) { setBackground(color); } } }
private JPanel createLeftPanel() { initTree(); MyRemoveAction removeAction = new MyRemoveAction(); MyMoveAction moveUpAction = new MyMoveAction(ExecutionBundle.message("move.up.action.name"), null, IconUtil.getMoveUpIcon(), -1); MyMoveAction moveDownAction = new MyMoveAction(ExecutionBundle.message("move.down.action.name"), null, IconUtil.getMoveDownIcon(), 1); myToolbarDecorator = ToolbarDecorator.createDecorator(myTree).setAsUsualTopToolbar() .setAddAction(myAddAction).setAddActionName(ExecutionBundle.message("add.new.run.configuration.acrtion.name")) .setRemoveAction(removeAction).setRemoveActionUpdater(removeAction) .setRemoveActionName(ExecutionBundle.message("remove.run.configuration.action.name")) .setMoveUpAction(moveUpAction).setMoveUpActionName(ExecutionBundle.message("move.up.action.name")).setMoveUpActionUpdater(moveUpAction) .setMoveDownAction(moveDownAction).setMoveDownActionName(ExecutionBundle.message("move.down.action.name")).setMoveDownActionUpdater(moveDownAction) .addExtraAction(AnActionButton.fromAction(new MyCopyAction())) .addExtraAction(AnActionButton.fromAction(new MySaveAction())) .addExtraAction(AnActionButton.fromAction(new MyEditDefaultsAction())) .addExtraAction(AnActionButton.fromAction(new MyCreateFolderAction())) .setButtonComparator(ExecutionBundle.message("add.new.run.configuration.acrtion.name"), ExecutionBundle.message("remove.run.configuration.action.name"), ExecutionBundle.message("copy.configuration.action.name"), ExecutionBundle.message("action.name.save.configuration"), ExecutionBundle.message("run.configuration.edit.default.configuration.settings.text"), ExecutionBundle.message("move.up.action.name"), ExecutionBundle.message("move.down.action.name"), ExecutionBundle.message("run.configuration.create.folder.text") ).setForcedDnD(); return myToolbarDecorator.createPanel(); }
@Override @Nullable protected ArrayList<AnAction> createActions(boolean fromPopup) { ArrayList<AnAction> result = new ArrayList<AnAction>(); result.add(new AnAction("Add", "Add", IconUtil.getAddIcon()) { { registerCustomShortcutSet(CommonShortcuts.INSERT, myTree); } public void actionPerformed(AnActionEvent event) { final VirtualFile sdk = NuxeoSDKChooser.chooseNuxeoSDK(project); if (sdk == null) return; final String name = askForNuxeoSDKName("Register Nuxeo SDK", ""); if (name == null) return; final NuxeoSDK nuxeoSDK = new NuxeoSDK(name, sdk.getPath()); addNuxeoSDKNode(nuxeoSDK); } }); result.add(new MyDeleteAction(forAll(Conditions.alwaysTrue()))); return result; }
public DropDownAction(String text, @Nullable LinkListener<Void> listener) { super(text, null, listener); setHorizontalTextPosition(SwingConstants.LEADING); setIconTextGap(0); setIcon(new Icon() { @Override public void paintIcon(Component c, Graphics g, int x, int y) { int lineY = getUI().getBaseline(DropDownAction.this, getWidth(), getHeight()) - getIconHeight(); IconUtil.colorize(myIcon, getTextColor()).paintIcon(c, g, x - 1, lineY); } @Override public int getIconWidth() { return myIcon.getIconWidth(); } @Override public int getIconHeight() { return myIcon.getIconHeight(); } }); }
private static void addActions(@Nonnull AnAction action, @Nonnull List<HighlightInfo.IntentionActionDescriptor> descriptors, @Nonnull GutterIconRenderer renderer, int order, @Nonnull AnActionEvent event) { if (action instanceof ActionGroup) { AnAction[] children = ((ActionGroup)action).getChildren(null); for (int i = 0; i < children.length; i++) { addActions(children[i], descriptors, renderer, i + order, event); } } Icon icon = action.getTemplatePresentation().getIcon(); if (icon == null) icon = renderer.getIcon(); if (icon.getIconWidth() < 16) icon = IconUtil.toSize(icon, 16, 16); final GutterIntentionAction gutterAction = new GutterIntentionAction(action, order, icon); if (!gutterAction.isAvailable(event)) return; descriptors.add(new HighlightInfo.IntentionActionDescriptor(gutterAction, Collections.emptyList(), null, icon) { @Nullable @Override public String getDisplayName() { return gutterAction.getText(); } }); }
@Override @Nullable protected ArrayList<AnAction> createActions(final boolean fromPopup) { final ArrayList<AnAction> actions = new ArrayList<AnAction>(); DefaultActionGroup group = new DefaultActionGroup(ProjectBundle.message("add.action.name"), true); group.getTemplatePresentation().setIcon(IconUtil.getAddIcon()); myProjectSdksModel.createAddActions(group, myTree, new Consumer<Sdk>() { @Override public void consume(final Sdk projectJdk) { addNode(new MyNode(new SdkConfigurable(((SdkImpl)projectJdk), myProjectSdksModel, TREE_UPDATER, myHistory, myProject), false), myRoot); selectNodeInTree(findNodeByObject(myRoot, projectJdk)); } }, SdkListConfigurable.ADD_SDK_FILTER); actions.add(new MyActionGroupWrapper(group)); actions.add(new MyDeleteAction(forAll(Conditions.alwaysTrue()))); return actions; }
private Icon getInformativeIcon(Project project, final RunnerAndConfigurationSettings selectedConfiguration) { final ExecutionManagerImpl executionManager = ExecutionManagerImpl.getInstance(project); List<RunContentDescriptor> runningDescriptors = executionManager.getRunningDescriptors(s -> s == selectedConfiguration); runningDescriptors = ContainerUtil.filter(runningDescriptors, descriptor -> { RunContentDescriptor contentDescriptor = executionManager.getContentManager().findContentDescriptor(myExecutor, descriptor.getProcessHandler()); return contentDescriptor != null && executionManager.getExecutors(contentDescriptor).contains(myExecutor); }); if (!runningDescriptors.isEmpty() && DefaultRunExecutor.EXECUTOR_ID.equals(myExecutor.getId()) && selectedConfiguration.isSingleton()) { return AllIcons.Actions.Restart; } if (runningDescriptors.isEmpty()) { return myExecutor.getIcon(); } if (runningDescriptors.size() == 1) { return ExecutionUtil.getLiveIndicator(myExecutor.getIcon()); } else { return IconUtil.addText(myExecutor.getIcon(), String.valueOf(runningDescriptors.size())); } }
@Override protected ArrayList<AnAction> createActions(final boolean fromPopup) { final ArrayList<AnAction> result = new ArrayList<AnAction>(); result.add(new MyAddAction(fromPopup)); result.add(new MyDeleteAction(forAll(new Condition<Object>() { @Override public boolean value(final Object o) { if (o instanceof MyNode) { final Object editableObject = ((MyNode)o).getConfigurable().getEditableObject(); return editableObject instanceof NamedScope; } return false; } }))); result.add(new MyCopyAction()); result.add(new MySaveAsAction()); result.add(new MyMoveAction(ExecutionBundle.message("move.up.action.name"), IconUtil.getMoveUpIcon(), -1)); result.add(new MyMoveAction(ExecutionBundle.message("move.down.action.name"), IconUtil.getMoveDownIcon(), 1)); return result; }
private void initTextInjectionAddButton() { if(getMode() == ViewMode.USAGE){ return; } JButton btnAdd = new JButton(Localizer.get("action.AddTextInjection"), IconUtil.getAddIcon()); btnAdd.addMouseListener(new ClickListener() { @Override public void mouseClicked(MouseEvent e) { createTextInjection(); } }); panel.add(btnAdd, new CC().wrap()); }
private JButton getAddButton() { JButton btnAdd = new JButton(Localizer.get("action.Add"), IconUtil.getAddIcon()); btnAdd.addMouseListener(new ClickListener() { @Override public void mouseClicked(MouseEvent e) { createSearchAction(null); } }); return btnAdd; }
public static Icon getIcon(Object object, @Iconable.IconFlags int flags, Project project) { if (object instanceof PsiElement) { return ((PsiElement)object).getIcon(flags); } if (object instanceof Module) { return ModuleType.get((Module)object).getIcon(); } if (object instanceof VirtualFile) { VirtualFile file = (VirtualFile)object; return IconUtil.getIcon(file, flags, project); } return ElementPresentationManager.getIcon(object); }
@Override public Icon getIcon(final boolean expanded) { if (isSyntheticJSP()) { final PsiElement element = getElement(); if (element != null && element.isValid()) { return IconUtil.getIcon(element.getContainingFile().getVirtualFile(), Iconable.ICON_FLAG_VISIBILITY | Iconable.ICON_FLAG_READ_STATUS, element.getProject()); } } return super.getIcon(expanded); }
@Override protected void setVisibilityIcon(MemberInfo memberInfo, RowIcon icon) { PsiMember member = memberInfo.getMember(); PsiModifierList modifiers = member != null ? member.getModifierList() : null; if (modifiers != null) { VisibilityIcons.setVisibilityIcon(modifiers, icon); } else { icon.setIcon(IconUtil.getEmptyIcon(true), VISIBILITY_ICON_POSITION); } }
private DefaultActionGroup createToolbarActionGroup() { final DefaultActionGroup toolbarActionGroup = new DefaultActionGroup(); final List<AnAction> createActions = new ArrayList<AnAction>(createNewElementActions()); for (AnAction createAction : createActions) { toolbarActionGroup.add(createAction); } toolbarActionGroup.add(new RemovePackagingElementAction(this)); toolbarActionGroup.add(Separator.getInstance()); toolbarActionGroup.add(new SortElementsToggleAction(this.getLayoutTreeComponent())); toolbarActionGroup.add(new MovePackagingElementAction(myLayoutTreeComponent, "Move Up", "", IconUtil.getMoveUpIcon(), -1)); toolbarActionGroup.add(new MovePackagingElementAction(myLayoutTreeComponent, "Move Down", "", IconUtil.getMoveDownIcon(), 1)); return toolbarActionGroup; }
private ActionGroup createAddNonCompositeElementGroup() { DefaultActionGroup group = new DefaultActionGroup(ProjectBundle.message("artifacts.add.copy.action"), true); group.getTemplatePresentation().setIcon(IconUtil.getAddIcon()); for (PackagingElementType<?> type : PackagingElementFactory.getInstance().getNonCompositeElementTypes()) { group.add(new AddNewPackagingElementAction(type, this)); } return group; }
@Nullable @Override protected ArrayList<AnAction> createActions(boolean fromPopup) { ArrayList<AnAction> actions = new ArrayList<AnAction>(); if (myServerType == null) { actions.add(new AddRemoteServerGroup()); } else { actions.add(new AddRemoteServerAction(myServerType, IconUtil.getAddIcon())); } actions.add(new MyDeleteAction()); return actions; }
@NotNull private static Icon createErrorIcon() { return new SingleColorIcon(CodeInsightColors.ERRORS_ATTRIBUTES) { @Override public void paintIcon(Component c, Graphics g, int x, int y) { IconUtil.colorize(AllIcons.General.InspectionsError, getColor()).paintIcon(c, g, x, y); } }; }
public Icon getIcon() { switch (this) { case ADD: return IconUtil.getAddIcon(); case EDIT: return IconUtil.getEditIcon(); case REMOVE: return IconUtil.getRemoveIcon(); case UP: return IconUtil.getMoveUpIcon(); case DOWN: return IconUtil.getMoveDownIcon(); } return null; }
private void showRecentFilesPopup() { final JBList files = new JBList(getRecentFiles()) { @Override public Dimension getPreferredSize() { return new Dimension(myPathTextField.getField().getWidth(), super.getPreferredSize().height); } }; files.setCellRenderer(new ColoredListCellRenderer() { @Override protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) { final String path = value.toString(); append(path); final VirtualFile file = LocalFileSystem.getInstance().findFileByIoFile(new File(path)); if (file != null) { setIcon(IconUtil.getIcon(file, Iconable.ICON_FLAG_READ_STATUS, null)); } } }); JBPopupFactory.getInstance() .createListPopupBuilder(files) .setItemChoosenCallback(new Runnable() { @Override public void run() { myPathTextField.getField().setText(files.getSelectedValue().toString()); } }).createPopup().showUnderneathOf(myPathTextField.getField()); }
@NotNull private static Icon getEmptyPinIcon() { if (ourEmptyPinIcon == null) { Icon icon = AllIcons.Nodes.PinToolWindow; int width = icon.getIconWidth(); ourEmptyPinIcon = IconUtil.cropIcon(icon, new Rectangle(width / 2, 0, width - width / 2, icon.getIconHeight())); } return ourEmptyPinIcon; }
private static Icon getIcon(ToolWindow toolWindow) { Icon icon = toolWindow.getIcon(); if (icon == null) { return PlatformIcons.UI_FORM_ICON; } icon = IconUtil.toSize(icon, 16, 16); return icon; }
protected JComponent createExpandableHintComponent(final SimpleColoredText text, final Runnable expand) { final JComponent component = HintUtil.createInformationLabel(text, IconUtil.getAddIcon()); addClickListenerToHierarchy(component, new ClickListener() { @Override public boolean onClick(@NotNull MouseEvent event, int clickCount) { if (myCurrentHint != null) { myCurrentHint.hide(); } expand.run(); return true; } }); return component; }
private static void addActions(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile psiFile, @Nullable AnAction action, @NotNull List<HighlightInfo.IntentionActionDescriptor> descriptors, @NotNull GutterIconRenderer renderer, int order) { if (action == null) { return; } if (action instanceof ActionGroup) { AnAction[] children = ((ActionGroup)action).getChildren(null); for (int i = 0; i < children.length; i++) { AnAction child = children[i]; addActions(project, editor, psiFile, child, descriptors, renderer, i + order); } } Icon icon = action.getTemplatePresentation().getIcon(); if (icon == null) icon = renderer.getIcon(); if (icon.getIconWidth() < 16) icon = IconUtil.toSize(icon, 16, 16); final IntentionAction gutterAction = new GutterIntentionAction(action, order, icon); if (!gutterAction.isAvailable(project, editor, psiFile)) return; HighlightInfo.IntentionActionDescriptor descriptor = new HighlightInfo.IntentionActionDescriptor(gutterAction, Collections.<IntentionAction>emptyList(), null, icon) { @Nullable @Override public String getDisplayName() { return gutterAction.getText(); } }; descriptors.add(descriptor); }
private JPanel createLeftPanel() { initTree(); MyRemoveAction removeAction = new MyRemoveAction(); MyMoveAction moveUpAction = new MyMoveAction(ExecutionBundle.message("move.up.action.name"), null, IconUtil.getMoveUpIcon(), -1); MyMoveAction moveDownAction = new MyMoveAction(ExecutionBundle.message("move.down.action.name"), null, IconUtil.getMoveDownIcon(), 1); myToolbarDecorator = ToolbarDecorator.createDecorator(myTree).setAsUsualTopToolbar() .setAddAction(myAddAction).setAddActionName(ExecutionBundle.message("add.new.run.configuration.acrtion.name")) .setRemoveAction(removeAction).setRemoveActionUpdater(removeAction) .setRemoveActionName(ExecutionBundle.message("remove.run.configuration.action.name")) .setMoveUpAction(moveUpAction).setMoveUpActionName(ExecutionBundle.message("move.up.action.name")).setMoveUpActionUpdater( moveUpAction) .setMoveDownAction(moveDownAction).setMoveDownActionName(ExecutionBundle.message("move.down.action.name")).setMoveDownActionUpdater( moveDownAction) .addExtraAction(AnActionButton.fromAction(new MyCopyAction())) .addExtraAction(AnActionButton.fromAction(new MySaveAction())) .addExtraAction(AnActionButton.fromAction(new MyEditDefaultsAction())) .addExtraAction(AnActionButton.fromAction(new MyCreateFolderAction())) .addExtraAction(AnActionButton.fromAction(new MySortFolderAction())) .setButtonComparator(ExecutionBundle.message("add.new.run.configuration.acrtion.name"), ExecutionBundle.message("remove.run.configuration.action.name"), ExecutionBundle.message("copy.configuration.action.name"), ExecutionBundle.message("action.name.save.configuration"), ExecutionBundle.message("run.configuration.edit.default.configuration.settings.text"), ExecutionBundle.message("move.up.action.name"), ExecutionBundle.message("move.down.action.name"), ExecutionBundle.message("run.configuration.create.folder.text") ).setForcedDnD(); return myToolbarDecorator.createPanel(); }
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); }
@SuppressWarnings("MethodMayBeStatic") @Nullable public Icon getIcon(final Object object) { if (!NavBarModel.isValid(object)) return null; if (object instanceof Project) return AllIcons.Nodes.Project; if (object instanceof Module) return ModuleType.get(((Module)object)).getIcon(); try { if (object instanceof PsiElement) { Icon icon = ApplicationManager.getApplication().runReadAction(new Computable<Icon>() { @Override public Icon compute() { return ((PsiElement)object).isValid() ? ((PsiElement)object).getIcon(0) : null; } }); if (icon != null && (icon.getIconHeight() > 16 * 2 || icon.getIconWidth() > 16 * 2)) { icon = IconUtil.cropIcon(icon, 16 * 2, 16 * 2); } return icon; } } catch (IndexNotReadyException e) { return null; } if (object instanceof JdkOrderEntry) { final SdkTypeId sdkType = ((JdkOrderEntry)object).getJdk().getSdkType(); return ((SdkType) sdkType).getIcon(); } if (object instanceof LibraryOrderEntry) return AllIcons.Nodes.PpLibFolder; if (object instanceof ModuleOrderEntry) return ModuleType.get(((ModuleOrderEntry)object).getModule()).getIcon(); return null; }