Search in sources :

Example 1 with ProjectSettingsService

use of com.intellij.openapi.roots.ui.configuration.ProjectSettingsService in project intellij-community by JetBrains.

the class BuildArtifactAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final Project project = getEventProject(e);
    if (project == null)
        return;
    final List<Artifact> artifacts = ArtifactUtil.getArtifactWithOutputPaths(project);
    if (artifacts.isEmpty())
        return;
    List<ArtifactPopupItem> items = new ArrayList<>();
    if (artifacts.size() > 1) {
        items.add(0, new ArtifactPopupItem(null, "All Artifacts", EmptyIcon.ICON_16));
    }
    Set<Artifact> selectedArtifacts = new HashSet<>(ArtifactsWorkspaceSettings.getInstance(project).getArtifactsToBuild());
    TIntArrayList selectedIndices = new TIntArrayList();
    if (Comparing.haveEqualElements(artifacts, selectedArtifacts) && selectedArtifacts.size() > 1) {
        selectedIndices.add(0);
        selectedArtifacts.clear();
    }
    for (Artifact artifact : artifacts) {
        final ArtifactPopupItem item = new ArtifactPopupItem(artifact, artifact.getName(), artifact.getArtifactType().getIcon());
        if (selectedArtifacts.contains(artifact)) {
            selectedIndices.add(items.size());
        }
        items.add(item);
    }
    final ProjectSettingsService projectSettingsService = ProjectSettingsService.getInstance(project);
    final ArtifactAwareProjectSettingsService settingsService = projectSettingsService instanceof ArtifactAwareProjectSettingsService ? (ArtifactAwareProjectSettingsService) projectSettingsService : null;
    final ChooseArtifactStep step = new ChooseArtifactStep(items, artifacts.get(0), project, settingsService);
    step.setDefaultOptionIndices(selectedIndices.toNativeArray());
    final ListPopupImpl popup = (ListPopupImpl) JBPopupFactory.getInstance().createListPopup(step);
    final KeyStroke editKeyStroke = KeymapUtil.getKeyStroke(CommonShortcuts.getEditSource());
    if (settingsService != null && editKeyStroke != null) {
        popup.registerAction("editArtifact", editKeyStroke, new AbstractAction() {

            @Override
            public void actionPerformed(ActionEvent e) {
                Object[] values = popup.getSelectedValues();
                popup.cancel();
                settingsService.openArtifactSettings(values.length > 0 ? ((ArtifactPopupItem) values[0]).getArtifact() : null);
            }
        });
    }
    popup.showCenteredInCurrentWindow(project);
}
Also used : ActionEvent(java.awt.event.ActionEvent) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) TIntArrayList(gnu.trove.TIntArrayList) Artifact(com.intellij.packaging.artifacts.Artifact) TIntArrayList(gnu.trove.TIntArrayList) Project(com.intellij.openapi.project.Project) ListPopupImpl(com.intellij.ui.popup.list.ListPopupImpl) ProjectSettingsService(com.intellij.openapi.roots.ui.configuration.ProjectSettingsService)

Example 2 with ProjectSettingsService

use of com.intellij.openapi.roots.ui.configuration.ProjectSettingsService in project android by JetBrains.

the class RenderService method getPlatform.

@Nullable
private static AndroidPlatform getPlatform(@NotNull final Module module, @Nullable RenderLogger logger) {
    AndroidPlatform platform = AndroidPlatform.getInstance(module);
    if (platform == null && logger != null) {
        if (!AndroidMavenUtil.isMavenizedModule(module)) {
            RenderProblem.Html message = RenderProblem.create(ERROR);
            logger.addMessage(message);
            message.getHtmlBuilder().addLink("No Android SDK found. Please ", "configure", " an Android SDK.", logger.getLinkManager().createRunnableLink(() -> {
                Project project = module.getProject();
                ProjectSettingsService service = ProjectSettingsService.getInstance(project);
                if (AndroidProjectInfo.getInstance(project).requiresAndroidModel() && service instanceof AndroidProjectSettingsService) {
                    ((AndroidProjectSettingsService) service).openSdkSettings();
                    return;
                }
                AndroidSdkUtils.openModuleDependenciesConfigurable(module);
            }));
        } else {
            String message = AndroidBundle.message("android.maven.cannot.parse.android.sdk.error", module.getName());
            logger.addMessage(RenderProblem.createPlain(ERROR, message));
        }
    }
    return platform;
}
Also used : Project(com.intellij.openapi.project.Project) AndroidProjectSettingsService(com.android.tools.idea.gradle.structure.editors.AndroidProjectSettingsService) ProjectSettingsService(com.intellij.openapi.roots.ui.configuration.ProjectSettingsService) AndroidPlatform(org.jetbrains.android.sdk.AndroidPlatform) AndroidProjectSettingsService(com.android.tools.idea.gradle.structure.editors.AndroidProjectSettingsService) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with ProjectSettingsService

use of com.intellij.openapi.roots.ui.configuration.ProjectSettingsService in project intellij-community by JetBrains.

the class PsiDirectoryNode method navigate.

@Override
public void navigate(final boolean requestFocus) {
    Module module = ModuleUtil.findModuleForPsiElement(getValue());
    if (module != null) {
        final VirtualFile file = getVirtualFile();
        final Project project = getProject();
        ProjectSettingsService service = ProjectSettingsService.getInstance(myProject);
        if (ProjectRootsUtil.isModuleContentRoot(file, project)) {
            service.openModuleSettings(module);
        } else if (ProjectRootsUtil.isLibraryRoot(file, project)) {
            final OrderEntry orderEntry = LibraryUtil.findLibraryEntry(file, module.getProject());
            if (orderEntry != null) {
                service.openLibraryOrSdkSettings(orderEntry);
            }
        } else {
            service.openContentEntriesSettings(module);
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) OrderEntry(com.intellij.openapi.roots.OrderEntry) ProjectSettingsService(com.intellij.openapi.roots.ui.configuration.ProjectSettingsService) Module(com.intellij.openapi.module.Module)

Example 4 with ProjectSettingsService

use of com.intellij.openapi.roots.ui.configuration.ProjectSettingsService in project android by JetBrains.

the class GradleApkProvider method validate.

@NotNull
@Override
public List<ValidationError> validate() {
    AndroidModuleModel androidModuleModel = AndroidModuleModel.get(myFacet);
    // This is a Gradle project, there must be an AndroidGradleModel.
    assert androidModuleModel != null;
    if (androidModuleModel.getMainArtifact().isSigned()) {
        return ImmutableList.of();
    }
    AndroidArtifactOutput output = GradleUtil.getOutput(androidModuleModel.getMainArtifact());
    final String message = AndroidBundle.message("run.error.apk.not.signed", output.getMainOutputFile().getOutputFile().getName(), androidModuleModel.getSelectedVariant().getDisplayName());
    Runnable quickFix = new Runnable() {

        @Override
        public void run() {
            Module module = myFacet.getModule();
            ProjectSettingsService service = ProjectSettingsService.getInstance(module.getProject());
            if (service instanceof AndroidProjectSettingsService) {
                ((AndroidProjectSettingsService) service).openSigningConfiguration(module);
            } else {
                service.openModuleSettings(module);
            }
        }
    };
    return ImmutableList.of(ValidationError.fatal(message, quickFix));
}
Also used : AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) AndroidProjectSettingsService(com.android.tools.idea.gradle.structure.editors.AndroidProjectSettingsService) ProjectSettingsService(com.intellij.openapi.roots.ui.configuration.ProjectSettingsService) AndroidProjectSettingsService(com.android.tools.idea.gradle.structure.editors.AndroidProjectSettingsService) AndroidArtifactOutput(com.android.builder.model.AndroidArtifactOutput) Module(com.intellij.openapi.module.Module) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with ProjectSettingsService

use of com.intellij.openapi.roots.ui.configuration.ProjectSettingsService in project intellij-community by JetBrains.

the class PsiDirectoryNode method canNavigate.

@Override
public boolean canNavigate() {
    VirtualFile file = getVirtualFile();
    Project project = getProject();
    ProjectSettingsService service = ProjectSettingsService.getInstance(myProject);
    return file != null && ((ProjectRootsUtil.isModuleContentRoot(file, project) && service.canOpenModuleSettings()) || (ProjectRootsUtil.isModuleSourceRoot(file, project) && service.canOpenContentEntriesSettings()) || (ProjectRootsUtil.isLibraryRoot(file, project) && service.canOpenModuleLibrarySettings()));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) ProjectSettingsService(com.intellij.openapi.roots.ui.configuration.ProjectSettingsService)

Aggregations

ProjectSettingsService (com.intellij.openapi.roots.ui.configuration.ProjectSettingsService)5 Project (com.intellij.openapi.project.Project)4 AndroidProjectSettingsService (com.android.tools.idea.gradle.structure.editors.AndroidProjectSettingsService)2 Module (com.intellij.openapi.module.Module)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 AndroidArtifactOutput (com.android.builder.model.AndroidArtifactOutput)1 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 OrderEntry (com.intellij.openapi.roots.OrderEntry)1 Artifact (com.intellij.packaging.artifacts.Artifact)1 ListPopupImpl (com.intellij.ui.popup.list.ListPopupImpl)1 TIntArrayList (gnu.trove.TIntArrayList)1 ActionEvent (java.awt.event.ActionEvent)1 AndroidPlatform (org.jetbrains.android.sdk.AndroidPlatform)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1