use of org.eclipse.ecf.presence.roster.IRosterEntry 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.presence.roster.IRosterEntry in project ecf by eclipse.
the class BrowseHandler method execute.
/**
* the command has been executed, so extract extract the needed information
* from the application context.
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
IContainerManager containerManager = Activator.getDefault().getContainerManager();
IContainer[] containers = containerManager.getAllContainers();
BrowseDialog dialog = new BrowseDialog(window.getShell(), containers);
int status = dialog.open();
if (status == Window.OK) {
Object[] object = dialog.getResult();
IRosterEntry entry = (IRosterEntry) object[0];
IRoster roster = entry.getRoster();
if (roster != null) {
IChatManager manager = roster.getPresenceContainerAdapter().getChatManager();
IChatMessageSender icms = manager.getChatMessageSender();
ITypingMessageSender itms = manager.getTypingMessageSender();
try {
MessagesView view = (MessagesView) window.getActivePage().showView(MessagesView.VIEW_ID);
view.selectTab(icms, itms, roster.getUser().getID(), entry.getUser().getID(), entry.getUser().getName());
} catch (PartInitException e) {
e.printStackTrace();
}
}
}
return null;
}
use of org.eclipse.ecf.presence.roster.IRosterEntry in project ecf by eclipse.
the class ScreenCaptureShareRosterEntryContributionItem method makeActions.
protected IAction[] makeActions() {
// Else check for Roster entry
final IRosterEntry entry = getSelectedRosterEntry();
final IContainer c = getContainerForRosterEntry(entry);
// If roster entry is selected and it has a container
if (entry != null && c != null) {
final IChannelContainerAdapter channelAdapter = (IChannelContainerAdapter) c.getAdapter(IChannelContainerAdapter.class);
// If the container has channel container adapter and is online/available
if (channelAdapter != null && isAvailable(entry)) {
final ScreenCaptureShare tmp = ScreenCaptureShare.getScreenCaptureShare(c.getID());
// If there is an URL share associated with this container
if (tmp != null) {
final ScreenCaptureShare screencaptureshare = tmp;
final IAction action = new Action() {
public void run() {
MessageDialog dialog = new MessageDialog(null, Messages.ScreenCaptureShareRosterEntryContributionItem_SCREEN_CAPTURE_MESSAGEBOX_TITLE, Window.getDefaultImage(), Messages.ScreenCaptureShareRosterEntryContributionItem_SCREEN_CAPTURE_MESSAGEBOX_MESSAGE, MessageDialog.QUESTION, new String[] { NLS.bind(Messages.ScreenCaptureShareRosterEntryContributionItem_VERIFY_SEND_BUTTON_TEXT, entry.getName()), Messages.ScreenCaptureShareRosterEntryContributionItem_VERIFY_CANCEL_BUTTON_TEXT }, 0);
if (dialog.open() == Window.OK) {
ScreenCaptureJob screenCaptureJob = new ScreenCaptureJob(Display.getCurrent(), entry.getUser().getID(), entry.getUser().getName(), new IImageSender() {
public void sendImage(ID targetID, ImageData imageData) {
screencaptureshare.sendImage(entry.getRoster().getUser().getID(), entry.getRoster().getUser().getName(), targetID, imageData);
}
});
screenCaptureJob.schedule(SCREEN_CAPTURE_DELAY);
}
}
};
action.setText(Messages.ScreenCaptureShareRosterEntryContributionItem_SCREEN_CAPTURE_MENU);
action.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_DEF_VIEW));
return new IAction[] { action };
}
}
}
return null;
}
use of org.eclipse.ecf.presence.roster.IRosterEntry in project ecf by eclipse.
the class XMPPContainerPresenceHelper method updatePresence.
private void updatePresence(XMPPID fromID, IPresence newPresence) {
final Collection rosterItems = roster.getItems();
List newEntrys = new ArrayList();
synchronized (rosterItems) {
for (final Iterator i = roster.getItems().iterator(); i.hasNext(); ) {
final IRosterItem item = (IRosterItem) i.next();
if (item instanceof IRosterGroup) {
AdditionalClientRosterEntry[] es = updatePresenceInGroup((IRosterGroup) item, fromID, newPresence);
for (int j = 0; j < es.length; j++) {
newEntrys.add(es[j]);
}
} else if (item instanceof org.eclipse.ecf.presence.roster.RosterEntry) {
AdditionalClientRosterEntry entry = updatePresenceForMatchingEntry((org.eclipse.ecf.presence.roster.RosterEntry) item, fromID, newPresence);
if (entry != null)
newEntrys.add(entry);
}
}
}
AdditionalClientRosterEntry[] entrys = (AdditionalClientRosterEntry[]) newEntrys.toArray(new AdditionalClientRosterEntry[] {});
if (entrys.length > 0) {
for (int i = 0; i < entrys.length; i++) {
if (entrys[i].add) {
IRosterEntry entry = new org.eclipse.ecf.presence.roster.RosterEntry(entrys[i].parent, entrys[i].user, entrys[i].presence);
addUniqueToRoster(new IRosterItem[] { entry });
fireSetRosterEntry(false, entry);
} else {
removeItemFromRoster(rosterItems, fromID);
}
}
}
}
use of org.eclipse.ecf.presence.roster.IRosterEntry in project ecf by eclipse.
the class XMPPContainerPresenceHelper method replace.
private boolean replace(IRosterItem i1, IRosterItem i2) {
if (i1 instanceof IRosterEntry) {
IRosterEntry re1 = (IRosterEntry) i1;
if (!(i2 instanceof IRosterEntry))
return false;
IRosterEntry re2 = (IRosterEntry) i2;
XMPPID id1 = (XMPPID) re1.getUser().getID();
XMPPID id2 = (XMPPID) re2.getUser().getID();
String jid1 = id1.getUsernameAtHost();
String jid2 = id2.getUsernameAtHost();
if (jid1.equals(jid2)) {
String r1 = id1.getResourceName();
String r2 = id2.getResourceName();
if (r1 == null && r2 != null)
return true;
}
}
return false;
}
Aggregations