summaryrefslogtreecommitdiff
path: root/platform/remote-servers/impl/src/com/intellij/remoteServer/util
diff options
context:
space:
mode:
Diffstat (limited to 'platform/remote-servers/impl/src/com/intellij/remoteServer/util')
-rw-r--r--platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudAccountSelectionEditor.form31
-rw-r--r--platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudAccountSelectionEditor.java304
-rw-r--r--platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudRuntimeTask.java9
-rw-r--r--platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudSupportConfigurableBase.java190
4 files changed, 185 insertions, 349 deletions
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudAccountSelectionEditor.form b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudAccountSelectionEditor.form
index bbfd6da1afcc..3e8f941ff13a 100644
--- a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudAccountSelectionEditor.form
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudAccountSelectionEditor.form
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.remoteServer.util.CloudAccountSelectionEditor">
- <grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+ <grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
@@ -8,26 +8,27 @@
<properties/>
<border type="none"/>
<children>
- <component id="82588" class="javax.swing.JComboBox" binding="myServerComboBox">
+ <vspacer id="e6946">
<constraints>
- <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
+ <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="5" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
- <properties/>
- </component>
- <grid id="27f9c" binding="myServerConfigurablePanel" custom-create="true" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
- <margin top="0" left="0" bottom="0" right="0"/>
+ </vspacer>
+ <component id="a54bb" class="javax.swing.JButton" binding="myNewButton">
<constraints>
- <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
+ <grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
- <properties/>
- <border type="none"/>
- <children/>
- </grid>
- <vspacer id="dcc88">
+ <properties>
+ <text value="New..."/>
+ </properties>
+ </component>
+ <component id="54cd4" class="com.intellij.openapi.ui.ComboBox" binding="myAccountComboBox">
<constraints>
- <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
+ <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="0" fill="1" indent="0" use-parent-layout="false">
+ <preferred-size width="200" height="-1"/>
+ </grid>
</constraints>
- </vspacer>
+ <properties/>
+ </component>
</children>
</grid>
</form>
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudAccountSelectionEditor.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudAccountSelectionEditor.java
index 7bd38b481cbb..fa4355eb356c 100644
--- a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudAccountSelectionEditor.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudAccountSelectionEditor.java
@@ -18,133 +18,164 @@ package com.intellij.remoteServer.util;
import com.intellij.execution.RunManagerEx;
import com.intellij.execution.RunnerAndConfigurationSettings;
import com.intellij.execution.configurations.ConfigurationType;
-import com.intellij.openapi.Disposable;
-import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.ide.DataManager;
+import com.intellij.ide.actions.ShowSettingsUtilImpl;
+import com.intellij.ide.util.projectWizard.WizardContext;
+import com.intellij.openapi.actionSystem.AnAction;
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModulePointer;
import com.intellij.openapi.module.ModulePointerManager;
import com.intellij.openapi.options.ConfigurationException;
+import com.intellij.openapi.options.ex.SingleConfigurableEditor;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.ComboBox;
+import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.util.Condition;
-import com.intellij.openapi.util.Disposer;
+import com.intellij.openapi.util.Key;
+import com.intellij.openapi.util.Ref;
import com.intellij.remoteServer.ServerType;
import com.intellij.remoteServer.configuration.RemoteServer;
import com.intellij.remoteServer.configuration.RemoteServersManager;
+import com.intellij.remoteServer.configuration.ServerConfiguration;
+import com.intellij.remoteServer.configuration.deployment.DeploymentConfiguration;
import com.intellij.remoteServer.impl.configuration.RemoteServerConfigurable;
import com.intellij.remoteServer.impl.configuration.deployment.DeployToServerConfigurationType;
import com.intellij.remoteServer.impl.configuration.deployment.DeployToServerRunConfiguration;
import com.intellij.remoteServer.impl.configuration.deployment.ModuleDeploymentSourceImpl;
+import com.intellij.util.Consumer;
+import com.intellij.util.containers.ContainerUtil;
+import com.intellij.util.containers.hash.HashMap;
import com.intellij.util.text.UniqueNameGenerator;
+import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.util.List;
+import java.util.Map;
-/**
- * @author michael.golubev
- */
-public class CloudAccountSelectionEditor<SC extends CloudConfigurationBase,
- DC extends CloudDeploymentNameConfiguration,
- ST extends ServerType<SC>> implements Disposable {
- private static final Logger LOG = Logger.getInstance("#" + CloudAccountSelectionEditor.class.getName());
+public class CloudAccountSelectionEditor {
- private JComboBox myServerComboBox;
- private JPanel myServerConfigurablePanel;
- private JPanel myMainPanel;
+ private static final Map<ServerType<?>, Key<RemoteServer<?>>> ourCloudType2AccountKey
+ = new HashMap<ServerType<?>, Key<RemoteServer<?>>>();
- private final ST myCloudType;
- private RemoteServer<SC> myNewServer;
- private RemoteServerConfigurable myServerConfigurable;
+ private JButton myNewButton;
+ private ComboBox myAccountComboBox;
+ private JPanel myMainPanel;
+ private final List<ServerType<?>> myCloudTypes;
- private DelayedRunner myRunner;
+ private Runnable myServerSelectionListener;
- private CloudDataLoader myDataLoader = CloudDataLoader.NULL;
+ public CloudAccountSelectionEditor(List<ServerType<?>> cloudTypes) {
+ myCloudTypes = cloudTypes;
- public CloudAccountSelectionEditor(ST cloudType) {
- myCloudType = cloudType;
- }
+ for (ServerType<?> cloudType : cloudTypes) {
+ for (RemoteServer<?> account : RemoteServersManager.getInstance().getServers(cloudType)) {
+ myAccountComboBox.addItem(new AccountItem(account));
+ }
+ }
- private void createUIComponents() {
- myServerConfigurablePanel = createServerConfigurablePanel();
- myServerConfigurablePanel.setVisible(false);
- }
+ myNewButton.addActionListener(new ActionListener() {
- public void initUI() {
- myServerComboBox.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ onNewButton();
+ }
+ });
+
+ myAccountComboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
- onAccountSelectionChanged();
+ if (myServerSelectionListener != null) {
+ myServerSelectionListener.run();
+ }
}
});
+ }
- for (RemoteServer<SC> server : RemoteServersManager.getInstance().getServers(myCloudType)) {
- myServerComboBox.addItem(new ServerItem(server));
+ public void setAccountSelectionListener(Runnable listener) {
+ myServerSelectionListener = listener;
+ }
+
+ private void onNewButton() {
+ if (myCloudTypes.size() == 1) {
+ createAccount(ContainerUtil.getFirstItem(myCloudTypes));
+ return;
}
- myServerComboBox.addItem(new ServerItem(myNewServer));
- myRunner= new DelayedRunner(myMainPanel) {
+ DefaultActionGroup group = new DefaultActionGroup();
+ for (final ServerType<?> cloudType : myCloudTypes) {
+ group.add(new AnAction(cloudType.getPresentableName(), cloudType.getPresentableName(), cloudType.getIcon()) {
- private ServerItem myPreviousServerItem;
+ @Override
+ public void actionPerformed(AnActionEvent e) {
+ createAccount(cloudType);
+ }
+ });
+ }
+ JBPopupFactory.getInstance().createActionGroupPopup("New Account", group, DataManager.getInstance().getDataContext(myMainPanel),
+ JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false)
+ .showUnderneathOf(myNewButton);
+ }
+
+ private void createAccount(ServerType<?> cloudType) {
+ RemoteServer<?> newAccount = RemoteServersManager.getInstance().createServer(cloudType, generateServerName(cloudType));
+
+ final Ref<Consumer<String>> errorConsumerRef = new Ref<Consumer<String>>();
+
+ RemoteServerConfigurable configurable = new RemoteServerConfigurable(newAccount, null, true) {
@Override
- protected boolean wasChanged() {
- ServerItem currentServerItem = getSelectedServerItem();
- boolean result = myPreviousServerItem != currentServerItem;
- if (result) {
- myPreviousServerItem = currentServerItem;
- myDataLoader.clearCloudData();
- }
- return result;
+ protected void setConnectionStatusText(boolean error, String text) {
+ super.setConnectionStatusText(error, error ? "" : text);
+ errorConsumerRef.get().consume(error ? text : null);
}
+ };
- @Override
- protected void run() {
- if (getSelectedServerItem().isNew()) {
- myServerConfigurable.setDataLoader(new CloudDataLoader() {
-
- @Override
- public void clearCloudData() {
- if (getSelectedServerItem().isNew()) {
- myDataLoader.clearCloudData();
- }
- }
-
- @Override
- public void loadCloudData() {
- if (getSelectedServerItem().isNew()) {
- myDataLoader.loadCloudData();
- }
- }
- });
- }
- else {
- myDataLoader.loadCloudData();
- }
+ final SingleConfigurableEditor configurableEditor
+ = new SingleConfigurableEditor(myMainPanel, configurable, ShowSettingsUtilImpl.createDimensionKey(configurable), false) {
+
+ {
+ errorConsumerRef.set(new Consumer<String>() {
+
+ @Override
+ public void consume(String s) {
+ setErrorText(s);
+ }
+ });
}
};
- }
- public void setDataLoader(CloudDataLoader dataLoader) {
- myDataLoader = dataLoader;
+ if (!configurableEditor.showAndGet()) {
+ return;
+ }
+
+ newAccount.setName(configurable.getDisplayName());
+
+ RemoteServersManager.getInstance().addServer(newAccount);
+ AccountItem newAccountItem = new AccountItem(newAccount);
+ myAccountComboBox.addItem(newAccountItem);
+ myAccountComboBox.setSelectedItem(newAccountItem);
}
- private void onAccountSelectionChanged() {
- myServerConfigurablePanel.setVisible(getSelectedServerItem().isNew());
+ public JComponent getMainPanel() {
+ return myMainPanel;
}
- protected JPanel createServerConfigurablePanel() {
- myNewServer = RemoteServersManager.getInstance().createServer(myCloudType, generateServerName());
- myServerConfigurable = new RemoteServerConfigurable(myNewServer, null, true);
- myServerConfigurablePanel = (JPanel)myServerConfigurable.createComponent();
- return myServerConfigurablePanel;
+ @Nullable
+ public RemoteServer<?> getSelectedAccount() {
+ AccountItem selectedItem = (AccountItem)myAccountComboBox.getSelectedItem();
+ return selectedItem == null ? null : selectedItem.getAccount();
}
- private String generateServerName() {
- return UniqueNameGenerator.generateUniqueName(myCloudType.getPresentableName(), new Condition<String>() {
+ private static String generateServerName(ServerType<?> cloudType) {
+ return UniqueNameGenerator.generateUniqueName(cloudType.getPresentableName(), new Condition<String>() {
@Override
public boolean value(String s) {
@@ -158,30 +189,60 @@ public class CloudAccountSelectionEditor<SC extends CloudConfigurationBase,
});
}
- public DeployToServerRunConfiguration<SC, DC> createRunConfiguration(Module module, DC deploymentConfiguration) {
- Project project = module.getProject();
+ public void validate() throws ConfigurationException {
+ if (getSelectedAccount() == null) {
+ throw new ConfigurationException("Account required");
+ }
+ }
- RemoteServer<SC> server = getServer();
- if (server == null) {
- return null;
+ public void setAccountOnContext(WizardContext context) {
+ RemoteServer<?> account = getSelectedAccount();
+ if (account == null) {
+ return;
}
+ context.putUserData(getKey(account.getType()), account);
+ }
+
+ public static void unsetAccountOnContext(WizardContext context, ServerType<?> cloudType) {
+ context.putUserData(getKey(cloudType), null);
+ }
+
+ private static Key<RemoteServer<?>> getKey(ServerType<?> cloudType) {
+ Key<RemoteServer<?>> result = ourCloudType2AccountKey.get(cloudType);
+ if (result == null) {
+ result = new Key<RemoteServer<?>>("cloud-account-" + cloudType.getId());
+ ourCloudType2AccountKey.put(cloudType, result);
+ }
+ return result;
+ }
- if (getSelectedServerItem().isNew()) {
- RemoteServersManager.getInstance().addServer(server);
- myNewServer = null;
+ public static void createRunConfiguration(WizardContext context,
+ ServerType<?> cloudType,
+ Module module,
+ CloudDeploymentNameConfiguration configuration) {
+ RemoteServer<?> account = context.getUserData(getKey(cloudType));
+ if (account == null) {
+ return;
}
+ createRunConfiguration(account, module, configuration);
+ }
+
+ public static <SC extends ServerConfiguration, DC extends DeploymentConfiguration>
+ DeployToServerRunConfiguration<SC, DC> createRunConfiguration(RemoteServer<SC> account, Module module, DC deploymentConfiguration) {
- String serverName = server.getName();
+ Project project = module.getProject();
- String name = generateRunConfigurationName(serverName, module.getName());
+ String accountName = account.getName();
+
+ String name = generateRunConfigurationName(accountName, module.getName());
final RunManagerEx runManager = RunManagerEx.getInstanceEx(project);
final RunnerAndConfigurationSettings runSettings
- = runManager.createRunConfiguration(name, getRunConfigurationType().getConfigurationFactories()[0]);
+ = runManager.createRunConfiguration(name, getRunConfigurationType(account.getType()).getConfigurationFactories()[0]);
final DeployToServerRunConfiguration<SC, DC> result = (DeployToServerRunConfiguration<SC, DC>)runSettings.getConfiguration();
- result.setServerName(serverName);
+ result.setServerName(accountName);
final ModulePointer modulePointer = ModulePointerManager.getInstance(project).create(module);
result.setDeploymentSource(new ModuleDeploymentSourceImpl(modulePointer));
@@ -194,43 +255,8 @@ public class CloudAccountSelectionEditor<SC extends CloudConfigurationBase,
return result;
}
- protected String generateRunConfigurationName(String serverName, String moduleName) {
- return CloudBundle.getText("run.configuration.name", serverName, moduleName);
- }
-
- protected void handleError(ConfigurationException e) {
- LOG.info(e);
- }
-
- public RemoteServer<SC> getServer() {
- try {
- return doGetServer();
- }
- catch (ConfigurationException e) {
- handleError(e);
- return null;
- }
- }
-
- private RemoteServer<SC> doGetServer() throws ConfigurationException {
- ServerItem serverItem = getSelectedServerItem();
- if (serverItem.isNew()) {
- myServerConfigurable.apply();
- myNewServer.setName(myServerConfigurable.getDisplayName());
- }
- return serverItem.getServer();
- }
-
- public void validate() throws ConfigurationException {
- doGetServer();
- }
-
- private ServerItem getSelectedServerItem() {
- return (ServerItem)myServerComboBox.getSelectedItem();
- }
-
- private DeployToServerConfigurationType getRunConfigurationType() {
- String id = DeployToServerConfigurationType.getId(myCloudType);
+ private static DeployToServerConfigurationType getRunConfigurationType(ServerType<?> cloudType) {
+ String id = DeployToServerConfigurationType.getId(cloudType);
for (ConfigurationType configurationType : ConfigurationType.CONFIGURATION_TYPE_EP.getExtensions()) {
if (configurationType instanceof DeployToServerConfigurationType) {
DeployToServerConfigurationType deployConfigurationType = (DeployToServerConfigurationType)configurationType;
@@ -242,35 +268,25 @@ public class CloudAccountSelectionEditor<SC extends CloudConfigurationBase,
return null;
}
- public JPanel getMainPanel() {
- return myMainPanel;
- }
-
- @Override
- public void dispose() {
- myServerConfigurable.disposeUIResources();
- Disposer.dispose(myRunner);
+ private static String generateRunConfigurationName(String serverName, String moduleName) {
+ return CloudBundle.getText("run.configuration.name", serverName, moduleName);
}
- private class ServerItem {
+ private static class AccountItem {
- private final RemoteServer<SC> myServer;
-
- public ServerItem(RemoteServer<SC> server) {
- myServer = server;
- }
+ private final RemoteServer<?> myAccount;
- public boolean isNew() {
- return myServer == myNewServer;
+ public AccountItem(RemoteServer<?> account) {
+ myAccount = account;
}
- public RemoteServer<SC> getServer() {
- return myServer;
+ public RemoteServer<?> getAccount() {
+ return myAccount;
}
@Override
public String toString() {
- return isNew() ? "New account..." : myServer.getName();
+ return myAccount.getName();
}
}
}
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudRuntimeTask.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudRuntimeTask.java
index 1e0326471d75..c8109dce3d29 100644
--- a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudRuntimeTask.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudRuntimeTask.java
@@ -109,6 +109,11 @@ public abstract class CloudRuntimeTask<
public void run(@NotNull ProgressIndicator indicator) {
progressive.run(indicator);
}
+
+ @Override
+ public boolean shouldStartInBackground() {
+ return CloudRuntimeTask.this.shouldStartInBackground();
+ }
};
}
@@ -122,6 +127,10 @@ public abstract class CloudRuntimeTask<
return result.get();
}
+ protected boolean shouldStartInBackground() {
+ return true;
+ }
+
protected void postPerform(T result) {
}
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudSupportConfigurableBase.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudSupportConfigurableBase.java
deleted file mode 100644
index 421e75da7eae..000000000000
--- a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudSupportConfigurableBase.java
+++ /dev/null
@@ -1,190 +0,0 @@
-package com.intellij.remoteServer.util;
-
-import com.intellij.ProjectTopics;
-import com.intellij.ide.util.frameworkSupport.FrameworkSupportConfigurable;
-import com.intellij.ide.util.frameworkSupport.FrameworkSupportModel;
-import com.intellij.openapi.module.Module;
-import com.intellij.openapi.options.ConfigurationException;
-import com.intellij.openapi.project.ModuleAdapter;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.startup.StartupManager;
-import com.intellij.openapi.ui.MessageType;
-import com.intellij.openapi.util.Disposer;
-import com.intellij.remoteServer.ServerType;
-import com.intellij.remoteServer.configuration.RemoteServer;
-import com.intellij.remoteServer.runtime.Deployment;
-import com.intellij.remoteServer.runtime.ServerConnection;
-import com.intellij.remoteServer.runtime.ServerConnector;
-import com.intellij.remoteServer.runtime.deployment.ServerRuntimeInstance;
-import com.intellij.util.concurrency.Semaphore;
-import com.intellij.util.messages.MessageBusConnection;
-import com.intellij.util.ui.UIUtil;
-import org.jetbrains.annotations.NotNull;
-
-import javax.swing.*;
-import java.util.Collection;
-import java.util.concurrent.atomic.AtomicReference;
-
-/**
- * @author michael.golubev
- */
-public abstract class CloudSupportConfigurableBase<
- SC extends CloudConfigurationBase,
- DC extends CloudDeploymentNameConfiguration,
- SR extends CloudMultiSourceServerRuntimeInstance<DC, ?, ?, ?>,
- ST extends ServerType<SC>>
- extends FrameworkSupportConfigurable implements CloudDataLoader {
-
- private final ST myCloudType;
- private final Project myModelProject;
-
- private final CloudNotifier myNotifier;
-
- private boolean myInitialized = false;
-
- private CloudAccountSelectionEditor<SC, DC, ST> myAccountSelectionEditor;
-
- public CloudSupportConfigurableBase(ST cloudType, FrameworkSupportModel frameworkSupportModel) {
- myCloudType = cloudType;
- myModelProject = frameworkSupportModel.getProject();
- myNotifier = new CloudNotifier(cloudType.getPresentableName());
- }
-
- @Override
- public void dispose() {
- Disposer.dispose(getAccountSelectionEditor());
- }
-
- protected void initUI() {
- getAccountSelectionEditor().initUI();
- }
-
- @Override
- public void clearCloudData() {
- getExistingComboBox().removeAllItems();
- }
-
- @Override
- public void loadCloudData() {
- new ConnectionTask<Collection<Deployment>>("Loading existing applications list") {
-
- @Override
- protected void run(final ServerConnection<DC> connection,
- final Semaphore semaphore,
- final AtomicReference<Collection<Deployment>> result) {
- connection.connectIfNeeded(new ServerConnector.ConnectionCallback<DC>() {
-
- @Override
- public void connected(@NotNull ServerRuntimeInstance<DC> serverRuntimeInstance) {
- connection.computeDeployments(new Runnable() {
-
- @Override
- public void run() {
- result.set(connection.getDeployments());
- semaphore.up();
- UIUtil.invokeLaterIfNeeded(new Runnable() {
- @Override
- public void run() {
- if (!Disposer.isDisposed(CloudSupportConfigurableBase.this)) {
- setupExistingApplications(result.get());
- }
- }
- });
- }
- });
- }
-
- @Override
- public void errorOccurred(@NotNull String errorMessage) {
- runtimeErrorOccurred(errorMessage);
- semaphore.up();
- }
- });
- }
-
- @Override
- protected Collection<Deployment> run(SR serverRuntimeInstance) throws ServerRuntimeException {
- return null;
- }
- }.performAsync();
- }
-
- private void setupExistingApplications(Collection<Deployment> deployments) {
- JComboBox existingComboBox = getExistingComboBox();
- existingComboBox.removeAllItems();
- for (Deployment deployment : deployments) {
- existingComboBox.addItem(deployment.getName());
- }
- }
-
- @Override
- public void onFrameworkSelectionChanged(boolean selected) {
- if (selected && !myInitialized) {
- myInitialized = true;
- initUI();
- updateApplicationUI();
- }
- }
-
- protected void showMessage(String message, MessageType messageType) {
- getNotifier().showMessage(message, messageType);
- }
-
- protected Project getProject() {
- return myModelProject;
- }
-
- protected RemoteServer<SC> getServer() {
- return getAccountSelectionEditor().getServer();
- }
-
- protected void runOnModuleAdded(final Module module, final Runnable runnable) {
- if (myModelProject == null) {
- StartupManager.getInstance(module.getProject()).runWhenProjectIsInitialized(runnable);
- }
- else {
- MessageBusConnection connection = myModelProject.getMessageBus().connect(myModelProject);
- connection.subscribe(ProjectTopics.MODULES, new ModuleAdapter() {
-
- public void moduleAdded(Project project, Module addedModule) {
- if (addedModule == module) {
- runnable.run();
- }
- }
- });
- }
- }
-
- protected CloudAccountSelectionEditor<SC, DC, ST> getAccountSelectionEditor() {
- if (myAccountSelectionEditor == null) {
- myAccountSelectionEditor = new CloudAccountSelectionEditor<SC, DC, ST>(myCloudType) {
-
- @Override
- protected void handleError(ConfigurationException e) {
- getNotifier().showMessage(e.getMessage(), MessageType.ERROR);
- }
- };
- myAccountSelectionEditor.setDataLoader(this);
- }
- return myAccountSelectionEditor;
- }
-
- protected CloudNotifier getNotifier() {
- return myNotifier;
- }
-
- protected abstract JComboBox getExistingComboBox();
-
- protected abstract void updateApplicationUI();
-
- protected abstract class ConnectionTask<T> extends CloudConnectionTask<T, SC, DC, SR> {
-
- public ConnectionTask(String title) {
- super(myModelProject, title, CloudSupportConfigurableBase.this.getServer());
- }
-
- public ConnectionTask(Module module, String title) {
- super(module.getProject(), title, CloudSupportConfigurableBase.this.getServer());
- }
- }
-}