Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
27,100
void () { setOKActionEnabled(!StringUtil.isEmptyOrSpaces(getKey())); }
somethingChanged
27,101
void () { List<@NlsSafe String> paths = suggestPropertiesFiles(); final String lastUrl = suggestSelectedFileUrl(); final String lastPath = lastUrl == null ? null : FileUtil.toSystemDependentName(VfsUtilCore.urlToPath(lastUrl)); if (lastPath != null) { paths.remove(lastPath); paths.add(0, lastPath); } myPropertiesFile.setHistory(paths); if (lastPath != null) { myPropertiesFile.setSelectedItem(lastPath); myPropertiesFile.setText(lastPath); } if (myPropertiesFile.getSelectedIndex() == -1 && !paths.isEmpty()) { String selectedItem = paths.get(0); myPropertiesFile.setSelectedItem(selectedItem); myPropertiesFile.setText(selectedItem); } }
populatePropertiesFiles
27,102
String () { return LastSelectedPropertiesFileStore.getInstance().suggestLastSelectedPropertiesFileUrl(myContext); }
suggestSelectedFileUrl
27,103
void () { if (myCreateNewPropertyRb.isSelected()) { PropertiesFile propertiesFile = getPropertiesFile(); if (propertiesFile != null) { LastSelectedPropertiesFileStore.getInstance().saveLastSelectedPropertiesFile(myContext, propertiesFile); } } }
saveLastSelectedFile
27,104
List<String> () { if (myCustomization.propertiesFiles != null && !myCustomization.propertiesFiles.isEmpty()) { ArrayList<String> list = new ArrayList<>(); for (PropertiesFile propertiesFile : myCustomization.propertiesFiles) { final VirtualFile virtualFile = propertiesFile.getVirtualFile(); if (virtualFile != null) { list.add(virtualFile.getPath()); } } return list; } return defaultSuggestPropertiesFiles(); }
suggestPropertiesFiles
27,105
List<String> () { return I18nUtil.defaultSuggestPropertiesFiles(myProject, myContextModules); }
defaultSuggestPropertiesFiles
27,106
PropertiesFile () { String path = getPropertiesFilePath(); if (path == null) return null; return getPropertyFileByPath(FileUtil.toSystemIndependentName(path)); }
getPropertiesFile
27,107
String () { return (String)myPropertiesFile.getSelectedItem(); }
getPropertiesFilePath
27,108
PropertiesFile (String path) { VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByPath(path); return virtualFile != null ? PropertiesImplUtil.getPropertiesFile(PsiManager.getInstance(myProject).findFile(virtualFile)) : null; }
getPropertyFileByPath
27,109
boolean () { if (myExistingProperties.isEnabled()) { IProperty item = myExistingProperties.getItem(); if (item != null) return true; } return false; }
useExistingProperty
27,110
boolean () { if (getPropertiesFile() != null) return true; final String path = getPropertiesFilePath(); if (StringUtil.isEmptyOrSpaces(path)) { String message = PropertiesBundle.message("i18nize.empty.file.path", path); Messages.showErrorDialog(myProject, message, PropertiesBundle.message("i18nize.error.creating.properties.file")); myPropertiesFile.requestFocusInWindow(); return false; } final FileType fileType = FileTypeManager.getInstance().getFileTypeByFileName(FileUtil.toSystemIndependentName(path)); if (fileType != PropertiesFileType.INSTANCE && fileType != XmlFileType.INSTANCE) { String message = PropertiesBundle.message("i18nize.cant.create.properties.file.because.its.name.is.associated", getPropertiesFilePath(), fileType.getDescription()); Messages.showErrorDialog(myProject, message, PropertiesBundle.message("i18nize.error.creating.properties.file")); myPropertiesFile.requestFocusInWindow(); return false; } try { final File file = new File(path).getCanonicalFile(); FileUtil.createParentDirs(file); ApplicationManager.getApplication().runWriteAction(new ThrowableComputable<PsiFile, Exception>() { @Override public PsiFile compute() throws Exception { VirtualFile dir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file.getParentFile()); final PsiManager psiManager = PsiManager.getInstance(myProject); if (dir == null) { throw new IOException("Error creating directory structure for file '" + path + "'"); } if (fileType == PropertiesFileType.INSTANCE) { return psiManager.findFile(dir.createChildData(this, file.getName())); } else { FileTemplate template = FileTemplateManager.getInstance(myProject).getInternalTemplate("XML Properties File.xml"); return (PsiFile)FileTemplateUtil.createFromTemplate(template, file.getName(), null, psiManager.findDirectory(dir)); } } }); } catch (Exception e) { Messages.showErrorDialog(myProject, e.getLocalizedMessage(), PropertiesBundle.message("i18nize.error.creating.properties.file")); return false; } return true; }
createPropertiesFileIfNotExists
27,111
JComponent () { return myPanel; }
createCenterPanel
27,112
JComponent () { return myCustomization.focusValueComponent ? myValue:myKey; }
getPreferredFocusedComponent
27,113
void () { super.dispose(); }
dispose
27,114
void () { if (!createPropertiesFileIfNotExists()) return; saveLastSelectedFile(); Collection<PropertiesFile> propertiesFiles = getAllPropertiesFiles(); HashMap<PropertiesFile, IProperty> existingProperties; try { ThrowableComputable<HashMap<PropertiesFile, IProperty>, RuntimeException> existingPropertiesGenerator = () -> findExistingProperties(propertiesFiles); existingProperties = ProgressManager.getInstance().runProcessWithProgressSynchronously( () -> ReadAction.compute(existingPropertiesGenerator), PropertiesBundle.message("i18nize.dialog.searching.for.already.existing.properties"), true, myProject ); } catch (ProcessCanceledException e) { super.doOKAction(); return; } for (PropertiesFile propertiesFile : propertiesFiles) { IProperty existingProperty = existingProperties.get(propertiesFile); final String propValue = getValue(); if (existingProperty != null && !Comparing.strEqual(existingProperty.getUnescapedValue(), propValue)) { final String messageText = PropertiesBundle.message("i18nize.dialog.error.property.already.defined.message", getKey(), propertiesFile.getName()); final boolean code = MessageDialogBuilder .yesNo(PropertiesBundle.message("i18nize.dialog.error.property.already.defined.title"), messageText) .ask(myProject); if (!code) { return; } } } super.doOKAction(); }
doOKAction
27,115
String () { return "editing.propertyFile.i18nInspection"; }
getHelpId
27,116
String () { if (useExistingProperty()) { return myExistingProperties.getItem().getUnescapedValue(); } return unescapeLineBreaks(myValue.getText()); }
getValue
27,117
String () { if (useExistingProperty()) { return myExistingProperties.getItem().getUnescapedKey(); } return getKeyTextField().getText(); }
getKey
27,118
boolean () { assert !ApplicationManager.getApplication().isUnitTestMode(); show(); return getExitCode() == OK_EXIT_CODE; }
hasValidData
27,119
boolean () { return myUseResourceBundle.isEnabled() && myUseResourceBundle.isSelected(); }
isUseResourceBundle
27,120
String () { return "#com.intellij.codeInsight.i18n.I18nizeQuickFixDialog"; }
getDimensionServiceKey
27,121
Collection<PropertiesFile> () { if (useExistingProperty()) { return Collections.singleton(myExistingProperties.getItem().getPropertiesFile()); } PropertiesFile propertiesFile = getPropertiesFile(); if (propertiesFile == null) return Collections.emptySet(); Collection<PropertiesFile> propertiesFiles; if (isUseResourceBundle()) { propertiesFiles = propertiesFile.getResourceBundle().getPropertiesFiles(); } else { propertiesFiles = Collections.singleton(propertiesFile); } return propertiesFiles; }
getAllPropertiesFiles
27,122
String () { return getFixName(); }
getName
27,123
String () { return getText(); }
getFamilyName
27,124
void (@NotNull Project project, @NotNull ProblemDescriptor descriptor) { PsiElement psiElement = descriptor.getPsiElement(); if (isAvailable(project, null, null)) { invoke(project, null, psiElement.getContainingFile()); } }
applyFix
27,125
String () { return getFixName(); }
getText
27,126
boolean (@NotNull Project project, @Nullable Editor editor, @Nullable PsiFile file) { return myElement != null && myElement.retrieve() != null; }
isAvailable
27,127
void (@NotNull final Project project, @Nullable Editor editor, @NotNull PsiFile file) { invokeAction(project, file, myElement.retrieve(), myKey, myPropertiesFiles); }
invoke
27,128
IntentionPreviewInfo (@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { String fileName = myPropertiesFiles != null && !myPropertiesFiles.isEmpty() ? myPropertiesFiles.get(0).getName() : ""; return new IntentionPreviewInfo.CustomDiff(PropertiesFileType.INSTANCE, fileName, myKey + "=", myKey + "=..."); }
generatePreview
27,129
void (@NotNull final Project project, @NotNull PsiFile file, @NotNull PsiElement psiElement, @Nullable final String suggestedKey, @Nullable final List<PropertiesFile> propertiesFiles) { final I18nizeQuickFixModel model; final I18nizeQuickFixDialog.DialogCustomization dialogCustomization = createDefaultCustomization(suggestedKey, propertiesFiles); if (ApplicationManager.getApplication().isUnitTestMode()) { model = new I18nizeQuickFixModel() { @Override public String getValue() { return ""; } @Override public String getKey() { return dialogCustomization.getSuggestedName(); } @Override public boolean hasValidData() { return true; } @Override public Collection<PropertiesFile> getAllPropertiesFiles() { return propertiesFiles; } }; } else { model = new I18nizeQuickFixDialog( project, file, getFixName(), dialogCustomization ); } doAction(project, psiElement, model); }
invokeAction
27,130
String () { return ""; }
getValue
27,131
String () { return dialogCustomization.getSuggestedName(); }
getKey
27,132
boolean () { return true; }
hasValidData
27,133
Collection<PropertiesFile> () { return propertiesFiles; }
getAllPropertiesFiles
27,134
Couple<String> (Project project, PsiElement psiElement, I18nizeQuickFixModel model) { if (!model.hasValidData()) { return null; } final String key = model.getKey(); final String value = model.getValue(); final Collection<PropertiesFile> selectedPropertiesFiles = model.getAllPropertiesFiles(); createProperty(project, psiElement, selectedPropertiesFiles, key, value); return Couple.of(key, value); }
doAction
27,135
void (@NotNull final Project project, @NotNull final PsiElement psiElement, @NotNull final Collection<? extends PropertiesFile> selectedPropertiesFiles, @NotNull final String key, @NotNull final String value) { for (PropertiesFile selectedFile : selectedPropertiesFiles) { if (!FileModificationService.getInstance().prepareFileForWrite(selectedFile.getContainingFile())) return; } UndoUtil.markPsiFileForUndo(psiElement.getContainingFile()); ApplicationManager.getApplication().runWriteAction(() -> CommandProcessor.getInstance().executeCommand(project, () -> { try { I18nUtil.createProperty(project, selectedPropertiesFiles, key, value); } catch (IncorrectOperationException e) { LOG.error(e); } }, PropertiesBundle.message("quickfix.i18n.command.name"), project)); }
createProperty
27,136
boolean () { return false; }
startInWriteAction
27,137
void (@NotNull CompletionParameters parameters, @NotNull ProcessingContext context, @NotNull CompletionResultSet result) { doAdd(parameters, result); }
addCompletions
27,138
void (CompletionParameters parameters, final CompletionResultSet result) { PsiElement position = parameters.getPosition(); PsiElement parent = position.getParent(); PsiElement gParent = parent != null ? parent.getParent() : null; PsiReference[] references = parent == null ? position.getReferences() : ArrayUtil.mergeArrays(position.getReferences(), parent.getReferences()); if (gParent instanceof PsiLanguageInjectionHost && references.length == 0) { //kotlin PsiReference[] gParentReferences = gParent.getReferences(); if (gParentReferences.length > 0) { references = ArrayUtil.mergeArrays(references, gParentReferences); } } PropertyReference propertyReference = ContainerUtil.findInstance(references, PropertyReference.class); if (propertyReference != null && !hasMoreImportantReference(references, propertyReference)) { final int startOffset = parameters.getOffset(); PsiElement element = propertyReference.getElement(); final int offsetInElement = startOffset - element.getTextRange().getStartOffset(); TextRange range = propertyReference.getRangeInElement(); if (offsetInElement >= range.getStartOffset()) { final String prefix = element.getText().substring(range.getStartOffset(), offsetInElement); LookupElement[] variants = getVariants(propertyReference); result.withPrefixMatcher(prefix).addAllElements(Arrays.asList(variants)); } } }
doAdd
27,139
boolean (PsiReference @NotNull [] references, @NotNull PropertyReference propertyReference) { return propertyReference.isSoft() && ContainerUtil.or(references, reference -> !reference.isSoft()); }
hasMoreImportantReference
27,140
void (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(); if (defaultPropertiesFile.getContainingFile() != propertiesFile.getContainingFile()) { IProperty defaultProperty = defaultPropertiesFile.findPropertyByKey(key); if (defaultProperty != null) { value = defaultProperty.getValue(); } } } if (hasBundle) { presentation.setTypeText(resourceBundle.getBaseName(), AllIcons.FileTypes.Properties); } TextAttributes attrs = EditorColorsManager.getInstance().getGlobalScheme() .getAttributes(PropertiesHighlighter.PropertiesComponent.PROPERTY_VALUE.getTextAttributesKey()); presentation.setTailText("=" + value, attrs.getForegroundColor()); }
renderElement
27,141
LookupElement[] (Set<Object> variants) { return variants.stream().map(o -> o instanceof String ? LookupElementBuilder.create((String)o).withIcon(PlatformIcons.PROPERTY_ICON) : createVariant((IProperty)o)) .filter(Objects::nonNull).toArray(LookupElement[]::new); }
getVariants
27,142
LookupElement (IProperty property) { String key = property.getKey(); return key == null ? null : LookupElementBuilder.create(property, key).withRenderer(LOOKUP_ELEMENT_RENDERER); }
createVariant
27,143
void (@NotNull CompletionInitializationContext context) { if (context.getFile() instanceof PropertiesFile) { context.setDummyIdentifier(CompletionUtil.DUMMY_IDENTIFIER_TRIMMED); } }
beforeCompletion
27,144
boolean (DataContext dataContext) { return ResourceBundle.ARRAY_DATA_KEY.getData(dataContext) != null; }
canMove
27,145
boolean (PsiElement[] elements, @Nullable final PsiElement targetContainer, @Nullable PsiReference reference) { return false; }
canMove
27,146
boolean (PsiElement psiElement, PsiElement[] sources) { return MoveFilesOrDirectoriesHandler.isValidTarget(psiElement); }
isValidTarget
27,147
void (DataContext dataContext, Set<PsiElement> filesOrDirs) { final ResourceBundle[] bundles = ResourceBundle.ARRAY_DATA_KEY.getData(dataContext); LOG.assertTrue(bundles != null); for (ResourceBundle bundle : bundles) { List<PropertiesFile> propertiesFiles = bundle.getPropertiesFiles(); for (PropertiesFile propertiesFile : propertiesFiles) { filesOrDirs.add(propertiesFile.getContainingFile()); } } }
collectFilesOrDirsFromContext
27,148
boolean (PsiElement source, PsiElement target) { if (source instanceof PropertiesFile && target instanceof PsiDirectory) { return source.getParent() == target; } return super.isMoveRedundant(source, target); }
isMoveRedundant
27,149
boolean (@NotNull Language language) { return false; // only available in project view }
supportsLanguage
27,150
void (@NotNull PresentationData data) { super.update(data); data.setLocationString(PropertiesBundle.message("project.view.resource.bundle.tree.node.text", getResourceBundle().getBaseName())); }
update
27,151
ResourceBundle () { return Objects.requireNonNull(PropertiesImplUtil.getPropertiesFile(getValue())).getResourceBundle(); }
getResourceBundle
27,152
String () { return super.getTestPresentation() + " (custom RB: " + getResourceBundle().getBaseName() + ")"; }
getTestPresentation
27,153
boolean (@NotNull VirtualFile file) { if (!file.isValid()) return false; assert myProject != null; PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file); PropertiesFile propertiesFile = PropertiesImplUtil.getPropertiesFile(psiFile); return propertiesFile != null && getResourceBundle().getPropertiesFiles().contains(propertiesFile); }
contains
27,154
VirtualFile () { ResourceBundle rb = getResourceBundle(); if (!rb.isValid()) return null; final List<PropertiesFile> list = rb.getPropertiesFiles(); if (!list.isEmpty()) { return list.get(0).getVirtualFile(); } return null; }
getVirtualFile
27,155
void (@NotNull PresentationData presentation) { presentation.setIcon(AllIcons.Nodes.ResourceBundle); ResourceBundle rb = getResourceBundle(); if (rb.isValid()) { presentation.setPresentableText(PropertiesBundle.message("project.view.resource.bundle.tree.node.text", rb.getBaseName())); } }
update
27,156
boolean () { return true; }
canNavigateToSource
27,157
boolean () { return true; }
canNavigate
27,158
void (final boolean requestFocus) { assert myProject != null; OpenFileDescriptor descriptor = new OpenFileDescriptor(myProject, new ResourceBundleAsVirtualFile(getResourceBundle())); FileEditorManager.getInstance(myProject).openTextEditor(descriptor, requestFocus); }
navigate
27,159
boolean () { return true; }
isSortByFirstChild
27,160
Comparable () { return new PsiFileNode.ExtensionSortKey(PropertiesFileType.INSTANCE.getDefaultExtension()); }
getTypeSortKey
27,161
boolean () { if (!super.validate()) { return false; } final ResourceBundle newBundle = getResourceBundle().getDefaultPropertiesFile().getResourceBundle(); final ResourceBundle currentBundle = getResourceBundle(); if (!Comparing.equal(newBundle, currentBundle)) { return false; } return currentBundle.isValid(); }
validate
27,162
boolean () { return getResourceBundle().isValid(); }
isValid
27,163
boolean (TreeNode @NotNull [] sourceNodes) { for (TreeNode node : sourceNodes) { if (extractPropertiesFileFromNode(node) == null) return false; } return true; }
canDrop
27,164
void (TreeNode @NotNull [] sourceNodes, @NotNull DataContext dataContext) { MultiMap<ResourceBundle, PropertiesFile> bundleGrouping = new MultiMap<>(); for (TreeNode sourceNode : sourceNodes) { final PropertiesFile propertiesFile = extractPropertiesFileFromNode(sourceNode); if (propertiesFile == null) return; bundleGrouping.putValue(propertiesFile.getResourceBundle(), propertiesFile); } final ResourceBundle resourceBundle = getResourceBundle(); bundleGrouping.remove(resourceBundle); final ResourceBundleManager resourceBundleManager = ResourceBundleManager.getInstance(myProject); final List<PropertiesFile> toAddInResourceBundle = new ArrayList<>(); for (Map.Entry<ResourceBundle, Collection<PropertiesFile>> entry : bundleGrouping.entrySet()) { toAddInResourceBundle.addAll(entry.getValue()); final ResourceBundle currentBundle = entry.getKey(); final Collection<PropertiesFile> propertiesFilesToMove = entry.getValue(); if (currentBundle.getPropertiesFiles().size() - propertiesFilesToMove.size() > 0) { final String currentBundleBaseName = currentBundle.getBaseName(); final ArrayList<PropertiesFile> files = new ArrayList<>(currentBundle.getPropertiesFiles()); files.removeAll(propertiesFilesToMove); resourceBundleManager.dissociateResourceBundle(currentBundle); resourceBundleManager.combineToResourceBundle(files, currentBundleBaseName); } } toAddInResourceBundle.addAll(resourceBundle.getPropertiesFiles()); final String baseName = resourceBundle.getBaseName(); assert myProject != null; final FileEditorManager fileEditorManager = FileEditorManager.getInstance(myProject); fileEditorManager.closeFile(new ResourceBundleAsVirtualFile(resourceBundle)); resourceBundleManager.dissociateResourceBundle(resourceBundle); final ResourceBundle updatedBundle = resourceBundleManager.combineToResourceBundleAndGet(toAddInResourceBundle, baseName); FileEditorManager.getInstance(myProject).openFile(new ResourceBundleAsVirtualFile(updatedBundle), true); ProjectView.getInstance(myProject).refresh(); }
drop
27,165
void (PsiFileSystemItem[] sourceFileArray, DataContext dataContext) { }
dropExternalFiles
27,166
Collection<VirtualFile> () { ResourceBundle rb = getResourceBundle(); return rb.isValid() ? ContainerUtil.map(rb.getPropertiesFiles(), PropertiesFile::getVirtualFile) : Collections.emptyList(); }
getRoots
27,167
ResourceBundle () { return Objects.requireNonNull(getValue()); }
getResourceBundle
27,168
PropertiesFile (TreeNode node) { if (!(node instanceof DefaultMutableTreeNode)) return null; final Object userObject = ((DefaultMutableTreeNode) node).getUserObject(); if (!(userObject instanceof PsiFileNode)) return null; final PsiFile file = ((PsiFileNode)userObject).getValue(); final PropertiesFile propertiesFile = PropertiesImplUtil.getPropertiesFile(file); if (propertiesFile == null || !file.getManager().isInProject(file) || !file.isValid()) return null; return propertiesFile; }
extractPropertiesFileFromNode
27,169
void (@NotNull List<? extends PropertiesFile> files, @NotNull Project project, @NotNull Consumer<? super AbstractTreeNode<?>> nodeConsumer, ViewSettings settings) { ResourceBundleManager manager = ResourceBundleManager.getInstance(project); MultiMap<Couple<String>, PropertiesFile> resourceBundles = new MultiMap<>(); MultiMap<CustomResourceBundle, PropertiesFile> customResourceBundles = new MultiMap<>(); for (PropertiesFile file : files) { final CustomResourceBundle customResourceBundle = manager.getCustomResourceBundle(file); if (customResourceBundle != null) { customResourceBundles.putValue(customResourceBundle, file); } else { String extension = file.getVirtualFile().getExtension(); String baseName = manager.getBaseName(file.getContainingFile()); resourceBundles.putValue(Couple.of(baseName, extension), file); } } for (Map.Entry<Couple<String>, Collection<PropertiesFile>> entry : resourceBundles.entrySet()) { Collection<PropertiesFile> bundleFiles = entry.getValue(); PropertiesFile defaultFile = bundleFiles.iterator().next(); nodeConsumer.consume(bundleFiles.size() == 1 ? new PsiFileNode(project, defaultFile.getContainingFile(), settings) : new ResourceBundleNode(project, new ResourceBundleImpl(defaultFile), settings)); } for (Map.Entry<CustomResourceBundle, Collection<PropertiesFile>> entry : customResourceBundles.entrySet()) { Collection<PropertiesFile> bundleFiles = entry.getValue(); if (bundleFiles.size() == 1) { PropertiesFile representative = bundleFiles.iterator().next(); nodeConsumer.consume(new CustomResourceBundlePropertiesFileNode(project, representative.getContainingFile(), settings)); } else { nodeConsumer.consume(new ResourceBundleNode(project, entry.getKey(), settings)); } } }
appendPropertiesFilesNodes
27,170
Object (@NotNull Collection<? extends AbstractTreeNode<?>> selected, @NotNull String dataId) { if (PlatformCoreDataKeys.BGT_DATA_PROVIDER.is(dataId)) { return (DataProvider)slowId -> getSlowData(selected, slowId); } return null; }
getData
27,171
Object (@NotNull Collection<? extends AbstractTreeNode<?>> selected, @NotNull String dataId) { if (PlatformDataKeys.DELETE_ELEMENT_PROVIDER.is(dataId)) { for (AbstractTreeNode<?> selectedElement : selected) { Object element = selectedElement.getValue(); if (element instanceof ResourceBundle) { return new ResourceBundleDeleteProvider(); } } } else if (ResourceBundle.ARRAY_DATA_KEY.is(dataId)) { List<ResourceBundle> selectedElements = new ArrayList<>(); for (AbstractTreeNode<?> node : selected) { final Object value = node.getValue(); if (value instanceof ResourceBundle) { selectedElements.add((ResourceBundle)value); } } return selectedElements.isEmpty() ? null : selectedElements.toArray(new ResourceBundle[0]); } return null; }
getSlowData
27,172
void (ContainerEvent e) { PropertiesComponent.getInstance().setValue(checkBoxSelectedStateKey, myUseXMLBasedPropertiesCheckBox.isSelected()); }
componentRemoved
27,173
void () { final String errorString = myComponent.canCreateAllFilesForAllLocales(); if (errorString != null) { Messages.showErrorDialog(getContentPanel(), errorString); } else { final List<PsiFile> createFiles = myComponent.createPropertiesFiles(); myCreatedFiles = createFiles.toArray(PsiElement.EMPTY_ARRAY); super.doOKAction(); } }
doOKAction
27,174
ValidationInfo () { for (String fileName : myComponent.getFileNamesToCreate()) { if (!PathUtil.isValidFileName(fileName)) { return new ValidationInfo( PropertiesBundle.message("create.resource.bundle.file.name.for.properties.file.0.is.invalid.error", fileName)); } else { if (myDirectory.findFile(fileName) != null) { return new ValidationInfo(PropertiesBundle.message("create.resource.bundle.file.with.name.0.already.exist.error", fileName)); } } } return null; }
doValidate
27,175
JComponent () { return myComponent.getPanel(); }
createCenterPanel
27,176
JComponent () { return myComponent.myResourceBundleBaseNameTextField; }
getPreferredFocusedComponent
27,177
PsiElement[] () { return myCreatedFiles; }
getCreatedFiles
27,178
List<PsiFile> () { final Set<String> fileNames = getFileNamesToCreate(); final List<PsiFile> createdFiles = WriteCommandAction.runWriteCommandAction(myProject, (Computable<List<PsiFile>>)() -> ReadAction.compute(() -> ContainerUtil.map(fileNames, n -> { final boolean isXml = myResourceBundle == null ? myUseXMLBasedPropertiesCheckBox.isSelected() : myResourceBundle.getDefaultPropertiesFile() instanceof XmlPropertiesFile; if (isXml) { FileTemplate template = FileTemplateManager.getInstance(myProject).getInternalTemplate("XML Properties File.xml"); try { return (PsiFile)FileTemplateUtil.createFromTemplate(template, n, null, myDirectory); } catch (Exception e) { throw new RuntimeException(e); } } else { return myDirectory.createFile(n); } }))); combineToResourceBundleIfNeeded(createdFiles); return createdFiles; }
createPropertiesFiles
27,179
Set<String> () { final String name = getBaseName(); final String suffix = getPropertiesFileSuffix(); return ContainerUtil.map2Set(myLocalesModel.getItems(), locale -> name + (locale == PropertiesUtil.DEFAULT_LOCALE ? "" : ("_" + myLocaleSuffixes .getOrDefault(locale, locale.toString()))) + suffix); }
getFileNamesToCreate
27,180
void (Collection<? extends PsiFile> files) { Collection<PropertiesFile> createdFiles = ContainerUtil.map(files, dom -> { final PropertiesFile file = PropertiesImplUtil.getPropertiesFile(dom); LOG.assertTrue(file != null, dom.getName()); return file; }); ResourceBundle mainBundle = myResourceBundle; final Set<ResourceBundle> allBundles = new HashSet<>(); if (mainBundle != null) { allBundles.add(mainBundle); } boolean needCombining = false; for (PropertiesFile file : createdFiles) { final ResourceBundle rb = file.getResourceBundle(); if (mainBundle == null) { mainBundle = rb; } else if (!mainBundle.equals(rb)) { needCombining = true; } allBundles.add(rb); } if (needCombining) { final List<PropertiesFile> toCombine = new ArrayList<>(createdFiles); final String baseName = getBaseName(); if (myResourceBundle != null) { toCombine.addAll(myResourceBundle.getPropertiesFiles()); } ResourceBundleManager manager = ResourceBundleManager.getInstance(mainBundle.getProject()); for (ResourceBundle bundle : allBundles) { manager.dissociateResourceBundle(bundle); } manager.combineToResourceBundle(toCombine, baseName); } }
combineToResourceBundleIfNeeded
27,181
String () { return myResourceBundle == null ? myResourceBundleBaseNameTextField.getText() : myResourceBundle.getBaseName(); }
getBaseName
27,182
String () { if (myResourceBundle == null) { return myUseXMLBasedPropertiesCheckBox.isSelected() ? ".xml" : ".properties"; } return "." + myResourceBundle.getDefaultPropertiesFile().getContainingFile().getFileType().getDefaultExtension(); }
getPropertiesFileSuffix
27,183
JPanel () { return myPanel; }
getPanel
27,184
void () { final JBList<Locale> projectExistLocalesList = new JBList<>(); final MyExistLocalesListModel existLocalesListModel = new MyExistLocalesListModel(); projectExistLocalesList.setModel(existLocalesListModel); projectExistLocalesList.setCellRenderer(getLocaleRenderer()); myProjectExistLocalesPanel = ToolbarDecorator.createDecorator(projectExistLocalesList) .disableRemoveAction() .disableUpDownActions() .createPanel(); myProjectExistLocalesPanel.setBorder(IdeBorderFactory.createTitledBorder( PropertiesBundle.message("create.resource.bundle.project.locales.title"), false)); final JBList localesToAddList = new JBList(); final List<Locale> locales; final List<Locale> restrictedLocales; if (myResourceBundle == null) { locales = Collections.singletonList(PropertiesUtil.DEFAULT_LOCALE); restrictedLocales = Collections.emptyList(); } else { locales = Collections.emptyList(); restrictedLocales = ContainerUtil.map(myResourceBundle.getPropertiesFiles(), PropertiesFile::getLocale); } myLocalesModel = new CollectionListModel<>(locales) { @Override public void add(@NotNull List<? extends Locale> elements) { final List<Locale> currentItems = getItems(); elements = ContainerUtil.filter(elements, locale -> !restrictedLocales.contains(locale) && !currentItems.contains(locale)); super.add(elements); } }; localesToAddList.setModel(myLocalesModel); localesToAddList.setCellRenderer(getLocaleRenderer()); localesToAddList.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { projectExistLocalesList.clearSelection(); } }); projectExistLocalesList.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { localesToAddList.clearSelection(); } }); myNewBundleLocalesPanel = ToolbarDecorator.createDecorator(localesToAddList).setAddAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { final String rawAddedLocales = Messages.showInputDialog(myProject, PropertiesBundle.message("create.resource.bundle.dialog.add.locales.validator.message"), PropertiesBundle.message("create.resource.bundle.dialog.add.locales.validator.title"), null, null, new InputValidatorEx() { @Nullable @Override public String getErrorText(String inputString) { return checkInput(inputString) ? null : PropertiesBundle.message("create.resource.bundle.invalid.locales.error.text"); } @Override public boolean checkInput(String inputString) { return extractLocalesFromString(inputString) != null; } @Override public boolean canClose(String inputString) { return checkInput(inputString); } }); if (rawAddedLocales != null) { final Map<Locale, String> locales = extractLocalesFromString(rawAddedLocales); LOG.assertTrue(locales != null); myLocaleSuffixes.putAll(locales); myLocalesModel.add(new ArrayList<>(locales.keySet())); } } }).setAddActionName(PropertiesBundle.message("create.resource.bundle.add.locales.by.suffix.action.text")) .disableUpDownActions().createPanel(); myNewBundleLocalesPanel.setBorder(IdeBorderFactory.createTitledBorder( PropertiesBundle.message("create.resource.bundle.locales.to.add.chooser.title"), false)); myAddLocaleFromExistButton = new JButton(AllIcons.Actions.Forward); new ClickListener(){ @Override public boolean onClick(@NotNull MouseEvent event, int clickCount) { if (clickCount == 1) { myLocalesModel.add(projectExistLocalesList.getSelectedValuesList()); return true; } return false; } }.installOn(myAddLocaleFromExistButton); projectExistLocalesList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { final List<Locale> currentItems = myLocalesModel.getItems(); for (Locale l : projectExistLocalesList.getSelectedValuesList()) { if (!restrictedLocales.contains(l) && !currentItems.contains(l)) { myAddLocaleFromExistButton.setEnabled(true); return; } } myAddLocaleFromExistButton.setEnabled(false); } }); myAddLocaleFromExistButton.setEnabled(false); myAddAllButton = new JButton(PropertiesBundle.message("create.resource.bundle.add.all.btn.text")); new ClickListener() { @Override public boolean onClick(@NotNull MouseEvent event, int clickCount) { if (clickCount == 1) { myLocalesModel.add(existLocalesListModel.getLocales()); } return false; } }.installOn(myAddAllButton); }
createUIComponents
27,185
void (@NotNull List<? extends Locale> elements) { final List<Locale> currentItems = getItems(); elements = ContainerUtil.filter(elements, locale -> !restrictedLocales.contains(locale) && !currentItems.contains(locale)); super.add(elements); }
add
27,186
void (FocusEvent e) { projectExistLocalesList.clearSelection(); }
focusGained
27,187
void (FocusEvent e) { localesToAddList.clearSelection(); }
focusGained
27,188
void (AnActionButton button) { final String rawAddedLocales = Messages.showInputDialog(myProject, PropertiesBundle.message("create.resource.bundle.dialog.add.locales.validator.message"), PropertiesBundle.message("create.resource.bundle.dialog.add.locales.validator.title"), null, null, new InputValidatorEx() { @Nullable @Override public String getErrorText(String inputString) { return checkInput(inputString) ? null : PropertiesBundle.message("create.resource.bundle.invalid.locales.error.text"); } @Override public boolean checkInput(String inputString) { return extractLocalesFromString(inputString) != null; } @Override public boolean canClose(String inputString) { return checkInput(inputString); } }); if (rawAddedLocales != null) { final Map<Locale, String> locales = extractLocalesFromString(rawAddedLocales); LOG.assertTrue(locales != null); myLocaleSuffixes.putAll(locales); myLocalesModel.add(new ArrayList<>(locales.keySet())); } }
run
27,189
String (String inputString) { return checkInput(inputString) ? null : PropertiesBundle.message("create.resource.bundle.invalid.locales.error.text"); }
getErrorText
27,190
boolean (String inputString) { return extractLocalesFromString(inputString) != null; }
checkInput
27,191
boolean (String inputString) { return checkInput(inputString); }
canClose
27,192
boolean (@NotNull MouseEvent event, int clickCount) { if (clickCount == 1) { myLocalesModel.add(projectExistLocalesList.getSelectedValuesList()); return true; } return false; }
onClick
27,193
void (ListSelectionEvent e) { final List<Locale> currentItems = myLocalesModel.getItems(); for (Locale l : projectExistLocalesList.getSelectedValuesList()) { if (!restrictedLocales.contains(l) && !currentItems.contains(l)) { myAddLocaleFromExistButton.setEnabled(true); return; } } myAddLocaleFromExistButton.setEnabled(false); }
valueChanged
27,194
boolean (@NotNull MouseEvent event, int clickCount) { if (clickCount == 1) { myLocalesModel.add(existLocalesListModel.getLocales()); } return false; }
onClick
27,195
ColoredListCellRenderer<Locale> () { return new ColoredListCellRenderer<>() { @Override protected void customizeCellRenderer(@NotNull JList list, Locale locale, int index, boolean selected, boolean hasFocus) { if (PropertiesUtil.DEFAULT_LOCALE == locale) { append(PropertiesBundle.message("create.resource.bundle.default.locale.presentation")); } else { append(myLocaleSuffixes.getOrDefault(locale, locale.toString())); append(PropertiesUtil.getPresentableLocale(locale), SimpleTextAttributes.GRAY_ATTRIBUTES); } } }; }
getLocaleRenderer
27,196
void (@NotNull JList list, Locale locale, int index, boolean selected, boolean hasFocus) { if (PropertiesUtil.DEFAULT_LOCALE == locale) { append(PropertiesBundle.message("create.resource.bundle.default.locale.presentation")); } else { append(myLocaleSuffixes.getOrDefault(locale, locale.toString())); append(PropertiesUtil.getPresentableLocale(locale), SimpleTextAttributes.GRAY_ATTRIBUTES); } }
customizeCellRenderer
27,197
int () { return myLocales.size(); }
getSize
27,198
Locale (int index) { return myLocales.get(index); }
getElementAt
27,199
List<Locale> () { return myLocales; }
getLocales