Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 74788 Details for
Bug 197329
[IRC] Action should be supported better in the UI
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
final
patch.txt (text/plain), 29.95 KB, created by
Jacek Pospychala
on 2007-07-27 07:34:30 EDT
(
hide
)
Description:
final
Filename:
MIME Type:
Creator:
Jacek Pospychala
Created:
2007-07-27 07:34:30 EDT
Size:
29.95 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ecf.presence.ui >Index: src/org/eclipse/ecf/internal/presence/ui/Messages.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.ecf/plugins/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/internal/presence/ui/Messages.java,v >retrieving revision 1.22 >diff -u -r1.22 Messages.java >--- src/org/eclipse/ecf/internal/presence/ui/Messages.java 19 Jul 2007 19:06:27 -0000 1.22 >+++ src/org/eclipse/ecf/internal/presence/ui/Messages.java 27 Jul 2007 11:15:06 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * Composent, Inc. - initial API and implementation >+ * Jacek Pospychala <jacek.pospychala@pl.ibm.com> - bug 197329 > *****************************************************************************/ > > package org.eclipse.ecf.internal.presence.ui; >@@ -60,8 +61,6 @@ > > public static String ChatRoomManagerView_COPY_TOOLTIP; > >- public static String ChatRoomManagerView_DATE_FORMAT; >- > public static String ChatRoomManagerView_DEFAULT_HOST; > > public static String ChatRoomManagerView_DEFAULT_USER; >@@ -73,8 +72,6 @@ > public static String ChatRoomManagerView_JOIN_COMMAND; > > public static String ChatRoomManagerView_MESSAGE; >- >- public static String ChatRoomManagerView_MESSAGE_DATE; > > public static String ChatRoomManagerView_NOT_CONNECTED_MESSAGE; > >@@ -88,8 +85,6 @@ > > public static String ChatRoomManagerView_SELECT_ALL_TOOLTIP; > >- public static String ChatRoomManagerView_TIME_FORMAT; >- > public static String ChatRoomManagerView_VIEW_DISABLED_NAME; > > public static String ChatRoomManagerView_VIEW_TITLE; >@@ -234,6 +229,10 @@ > > public static String ToggleOnlineOnlyAction_title; > >+ public static String MessageRenderer_DEFAULT_DATE_FORMAT; >+ public static String MessageRenderer_DEFAULT_DATETIME_FORMAT; >+ public static String MessageRenderer_DEFAULT_TIME_FORMAT; >+ > static { > NLS.initializeMessages(BUNDLE_NAME, Messages.class); > } >Index: src/org/eclipse/ecf/internal/presence/ui/messages.properties >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.ecf/plugins/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/internal/presence/ui/messages.properties,v >retrieving revision 1.24 >diff -u -r1.24 messages.properties >--- src/org/eclipse/ecf/internal/presence/ui/messages.properties 19 Jul 2007 19:06:27 -0000 1.24 >+++ src/org/eclipse/ecf/internal/presence/ui/messages.properties 27 Jul 2007 11:15:06 -0000 >@@ -7,6 +7,7 @@ > # > # Contributors: > # Composent, Inc. - initial API and implementation >+# Jacek Pospychala <jacek.pospychala@pl.ibm.com> - bug 197329 > ################################################################################ > > ########################## >@@ -84,8 +85,6 @@ > MultiRosterView_DISCONNECT_ACCOUNT_QUESTION_MESSAGE=Disconnect account {0}? > MultiRosterView_ROSTER_VIEW_EXT_POINT_ERROR_MESSAGE=Error in loading rosterViewerDropTargetExtension > MultiRosterView_EXCEPTION_JOIN_ROOM_INVALID_ACCOUNT=Invalid account >-ChatRoomManagerView_TIME_FORMAT=HH:mm:ss >-ChatRoomManagerView_DATE_FORMAT=yyyy-MM-dd > ChatRoomSelectionDialog_MESSAGE=Select a Chat Room to Enter > ChatRoomManagerView_DEFAULT_USER=<user> > ChatRoomManagerView_DEFAULT_HOST=<host> >@@ -111,14 +110,13 @@ > ChatRoomManagerView_NOT_CONNECTED_TITLE=Not Connected > ChatRoomManagerView_NOT_CONNECTED_MESSAGE=Not connected to chat room > ChatRoomManagerView_PART_COMMAND=PART >-ChatRoomManagerView_ENTERED_MESSAGE=({0}) {1} entered >+ChatRoomManagerView_ENTERED_MESSAGE={0} entered > ChatRoomView_NOT_CONNECTED_MESSAGE=Not connected to chat room >-ChatRoomManagerView_LEFT_MESSAGE=({0}) {1} left >+ChatRoomManagerView_LEFT_MESSAGE={0} left > ChangePasswordDialog_CHANGE_PASSWORD=Change Password > ChatRoomManagerView_MESSAGE={0}: {1}\n > ChatRoomView_TIME_FORMAT=HH:mm:ss >-ChatRoomView_DATE_FORMAT=yyyy-MM-dd >-ChatRoomManagerView_MESSAGE_DATE=({0}) >+ChatRoomView_DATE_FORMAT=yyyy-MM-dd > ChatRoomView_NOT_CONNECTED_TITLE=Not connect > ChatRoomManagerView_CLEAR_CONFIRM_TITLE=Confirm Clear Output > ChangePasswordDialog_NEW_PASSWORD_LABEL=New Password: >@@ -138,4 +136,8 @@ > BrowseDialog_title=Open Contact > BrowseDialog_message=Select a contact to message (*, ?, or camel case): > BrowseDialog_scanning=Scanning contacts... >-ToggleOnlineOnlyAction_title=Show Online Only >\ No newline at end of file >+ToggleOnlineOnlyAction_title=Show Online Only >+ >+MessageRenderer_DEFAULT_TIME_FORMAT=HH:mm:ss >+MessageRenderer_DEFAULT_DATE_FORMAT=yyyy-MM-dd >+MessageRenderer_DEFAULT_DATETIME_FORMAT=({0}) >\ No newline at end of file >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.17 >diff -u -r1.17 ChatRoomManagerView.java >--- src/org/eclipse/ecf/presence/ui/chatroom/ChatRoomManagerView.java 26 Jul 2007 20:43:14 -0000 1.17 >+++ src/org/eclipse/ecf/presence/ui/chatroom/ChatRoomManagerView.java 27 Jul 2007 11:15:07 -0000 >@@ -7,7 +7,7 @@ > * > * Contributors: > * Composent, Inc. - initial API and implementation >- * Jacek Pospychala <jacek.pospychala@pl.ibm.com> - bug 192762 >+ * Jacek Pospychala <jacek.pospychala@pl.ibm.com> - bug 192762, 197329 > ******************************************************************************/ > package org.eclipse.ecf.presence.ui.chatroom; > >@@ -76,7 +76,6 @@ > import org.eclipse.swt.events.KeyListener; > import org.eclipse.swt.events.SelectionEvent; > import org.eclipse.swt.events.SelectionListener; >-import org.eclipse.swt.graphics.Color; > import org.eclipse.swt.graphics.Font; > import org.eclipse.swt.graphics.FontData; > import org.eclipse.swt.graphics.Point; >@@ -120,25 +119,7 @@ > private static final int RATIO_READ_WRITE_PANE = 85; > > private static final int RATIO_PRESENCE_PANE = 15; >- >- 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$ >- >- /** >- * 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. >- */ >- 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 DEFAULT_TIME_FORMAT = Messages.ChatRoomManagerView_TIME_FORMAT; >- >- protected static final String DEFAULT_DATE_FORMAT = Messages.ChatRoomManagerView_DATE_FORMAT; >- >+ > protected static final int DEFAULT_INPUT_HEIGHT = 25; > > protected static final int DEFAULT_INPUT_SEPARATOR = 5; >@@ -150,14 +131,12 @@ > private IChatRoomViewCloseListener rootCloseListener = null; > > private IChatRoomMessageSender rootMessageSender = null; >- >- private Color otherColor = null; >- >- private Color systemColor = null; >- >- private Color dateColor = null; >- >- private Color highlightColor = null; >+ >+ /** >+ * UI independent renderer, that is aware of displaying any special fragments >+ * of message, like formatting, graphical attachments, emotional content, etc. >+ */ >+ private IMessageRenderer messageRenderer = null; > > Action outputClear = null; > >@@ -467,10 +446,6 @@ > } > > public void createPartControl(Composite parent) { >- otherColor = colorFromRGBString(DEFAULT_OTHER_COLOR); >- systemColor = colorFromRGBString(DEFAULT_SYSTEM_COLOR); >- highlightColor = colorFromRGBString(DEFAULT_HIGHLIGHT_COLOR); >- dateColor = colorFromRGBString(DEFAULT_DATE_COLOR); > Composite rootComposite = new Composite(parent, SWT.NONE); > rootComposite.setLayout(new FillLayout()); > boolean useTraditionalTabFolder = PlatformUI >@@ -1143,7 +1118,7 @@ > if (id != null) { > appendText(getOutputText(), new ChatLine(NLS.bind( > Messages.ChatRoomManagerView_ENTERED_MESSAGE, >- getDateTime(), getUsernameFromID(id)), null)); >+ getUsernameFromID(id)), null)); > chatRoomParticipantViewer.add(p); > } > } >@@ -1174,7 +1149,7 @@ > if (id != null) { > appendText(getOutputText(), new ChatLine(NLS.bind( > Messages.ChatRoomManagerView_LEFT_MESSAGE, >- getDateTime(), getUsernameFromID(id)), null)); >+ getUsernameFromID(id)), null)); > chatRoomParticipantViewer.remove(p); > } > } >@@ -1365,19 +1340,6 @@ > } > } > >- protected String getCurrentDate(String format) { >- SimpleDateFormat sdf = new SimpleDateFormat(format); >- String res = sdf.format(new Date()); >- return res; >- } >- >- protected String getDateTime() { >- StringBuffer buf = new StringBuffer(); >- buf.append(getCurrentDate(DEFAULT_DATE_FORMAT)).append(" ").append( //$NON-NLS-1$ >- getCurrentDate(DEFAULT_TIME_FORMAT)); >- return buf.toString(); >- } >- > public void disconnect() { > if (rootCloseListener != null) { > rootCloseListener.chatRoomViewClosing(); >@@ -1411,8 +1373,7 @@ > private boolean shouldScrollToEnd(StyledText chatText) { > Point locAtEnd = chatText.getLocationAtOffset(chatText.getText().length()); > Rectangle bounds = chatText.getBounds(); >- if (locAtEnd.y > bounds.height + 5) return false; >- return true; >+ return (locAtEnd.y > bounds.height + 5); > } > > protected void appendText(StyledText st, ChatLine text) { >@@ -1420,63 +1381,35 @@ > return; > } > >- boolean scrollToBottom = shouldScrollToEnd(st); >- >- int startRange = st.getText().length(); >- StringBuffer sb = new StringBuffer(); >- // check to see if the message has the user's name contained within >- boolean nickContained = text.getText().indexOf(localUserName) != -1; >+ String originator = null; > if (text.getOriginator() != null) { >- // check to make sure that the person referring to the user's name >- // 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 = !text.getOriginator().getName().equals( >- localUserName) >- && nickContained; >- sb.append(NLS.bind(Messages.ChatRoomManagerView_MESSAGE_DATE, >- getCurrentDate(DEFAULT_TIME_FORMAT))); >- StyleRange dateStyle = new StyleRange(); >- dateStyle.start = startRange; >- dateStyle.length = sb.length(); >- dateStyle.foreground = dateColor; >- dateStyle.fontStyle = SWT.NORMAL; >- st.append(sb.toString()); >- st.setStyleRange(dateStyle); >- sb = new StringBuffer(); >- sb.append(text.getOriginator().getName()).append(": "); //$NON-NLS-1$ >- StyleRange sr = new StyleRange(); >- sr.start = startRange + dateStyle.length; >- sr.length = sb.length(); >- sr.fontStyle = SWT.BOLD; >- // check to see which color should be used >- sr.foreground = nickContained ? highlightColor : otherColor; >- st.append(sb.toString()); >- st.setStyleRange(sr); >- } >- int beforeMessageIndex = st.getText().length(); >- st.append(text.getText()); >- if (text.getOriginator() == null) { >- StyleRange sr = new StyleRange(); >- sr.start = beforeMessageIndex; >- sr.length = text.getText().length(); >- sr.foreground = systemColor; >- sr.fontStyle = SWT.BOLD; >- st.setStyleRange(sr); >- } else if (nickContained) { >- // highlight the message itself as necessary >- StyleRange sr = new StyleRange(); >- sr.start = beforeMessageIndex; >- sr.length = text.getText().length(); >- sr.foreground = highlightColor; >- st.setStyleRange(sr); >+ originator = text.getOriginator().getNickname(); >+ } >+ >+ String output = messageRenderer.render(text.getText(), originator, localUserName); >+ StyleRange[] ranges = messageRenderer.getStyleRanges(); >+ >+ if (output == null) { >+ return; > } >+ >+ int startRange = st.getText().length(); >+ > if (!text.isNoCRLF()) { >- st.append("\n"); //$NON-NLS-1$ >+ output += "\n"; //$NON-NLS-1$ > } >- String t = st.getText(); >- if (t == null) >- return; >- if (scrollToBottom) st.setSelection(t.length()); >+ >+ 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]); >+ } >+ } >+ >+ if (shouldScrollToEnd(st)) st.setSelection(startRange + output.length()); > // Bold title if view is not visible. > IWorkbenchSiteProgressService pservice = (IWorkbenchSiteProgressService) this > .getSite().getAdapter(IWorkbenchSiteProgressService.class); >@@ -1600,19 +1533,7 @@ > getSite().registerContextMenu(menuMgr, selectionProvider); > } > >- private Color colorFromRGBString(String rgb) { >- Color color = null; >- if (rgb == null || rgb.equals("")) { //$NON-NLS-1$ >- color = new Color(getViewSite().getShell().getDisplay(), 0, 0, 0); >- return color; >- } >- if (color != null) { >- color.dispose(); >- } >- String[] vals = rgb.split(","); //$NON-NLS-1$ >- color = new Color(getViewSite().getShell().getDisplay(), Integer >- .parseInt(vals[0]), Integer.parseInt(vals[1]), Integer >- .parseInt(vals[2])); >- return color; >+ public void setMessageRenderer(IMessageRenderer defaultMessageRenderer) { >+ this.messageRenderer = defaultMessageRenderer; > } > } >\ No newline at end of file >Index: src/org/eclipse/ecf/presence/ui/chatroom/ChatRoomManagerUI.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.ecf/plugins/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/presence/ui/chatroom/ChatRoomManagerUI.java,v >retrieving revision 1.9 >diff -u -r1.9 ChatRoomManagerUI.java >--- src/org/eclipse/ecf/presence/ui/chatroom/ChatRoomManagerUI.java 2 May 2007 04:58:38 -0000 1.9 >+++ src/org/eclipse/ecf/presence/ui/chatroom/ChatRoomManagerUI.java 27 Jul 2007 11:15:07 -0000 >@@ -1,5 +1,5 @@ > /**************************************************************************** >- * Copyright (c) 2004 Composent, Inc. and others. >+ * Copyright (c) 2004, 2007 Composent, Inc. and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * Composent, Inc. - initial API and implementation >+ * Jacek Pospychala <jacek.pospychala@pl.ibm.com> - bug 197329 > *****************************************************************************/ > package org.eclipse.ecf.presence.ui.chatroom; > >@@ -106,6 +107,7 @@ > chatroomview.initializeWithManager(ChatRoomManagerView.getUsernameFromID(targetID), > ChatRoomManagerView.getHostnameFromID(targetID), > managerChatRoom, this, createChatRoomViewCloseListener()); >+ chatroomview.setMessageRenderer(getDefaultMessageRenderer()); > // Add listener for container, so that if the container is spontaneously > // disconnected, > // then we will be able to have the UI respond by making itself inactive >@@ -150,6 +152,10 @@ > }); > } > >+ protected IMessageRenderer getDefaultMessageRenderer() { >+ return new MessageRenderer(); >+ } >+ > protected String getPasswordForChatRoomConnect(IChatRoomInfo info) { > return null; > } >Index: src/org/eclipse/ecf/presence/ui/chatroom/IMessageRenderer.java >=================================================================== >RCS file: src/org/eclipse/ecf/presence/ui/chatroom/IMessageRenderer.java >diff -N src/org/eclipse/ecf/presence/ui/chatroom/IMessageRenderer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/presence/ui/chatroom/IMessageRenderer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,38 @@ >+/**************************************************************************** >+ * Copyright (c) 2007 Composent, Inc. and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Jacek Pospychala <jacek.pospychala@pl.ibm.com> - bug 197329 >+ *****************************************************************************/ >+package org.eclipse.ecf.presence.ui.chatroom; >+ >+import org.eclipse.ecf.internal.presence.ui.ChatLine; >+import org.eclipse.swt.custom.StyleRange; >+ >+/** >+ * Renders chat line, by arranging text content to be finally printed to >+ * Chat room output together with it's formatting. >+ * >+ */ >+public interface IMessageRenderer { >+ >+ /** >+ * Returns text content to be finally printed to chat room output. >+ * @param message chat message to be processed >+ * @param originator name of message sender >+ * @param localUserName local user name >+ * @return text to be printed to output, nothing will be printed if null >+ */ >+ String render(String message, String originator, String localUserName); >+ >+ /** >+ * Returns formatting to be applied to rendered final output, returned by {@link #render(ChatLine, boolean)}. >+ * @return formatting to be applied to output, or null if no formatting >+ */ >+ StyleRange[] getStyleRanges(); >+ >+} >Index: src/org/eclipse/ecf/presence/ui/chatroom/MessageRenderer.java >=================================================================== >RCS file: src/org/eclipse/ecf/presence/ui/chatroom/MessageRenderer.java >diff -N src/org/eclipse/ecf/presence/ui/chatroom/MessageRenderer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/presence/ui/chatroom/MessageRenderer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,176 @@ >+/**************************************************************************** >+ * Copyright (c) 2007 Composent, Inc. and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Jacek Pospychala <jacek.pospychala@pl.ibm.com> - bug 197329 >+ *****************************************************************************/ >+package org.eclipse.ecf.presence.ui.chatroom; >+ >+import java.text.SimpleDateFormat; >+import java.util.ArrayList; >+import java.util.Date; >+import java.util.List; >+ >+import org.eclipse.core.runtime.Assert; >+import org.eclipse.ecf.internal.presence.ui.Messages; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.StyleRange; >+import org.eclipse.swt.graphics.Color; >+import org.eclipse.swt.widgets.Display; >+ >+/** >+ * 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$ >+ >+ /** >+ * 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. >+ */ >+ 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 DEFAULT_TIME_FORMAT = Messages.MessageRenderer_DEFAULT_TIME_FORMAT; >+ >+ protected static final String DEFAULT_DATE_FORMAT = Messages.MessageRenderer_DEFAULT_DATE_FORMAT; >+ >+ protected boolean nickContained; >+ 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); >+ } >+ >+ public StyleRange[] getStyleRanges() { >+ return (StyleRange[]) styleRanges.toArray(new StyleRange[styleRanges.size()]); >+ } >+ >+ public String render(String message, String originator, String localUserName) { >+ Assert.isNotNull(localUserName); >+ >+ styleRanges.clear(); >+ >+ if (message == null) { >+ return null; >+ } >+ >+ buffer = new StringBuffer(); >+ >+ >+ this.message = message; >+ this.originator = originator; >+ >+ // check to see if the message has the user's name contained within >+ // and make sure that the person referring to the user's name >+ // 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)); >+ >+ doRender(); >+ >+ return buffer.toString(); >+ } >+ >+ protected void doRender() { >+ >+ appendDateTime(); >+ if (originator != null) { >+ appendNickname(); >+ } >+ appendMessage(); >+ } >+ >+ protected void appendDateTime() { >+ String message = NLS.bind(Messages.MessageRenderer_DEFAULT_DATETIME_FORMAT, getCurrentDate(DEFAULT_TIME_FORMAT)); >+ append(message, dateColor, null, SWT.NORMAL); >+ } >+ >+ 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); >+ } >+ >+ 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); >+ } >+ >+ protected void append(String message, Color foreground, Color background, int style) { >+ if (message == null) { >+ return; >+ } >+ >+ int start = buffer.length(); >+ >+ buffer.append(message); >+ >+ if (foreground == null && background == null && style == SWT.NONE) { >+ return; >+ } >+ >+ StyleRange styleRange = new StyleRange(start, message.length(), foreground, background, style); >+ 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])); >+ return color; >+ } >+ >+ protected String getCurrentDate(String format) { >+ SimpleDateFormat sdf = new SimpleDateFormat(format); >+ String res = sdf.format(new Date()); >+ return res; >+ } >+ >+ protected String getDateTime() { >+ StringBuffer buf = new StringBuffer(); >+ buf.append(getCurrentDate(DEFAULT_DATE_FORMAT)).append(" ").append( //$NON-NLS-1$ >+ getCurrentDate(DEFAULT_TIME_FORMAT)); >+ return buf.toString(); >+ } >+} >#P org.eclipse.ecf.provider.irc >Index: src/org/eclipse/ecf/internal/provider/irc/container/IRCRootContainer.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.ecf/plugins/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/container/IRCRootContainer.java,v >retrieving revision 1.17 >diff -u -r1.17 IRCRootContainer.java >--- src/org/eclipse/ecf/internal/provider/irc/container/IRCRootContainer.java 24 Jul 2007 14:49:16 -0000 1.17 >+++ src/org/eclipse/ecf/internal/provider/irc/container/IRCRootContainer.java 27 Jul 2007 11:15:15 -0000 >@@ -7,7 +7,7 @@ > * > * Contributors: > * Composent, Inc. - initial API and implementation >- * Jacek Pospychala <jacek.pospychala@pl.ibm.com> - bug 197604 >+ * Jacek Pospychala <jacek.pospychala@pl.ibm.com> - bug 197604, 197329 > ******************************************************************************/ > package org.eclipse.ecf.internal.provider.irc.container; > >@@ -135,7 +135,7 @@ > connection.addIRCEventListener(getIRCEventListener()); > connection.setPong(true); > connection.setDaemon(false); >- connection.setColors(false); >+ connection.setColors(true); > if (encoding != null) > connection.setEncoding(encoding); > trace(Messages.IRCRootContainer_Connecting_To + targetID); >@@ -518,7 +518,7 @@ > return new IChatRoomMessageSender() { > public void sendMessage(String message) throws ECFException { > if (isCommand(message)) >- parseCommandAndSend(message, null); >+ parseCommandAndSend(message, null, null); > else > showErrorMessage(null, NLS.bind( > Messages.IRCRootContainer_Command_Error, message, >@@ -565,7 +565,7 @@ > return token; > } > >- protected void parseCommandAndSend(String commandMessage, String channelName) { >+ protected void parseCommandAndSend(String commandMessage, String channelName, String ircUser) { > synchronized (this) { > if (connection != null) { > try { >@@ -645,6 +645,15 @@ > if (index != -1) { > connection.doMode(channelName, commandMessage); > } >+ } else if (lowerCase.startsWith("/me ")) { //$NON-NLS-1$ >+ nextToken(command); // skip command >+ >+ String message = command.toString(); >+ if (message.length() > 0) { >+ message = "\01ACTION "+message+"\01"; //$NON-NLS-1$ //$NON-NLS-2$ >+ connection.doPrivmsg(channelName, message); >+ showMessage(channelName, ircUser, message); >+ } > } else { > String[] tokens = parseCommandTokens(commandMessage); > handleCommandMessage(tokens, channelName); >@@ -909,7 +918,7 @@ > if (connection != null) { > // If it's a command, > if (isCommand(msg)) { >- parseCommandAndSend(msg, channelName); >+ parseCommandAndSend(msg, channelName, ircUser); > } else { > connection.doPrivmsg(channelName, msg); > showMessage(channelName, ircUser, msg); >#P org.eclipse.ecf.provider.irc.ui >Index: src/org/eclipse/ecf/internal/irc/ui/IRCUI.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.ecf/plugins/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/IRCUI.java,v >retrieving revision 1.4 >diff -u -r1.4 IRCUI.java >--- src/org/eclipse/ecf/internal/irc/ui/IRCUI.java 2 May 2007 04:58:23 -0000 1.4 >+++ src/org/eclipse/ecf/internal/irc/ui/IRCUI.java 27 Jul 2007 11:15:39 -0000 >@@ -1,5 +1,5 @@ > /**************************************************************************** >- * Copyright (c) 2004 Composent, Inc. and others. >+ * Copyright (c) 2004, 2007 Composent, Inc. and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * Composent, Inc. - initial API and implementation >+ * Jacek Pospychala <jacek.pospychala@pl.ibm.com> - bug 197329 > *****************************************************************************/ > > package org.eclipse.ecf.internal.irc.ui; >@@ -21,6 +22,7 @@ > import org.eclipse.ecf.presence.chatroom.IChatRoomContainer; > import org.eclipse.ecf.presence.chatroom.IChatRoomManager; > import org.eclipse.ecf.presence.ui.chatroom.ChatRoomManagerUI; >+import org.eclipse.ecf.presence.ui.chatroom.IMessageRenderer; > import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.osgi.util.NLS; > >@@ -120,5 +122,8 @@ > return inputLine; > > } >- >+ >+ protected IMessageRenderer getDefaultMessageRenderer() { >+ return new IRCMessageRenderer(); >+ } > } >Index: src/org/eclipse/ecf/internal/irc/ui/IRCMessageRenderer.java >=================================================================== >RCS file: src/org/eclipse/ecf/internal/irc/ui/IRCMessageRenderer.java >diff -N src/org/eclipse/ecf/internal/irc/ui/IRCMessageRenderer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/internal/irc/ui/IRCMessageRenderer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,60 @@ >+/**************************************************************************** >+ * Copyright (c) 2007 Composent, Inc. and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Jacek Pospychala <jacek.pospychala@pl.ibm.com> - bug 197329 >+ *****************************************************************************/ >+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 { >+ >+ private final static String ME_PREFIX = "\01ACTION "; //$NON-NLS-1$ >+ private final static String ME_SUFFIX = "\01"; //$NON-NLS-1$ >+ >+ private boolean isActionMessage; >+ >+ protected void doRender() { >+ String actionMessage = getActionMessage(message); >+ isActionMessage = (actionMessage != null); >+ >+ if (isActionMessage) { >+ message = actionMessage; >+ } >+ >+ super.doRender(); >+ } >+ >+ protected void appendNickname() { >+ if (isActionMessage) { >+ String message = originator + " "; //$NON-NLS-1$ >+ append(message, null, null, SWT.ITALIC); >+ } else { >+ super.appendNickname(); >+ } >+ } >+ >+ protected void appendMessage() { >+ if (isActionMessage) { >+ append(message, null, null, SWT.ITALIC); >+ } else { >+ super.appendMessage(); >+ } >+ } >+ >+ private String getActionMessage(String message) { >+ if (message.startsWith(ME_PREFIX) && message.endsWith(ME_SUFFIX)) { >+ return message.substring(ME_PREFIX.length(), message.length() - ME_SUFFIX.length()); >+ } else { >+ return null; >+ } >+ } >+ >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 197329
:
74721
| 74788 |
74790
|
74799