List of usage examples for com.intellij.openapi.ui DialogWrapper OK_EXIT_CODE
int OK_EXIT_CODE
To view the source code for com.intellij.openapi.ui DialogWrapper OK_EXIT_CODE.
Click Source Link
From source file:com.microsoft.intellij.actions.AzureWebDeployAction.java
License:Open Source License
public void actionPerformed(AnActionEvent e) { Module module = LangDataKeys.MODULE.getData(e.getDataContext()); WebSiteDeployForm form = new WebSiteDeployForm(module); form.show();/*from w w w. j av a2s .c om*/ if (form.getExitCode() == DialogWrapper.OK_EXIT_CODE) { try { String url = form.deploy(); WebSiteDeployTask task = new WebSiteDeployTask(e.getProject(), form.getSelectedWebSite(), url); task.queue(); } catch (AzureCmdException ex) { PluginUtil.displayErrorDialogAndLog(message("webAppDplyErr"), ex.getMessage(), ex); } } }
From source file:com.microsoft.intellij.docker.forms.AzureDockerHostUpdateDaemonPanel.java
License:Open Source License
public AzureDockerHostUpdateDaemonPanel(Project project, EditableDockerHost editableHost, AzureDockerHostsManager dockerUIManager) { this.project = project; this.editableHost = editableHost; this.dockerManager = dockerUIManager; dockerDaemonPortTextField.setText(editableHost.updatedDockerHost.port); mainSelectionGroup = new ButtonGroup(); mainSelectionGroup.add(dockerHostNoTlsRadioButton); mainSelectionGroup.add(dockerHostKeepTlsRadioButton); mainSelectionGroup.add(dockerHostAutoTlsRadioButton); mainSelectionGroup.add(dockerHostImportTlsRadioButton); initDefaultUIState();//from w ww. ja va2 s . com dockerSelectKeyvaultButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { AzureSelectKeyVault selectKeyvaultDialog = new AzureSelectKeyVault(project, dockerUIManager); selectKeyvaultDialog.show(); if (selectKeyvaultDialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { updateUIWithKeyvault(selectKeyvaultDialog.getSelectedKeyvault()); } } }); dockerHostNoTlsRadioButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dockerHostImportTLSBrowseTextField.setEnabled(false); } }); dockerHostNoTlsRadioButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dockerHostImportTLSBrowseTextField.setEnabled(false); } }); dockerHostAutoTlsRadioButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dockerHostImportTLSBrowseTextField.setEnabled(false); } }); dockerHostImportTlsRadioButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dockerHostImportTLSBrowseTextField.setEnabled(true); } }); }
From source file:com.microsoft.intellij.docker.forms.AzureDockerHostUpdateLoginPanel.java
License:Open Source License
public AzureDockerHostUpdateLoginPanel(Project project, EditableDockerHost editableHost, AzureDockerHostsManager dockerUIManager, DialogWrapper dialogWrapper) { this.project = project; this.editableHost = editableHost; this.dockerManager = dockerUIManager; this.dialogWrapperParent = dialogWrapper; authSelectionGroup = new ButtonGroup(); authSelectionGroup.add(dockerHostKeepSshRadioButton); authSelectionGroup.add(dockerHostAutoSshRadioButton); authSelectionGroup.add(dockerHostImportSshRadioButton); initDefaultUI();/*from www. j a v a 2 s.c o m*/ copyFromAzureKeyButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { AzureSelectKeyVault selectKeyvaultDialog = new AzureSelectKeyVault(project, dockerUIManager); selectKeyvaultDialog.show(); if (selectKeyvaultDialog.getExitCode() == DialogWrapper.OK_EXIT_CODE && selectKeyvaultDialog.getSelectedKeyvault() != null) { updateUIWithKeyvault(selectKeyvaultDialog.getSelectedKeyvault()); } } }); dockerHostUsernameLabel.setVisible(editableHost.originalDockerHost.certVault == null || editableHost.originalDockerHost.certVault.vmUsername == null); dockerHostUsernameTextField.setText((editableHost.originalDockerHost.certVault != null && editableHost.originalDockerHost.certVault.vmUsername != null) ? editableHost.originalDockerHost.certVault.vmUsername : ""); dockerHostUsernameTextField.setToolTipText(AzureDockerValidationUtils.getDockerHostUserNameTip()); dockerHostUsernameTextField.setInputVerifier(new InputVerifier() { @Override public boolean verify(JComponent input) { String text = dockerHostUsernameTextField.getText(); if (text == null || text.isEmpty() || (dockerHostSecondPwdField.isVisible() && !AzureDockerValidationUtils.validateDockerHostUserName(text))) { dockerHostUsernameLabel.setVisible(true); return false; } else { dockerHostUsernameLabel.setVisible(false); return true; } } }); // dockerHostUsernameTextField.getDocument().addDocumentListener(resetDialogButtonsState(null)); dockerHostFirstPwdField.setInputVerifier(new InputVerifier() { @Override public boolean verify(JComponent input) { String text = new String(dockerHostFirstPwdField.getPassword()); if (dockerHostFirstPwdField.getPassword().length > 0 && !text.isEmpty() && dockerHostSecondPwdField.isVisible() && !AzureDockerValidationUtils.validateDockerHostPassword(text)) { dockerHostFirstPwdLabel.setVisible(true); return false; } else { dockerHostFirstPwdLabel.setVisible(false); if (!dockerHostSecondPwdField.isVisible()) { dockerHostSecondPwdField.setText(text); } return true; } } }); dockerHostFirstPwdLabel.setVisible(false); dockerHostFirstPwdField.setToolTipText(AzureDockerValidationUtils.getDockerHostPasswordTip()); dockerHostSecondPwdField.setInputVerifier(new InputVerifier() { @Override public boolean verify(JComponent input) { String pwd1 = new String(dockerHostFirstPwdField.getPassword()); String pwd2 = new String(dockerHostSecondPwdField.getPassword()); if (dockerHostSecondPwdField.getPassword().length > 0 && !pwd2.isEmpty() && !pwd2.equals(pwd1)) { dockerHostFirstPwdLabel.setVisible(true); return false; } else { dockerHostFirstPwdLabel.setVisible(false); return true; } } }); dockerHostSecondPwdField.setToolTipText(AzureDockerValidationUtils.getDockerHostPasswordTip()); dockerHostKeepSshRadioButton .setText(editableHost.originalDockerHost.hasSSHLogIn ? "Use current keys" : "None"); dockerHostKeepSshRadioButton.setSelected(true); dockerHostKeepSshRadioButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dockerHostImportSSHBrowseTextField.setEnabled(false); } }); dockerHostAutoSshRadioButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dockerHostImportSSHBrowseTextField.setEnabled(false); } }); dockerHostImportSshRadioButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dockerHostImportSSHBrowseTextField.setEnabled(true); } }); dockerHostImportSSHBrowseLabel.setVisible(false); dockerHostImportSSHBrowseTextField .addActionListener(UIUtils.createFileChooserListener(dockerHostImportSSHBrowseTextField, project, FileChooserDescriptorFactory.createSingleFolderDescriptor())); dockerHostImportSSHBrowseTextField.getTextField() .setToolTipText(AzureDockerValidationUtils.getDockerHostSshDirectoryTip()); dockerHostImportSSHBrowseTextField.getTextField().setInputVerifier(new InputVerifier() { @Override public boolean verify(JComponent input) { String text = dockerHostImportSSHBrowseTextField.getText(); if (text == null || text.isEmpty() || !AzureDockerValidationUtils.validateDockerHostSshDirectory(text)) { dockerHostImportSSHBrowseLabel.setVisible(true); return false; } else { dockerHostImportSSHBrowseLabel.setVisible(false); return true; } } }); }
From source file:com.microsoft.intellij.docker.utils.AzureDockerUIResources.java
License:Open Source License
public static void publish2DockerHostContainer(Project project) { try {//from w ww. ja v a 2 s.c o m AzureDockerUIResources.CANCELED = false; AzureManager azureAuthManager = AuthMethodManager.getInstance().getAzureManager(); // not signed in if (azureAuthManager == null) { System.out.println("ERROR! Not signed in!"); return; } AzureDockerHostsManager dockerManager = AzureDockerHostsManager .getAzureDockerHostsManagerEmpty(azureAuthManager); if (!dockerManager.isInitialized()) { AzureDockerUIResources.updateAzureResourcesWithProgressDialog(project); if (AzureDockerUIResources.CANCELED) { return; } } DockerHost dockerHost = (dockerManager.getDockerPreferredSettings() != null) ? dockerManager.getDockerHostForURL(dockerManager.getDockerPreferredSettings().dockerApiName) : null; AzureDockerImageInstance dockerImageDescription = dockerManager .getDefaultDockerImageDescription(project.getName(), dockerHost); AzureSelectDockerWizardModel model = new AzureSelectDockerWizardModel(project, dockerManager, dockerImageDescription); AzureSelectDockerWizardDialog wizard = new AzureSelectDockerWizardDialog(model); if (dockerHost != null) { model.selectDefaultDockerHost(dockerHost, true); } wizard.show(); if (wizard.getExitCode() == DialogWrapper.OK_EXIT_CODE) { try { String url = wizard.deploy(); if (AzureDockerUtils.DEBUG) System.out.println("Web app published at: " + url); } catch (Exception ex) { PluginUtil.displayErrorDialogAndLog(message("webAppDplyErr"), ex.getMessage(), ex); } } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.microsoft.intellij.docker.utils.AzureDockerUIResources.java
License:Open Source License
public static void updateDockerHost(Project project, EditableDockerHost editableDockerHost, AzureDockerHostsManager dockerManager, boolean doReset) { AppInsightsClient.createByType(AppInsightsClient.EventType.DockerHost, "", "Update"); AzureInputDockerLoginCredsDialog loginCredsDialog = new AzureInputDockerLoginCredsDialog(project, editableDockerHost, dockerManager, doReset); loginCredsDialog.show();/* www .j a v a 2 s. c o m*/ if (loginCredsDialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { // Update Docker host log in credentials DockerHost updateHost = editableDockerHost.originalDockerHost; updateHost.isUpdating = true; DefaultLoader.getIdeHelper().runInBackground(project, String.format("Updating %s Log In Credentials", updateHost.name), false, true, String.format("Updating log in credentials for %s...", updateHost.name), new Runnable() { @Override public void run() { try { AzureDockerVMOps.updateDockerHostVM( dockerManager.getSubscriptionsMap().get(updateHost.sid).azureClient, editableDockerHost.updatedDockerHost); updateHost.certVault = editableDockerHost.updatedDockerHost.certVault; updateHost.hasPwdLogIn = editableDockerHost.updatedDockerHost.hasPwdLogIn; updateHost.hasSSHLogIn = editableDockerHost.updatedDockerHost.hasSSHLogIn; updateHost.hasKeyVault = false; updateHost.certVault.uri = ""; updateHost.certVault.name = ""; Session session = AzureDockerSSHOps.createLoginInstance(updateHost); AzureDockerVMOps.UpdateCurrentDockerUser(session); updateHost.session = session; } catch (Exception ee) { if (AzureDockerUtils.DEBUG) ee.printStackTrace(); LOGGER.error("onEditDockerHostAction", ee); } updateHost.isUpdating = false; } }); } }
From source file:com.microsoft.intellij.docker.wizards.publish.AzureSelectDockerWizardDialog.java
License:Open Source License
public String deploy() { AzureDockerImageInstance dockerImageInstance = model.getDockerImageDescription(); AzureDockerPreferredSettings dockerPreferredSettings = model.getDockerHostsManager() .getDockerPreferredSettings(); if (dockerPreferredSettings == null) { dockerPreferredSettings = new AzureDockerPreferredSettings(); }//from w w w.j a v a 2 s .c o m dockerPreferredSettings.dockerApiName = dockerImageInstance.host.apiUrl; dockerPreferredSettings.dockerfileOption = dockerImageInstance.predefinedDockerfile; dockerPreferredSettings.region = dockerImageInstance.host.hostVM.region; dockerPreferredSettings.vmSize = dockerImageInstance.host.hostVM.vmSize; dockerPreferredSettings.vmOS = dockerImageInstance.host.hostOSType.name(); model.getDockerHostsManager().setDockerPreferredSettings(dockerPreferredSettings); DefaultLoader.getIdeHelper().runInBackground(model.getProject(), "Deploying Docker Container on Azure", false, true, "Deploying Web app to a Docker host on Azure...", new Runnable() { @Override public void run() { try { DefaultLoader.getIdeHelper().invokeLater(new Runnable() { @Override public void run() { AzureDockerImageInstance dockerImageInstance = model .getDockerImageDescription(); if (!dockerImageInstance.hasNewDockerHost) { Session session = null; do { try { // check if the Docker host is accessible session = AzureDockerSSHOps .createLoginInstance(dockerImageInstance.host); } catch (Exception e) { session = null; } if (session == null) { EditableDockerHost editableDockerHost = new EditableDockerHost( dockerImageInstance.host); AzureInputDockerLoginCredsDialog loginCredsDialog = new AzureInputDockerLoginCredsDialog( model.getProject(), editableDockerHost, model.getDockerHostsManager(), false); loginCredsDialog.show(); if (loginCredsDialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { // Update Docker host log in credentials DockerHost dockerHost = model.getDockerHostsManager() .getDockerHostForURL(dockerImageInstance.host.apiUrl); dockerHost.certVault = editableDockerHost.updatedDockerHost.certVault; dockerHost.hasPwdLogIn = editableDockerHost.updatedDockerHost.hasPwdLogIn; dockerHost.hasSSHLogIn = editableDockerHost.updatedDockerHost.hasSSHLogIn; dockerImageInstance.host = dockerHost; // AzureDockerVMOps.updateDockerHostVM(model.getDockerHostsManager().getSubscriptionsMap().get(model.getDockerImageDescription().sid).azureClient, editableDockerHost.updatedDockerHost); } else { return; } } } while (session == null); } Azure azureClient = model.getDockerHostsManager().getSubscriptionsMap() .get(model.getDockerImageDescription().sid).azureClient; DockerContainerDeployTask task = new DockerContainerDeployTask( model.getProject(), azureClient, model.getDockerImageDescription()); task.queue(); // Update caches here if (onCreate != null) { onCreate.run(); } } }); } catch (Exception e) { String msg = "An error occurred while attempting to deploy to the selected Docker host." + "\n" + e.getMessage(); PluginUtil.displayErrorDialogInAWTAndLog("Failed to Deploy Web App as Docker Container", msg, e); } } }); return AzureDockerUtils.getUrl(dockerImageInstance); }
From source file:com.microsoft.intellij.forms.CreateArmStorageAccountForm.java
License:Open Source License
@Override protected void doOKAction() { // final String name = nameTextField.getText(); // final String region = regionComboBox.getSelectedItem().toString(); // final String replication = replicationComboBox.getSelectedItem().toString(); // final boolean isNewResourceGroup = createNewRadioButton.isSelected(); // final String resourceGroupName = isNewResourceGroup ? resourceGrpField.getText() : resourceGrpCombo.getSelectedItem().toString(); // storageAccount = new ArmStorageAccount(name, subscription.getSubscriptionId(), null); // storageAccount.setType(replication); // storageAccount.setLocation(region); // storageAccount.setNewResourceGroup(isNewResourceGroup); // storageAccount.setResourceGroupName(resourceGroupName); // storageAccount.setKind((Kind) accoountKindCombo.getSelectedItem()); // storageAccount.setAccessTier((AccessTier)accessTeirComboBox.getSelectedItem()); // storageAccount.setEnableEncription((Boolean)encriptonComboBox.getSelectedItem()); // creating from Azure Explorer directly setSubscription((SubscriptionDetail) subscriptionComboBox.getSelectedItem()); if (subscription == null) { ProgressManager.getInstance().run(new Task.Backgroundable(project, "Creating storage account " + nameTextField.getText() + "...", false) { @Override//from w ww.ja v a2s. co m public void run(@NotNull ProgressIndicator indicator) { indicator.setIndeterminate(true); createStorageAccount(); } }); sendTelemetry(OK_EXIT_CODE); close(DialogWrapper.OK_EXIT_CODE, true); } else { //creating from 'create vm' newStorageAccount = new com.microsoft.tooling.msservices.model.storage.StorageAccount( nameTextField.getText(), subscription.getSubscriptionId()); boolean isNewResourceGroup = createNewRadioButton.isSelected(); final String resourceGroupName = isNewResourceGroup ? resourceGrpField.getText() : resourceGrpCombo.getSelectedItem().toString(); newStorageAccount.setResourceGroupName(resourceGroupName); newStorageAccount.setNewResourceGroup(isNewResourceGroup); newStorageAccount.setType(replicationComboBox.getSelectedItem().toString()); newStorageAccount.setLocation(((Location) regionComboBox.getSelectedItem()).name()); newStorageAccount.setKind((Kind) accoountKindCombo.getSelectedItem()); newStorageAccount.setAccessTier((AccessTier) accessTeirComboBox.getSelectedItem()); if (onCreate != null) { onCreate.run(); } sendTelemetry(OK_EXIT_CODE); close(DialogWrapper.OK_EXIT_CODE, true); } // ProgressManager.getInstance().run( // new Task.Modal(project, "Creating storage account", true) { // @Override // public void run(@NotNull ProgressIndicator indicator) { // indicator.setIndeterminate(true); // boolean success = createStorageAccount(); // if (success) { // ApplicationManager.getApplication().invokeLater(new Runnable() { // @Override // public void run() { // close(DialogWrapper.OK_EXIT_CODE, true); // } // }, ModalityState.any()); // // } // } // } // ); }
From source file:com.microsoft.intellij.forms.CreateBlobContainerForm.java
License:Open Source License
@Override protected void doOKAction() { final String name = nameTextField.getText(); ProgressManager.getInstance().run(new Task.Backgroundable(project, "Creating blob container...", false) { @Override/*www . ja va 2 s. c o m*/ public void run(@NotNull ProgressIndicator progressIndicator) { try { progressIndicator.setIndeterminate(true); for (BlobContainer blobContainer : StorageClientSDKManagerImpl.getManager() .getBlobContainers(storageAccount)) { if (blobContainer.getName().equals(name)) { ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { JOptionPane.showMessageDialog(null, "A blob container with the specified name already exists.", "Service Explorer", JOptionPane.ERROR_MESSAGE); } }); return; } } BlobContainer blobContainer = new BlobContainer(name, storageAccount.getBlobsUri() + name, "", Calendar.getInstance(), ""); StorageClientSDKManagerImpl.getManager().createBlobContainer(storageAccount, blobContainer); if (onCreate != null) { ApplicationManager.getApplication().invokeLater(onCreate); } } catch (AzureCmdException e) { String msg = "An error occurred while attempting to create blob container." + "\n" + String.format(message("webappExpMsg"), e.getMessage()); PluginUtil.displayErrorDialogAndLog(message("errTtl"), msg, e); } } }); this.close(DialogWrapper.OK_EXIT_CODE, true); }
From source file:com.microsoft.intellij.forms.CreateCloudServiceForm.java
License:Open Source License
@Override protected void doOKAction() { DefaultLoader.getIdeHelper().runInBackground(project, "Creating cloud service", false, true, "Creating cloud service...", new Runnable() { @Override//from w w w.ja va 2s . c o m public void run() { try { String name = nameTextField.getText(); Object regionOrAffinity = regionOrAffinityGroupComboBox.getSelectedItem(); String location = (regionOrAffinity instanceof Location) ? ((Location) regionOrAffinity).getName() : ""; String affinityGroup = (regionOrAffinity instanceof AffinityGroup) ? ((AffinityGroup) regionOrAffinity).getName() : ""; cloudService = new CloudService(name, location, affinityGroup, subscription.getId()); AzureManagerImpl.getManager().createCloudService(cloudService); } catch (Exception e) { cloudService = null; String msg = "An error occurred while attempting to create the specified cloud service." + "\n" + String.format(message("webappExpMsg"), e.getMessage()); PluginUtil.displayErrorDialogAndLog(message("errTtl"), msg, e); } DefaultLoader.getIdeHelper().invokeLater(new Runnable() { @Override public void run() { onCreate.run(); } }); } }); this.close(DialogWrapper.OK_EXIT_CODE, true); }
From source file:com.microsoft.intellij.forms.CreateMobileServiceForm.java
License:Open Source License
@Override protected void doOKAction() { final String id = ((Subscription) subscriptionComboBox.getSelectedItem()).getId(); final String name = nameTextField.getText(); final String region = regionComboBox.getSelectedItem().toString(); final String server = (serverComboBox.getSelectedItem() instanceof SqlDb ? ((SqlDb) serverComboBox.getSelectedItem()).getServer().getName() : null);//from w w w . j av a2s . c o m final String admin = serverUserNameTextField.getText(); final String pass = new String(serverPasswordPasswordField.getPassword()); final String db = (serverComboBox.getSelectedItem() instanceof SqlDb ? ((SqlDb) serverComboBox.getSelectedItem()).getName() : null); final CreateMobileServiceForm createMobileServiceForm = this; setEnabled(false); ProgressManager.getInstance().run(new Task.Backgroundable(project, "Creating service...", false) { @Override public void run(ProgressIndicator progressIndicator) { try { progressIndicator.setText2("Checking name..."); if (AzureRestAPIHelper.existsMobileService(name)) { JOptionPane.showMessageDialog(mainPanel, "The service name is used by another mobile service", "Error creating the service", JOptionPane.ERROR_MESSAGE); return; } progressIndicator.setText2("Creating service"); progressIndicator.setFraction(0.1); AzureManagerImpl.getManager().createMobileService(id, region, admin, pass, name, server, db); DefaultLoader.getIdeHelper().invokeLater(new Runnable() { @Override public void run() { serviceCreated.run(); } }); } catch (Throwable e) { AzurePlugin.log(e.getStackTrace().toString()); PluginUtil.displayErrorDialog(message("errTtl"), "An error occurred while attempting to create the mobile service."); } } }); createMobileServiceForm.close(DialogWrapper.OK_EXIT_CODE, true); }