Omaha #3269 - Fix editing of Notifiers before saving

Amend - Remove save confirmation dialog, rename buttons

Change-Id: I0dd81db4c74d07f0535341fc410c288b077463c4

Former-commit-id: 522d3c70f2 [formerly 80922824a3] [formerly c920a24300 [formerly 47d57692c81757a8b8c0d3217e21f701f18cdf2c]]
Former-commit-id: c920a24300
Former-commit-id: b15b6514fd
This commit is contained in:
Mike Duff 2014-06-12 10:48:30 -05:00
parent 990b79ddb3
commit 0bdefaabdd
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
* Mar 27, 2014 2632 mpduff Corrected the OK, Apply, Cancel actions
* Jun 12, 2014 3269 mpduff Corrected button state.
*
* </pre>
*
@ -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<String, NotifierTask>) 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();
}
/**

View file

@ -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.
*
* </pre>
*
@ -84,7 +85,7 @@ public class AddNotifierDlg extends CaveSWTDialog {
private final Map<Button, Notifier> buttonMap = new HashMap<Button, Notifier>();
/** 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 */
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<String, NotifierTask> 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<NotifierTask> taskList = NotifierTools.getNotifierTasks();
Collection<NotifierTask> 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();
}
/**