View | Details | Raw Unified | Return to bug 222253 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/ecf/internal/presence/ui/preferences/PreferenceConstants.java (+1 lines)
Lines 16-19 Link Here
16
 */
16
 */
17
public class PreferenceConstants {
17
public class PreferenceConstants {
18
	public static final String CHATROOM_SHOW_USER_PRESENCE = "chatroom.user.presence.visible"; //$NON-NLS-1$
18
	public static final String CHATROOM_SHOW_USER_PRESENCE = "chatroom.user.presence.visible"; //$NON-NLS-1$
19
	public static final String CHATROOM_DISPLAY_TIMESTAMP = "chatroom.display.TimeStamp"; //$NON-NLS-1$
19
}
20
}
(-)src/org/eclipse/ecf/internal/presence/ui/preferences/PreferenceInitializer.java (+1 lines)
Lines 27-32 Link Here
27
	public void initializeDefaultPreferences() {
27
	public void initializeDefaultPreferences() {
28
		IPreferenceStore store = Activator.getDefault().getPreferenceStore();
28
		IPreferenceStore store = Activator.getDefault().getPreferenceStore();
29
		store.setDefault(PreferenceConstants.CHATROOM_SHOW_USER_PRESENCE, false);
29
		store.setDefault(PreferenceConstants.CHATROOM_SHOW_USER_PRESENCE, false);
30
		store.setDefault(PreferenceConstants.CHATROOM_DISPLAY_TIMESTAMP, true);
30
	}
31
	}
31
32
32
}
33
}
(-)src/org/eclipse/ecf/internal/presence/ui/preferences/ChatRoomPreferencePage.java (-14 / +271 lines)
Lines 11-42 Link Here
11
 ******************************************************************************/
11
 ******************************************************************************/
12
package org.eclipse.ecf.internal.presence.ui.preferences;
12
package org.eclipse.ecf.internal.presence.ui.preferences;
13
13
14
import org.eclipse.ecf.internal.presence.ui.Activator;
14
import org.eclipse.ecf.internal.presence.ui.*;
15
import org.eclipse.ecf.internal.presence.ui.Messages;
15
import org.eclipse.ecf.presence.ui.chatroom.MessageRenderer;
16
import org.eclipse.jface.preference.BooleanFieldEditor;
16
import org.eclipse.jface.preference.*;
17
import org.eclipse.jface.preference.FieldEditorPreferencePage;
17
import org.eclipse.jface.util.IPropertyChangeListener;
18
import org.eclipse.ui.IWorkbench;
18
import org.eclipse.jface.util.PropertyChangeEvent;
19
import org.eclipse.ui.IWorkbenchPreferencePage;
19
import org.eclipse.osgi.util.NLS;
20
import org.eclipse.swt.SWT;
21
import org.eclipse.swt.custom.StyleRange;
22
import org.eclipse.swt.custom.StyledText;
23
import org.eclipse.swt.events.*;
24
import org.eclipse.swt.graphics.Color;
25
import org.eclipse.swt.layout.GridData;
26
import org.eclipse.swt.layout.GridLayout;
27
import org.eclipse.swt.widgets.*;
28
import org.eclipse.ui.*;
29
import org.eclipse.ui.dialogs.PreferencesUtil;
30
import org.eclipse.ui.themes.ITheme;
20
31
21
public class ChatRoomPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
32
public class ChatRoomPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
22
33
34
	class Renderer extends MessageRenderer {
35
		public String[] nameColor={DATE_COLOR,
36
				RECEIVEDHIGHLIGHT_COLOR,SYSTEM_COLOR,
37
				RECEIVED_COLOR,SENT_COLOR};
38
39
		public String[] loadThemeName() {
40
			String[] names = new String[nameColor.length];
41
			for(int n=0; n<nameColor.length; n++)
42
				if(nameColor[n].equals(DATE_COLOR))
43
					names[n]=Messages.ChatRoomPreferencePage_DATE;
44
				else if(nameColor[n].equals(RECEIVEDHIGHLIGHT_COLOR))
45
					names[n]=Messages.ChatRoomPreferencePage_RECEIVEDHIGHLIGHT_MESSAGE;
46
				else if(nameColor[n].equals(SYSTEM_COLOR))
47
					names[n]=Messages.ChatRoomPreferencePage_SYSTEM_MESSAGE;
48
				else if(nameColor[n].equals(RECEIVED_COLOR))
49
					names[n]=Messages.ChatRoomPreferencePage_RECEIVED_MESSAGE;
50
				else if(nameColor[n].equals(SENT_COLOR))
51
					names[n]=Messages.ChatRoomPreferencePage_SENT_MESSAGE;
52
				else
53
					names[n]="?"; //$NON-NLS-1$
54
			return names;
55
		}
56
		public Color[] loadThemeColors() {
57
			Color[] colors = new Color[nameColor.length];
58
			ITheme theme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
59
			for(int n=0; n<nameColor.length; n++)
60
				colors[n]=theme.getColorRegistry().get(nameColor[n]);
61
			return colors;
62
		}
63
		public void saveThemeColors(Color[] colors) {
64
			ITheme theme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
65
			for(int n=0; n<nameColor.length; n++) {
66
				if(!theme.getColorRegistry().get(nameColor[n]).getRGB().equals(colors[n].getRGB()))
67
					theme.getColorRegistry().put(nameColor[n], colors[n].getRGB());
68
			}
69
		}
70
71
		protected void doRender() {
72
			if(timestamp.getBooleanValue())
73
				appendDateTime();
74
			if (originator != null) {
75
				appendNickname();
76
			}
77
			appendMessage();
78
		}
79
		protected Color getColor(String name) {
80
			if (name == null) {
81
				return null;
82
			}
83
			Color c = null;
84
			for(int n=0; n<nameColor.length; n++) {
85
				if(name.equals(nameColor[n])) {
86
					c = colorElement[n];
87
					break;
88
				}
89
			}
90
			if (c == null) {
91
				return Display.getDefault().getSystemColor(SWT.COLOR_BLACK);
92
			}
93
			return c;
94
		}
95
	}
96
97
	class CheckboxFieldEditor extends BooleanFieldEditor {
98
		public CheckboxFieldEditor(String name, String label, Composite parent, boolean value) {
99
			super(name, label, parent);
100
			getChangeControl(parent).setSelection(value);
101
		}
102
		protected void valueChanged(boolean oldValue, boolean newValue) {
103
			super.valueChanged(oldValue, newValue);
104
			updatePreview();
105
		}
106
	}
107
108
	private CheckboxFieldEditor userPresence;
109
	CheckboxFieldEditor timestamp;
110
	List element;
111
	ColorSelector colorButton;
112
	//private Button bold;
113
	//private Button italic;
114
	private StyledText preview;
115
	private Renderer messageRenderer;
116
117
	Color[] colorElement;
118
23
	public ChatRoomPreferencePage() {
119
	public ChatRoomPreferencePage() {
24
		super(GRID);
120
		super(GRID);
25
		setPreferenceStore(Activator.getDefault().getPreferenceStore());
121
		setPreferenceStore(Activator.getDefault().getPreferenceStore());
26
	}
122
	}
27
123
28
	/* (non-Javadoc)
124
	protected void performDefaults() {
29
	 * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
125
		super.performDefaults();
30
	 */
126
		colorElement = messageRenderer.loadThemeColors();
127
		int sel = element.getSelectionIndex();
128
		colorButton.setColorValue(colorElement[sel].getRGB());
129
		updatePreview();
130
	}
131
132
	public boolean performOk() {
133
		messageRenderer.saveThemeColors(colorElement);
134
		return super.performOk();
135
	}
136
31
	public void createFieldEditors() {
137
	public void createFieldEditors() {
32
		addField(new BooleanFieldEditor(PreferenceConstants.CHATROOM_SHOW_USER_PRESENCE, Messages.ChatRoomPreferencePage_CHATROOM_SHOW_USER_PRESENCE_TEXT, getFieldEditorParent()));
138
		boolean value = getPreferenceStore().getBoolean(
139
				PreferenceConstants.CHATROOM_SHOW_USER_PRESENCE);
140
		userPresence = new CheckboxFieldEditor(
141
				PreferenceConstants.CHATROOM_SHOW_USER_PRESENCE,
142
				Messages.ChatRoomPreferencePage_CHATROOM_SHOW_USER_PRESENCE_TEXT,
143
				getFieldEditorParent(),
144
				value);
145
		addField(userPresence);
146
		value = getPreferenceStore().getBoolean(
147
				PreferenceConstants.CHATROOM_DISPLAY_TIMESTAMP);
148
		timestamp=new CheckboxFieldEditor(
149
				PreferenceConstants.CHATROOM_DISPLAY_TIMESTAMP,
150
				Messages.ChatRoomPreferencePage_CHATROOM_DISPLAY_TIMESTAMP_TEXT,
151
				getFieldEditorParent(),
152
				value);
153
		addField(timestamp);
154
155
		messageRenderer = new Renderer();
156
		colorElement = messageRenderer.loadThemeColors();
157
158
		final Composite parent = getFieldEditorParent();
159
		new Label(parent, SWT.NONE);
160
161
		Label label = new Label(parent, SWT.NONE);
162
		label.setText(Messages.ChatRoomPreferencePage_ELEMENT);
163
164
		Composite group = new Composite(parent, SWT.NONE);
165
		group.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
166
		GridLayout layout = new GridLayout(3,false);
167
		layout.marginHeight=0;
168
		layout.marginWidth=0;
169
		layout.verticalSpacing=0;
170
		group.setLayout(layout);
171
172
		element=new List(group, SWT.SINGLE | SWT.BORDER);
173
		GridData gd = new GridData(200, SWT.DEFAULT);
174
		element.setLayoutData(gd);
175
		String[] names = messageRenderer.loadThemeName();
176
		for(int i=0; i<names.length; i++)
177
			element.add(names[i]);
178
179
		label=new Label(group, SWT.NONE);
180
		label.setText(" "); //$NON-NLS-1$
181
182
		Composite subgroup = new Composite(group, SWT.NONE);
183
		subgroup.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); 
184
		layout = new GridLayout(2,false);
185
		layout.marginHeight=0;
186
		layout.marginWidth=0;
187
		layout.verticalSpacing=0;
188
		subgroup.setLayout(layout);
189
190
		label=new Label(subgroup, SWT.NONE);
191
		label.setText(Messages.ChatRoomPreferencePage_COLOR);
192
		label.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_CENTER)); 
193
		colorButton = new ColorSelector(subgroup);
194
		colorButton.getButton();
195
196
		//bold = new Button(subgroup, SWT.CHECK); 
197
		//bold.setText("Bold");  //$NON-NLS-1$
198
		//gd = new GridData(GridData.VERTICAL_ALIGN_CENTER); 
199
		//gd.horizontalSpan=2;
200
		//bold.setLayoutData(gd); 
201
202
		//italic = new Button(subgroup, SWT.CHECK); 
203
		//italic.setText("Italic");  //$NON-NLS-1$
204
		//gd = new GridData(GridData.VERTICAL_ALIGN_CENTER); 
205
		//gd.horizontalSpan=2;
206
		//italic.setLayoutData(gd); 
207
208
		label = new Label(parent, SWT.NONE);
209
		label.setText(Messages.ChatRoomPreferencePage_PREVIEW);
210
211
		preview=new StyledText(parent, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI | SWT.READ_ONLY);
212
		preview.setLayoutData(new GridData(GridData.FILL_BOTH));
213
214
		new Label(parent, SWT.NONE);
215
216
		Link link= new Link(parent, SWT.NONE);
217
		link.setText(Messages.ChatRoomPreferencePage_LINK_COLORS_AND_FONTS_TEXT);
218
		link.addSelectionListener(new SelectionAdapter() {
219
			public void widgetSelected(SelectionEvent e) {
220
				PreferencesUtil.createPreferenceDialogOn(
221
						/*getFieldEditorParent()*/parent.getShell(),
222
						e.text, null, null); 
223
			}
224
		});
225
		GridData gridData= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
226
		gridData.widthHint= 150; // only expand further if anyone else requires it
227
		link.setLayoutData(gridData);
228
229
		new Label(parent, SWT.NONE);
230
231
		element.addSelectionListener(new SelectionListener() {
232
			public void widgetDefaultSelected(SelectionEvent e) {
233
				int sel = element.getSelectionIndex();
234
				colorButton.setColorValue(colorElement[sel].getRGB());
235
			}
236
			public void widgetSelected(SelectionEvent e) {
237
				int sel = element.getSelectionIndex();
238
				colorButton.setColorValue(colorElement[sel].getRGB());
239
			}
240
		});
241
		element.select(0);
242
		colorButton.setColorValue(colorElement[0].getRGB());
243
		colorButton.addListener(new IPropertyChangeListener() {
244
			public void propertyChange(PropertyChangeEvent event) {
245
				int sel = element.getSelectionIndex();
246
				colorElement[sel] = new Color(colorElement[sel].getDevice(),
247
						colorButton.getColorValue());
248
				updatePreview();
249
			}
250
		});
251
		
252
		updatePreview();
253
	}
254
255
	void updatePreview() {
256
		preview.setText(""); //$NON-NLS-1$
257
		String remote1 = "friend1"; //$NON-NLS-1$
258
		String remote2 = "friend2"; //$NON-NLS-1$
259
		String local = "myself"; //$NON-NLS-1$
260
		addPreviewLine("Welcome, everybody...", null, local); //$NON-NLS-1$
261
		addPreviewLine("Home/Wiki: http://myserver.domain", null, local); //$NON-NLS-1$
262
		if(userPresence.getBooleanValue()) {
263
			addPreviewLine(
264
					NLS.bind(org.eclipse.ecf.internal.presence.ui.Messages.ChatRoomManagerView_ENTERED_MESSAGE,
265
							local), null, local);
266
			addPreviewLine(
267
					NLS.bind(org.eclipse.ecf.internal.presence.ui.Messages.ChatRoomManagerView_ENTERED_MESSAGE,
268
							remote1), null, local);
269
			addPreviewLine(
270
					NLS.bind(org.eclipse.ecf.internal.presence.ui.Messages.ChatRoomManagerView_ENTERED_MESSAGE,
271
							remote2), null, local);
272
		}
273
		addPreviewLine("Hello", remote1, local); //$NON-NLS-1$
274
		addPreviewLine("Hello, "+local, remote2, local); //$NON-NLS-1$
275
		addPreviewLine("Hello", local, local); //$NON-NLS-1$
276
	}
277
278
	private void addPreviewLine(String body, String remote, String local) {
279
		String output = messageRenderer.render(body, remote, local);
280
		StyleRange[] ranges = messageRenderer.getStyleRanges();
281
		if (output != null) {
282
			int startRange = preview.getText().length();
283
			if(!output.endsWith("\n")) //$NON-NLS-1$
284
				output+="\n"; //$NON-NLS-1$
285
			preview.append(output);
286
			if (ranges != null) {
287
				// set all ranges to start as message line starts
288
				for (int i = 0; i < ranges.length; i++) {
289
					ranges[i].start += startRange;
290
				}
291
				preview.replaceStyleRanges(startRange, output.length(), ranges);
292
			}
293
		}
33
	}
294
	}
34
295
35
	/*
36
	 * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
37
	 */
38
	public void init(IWorkbench workbench) {
296
	public void init(IWorkbench workbench) {
39
		// do nothing
297
		// do nothing
40
	}
298
	}
41
42
}
299
}
(-)src/org/eclipse/ecf/internal/presence/ui/Messages.java (-1 / +53 lines)
Lines 238-244 Link Here
238
	public static String MessageRenderer_DEFAULT_TIME_FORMAT;
238
	public static String MessageRenderer_DEFAULT_TIME_FORMAT;
239
	
239
	
240
	public static String ChatRoomPreferencePage_CHATROOM_SHOW_USER_PRESENCE_TEXT;
240
	public static String ChatRoomPreferencePage_CHATROOM_SHOW_USER_PRESENCE_TEXT;
241
	
241
	public static String ChatRoomPreferencePage_CHATROOM_DISPLAY_TIMESTAMP_TEXT;
242
	public static String ChatRoomPreferencePage_LINK_COLORS_AND_FONTS_TEXT;
243
	public static String ChatRoomPreferencePage_ELEMENT;
244
	public static String ChatRoomPreferencePage_COLOR;
245
	public static String ChatRoomPreferencePage_PREVIEW;
246
	public static String ChatRoomPreferencePage_DATE;
247
	public static String ChatRoomPreferencePage_RECEIVEDHIGHLIGHT_MESSAGE;
248
	public static String ChatRoomPreferencePage_SYSTEM_MESSAGE;
249
	public static String ChatRoomPreferencePage_RECEIVED_MESSAGE;
250
	public static String ChatRoomPreferencePage_SENT_MESSAGE;
251
252
	public static String MessagesView_broadcast;
253
254
	public static String RosterItemWrapper_PROPERTY_NAME;
255
	public static String RosterItemWrapper_PROPERTY_NICKNAME;
256
	public static String RosterItemWrapper_PROPERTY_ID;
257
	public static String RosterItemWrapper_PROPERTY_TYPE;
258
	public static String RosterItemWrapper_PROPERTY_MODE;
259
	public static String RosterItemWrapper_PROPERTY_STATUS;
260
	public static String RosterItemWrapper_PROPERTY_GROUP_ACCOUNT;
261
	public static String RosterItemWrapper_PROPERTY_GROUP_STATUS;
262
263
	public static String RosterItemWrapper_PRESENCE_TYPE_AVAILABLE;
264
	public static String RosterItemWrapper_PRESENCE_TYPE_ERROR;
265
	public static String RosterItemWrapper_PRESENCE_TYPE_SUBSCRIBE;
266
	public static String RosterItemWrapper_PRESENCE_TYPE_SUBSCRIBED;
267
	public static String RosterItemWrapper_PRESENCE_TYPE_UNAVAILABLE;
268
	public static String RosterItemWrapper_PRESENCE_TYPE_UNSUBSCRIBE;
269
	public static String RosterItemWrapper_PRESENCE_TYPE_UNSUBSCRIBED;
270
	public static String RosterItemWrapper_PRESENCE_TYPE_UNKWOWN;
271
272
	public static String RosterItemWrapper_PRESENCE_MODE_AVAILABLE;
273
	public static String RosterItemWrapper_PRESENCE_MODE_AWAY;
274
	public static String RosterItemWrapper_PRESENCE_MODE_CHAT;
275
	public static String RosterItemWrapper_PRESENCE_MODE_DND;
276
	public static String RosterItemWrapper_PRESENCE_MODE_EXTENDED_AWAY;
277
	public static String RosterItemWrapper_PRESENCE_MODE_INVISIBLE;
278
279
	public static String RosterItemWrapper_VCARD_EMAIL_HOME;
280
	public static String RosterItemWrapper_VCARD_EMAIL_WORK;
281
	public static String RosterItemWrapper_VCARD_NAME_FIRST;
282
	public static String RosterItemWrapper_VCARD_NAME_MIDDLE;
283
	public static String RosterItemWrapper_VCARD_NAME_LAST;
284
	public static String RosterItemWrapper_VCARD_NAME_NICK;
285
	public static String RosterItemWrapper_VCARD_PHONE_HOME_VOICE;
286
	public static String RosterItemWrapper_VCARD_PHONE_HOME_CELL;
287
	public static String RosterItemWrapper_VCARD_PHONE_WORK_VOICE;
288
	public static String RosterItemWrapper_VCARD_PHONE_WORK_CELL;
289
290
	public static String RosterPropertySheetPage_ACCOUNT;
291
	public static String RosterPropertySheetPage_PROFILE;
292
	public static String RosterPropertySheetPage_AVATAR;
293
242
	static {
294
	static {
243
		NLS.initializeMessages(BUNDLE_NAME, Messages.class);
295
		NLS.initializeMessages(BUNDLE_NAME, Messages.class);
244
	}
296
	}
(-)src/org/eclipse/ecf/internal/presence/ui/messages.properties (-2 / +53 lines)
Lines 16-22 Link Here
16
16
17
MultiRosterView_SendIM = Send &IM
17
MultiRosterView_SendIM = Send &IM
18
MultiRosterView_Remove = &Remove
18
MultiRosterView_Remove = &Remove
19
MultiRosterView_SetStatusAs = Set Status As...
19
#MultiRosterView_SetStatusAs = Set Status As...
20
MultiRosterView_SetStatusAs = Set Status As
20
MultiRosterView_SetAvailable = &Available
21
MultiRosterView_SetAvailable = &Available
21
MultiRosterView_SetAway = A&way
22
MultiRosterView_SetAway = A&way
22
MultiRosterView_SetDoNotDisturb = &Do Not Disturb
23
MultiRosterView_SetDoNotDisturb = &Do Not Disturb
Lines 50-55 Link Here
50
MessagesView_TypingNotification = {0} is typing a message...
51
MessagesView_TypingNotification = {0} is typing a message...
51
MessagesView_Copy = &Copy
52
MessagesView_Copy = &Copy
52
MessagesView_SelectAll = &Select All
53
MessagesView_SelectAll = &Select All
54
MessagesView_broadcast=<Broadcast>
53
55
54
AddContactDialog_DialogTitle = Add Contact
56
AddContactDialog_DialogTitle = Add Contact
55
AddContactDialog_UserID = User ID:
57
AddContactDialog_UserID = User ID:
Lines 145-148 Link Here
145
MessageRenderer_DEFAULT_DATETIME_FORMAT=({0})
147
MessageRenderer_DEFAULT_DATETIME_FORMAT=({0})
146
148
147
ChatRoomPreferencePage_CHATROOM_SHOW_USER_PRESENCE_TEXT=&Show user entry messages
149
ChatRoomPreferencePage_CHATROOM_SHOW_USER_PRESENCE_TEXT=&Show user entry messages
148
 
150
ChatRoomPreferencePage_CHATROOM_DISPLAY_TIMESTAMP_TEXT=Show &time for each chat entry
151
ChatRoomPreferencePage_LINK_COLORS_AND_FONTS_TEXT=Default colors and fonts can be configured on the <a href=\"org.eclipse.ui.preferencePages.ColorsAndFonts\">Colors and Fonts</a> preference page.
152
ChatRoomPreferencePage_ELEMENT=Element:
153
ChatRoomPreferencePage_COLOR=Color:
154
ChatRoomPreferencePage_PREVIEW=Preview:
155
ChatRoomPreferencePage_DATE=Time
156
ChatRoomPreferencePage_RECEIVEDHIGHLIGHT_MESSAGE=Highlight message
157
ChatRoomPreferencePage_SYSTEM_MESSAGE=System message
158
ChatRoomPreferencePage_RECEIVED_MESSAGE=Received message
159
ChatRoomPreferencePage_SENT_MESSAGE=Sent message
160
161
RosterItemWrapper_PROPERTY_NAME=Name
162
RosterItemWrapper_PROPERTY_NICKNAME=Nickname
163
RosterItemWrapper_PROPERTY_ID=ID
164
RosterItemWrapper_PROPERTY_TYPE=Type
165
RosterItemWrapper_PROPERTY_MODE=Mode
166
RosterItemWrapper_PROPERTY_STATUS=Info
167
RosterItemWrapper_PROPERTY_GROUP_ACCOUNT=Account
168
RosterItemWrapper_PROPERTY_GROUP_STATUS=Status
169
170
RosterItemWrapper_PRESENCE_TYPE_AVAILABLE=Available
171
RosterItemWrapper_PRESENCE_TYPE_ERROR=Error
172
RosterItemWrapper_PRESENCE_TYPE_SUBSCRIBE=Subscribe
173
RosterItemWrapper_PRESENCE_TYPE_SUBSCRIBED=Subscribed
174
RosterItemWrapper_PRESENCE_TYPE_UNAVAILABLE=Unavailable
175
RosterItemWrapper_PRESENCE_TYPE_UNSUBSCRIBE=Unsubscribe
176
RosterItemWrapper_PRESENCE_TYPE_UNSUBSCRIBED=Unsubscribed
177
RosterItemWrapper_PRESENCE_TYPE_UNKWOWN=Unknown
178
179
RosterItemWrapper_PRESENCE_MODE_AVAILABLE=Available
180
RosterItemWrapper_PRESENCE_MODE_AWAY=Away
181
RosterItemWrapper_PRESENCE_MODE_CHAT=Chat
182
RosterItemWrapper_PRESENCE_MODE_DND=Do not disturb
183
RosterItemWrapper_PRESENCE_MODE_EXTENDED_AWAY=Extended away
184
RosterItemWrapper_PRESENCE_MODE_INVISIBLE=Invisible
185
186
RosterItemWrapper_VCARD_EMAIL_HOME=E-Mail (Home)
187
RosterItemWrapper_VCARD_EMAIL_WORK=E-Mail (Work)
188
RosterItemWrapper_VCARD_NAME_FIRST=First name
189
RosterItemWrapper_VCARD_NAME_MIDDLE=Middle name
190
RosterItemWrapper_VCARD_NAME_LAST=Last name
191
RosterItemWrapper_VCARD_NAME_NICK=Nickname
192
RosterItemWrapper_VCARD_PHONE_HOME_VOICE=Phone (Home)
193
RosterItemWrapper_VCARD_PHONE_HOME_CELL=Phone (Home cell)
194
RosterItemWrapper_VCARD_PHONE_WORK_VOICE=Phone (Work)
195
RosterItemWrapper_VCARD_PHONE_WORK_CELL=Phone (Work cell)
196
197
RosterPropertySheetPage_ACCOUNT=Account
198
RosterPropertySheetPage_PROFILE=Profile
199
RosterPropertySheetPage_AVATAR=Avatar
(-)src/org/eclipse/ecf/presence/ui/chatroom/IMessageRenderer.java (-1 / +7 lines)
Lines 11-16 Link Here
11
package org.eclipse.ecf.presence.ui.chatroom;
11
package org.eclipse.ecf.presence.ui.chatroom;
12
12
13
import org.eclipse.swt.custom.StyleRange;
13
import org.eclipse.swt.custom.StyleRange;
14
import org.eclipse.swt.graphics.Font;
14
15
15
/**
16
/**
16
 * Renders chat line, by arranging text content to be finally printed to 
17
 * Renders chat line, by arranging text content to be finally printed to 
Lines 33-37 Link Here
33
	 * @return formatting to be applied to output, or null if no formatting
34
	 * @return formatting to be applied to output, or null if no formatting
34
	 */
35
	 */
35
	StyleRange[] getStyleRanges();
36
	StyleRange[] getStyleRanges();
36
	
37
38
	/**
39
	 * Returns text font of output
40
	 * @return text font of output
41
	 */
42
	Font getTextFont();
37
}
43
}
(-)src/org/eclipse/ecf/presence/ui/chatroom/ChatRoomManagerView.java (-17 / +53 lines)
Lines 34-39 Link Here
34
import org.eclipse.ecf.presence.ui.MessagesView;
34
import org.eclipse.ecf.presence.ui.MessagesView;
35
import org.eclipse.jface.action.*;
35
import org.eclipse.jface.action.*;
36
import org.eclipse.jface.dialogs.MessageDialog;
36
import org.eclipse.jface.dialogs.MessageDialog;
37
import org.eclipse.jface.resource.JFaceResources;
37
import org.eclipse.jface.text.*;
38
import org.eclipse.jface.text.*;
38
import org.eclipse.jface.text.source.SourceViewer;
39
import org.eclipse.jface.text.source.SourceViewer;
39
import org.eclipse.jface.util.IPropertyChangeListener;
40
import org.eclipse.jface.util.IPropertyChangeListener;
Lines 59-67 Link Here
59
60
60
	public static final String PARTICIPANTS_MENU_ID = "org.eclipse.ecf.presence.ui.chatroom.participantsView"; //$NON-NLS-1$ 
61
	public static final String PARTICIPANTS_MENU_ID = "org.eclipse.ecf.presence.ui.chatroom.participantsView"; //$NON-NLS-1$ 
61
62
62
	private static final int RATIO_WRITE_PANE = 1;
63
	//private static final int RATIO_WRITE_PANE = 1;
63
64
	//private static final int RATIO_READ_PANE = 9;
64
	private static final int RATIO_READ_PANE = 9;
65
65
66
	private static final int RATIO_READ_WRITE_PANE = 85;
66
	private static final int RATIO_READ_WRITE_PANE = 85;
67
67
Lines 112-118 Link Here
112
112
113
		private CTabItem tabItem;
113
		private CTabItem tabItem;
114
114
115
		private SashForm rightSash;
115
		//private SashForm rightSash;
116
		Composite rightComp;
116
117
117
		private StyledText subjectText;
118
		private StyledText subjectText;
118
119
Lines 147-152 Link Here
147
				GridLayout layout = new GridLayout(1, true);
148
				GridLayout layout = new GridLayout(1, true);
148
				layout.marginWidth = 0;
149
				layout.marginWidth = 0;
149
				layout.marginHeight = 0;
150
				layout.marginHeight = 0;
151
				layout.marginHeight = 0;
152
				layout.verticalSpacing = 3;
153
				layout.horizontalSpacing = 3;
150
				memberComp.setLayout(layout);
154
				memberComp.setLayout(layout);
151
155
152
				participantsNumberLabel = new Label(memberComp, SWT.BORDER | SWT.READ_ONLY);
156
				participantsNumberLabel = new Label(memberComp, SWT.BORDER | SWT.READ_ONLY);
Lines 171-181 Link Here
171
					}
175
					}
172
				});
176
				});
173
177
174
				Composite rightComp = new Composite(fullChat, SWT.NONE);
178
				/*Composite*/rightComp = new Composite(fullChat, SWT.NONE);
179
				layout = new GridLayout(1, true);
180
				layout.marginWidth = 0;
181
				layout.marginHeight = 0;
182
				layout.marginHeight = 0;
183
				layout.verticalSpacing = 3;
184
				layout.horizontalSpacing = 3;
185
				memberComp.setLayout(layout);
175
				rightComp.setLayout(layout);
186
				rightComp.setLayout(layout);
176
187
177
				subjectText = createStyledTextWidget(rightComp, SWT.SINGLE | SWT.BORDER);
188
				subjectText = createStyledTextWidget(rightComp, SWT.SINGLE | SWT.BORDER);
178
				subjectText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
189
				//subjectText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL, SWT.CENTER, true, false));
190
				subjectText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
179
				subjectText.addKeyListener(new KeyAdapter() {
191
				subjectText.addKeyListener(new KeyAdapter() {
180
					public void keyPressed(KeyEvent evt) {
192
					public void keyPressed(KeyEvent evt) {
181
						if (evt.character == SWT.CR || evt.character == SWT.KEYPAD_CR) {
193
						if (evt.character == SWT.CR || evt.character == SWT.KEYPAD_CR) {
Lines 187-217 Link Here
187
										chatRoomAdminSender.sendSubjectChange(subjectText.getText());
199
										chatRoomAdminSender.sendSubjectChange(subjectText.getText());
188
									}
200
									}
189
								} catch (ECFException e) {
201
								} catch (ECFException e) {
190
									disconnected();
202
									//disconnected();
191
								}
203
								}
192
							}
204
							}
193
						}
205
						}
194
					}
206
					}
195
				});
207
				});
196
208
197
				rightSash = new SashForm(rightComp, SWT.VERTICAL);
209
				//rightSash = new SashForm(rightComp, SWT.VERTICAL);
198
				rightSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
210
				//rightSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
199
			} else
211
			} else {
200
				rightSash = new SashForm(parent, SWT.VERTICAL);
212
				//rightSash = new SashForm(parent, SWT.VERTICAL);
213
				rightComp = new Composite(parent, SWT.NONE);
214
				rightComp.setLayoutData(new GridData(GridData.FILL_BOTH));
215
				GridLayout layout = new GridLayout(1, true);
216
				layout = new GridLayout(1, true);
217
				layout.marginWidth = 0;
218
				layout.marginHeight = 0;
219
				layout.marginHeight = 0;
220
				layout.verticalSpacing = 3;
221
				layout.horizontalSpacing = 3;
222
				rightComp.setLayout(layout);
223
			}
201
224
202
			outputText = createStyledTextWidget(rightSash, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI | SWT.READ_ONLY);
225
			outputText = createStyledTextWidget(/*rightSash*/rightComp, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI | SWT.READ_ONLY);
203
			outputText.setEditable(false);
226
			outputText.setEditable(false);
204
			outputText.setLayoutData(new GridData(GridData.FILL_BOTH));
227
			outputText.setLayoutData(new GridData(GridData.FILL_BOTH));
205
228
206
			inputText = new Text(rightSash, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
229
			inputText = new Text(/*rightSash*/rightComp, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
230
			GridData gd = new GridData(GridData.FILL_HORIZONTAL);
231
			GC gc = new GC(inputText);
232
			gc.setFont(JFaceResources.getDialogFont());
233
			FontMetrics fontMetrics = gc.getFontMetrics();
234
			gc.dispose();
235
			gd.heightHint = fontMetrics.getHeight() * 2;
236
			inputText.setLayoutData(gd);
207
			if (keyListener != null)
237
			if (keyListener != null)
208
				inputText.addKeyListener(keyListener);
238
				inputText.addKeyListener(keyListener);
209
			rightSash.setWeights(new int[] {RATIO_READ_PANE, RATIO_WRITE_PANE});
239
			//rightSash.setWeights(new int[] {RATIO_READ_PANE, RATIO_WRITE_PANE});
210
			if (withParticipants) {
240
			if (withParticipants) {
211
				fullChat.setWeights(new int[] {RATIO_PRESENCE_PANE, RATIO_READ_WRITE_PANE});
241
				fullChat.setWeights(new int[] {RATIO_PRESENCE_PANE, RATIO_READ_WRITE_PANE});
212
				tabItem.setControl(fullChat);
242
				tabItem.setControl(fullChat);
213
			} else
243
			} else
214
				tabItem.setControl(rightSash);
244
				tabItem.setControl(/*rightSash*/rightComp);
215
245
216
			parent.setSelection(tabItem);
246
			parent.setSelection(tabItem);
217
247
Lines 424-429 Link Here
424
		public void setSubject(String subject) {
454
		public void setSubject(String subject) {
425
			subjectText.setText(subject);
455
			subjectText.setText(subject);
426
		}
456
		}
457
458
		public CTabItem getTabItem() {
459
			return tabItem;
460
		}
427
	}
461
	}
428
462
429
	public void createPartControl(Composite parent) {
463
	public void createPartControl(Composite parent) {
Lines 630-636 Link Here
630
			});
664
			});
631
			chatRoomContainer.addListener(new IContainerListener() {
665
			chatRoomContainer.addListener(new IContainerListener() {
632
				public void handleEvent(IContainerEvent evt) {
666
				public void handleEvent(IContainerEvent evt) {
633
					if (evt instanceof IContainerDisconnectedEvent || evt instanceof IContainerEjectedEvent) {
667
					if (evt instanceof IContainerDisconnectedEvent) {
634
						chatroom.disconnected();
668
						chatroom.disconnected();
635
					}
669
					}
636
				}
670
				}
Lines 1351-1360 Link Here
1351
	}
1385
	}
1352
1386
1353
	protected void appendText(ChatRoomTab chatRoomTab, StyledText st, ChatLine text) {
1387
	protected void appendText(ChatRoomTab chatRoomTab, StyledText st, ChatLine text) {
1354
		if (st == null || text == null) {
1388
		if (/*st == null ||*/text == null) {
1355
			return;
1389
			return;
1356
		}
1390
		}
1357
1391
1392
		/*StyledText*/st = chatRoomTab.getOutputText();
1393
1358
		boolean isAtEndBeforeAppend = !isLastOutputInvisible(st);
1394
		boolean isAtEndBeforeAppend = !isLastOutputInvisible(st);
1359
1395
1360
		String originator = null;
1396
		String originator = null;
(-)src/org/eclipse/ecf/presence/ui/chatroom/ChatRoomManagerUI.java (-1 / +1 lines)
Lines 92-98 Link Here
92
		Assert.isNotNull(roomInfo, Messages.ChatRoomManagerUI_EXCEPTION_NO_ROOT_CHAT_ROOM_MANAGER);
92
		Assert.isNotNull(roomInfo, Messages.ChatRoomManagerUI_EXCEPTION_NO_ROOT_CHAT_ROOM_MANAGER);
93
		final IChatRoomContainer managerChatRoom = roomInfo.createChatRoomContainer();
93
		final IChatRoomContainer managerChatRoom = roomInfo.createChatRoomContainer();
94
		chatroomview.initializeWithManager(ChatRoomManagerView.getUsernameFromID(targetID), ChatRoomManagerView.getHostnameFromID(targetID), managerChatRoom, this, createChatRoomViewCloseListener());
94
		chatroomview.initializeWithManager(ChatRoomManagerView.getUsernameFromID(targetID), ChatRoomManagerView.getHostnameFromID(targetID), managerChatRoom, this, createChatRoomViewCloseListener());
95
		chatroomview.setMessageRenderer(getDefaultMessageRenderer());
95
		//chatroomview.setMessageRenderer(getDefaultMessageRenderer());
96
		// Add listener for container, so that if the container is spontaneously
96
		// Add listener for container, so that if the container is spontaneously
97
		// disconnected,
97
		// disconnected,
98
		// then we will be able to have the UI respond by making itself inactive
98
		// then we will be able to have the UI respond by making itself inactive
(-)src/org/eclipse/ecf/presence/ui/chatroom/MessageRenderer.java (-6 / +12 lines)
Lines 8-24 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *    Jacek Pospychala <jacek.pospychala@pl.ibm.com> - bug 197329, 190851
9
 *    Jacek Pospychala <jacek.pospychala@pl.ibm.com> - bug 197329, 190851
10
 *****************************************************************************/
10
 *****************************************************************************/
11
11
package org.eclipse.ecf.presence.ui.chatroom;
12
package org.eclipse.ecf.presence.ui.chatroom;
12
13
13
import java.text.SimpleDateFormat;
14
import java.text.SimpleDateFormat;
14
import java.util.*;
15
import java.util.*;
15
import org.eclipse.core.runtime.Assert;
16
import org.eclipse.core.runtime.Assert;
17
import org.eclipse.ecf.internal.presence.ui.Activator;
16
import org.eclipse.ecf.internal.presence.ui.Messages;
18
import org.eclipse.ecf.internal.presence.ui.Messages;
19
import org.eclipse.ecf.internal.presence.ui.preferences.PreferenceConstants;
17
import org.eclipse.osgi.util.NLS;
20
import org.eclipse.osgi.util.NLS;
18
import org.eclipse.swt.SWT;
21
import org.eclipse.swt.SWT;
19
import org.eclipse.swt.custom.StyleRange;
22
import org.eclipse.swt.custom.StyleRange;
20
import org.eclipse.swt.graphics.Color;
23
import org.eclipse.swt.graphics.*;
21
import org.eclipse.swt.graphics.Font;
22
import org.eclipse.swt.widgets.Display;
24
import org.eclipse.swt.widgets.Display;
23
import org.eclipse.ui.PlatformUI;
25
import org.eclipse.ui.PlatformUI;
24
import org.eclipse.ui.themes.ITheme;
26
import org.eclipse.ui.themes.ITheme;
Lines 121-128 Link Here
121
	}
123
	}
122
124
123
	protected void doRender() {
125
	protected void doRender() {
124
126
		if(Activator.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.CHATROOM_DISPLAY_TIMESTAMP))
125
		appendDateTime();
127
			appendDateTime();
126
		if (originator != null) {
128
		if (originator != null) {
127
			appendNickname();
129
			appendNickname();
128
		}
130
		}
Lines 161-167 Link Here
161
		styleRanges.add(styleRange);
163
		styleRanges.add(styleRange);
162
	}
164
	}
163
165
164
	private Color getColor(String name) {
166
	protected Color getColor(String name) {
165
		if (name == null) {
167
		if (name == null) {
166
			return null;
168
			return null;
167
		}
169
		}
Lines 176-182 Link Here
176
		return c;
178
		return c;
177
	}
179
	}
178
180
179
	private Font getFont(String name) {
181
	protected Font getFont(String name) {
180
		if (name == null) {
182
		if (name == null) {
181
			return null;
183
			return null;
182
		}
184
		}
Lines 203-206 Link Here
203
				getCurrentDate(DEFAULT_TIME_FORMAT));
205
				getCurrentDate(DEFAULT_TIME_FORMAT));
204
		return buf.toString();
206
		return buf.toString();
205
	}
207
	}
208
209
	public Font getTextFont() {
210
		return getFont(font);
211
	}
206
}
212
}
(-)plugin.properties (-6 / +7 lines)
Lines 19-25 Link Here
19
browse.command.label = Open Contact...
19
browse.command.label = Open Contact...
20
browse.command.tooltip = Open Contact
20
browse.command.tooltip = Open Contact
21
21
22
chatroom.preferencePage.name = Chat Room
22
#chatroom.preferencePage.name = Chat Room
23
chatroom.preferencePage.name = Messages and Chats
23
themeElementCategory.messagesAndChats = Messages and Chats
24
themeElementCategory.messagesAndChats = Messages and Chats
24
themeElementCategory.messagesAndChats.description = Appearance details of ECF message and chat windows.
25
themeElementCategory.messagesAndChats.description = Appearance details of ECF message and chat windows.
25
fontDefinition.dateFont = Date font
26
fontDefinition.dateFont = Date font
Lines 27-45 Link Here
27
colorDefinition.dateColor = Date color
28
colorDefinition.dateColor = Date color
28
colorDefinition.dateColor.description = Color of the date stamp in message window.
29
colorDefinition.dateColor.description = Color of the date stamp in message window.
29
fontDefinition.highlightFont = Highlight font
30
fontDefinition.highlightFont = Highlight font
30
fontDefinition.highlightFont.description = Font of the date stamp in message window.
31
fontDefinition.highlightFont.description = Font of the highlight text in message window.
31
colorDefinition.highlightColor = Highlight color
32
colorDefinition.highlightColor = Highlight color
32
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.
33
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.
33
fontDefinition.systemMessagesFont = System messages font
34
fontDefinition.systemMessagesFont = System messages font
34
fontDefinition.systemMessagesFont.description = Font of the date stamp in message window.
35
fontDefinition.systemMessagesFont.description = Font of the system messages in message window.
35
colorDefinition.systemMessagesColor = System messages color
36
colorDefinition.systemMessagesColor = System messages color
36
colorDefinition.systemMessagesColor.description = Color of messages sent by the system, eg. a server notifications.
37
colorDefinition.systemMessagesColor.description = Color of messages sent by the system, eg. a server notifications.
37
fontDefinition.receivedMessagesFont = Received messages font
38
fontDefinition.receivedMessagesFont = Received messages font
38
fontDefinition.receivedMessagesFont.description = Font of the date stamp in message window.
39
fontDefinition.receivedMessagesFont.description = Font of the received messages in message window.
39
colorDefinition.receivedMessagesColor = Received messages color
40
colorDefinition.receivedMessagesColor = Received messages color
40
colorDefinition.receivedMessagesColor.description = Color of any received messages.
41
colorDefinition.receivedMessagesColor.description = Color of any received messages.
41
fontDefinition.sentMessagesFont = Sent messages font
42
fontDefinition.sentMessagesFont = Sent messages font
42
fontDefinition.sentMessagesFont.description = Font of the date stamp in message window.
43
fontDefinition.sentMessagesFont.description = Font of the sent messages in message window.
43
colorDefinition.sentMessagesColor = Sent messages color
44
colorDefinition.sentMessagesColor = Sent messages color
44
colorDefinition.sentMessagesColor.description = Color of messages sent by local user.
45
colorDefinition.sentMessagesColor.description = Color of messages sent by local user.
45
46
(-)src/org/eclipse/ecf/presence/ui/MessagesView.java (-69 / +157 lines)
Lines 10-25 Link Here
10
 *****************************************************************************/
10
 *****************************************************************************/
11
package org.eclipse.ecf.presence.ui;
11
package org.eclipse.ecf.presence.ui;
12
12
13
import java.text.SimpleDateFormat;
13
//import java.text.SimpleDateFormat;
14
import java.util.*;
14
import java.util.*;
15
import org.eclipse.core.runtime.*;
15
import org.eclipse.core.runtime.*;
16
import org.eclipse.ecf.core.identity.ID;
16
import org.eclipse.ecf.core.identity.ID;
17
//import org.eclipse.ecf.core.user.User;
17
import org.eclipse.ecf.core.util.ECFException;
18
import org.eclipse.ecf.core.util.ECFException;
18
import org.eclipse.ecf.internal.presence.ui.Activator;
19
import org.eclipse.ecf.internal.presence.ui.*;
19
import org.eclipse.ecf.internal.presence.ui.Messages;
20
import org.eclipse.ecf.presence.im.*;
20
import org.eclipse.ecf.presence.im.*;
21
import org.eclipse.ecf.presence.ui.chatroom.*;
21
import org.eclipse.jface.action.*;
22
import org.eclipse.jface.action.*;
22
import org.eclipse.jface.dialogs.MessageDialog;
23
import org.eclipse.jface.dialogs.MessageDialog;
24
import org.eclipse.jface.resource.JFaceResources;
23
import org.eclipse.jface.text.Document;
25
import org.eclipse.jface.text.Document;
24
import org.eclipse.jface.text.source.SourceViewer;
26
import org.eclipse.jface.text.source.SourceViewer;
25
import org.eclipse.jface.util.IPropertyChangeListener;
27
import org.eclipse.jface.util.IPropertyChangeListener;
Lines 29-35 Link Here
29
import org.eclipse.swt.custom.*;
31
import org.eclipse.swt.custom.*;
30
import org.eclipse.swt.events.*;
32
import org.eclipse.swt.events.*;
31
import org.eclipse.swt.graphics.*;
33
import org.eclipse.swt.graphics.*;
32
import org.eclipse.swt.layout.FillLayout;
34
import org.eclipse.swt.layout.*;
33
import org.eclipse.swt.widgets.*;
35
import org.eclipse.swt.widgets.*;
34
import org.eclipse.ui.IWorkbenchPreferenceConstants;
36
import org.eclipse.ui.IWorkbenchPreferenceConstants;
35
import org.eclipse.ui.PlatformUI;
37
import org.eclipse.ui.PlatformUI;
Lines 40-50 Link Here
40
42
41
public class MessagesView extends ViewPart {
43
public class MessagesView extends ViewPart {
42
44
43
	private static final SimpleDateFormat FORMATTER = new SimpleDateFormat("(hh:mm:ss a)"); //$NON-NLS-1$
45
	//private static final SimpleDateFormat FORMATTER = new SimpleDateFormat("(hh:mm:ss a)"); //$NON-NLS-1$
46
	//	private static final SimpleDateFormat FORMATTER = new SimpleDateFormat("(HH:mm:ss)"); //$NON-NLS-1$
44
47
45
	public static final String VIEW_ID = "org.eclipse.ecf.presence.ui.MessagesView"; //$NON-NLS-1$
48
	public static final String VIEW_ID = "org.eclipse.ecf.presence.ui.MessagesView"; //$NON-NLS-1$
46
49
47
	private static final int[] WEIGHTS = {75, 25};
50
	//private static final int[] WEIGHTS = {75, 25};
48
51
49
	private CTabFolder tabFolder;
52
	private CTabFolder tabFolder;
50
53
Lines 57-62 Link Here
57
	private boolean showTimestamps = true;
60
	private boolean showTimestamps = true;
58
61
59
	private static final String getUserName(ID id) {
62
	private static final String getUserName(ID id) {
63
		if (id == null)
64
			return Messages.MessagesView_broadcast;
60
		IChatID chatID = (IChatID) id.getAdapter(IChatID.class);
65
		IChatID chatID = (IChatID) id.getAdapter(IChatID.class);
61
		return chatID == null ? id.getName() : chatID.getUsername();
66
		return chatID == null ? id.getName() : chatID.getUsername();
62
	}
67
	}
Lines 86-92 Link Here
86
				while (it.hasNext()) {
91
				while (it.hasNext()) {
87
					ChatTab tab = (ChatTab) it.next();
92
					ChatTab tab = (ChatTab) it.next();
88
					if (tab.item == e.item) {
93
					if (tab.item == e.item) {
89
						tab.inputText.setFocus();
94
						if (tab.inputText != null)
95
							tab.inputText.setFocus();
90
						break;
96
						break;
91
					}
97
					}
92
				}
98
				}
Lines 147-156 Link Here
147
	}
153
	}
148
154
149
	private ChatTab getTab(IChatMessageSender messageSender, ITypingMessageSender typingSender, ID localID, ID userID) {
155
	private ChatTab getTab(IChatMessageSender messageSender, ITypingMessageSender typingSender, ID localID, ID userID) {
150
		ChatTab tab = (ChatTab) tabs.get(userID);
156
		ChatTab tab = (ChatTab) tabs.get((userID != null) ? userID : (Object) Messages.MessagesView_broadcast);
151
		if (tab == null) {
157
		if (tab == null) {
152
			tab = new ChatTab(messageSender, typingSender, localID, userID);
158
			tab = new ChatTab(messageSender, typingSender, localID, userID);
153
			tabs.put(userID, tab);
159
			tabs.put((userID != null) ? userID : (Object) Messages.MessagesView_broadcast, tab);
154
		}
160
		}
155
		return tab;
161
		return tab;
156
	}
162
	}
Lines 190-196 Link Here
190
	public synchronized void openTab(IChatMessageSender messageSender, ITypingMessageSender typingSender, ID localID, ID remoteID) {
196
	public synchronized void openTab(IChatMessageSender messageSender, ITypingMessageSender typingSender, ID localID, ID remoteID) {
191
		Assert.isNotNull(messageSender);
197
		Assert.isNotNull(messageSender);
192
		Assert.isNotNull(localID);
198
		Assert.isNotNull(localID);
193
		Assert.isNotNull(remoteID);
199
		//Assert.isNotNull(remoteID);
194
		ChatTab tab = getTab(messageSender, typingSender, localID, remoteID);
200
		ChatTab tab = getTab(messageSender, typingSender, localID, remoteID);
195
		// if there is only one tab, select this tab
201
		// if there is only one tab, select this tab
196
		if (tabs.size() == 1) {
202
		if (tabs.size() == 1) {
Lines 213-219 Link Here
213
	public synchronized void showMessage(IChatMessage message) {
219
	public synchronized void showMessage(IChatMessage message) {
214
		Assert.isNotNull(message);
220
		Assert.isNotNull(message);
215
		ID remoteID = message.getFromID();
221
		ID remoteID = message.getFromID();
216
		ChatTab tab = (ChatTab) tabs.get(remoteID);
222
		ChatTab tab = (ChatTab) tabs.get((remoteID != null) ? remoteID : (Object) Messages.MessagesView_broadcast);
217
		if (tab != null) {
223
		if (tab != null) {
218
			tab.append(remoteID, message.getBody());
224
			tab.append(remoteID, message.getBody());
219
		}
225
		}
Lines 225-231 Link Here
225
			for (Iterator it = tabs.values().iterator(); it.hasNext();) {
231
			for (Iterator it = tabs.values().iterator(); it.hasNext();) {
226
				ChatTab tab = (ChatTab) it.next();
232
				ChatTab tab = (ChatTab) it.next();
227
				if (tab.item == item) {
233
				if (tab.item == item) {
228
					tab.inputText.setFocus();
234
					if (tab.inputText != null)
235
						tab.inputText.setFocus();
229
					break;
236
					break;
230
				}
237
				}
231
			}
238
			}
Lines 234-243 Link Here
234
241
235
	private class ChatTab {
242
	private class ChatTab {
236
243
237
		private CTabItem item;
244
		/*private*/ CTabItem item;
238
245
239
		private StyledText chatText;
246
		private StyledText chatText;
240
247
248
		private MessageRenderer messageRenderer = null;
249
241
		private Text inputText;
250
		private Text inputText;
242
251
243
		private IChatMessageSender icms;
252
		private IChatMessageSender icms;
Lines 261-303 Link Here
261
		}
270
		}
262
271
263
		private void addListeners() {
272
		private void addListeners() {
264
			inputText.addKeyListener(new KeyAdapter() {
273
			if (remoteID != null)
265
				public void keyPressed(KeyEvent e) {
274
				inputText.addKeyListener(new KeyAdapter() {
266
					switch (e.keyCode) {
275
					public void keyPressed(KeyEvent e) {
267
						case SWT.CR :
276
						switch (e.keyCode) {
268
						case SWT.KEYPAD_CR :
277
							case SWT.CR :
269
							if (e.stateMask == 0) {
278
							case SWT.KEYPAD_CR :
270
								String text = inputText.getText();
279
								if (e.stateMask == 0) {
271
								inputText.setText(""); //$NON-NLS-1$
280
									String text = inputText.getText();
272
								try {
281
									inputText.setText(""); //$NON-NLS-1$
273
									if (!text.equals("")) { //$NON-NLS-1$
282
									try {
274
										icms.sendChatMessage(remoteID, text);
283
										if (!text.equals("")) { //$NON-NLS-1$
284
											icms.sendChatMessage(remoteID, text);
285
										}
286
										append(localID, text);
287
									} catch (ECFException ex) {
288
										setContentDescription(Messages.MessagesView_CouldNotSendMessage);
275
									}
289
									}
276
									append(localID, text);
290
									e.doit = false;
277
								} catch (ECFException ex) {
291
									sendTyping = false;
278
									setContentDescription(Messages.MessagesView_CouldNotSendMessage);
279
								}
292
								}
280
								e.doit = false;
293
								break;
281
								sendTyping = false;
294
						}
282
							}
283
							break;
284
					}
295
					}
285
				}
296
				});
286
			});
287
297
288
			inputText.addModifyListener(new ModifyListener() {
298
			if (remoteID != null)
289
				public void modifyText(ModifyEvent e) {
299
				inputText.addModifyListener(new ModifyListener() {
290
					if (!sendTyping && itms != null) {
300
					public void modifyText(ModifyEvent e) {
291
						sendTyping = true;
301
						if (!sendTyping && itms != null) {
292
						try {
302
							sendTyping = true;
293
							itms.sendTypingMessage(remoteID, true, null);
303
							try {
294
						} catch (ECFException ex) {
304
								itms.sendTypingMessage(remoteID, true, null);
295
							// ignored since this is not really that important
305
							} catch (ECFException ex) {
296
							return;
306
								// ignored since this is not really that important
307
								return;
308
							}
297
						}
309
						}
298
					}
310
					}
299
				}
311
				});
300
			});
301
312
302
			ScrollBar vscrollBar = chatText.getVerticalBar();
313
			ScrollBar vscrollBar = chatText.getVerticalBar();
303
			if (vscrollBar != null) {
314
			if (vscrollBar != null) {
Lines 334-353 Link Here
334
		private void append(ID fromID, String body) {
345
		private void append(ID fromID, String body) {
335
			boolean scrollToEnd = shouldScrollToEnd(chatText);
346
			boolean scrollToEnd = shouldScrollToEnd(chatText);
336
347
337
			if (!isFirstMessage) {
348
			//if (!isFirstMessage) {
338
				chatText.append(Text.DELIMITER);
349
			//	chatText.append(Text.DELIMITER);
339
			}
350
			//}
340
			int length = chatText.getCharCount();
351
			//int length = chatText.getCharCount();
341
			String name = getUserName(fromID);
352
			String name = getUserName(fromID);
342
			if (fromID.equals(remoteID)) {
353
			String local = getUserName(localID);
343
				if (showTimestamps) {
354
344
					chatText.append(FORMATTER.format(new Date(System.currentTimeMillis())) + ' ');
355
			String output = messageRenderer.render(body, (fromID!=null)? name:null, local);
345
					chatText.setStyleRange(new StyleRange(length, 13, redColor, null));
356
			StyleRange[] ranges = messageRenderer.getStyleRanges();
346
					length = chatText.getCharCount();
357
347
				}
358
			if (fromID == remoteID || fromID.equals(remoteID)) {
348
				chatText.append(name + ": " + body); //$NON-NLS-1$
359
//				if (showTimestamps) {
349
				chatText.setStyleRange(new StyleRange(length, name.length() + 1, redColor, null, SWT.BOLD));
360
//					//chatText.append(FORMATTER.format(new Date(System.currentTimeMillis())) + ' ');
350
				setContentDescription(""); //$NON-NLS-1$
361
//					//chatText.setStyleRange(new StyleRange(length, 13, redColor, null));
362
//					String text = FORMATTER.format(new Date(System.currentTimeMillis())) + ' ';
363
//					chatText.append(text);
364
//					chatText.setStyleRange(new StyleRange(length, text.length(), redColor, null));
365
//					length = chatText.getCharCount();
366
//				}
367
//				if (remoteID != null) {
368
//					chatText.append(name + ": "); //$NON-NLS-1$
369
//					//chatText.append(body);
370
//					{
371
//						int posStyleRange = chatLink.scan(body);
372
//						chatText.append(body);
373
//						chatLink.setStyleRange(posStyleRange);
374
//					}
375
//					chatText.setStyleRange(new StyleRange(length, name.length() + 1, redColor, null, SWT.BOLD));
376
//				} else {
377
//					//chatText.append(body);
378
//					{
379
//						int posStyleRange = chatLink.scan(body);
380
//						chatText.append(body);
381
//						chatLink.setStyleRange(posStyleRange);
382
//					}
383
//					chatText.setStyleRange(new StyleRange(length, 0, redColor, null, SWT.BOLD));
384
//				}
385
//				setContentDescription(""); //$NON-NLS-1$
351
				if (isFirstMessage) {
386
				if (isFirstMessage) {
352
					final MessageNotificationPopup popup = new MessageNotificationPopup(getSite().getWorkbenchWindow(), tabFolder.getShell(), remoteID);
387
					final MessageNotificationPopup popup = new MessageNotificationPopup(getSite().getWorkbenchWindow(), tabFolder.getShell(), remoteID);
353
					popup.setContent(name, body);
388
					popup.setContent(name, body);
Lines 364-378 Link Here
364
					}.schedule(5000);
399
					}.schedule(5000);
365
				}
400
				}
366
			} else {
401
			} else {
367
				if (showTimestamps) {
402
//				if (showTimestamps) {
368
					chatText.append(FORMATTER.format(new Date(System.currentTimeMillis())) + ' ');
403
//					//chatText.append(FORMATTER.format(new Date(System.currentTimeMillis())) + ' ');
369
					chatText.setStyleRange(new StyleRange(length, 13, blueColor, null));
404
//					//chatText.setStyleRange(new StyleRange(length, 13, blueColor, null));
370
					length = chatText.getCharCount();
405
//					String text = FORMATTER.format(new Date(System.currentTimeMillis())) + ' ';
371
				}
406
//					chatText.append(text);
372
				chatText.append(name + ": " + body); //$NON-NLS-1$
407
//					chatText.setStyleRange(new StyleRange(length, text.length(), blueColor, null));
373
				chatText.setStyleRange(new StyleRange(length, name.length() + 1, blueColor, null, SWT.BOLD));
408
//					length = chatText.getCharCount();
409
//				}
410
//				chatText.append(name + ": "); //$NON-NLS-1$
411
//				//chatText.append(body);
412
//				{
413
//					int posStyleRange = chatLink.scan(body);
414
//					chatText.append(body);
415
//					chatLink.setStyleRange(posStyleRange);
416
//				}
417
//				chatText.setStyleRange(new StyleRange(length, name.length() + 1, blueColor, null, SWT.BOLD));
374
			}
418
			}
375
			isFirstMessage = false;
419
			isFirstMessage = false;
420
421
			if (output == null) {
422
				return;
423
			}
424
425
			int startRange = chatText.getText().length();
426
427
			if (!body.endsWith("\n")) {
428
				output += "\n"; //$NON-NLS-1$
429
			}
430
431
			chatText.append(output);
432
433
			if (ranges != null) {
434
435
				// set all ranges to start as message line starts
436
				for (int i = 0; i < ranges.length; i++) {
437
					ranges[i].start += startRange;
438
				}
439
				chatText.replaceStyleRanges(startRange, output.length(), ranges);
440
			}
441
376
			if (scrollToEnd)
442
			if (scrollToEnd)
377
				chatText.invokeAction(ST.TEXT_END);
443
				chatText.invokeAction(ST.TEXT_END);
378
			boldTabTitle(!scrollToEnd);
444
			boldTabTitle(!scrollToEnd);
Lines 404-416 Link Here
404
			Composite parent = new Composite(tabFolder, SWT.NONE);
470
			Composite parent = new Composite(tabFolder, SWT.NONE);
405
			parent.setLayout(new FillLayout());
471
			parent.setLayout(new FillLayout());
406
472
407
			SashForm sash = new SashForm(parent, SWT.VERTICAL);
473
			if (remoteID != null) {
408
474
				//SashForm sash = new SashForm(parent, SWT.VERTICAL);
409
			chatText = createStyledTextWidget(sash);
475
				Composite composite = new Composite(parent, SWT.NONE);
476
				GridLayout layout = new GridLayout();
477
				layout.marginWidth = 0;
478
				layout.marginHeight = 0;
479
				layout.marginHeight = 0;
480
				layout.verticalSpacing = 3;
481
				layout.horizontalSpacing = 3;
482
				composite.setLayout(layout);
483
484
				chatText = createStyledTextWidget(/*sash*/composite);
485
				chatText.setLayoutData(new GridData(GridData.FILL_BOTH));
486
487
				inputText = new Text(/*sash*/composite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.WRAP);
488
				GridData gd = new GridData(GridData.FILL_HORIZONTAL);
489
				GC gc = new GC(inputText);
490
				gc.setFont(JFaceResources.getDialogFont());
491
				FontMetrics fontMetrics = gc.getFontMetrics();
492
				gc.dispose();
493
				gd.heightHint = fontMetrics.getHeight() * 2;
494
				inputText.setLayoutData(gd);
410
495
411
			inputText = new Text(sash, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL);
496
				//sash.setWeights(WEIGHTS);
497
			} else {
498
				chatText = createStyledTextWidget(parent);
499
			}
412
500
413
			sash.setWeights(WEIGHTS);
501
			messageRenderer = new MessageRenderer();
414
502
415
			Menu menu = new Menu(chatText);
503
			Menu menu = new Menu(chatText);
416
			MenuItem mi = new MenuItem(menu, SWT.PUSH);
504
			MenuItem mi = new MenuItem(menu, SWT.PUSH);
(-)src/org/eclipse/ecf/presence/ui/RosterWorkbenchAdapterFactory.java (+3 lines)
Lines 175-180 Link Here
175
				// available
175
				// available
176
				if (pMode.equals(IPresence.Mode.AVAILABLE))
176
				if (pMode.equals(IPresence.Mode.AVAILABLE))
177
					return getImageDescriptor(SharedImages.IMG_USER_AVAILABLE);
177
					return getImageDescriptor(SharedImages.IMG_USER_AVAILABLE);
178
				// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=223290
179
				else if (pMode.equals(IPresence.Mode.CHAT))
180
					return getImageDescriptor(SharedImages.IMG_USER_AVAILABLE);
178
				// If mode is away then we're away
181
				// If mode is away then we're away
179
				else if (pMode.equals(IPresence.Mode.AWAY) || pMode.equals(IPresence.Mode.EXTENDED_AWAY))
182
				else if (pMode.equals(IPresence.Mode.AWAY) || pMode.equals(IPresence.Mode.EXTENDED_AWAY))
180
					return getImageDescriptor(SharedImages.IMG_USER_AWAY);
183
					return getImageDescriptor(SharedImages.IMG_USER_AWAY);

Return to bug 222253