@NotNull @Override public ItemPresentation getPresentation() { return new ItemPresentation() { @Nullable @Override public String getPresentableText() { return packageName; } @Nullable @Override public String getLocationString() { return ""; } @Nullable @Override public Icon getIcon(boolean b) { return PlatformIcons.PACKAGE_ICON; } }; }
@NotNull @Override public ItemPresentation getPresentation() { return new ItemPresentation() { @Nullable @Override public String getPresentableText() { return presText; } @Nullable @Override public String getLocationString() { return null; } @Nullable @Override public Icon getIcon(boolean b) { return PlatformIcons.CLASS_ICON; } }; }
@NotNull public CheckBoxListModelEditor<T> copyAction(final @NotNull Consumer<T> consumer) { toolbarDecorator.addExtraAction(new ToolbarDecorator.ElementActionButton(IdeBundle.message("button.copy"), PlatformIcons.COPY_ICON) { @Override public void actionPerformed(AnActionEvent e) { int[] indices = list.getSelectedIndices(); if (indices == null || indices.length == 0) { return; } for (int index : indices) { T item = list.getItemAt(index); if (item != null) { consumer.consume(item); } } } }); return this; }
@Override protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext processingContext, @NotNull CompletionResultSet result) { final PsiElement original = parameters.getOriginalPosition(); if (original != null) { result = result.withPrefixMatcher(getPrefix(parameters.getOffset(), parameters.getOriginalFile())); SyntheticTypeInfo sti = processingContext.get(SYNTHETIC_TYPE_INFO_KEY); if (sti.hasSyntheticConstructor()) { for (SyntheticMemberInfo smi : sti.getMembers()) { LookupElement lookupElement = LookupElementBuilder .create(smi.getName() + "=") .withIcon(PlatformIcons.PARAMETER_ICON); result.addElement(lookupElement); } } } }
public FilePathLookupElement lookupElementForFile( Project project, VirtualFile file, @Nullable WorkspacePath workspacePath) { NullableLazyValue<Icon> icon = new NullableLazyValue<Icon>() { @Override protected Icon compute() { if (file.findChild("BUILD") != null) { return BlazeIcons.BuildFile; } if (file.isDirectory()) { return PlatformIcons.FOLDER_ICON; } PsiFile psiFile = PsiManager.getInstance(project).findFile(file); return psiFile != null ? psiFile.getIcon(0) : AllIcons.FileTypes.Any_type; } }; String fullLabel = workspacePath != null ? getFullLabel(workspacePath.relativePath()) : file.getPath(); String itemText = workspacePath != null ? getItemText(workspacePath.relativePath()) : fullLabel; return new FilePathLookupElement(fullLabel, itemText, quoteType, icon); }
@Override public Icon getIcon(int flags) { if (isValid()) { final Property property = getProperty(); if (property != null) { if (property.getGetter().valueOrNull() == this) { return PythonIcons.Python.PropertyGetter; } if (property.getSetter().valueOrNull() == this) { return PythonIcons.Python.PropertySetter; } if (property.getDeleter().valueOrNull() == this) { return PythonIcons.Python.PropertyDeleter; } return PlatformIcons.PROPERTY_ICON; } if (getContainingClass() != null) { return PlatformIcons.METHOD_ICON; } } return PythonIcons.Python.Function; }
@NotNull public Object[] getVariants() { final ASTNode categoryNode = getCategoryNode(); if (categoryNode != null && categoryNode.getText().startsWith("In") && !categoryNode.getText().startsWith("Intelli")) { return UNICODE_BLOCKS; } else { boolean startsWithIs = categoryNode != null && categoryNode.getText().startsWith("Is"); Collection<LookupElement> result = ContainerUtil.newArrayList(); for (String[] properties : RegExpLanguageHosts.getInstance().getAllKnownProperties(getElement())) { String name = ArrayUtil.getFirstElement(properties); if (name != null) { String typeText = properties.length > 1 ? properties[1] : ("Character.is" + name.substring("java".length()) + "()"); result.add(PrioritizedLookupElement.withPriority(LookupElementBuilder.create(name) .withPresentableText(startsWithIs ? "Is" + name : name) .withIcon(PlatformIcons.PROPERTY_ICON) .withTypeText(typeText), getPriority(name))); } } return ArrayUtil.toObjectArray(result); } }
private static void addToArrayConversion(final PsiElement element, final String prefix, @NonNls final String expressionString, @NonNls String presentableString, final Consumer<LookupElement> result, PsiElement qualifier) { final boolean callSpace = CodeStyleSettingsManager.getSettings(element.getProject()).SPACE_WITHIN_METHOD_CALL_PARENTHESES; final PsiExpression conversion; try { conversion = createExpression( getQualifierText(qualifier) + prefix + ".toArray(" + getSpace(callSpace) + expressionString + getSpace(callSpace) + ")", element); } catch (IncorrectOperationException e) { return; } String[] lookupStrings = {prefix + ".toArray(" + getSpace(callSpace) + expressionString + getSpace(callSpace) + ")", presentableString}; result.consume(new ExpressionLookupItem(conversion, PlatformIcons.METHOD_ICON, prefix + ".toArray(" + presentableString + ")", lookupStrings) { @Override public void handleInsert(InsertionContext context) { FeatureUsageTracker.getInstance().triggerFeatureUsed(JavaCompletionFeatures.SECOND_SMART_COMPLETION_TOAR); context.commitDocument(); JavaCodeStyleManager.getInstance(context.getProject()).shortenClassReferences(context.getFile(), context.getStartOffset(), context.getTailOffset()); } }); }
@Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { final Component rendererComponent = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value instanceof String) { final String path = (String)value; final VirtualFile file = LocalFileSystem.getInstance().findFileByPath(path); if (file == null) { setForeground(JBColor.RED); setIcon(null); } else { setForeground(myFilesList.getForeground()); setIcon(file.isDirectory() ? PlatformIcons.FOLDER_ICON : VirtualFilePresentation.getIcon(file)); } setText(path); } return rendererComponent; }
@NotNull public JComponent createComponent() { return toolbarDecorator.addExtraAction( new ToolbarDecorator.ElementActionButton(IdeBundle.message("button.copy"), PlatformIcons.COPY_ICON) { @Override public void actionPerformed(@NotNull AnActionEvent e) { TableUtil.stopEditing(table); List<T> selectedItems = table.getSelectedObjects(); if (selectedItems.isEmpty()) { return; } for (T item : selectedItems) { model.addRow(itemEditor.clone(item, false)); } table.requestFocus(); TableUtil.updateScroller(table); } } ).createPanel(); }
public VcsCommittedViewAuxiliary createActions(DecoratorManager decoratorManager, RepositoryLocation repositoryLocation) { AnAction copyHashAction = new AnAction("Copy &Hash", "Copy hash to clipboard", PlatformIcons.COPY_ICON) { @Override public void actionPerformed(AnActionEvent e) { ChangeList[] changeLists = e.getData(VcsDataKeys.CHANGE_LISTS); if (changeLists != null && changeLists[0] instanceof HgCommittedChangeList) { HgRevisionNumber revisionNumber = ((HgCommittedChangeList)changeLists[0]).getRevision(); CopyPasteManager.getInstance().setContents(new StringSelection(revisionNumber.getChangeset())); } } }; return new VcsCommittedViewAuxiliary(Collections.singletonList(copyHashAction), new Runnable() { public void run() { } }, Collections.singletonList(copyHashAction)); }
@Override public void render(@NotNull PresentationData presentationData, SimpleTextAttributes mainAttributes, SimpleTextAttributes commentAttributes) { final String name = myLibrary.getName(); if (name != null) { presentationData.setIcon(PlatformIcons.LIBRARY_ICON); presentationData.addText(name, mainAttributes); presentationData.addText(LibraryElementPresentation.getLibraryTableComment(myLibrary), commentAttributes); } else { if (((LibraryEx)myLibrary).isDisposed()) { //todo[nik] disposed library should not be shown in the tree presentationData.addText("Invalid Library", SimpleTextAttributes.ERROR_ATTRIBUTES); return; } final VirtualFile[] files = myLibrary.getFiles(OrderRootType.CLASSES); if (files.length > 0) { final VirtualFile file = files[0]; presentationData.setIcon(VirtualFilePresentation.getIcon(file)); presentationData.addText(file.getName(), mainAttributes); } else { presentationData.addText("Empty Library", SimpleTextAttributes.ERROR_ATTRIBUTES); } } }
@Override protected void subInit() { super.subInit(); this.myMessageTextField = new EditorTextField(""); this.myKindUpDownHint = new JLabel(); this.myKindUpDownHint.setIcon(PlatformIcons.UP_DOWN_ARROWS); this.myKindUpDownHint.setToolTipText(PhpBundle.message("actions.new.php.base.arrows.kind.tooltip")); this.myKindComboBox = new ComboBox<String>(); this.myKindComboBox.setMinimumAndPreferredWidth(400); this.myKindComboBox.setRenderer(new ListCellRendererWrapper<Trinity>() { public void customize(JList list, Trinity value, int index, boolean selected, boolean hasFocus) { this.setText((String)value.first); this.setIcon((Icon)value.second); } }); ComboboxSpeedSearch var10001 = new ComboboxSpeedSearch(this.myKindComboBox) { protected String getElementText(Object element) { return (String)((Trinity)element).first; } }; KeyboardShortcut up = new KeyboardShortcut(KeyStroke.getKeyStroke(38, 0), (KeyStroke)null); KeyboardShortcut down = new KeyboardShortcut(KeyStroke.getKeyStroke(40, 0), (KeyStroke)null); AnAction kindArrow = PhpNewFileDialog.getCbArrowAction(this.myKindComboBox); kindArrow.registerCustomShortcutSet(new CustomShortcutSet(new Shortcut[]{up, down}), this.myNameTextField); List<Trinity> exceptionTypes = this.getExceptionTypes(); for(Trinity type : exceptionTypes) { this.myKindComboBox.addItem(type); } }
@NotNull @Override public ItemPresentation getPresentation() { return new ItemPresentation() { @Nullable @Override public String getPresentableText() { if (refDecl.getText().trim().startsWith("ref*")) { return "*" + relText(refDecl) + " : " + simpleType; } else { return relText(refDecl) + " : " + simpleType; } } @Nullable @Override public String getLocationString() { return null; } @Nullable @Override public Icon getIcon(boolean b) { return PlatformIcons.PROPERTY_ICON; } }; }
@Override public void update(AnActionEvent e) { super.update(e); final InspectionProfileImpl inspectionProfile = getInspectionProfile(); final Icon icon = AllIcons.General.Gear; e.getPresentation().setIcon( (inspectionProfile != null && inspectionProfile.isProfileLocked()) ? LayeredIcon.create(icon, PlatformIcons.LOCKED_ICON) : icon); }
public static Collection<Lookup> getVariableCompletions(XPathElement reference) { final ContextProvider contextProvider = ContextProvider.getContextProvider(reference); final VariableContext resolver = contextProvider.getVariableContext(); if (resolver != null) { final Object[] variablesInScope = resolver.getVariablesInScope(reference); final List<Lookup> lookups = new ArrayList<Lookup>(variablesInScope.length); for (final Object o : variablesInScope) { if (o instanceof PsiNamedElement) { final String type; if (o instanceof XPathVariable) { final XPathType t = ((XPathVariable)o).getType(); if (t != XPathType.UNKNOWN) { type = t.getName(); } else { type = ""; } } else { type = ""; } final String name = ((PsiNamedElement)o).getName(); lookups.add(new VariableLookup("$" + name, type, ((PsiNamedElement)o).getIcon(0), (PsiElement)o)); } else { lookups.add(new VariableLookup("$" + String.valueOf(o), PlatformIcons.VARIABLE_ICON)); } } return lookups; } else { return Collections.emptySet(); } }
protected void renderIcon(FilePath path) { if (path.isDirectory()) { setIcon(PlatformIcons.DIRECTORY_CLOSED_ICON); } else { setIcon(path.getFileType().getIcon()); } }
@Override public Icon getIcon() { if (myDirectory != null) { return new DirectoryIconProvider().getIcon(myDirectory, 0); } return PlatformIcons.PACKAGE_ICON; }
public void addCompletions(@NotNull final CompletionParameters parameters, final ProcessingContext context, @NotNull final CompletionResultSet result) { for (final String[] completion : RegExpLanguageHosts.getInstance().getKnownCharacterClasses(parameters.getPosition())) { addLookupElement(result, completion[0], completion[1], emptyIcon); } for (String[] stringArray : RegExpLanguageHosts.getInstance().getAllKnownProperties(parameters.getPosition())) { addLookupElement(result, "p{" + stringArray[0] + "}", stringArray.length > 1? stringArray[1]:null, PlatformIcons.PROPERTY_ICON); } }
@Override public Icon getElementIcon(final int flags) { Icon methodIcon = myBaseIcon != null ? myBaseIcon : hasModifierProperty(PsiModifier.ABSTRACT) ? PlatformIcons.ABSTRACT_METHOD_ICON : PlatformIcons.METHOD_ICON; RowIcon baseIcon = ElementPresentationUtil.createLayeredIcon(methodIcon, this, false); return ElementPresentationUtil.addVisibilityIcon(this, flags, baseIcon); }
@NotNull public Object[] getVariants() { final Set<String> values = getEnumValues(); if (values == null || values.size() == 0) { return ArrayUtil.EMPTY_OBJECT_ARRAY; } return ContainerUtil.map2Array(values, new Function<String, Object>() { public Object fun(String s) { return LookupElementBuilder.create(s).withIcon(PlatformIcons.ENUM_ICON); } }); }
@Override public void renderElement(LookupElement element, LookupElementPresentation presentation) { IProperty property = (IProperty)element.getObject(); presentation.setIcon(PlatformIcons.PROPERTY_ICON); String key = StringUtil.notNullize(property.getUnescapedKey()); presentation.setItemText(key); PropertiesFile propertiesFile = property.getPropertiesFile(); ResourceBundle resourceBundle = propertiesFile.getResourceBundle(); String value = property.getValue(); boolean hasBundle = resourceBundle != EmptyResourceBundle.getInstance(); if (hasBundle) { PropertiesFile defaultPropertiesFile = resourceBundle.getDefaultPropertiesFile(); IProperty defaultProperty = defaultPropertiesFile.findPropertyByKey(key); if (defaultProperty != null) { value = defaultProperty.getValue(); } } if (hasBundle) { presentation.setTypeText(resourceBundle.getBaseName(), AllIcons.FileTypes.Properties); } if (presentation instanceof RealLookupElementPresentation && value != null) { value = "=" + value; int limit = 1000; if (value.length() > limit || !((RealLookupElementPresentation)presentation).hasEnoughSpaceFor(value, false)) { if (value.length() > limit) { value = value.substring(0, limit); } while (value.length() > 0 && !((RealLookupElementPresentation)presentation).hasEnoughSpaceFor(value + "...", false)) { value = value.substring(0, value.length() - 1); } value += "..."; } } TextAttributes attrs = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(PropertiesHighlighter.PROPERTY_VALUE); presentation.setTailText(value, attrs.getForegroundColor()); }
/** * @param currentRepository Pass null in the case of common repositories - none repository will be highlighted then. * @param actionsGroup * @param branchText */ public RootAction(@NotNull T repository, @Nullable T currentRepository, @NotNull ActionGroup actionsGroup, @NotNull String branchText) { super("", true); myRepository = repository; myGroup = actionsGroup; myBranchText = branchText; if (repository.equals(currentRepository)) { getTemplatePresentation().setIcon(PlatformIcons.CHECK_ICON); } getTemplatePresentation().setText(DvcsUtil.getShortRepositoryName(repository), false); }
public ConfigurationArgumentsHelpArea() { super(new BorderLayout()); add(myPanel); setBorder(IdeBorderFactory.createEmptyBorder(10, 0, 0, 0)); final DefaultActionGroup group = new DefaultActionGroup(); group.add(new MyCopyAction()); myHelpArea.addMouseListener( new PopupHandler(){ @Override public void invokePopup(final Component comp,final int x,final int y){ ActionManager.getInstance().createActionPopupMenu(ActionPlaces.UNKNOWN, group).getComponent().show(comp, x, y); } } ); FixedSizeButton copyButton = new FixedSizeButton(22); copyButton.setIcon(PlatformIcons.COPY_ICON); copyButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final StringSelection contents = new StringSelection(myHelpArea.getText().trim()); CopyPasteManager.getInstance().setContents(contents); } }); myToolbarPanel.add(copyButton, BorderLayout.NORTH); myToolbarPanel.setVisible(false); }
public NavBarItem(NavBarPanel panel, Object object, int idx, Disposable parent) { myPanel = panel; myUI = panel.getNavBarUI(); myObject = object; myIndex = idx; isPopupElement = idx == -1; if (object != null) { NavBarPresentation presentation = myPanel.getPresentation(); myText = presentation.getPresentableText(object); Icon icon = presentation.getIcon(object); myIcon = icon != null ? icon : EmptyIcon.create(5); myAttributes = presentation.getTextAttributes(object, false); } else { myText = "Sample"; myIcon = PlatformIcons.DIRECTORY_CLOSED_ICON; myAttributes = SimpleTextAttributes.REGULAR_ATTRIBUTES; } Disposer.register(parent == null ? panel : parent, this); setOpaque(false); setIpad(myUI.getElementIpad(isPopupElement)); if (!isPopupElement) { setMyBorder(null); setBorder(null); setPaintFocusBorder(false); } update(); }
@Nullable private static Icon getExpressionIcon(@NotNull PsiExpression expression) { if (expression instanceof PsiReferenceExpression) { final PsiElement element = ((PsiReferenceExpression)expression).resolve(); if (element != null) { return element.getIcon(0); } } if (expression instanceof PsiMethodCallExpression) { return PlatformIcons.METHOD_ICON; } return null; }
@Override protected void updateForBlazeProject(Project project, AnActionEvent event) { Presentation presentation = event.getPresentation(); if (isEnabled(event)) { String text = String.format("New %s Package", Blaze.buildSystemName(project)); presentation.setEnabledAndVisible(true); presentation.setText(text); presentation.setDescription(text); presentation.setIcon(PlatformIcons.PACKAGE_ICON); } else { presentation.setEnabledAndVisible(false); } }
public MyCopyAction() { super(ExecutionBundle.message("copy.configuration.action.name"), ExecutionBundle.message("copy.configuration.action.name"), PlatformIcons.COPY_ICON); final AnAction action = ActionManager.getInstance().getAction(IdeActions.ACTION_EDITOR_DUPLICATE); registerCustomShortcutSet(action.getShortcutSet(), myTree); }
private static Icon getIconForUrl(final String url, final boolean isValid, final boolean isJarDirectory) { final Icon icon; if (isValid) { VirtualFile presentableFile; if (isJarFileRoot(url)) { presentableFile = LocalFileSystem.getInstance().findFileByPath(getPresentablePath(url)); } else { presentableFile = VirtualFileManager.getInstance().findFileByUrl(url); } if (presentableFile != null && presentableFile.isValid()) { if (presentableFile.getFileSystem() instanceof HttpFileSystem) { icon = PlatformIcons.WEB_ICON; } else { if (presentableFile.isDirectory()) { if (isJarDirectory) { icon = AllIcons.Nodes.JarDirectory; } else { icon = PlatformIcons.DIRECTORY_CLOSED_ICON; } } else { icon = IconUtilEx.getIcon(presentableFile, 0, null); } } } else { icon = AllIcons.Nodes.PpInvalid; } } else { icon = AllIcons.Nodes.PpInvalid; } return icon; }
@Nullable protected Icon getElementIcon(Object element) { if (element instanceof ModuleDescriptor) { return ((ModuleDescriptor)element).getModuleType().getIcon(); } if (element instanceof LibraryDescriptor) { return PlatformIcons.LIBRARY_ICON; } if (element instanceof File) { final File file = (File)element; return file.isDirectory()? PlatformIcons.DIRECTORY_CLOSED_ICON : PlatformIcons.JAR_ICON; } return null; }
protected CreateFileFromTemplateDialog(@NotNull Project project) { super(project, true); myKindLabel.setLabelFor(myKindCombo); myKindCombo.registerUpDownHint(myNameField); myUpDownHint.setIcon(PlatformIcons.UP_DOWN_ARROWS); setTemplateKindComponentsVisible(false); init(); }
private AnAction createSortingAction(boolean checked) { boolean currentSetting = UISettings.getInstance().SORT_LOOKUP_ELEMENTS_LEXICOGRAPHICALLY; final boolean newSetting = checked ? currentSetting : !currentSetting; return new DumbAwareAction(newSetting ? "Sort lexicographically" : "Sort by relevance", null, checked ? PlatformIcons.CHECK_ICON : null) { @Override public void actionPerformed(AnActionEvent e) { FeatureUsageTracker.getInstance().triggerFeatureUsed(CodeCompletionFeatures.EDITING_COMPLETION_CHANGE_SORTING); UISettings.getInstance().SORT_LOOKUP_ELEMENTS_LEXICOGRAPHICALLY = newSetting; updateSorting(); } }; }
public void render(@NotNull PresentationData presentationData, SimpleTextAttributes mainAttributes, SimpleTextAttributes commentAttributes) { if (myLibrary != null) { presentationData.setIcon(PlatformIcons.LIBRARY_ICON); presentationData.addText(myLibraryName, mainAttributes); presentationData.addText(getLibraryTableComment(myLibrary), commentAttributes); } else { presentationData.addText(myLibraryName + " (" + (myModuleName != null ? "module '" + myModuleName + "'" : myLevel) + ")", SimpleTextAttributes.ERROR_ATTRIBUTES); } }
public void render(@NotNull PresentationData presentationData, SimpleTextAttributes mainAttributes, SimpleTextAttributes commentAttributes) { final Module module = findModule(); if (myTestOutput) { presentationData.setIcon(PlatformIcons.TEST_SOURCE_FOLDER); } else if (module != null) { presentationData.setIcon(ModuleType.get(module).getIcon()); } String moduleName; if (module != null) { moduleName = module.getName(); final ModifiableModuleModel moduleModel = myContext.getModifiableModuleModel(); if (moduleModel != null) { final String newName = moduleModel.getNewName(module); if (newName != null) { moduleName = newName; } } } else if (myModulePointer != null) { moduleName = myModulePointer.getModuleName(); } else { moduleName = "<unknown>"; } String text = myTestOutput ? CompilerBundle.message("node.text.0.test.compile.output", moduleName) : CompilerBundle.message("node.text.0.compile.output", moduleName); presentationData.addText(text, module != null ? mainAttributes : SimpleTextAttributes.ERROR_ATTRIBUTES); }
ActionGroup createActions(@Nullable DefaultActionGroup toInsert) { DefaultActionGroup popupGroup = new DefaultActionGroup(null, false); popupGroup.addAction(new HgNewBranchAction(myProject, Collections.singletonList(myRepository), myRepository)); popupGroup.addAction(new HgNewBookmarkAction(Collections.singletonList(myRepository), myRepository)); popupGroup.addAction(new HgBranchPopupActions.HgCloseBranchAction(Collections.singletonList(myRepository), myRepository)); popupGroup.addAction(new HgShowUnnamedHeadsForCurrentBranchAction(myRepository)); if (toInsert != null) { popupGroup.addAll(toInsert); } popupGroup.addSeparator("Bookmarks"); List<String> bookmarkNames = getSortedNamesWithoutHashes(myRepository.getBookmarks()); String currentBookmark = myRepository.getCurrentBookmark(); for (String bookmark : bookmarkNames) { AnAction bookmarkAction = new BookmarkActions(myProject, Collections.singletonList(myRepository), bookmark); if (bookmark.equals(currentBookmark)) { bookmarkAction.getTemplatePresentation().setIcon(PlatformIcons.CHECK_ICON); } popupGroup.add(bookmarkAction); } popupGroup.addSeparator("Branches"); List<String> branchNamesList = new ArrayList<String>(myRepository.getOpenedBranches());//only opened branches have to be shown Collections.sort(branchNamesList); for (String branch : branchNamesList) { if (!branch.equals(myRepository.getCurrentBranch())) { // don't show current branch in the list popupGroup.add(new HgCommonBranchActions(myProject, Collections.singletonList(myRepository), branch)); } } return popupGroup; }
/** * Returns an image for the given type * @param type * @return */ @Nullable public static Icon getImageForType(int type){ switch (type) { case IToken.TYPE_CLASS: return PlatformIcons.CLASS_ICON; case IToken.TYPE_FUNCTION: return PlatformIcons.METHOD_ICON; default: return null; } }
public void createComponent() { removeAll(); setLayout(new GridBagLayout()); if (myLabelText != null) { myLabel = new JLabel(myLabelText); this.add(myLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 0), 0, 0)); myLabel.setLabelFor(myComponent); } this.add(myComponent, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); if (myBrowseButtonActionListener != null) { FixedSizeButton browseButton = new FixedSizeButton(getComponent()); myDoClickAction = new TextFieldWithBrowseButton.MyDoClickAction(browseButton); browseButton.setFocusable(false); browseButton.addActionListener(myBrowseButtonActionListener); myButtons.add(browseButton); this.add(browseButton, new GridBagConstraints(GridBagConstraints.RELATIVE, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 2, 0, 0), 0, 0)); } if (myViewerDialogTitle != null) { final FixedSizeButton showViewerButton = new FixedSizeButton(getComponent()); if (myBrowseButtonActionListener == null) { LOG.assertTrue(myDoClickAction == null); myDoClickAction = new TextFieldWithBrowseButton.MyDoClickAction(showViewerButton); } showViewerButton.setFocusable(false); showViewerButton.setIcon(PlatformIcons.OPEN_EDIT_DIALOG_ICON); showViewerButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Viewer viewer = new Viewer(); viewer.setTitle(myViewerDialogTitle); viewer.show(); } }); myButtons.add(showViewerButton); this.add(showViewerButton, new GridBagConstraints(GridBagConstraints.RELATIVE, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); } }
@Nullable @Override public Icon getIcon(int flags) { return PlatformIcons.FUNCTION_ICON; }
@Override protected void subInit() { super.subInit(); this.myTemplateAttributes = new FormBuilder(); this.myTemplateAttributesFields = new Hashtable<String, EditorTextField>(); this.myKindUpDownHint = new JLabel(); this.myKindUpDownHint.setIcon(PlatformIcons.UP_DOWN_ARROWS); this.myKindUpDownHint.setToolTipText("Pressing Up or Down arrows while in editor changes the template"); this.myKindComboBox = new ComboBox<String>(); this.myKindComboBox.setMinimumAndPreferredWidth(400); this.myKindComboBox.setRenderer(new ListCellRendererWrapper<Trinity>() { public void customize(JList list, Trinity value, int index, boolean selected, boolean hasFocus) { this.setText((String) value.first); this.setIcon((Icon) value.second); } }); ComboboxSpeedSearch var10001 = new ComboboxSpeedSearch(this.myKindComboBox) { protected String getElementText(Object element) { return (String) ((Trinity) element).first; } }; KeyboardShortcut up = new KeyboardShortcut(KeyStroke.getKeyStroke(38, 0), (KeyStroke) null); KeyboardShortcut down = new KeyboardShortcut(KeyStroke.getKeyStroke(40, 0), (KeyStroke) null); AnAction kindArrow = PhpNewFileDialog.getCbArrowAction(this.myKindComboBox); kindArrow.registerCustomShortcutSet(new CustomShortcutSet(new Shortcut[]{up, down}), this.myNameTextField); List<Trinity> availableTemplates = this.getAvailableTemplates(); for (Trinity type : availableTemplates) { this.myKindComboBox.addItem(type); } this.myKindComboBox.addActionListener(e -> { this.updateTemplateAttributes(); }); this.updateTemplateAttributes(); }
public NewClassAction() { super(PlatformIcons.CLASS_ICON); }