com.intellij.openapi.roots.ModuleRootEvent Java Examples

The following examples show how to use com.intellij.openapi.roots.ModuleRootEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RunManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Inject
public RunManagerImpl(@Nonnull Project project, @Nonnull ProjectPropertiesComponent propertiesComponent) {
  myConfig = new RunManagerConfig(propertiesComponent);
  myProject = project;

  initializeConfigurationTypes(ConfigurationType.CONFIGURATION_TYPE_EP.getExtensions());
  myProject.getMessageBus().connect(myProject).subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() {
    @Override
    public void rootsChanged(ModuleRootEvent event) {
      RunnerAndConfigurationSettings configuration = getSelectedConfiguration();
      if (configuration != null) {
        myIconCheckTimes.remove(configuration.getUniqueID());//cache will be expired
      }
    }
  });
}
 
Example #2
Source File: PsiVFSListener.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void rootsChanged(@Nonnull final ModuleRootEvent event) {
  myFileManager.dispatchPendingEvents();

  if (event.isCausedByFileTypesChange()) return;
  runExternalAction(() -> {
    depthCounter--;
    assert depthCounter >= 0 : depthCounter;
    if (depthCounter > 0) return;

    DebugUtil.performPsiModification(null, () -> myFileManager.possiblyInvalidatePhysicalPsi());

    PsiTreeChangeEventImpl treeEvent = new PsiTreeChangeEventImpl(myManager);
    treeEvent.setPropertyName(PsiTreeChangeEvent.PROP_ROOTS);
    myManager.propertyChanged(treeEvent);
  });
}
 
Example #3
Source File: PantsSystemProjectResolver.java    From intellij-pants-plugin with Apache License 2.0 6 votes vote down vote up
private void doViewSwitch(@NotNull ExternalSystemTaskId id, @NotNull String projectPath) {
  Project ideProject = id.findProject();
  if (ideProject == null) {
    return;
  }
  // Disable zooming on subsequent project resolves/refreshes,
  // i.e. a project that already has existing modules, because it may zoom at a module
  // that is going to be replaced by the current resolve.
  if (ModuleManager.getInstance(ideProject).getModules().length > 0) {
    return;
  }

  MessageBusConnection messageBusConnection = ideProject.getMessageBus().connect();
  messageBusConnection.subscribe(
    ProjectTopics.PROJECT_ROOTS,
    new ModuleRootListener() {
      @Override
      public void rootsChanged(ModuleRootEvent event) {
        // Initiate view switch only when project modules have been created.
        new ViewSwitchProcessor(ideProject, projectPath).asyncViewSwitch();
      }
    }
  );
}
 
Example #4
Source File: AnalyzeDependenciesComponent.java    From consulo with Apache License 2.0 6 votes vote down vote up
/**
 * The constructor
 *
 * @param module the module to analyze
 */
public AnalyzeDependenciesComponent(Module module) {
  myModule = module;
  mySettings = AnalyzeDependenciesSettings.getInstance(myModule.getProject());
  initTree();
  init();
  getSplitter().setProportion(0.3f);
  myMessageBusConnection = myModule.getProject().getMessageBus().connect();
  myMessageBusConnection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() {
    @Override
    public void rootsChanged(ModuleRootEvent event) {
      myClasspaths.clear();
      updateTree();
    }
  });
}
 
Example #5
Source File: VcsEventWatcher.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void projectOpened() {
  MessageBusConnection connection = myProject.getMessageBus().connect(myProject);
  connection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() {
    @Override
    public void rootsChanged(ModuleRootEvent event) {
      ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
          if (myProject.isDisposed()) return;
          VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
        }
      }, ModalityState.NON_MODAL);
    }
  });
  connection.subscribe(ProblemListener.TOPIC, new MyProblemListener());
}
 
Example #6
Source File: CSharpPartialElementManager.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@Inject
public CSharpPartialElementManager(@Nonnull Project project)
{
	myProject = project;
	project.getMessageBus().connect().subscribe(PsiManagerImpl.ANY_PSI_CHANGE_TOPIC, new AnyPsiChangeListener.Adapter()
	{
		@Override
		public void beforePsiChanged(boolean isPhysical)
		{
			myCache.clear();
		}
	});

	project.getMessageBus().connect().subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter()
	{
		@Override
		public void rootsChanged(ModuleRootEvent event)
		{
			myCache.clear();
		}
	});
}
 
Example #7
Source File: ORProjectRootListener.java    From reasonml-idea-plugin with MIT License 6 votes vote down vote up
private ORProjectRootListener(@NotNull Project project) {
    project.getMessageBus().
            connect(project).
            subscribe(PROJECT_ROOTS, new ModuleRootListener() {
                @Override
                public void rootsChanged(@NotNull ModuleRootEvent event) {
                    DumbService.getInstance(project).queueTask(new DumbModeTask() {
                        @Override
                        public void performInDumbMode(@NotNull ProgressIndicator indicator) {
                            if (!project.isDisposed()) {
                                indicator.setText("Updating resource repository roots");
                                // should be done per module
                                //ModuleManager moduleManager = ModuleManager.getInstance(project);
                                //for (Module module : moduleManager.getModules()) {
                                //    moduleRootsOrDependenciesChanged(module);
                                //}
                                Sdk projectSdk = ProjectRootManager.getInstance(project).getProjectSdk();
                                if (projectSdk != null && projectSdk.getSdkType() instanceof OCamlSdkType) {
                                    OCamlSdkType.reindexSourceRoots(projectSdk);
                                }
                            }
                        }
                    });
                }
            });
}
 
Example #8
Source File: BaseCompilerTestCase.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected void setUp() throws Exception {
  super.setUp();
  if (useExternalCompiler()) {
    myProject.getMessageBus().connect(myTestRootDisposable).subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() {
      @Override
      public void rootsChanged(ModuleRootEvent event) {
        //todo[nik] projectOpened isn't called in tests so we need to add this listener manually
        forceFSRescan();
      }
    });
    // CompilerTestUtil.enableExternalCompiler(myProject);
  }
  else {
    // CompilerTestUtil.disableExternalCompiler(myProject);
  }
}
 
Example #9
Source File: FileEditorManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void rootsChanged(ModuleRootEvent event) {
  if (myScheduled) return;
  myScheduled = true;

  UIAccess uiAccess = UIAccess.get();
  DumbService.getInstance(myProject).runWhenSmart(() -> {
    myScheduled = false;
    handleRootChange(uiAccess);
  });
}
 
Example #10
Source File: PsiVFSListener.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void beforeRootsChange(@Nonnull final ModuleRootEvent event) {
  if (event.isCausedByFileTypesChange()) return;
  runExternalAction(() -> {
    depthCounter++;
    if (depthCounter > 1) return;

    PsiTreeChangeEventImpl treeEvent = new PsiTreeChangeEventImpl(myManager);
    treeEvent.setPropertyName(PsiTreeChangeEvent.PROP_ROOTS);
    myManager.beforePropertyChange(treeEvent);
  });
}
 
Example #11
Source File: UnindexedFilesUpdater.java    From consulo with Apache License 2.0 5 votes vote down vote up
public UnindexedFilesUpdater(final Project project) {
  myProject = project;
  myPusher = PushedFilePropertiesUpdater.getInstance(myProject);
  project.getMessageBus().connect(this).subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() {
    @Override
    public void rootsChanged(@Nonnull ModuleRootEvent event) {
      DumbService.getInstance(project).cancelTask(UnindexedFilesUpdater.this);
    }
  });
}
 
Example #12
Source File: LogicalRootsManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Inject
public LogicalRootsManagerImpl(final ModuleManager moduleManager, final Project project) {
  myModuleManager = moduleManager;
  myProject = project;

  final MessageBusConnection connection = project.getMessageBus().connect();
  connection.subscribe(LOGICAL_ROOTS, new LogicalRootListener() {
    @Override
    public void logicalRootsChanged() {
      clear();
      //updateCache(moduleManager);
    }
  });
  connection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() {
    @Override
    public void rootsChanged(ModuleRootEvent event) {
      project.getMessageBus().syncPublisher(LOGICAL_ROOTS).logicalRootsChanged();
    }
  });
  registerLogicalRootProvider(LogicalRootType.SOURCE_ROOT, new NotNullFunction<Module, List<VirtualFileLogicalRoot>>() {
    @Override
    @Nonnull
    public List<VirtualFileLogicalRoot> fun(final Module module) {
      return ContainerUtil.map2List(ModuleRootManager.getInstance(module).getContentFolderFiles(ContentFolderScopes.productionAndTest()), new Function<VirtualFile, VirtualFileLogicalRoot>() {
        @Override
        public VirtualFileLogicalRoot fun(final VirtualFile s) {
          return new VirtualFileLogicalRoot(s);
        }
      });
    }
  });
}
 
Example #13
Source File: ModuleVcsDetector.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void rootsChanged(ModuleRootEvent event) {
  for (Pair<String, VcsDirectoryMapping> mapping : myMappingsForRemovedModules) {
    promptRemoveMapping(mapping.first, mapping.second);
  }
  // the check calculates to true only before user has done any change to mappings, i.e. in case modules are detected/added automatically
  // on start etc (look inside)
  if (myVcsManager.needAutodetectMappings()) {
    autoDetectVcsMappings(false);
  }
}
 
Example #14
Source File: RecentProjectsManagerBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void projectOpened(final Project project, UIAccess uiAccess) {
  String path = getProjectPath(project);
  if (path != null) {
    markPathRecent(path, project);
  }
  SystemDock.getInstance().updateMenu();

  project.getMessageBus().connect().subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() {
    @Override
    public void rootsChanged(ModuleRootEvent event) {
      updateProjectModuleExtensions(project);
    }
  });
}
 
Example #15
Source File: EditorNotificationsImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Inject
public EditorNotificationsImpl(Project project) {
  myProject = project;
  myUpdateMerger = new MergingUpdateQueue("EditorNotifications update merger", 100, true, null, project);
  MessageBusConnection connection = project.getMessageBus().connect(project);
  connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerListener() {
    @Override
    public void fileOpened(@Nonnull FileEditorManager source, @Nonnull VirtualFile file) {
      updateNotifications(file);
    }
  });
  connection.subscribe(DumbService.DUMB_MODE, new DumbService.DumbModeListener() {
    @Override
    public void enteredDumbMode() {
      updateAllNotifications();
    }

    @Override
    public void exitDumbMode() {
      updateAllNotifications();
    }
  });
  connection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() {
    @Override
    public void rootsChanged(ModuleRootEvent event) {
      updateAllNotifications();
    }
  });
}
 
Example #16
Source File: HaxeProjectModel.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
private void addProjectListeners() {
  project.getMessageBus().connect().subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() {
    @Override
    public void rootsChanged(ModuleRootEvent event) {
      rootsCache = null;
    }
  });
}
 
Example #17
Source File: ProjectTreeBuilder.java    From consulo with Apache License 2.0 5 votes vote down vote up
public ProjectTreeBuilder(@Nonnull Project project,
                          @Nonnull JTree tree,
                          @Nonnull DefaultTreeModel treeModel,
                          @Nullable Comparator<NodeDescriptor> comparator,
                          @Nonnull ProjectAbstractTreeStructureBase treeStructure) {
  super(project, tree, treeModel, treeStructure, comparator);

  final MessageBusConnection connection = project.getMessageBus().connect(this);

  connection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() {
    @Override
    public void rootsChanged(ModuleRootEvent event) {
      queueUpdate();
    }
  });

  connection.subscribe(BookmarksListener.TOPIC, new MyBookmarksListener());

  PsiManager.getInstance(project).addPsiTreeChangeListener(createPsiTreeChangeListener(project), this);
  FileStatusManager.getInstance(project).addFileStatusListener(new MyFileStatusListener(), this);
  CopyPasteManager.getInstance().addContentChangedListener(new CopyPasteUtil.DefaultCopyPasteListener(getUpdater()), this);

  connection.subscribe(ProblemListener.TOPIC, new MyProblemListener());

  setCanYieldUpdate(true);

  initRootNode();
}
 
Example #18
Source File: ScopeTreeViewPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void rootsChanged(ModuleRootEvent event) {
  myUpdateQueue.cancelAllUpdates();
  myUpdateQueue.queue(new Update("RootsChanged") {
    @Override
    public void run() {
      refreshScope(getCurrentScope());
    }

    @Override
    public boolean isExpired() {
      return !isTreeShowing();
    }
  });
}
 
Example #19
Source File: FileIsNotAttachedProvider.java    From consulo-unity3d with Apache License 2.0 5 votes vote down vote up
@Inject
public FileIsNotAttachedProvider(Project project, final EditorNotifications notifications)
{
	myProject = project;
	myProject.getMessageBus().connect().subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener()
	{
		@Override
		public void rootsChanged(ModuleRootEvent event)
		{
			notifications.updateAllNotifications();
		}
	});
	myProject.getMessageBus().connect().subscribe(ModuleExtension.CHANGE_TOPIC, (oldExtension, newExtension) -> notifications.updateAllNotifications());
}
 
Example #20
Source File: SetupUnitySDKProvider.java    From consulo-unity3d with Apache License 2.0 5 votes vote down vote up
@Inject
public SetupUnitySDKProvider(Project project, final EditorNotifications notifications)
{
	myProject = project;
	myProject.getMessageBus().connect().subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener()
	{
		@Override
		public void rootsChanged(ModuleRootEvent event)
		{
			notifications.updateAllNotifications();
		}
	});
	myProject.getMessageBus().connect().subscribe(ModuleExtension.CHANGE_TOPIC, (oldExtension, newExtension) -> notifications.updateAllNotifications());
}
 
Example #21
Source File: Unity3dProjectService.java    From consulo-unity3d with Apache License 2.0 5 votes vote down vote up
@Inject
Unity3dProjectService(Project project)
{
	myProject = project;
	project.getMessageBus().connect().subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener()
	{
		@Override
		public void rootsChanged(ModuleRootEvent event)
		{
			myValue.drop();
		}
	});
}
 
Example #22
Source File: PantsProjectCache.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
private void listenForRootsChange() {
  if (myProject.isDefault() || !PantsUtil.isPantsProject(myProject)) {
    return;
  }
  final MessageBusConnection connection = myProject.getMessageBus().connect(this);
  connection.subscribe(
    ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() {
      @Override
      public void rootsChanged(@NotNull ModuleRootEvent event) {
        myProjectRoots = null;
      }
    }
  );
}
 
Example #23
Source File: KnowledgeViewTreeBuilder.java    From netbeans-mmd-plugin with Apache License 2.0 5 votes vote down vote up
public KnowledgeViewTreeBuilder(@Nonnull Project project,
                                @Nonnull JTree tree,
                                @Nonnull DefaultTreeModel treeModel,
                                @Nullable Comparator<NodeDescriptor> comparator,
                                @Nonnull KnowledgeViewPanelTreeStructure treeStructure) {
  super(project, tree, treeModel, treeStructure, comparator);

  final MessageBusConnection connection = project.getMessageBus().connect(this);

  connection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() {
    @Override
    public void rootsChanged(ModuleRootEvent event) {
      queueUpdate();
    }
  });

  connection.subscribe(BookmarksListener.TOPIC, new MyBookmarksListener());

  PsiManager.getInstance(project).addPsiTreeChangeListener(createPsiTreeChangeListener(project), this);
  FileStatusManager.getInstance(project).addFileStatusListener(new MyFileStatusListener(), this);
  CopyPasteManager.getInstance().addContentChangedListener(new CopyPasteUtil.DefaultCopyPasteListener(getUpdater()), this);

  WolfTheProblemSolver.getInstance(project).addProblemListener(new MyProblemListener(), this);

  setCanYieldUpdate(true);

  initRootNode();
}
 
Example #24
Source File: BitrixFramework.java    From bxfs with MIT License 5 votes vote down vote up
@Override
	public void rootsChanged(ModuleRootEvent moduleRootEvent) {
//		projectSourceRoots = ProjectRootManager.getInstance(project).getContentSourceRoots();
//		projectResourceRoots = new VirtualFile[0];
//		for (VirtualFile resourceRoot : WebResourcesPathsConfiguration.getInstance(project).getResourceDirectories()) {
//			projectResourceRoots = Arrays.copyOf(projectResourceRoots, projectResourceRoots.length + 1);
//			projectResourceRoots[projectResourceRoots.length - 1] = resourceRoot;
//		}
	}
 
Example #25
Source File: VcsRootScanner.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void rootsChanged(ModuleRootEvent event) {
  scheduleScan();
}
 
Example #26
Source File: NavBarListener.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void beforeRootsChange(ModuleRootEvent event) {}
 
Example #27
Source File: NavBarListener.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void rootsChanged(ModuleRootEvent event) {
  updateModel();
}
 
Example #28
Source File: EnvironmentFacade.java    From CppTools with Apache License 2.0 4 votes vote down vote up
public boolean isRealRootChangedEvent(ModuleRootEvent moduleRootEvent) {
  if (fileTypeRegistrationAtStartup) return false;
  return true;
}
 
Example #29
Source File: ClasspathEditor.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void rootsChanged(ModuleRootEvent event) {
  if (myPanel != null) {
    myPanel.rootsChanged();
  }
}
 
Example #30
Source File: ClasspathEditor.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void beforeRootsChange(ModuleRootEvent event) {
}