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);
}
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;
}
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);
}
}
}
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));
}
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()));
}
Aggregations