Search in sources :

Example 1 with ExternalStorageNode

use of com.microsoft.tooling.msservices.serviceexplorer.azure.storage.ExternalStorageNode in project azure-tools-for-java by Microsoft.

the class ModifyExternalStorageAccountAction method actionPerformed.

@Override
public void actionPerformed(NodeActionEvent e) {
    final ExternalStorageAccountForm form = new ExternalStorageAccountForm((Project) storageNode.getProject());
    form.setTitle("Modify External Storage Account");
    for (ClientStorageAccount account : ExternalStorageHelper.getList(storageNode.getProject())) {
        if (account.getName().equals(storageNode.getClientStorageAccount().getName())) {
            form.setStorageAccount(account);
        }
    }
    form.setOnFinish(new Runnable() {

        @Override
        public void run() {
            ClientStorageAccount oldStorageAccount = storageNode.getClientStorageAccount();
            ClientStorageAccount storageAccount = StorageClientSDKManager.getManager().getStorageAccount(form.getStorageAccount().getConnectionString());
            ClientStorageAccount fullStorageAccount = form.getFullStorageAccount();
            StorageModule parent = (StorageModule) storageNode.getParent();
            parent.removeDirectChildNode(storageNode);
            parent.addChildNode(new ExternalStorageNode(parent, fullStorageAccount));
            ExternalStorageHelper.detach(oldStorageAccount);
            ExternalStorageHelper.add(form.getStorageAccount());
        }
    });
    form.show();
}
Also used : StorageModule(com.microsoft.tooling.msservices.serviceexplorer.azure.storage.StorageModule) ClientStorageAccount(com.microsoft.tooling.msservices.model.storage.ClientStorageAccount) ExternalStorageAccountForm(com.microsoft.intellij.forms.ExternalStorageAccountForm) ExternalStorageNode(com.microsoft.tooling.msservices.serviceexplorer.azure.storage.ExternalStorageNode)

Example 2 with ExternalStorageNode

use of com.microsoft.tooling.msservices.serviceexplorer.azure.storage.ExternalStorageNode in project azure-tools-for-java by Microsoft.

the class ConfirmDialogAction method actionPerformed.

@Override
public void actionPerformed(NodeActionEvent e) {
    final ExternalStorageNode node = (ExternalStorageNode) e.getAction().getNode();
    final ExternalStorageAccountForm form = new ExternalStorageAccountForm((Project) node.getProject());
    form.setTitle("Storage Account Key Required");
    form.setStorageAccount(node.getClientStorageAccount());
    form.setOnFinish(new Runnable() {

        @Override
        public void run() {
            node.getClientStorageAccount().setPrimaryKey(form.getPrimaryKey());
            ClientStorageAccount clientStorageAccount = StorageClientSDKManager.getManager().getStorageAccount(node.getClientStorageAccount().getConnectionString());
            node.getClientStorageAccount().setPrimaryKey(clientStorageAccount.getPrimaryKey());
            node.getClientStorageAccount().setBlobsUri(clientStorageAccount.getBlobsUri());
            node.getClientStorageAccount().setQueuesUri(clientStorageAccount.getQueuesUri());
            node.getClientStorageAccount().setTablesUri(clientStorageAccount.getTablesUri());
            node.load(false);
        }
    });
    form.show();
}
Also used : ClientStorageAccount(com.microsoft.tooling.msservices.model.storage.ClientStorageAccount) ExternalStorageNode(com.microsoft.tooling.msservices.serviceexplorer.azure.storage.ExternalStorageNode) ExternalStorageAccountForm(com.microsoft.intellij.forms.ExternalStorageAccountForm)

Example 3 with ExternalStorageNode

use of com.microsoft.tooling.msservices.serviceexplorer.azure.storage.ExternalStorageNode in project azure-tools-for-java by Microsoft.

the class AttachExternalStorageAccountAction method actionPerformed.

@Override
public void actionPerformed(NodeActionEvent e) {
    final ExternalStorageAccountForm form = new ExternalStorageAccountForm(PluginUtil.getParentShell(), "Attach External Storage Account");
    form.setOnFinish(new Runnable() {

        @Override
        public void run() {
            DefaultLoader.getIdeHelper().invokeLater(new Runnable() {

                public void run() {
                    ClientStorageAccount storageAccount = form.getStorageAccount();
                    ClientStorageAccount fullStorageAccount = form.getFullStorageAccount();
                    for (ClientStorageAccount clientStorageAccount : ExternalStorageHelper.getList(null)) {
                        String name = storageAccount.getName();
                        if (clientStorageAccount.getName().equals(name)) {
                            DefaultLoader.getUIHelper().showError("Storage account with name '" + name + "' already exists.", "Service Explorer");
                            return;
                        }
                    }
                    ExternalStorageNode node = new ExternalStorageNode(storageModule, fullStorageAccount);
                    storageModule.addChildNode(node);
                    ExternalStorageHelper.add(storageAccount);
                }
            });
        }
    });
    form.open();
}
Also used : ClientStorageAccount(com.microsoft.tooling.msservices.model.storage.ClientStorageAccount) ExternalStorageAccountForm(com.microsoft.azuretools.azureexplorer.forms.ExternalStorageAccountForm) ExternalStorageNode(com.microsoft.tooling.msservices.serviceexplorer.azure.storage.ExternalStorageNode)

Example 4 with ExternalStorageNode

use of com.microsoft.tooling.msservices.serviceexplorer.azure.storage.ExternalStorageNode in project azure-tools-for-java by Microsoft.

the class AttachExternalStorageAccountAction method actionPerformed.

@Override
public void actionPerformed(NodeActionEvent e) {
    final ExternalStorageAccountForm form = new ExternalStorageAccountForm((Project) storageModule.getProject());
    form.setTitle("Attach External Storage Account");
    form.setOnFinish(new Runnable() {

        @Override
        public void run() {
            ClientStorageAccount storageAccount = form.getStorageAccount();
            ClientStorageAccount fullStorageAccount = form.getFullStorageAccount();
            for (ClientStorageAccount clientStorageAccount : ExternalStorageHelper.getList(storageModule.getProject())) {
                String name = storageAccount.getName();
                if (clientStorageAccount.getName().equals(name)) {
                    JOptionPane.showMessageDialog(form.getContentPane(), "Storage account with name '" + name + "' already exists.", "Azure Explorer", JOptionPane.ERROR_MESSAGE);
                    return;
                }
            }
            ExternalStorageNode node = new ExternalStorageNode(storageModule, fullStorageAccount);
            storageModule.addChildNode(node);
            ExternalStorageHelper.add(storageAccount);
        }
    });
    form.show();
}
Also used : ClientStorageAccount(com.microsoft.tooling.msservices.model.storage.ClientStorageAccount) ExternalStorageAccountForm(com.microsoft.intellij.forms.ExternalStorageAccountForm) ExternalStorageNode(com.microsoft.tooling.msservices.serviceexplorer.azure.storage.ExternalStorageNode)

Aggregations

ClientStorageAccount (com.microsoft.tooling.msservices.model.storage.ClientStorageAccount)4 ExternalStorageNode (com.microsoft.tooling.msservices.serviceexplorer.azure.storage.ExternalStorageNode)4 ExternalStorageAccountForm (com.microsoft.intellij.forms.ExternalStorageAccountForm)3 ExternalStorageAccountForm (com.microsoft.azuretools.azureexplorer.forms.ExternalStorageAccountForm)1 StorageModule (com.microsoft.tooling.msservices.serviceexplorer.azure.storage.StorageModule)1