diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/ContactNotifierPreferencePage.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/ContactNotifierPreferencePage.java index eba3ea36d2..eb6dbbeae4 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/ContactNotifierPreferencePage.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/ContactNotifierPreferencePage.java @@ -65,6 +65,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback; * ------------ ---------- ----------- -------------------------- * Feb 20, 2014 2632 mpduff Initial creation * Mar 27, 2014 2632 mpduff Corrected the OK, Apply, Cancel actions + * Jun 12, 2014 3269 mpduff Corrected button state. * * * @@ -135,6 +136,7 @@ public class ContactNotifierPreferencePage extends PreferencePage implements @Override public void widgetSelected(SelectionEvent e) { editNotifierTask(); + setButtonState(); } }); @@ -176,6 +178,7 @@ public class ContactNotifierPreferencePage extends PreferencePage implements taskList.clear(); taskList.addAll(dataMap.values()); } + dataMap.clear(); for (NotifierTask task : taskList) { dataMap.put(task.getUserName(), task); } @@ -204,11 +207,12 @@ public class ContactNotifierPreferencePage extends PreferencePage implements @Override public void dialogClosed(Object returnValue) { updatePrefs((Map) returnValue); + setButtonState(); } }; AddNotifierDlg dlg = new AddNotifierDlg(getShell(), - new String[] { task.getUserName() }, callback); + new String[] { task.getUserName() }, true, dataMap, callback); dlg.open(); } } @@ -247,7 +251,7 @@ public class ContactNotifierPreferencePage extends PreferencePage implements setButtonState(); } }; - AddNotifierDlg dlg = new AddNotifierDlg(getShell(), contacts, + AddNotifierDlg dlg = new AddNotifierDlg(getShell(), contacts, false, dataMap, callback); dlg.open(); } else { @@ -257,6 +261,8 @@ public class ContactNotifierPreferencePage extends PreferencePage implements .setMessage("User must be logged in to Collaboration to add contact notifiers."); messageDialog.open(); } + + setButtonState(); } /** diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/AddNotifierDlg.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/AddNotifierDlg.java index 6c84c05321..9bdc7a54b8 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/AddNotifierDlg.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/AddNotifierDlg.java @@ -21,8 +21,8 @@ package com.raytheon.uf.viz.collaboration.ui.session; import java.io.File; import java.util.Arrays; +import java.util.Collection; import java.util.HashMap; -import java.util.List; import java.util.Map; import org.eclipse.swt.SWT; @@ -68,6 +68,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback; * Feb 20, 2014 2632 mpduff Initial creation * Mar 05, 2014 2632 mpduff Changed task set to map of user->task. * Mar 27, 2014 2632 mpduff Sorted users in combo box, changed how Add action works. + * Jun 12, 2014 3269 mpduff Changed to use the unsaved values upon open. * * * @@ -84,7 +85,7 @@ public class AddNotifierDlg extends CaveSWTDialog { private final Map buttonMap = new HashMap(); /** Set of NotifierTask objects */ - private final Map taskMap = new HashMap(); + private Map taskMap = new HashMap(); /** The user select Combo box */ private Combo userCbo; @@ -101,8 +102,8 @@ public class AddNotifierDlg extends CaveSWTDialog { /** Close callback */ private final ICloseCallback callback; - /** The class return value */ - private boolean returnValue = false; + /** Flag for dialog mode, edit or new */ + private boolean editFlag; /** * Constructor. @@ -111,16 +112,22 @@ public class AddNotifierDlg extends CaveSWTDialog { * @param userIds * @param callback */ - public AddNotifierDlg(Shell parent, String[] userIds, + public AddNotifierDlg(Shell parent, String[] userIds, boolean editFlag, Map taskMap, ICloseCallback callback) { super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK); - setText("Add Notifier"); + if (editFlag) { + setText("Edit Notifier"); + } else { + setText("Add Notifier"); + } this.userIds = userIds; this.callback = callback; + this.editFlag = editFlag; + this.taskMap = taskMap; } public AddNotifierDlg(Shell parent, String[] userIds) { - this(parent, userIds, null); + this(parent, userIds, false, null, null); } /* @@ -311,25 +318,24 @@ public class AddNotifierDlg extends CaveSWTDialog { comp.setLayoutData(gd); GridData btnData = new GridData(75, SWT.DEFAULT); - Button addBtn = new Button(comp, SWT.PUSH); - addBtn.setText("Add"); - addBtn.setLayoutData(btnData); - addBtn.addSelectionListener(new SelectionAdapter() { + Button okBtn = new Button(comp, SWT.PUSH); + okBtn.setText("OK"); + okBtn.setLayoutData(btnData); + okBtn.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { addNotifierTask(); - returnValue = true; + close(); } }); btnData = new GridData(75, SWT.DEFAULT); Button cancelBtn = new Button(comp, SWT.PUSH); - cancelBtn.setText("Close"); + cancelBtn.setText("Cancel"); cancelBtn.setLayoutData(btnData); cancelBtn.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { - returnValue = false; close(); } }); @@ -342,7 +348,7 @@ public class AddNotifierDlg extends CaveSWTDialog { */ @Override protected void opened() { - List taskList = NotifierTools.getNotifierTasks(); + Collection taskList = taskMap.values(); for (NotifierTask task : taskList) { this.taskMap.put(task.getUserName(), task); if (task.getUserName().equals(userCbo.getText())) { @@ -418,12 +424,6 @@ public class AddNotifierDlg extends CaveSWTDialog { this.taskMap.put(task.getUserName(), task); updatePreferences(); - - MessageBox messageDialog = new MessageBox(this.getShell(), SWT.OK); - messageDialog.setText("Notifier Saved"); - messageDialog - .setMessage("The contact notifier was successfully saved."); - messageDialog.open(); } /**