Search in sources :

Example 1 with DeveloperService

use of com.android.tools.idea.structure.services.DeveloperService in project android by JetBrains.

the class DeveloperServicesPanel method updateServicePanels.

private void updateServicePanels(@NotNull ServiceCategory serviceCategory) {
    for (DeveloperServicePanel developerServicePanel : myPanelsList) {
        developerServicePanel.dispose();
    }
    myPanelsList.clear();
    myServicesPanel.removeAll();
    Module module = (Module) myModuleCombo.getSelectedItem();
    if (module == null) {
        return;
    }
    for (DeveloperService service : DeveloperServices.getFor(module, serviceCategory)) {
        if (service.getContext().hiddenFromStructureDialog().get()) {
            continue;
        }
        myPanelsList.add(new DeveloperServicePanel(service));
    }
    for (DeveloperServicePanel panel : myPanelsList) {
        if (myServicesPanel.getComponentCount() > 0) {
            myServicesPanel.add(new SeparatorComponent());
        }
        myServicesPanel.add(panel);
    }
    // For some reason, requesting a layout and paint update is required here, as otherwise
    // previous content may not be cleared and new content may not be laid out.
    myServicesPanel.validate();
    myServicesPanel.repaint();
}
Also used : DeveloperService(com.android.tools.idea.structure.services.DeveloperService) SeparatorComponent(com.intellij.ui.SeparatorComponent) Module(com.intellij.openapi.module.Module)

Example 2 with DeveloperService

use of com.android.tools.idea.structure.services.DeveloperService in project android by JetBrains.

the class AndroidProjectStructureConfigurable method reset.

@Override
public void reset() {
    // Need this to ensure VFS operations will not block because of storage flushing and other maintenance IO tasks run in background.
    AccessToken token = HeavyProcessLatch.INSTANCE.processStarted("Resetting project structure");
    try {
        for (Configurable configurable : myConfigurables) {
            configurable.reset();
        }
        if (myUiInitialized) {
            validateState();
            // Prepare module entries but don't add them until after developer services
            ModuleManager moduleManager = ModuleManager.getInstance(myProject);
            Module[] modules = moduleManager.getModules();
            Arrays.sort(modules, ModuleTypeComparator.INSTANCE);
            List<AndroidModuleConfigurable> moduleConfigurables = Lists.newArrayList();
            for (Module module : modules) {
                AndroidModuleConfigurable configurable = addModule(module);
                if (configurable != null) {
                    moduleConfigurables.add(configurable);
                }
            }
            // Populate the "Developer Services" section
            removeServices();
            if (Projects.isBuildWithGradle(myProject)) {
                DefaultComboBoxModel moduleList = new DefaultComboBoxModel();
                for (AndroidModuleConfigurable moduleConfigurable : moduleConfigurables) {
                    // Collect only Android modules
                    if (AndroidFacet.getInstance(moduleConfigurable.getModule()) != null) {
                        moduleList.addElement(moduleConfigurable.getModule());
                    }
                }
                if (!myProject.isDefault() && moduleList.getSize() > 0) {
                    // into that event.
                    for (int i = 0; i < moduleList.getSize(); i++) {
                        Module module = (Module) moduleList.getElementAt(i);
                        for (DeveloperService service : DeveloperServices.getAll(module)) {
                            service.getContext().restore();
                        }
                    }
                    Module module = (Module) moduleList.getSelectedItem();
                    Set<ServiceCategory> categories = Sets.newHashSet();
                    for (DeveloperService s : DeveloperServices.getAll(module)) {
                        if (!s.getContext().hiddenFromStructureDialog().get()) {
                            categories.add(s.getCategory());
                        }
                    }
                    ArrayList<ServiceCategory> categoriesSorted = Lists.newArrayList(categories);
                    Collections.sort(categoriesSorted);
                    for (ServiceCategory category : categoriesSorted) {
                        myConfigurables.add(new ServiceCategoryConfigurable(moduleList, category));
                    }
                }
            }
            // Populate the "Modules" section.
            removeModules();
            Module toSelect = null;
            for (Module module : modules) {
                AndroidModuleConfigurable configurable = addModule(module);
                if (configurable != null) {
                    myConfigurables.add(configurable);
                    if (configurable.getDisplayName().equals(myUiState.lastSelectedConfigurable)) {
                        toSelect = module;
                    }
                }
            }
            if (myUiState.proportion > 0) {
                mySplitter.setProportion(myUiState.proportion);
            }
            mySidePanel.reset();
            if (toSelect != null) {
                mySidePanel.select(toSelect);
            } else {
                mySidePanel.selectSdk();
            }
        }
    } finally {
        token.finish();
    }
}
Also used : ServiceCategory(com.android.tools.idea.structure.services.ServiceCategory) ServiceCategoryConfigurable(com.android.tools.idea.structure.services.view.ServiceCategoryConfigurable) AndroidModuleConfigurable(com.android.tools.idea.gradle.structure.editors.AndroidModuleConfigurable) AndroidModuleConfigurable(com.android.tools.idea.gradle.structure.editors.AndroidModuleConfigurable) ServiceCategoryConfigurable(com.android.tools.idea.structure.services.view.ServiceCategoryConfigurable) AndroidProjectConfigurable(com.android.tools.idea.gradle.structure.editors.AndroidProjectConfigurable) ModuleManager(com.intellij.openapi.module.ModuleManager) DeveloperService(com.android.tools.idea.structure.services.DeveloperService) AccessToken(com.intellij.openapi.application.AccessToken) Module(com.intellij.openapi.module.Module)

Aggregations

DeveloperService (com.android.tools.idea.structure.services.DeveloperService)2 Module (com.intellij.openapi.module.Module)2 AndroidModuleConfigurable (com.android.tools.idea.gradle.structure.editors.AndroidModuleConfigurable)1 AndroidProjectConfigurable (com.android.tools.idea.gradle.structure.editors.AndroidProjectConfigurable)1 ServiceCategory (com.android.tools.idea.structure.services.ServiceCategory)1 ServiceCategoryConfigurable (com.android.tools.idea.structure.services.view.ServiceCategoryConfigurable)1 AccessToken (com.intellij.openapi.application.AccessToken)1 ModuleManager (com.intellij.openapi.module.ModuleManager)1 SeparatorComponent (com.intellij.ui.SeparatorComponent)1