Search in sources :

Example 36 with AzureString

use of com.microsoft.azure.toolkit.lib.common.bundle.AzureString in project azure-tools-for-java by Microsoft.

the class SubscriptionsDialog method createUIComponents.

private void createUIComponents() {
    contentPane = new JPanel();
    contentPane.setPreferredSize(new Dimension(350, 200));
    DefaultTableModel model = new SubscriptionTableModel();
    // Set the text read by JAWS
    model.addColumn("Selected");
    model.addColumn("Subscription name");
    model.addColumn("Subscription ID");
    table = new JBTable();
    table.setModel(model);
    TableColumn column = table.getColumnModel().getColumn(CHECKBOX_COLUMN);
    // Don't show title text
    column.setHeaderValue("");
    column.setMinWidth(23);
    column.setMaxWidth(23);
    JTableUtils.enableBatchSelection(table, CHECKBOX_COLUMN);
    table.getTableHeader().setReorderingAllowed(false);
    new TableSpeedSearch(table);
    AnActionButton refreshAction = new AnActionButton("Refresh", AllIcons.Actions.Refresh) {

        @Override
        public void actionPerformed(AnActionEvent anActionEvent) {
            this.setEnabled(false);
            model.setRowCount(0);
            model.fireTableDataChanged();
            table.getEmptyText().setText("Refreshing");
            AppInsightsClient.createByType(AppInsightsClient.EventType.Subscription, "", "Refresh", null);
            final AzureString title = AzureOperationBundle.title("account|subscription.refresh");
            final AzureTask task = new AzureTask(project, title, true, () -> {
                try {
                    SubscriptionsDialog.this.refreshSubscriptions();
                } finally {
                    this.setEnabled(true);
                }
            }, AzureTask.Modality.ANY);
            AzureTaskManager.getInstance().runInBackground(task);
        }
    };
    refreshAction.registerCustomShortcutSet(KeyEvent.VK_R, InputEvent.ALT_DOWN_MASK, contentPane);
    ToolbarDecorator tableToolbarDecorator = ToolbarDecorator.createDecorator(table).disableUpDownActions().addExtraActions(refreshAction);
    panelTable = tableToolbarDecorator.createPanel();
}
Also used : TableSpeedSearch(com.intellij.ui.TableSpeedSearch) DefaultTableModel(javax.swing.table.DefaultTableModel) ToolbarDecorator(com.intellij.ui.ToolbarDecorator) JBTable(com.intellij.ui.table.JBTable) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) TableColumn(javax.swing.table.TableColumn) AnActionButton(com.intellij.ui.AnActionButton) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString)

Example 37 with AzureString

use of com.microsoft.azure.toolkit.lib.common.bundle.AzureString in project azure-tools-for-java by Microsoft.

the class BlobExplorerFileEditor method deleteSelectedFile.

private void deleteSelectedFile() {
    final BlobFile blobItem = getFileSelection();
    if (blobItem != null) {
        boolean isConfirm = DefaultLoader.getUIHelper().showYesNoDialog(mainPanel, "Are you sure you want to " + "delete this blob?", "Delete Blob", null);
        if (isConfirm) {
            setUIState(true);
            final AzureString title = AzureOperationBundle.title("blob.delete", blobItem.getName());
            AzureTaskManager.getInstance().runInBackground(new AzureTask(project, title, false, () -> {
                final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
                progressIndicator.setIndeterminate(true);
                try {
                    StorageClientSDKManager.getManager().deleteBlobFile(connectionString, blobItem);
                    if (blobItems.size() <= 1) {
                        directoryQueue.clear();
                        directoryQueue.addLast(StorageClientSDKManager.getManager().getRootDirectory(connectionString, blobContainer));
                        queryTextField.setText("");
                    }
                    AzureTaskManager.getInstance().runLater(this::fillGrid);
                } catch (AzureCmdException ex) {
                    String msg = "An error occurred while attempting to delete blob." + "\n" + String.format(message("webappExpMsg"), ex.getMessage());
                    PluginUtil.displayErrorDialogAndLog(message("errTtl"), msg, ex);
                }
            }));
        }
    }
}
Also used : ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException) BlobFile(com.microsoft.tooling.msservices.model.storage.BlobFile) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString)

Example 38 with AzureString

use of com.microsoft.azure.toolkit.lib.common.bundle.AzureString in project azure-tools-for-java by Microsoft.

the class AzureSignInAction method loginNonDeviceCodeSingle.

private static Single<AuthMethodDetails> loginNonDeviceCodeSingle(AuthConfiguration auth) {
    final AzureString title = AzureOperationBundle.title("account.sign_in");
    final AzureTask<AuthMethodDetails> task = new AzureTask<>(null, title, true, () -> {
        final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
        indicator.setIndeterminate(true);
        return doLogin(indicator, auth);
    });
    return AzureTaskManager.getInstance().runInBackgroundAsObservable(task).toSingle();
}
Also used : AuthMethodDetails(com.microsoft.azuretools.authmanage.models.AuthMethodDetails) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString)

Example 39 with AzureString

use of com.microsoft.azure.toolkit.lib.common.bundle.AzureString in project azure-tools-for-java by Microsoft.

the class SettingsStep method retrieveVirtualNetworks.

private void retrieveVirtualNetworks() {
    final AzureString title = AzureOperationBundle.title("vm.list_virtual_networks");
    AzureTaskManager.getInstance().runInBackground(new AzureTask(project, title, false, () -> {
        final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
        progressIndicator.setIndeterminate(true);
        if (virtualNetworks == null) {
            virtualNetworks = azure.networks().list();
        }
        final Runnable task = () -> networkComboBox.setModel(getVirtualNetworkModel(model.getVirtualNetwork(), model.getSubnet()));
        AzureTaskManager.getInstance().runLater(task);
    }));
    if (virtualNetworks == null) {
        AzureTaskManager.getInstance().runAndWait(() -> {
            final DefaultComboBoxModel loadingVNModel = new DefaultComboBoxModel(new String[] { CREATE_NEW, "<Loading...>" }) {

                @Override
                public void setSelectedItem(Object o) {
                    super.setSelectedItem(o);
                    if (CREATE_NEW.equals(o)) {
                        showNewVirtualNetworkForm();
                    } else {
                        model.setVirtualNetwork((Network) o);
                    }
                }
            };
            loadingVNModel.setSelectedItem(null);
            networkComboBox.setModel(loadingVNModel);
            subnetComboBox.removeAllItems();
            subnetComboBox.setEnabled(false);
        });
    }
}
Also used : ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString)

Example 40 with AzureString

use of com.microsoft.azure.toolkit.lib.common.bundle.AzureString in project azure-tools-for-java by Microsoft.

the class SettingsStep method retrieveStorageAccounts.

private void retrieveStorageAccounts() {
    final AzureString title = AzureOperationBundle.title("vm.list_storage_accounts");
    AzureTaskManager.getInstance().runInBackground(new AzureTask(project, title, false, () -> {
        final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
        progressIndicator.setIndeterminate(true);
        if (storageAccounts == null) {
            List<StorageAccount> accounts = Azure.az(AzureStorageAccount.class).subscription(model.getSubscription().getId()).list();
            storageAccounts = new TreeMap<>();
            for (StorageAccount storageAccount : accounts) {
                storageAccounts.put(storageAccount.name(), storageAccount);
            }
        }
        refreshStorageAccounts(null);
    }));
    if (storageAccounts == null) {
        final DefaultComboBoxModel loadingSAModel = new DefaultComboBoxModel(new String[] { CREATE_NEW, "<Loading...>" }) {

            @Override
            public void setSelectedItem(Object o) {
                if (CREATE_NEW.equals(o)) {
                    showNewStorageForm();
                } else {
                    super.setSelectedItem(o);
                }
            }
        };
        loadingSAModel.setSelectedItem(null);
        AzureTaskManager.getInstance().runAndWait(() -> storageComboBox.setModel(loadingSAModel), AzureTask.Modality.ANY);
    }
}
Also used : AzureStorageAccount(com.microsoft.azure.toolkit.lib.storage.service.AzureStorageAccount) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) AzureStorageAccount(com.microsoft.azure.toolkit.lib.storage.service.AzureStorageAccount) StorageAccount(com.microsoft.azure.toolkit.lib.storage.service.StorageAccount) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString)

Aggregations

AzureString (com.microsoft.azure.toolkit.lib.common.bundle.AzureString)46 AzureTask (com.microsoft.azure.toolkit.lib.common.task.AzureTask)36 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)21 Project (com.intellij.openapi.project.Project)7 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)6 List (java.util.List)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 AzureOperationBundle (com.microsoft.azure.toolkit.lib.common.operation.AzureOperationBundle)5 AzureTaskManager (com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager)5 AzureCmdException (com.microsoft.azuretools.azurecommons.helpers.AzureCmdException)5 EventUtil (com.microsoft.azuretools.telemetrywrapper.EventUtil)4 BlobFile (com.microsoft.tooling.msservices.model.storage.BlobFile)4 IOException (java.io.IOException)4 MessageType (com.intellij.openapi.ui.MessageType)3 LightVirtualFile (com.intellij.testFramework.LightVirtualFile)3 AzureAccount (com.microsoft.azure.toolkit.lib.auth.AzureAccount)3 AzureToolkitRuntimeException (com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException)3 File (java.io.File)3 javax.swing (javax.swing)3 FileChooserDescriptorFactory (com.intellij.openapi.fileChooser.FileChooserDescriptorFactory)2