Merge "Issue #2632 - Fixed notifier preference OK, Apply, Cancel actions" into development
Former-commit-id:95710fff2a
[formerlya69165b4db
] [formerlye7882b1409
] [formerly95710fff2a
[formerlya69165b4db
] [formerlye7882b1409
] [formerly5af9c9113c
[formerlye7882b1409
[formerly 723d44e31b8aad30428a3c1fd024b05555b4e9af]]]] Former-commit-id:5af9c9113c
Former-commit-id:b9a24788bc
[formerly219be3e2e3
] [formerly 1196279dfcb99aa5ff7ca86319c6b157a1e5fc53 [formerlyca19d00b1d
]] Former-commit-id: 04399542fb3cd59e9e4877f1d6c9c41c32332ddd [formerly582aa4c699
] Former-commit-id:6d34715e21
This commit is contained in:
commit
22028c8e80
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
|
||||
* Feb 17, 2014 2800 bclement added equals/hashcode
|
||||
* Mar 27, 2014 2632 mpduff Changed to call a convenience method.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -101,7 +102,7 @@ public class SharedGroup {
|
|||
return false;
|
||||
}
|
||||
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 13, 2014 2751 bclement better types for roomid and inviter
|
||||
* 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>
|
||||
*
|
||||
|
@ -77,15 +78,15 @@ public class InviteDialog extends CaveSWTDialogBase {
|
|||
/** Main composite. */
|
||||
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;
|
||||
|
||||
|
@ -93,9 +94,9 @@ public class InviteDialog extends CaveSWTDialogBase {
|
|||
|
||||
private VenueSession session;
|
||||
|
||||
private boolean sharedDisplay;
|
||||
private final boolean sharedDisplay;
|
||||
|
||||
private IVenueInvitationEvent event;
|
||||
private final IVenueInvitationEvent event;
|
||||
|
||||
private Text errorMessage;
|
||||
|
||||
|
@ -292,6 +293,8 @@ public class InviteDialog extends CaveSWTDialogBase {
|
|||
close();
|
||||
}
|
||||
});
|
||||
|
||||
this.getShell().setDefaultButton(okBtn);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -302,7 +305,7 @@ public class InviteDialog extends CaveSWTDialogBase {
|
|||
* @throws CollaborationException
|
||||
*/
|
||||
public void join(IVenueInvitationEvent invitation, String handle)
|
||||
throws CollaborationException {
|
||||
throws CollaborationException {
|
||||
String venueName = invitation.getRoomId().getName();
|
||||
CollaborationConnection connection = CollaborationConnection
|
||||
.getConnection();
|
||||
|
|
|
@ -28,6 +28,7 @@ import javax.xml.bind.annotation.XmlElement;
|
|||
import javax.xml.bind.annotation.XmlElements;
|
||||
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.util.StringUtil;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 20, 2014 2632 mpduff Initial creation
|
||||
* Feb 20, 2014 2632 mpduff Initial creation.
|
||||
* Mar 27, 2014 2632 mpduff Implemented toString()
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -234,4 +236,22 @@ public class NotifierTask {
|
|||
}
|
||||
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
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 20, 2014 2632 mpduff Initial creation
|
||||
* Mar 27, 2014 2632 mpduff Corrected the OK, Apply, Cancel actions
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -90,7 +91,7 @@ public class ContactNotifierPreferencePage extends PreferencePage implements
|
|||
.getNotifierTasks();
|
||||
|
||||
/** 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}
|
||||
|
@ -160,7 +161,7 @@ public class ContactNotifierPreferencePage extends PreferencePage implements
|
|||
}
|
||||
});
|
||||
|
||||
populate();
|
||||
populate(true);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -168,8 +169,13 @@ public class ContactNotifierPreferencePage extends PreferencePage implements
|
|||
/**
|
||||
* Populate the list.
|
||||
*/
|
||||
private void populate() {
|
||||
taskList = NotifierTools.getNotifierTasks();
|
||||
private void populate(boolean reload) {
|
||||
if (reload) {
|
||||
taskList = NotifierTools.getNotifierTasks();
|
||||
} else {
|
||||
taskList.clear();
|
||||
taskList.addAll(dataMap.values());
|
||||
}
|
||||
for (NotifierTask task : taskList) {
|
||||
dataMap.put(task.getUserName(), task);
|
||||
}
|
||||
|
@ -184,11 +190,25 @@ public class ContactNotifierPreferencePage extends PreferencePage implements
|
|||
* Edit the notifier task.
|
||||
*/
|
||||
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());
|
||||
NotifierTask task = dataMap.get(user);
|
||||
if (task != null) {
|
||||
ICloseCallback callback = new ICloseCallback() {
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
updatePrefs((Map<String, NotifierTask>) returnValue);
|
||||
}
|
||||
};
|
||||
|
||||
AddNotifierDlg dlg = new AddNotifierDlg(getShell(),
|
||||
new String[] { task.getUserName() });
|
||||
new String[] { task.getUserName() }, callback);
|
||||
dlg.open();
|
||||
}
|
||||
}
|
||||
|
@ -197,8 +217,15 @@ public class ContactNotifierPreferencePage extends PreferencePage implements
|
|||
* Delete the notifier task.
|
||||
*/
|
||||
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());
|
||||
NotifierTask task = dataMap.get(user);
|
||||
NotifierTask task = dataMap.remove(user);
|
||||
if (task != null) {
|
||||
taskList.remove(task);
|
||||
notifierList.remove(notifierList.getSelectionIndex());
|
||||
|
@ -206,19 +233,6 @@ public class ContactNotifierPreferencePage extends PreferencePage implements
|
|||
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.
|
||||
*/
|
||||
|
@ -229,7 +243,8 @@ public class ContactNotifierPreferencePage extends PreferencePage implements
|
|||
ICloseCallback callback = new ICloseCallback() {
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
populate();
|
||||
updatePrefs((Map<String, NotifierTask>) returnValue);
|
||||
setButtonState();
|
||||
}
|
||||
};
|
||||
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.
|
||||
*
|
||||
|
@ -275,9 +303,35 @@ public class ContactNotifierPreferencePage extends PreferencePage implements
|
|||
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
|
||||
public boolean performOk() {
|
||||
NotifierTools.saveNotifiers(taskList);
|
||||
performApply();
|
||||
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;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -66,6 +67,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.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -395,6 +397,7 @@ public class AddNotifierDlg extends CaveSWTDialog {
|
|||
usernames[i] = userIds[i];
|
||||
}
|
||||
|
||||
Arrays.sort(usernames);
|
||||
return usernames;
|
||||
}
|
||||
|
||||
|
@ -414,17 +417,23 @@ public class AddNotifierDlg extends CaveSWTDialog {
|
|||
task.setRecurring(recurringRdo.getSelection());
|
||||
this.taskMap.put(task.getUserName(), task);
|
||||
|
||||
if (NotifierTools.saveNotifiers(Lists.newArrayList(taskMap.values()))) {
|
||||
MessageBox messageDialog = new MessageBox(this.getShell(), SWT.OK);
|
||||
messageDialog.setText("Notifier Saved");
|
||||
messageDialog
|
||||
.setMessage("The contact notifier was successfully saved.");
|
||||
messageDialog.open();
|
||||
updatePreferences();
|
||||
|
||||
MessageBox messageDialog = new MessageBox(this.getShell(), SWT.OK);
|
||||
messageDialog.setText("Notifier Saved");
|
||||
messageDialog
|
||||
.setMessage("The contact notifier was successfully saved.");
|
||||
messageDialog.open();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the preferences.
|
||||
*/
|
||||
private void updatePreferences() {
|
||||
if (this.callback == null) {
|
||||
NotifierTools.saveNotifiers(Lists.newArrayList(taskMap.values()));
|
||||
} else {
|
||||
MessageBox messageDialog = new MessageBox(this.getShell(), SWT.OK);
|
||||
messageDialog.setText("Save Failed");
|
||||
messageDialog.setMessage("The contact notifier failed to save.");
|
||||
messageDialog.open();
|
||||
callback.dialogClosed(taskMap);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -436,7 +445,7 @@ public class AddNotifierDlg extends CaveSWTDialog {
|
|||
@Override
|
||||
protected void disposed() {
|
||||
if (this.callback != null) {
|
||||
callback.dialogClosed(returnValue);
|
||||
callback.dialogClosed(taskMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue