use of com.android.tools.idea.gradle.project.model.AndroidModuleModel in project android by JetBrains.
the class GeneratedFileNotificationProvider method createNotificationPanel.
@Nullable
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
AndroidModuleModel androidModel = GradleProjectInfo.getInstance(myProject).findAndroidModelInModule(file);
if (androidModel == null) {
return null;
}
VirtualFile buildFolder = VfsUtil.findFileByIoFile(androidModel.getAndroidProject().getBuildFolder(), false);
if (buildFolder == null || !buildFolder.isDirectory()) {
return null;
}
if (VfsUtilCore.isAncestor(buildFolder, file, false)) {
if (myGeneratedSourceFileChangeTracker.isEditedGeneratedFile(file)) {
// A warning is already being displayed by GeneratedFileEditingNotificationProvider
return null;
}
VirtualFile explodedBundled = buildFolder.findChild(EXPLODED_AAR);
boolean inAar = explodedBundled != null && VfsUtilCore.isAncestor(explodedBundled, file, true);
String text;
if (inAar) {
text = "Resource files inside Android library archive files (.aar) should not be edited";
} else {
text = "Files under the build folder are generated and should not be edited.";
}
EditorNotificationPanel panel = new EditorNotificationPanel();
panel.setText(text);
return panel;
}
return null;
}
use of com.android.tools.idea.gradle.project.model.AndroidModuleModel in project android by JetBrains.
the class AndroidModelView method updateContents.
private void updateContents() {
myTree.setRootVisible(true);
if (GradleSyncState.getInstance(myProject).isSyncInProgress()) {
myTree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode("Gradle project sync in progress ...")));
return;
} else {
myTree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode("Loading ...")));
}
ApplicationManager.getApplication().executeOnPooledThread(() -> {
final DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(myProject.getName());
String projectPath = myProject.getBasePath();
for (Module module : ModuleManager.getInstance(myProject).getModules()) {
AndroidModuleModel androidModel = AndroidModuleModel.get(module);
if (androidModel != null) {
DefaultMutableTreeNode moduleNode = new ModuleNodeBuilder(module.getName(), androidModel, projectPath).getNode();
rootNode.add(moduleNode);
}
// TODO: Also add NativeAndroidGradleModel to the view.
}
UIUtil.invokeLaterIfNeeded(() -> {
DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
renderer.setOpenIcon(AllIcons.Nodes.NewFolder);
renderer.setClosedIcon(AllIcons.Nodes.NewFolder);
renderer.setLeafIcon(AllIcons.ObjectBrowser.ShowModules);
myTree.setCellRenderer(renderer);
DefaultTreeModel model = new DefaultTreeModel(rootNode);
myTree.setRootVisible(false);
myTree.setModel(model);
});
});
}
use of com.android.tools.idea.gradle.project.model.AndroidModuleModel in project android by JetBrains.
the class InternalAndroidModelView method updateContents.
private void updateContents() {
myTree.setRootVisible(true);
if (GradleSyncState.getInstance(myProject).isSyncInProgress()) {
myTree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode("Gradle project sync in progress ...")));
return;
} else {
myTree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode("Loading ...")));
}
ApplicationManager.getApplication().executeOnPooledThread(() -> {
final DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(myProject.getName());
for (Module module : ModuleManager.getInstance(myProject).getModules()) {
AndroidModuleModel androidModel = AndroidModuleModel.get(module);
if (androidModel != null) {
DefaultMutableTreeNode moduleNode = new DefaultMutableTreeNode(module.getName());
AndroidProject androidProject = androidModel.waitForAndGetProxyAndroidProject();
addProxyObject(moduleNode, androidProject);
rootNode.add(moduleNode);
}
NdkModuleModel ndkModuleModel = NdkModuleModel.get(module);
if (ndkModuleModel != null) {
String nodeName = androidModel == null ? module.getName() : module.getName() + " (native)";
DefaultMutableTreeNode nativeModuleNode = new DefaultMutableTreeNode(nodeName);
NativeAndroidProject nativeAndroidProject = ndkModuleModel.waitForAndGetProxyAndroidProject();
addProxyObject(nativeModuleNode, nativeAndroidProject);
rootNode.add(nativeModuleNode);
}
}
invokeLaterIfNeeded(() -> {
DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
renderer.setOpenIcon(AllIcons.Nodes.NewFolder);
renderer.setClosedIcon(AllIcons.Nodes.NewFolder);
renderer.setLeafIcon(AllIcons.ObjectBrowser.ShowModules);
myTree.setCellRenderer(renderer);
DefaultTreeModel model = new DefaultTreeModel(rootNode);
myTree.setRootVisible(false);
myTree.setModel(model);
});
});
}
use of com.android.tools.idea.gradle.project.model.AndroidModuleModel in project android by JetBrains.
the class RestartActivityAction method update.
@Override
public void update(AnActionEvent e) {
Module module = LangDataKeys.MODULE.getData(e.getDataContext());
if (module == null) {
e.getPresentation().setEnabled(false);
return;
}
if (!InstantRunSettings.isInstantRunEnabled()) {
e.getPresentation().setEnabled(false);
return;
}
AndroidModuleModel model = InstantRunGradleUtils.getAppModel(module);
if (model == null) {
e.getPresentation().setEnabled(false);
return;
}
Project project = module.getProject();
boolean enabled = InstantRunSettings.isInstantRunEnabled() && (InstantRunGradleUtils.getIrSupportStatus(model, null) == InstantRunGradleSupport.SUPPORTED) && !getActiveSessions(project).isEmpty() && !isDebuggerPaused(project);
e.getPresentation().setEnabled(enabled);
}
use of com.android.tools.idea.gradle.project.model.AndroidModuleModel in project android by JetBrains.
the class DataNodeCaches method isCacheMissingModels.
private static boolean isCacheMissingModels(@NotNull DataNode<ModuleData> cache, @NotNull Module module) {
GradleFacet gradleFacet = GradleFacet.getInstance(module);
if (gradleFacet != null) {
DataNode<GradleModuleModel> gradleDataNode = find(cache, GRADLE_MODULE_MODEL);
if (gradleDataNode == null) {
return true;
}
AndroidFacet androidFacet = AndroidFacet.getInstance(module);
if (androidFacet != null) {
DataNode<AndroidModuleModel> androidDataNode = find(cache, ANDROID_MODEL);
if (androidDataNode == null || !isValidProxyObject(androidDataNode.getData().getAndroidProject())) {
return true;
}
} else {
JavaFacet javaFacet = JavaFacet.getInstance(module);
if (javaFacet != null) {
DataNode<JavaModuleModel> javaProjectDataNode = find(cache, JAVA_MODULE_MODEL);
if (javaProjectDataNode == null) {
return true;
}
}
}
}
NdkFacet ndkFacet = NdkFacet.getInstance(module);
if (ndkFacet != null) {
DataNode<NdkModuleModel> ndkModuleModelDataNode = find(cache, NDK_MODEL);
if (ndkModuleModelDataNode == null || !isValidProxyObject(ndkModuleModelDataNode.getData().getAndroidProject())) {
return true;
}
}
return false;
}
Aggregations