/**
 * Copyright 2014 Microsoft Open Technologies Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package com.microsoftopentechnologies.tooling.msservices.serviceexplorer.azure.storage;

import com.microsoftopentechnologies.tooling.msservices.helpers.azure.AzureCmdException;
import com.microsoftopentechnologies.tooling.msservices.model.storage.StorageAccount;
import com.microsoftopentechnologies.tooling.msservices.serviceexplorer.Node;
import com.microsoftopentechnologies.tooling.msservices.serviceexplorer.NodeActionEvent;

public class StorageNode extends Node {
    private static final String WAIT_ICON_PATH = "storageaccount.png";
    private final StorageAccount storageAccount;

    public StorageNode(Node parent, StorageAccount sm) {
        super(sm.getName(), sm.getName(), parent, WAIT_ICON_PATH, true);
        this.storageAccount = sm;
    }

    @Override
    protected void onNodeClick(NodeActionEvent e) {
        this.load();
    }

    @Override
    protected void refreshItems() throws AzureCmdException {

        removeAllChildNodes();

        Node blobsNode = new BlobModule(this, storageAccount);
        blobsNode.load();

        Node queueNode = new QueueModule(this, storageAccount);
        queueNode.load();

        Node tableNode = new TableModule(this, storageAccount);
        tableNode.load();

        addChildNode(blobsNode);
        addChildNode(queueNode);
        addChildNode(tableNode);
    }

}

@@ -763,292 +763,814 @@
 ces.
-helpers.azure.AzureCmdException;%0Aimport com.microsoftopentechnologies.tooling.msservices.model.storage.StorageAccount;%0Aimport com.microsoftopentechnologies.tooling.msservices.serviceexplorer.Node;%0Aimport com.microsoftopentechnologies.tooling.msservices.serviceexplorer.NodeActionEvent
+components.DefaultLoader;%0Aimport com.microsoftopentechnologies.tooling.msservices.helpers.NotNull;%0Aimport com.microsoftopentechnologies.tooling.msservices.helpers.azure.AzureCmdException;%0Aimport com.microsoftopentechnologies.tooling.msservices.helpers.azure.sdk.AzureSDKManagerImpl;%0Aimport com.microsoftopentechnologies.tooling.msservices.model.storage.StorageAccount;%0Aimport com.microsoftopentechnologies.tooling.msservices.serviceexplorer.Node;%0Aimport com.microsoftopentechnologies.tooling.msservices.serviceexplorer.NodeActionEvent;%0Aimport com.microsoftopentechnologies.tooling.msservices.serviceexplorer.NodeActionListener;%0Aimport com.microsoftopentechnologies.tooling.msservices.serviceexplorer.NodeActionListenerAsync;%0A%0Aimport javax.swing.*;%0Aimport java.util.Map;%0Aimport java.util.concurrent.Callable
 ;%0A%0Ap
@@ -2480,10 +2480,1885 @@
 %0A    %7D%0A%0A
+    @Override%0A    protected Map%3CString, Class%3C? extends NodeActionListener%3E%3E initActions() %7B%0A        addAction(%22Delete%22, new DeleteStorageAccountAction());%0A        return super.initActions();%0A    %7D%0A%0A    public class DeleteStorageAccountAction extends NodeActionListenerAsync %7B%0A        int optionDialog;%0A%0A        public DeleteStorageAccountAction() %7B%0A            super(%22Deleting Storage Account%22);%0A        %7D%0A%0A        @NotNull%0A        @Override%0A        protected Callable%3CBoolean%3E beforeAsyncActionPerfomed() %7B%0A%0A            return new Callable%3CBoolean%3E() %7B%0A                @Override%0A                public Boolean call() throws Exception %7B%0A                    optionDialog = JOptionPane.showOptionDialog(null,%0A                            %22This operation will delete storage account %22 + storageAccount.getName() +%0A                                    %22.%5CnAre you sure you want to continue?%22,%0A                            %22Service explorer%22,%0A                            JOptionPane.YES_NO_OPTION,%0A                            JOptionPane.QUESTION_MESSAGE,%0A                            null,%0A                            new String%5B%5D%7B%22Yes%22, %22No%22%7D,%0A                            null);%0A%0A                    return (optionDialog == JOptionPane.YES_OPTION);%0A                %7D%0A            %7D;%0A        %7D%0A%0A        @Override%0A        protected void runInBackground(NodeActionEvent e) throws AzureCmdException %7B%0A            final Node node = e.getAction().getNode();%0A            node.setLoading(true);%0A%0A            AzureSDKManagerImpl.getManager().deleteStorageAccount(storageAccount);%0A%0A            DefaultLoader.getIdeHelper().invokeLater(new Runnable() %7B%0A                @Override%0A                public void run() %7B%0A%0A                    // instruct parent node to remove this node%0A                    getParent().removeDirectChildNode(node);%0A                %7D%0A            %7D);%0A%0A        %7D%0A    %7D%0A%0A
 %7D%0A

Fix issue #282