public void registerActions()

in Utils/azure-toolkit-ide-hdinsight-libs/azure-toolkit-ide-hdinsight-spark-lib/src/main/java/com/microsoft/azure/toolkit/ide/hdinsight/spark/HDInsightActionsContributor.java [59:189]


    public void registerActions(AzureActionManager am) {
        new Action<>(GROUP_CREATE_HDInsight_SERVICE)
                .withLabel("HDInsight")
                .withIdParam(AzResource::getName)
                .visibleWhen(s -> true)
                .enableWhen(s -> true)
                .register(am);

        new Action<>(REFRESH)
                .withLabel("Refresh")
                .withIcon(AzureIcons.Action.REFRESH.getIconPath())
                .withIdParam(s -> Optional.ofNullable(s).map(r -> {
                    if (r instanceof AzResource) {
                        return ((AzResource) r).getName();
                    } else if (r instanceof AbstractAzResourceModule) {
                        return ((AbstractAzResourceModule<?, ?, ?>) r).getResourceTypeName();
                    }
                    throw new IllegalArgumentException("Unsupported type: " + r.getClass());
                }).orElse(null))
                .withShortcut(am.getIDEDefaultShortcuts().refresh())
                .withAuthRequired(false)
                .visibleWhen(s -> s instanceof Refreshable)
                .withHandler(Refreshable::refresh)
                .register(am);

        new Action<>(LINK_A_CLUSTER)
                .withLabel("Link A Cluster")
                .enableWhen(s -> true)
                .withAuthRequired(false)
                .withShortcut(am.getIDEDefaultShortcuts().edit())
                .register(am);

        new Action<>(UNLINK_A_CLUSTER)
                .withLabel("Unlink")
                .enableWhen(s -> true)
                .withAuthRequired(false)
                .withHandler(resource -> {
                    SparkClusterNode sparkClusterNode = (SparkClusterNode) resource;
                    boolean choice = DefaultLoader.getUIHelper().showConfirmation("Do you really want to unlink the HDInsight cluster?",
                            "Unlink HDInsight Cluster", new String[]{"Yes", "No"}, null);
                    if (choice) {
                        ClusterManagerEx.getInstance().removeAdditionalCluster(sparkClusterNode.getClusterDetail());
                        AzureHDInsightService service = az(AzureHDInsightService.class);
                        service.refresh();
                    }
                })
                .withShortcut(am.getIDEDefaultShortcuts().edit())
                .register(am);

        new Action<>(OPEN_HDINSIGHT_JOB_VIEW)
                .withLabel("Open HDInsight Spark JobView")
                .withAuthRequired(false)
                .enableWhen(s -> s instanceof AzResource)
                .withShortcut(am.getIDEDefaultShortcuts().edit())
                .register(am);

        new Action<>(OPEN_AZURE_STORAGE_EXPLORER)
                .withLabel("Open Azure Storage Explorer")
                .withAuthRequired(false)
                .enableWhen(s -> s instanceof SparkClusterNode)
                .withHandler(resource -> {
                    IClusterDetail clusterDetail = ((SparkClusterNode) resource).getClusterDetail();
                    final AzureString title = OperationBundle.description("user/hdinsight.open_azure_storage_explorer.cluster", ObjectUtils.isEmpty(clusterDetail) ?  StringUtils.EMPTY : clusterDetail.getName());
                    AzureTaskManager.getInstance().runInBackground(new AzureTask<>(title, () -> {
                        OpenHDIAzureStorageExplorerAction openHDIAzureStorageExplorerAction = new OpenHDIAzureStorageExplorerAction();
                        openHDIAzureStorageExplorerAction.openResource(clusterDetail);
                    }));
                })
                .withShortcut(am.getIDEDefaultShortcuts().edit())
                .register(am);

        new Action<>(OPEN_AZURE_STORAGE_EXPLORER_ON_MODULE)
                .withLabel("Open Azure Storage Explorer!")
                .withAuthRequired(false)
                .enableWhen(s -> true)
                .withShortcut(am.getIDEDefaultShortcuts().edit())
                .register(am);

        new Action<>(OPEN_AZURE_EXPLORER_AMBARI)
                .withLabel("Open Cluster Management Portal(Ambari)")
                .withAuthRequired(false)
                .enableWhen(s -> s instanceof SparkClusterNode)
                .withHandler(resource -> {
                    IClusterDetail clusterDetail = ((SparkClusterNode) resource).getClusterDetail();
                    String ambariUrl = clusterDetail.isEmulator() ?
                            ((EmulatorClusterDetail) clusterDetail).getAmbariEndpoint() :
                            ClusterManagerEx.getInstance().getClusterConnectionString(clusterDetail.getName());
                    openUrlLink(clusterDetail,ambariUrl);
                })
                .register(am);

        new Action<>(OPEN_AZURE_EXPLORER_JUPYTER)
                .withLabel("Open Jupyter Notebook")
                .withAuthRequired(false)
                .enableWhen(s -> s instanceof SparkClusterNode)
                .withHandler(resource -> {
                    IClusterDetail clusterDetail = ((SparkClusterNode) resource).getClusterDetail();
                    final String jupyterUrl = ClusterManagerEx.getInstance().getClusterConnectionString(clusterDetail.getName()) + "/jupyter/tree";
                    openUrlLink(clusterDetail,jupyterUrl);
                })
                .register(am);

        new Action<>(OPEN_SPARK_HISTORY_UI)
                .withLabel("Open Spark History UI")
                .withAuthRequired(false)
                .enableWhen(s -> s instanceof SparkClusterNode)
                .withHandler(resource -> {
                    IClusterDetail clusterDetail = ((SparkClusterNode) resource).getClusterDetail();
                    String sparkHistoryUrl = clusterDetail.isEmulator() ?
                            ((EmulatorClusterDetail)clusterDetail).getSparkHistoryEndpoint() :
                            ClusterManagerEx.getInstance().getClusterConnectionString(clusterDetail.getName()) + "/sparkhistory";
                    openUrlLink(clusterDetail,sparkHistoryUrl);
                })
                .register(am);

        new Action<>(OPEN_AZURE_STORAGE_MANAGEMENT_EXPLORER)
                .withLabel("Open Storage in Azure management Portal")
                .withAuthRequired(false)
                .enableWhen(s -> s instanceof StorageAccountNode)
                .withHandler(resource -> {
                    final Account account = Azure.az(AzureAccount.class).account();
                    final String portalUrl = account.getPortalUrl();
                    StorageAccountNode storageAccountNode = (StorageAccountNode)resource;
                    StorageAccount remote = storageAccountNode.getRemote();
                    String resourceId = remote.resourceId();
                    String tenantId = storageAccountNode.getSubscription().getTenantId();
                    String url = portalUrl + "/#@" + tenantId + "/resource" + resourceId;
                    DefaultLoader.getIdeHelper().openLinkInBrowser(url);
                })
                .register(am);
    }