use of org.eclipse.ecf.presence.IPresenceContainerAdapter in project ecf by eclipse.
the class BrowseDialog method fillContentProvider.
/* (non-Javadoc)
* @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#fillContentProvider(org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.AbstractContentProvider, org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.ItemsFilter, org.eclipse.core.runtime.IProgressMonitor)
*/
protected void fillContentProvider(AbstractContentProvider contentProvider, ItemsFilter itemsFilter, IProgressMonitor progressMonitor) {
progressMonitor.beginTask(Messages.BrowseDialog_scanning, containers.length);
// cycle through all the containers and grab entries
for (int i = 0; i < containers.length; i++) {
IContainer container = containers[i];
IPresenceContainerAdapter presenceContainer = (IPresenceContainerAdapter) container.getAdapter(IPresenceContainerAdapter.class);
if (presenceContainer != null) {
IRosterManager manager = presenceContainer.getRosterManager();
if (manager != null) {
Collection items = manager.getRoster().getItems();
for (Iterator it = items.iterator(); it.hasNext(); ) {
IRosterItem item = (IRosterItem) it.next();
addRosterItem(item, contentProvider, itemsFilter);
}
}
}
progressMonitor.worked(1);
}
progressMonitor.done();
}
use of org.eclipse.ecf.presence.IPresenceContainerAdapter in project ecf by eclipse.
the class AbstractRosterMenuContributionItem method getPresenceContainerAdapters.
protected List getPresenceContainerAdapters() {
List presenceContainers = new ArrayList();
IContainerManager containerManager = Activator.getDefault().getContainerManager();
if (containerManager == null)
return presenceContainers;
IContainer[] containers = containerManager.getAllContainers();
for (int i = 0; i < containers.length; i++) {
IPresenceContainerAdapter presenceContainerAdapter = (IPresenceContainerAdapter) containers[i].getAdapter(IPresenceContainerAdapter.class);
if ((containers[i].getConnectedID() != null) && (presenceContainerAdapter != null)) {
presenceContainers.add(presenceContainerAdapter);
}
}
return presenceContainers;
}
use of org.eclipse.ecf.presence.IPresenceContainerAdapter in project ecf by eclipse.
the class XMPPHyperlink method chooseAccount.
/**
* @param adapters
*/
private void chooseAccount(final IContainer[] containers) {
// If there's only one choice then use it
if (containers.length == 1) {
openContainer(containers[0]);
return;
} else {
final IPresenceContainerAdapter[] adapters = new IPresenceContainerAdapter[containers.length];
for (int i = 0; i < containers.length; i++) adapters[i] = (IPresenceContainerAdapter) containers[i].getAdapter(IPresenceContainerAdapter.class);
final ListDialog dialog = new ListDialog(null);
dialog.setContentProvider(new IStructuredContentProvider() {
public Object[] getElements(Object inputElement) {
return adapters;
}
public void dispose() {
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
dialog.setInput(adapters);
dialog.setAddCancelButton(true);
dialog.setBlockOnOpen(true);
dialog.setTitle(Messages.XMPPHyperlink_SELECT_ACCOUNT_TITLE);
dialog.setMessage(Messages.XMPPHyperlink_SELECT_ACCOUNT_MESSAGE);
dialog.setHeightInChars(adapters.length > 4 ? adapters.length : 4);
dialog.setInitialSelections(new IPresenceContainerAdapter[] { adapters[0] });
dialog.setLabelProvider(new ILabelProvider() {
public Image getImage(Object element) {
return null;
}
public String getText(Object element) {
final IRosterManager manager = ((IPresenceContainerAdapter) element).getRosterManager();
if (manager == null)
return null;
return manager.getRoster().getUser().getID().getName();
}
public void addListener(ILabelProviderListener listener) {
}
public void dispose() {
}
public boolean isLabelProperty(Object element, String property) {
return false;
}
public void removeListener(ILabelProviderListener listener) {
}
});
final int result = dialog.open();
if (result == ListDialog.OK) {
final Object[] res = dialog.getResult();
if (res.length > 0)
openContainer((IContainer) res[0]);
}
}
}
Aggregations