### Eclipse Workspace Patch 1.0 #P org.eclipse.ecf.presence.ui Index: src/org/eclipse/ecf/internal/presence/ui/preferences/PreferenceConstants.java =================================================================== RCS file: /cvsroot/technology/org.eclipse.ecf/plugins/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/internal/presence/ui/preferences/PreferenceConstants.java,v retrieving revision 1.2 diff -u -r1.2 PreferenceConstants.java --- src/org/eclipse/ecf/internal/presence/ui/preferences/PreferenceConstants.java 6 Sep 2007 04:41:55 -0000 1.2 +++ src/org/eclipse/ecf/internal/presence/ui/preferences/PreferenceConstants.java 11 Apr 2008 13:16:16 -0000 @@ -16,4 +16,5 @@ */ public class PreferenceConstants { public static final String CHATROOM_SHOW_USER_PRESENCE = "chatroom.user.presence.visible"; //$NON-NLS-1$ + public static final String CHATROOM_DISPLAY_TIMESTAMP = "chatroom.display.TimeStamp"; //$NON-NLS-1$ } Index: src/org/eclipse/ecf/internal/presence/ui/preferences/PreferenceInitializer.java =================================================================== RCS file: /cvsroot/technology/org.eclipse.ecf/plugins/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/internal/presence/ui/preferences/PreferenceInitializer.java,v retrieving revision 1.1 diff -u -r1.1 PreferenceInitializer.java --- src/org/eclipse/ecf/internal/presence/ui/preferences/PreferenceInitializer.java 27 Jul 2007 22:05:01 -0000 1.1 +++ src/org/eclipse/ecf/internal/presence/ui/preferences/PreferenceInitializer.java 11 Apr 2008 13:16:16 -0000 @@ -27,6 +27,7 @@ public void initializeDefaultPreferences() { IPreferenceStore store = Activator.getDefault().getPreferenceStore(); store.setDefault(PreferenceConstants.CHATROOM_SHOW_USER_PRESENCE, false); + store.setDefault(PreferenceConstants.CHATROOM_DISPLAY_TIMESTAMP, true); } } Index: src/org/eclipse/ecf/internal/presence/ui/preferences/ChatRoomPreferencePage.java =================================================================== RCS file: /cvsroot/technology/org.eclipse.ecf/plugins/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/internal/presence/ui/preferences/ChatRoomPreferencePage.java,v retrieving revision 1.2 diff -u -r1.2 ChatRoomPreferencePage.java --- src/org/eclipse/ecf/internal/presence/ui/preferences/ChatRoomPreferencePage.java 6 Sep 2007 04:41:56 -0000 1.2 +++ src/org/eclipse/ecf/internal/presence/ui/preferences/ChatRoomPreferencePage.java 11 Apr 2008 13:16:16 -0000 @@ -11,32 +11,289 @@ ******************************************************************************/ package org.eclipse.ecf.internal.presence.ui.preferences; -import org.eclipse.ecf.internal.presence.ui.Activator; -import org.eclipse.ecf.internal.presence.ui.Messages; -import org.eclipse.jface.preference.BooleanFieldEditor; -import org.eclipse.jface.preference.FieldEditorPreferencePage; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.ecf.internal.presence.ui.*; +import org.eclipse.ecf.presence.ui.chatroom.MessageRenderer; +import org.eclipse.jface.preference.*; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.osgi.util.NLS; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.StyleRange; +import org.eclipse.swt.custom.StyledText; +import org.eclipse.swt.events.*; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.*; +import org.eclipse.ui.*; +import org.eclipse.ui.dialogs.PreferencesUtil; +import org.eclipse.ui.themes.ITheme; public class ChatRoomPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { + class Renderer extends MessageRenderer { + public String[] nameColor={DATE_COLOR, + RECEIVEDHIGHLIGHT_COLOR,SYSTEM_COLOR, + RECEIVED_COLOR,SENT_COLOR}; + + public String[] loadThemeName() { + String[] names = new String[nameColor.length]; + for(int n=0; n AddContactDialog_DialogTitle = Add Contact AddContactDialog_UserID = User ID: @@ -145,4 +147,53 @@ MessageRenderer_DEFAULT_DATETIME_FORMAT=({0}) ChatRoomPreferencePage_CHATROOM_SHOW_USER_PRESENCE_TEXT=&Show user entry messages - \ No newline at end of file +ChatRoomPreferencePage_CHATROOM_DISPLAY_TIMESTAMP_TEXT=Show &time for each chat entry +ChatRoomPreferencePage_LINK_COLORS_AND_FONTS_TEXT=Default colors and fonts can be configured on the Colors and Fonts preference page. +ChatRoomPreferencePage_ELEMENT=Element: +ChatRoomPreferencePage_COLOR=Color: +ChatRoomPreferencePage_PREVIEW=Preview: +ChatRoomPreferencePage_DATE=Time +ChatRoomPreferencePage_RECEIVEDHIGHLIGHT_MESSAGE=Highlight message +ChatRoomPreferencePage_SYSTEM_MESSAGE=System message +ChatRoomPreferencePage_RECEIVED_MESSAGE=Received message +ChatRoomPreferencePage_SENT_MESSAGE=Sent message + +RosterItemWrapper_PROPERTY_NAME=Name +RosterItemWrapper_PROPERTY_NICKNAME=Nickname +RosterItemWrapper_PROPERTY_ID=ID +RosterItemWrapper_PROPERTY_TYPE=Type +RosterItemWrapper_PROPERTY_MODE=Mode +RosterItemWrapper_PROPERTY_STATUS=Info +RosterItemWrapper_PROPERTY_GROUP_ACCOUNT=Account +RosterItemWrapper_PROPERTY_GROUP_STATUS=Status + +RosterItemWrapper_PRESENCE_TYPE_AVAILABLE=Available +RosterItemWrapper_PRESENCE_TYPE_ERROR=Error +RosterItemWrapper_PRESENCE_TYPE_SUBSCRIBE=Subscribe +RosterItemWrapper_PRESENCE_TYPE_SUBSCRIBED=Subscribed +RosterItemWrapper_PRESENCE_TYPE_UNAVAILABLE=Unavailable +RosterItemWrapper_PRESENCE_TYPE_UNSUBSCRIBE=Unsubscribe +RosterItemWrapper_PRESENCE_TYPE_UNSUBSCRIBED=Unsubscribed +RosterItemWrapper_PRESENCE_TYPE_UNKWOWN=Unknown + +RosterItemWrapper_PRESENCE_MODE_AVAILABLE=Available +RosterItemWrapper_PRESENCE_MODE_AWAY=Away +RosterItemWrapper_PRESENCE_MODE_CHAT=Chat +RosterItemWrapper_PRESENCE_MODE_DND=Do not disturb +RosterItemWrapper_PRESENCE_MODE_EXTENDED_AWAY=Extended away +RosterItemWrapper_PRESENCE_MODE_INVISIBLE=Invisible + +RosterItemWrapper_VCARD_EMAIL_HOME=E-Mail (Home) +RosterItemWrapper_VCARD_EMAIL_WORK=E-Mail (Work) +RosterItemWrapper_VCARD_NAME_FIRST=First name +RosterItemWrapper_VCARD_NAME_MIDDLE=Middle name +RosterItemWrapper_VCARD_NAME_LAST=Last name +RosterItemWrapper_VCARD_NAME_NICK=Nickname +RosterItemWrapper_VCARD_PHONE_HOME_VOICE=Phone (Home) +RosterItemWrapper_VCARD_PHONE_HOME_CELL=Phone (Home cell) +RosterItemWrapper_VCARD_PHONE_WORK_VOICE=Phone (Work) +RosterItemWrapper_VCARD_PHONE_WORK_CELL=Phone (Work cell) + +RosterPropertySheetPage_ACCOUNT=Account +RosterPropertySheetPage_PROFILE=Profile +RosterPropertySheetPage_AVATAR=Avatar Index: src/org/eclipse/ecf/presence/ui/chatroom/IMessageRenderer.java =================================================================== RCS file: /cvsroot/technology/org.eclipse.ecf/plugins/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/presence/ui/chatroom/IMessageRenderer.java,v retrieving revision 1.2 diff -u -r1.2 IMessageRenderer.java --- src/org/eclipse/ecf/presence/ui/chatroom/IMessageRenderer.java 5 Aug 2007 21:15:18 -0000 1.2 +++ src/org/eclipse/ecf/presence/ui/chatroom/IMessageRenderer.java 11 Apr 2008 13:16:21 -0000 @@ -11,6 +11,7 @@ package org.eclipse.ecf.presence.ui.chatroom; import org.eclipse.swt.custom.StyleRange; +import org.eclipse.swt.graphics.Font; /** * Renders chat line, by arranging text content to be finally printed to @@ -33,5 +34,10 @@ * @return formatting to be applied to output, or null if no formatting */ StyleRange[] getStyleRanges(); - + + /** + * Returns text font of output + * @return text font of output + */ + Font getTextFont(); } 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.44 diff -u -r1.44 ChatRoomManagerView.java --- src/org/eclipse/ecf/presence/ui/chatroom/ChatRoomManagerView.java 11 Apr 2008 04:52:58 -0000 1.44 +++ src/org/eclipse/ecf/presence/ui/chatroom/ChatRoomManagerView.java 11 Apr 2008 13:16:21 -0000 @@ -34,6 +34,7 @@ import org.eclipse.ecf.presence.ui.MessagesView; import org.eclipse.jface.action.*; import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.text.*; import org.eclipse.jface.text.source.SourceViewer; import org.eclipse.jface.util.IPropertyChangeListener; @@ -59,9 +60,8 @@ public static final String PARTICIPANTS_MENU_ID = "org.eclipse.ecf.presence.ui.chatroom.participantsView"; //$NON-NLS-1$ - private static final int RATIO_WRITE_PANE = 1; - - private static final int RATIO_READ_PANE = 9; + //private static final int RATIO_WRITE_PANE = 1; + //private static final int RATIO_READ_PANE = 9; private static final int RATIO_READ_WRITE_PANE = 85; @@ -112,7 +112,8 @@ private CTabItem tabItem; - private SashForm rightSash; + //private SashForm rightSash; + Composite rightComp; private StyledText subjectText; @@ -147,6 +148,9 @@ GridLayout layout = new GridLayout(1, true); layout.marginWidth = 0; layout.marginHeight = 0; + layout.marginHeight = 0; + layout.verticalSpacing = 3; + layout.horizontalSpacing = 3; memberComp.setLayout(layout); participantsNumberLabel = new Label(memberComp, SWT.BORDER | SWT.READ_ONLY); @@ -171,11 +175,19 @@ } }); - Composite rightComp = new Composite(fullChat, SWT.NONE); + /*Composite*/rightComp = new Composite(fullChat, SWT.NONE); + layout = new GridLayout(1, true); + layout.marginWidth = 0; + layout.marginHeight = 0; + layout.marginHeight = 0; + layout.verticalSpacing = 3; + layout.horizontalSpacing = 3; + memberComp.setLayout(layout); rightComp.setLayout(layout); subjectText = createStyledTextWidget(rightComp, SWT.SINGLE | SWT.BORDER); - subjectText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + //subjectText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL, SWT.CENTER, true, false)); + subjectText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); subjectText.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { if (evt.character == SWT.CR || evt.character == SWT.KEYPAD_CR) { @@ -187,31 +199,49 @@ chatRoomAdminSender.sendSubjectChange(subjectText.getText()); } } catch (ECFException e) { - disconnected(); + //disconnected(); } } } } }); - rightSash = new SashForm(rightComp, SWT.VERTICAL); - rightSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - } else - rightSash = new SashForm(parent, SWT.VERTICAL); + //rightSash = new SashForm(rightComp, SWT.VERTICAL); + //rightSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + } else { + //rightSash = new SashForm(parent, SWT.VERTICAL); + rightComp = new Composite(parent, SWT.NONE); + rightComp.setLayoutData(new GridData(GridData.FILL_BOTH)); + GridLayout layout = new GridLayout(1, true); + layout = new GridLayout(1, true); + layout.marginWidth = 0; + layout.marginHeight = 0; + layout.marginHeight = 0; + layout.verticalSpacing = 3; + layout.horizontalSpacing = 3; + rightComp.setLayout(layout); + } - outputText = createStyledTextWidget(rightSash, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI | SWT.READ_ONLY); + outputText = createStyledTextWidget(/*rightSash*/rightComp, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI | SWT.READ_ONLY); outputText.setEditable(false); outputText.setLayoutData(new GridData(GridData.FILL_BOTH)); - inputText = new Text(rightSash, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL); + inputText = new Text(/*rightSash*/rightComp, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + GC gc = new GC(inputText); + gc.setFont(JFaceResources.getDialogFont()); + FontMetrics fontMetrics = gc.getFontMetrics(); + gc.dispose(); + gd.heightHint = fontMetrics.getHeight() * 2; + inputText.setLayoutData(gd); if (keyListener != null) inputText.addKeyListener(keyListener); - rightSash.setWeights(new int[] {RATIO_READ_PANE, RATIO_WRITE_PANE}); + //rightSash.setWeights(new int[] {RATIO_READ_PANE, RATIO_WRITE_PANE}); if (withParticipants) { fullChat.setWeights(new int[] {RATIO_PRESENCE_PANE, RATIO_READ_WRITE_PANE}); tabItem.setControl(fullChat); } else - tabItem.setControl(rightSash); + tabItem.setControl(/*rightSash*/rightComp); parent.setSelection(tabItem); @@ -424,6 +454,10 @@ public void setSubject(String subject) { subjectText.setText(subject); } + + public CTabItem getTabItem() { + return tabItem; + } } public void createPartControl(Composite parent) { @@ -630,7 +664,7 @@ }); chatRoomContainer.addListener(new IContainerListener() { public void handleEvent(IContainerEvent evt) { - if (evt instanceof IContainerDisconnectedEvent || evt instanceof IContainerEjectedEvent) { + if (evt instanceof IContainerDisconnectedEvent) { chatroom.disconnected(); } } @@ -1351,10 +1385,12 @@ } protected void appendText(ChatRoomTab chatRoomTab, StyledText st, ChatLine text) { - if (st == null || text == null) { + if (/*st == null ||*/text == null) { return; } + /*StyledText*/st = chatRoomTab.getOutputText(); + boolean isAtEndBeforeAppend = !isLastOutputInvisible(st); String originator = null; 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.14 diff -u -r1.14 ChatRoomManagerUI.java --- src/org/eclipse/ecf/presence/ui/chatroom/ChatRoomManagerUI.java 11 Apr 2008 04:52:57 -0000 1.14 +++ src/org/eclipse/ecf/presence/ui/chatroom/ChatRoomManagerUI.java 11 Apr 2008 13:16:21 -0000 @@ -92,7 +92,7 @@ Assert.isNotNull(roomInfo, Messages.ChatRoomManagerUI_EXCEPTION_NO_ROOT_CHAT_ROOM_MANAGER); final IChatRoomContainer managerChatRoom = roomInfo.createChatRoomContainer(); chatroomview.initializeWithManager(ChatRoomManagerView.getUsernameFromID(targetID), ChatRoomManagerView.getHostnameFromID(targetID), managerChatRoom, this, createChatRoomViewCloseListener()); - chatroomview.setMessageRenderer(getDefaultMessageRenderer()); + //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 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.4 diff -u -r1.4 MessageRenderer.java --- src/org/eclipse/ecf/presence/ui/chatroom/MessageRenderer.java 6 Sep 2007 04:41:55 -0000 1.4 +++ src/org/eclipse/ecf/presence/ui/chatroom/MessageRenderer.java 11 Apr 2008 13:16:21 -0000 @@ -8,17 +8,19 @@ * Contributors: * Jacek Pospychala - bug 197329, 190851 *****************************************************************************/ + package org.eclipse.ecf.presence.ui.chatroom; import java.text.SimpleDateFormat; import java.util.*; import org.eclipse.core.runtime.Assert; +import org.eclipse.ecf.internal.presence.ui.Activator; import org.eclipse.ecf.internal.presence.ui.Messages; +import org.eclipse.ecf.internal.presence.ui.preferences.PreferenceConstants; 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.graphics.Font; +import org.eclipse.swt.graphics.*; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.themes.ITheme; @@ -121,8 +123,8 @@ } protected void doRender() { - - appendDateTime(); + if(Activator.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.CHATROOM_DISPLAY_TIMESTAMP)) + appendDateTime(); if (originator != null) { appendNickname(); } @@ -161,7 +163,7 @@ styleRanges.add(styleRange); } - private Color getColor(String name) { + protected Color getColor(String name) { if (name == null) { return null; } @@ -176,7 +178,7 @@ return c; } - private Font getFont(String name) { + protected Font getFont(String name) { if (name == null) { return null; } @@ -203,4 +205,8 @@ getCurrentDate(DEFAULT_TIME_FORMAT)); return buf.toString(); } + + public Font getTextFont() { + return getFont(font); + } } Index: plugin.properties =================================================================== RCS file: /cvsroot/technology/org.eclipse.ecf/plugins/org.eclipse.ecf.presence.ui/plugin.properties,v retrieving revision 1.8 diff -u -r1.8 plugin.properties --- plugin.properties 22 Mar 2008 17:38:49 -0000 1.8 +++ plugin.properties 11 Apr 2008 13:16:05 -0000 @@ -19,7 +19,8 @@ browse.command.label = Open Contact... browse.command.tooltip = Open Contact -chatroom.preferencePage.name = Chat Room +#chatroom.preferencePage.name = Chat Room +chatroom.preferencePage.name = Messages and Chats themeElementCategory.messagesAndChats = Messages and Chats themeElementCategory.messagesAndChats.description = Appearance details of ECF message and chat windows. fontDefinition.dateFont = Date font @@ -27,19 +28,19 @@ 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. +fontDefinition.highlightFont.description = Font of the highlight text 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. +colorDefinition.HighlightColor.description = The default color used to highlight the string of text when the user's name is referred. The default color is red. fontDefinition.systemMessagesFont = System messages font -fontDefinition.systemMessagesFont.description = Font of the date stamp in message window. +fontDefinition.systemMessagesFont.description = Font of the system messages 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. +fontDefinition.receivedMessagesFont.description = Font of the received messages 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. +fontDefinition.sentMessagesFont.description = Font of the sent messages in message window. colorDefinition.sentMessagesColor = Sent messages color colorDefinition.sentMessagesColor.description = Color of messages sent by local user. Index: src/org/eclipse/ecf/presence/ui/MessagesView.java =================================================================== RCS file: /cvsroot/technology/org.eclipse.ecf/plugins/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/presence/ui/MessagesView.java,v retrieving revision 1.40 diff -u -r1.40 MessagesView.java --- src/org/eclipse/ecf/presence/ui/MessagesView.java 24 Jan 2008 18:32:36 -0000 1.40 +++ src/org/eclipse/ecf/presence/ui/MessagesView.java 11 Apr 2008 13:16:21 -0000 @@ -10,16 +10,18 @@ *****************************************************************************/ package org.eclipse.ecf.presence.ui; -import java.text.SimpleDateFormat; +//import java.text.SimpleDateFormat; import java.util.*; import org.eclipse.core.runtime.*; import org.eclipse.ecf.core.identity.ID; +//import org.eclipse.ecf.core.user.User; import org.eclipse.ecf.core.util.ECFException; -import org.eclipse.ecf.internal.presence.ui.Activator; -import org.eclipse.ecf.internal.presence.ui.Messages; +import org.eclipse.ecf.internal.presence.ui.*; import org.eclipse.ecf.presence.im.*; +import org.eclipse.ecf.presence.ui.chatroom.*; import org.eclipse.jface.action.*; import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.source.SourceViewer; import org.eclipse.jface.util.IPropertyChangeListener; @@ -29,7 +31,7 @@ import org.eclipse.swt.custom.*; import org.eclipse.swt.events.*; import org.eclipse.swt.graphics.*; -import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.*; import org.eclipse.swt.widgets.*; import org.eclipse.ui.IWorkbenchPreferenceConstants; import org.eclipse.ui.PlatformUI; @@ -40,11 +42,12 @@ public class MessagesView extends ViewPart { - private static final SimpleDateFormat FORMATTER = new SimpleDateFormat("(hh:mm:ss a)"); //$NON-NLS-1$ + //private static final SimpleDateFormat FORMATTER = new SimpleDateFormat("(hh:mm:ss a)"); //$NON-NLS-1$ + // private static final SimpleDateFormat FORMATTER = new SimpleDateFormat("(HH:mm:ss)"); //$NON-NLS-1$ public static final String VIEW_ID = "org.eclipse.ecf.presence.ui.MessagesView"; //$NON-NLS-1$ - private static final int[] WEIGHTS = {75, 25}; + //private static final int[] WEIGHTS = {75, 25}; private CTabFolder tabFolder; @@ -57,6 +60,8 @@ private boolean showTimestamps = true; private static final String getUserName(ID id) { + if (id == null) + return Messages.MessagesView_broadcast; IChatID chatID = (IChatID) id.getAdapter(IChatID.class); return chatID == null ? id.getName() : chatID.getUsername(); } @@ -86,7 +91,8 @@ while (it.hasNext()) { ChatTab tab = (ChatTab) it.next(); if (tab.item == e.item) { - tab.inputText.setFocus(); + if (tab.inputText != null) + tab.inputText.setFocus(); break; } } @@ -147,10 +153,10 @@ } private ChatTab getTab(IChatMessageSender messageSender, ITypingMessageSender typingSender, ID localID, ID userID) { - ChatTab tab = (ChatTab) tabs.get(userID); + ChatTab tab = (ChatTab) tabs.get((userID != null) ? userID : (Object) Messages.MessagesView_broadcast); if (tab == null) { tab = new ChatTab(messageSender, typingSender, localID, userID); - tabs.put(userID, tab); + tabs.put((userID != null) ? userID : (Object) Messages.MessagesView_broadcast, tab); } return tab; } @@ -190,7 +196,7 @@ public synchronized void openTab(IChatMessageSender messageSender, ITypingMessageSender typingSender, ID localID, ID remoteID) { Assert.isNotNull(messageSender); Assert.isNotNull(localID); - Assert.isNotNull(remoteID); + //Assert.isNotNull(remoteID); ChatTab tab = getTab(messageSender, typingSender, localID, remoteID); // if there is only one tab, select this tab if (tabs.size() == 1) { @@ -213,7 +219,7 @@ public synchronized void showMessage(IChatMessage message) { Assert.isNotNull(message); ID remoteID = message.getFromID(); - ChatTab tab = (ChatTab) tabs.get(remoteID); + ChatTab tab = (ChatTab) tabs.get((remoteID != null) ? remoteID : (Object) Messages.MessagesView_broadcast); if (tab != null) { tab.append(remoteID, message.getBody()); } @@ -225,7 +231,8 @@ for (Iterator it = tabs.values().iterator(); it.hasNext();) { ChatTab tab = (ChatTab) it.next(); if (tab.item == item) { - tab.inputText.setFocus(); + if (tab.inputText != null) + tab.inputText.setFocus(); break; } } @@ -234,10 +241,12 @@ private class ChatTab { - private CTabItem item; + /*private*/ CTabItem item; private StyledText chatText; + private MessageRenderer messageRenderer = null; + private Text inputText; private IChatMessageSender icms; @@ -261,43 +270,45 @@ } private void addListeners() { - inputText.addKeyListener(new KeyAdapter() { - public void keyPressed(KeyEvent e) { - switch (e.keyCode) { - case SWT.CR : - case SWT.KEYPAD_CR : - if (e.stateMask == 0) { - String text = inputText.getText(); - inputText.setText(""); //$NON-NLS-1$ - try { - if (!text.equals("")) { //$NON-NLS-1$ - icms.sendChatMessage(remoteID, text); + if (remoteID != null) + inputText.addKeyListener(new KeyAdapter() { + public void keyPressed(KeyEvent e) { + switch (e.keyCode) { + case SWT.CR : + case SWT.KEYPAD_CR : + if (e.stateMask == 0) { + String text = inputText.getText(); + inputText.setText(""); //$NON-NLS-1$ + try { + if (!text.equals("")) { //$NON-NLS-1$ + icms.sendChatMessage(remoteID, text); + } + append(localID, text); + } catch (ECFException ex) { + setContentDescription(Messages.MessagesView_CouldNotSendMessage); } - append(localID, text); - } catch (ECFException ex) { - setContentDescription(Messages.MessagesView_CouldNotSendMessage); + e.doit = false; + sendTyping = false; } - e.doit = false; - sendTyping = false; - } - break; + break; + } } - } - }); + }); - inputText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - if (!sendTyping && itms != null) { - sendTyping = true; - try { - itms.sendTypingMessage(remoteID, true, null); - } catch (ECFException ex) { - // ignored since this is not really that important - return; + if (remoteID != null) + inputText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + if (!sendTyping && itms != null) { + sendTyping = true; + try { + itms.sendTypingMessage(remoteID, true, null); + } catch (ECFException ex) { + // ignored since this is not really that important + return; + } } } - } - }); + }); ScrollBar vscrollBar = chatText.getVerticalBar(); if (vscrollBar != null) { @@ -334,20 +345,44 @@ private void append(ID fromID, String body) { boolean scrollToEnd = shouldScrollToEnd(chatText); - if (!isFirstMessage) { - chatText.append(Text.DELIMITER); - } - int length = chatText.getCharCount(); + //if (!isFirstMessage) { + // chatText.append(Text.DELIMITER); + //} + //int length = chatText.getCharCount(); String name = getUserName(fromID); - if (fromID.equals(remoteID)) { - if (showTimestamps) { - chatText.append(FORMATTER.format(new Date(System.currentTimeMillis())) + ' '); - chatText.setStyleRange(new StyleRange(length, 13, redColor, null)); - length = chatText.getCharCount(); - } - chatText.append(name + ": " + body); //$NON-NLS-1$ - chatText.setStyleRange(new StyleRange(length, name.length() + 1, redColor, null, SWT.BOLD)); - setContentDescription(""); //$NON-NLS-1$ + String local = getUserName(localID); + + String output = messageRenderer.render(body, (fromID!=null)? name:null, local); + StyleRange[] ranges = messageRenderer.getStyleRanges(); + + if (fromID == remoteID || fromID.equals(remoteID)) { +// if (showTimestamps) { +// //chatText.append(FORMATTER.format(new Date(System.currentTimeMillis())) + ' '); +// //chatText.setStyleRange(new StyleRange(length, 13, redColor, null)); +// String text = FORMATTER.format(new Date(System.currentTimeMillis())) + ' '; +// chatText.append(text); +// chatText.setStyleRange(new StyleRange(length, text.length(), redColor, null)); +// length = chatText.getCharCount(); +// } +// if (remoteID != null) { +// chatText.append(name + ": "); //$NON-NLS-1$ +// //chatText.append(body); +// { +// int posStyleRange = chatLink.scan(body); +// chatText.append(body); +// chatLink.setStyleRange(posStyleRange); +// } +// chatText.setStyleRange(new StyleRange(length, name.length() + 1, redColor, null, SWT.BOLD)); +// } else { +// //chatText.append(body); +// { +// int posStyleRange = chatLink.scan(body); +// chatText.append(body); +// chatLink.setStyleRange(posStyleRange); +// } +// chatText.setStyleRange(new StyleRange(length, 0, redColor, null, SWT.BOLD)); +// } +// setContentDescription(""); //$NON-NLS-1$ if (isFirstMessage) { final MessageNotificationPopup popup = new MessageNotificationPopup(getSite().getWorkbenchWindow(), tabFolder.getShell(), remoteID); popup.setContent(name, body); @@ -364,15 +399,46 @@ }.schedule(5000); } } else { - if (showTimestamps) { - chatText.append(FORMATTER.format(new Date(System.currentTimeMillis())) + ' '); - chatText.setStyleRange(new StyleRange(length, 13, blueColor, null)); - length = chatText.getCharCount(); - } - chatText.append(name + ": " + body); //$NON-NLS-1$ - chatText.setStyleRange(new StyleRange(length, name.length() + 1, blueColor, null, SWT.BOLD)); +// if (showTimestamps) { +// //chatText.append(FORMATTER.format(new Date(System.currentTimeMillis())) + ' '); +// //chatText.setStyleRange(new StyleRange(length, 13, blueColor, null)); +// String text = FORMATTER.format(new Date(System.currentTimeMillis())) + ' '; +// chatText.append(text); +// chatText.setStyleRange(new StyleRange(length, text.length(), blueColor, null)); +// length = chatText.getCharCount(); +// } +// chatText.append(name + ": "); //$NON-NLS-1$ +// //chatText.append(body); +// { +// int posStyleRange = chatLink.scan(body); +// chatText.append(body); +// chatLink.setStyleRange(posStyleRange); +// } +// chatText.setStyleRange(new StyleRange(length, name.length() + 1, blueColor, null, SWT.BOLD)); } isFirstMessage = false; + + if (output == null) { + return; + } + + int startRange = chatText.getText().length(); + + if (!body.endsWith("\n")) { + output += "\n"; //$NON-NLS-1$ + } + + chatText.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; + } + chatText.replaceStyleRanges(startRange, output.length(), ranges); + } + if (scrollToEnd) chatText.invokeAction(ST.TEXT_END); boldTabTitle(!scrollToEnd); @@ -404,13 +470,35 @@ Composite parent = new Composite(tabFolder, SWT.NONE); parent.setLayout(new FillLayout()); - SashForm sash = new SashForm(parent, SWT.VERTICAL); - - chatText = createStyledTextWidget(sash); + if (remoteID != null) { + //SashForm sash = new SashForm(parent, SWT.VERTICAL); + Composite composite = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.marginWidth = 0; + layout.marginHeight = 0; + layout.marginHeight = 0; + layout.verticalSpacing = 3; + layout.horizontalSpacing = 3; + composite.setLayout(layout); + + chatText = createStyledTextWidget(/*sash*/composite); + chatText.setLayoutData(new GridData(GridData.FILL_BOTH)); + + inputText = new Text(/*sash*/composite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.WRAP); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + GC gc = new GC(inputText); + gc.setFont(JFaceResources.getDialogFont()); + FontMetrics fontMetrics = gc.getFontMetrics(); + gc.dispose(); + gd.heightHint = fontMetrics.getHeight() * 2; + inputText.setLayoutData(gd); - inputText = new Text(sash, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); + //sash.setWeights(WEIGHTS); + } else { + chatText = createStyledTextWidget(parent); + } - sash.setWeights(WEIGHTS); + messageRenderer = new MessageRenderer(); Menu menu = new Menu(chatText); MenuItem mi = new MenuItem(menu, SWT.PUSH); Index: src/org/eclipse/ecf/presence/ui/RosterWorkbenchAdapterFactory.java =================================================================== RCS file: /cvsroot/technology/org.eclipse.ecf/plugins/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/presence/ui/RosterWorkbenchAdapterFactory.java,v retrieving revision 1.13 diff -u -r1.13 RosterWorkbenchAdapterFactory.java --- src/org/eclipse/ecf/presence/ui/RosterWorkbenchAdapterFactory.java 6 Sep 2007 04:41:55 -0000 1.13 +++ src/org/eclipse/ecf/presence/ui/RosterWorkbenchAdapterFactory.java 11 Apr 2008 13:16:21 -0000 @@ -175,6 +175,9 @@ // available if (pMode.equals(IPresence.Mode.AVAILABLE)) return getImageDescriptor(SharedImages.IMG_USER_AVAILABLE); + // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=223290 + else if (pMode.equals(IPresence.Mode.CHAT)) + return getImageDescriptor(SharedImages.IMG_USER_AVAILABLE); // If mode is away then we're away else if (pMode.equals(IPresence.Mode.AWAY) || pMode.equals(IPresence.Mode.EXTENDED_AWAY)) return getImageDescriptor(SharedImages.IMG_USER_AWAY);