### Eclipse Workspace Patch 1.0 #P org.eclipse.ecf.presence.ui Index: src/org/eclipse/ecf/presence/ui/chatroom/ChatRoomManagerView.java =================================================================== RCS file: /cvsroot/technology/org.eclipse.ecf/plugins/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/presence/ui/chatroom/ChatRoomManagerView.java,v retrieving revision 1.29 diff -u -r1.29 ChatRoomManagerView.java --- src/org/eclipse/ecf/presence/ui/chatroom/ChatRoomManagerView.java 27 Aug 2007 22:08:49 -0000 1.29 +++ src/org/eclipse/ecf/presence/ui/chatroom/ChatRoomManagerView.java 1 Sep 2007 15:26:53 -0000 @@ -1422,16 +1422,18 @@ } st.append(output); + if (ranges != null) { // set all ranges to start as message line starts for (int i = 0; i < ranges.length; i++) { ranges[i].start += startRange; - st.setStyleRange(ranges[i]); } + st.replaceStyleRanges(startRange, output.length(), ranges); } if (isAtEndBeforeAppend) scrollToEnd(st); + if (isCurrentlyActive(chatRoomTab)) chatRoomTab.makeTabItemNormal(); else chatRoomTab.makeTabItemBold(); } Index: src/org/eclipse/ecf/presence/ui/chatroom/MessageRenderer.java =================================================================== RCS file: /cvsroot/technology/org.eclipse.ecf/plugins/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/presence/ui/chatroom/MessageRenderer.java,v retrieving revision 1.2 diff -u -r1.2 MessageRenderer.java --- src/org/eclipse/ecf/presence/ui/chatroom/MessageRenderer.java 30 Jul 2007 20:56:48 -0000 1.2 +++ src/org/eclipse/ecf/presence/ui/chatroom/MessageRenderer.java 1 Sep 2007 15:26:53 -0000 @@ -21,48 +21,63 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyleRange; import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Font; import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.themes.ITheme; /** * Default implementation of {@link IMessageRenderer}. * */ public class MessageRenderer implements IMessageRenderer { - - private Color otherColor = null; - private Color systemColor = null; - private Color dateColor = null; - private Color highlightColor = null; private StringBuffer buffer; private List styleRanges = new ArrayList(); - protected static final String DEFAULT_ME_COLOR = "0,255,0"; //$NON-NLS-1$ - protected static final String DEFAULT_OTHER_COLOR = "0,0,0"; //$NON-NLS-1$ - protected static final String DEFAULT_SYSTEM_COLOR = "0,0,255"; //$NON-NLS-1$ + /** + * Messages sent by local user + */ + protected static final String SENT_COLOR = "org.eclipse.ecf.presence.sentColor"; //$NON-NLS-1$ + protected static final String SENT_FONT = "org.eclipse.ecf.presence.sentFont"; //$NON-NLS-1$ + + /** + * Any received messages + */ + protected static final String RECEIVED_COLOR = "org.eclipse.ecf.presence.receivedColor"; //$NON-NLS-1$ + protected static final String RECEIVED_FONT = "org.eclipse.ecf.presence.receivedFont"; //$NON-NLS-1$ + + /** + * System messages, eg. server notifications + */ + protected static final String SYSTEM_COLOR = "org.eclipse.ecf.presence.systemColor"; //$NON-NLS-1$ + protected static final String SYSTEM_FONT = "org.eclipse.ecf.presence.systemFont"; //$NON-NLS-1$ /** - * The default color used to highlight the string of text when the user's + * The default color used to highlight message when the user's * name is referred to in the chatroom. The default color is red. */ - protected static final String DEFAULT_HIGHLIGHT_COLOR = "255,0,0"; //$NON-NLS-1$ - protected static final String DEFAULT_DATE_COLOR = "0,0,0"; //$NON-NLS-1$ + protected static final String RECEIVEDHIGHLIGHT_COLOR = "org.eclipse.ecf.presence.receivedHighlightColor"; //$NON-NLS-1$ + protected static final String RECEIVEDHIGHLIGHT_FONT = "org.eclipse.ecf.presence.receivedHighlightFont"; //$NON-NLS-1$ + + /** + * Date stamp in message window + */ + protected static final String DATE_COLOR = "org.eclipse.ecf.presence.dateColor"; //$NON-NLS-1$ + protected static final String DATE_FONT = "org.eclipse.ecf.presence.dateFont"; //$NON-NLS-1$ protected static final String DEFAULT_TIME_FORMAT = Messages.MessageRenderer_DEFAULT_TIME_FORMAT; protected static final String DEFAULT_DATE_FORMAT = Messages.MessageRenderer_DEFAULT_DATE_FORMAT; protected boolean nickContained; + protected boolean isSent; protected String message; protected String originator; - public MessageRenderer() { - otherColor = colorFromRGBString(DEFAULT_OTHER_COLOR); - systemColor = colorFromRGBString(DEFAULT_SYSTEM_COLOR); - highlightColor = colorFromRGBString(DEFAULT_HIGHLIGHT_COLOR); - dateColor = colorFromRGBString(DEFAULT_DATE_COLOR); - } + private String font; + private String color; public StyleRange[] getStyleRanges() { return (StyleRange[]) styleRanges.toArray(new StyleRange[styleRanges.size()]); @@ -88,6 +103,21 @@ // is not the user himself, no highlighting is required in this case // as the user is already aware that his name is being referenced nickContained = (message.indexOf(localUserName) != -1) && (! localUserName.equals(originator)); + isSent = (originator != null) && (originator.equals(localUserName)); + + if (originator == null) { + color = SYSTEM_COLOR; + font = SYSTEM_FONT; + } else if (isSent) { + color = SENT_COLOR; + font = SENT_FONT; + } else if (nickContained) { + color = RECEIVEDHIGHLIGHT_COLOR; + font = RECEIVEDHIGHLIGHT_FONT; + } else { + color = RECEIVED_COLOR; + font = RECEIVED_FONT; + } doRender(); @@ -105,30 +135,19 @@ protected void appendDateTime() { String message = NLS.bind(Messages.MessageRenderer_DEFAULT_DATETIME_FORMAT, getCurrentDate(DEFAULT_TIME_FORMAT)) + " "; - append(message, dateColor, null, SWT.NORMAL); + append(message, DATE_COLOR, null, DATE_FONT); } protected void appendNickname() { String message = originator + ": "; //$NON-NLS-1$ - // check to see which color should be used - Color foreground = nickContained ? highlightColor : otherColor; - append(message, foreground, null, SWT.BOLD); + append(message, color, null, font); } protected void appendMessage() { - Color color = null; - int style = SWT.NONE; - if (originator == null) { - color = systemColor; - style = SWT.BOLD; - } else if (nickContained) { - // highlight the message itself as necessary - color = highlightColor; - } - append(message, color, null, style); + append(message, color, null, font); } - protected void append(String message, Color foreground, Color background, int style) { + protected void append(String message, String foreground, String background, String font) { if (message == null) { return; } @@ -137,30 +156,45 @@ buffer.append(message); - if (foreground == null && background == null && style == SWT.NONE) { + if (foreground == null && background == null && font == null) { return; } - StyleRange styleRange = new StyleRange(start, message.length(), foreground, background, style); + StyleRange styleRange = new StyleRange(start, message.length(), getColor(foreground), getColor(background)); + styleRange.font = getFont(font); styleRanges.add(styleRange); } - private Color colorFromRGBString(String rgb) { - Color color = null; - if (rgb == null || rgb.equals("")) { //$NON-NLS-1$ - color = new Color(Display.getCurrent(), 0, 0, 0); - return color; - } - if (color != null) { - color.dispose(); - } - String[] vals = rgb.split(","); //$NON-NLS-1$ - color = new Color(Display.getCurrent(), Integer - .parseInt(vals[0]), Integer.parseInt(vals[1]), Integer - .parseInt(vals[2])); + private Color getColor(String name) { + if (name == null) { + return null; + } + + ITheme theme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme(); + Color color = theme.getColorRegistry().get(name); + + if (color == null) { + return Display.getDefault().getSystemColor(SWT.COLOR_BLACK); + } + return color; } + private Font getFont(String name) { + if (name == null) { + return null; + } + + ITheme theme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme(); + Font font = theme.getFontRegistry().get(name); + + if (font == null) { + return Display.getDefault().getSystemFont(); + } + + return font; + } + protected String getCurrentDate(String format) { SimpleDateFormat sdf = new SimpleDateFormat(format); String res = sdf.format(new Date()); Index: plugin.properties =================================================================== RCS file: /cvsroot/technology/org.eclipse.ecf/plugins/org.eclipse.ecf.presence.ui/plugin.properties,v retrieving revision 1.6 diff -u -r1.6 plugin.properties --- plugin.properties 27 Jul 2007 22:05:01 -0000 1.6 +++ plugin.properties 1 Sep 2007 15:26:47 -0000 @@ -15,4 +15,26 @@ browse.command.label = Open Contact... browse.command.tooltip = Open Contact -chatroom.preferencePage.name = Chat Room \ No newline at end of file +chatroom.preferencePage.name = Chat Room +themeElementCategory.messagesAndChats = Messages and Chats +themeElementCategory.messagesAndChats.description = Appearance details of ECF message and chat windows. +fontDefinition.dateFont = Date font +fontDefinition.dateFont.description = Font of the date stamp in message window. +colorDefinition.dateColor = Date color +colorDefinition.dateColor.description = Color of the date stamp in message window. +fontDefinition.highlightFont = Highlight font +fontDefinition.highlightFont.description = Font of the date stamp in message window. +colorDefinition.highlightColor = Highlight color +colorDefinition.HighlightColor.description = The default color used to highlight the string of text when the user's name is referred to in the chatroom. The default color is red. +fontDefinition.systemMessagesFont = System messages font +fontDefinition.systemMessagesFont.description = Font of the date stamp in message window. +colorDefinition.systemMessagesColor = System messages color +colorDefinition.systemMessagesColor.description = Color of messages sent by the system, eg. a server notifications. +fontDefinition.receivedMessagesFont = Received messages font +fontDefinition.receivedMessagesFont.description = Font of the date stamp in message window. +colorDefinition.receivedMessagesColor = Received messages color +colorDefinition.receivedMessagesColor.description = Color of any received messages. +fontDefinition.sentMessagesFont = Sent messages font +fontDefinition.sentMessagesFont.description = Font of the date stamp in message window. +colorDefinition.sentMessagesColor = Sent messages color +colorDefinition.sentMessagesColor.description = Color of messages sent by local user. \ No newline at end of file Index: plugin.xml =================================================================== RCS file: /cvsroot/technology/org.eclipse.ecf/plugins/org.eclipse.ecf.presence.ui/plugin.xml,v retrieving revision 1.21 diff -u -r1.21 plugin.xml --- plugin.xml 28 Jul 2007 04:51:23 -0000 1.21 +++ plugin.xml 1 Sep 2007 15:26:47 -0000 @@ -180,5 +180,107 @@ class="org.eclipse.ecf.internal.presence.ui.preferences.PreferenceInitializer"> + + + + %themeElementCategory.messagesAndChats.description + + + + + %fontDefinition.dateFont.description + + + + + %colorDefinition.dateColor.description + + + + + %fontDefinition.highlightFont.description + + + + + %colorDefinition.HighlightColor.description + + + + + %fontDefinition.systemMessagesFont.description + + + + + %colorDefinition.systemMessagesColor.description + + + + + %fontDefinition.receivedMessagesFont.description + + + + + %colorDefinition.receivedMessagesColor.description + + + + + %fontDefinition.sentMessagesFont.description + + + + + %colorDefinition.sentMessagesColor.description + + + + #P org.eclipse.ecf.provider.irc.ui Index: src/org/eclipse/ecf/internal/irc/ui/IRCMessageRenderer.java =================================================================== RCS file: /cvsroot/technology/org.eclipse.ecf/plugins/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/IRCMessageRenderer.java,v retrieving revision 1.1 diff -u -r1.1 IRCMessageRenderer.java --- src/org/eclipse/ecf/internal/irc/ui/IRCMessageRenderer.java 27 Jul 2007 15:11:23 -0000 1.1 +++ src/org/eclipse/ecf/internal/irc/ui/IRCMessageRenderer.java 1 Sep 2007 15:26:56 -0000 @@ -11,10 +11,16 @@ package org.eclipse.ecf.internal.irc.ui; import org.eclipse.ecf.presence.ui.chatroom.MessageRenderer; -import org.eclipse.swt.SWT; public class IRCMessageRenderer extends MessageRenderer { + /** + * Messages sent by local user using /me command + */ + protected static final String IRC_ME_COLOR = "org.eclipse.ecf.presence.irc.meColor"; //$NON-NLS-1$ + protected static final String IRC_ME_FONT = "org.eclipse.ecf.provider.irc.meFont"; //$NON-NLS-1$ + + private final static String ME_PREFIX = "\01ACTION "; //$NON-NLS-1$ private final static String ME_SUFFIX = "\01"; //$NON-NLS-1$ @@ -34,7 +40,7 @@ protected void appendNickname() { if (isActionMessage) { String message = originator + " "; //$NON-NLS-1$ - append(message, null, null, SWT.ITALIC); + append(message, IRC_ME_COLOR, null, IRC_ME_FONT); } else { super.appendNickname(); } @@ -42,7 +48,7 @@ protected void appendMessage() { if (isActionMessage) { - append(message, null, null, SWT.ITALIC); + append(message, IRC_ME_COLOR, null, IRC_ME_FONT); } else { super.appendMessage(); } Index: plugin.properties =================================================================== RCS file: /cvsroot/technology/org.eclipse.ecf/plugins/org.eclipse.ecf.provider.irc.ui/plugin.properties,v retrieving revision 1.4 diff -u -r1.4 plugin.properties --- plugin.properties 24 Jul 2007 15:25:19 -0000 1.4 +++ plugin.properties 1 Sep 2007 15:26:56 -0000 @@ -18,4 +18,8 @@ DeopAction_Label=Deop VoiceAction_Label=Voice DevoiceAction_Label=Devoice -WhoisAction_Label=Whois \ No newline at end of file +WhoisAction_Label=Whois +colorDefinition.ircMeColor = IRC /me color +colorDefinition.ircMeColor.description = Color of messages sent by local user using /me command. +fontDefinition.ircMeFont = IRC /me font +fontDefinition.ircMeFont.description = Font of messages sent by local user using /me command. \ No newline at end of file Index: plugin.xml =================================================================== RCS file: /cvsroot/technology/org.eclipse.ecf/plugins/org.eclipse.ecf.provider.irc.ui/plugin.xml,v retrieving revision 1.6 diff -u -r1.6 plugin.xml --- plugin.xml 24 Jul 2007 15:25:19 -0000 1.6 +++ plugin.xml 1 Sep 2007 15:26:56 -0000 @@ -75,5 +75,28 @@ + + + + %colorDefinition.ircMeColor.description + + + + + %fontDefinition.ircMeFont.description + + +