Merge "Omaha #3269 - Fix editing of Notifiers before saving Amend - Remove save confirmation dialog, rename buttons" into omaha_14.4.1

Former-commit-id: f118e1b0e9 [formerly cd10372371 [formerly 4ac8246386] [formerly f118e1b0e9 [formerly 88280dedea4b6065a5603ac26e982eab0a2e0e72]]]
Former-commit-id: cd10372371 [formerly 4ac8246386]
Former-commit-id: cd10372371
Former-commit-id: 57366a56b7
This commit is contained in:
Nate Jensen 2014-06-12 12:36:14 -05:00 committed by Gerrit Code Review
commit 5e98231c33
2 changed files with 29 additions and 23 deletions

View file

@ -65,6 +65,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Feb 20, 2014 2632 mpduff Initial creation * Feb 20, 2014 2632 mpduff Initial creation
* Mar 27, 2014 2632 mpduff Corrected the OK, Apply, Cancel actions * Mar 27, 2014 2632 mpduff Corrected the OK, Apply, Cancel actions
* Jun 12, 2014 3269 mpduff Corrected button state.
* *
* </pre> * </pre>
* *
@ -135,6 +136,7 @@ public class ContactNotifierPreferencePage extends PreferencePage implements
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
editNotifierTask(); editNotifierTask();
setButtonState();
} }
}); });
@ -176,6 +178,7 @@ public class ContactNotifierPreferencePage extends PreferencePage implements
taskList.clear(); taskList.clear();
taskList.addAll(dataMap.values()); taskList.addAll(dataMap.values());
} }
dataMap.clear();
for (NotifierTask task : taskList) { for (NotifierTask task : taskList) {
dataMap.put(task.getUserName(), task); dataMap.put(task.getUserName(), task);
} }
@ -204,11 +207,12 @@ public class ContactNotifierPreferencePage extends PreferencePage implements
@Override @Override
public void dialogClosed(Object returnValue) { public void dialogClosed(Object returnValue) {
updatePrefs((Map<String, NotifierTask>) returnValue); updatePrefs((Map<String, NotifierTask>) returnValue);
setButtonState();
} }
}; };
AddNotifierDlg dlg = new AddNotifierDlg(getShell(), AddNotifierDlg dlg = new AddNotifierDlg(getShell(),
new String[] { task.getUserName() }, callback); new String[] { task.getUserName() }, true, dataMap, callback);
dlg.open(); dlg.open();
} }
} }
@ -247,7 +251,7 @@ public class ContactNotifierPreferencePage extends PreferencePage implements
setButtonState(); setButtonState();
} }
}; };
AddNotifierDlg dlg = new AddNotifierDlg(getShell(), contacts, AddNotifierDlg dlg = new AddNotifierDlg(getShell(), contacts, false, dataMap,
callback); callback);
dlg.open(); dlg.open();
} else { } else {
@ -257,6 +261,8 @@ public class ContactNotifierPreferencePage extends PreferencePage implements
.setMessage("User must be logged in to Collaboration to add contact notifiers."); .setMessage("User must be logged in to Collaboration to add contact notifiers.");
messageDialog.open(); messageDialog.open();
} }
setButtonState();
} }
/** /**

View file

@ -21,8 +21,8 @@ package com.raytheon.uf.viz.collaboration.ui.session;
import java.io.File; import java.io.File;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
@ -68,6 +68,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
* Feb 20, 2014 2632 mpduff Initial creation * Feb 20, 2014 2632 mpduff Initial creation
* Mar 05, 2014 2632 mpduff Changed task set to map of user->task. * 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. * 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.
* *
* </pre> * </pre>
* *
@ -84,7 +85,7 @@ public class AddNotifierDlg extends CaveSWTDialog {
private final Map<Button, Notifier> buttonMap = new HashMap<Button, Notifier>(); private final Map<Button, Notifier> buttonMap = new HashMap<Button, Notifier>();
/** Set of NotifierTask objects */ /** Set of NotifierTask objects */
private final Map<String, NotifierTask> taskMap = new HashMap<String, NotifierTask>(); private Map<String, NotifierTask> taskMap = new HashMap<String, NotifierTask>();
/** The user select Combo box */ /** The user select Combo box */
private Combo userCbo; private Combo userCbo;
@ -101,8 +102,8 @@ public class AddNotifierDlg extends CaveSWTDialog {
/** Close callback */ /** Close callback */
private final ICloseCallback callback; private final ICloseCallback callback;
/** The class return value */ /** Flag for dialog mode, edit or new */
private boolean returnValue = false; private boolean editFlag;
/** /**
* Constructor. * Constructor.
@ -111,16 +112,22 @@ public class AddNotifierDlg extends CaveSWTDialog {
* @param userIds * @param userIds
* @param callback * @param callback
*/ */
public AddNotifierDlg(Shell parent, String[] userIds, public AddNotifierDlg(Shell parent, String[] userIds, boolean editFlag, Map<String, NotifierTask> taskMap,
ICloseCallback callback) { ICloseCallback callback) {
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK); 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.userIds = userIds;
this.callback = callback; this.callback = callback;
this.editFlag = editFlag;
this.taskMap = taskMap;
} }
public AddNotifierDlg(Shell parent, String[] userIds) { 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); comp.setLayoutData(gd);
GridData btnData = new GridData(75, SWT.DEFAULT); GridData btnData = new GridData(75, SWT.DEFAULT);
Button addBtn = new Button(comp, SWT.PUSH); Button okBtn = new Button(comp, SWT.PUSH);
addBtn.setText("Add"); okBtn.setText("OK");
addBtn.setLayoutData(btnData); okBtn.setLayoutData(btnData);
addBtn.addSelectionListener(new SelectionAdapter() { okBtn.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent event) { public void widgetSelected(SelectionEvent event) {
addNotifierTask(); addNotifierTask();
returnValue = true; close();
} }
}); });
btnData = new GridData(75, SWT.DEFAULT); btnData = new GridData(75, SWT.DEFAULT);
Button cancelBtn = new Button(comp, SWT.PUSH); Button cancelBtn = new Button(comp, SWT.PUSH);
cancelBtn.setText("Close"); cancelBtn.setText("Cancel");
cancelBtn.setLayoutData(btnData); cancelBtn.setLayoutData(btnData);
cancelBtn.addSelectionListener(new SelectionAdapter() { cancelBtn.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent event) { public void widgetSelected(SelectionEvent event) {
returnValue = false;
close(); close();
} }
}); });
@ -342,7 +348,7 @@ public class AddNotifierDlg extends CaveSWTDialog {
*/ */
@Override @Override
protected void opened() { protected void opened() {
List<NotifierTask> taskList = NotifierTools.getNotifierTasks(); Collection<NotifierTask> taskList = taskMap.values();
for (NotifierTask task : taskList) { for (NotifierTask task : taskList) {
this.taskMap.put(task.getUserName(), task); this.taskMap.put(task.getUserName(), task);
if (task.getUserName().equals(userCbo.getText())) { if (task.getUserName().equals(userCbo.getText())) {
@ -418,12 +424,6 @@ public class AddNotifierDlg extends CaveSWTDialog {
this.taskMap.put(task.getUserName(), task); this.taskMap.put(task.getUserName(), task);
updatePreferences(); updatePreferences();
MessageBox messageDialog = new MessageBox(this.getShell(), SWT.OK);
messageDialog.setText("Notifier Saved");
messageDialog
.setMessage("The contact notifier was successfully saved.");
messageDialog.open();
} }
/** /**