@Override public void moduleAdded() { if (!myModuleInitialized) { myConnection.subscribe( ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() { @Override public void rootsChanged(ModuleRootEvent event) { scheduleUpdate(); } }); myConnection.subscribe(GoLibrariesService.LIBRARIES_TOPIC, newRootUrls -> scheduleUpdate()); Project project = myModule.getProject(); StartupManager.getInstance(project) .runWhenProjectIsInitialized( () -> { if (!project.isDisposed() && !myModule.isDisposed()) { for (PsiFileSystemItem vendor : FilenameIndex.getFilesByName( project, GoConstants.VENDOR, GoUtil.moduleScope(myModule), true)) { if (vendor.isDirectory()) { showVendoringNotification(); break; } } } }); VirtualFileManager.getInstance().addVirtualFileListener(myFilesListener); } scheduleUpdate(0); myModuleInitialized = true; }
public static void copyAsFiles( PsiElement[] elements, @Nullable PsiDirectory defaultTargetDirectory, Project project) { PsiDirectory targetDirectory = null; String newName = null; boolean openInEditor = true; if (ApplicationManager.getApplication().isUnitTestMode()) { targetDirectory = defaultTargetDirectory; } else { CopyFilesOrDirectoriesDialog dialog = new CopyFilesOrDirectoriesDialog(elements, defaultTargetDirectory, project, false); if (dialog.showAndGet()) { newName = elements.length == 1 ? dialog.getNewName() : null; targetDirectory = dialog.getTargetDirectory(); openInEditor = dialog.openInEditor(); } } if (targetDirectory != null) { try { for (PsiElement element : elements) { PsiFileSystemItem psiElement = (PsiFileSystemItem) element; if (psiElement.isDirectory()) { MoveFilesOrDirectoriesUtil.checkIfMoveIntoSelf(psiElement, targetDirectory); } } } catch (IncorrectOperationException e) { CommonRefactoringUtil.showErrorHint( project, null, e.getMessage(), CommonBundle.getErrorTitle(), null); return; } copyImpl(elements, newName, targetDirectory, false, openInEditor); } }