com.intellij.openapi.project.Project

Here are the examples of the java api class com.intellij.openapi.project.Project taken from open source projects.

1. XVariablesViewBase#buildTreeAndRestoreState()

Project: consulo
Source File: XVariablesViewBase.java
View license
protected void buildTreeAndRestoreState(@NotNull final XStackFrame stackFrame) {
    XSourcePosition position = stackFrame.getSourcePosition();
    XDebuggerTree tree = getTree();
    tree.setSourcePosition(position);
    createNewRootNode(stackFrame);
    final Project project = tree.getProject();
    project.putUserData(XVariablesView.DEBUG_VARIABLES, new XVariablesView.InlineVariablesInfo());
    project.putUserData(XVariablesView.DEBUG_VARIABLES_TIMESTAMPS, new ObjectLongHashMap<VirtualFile>());
    Object newEqualityObject = stackFrame.getEqualityObject();
    if (myFrameEqualityObject != null && newEqualityObject != null && myFrameEqualityObject.equals(newEqualityObject) && myTreeState != null) {
        disposeTreeRestorer();
        myTreeRestorer = myTreeState.restoreState(tree);
    }
    if (position != null && Registry.is("debugger.valueTooltipAutoShowOnSelection")) {
        registerInlineEvaluator(stackFrame, position, project);
    }
}

2. XVariablesViewBase#buildTreeAndRestoreState()

View license
protected void buildTreeAndRestoreState(@NotNull final XStackFrame stackFrame) {
    XSourcePosition position = stackFrame.getSourcePosition();
    XDebuggerTree tree = getTree();
    tree.setSourcePosition(position);
    createNewRootNode(stackFrame);
    final Project project = tree.getProject();
    project.putUserData(XVariablesView.DEBUG_VARIABLES, new XVariablesView.InlineVariablesInfo());
    project.putUserData(XVariablesView.DEBUG_VARIABLES_TIMESTAMPS, new ObjectLongHashMap<>());
    Object newEqualityObject = stackFrame.getEqualityObject();
    if (myFrameEqualityObject != null && newEqualityObject != null && myFrameEqualityObject.equals(newEqualityObject) && myTreeState != null) {
        disposeTreeRestorer();
        myTreeRestorer = myTreeState.restoreState(tree);
    }
    if (position != null && Registry.is("debugger.valueTooltipAutoShowOnSelection")) {
        registerInlineEvaluator(stackFrame, position, project);
    }
}

3. IDEHelperImpl#findOpenProject()

View license
@NotNull
private static Project findOpenProject(@NotNull ProjectDescriptor projectDescriptor) throws AzureCmdException {
    Project project = null;
    for (Project openProject : ProjectManager.getInstance().getOpenProjects()) {
        if (projectDescriptor.getName().equals(openProject.getName()) && projectDescriptor.getPath().equals(openProject.getBasePath())) {
            project = openProject;
            break;
        }
    }
    if (project == null) {
        throw new AzureCmdException("Unable to find an open project with the specified description.");
    }
    return project;
}

4. FileManagerImpl#findFile()

Project: consulo
Source File: FileManagerImpl.java
View license
@RequiredReadAction
@Override
@Nullable
public PsiFile findFile(@NotNull VirtualFile vFile) {
    if (vFile.isDirectory())
        return null;
    final Project project = myManager.getProject();
    if (project.isDefault())
        return null;
    ApplicationManager.getApplication().assertReadAccessAllowed();
    if (!vFile.isValid()) {
        LOG.error("Invalid file: " + vFile);
        return null;
    }
    dispatchPendingEvents();
    final FileViewProvider viewProvider = findViewProvider(vFile);
    return viewProvider.getPsi(viewProvider.getBaseLanguage());
}

5. CoverageDataManagerImpl#processGatheredCoverage()

View license
public static void processGatheredCoverage(RunConfigurationBase configuration) {
    final Project project = configuration.getProject();
    if (project.isDisposed())
        return;
    final CoverageDataManager coverageDataManager = CoverageDataManager.getInstance(project);
    final CoverageEnabledConfiguration coverageEnabledConfiguration = CoverageEnabledConfiguration.getOrCreate(configuration);
    //noinspection ConstantConditions
    final CoverageSuite coverageSuite = coverageEnabledConfiguration.getCurrentCoverageSuite();
    if (coverageSuite != null) {
        ((BaseCoverageSuite) coverageSuite).setConfiguration(configuration);
        coverageDataManager.coverageGathered(coverageSuite);
    }
}

6. FindAllAction#actionPerformed()

Project: consulo
Source File: FindAllAction.java
View license
@Override
public void actionPerformed(final AnActionEvent e) {
    Editor editor = e.getRequiredData(CommonDataKeys.EDITOR_EVEN_IF_INACTIVE);
    Project project = e.getRequiredData(CommonDataKeys.PROJECT);
    EditorSearchSession search = e.getRequiredData(EditorSearchSession.SESSION_KEY);
    if (project.isDisposed())
        return;
    FindModel oldModel = FindManager.getInstance(project).getFindInFileModel();
    FindModel newModel = oldModel.clone();
    String text = search.getTextInField();
    if (StringUtil.isEmpty(text))
        return;
    newModel.setStringToFind(text);
    FindUtil.findAllAndShow(project, editor, newModel);
}

7. IdeaModifiableModelsProvider#getLibraryTableModifiableModel()

View license
@Override
public LibraryTable.ModifiableModel getLibraryTableModifiableModel() {
    final Project[] projects = ProjectManager.getInstance().getOpenProjects();
    for (Project project : projects) {
        if (!project.isInitialized()) {
            continue;
        }
        StructureConfigurableContext context = getProjectStructureContext(project);
        LibraryTableModifiableModelProvider provider = context != null ? context.createModifiableModelProvider(LibraryTablesRegistrar.APPLICATION_LEVEL) : null;
        final LibraryTable.ModifiableModel modifiableModel = provider != null ? provider.getModifiableModel() : null;
        if (modifiableModel != null) {
            return modifiableModel;
        }
    }
    return LibraryTablesRegistrar.getInstance().getLibraryTable().getModifiableModel();
}

8. IdeaGateway#isVersioned()

Project: consulo
Source File: IdeaGateway.java
View license
public boolean isVersioned(@NotNull VirtualFile f, boolean shouldBeInContent) {
    if (!f.isInLocalFileSystem())
        return false;
    if (!f.isDirectory() && StringUtil.endsWith(f.getNameSequence(), ".class"))
        return false;
    Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
    boolean isInContent = false;
    for (Project each : openProjects) {
        if (each.isDefault())
            continue;
        if (!each.isInitialized())
            continue;
        if (Comparing.equal(each.getWorkspaceFile(), f))
            return false;
        ProjectFileIndex index = ProjectRootManager.getInstance(each).getFileIndex();
        if (index.isExcluded(f))
            return false;
        isInContent |= index.isInContent(f);
    }
    if (shouldBeInContent && !isInContent)
        return false;
    // optimisation: FileTypeManager.isFileIgnored(f) already checked inside ProjectFileIndex.isIgnored()
    return openProjects.length != 0 || !FileTypeManager.getInstance().isFileIgnored(f);
}

9. CustomizableActionsPanel#setCustomizationSchemaForCurrentProjects()

View license
private static void setCustomizationSchemaForCurrentProjects() {
    final Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
    for (Project project : openProjects) {
        final IdeFrameImpl frame = WindowManagerEx.getInstanceEx().getFrame(project);
        if (frame != null) {
            frame.updateView();
        }
    //final FavoritesManager favoritesView = FavoritesManager.getInstance(project);
    //final String[] availableFavoritesLists = favoritesView.getAvailableFavoritesLists();
    //for (String favoritesList : availableFavoritesLists) {
    //  favoritesView.getFavoritesTreeViewPanel(favoritesList).updateTreePopupHandler();
    //}
    }
    final IdeFrameImpl frame = WindowManagerEx.getInstanceEx().getFrame(null);
    if (frame != null) {
        frame.updateView();
    }
}

10. LafManagerImpl#fireUpdate()

Project: consulo
Source File: LafManagerImpl.java
View license
private static void fireUpdate() {
    UISettings.getInstance().fireUISettingsChanged();
    EditorFactory.getInstance().refreshAllEditors();
    Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
    for (Project openProject : openProjects) {
        FileStatusManager.getInstance(openProject).fileStatusesChanged();
        DaemonCodeAnalyzer.getInstance(openProject).restart();
    }
    for (IdeFrame frame : WindowManagerEx.getInstanceEx().getAllProjectFrames()) {
        if (frame instanceof IdeFrameImpl) {
            ((IdeFrameImpl) frame).updateView();
        }
    }
    ActionToolbarImpl.updateAllToolbarsImmediately();
}

11. ApplicationImpl#canExit()

Project: consulo
Source File: ApplicationImpl.java
View license
private boolean canExit() {
    for (ApplicationListener applicationListener : myDispatcher.getListeners()) {
        if (!applicationListener.canExitApplication()) {
            return false;
        }
    }
    ProjectManagerEx projectManager = (ProjectManagerEx) ProjectManager.getInstance();
    Project[] projects = projectManager.getOpenProjects();
    for (Project project : projects) {
        if (!projectManager.canClose(project)) {
            return false;
        }
    }
    return true;
}

12. ApplicationImpl#saveAll()

Project: consulo
Source File: ApplicationImpl.java
View license
@Override
public void saveAll() {
    if (myDoNotSave)
        return;
    FileDocumentManager.getInstance().saveAllDocuments();
    Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
    for (Project openProject : openProjects) {
        ProjectEx project = (ProjectEx) openProject;
        project.save();
    }
    saveSettings();
}

13. LvcsHelper#addLabel()

Project: consulo
Source File: LvcsHelper.java
View license
public static void addLabel(final TestFrameworkRunningModel model) {
    String label;
    int color;
    if (model.getRoot().isDefect()) {
        color = RED.getRGB();
        label = ExecutionBundle.message("junit.runing.info.tests.failed.label");
    } else {
        color = GREEN.getRGB();
        label = ExecutionBundle.message("junit.runing.info.tests.passed.label");
    }
    final TestConsoleProperties consoleProperties = model.getProperties();
    String name = label + " " + consoleProperties.getConfiguration().getName();
    Project project = consoleProperties.getProject();
    if (project.isDisposed())
        return;
    LocalHistory.getInstance().putSystemLabel(project, name, color);
}

14. ProjectUtils#notifyProjectsWhichUsesThisSettings()

View license
public static void notifyProjectsWhichUsesThisSettings(Settings deletedSettings, Project project, Settings defaultSettings) {
    Project[] openProjects = ProjectManagerImpl.getInstance().getOpenProjects();
    for (Project openProject : openProjects) {
        ProjectSettingsComponent component = openProject.getComponent(ProjectSettingsComponent.class);
        if (component != null) {
            Settings state = component.getSettings();
            if (deletedSettings.getId().equals(state.getId())) {
                component.loadState(defaultSettings);
                if (project != openProject) {
                    Notifier.notifyDeletedSettings(component.getProject());
                }
            }
        }
    }
}

15. ProjectUtils#applyToAllOpenedProjects()

View license
public static void applyToAllOpenedProjects(Settings updatedSettings) {
    Project[] openProjects = ProjectManagerImpl.getInstance().getOpenProjects();
    for (Project openProject : openProjects) {
        ProjectSettingsComponent component = openProject.getComponent(ProjectSettingsComponent.class);
        if (component != null) {
            Settings state = component.getSettings();
            if (updatedSettings.getId().equals(state.getId())) {
                component.settingsUpdatedFromOtherProject(updatedSettings);
            }
        }
    }
}

16. VimPlugin#showMessage()

Project: ideavim
Source File: VimPlugin.java
View license
public static void showMessage(@Nullable String msg) {
    ProjectManager pm = ProjectManager.getInstance();
    Project[] projects = pm.getOpenProjects();
    for (Project project : projects) {
        StatusBar bar = WindowManager.getInstance().getStatusBar(project);
        if (bar != null) {
            if (msg == null || msg.length() == 0) {
                bar.setInfo("");
            } else {
                bar.setInfo("VIM - " + msg);
            }
        }
    }
}

17. BuildManager#getOpenProjects()

View license
private List<Project> getOpenProjects() {
    final Project[] projects = myProjectManager.getOpenProjects();
    if (projects.length == 0) {
        return Collections.emptyList();
    }
    final List<Project> projectList = new SmartList<Project>();
    for (Project project : projects) {
        if (isValidProject(project)) {
            projectList.add(project);
        }
    }
    return projectList;
}

18. IdeaModifiableModelsProvider#getLibraryTableModifiableModel()

View license
@Override
public LibraryTable.ModifiableModel getLibraryTableModifiableModel() {
    final Project[] projects = ProjectManager.getInstance().getOpenProjects();
    for (Project project : projects) {
        if (!project.isInitialized()) {
            continue;
        }
        StructureConfigurableContext context = getProjectStructureContext(project);
        LibraryTableModifiableModelProvider provider = context != null ? context.createModifiableModelProvider(LibraryTablesRegistrar.APPLICATION_LEVEL) : null;
        final LibraryTable.ModifiableModel modifiableModel = provider != null ? provider.getModifiableModel() : null;
        if (modifiableModel != null) {
            return modifiableModel;
        }
    }
    return LibraryTablesRegistrar.getInstance().getLibraryTable().getModifiableModel();
}

19. JsonSchemaMappingsConfigurable#apply()

View license
@Override
public void apply() throws ConfigurationException {
    final List<JsonSchemaMappingsConfigurationBase.SchemaInfo> uiList = getUiList(true);
    validate(uiList);
    final Map<String, JsonSchemaMappingsConfigurationBase.SchemaInfo> projectMap = new HashMap<String, JsonSchemaMappingsConfigurationBase.SchemaInfo>();
    for (JsonSchemaMappingsConfigurationBase.SchemaInfo info : uiList) {
        if (!info.isApplicationLevel()) {
            projectMap.put(info.getName(), info);
        }
    }
    if (myProject != null) {
        JsonSchemaMappingsProjectConfiguration.getInstance(myProject).setState(projectMap);
    }
    final Project[] projects = ProjectManager.getInstance().getOpenProjects();
    for (Project project : projects) {
        final JsonSchemaService service = JsonSchemaService.Impl.get(project);
        if (service != null)
            service.reset();
    }
    if (myProject != null) {
        DaemonCodeAnalyzer.getInstance(myProject).restart();
        EditorNotifications.getInstance(myProject).updateAllNotifications();
    }
}

20. FileManagerImpl#findFile()

View license
@Override
@Nullable
public PsiFile findFile(@NotNull VirtualFile vFile) {
    if (vFile.isDirectory())
        return null;
    final Project project = myManager.getProject();
    if (project.isDefault())
        return null;
    ApplicationManager.getApplication().assertReadAccessAllowed();
    if (!vFile.isValid()) {
        LOG.error("Invalid file: " + vFile);
        return null;
    }
    dispatchPendingEvents();
    final FileViewProvider viewProvider = findViewProvider(vFile);
    return viewProvider.getPsi(viewProvider.getBaseLanguage());
}

21. InspectionDescriptionLinkHandler#getDescription()

View license
@Override
public String getDescription(@NotNull final String refSuffix, @NotNull final Editor editor) {
    final Project project = editor.getProject();
    if (project == null) {
        LOG.error(editor);
        return null;
    }
    if (project.isDisposed())
        return null;
    final PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
    if (file == null) {
        return null;
    }
    final InspectionProfile profile = (InspectionProfile) InspectionProfileManager.getInstance().getRootProfile();
    final InspectionToolWrapper toolWrapper = profile.getInspectionTool(refSuffix, file);
    if (toolWrapper == null)
        return null;
    String description = toolWrapper.loadDescription();
    if (description == null) {
        LOG.warn("No description for inspection '" + refSuffix + "'");
        description = InspectionsBundle.message("inspection.tool.description.under.construction.text");
    }
    return description;
}

22. FindAllAction#actionPerformed()

View license
@Override
public void actionPerformed(final AnActionEvent e) {
    Editor editor = e.getRequiredData(CommonDataKeys.EDITOR_EVEN_IF_INACTIVE);
    Project project = e.getRequiredData(CommonDataKeys.PROJECT);
    EditorSearchSession search = e.getRequiredData(EditorSearchSession.SESSION_KEY);
    if (project.isDisposed())
        return;
    FindModel oldModel = FindManager.getInstance(project).getFindInFileModel();
    FindModel newModel = oldModel.clone();
    String text = search.getTextInField();
    if (StringUtil.isEmpty(text))
        return;
    newModel.setStringToFind(text);
    FindUtil.findAllAndShow(project, editor, newModel);
}

23. IdeaGateway#isVersioned()

Project: intellij-community
Source File: IdeaGateway.java
View license
public boolean isVersioned(@NotNull VirtualFile f, boolean shouldBeInContent) {
    if (!f.isInLocalFileSystem())
        return false;
    if (!f.isDirectory() && StringUtil.endsWith(f.getNameSequence(), ".class"))
        return false;
    Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
    boolean isInContent = false;
    for (Project each : openProjects) {
        if (each.isDefault())
            continue;
        if (!each.isInitialized())
            continue;
        if (Comparing.equal(each.getWorkspaceFile(), f))
            return false;
        ProjectFileIndex index = ProjectRootManager.getInstance(each).getFileIndex();
        if (index.isExcluded(f))
            return false;
        isInContent |= index.isInContent(f);
    }
    if (shouldBeInContent && !isInContent)
        return false;
    // optimisation: FileTypeManager.isFileIgnored(f) already checked inside ProjectFileIndex.isIgnored()
    return openProjects.length != 0 || !FileTypeManager.getInstance().isFileIgnored(f);
}

24. ApplicationImpl#canExit()

View license
private boolean canExit() {
    for (ApplicationListener applicationListener : myDispatcher.getListeners()) {
        if (!applicationListener.canExitApplication()) {
            return false;
        }
    }
    ProjectManagerEx projectManager = (ProjectManagerEx) ProjectManager.getInstance();
    Project[] projects = projectManager.getOpenProjects();
    for (Project project : projects) {
        if (!projectManager.canClose(project)) {
            return false;
        }
    }
    return true;
}

25. ApplicationImpl#saveAll()

View license
@Override
public void saveAll() {
    if (myDoNotSave)
        return;
    FileDocumentManager.getInstance().saveAllDocuments();
    Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
    for (Project openProject : openProjects) {
        openProject.save();
    }
    saveSettings();
}

26. LvcsHelper#addLabel()

Project: intellij-community
Source File: LvcsHelper.java
View license
public static void addLabel(final TestFrameworkRunningModel model) {
    String label;
    int color;
    AbstractTestProxy root = model.getRoot();
    if (root.isInterrupted())
        return;
    if (root.isPassed() || root.isIgnored()) {
        color = GREEN.getRGB();
        label = ExecutionBundle.message("junit.runing.info.tests.passed.label");
    } else {
        color = RED.getRGB();
        label = ExecutionBundle.message("junit.runing.info.tests.failed.label");
    }
    final TestConsoleProperties consoleProperties = model.getProperties();
    String name = label + " " + consoleProperties.getConfiguration().getName();
    Project project = consoleProperties.getProject();
    if (project.isDisposed())
        return;
    LocalHistory.getInstance().putSystemLabel(project, name, color);
}

27. CoverageDataManagerImpl#processGatheredCoverage()

View license
public static void processGatheredCoverage(RunConfigurationBase configuration) {
    final Project project = configuration.getProject();
    if (project.isDisposed())
        return;
    final CoverageDataManager coverageDataManager = CoverageDataManager.getInstance(project);
    final CoverageEnabledConfiguration coverageEnabledConfiguration = CoverageEnabledConfiguration.getOrCreate(configuration);
    //noinspection ConstantConditions
    final CoverageSuite coverageSuite = coverageEnabledConfiguration.getCurrentCoverageSuite();
    if (coverageSuite != null) {
        ((BaseCoverageSuite) coverageSuite).setConfiguration(configuration);
        coverageDataManager.coverageGathered(coverageSuite);
    }
}

28. DomDescriptorProvider#getDescriptor()

View license
@Override
@Nullable
public XmlElementDescriptor getDescriptor(final XmlTag tag) {
    Project project = tag.getProject();
    if (project.isDefault())
        return null;
    final DomInvocationHandler<?, ?> handler = DomManagerImpl.getDomManager(project).getDomHandler(tag);
    if (handler != null) {
        final DefinesXml definesXml = handler.getAnnotation(DefinesXml.class);
        if (definesXml != null) {
            return new DomElementXmlDescriptor(handler);
        }
        final PsiElement parent = tag.getParent();
        if (parent instanceof XmlTag) {
            final XmlElementDescriptor descriptor = ((XmlTag) parent).getDescriptor();
            if (descriptor instanceof DomElementXmlDescriptor) {
                return descriptor.getElementDescriptor(tag, (XmlTag) parent);
            }
        }
    }
    return null;
}

29. IdeaHelper#getProject()

Project: vso-intellij
Source File: IdeaHelper.java
View license
/**
     * Find the project that is associated with the repository directory
     *
     * @param repoBaseDirectory
     * @return project based on repo
     */
public static Project getProject(final String repoBaseDirectory) {
    final Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
    for (final Project project : openProjects) {
        // standardize the repo path passed in so that both paths being compared are Unix standard
        if (project.getBasePath().equals(SystemHelper.getUnixPath(repoBaseDirectory))) {
            return project;
        }
    }
    return null;
}

30. Utils#findLayoutResource()

View license
/**
     * Try to find layout XML file in selected element
     *
     * @param element
     * @return
     */
public static PsiFile findLayoutResource(PsiElement element) {
    log.info("Finding layout resource for element: " + element.getText());
    if (element == null) {
        // nothing to be used
        return null;
    }
    if (!(element instanceof PsiIdentifier)) {
        // nothing to be used
        return null;
    }
    PsiElement layout = element.getParent().getFirstChild();
    if (layout == null) {
        // no file to process
        return null;
    }
    if (!"R.layout".equals(layout.getText())) {
        // not layout file
        return null;
    }
    Project project = element.getProject();
    String name = String.format("%s.xml", element.getText());
    return resolveLayoutResourceFile(element, project, name);
}

31. MenuAction#actionPerformed()

View license
@Override
public void actionPerformed(AnActionEvent event) {
    final Project project = event.getData(PlatformDataKeys.PROJECT);
    final VirtualFile selectedFile = event.getData(PlatformDataKeys.VIRTUAL_FILE);
    try {
        CodeGeneratorController codeGeneratorController = new CodeGeneratorController("Menu_template", new MenuResourceProvidersFactory());
        String generatedCode = codeGeneratorController.generateCode(project, selectedFile, event.getData(PlatformDataKeys.EDITOR));
        final CodeDialogBuilder codeDialogBuilder = new CodeDialogBuilder(project, String.format(StringResources.TITLE_FORMAT_TEXT, selectedFile.getName()), generatedCode);
        codeDialogBuilder.addAction(StringResources.COPY_ACTION_LABEL, new Runnable() {

            @Override
            public void run() {
                ClipboardHelper.copy(codeDialogBuilder.getModifiedCode());
                codeDialogBuilder.closeDialog();
            }
        });
        codeDialogBuilder.showDialog();
    } catch (Exception exception) {
        errorHandler.handleError(project, exception);
    }
}

32. MainAnAction#actionPerformed()

View license
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
    Project project = anActionEvent.getData(PlatformDataKeys.PROJECT);
    //        PsiFile psiFile = anActionEvent.getData(LangDataKeys.PSI_FILE);
    //        Editor editor = anActionEvent.getData(PlatformDataKeys.EDITOR);
    //        Application application = ApplicationManager.getApplication();
    //        MyApplicationComponent myApplicationComponent = application.getComponent(MyApplicationComponent.class);
    MyDialog myDialog = new MyDialog(project);
    myDialog.show();
    if (myDialog.isOK()) {
        Messages.showMessageDialog(project, "????dimen????\nGenerate pixel dimen file success", PROJECT_NAME, Messages.getInformationIcon());
    }
//        String txt = Messages.showMultilineInputDialog(project,
//                "?????????????",
//                "AutoGeneratePixelDimen",
//                "1920 1080\n1280 720", Messages.getQuestionIcon(), null);
}

33. CodegenBean#getModuleSrc()

Project: axis2-java
Source File: CodegenBean.java
View license
public String[] getModuleSrc(String name) {
    Project project = getActiveProject();
    if (project != null) {
        Module module = ModuleManager.getInstance(project).findModuleByName(name);
        ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
        VirtualFile virtualFiles[] = moduleRootManager.getSourceRoots();
        String src[] = new String[virtualFiles.length];
        for (int count = 0; count < src.length; count++) {
            src[count] = virtualFiles[count].getPresentableUrl();
        }
        return src;
    }
    return null;
}

34. WsdlgenBean#getModuleSrc()

Project: axis2-java
Source File: WsdlgenBean.java
View license
public String[] getModuleSrc(String name) {
    Project project = getActiveProject();
    if (project != null) {
        Module module = ModuleManager.getInstance(project).findModuleByName(name);
        ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
        VirtualFile virtualFiles[] = moduleRootManager.getSourceRoots();
        String src[] = new String[virtualFiles.length];
        for (int count = 0; count < src.length; count++) {
            src[count] = virtualFiles[count].getPresentableUrl();
        }
        return src;
    }
    return null;
}

35. AzureWebDeployAction#update()

View license
@Override
public void update(AnActionEvent e) {
    Project project = e.getProject();
    if (project != null) {
        IDEHelper.ProjectDescriptor projectDescriptor = new IDEHelper.ProjectDescriptor(project.getName(), project.getBasePath() == null ? "" : project.getBasePath());
        try {
            for (IDEHelper.ArtifactDescriptor descriptor : DefaultLoader.getIdeHelper().getArtifacts(projectDescriptor)) {
                if ("war".equals(descriptor.getArtifactType())) {
                    e.getPresentation().setEnabled(true);
                    return;
                }
            }
        } catch (AzureCmdException ignored) {
        }
    }
    e.getPresentation().setEnabled(false);
}

36. PackageAction#actionPerformed()

View license
public void actionPerformed(AnActionEvent event) {
    Project project = event.getData(com.intellij.openapi.actionSystem.CommonDataKeys.PROJECT);
    if (checkSdk()) {
        AzureWizardModel model = new AzureWizardModel(project, createWaProjMgr());
        AzureWizardDialog wizard = new AzureWizardDialog(model);
        final String title = AzureBundle.message("pWizWindowTitle");
        wizard.setTitle(title);
        wizard.show();
        if (wizard.isOK()) {
        //            FileContentUtil.reparseFiles();
        }
    }
}

37. RolesConfigurable#buildConfigurables()

View license
@Override
protected Configurable[] buildConfigurables() {
    Project project = module.getProject();
    return new Configurable[] { new CachingPanel(module, waProjManager, windowsAzureRole), new CertificatesPanel(module, waProjManager, windowsAzureRole), new ComponentsPanel(project, waProjManager, windowsAzureRole), new DebuggingPanel(project, waProjManager, windowsAzureRole), new RoleEndpointsPanel(module, waProjManager, windowsAzureRole), new EnvVarsPanel(module, waProjManager, windowsAzureRole), new LoadBalancingPanel(waProjManager, windowsAzureRole), new LocalStoragePanel(module, waProjManager, windowsAzureRole), new ServerConfigurationConfigurable(module, waProjManager, windowsAzureRole), new SSLOffloadingPanel(module, waProjManager, windowsAzureRole) };
}

38. PackageAction#actionPerformed()

View license
public void actionPerformed(AnActionEvent event) {
    Project project = event.getData(com.intellij.openapi.actionSystem.CommonDataKeys.PROJECT);
    if (checkSdk()) {
        AzureWizardModel model = new AzureWizardModel(project, createWaProjMgr());
        AzureWizardDialog wizard = new AzureWizardDialog(model);
        final String title = AzureBundle.message("pWizWindowTitle");
        wizard.setTitle(title);
        wizard.show();
        if (wizard.isOK()) {
        //            FileContentUtil.reparseFiles();
        }
    }
}

39. IDEHelperImpl#runInBackground()

View license
@NotNull
@Override
public CancellableTaskHandle runInBackground(@NotNull ProjectDescriptor projectDescriptor, @NotNull final String name, @Nullable final String indicatorText, @NotNull final CancellableTask cancellableTask) throws AzureCmdException {
    final CancellableTaskHandleImpl handle = new CancellableTaskHandleImpl();
    final Project project = findOpenProject(projectDescriptor);
    // background tasks via ProgressManager can be scheduled only on the
    // dispatch thread
    ApplicationManager.getApplication().invokeLater(new Runnable() {

        @Override
        public void run() {
            ProgressManager.getInstance().run(getCancellableBackgroundTask(project, name, indicatorText, handle, cancellableTask));
        }
    }, ModalityState.any());
    return handle;
}

40. IDEHelperImpl#getArtifacts()

View license
@NotNull
@Override
public List<ArtifactDescriptor> getArtifacts(@NotNull ProjectDescriptor projectDescriptor) throws AzureCmdException {
    Project project = findOpenProject(projectDescriptor);
    List<ArtifactDescriptor> artifactDescriptors = new ArrayList<ArtifactDescriptor>();
    for (Artifact artifact : ArtifactUtil.getArtifactWithOutputPaths(project)) {
        artifactDescriptors.add(new ArtifactDescriptor(artifact.getName(), artifact.getArtifactType().getId()));
    }
    return artifactDescriptors;
}

41. RolesConfigurable#buildConfigurables()

View license
@Override
protected Configurable[] buildConfigurables() {
    Project project = module.getProject();
    return new Configurable[] { new CachingPanel(module, waProjManager, windowsAzureRole), new CertificatesPanel(module, waProjManager, windowsAzureRole), new ComponentsPanel(project, waProjManager, windowsAzureRole), new DebuggingPanel(project, waProjManager, windowsAzureRole), new RoleEndpointsPanel(module, waProjManager, windowsAzureRole), new EnvVarsPanel(module, waProjManager, windowsAzureRole), new LoadBalancingPanel(waProjManager, windowsAzureRole), new LocalStoragePanel(module, waProjManager, windowsAzureRole), new ServerConfigurationConfigurable(module, waProjManager, windowsAzureRole), new SSLOffloadingPanel(module, waProjManager, windowsAzureRole) };
}

42. BuckBuildAction#executeOnPooledThread()

Project: buck
Source File: BuckBuildAction.java
View license
@Override
public void executeOnPooledThread(final AnActionEvent e) {
    Project project = e.getProject();
    BuckBuildManager buildManager = BuckBuildManager.getInstance(project);
    String target = buildManager.getCurrentSavedTarget(project);
    // Initiate a buck build
    BuckModule buckModule = project.getComponent(BuckModule.class);
    buckModule.attach(target);
    if (target == null) {
        buildManager.showNoTargetMessage(project);
        return;
    }
    BuckBuildCommandHandler handler = new BuckBuildCommandHandler(project, project.getBaseDir(), BuckCommand.BUILD);
    handler.command().addParameter(target);
    buildManager.runBuckCommandWhileConnectedToBuck(handler, ACTION_TITLE, buckModule);
}

43. BuckKillAction#executeOnPooledThread()

Project: buck
Source File: BuckKillAction.java
View license
@Override
public void executeOnPooledThread(final AnActionEvent e) {
    Project project = e.getProject();
    // stop the current running process
    BuckBuildManager.getInstance(project).getCurrentRunningBuckCommandHandler().stop();
    BuckModule buckModule = project.getComponent(BuckModule.class);
    // run the buck kill command
    BuckKillCommandHandler handler = new BuckKillCommandHandler(project, project.getBaseDir(), BuckCommand.KILL);
    BuckBuildManager.getInstance(project).runBuckCommandWhileConnectedToBuck(handler, ACTION_TITLE, buckModule);
}

44. BuckProjectGenerationAction#executeOnPooledThread()

View license
@Override
public void executeOnPooledThread(final AnActionEvent e) {
    Project project = e.getProject();
    BuckBuildManager buildManager = BuckBuildManager.getInstance(project);
    String target = buildManager.getCurrentSavedTarget(project);
    BuckModule buckModule = project.getComponent(BuckModule.class);
    buckModule.attach(target);
    if (target == null) {
        buildManager.showNoTargetMessage(project);
        return;
    }
    BuckBuildCommandHandler handler = new BuckBuildCommandHandler(project, project.getBaseDir(), BuckCommand.PROJECT);
    handler.command().addParameter(target);
    buildManager.runBuckCommandWhileConnectedToBuck(handler, ACTION_TITLE, buckModule);
}

45. BuckTestAction#executeOnPooledThread()

Project: buck
Source File: BuckTestAction.java
View license
@Override
public void executeOnPooledThread(final AnActionEvent e) {
    Project project = e.getProject();
    BuckBuildManager buildManager = BuckBuildManager.getInstance(project);
    String target = buildManager.getCurrentSavedTarget(project);
    BuckModule buckModule = project.getComponent(BuckModule.class);
    buckModule.attach(target);
    if (target == null) {
        buildManager.showNoTargetMessage(project);
        return;
    }
    // Initiate a buck test
    BuckBuildCommandHandler handler = new BuckBuildCommandHandler(project, project.getBaseDir(), BuckCommand.TEST);
    handler.command().addParameter(target);
    buildManager.runBuckCommandWhileConnectedToBuck(handler, ACTION_TITLE, buckModule);
}

46. BuckUninstallAction#executeOnPooledThread()

Project: buck
Source File: BuckUninstallAction.java
View license
@Override
public void executeOnPooledThread(final AnActionEvent e) {
    Project project = e.getProject();
    BuckBuildManager buildManager = BuckBuildManager.getInstance(project);
    String target = buildManager.getCurrentSavedTarget(project);
    BuckModule buckModule = project.getComponent(BuckModule.class);
    buckModule.attach(target);
    if (target == null) {
        buildManager.showNoTargetMessage(project);
        return;
    }
    // Initiate a buck uninstall
    BuckBuildCommandHandler handler = new BuckBuildCommandHandler(project, project.getBaseDir(), BuckCommand.UNINSTALL);
    handler.command().addParameter(target);
    buildManager.runBuckCommandWhileConnectedToBuck(handler, ACTION_TITLE, buckModule);
}

47. BuckClientTest#testConnectDisconnect()

Project: buck
Source File: BuckClientTest.java
View license
@Test
public void testConnectDisconnect() {
    Extensions.registerAreaClass("IDEA_PROJECT", null);
    MockDisposable mockDisposable = new MockDisposable();
    MockApplication application = new MockApplicationEx(mockDisposable);
    ApplicationManager.setApplication(application, mockDisposable);
    Project project = new MockProjectEx(new MockDisposable());
    TestBuckEventHandler handler = new TestBuckEventHandler();
    BuckSocket buckSocket = new BuckSocket(handler);
    BuckClient.getOrInstantiate(project, handler).setBuckSocket(buckSocket);
    BuckClient.getOrInstantiate(project, handler).connect();
    buckSocket.onConnect(new MockSession());
    BuckClient.getOrInstantiate(project, handler).disconnectWithoutRetry();
    buckSocket.onClose(0, "FOO");
    assertFalse(BuckClient.getOrInstantiate(project, handler).isConnected());
}

48. BuckClientTest#hasBuckDisconnectedThenWeReconnectIfSoSpecified()

Project: buck
Source File: BuckClientTest.java
View license
@Test
public void hasBuckDisconnectedThenWeReconnectIfSoSpecified() {
    Extensions.registerAreaClass("IDEA_PROJECT", null);
    MockDisposable mockDisposable = new MockDisposable();
    MockApplication application = new MockApplicationEx(mockDisposable);
    ApplicationManager.setApplication(application, mockDisposable);
    Project project = new MockProjectEx(new MockDisposable());
    TestBuckEventHandler handler = new TestBuckEventHandler();
    BuckSocket buckSocket = new BuckSocket(handler);
    BuckClient.getOrInstantiate(project, handler).setBuckSocket(buckSocket);
    BuckClient.getOrInstantiate(project, handler).connect();
    buckSocket.onConnect(new MockSession());
    BuckClient.getOrInstantiate(project, handler).disconnectWithRetry();
    buckSocket.onClose(0, "FOO");
    buckSocket.onConnect(new MockSession());
    assertTrue(BuckClient.getOrInstantiate(project, handler).isConnected());
}

49. BuckModuleTest#hasBuckModuleInitThenActionToolbarPopupShownOnce()

Project: buck
Source File: BuckModuleTest.java
View license
@Test
public void hasBuckModuleInitThenActionToolbarPopupShownOnce() {
    Project project = initBuckModule();
    Field field = BuckPluginNotifications.class.getDeclaredFields()[0];
    field.setAccessible(true);
    NotificationsAdapterTester notificationsAdapterTester = new NotificationsAdapterTester();
    project.getMessageBus().connect().subscribe(Notifications.TOPIC, notificationsAdapterTester);
    new BuckModule(project).projectOpened();
    try {
        String groupId = field.get(field.getType()).toString();
        assertTrue(PropertiesComponent.getInstance().isValueSet(groupId));
        new BuckModule(project);
        assertTrue(PropertiesComponent.getInstance().isValueSet(groupId));
        new BuckModule(project);
        assertTrue(PropertiesComponent.getInstance().isValueSet(groupId));
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    assertEquals(notificationsAdapterTester.countCalls, 1);
}

50. Close#actionPerformed()

Project: checkstyle-idea
Source File: Close.java
View license
@Override
public void actionPerformed(final AnActionEvent event) {
    final Project project = DataKeys.PROJECT.getData(event.getDataContext());
    if (project == null) {
        return;
    }
    final CheckStylePlugin checkStylePlugin = project.getComponent(CheckStylePlugin.class);
    if (checkStylePlugin == null) {
        throw new IllegalStateException("Couldn't get checkstyle plugin");
    }
    final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(CheckStyleToolWindowPanel.ID_TOOLWINDOW);
    toolWindow.hide(null);
}

51. CollapseAll#actionPerformed()

Project: checkstyle-idea
Source File: CollapseAll.java
View license
@Override
public void actionPerformed(final AnActionEvent event) {
    final Project project = DataKeys.PROJECT.getData(event.getDataContext());
    if (project == null) {
        return;
    }
    final CheckStylePlugin checkStylePlugin = project.getComponent(CheckStylePlugin.class);
    if (checkStylePlugin == null) {
        throw new IllegalStateException("Couldn't get checkstyle plugin");
    }
    final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(CheckStyleToolWindowPanel.ID_TOOLWINDOW);
    final Content content = toolWindow.getContentManager().getContent(0);
    if (content != null && content.getComponent() instanceof CheckStyleToolWindowPanel) {
        ((CheckStyleToolWindowPanel) content.getComponent()).collapseTree();
    }
}

52. DisplayErrors#isSelected()

Project: checkstyle-idea
Source File: DisplayErrors.java
View license
@Override
public boolean isSelected(final AnActionEvent event) {
    final Project project = DataKeys.PROJECT.getData(event.getDataContext());
    if (project == null) {
        return false;
    }
    final CheckStylePlugin checkStylePlugin = project.getComponent(CheckStylePlugin.class);
    if (checkStylePlugin == null) {
        throw new IllegalStateException("Couldn't get checkstyle plugin");
    }
    final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(CheckStyleToolWindowPanel.ID_TOOLWINDOW);
    final Content content = toolWindow.getContentManager().getContent(0);
    if (content != null && content.getComponent() instanceof CheckStyleToolWindowPanel) {
        return ((CheckStyleToolWindowPanel) content.getComponent()).isDisplayingErrors();
    }
    return false;
}

53. DisplayErrors#setSelected()

Project: checkstyle-idea
Source File: DisplayErrors.java
View license
@Override
public void setSelected(final AnActionEvent event, final boolean selected) {
    final Project project = DataKeys.PROJECT.getData(event.getDataContext());
    if (project == null) {
        return;
    }
    final CheckStylePlugin checkStylePlugin = project.getComponent(CheckStylePlugin.class);
    if (checkStylePlugin == null) {
        throw new IllegalStateException("Couldn't get checkstyle plugin");
    }
    final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(CheckStyleToolWindowPanel.ID_TOOLWINDOW);
    final Content content = toolWindow.getContentManager().getContent(0);
    if (content != null && content.getComponent() instanceof CheckStyleToolWindowPanel) {
        final CheckStyleToolWindowPanel panel = (CheckStyleToolWindowPanel) content.getComponent();
        panel.setDisplayingErrors(selected);
        panel.filterDisplayedResults();
    }
}

54. DisplayInfo#isSelected()

Project: checkstyle-idea
Source File: DisplayInfo.java
View license
@Override
public boolean isSelected(final AnActionEvent event) {
    final Project project = DataKeys.PROJECT.getData(event.getDataContext());
    if (project == null) {
        return false;
    }
    final CheckStylePlugin checkStylePlugin = project.getComponent(CheckStylePlugin.class);
    if (checkStylePlugin == null) {
        throw new IllegalStateException("Couldn't get checkstyle plugin");
    }
    final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(CheckStyleToolWindowPanel.ID_TOOLWINDOW);
    final Content content = toolWindow.getContentManager().getContent(0);
    if (content != null && content.getComponent() instanceof CheckStyleToolWindowPanel) {
        return ((CheckStyleToolWindowPanel) content.getComponent()).isDisplayingInfo();
    }
    return false;
}

55. DisplayInfo#setSelected()

Project: checkstyle-idea
Source File: DisplayInfo.java
View license
@Override
public void setSelected(final AnActionEvent event, final boolean selected) {
    final Project project = DataKeys.PROJECT.getData(event.getDataContext());
    if (project == null) {
        return;
    }
    final CheckStylePlugin checkStylePlugin = project.getComponent(CheckStylePlugin.class);
    if (checkStylePlugin == null) {
        throw new IllegalStateException("Couldn't get checkstyle plugin");
    }
    final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(CheckStyleToolWindowPanel.ID_TOOLWINDOW);
    final Content content = toolWindow.getContentManager().getContent(0);
    if (content != null && content.getComponent() instanceof CheckStyleToolWindowPanel) {
        final CheckStyleToolWindowPanel panel = (CheckStyleToolWindowPanel) content.getComponent();
        panel.setDisplayingInfo(selected);
        panel.filterDisplayedResults();
    }
}

56. DisplayWarnings#isSelected()

View license
@Override
public boolean isSelected(final AnActionEvent event) {
    final Project project = DataKeys.PROJECT.getData(event.getDataContext());
    if (project == null) {
        return false;
    }
    final CheckStylePlugin checkStylePlugin = project.getComponent(CheckStylePlugin.class);
    if (checkStylePlugin == null) {
        throw new IllegalStateException("Couldn't get checkstyle plugin");
    }
    final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(CheckStyleToolWindowPanel.ID_TOOLWINDOW);
    final Content content = toolWindow.getContentManager().getContent(0);
    if (content != null && content.getComponent() instanceof CheckStyleToolWindowPanel) {
        return ((CheckStyleToolWindowPanel) content.getComponent()).isDisplayingWarnings();
    }
    return false;
}

57. DisplayWarnings#setSelected()

View license
@Override
public void setSelected(final AnActionEvent event, final boolean selected) {
    final Project project = DataKeys.PROJECT.getData(event.getDataContext());
    if (project == null) {
        return;
    }
    final CheckStylePlugin checkStylePlugin = project.getComponent(CheckStylePlugin.class);
    if (checkStylePlugin == null) {
        throw new IllegalStateException("Couldn't get checkstyle plugin");
    }
    final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(CheckStyleToolWindowPanel.ID_TOOLWINDOW);
    final Content content = toolWindow.getContentManager().getContent(0);
    if (content != null && content.getComponent() instanceof CheckStyleToolWindowPanel) {
        final CheckStyleToolWindowPanel panel = (CheckStyleToolWindowPanel) content.getComponent();
        panel.setDisplayingWarnings(selected);
        panel.filterDisplayedResults();
    }
}

58. ExpandAll#actionPerformed()

Project: checkstyle-idea
Source File: ExpandAll.java
View license
@Override
public void actionPerformed(final AnActionEvent event) {
    final Project project = DataKeys.PROJECT.getData(event.getDataContext());
    if (project == null) {
        return;
    }
    final CheckStylePlugin checkStylePlugin = project.getComponent(CheckStylePlugin.class);
    if (checkStylePlugin == null) {
        throw new IllegalStateException("Couldn't get checkstyle plugin");
    }
    final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(CheckStyleToolWindowPanel.ID_TOOLWINDOW);
    final Content content = toolWindow.getContentManager().getContent(0);
    if (content != null && content.getComponent() instanceof CheckStyleToolWindowPanel) {
        ((CheckStyleToolWindowPanel) content.getComponent()).expandTree();
    }
}

59. ScrollToSource#isSelected()

Project: checkstyle-idea
Source File: ScrollToSource.java
View license
@Override
public boolean isSelected(final AnActionEvent event) {
    final Project project = DataKeys.PROJECT.getData(event.getDataContext());
    if (project == null) {
        return false;
    }
    final CheckStylePlugin checkStylePlugin = project.getComponent(CheckStylePlugin.class);
    if (checkStylePlugin == null) {
        throw new IllegalStateException("Couldn't get checkstyle plugin");
    }
    final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(CheckStyleToolWindowPanel.ID_TOOLWINDOW);
    final Content content = toolWindow.getContentManager().getContent(0);
    if (content != null && content.getComponent() instanceof CheckStyleToolWindowPanel) {
        return ((CheckStyleToolWindowPanel) content.getComponent()).isScrollToSource();
    }
    return false;
}

60. ScrollToSource#setSelected()

Project: checkstyle-idea
Source File: ScrollToSource.java
View license
@Override
public void setSelected(final AnActionEvent event, final boolean selected) {
    final Project project = DataKeys.PROJECT.getData(event.getDataContext());
    if (project == null) {
        return;
    }
    final CheckStylePlugin checkStylePlugin = project.getComponent(CheckStylePlugin.class);
    if (checkStylePlugin == null) {
        throw new IllegalStateException("Couldn't get checkstyle plugin");
    }
    final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(CheckStyleToolWindowPanel.ID_TOOLWINDOW);
    final Content content = toolWindow.getContentManager().getContent(0);
    if (content != null && content.getComponent() instanceof CheckStyleToolWindowPanel) {
        ((CheckStyleToolWindowPanel) content.getComponent()).setScrollToSource(selected);
    }
}

61. ScanFilesBeforeCheckinHandler#settings()

View license
private Optional<CheckStyleConfiguration> settings() {
    final Project project = checkinPanel.getProject();
    if (project == null) {
        LOG.error("Could not get project for check-in panel");
        return empty();
    }
    final CheckStylePlugin plugin = project.getComponent(CheckStylePlugin.class);
    if (plugin == null) {
        LOG.error("Could not get CheckStyle Plug-in, skipping");
        return empty();
    }
    return ofNullable(plugin.getConfiguration());
}

62. AnalysisScope#accept()

Project: consulo
Source File: AnalysisScope.java
View license
protected boolean accept(@NotNull final PsiDirectory dir, @NotNull final Processor<VirtualFile> processor) {
    final Project project = dir.getProject();
    final ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex();
    //we should analyze generated source files only if the action is explicitly invoked for a directory located under generated roots
    final boolean processGeneratedFiles = isInGeneratedSources(dir.getVirtualFile(), project);
    return VfsUtilCore.iterateChildrenRecursively(dir.getVirtualFile(), VirtualFileFilter.ALL, new ContentIterator() {

        @Override
        @SuppressWarnings({ "SimplifiableIfStatement" })
        public boolean processFile(@NotNull final VirtualFile fileOrDir) {
            if (!myIncludeTestSource && index.isInTestSourceContent(fileOrDir))
                return true;
            if (!processGeneratedFiles && isInGeneratedSources(fileOrDir, project))
                return true;
            if (!fileOrDir.isDirectory()) {
                return processor.process(fileOrDir);
            }
            return true;
        }
    });
}

63. LocalQuickFixOnPsiElement#isAvailable()

View license
protected boolean isAvailable() {
    if (myStartElement == null)
        return false;
    final PsiElement startElement = myStartElement.getElement();
    final PsiElement endElement = myEndElement == null ? startElement : myEndElement.getElement();
    PsiFile file = myStartElement.getContainingFile();
    Project project = myStartElement.getProject();
    return startElement != null && endElement != null && startElement.isValid() && (endElement == startElement || endElement.isValid()) && file != null && isAvailable(project, file, startElement, endElement);
}

64. GeneralHighlightingPass#reportErrorsToWolf()

View license
private void reportErrorsToWolf() {
    // e.g. errors in evaluate expression
    if (!getFile().getViewProvider().isPhysical())
        return;
    Project project = getFile().getProject();
    // do not report problems in libraries
    if (!PsiManager.getInstance(project).isInProject(getFile()))
        return;
    VirtualFile file = getFile().getVirtualFile();
    if (file == null)
        return;
    List<Problem> problems = convertToProblems(getInfos(), file, myHasErrorElement);
    WolfTheProblemSolver wolf = WolfTheProblemSolver.getInstance(project);
    boolean hasErrors = DaemonCodeAnalyzerEx.hasErrors(project, getDocument());
    if (!hasErrors || isWholeFileHighlighting()) {
        wolf.reportProblems(file, problems);
    } else {
        wolf.weHaveGotProblems(file, problems);
    }
}

65. ToolsImpl#getLevel()

Project: consulo
Source File: ToolsImpl.java
View license
public HighlightDisplayLevel getLevel(PsiElement element) {
    if (myTools == null || element == null)
        return myDefaultState.getLevel();
    final Project project = element.getProject();
    final DependencyValidationManager manager = DependencyValidationManager.getInstance(project);
    for (ScopeToolState state : myTools) {
        final NamedScope scope = state.getScope(project);
        final PackageSet set = scope != null ? scope.getValue() : null;
        if (set != null && set.contains(element.getContainingFile(), manager)) {
            return state.getLevel();
        }
    }
    return myDefaultState.getLevel();
}

66. ToolsImpl#isEnabled()

Project: consulo
Source File: ToolsImpl.java
View license
@Override
public boolean isEnabled(PsiElement element) {
    if (!myEnabled)
        return false;
    if (myTools == null || element == null)
        return myDefaultState.isEnabled();
    final Project project = element.getProject();
    final DependencyValidationManager manager = DependencyValidationManager.getInstance(project);
    for (ScopeToolState state : myTools) {
        final NamedScope scope = state.getScope(project);
        if (scope != null) {
            final PackageSet set = scope.getValue();
            if (set != null && set.contains(element.getContainingFile(), manager)) {
                return state.isEnabled();
            }
        }
    }
    return myDefaultState.isEnabled();
}

67. ToolsImpl#getEnabledTool()

Project: consulo
Source File: ToolsImpl.java
View license
@Override
@Nullable
public InspectionToolWrapper getEnabledTool(PsiElement element) {
    if (!myEnabled)
        return null;
    if (myTools == null || element == null) {
        return myDefaultState.isEnabled() ? myDefaultState.getTool() : null;
    }
    final Project project = element.getProject();
    final DependencyValidationManager manager = DependencyValidationManager.getInstance(project);
    for (ScopeToolState state : myTools) {
        final NamedScope scope = state.getScope(project);
        if (scope != null) {
            final PackageSet set = scope.getValue();
            if (set != null && set.contains(element.getContainingFile(), manager)) {
                return state.isEnabled() ? state.getTool() : null;
            }
        }
    }
    return myDefaultState.isEnabled() ? myDefaultState.getTool() : null;
}

68. ToolsImpl#disableTool()

Project: consulo
Source File: ToolsImpl.java
View license
public void disableTool(@NotNull PsiElement element) {
    final Project project = element.getProject();
    final DependencyValidationManager validationManager = DependencyValidationManager.getInstance(project);
    if (myTools != null) {
        for (ScopeToolState state : myTools) {
            final NamedScope scope = state.getScope(project);
            if (scope != null) {
                final PackageSet packageSet = scope.getValue();
                if (packageSet != null && packageSet.contains(element.getContainingFile(), validationManager)) {
                    state.setEnabled(false);
                    return;
                }
            }
        }
        myDefaultState.setEnabled(false);
    } else {
        myDefaultState.setEnabled(false);
        setEnabled(false);
    }
}

69. FileReferenceHelperRegistrar#getHelper()

View license
/**
   * @deprecated this method is broken, please avoid using it, use getHelpers() instead
   */
@Deprecated
public static <T extends PsiFileSystemItem> FileReferenceHelper getHelper(@NotNull final T psiFileSystemItem) {
    final VirtualFile file = psiFileSystemItem.getVirtualFile();
    if (file == null)
        return null;
    final Project project = psiFileSystemItem.getProject();
    return ContainerUtil.find(getHelpers(), new Condition<FileReferenceHelper>() {

        @Override
        public boolean value(final FileReferenceHelper fileReferenceHelper) {
            return fileReferenceHelper.isMine(project, file);
        }
    });
}

70. CompileActionBase#actionPerformed()

Project: consulo
Source File: CompileActionBase.java
View license
@RequiredDispatchThread
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    final DataContext dataContext = e.getDataContext();
    final Project project = e.getData(CommonDataKeys.PROJECT);
    if (project == null) {
        return;
    }
    Editor editor = e.getData(PlatformDataKeys.EDITOR);
    PsiFile file = e.getData(LangDataKeys.PSI_FILE);
    if (file != null && editor != null && !DumbService.getInstance(project).isDumb()) {
        //let autoimport complete
        DaemonCodeAnalyzer.getInstance(project).autoImportReferenceAtCursor(editor, file);
    }
    doAction(dataContext, project);
}

71. CompileActionBase#update()

Project: consulo
Source File: CompileActionBase.java
View license
@RequiredDispatchThread
@Override
public void update(@NotNull final AnActionEvent e) {
    super.update(e);
    final Project project = e.getData(CommonDataKeys.PROJECT);
    if (project == null) {
        e.getPresentation().setEnabled(false);
    } else {
        e.getPresentation().setEnabled(!CompilerManager.getInstance(project).isCompilationActive());
    }
}

72. ArtifactElementType#chooseAndCreate()

Project: consulo
Source File: ArtifactElementType.java
View license
@Override
@NotNull
public List<? extends ArtifactPackagingElement> chooseAndCreate(@NotNull ArtifactEditorContext context, @NotNull Artifact artifact, @NotNull CompositePackagingElement<?> parent) {
    final Project project = context.getProject();
    List<Artifact> artifacts = context.chooseArtifacts(getAvailableArtifacts(context, artifact, false), CompilerBundle.message("dialog.title.choose.artifacts"));
    final List<ArtifactPackagingElement> elements = new ArrayList<ArtifactPackagingElement>();
    for (Artifact selected : artifacts) {
        elements.add(new ArtifactPackagingElement(project, ArtifactPointerUtil.getPointerManager(project).create(selected, context.getArtifactModel())));
    }
    return elements;
}

73. PackageFileAction#update()

Project: consulo
Source File: PackageFileAction.java
View license
@Override
public void update(AnActionEvent e) {
    boolean visible = false;
    final Project project = e.getData(CommonDataKeys.PROJECT);
    if (project != null) {
        final List<VirtualFile> files = getFilesToPackage(e, project);
        if (!files.isEmpty()) {
            visible = true;
            e.getPresentation().setText(files.size() == 1 ? CompilerBundle.message("action.name.package.file") : CompilerBundle.message("action.name.package.files"));
        }
    }
    e.getPresentation().setVisible(visible);
}

74. PackageFileAction#actionPerformed()

Project: consulo
Source File: PackageFileAction.java
View license
@Override
public void actionPerformed(AnActionEvent event) {
    final Project project = event.getData(CommonDataKeys.PROJECT);
    if (project == null)
        return;
    FileDocumentManager.getInstance().saveAllDocuments();
    final List<VirtualFile> files = getFilesToPackage(event, project);
    Artifact[] allArtifacts = ArtifactManager.getInstance(project).getArtifacts();
    PackageFileWorker.startPackagingFiles(project, files, allArtifacts, new Runnable() {

        public void run() {
            setStatusText(project, files);
        }
    });
}

75. ASTDelegatePsiElement#getManager()

Project: consulo
Source File: ASTDelegatePsiElement.java
View license
@Override
public PsiManagerEx getManager() {
    Project project = ProjectCoreUtil.theOnlyOpenProject();
    if (project != null) {
        return PsiManagerEx.getInstanceEx(project);
    }
    PsiElement parent = this;
    while (parent instanceof ASTDelegatePsiElement) {
        parent = parent.getParent();
    }
    if (parent == null) {
        throw new PsiInvalidElementAccessException(this);
    }
    return (PsiManagerEx) parent.getManager();
}

76. PsiFileFactoryImpl#createElementFromText()

Project: consulo
Source File: PsiFileFactoryImpl.java
View license
@Nullable
public PsiElement createElementFromText(@Nullable final String text, @NotNull final Language language, @NotNull final LanguageVersion languageVersion, @NotNull final IElementType type, @Nullable final PsiElement context) {
    if (text == null)
        return null;
    final DummyHolder result = DummyHolderFactory.createHolder(myManager, language, context);
    final FileElement holder = result.getTreeElement();
    final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(language);
    if (parserDefinition == null) {
        throw new AssertionError("No parser definition for " + language);
    }
    final Project project = myManager.getProject();
    final Lexer lexer = parserDefinition.createLexer(project, languageVersion);
    final PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, holder, lexer, language, languageVersion, text);
    final ASTNode node = parserDefinition.createParser(project, languageVersion).parse(type, builder, languageVersion);
    holder.rawAddChildren((TreeElement) node);
    markGenerated(result);
    return node.getPsi();
}

77. SmartPsiFileRangePointerImpl#createElementInfo()

View license
@NotNull
private static SmartPointerElementInfo createElementInfo(@NotNull PsiFile containingFile, @NotNull ProperTextRange range, boolean forInjected) {
    Project project = containingFile.getProject();
    if (containingFile.getViewProvider() instanceof FreeThreadedFileViewProvider) {
        PsiLanguageInjectionHost host = InjectedLanguageManager.getInstance(project).getInjectionHost(containingFile);
        if (host != null) {
            SmartPsiElementPointer<PsiLanguageInjectionHost> hostPointer = SmartPointerManager.getInstance(project).createSmartPsiElementPointer(host);
            return new InjectedSelfElementInfo(project, containingFile, range, containingFile, hostPointer);
        }
    }
    if (range.equals(containingFile.getTextRange()))
        return new FileElementInfo(containingFile);
    return new SelfElementInfo(project, range, AnchorTypeInfo.obtainInfo(PsiElement.class, null, LanguageUtil.getRootLanguage(containingFile)), containingFile, forInjected);
}

78. CompositePsiElement#getProject()

Project: consulo
Source File: CompositePsiElement.java
View license
@Override
@NotNull
public Project getProject() {
    Project project = ProjectCoreUtil.theOnlyOpenProject();
    if (project != null) {
        return project;
    }
    final PsiManager manager = getManager();
    if (manager == null)
        throw new PsiInvalidElementAccessException(this);
    return manager.getProject();
}

79. LazyParseablePsiElement#getProject()

View license
@Override
@NotNull
public Project getProject() {
    Project project = ProjectCoreUtil.theOnlyOpenProject();
    if (project != null) {
        return project;
    }
    final PsiManager manager = getManager();
    if (manager == null)
        throw new PsiInvalidElementAccessException(this);
    return manager.getProject();
}

80. TreeElement#getManager()

Project: consulo
Source File: TreeElement.java
View license
public PsiManagerEx getManager() {
    Project project = ProjectCoreUtil.theOnlyOpenProject();
    if (project != null) {
        return PsiManagerEx.getInstanceEx(project);
    }
    TreeElement element;
    for (element = this; element.getTreeParent() != null; element = element.getTreeParent()) {
    }
    if (element instanceof FileElement) {
        //TODO!!
        return element.getManager();
    } else {
        if (getTreeParent() != null) {
            return getTreeParent().getManager();
        }
        return null;
    }
}

81. ILightStubFileElementType#parseContentsLight()

View license
public FlyweightCapableTreeStructure<LighterASTNode> parseContentsLight(final ASTNode chameleon) {
    final PsiElement psi = chameleon.getPsi();
    assert psi != null : "Bad chameleon: " + chameleon;
    final Project project = psi.getProject();
    final PsiBuilderFactory factory = PsiBuilderFactory.getInstance();
    final Language language = getLanguage();
    final LanguageVersion languageVersion = psi.getLanguageVersion();
    final PsiBuilder builder = factory.createBuilder(project, chameleon, languageVersion);
    final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(language);
    assert parserDefinition != null : this;
    final PsiParser parser = parserDefinition.createParser(project, languageVersion);
    parser.parse(this, builder, languageVersion);
    return builder.getLightTree();
}

82. FileContentImpl#createFileFromText()

Project: consulo
Source File: FileContentImpl.java
View license
public PsiFile createFileFromText(@NotNull CharSequence text) {
    Project project = getProject();
    if (project == null) {
        project = DefaultProjectFactory.getInstance().getDefaultProject();
    }
    final Language language = ((LanguageFileType) getFileTypeWithoutSubstitution()).getLanguage();
    final Language substitutedLanguage = LanguageSubstitutors.INSTANCE.substituteLanguage(language, getFile(), project);
    LanguageVersion<? extends Language> languageVersion = LanguageVersionResolvers.INSTANCE.forLanguage(substitutedLanguage).getLanguageVersion(substitutedLanguage, project, getFile());
    return PsiFileFactory.getInstance(project).createFileFromText(getFileName(), languageVersion, text, false, false, true);
}

83. GenerateCoverageReportAction#actionPerformed()

View license
public void actionPerformed(final AnActionEvent e) {
    final DataContext dataContext = e.getDataContext();
    final Project project = CommonDataKeys.PROJECT.getData(dataContext);
    assert project != null;
    final CoverageDataManager coverageDataManager = CoverageDataManager.getInstance(project);
    final CoverageSuitesBundle currentSuite = coverageDataManager.getCurrentSuitesBundle();
    final CoverageEngine coverageEngine = currentSuite.getCoverageEngine();
    final ExportToHTMLDialog dialog = coverageEngine.createGenerateReportDialog(project, dataContext, currentSuite);
    dialog.reset();
    dialog.show();
    if (!dialog.isOK())
        return;
    dialog.apply();
    coverageEngine.generateReport(project, dataContext, currentSuite);
}

84. GenerateCoverageReportAction#update()

View license
public void update(final AnActionEvent e) {
    final DataContext dataContext = e.getDataContext();
    final Presentation presentation = e.getPresentation();
    presentation.setEnabled(false);
    presentation.setVisible(false);
    final Project project = CommonDataKeys.PROJECT.getData(dataContext);
    if (project != null) {
        final CoverageSuitesBundle currentSuite = CoverageDataManager.getInstance(project).getCurrentSuitesBundle();
        if (currentSuite != null) {
            final CoverageEngine coverageEngine = currentSuite.getCoverageEngine();
            if (coverageEngine.isReportGenerationAvailable(project, dataContext, currentSuite)) {
                presentation.setEnabled(true);
                presentation.setVisible(true);
            }
        }
    }
}

85. HideCoverageInfoAction#update()

Project: consulo
Source File: HideCoverageInfoAction.java
View license
@Override
public void update(AnActionEvent e) {
    final Presentation presentation = e.getPresentation();
    presentation.setEnabled(false);
    presentation.setVisible(ActionPlaces.isToolbarPlace(e.getPlace()));
    final Project project = e.getData(CommonDataKeys.PROJECT);
    if (project != null) {
        final CoverageSuitesBundle suitesBundle = CoverageDataManager.getInstance(project).getCurrentSuitesBundle();
        presentation.setEnabled(suitesBundle != null);
        presentation.setVisible(suitesBundle != null);
    }
}

86. CoverageLineMarkerRenderer#getReport()

View license
private String getReport(final Editor editor, final int lineNumber) {
    final LineData lineData = getLineData(lineNumber);
    final Document document = editor.getDocument();
    final Project project = editor.getProject();
    assert project != null;
    final PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(document);
    assert psiFile != null;
    final int lineStartOffset = document.getLineStartOffset(lineNumber);
    final int lineEndOffset = document.getLineEndOffset(lineNumber);
    return myCoverageSuite.getCoverageEngine().generateBriefReport(editor, psiFile, lineNumber, lineStartOffset, lineEndOffset, lineData);
}

87. CompareClipboardWithSelectionAction#getEditor()

View license
@Nullable
private static Editor getEditor(@NotNull AnActionEvent e) {
    Project project = e.getProject();
    if (project == null)
        return null;
    Editor editor = e.getData(CommonDataKeys.EDITOR);
    if (editor != null)
        return editor;
    editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
    if (editor != null)
        return editor;
    return null;
}

88. CompareClipboardWithSelectionAction#getDiffRequest()

View license
@Nullable
@Override
protected DiffRequest getDiffRequest(@NotNull AnActionEvent e) {
    Project project = e.getRequiredData(CommonDataKeys.PROJECT);
    Editor editor = getEditor(e);
    FileType editorFileType = getEditorFileType(e);
    assert editor != null;
    DocumentContent content2 = createContent(project, editor, editorFileType);
    DocumentContent content1 = DiffContentFactory.getInstance().createClipboardContent(content2);
    String title1 = DiffBundle.message("diff.content.clipboard.content.title");
    String title2 = createContentTitle(editor);
    String title = DiffBundle.message("diff.clipboard.vs.editor.dialog.title");
    SimpleDiffRequest request = new SimpleDiffRequest(title, content1, content2, title1, title2);
    if (editor.isViewer()) {
        request.putUserData(DiffUserDataKeys.FORCE_READ_ONLY_CONTENTS, new boolean[] { false, true });
    }
    return request;
}

89. CompareFilesAction#getDiffRequest()

Project: consulo
Source File: CompareFilesAction.java
View license
@Nullable
@Override
protected DiffRequest getDiffRequest(@NotNull AnActionEvent e) {
    Project project = e.getProject();
    DiffRequest diffRequest = e.getData(DIFF_REQUEST);
    if (diffRequest != null) {
        return diffRequest;
    }
    VirtualFile[] data = e.getRequiredData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
    if (data.length == 1) {
        VirtualFile otherFile = getOtherFile(project, data[0]);
        if (otherFile == null)
            return null;
        if (!data[0].isValid())
            return null;
        return DiffRequestFactory.getInstance().createFromFiles(project, data[0], otherFile);
    } else {
        return DiffRequestFactory.getInstance().createFromFiles(project, data[0], data[1]);
    }
}

90. CompareFileWithEditorAction#getDiffRequest()

View license
@Nullable
@Override
protected DiffRequest getDiffRequest(@NotNull AnActionEvent e) {
    Project project = e.getProject();
    VirtualFile selectedFile = getSelectedFile(e);
    VirtualFile currentFile = getEditingFile(e);
    assert selectedFile != null && currentFile != null;
    ContentDiffRequest request = DiffRequestFactory.getInstance().createFromFiles(project, selectedFile, currentFile);
    DiffContent editorContent = request.getContents().get(1);
    if (editorContent instanceof DocumentContent) {
        Editor[] editors = EditorFactory.getInstance().getEditors(((DocumentContent) editorContent).getDocument());
        if (editors.length != 0) {
            request.putUserData(DiffUserDataKeys.SCROLL_TO_LINE, Pair.create(Side.RIGHT, editors[0].getCaretModel().getLogicalPosition().line));
        }
    }
    return request;
}

91. OpenInEditorWithMouseAction#actionPerformed()

View license
@RequiredDispatchThread
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    MouseEvent inputEvent = (MouseEvent) e.getInputEvent();
    OpenInEditorAction openInEditorAction = e.getRequiredData(OpenInEditorAction.KEY);
    Project project = e.getRequiredData(CommonDataKeys.PROJECT);
    Component component = inputEvent.getComponent();
    Point point = inputEvent.getPoint();
    Component componentAt = SwingUtilities.getDeepestComponentAt(component, point.x, point.y);
    MouseEvent convertedEvent = SwingUtilities.convertMouseEvent(inputEvent.getComponent(), inputEvent, componentAt);
    Editor editor = getEditor(componentAt);
    assert editor != null;
    int line = editor.xyToLogicalPosition(convertedEvent.getPoint()).line;
    OpenFileDescriptor descriptor = getDescriptor(editor, line);
    if (descriptor == null)
        return;
    openInEditorAction.openEditor(project, descriptor);
}

92. DirDiffPanel#getOpenFileDescriptor()

Project: consulo
Source File: DirDiffPanel.java
View license
@Nullable
private OpenFileDescriptor getOpenFileDescriptor() {
    Project project = myModel.getProject();
    List<DirDiffElementImpl> elements = myModel.getSelectedElements();
    if (elements.isEmpty())
        return null;
    DirDiffElement element = elements.get(0);
    DiffElement source = element.getSource();
    DiffElement target = element.getTarget();
    OpenFileDescriptor descriptor1 = source != null ? source.getOpenFileDescriptor(project) : null;
    OpenFileDescriptor descriptor2 = target != null ? target.getOpenFileDescriptor(project) : null;
    return descriptor2 != null ? descriptor2 : descriptor1;
}

93. DirDiffPanel#getOpenFileDescriptorsArray()

Project: consulo
Source File: DirDiffPanel.java
View license
@Nullable
private OpenFileDescriptor[] getOpenFileDescriptorsArray() {
    Project project = myModel.getProject();
    List<DirDiffElementImpl> elements = myModel.getSelectedElements();
    List<OpenFileDescriptor> descriptors = new ArrayList<OpenFileDescriptor>();
    for (DirDiffElementImpl element : elements) {
        DiffElement source = element.getSource();
        DiffElement target = element.getTarget();
        OpenFileDescriptor descriptor1 = source != null ? source.getOpenFileDescriptor(project) : null;
        OpenFileDescriptor descriptor2 = target != null ? target.getOpenFileDescriptor(project) : null;
        if (descriptor1 != null)
            descriptors.add(descriptor1);
        if (descriptor2 != null)
            descriptors.add(descriptor2);
    }
    return ContainerUtil.toArray(descriptors, new OpenFileDescriptor[descriptors.size()]);
}

94. VcsCherryPickAction#update()

Project: consulo
Source File: VcsCherryPickAction.java
View license
@Override
public void update(@NotNull AnActionEvent e) {
    super.update(e);
    e.getPresentation().setVisible(true);
    final VcsLog log = e.getData(VcsLogDataKeys.VCS_LOG);
    Project project = getEventProject(e);
    final List<VcsCherryPicker> cherryPickers = getActiveCherryPickersForProject(project);
    if (log == null || cherryPickers.isEmpty()) {
        e.getPresentation().setEnabledAndVisible(false);
        return;
    }
    final List<VcsFullCommitDetails> details = log.getSelectedDetails();
    VcsCherryPicker enabledCherryPicker = ContainerUtil.find(cherryPickers, new Condition<VcsCherryPicker>() {

        @Override
        public boolean value(VcsCherryPicker picker) {
            //all commits should be from one vcs, if not then all pickers should return false
            return picker.isEnabled(log, details);
        }
    });
    e.getPresentation().setEnabled(enabledCherryPicker != null);
    e.getPresentation().setText(enabledCherryPicker == null ? concatActionNamesForAllAvailable(cherryPickers) : enabledCherryPicker.getActionTitle());
}

95. DvcsStatusWidget#update()

Project: consulo
Source File: DvcsStatusWidget.java
View license
@RequiredDispatchThread
private void update() {
    myText = null;
    myTooltip = null;
    Project project = getProject();
    if (project == null || project.isDisposed())
        return;
    T repository = guessCurrentRepository(project);
    if (repository == null)
        return;
    // -1, because there are arrows indicating that it is a popup
    int maxLength = MAX_STRING.length() - 1;
    myText = StringUtil.shortenTextWithEllipsis(getFullBranchName(repository), maxLength, 5);
    myTooltip = getToolTip(project);
    if (myStatusBar != null) {
        myStatusBar.updateWidget(ID());
    }
    rememberRecentRoot(repository.getRoot().getPath());
}

96. VcsLogAction#update()

Project: consulo
Source File: VcsLogAction.java
View license
@Override
public void update(@NotNull AnActionEvent e) {
    Project project = e.getProject();
    VcsLog log = e.getData(VcsLogDataKeys.VCS_LOG);
    if (project == null || log == null) {
        e.getPresentation().setEnabledAndVisible(false);
        return;
    }
    List<VcsFullCommitDetails> details = log.getSelectedDetails();
    MultiMap<Repo, VcsFullCommitDetails> grouped = groupByRootWithCheck(project, details);
    if (grouped == null) {
        e.getPresentation().setEnabledAndVisible(false);
    } else {
        e.getPresentation().setVisible(isVisible(project, grouped));
        e.getPresentation().setEnabled(!grouped.isEmpty() && isEnabled(grouped));
    }
}

97. OpenExternalConfigAction#actionPerformed()

View license
@Override
public void actionPerformed(AnActionEvent e) {
    Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
    if (project == null) {
        return;
    }
    VirtualFile configFile = getExternalConfig(e.getDataContext());
    if (configFile == null) {
        return;
    }
    OpenFileDescriptor descriptor = new OpenFileDescriptor(project, configFile);
    FileEditorManager.getInstance(project).openTextEditor(descriptor, true);
}

98. RefreshAllExternalProjectsAction#actionPerformed()

View license
@Override
public void actionPerformed(AnActionEvent e) {
    final Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
    if (project == null) {
        e.getPresentation().setEnabled(false);
        return;
    }
    final List<ProjectSystemId> systemIds = getSystemIds(e);
    if (systemIds.isEmpty()) {
        e.getPresentation().setEnabled(false);
        return;
    }
    // We save all documents because there is a possible case that there is an external system config file changed inside the ide.
    FileDocumentManager.getInstance().saveAllDocuments();
    for (ProjectSystemId externalSystemId : systemIds) {
        ExternalSystemUtil.refreshProjects(project, externalSystemId, true);
    }
}

99. ExternalSystemResolveProjectTask#doExecute()

View license
@SuppressWarnings("unchecked")
protected void doExecute() throws Exception {
    final ExternalSystemFacadeManager manager = ServiceManager.getService(ExternalSystemFacadeManager.class);
    Project ideProject = getIdeProject();
    RemoteExternalSystemProjectResolver resolver = manager.getFacade(ideProject, myProjectPath, getExternalSystemId()).getResolver();
    ExternalSystemExecutionSettings settings = ExternalSystemApiUtil.getExecutionSettings(ideProject, myProjectPath, getExternalSystemId());
    DataNode<ProjectData> project = resolver.resolveProjectInfo(getId(), myProjectPath, myIsPreviewMode, settings);
    if (project == null) {
        return;
    }
    myExternalProject.set(project);
}

100. CreateElementActionBase#actionPerformed()

View license
@RequiredDispatchThread
@Override
public final void actionPerformed(@NotNull final AnActionEvent e) {
    final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
    if (view == null) {
        return;
    }
    final Project project = e.getProject();
    final PsiDirectory dir = view.getOrChooseDirectory();
    if (dir == null)
        return;
    final PsiElement[] createdElements = invokeDialog(project, dir);
    for (PsiElement createdElement : createdElements) {
        view.selectElement(createdElement);
    }
}