use of org.eclipse.ecf.core.user.IUser in project ecf by eclipse.
the class ChatComposite method appendText.
public void appendText(ChatLine text) {
if (text == null || textoutput == null || textoutput.isDisposed()) {
return;
}
final IUser user = text.getOriginator();
final StyleRange range = new StyleRange();
range.start = textoutput.getText().length();
if (user != null) {
// $NON-NLS-1$
String prefix = user.getNickname() + ": ";
final String date = text.getDate();
if (date != null && !date.equals("")) {
// $NON-NLS-1$
prefix = date + ' ' + prefix;
}
range.length = prefix.length();
range.foreground = user.equals(view.userdata) ? meColor : otherColor;
textoutput.append(prefix);
textoutput.setStyleRange(range);
textoutput.append(text.getText());
} else {
String content = text.getText();
final String date = text.getDate();
if (date != null && !date.equals("")) {
// $NON-NLS-1$
content = date + ' ' + content;
}
range.length = content.length();
range.foreground = otherColor;
textoutput.append(content);
}
if (!text.isNoCRLF()) {
textoutput.append(Text.DELIMITER);
}
// scroll to end
final String t = textoutput.getText();
if (t != null) {
textoutput.setSelection(t.length());
}
}
use of org.eclipse.ecf.core.user.IUser in project ecf by eclipse.
the class LineChatClientView method removeUserFromTree.
protected void removeUserFromTree(ID id) {
if (id == null) {
return;
} else {
for (int i = 0; i < users.size(); i++) {
final IUser user = (IUser) users.get(i);
if (user.getID().equals(id)) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
if (!teamChat.isDisposed())
teamChat.getTableViewer().remove(user);
}
});
users.remove(i);
break;
}
}
}
}
use of org.eclipse.ecf.core.user.IUser in project ecf by eclipse.
the class CompareWithHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
IRosterEntry selectedEntry = getRosterEntry();
IRoster roster = selectedEntry.getRoster();
final IUser remoteUser = roster.getUser();
ID localId = remoteUser.getID();
ID remoteId = selectedEntry.getUser().getID();
IContainer container = (IContainer) roster.getPresenceContainerAdapter().getAdapter(IContainer.class);
final IResource resource = getResource(event);
if (resource == null) {
MessageDialog.openInformation(HandlerUtil.getActiveShell(event), null, Messages.CompareWithHandler_FileNotSelectedError);
return null;
}
RemoteShare share = TeamSynchronization.getShare(container.getID());
final RemoteResourceVariantTreeSubscriber subscriber = new RemoteResourceVariantTreeSubscriber(share, localId, remoteId);
Job job = new Job(Messages.CompareWithHandler_ResourceComparisonJobTitle) {
protected IStatus run(IProgressMonitor monitor) {
try {
openCompareEditor(subscriber.getSyncInfo(resource, monitor), remoteUser);
return Status.OK_STATUS;
} catch (TeamException e) {
return e.getStatus();
}
}
};
job.setUser(true);
job.schedule();
return null;
}
use of org.eclipse.ecf.core.user.IUser in project ecf by eclipse.
the class XMPPUserSearchManager method createResultList.
/**
* Create a result list from ReportedData. Identify dynamically columns and
* rows and create users adding it to a {@link IResultList}
*
* @param data
* ReportedData
* @return {@link IResultList} a list of users
* @throws
*/
protected IResultList createResultList(ReportedData data) {
ResultList result = new ResultList();
Iterator rows = data.getRows();
while (rows.hasNext()) {
Row row = (Row) rows.next();
Iterator jids = row.getValues(JID);
Iterator names = row.getValues(NAME);
String jid = null;
String name = null;
// XMPP server returns the same length for both
while (jids.hasNext() && names.hasNext()) {
try {
jid = (String) jids.next();
name = (String) names.next();
IUser user = new User(new XMPPID(connectNamespace, jid), name);
result.add(new XMPPResultItem(user));
} catch (URISyntaxException e) {
throw new RuntimeException(// $NON-NLS-1$
"cannot create connect id for client " + jid + " , name = " + name, // $NON-NLS-1$
e);
}
}
}
return result;
}
use of org.eclipse.ecf.core.user.IUser in project ecf by eclipse.
the class ChatRoomManagerView method doJoinRoom.
protected void doJoinRoom(final IChatRoomInfo roomInfo, final String password) {
final ID targetRoomID = roomInfo.getRoomID();
final String targetRoomName = targetRoomID.getName();
// first, check to see if we already have it open. If so just activate
ChatRoom room = (ChatRoom) chatRooms.get(targetRoomName);
if (room != null && room.isConnected()) {
room.setSelected();
return;
}
// Then we create a new chatRoomContainer from the roomInfo
try {
final IChatRoomContainer chatRoomContainer = roomInfo.createChatRoomContainer();
// Setup new user interface (new tab)
final ChatRoom chatroom = new ChatRoom(chatRoomContainer, new ChatRoomTab(rootTabFolder, targetRoomName));
// setup message listener
chatRoomContainer.addMessageListener(new IIMMessageListener() {
public void handleMessageEvent(IIMMessageEvent messageEvent) {
if (messageEvent instanceof IChatRoomMessageEvent) {
IChatRoomMessage m = ((IChatRoomMessageEvent) messageEvent).getChatRoomMessage();
chatroom.handleMessage(m.getFromID(), m.getMessage());
}
}
});
// setup participant listener
chatRoomContainer.addChatRoomParticipantListener(new IChatRoomParticipantListener() {
public void handlePresenceUpdated(ID fromID, IPresence presence) {
chatroom.handlePresence(fromID, presence);
}
public void handleArrived(IUser participant) {
// do nothing
}
public void handleUpdated(IUser updatedParticipant) {
// do nothing
}
public void handleDeparted(IUser participant) {
// do nothing
}
});
chatRoomContainer.addListener(new IContainerListener() {
public void handleEvent(IContainerEvent evt) {
if (evt instanceof IContainerDisconnectedEvent || evt instanceof IContainerEjectedEvent) {
chatroom.disconnected();
}
}
});
// Now connect/join
Display.getDefault().asyncExec(new Runnable() {
public void run() {
try {
chatRoomContainer.connect(targetRoomID, ConnectContextFactory.createPasswordConnectContext(password));
chatRooms.put(targetRoomName, chatroom);
} catch (Exception e) {
// $NON-NLS-1$
MessageDialog.openError(// $NON-NLS-1$
getSite().getShell(), // $NON-NLS-1$
"Connect Error", // $NON-NLS-1$
NLS.bind(// $NON-NLS-1$
"Could not connect to {0}.\n\nError is {1}.", targetRoomName, e.getLocalizedMessage()));
}
}
});
} catch (Exception e) {
// $NON-NLS-1$
MessageDialog.openError(// $NON-NLS-1$
getSite().getShell(), // $NON-NLS-1$
"Container Create Error", // $NON-NLS-1$
NLS.bind(// $NON-NLS-1$
"Could not create chatRoomContainer for {0}.\n\nError is {1}.", targetRoomName, e.getLocalizedMessage()));
}
}
Aggregations