Search in sources :

Example 1 with ServiceCategoryConfigurable

use of com.android.tools.idea.structure.services.view.ServiceCategoryConfigurable 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

AndroidModuleConfigurable (com.android.tools.idea.gradle.structure.editors.AndroidModuleConfigurable)1 AndroidProjectConfigurable (com.android.tools.idea.gradle.structure.editors.AndroidProjectConfigurable)1 DeveloperService (com.android.tools.idea.structure.services.DeveloperService)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 Module (com.intellij.openapi.module.Module)1 ModuleManager (com.intellij.openapi.module.ModuleManager)1