@Override public boolean isSelected(final AnActionEvent e) { final VirtualFile[] selectedFiles = getSelectedFiles(); if (selectedFiles.length == 0) return false; final ContentEntryEditor editor = myEntryTreeEditor.getContentEntryEditor(); return myEditTestSources ? editor.isTestSource(selectedFiles[0]) : editor.isSource(selectedFiles[0]); }
@Override public void reset() { if (myFilePointersDisposable != null) { Disposer.dispose(myFilePointersDisposable); } myFilePointersDisposable = Disposer.newDisposable(); for (PyRootTypeProvider provider : myRootTypeProviders) { provider.reset(myFilePointersDisposable, this, myModule); } if (myRootTreeEditor != null) { ContentEntryEditor editor = myRootTreeEditor.getContentEntryEditor(); if (editor != null) editor.update(); myRootTreeEditor.update(); } }
@Override public void deleteContentFolder(ContentEntry contentEntry, ContentFolder folder) { for (PyRootTypeProvider provider : myRootTypeProviders) { if (provider.isMine(folder)) { removeRoot(contentEntry, folder.getUrl(), provider); return; } } super.deleteContentFolder(contentEntry, folder); }
@Override public void setSelected(final AnActionEvent e, final boolean isSelected) { final VirtualFile[] selectedFiles = getSelectedFiles(); assert selectedFiles.length != 0; final ContentEntryEditor contentEntryEditor = myEntryTreeEditor.getContentEntryEditor(); for (VirtualFile selectedFile : selectedFiles) { final SourceFolder sourceFolder = contentEntryEditor.getSourceFolder(selectedFile); if (isSelected) { if (sourceFolder == null) { // not marked yet contentEntryEditor.addSourceFolder(selectedFile, myEditTestSources, ""); } else { if (myEditTestSources != sourceFolder.isTestSource()) { final String packagePrefix = sourceFolder.getPackagePrefix(); contentEntryEditor.removeSourceFolder(sourceFolder); contentEntryEditor.addSourceFolder(selectedFile, myEditTestSources, packagePrefix); } } } else { if (sourceFolder != null) { // already marked contentEntryEditor.removeSourceFolder(sourceFolder); } } } }