public void createToolWindowContent()

in src/main/java/org/apache/openwhisk/intellij/explorer/toolwindow/WhiskExplorerWindowFactory.java [53:97]


    public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
        try {
            // Load endpoint from ~/.wskprops
            WhiskService service = ServiceManager.getService(project, WhiskService.class);

            String filterEndpoints = filterEndpoints(service.getEndpoints());
            LOG.info(filterEndpoints);
            List<WhiskEndpoint> endpoints = new ArrayList<>(JsonParserUtils.parseWhiskEndpoints(filterEndpoints));
            WhiskNamespaceService whiskNamespaceService = WhiskNamespaceService.getInstance();

            readWskProps().ifPresent(auth -> {
                Optional<WhiskNamespace> validNamespace = whiskNamespaceService.validateNamespace(auth);
                if (validNamespace.isPresent()) {
                    WhiskNamespace ns = validNamespace.get();
                    Optional<WhiskEndpoint> existEndpoint = hasWhiskEndpoint(endpoints, auth);
                    if (existEndpoint.isPresent()) {
                        Optional<WhiskNamespace> existNamespace = hasWhiskNamespace(existEndpoint.get().getNamespaces(), auth);
                        if (!existNamespace.isPresent()) {
                            int epIndex = endpoints.indexOf(existEndpoint.get());
                            WhiskEndpoint ep = endpoints.get(epIndex);
                            ep.addNamespaces(ns);
                            endpoints.set(epIndex, ep);
                        }
                    } else {
                        endpoints.add(new WhiskEndpoint("endpoint(" + endpoints.size() + ")", auth.getApihost(), Arrays.asList(ns)));
                    }
                } else {
                    final String msg = "Cannot read the " + System.getProperty("user.home") + "/.wskprops file Please check the file.";
                    NOTIFIER.notify(project, msg, NotificationType.WARNING);
                }
            });
            service.setEndpoints(JsonParserUtils.writeEndpointsToJson(endpoints));
            service.loadState(service);
        } catch (IOException e) {
            final String msg = "Endpoints cannot be loaded.";
            LOG.error(msg, e);
            NOTIFIER.notify(project, msg, NotificationType.ERROR);
        }

        // Tree View
        WhiskExplorerWindowForm whiskExplorerWindowForm = new WhiskExplorerWindowForm(project, toolWindow);
        ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
        Content content = contentFactory.createContent(whiskExplorerWindowForm.getContent(), null, false);
        toolWindow.getContentManager().addContent(content);
    }