@Override
 public void projectOpened() {
   StartupManager startupManager = StartupManager.getInstance(myProject);
   if (startupManager == null) {
     return; // upsource
   }
   startupManager.registerPostStartupActivity(
       new DumbAwareRunnable() {
         @Override
         public void run() {
           final Set<Profile> profiles = new HashSet<Profile>();
           profiles.add(getProjectProfileImpl());
           profiles.addAll(getProfiles());
           profiles.addAll(InspectionProfileManager.getInstance().getProfiles());
           final Application app = ApplicationManager.getApplication();
           Runnable initInspectionProfilesRunnable =
               () -> {
                 for (Profile profile : profiles) {
                   initProfileWrapper(profile);
                 }
                 fireProfilesInitialized();
               };
           if (app.isUnitTestMode() || app.isHeadlessEnvironment()) {
             initInspectionProfilesRunnable.run();
             UIUtil
                 .dispatchAllInvocationEvents(); // do not restart daemon in the middle of the test
           } else {
             app.executeOnPooledThread(initInspectionProfilesRunnable);
           }
           myScopeListener =
               new NamedScopesHolder.ScopeListener() {
                 @Override
                 public void scopesChanged() {
                   for (Profile profile : getProfiles()) {
                     ((InspectionProfile) profile).scopesChanged();
                   }
                 }
               };
           myHolder.addScopeListener(myScopeListener);
           myLocalScopesHolder.addScopeListener(myScopeListener);
           Disposer.register(
               myProject,
               new Disposable() {
                 @Override
                 public void dispose() {
                   myHolder.removeScopeListener(myScopeListener);
                   myLocalScopesHolder.removeScopeListener(myScopeListener);
                 }
               });
         }
       });
 }
 private void moveFocusToEditor() {
   StartupManager.getInstance(myProject)
       .runWhenProjectIsInitialized(
           new Runnable() {
             @Override
             public void run() {
               ToolWindowManager.getInstance(myProject)
                   .getToolWindow(ToolWindowId.PROJECT_VIEW)
                   .show(
                       new Runnable() {
                         @Override
                         public void run() {
                           FileEditor[] editors =
                               FileEditorManager.getInstance(myProject).getSelectedEditors();
                           if (editors.length > 0) {
                             final JComponent focusedComponent =
                                 editors[0].getPreferredFocusedComponent();
                             if (focusedComponent != null) {
                               ApplicationManager.getApplication()
                                   .invokeLater(
                                       new Runnable() {
                                         @Override
                                         public void run() {
                                           IdeFocusManager.getInstance(myProject)
                                               .requestFocus(focusedComponent, true);
                                         }
                                       });
                             }
                           }
                         }
                       });
             }
           });
 }
 @Override
 public void projectOpened() {
   super.projectOpened();
   if (myProject.isDefault()) {
     return;
   }
   StartupManager.getInstance(myProject)
       .registerPostStartupActivity(
           new Runnable() {
             @Override
             public void run() {
               final AbstractExternalSystemSettings pantsSettings =
                   ExternalSystemApiUtil.getSettings(myProject, PantsConstants.SYSTEM_ID);
               final boolean resolverVersionMismatch =
                   pantsSettings instanceof PantsSettings
                       && ((PantsSettings) pantsSettings).getResolverVersion()
                           != PantsResolver.VERSION;
               if (resolverVersionMismatch
                   && /* additional check */ PantsUtil.isPantsProject(myProject)) {
                 final int answer =
                     Messages.showYesNoDialog(
                         myProject,
                         PantsBundle.message(
                             "pants.project.generated.with.old.version", myProject.getName()),
                         PantsBundle.message("pants.name"),
                         PantsIcons.Icon);
                 if (answer == Messages.YES) {
                   PantsUtil.refreshAllProjects(myProject);
                 }
               }
             }
           });
 }
Ejemplo n.º 4
0
 public CtrlMouseHandler(
     final Project project,
     StartupManager startupManager,
     EditorColorsManager colorsManager,
     FileEditorManager fileEditorManager,
     @NotNull DocumentationManager documentationManager,
     @NotNull final EditorFactory editorFactory) {
   super(project);
   myEditorColorsManager = colorsManager;
   startupManager.registerPostStartupActivity(
       new DumbAwareRunnable() {
         @Override
         public void run() {
           EditorEventMulticaster eventMulticaster = editorFactory.getEventMulticaster();
           eventMulticaster.addEditorMouseListener(myEditorMouseAdapter, project);
           eventMulticaster.addEditorMouseMotionListener(myEditorMouseMotionListener, project);
           eventMulticaster.addCaretListener(
               new CaretAdapter() {
                 @Override
                 public void caretPositionChanged(CaretEvent e) {
                   if (myHint != null) {
                     myDocumentationManager.updateToolwindowContext();
                   }
                 }
               },
               project);
         }
       });
   myFileEditorManager = fileEditorManager;
   myDocumentationManager = documentationManager;
   myDocAlarm = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, myProject);
 }
  private LocalTask doActivate(Task origin, boolean explicitly) {
    final LocalTaskImpl task =
        origin instanceof LocalTaskImpl ? (LocalTaskImpl) origin : new LocalTaskImpl(origin);
    if (explicitly) {
      task.setUpdated(new Date());
    }
    myActiveTask.setActive(false);
    task.setActive(true);
    addTask(task);
    if (task.isIssue()) {
      StartupManager.getInstance(myProject)
          .runWhenProjectIsInitialized(
              new Runnable() {
                public void run() {
                  ProgressManager.getInstance()
                      .run(
                          new com.intellij.openapi.progress.Task.Backgroundable(
                              myProject, "Updating " + task.getId()) {

                            public void run(@NotNull ProgressIndicator indicator) {
                              updateIssue(task.getId());
                            }
                          });
                }
              });
    }
    LocalTask oldActiveTask = myActiveTask;
    boolean isChanged = !task.equals(oldActiveTask);
    myActiveTask = task;
    if (isChanged) {
      myDispatcher.getMulticaster().taskDeactivated(oldActiveTask);
      myDispatcher.getMulticaster().taskActivated(task);
    }
    return task;
  }
  @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 MPSFileBasedIndexProjectHandler(
      final Project project,
      final ProjectRootManagerEx rootManager,
      ProjectManager projectManager,
      FileBasedIndex index,
      StartupModuleMaker maker) {
    super(project);
    myRootManager = rootManager;
    myProjectManager = projectManager;
    myIndex = index;

    final MPSUnindexedFilesUpdater updater = new MPSUnindexedFilesUpdater(myIndex, myRootManager);

    final StartupManagerEx startupManager =
        (StartupManagerEx) StartupManager.getInstance(myProject);
    if (startupManager == null) return;

    startupManager.registerPreStartupActivity(
        new Runnable() {
          public void run() {
            startupManager.registerCacheUpdater(updater);
            myIndex.registerIndexableSet(MPSFileBasedIndexProjectHandler.this, myProject);
            DumbServiceImpl.getInstance(myProject)
                .queueCacheUpdate(Collections.<CacheUpdater>singletonList(updater));
          }
        });
  }
 protected void runStartupActivities() {
   final StartupManagerImpl startupManager =
       (StartupManagerImpl) StartupManager.getInstance(myProject);
   startupManager.runStartupActivities();
   startupManager.startCacheUpdate();
   startupManager.runPostStartupActivities();
 }
Ejemplo n.º 9
0
  @Override
  protected void doSetModuleDescriptor(ModuleDescriptor moduleDescriptor) {
    assert moduleDescriptor instanceof SolutionDescriptor;
    SolutionDescriptor newDescriptor = (SolutionDescriptor) moduleDescriptor;
    newDescriptor.setNamespace(myModule.getName());
    //    addLibs(newDescriptor);
    super.doSetModuleDescriptor(newDescriptor);

    try {
      ApplicationManager.getApplication()
          .getComponent(JdkStubSolutionManager.class)
          .claimSdk(myModule);
    } catch (final DifferentSdkException e) {

      // TODO this seems to behave suspiciously in tests
      StartupManager.getInstance(myModule.getProject())
          .runWhenProjectIsInitialized(
              new Runnable() {
                @Override
                public void run() {
                  Messages.showErrorDialog(
                      myModule.getProject(),
                      "There are more than one different SDKs used in modules with MPS facets.\n"
                          + "Trying to use "
                          + e.getRequestedSdk().getName()
                          + " while "
                          + e.getCurrentSdk().getName()
                          + " is already used."
                          + "\n",
                      "Multiple SDKs not supported in MPS plugin");
                }
              });
    }
  }
  public void commitSynchronously(
      @NotNull Document document, @NotNull Project project, PsiFile excludeFile) {
    assert !isDisposed;

    if (!project.isInitialized() && !project.isDefault()) {
      @NonNls
      String s = project + "; Disposed: " + project.isDisposed() + "; Open: " + project.isOpen();
      s += "; SA Passed: ";
      try {
        s += ((StartupManagerImpl) StartupManager.getInstance(project)).startupActivityPassed();
      } catch (Exception e) {
        s += e;
      }
      throw new RuntimeException(s);
    }

    ApplicationManager.getApplication().assertWriteAccessAllowed();
    synchronized (documentsToCommit) {
      setCommitStage(document, CommitStage.ABOUT_TO_BE_SYNC_COMMITTED, true);
      removeCommitFromQueue(document);
    }

    ProgressIndicatorBase indicator = new ProgressIndicatorBase();
    indicator.start();
    log("About to commit sync", document, true, indicator);
    Runnable finish = commit(document, project, excludeFile, indicator, true, "Sync commit");
    log("Committed sync", document, true, finish, indicator);

    assert finish != null;
    finish.run();
  }
  public ProjectRootManagerComponent(Project project, StartupManager startupManager) {
    super(project);

    myConnection = project.getMessageBus().connect(project);
    myConnection.subscribe(
        FileTypeManager.TOPIC,
        new FileTypeListener() {
          @Override
          public void beforeFileTypesChanged(@NotNull FileTypeEvent event) {
            beforeRootsChange(true);
          }

          @Override
          public void fileTypesChanged(@NotNull FileTypeEvent event) {
            rootsChanged(true);
          }
        });

    VirtualFileManager.getInstance()
        .addVirtualFileManagerListener(
            new VirtualFileManagerAdapter() {
              @Override
              public void afterRefreshFinish(boolean asynchronous) {
                doUpdateOnRefresh();
              }
            },
            project);

    startupManager.registerStartupActivity(
        new Runnable() {
          @Override
          public void run() {
            myStartupActivityPerformed = true;
          }
        });

    myHandler =
        new BatchUpdateListener() {
          @Override
          public void onBatchUpdateStarted() {
            myRootsChanged.levelUp();
            myFileTypesChanged.levelUp();
          }

          @Override
          public void onBatchUpdateFinished() {
            myRootsChanged.levelDown();
            myFileTypesChanged.levelDown();
          }
        };

    myConnection.subscribe(VirtualFilePointerListener.TOPIC, new MyVirtualFilePointerListener());
    myDoLogCachesUpdate =
        ApplicationManager.getApplication().isInternal()
            && !ApplicationManager.getApplication().isUnitTestMode();
  }
 @Override
 public void initComponent() {
   StartupManager.getInstance(myProject)
       .registerPostStartupActivity(
           new Runnable() {
             @Override
             public void run() {
               initialize();
             }
           });
 }
Ejemplo n.º 13
0
  protected void tearDown() throws Exception {
    ((StartupManagerImpl) StartupManager.getInstance(getProject())).prepareForNextTest();
    checkAllTimersAreDisposed();

    CodeStyleSettingsManager.getInstance(getProject()).dropTemporarySettings();
    checkForSettingsDamage();
    doTearDown();

    super.tearDown();

    myThreadTracker.checkLeak();
  }
 @Override
 public void projectOpened() {
   StartupManager.getInstance(myProject)
       .registerPostStartupActivity(
           new Runnable() {
             @Override
             public void run() {
               myToolWindowReady = true;
               processFileEditorChange(getActiveLayoutXmlEditor());
             }
           });
 }
  @Override
  public void projectOpened() {
    final StartupManager manager = StartupManager.getInstance(myProject);
    manager.registerPostStartupActivity(
        new DumbAwareRunnable() {
          @Override
          public void run() {
            ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject);
            if (toolWindowManager != null) { // Can be null in tests
              if (!Registry.is("vcs.merge.toolwindows")) {
                ToolWindow toolWindow =
                    toolWindowManager.registerToolWindow(
                        ToolWindowId.VCS, true, ToolWindowAnchor.BOTTOM, myProject, true);
                myContentManager = toolWindow.getContentManager();
                toolWindow.setIcon(AllIcons.Toolwindows.VcsSmallTab);
                toolWindow.installWatcher(myContentManager);
              }
            } else {
              myContentManager =
                  ContentFactory.SERVICE.getInstance().createContentManager(true, myProject);
            }
          }
        });

    addInitializationRequest(
        VcsInitObject.AFTER_COMMON,
        new Runnable() {
          @Override
          public void run() {
            if (!ApplicationManager.getApplication().isUnitTestMode()) {
              VcsRootChecker[] checkers =
                  Extensions.getExtensions(VcsRootChecker.EXTENSION_POINT_NAME);
              if (checkers.length != 0) {
                VcsRootScanner.start(myProject, checkers);
              }
            }
          }
        });
  }
  @Override
  public void projectOpened() {
    if (ApplicationManager.getApplication().isUnitTestMode()) return;

    StartupManager.getInstance(myProject)
        .runWhenProjectIsInitialized(
            new Runnable() {
              @Override
              public void run() {
                runStatisticsService();
              }
            });
  }
  public void projectOpened() {
    StartupManager.getInstance(myProject)
        .runWhenProjectIsInitialized(
            new Runnable() {
              public void run() {
                if (!ApplicationManager.getApplication().isUnitTestMode()
                    && DartLineBreakpointType.getJSBreakpointType() != null) {
                  removeDartLineBreakpoints(myProject);
                }
                // removeJSBreakpointsInDartFiles(myProject); // todo remove above and uncomment
                // this line in 13.1.1 (when JavaScriptDebugAware.isOnlySourceMappedBreakpoints() is
                // introduced)

                final boolean dartSdkWasEnabledInOldModel =
                    hasJSLibraryMappingToOldDartSdkGlobalLib(myProject);
                deleteDartSdkGlobalLibConfiguredInOldIde();

                final String dartSdkGlobalLibName =
                    importKnowledgeAboutOldDartSdkAndReturnGlobalLibName(myProject);

                final Collection<VirtualFile> pubspecYamlFiles =
                    FilenameIndex.getVirtualFilesByName(
                        myProject, PUBSPEC_YAML, GlobalSearchScope.projectScope(myProject));

                for (VirtualFile pubspecYamlFile : pubspecYamlFiles) {
                  final Module module =
                      ModuleUtilCore.findModuleForFile(pubspecYamlFile, myProject);
                  if (module != null
                      && FileTypeIndex.containsFileOfType(
                          DartFileType.INSTANCE, module.getModuleContentScope())) {
                    excludePackagesFolders(module, pubspecYamlFile);

                    if (dartSdkGlobalLibName != null
                        && dartSdkWasEnabledInOldModel
                        && ModuleType.get(module) instanceof WebModuleTypeBase
                        && !DartSdkGlobalLibUtil.isDartSdkGlobalLibAttached(
                            module, dartSdkGlobalLibName)) {
                      ApplicationManager.getApplication()
                          .runWriteAction(
                              new Runnable() {
                                public void run() {
                                  DartSdkGlobalLibUtil.configureDependencyOnGlobalLib(
                                      module, dartSdkGlobalLibName);
                                }
                              });
                    }
                  }
                }
              }
            });
  }
  public void initComponent() {
    if (!ApplicationManager.getApplication().isUnitTestMode()) {
      myCacheRefreshTimer =
          UIUtil.createNamedTimer(
              "TaskManager refresh",
              myConfig.updateInterval * 60 * 1000,
              new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                  if (myConfig.updateEnabled && !myUpdating) {
                    updateIssues(null);
                  }
                }
              });
      myCacheRefreshTimer.setInitialDelay(0);
      StartupManager.getInstance(myProject)
          .registerPostStartupActivity(
              new Runnable() {
                public void run() {
                  myCacheRefreshTimer.start();
                }
              });
    }

    // make sure that the default task is exist
    LocalTask defaultTask = findTask(LocalTaskImpl.DEFAULT_TASK_ID);
    if (defaultTask == null) {
      defaultTask = createDefaultTask();
      addTask(defaultTask);
    }

    // search for active task
    LocalTask activeTask = null;
    final List<LocalTask> tasks = getLocalTasks();
    Collections.sort(tasks, TASK_UPDATE_COMPARATOR);
    for (LocalTask task : tasks) {
      if (activeTask == null) {
        if (task.isActive()) {
          activeTask = task;
        }
      } else {
        task.setActive(false);
      }
    }
    if (activeTask == null) {
      activeTask = defaultTask;
    }

    myActiveTask = activeTask;
    doActivate(myActiveTask, false);
    myDispatcher.getMulticaster().taskActivated(myActiveTask);
  }
Ejemplo n.º 19
0
  public static void runWhenInitialized(final Project project, final Runnable r) {
    if (project.isDisposed()) return;

    if (isNoBackgroundMode()) {
      r.run();
      return;
    }

    if (!project.isInitialized()) {
      StartupManager.getInstance(project).registerPostStartupActivity(r);
      return;
    }

    runDumbAware(project, r);
  }
 @Override
 protected void tearDown() throws Exception {
   try {
     DaemonCodeAnalyzerSettings.getInstance()
         .setImportHintEnabled(true); // return default value to avoid unnecessary save
     final Project project = getProject();
     if (project != null) {
       ((StartupManagerImpl) StartupManager.getInstance(project)).checkCleared();
       ((DaemonCodeAnalyzerImpl) DaemonCodeAnalyzer.getInstance(project)).cleanupAfterTest();
     }
   } finally {
     super.tearDown();
   }
   // ((VirtualFilePointerManagerImpl)VirtualFilePointerManager.getInstance()).assertPointersDisposed();
 }
  public PsiVFSListener(Project project) {
    myProject = project;
    myFileTypeManager = FileTypeManager.getInstance();
    myProjectRootManager = ProjectRootManager.getInstance(project);
    myManager = (PsiManagerImpl) PsiManager.getInstance(project);
    myFileManager = (FileManagerImpl) myManager.getFileManager();

    myConnection = project.getMessageBus().connect(project);

    StartupManager.getInstance(project)
        .registerPreStartupActivity(
            new Runnable() {
              @Override
              public void run() {
                final BulkVirtualFileListenerAdapter adapter =
                    new BulkVirtualFileListenerAdapter(PsiVFSListener.this);
                myConnection.subscribe(
                    VirtualFileManager.VFS_CHANGES,
                    new BulkFileListener() {
                      @Override
                      public void before(@NotNull List<? extends VFileEvent> events) {
                        adapter.before(events);
                      }

                      @Override
                      public void after(@NotNull List<? extends VFileEvent> events) {
                        myReportedUnloadedPsiChange = false;
                        adapter.after(events);
                        myReportedUnloadedPsiChange = false;
                      }
                    });
                myConnection.subscribe(ProjectTopics.PROJECT_ROOTS, new MyModuleRootListener());
                myConnection.subscribe(
                    FileTypeManager.TOPIC,
                    new FileTypeListener.Adapter() {
                      @Override
                      public void fileTypesChanged(@NotNull FileTypeEvent e) {
                        myFileManager.processFileTypesChanged();
                      }
                    });
                myConnection.subscribe(
                    AppTopics.FILE_DOCUMENT_SYNC, new MyFileDocumentManagerAdapter());
                myFileManager.markInitialized();
              }
            });
  }
 public void readExternal(@NotNull final Element parentNode) {
   // save old breakpoints
   for (Element element : parentNode.getChildren()) {
     myOriginalBreakpointsNodes.add(element.clone());
   }
   if (myProject.isOpen()) {
     doRead(parentNode);
   } else {
     myStartupManager.registerPostStartupActivity(
         new Runnable() {
           @Override
           public void run() {
             doRead(parentNode);
           }
         });
   }
 }
  public void projectOpened() {
    StartupManager.getInstance(myProject)
        .registerPostStartupActivity(
            new DumbAwareRunnable() {
              public void run() {
                final FavoritesListProvider[] extensions =
                    Extensions.getExtensions(FavoritesListProvider.EP_NAME, myProject);
                for (FavoritesListProvider extension : extensions) {
                  final String name = extension.getListName(myProject);
                  if (!myName2FavoritesRoots.containsKey(name)) {
                    createNewList(name, extension.canBeRemoved(), extension.isTreeLike());
                  } else if (!myReadOnlyLists.contains(name) && !extension.canBeRemoved()) {
                    myReadOnlyLists.add(name);
                  }
                  final FavoritesListProvider.Operation addOperation =
                      extension.getCustomAddOperation();
                  if (!myAddHandlers.containsKey(name)) {
                    myAddHandlers.put(name, addOperation);
                  }
                  final FavoritesListProvider.Operation editOperation =
                      extension.getCustomEditOperation();
                  if (!myEditHandlers.containsKey(name)) {
                    myEditHandlers.put(name, editOperation);
                  }
                  final FavoritesListProvider.Operation deleteOperation =
                      extension.getCustomDeleteOperation();
                  if (!myDeleteHandlers.containsKey(name)) {
                    myDeleteHandlers.put(name, deleteOperation);
                  }
                  final TreeCellRenderer treeCellRenderer = extension.getTreeCellRenderer();
                  if (treeCellRenderer != null && !myCustomRenderers.containsKey(name)) {
                    myCustomRenderers.put(name, treeCellRenderer);
                  }
                  final Comparator<FavoritesTreeNodeDescriptor> comparator =
                      extension.getNodeDescriptorComparator();
                  if (comparator != null && !myComparators.containsKey(name)) {
                    myComparators.put(name, comparator);
                  }
                }
                final MyRootsChangeAdapter myPsiTreeChangeAdapter = new MyRootsChangeAdapter();

                PsiManager.getInstance(myProject)
                    .addPsiTreeChangeListener(myPsiTreeChangeAdapter, myProject);
              }
            });
  }
  public void initComponent() {
    StartupManager.getInstance(myProject)
        .runWhenProjectIsInitialized(
            new Runnable() {
              @Override
              public void run() {
                ModelAccess.instance()
                    .runReadAction(
                        new Runnable() {
                          @Override
                          public void run() {
                            MPSProject mpsProject = myProject.getComponent(MPSProject.class);
                            List<Solution> projectSolutions = mpsProject.getProjectSolutions();
                            List<String> updatedSolutions = new ArrayList<String>();

                            for (Solution solution : projectSolutions) {
                              try {
                                SolutionDescriptor moduleDescriptor =
                                    solution.getModuleDescriptor();
                                if (moduleDescriptor != null
                                    && moduleDescriptor.getGitTimeUpdate() != null) {
                                  String gitHubUrl = moduleDescriptor.getGitHubUrl();
                                  if (!(moduleDescriptor
                                      .getGitTimeUpdate()
                                      .equals(GitHubUtil.getLastUpdateTime(gitHubUrl)))) {
                                    updatedSolutions.add(solution.getModuleFqName());
                                  }
                                }
                              } catch (IOException e) {
                                //
                              }
                            }
                            if (!updatedSolutions.isEmpty()) {
                              String message =
                                  updatedSolutions.toString().replace("[", "").replace("]", "");
                              JFrame frame = new JFrame();
                              frame.setTitle("New Update");
                              JOptionPane.showMessageDialog(
                                  frame,
                                  "New update is available for following libraries:\n" + message);
                            }
                          }
                        });
              }
            });
  }
  private void updateUnindexedFiles(ProgressIndicator indicator) {
    PerformanceWatcher.Snapshot snapshot = PerformanceWatcher.takeSnapshot();
    PushedFilePropertiesUpdater.getInstance(myProject).pushAllPropertiesNow();
    boolean trackResponsiveness = !ApplicationManager.getApplication().isUnitTestMode();

    if (trackResponsiveness) snapshot.logResponsivenessSinceCreation("Pushing properties");

    indicator.setIndeterminate(true);
    indicator.setText(IdeBundle.message("progress.indexing.scanning"));

    myIndex.clearIndicesIfNecessary();

    CollectingContentIterator finder = myIndex.createContentIterator(indicator);
    snapshot = PerformanceWatcher.takeSnapshot();

    myIndex.iterateIndexableFilesConcurrently(finder, myProject, indicator);

    myIndex.filesUpdateEnumerationFinished();

    if (trackResponsiveness) snapshot.logResponsivenessSinceCreation("Indexable file iteration");

    List<VirtualFile> files = finder.getFiles();

    if (myOnStartup && !ApplicationManager.getApplication().isUnitTestMode()) {
      // full VFS refresh makes sense only after it's loaded, i.e. after scanning files to index is
      // finished
      ((StartupManagerImpl) StartupManager.getInstance(myProject)).scheduleInitialVfsRefresh();
    }

    if (files.isEmpty()) {
      return;
    }

    snapshot = PerformanceWatcher.takeSnapshot();

    if (trackResponsiveness)
      LOG.info("Unindexed files update started: " + files.size() + " files to update");

    indicator.setIndeterminate(false);
    indicator.setText(IdeBundle.message("progress.indexing.updating"));

    indexFiles(indicator, files);

    if (trackResponsiveness) snapshot.logResponsivenessSinceCreation("Unindexed files update");
  }
  @Override
  public void projectOpened() {
    StartupManager.getInstance(myProject)
        .registerPostStartupActivity(
            new Runnable() {
              @Override
              public void run() {
                try {
                  // get project root dir and check if this is an Android project
                  // if (AndroidStudioHelper.isAndroidGradleModule(myProject.getBaseDir())) {
                  if (isAndroidProject()) {
                    createActivityTemplates();
                  }

                } catch (IOException ignored) {
                }
              }
            });
  }
Ejemplo n.º 27
0
 public CtrlMouseHandler(
     final Project project,
     StartupManager startupManager,
     EditorColorsManager colorsManager,
     FileEditorManager fileEditorManager) {
   super(project);
   startupManager.registerPostStartupActivity(
       new DumbAwareRunnable() {
         public void run() {
           EditorEventMulticaster eventMulticaster =
               EditorFactory.getInstance().getEventMulticaster();
           eventMulticaster.addEditorMouseListener(myEditorMouseAdapter, project);
           eventMulticaster.addEditorMouseMotionListener(myEditorMouseMotionListener, project);
         }
       });
   ourReferenceAttributes =
       colorsManager.getGlobalScheme().getAttributes(CTRL_CLICKABLE_ATTRIBUTES_KEY);
   myFileEditorManager = fileEditorManager;
 }
Ejemplo n.º 28
0
 @Override
 public void loadState(final Element state) {
   // startup manager is needed cause the contract is that you can't use read and write locks
   // on component load - it can cause a deadlock (MPS-2811)
   StartupManager.getInstance(getProject())
       .runWhenProjectIsInitialized(
           new Runnable() {
             @Override
             public void run() {
               ModelAccess.instance()
                   .runReadAction(
                       new Runnable() {
                         @Override
                         public void run() {
                           read(state, getProject().getComponent(MPSProject.class));
                         }
                       });
             }
           });
 }
Ejemplo n.º 29
0
 public void projectOpened() {
   if (!ApplicationManager.getApplication().isHeadlessEnvironment()) {
     StartupManager.getInstance(myProject)
         .registerPostStartupActivity(
             new Runnable() {
               public void run() {
                 myPaletteWindow = new PaletteWindow(myProject);
                 myPaletteToolWindow =
                     ToolWindowManager.getInstance(myProject)
                         .registerToolWindow(
                             IdeBundle.message("toolwindow.palette"),
                             myPaletteWindow,
                             ToolWindowAnchor.RIGHT,
                             myProject,
                             true);
                 myPaletteToolWindow.setIcon(AllIcons.Toolwindows.ToolWindowPalette);
                 setContent();
                 final MyFileEditorManagerListener myListener = new MyFileEditorManagerListener();
                 myFileEditorManager.addFileEditorManagerListener(myListener, myProject);
               }
             });
   }
 }
 @Override
 public void loadState(ExternalDependenciesState state) {
   ArrayList<ProjectExternalDependency> oldDependencies =
       new ArrayList<ProjectExternalDependency>(myDependencies);
   myDependencies.clear();
   for (DependencyOnPluginState dependency : state.myDependencies) {
     myDependencies.add(
         new DependencyOnPlugin(
             dependency.myId,
             dependency.myMinVersion,
             dependency.myMaxVersion,
             dependency.myChannel));
   }
   if (!oldDependencies.equals(myDependencies) && !myDependencies.isEmpty()) {
     StartupManager.getInstance(myProject)
         .runWhenProjectIsInitialized(
             new DumbAwareRunnable() {
               @Override
               public void run() {
                 CheckRequiredPluginsActivity.runCheck(myProject);
               }
             });
   }
 }