Search in sources :

Example 51 with Subscription

use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by microsoft.

the class Node method openResourcesInPortal.

@AzureOperation(name = "common.open_portal", params = { "nameFromResourceId(resourceId)" }, type = AzureOperation.Type.ACTION)
public void openResourcesInPortal(String subscriptionId, String resourceId) {
    final AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
    // not signed in
    if (azureManager == null) {
        return;
    }
    final String portalUrl = azureManager.getPortalUrl();
    Subscription subscription = Azure.az(AzureAccount.class).account().getSubscription(subscriptionId);
    final String url = portalUrl + REST_SEGMENT_JOB_MANAGEMENT_TENANTID + subscription.getTenantId() + REST_SEGMENT_JOB_MANAGEMENT_RESOURCE + resourceId;
    DefaultLoader.getIdeHelper().openLinkInBrowser(url);
}
Also used : AzureManager(com.microsoft.azuretools.sdkmanage.AzureManager) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Example 52 with Subscription

use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by microsoft.

the class SqlServerPropertyView method showProperty.

// @Override
public void showProperty(SqlServerProperty property) {
    SqlServerEntity entity = property.getServer().entity();
    Subscription subscription = Azure.az(AzureAccount.class).account().getSubscription(entity.getSubscriptionId());
    if (subscription != null) {
        overview.getSubscriptionTextField().setText(subscription.getName());
    }
    databaseComboBox.setServer(property.getServer());
    overview.getResourceGroupTextField().setText(entity.getResourceGroupName());
    overview.getStatusTextField().setText(entity.getState());
    overview.getLocationTextField().setText(entity.getRegion().getLabel());
    overview.getSubscriptionIDTextField().setText(entity.getSubscriptionId());
    overview.getServerNameTextField().setText(entity.getFullyQualifiedDomainName());
    overview.getServerNameTextField().setCaretPosition(0);
    overview.getServerAdminLoginNameTextField().setText(entity.getAdministratorLoginName() + "@" + entity.getName());
    overview.getServerAdminLoginNameTextField().setCaretPosition(0);
    overview.getVersionTextField().setText(entity.getVersion());
    if ("Ready".equals(entity.getState())) {
        List<FirewallRuleEntity> firewallRules = property.getFirewallRules();
        originalAllowAccessToAzureServices = firewallRules.stream().anyMatch(e -> FirewallRuleEntity.ACCESS_FROM_AZURE_SERVICES_FIREWALL_RULE_NAME.equalsIgnoreCase(e.getName()));
        connectionSecurity.getAllowAccessFromAzureServicesCheckBox().setSelected(originalAllowAccessToAzureServices);
        originalAllowAccessToLocal = firewallRules.stream().anyMatch(e -> StringUtils.equalsIgnoreCase(FirewallRuleEntity.getAccessFromLocalFirewallRuleName(), e.getName()));
        connectionSecurity.getAllowAccessFromLocalMachineCheckBox().setSelected(originalAllowAccessToLocal);
    } else {
        connectionSecuritySeparator.collapse();
        connectionSecuritySeparator.setEnabled(false);
        connectionStringsSeparator.collapse();
        connectionStringsSeparator.setEnabled(false);
    }
}
Also used : Azure(com.microsoft.azure.toolkit.lib.Azure) VirtualFile(com.intellij.openapi.vfs.VirtualFile) FirewallRuleEntity(com.microsoft.azure.toolkit.lib.database.entity.FirewallRuleEntity) Node(com.microsoft.tooling.msservices.serviceexplorer.Node) HashMap(java.util.HashMap) StringUtils(org.apache.commons.lang3.StringUtils) SqlServerEntity(com.microsoft.azure.toolkit.lib.sqlserver.model.SqlServerEntity) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) SqlDatabaseEntity(com.microsoft.azure.toolkit.lib.sqlserver.model.SqlDatabaseEntity) Map(java.util.Map) Project(com.intellij.openapi.project.Project) Nonnull(javax.annotation.Nonnull) SqlServerModule(com.microsoft.tooling.msservices.serviceexplorer.azure.sqlserver.SqlServerModule) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) ConnectionStringsOutputPanel(com.microsoft.azure.toolkit.intellij.database.ui.ConnectionStringsOutputPanel) ItemEvent(java.awt.event.ItemEvent) AzureToolkitRuntimeException(com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException) ActionConstants(com.microsoft.azuretools.ActionConstants) SqlServerProperty(com.microsoft.tooling.msservices.serviceexplorer.azure.sqlserver.SqlServerProperty) MySQLPropertyActionPanel(com.microsoft.azure.toolkit.intellij.database.ui.MySQLPropertyActionPanel) SqlServer(com.microsoft.azure.toolkit.lib.sqlserver.SqlServer) BaseEditor(com.microsoft.azure.toolkit.intellij.common.BaseEditor) ActionEvent(java.awt.event.ActionEvent) JdbcUrl(com.microsoft.azure.toolkit.lib.database.JdbcUrl) DatabaseTemplateUtils(com.microsoft.azure.toolkit.lib.database.utils.DatabaseTemplateUtils) DatabaseComboBox(com.microsoft.azure.toolkit.intellij.database.DatabaseComboBox) List(java.util.List) AzureSqlServer(com.microsoft.azure.toolkit.lib.sqlserver.AzureSqlServer) EventType(com.microsoft.azuretools.telemetrywrapper.EventType) AzureAccount(com.microsoft.azure.toolkit.lib.auth.AzureAccount) TelemetryConstants(com.microsoft.azuretools.telemetry.TelemetryConstants) MvpView(com.microsoft.azuretools.core.mvp.ui.base.MvpView) AzureEventBus(com.microsoft.azure.toolkit.lib.common.event.AzureEventBus) EventUtil(com.microsoft.azuretools.telemetrywrapper.EventUtil) AzureHideableTitledSeparator(com.microsoft.azure.toolkit.intellij.common.AzureHideableTitledSeparator) NotNull(org.jetbrains.annotations.NotNull) ConnectionSecurityPanel(com.microsoft.azure.toolkit.intellij.database.ui.ConnectionSecurityPanel) Utils(com.microsoft.azuretools.azurecommons.util.Utils) AzureTaskManager(com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager) javax.swing(javax.swing) SqlServerEntity(com.microsoft.azure.toolkit.lib.sqlserver.model.SqlServerEntity) FirewallRuleEntity(com.microsoft.azure.toolkit.lib.database.entity.FirewallRuleEntity) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription)

Example 53 with Subscription

use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by microsoft.

the class RedisCreationDialog method onSubscriptionChanged.

private void onSubscriptionChanged(final ItemEvent e) {
    if (e.getStateChange() == ItemEvent.SELECTED) {
        final Subscription subscription = (Subscription) e.getItem();
        this.resourceGroupComboBox.setSubscription(subscription);
        this.regionComboBox.setSubscription(subscription);
    } else if (e.getStateChange() == ItemEvent.DESELECTED) {
        this.resourceGroupComboBox.setSubscription(null);
        this.regionComboBox.setSubscription(null);
    }
}
Also used : Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription)

Example 54 with Subscription

use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by microsoft.

the class CreateRedisCacheForm method initWidgetListeners.

private void initWidgetListeners() {
    txtRedisName.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void insertUpdate(DocumentEvent documentEvent) {
            validateEmptyFields();
        }

        @Override
        public void removeUpdate(DocumentEvent documentEvent) {
            validateEmptyFields();
        }

        @Override
        public void changedUpdate(DocumentEvent documentEvent) {
            validateEmptyFields();
        }
    });
    cbSubs.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            currentSub = (Subscription) cbSubs.getSelectedItem();
            cbLocations.setSubscription(currentSub);
            fillResourceGrps(currentSub);
            validateEmptyFields();
        }
    });
    rdoCreateNewGrp.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            txtNewResGrp.setVisible(true);
            cbUseExist.setVisible(false);
            newResGrp = true;
            validateEmptyFields();
        }
    });
    txtNewResGrp.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void insertUpdate(DocumentEvent documentEvent) {
            validateEmptyFields();
        }

        @Override
        public void removeUpdate(DocumentEvent documentEvent) {
            validateEmptyFields();
        }

        @Override
        public void changedUpdate(DocumentEvent documentEvent) {
            validateEmptyFields();
        }
    });
    rdoUseExist.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            txtNewResGrp.setVisible(false);
            cbUseExist.setVisible(true);
            newResGrp = false;
            validateEmptyFields();
        }
    });
    cbUseExist.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            validateEmptyFields();
        }
    });
    cbLocations.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            validateEmptyFields();
        }
    });
    lblPricing.addMouseListener(new LinkListener(PRICING_LINK));
    cbPricing.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            validateEmptyFields();
        }
    });
    chkNoSSL.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (chkNoSSL.isSelected()) {
                noSSLPort = true;
            } else {
                noSSLPort = false;
            }
        }
    });
}
Also used : DocumentListener(javax.swing.event.DocumentListener) MouseEvent(java.awt.event.MouseEvent) ActionListener(java.awt.event.ActionListener) LinkListener(com.microsoft.intellij.helpers.LinkListener) ActionEvent(java.awt.event.ActionEvent) MouseAdapter(java.awt.event.MouseAdapter) DocumentEvent(javax.swing.event.DocumentEvent) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription)

Example 55 with Subscription

use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by microsoft.

the class MySQLPropertyView method showProperty.

@Override
public void showProperty(MySQLProperty property) {
    final MySqlServer server = property.getServer();
    final String sid = server.entity().getSubscriptionId();
    if (!server.exists()) {
        this.closeEditor();
        return;
    }
    final Subscription subscription = az(AzureAccount.class).account().getSubscription(sid);
    if (subscription != null) {
        overview.getSubscriptionTextField().setText(subscription.getName());
        databaseComboBox.setServer(server);
        databaseComboBox.refreshItems();
    }
    overview.getResourceGroupTextField().setText(server.entity().getResourceGroupName());
    overview.getStatusTextField().setText(server.entity().getState());
    overview.getLocationTextField().setText(server.entity().getRegion().getLabel());
    overview.getSubscriptionIDTextField().setText(sid);
    overview.getServerNameTextField().setText(server.entity().getFullyQualifiedDomainName());
    overview.getServerNameTextField().setCaretPosition(0);
    overview.getServerAdminLoginNameTextField().setText(server.entity().getAdministratorLoginName() + "@" + server.name());
    overview.getServerAdminLoginNameTextField().setCaretPosition(0);
    overview.getMysqlVersionTextField().setText(server.entity().getVersion());
    final String skuTier = server.entity().getSkuTier();
    final int skuCapacity = server.entity().getVCore();
    final int storageGB = server.entity().getStorageInMB() / 1024;
    final String performanceConfigurations = skuTier + ", " + skuCapacity + " vCore(s), " + storageGB + " GB";
    overview.getPerformanceConfigurationsTextField().setText(performanceConfigurations);
    overview.getSslEnforceStatusTextField().setText(server.entity().getSslEnforceStatus());
    if (StringUtils.equalsIgnoreCase("READY", server.entity().getState())) {
        connectionSecuritySeparator.expand();
        connectionSecuritySeparator.setEnabled(true);
        connectionStringsSeparator.expand();
        connectionStringsSeparator.setEnabled(true);
        originalAllowAccessToAzureServices = server.firewallRules().isAzureAccessRuleEnabled();
        connectionSecurity.getAllowAccessFromAzureServicesCheckBox().setSelected(originalAllowAccessToAzureServices);
        originalAllowAccessToLocal = server.firewallRules().isLocalMachineAccessRuleEnabled();
        connectionSecurity.getAllowAccessFromLocalMachineCheckBox().setSelected(originalAllowAccessToLocal);
    } else {
        connectionSecuritySeparator.collapse();
        connectionSecuritySeparator.setEnabled(false);
        connectionStringsSeparator.collapse();
        connectionStringsSeparator.setEnabled(false);
    }
}
Also used : MySqlServer(com.microsoft.azure.toolkit.lib.mysql.MySqlServer) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription)

Aggregations

Subscription (com.microsoft.azure.toolkit.lib.common.model.Subscription)139 ResourceGroup (com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)26 Region (com.microsoft.azure.toolkit.lib.common.model.Region)18 AzureManager (com.microsoft.azuretools.sdkmanage.AzureManager)18 AzureAccount (com.microsoft.azure.toolkit.lib.auth.AzureAccount)17 ArrayList (java.util.ArrayList)14 IOException (java.io.IOException)11 SelectionEvent (org.eclipse.swt.events.SelectionEvent)10 Project (com.intellij.openapi.project.Project)8 Azure (com.microsoft.azure.toolkit.lib.Azure)8 IAppServicePlan (com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan)8 IWebApp (com.microsoft.azure.toolkit.lib.appservice.service.IWebApp)8 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)8 HashMap (java.util.HashMap)8 List (java.util.List)8 StringUtils (org.apache.commons.lang3.StringUtils)8 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)8 Point (org.eclipse.swt.graphics.Point)8 GridData (org.eclipse.swt.layout.GridData)8 Combo (org.eclipse.swt.widgets.Combo)8