Merge "Issue #2632 - Fixed notifier preference OK, Apply, Cancel actions" into development
Former-commit-id:95710fff2a
[formerlya69165b4db
] [formerlye7882b1409
] [formerly5af9c9113c
[formerlye7882b1409
[formerly 723d44e31b8aad30428a3c1fd024b05555b4e9af]]] Former-commit-id:5af9c9113c
Former-commit-id: 1196279dfcb99aa5ff7ca86319c6b157a1e5fc53 [formerlyca19d00b1d
] Former-commit-id:219be3e2e3
This commit is contained in:
commit
b9a24788bc
5 changed files with 129 additions and 42 deletions
|
@ -36,6 +36,7 @@ import org.jivesoftware.smack.RosterGroup;
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Jan 23, 2014 2701 bclement Initial creation
|
* Jan 23, 2014 2701 bclement Initial creation
|
||||||
* Feb 17, 2014 2800 bclement added equals/hashcode
|
* Feb 17, 2014 2800 bclement added equals/hashcode
|
||||||
|
* Mar 27, 2014 2632 mpduff Changed to call a convenience method.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -101,7 +102,7 @@ public class SharedGroup {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
SharedGroup other = (SharedGroup) obj;
|
SharedGroup other = (SharedGroup) obj;
|
||||||
return this.delegate.getName().equals(other.getName());
|
return this.getName().equals(other.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialogBase;
|
||||||
* Feb 11, 2014 2699 bclement require non-blank handle
|
* Feb 11, 2014 2699 bclement require non-blank handle
|
||||||
* Feb 13, 2014 2751 bclement better types for roomid and inviter
|
* Feb 13, 2014 2751 bclement better types for roomid and inviter
|
||||||
* Mar 06, 2014 2848 bclement moved join logic to separate method
|
* Mar 06, 2014 2848 bclement moved join logic to separate method
|
||||||
|
* Mar 27, 2014 2632 mpduff Set the OK button as the default button.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -77,15 +78,15 @@ public class InviteDialog extends CaveSWTDialogBase {
|
||||||
/** Main composite. */
|
/** Main composite. */
|
||||||
private Composite mainComp;
|
private Composite mainComp;
|
||||||
|
|
||||||
private String inviter;
|
private final String inviter;
|
||||||
|
|
||||||
private String subject;
|
private final String subject;
|
||||||
|
|
||||||
private String room;
|
private final String room;
|
||||||
|
|
||||||
private String inviteText;
|
private final String inviteText;
|
||||||
|
|
||||||
private String message;
|
private final String message;
|
||||||
|
|
||||||
private Font font;
|
private Font font;
|
||||||
|
|
||||||
|
@ -93,9 +94,9 @@ public class InviteDialog extends CaveSWTDialogBase {
|
||||||
|
|
||||||
private VenueSession session;
|
private VenueSession session;
|
||||||
|
|
||||||
private boolean sharedDisplay;
|
private final boolean sharedDisplay;
|
||||||
|
|
||||||
private IVenueInvitationEvent event;
|
private final IVenueInvitationEvent event;
|
||||||
|
|
||||||
private Text errorMessage;
|
private Text errorMessage;
|
||||||
|
|
||||||
|
@ -292,6 +293,8 @@ public class InviteDialog extends CaveSWTDialogBase {
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.getShell().setDefaultButton(okBtn);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -28,6 +28,7 @@ import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlElements;
|
import javax.xml.bind.annotation.XmlElements;
|
||||||
|
|
||||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||||
|
import com.raytheon.uf.common.util.StringUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notifier Task. Holds a list of {@link Notifier} actions.
|
* Notifier Task. Holds a list of {@link Notifier} actions.
|
||||||
|
@ -38,7 +39,8 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||||
*
|
*
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Feb 20, 2014 2632 mpduff Initial creation
|
* Feb 20, 2014 2632 mpduff Initial creation.
|
||||||
|
* Mar 27, 2014 2632 mpduff Implemented toString()
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -234,4 +236,22 @@ public class NotifierTask {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see java.lang.Object#toString()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
String nl = StringUtil.NEWLINE;
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("User: " + this.userName).append(nl);
|
||||||
|
sb.append("Sound: " + this.soundFilePath).append(nl);
|
||||||
|
for (Notifier notifier : this.notifierList) {
|
||||||
|
sb.append(notifier.getDescription()).append(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* 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
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -90,7 +91,7 @@ public class ContactNotifierPreferencePage extends PreferencePage implements
|
||||||
.getNotifierTasks();
|
.getNotifierTasks();
|
||||||
|
|
||||||
/** Data map backing the notifier list */
|
/** Data map backing the notifier list */
|
||||||
private final Map<String, NotifierTask> dataMap = new HashMap<String, NotifierTask>();
|
private Map<String, NotifierTask> dataMap = new HashMap<String, NotifierTask>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
|
@ -160,7 +161,7 @@ public class ContactNotifierPreferencePage extends PreferencePage implements
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
populate();
|
populate(true);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -168,8 +169,13 @@ public class ContactNotifierPreferencePage extends PreferencePage implements
|
||||||
/**
|
/**
|
||||||
* Populate the list.
|
* Populate the list.
|
||||||
*/
|
*/
|
||||||
private void populate() {
|
private void populate(boolean reload) {
|
||||||
|
if (reload) {
|
||||||
taskList = NotifierTools.getNotifierTasks();
|
taskList = NotifierTools.getNotifierTasks();
|
||||||
|
} else {
|
||||||
|
taskList.clear();
|
||||||
|
taskList.addAll(dataMap.values());
|
||||||
|
}
|
||||||
for (NotifierTask task : taskList) {
|
for (NotifierTask task : taskList) {
|
||||||
dataMap.put(task.getUserName(), task);
|
dataMap.put(task.getUserName(), task);
|
||||||
}
|
}
|
||||||
|
@ -184,11 +190,25 @@ public class ContactNotifierPreferencePage extends PreferencePage implements
|
||||||
* Edit the notifier task.
|
* Edit the notifier task.
|
||||||
*/
|
*/
|
||||||
private void editNotifierTask() {
|
private void editNotifierTask() {
|
||||||
|
if (notifierList.getSelectionIndex() == -1) {
|
||||||
|
MessageBox messageDialog = new MessageBox(this.getShell(), SWT.OK);
|
||||||
|
messageDialog.setText("Select User");
|
||||||
|
messageDialog.setMessage("Please select a user to edit.");
|
||||||
|
messageDialog.open();
|
||||||
|
return;
|
||||||
|
}
|
||||||
String user = notifierList.getItem(notifierList.getSelectionIndex());
|
String user = notifierList.getItem(notifierList.getSelectionIndex());
|
||||||
NotifierTask task = dataMap.get(user);
|
NotifierTask task = dataMap.get(user);
|
||||||
if (task != null) {
|
if (task != null) {
|
||||||
|
ICloseCallback callback = new ICloseCallback() {
|
||||||
|
@Override
|
||||||
|
public void dialogClosed(Object returnValue) {
|
||||||
|
updatePrefs((Map<String, NotifierTask>) returnValue);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
AddNotifierDlg dlg = new AddNotifierDlg(getShell(),
|
AddNotifierDlg dlg = new AddNotifierDlg(getShell(),
|
||||||
new String[] { task.getUserName() });
|
new String[] { task.getUserName() }, callback);
|
||||||
dlg.open();
|
dlg.open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,8 +217,15 @@ public class ContactNotifierPreferencePage extends PreferencePage implements
|
||||||
* Delete the notifier task.
|
* Delete the notifier task.
|
||||||
*/
|
*/
|
||||||
private void deleteNotifierTask() {
|
private void deleteNotifierTask() {
|
||||||
|
if (notifierList.getSelectionIndex() == -1) {
|
||||||
|
MessageBox messageDialog = new MessageBox(this.getShell(), SWT.OK);
|
||||||
|
messageDialog.setText("Select User");
|
||||||
|
messageDialog.setMessage("Please select a user to delete.");
|
||||||
|
messageDialog.open();
|
||||||
|
return;
|
||||||
|
}
|
||||||
String user = notifierList.getItem(notifierList.getSelectionIndex());
|
String user = notifierList.getItem(notifierList.getSelectionIndex());
|
||||||
NotifierTask task = dataMap.get(user);
|
NotifierTask task = dataMap.remove(user);
|
||||||
if (task != null) {
|
if (task != null) {
|
||||||
taskList.remove(task);
|
taskList.remove(task);
|
||||||
notifierList.remove(notifierList.getSelectionIndex());
|
notifierList.remove(notifierList.getSelectionIndex());
|
||||||
|
@ -206,19 +233,6 @@ public class ContactNotifierPreferencePage extends PreferencePage implements
|
||||||
setButtonState();
|
setButtonState();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the state of the buttons.
|
|
||||||
*/
|
|
||||||
private void setButtonState() {
|
|
||||||
if (notifierList.getSelectionCount() > 0) {
|
|
||||||
deleteBtn.setEnabled(true);
|
|
||||||
editBtn.setEnabled(true);
|
|
||||||
} else {
|
|
||||||
deleteBtn.setEnabled(false);
|
|
||||||
editBtn.setEnabled(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new notifier task.
|
* Create a new notifier task.
|
||||||
*/
|
*/
|
||||||
|
@ -229,7 +243,8 @@ public class ContactNotifierPreferencePage extends PreferencePage implements
|
||||||
ICloseCallback callback = new ICloseCallback() {
|
ICloseCallback callback = new ICloseCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void dialogClosed(Object returnValue) {
|
public void dialogClosed(Object returnValue) {
|
||||||
populate();
|
updatePrefs((Map<String, NotifierTask>) returnValue);
|
||||||
|
setButtonState();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
AddNotifierDlg dlg = new AddNotifierDlg(getShell(), contacts,
|
AddNotifierDlg dlg = new AddNotifierDlg(getShell(), contacts,
|
||||||
|
@ -244,6 +259,19 @@ public class ContactNotifierPreferencePage extends PreferencePage implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the state of the buttons.
|
||||||
|
*/
|
||||||
|
private void setButtonState() {
|
||||||
|
if (notifierList.getSelectionCount() > 0) {
|
||||||
|
deleteBtn.setEnabled(true);
|
||||||
|
editBtn.setEnabled(true);
|
||||||
|
} else {
|
||||||
|
deleteBtn.setEnabled(false);
|
||||||
|
editBtn.setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the contacts.
|
* Get the contacts.
|
||||||
*
|
*
|
||||||
|
@ -275,9 +303,35 @@ public class ContactNotifierPreferencePage extends PreferencePage implements
|
||||||
return users.toArray(new String[users.size()]);
|
return users.toArray(new String[users.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update with the new settings.
|
||||||
|
*/
|
||||||
|
private void updatePrefs(Map<String, NotifierTask> dataMap) {
|
||||||
|
this.dataMap = dataMap;
|
||||||
|
populate(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.jface.preference.PreferencePage#performOk()
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean performOk() {
|
public boolean performOk() {
|
||||||
NotifierTools.saveNotifiers(taskList);
|
performApply();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.jface.preference.PreferencePage#performApply()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void performApply() {
|
||||||
|
taskList.clear();
|
||||||
|
taskList.addAll(dataMap.values());
|
||||||
|
NotifierTools.saveNotifiers(taskList);
|
||||||
|
setButtonState();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
package com.raytheon.uf.viz.collaboration.ui.session;
|
package com.raytheon.uf.viz.collaboration.ui.session;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -66,6 +67,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.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -395,6 +397,7 @@ public class AddNotifierDlg extends CaveSWTDialog {
|
||||||
usernames[i] = userIds[i];
|
usernames[i] = userIds[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Arrays.sort(usernames);
|
||||||
return usernames;
|
return usernames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,17 +417,23 @@ public class AddNotifierDlg extends CaveSWTDialog {
|
||||||
task.setRecurring(recurringRdo.getSelection());
|
task.setRecurring(recurringRdo.getSelection());
|
||||||
this.taskMap.put(task.getUserName(), task);
|
this.taskMap.put(task.getUserName(), task);
|
||||||
|
|
||||||
if (NotifierTools.saveNotifiers(Lists.newArrayList(taskMap.values()))) {
|
updatePreferences();
|
||||||
|
|
||||||
MessageBox messageDialog = new MessageBox(this.getShell(), SWT.OK);
|
MessageBox messageDialog = new MessageBox(this.getShell(), SWT.OK);
|
||||||
messageDialog.setText("Notifier Saved");
|
messageDialog.setText("Notifier Saved");
|
||||||
messageDialog
|
messageDialog
|
||||||
.setMessage("The contact notifier was successfully saved.");
|
.setMessage("The contact notifier was successfully saved.");
|
||||||
messageDialog.open();
|
messageDialog.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the preferences.
|
||||||
|
*/
|
||||||
|
private void updatePreferences() {
|
||||||
|
if (this.callback == null) {
|
||||||
|
NotifierTools.saveNotifiers(Lists.newArrayList(taskMap.values()));
|
||||||
} else {
|
} else {
|
||||||
MessageBox messageDialog = new MessageBox(this.getShell(), SWT.OK);
|
callback.dialogClosed(taskMap);
|
||||||
messageDialog.setText("Save Failed");
|
|
||||||
messageDialog.setMessage("The contact notifier failed to save.");
|
|
||||||
messageDialog.open();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -436,7 +445,7 @@ public class AddNotifierDlg extends CaveSWTDialog {
|
||||||
@Override
|
@Override
|
||||||
protected void disposed() {
|
protected void disposed() {
|
||||||
if (this.callback != null) {
|
if (this.callback != null) {
|
||||||
callback.dialogClosed(returnValue);
|
callback.dialogClosed(taskMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue