Search in sources :

Example 11 with SourceProvider

use of com.android.builder.model.SourceProvider in project android by JetBrains.

the class ConfigureTemplateParametersStep method validateAllParameters.

@Nullable
private String validateAllParameters() {
    String message = null;
    Collection<Parameter> parameters = getModel().getTemplateHandle().getMetadata().getParameters();
    Module module = myFacet == null ? null : myFacet.getModule();
    Project project = getModel().getProject().getValueOrNull();
    SourceProvider sourceProvider = getModel().getSourceSet().get().toSourceProvider();
    for (Parameter parameter : parameters) {
        ObservableValue<?> property = myParameterRows.get(parameter).getProperty();
        if (property == null) {
            continue;
        }
        Set<Object> relatedValues = getRelatedValues(parameter);
        message = parameter.validate(project, module, sourceProvider, myPackageName.get(), property.get(), relatedValues);
        if (message != null) {
            break;
        }
    }
    return message;
}
Also used : Project(com.intellij.openapi.project.Project) SourceProvider(com.android.builder.model.SourceProvider) Module(com.intellij.openapi.module.Module) Nullable(org.jetbrains.annotations.Nullable)

Example 12 with SourceProvider

use of com.android.builder.model.SourceProvider in project android by JetBrains.

the class LintIdeUtils method getResourceDirectories.

/** Returns the resource directories to use for the given module */
@NotNull
public static List<File> getResourceDirectories(@NotNull AndroidFacet facet) {
    if (facet.requiresAndroidModel()) {
        AndroidModel androidModel = facet.getAndroidModel();
        if (androidModel != null) {
            List<File> resDirectories = new ArrayList<File>();
            List<SourceProvider> sourceProviders = androidModel.getActiveSourceProviders();
            for (SourceProvider provider : sourceProviders) {
                for (File file : provider.getResDirectories()) {
                    if (file.isDirectory()) {
                        resDirectories.add(file);
                    }
                }
            }
            return resDirectories;
        }
    }
    return new ArrayList<File>(facet.getMainSourceProvider().getResDirectories());
}
Also used : AndroidModel(com.android.tools.idea.model.AndroidModel) ArrayList(java.util.ArrayList) SourceProvider(com.android.builder.model.SourceProvider) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Example 13 with SourceProvider

use of com.android.builder.model.SourceProvider in project android by JetBrains.

the class CreateResourceDialogUtils method updateSourceSetCombo.

public static void updateSourceSetCombo(@NotNull JComponent label, @NotNull JComboBox combo, @Nullable AndroidFacet facet) {
    // we're in here, so we default to always including the source set combo (if it's a Gradle project that is.)
    if (facet != null && facet.requiresAndroidModel() && facet.getAndroidModel() != null) {
        List<SourceProvider> providers = IdeaSourceProvider.getAllSourceProviders(facet);
        DefaultComboBoxModel model = new DefaultComboBoxModel();
        for (SourceProvider sourceProvider : providers) {
            //noinspection unchecked
            model.addElement(new ApiComboBoxItem(sourceProvider, sourceProvider.getName(), 0, 0));
        }
        combo.setModel(model);
        label.setVisible(true);
        combo.setVisible(true);
    } else {
        label.setVisible(false);
        combo.setVisible(false);
    }
}
Also used : SourceProvider(com.android.builder.model.SourceProvider) IdeaSourceProvider(org.jetbrains.android.facet.IdeaSourceProvider) ApiComboBoxItem(com.android.tools.idea.ui.ApiComboBoxItem)

Example 14 with SourceProvider

use of com.android.builder.model.SourceProvider in project android by JetBrains.

the class AddAndroidActivityPath method init.

@Override
protected void init() {
    Module module = getModule();
    assert module != null;
    AndroidFacet facet = AndroidFacet.getInstance(module);
    assert facet != null;
    AndroidPlatform platform = AndroidPlatform.getInstance(module);
    if (platform != null) {
        myState.put(KEY_BUILD_SDK, platform.getTarget().getVersion().getFeatureLevel());
    }
    AndroidModuleInfo moduleInfo = AndroidModuleInfo.get(facet);
    AndroidVersion minSdkVersion = moduleInfo.getMinSdkVersion();
    myState.put(KEY_MIN_SDK, minSdkVersion);
    myState.put(KEY_TARGET_API, moduleInfo.getTargetSdkVersion());
    myState.put(KEY_PACKAGE_NAME, getInitialPackageName(module, facet));
    myState.put(KEY_OPEN_EDITORS, true);
    if (myTemplate == null) {
        FormFactor formFactor = getFormFactor(myTargetFolder);
        myState.put(FormFactorUtils.getMinApiLevelKey(formFactor), minSdkVersion.getApiLevel());
        myState.put(FormFactorUtils.getBuildApiLevelKey(formFactor), moduleInfo.getTargetSdkVersion().getApiLevel());
        ActivityGalleryStep galleryStep = new ActivityGalleryStep(formFactor, false, KEY_SELECTED_TEMPLATE, module, myParentDisposable);
        addStep(galleryStep);
    } else {
        TemplateMetadata templateMetadata = TemplateManager.getInstance().getTemplateMetadata(myTemplate);
        assert templateMetadata != null;
        myState.put(KEY_SELECTED_TEMPLATE, new TemplateEntry(myTemplate, templateMetadata));
    }
    SourceProvider[] sourceProviders = getSourceProviders(module, myTargetFolder);
    boolean isInstantAppModule = facet.getProjectType() == PROJECT_TYPE_ATOM;
    myState.put(IS_INSTANT_APP_KEY, isInstantAppModule);
    myParameterStep = new TemplateParameterStep2(getFormFactor(myTargetFolder), ImmutableMap.of(), myParentDisposable, KEY_PACKAGE_NAME, sourceProviders, CUSTOMIZE_ACTIVITY_TITLE);
    myAssetStudioStep = new IconStep(KEY_SELECTED_TEMPLATE, KEY_SOURCE_PROVIDER, myParentDisposable);
    addStep(myParameterStep);
    addStep(myAssetStudioStep);
}
Also used : IdeaSourceProvider(org.jetbrains.android.facet.IdeaSourceProvider) SourceProvider(com.android.builder.model.SourceProvider) AndroidPlatform(org.jetbrains.android.sdk.AndroidPlatform) AndroidVersion(com.android.sdklib.AndroidVersion) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) AndroidModuleInfo(com.android.tools.idea.model.AndroidModuleInfo) Module(com.intellij.openapi.module.Module) TemplateMetadata(com.android.tools.idea.templates.TemplateMetadata)

Example 15 with SourceProvider

use of com.android.builder.model.SourceProvider in project android by JetBrains.

the class TestArtifactSearchScopes method getSourceScope.

@NotNull
private FileRootSearchScope getSourceScope(@NotNull String artifactName) {
    Set<File> roots = Collections.emptySet();
    AndroidModuleModel androidModel = getAndroidModel();
    if (androidModel != null) {
        roots = new HashSet<>();
        // TODO consider generated source
        for (SourceProvider sourceProvider : androidModel.getTestSourceProviders(artifactName)) {
            roots.addAll(getAllSourceFolders(sourceProvider));
        }
    }
    return new FileRootSearchScope(myModule.getProject(), roots);
}
Also used : AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) SourceProvider(com.android.builder.model.SourceProvider) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

SourceProvider (com.android.builder.model.SourceProvider)15 File (java.io.File)9 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 IdeaSourceProvider (org.jetbrains.android.facet.IdeaSourceProvider)4 AndroidModel (com.android.tools.idea.model.AndroidModel)3 Module (com.intellij.openapi.module.Module)3 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)3 NotNull (org.jetbrains.annotations.NotNull)3 AndroidVersion (com.android.sdklib.AndroidVersion)2 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)2 AndroidModuleInfo (com.android.tools.idea.model.AndroidModuleInfo)2 ApiComboBoxItem (com.android.tools.idea.ui.ApiComboBoxItem)2 Project (com.intellij.openapi.project.Project)2 ArrayList (java.util.ArrayList)2 AndroidPlatform (org.jetbrains.android.sdk.AndroidPlatform)2 ConfigureInstantModuleStep (com.android.tools.idea.npw.instantapp.ConfigureInstantModuleStep)1 TemplateMetadata (com.android.tools.idea.templates.TemplateMetadata)1 ModuleInfo (com.taobao.android.builder.tasks.awo.projectstrucure.ModuleInfo)1 Nullable (org.jetbrains.annotations.Nullable)1 JpsAndroidModuleProperties (org.jetbrains.jps.android.model.impl.JpsAndroidModuleProperties)1