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:
parent
08ad661af4
commit
e8355a9a2b
7 changed files with 462 additions and 118 deletions
BIN
cave/com.raytheon.uf.viz.collaboration.ui/icons/lock.gif
Normal file
BIN
cave/com.raytheon.uf.viz.collaboration.ui/icons/lock.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 575 B |
|
@ -278,6 +278,25 @@ public class CollaborationUtils {
|
||||||
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
|
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
|
||||||
file = PathManagerFactory.getPathManager().getLocalizationFile(context,
|
file = PathManagerFactory.getPathManager().getLocalizationFile(context,
|
||||||
"collaboration" + File.separator + "alertWords.xml");
|
"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();
|
AlertWordWrapper wrapper = new AlertWordWrapper();
|
||||||
wrapper.setAlertWords(words.toArray(new AlertWord[0]));
|
wrapper.setAlertWords(words.toArray(new AlertWord[0]));
|
||||||
JAXB.marshal(wrapper, file.getFile());
|
JAXB.marshal(wrapper, file.getFile());
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
**/
|
**/
|
||||||
package com.raytheon.uf.viz.collaboration.ui.prefs;
|
package com.raytheon.uf.viz.collaboration.ui.prefs;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.jface.preference.ColorFieldEditor;
|
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.IWorkbench;
|
||||||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
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.comm.provider.session.CollaborationConnection;
|
||||||
import com.raytheon.uf.viz.collaboration.data.AlertWord;
|
import com.raytheon.uf.viz.collaboration.data.AlertWord;
|
||||||
import com.raytheon.uf.viz.collaboration.data.AlertWordWrapper;
|
import com.raytheon.uf.viz.collaboration.data.AlertWordWrapper;
|
||||||
|
@ -139,6 +146,16 @@ public class CollaborationAlertWordsPreferencePage extends
|
||||||
|
|
||||||
final FileFieldEditor fileEditor = new FileFieldEditor("fileeditor",
|
final FileFieldEditor fileEditor = new FileFieldEditor("fileeditor",
|
||||||
"Sound File", getFieldEditorParent());
|
"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);
|
this.addField(fileEditor);
|
||||||
|
|
||||||
fontButton.addSelectionListener(new SelectionAdapter() {
|
fontButton.addSelectionListener(new SelectionAdapter() {
|
||||||
|
|
|
@ -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.data.CollaborationDataManager;
|
||||||
import com.raytheon.uf.viz.collaboration.ui.Activator;
|
import com.raytheon.uf.viz.collaboration.ui.Activator;
|
||||||
import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils;
|
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.core.icon.IconUtil;
|
||||||
import com.raytheon.uf.viz.notification.notifier.PopupNotifier;
|
import com.raytheon.uf.viz.notification.notifier.PopupNotifier;
|
||||||
import com.raytheon.viz.ui.views.CaveFloatingView;
|
import com.raytheon.viz.ui.views.CaveFloatingView;
|
||||||
|
@ -269,124 +270,141 @@ public abstract class AbstractSessionView extends CaveFloatingView {
|
||||||
appendMessage(userId, timestamp, body);
|
appendMessage(userId, timestamp, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void appendMessage(UserId userId, long timestamp, String body) {
|
public void appendMessage(final UserId userId, final long timestamp,
|
||||||
IWorkbenchSiteProgressService service = (IWorkbenchSiteProgressService) getSite()
|
final String body) {
|
||||||
.getAdapter(IWorkbenchSiteProgressService.class);
|
VizApp.runAsync(new Runnable() {
|
||||||
service.warnOfContentChange();
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
Calendar cal = Calendar.getInstance();
|
IWorkbenchSiteProgressService service = (IWorkbenchSiteProgressService) getSite()
|
||||||
cal.setTimeInMillis(timestamp);
|
.getAdapter(IWorkbenchSiteProgressService.class);
|
||||||
String time = String.format("%1$tI:%1$tM:%1$tS %1$Tp", cal);
|
service.warnOfContentChange();
|
||||||
|
|
||||||
UserId myUser = CollaborationDataManager.getInstance()
|
Calendar cal = Calendar.getInstance();
|
||||||
.getCollaborationConnection(true).getUser();
|
cal.setTimeInMillis(timestamp);
|
||||||
if (!myUser.equals(userId)
|
String time = String.format("%1$tI:%1$tM:%1$tS %1$Tp", cal);
|
||||||
&& Activator.getDefault().getPreferenceStore()
|
|
||||||
.getBoolean("notifications")) {
|
|
||||||
createNotifier(userId, time, body);
|
|
||||||
}
|
|
||||||
|
|
||||||
String name = null;
|
UserId myUser = CollaborationDataManager.getInstance()
|
||||||
if (userId != null) {
|
.getCollaborationConnection(true).getUser();
|
||||||
name = userId.getName();
|
if (!myUser.equals(userId)
|
||||||
for (UserId id : userIds) {
|
&& Activator.getDefault().getPreferenceStore()
|
||||||
if (id.equals(userId)) {
|
.getBoolean("notifications")) {
|
||||||
name = id.getAlias();
|
createNotifier(userId, time, body);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
|
||||||
name = getPartName();
|
|
||||||
}
|
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
String name = null;
|
||||||
if (messagesText.getCharCount() != 0) {
|
if (userId != null) {
|
||||||
sb.append("\n");
|
name = userId.getName();
|
||||||
}
|
for (UserId id : userIds) {
|
||||||
sb.append("(").append(time).append(") ");
|
if (id.equals(userId)) {
|
||||||
int offset = sb.length();
|
name = id.getAlias();
|
||||||
|
break;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
name = "";
|
||||||
|
}
|
||||||
|
|
||||||
RGB rgb = new RGB(keyword.getRed(), keyword.getGreen(),
|
StringBuilder sb = new StringBuilder();
|
||||||
keyword.getBlue());
|
if (messagesText.getCharCount() != 0) {
|
||||||
Color color = null;
|
sb.append("\n");
|
||||||
// using the stored colors so we don't leak
|
}
|
||||||
if (colors.containsKey(rgb)) {
|
sb.append("(").append(time).append(") ");
|
||||||
color = colors.get(rgb);
|
int offset = sb.length();
|
||||||
} 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);
|
sb.append(name).append(": ").append(body);
|
||||||
// compare to see if this position is already styled
|
// here is the place to put the font and color changes for
|
||||||
List<StyleRange> rnges = new ArrayList<StyleRange>();
|
// keywords
|
||||||
rnges.addAll(ranges);
|
// read in localization file once and then don't read in again,
|
||||||
for (StyleRange range : rnges) {
|
// per
|
||||||
if (range.start <= keywordRange.start
|
// chat room?
|
||||||
&& (range.start + range.length) >= keywordRange.start) {
|
List<AlertWord> alertWords = retrieveAlertWords();
|
||||||
if (keywordRange != range) {
|
List<StyleRange> ranges = new ArrayList<StyleRange>();
|
||||||
if (range.length < keywordRange.length) {
|
if (alertWords != null) {
|
||||||
ranges.remove(range);
|
for (AlertWord keyword : alertWords) {
|
||||||
} else {
|
String text = keyword.getText().toLowerCase();
|
||||||
ranges.remove(keywordRange);
|
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);
|
styleAndAppendText(sb, offset, name, userId, ranges);
|
||||||
if (msgArchive == null) {
|
if (msgArchive == null) {
|
||||||
msgArchive = getMessageArchive();
|
msgArchive = getMessageArchive();
|
||||||
}
|
}
|
||||||
msgArchive.archive(sb.toString());
|
msgArchive.archive(sb.toString());
|
||||||
searchComp.appendText(sb.toString());
|
searchComp.appendText(sb.toString());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void styleAndAppendText(StringBuilder sb, int offset,
|
protected abstract void styleAndAppendText(StringBuilder sb, int offset,
|
||||||
String name, UserId userId, List<StyleRange> ranges);
|
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. /**
|
* 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 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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,10 @@ package com.raytheon.uf.viz.collaboration.ui.session;
|
||||||
|
|
||||||
import org.eclipse.ecf.presence.roster.IRosterEntry;
|
import org.eclipse.ecf.presence.roster.IRosterEntry;
|
||||||
import org.eclipse.jface.action.Action;
|
import org.eclipse.jface.action.Action;
|
||||||
|
import org.eclipse.jface.action.ActionContributionItem;
|
||||||
import org.eclipse.jface.action.IMenuManager;
|
import org.eclipse.jface.action.IMenuManager;
|
||||||
import org.eclipse.jface.action.Separator;
|
import org.eclipse.jface.action.Separator;
|
||||||
|
import org.eclipse.jface.action.ToolBarManager;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.graphics.RGB;
|
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.Composite;
|
||||||
import org.eclipse.swt.widgets.Display;
|
import org.eclipse.swt.widgets.Display;
|
||||||
import org.eclipse.swt.widgets.Label;
|
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.google.common.eventbus.Subscribe;
|
||||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
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.comm.provider.user.UserId;
|
||||||
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
|
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
|
||||||
import com.raytheon.uf.viz.collaboration.data.SharedDisplaySessionMgr;
|
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.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.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
|
* TODO Add Description
|
||||||
|
@ -75,8 +90,22 @@ public class CollaborationSessionView extends SessionView {
|
||||||
|
|
||||||
private Action colorChangeAction;
|
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 ISharedDisplaySession session;
|
||||||
|
|
||||||
|
private DrawingToolLayer layer;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
|
@ -91,6 +120,46 @@ public class CollaborationSessionView extends SessionView {
|
||||||
.getEventPublisher().register(this);
|
.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() {
|
protected void createActions() {
|
||||||
super.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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -22,6 +22,8 @@ package com.raytheon.uf.viz.collaboration.ui.session;
|
||||||
|
|
||||||
import java.util.List;
|
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.SWT;
|
||||||
import org.eclipse.swt.custom.SashForm;
|
import org.eclipse.swt.custom.SashForm;
|
||||||
import org.eclipse.swt.custom.StyleRange;
|
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.Composite;
|
||||||
import org.eclipse.swt.widgets.Display;
|
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.IUFStatusHandler;
|
||||||
import com.raytheon.uf.common.status.UFStatus;
|
import com.raytheon.uf.common.status.UFStatus;
|
||||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
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.IPeerToPeer;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.identity.listener.IMessageListener;
|
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.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.comm.provider.user.UserId;
|
||||||
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
|
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 chatterColor = null;
|
||||||
|
|
||||||
|
private static Color black = null;
|
||||||
|
|
||||||
protected IMessageListener messageListener;
|
protected IMessageListener messageListener;
|
||||||
|
|
||||||
private IQualifiedID peer;
|
private IQualifiedID peer;
|
||||||
|
|
||||||
|
private boolean online = true;
|
||||||
|
|
||||||
public PeerToPeerView() {
|
public PeerToPeerView() {
|
||||||
super();
|
super();
|
||||||
userColor = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE);
|
userColor = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE);
|
||||||
chatterColor = Display.getCurrent().getSystemColor(SWT.COLOR_RED);
|
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 {
|
try {
|
||||||
CollaborationDataManager manager = CollaborationDataManager
|
CollaborationDataManager manager = CollaborationDataManager
|
||||||
.getInstance();
|
.getInstance();
|
||||||
appendMessage(manager.getCollaborationConnection(true)
|
if (online) {
|
||||||
.getUser(), System.currentTimeMillis(), message);
|
appendMessage(manager.getCollaborationConnection(true)
|
||||||
IPeerToPeer p2p = (IPeerToPeer) manager
|
.getUser(), System.currentTimeMillis(), message);
|
||||||
.getCollaborationConnection(true)
|
IPeerToPeer p2p = (IPeerToPeer) manager
|
||||||
.getPeerToPeerSession();
|
.getCollaborationConnection(true)
|
||||||
p2p.sendPeerToPeer(peer, message);
|
.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) {
|
} catch (CollaborationException e) {
|
||||||
statusHandler.handle(Priority.PROBLEM,
|
statusHandler.handle(Priority.PROBLEM,
|
||||||
"Unable to send message to " + peer.getName(), e);
|
"Unable to send message to " + peer.getName(), e);
|
||||||
|
@ -128,24 +161,36 @@ public class PeerToPeerView extends AbstractSessionView {
|
||||||
protected void styleAndAppendText(StringBuilder sb, int offset,
|
protected void styleAndAppendText(StringBuilder sb, int offset,
|
||||||
String name, UserId userId, List<StyleRange> ranges) {
|
String name, UserId userId, List<StyleRange> ranges) {
|
||||||
Color color = null;
|
Color color = null;
|
||||||
if (!userId.equals(CollaborationDataManager.getInstance()
|
if (userId == null) {
|
||||||
|
color = black;
|
||||||
|
} else if (!userId.equals(CollaborationDataManager.getInstance()
|
||||||
.getCollaborationConnection(true).getUser())) {
|
.getCollaborationConnection(true).getUser())) {
|
||||||
color = chatterColor;
|
color = chatterColor;
|
||||||
} else {
|
} else {
|
||||||
color = userColor;
|
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,
|
StyleRange range = new StyleRange(messagesText.getCharCount(), offset,
|
||||||
color, null, SWT.NORMAL);
|
color, null, SWT.NORMAL);
|
||||||
ranges.add(range);
|
ranges.add(range);
|
||||||
range = new StyleRange(messagesText.getCharCount() + offset,
|
if (userId != null) {
|
||||||
name.length() + 1, color, null, SWT.BOLD);
|
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);
|
ranges.add(range);
|
||||||
messagesText.append(sb.toString());
|
messagesText.append(sb.toString());
|
||||||
for (StyleRange newRange : ranges) {
|
for (StyleRange newRange : ranges) {
|
||||||
messagesText.setStyleRange(newRange);
|
messagesText.setStyleRange(newRange);
|
||||||
}
|
}
|
||||||
messagesText.setTopIndex(messagesText.getLineCount() - 1);
|
messagesText.setTopIndex(messagesText.getLineCount() - 1);
|
||||||
};
|
}
|
||||||
|
|
||||||
protected String getSessionImageName() {
|
protected String getSessionImageName() {
|
||||||
return PEER_TO_PEER_IMAGE_NAME;
|
return PEER_TO_PEER_IMAGE_NAME;
|
||||||
|
@ -187,4 +232,16 @@ public class PeerToPeerView extends AbstractSessionView {
|
||||||
public IQualifiedID getPeer() {
|
public IQualifiedID getPeer() {
|
||||||
return peer;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.IVenueParticipantEvent;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.identity.event.ParticipantEventType;
|
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.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.session.CollaborationConnection;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter;
|
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.comm.provider.user.UserId;
|
||||||
|
@ -471,18 +470,37 @@ public class SessionView extends AbstractSessionView {
|
||||||
Color col = new Color(Display.getCurrent(), rgb);
|
Color col = new Color(Display.getCurrent(), rgb);
|
||||||
mappedColors.put(rgb, col);
|
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,
|
StyleRange range = new StyleRange(messagesText.getCharCount(), offset,
|
||||||
mappedColors.get(rgb), null, SWT.NORMAL);
|
color, null, SWT.NORMAL);
|
||||||
ranges.add(range);
|
ranges.add(range);
|
||||||
range = new StyleRange(messagesText.getCharCount() + offset,
|
if (userId != null) {
|
||||||
name.length() + 1, mappedColors.get(rgb), null, SWT.BOLD);
|
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);
|
ranges.add(range);
|
||||||
messagesText.append(sb.toString());
|
messagesText.append(sb.toString());
|
||||||
for (StyleRange newRange : ranges) {
|
for (StyleRange newRange : ranges) {
|
||||||
messagesText.setStyleRange(newRange);
|
messagesText.setStyleRange(newRange);
|
||||||
}
|
}
|
||||||
messagesText.setTopIndex(messagesText.getLineCount() - 1);
|
messagesText.setTopIndex(messagesText.getLineCount() - 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRoom() {
|
public String getRoom() {
|
||||||
|
@ -639,9 +657,10 @@ public class SessionView extends AbstractSessionView {
|
||||||
}
|
}
|
||||||
usersTable.setInput(users);
|
usersTable.setInput(users);
|
||||||
usersTable.refresh();
|
usersTable.refresh();
|
||||||
IMessage message = new TextMessage(participant, participant.getName()
|
|
||||||
+ " has entered the room.");
|
StringBuilder builder = new StringBuilder(participant.getName()
|
||||||
appendMessage(message);
|
+ " has entered the room");
|
||||||
|
sendSystemMessage(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -656,9 +675,9 @@ public class SessionView extends AbstractSessionView {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IMessage message = new TextMessage(participant, participant.getName()
|
StringBuilder builder = new StringBuilder(participant.getName()
|
||||||
+ " has left the room.");
|
+ " has left the room");
|
||||||
appendMessage(message);
|
sendSystemMessage(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue