public void registerActions()

in Utils/azure-toolkit-ide-libs/azure-toolkit-ide-storage-lib/src/main/java/com/microsoft/azure/toolkit/ide/storage/StorageActionsContributor.java [69:248]


    public void registerActions(AzureActionManager am) {
        new Action<>(OPEN_AZURE_STORAGE_EXPLORER)
            .withLabel("Open Azure Storage Explorer")
            .withIdParam(AzResource::getName)
            .visibleWhen(s -> s instanceof AzResource)
            .enableWhen(s -> !(s instanceof StorageAccount) || s.getFormalStatus().isConnected())
            .withHandler(resource -> {
                if (resource instanceof StorageAccount) {
                    new OpenAzureStorageExplorerAction().openResource((StorageAccount) resource);
                } else if (resource instanceof AbstractAzResource && ((AbstractAzResource<?, ?, ?>) resource).getParent() instanceof StorageAccount) {
                    //noinspection unchecked
                    new OpenAzureStorageExplorerAction().openResource((AbstractAzResource<?, StorageAccount, ?>) resource);
                } else {
                    AzureMessager.getMessager().warning("Only Azure Storages can be opened with Azure Storage Explorer.");
                }
            })
            .withAuthRequired(false)
            .withShortcut(am.getIDEDefaultShortcuts().edit())
            .register(am);

        new Action<>(COPY_CONNECTION_STRING)
            .withLabel("Copy Connection String")
            .withIdParam(AzResource::getName)
            .visibleWhen(s -> s instanceof IStorageAccount)
            .enableWhen(s -> s.getFormalStatus().isConnected())
            .withHandler(r -> {
                copyContentToClipboard(r.getConnectionString());
                AzureMessager.getMessager().info("Connection string copied");
            })
            .register(am);

        new Action<>(COPY_CONNECTION_STRING_AZURITE)
            .withLabel("Copy Connection String")
            .withIdParam(AzResource::getName)
            .visibleWhen(s -> s instanceof AzuriteStorageAccount)
            .enableWhen(s -> s.getFormalStatus().isConnected())
            .withHandler(r -> {
                copyContentToClipboard(r.getConnectionString());
                AzureMessager.getMessager().info("Connection string copied");
            })
            .withAuthRequired(false)
            .register(am);

        new Action<>(START_AZURITE_INSTANCE)
            .withLabel("Start Azurite Emulator")
            .enableWhen(s -> !AzuriteStorageAccount.AZURITE_STORAGE_ACCOUNT.getFormalStatus().isRunning())
            .withHandler((s, e) -> AzureActionManager.getInstance().getAction(START_AZURITE).handle(AzuriteStorageAccount.AZURITE_STORAGE_ACCOUNT, e))
            .withAuthRequired(false)
            .register(am);

        new Action<>(START_AZURITE)
            .withLabel("Start Azurite")
            .visibleWhen(s -> s instanceof AzuriteStorageAccount)
            .enableWhen(s -> !s.getFormalStatus().isRunning())
            .withAuthRequired(false)
            .register(am);

        new Action<>(STOP_AZURITE)
            .withLabel("Stop Azurite")
            .visibleWhen(s -> s instanceof AzuriteStorageAccount)
            .enableWhen(s -> s.getFormalStatus().isRunning())
            .withAuthRequired(false)
            .register(am);

        new Action<>(COPY_PRIMARY_KEY)
            .withLabel("Copy Primary Key")
            .withIdParam(AzResource::getName)
            .visibleWhen(s -> s instanceof IStorageAccount)
            .enableWhen(s -> s.getFormalStatus().isConnected())
            .withHandler(resource -> {
                copyContentToClipboard(resource.getKey());
                AzureMessager.getMessager().info("Primary key copied");
            })
            .register(am);

        new Action<>(COPY_PRIMARY_KEY_AZURITE)
            .withLabel("Copy Primary Key")
            .visibleWhen(s -> s instanceof AzuriteStorageAccount)
            .enableWhen(s -> s.getFormalStatus().isConnected())
            .withHandler(resource -> {
                copyContentToClipboard(resource.getKey());
                AzureMessager.getMessager().info("Primary key copied");
            })
            .withAuthRequired(false)
            .register(am);

        new Action<>(OPEN_FILE)
            .withLabel("Open in Editor")
            .withIdParam(AzResource::getName)
            .visibleWhen(s -> s instanceof StorageFile)
            .register(am);

        new Action<>(CREATE_BLOB)
            .withLabel("Create Empty Blob")
            .withIcon(AzureIcons.Action.CREATE.getIconPath())
            .withIdParam(AzResource::getName)
            .visibleWhen(s -> s instanceof IBlobFile && ((StorageFile) s).isDirectory())
            .register(am);

        new Action<>(CREATE_FILE)
            .withLabel("Create Empty File")
            .withIcon(AzureIcons.Action.CREATE.getIconPath())
            .withIdParam(AzResource::getName)
            .visibleWhen(s -> s instanceof IShareFile && ((StorageFile) s).isDirectory())
            .register(am);

        new Action<>(CREATE_DIRECTORY)
            .withLabel("Create Subdirectory")
            .withIcon(AzureIcons.Action.CREATE.getIconPath())
            .withIdParam(AzResource::getName)
            .visibleWhen(s -> s instanceof IShareFile && ((StorageFile) s).isDirectory())
            .register(am);

        new Action<>(CREATE_DIRECTORY)
            .withLabel("Upload Files")
            .withIcon(AzureIcons.Action.UPLOAD.getIconPath())
            .withIdParam(AzResource::getName)
            .visibleWhen(s -> s instanceof IShareFile && ((StorageFile) s).isDirectory())
            .register(am);

        new Action<>(UPLOAD_FILES)
            .withLabel("Upload Files")
            .withIcon(AzureIcons.Action.UPLOAD.getIconPath())
            .withIdParam(AzResource::getName)
            .visibleWhen(s -> s instanceof StorageFile && ((StorageFile) s).isDirectory())
            .register(am);

        new Action<>(UPLOAD_FILE)
            .withLabel("Upload File")
            .withIcon(AzureIcons.Action.UPLOAD.getIconPath())
            .withIdParam(AzResource::getName)
            .visibleWhen(s -> s instanceof StorageFile && !((StorageFile) s).isDirectory())
            .register(am);

        new Action<>(UPLOAD_FOLDER)
            .withLabel("Upload Folder")
            .withIcon(AzureIcons.Action.UPLOAD.getIconPath())
            .withIdParam(AzResource::getName)
            .visibleWhen(s -> s instanceof StorageFile && ((StorageFile) s).isDirectory())
            .register(am);

        new Action<>(DOWNLOAD_FILE)
            .withLabel("Download")
            .withIcon(AzureIcons.Action.DOWNLOAD.getIconPath())
            .withIdParam(AzResource::getName)
            .visibleWhen(s -> s instanceof StorageFile && !((StorageFile) s).isDirectory())
            .register(am);

        new Action<>(COPY_FILE_URL)
            .withLabel("Copy URL")
            .withIdParam(AzResource::getName)
            .visibleWhen(s -> s instanceof StorageFile)
            .register(am);

        new Action<>(COPY_FILE_SAS_URL)
            .withLabel("Generate and Copy SAS Token and URL")
            .withIdParam(AzResource::getName)
            .visibleWhen(s -> s instanceof StorageFile)
            .register(am);

        new Action<>(DELETE_DIRECTORY)
            .withLabel("Delete Directory")
            .withIcon(AzureIcons.Action.DELETE.getIconPath())
            .withIdParam(AzResource::getName)
            .visibleWhen(s -> s instanceof StorageFile && ((StorageFile) s).isDirectory())
            .withHandler(s -> {
                if (AzureMessager.getMessager().confirm(AzureString.format("Are you sure to delete directory \"%s\" and all its contents?", s.getName()))) {
                    ((Deletable) s).delete();
                }
            })
            .withShortcut(am.getIDEDefaultShortcuts().delete())
            .register(am);

        new Action<>(GROUP_CREATE_ACCOUNT)
            .withLabel("Storage Account")
            .withIdParam(AzResource::getName)
            .visibleWhen(s -> s instanceof ResourceGroup)
            .enableWhen(s -> s.getFormalStatus().isConnected())
            .register(am);
    }