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.forms.CreateOffice365ApplicationForm.java
License:Open Source License
@Override protected void doOKAction() { final CreateOffice365ApplicationForm form = this; DefaultLoader.getIdeHelper().runInBackground(project, "Registering Office 365 Application", false, true, "Registering Office 365 Application...", new Runnable() { @Override/* w ww .jav a2s .c o m*/ public void run() { try { final String name = nameTextField.getText(); final String replyURL = redirectURITextField.getText(); Application application = new Application(); application.setdisplayName(name); application.setreplyUrls(Lists.newArrayList(replyURL)); application.sethomepage(replyURL); application.setavailableToOtherTenants(multiTenantCheckBox.isSelected()); application.setpublicClient(true); Futures.addCallback(Office365ManagerImpl.getManager().registerApplication(application), new FutureCallback<Application>() { @Override public void onSuccess(final Application application) { ApplicationManager.getApplication().invokeAndWait(new Runnable() { @Override public void run() { setApplication(application); if (onRegister != null) { onRegister.run(); } } }, ModalityState.any()); } @Override public void onFailure(final Throwable throwable) { ApplicationManager.getApplication().invokeAndWait(new Runnable() { @Override public void run() { DefaultLoader.getUIHelper().showException( "An error occurred while attempting to register the Office 365 application.", throwable, "Microsoft Cloud Services For Android - Error Registering Office 365 Application", false, true); } }, ModalityState.any()); } }); } catch (Throwable e) { form.getWindow().setCursor(Cursor.getDefaultCursor()); DefaultLoader.getUIHelper().showException( "An error occurred while attempting to register the Office 365 application.", e, "Microsoft Cloud Services For Android - Error Registering Office 365 Application", false, true); } } }); form.close(DialogWrapper.OK_EXIT_CODE, true); }
From source file:com.microsoft.intellij.forms.CreateQueueForm.java
License:Open Source License
@Override protected void doOKAction() { final String name = nameTextField.getText(); ProgressManager.getInstance().run(new Task.Backgroundable(project, "Creating queue...", false) { @Override// ww w . java 2 s . c o m public void run(@NotNull ProgressIndicator progressIndicator) { try { progressIndicator.setIndeterminate(true); for (Queue queue : StorageClientSDKManagerImpl.getManager().getQueues(storageAccount)) { if (queue.getName().equals(name)) { DefaultLoader.getIdeHelper().invokeLater(new Runnable() { @Override public void run() { JOptionPane.showMessageDialog(null, "A queue with the specified name already exists.", "Service Explorer", JOptionPane.ERROR_MESSAGE); } }); return; } } Queue queue = new Queue(name, "", 0); StorageClientSDKManagerImpl.getManager().createQueue(storageAccount, queue); if (onCreate != null) { DefaultLoader.getIdeHelper().invokeLater(onCreate); } } catch (AzureCmdException e) { String msg = "An error occurred while attempting to create queue." + "\n" + String.format(message("webappExpMsg"), e.getMessage()); PluginUtil.displayErrorDialogAndLog(message("errTtl"), msg, e); } } }); close(DialogWrapper.OK_EXIT_CODE, true); }
From source file:com.microsoft.intellij.forms.CreateRedisCacheForm.java
License:Open Source License
private void onOK() { try {/*from w ww .ja v a2 s . co m*/ Azure azure = azureManager.getAzure(currentSub.getSubscriptionId()); setSubscription(currentSub); ProcessingStrategy processor = RedisCacheUtil.doGetProcessor(azure, skus, redisCacheNameValue, selectedLocationValue, selectedResGrpValue, selectedPriceTierValue, noSSLPort, newResGrp); ExecutorService executor = Executors.newSingleThreadExecutor(); ListeningExecutorService executorService = MoreExecutors.listeningDecorator(executor); ListenableFuture<Void> futureTask = executorService.submit(new CreateRedisCallable(processor)); final ProcessingStrategy processorInner = processor; Futures.addCallback(futureTask, new FutureCallback<Void>() { @Override public void onSuccess(Void arg0) { if (onCreate != null) { onCreate.run(); } } @Override public void onFailure(Throwable throwable) { JOptionPane.showMessageDialog(null, throwable.getMessage(), "Error occurred when creating Redis Cache: " + redisCacheNameValue, JOptionPane.ERROR_MESSAGE, null); try { // notify the waitting thread the thread being waited incurred exception to clear blocking queue processorInner.notifyCompletion(); } catch (InterruptedException ex) { String msg = String.format(CREATING_ERROR_INDICATOR, "notifyCompletion", ex.getMessage()); PluginUtil.displayErrorDialogAndLog(message("errTtl"), msg, ex); } } }); close(DialogWrapper.OK_EXIT_CODE, true); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:com.microsoft.intellij.forms.CreateStorageAccountForm.java
License:Open Source License
@Override protected void doOKAction() { final String name = nameTextField.getText(); final String region = (regionOrAffinityGroupComboBox.getSelectedItem() instanceof Location) ? regionOrAffinityGroupComboBox.getSelectedItem().toString() : ""; final String affinityGroup = (regionOrAffinityGroupComboBox.getSelectedItem() instanceof AffinityGroup) ? regionOrAffinityGroupComboBox.getSelectedItem().toString() : ""; final String replication = replicationComboBox.getSelectedItem().toString(); DefaultLoader.getIdeHelper().runInBackground(project, "Creating storage account", false, true, "Creating storage account...", new Runnable() { @Override//from w w w .j a va2 s . co m public void run() { try { storageAccount = new StorageAccount(name, subscription.getId().toString()); storageAccount.setType(replication); storageAccount.setLocation(region); storageAccount.setAffinityGroup(affinityGroup); AzureManagerImpl.getManager().createStorageAccount(storageAccount); AzureManagerImpl.getManager().refreshStorageAccountInformation(storageAccount); DefaultLoader.getIdeHelper().invokeLater(new Runnable() { @Override public void run() { if (onCreate != null) { onCreate.run(); } } }); } catch (AzureCmdException e) { storageAccount = null; String msg = "An error occurred while attempting to create the specified storage account." + "\n" + String.format(message("webappExpMsg"), e.getMessage()); PluginUtil.displayErrorDialogAndLog(message("errTtl"), msg, e); } } }); close(DialogWrapper.OK_EXIT_CODE, true); }
From source file:com.microsoft.intellij.forms.CreateTableForm.java
License:Open Source License
@Override protected void doOKAction() { final String name = nameTextField.getText(); ProgressManager.getInstance().run(new Task.Backgroundable(project, "Creating table...", false) { @Override// ww w .ja va 2s. c o m public void run(@NotNull ProgressIndicator progressIndicator) { try { progressIndicator.setIndeterminate(true); for (Table table : StorageClientSDKManagerImpl.getManager().getTables(storageAccount)) { if (table.getName().equals(name)) { DefaultLoader.getIdeHelper().invokeLater(new Runnable() { @Override public void run() { JOptionPane.showMessageDialog(null, "A table with the specified name already exists.", "Service Explorer", JOptionPane.ERROR_MESSAGE); } }); return; } } Table table = new Table(name, ""); StorageClientSDKManagerImpl.getManager().createTable(storageAccount, table); if (onCreate != null) { DefaultLoader.getIdeHelper().invokeLater(onCreate); } } catch (AzureCmdException e) { String msg = "An error occurred while attempting to create table." + "\n" + String.format(message("webappExpMsg"), e.getMessage()); PluginUtil.displayErrorDialogAndLog(message("errTtl"), msg, e); } } }); close(DialogWrapper.OK_EXIT_CODE, true); }
From source file:com.microsoft.intellij.forms.CreateVirtualNetworkForm.java
License:Open Source License
@Override protected void doOKAction() { network = new VirtualNetwork(nameField.getText().trim(), addressSpaceField.getText().trim(), subnetNameField.getText().trim(), subnetAddressRangeField.getText().trim()); DefaultLoader.getIdeHelper().invokeLater(new Runnable() { @Override//from w w w.j av a 2s. c o m public void run() { if (onCreate != null) { onCreate.run(); } } }); sendTelemetry(OK_EXIT_CODE); close(DialogWrapper.OK_EXIT_CODE, true); // ProgressManager.getInstance().run( // new Task.Modal(project, "Creating virtual network", true) { // @Override // public void run(@NotNull ProgressIndicator indicator) { // indicator.setIndeterminate(true); // boolean success = createVirtualNetwork(); // 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.CustomAPIForm.java
License:Open Source License
@Override protected void doOKAction() { final String apiName = tableNameTextField.getText().trim(); final CustomAPIPermissions permissions = new CustomAPIPermissions(); permissions.setPatchPermission(((PermissionItem) patchPermissionComboBox.getSelectedItem()).getType()); permissions.setDeletePermission(((PermissionItem) deletePermissionComboBox.getSelectedItem()).getType()); permissions.setGetPermission(((PermissionItem) getPermissionComboBox.getSelectedItem()).getType()); permissions.setPostPermission(((PermissionItem) postPermissionComboBox.getSelectedItem()).getType()); permissions.setPutPermission(((PermissionItem) putPermissionComboBox.getSelectedItem()).getType()); DefaultLoader.getIdeHelper().runInBackground(project, "Saving Custom API", false, true, "Saving Custom API", new Runnable() { @Override//from w w w.j a va 2 s .c o m public void run() { try { if (existingApiNames == null) { existingApiNames = new ArrayList<String>(); for (CustomAPI api : AzureManagerImpl.getManager().getAPIList(subscriptionId, serviceName)) { existingApiNames.add(api.getName().toLowerCase()); } } if (editingCustomAPI == null && existingApiNames.contains(apiName.toLowerCase())) { JOptionPane.showMessageDialog(mainPanel, "Invalid API name. An API with that name already exists in this service.", "Service Explorer", JOptionPane.ERROR_MESSAGE); return; } if (editingCustomAPI == null) { AzureManagerImpl.getManager().createCustomAPI(subscriptionId, serviceName, apiName, permissions); } else { AzureManagerImpl.getManager().updateCustomAPI(subscriptionId, serviceName, apiName, permissions); editingCustomAPI.setCustomAPIPermissions(permissions); } DefaultLoader.getIdeHelper().invokeLater(new Runnable() { @Override public void run() { if (afterSave != null) { afterSave.run(); } } }); } catch (Throwable e) { AzurePlugin.log(e.getStackTrace().toString()); PluginUtil.displayErrorDialog(message("errTtl"), "An error occurred while attempting to save the table."); } } }); close(DialogWrapper.OK_EXIT_CODE, true); }
From source file:com.microsoft.intellij.forms.ExternalStorageAccountForm.java
License:Open Source License
@Override protected void doOKAction() { try {//from w ww .ja v a 2 s . c o m //Validate querystring by making a request StorageClientSDKManagerImpl.getManager().getTables(StorageClientSDKManagerImpl.getManager() .getStorageAccount(getFullStorageAccount().getConnectionString())); } catch (AzureCmdException e) { JOptionPane.showMessageDialog(contentPane, "The storage account contains invalid values. More information:\n" + e.getCause().getMessage(), "Service Explorer", JOptionPane.ERROR_MESSAGE); return; } if (onFinish != null) { onFinish.run(); } close(DialogWrapper.OK_EXIT_CODE, true); }
From source file:com.microsoft.intellij.forms.ImportSubscriptionForm.java
License:Open Source License
@Override protected void doOKAction() { try {/*from ww w. j a v a 2 s .co m*/ // Note: these 2 operations always go together, as apiManager imports .publishsettings for Azure Explorer // and handleFile() caches it for Azure Toolkit plugin AzureManager apiManager = AzureManagerImpl.getManager(); if (apiManager.authenticated()) { apiManager.clearAuthentication(); WizardCacheManager.getPublishDatas().clear(); } apiManager.clearAuthentication(); apiManager.importPublishSettingsFile(txtFile.getText()); MethodUtils.handleFile(txtFile.getText(), myProject); if (onSubscriptionLoaded != null) onSubscriptionLoaded.run(); close(DialogWrapper.OK_EXIT_CODE, true); } catch (Throwable e) { AzurePlugin.log(e.getStackTrace().toString()); PluginUtil.displayErrorDialog(message("errTtl"), "An error occurred while attempting to import the subscription."); } }
From source file:com.microsoft.intellij.forms.JobForm.java
License:Open Source License
@Override protected void doOKAction() { final String jobName = jobNameTextField.getText().trim(); final int interval = onDemandRadioButton.isSelected() ? 0 : parseInt(intervalTextField.getText()); final String unit = onDemandRadioButton.isSelected() ? "none" : Job.getUnits()[intervalUnitComboBox.getSelectedIndex()]; final SimpleDateFormat ISO8601DATEFORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.ENGLISH);/*w w w . j a va2 s . c o m*/ DefaultLoader.getIdeHelper().runInBackground(project, "Saving job", false, true, "Saving job...", new Runnable() { @Override public void run() { try { String now = ISO8601DATEFORMAT.format(new Date()); if (id == null) { List<String> existingJobNames = new ArrayList<String>(); for (Job job : AzureManagerImpl.getManager().listJobs(subscriptionId, serviceName)) { existingJobNames.add(job.getName().toLowerCase()); } if (existingJobNames.contains(jobName.toLowerCase())) { JOptionPane.showMessageDialog(mainPanel, "Invalid job name. A job with that name already exists in this service.", "Service Explorer", JOptionPane.ERROR_MESSAGE); return; } } if (id == null) AzureManagerImpl.getManager().createJob(subscriptionId, serviceName, jobName, interval, unit, now); else { AzureManagerImpl.getManager().updateJob(subscriptionId, serviceName, jobName, interval, unit, now, enabledCheckBox.isSelected()); } DefaultLoader.getIdeHelper().invokeLater(new Runnable() { @Override public void run() { if (afterSave != null) { afterSave.run(); } } }); } catch (Throwable ex) { AzurePlugin.log(ex.getStackTrace().toString()); PluginUtil.displayErrorDialog(message("errTtl"), "An error occurred while trying to save job."); } } }); close(DialogWrapper.OK_EXIT_CODE, true); }