当前位置: 首页>>代码示例>>Java>>正文


Java StartupManager.runWhenProjectIsInitialized方法代码示例

本文整理汇总了Java中com.intellij.openapi.startup.StartupManager.runWhenProjectIsInitialized方法的典型用法代码示例。如果您正苦于以下问题:Java StartupManager.runWhenProjectIsInitialized方法的具体用法?Java StartupManager.runWhenProjectIsInitialized怎么用?Java StartupManager.runWhenProjectIsInitialized使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.startup.StartupManager的用法示例。


在下文中一共展示了StartupManager.runWhenProjectIsInitialized方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: RefResolveServiceImpl

import com.intellij.openapi.startup.StartupManager; //导入方法依赖的package包/类
public RefResolveServiceImpl(final Project project,
                             final MessageBus messageBus,
                             final PsiManager psiManager,
                             StartupManager startupManager,
                             ApplicationEx application,
                             ProjectFileIndex projectFileIndex) throws IOException {
  super(project);
  ((FutureTask)resolveProcess).run();
  myApplication = application;
  myProjectFileIndex = projectFileIndex;
  if (ENABLED) {
    log = new FileWriter(new File(getStorageDirectory(), "log.txt"));

    File dataFile = new File(getStorageDirectory(), "data");
    fileIsResolved = ConcurrentBitSet.readFrom(new File(getStorageDirectory(), "bitSet"));
    log("Read resolved file bitset: " + fileIsResolved);

    int maxId = FSRecords.getMaxId();
    PersistentIntList list = new PersistentIntList(dataFile, dataFile.exists() ? 0 : maxId);
    if (list.getSize() == maxId) {
      storage = list;
    }
    else {
      // just to be safe, re-resolve all if VFS files count changes since last restart
      list.dispose();
      storage = new PersistentIntList(dataFile, maxId);
      log("VFS maxId changed: was "+list.getSize()+"; now: "+maxId+"; re-resolving everything");
      fileIsResolved.clear();
    }
    Disposer.register(this, storage);
    if (!application.isUnitTestMode()) {
      startupManager.runWhenProjectIsInitialized(new Runnable() {
        @Override
        public void run() {
          initListeners(messageBus, psiManager);
          startThread();
        }
      });
    }
    Disposer.register(this, new Disposable() {
      @Override
      public void dispose() {
        try {
          save();
          log.close();
        }
        catch (IOException e) {
          LOG.error(e);
        }
      }
    });
  }
  else {
    log = null;
    fileIsResolved = null;
    storage = null;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:59,代码来源:RefResolveServiceImpl.java

示例2: CopyrightManager

import com.intellij.openapi.startup.StartupManager; //导入方法依赖的package包/类
public CopyrightManager(@NotNull Project project,
                        @NotNull final EditorFactory editorFactory,
                        @NotNull final Application application,
                        @NotNull final FileDocumentManager fileDocumentManager,
                        @NotNull final FileTypeUtil fileTypeUtil,
                        @NotNull final ProjectRootManager projectRootManager,
                        @NotNull final PsiManager psiManager,
                        @NotNull StartupManager startupManager) {
  super(project);
  if (!myProject.isDefault()) {
    final NewFileTracker newFileTracker = NewFileTracker.getInstance();
    Disposer.register(myProject, new Disposable() {
      @Override
      public void dispose() {
        newFileTracker.clear();
      }
    });
    startupManager.runWhenProjectIsInitialized(new Runnable() {
      @Override
      public void run() {
        DocumentListener listener = new DocumentAdapter() {
          @Override
          public void documentChanged(DocumentEvent e) {
            final Document document = e.getDocument();
            final VirtualFile virtualFile = fileDocumentManager.getFile(document);
            if (virtualFile == null) return;
            final Module module = projectRootManager.getFileIndex().getModuleForFile(virtualFile);
            if (module == null) return;
            if (!newFileTracker.poll(virtualFile)) return;
            if (!fileTypeUtil.isSupportedFile(virtualFile)) return;
            if (psiManager.findFile(virtualFile) == null) return;
            application.invokeLater(new Runnable() {
              @Override
              public void run() {
                if (!virtualFile.isValid()) return;
                final PsiFile file = psiManager.findFile(virtualFile);
                if (file != null && file.isWritable()) {
                  final CopyrightProfile opts = getCopyrightOptions(file);
                  if (opts != null) {
                    new UpdateCopyrightProcessor(myProject, module, file).run();
                  }
                }
              }
            }, ModalityState.NON_MODAL, myProject.getDisposed());
          }
        };
        editorFactory.getEventMulticaster().addDocumentListener(listener, myProject);
      }
    });
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:52,代码来源:CopyrightManager.java

示例3: ContentResourceChangeListener

import com.intellij.openapi.startup.StartupManager; //导入方法依赖的package包/类
public ContentResourceChangeListener(@NotNull Project project) {
    super(project);
    final ServerConnectionManager serverConnectionManager = ComponentProvider.getComponent(project, ServerConnectionManager.class);
    pluginConfiguration = ComponentProvider.getComponent(project, AEMPluginConfiguration.class);
    this.serverConnectionManager = serverConnectionManager;
    this.project = project;

    // Register a Startup Manager to check the project if it is default after the project is initialized
    StartupManager startupManager = StartupManager.getInstance(project);
    startupManager.runWhenProjectIsInitialized(
        new Runnable() {
            @Override
            public void run() {
                SlingServerTreeManager slingServerTreeManager = ComponentProvider.getComponent(myProject, SlingServerTreeManager.class);
                if(slingServerTreeManager != null) {
                    // At the end of the Tool Window is created we run the Check if a project is marked as Default
                    Object modelRoot = slingServerTreeManager.getTree().getModel().getRoot();
                    if (modelRoot instanceof DefaultMutableTreeNode) {
                        DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) modelRoot;
                        Enumeration e = rootNode.children();
                        while (e.hasMoreElements()) {
                            TreeNode child = (TreeNode) e.nextElement();
                            if (child instanceof DefaultMutableTreeNode) {
                                DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) child;
                                Object target = childNode.getUserObject();
                                if (target instanceof SlingServerNodeDescriptor) {
                                    ActionManager actionManager = ActionManager.getInstance();
                                    SlingServerNodeDescriptor descriptor = (SlingServerNodeDescriptor) target;
                                    switch (descriptor.getTarget().getDefaultMode()) {
                                        case run:
                                            slingServerTreeManager.getTree().setSelectionPath(new TreePath(childNode.getPath()));
                                            StartRunConnectionAction runAction = (StartRunConnectionAction) actionManager.getAction("AEM.Check.Action");
                                            if (runAction != null) {
                                                runAction.doRun(myProject, SimpleDataContext.EMPTY_CONTEXT, new ProgressHandlerImpl("Connection Change Listener Check").setForceAsynchronous(false));
                                            }
                                            break;
                                        case debug:
                                            slingServerTreeManager.getTree().setSelectionPath(new TreePath(childNode.getPath()));
                                            StartDebugConnectionAction debugAction = (StartDebugConnectionAction) actionManager.getAction("AEM.Start.Debug.Action");
                                            if (debugAction != null) {
                                                debugAction.doDebug(myProject, serverConnectionManager);
                                            }
                                            break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    );
}
 
开发者ID:headwirecom,项目名称:aem-ide-tooling-4-intellij,代码行数:54,代码来源:ContentResourceChangeListener.java

示例4: CopyrightManager

import com.intellij.openapi.startup.StartupManager; //导入方法依赖的package包/类
public CopyrightManager(@NotNull Project project,
                        @NotNull final EditorFactory editorFactory,
                        @NotNull final Application application,
                        @NotNull final FileDocumentManager fileDocumentManager,
                        @NotNull final FileTypeUtil fileTypeUtil,
                        @NotNull final ProjectRootManager projectRootManager,
                        @NotNull final PsiManager psiManager,
                        @NotNull StartupManager startupManager) {
  super(project);
  if (!myProject.isDefault()) {
    final NewFileTracker newFileTracker = NewFileTracker.getInstance();
    Disposer.register(myProject, newFileTracker);
    startupManager.runWhenProjectIsInitialized(new Runnable() {
      @Override
      public void run() {
        DocumentListener listener = new DocumentAdapter() {
          @Override
          public void documentChanged(DocumentEvent e) {
            final Document document = e.getDocument();
            final VirtualFile virtualFile = fileDocumentManager.getFile(document);
            if (virtualFile == null) return;
            if (!newFileTracker.poll(virtualFile)) return;
            if (!fileTypeUtil.isSupportedFile(virtualFile)) return;
            final Module module = projectRootManager.getFileIndex().getModuleForFile(virtualFile);
            if (module == null) return;
            final PsiFile file = psiManager.findFile(virtualFile);
            if (file == null) return;
            application.invokeLater(new Runnable() {
              @Override
              public void run() {
                if (myProject.isDisposed()) return;
                if (file.isValid() && file.isWritable()) {
                  final CopyrightProfile opts = getCopyrightOptions(file);
                  if (opts != null) {
                    new UpdateCopyrightProcessor(myProject, module, file).run();
                  }
                }
              }
            }, ModalityState.NON_MODAL, myProject.getDisposed());
          }
        };
        editorFactory.getEventMulticaster().addDocumentListener(listener, myProject);
      }
    });
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:47,代码来源:CopyrightManager.java

示例5: CopyrightManager

import com.intellij.openapi.startup.StartupManager; //导入方法依赖的package包/类
public CopyrightManager(@Nonnull Project project,
                        @Nonnull final EditorFactory editorFactory,
                        @Nonnull final Application application,
                        @Nonnull final FileDocumentManager fileDocumentManager,
                        @Nonnull final ProjectRootManager projectRootManager,
                        @Nonnull final PsiManager psiManager,
                        @Nonnull StartupManager startupManager) {
  super(project);
  if (!myProject.isDefault()) {
    final NewFileTracker newFileTracker = NewFileTracker.getInstance();
    Disposer.register(myProject, newFileTracker::clear);
    startupManager.runWhenProjectIsInitialized(new Runnable() {
      @Override
      public void run() {
        DocumentListener listener = new DocumentAdapter() {
          @Override
          public void documentChanged(DocumentEvent e) {
            final Document document = e.getDocument();
            final VirtualFile virtualFile = fileDocumentManager.getFile(document);
            if (virtualFile == null) return;
            if (!newFileTracker.poll(virtualFile)) return;
            if (!CopyrightUpdaters.hasExtension(virtualFile)) return;
            final Module module = projectRootManager.getFileIndex().getModuleForFile(virtualFile);
            if (module == null) return;
            final PsiFile file = psiManager.findFile(virtualFile);
            if (file == null) return;
            application.invokeLater(new Runnable() {
              @Override
              public void run() {
                if (myProject.isDisposed()) return;
                if (file.isValid() && file.isWritable()) {
                  final CopyrightProfile opts = getCopyrightOptions(file);
                  if (opts != null) {
                    new UpdateCopyrightProcessor(myProject, module, file).run();
                  }
                }
              }
            }, ModalityState.NON_MODAL, myProject.getDisposed());
          }
        };
        editorFactory.getEventMulticaster().addDocumentListener(listener, myProject);
      }
    });
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:46,代码来源:CopyrightManager.java


注:本文中的com.intellij.openapi.startup.StartupManager.runWhenProjectIsInitialized方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。