Search in sources :

Example 1 with AzureSdkFeatureEntity

use of com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkFeatureEntity in project azure-tools-for-java by Microsoft.

the class AzureSdkLibraryService method addClientLibs.

private static void addClientLibs(Map<String, AzureSdkServiceEntity> services) {
    getClientLibs().stream().sorted(Comparator.comparing(AzureJavaSdkEntity::getServiceName)).forEachOrdered(raw -> {
        final AzureSdkServiceEntity service = getOrCreateService(services, raw);
        for (final AzureSdkFeatureEntity feature : service.getContent()) {
            final boolean specified = Optional.ofNullable(feature.getClientSource()).filter(s -> s.getGroupId().equals(raw.getGroupId()) && s.getArtifactId().equals(raw.getArtifactId())).isPresent();
            final boolean sameFeatureName = trim(feature.getName()).equals(trim(raw.getDisplayName()));
            if (specified || sameFeatureName) {
                feature.getArtifacts().add(toSdkArtifactEntity(raw));
                return;
            }
        }
        // if no mapping feature found.
        final AzureSdkFeatureEntity feature = AzureSdkFeatureEntity.builder().name(raw.getDisplayName()).msdocs(raw.getMsdocsUrl()).artifacts(new ArrayList<>(Collections.singletonList(toSdkArtifactEntity(raw)))).build();
        service.getContent().add(feature);
    });
}
Also used : java.util(java.util) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation) SneakyThrows(lombok.SneakyThrows) URL(java.net.URL) MappingIterator(com.fasterxml.jackson.databind.MappingIterator) StringUtils(org.apache.commons.lang3.StringUtils) Function(java.util.function.Function) DeserializationFeature(com.fasterxml.jackson.databind.DeserializationFeature) CollectionUtils(org.apache.commons.collections4.CollectionUtils) ObjectReader(com.fasterxml.jackson.databind.ObjectReader) AzureSdkAllowListEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkAllowListEntity) CacheEvict(com.microsoft.azure.toolkit.lib.common.cache.CacheEvict) YAMLMapper(com.fasterxml.jackson.dataformat.yaml.YAMLMapper) CacheManager(com.microsoft.azure.toolkit.lib.common.cache.CacheManager) Cacheable(com.microsoft.azure.toolkit.lib.common.cache.Cacheable) Preload(com.microsoft.azure.toolkit.lib.common.cache.Preload) Nonnull(javax.annotation.Nonnull) AzureSdkArtifactEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkArtifactEntity) AzureToolkitRuntimeException(com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException) ImmutableMap(com.google.common.collect.ImmutableMap) MalformedURLException(java.net.MalformedURLException) CsvMapper(com.fasterxml.jackson.dataformat.csv.CsvMapper) AzureJavaSdkEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureJavaSdkEntity) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) CsvSchema(com.fasterxml.jackson.dataformat.csv.CsvSchema) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) ExecutionException(java.util.concurrent.ExecutionException) Slf4j(lombok.extern.slf4j.Slf4j) AzureSdkFeatureEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkFeatureEntity) AzureSdkServiceEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkServiceEntity) AzureJavaSdkEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureJavaSdkEntity) AzureSdkServiceEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkServiceEntity) AzureSdkFeatureEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkFeatureEntity)

Example 2 with AzureSdkFeatureEntity

use of com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkFeatureEntity in project azure-tools-for-java by Microsoft.

the class AzureSdkLibraryService method addManagementLibs.

private static void addManagementLibs(Map<String, AzureSdkServiceEntity> services) {
    getManagementLibs().stream().sorted(Comparator.comparing(AzureJavaSdkEntity::getServiceName)).forEachOrdered(raw -> {
        final AzureSdkServiceEntity service = getOrCreateService(services, raw);
        for (final AzureSdkFeatureEntity feature : service.getContent()) {
            feature.setName(feature.getName().replace("Resource Management - ", "").trim());
            feature.getArtifacts().add(toSdkArtifactEntity(raw));
        }
    });
}
Also used : AzureJavaSdkEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureJavaSdkEntity) AzureSdkServiceEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkServiceEntity) AzureSdkFeatureEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkFeatureEntity)

Example 3 with AzureSdkFeatureEntity

use of com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkFeatureEntity in project azure-tools-for-java by Microsoft.

the class AzureSdkTreePanel method fillDescriptionFromCategoryIfMissing.

private void fillDescriptionFromCategoryIfMissing(final Map<String, List<AzureSdkCategoryEntity>> categoryToServiceMap, final List<? extends AzureSdkServiceEntity> services) {
    final Map<String, AzureSdkServiceEntity> serviceMap = services.stream().collect(Collectors.toMap(e -> getServiceKeyByName(e.getName()), e -> e));
    categoryToServiceMap.forEach((category, categoryServices) -> categoryServices.forEach(categoryService -> Optional.ofNullable(serviceMap.get(getServiceKeyByName(categoryService.getServiceName()))).ifPresent(service -> {
        for (final AzureSdkFeatureEntity feature : service.getContent()) {
            if (StringUtils.isBlank(feature.getDescription()) && StringUtils.isNotBlank(categoryService.getDescription())) {
                feature.setDescription(categoryService.getDescription());
            }
        }
    })));
}
Also used : Arrays(java.util.Arrays) AllIcons(com.intellij.icons.AllIcons) AzureSdkCategoryService(com.microsoft.azure.toolkit.intellij.azuresdk.service.AzureSdkCategoryService) Presentation(com.intellij.openapi.actionSystem.Presentation) StringUtils(org.apache.commons.lang3.StringUtils) Map(java.util.Map) CommonActionsManager(com.intellij.ide.CommonActionsManager) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) TreePath(javax.swing.tree.TreePath) TailingDebouncer(com.microsoft.azure.toolkit.lib.common.utils.TailingDebouncer) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) Collectors(java.util.stream.Collectors) DefaultTreeExpander(com.intellij.ide.DefaultTreeExpander) MutableTreeNode(javax.swing.tree.MutableTreeNode) JBScrollPane(com.intellij.ui.components.JBScrollPane) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Objects(java.util.Objects) IdeBundle(com.intellij.ide.IdeBundle) RelativeFont(com.intellij.ui.RelativeFont) List(java.util.List) SimpleTree(com.intellij.ui.treeStructure.SimpleTree) ActionPlaces(com.intellij.openapi.actionSystem.ActionPlaces) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) Optional(java.util.Optional) TextDocumentListenerAdapter(com.microsoft.azure.toolkit.intellij.common.TextDocumentListenerAdapter) NotNull(org.jetbrains.annotations.NotNull) AzureTaskManager(com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager) Setter(lombok.Setter) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation) Getter(lombok.Getter) ActionToolbarImpl(com.intellij.openapi.actionSystem.impl.ActionToolbarImpl) SearchTextField(com.intellij.ui.SearchTextField) ArrayUtils(org.apache.commons.lang3.ArrayUtils) NodeRenderer(com.intellij.ide.util.treeView.NodeRenderer) CollectionUtils(org.apache.commons.collections4.CollectionUtils) AzureSdkLibraryService(com.microsoft.azure.toolkit.intellij.azuresdk.service.AzureSdkLibraryService) ActivityTracker(com.intellij.ide.ActivityTracker) Tree(com.intellij.ui.treeStructure.Tree) TreeUtil(com.intellij.util.ui.tree.TreeUtil) AnimatedIcon(com.intellij.ui.AnimatedIcon) AzureSdkCategoryEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkCategoryEntity) IOException(java.io.IOException) TreeSelectionModel(javax.swing.tree.TreeSelectionModel) RenderingUtil(com.intellij.ui.render.RenderingUtil) Consumer(java.util.function.Consumer) AzureSdkFeatureEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkFeatureEntity) AzureSdkServiceEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkServiceEntity) Comparator(java.util.Comparator) javax.swing(javax.swing) AzureSdkServiceEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkServiceEntity) AzureSdkFeatureEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkFeatureEntity)

Example 4 with AzureSdkFeatureEntity

use of com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkFeatureEntity in project azure-tools-for-java by Microsoft.

the class AzureSdkTreePanel method initEventListeners.

private void initEventListeners() {
    this.searchBox.addDocumentListener(this);
    this.tree.addTreeSelectionListener(e -> {
        final DefaultMutableTreeNode node = (DefaultMutableTreeNode) this.tree.getLastSelectedPathComponent();
        if (Objects.nonNull(node) && node.isLeaf() && node.getUserObject() instanceof AzureSdkFeatureEntity) {
            this.lastNodePath = TreeUtil.getPathFromRoot(node);
            selectFeature((AzureSdkFeatureEntity) node.getUserObject());
        }
    });
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) AzureSdkFeatureEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkFeatureEntity)

Example 5 with AzureSdkFeatureEntity

use of com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkFeatureEntity in project azure-tools-for-java by Microsoft.

the class AzureSdkTreePanel method loadServiceData.

private void loadServiceData(AzureSdkServiceEntity service, AzureSdkCategoryEntity categoryService, MutableTreeNode categoryNode, String... filters) {
    if (Objects.isNull(service) || CollectionUtils.isEmpty(service.getContent())) {
        return;
    }
    final boolean categoryMatched = this.isMatchedFilters(categoryService.getCategory(), filters);
    if (CollectionUtils.size(service.getContent()) == 1 && StringUtils.equals(service.getName(), service.getContent().get(0).getName())) {
        final AzureSdkFeatureEntity feature = service.getContent().get(0);
        final boolean featureMatched = this.isMatchedFilters(feature.getName(), filters);
        if (ArrayUtils.isEmpty(filters) || categoryMatched || featureMatched) {
            final DefaultMutableTreeNode featureNode = new DefaultMutableTreeNode(feature);
            this.model.insertNodeInto(featureNode, categoryNode, categoryNode.getChildCount());
        }
        return;
    }
    final MutableTreeNode serviceNode = new DefaultMutableTreeNode(service);
    final boolean serviceMatched = this.isMatchedFilters(service.getName(), filters);
    for (final AzureSdkFeatureEntity feature : service.getContent()) {
        final boolean featureMatched = this.isMatchedFilters(feature.getName(), filters);
        if (ArrayUtils.isEmpty(filters) || categoryMatched || serviceMatched || featureMatched) {
            final DefaultMutableTreeNode featureNode = new DefaultMutableTreeNode(feature);
            this.model.insertNodeInto(featureNode, serviceNode, serviceNode.getChildCount());
        }
    }
    if (ArrayUtils.isEmpty(filters) || categoryMatched || serviceMatched || serviceNode.getChildCount() > 0) {
        this.model.insertNodeInto(serviceNode, categoryNode, categoryNode.getChildCount());
    }
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) AzureSdkFeatureEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkFeatureEntity) MutableTreeNode(javax.swing.tree.MutableTreeNode) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode)

Aggregations

AzureSdkFeatureEntity (com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkFeatureEntity)5 AzureSdkServiceEntity (com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkServiceEntity)3 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)3 AzureJavaSdkEntity (com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureJavaSdkEntity)2 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)2 IOException (java.io.IOException)2 Collectors (java.util.stream.Collectors)2 MutableTreeNode (javax.swing.tree.MutableTreeNode)2 DeserializationFeature (com.fasterxml.jackson.databind.DeserializationFeature)1 MappingIterator (com.fasterxml.jackson.databind.MappingIterator)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ObjectReader (com.fasterxml.jackson.databind.ObjectReader)1 CsvMapper (com.fasterxml.jackson.dataformat.csv.CsvMapper)1 CsvSchema (com.fasterxml.jackson.dataformat.csv.CsvSchema)1 YAMLMapper (com.fasterxml.jackson.dataformat.yaml.YAMLMapper)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 AllIcons (com.intellij.icons.AllIcons)1 ActivityTracker (com.intellij.ide.ActivityTracker)1 CommonActionsManager (com.intellij.ide.CommonActionsManager)1 DefaultTreeExpander (com.intellij.ide.DefaultTreeExpander)1