use of com.microsoft.azuretools.authmanage.models.SubscriptionDetail in project azure-tools-for-java by Microsoft.
the class AzureDockerHostsManager method subscriptionsChanged.
private static boolean subscriptionsChanged(AzureManager azureAuthManager) {
try {
SubscriptionManager subscriptionManager = azureAuthManager.getSubscriptionManager();
List<SubscriptionDetail> subscriptions = subscriptionManager.getSubscriptionDetails();
if (instance.subscriptionsMap == null || instance.subscriptionsMap.isEmpty()) {
return true;
}
for (SubscriptionDetail subscriptionDetail : subscriptions) {
if (subscriptionDetail.isSelected() != instance.subscriptionsMap.get(subscriptionDetail.getSubscriptionId()).isSelected)
return true;
}
return false;
} catch (Exception ignored) {
return true;
}
}
use of com.microsoft.azuretools.authmanage.models.SubscriptionDetail in project azure-tools-for-java by Microsoft.
the class CreateArmStorageAccountForm method okPressed.
@Override
protected void okPressed() {
if (nameTextField.getText().length() < 3 || nameTextField.getText().length() > 24 || !nameTextField.getText().matches("[a-z0-9]+")) {
DefaultLoader.getUIHelper().showError("Invalid storage account name. The name should be between 3 and 24 characters long and " + "can contain only lowercase letters and numbers.", "Azure Explorer");
return;
}
final boolean isNewResourceGroup = createNewRadioButton.getSelection();
final String resourceGroupName = isNewResourceGroup ? resourceGrpField.getText() : resourceGrpCombo.getText();
String replication = replicationComboBox.getData(replicationComboBox.getText()).toString();
String region = ((Location) regionComboBox.getData(regionComboBox.getText())).name();
Kind kind = (Kind) kindCombo.getData(kindCombo.getText());
if (subscription == null) {
String name = nameTextField.getText();
AccessTier accessTier = (AccessTier) accessTierComboBox.getData(accessTierComboBox.getText());
SubscriptionDetail subscriptionDetail = (SubscriptionDetail) subscriptionComboBox.getData(subscriptionComboBox.getText());
setSubscription(subscriptionDetail);
DefaultLoader.getIdeHelper().runInBackground(null, "Creating storage account", false, true, "Creating storage account " + name + "...", new Runnable() {
@Override
public void run() {
try {
AzureSDKManager.createStorageAccount(subscriptionDetail.getSubscriptionId(), name, region, isNewResourceGroup, resourceGroupName, kind, accessTier, false, replication);
// update resource groups cache if new resource group was created when creating storage account
if (isNewResourceGroup) {
AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
if (azureManager != null) {
ResourceGroup rg = azureManager.getAzure(subscriptionDetail.getSubscriptionId()).resourceGroups().getByName(resourceGroupName);
AzureModelController.addNewResourceGroup(subscriptionDetail, rg);
}
}
if (onCreate != null) {
onCreate.run();
}
} catch (Exception e) {
DefaultLoader.getIdeHelper().invokeLater(new Runnable() {
@Override
public void run() {
PluginUtil.displayErrorDialog(PluginUtil.getParentShell(), Messages.err, "An error occurred while creating the storage account: " + e.getMessage());
}
});
}
}
});
} else {
//creating from 'create vm'
newStorageAccount = new com.microsoft.tooling.msservices.model.storage.StorageAccount(nameTextField.getText(), subscription.getSubscriptionId());
newStorageAccount.setResourceGroupName(resourceGroupName);
newStorageAccount.setNewResourceGroup(isNewResourceGroup);
newStorageAccount.setType(replication);
newStorageAccount.setLocation(region);
newStorageAccount.setKind(kind);
if (onCreate != null) {
onCreate.run();
}
}
super.okPressed();
}
use of com.microsoft.azuretools.authmanage.models.SubscriptionDetail in project azure-tools-for-java by Microsoft.
the class CreateArmStorageAccountForm method fillFields.
public void fillFields() {
if (subscription == null) {
try {
subscriptionComboBox.setEnabled(true);
AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
// not signed in
if (azureManager == null) {
return;
}
SubscriptionManager subscriptionManager = azureManager.getSubscriptionManager();
List<SubscriptionDetail> subscriptionDetails = subscriptionManager.getSubscriptionDetails();
for (SubscriptionDetail sub : subscriptionDetails) {
if (sub.isSelected()) {
subscriptionComboBox.add(sub.getSubscriptionName());
subscriptionComboBox.setData(sub.getSubscriptionName(), sub);
}
}
subscriptionComboBox.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
loadRegionsAndGroups();
}
});
if (subscriptionDetails.size() > 0) {
subscriptionComboBox.select(0);
loadRegionsAndGroups();
}
} catch (Exception e) {
PluginUtil.displayErrorDialogWithAzureMsg(PluginUtil.getParentShell(), Messages.err, "An error occurred while loading subscriptions.", e);
}
for (Map.Entry<String, Kind> entry : ACCOUNT_KIND.entrySet()) {
kindCombo.add(entry.getKey());
kindCombo.setData(entry.getKey(), entry.getValue());
}
kindCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
fillPerformanceComboBox();
fillReplicationTypes();
showAccessTier();
}
});
kindCombo.select(1);
showAccessTier();
} else {
// create form create VM form
subscriptionComboBox.setEnabled(false);
subscriptionComboBox.add(subscription.getSubscriptionName());
subscriptionComboBox.setData(subscription.getSubscriptionName(), subscription);
subscriptionComboBox.select(0);
// only General purpose accounts supported for VMs
kindCombo.add("General purpose");
kindCombo.setData(Kind.STORAGE);
kindCombo.setEnabled(false);
kindCombo.select(0);
regionComboBox.add(region.displayName());
regionComboBox.setData(region.displayName(), region);
regionComboBox.setEnabled(false);
regionComboBox.select(0);
loadGroups();
//loadRegions();
}
fillPerformanceComboBox();
//performanceCombo.select(0);
performanceCombo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
fillReplicationTypes();
}
});
fillReplicationTypes();
}
use of com.microsoft.azuretools.authmanage.models.SubscriptionDetail 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 = (SubscriptionDetail) cbSubs.getSelectedItem();
fillLocationsAndResourceGrps(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;
}
}
});
cbLocations.setRenderer(new ListCellRendererWrapper<Object>() {
@Override
public void customize(JList jList, Object o, int i, boolean b, boolean b1) {
if (o != null && (o instanceof Location)) {
setText(" " + ((Location) o).displayName());
}
}
});
}
use of com.microsoft.azuretools.authmanage.models.SubscriptionDetail in project azure-tools-for-java by Microsoft.
the class AzureViewDockerDialog method initDefaultUIValues.
private void initDefaultUIValues(String updating) {
// Docker VM info
setTextField(dockerHostNameTextField, dockerHost.name);
setTextField(dockerHostUrlTextField, dockerHost.apiUrl);
setTextField(dockerHostSidTextField, dockerHost.sid);
setSubscription(new SubscriptionDetail(dockerHost.sid, null, null, true));
setTextField(dockerHostLocationTextField, dockerHost.hostVM.region);
setTextField(dockerHostStatusTextField, (updating != null) ? dockerHost.state.toString() + updating : dockerHost.state.toString());
// Docker VM settings
setTextField(dockerHostOSTypeTextField, dockerHost.hostOSType.toString());
// TODO: enable resizing of the current VM -> see VirtualMachine::availableSizes() and update.withSize();
setTextField(dockerHostVMSizeTextField, (updating != null) ? dockerHost.hostVM.vmSize + updating : dockerHost.hostVM.vmSize);
setTextField(dockerHostRGNameTextField, dockerHost.hostVM.resourceGroupName);
setTextField(dockerHostVnetNameAddrTextField, String.format("%s (%s)", dockerHost.hostVM.vnetName, dockerHost.hostVM.vnetAddressSpace));
setTextField(dockerHostSubnetNameAddrTextField, String.format("%s (%s)", dockerHost.hostVM.subnetName, dockerHost.hostVM.subnetAddressRange));
setTextField(dockerHostPublicIpTextField, String.format("%s (%s)", dockerHost.hostVM.publicIp, dockerHost.hostVM.publicIpName));
setTextField(dockerHostPrivateIpTextField, dockerHost.hostVM.privateIp);
setTextField(dockerHostStorageNameTypeTextField, String.format("%s (%s)", dockerHost.hostVM.storageAccountName, dockerHost.hostVM.storageAccountType));
// Docker VM log in settings
dockerHostAuthUpdateHyperlink.setEnabled(!dockerHost.isUpdating);
String username = (dockerHost.certVault != null && dockerHost.certVault.vmUsername != null) ? dockerHost.certVault.vmUsername : "-unknown-";
setTextField(dockerHostUsernameTextField, (updating != null) ? username + updating : username);
setTextField(dockerHostPwdLoginTextField, (updating != null) ? (dockerHost.hasPwdLogIn ? "Yes" : (dockerHost.certVault == null) ? "-unknown- " : "No") + updating : (dockerHost.hasPwdLogIn ? "Yes" : (dockerHost.certVault == null) ? "-unknown- " : "No"));
setTextField(dockerHostSshLoginTextField, (updating != null) ? (dockerHost.hasSSHLogIn ? "Yes" : (dockerHost.certVault == null) ? "-unknown- " : "No") + updating : (dockerHost.hasSSHLogIn ? "Yes" : (dockerHost.certVault == null) ? "-unknown- " : "No"));
dockerHostSshExportHyperlink.setEnabled(!dockerHost.isUpdating && dockerHost.hasSSHLogIn);
// Docker Daemon settings
setTextField(dockerHostTlsAuthTextField, (updating != null) ? (dockerHost.isTLSSecured ? "Using TLS certificates" : (dockerHost.certVault == null) ? "-unknown- " : "Open/unsecured access") + updating : (dockerHost.isTLSSecured ? "Using TLS certificates" : (dockerHost.certVault == null) ? "-unknown- " : "Open/unsecured access"));
dockerHostTlsExportHyperlink.setEnabled(!dockerHost.isUpdating && dockerHost.isTLSSecured);
setTextField(dockerHostPortTextField, (updating != null) ? dockerHost.port + updating : dockerHost.port);
// Docker Keyvault settings
if (dockerHost.certVault != null && dockerHost.hostVM.vaultName != null && !dockerHost.hostVM.vaultName.isEmpty() && dockerHost.certVault.uri != null && !dockerHost.certVault.uri.isEmpty()) {
setTextField(dockerHostKeyvaultTextField, (updating != null) ? dockerHost.certVault.uri + updating : dockerHost.certVault.uri);
dockerHostKeyvaultTextPane.setVisible(false);
} else if (dockerHost.hostVM.vaultName != null && !dockerHost.hostVM.vaultName.isEmpty()) {
setTextField(dockerHostKeyvaultTextField, String.format("Error reading http://%s.vault.azure.net", dockerHost.hostVM.vaultName));
dockerHostKeyvaultTextPane.setVisible(true);
} else {
setTextField(dockerHostKeyvaultTextField, "Not using Key Vault");
dockerHostKeyvaultTextPane.setVisible(false);
}
dockerHostKeyvaultTextPane.setFont(UIManager.getFont("Label.font"));
exitCode = CLOSE_EXIT_CODE;
// myClickApplyAction.setEnabled(!editableHost.originalDockerHost.equalsTo(dockerHost));
}
Aggregations