Issue #642 alert words now filter what directory is shown

Former-commit-id: c5509344e9 [formerly df7971ed32994f6ac52ac10fcb03945d57eb5872]
Former-commit-id: 82cad97932
This commit is contained in:
Matt Nash 2012-06-01 10:40:18 -05:00
parent 08ad661af4
commit e8355a9a2b
7 changed files with 462 additions and 118 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 575 B

View file

@ -278,6 +278,25 @@ public class CollaborationUtils {
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
file = PathManagerFactory.getPathManager().getLocalizationFile(context,
"collaboration" + File.separator + "alertWords.xml");
// save the sound file in the correct place if not there
for (AlertWord word : words) {
String soundPath = word.getSoundPath();
if (soundPath != null && !soundPath.isEmpty()) {
String[] dirs = soundPath.split(File.separator);
String filename = dirs[dirs.length - 1];
LocalizationFile lFile = pm.getLocalizationFile(context,
"collaboration" + File.separator + "sounds"
+ File.separator + filename);
if (!lFile.exists()) {
File soundFile = new File(soundPath);
File destination = lFile.getFile();
soundFile.renameTo(destination);
}
}
}
AlertWordWrapper wrapper = new AlertWordWrapper();
wrapper.setAlertWords(words.toArray(new AlertWord[0]));
JAXB.marshal(wrapper, file.getFile());

View file

@ -19,6 +19,7 @@
**/
package com.raytheon.uf.viz.collaboration.ui.prefs;
import java.io.File;
import java.util.List;
import org.eclipse.jface.preference.ColorFieldEditor;
@ -43,6 +44,12 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.PathManager;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection;
import com.raytheon.uf.viz.collaboration.data.AlertWord;
import com.raytheon.uf.viz.collaboration.data.AlertWordWrapper;
@ -139,6 +146,16 @@ public class CollaborationAlertWordsPreferencePage extends
final FileFieldEditor fileEditor = new FileFieldEditor("fileeditor",
"Sound File", getFieldEditorParent());
PathManager manager = (PathManager) PathManagerFactory.getPathManager();
LocalizationContext context = manager.getContext(
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
LocalizationFile file = manager.getLocalizationFile(context,
"collaboration" + File.separator + "sounds" + File.separator);
if (!file.exists()) {
file.getFile().mkdirs();
}
fileEditor.setFilterPath(file.getFile());
this.addField(fileEditor);
fontButton.addSelectionListener(new SelectionAdapter() {

View file

@ -66,6 +66,7 @@ import com.raytheon.uf.viz.collaboration.data.AlertWord;
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
import com.raytheon.uf.viz.collaboration.ui.Activator;
import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.icon.IconUtil;
import com.raytheon.uf.viz.notification.notifier.PopupNotifier;
import com.raytheon.viz.ui.views.CaveFloatingView;
@ -269,124 +270,141 @@ public abstract class AbstractSessionView extends CaveFloatingView {
appendMessage(userId, timestamp, body);
}
public void appendMessage(UserId userId, long timestamp, String body) {
IWorkbenchSiteProgressService service = (IWorkbenchSiteProgressService) getSite()
.getAdapter(IWorkbenchSiteProgressService.class);
service.warnOfContentChange();
public void appendMessage(final UserId userId, final long timestamp,
final String body) {
VizApp.runAsync(new Runnable() {
@Override
public void run() {
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(timestamp);
String time = String.format("%1$tI:%1$tM:%1$tS %1$Tp", cal);
IWorkbenchSiteProgressService service = (IWorkbenchSiteProgressService) getSite()
.getAdapter(IWorkbenchSiteProgressService.class);
service.warnOfContentChange();
UserId myUser = CollaborationDataManager.getInstance()
.getCollaborationConnection(true).getUser();
if (!myUser.equals(userId)
&& Activator.getDefault().getPreferenceStore()
.getBoolean("notifications")) {
createNotifier(userId, time, body);
}
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(timestamp);
String time = String.format("%1$tI:%1$tM:%1$tS %1$Tp", cal);
String name = null;
if (userId != null) {
name = userId.getName();
for (UserId id : userIds) {
if (id.equals(userId)) {
name = id.getAlias();
break;
UserId myUser = CollaborationDataManager.getInstance()
.getCollaborationConnection(true).getUser();
if (!myUser.equals(userId)
&& Activator.getDefault().getPreferenceStore()
.getBoolean("notifications")) {
createNotifier(userId, time, body);
}
}
} else {
name = getPartName();
}
StringBuilder sb = new StringBuilder();
if (messagesText.getCharCount() != 0) {
sb.append("\n");
}
sb.append("(").append(time).append(") ");
int offset = sb.length();
sb.append(name).append(": ").append(body);
// here is the place to put the font and color changes for keywords
// read in localization file once and then don't read in again, per
// chat room?
List<AlertWord> alertWords = retrieveAlertWords();
List<StyleRange> ranges = new ArrayList<StyleRange>();
if (alertWords != null) {
for (AlertWord keyword : alertWords) {
String text = keyword.getText().toLowerCase();
if (sb.toString().toLowerCase().contains(text)) {
String lowerCase = sb.toString().toLowerCase();
// getting the current length of the text
int currentLength = messagesText.getCharCount();
int index = lowerCase.indexOf(text);
while (index >= 0) {
Font font = null;
// storing off fonts so we don't leak
if (fonts.containsKey(keyword.getFont())) {
font = fonts.get(keyword.getFont());
} else {
FontData fd = StringConverter.asFontData(keyword
.getFont());
font = new Font(Display.getCurrent(), fd);
fonts.put(keyword.getFont(), font);
String name = null;
if (userId != null) {
name = userId.getName();
for (UserId id : userIds) {
if (id.equals(userId)) {
name = id.getAlias();
break;
}
}
} else {
name = "";
}
RGB rgb = new RGB(keyword.getRed(), keyword.getGreen(),
keyword.getBlue());
Color color = null;
// using the stored colors so we don't leak
if (colors.containsKey(rgb)) {
color = colors.get(rgb);
} else {
color = new Color(Display.getCurrent(), rgb);
colors.put(rgb, color);
}
TextStyle style = new TextStyle(font, color, null);
StyleRange keywordRange = new StyleRange(style);
keywordRange.start = currentLength + index;
keywordRange.length = keyword.getText().length();
StringBuilder sb = new StringBuilder();
if (messagesText.getCharCount() != 0) {
sb.append("\n");
}
sb.append("(").append(time).append(") ");
int offset = sb.length();
ranges.add(keywordRange);
// compare to see if this position is already styled
List<StyleRange> rnges = new ArrayList<StyleRange>();
rnges.addAll(ranges);
for (StyleRange range : rnges) {
if (range.start <= keywordRange.start
&& (range.start + range.length) >= keywordRange.start) {
if (keywordRange != range) {
if (range.length < keywordRange.length) {
ranges.remove(range);
} else {
ranges.remove(keywordRange);
sb.append(name).append(": ").append(body);
// here is the place to put the font and color changes for
// keywords
// read in localization file once and then don't read in again,
// per
// chat room?
List<AlertWord> alertWords = retrieveAlertWords();
List<StyleRange> ranges = new ArrayList<StyleRange>();
if (alertWords != null) {
for (AlertWord keyword : alertWords) {
String text = keyword.getText().toLowerCase();
if (sb.toString().toLowerCase().contains(text)) {
String lowerCase = sb.toString().toLowerCase();
// getting the current length of the text
int currentLength = messagesText.getCharCount();
int index = lowerCase.indexOf(text);
while (index >= 0) {
Font font = null;
// storing off fonts so we don't leak
if (fonts.containsKey(keyword.getFont())) {
font = fonts.get(keyword.getFont());
} else {
FontData fd = StringConverter
.asFontData(keyword.getFont());
font = new Font(Display.getCurrent(), fd);
fonts.put(keyword.getFont(), font);
}
RGB rgb = new RGB(keyword.getRed(), keyword
.getGreen(), keyword.getBlue());
Color color = null;
// using the stored colors so we don't leak
if (colors.containsKey(rgb)) {
color = colors.get(rgb);
} else {
color = new Color(Display.getCurrent(), rgb);
colors.put(rgb, color);
}
TextStyle style = new TextStyle(font, color,
null);
StyleRange keywordRange = new StyleRange(style);
keywordRange.start = currentLength + index;
keywordRange.length = keyword.getText()
.length();
ranges.add(keywordRange);
// compare to see if this position is already
// styled
List<StyleRange> rnges = new ArrayList<StyleRange>();
rnges.addAll(ranges);
for (StyleRange range : rnges) {
if (range.start <= keywordRange.start
&& (range.start + range.length) >= keywordRange.start) {
if (keywordRange != range) {
if (range.length < keywordRange.length) {
ranges.remove(range);
} else {
ranges.remove(keywordRange);
}
}
}
}
// only execute things if the same user didn't
// type it
if (!myUser.equals(userId)) {
executeSightsSounds(keyword);
}
// need to handle all instances of the keyword
// within
// the chat
index = lowerCase.indexOf(text, text.length()
+ index);
}
}
// only execute things if the same user didn't type it
if (!myUser.equals(userId)) {
executeSightsSounds(keyword);
}
// need to handle all instances of the keyword within
// the chat
index = lowerCase.indexOf(text, text.length() + index);
}
}
}
}
styleAndAppendText(sb, offset, name, userId, ranges);
if (msgArchive == null) {
msgArchive = getMessageArchive();
}
msgArchive.archive(sb.toString());
styleAndAppendText(sb, offset, name, userId, ranges);
if (msgArchive == null) {
msgArchive = getMessageArchive();
}
msgArchive.archive(sb.toString());
searchComp.appendText(sb.toString());
});
}
protected abstract void styleAndAppendText(StringBuilder sb, int offset,
String name, UserId userId, List<StyleRange> ranges);
protected abstract void styleAndAppendText(StringBuilder sb, int offset,
String name, UserId userId, List<StyleRange> ranges, Color color);
/**
* Find keys words in body of message starting at offset. /**
*
@ -514,4 +532,36 @@ public abstract class AbstractSessionView extends CaveFloatingView {
}
protected abstract SessionMsgArchive getMessageArchive();
protected void sendErrorMessage(StringBuilder sb) {
Color color = Display.getCurrent().getSystemColor(SWT.COLOR_RED);
sendGenericMessage(sb, color);
}
protected void sendSystemMessage(StringBuilder sb) {
Color color = Display.getCurrent().getSystemColor(SWT.COLOR_BLACK);
sendGenericMessage(sb, color);
}
private void sendGenericMessage(final StringBuilder string,
final Color color) {
VizApp.runAsync(new Runnable() {
@Override
public void run() {
StyleRange range = new StyleRange(messagesText.getCharCount(),
string.length(), color, null, SWT.BOLD);
if (messagesText.getCharCount() != 0) {
messagesText.append("\n");
}
List<StyleRange> ranges = new ArrayList<StyleRange>();
ranges.add(range);
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(System.currentTimeMillis());
String time = String.format("%1$tI:%1$tM:%1$tS %1$Tp", cal);
string.insert(0, "(" + time + ") : ");
styleAndAppendText(string, 0, string.toString(), null, ranges,
color);
}
});
}
}

View file

@ -22,8 +22,10 @@ package com.raytheon.uf.viz.collaboration.ui.session;
import org.eclipse.ecf.presence.roster.IRosterEntry;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.RGB;
@ -31,6 +33,9 @@ import org.eclipse.swt.widgets.ColorDialog;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IViewSite;
import org.eclipse.ui.PartInitException;
import com.google.common.eventbus.Subscribe;
import com.raytheon.uf.common.status.IUFStatusHandler;
@ -46,8 +51,18 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
import com.raytheon.uf.viz.collaboration.data.SharedDisplaySessionMgr;
import com.raytheon.uf.viz.collaboration.ui.Activator;
import com.raytheon.uf.viz.collaboration.ui.ColorChangeEvent;
import com.raytheon.uf.viz.collaboration.ui.telestrator.CollaborationDrawingResource;
import com.raytheon.uf.viz.collaboration.ui.telestrator.CollaborationDrawingResource.DrawingLayerUpdate;
import com.raytheon.uf.viz.core.IDisplayPane;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.icon.IconUtil;
import com.raytheon.uf.viz.core.rsc.ResourceList;
import com.raytheon.uf.viz.drawing.DrawingToolLayer;
import com.raytheon.uf.viz.drawing.DrawingToolLayer.DrawMode;
import com.raytheon.viz.ui.editor.AbstractEditor;
/**
* TODO Add Description
@ -75,8 +90,22 @@ public class CollaborationSessionView extends SessionView {
private Action colorChangeAction;
private ActionContributionItem drawAction;
private ActionContributionItem undoAction;
private ActionContributionItem redoAction;
private ActionContributionItem eraseAction;
private ActionContributionItem clearAction;
private ActionContributionItem lockAction;
private ISharedDisplaySession session;
private DrawingToolLayer layer;
/*
* (non-Javadoc)
*
@ -91,6 +120,46 @@ public class CollaborationSessionView extends SessionView {
.getEventPublisher().register(this);
}
@Subscribe
public void drawingLayerUpdate(DrawingLayerUpdate update) {
IEditorPart part = null;
if (SharedDisplaySessionMgr.getSessionContainer(sessionId)
.getCollaborationEditor() == null) {
for (AbstractEditor editor : SharedDisplaySessionMgr
.getSessionContainer(sessionId).getSharedEditors()) {
part = editor;
}
} else {
part = SharedDisplaySessionMgr.getSessionContainer(sessionId)
.getCollaborationEditor();
}
if (part instanceof AbstractEditor) {
AbstractEditor editor = (AbstractEditor) part;
for (IDisplayPane pane : editor.getDisplayPanes()) {
ResourceList list = pane.getDescriptor().getResourceList();
for (ResourcePair pair : list) {
if (pair.getResource() instanceof CollaborationDrawingResource) {
CollaborationDrawingResource resource = (CollaborationDrawingResource) pair
.getResource();
layer = resource.getDrawingLayerFor(resource
.getMyUser());
break;
}
}
}
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.part.ViewPart#init(org.eclipse.ui.IViewSite)
*/
@Override
public void init(IViewSite site) throws PartInitException {
super.init(site);
}
protected void createActions() {
super.createActions();
@ -113,6 +182,119 @@ public class CollaborationSessionView extends SessionView {
}
}
};
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.views.CaveFloatingView#createToolbarButton()
*/
@Override
protected void createToolbarButton() {
super.createToolbarButton();
drawAction = new ActionContributionItem(new Action("Draw", SWT.TOGGLE) {
@Override
public void run() {
layer.setDrawMode(DrawMode.DRAW);
updateToolItem();
}
});
drawAction.getAction().setImageDescriptor(
IconUtil.getImageDescriptor(
com.raytheon.uf.viz.drawing.Activator.getDefault()
.getBundle(), "draw.gif"));
undoAction = new ActionContributionItem(new Action("Undo") {
@Override
public void run() {
layer.undo();
updateToolItem();
}
});
undoAction.getAction().setImageDescriptor(
IconUtil.getImageDescriptor(
com.raytheon.uf.viz.drawing.Activator.getDefault()
.getBundle(), "undo.gif"));
redoAction = new ActionContributionItem(new Action("Redo") {
@Override
public void run() {
layer.redo();
updateToolItem();
}
});
redoAction.getAction().setImageDescriptor(
IconUtil.getImageDescriptor(
com.raytheon.uf.viz.drawing.Activator.getDefault()
.getBundle(), "redo.gif"));
eraseAction = new ActionContributionItem(
new Action("Erase", SWT.TOGGLE) {
@Override
public void run() {
layer.setDrawMode(DrawMode.ERASE);
}
});
eraseAction.getAction().setImageDescriptor(
IconUtil.getImageDescriptor(
com.raytheon.uf.viz.drawing.Activator.getDefault()
.getBundle(), "eraser.png"));
clearAction = new ActionContributionItem(new Action("Clear") {
public void run() {
layer.clear();
};
});
clearAction.getAction().setImageDescriptor(
IconUtil.getImageDescriptor(
com.raytheon.uf.viz.drawing.Activator.getDefault()
.getBundle(), "remove.gif"));
lockAction = new ActionContributionItem(new Action(
"Lock Collaborators", SWT.TOGGLE) {
public void run() {
System.out.println("Locking");
};
});
lockAction.getAction().setImageDescriptor(
IconUtil.getImageDescriptor(Activator.getDefault().getBundle(),
"lock.gif"));
ToolBarManager mgr = (ToolBarManager) getViewSite().getActionBars()
.getToolBarManager();
mgr.insert(mgr.getSize() - 1, drawAction);
mgr.insert(mgr.getSize() - 1, undoAction);
mgr.insert(mgr.getSize() - 1, redoAction);
mgr.insert(mgr.getSize() - 1, clearAction);
mgr.insert(mgr.getSize() - 1, eraseAction);
mgr.insert(mgr.getSize() - 1, lockAction);
mgr.insert(mgr.getSize() - 1, new Separator());
}
private void updateToolItem() {
drawAction.getAction().setEnabled(true);
undoAction.getAction().setEnabled(layer.canUndo());
redoAction.getAction().setEnabled(layer.canRedo());
clearAction.getAction().setEnabled(layer.canClear());
eraseAction.getAction().setEnabled(true);
switch (layer.getDrawMode()) {
case DRAW:
drawAction.getAction().setChecked(true);
eraseAction.getAction().setChecked(false);
break;
case ERASE:
drawAction.getAction().setChecked(false);
eraseAction.getAction().setChecked(true);
break;
case NONE:
drawAction.getAction().setChecked(false);
eraseAction.getAction().setChecked(false);
break;
}
}
/*

View file

@ -22,6 +22,8 @@ package com.raytheon.uf.viz.collaboration.ui.session;
import java.util.List;
import org.eclipse.ecf.presence.IPresence.Type;
import org.eclipse.ecf.presence.roster.IRosterEntry;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.custom.StyleRange;
@ -29,6 +31,7 @@ import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import com.google.common.eventbus.Subscribe;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
@ -36,6 +39,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException;
import com.raytheon.uf.viz.collaboration.comm.identity.IPeerToPeer;
import com.raytheon.uf.viz.collaboration.comm.identity.listener.IMessageListener;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
@ -67,14 +71,35 @@ public class PeerToPeerView extends AbstractSessionView {
private static Color chatterColor = null;
private static Color black = null;
protected IMessageListener messageListener;
private IQualifiedID peer;
private boolean online = true;
public PeerToPeerView() {
super();
userColor = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE);
chatterColor = Display.getCurrent().getSystemColor(SWT.COLOR_RED);
black = Display.getCurrent().getSystemColor(SWT.COLOR_BLACK);
CollaborationDataManager.getInstance().getCollaborationConnection(true)
.getEventPublisher().register(this);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.collaboration.ui.session.AbstractSessionView#dispose
* ()
*/
@Override
public void dispose() {
CollaborationDataManager.getInstance().getCollaborationConnection(true)
.getEventPublisher().unregister(this);
super.dispose();
}
/*
@ -112,12 +137,20 @@ public class PeerToPeerView extends AbstractSessionView {
try {
CollaborationDataManager manager = CollaborationDataManager
.getInstance();
appendMessage(manager.getCollaborationConnection(true)
.getUser(), System.currentTimeMillis(), message);
IPeerToPeer p2p = (IPeerToPeer) manager
.getCollaborationConnection(true)
.getPeerToPeerSession();
p2p.sendPeerToPeer(peer, message);
if (online) {
appendMessage(manager.getCollaborationConnection(true)
.getUser(), System.currentTimeMillis(), message);
IPeerToPeer p2p = (IPeerToPeer) manager
.getCollaborationConnection(true)
.getPeerToPeerSession();
p2p.sendPeerToPeer(peer, message);
} else {
appendMessage(manager.getCollaborationConnection(true)
.getUser(), System.currentTimeMillis(), message);
StringBuilder builder = new StringBuilder();
builder.append("Unable to send message. User is not online.");
sendErrorMessage(builder);
}
} catch (CollaborationException e) {
statusHandler.handle(Priority.PROBLEM,
"Unable to send message to " + peer.getName(), e);
@ -128,24 +161,36 @@ public class PeerToPeerView extends AbstractSessionView {
protected void styleAndAppendText(StringBuilder sb, int offset,
String name, UserId userId, List<StyleRange> ranges) {
Color color = null;
if (!userId.equals(CollaborationDataManager.getInstance()
if (userId == null) {
color = black;
} else if (!userId.equals(CollaborationDataManager.getInstance()
.getCollaborationConnection(true).getUser())) {
color = chatterColor;
} else {
color = userColor;
}
styleAndAppendText(sb, offset, name, userId, ranges, color);
};
public void styleAndAppendText(StringBuilder sb, int offset, String name,
UserId userId, List<StyleRange> ranges, Color color) {
StyleRange range = new StyleRange(messagesText.getCharCount(), offset,
color, null, SWT.NORMAL);
ranges.add(range);
range = new StyleRange(messagesText.getCharCount() + offset,
name.length() + 1, color, null, SWT.BOLD);
if (userId != null) {
range = new StyleRange(messagesText.getCharCount() + offset,
name.length() + 1, color, null, SWT.BOLD);
} else {
range = new StyleRange(messagesText.getCharCount() + offset,
sb.length() - offset, color, null, SWT.BOLD);
}
ranges.add(range);
messagesText.append(sb.toString());
for (StyleRange newRange : ranges) {
messagesText.setStyleRange(newRange);
}
messagesText.setTopIndex(messagesText.getLineCount() - 1);
};
}
protected String getSessionImageName() {
return PEER_TO_PEER_IMAGE_NAME;
@ -187,4 +232,16 @@ public class PeerToPeerView extends AbstractSessionView {
public IQualifiedID getPeer() {
return peer;
}
@Subscribe
public void handleModifiedPresence(IRosterEntry entry) {
UserId id = IDConverter.convertFrom(entry.getUser());
if (id.equals(peer)) {
if (entry.getPresence().getType() == Type.UNAVAILABLE) {
online = false;
} else {
online = true;
}
}
}
}

View file

@ -71,7 +71,6 @@ import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueParticipantEvent;
import com.raytheon.uf.viz.collaboration.comm.identity.event.ParticipantEventType;
import com.raytheon.uf.viz.collaboration.comm.identity.info.IVenueInfo;
import com.raytheon.uf.viz.collaboration.comm.provider.TextMessage;
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection;
import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
@ -471,18 +470,37 @@ public class SessionView extends AbstractSessionView {
Color col = new Color(Display.getCurrent(), rgb);
mappedColors.put(rgb, col);
}
styleAndAppendText(sb, offset, name, userId, ranges,
mappedColors.get(rgb));
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.collaboration.ui.session.AbstractSessionView#
* styleAndAppendText(java.lang.StringBuilder, int, java.lang.String,
* com.raytheon.uf.viz.collaboration.comm.provider.user.UserId,
* java.util.List, org.eclipse.swt.graphics.Color)
*/
@Override
protected void styleAndAppendText(StringBuilder sb, int offset,
String name, UserId userId, List<StyleRange> ranges, Color color) {
StyleRange range = new StyleRange(messagesText.getCharCount(), offset,
mappedColors.get(rgb), null, SWT.NORMAL);
color, null, SWT.NORMAL);
ranges.add(range);
range = new StyleRange(messagesText.getCharCount() + offset,
name.length() + 1, mappedColors.get(rgb), null, SWT.BOLD);
if (userId != null) {
range = new StyleRange(messagesText.getCharCount() + offset,
name.length() + 1, color, null, SWT.BOLD);
} else {
range = new StyleRange(messagesText.getCharCount() + offset,
sb.length() - offset, color, null, SWT.BOLD);
}
ranges.add(range);
messagesText.append(sb.toString());
for (StyleRange newRange : ranges) {
messagesText.setStyleRange(newRange);
}
messagesText.setTopIndex(messagesText.getLineCount() - 1);
}
public String getRoom() {
@ -639,9 +657,10 @@ public class SessionView extends AbstractSessionView {
}
usersTable.setInput(users);
usersTable.refresh();
IMessage message = new TextMessage(participant, participant.getName()
+ " has entered the room.");
appendMessage(message);
StringBuilder builder = new StringBuilder(participant.getName()
+ " has entered the room");
sendSystemMessage(builder);
}
@SuppressWarnings("unchecked")
@ -656,9 +675,9 @@ public class SessionView extends AbstractSessionView {
break;
}
}
IMessage message = new TextMessage(participant, participant.getName()
+ " has left the room.");
appendMessage(message);
StringBuilder builder = new StringBuilder(participant.getName()
+ " has left the room");
sendSystemMessage(builder);
}
/**