@Override protected void uploadKey(final File sskKey) { FeatureUsageTracker.getInstance() .triggerFeatureUsed(CloudFeaturesProvider.UPLOAD_SSH_KEY_FEATURE_ID); try { myServerConfigurable.apply(); } catch (ConfigurationException e) { Messages.showErrorDialog("Cannot upload SSH key: " + e.getMessage(), e.getTitle()); return; } RemoteServer<C> server = new RemoteServerImpl<C>( "<temp server to upload ssh key>", myServerType, myServerConfiguration); CloudConnectionTask task = new CloudConnectionTask(null, "Uploading SSH key", server) { @Override protected Object run(CloudServerRuntimeInstance serverRuntime) throws ServerRuntimeException { ((SshKeyAwareServerRuntime) serverRuntime).addSshKey(sskKey); return null; } }; task.performSync(); task.showMessageDialog(myLabel, "SSH key was uploaded", "Public SSH Key"); }
@Override protected void uploadKey(final File sskKey) { new CloudConnectionTask(myProject, "Uploading SSH key", myConnectionTask.getServer()) { @Override protected Object run(CloudServerRuntimeInstance serverRuntime) throws ServerRuntimeException { ((SshKeyAwareServerRuntime) serverRuntime).addSshKey(sskKey); myErrorNotification.expire(); myNotifier.showMessage( "SSH key was uploaded, you may <a href=\"#\">reconnect</a>", MessageType.INFO, new NotificationListener() { @Override public void hyperlinkUpdate( @NotNull Notification notification, @NotNull HyperlinkEvent event) { notification.expire(); reconnect(); } }); return null; } @Override protected void runtimeErrorOccurred(@NotNull String errorMessage) { myNotifier.showMessage(errorMessage, MessageType.ERROR); } }.performSync(); }
private void reconnect() { myConnectionTask.performAsync(); }