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
|
||||
* Jan 15, 2014 2630 bclement added mode map
|
||||
* Mar 24, 2015 4265 mapeters Get alert words from not only user localization level.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -88,7 +89,7 @@ public class CollaborationUtils {
|
|||
/**
|
||||
* Get an image associated with the node.
|
||||
*
|
||||
* @param node
|
||||
* @param name
|
||||
* @return image
|
||||
*/
|
||||
public static Image getNodeImage(String name) {
|
||||
|
@ -103,7 +104,7 @@ public class CollaborationUtils {
|
|||
LocalizationFile file = PathManagerFactory.getPathManager()
|
||||
.getLocalizationFile(
|
||||
context,
|
||||
"collaboration" + File.separator
|
||||
"collaboration" + IPathManager.SEPARATOR
|
||||
+ "collaborationAliases.xml");
|
||||
if (file.exists()) {
|
||||
UserIdWrapper ids = JAXB.unmarshal(file.getFile(),
|
||||
|
@ -151,29 +152,40 @@ public class CollaborationUtils {
|
|||
return modeMap.get(status);
|
||||
}
|
||||
|
||||
public static List<AlertWord> getAlertWords() {
|
||||
LocalizationFile file = null;
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
LocalizationContext context = pm.getContext(
|
||||
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
|
||||
file = PathManagerFactory.getPathManager().getLocalizationFile(context,
|
||||
"collaboration" + File.separator + "alertWords.xml");
|
||||
if (file.exists() || file.getFile().exists()) {
|
||||
AlertWordWrapper words = JAXB.unmarshal(file.getFile(),
|
||||
AlertWordWrapper.class);
|
||||
if (words.getAlertWords() == null) {
|
||||
return new ArrayList<AlertWord>();
|
||||
}
|
||||
/**
|
||||
* Gets the alert words either from the lowest localization level or from
|
||||
* only the user level (if specified).
|
||||
*
|
||||
* @param userOnly
|
||||
* whether or not to only retrieve alert words from user level
|
||||
* @return list of alert words
|
||||
*/
|
||||
public static List<AlertWord> getAlertWords(boolean userOnly) {
|
||||
LocalizationFile file = PathManagerFactory.getPathManager()
|
||||
.getStaticLocalizationFile(
|
||||
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>();
|
||||
for (int i = 0; i < words.getAlertWords().length; i++) {
|
||||
alertWords.add(words.getAlertWords()[i]);
|
||||
}
|
||||
List<AlertWord> alertWords = new ArrayList<AlertWord>();
|
||||
for (int i = 0; i < words.getAlertWords().length; 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) {
|
||||
|
@ -181,8 +193,8 @@ public class CollaborationUtils {
|
|||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
LocalizationContext context = pm.getContext(
|
||||
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
|
||||
file = PathManagerFactory.getPathManager().getLocalizationFile(context,
|
||||
"collaboration" + File.separator + "alertWords.xml");
|
||||
file = pm.getLocalizationFile(context, "collaboration"
|
||||
+ IPathManager.SEPARATOR + "alertWords.xml");
|
||||
|
||||
// save the sound file in the correct place if not there
|
||||
for (AlertWord word : words) {
|
||||
|
@ -191,8 +203,8 @@ public class CollaborationUtils {
|
|||
String[] dirs = soundPath.split(File.separator);
|
||||
String filename = dirs[dirs.length - 1];
|
||||
LocalizationFile lFile = pm.getLocalizationFile(context,
|
||||
"collaboration" + File.separator + "sounds"
|
||||
+ File.separator + filename);
|
||||
"collaboration" + IPathManager.SEPARATOR + "sounds"
|
||||
+ IPathManager.SEPARATOR + filename);
|
||||
if (!lFile.exists()) {
|
||||
File soundFile = new File(soundPath);
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@ import com.raytheon.uf.viz.collaboration.ui.data.AlertWordWrapper;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* May 17, 2012 mnash Initial creation
|
||||
* Feb 24, 2014 2632 mpduf Created CollaborationPreferencesAlertWordLabelProvider
|
||||
* Mar 24, 2015 4265 mapeters Account for altered CollaborationUtils.getAlertWords()
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -253,7 +254,7 @@ public class CollaborationAlertWordsPreferencePage extends
|
|||
fileEditor.setStringValue(word.getSoundPath());
|
||||
}
|
||||
});
|
||||
viewer.setInput(CollaborationUtils.getAlertWords());
|
||||
viewer.setInput(CollaborationUtils.getAlertWords(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -100,6 +100,8 @@ import com.raytheon.viz.ui.views.CaveFloatingView;
|
|||
* Nov 26, 2014 3709 mapeters Added {@link #getColorFromRGB()}.
|
||||
* Dec 08, 2014 3709 mapeters Removed messagesTextMenuMgr.
|
||||
* 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>
|
||||
*
|
||||
* @author rferrel
|
||||
|
@ -450,8 +452,7 @@ public abstract class AbstractSessionView<T extends IUser> extends
|
|||
}
|
||||
}
|
||||
|
||||
styleAndAppendText(sb, offset, name, userId, subject,
|
||||
ranges);
|
||||
styleAndAppendText(sb, offset, name, userId, ranges);
|
||||
}
|
||||
|
||||
// Archive the message
|
||||
|
@ -468,11 +469,31 @@ public abstract class AbstractSessionView<T extends IUser> extends
|
|||
}
|
||||
|
||||
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,
|
||||
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.
|
||||
|
@ -483,7 +504,7 @@ public abstract class AbstractSessionView<T extends IUser> extends
|
|||
*/
|
||||
protected List<AlertWord> retrieveAlertWords() {
|
||||
if (alertWords == null) {
|
||||
alertWords = CollaborationUtils.getAlertWords();
|
||||
alertWords = CollaborationUtils.getAlertWords(false);
|
||||
}
|
||||
return alertWords;
|
||||
}
|
||||
|
|
|
@ -78,6 +78,7 @@ import com.raytheon.uf.viz.core.sounds.SoundUtil;
|
|||
* dispose them.
|
||||
* Jan 09, 2015 3709 bclement color config manager API changes
|
||||
* Jan 13, 2015 3709 bclement ChangeTextColorAction API changes
|
||||
* Mar 24, 2015 4265 mapeters abstracted out common styleAndAppendText()
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -213,7 +214,7 @@ public class PeerToPeerView extends AbstractSessionView<IUser> implements
|
|||
|
||||
@Override
|
||||
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
|
||||
.getConnection();
|
||||
if (connection == null) {
|
||||
|
@ -231,29 +232,6 @@ public class PeerToPeerView extends AbstractSessionView<IUser> implements
|
|||
}
|
||||
styleAndAppendText(sb, offset, name, userId, ranges, foreground,
|
||||
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
|
||||
|
|
|
@ -50,7 +50,6 @@ import org.eclipse.swt.custom.StyledText;
|
|||
import org.eclipse.swt.events.MouseAdapter;
|
||||
import org.eclipse.swt.events.MouseEvent;
|
||||
import org.eclipse.swt.events.MouseTrackAdapter;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.GC;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
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.
|
||||
* Jan 09, 2015 3709 bclement color config manager API changes
|
||||
* Jan 12, 2015 3709 bclement unified color management into SessionColorManager
|
||||
* Mar 24, 2015 4265 mapeters abstracted out common styleAndAppendText()s
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -164,6 +164,7 @@ public class SessionView extends AbstractSessionView<VenueParticipant>
|
|||
* custom color configuration for a participant
|
||||
*/
|
||||
protected final ChangeTextColorCallback refreshCallback = new ChangeTextColorCallback() {
|
||||
@Override
|
||||
public void newColor(IUser user, UserColorInfo colors) {
|
||||
refreshParticipantList();
|
||||
}
|
||||
|
@ -510,47 +511,11 @@ public class SessionView extends AbstractSessionView<VenueParticipant>
|
|||
*/
|
||||
@Override
|
||||
protected void styleAndAppendText(StringBuilder sb, int offset,
|
||||
String name, VenueParticipant userId, String subject,
|
||||
List<StyleRange> ranges) {
|
||||
String name, VenueParticipant userId, List<StyleRange> ranges) {
|
||||
UserColorInfo colors = colorManager.getColorForUser(userId);
|
||||
styleAndAppendText(sb, offset, name, userId, ranges,
|
||||
getColorFromRGB(colors.getForeground()),
|
||||
getColorFromRGB(colors.getBackground()), subject);
|
||||
}
|
||||
|
||||
/*
|
||||
* (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);
|
||||
getColorFromRGB(colors.getBackground()));
|
||||
}
|
||||
|
||||
public String getRoom() {
|
||||
|
|
Loading…
Add table
Reference in a new issue