private boolean checkReadonlyUsages() { final Set<VirtualFile> readOnlyUsages = getReadOnlyUsagesFiles(); return readOnlyUsages.isEmpty() || !ReadonlyStatusHandler.getInstance(myProject) .ensureFilesWritable(VfsUtil.toVirtualFileArray(readOnlyUsages)) .hasReadonlyFiles(); }
public boolean isModified() { Sdk projectSdk = getSdk(); if (projectSdk != null) { projectSdk = myProjectSdksModel.findSdk(projectSdk.getName()); } return getSelectedSdk() != projectSdk || mySdkListChanged || myProjectSdksModel.isModified() || !myModifiedModificators.isEmpty(); }
private InspectionProfile guessProfileToSelect( final InspectionProjectProfileManager profileManager) { final Set<InspectionProfile> profiles = new HashSet<InspectionProfile>(); final RefEntity[] selectedElements = myTree.getSelectedElements(); for (RefEntity selectedElement : selectedElements) { if (selectedElement instanceof RefElement) { final RefElement refElement = (RefElement) selectedElement; final PsiElement element = refElement.getElement(); if (element != null) { profiles.add(profileManager.getInspectionProfile()); } } } if (profiles.isEmpty()) { return (InspectionProfile) profileManager.getProjectProfileImpl(); } return profiles.iterator().next(); }
public void apply() throws ConfigurationException { if (!myModifiedModificators.isEmpty()) { mySdkSettingsWereModified.run(); } for (SdkModificator modificator : myModifiedModificators) { /* This should always be true barring bug elsewhere, log error on else? */ if (modificator.isWritable()) { modificator.commitChanges(); } } myModificators.clear(); myModifiedModificators.clear(); mySdkListChanged = false; final Sdk sdk = getSelectedSdk(); myShowMoreCallback.consume(sdk); PyPackageManagers.getInstance().clearCache(sdk); Disposer.dispose(getDisposable()); }
@Nullable private UsageTarget[] getSelectedUsageTargets() { TreePath[] selectionPaths = myTree.getSelectionPaths(); if (selectionPaths == null) return null; Set<UsageTarget> targets = new THashSet<UsageTarget>(); for (TreePath selectionPath : selectionPaths) { Object lastPathComponent = selectionPath.getLastPathComponent(); if (lastPathComponent instanceof UsageTargetNode) { UsageTargetNode usageTargetNode = (UsageTargetNode) lastPathComponent; UsageTarget target = usageTargetNode.getTarget(); if (target != null && target.isValid()) { targets.add(target); } } } return targets.isEmpty() ? null : targets.toArray(new UsageTarget[targets.size()]); }
@Nullable private AnalysisScope getScope() { final Set<PsiFile> selectedScope = getSelectedScope(myRightTree); Set<PsiFile> result = new HashSet<PsiFile>(); ((PackageDependenciesNode) myLeftTree.getModel().getRoot()) .fillFiles(result, !mySettings.UI_FLATTEN_PACKAGES); selectedScope.removeAll(result); if (selectedScope.isEmpty()) return null; List<VirtualFile> files = new ArrayList<VirtualFile>(); final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex(); for (PsiFile psiFile : selectedScope) { final VirtualFile file = psiFile.getVirtualFile(); LOG.assertTrue(file != null); if (fileIndex.isInContent(file)) { files.add(file); } } if (!files.isEmpty()) { return new AnalysisScope(myProject, files); } return null; }
private String canCreateAllFilesForAllLocales() { final String name = getBaseName(); if (name.isEmpty()) { return "Base name is empty"; } final Set<String> files = getFileNamesToCreate(); if (files.isEmpty()) { return "No locales added"; } for (PsiElement element : myDirectory.getChildren()) { if (element instanceof PsiFile) { if (element instanceof PropertiesFile) { PropertiesFile propertiesFile = (PropertiesFile) element; final String propertiesFileName = propertiesFile.getName(); if (files.contains(propertiesFileName)) { return "Some of files already exist"; } } } } return null; }
private void checkEmpty() { setOKActionEnabled(!mySelectedFiles.isEmpty()); }