Issue #642 fix for finding double instances of words
Former-commit-id:253b5fe2e8
[formerly253b5fe2e8
[formerly 5d3001a8bdd5ab6b89efe54e7d3c6b3266e880ec]] Former-commit-id:bed5ec6876
Former-commit-id:bb957ec167
This commit is contained in:
parent
1dc156d196
commit
bcb561b87b
1 changed files with 66 additions and 45 deletions
|
@ -267,8 +267,9 @@ public abstract class AbstractSessionView extends ViewPart {
|
|||
cal.setTimeInMillis(timestamp);
|
||||
String time = String.format("%1$tI:%1$tM:%1$tS %1$Tp", cal);
|
||||
|
||||
if (!CollaborationDataManager.getInstance()
|
||||
.getCollaborationConnection(true).getUser().equals(userId)
|
||||
UserId myUser = CollaborationDataManager.getInstance()
|
||||
.getCollaborationConnection(true).getUser();
|
||||
if (!myUser.equals(userId)
|
||||
&& Activator.getDefault().getPreferenceStore()
|
||||
.getBoolean("notifications")) {
|
||||
createNotifier(userId, time, body);
|
||||
|
@ -297,9 +298,15 @@ public abstract class AbstractSessionView extends ViewPart {
|
|||
List<StyleRange> ranges = new ArrayList<StyleRange>();
|
||||
if (alertWords != null) {
|
||||
for (AlertWord keyword : alertWords) {
|
||||
if (sb.toString().toLowerCase()
|
||||
.contains(keyword.getText().toLowerCase())) {
|
||||
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 {
|
||||
|
@ -308,9 +315,11 @@ public abstract class AbstractSessionView extends ViewPart {
|
|||
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 {
|
||||
|
@ -319,9 +328,7 @@ public abstract class AbstractSessionView extends ViewPart {
|
|||
}
|
||||
TextStyle style = new TextStyle(font, color, null);
|
||||
StyleRange keywordRange = new StyleRange(style);
|
||||
keywordRange.start = messagesText.getCharCount()
|
||||
+ sb.toString().toLowerCase()
|
||||
.indexOf(keyword.getText().toLowerCase());
|
||||
keywordRange.start = currentLength + index;
|
||||
keywordRange.length = keyword.getText().length();
|
||||
|
||||
// compare to see if this position is already styled
|
||||
|
@ -329,7 +336,8 @@ public abstract class AbstractSessionView extends ViewPart {
|
|||
// rnges.addAll(ranges);
|
||||
// for (StyleRange range : rnges) {
|
||||
// if (range.start >= keywordRange.start
|
||||
// && (range.start + range.length) >= (keywordRange.start))
|
||||
// && (range.start + range.length) >=
|
||||
// (keywordRange.start))
|
||||
// {
|
||||
// if (range.length < keywordRange.length) {
|
||||
// ranges.remove(range);
|
||||
|
@ -339,9 +347,22 @@ public abstract class AbstractSessionView extends ViewPart {
|
|||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
ranges.add(keywordRange);
|
||||
|
||||
// only execute things if the same user didn't type it
|
||||
if (!myUser.equals(userId)) {
|
||||
executeSightsSounds(keyword);
|
||||
}
|
||||
System.out.println("index before : " + index);
|
||||
// need to handle all instances of the keyword within
|
||||
// the chat
|
||||
index = lowerCase.indexOf(text, text.length() + index);
|
||||
System.out.println("index after : " + index);
|
||||
System.out.println("messagesText.getCharCount() : "
|
||||
+ messagesText.getCharCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue