use of org.jetbrains.android.facet.AndroidFacet in project android by JetBrains.
the class NlProperties method getProperties.
@NotNull
public Table<String, String, NlPropertyItem> getProperties(@NotNull List<NlComponent> components) {
AndroidFacet facet = getFacet(components);
if (facet == null) {
return ImmutableTable.of();
}
GradleDependencyManager dependencyManager = GradleDependencyManager.getInstance(facet.getModule().getProject());
return getProperties(facet, components, dependencyManager);
}
use of org.jetbrains.android.facet.AndroidFacet in project android by JetBrains.
the class NlPreviewImagePanel method setDesignSurface.
public void setDesignSurface(@Nullable DesignSurface designSurface) {
Module oldModule = null;
Configuration oldConfiguration = myDesignSurface != null ? myDesignSurface.getConfiguration() : null;
if (oldConfiguration != null) {
oldModule = oldConfiguration.getModule();
oldConfiguration.removeListener(myConfigurationListener);
}
if (myDesignSurface != null) {
myDesignSurface.removePanZoomListener(myZoomListener);
}
myDesignSurface = designSurface;
Module newModule = null;
Configuration newConfiguration = myDesignSurface != null ? myDesignSurface.getConfiguration() : null;
if (newConfiguration != null) {
newModule = newConfiguration.getModule();
newConfiguration.addListener(myConfigurationListener);
}
if (myDesignSurface != null) {
myDesignSurface.addPanZoomListener(myZoomListener);
}
if (newModule != oldModule) {
ResourceNotificationManager manager = ResourceNotificationManager.getInstance(myDependencyManager.getProject());
AndroidFacet oldFacet = oldModule != null ? AndroidFacet.getInstance(oldModule) : null;
if (oldFacet != null) {
manager.removeListener(myResourceChangeListener, oldFacet, null, null);
}
AndroidFacet newFacet = newModule != null ? AndroidFacet.getInstance(newModule) : null;
if (newFacet != null) {
manager.addListener(myResourceChangeListener, newFacet, null, null);
}
}
myImage = null;
myPreviewGenerationDone = false;
setTransferHandler(designSurface != null ? new ItemTransferHandler(myDesignSurface, this::getItem, myIconPreviewFactory) : null);
invalidateUI();
}
use of org.jetbrains.android.facet.AndroidFacet in project android by JetBrains.
the class NlOldPalettePanel method setToolContext.
@Override
public void setToolContext(@Nullable DesignSurface designSurface) {
Module prevModule = null;
if (myConfiguration != null) {
prevModule = myConfiguration.getModule();
myConfiguration.removeListener(this);
}
Module newModule = null;
myDesignSurface = designSurface != null && designSurface.getLayoutType().isSupportedByDesigner() ? designSurface : null;
if (myDesignSurface != null) {
updateConfiguration();
if (myConfiguration != null) {
newModule = myConfiguration.getModule();
myConfiguration.addListener(this);
}
initItems();
checkForNewMissingDependencies();
repaint();
}
if (prevModule != newModule) {
if (prevModule != null) {
AndroidFacet facet = AndroidFacet.getInstance(prevModule);
if (facet != null) {
ResourceNotificationManager manager = ResourceNotificationManager.getInstance(myProject);
manager.removeListener(this, facet, null, null);
}
}
if (newModule != null) {
AndroidFacet facet = AndroidFacet.getInstance(newModule);
if (facet != null) {
ResourceNotificationManager manager = ResourceNotificationManager.getInstance(myProject);
manager.addListener(this, facet, null, null);
}
myIconFactory.dropCache();
}
}
}
use of org.jetbrains.android.facet.AndroidFacet in project android by JetBrains.
the class IconPreviewFactory method getRenderTask.
@Nullable
private RenderTask getRenderTask(Configuration configuration) {
if (myRenderTask == null || myRenderTask.getModule() != configuration.getModule()) {
if (myRenderTask != null) {
myRenderTask.dispose();
}
AndroidFacet facet = AndroidFacet.getInstance(configuration.getModule());
if (facet == null) {
return null;
}
RenderService renderService = RenderService.get(facet);
RenderLogger logger = renderService.createLogger();
myRenderTask = renderService.createTask(null, configuration, logger, null);
}
return myRenderTask;
}
use of org.jetbrains.android.facet.AndroidFacet in project android by JetBrains.
the class SdkUpdaterConfigPanel method getSdkLocations.
@NotNull
private static Collection<File> getSdkLocations() {
File androidHome = IdeSdks.getInstance().getAndroidSdkPath();
if (androidHome != null) {
return ImmutableList.of(androidHome);
}
Set<File> locations = new HashSet<>();
// Gradle project.
for (Project project : ProjectManager.getInstance().getOpenProjects()) {
try {
LocalProperties localProperties = new LocalProperties(project);
File androidSdkPath = localProperties.getAndroidSdkPath();
if (androidSdkPath != null) {
locations.add(androidSdkPath);
continue;
}
} catch (IOException ignored) {
Logger.getInstance(SdkUpdaterConfigPanel.class).info("Unable to read local.properties file from project: " + project.getName(), ignored);
}
List<AndroidFacet> facets = ProjectFacetManager.getInstance(project).getFacets(AndroidFacet.ID);
for (AndroidFacet facet : facets) {
AndroidSdkData sdkData = facet.getConfiguration().getAndroidSdk();
if (sdkData != null) {
locations.add(sdkData.getLocation());
}
}
}
return locations;
}
Aggregations