Java Code Examples for org.jetbrains.android.facet.AndroidFacet#getModule()
The following examples show how to use
org.jetbrains.android.facet.AndroidFacet#getModule() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ModuleChooserDialogHelper.java From ADB-Duang with MIT License | 5 votes |
public static AndroidFacet showDialogForFacets(Project project, List<AndroidFacet> facets) { List<Module> modules = Lists.newArrayList(); String previousModuleName = getPreviousModuleName(project); List<Module> previousSelectedModule = null; for (AndroidFacet facet : facets) { Module module = facet.getModule(); modules.add(module); if (module.getName().equals(previousModuleName)) { previousSelectedModule = Lists.newArrayList(module); } } ChooseModulesDialog dialog = new ChooseModulesDialog(project, modules, "Choose Module", ""); dialog.setSingleSelectionMode(); if (previousSelectedModule != null) { dialog.selectElements(previousSelectedModule); } dialog.show(); List<Module> chosenElements = dialog.getChosenElements(); if (chosenElements.isEmpty()) { return null; } Module chosenModule = chosenElements.get(0); saveModuleName(project, chosenModule.getName()); int chosenModuleIndex = modules.indexOf(chosenModule); return facets.get(chosenModuleIndex); }
Example 2
Source File: BlazeAndroidModuleTemplate.java From intellij with Apache License 2.0 | 5 votes |
public static List<NamedModuleTemplate> getTemplates( AndroidFacet androidFacet, @Nullable VirtualFile targetDirectory) { Module module = androidFacet.getModule(); BlazeAndroidModuleTemplate paths = new BlazeAndroidModuleTemplate(); VirtualFile[] roots = ModuleRootManager.getInstance(module).getContentRoots(); if (roots.length > 0) { paths.moduleRoot = VfsUtilCore.virtualToIoFile(roots[0]); } IdeaSourceProvider sourceProvider = SourceProviderManager.getInstance(androidFacet).getSources(); // If this happens to be a resource package, // the module name (resource package) would be more descriptive than the facet name (Android). // Otherwise, .workspace is still better than (Android). String name = androidFacet.getModule().getName(); if (targetDirectory != null) { String packageName = getPackageName(module.getProject(), targetDirectory); if (packageName != null) { name = packageName; } paths.srcDirectory = VfsUtilCore.virtualToIoFile(targetDirectory); } else { // People usually put the manifest file with their sources. //noinspection OptionalGetWithoutIsPresent paths.srcDirectory = sourceProvider.getManifestDirectoryUrls().stream() .map(it -> new File(VfsUtilCore.urlToPath(it))) .findFirst() .get(); } // We have a res dir if this happens to be a resource module. paths.resDirectories = sourceProvider.getResDirectoryUrls().stream() .map(it -> new File(VfsUtilCore.urlToPath(it))) .collect(Collectors.toList()); return Collections.singletonList(new NamedModuleTemplate(name, paths)); }
Example 3
Source File: ModuleChooserDialogHelper.java From ADBWIFI with Apache License 2.0 | 5 votes |
public static AndroidFacet showDialogForFacets(Project project, List<AndroidFacet> facets) { List<Module> modules = Lists.newArrayList(); String previousModuleName = getPreviousModuleName(project); List<Module> previousSelectedModule = null; for (AndroidFacet facet : facets) { Module module = facet.getModule(); modules.add(module); if (module.getName().equals(previousModuleName)) { previousSelectedModule = Lists.newArrayList(module); } } ChooseModulesDialog dialog = new ChooseModulesDialog(project, modules, "Choose Module", ""); dialog.setSingleSelectionMode(); if (previousSelectedModule != null) { dialog.selectElements(previousSelectedModule); } dialog.show(); List<Module> chosenElements = dialog.getChosenElements(); if (chosenElements.isEmpty()) { return null; } Module chosenModule = chosenElements.get(0); saveModuleName(project, chosenModule.getName()); int chosenModuleIndex = modules.indexOf(chosenModule); return facets.get(chosenModuleIndex); }