Search in sources :

Example 1 with SqlServerProperty

use of com.microsoft.tooling.msservices.serviceexplorer.azure.sqlserver.SqlServerProperty 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)

Aggregations

FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 AzureHideableTitledSeparator (com.microsoft.azure.toolkit.intellij.common.AzureHideableTitledSeparator)1 BaseEditor (com.microsoft.azure.toolkit.intellij.common.BaseEditor)1 DatabaseComboBox (com.microsoft.azure.toolkit.intellij.database.DatabaseComboBox)1 ConnectionSecurityPanel (com.microsoft.azure.toolkit.intellij.database.ui.ConnectionSecurityPanel)1 ConnectionStringsOutputPanel (com.microsoft.azure.toolkit.intellij.database.ui.ConnectionStringsOutputPanel)1 MySQLPropertyActionPanel (com.microsoft.azure.toolkit.intellij.database.ui.MySQLPropertyActionPanel)1 Azure (com.microsoft.azure.toolkit.lib.Azure)1 AzureAccount (com.microsoft.azure.toolkit.lib.auth.AzureAccount)1 AzureEventBus (com.microsoft.azure.toolkit.lib.common.event.AzureEventBus)1 AzureToolkitRuntimeException (com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException)1 Subscription (com.microsoft.azure.toolkit.lib.common.model.Subscription)1 AzureTask (com.microsoft.azure.toolkit.lib.common.task.AzureTask)1 AzureTaskManager (com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager)1 JdbcUrl (com.microsoft.azure.toolkit.lib.database.JdbcUrl)1 FirewallRuleEntity (com.microsoft.azure.toolkit.lib.database.entity.FirewallRuleEntity)1 DatabaseTemplateUtils (com.microsoft.azure.toolkit.lib.database.utils.DatabaseTemplateUtils)1 AzureSqlServer (com.microsoft.azure.toolkit.lib.sqlserver.AzureSqlServer)1