Omaha #4265 Collaboration alert words should be able to load from different localization levels
Change-Id: Ia11db64b7e5a0ac246355b9bfbe6207484ef7bc1 Former-commit-id: 203ada0e884d0c7ade4642ffbc227faeac393254
This commit is contained in:
parent
24d7b86a74
commit
7efcfcd429
5 changed files with 72 additions and 95 deletions
|
@ -59,6 +59,7 @@ import com.raytheon.uf.viz.core.icon.IconUtil;
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Feb 24, 2012 mnash Initial creation
|
* Feb 24, 2012 mnash Initial creation
|
||||||
* Jan 15, 2014 2630 bclement added mode map
|
* Jan 15, 2014 2630 bclement added mode map
|
||||||
|
* Mar 24, 2015 4265 mapeters Get alert words from not only user localization level.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -88,7 +89,7 @@ public class CollaborationUtils {
|
||||||
/**
|
/**
|
||||||
* Get an image associated with the node.
|
* Get an image associated with the node.
|
||||||
*
|
*
|
||||||
* @param node
|
* @param name
|
||||||
* @return image
|
* @return image
|
||||||
*/
|
*/
|
||||||
public static Image getNodeImage(String name) {
|
public static Image getNodeImage(String name) {
|
||||||
|
@ -103,7 +104,7 @@ public class CollaborationUtils {
|
||||||
LocalizationFile file = PathManagerFactory.getPathManager()
|
LocalizationFile file = PathManagerFactory.getPathManager()
|
||||||
.getLocalizationFile(
|
.getLocalizationFile(
|
||||||
context,
|
context,
|
||||||
"collaboration" + File.separator
|
"collaboration" + IPathManager.SEPARATOR
|
||||||
+ "collaborationAliases.xml");
|
+ "collaborationAliases.xml");
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
UserIdWrapper ids = JAXB.unmarshal(file.getFile(),
|
UserIdWrapper ids = JAXB.unmarshal(file.getFile(),
|
||||||
|
@ -151,29 +152,40 @@ public class CollaborationUtils {
|
||||||
return modeMap.get(status);
|
return modeMap.get(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<AlertWord> getAlertWords() {
|
/**
|
||||||
LocalizationFile file = null;
|
* Gets the alert words either from the lowest localization level or from
|
||||||
IPathManager pm = PathManagerFactory.getPathManager();
|
* only the user level (if specified).
|
||||||
LocalizationContext context = pm.getContext(
|
*
|
||||||
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
|
* @param userOnly
|
||||||
file = PathManagerFactory.getPathManager().getLocalizationFile(context,
|
* whether or not to only retrieve alert words from user level
|
||||||
"collaboration" + File.separator + "alertWords.xml");
|
* @return list of alert words
|
||||||
if (file.exists() || file.getFile().exists()) {
|
*/
|
||||||
AlertWordWrapper words = JAXB.unmarshal(file.getFile(),
|
public static List<AlertWord> getAlertWords(boolean userOnly) {
|
||||||
AlertWordWrapper.class);
|
LocalizationFile file = PathManagerFactory.getPathManager()
|
||||||
if (words.getAlertWords() == null) {
|
.getStaticLocalizationFile(
|
||||||
return new ArrayList<AlertWord>();
|
LocalizationType.CAVE_STATIC,
|
||||||
}
|
"collaboration" + IPathManager.SEPARATOR
|
||||||
|
+ "alertWords.xml");
|
||||||
|
if (file != null && (file.exists() || file.getFile().exists())) {
|
||||||
|
boolean userLocalized = file.getContext().getLocalizationLevel()
|
||||||
|
.equals(LocalizationLevel.USER);
|
||||||
|
if (!userOnly || userLocalized) {
|
||||||
|
AlertWordWrapper words = JAXB.unmarshal(file.getFile(),
|
||||||
|
AlertWordWrapper.class);
|
||||||
|
if (words.getAlertWords() == null) {
|
||||||
|
return new ArrayList<AlertWord>();
|
||||||
|
}
|
||||||
|
|
||||||
List<AlertWord> alertWords = new ArrayList<AlertWord>();
|
List<AlertWord> alertWords = new ArrayList<AlertWord>();
|
||||||
for (int i = 0; i < words.getAlertWords().length; i++) {
|
for (int i = 0; i < words.getAlertWords().length; i++) {
|
||||||
alertWords.add(words.getAlertWords()[i]);
|
alertWords.add(words.getAlertWords()[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return alertWords;
|
return alertWords;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ArrayList<AlertWord>();
|
return new ArrayList<AlertWord>(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void saveAlertWords(List<AlertWord> words) {
|
public static void saveAlertWords(List<AlertWord> words) {
|
||||||
|
@ -181,8 +193,8 @@ public class CollaborationUtils {
|
||||||
IPathManager pm = PathManagerFactory.getPathManager();
|
IPathManager pm = PathManagerFactory.getPathManager();
|
||||||
LocalizationContext context = pm.getContext(
|
LocalizationContext context = pm.getContext(
|
||||||
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
|
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
|
||||||
file = PathManagerFactory.getPathManager().getLocalizationFile(context,
|
file = pm.getLocalizationFile(context, "collaboration"
|
||||||
"collaboration" + File.separator + "alertWords.xml");
|
+ IPathManager.SEPARATOR + "alertWords.xml");
|
||||||
|
|
||||||
// save the sound file in the correct place if not there
|
// save the sound file in the correct place if not there
|
||||||
for (AlertWord word : words) {
|
for (AlertWord word : words) {
|
||||||
|
@ -191,8 +203,8 @@ public class CollaborationUtils {
|
||||||
String[] dirs = soundPath.split(File.separator);
|
String[] dirs = soundPath.split(File.separator);
|
||||||
String filename = dirs[dirs.length - 1];
|
String filename = dirs[dirs.length - 1];
|
||||||
LocalizationFile lFile = pm.getLocalizationFile(context,
|
LocalizationFile lFile = pm.getLocalizationFile(context,
|
||||||
"collaboration" + File.separator + "sounds"
|
"collaboration" + IPathManager.SEPARATOR + "sounds"
|
||||||
+ File.separator + filename);
|
+ IPathManager.SEPARATOR + filename);
|
||||||
if (!lFile.exists()) {
|
if (!lFile.exists()) {
|
||||||
File soundFile = new File(soundPath);
|
File soundFile = new File(soundPath);
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,7 @@ import com.raytheon.uf.viz.collaboration.ui.data.AlertWordWrapper;
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* May 17, 2012 mnash Initial creation
|
* May 17, 2012 mnash Initial creation
|
||||||
* Feb 24, 2014 2632 mpduf Created CollaborationPreferencesAlertWordLabelProvider
|
* Feb 24, 2014 2632 mpduf Created CollaborationPreferencesAlertWordLabelProvider
|
||||||
|
* Mar 24, 2015 4265 mapeters Account for altered CollaborationUtils.getAlertWords()
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -253,7 +254,7 @@ public class CollaborationAlertWordsPreferencePage extends
|
||||||
fileEditor.setStringValue(word.getSoundPath());
|
fileEditor.setStringValue(word.getSoundPath());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
viewer.setInput(CollaborationUtils.getAlertWords());
|
viewer.setInput(CollaborationUtils.getAlertWords(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -100,6 +100,8 @@ import com.raytheon.viz.ui.views.CaveFloatingView;
|
||||||
* Nov 26, 2014 3709 mapeters Added {@link #getColorFromRGB()}.
|
* Nov 26, 2014 3709 mapeters Added {@link #getColorFromRGB()}.
|
||||||
* Dec 08, 2014 3709 mapeters Removed messagesTextMenuMgr.
|
* Dec 08, 2014 3709 mapeters Removed messagesTextMenuMgr.
|
||||||
* Jan 13, 2015 3709 bclement styleAndAppendText() takes foreground and background
|
* Jan 13, 2015 3709 bclement styleAndAppendText() takes foreground and background
|
||||||
|
* Mar 24, 2015 4265 mapeters Implement common styleAndAppendText()s here, apply
|
||||||
|
* most general StyleRange to text first.
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author rferrel
|
* @author rferrel
|
||||||
|
@ -450,8 +452,7 @@ public abstract class AbstractSessionView<T extends IUser> extends
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
styleAndAppendText(sb, offset, name, userId, subject,
|
styleAndAppendText(sb, offset, name, userId, ranges);
|
||||||
ranges);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Archive the message
|
// Archive the message
|
||||||
|
@ -468,11 +469,31 @@ public abstract class AbstractSessionView<T extends IUser> extends
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void styleAndAppendText(StringBuilder sb, int offset,
|
protected abstract void styleAndAppendText(StringBuilder sb, int offset,
|
||||||
String name, T userId, String subject, List<StyleRange> ranges);
|
String name, T userId, List<StyleRange> ranges);
|
||||||
|
|
||||||
protected abstract void styleAndAppendText(StringBuilder sb, int offset,
|
protected void styleAndAppendText(StringBuilder sb, int offset,
|
||||||
String name, T userId, List<StyleRange> ranges, Color foreground,
|
String name, T userId, List<StyleRange> ranges, Color foreground,
|
||||||
Color background);
|
Color background) {
|
||||||
|
StyleRange range = new StyleRange(messagesText.getCharCount(),
|
||||||
|
sb.length(), foreground, null, SWT.NORMAL);
|
||||||
|
// This must go first to be overridden by other ranges (name bolding,
|
||||||
|
// alert words)
|
||||||
|
ranges.add(0, range);
|
||||||
|
|
||||||
|
range = new StyleRange(messagesText.getCharCount() + offset,
|
||||||
|
(userId != null ? name.length() + 1 : sb.length() - offset),
|
||||||
|
foreground, null, SWT.BOLD);
|
||||||
|
ranges.add(range);
|
||||||
|
messagesText.append(sb.toString());
|
||||||
|
|
||||||
|
for (StyleRange newRange : ranges) {
|
||||||
|
messagesText.setStyleRange(newRange);
|
||||||
|
}
|
||||||
|
|
||||||
|
int lineNumber = messagesText.getLineCount() - 1;
|
||||||
|
messagesText.setLineBackground(lineNumber, 1, background);
|
||||||
|
messagesText.setTopIndex(lineNumber);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find keys words in body of message starting at offset.
|
* Find keys words in body of message starting at offset.
|
||||||
|
@ -483,7 +504,7 @@ public abstract class AbstractSessionView<T extends IUser> extends
|
||||||
*/
|
*/
|
||||||
protected List<AlertWord> retrieveAlertWords() {
|
protected List<AlertWord> retrieveAlertWords() {
|
||||||
if (alertWords == null) {
|
if (alertWords == null) {
|
||||||
alertWords = CollaborationUtils.getAlertWords();
|
alertWords = CollaborationUtils.getAlertWords(false);
|
||||||
}
|
}
|
||||||
return alertWords;
|
return alertWords;
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,7 @@ import com.raytheon.uf.viz.core.sounds.SoundUtil;
|
||||||
* dispose them.
|
* dispose them.
|
||||||
* Jan 09, 2015 3709 bclement color config manager API changes
|
* Jan 09, 2015 3709 bclement color config manager API changes
|
||||||
* Jan 13, 2015 3709 bclement ChangeTextColorAction API changes
|
* Jan 13, 2015 3709 bclement ChangeTextColorAction API changes
|
||||||
|
* Mar 24, 2015 4265 mapeters abstracted out common styleAndAppendText()
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -213,7 +214,7 @@ public class PeerToPeerView extends AbstractSessionView<IUser> implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void styleAndAppendText(StringBuilder sb, int offset,
|
protected void styleAndAppendText(StringBuilder sb, int offset,
|
||||||
String name, IUser userId, String subject, List<StyleRange> ranges) {
|
String name, IUser userId, List<StyleRange> ranges) {
|
||||||
CollaborationConnection connection = CollaborationConnection
|
CollaborationConnection connection = CollaborationConnection
|
||||||
.getConnection();
|
.getConnection();
|
||||||
if (connection == null) {
|
if (connection == null) {
|
||||||
|
@ -231,29 +232,6 @@ public class PeerToPeerView extends AbstractSessionView<IUser> implements
|
||||||
}
|
}
|
||||||
styleAndAppendText(sb, offset, name, userId, ranges, foreground,
|
styleAndAppendText(sb, offset, name, userId, ranges, foreground,
|
||||||
background);
|
background);
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void styleAndAppendText(StringBuilder sb, int offset, String name,
|
|
||||||
IUser userId, List<StyleRange> ranges, Color foreground,
|
|
||||||
Color background) {
|
|
||||||
|
|
||||||
StyleRange range = new StyleRange(messagesText.getCharCount(),
|
|
||||||
sb.length(), foreground, null, SWT.NORMAL);
|
|
||||||
ranges.add(range);
|
|
||||||
range = new StyleRange(messagesText.getCharCount() + offset,
|
|
||||||
(userId != null ? name.length() + 1 : sb.length() - offset),
|
|
||||||
foreground, null, SWT.BOLD);
|
|
||||||
ranges.add(range);
|
|
||||||
messagesText.append(sb.toString());
|
|
||||||
|
|
||||||
for (StyleRange newRange : ranges) {
|
|
||||||
messagesText.setStyleRange(newRange);
|
|
||||||
}
|
|
||||||
|
|
||||||
int lineNumber = messagesText.getLineCount() - 1;
|
|
||||||
messagesText.setLineBackground(lineNumber, 1, background);
|
|
||||||
messagesText.setTopIndex(lineNumber);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -50,7 +50,6 @@ import org.eclipse.swt.custom.StyledText;
|
||||||
import org.eclipse.swt.events.MouseAdapter;
|
import org.eclipse.swt.events.MouseAdapter;
|
||||||
import org.eclipse.swt.events.MouseEvent;
|
import org.eclipse.swt.events.MouseEvent;
|
||||||
import org.eclipse.swt.events.MouseTrackAdapter;
|
import org.eclipse.swt.events.MouseTrackAdapter;
|
||||||
import org.eclipse.swt.graphics.Color;
|
|
||||||
import org.eclipse.swt.graphics.GC;
|
import org.eclipse.swt.graphics.GC;
|
||||||
import org.eclipse.swt.graphics.Image;
|
import org.eclipse.swt.graphics.Image;
|
||||||
import org.eclipse.swt.layout.GridData;
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
@ -124,6 +123,7 @@ import com.raytheon.uf.viz.core.sounds.SoundUtil;
|
||||||
* Dec 12, 2014 3709 mapeters Store {@link ChangeTextColorAction}s in map, dispose them.
|
* Dec 12, 2014 3709 mapeters Store {@link ChangeTextColorAction}s in map, dispose them.
|
||||||
* Jan 09, 2015 3709 bclement color config manager API changes
|
* Jan 09, 2015 3709 bclement color config manager API changes
|
||||||
* Jan 12, 2015 3709 bclement unified color management into SessionColorManager
|
* Jan 12, 2015 3709 bclement unified color management into SessionColorManager
|
||||||
|
* Mar 24, 2015 4265 mapeters abstracted out common styleAndAppendText()s
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -164,6 +164,7 @@ public class SessionView extends AbstractSessionView<VenueParticipant>
|
||||||
* custom color configuration for a participant
|
* custom color configuration for a participant
|
||||||
*/
|
*/
|
||||||
protected final ChangeTextColorCallback refreshCallback = new ChangeTextColorCallback() {
|
protected final ChangeTextColorCallback refreshCallback = new ChangeTextColorCallback() {
|
||||||
|
@Override
|
||||||
public void newColor(IUser user, UserColorInfo colors) {
|
public void newColor(IUser user, UserColorInfo colors) {
|
||||||
refreshParticipantList();
|
refreshParticipantList();
|
||||||
}
|
}
|
||||||
|
@ -510,47 +511,11 @@ public class SessionView extends AbstractSessionView<VenueParticipant>
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void styleAndAppendText(StringBuilder sb, int offset,
|
protected void styleAndAppendText(StringBuilder sb, int offset,
|
||||||
String name, VenueParticipant userId, String subject,
|
String name, VenueParticipant userId, List<StyleRange> ranges) {
|
||||||
List<StyleRange> ranges) {
|
|
||||||
UserColorInfo colors = colorManager.getColorForUser(userId);
|
UserColorInfo colors = colorManager.getColorForUser(userId);
|
||||||
styleAndAppendText(sb, offset, name, userId, ranges,
|
styleAndAppendText(sb, offset, name, userId, ranges,
|
||||||
getColorFromRGB(colors.getForeground()),
|
getColorFromRGB(colors.getForeground()),
|
||||||
getColorFromRGB(colors.getBackground()), subject);
|
getColorFromRGB(colors.getBackground()));
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (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, VenueParticipant userId, List<StyleRange> ranges,
|
|
||||||
Color foreground, Color background) {
|
|
||||||
styleAndAppendText(sb, offset, name, userId, ranges, foreground,
|
|
||||||
background, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void styleAndAppendText(StringBuilder sb, int offset,
|
|
||||||
String name, VenueParticipant userId, List<StyleRange> ranges,
|
|
||||||
Color fgColor, Color bgColor, String subject) {
|
|
||||||
StyleRange range = new StyleRange(messagesText.getCharCount(),
|
|
||||||
sb.length(), fgColor, null, SWT.NORMAL);
|
|
||||||
ranges.add(range);
|
|
||||||
range = new StyleRange(messagesText.getCharCount() + offset,
|
|
||||||
(userId != null ? name.length() + 1 : sb.length() - offset),
|
|
||||||
fgColor, null, SWT.BOLD);
|
|
||||||
ranges.add(range);
|
|
||||||
messagesText.append(sb.toString());
|
|
||||||
for (StyleRange newRange : ranges) {
|
|
||||||
messagesText.setStyleRange(newRange);
|
|
||||||
}
|
|
||||||
int lineNumber = messagesText.getLineCount() - 1;
|
|
||||||
messagesText.setLineBackground(lineNumber, 1, bgColor);
|
|
||||||
messagesText.setTopIndex(lineNumber);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRoom() {
|
public String getRoom() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue