com.intellij.openapi.roots.ModuleRootAdapter Java Examples

The following examples show how to use com.intellij.openapi.roots.ModuleRootAdapter. 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: 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 #2
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 #3
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 #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: 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 #6
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 #7
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);
        }
      });
    }
  });
}