use of org.eclipse.ecf.core.user.IUser in project ecf by eclipse.
the class AbstractActionDelegate method run.
public void run(IAction action) {
if ((chatRoomContainer == null) || (selection == null)) {
return;
}
try {
Iterator iterator = selection.iterator();
while (iterator.hasNext()) {
IUser user = (IUser) iterator.next();
String message = getMessage(getUsername(user));
chatRoomContainer.getChatRoomMessageSender().sendMessage(message);
}
} catch (ECFException e) {
StatusManager.getManager().handle(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));
}
}
use of org.eclipse.ecf.core.user.IUser in project ecf by eclipse.
the class DocShareRosterMenuHandler method execute.
/**
* @throws ExecutionException
*/
public Object execute(ExecutionEvent arg0) throws ExecutionException {
IRosterEntry rosterEntry = getRosterEntry();
if (rosterEntry != null) {
IRoster roster = rosterEntry.getRoster();
final IContainer container = (IContainer) roster.getPresenceContainerAdapter().getAdapter(IContainer.class);
if (container.getConnectedID() == null)
showErrorMessage(Messages.DocShareRosterMenuHandler_ERROR_NOT_CONNECTED);
final DocShare sender = Activator.getDefault().getDocShare(container.getID());
if (sender == null)
showErrorMessage(Messages.DocShareRosterMenuHandler_ERROR_NO_SENDER);
if (sender.isSharing())
showErrorMessage(Messages.DocShareRosterMenuHandler_ERROR_EDITOR_ALREADY_SHARING);
final ITextEditor textEditor = getTextEditor();
if (textEditor == null)
showErrorMessage(Messages.DocShareRosterMenuHandler_EXCEPTION_EDITOR_NOT_TEXT);
final String inputName = getInputName(textEditor);
if (inputName == null)
showErrorMessage(Messages.DocShareRosterMenuHandler_NO_FILENAME_WITH_CONTENT);
final IUser user = roster.getUser();
sender.startShare(user.getID(), user.getName(), rosterEntry.getUser().getID(), inputName, textEditor);
}
return null;
}
use of org.eclipse.ecf.core.user.IUser in project ecf by eclipse.
the class SharedObjectContainerUI method getUserData.
protected IUser getUserData(String containerType, ID clientID, String usernick, IResource project) {
final Map topElements = new HashMap();
topElements.put(Messages.SharedObjectContainerUI_PROJECT_LABEL, CollabClient.getNameForResource(project));
final SimpleDateFormat sdf = new SimpleDateFormat(JOIN_TIME_FORMAT);
topElements.put(Messages.SharedObjectContainerUI_TIME_LABEL, sdf.format(new Date()));
try {
// $NON-NLS-1$
topElements.put(Messages.SharedObjectContainerUI_LANGUAGE_LABEL, System.getProperty("user.language"));
} catch (final Exception e) {
}
try {
// $NON-NLS-1$
topElements.put(Messages.SharedObjectContainerUI_TIME_ZONE_LABEL, System.getProperty("user.timezone"));
} catch (final Exception e) {
}
try {
topElements.put(Messages.SharedObjectContainerUI_OS_LABEL, Platform.getOS());
} catch (final Exception e) {
}
try {
// $NON-NLS-1$ //$NON-NLS-2$
topElements.put("Username", System.getProperty("user.name"));
} catch (final Exception e) {
}
try {
// $NON-NLS-1$
topElements.put("Hostname/IP", InetAddress.getLocalHost().toString());
} catch (final Exception e) {
}
return new User(clientID, usernick, usernick, topElements);
}
use of org.eclipse.ecf.core.user.IUser in project ecf by eclipse.
the class SharedObjectContainerUI method addObjectToClient.
void addObjectToClient(ISharedObjectContainer soContainer, ClientEntry client, String username, IResource proj) throws Exception {
final IResource project = (proj == null) ? CollabClient.getWorkspace() : proj;
final IUser user = getUserData(client.getClass().getName(), client.getContainer().getID(), username, proj);
createAndAddSharedObject(soContainer, client, project, user, getSharedFileDirectoryForProject(project));
}
use of org.eclipse.ecf.core.user.IUser in project ecf by eclipse.
the class XMPPContainerPresenceHelper method updatePresenceForMatchingEntry.
private AdditionalClientRosterEntry updatePresenceForMatchingEntry(org.eclipse.ecf.presence.roster.RosterEntry entry, XMPPID fromID, IPresence newPresence) {
final IUser user = entry.getUser();
XMPPID oldID = (XMPPID) user.getID();
// the resource, or create a new client
if (oldID.equals(fromID)) {
if (newPresence.getType() == IPresence.Type.UNAVAILABLE) {
return removeEntryFromRoster(oldID, entry, newPresence, user);
} else {
// set the new presence state
entry.setPresence(newPresence);
// and notify with roster update
rosterManager.notifyRosterUpdate(entry);
}
} else if (oldID.getUsernameAtHost().equals(fromID.getUsernameAtHost())) {
if (oldID.getResourceName() == null) {
oldID.setResourceName(fromID.getResourceName());
// set the new presence state
entry.setPresence(newPresence);
// and notify with roster update
rosterManager.notifyRosterUpdate(entry);
} else if (fromID.getResourceName() != null && !newPresence.getType().equals(IPresence.Type.UNAVAILABLE)) {
return new AdditionalClientRosterEntry(entry.getParent(), new User(fromID, user.getName()), newPresence);
}
}
return null;
}
Aggregations