Lines 150-155
Link Here
|
150 |
private IChatRoomViewCloseListener rootCloseListener = null; |
150 |
private IChatRoomViewCloseListener rootCloseListener = null; |
151 |
|
151 |
|
152 |
private IChatRoomMessageSender rootMessageSender = null; |
152 |
private IChatRoomMessageSender rootMessageSender = null; |
|
|
153 |
|
154 |
/** |
155 |
* UI independent renderer, that is aware of displaying any special fragments |
156 |
* of message, like formatting, graphical attachments, emotional content, etc. |
157 |
*/ |
158 |
private IMessageRenderer messageRenderer = null; |
153 |
|
159 |
|
154 |
private Color otherColor = null; |
160 |
private Color otherColor = null; |
155 |
|
161 |
|
Lines 1373-1433
Link Here
|
1373 |
|
1379 |
|
1374 |
boolean scrollToBottom = shouldScrollToEnd(st); |
1380 |
boolean scrollToBottom = shouldScrollToEnd(st); |
1375 |
|
1381 |
|
1376 |
int startRange = st.getText().length(); |
1382 |
String output = messageRenderer.render(text, localUserName); |
1377 |
StringBuffer sb = new StringBuffer(); |
1383 |
StyleRange[] ranges = messageRenderer.getStyleRanges(); |
1378 |
// check to see if the message has the user's name contained within |
1384 |
|
1379 |
boolean nickContained = text.getText().indexOf(localUserName) != -1; |
1385 |
if (output == null) { |
1380 |
if (text.getOriginator() != null) { |
1386 |
return; |
1381 |
// check to make sure that the person referring to the user's name |
|
|
1382 |
// is not the user himself, no highlighting is required in this case |
1383 |
// as the user is already aware that his name is being referenced |
1384 |
nickContained = !text.getOriginator().getName().equals( |
1385 |
localUserName) |
1386 |
&& nickContained; |
1387 |
sb.append(NLS.bind(Messages.ChatRoomManagerView_MESSAGE_DATE, |
1388 |
getCurrentDate(DEFAULT_TIME_FORMAT))); |
1389 |
StyleRange dateStyle = new StyleRange(); |
1390 |
dateStyle.start = startRange; |
1391 |
dateStyle.length = sb.length(); |
1392 |
dateStyle.foreground = dateColor; |
1393 |
dateStyle.fontStyle = SWT.NORMAL; |
1394 |
st.append(sb.toString()); |
1395 |
st.setStyleRange(dateStyle); |
1396 |
sb = new StringBuffer(); |
1397 |
sb.append(text.getOriginator().getName()).append(": "); //$NON-NLS-1$ |
1398 |
StyleRange sr = new StyleRange(); |
1399 |
sr.start = startRange + dateStyle.length; |
1400 |
sr.length = sb.length(); |
1401 |
sr.fontStyle = SWT.BOLD; |
1402 |
// check to see which color should be used |
1403 |
sr.foreground = nickContained ? highlightColor : otherColor; |
1404 |
st.append(sb.toString()); |
1405 |
st.setStyleRange(sr); |
1406 |
} |
1407 |
int beforeMessageIndex = st.getText().length(); |
1408 |
st.append(text.getText()); |
1409 |
if (text.getOriginator() == null) { |
1410 |
StyleRange sr = new StyleRange(); |
1411 |
sr.start = beforeMessageIndex; |
1412 |
sr.length = text.getText().length(); |
1413 |
sr.foreground = systemColor; |
1414 |
sr.fontStyle = SWT.BOLD; |
1415 |
st.setStyleRange(sr); |
1416 |
} else if (nickContained) { |
1417 |
// highlight the message itself as necessary |
1418 |
StyleRange sr = new StyleRange(); |
1419 |
sr.start = beforeMessageIndex; |
1420 |
sr.length = text.getText().length(); |
1421 |
sr.foreground = highlightColor; |
1422 |
st.setStyleRange(sr); |
1423 |
} |
1387 |
} |
1424 |
if (!text.isNoCRLF()) { |
1388 |
|
1425 |
st.append("\n"); //$NON-NLS-1$ |
1389 |
st.append(output); |
|
|
1390 |
if (ranges != null) { |
1391 |
// TODO: recalc StyleRanges start offsets to start begin with appended output |
1392 |
st.setStyleRanges(ranges); |
1426 |
} |
1393 |
} |
1427 |
String t = st.getText(); |
1394 |
|
1428 |
if (t == null) |
1395 |
if (scrollToBottom) st.setSelection(output.length()); |
1429 |
return; |
|
|
1430 |
if (scrollToBottom) st.setSelection(t.length()); |
1431 |
// Bold title if view is not visible. |
1396 |
// Bold title if view is not visible. |
1432 |
IWorkbenchSiteProgressService pservice = (IWorkbenchSiteProgressService) this |
1397 |
IWorkbenchSiteProgressService pservice = (IWorkbenchSiteProgressService) this |
1433 |
.getSite().getAdapter(IWorkbenchSiteProgressService.class); |
1398 |
.getSite().getAdapter(IWorkbenchSiteProgressService.class); |
Lines 1566-1569
Link Here
|
1566 |
.parseInt(vals[2])); |
1531 |
.parseInt(vals[2])); |
1567 |
return color; |
1532 |
return color; |
1568 |
} |
1533 |
} |
|
|
1534 |
|
1535 |
public void setMessageRenderer(IMessageRenderer defaultMessageRenderer) { |
1536 |
this.messageRenderer = defaultMessageRenderer; |
1537 |
} |
1569 |
} |
1538 |
} |