tuleap # 265 Multiple server dialogs popup if I press more
than once on the server field of the dashboard.
Change-Id: I3b69509ec0f544b4ec2a58458ced3aa228b61ebf
Signed-off-by: Jacques Bouthillier <lmcbout@gmail.com>
diff --git a/org.eclipse.egerrit.dashboard.ui/src/org/eclipse/egerrit/internal/dashboard/ui/views/GerritTableView.java b/org.eclipse.egerrit.dashboard.ui/src/org/eclipse/egerrit/internal/dashboard/ui/views/GerritTableView.java
index cb4bcaa..beacf24 100644
--- a/org.eclipse.egerrit.dashboard.ui/src/org/eclipse/egerrit/internal/dashboard/ui/views/GerritTableView.java
+++ b/org.eclipse.egerrit.dashboard.ui/src/org/eclipse/egerrit/internal/dashboard/ui/views/GerritTableView.java
@@ -123,6 +123,8 @@
private static final String JOB_FAMILY = "DASHBOARD_UI"; //$NON-NLS-1$
+ private AddOneServerDialog fAddOneServerDialog = null;
+
// For the images
private static ImageRegistry fImageRegistry = new ImageRegistry();
@@ -612,12 +614,16 @@
if (defaultServerInfo == null) {
UIUtils.showNoServerMessage();
- final AddOneServerDialog addOneServer = new AddOneServerDialog();
- Display.getDefault().syncExec(() -> addOneServer.promptForNewServer(true));
- defaultServerInfo = addOneServer.getServer();
- if (defaultServerInfo == null) {
- logger.debug("No new server entered by the user. "); //$NON-NLS-1$
- return;
+ //Only one instance of the pop-up
+ if (fAddOneServerDialog == null) {
+ fAddOneServerDialog = new AddOneServerDialog();
+ Display.getDefault().syncExec(() -> fAddOneServerDialog.promptForNewServer(true));
+ defaultServerInfo = fAddOneServerDialog.getServer();
+ fAddOneServerDialog = null; //reset the instance
+ if (defaultServerInfo == null) {
+ logger.debug("No new server entered by the user. "); //$NON-NLS-1$
+ return;
+ }
}
}
@@ -1121,9 +1127,17 @@
}
private void addOrChangeServerThenLoad() {
- final AddOneServerDialog addOneServer = new AddOneServerDialog();
- addOneServer.promptToModifyServer(defaultServerInfo, true);
- defaultServerInfo = addOneServer.getServer();
+ //Only one instance of the pop-up
+ if (fAddOneServerDialog == null) {
+ fAddOneServerDialog = new AddOneServerDialog();
+ fAddOneServerDialog.promptToModifyServer(defaultServerInfo, true);
+ defaultServerInfo = fAddOneServerDialog.getServer();
+ fAddOneServerDialog = null; //Reset the instance
+ if (defaultServerInfo == null) {
+ logger.debug("No new server entered by the user."); //$NON-NLS-1$
+ return;
+ }
+ }
if (defaultServerInfo == null) {
logger.debug("No new server entered by the user."); //$NON-NLS-1$
return;