Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 122604 Details for
Bug 256696
[presence] Support XMPP Search (XEP-0055)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
User search API
patch.txt (text/plain), 95.97 KB, created by
Marcelo Mayworm
on 2009-01-14 17:38:40 EST
(
hide
)
Description:
User search API
Filename:
MIME Type:
Creator:
Marcelo Mayworm
Created:
2009-01-14 17:38:40 EST
Size:
95.97 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ecf.provider.msn >Index: src/org/eclipse/ecf/internal/provider/msn/MSNContainer.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.ecf/providers/bundles/org.eclipse.ecf.provider.msn/src/org/eclipse/ecf/internal/provider/msn/MSNContainer.java,v >retrieving revision 1.31 >diff -u -r1.31 MSNContainer.java >--- src/org/eclipse/ecf/internal/provider/msn/MSNContainer.java 3 Nov 2007 12:58:41 -0000 1.31 >+++ src/org/eclipse/ecf/internal/provider/msn/MSNContainer.java 14 Jan 2009 22:31:20 -0000 >@@ -63,6 +63,11 @@ > import org.eclipse.ecf.presence.roster.IRosterManager; > import org.eclipse.ecf.presence.roster.IRosterSubscriptionListener; > import org.eclipse.ecf.presence.roster.IRosterSubscriptionSender; >+import org.eclipse.ecf.presence.search.ICriteria; >+import org.eclipse.ecf.presence.search.ISearch; >+import org.eclipse.ecf.presence.search.ISelection; >+import org.eclipse.ecf.presence.search.IUserSearchListener; >+import org.eclipse.ecf.presence.search.IUserSearchManager; > import org.eclipse.ecf.presence.service.IPresenceService; > import org.eclipse.ecf.protocol.msn.ChatSession; > import org.eclipse.ecf.protocol.msn.Contact; >@@ -758,4 +763,48 @@ > return null; > } > >+ /** >+ * TODO Implement a User Search Manager for MSN >+ * for while it just returns a manger >+ * to inform that user search is not allow >+ * for this provider see {@link IUserSearchManager#isEnabled()} >+ */ >+ public IUserSearchManager getUserSearchManager() { >+ return new IUserSearchManager(){ >+ >+ public ICriteria createCriteria() { >+ // TODO Auto-generated method stub >+ return null; >+ } >+ >+ public ISelection createSelection() { >+ // TODO Auto-generated method stub >+ return null; >+ } >+ >+ public String[] getUserPropertiesFields() >+ throws ContainerConnectException { >+ // TODO Auto-generated method stub >+ return null; >+ } >+ >+ public boolean isEnabled() { >+ // TODO Auto-generated method stub >+ return false; >+ } >+ >+ public ISearch search(ICriteria criteria) >+ throws ContainerConnectException { >+ // TODO Auto-generated method stub >+ return null; >+ } >+ >+ public void search(IUserSearchListener listener) { >+ // TODO Auto-generated method stub >+ >+ } >+ >+ }; >+ } >+ > } >#P org.eclipse.ecf.tests.presence >Index: src/org/eclipse/ecf/tests/presence/AbstractSearchTest.java >=================================================================== >RCS file: src/org/eclipse/ecf/tests/presence/AbstractSearchTest.java >diff -N src/org/eclipse/ecf/tests/presence/AbstractSearchTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/tests/presence/AbstractSearchTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,23 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Marcelo Mayworm. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: Marcelo Mayworm - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.ecf.tests.presence; >+ >+ >+public abstract class AbstractSearchTest extends AbstractPresenceTestCase { >+ >+ public static final int CLIENT_COUNT = 1; >+ public static final int WAITTIME = 3000; >+ >+ protected void setUp() throws Exception { >+ setClientCount(CLIENT_COUNT); >+ clients = createClients(); >+ } >+ >+} >#P org.eclipse.ecf.tests.provider.xmpp >Index: src/org/ecllpse/ecf/tests/provider/xmpp/search/XMPPSearchTest.java >=================================================================== >RCS file: src/org/ecllpse/ecf/tests/provider/xmpp/search/XMPPSearchTest.java >diff -N src/org/ecllpse/ecf/tests/provider/xmpp/search/XMPPSearchTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/ecllpse/ecf/tests/provider/xmpp/search/XMPPSearchTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,210 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Marcelo Mayworm. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: Marcelo Mayworm - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.ecllpse.ecf.tests.provider.xmpp.search; >+ >+import java.util.Iterator; >+ >+import org.eclipse.ecf.core.ContainerConnectException; >+import org.eclipse.ecf.core.IContainer; >+import org.eclipse.ecf.core.identity.ID; >+import org.eclipse.ecf.presence.search.ICriteria; >+import org.eclipse.ecf.presence.search.ICriterion; >+import org.eclipse.ecf.presence.search.IResult; >+import org.eclipse.ecf.presence.search.IResultList; >+import org.eclipse.ecf.presence.search.ISearch; >+import org.eclipse.ecf.presence.search.ISelection; >+import org.eclipse.ecf.presence.search.IUserSearchManager; >+import org.eclipse.ecf.tests.presence.AbstractSearchTest; >+import org.ecllpse.ecf.tests.provider.xmpp.XMPP; >+ >+public class XMPPSearchTest extends AbstractSearchTest { >+ >+ IContainer client; >+ IUserSearchManager searchManager; >+ >+ protected String getClientContainerName() { >+ return XMPP.CONTAINER_NAME; >+ } >+ >+ public void testRetrieveBuddiesAsync() throws ContainerConnectException{ >+ assertNotNull(searchManager); >+ assertNotNull(searchManager.createCriteria()); >+ assertNotNull(searchManager.createSelection()); >+ >+ ISelection selection = searchManager.createSelection(); >+ >+ //fields to consider on XMPP server side search >+ ICriterion name = selection.eq("Name", "true"); >+ ICriterion email = selection.eq("Email", "true"); >+ ICriterion username = selection.eq("Username", "true"); >+ //search field for XMPP, criterion to match the search >+ ICriterion searchCriterion = selection.eq("search", "marcelo*"); >+ >+ //create a specific criteria >+ ICriteria criteria = searchManager.createCriteria(); >+ criteria.add(searchCriterion); >+ criteria.add(name); >+ criteria.add(email); >+ criteria.add(username); >+ >+ //call the block search >+ ISearch search = searchManager.search(criteria); >+ >+ //the collection of IResult >+ IResultList resultList = search.getResultList(); >+ >+ //check if there is at least one result >+ assertTrue(0 != resultList.geResults().size()); >+ >+ } >+ >+ >+ /** >+ * Try to locate buddies on the XMPP server in a call block way >+ * @throws ContainerConnectException >+ */ >+ public void testRetrieveBuddiesAllFieldsSync() throws ContainerConnectException{ >+ >+ try{ >+ assertNotNull(searchManager); >+ >+ ISelection selection = searchManager.createSelection(); >+ assertNotNull(selection); >+ >+ //fields to consider on XMPP server side search >+ //search field for XMPP, criterion to match the search >+ ICriterion name = selection.eq("Name", "Marcelo*"); >+ ICriterion email = selection.eq("Email", "zx*"); >+ ICriterion username = selection.eq("Username", "sl*"); >+ >+ //create a specific criteria >+ ICriteria criteria = searchManager.createCriteria(); >+ assertNotNull(criteria); >+ criteria.add(name); >+ criteria.add(email); >+ criteria.add(username); >+ >+ //call the block search >+ ISearch search = searchManager.search(criteria); >+ >+ //the collection of IResult >+ IResultList resultList = search.getResultList(); >+ >+ //check if there is at least one result >+ assertTrue(0 != resultList.geResults().size()); >+ >+ Iterator it = resultList.geResults().iterator(); >+ while (it.hasNext()) { >+ IResult type = (IResult) it.next(); >+ System.out.println(type.getUser().getName() + " : "+type.getUser().getID()); >+ >+ } >+ }catch (Exception e) { >+ e.printStackTrace(); >+ } >+ >+ } >+ >+ >+ /** >+ * Try to locate buddies on the XMPP server in a call block way >+ * @throws ContainerConnectException >+ */ >+ public void testRetrieveBuddiesEmailFieldSync() throws ContainerConnectException{ >+ >+ assertNotNull(searchManager); >+ >+ ISelection selection = searchManager.createSelection(); >+ assertNotNull(selection); >+ >+ //search field for XMPP, criterion to match the search >+ //fields to consider on XMPP server side search >+ ICriterion email = selection.eq("Email", "mayworm*"); >+ >+ //create a specific criteria >+ ICriteria criteria = searchManager.createCriteria(); >+ assertNotNull(criteria); >+ criteria.add(email); >+ >+ //call the block search >+ ISearch search = searchManager.search(criteria); >+ >+ //the collection of IResult >+ IResultList resultList = search.getResultList(); >+ >+ //check if there is at least one result >+ assertTrue(1 == resultList.geResults().size()); >+ >+ >+ } >+ >+ /** >+ * Try to locate buddies on the XMPP server in a call block way >+ * @throws ContainerConnectException >+ */ >+ public void testRetrieveBuddiesNameFieldSync() throws ContainerConnectException{ >+ >+ assertNotNull(searchManager); >+ >+ ISelection selection = searchManager.createSelection(); >+ assertNotNull(selection); >+ >+ //fields to consider on XMPP server side search >+ //search field for XMPP, criterion to match the search >+ ICriterion name = selection.eq("Name", "marcelo*"); >+ >+ //create a specific criteria >+ ICriteria criteria = searchManager.createCriteria(); >+ assertNotNull(criteria); >+ //criteria.add(searchCriterion); >+ criteria.add(name); >+ >+ //call the block search >+ ISearch search = searchManager.search(criteria); >+ >+ //the collection of IResult >+ IResultList resultList = search.getResultList(); >+ >+ //check if there is at least one result >+ assertTrue(1 == resultList.geResults().size()); >+ >+ } >+ >+ protected void setUp() throws Exception { >+ super.setUp(); >+ final int clientIndex = 0; >+ client = getClient(clientIndex); >+ assertNull(client.getConnectedID()); >+ final ID serverConnectID = getServerConnectID(clientIndex); >+ assertNotNull(serverConnectID); >+ >+ connectClient(client, serverConnectID, getConnectContext(clientIndex)); >+ assertEquals(serverConnectID, client.getConnectedID()); >+ >+ searchManager = getPresenceAdapter(clientIndex).getUserSearchManager(); >+ >+ } >+ >+ protected void tearDown() throws Exception { >+ super.tearDown(); >+ client.disconnect(); >+ } >+ >+ public void testUserProperties() throws ContainerConnectException{ >+ assertNotNull(searchManager); >+ String userProperties[] = searchManager.getUserPropertiesFields(); >+ >+ //check if there is at least one result >+ assertTrue(0 != userProperties.length); >+ >+ } >+ >+ >+} >#P org.eclipse.ecf.provider.xmpp >Index: src/org/eclipse/ecf/provider/xmpp/XMPPContainer.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.ecf/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/XMPPContainer.java,v >retrieving revision 1.18 >diff -u -r1.18 XMPPContainer.java >--- src/org/eclipse/ecf/provider/xmpp/XMPPContainer.java 31 Mar 2008 23:35:01 -0000 1.18 >+++ src/org/eclipse/ecf/provider/xmpp/XMPPContainer.java 14 Jan 2009 22:31:22 -0000 >@@ -41,6 +41,7 @@ > import org.eclipse.ecf.internal.provider.xmpp.events.MessageEvent; > import org.eclipse.ecf.internal.provider.xmpp.events.PresenceEvent; > import org.eclipse.ecf.internal.provider.xmpp.filetransfer.XMPPOutgoingFileTransferHelper; >+import org.eclipse.ecf.internal.provider.xmpp.search.XMPPSearchManager; > import org.eclipse.ecf.internal.provider.xmpp.smack.ECFConnection; > import org.eclipse.ecf.internal.provider.xmpp.smack.ECFConnectionObjectPacketEvent; > import org.eclipse.ecf.internal.provider.xmpp.smack.ECFConnectionPacketEvent; >@@ -50,6 +51,7 @@ > import org.eclipse.ecf.presence.chatroom.IChatRoomManager; > import org.eclipse.ecf.presence.im.IChatManager; > import org.eclipse.ecf.presence.roster.IRosterManager; >+import org.eclipse.ecf.presence.search.IUserSearchManager; > import org.eclipse.ecf.presence.service.IPresenceService; > import org.eclipse.ecf.provider.comm.AsynchEvent; > import org.eclipse.ecf.provider.comm.ConnectionCreateException; >@@ -104,6 +106,8 @@ > protected XMPPOutgoingFileTransferHelper outgoingFileTransferContainerAdapter = null; > > protected XMPPContainerPresenceHelper presenceHelper = null; >+ >+ protected XMPPSearchManager searchManager = null; > > protected ID presenceHelperID = null; > >@@ -112,6 +116,7 @@ > this.keepAlive = keepAlive; > accountManager = new XMPPContainerAccountManager(); > chatRoomManager = new XMPPChatRoomManager(getID()); >+ searchManager = new XMPPSearchManager(); > this.presenceHelperID = IDFactory.getDefault().createStringID(CONTAINER_HELPER_ID); > presenceHelper = new XMPPContainerPresenceHelper(this); > outgoingFileTransferContainerAdapter = new XMPPOutgoingFileTransferHelper(this); >@@ -132,6 +137,10 @@ > public IRosterManager getRosterManager() { > return presenceHelper.getRosterManager(); > } >+ >+ public IUserSearchManager getUserSearchManager() { >+ return searchManager; >+ } > > public IAccountManager getAccountManager() { > return accountManager; >@@ -238,6 +247,8 @@ > final ECFConnection conn = getECFConnection(); > accountManager.setConnection(conn.getXMPPConnection()); > chatRoomManager.setConnection(getConnectNamespace(), originalTarget, conn); >+ searchManager.setConnection(getConnectNamespace(), originalTarget,conn); >+ searchManager.setEnabled(!isGoogle(originalTarget)); > presenceHelper.setUser(new User(originalTarget)); > outgoingFileTransferContainerAdapter.setConnection(conn.getXMPPConnection()); > return originalTarget; >Index: src/org/eclipse/ecf/internal/provider/xmpp/Messages.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.ecf/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/Messages.java,v >retrieving revision 1.5 >diff -u -r1.5 Messages.java >--- src/org/eclipse/ecf/internal/provider/xmpp/Messages.java 10 Dec 2007 18:58:54 -0000 1.5 >+++ src/org/eclipse/ecf/internal/provider/xmpp/Messages.java 14 Jan 2009 22:31:22 -0000 >@@ -35,6 +35,7 @@ > public static String XMPPContainer_UNEXPECTED_EVENT; > public static String XMPPContainer_UNEXPECTED_XMPP_MESSAGE; > public static String XMPPContainer_UNRECOGONIZED_CONTAINER_MESSAGE; >+ public static String XMPPContainer_UNRECOGONIZED_SEARCH_SERVICE; > public static String XMPPFileID_EXCEPTION_FILE_IDS_NOT_URLS; > public static String XMPPFileNamespace_EXCEPTION_FILEID_FILENAME_NOT_NULL; > public static String XMPPFileNamespace_EXCEPTION_FILEID_TARGETID_NOT_NULL; >Index: src/org/eclipse/ecf/internal/provider/xmpp/messages.properties >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.ecf/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/messages.properties,v >retrieving revision 1.5 >diff -u -r1.5 messages.properties >--- src/org/eclipse/ecf/internal/provider/xmpp/messages.properties 10 Dec 2007 18:58:54 -0000 1.5 >+++ src/org/eclipse/ecf/internal/provider/xmpp/messages.properties 14 Jan 2009 22:31:22 -0000 >@@ -22,7 +22,8 @@ > XMPPContainer_EXCEPTION_INVALID_RESPONSE_FROM_SERVER=invalid connect response from server > XMPPIncomingFileTransfer_Status_Transfer_Exception=Transfer Exception > XMPPContainer_EXCEPTION_ADDING_SHARED_OBJECT=Exception adding shared object %1 >-XMPPContainer_UNRECOGONIZED_CONTAINER_MESSAGE=got unrecognized container message...ignoring message >+XMPPContainer_UNRECOGONIZED_CONTAINER_MESSAGE=got unrecognized container message...ignoring message >+XMPPContainer_UNRECOGONIZED_SEARCH_SERVICE=Search Service not available on the server > XMPPContainer_UNEXPECTED_EVENT=processAsynch got unexpected event %1 > XMPPContainer_EXCEPTION_HANDLING_ASYCH_EVENT=processAsynch exception processing event %1 > XMPPFileID_EXCEPTION_FILE_IDS_NOT_URLS=XMPPFileIDs cannot be represented as URLs. >Index: src/org/eclipse/ecf/internal/provider/xmpp/search/XMPPResultItem.java >=================================================================== >RCS file: src/org/eclipse/ecf/internal/provider/xmpp/search/XMPPResultItem.java >diff -N src/org/eclipse/ecf/internal/provider/xmpp/search/XMPPResultItem.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/internal/provider/xmpp/search/XMPPResultItem.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,60 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Marcelo Mayworm. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: Marcelo Mayworm - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.ecf.internal.provider.xmpp.search; >+ >+import org.eclipse.ecf.core.user.IUser; >+import org.eclipse.ecf.presence.search.IResult; >+ >+/** >+ * Implement a specific result for XMPP >+ * >+ */ >+public class XMPPResultItem implements IResult { >+ >+ /** contain a IUser */ >+ protected IUser user; >+ >+ /** >+ * Create a XMPP result with a IUser >+ * @param user IUser >+ */ >+ public XMPPResultItem(IUser user) { >+ this.user = user; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.ecf.presence.search.IResult#getUser() >+ */ >+ public IUser getUser() { >+ return user; >+ } >+ >+ /** >+ * Verify if there is the same IUser. Compare using ID >+ */ >+ public boolean equals(Object o) { >+ if(o instanceof XMPPResultItem) >+ return ((XMPPResultItem) o).getUser().getID().toString().equals(user.getID().toString()); >+ else >+ return false; >+ } >+ >+ public int hashCode() { >+ return (user.getID().toString() != null ? user.getID().toString() >+ .hashCode() : 0); >+ } >+ >+ public Object getAdapter(Class adapter) { >+ // TODO Auto-generated method stub >+ return null; >+ } >+ >+} >Index: src/org/eclipse/ecf/internal/provider/xmpp/search/XMPPCriteria.java >=================================================================== >RCS file: src/org/eclipse/ecf/internal/provider/xmpp/search/XMPPCriteria.java >diff -N src/org/eclipse/ecf/internal/provider/xmpp/search/XMPPCriteria.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/internal/provider/xmpp/search/XMPPCriteria.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,72 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Marcelo Mayworm. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: Marcelo Mayworm - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.ecf.internal.provider.xmpp.search; >+ >+import java.util.ArrayList; >+import java.util.Collections; >+import java.util.Iterator; >+import java.util.List; >+ >+import org.eclipse.ecf.presence.search.ICriteria; >+import org.eclipse.ecf.presence.search.ICriterion; >+ >+/** >+ * Implement a specific criteria control for XMPP >+ * >+ */ >+public class XMPPCriteria implements ICriteria { >+ >+ /** criteria list */ >+ protected List criteria; >+ >+ /** >+ * Create a criteria with a sync list >+ */ >+ public XMPPCriteria(){ >+ criteria = Collections.synchronizedList(new ArrayList()); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.ecf.presence.search.ICriteria#add(org.eclipse.ecf.presence.search.ICriterion) >+ */ >+ public void add(ICriterion criterion) { >+ criteria.add(criterion); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.ecf.presence.search.ICriteria#getCriterions() >+ */ >+ public List getCriterions() { >+ return criteria; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.ecf.presence.search.ICriteria#isEmpty() >+ */ >+ public boolean isEmpty() { >+ return criteria.isEmpty(); >+ } >+ >+ public String toString() { >+ StringBuffer sb = new StringBuffer("XMPPCriteria["); //$NON-NLS-1$ >+ Iterator it = criteria.iterator(); >+ while (it.hasNext()) { >+ sb.append("[");//$NON-NLS-1$ >+ ICriterion criterion = (ICriterion) it.next(); >+ sb.append(criterion.toString()); >+ sb.append("];");//$NON-NLS-1$ >+ } >+ return sb.toString(); >+ } >+ >+} >Index: src/org/eclipse/ecf/internal/provider/xmpp/search/XMPPSearch.java >=================================================================== >RCS file: src/org/eclipse/ecf/internal/provider/xmpp/search/XMPPSearch.java >diff -N src/org/eclipse/ecf/internal/provider/xmpp/search/XMPPSearch.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/internal/provider/xmpp/search/XMPPSearch.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,36 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Marcelo Mayworm. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: Marcelo Mayworm - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.ecf.internal.provider.xmpp.search; >+ >+import org.eclipse.ecf.presence.search.IResultList; >+import org.eclipse.ecf.presence.search.ISearch; >+ >+/** >+ * Implement ISearch for XMPP >+ * >+ */ >+public class XMPPSearch implements ISearch { >+ >+ protected IResultList resultList; >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.ecf.presence.search.ISearch#getResultList() >+ */ >+ public IResultList getResultList() { >+ return resultList; >+ } >+ >+ protected XMPPSearch(IResultList resultList) { >+ this.resultList = resultList; >+ } >+ >+ >+} >Index: src/org/eclipse/ecf/internal/provider/xmpp/search/XMPPSelection.java >=================================================================== >RCS file: src/org/eclipse/ecf/internal/provider/xmpp/search/XMPPSelection.java >diff -N src/org/eclipse/ecf/internal/provider/xmpp/search/XMPPSelection.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/internal/provider/xmpp/search/XMPPSelection.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,39 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Marcelo Mayworm. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: Marcelo Mayworm - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.ecf.internal.provider.xmpp.search; >+ >+import org.eclipse.ecf.presence.search.ICriterion; >+import org.eclipse.ecf.presence.search.Selection; >+ >+/** >+ * Implement a specific Selection for XMPP >+ * >+ */ >+public class XMPPSelection extends Selection { >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.ecf.presence.search.ISelection#eq(java.lang.String, java.lang.String) >+ */ >+ public ICriterion eq(String field, String value) { >+ //the operator is ignored for XMPP >+ return new XMPPSimpleCriterion(field, value, ""); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.ecf.presence.search.ISelection#eq(java.lang.String, java.lang.String) >+ */ >+ public ICriterion eq(String field, String value, boolean ignoreCase) { >+ //the operator is ignored for XMPP >+ return new XMPPSimpleCriterion(field, value, ""); >+ } >+ >+} >Index: src/org/eclipse/ecf/internal/provider/xmpp/search/XMPPSearchManager.java >=================================================================== >RCS file: src/org/eclipse/ecf/internal/provider/xmpp/search/XMPPSearchManager.java >diff -N src/org/eclipse/ecf/internal/provider/xmpp/search/XMPPSearchManager.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/internal/provider/xmpp/search/XMPPSearchManager.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,266 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Marcelo Mayworm. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: Marcelo Mayworm - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.ecf.internal.provider.xmpp.search; >+ >+import java.net.URISyntaxException; >+import java.util.HashSet; >+import java.util.Iterator; >+import java.util.List; >+import java.util.Set; >+ >+import org.eclipse.core.runtime.Assert; >+import org.eclipse.ecf.core.ContainerConnectException; >+import org.eclipse.ecf.core.identity.ID; >+import org.eclipse.ecf.core.identity.Namespace; >+import org.eclipse.ecf.core.user.IUser; >+import org.eclipse.ecf.core.user.User; >+import org.eclipse.ecf.internal.provider.xmpp.Messages; >+import org.eclipse.ecf.internal.provider.xmpp.smack.ECFConnection; >+import org.eclipse.ecf.presence.search.AbstractUserSearchManager; >+import org.eclipse.ecf.presence.search.ICriteria; >+import org.eclipse.ecf.presence.search.ICriterion; >+import org.eclipse.ecf.presence.search.IResultList; >+import org.eclipse.ecf.presence.search.ISearch; >+import org.eclipse.ecf.presence.search.ISelection; >+import org.eclipse.ecf.presence.search.IUserSearchListener; >+import org.eclipse.ecf.presence.search.IUserSearchManager; >+import org.eclipse.ecf.presence.search.ResultList; >+import org.eclipse.ecf.provider.xmpp.identity.XMPPID; >+import org.jivesoftware.smack.XMPPException; >+import org.jivesoftware.smackx.Form; >+import org.jivesoftware.smackx.FormField; >+import org.jivesoftware.smackx.ReportedData; >+import org.jivesoftware.smackx.ReportedData.Row; >+import org.jivesoftware.smackx.search.UserSearch; >+ >+/** >+ * A specific implementation for XMPP provider. XEP-0055: >+ * http://www.xmpp.org/extensions/xep-0055.html >+ * >+ * @see IUserSearchManager >+ */ >+public class XMPPSearchManager extends AbstractUserSearchManager { >+ >+ /** Search service name on XMPP server */ >+ protected static final String SERVICE_SEARCH = "search."; >+ >+ /** Wrapper for XMPP connection */ >+ protected ECFConnection ecfConnection; >+ >+ protected Namespace connectNamespace; >+ >+ protected ID connectedID; >+ >+ protected Form form; >+ >+ protected UserSearch manager; >+ >+ protected boolean enabled; >+ >+ protected static final String FORM_TYPE = "FORM_TYPE"; >+ >+ protected static final String NAME = "name"; >+ >+ protected static final String JID = "jid"; >+ >+ protected static final String SEARCH_ACTION = "search"; >+ >+ >+ public XMPPSearchManager() { >+ manager = new UserSearch(); >+ } >+ >+ /** >+ * Create a specific {@link ICriteria} for XMPP >+ */ >+ public ICriteria createCriteria() { >+ return new XMPPCriteria(); >+ } >+ >+ /** >+ * Create a specific {@link ISelection} for XMPP >+ */ >+ public ISelection createSelection() { >+ return new XMPPSelection(); >+ } >+ >+ /** >+ * Specific implementation for XMPP >+ * >+ * @see IUserSearchManager#search(ICriteria). >+ */ >+ public ISearch search(ICriteria criteria) throws ContainerConnectException { >+ >+ ResultList resultList = new ResultList(); >+ try { >+ //initialize the form by chance it is null >+ if (form == null) >+ form = manager.getSearchForm(ecfConnection.getXMPPConnection(), >+ SERVICE_SEARCH >+ + ecfConnection.getXMPPConnection() >+ .getServiceName()); >+ >+ /* >+ * For XMPP criterion is considered. The XMPP server will deal with >+ * the search. >+ */ >+ List criterions = criteria.getCriterions(); >+ // add the fields for the search dynamically >+ // consider just the fields used on the search >+ // fields checked by user >+ >+ String fields[] = getUserPropertiesFields(); >+ for (int i = 0; i < fields.length; i++) { >+ Iterator criterionsIterator = criterions.iterator(); >+ //for each user properties field check if it >+ //was added by user for the criteria >+ //for each field, a search is performed, and >+ //the partial result is added to the result list >+ while (criterionsIterator.hasNext()) { >+ ICriterion criterion = (ICriterion) criterionsIterator.next(); >+ if(criterion.equals(fields[i])){ >+ Form answerForm = form.createAnswerForm(); >+ answerForm.setAnswer(fields[i], true); >+ answerForm.setAnswer(SEARCH_ACTION, criterion.toExpression()); >+ ReportedData data = manager.sendSearchForm(ecfConnection >+ .getXMPPConnection(), answerForm, SERVICE_SEARCH + ecfConnection.getXMPPConnection().getServiceName()); >+ // create a result list from ReportedData >+ IResultList partialResultList = createResultList(data); >+ resultList.addAll(partialResultList.geResults()); >+ } >+ } >+ } >+ >+ return new XMPPSearch(resultList); >+ >+ } catch (final XMPPException e) { >+ String message = null; >+ if (e.getXMPPError() != null && e.getXMPPError().getCode() == 404) { >+ message = Messages.XMPPContainer_UNRECOGONIZED_SEARCH_SERVICE; >+ } else{ >+ message = e.getLocalizedMessage(); >+ } >+ throw new ContainerConnectException(message, e); >+ } >+ >+ } >+ >+ /** >+ * 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( >+ "cannot create connect id for client " + jid >+ + " , name = " + name, e); >+ } >+ } >+ } >+ return result; >+ } >+ >+ /** >+ * Specific implementation for XMPP >+ * >+ * @see IUserSearchManager#search(ICriteria). >+ */ >+ public void search(IUserSearchListener listener) { >+ addListener(listener); >+ } >+ >+ /** >+ * These parameters must be not null >+ * >+ * @param connectNamespace >+ * @param connectedID >+ * @param connection >+ */ >+ public void setConnection(Namespace connectNamespace, ID connectedID, >+ ECFConnection connection) { >+ Assert.isNotNull(connectNamespace); >+ Assert.isNotNull(connectedID); >+ Assert.isNotNull(connection); >+ this.connectNamespace = connectNamespace; >+ this.connectedID = connectedID; >+ this.ecfConnection = connection; >+ } >+ >+ /** >+ * Returns the user properties fields available on the XMPP server >+ * >+ * @param form >+ * @return String[] fields for form >+ * @throws ContainerConnectException >+ */ >+ public String[] getUserPropertiesFields() throws ContainerConnectException { >+ try{ >+ if (form == null) >+ form = manager.getSearchForm(ecfConnection.getXMPPConnection(), >+ SERVICE_SEARCH + ecfConnection.getXMPPConnection().getServiceName()); >+ >+ Set fields = new HashSet(); >+ Iterator userProperties = form.getFields(); >+ while (userProperties.hasNext()) { >+ FormField field = (FormField) userProperties.next(); >+ String variable = field.getVariable(); >+ // ignore these fields >+ if (!variable.equalsIgnoreCase(FORM_TYPE) >+ && !variable.equalsIgnoreCase(SEARCH_ACTION)) >+ fields.add(variable); >+ } >+ return (String[]) fields.toArray(new String[0]); >+ } catch (final XMPPException e) { >+ String message = null; >+ if (e.getXMPPError() != null && e.getXMPPError().getCode() == 404) { >+ message = Messages.XMPPContainer_UNRECOGONIZED_SEARCH_SERVICE; >+ } else{ >+ message = e.getLocalizedMessage(); >+ } >+ throw new ContainerConnectException(message, e); >+ } >+ >+ } >+ >+ /** >+ * Notify that user search for XMPP is enabled >+ */ >+ public boolean isEnabled() { >+ return this.enabled; >+ } >+ >+ /** >+ * For gtalk it should be not enabled >+ * @param enabled >+ */ >+ public void setEnabled(boolean enabled) { >+ this.enabled = enabled; >+ } >+ >+} >Index: src/org/eclipse/ecf/internal/provider/xmpp/search/XMPPSimpleCriterion.java >=================================================================== >RCS file: src/org/eclipse/ecf/internal/provider/xmpp/search/XMPPSimpleCriterion.java >diff -N src/org/eclipse/ecf/internal/provider/xmpp/search/XMPPSimpleCriterion.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/internal/provider/xmpp/search/XMPPSimpleCriterion.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,36 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Marcelo Mayworm. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: Marcelo Mayworm - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.ecf.internal.provider.xmpp.search; >+ >+import org.eclipse.ecf.presence.search.SimpleCriterion; >+ >+/** >+ * Implement specific for ICriterion >+ * >+ */ >+public class XMPPSimpleCriterion extends SimpleCriterion { >+ >+ public XMPPSimpleCriterion(String field, String value, String operator, >+ boolean ignoreCase) { >+ super(field, value, operator, ignoreCase); >+ >+ } >+ >+ public XMPPSimpleCriterion(String field, String value, String operator) { >+ super(field, value, operator); >+ } >+ >+ /** >+ * Provide the expression compose just for the value >+ */ >+ public String toExpression() { >+ return value; >+ } >+} >#P org.eclipse.ecf.presence >Index: src/org/eclipse/ecf/presence/IPresenceContainerAdapter.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.ecf/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/IPresenceContainerAdapter.java,v >retrieving revision 1.19 >diff -u -r1.19 IPresenceContainerAdapter.java >--- src/org/eclipse/ecf/presence/IPresenceContainerAdapter.java 31 Dec 2006 07:54:44 -0000 1.19 >+++ src/org/eclipse/ecf/presence/IPresenceContainerAdapter.java 14 Jan 2009 22:31:23 -0000 >@@ -14,6 +14,7 @@ > import org.eclipse.ecf.presence.chatroom.IChatRoomManager; > import org.eclipse.ecf.presence.im.IChatManager; > import org.eclipse.ecf.presence.roster.IRosterManager; >+import org.eclipse.ecf.presence.search.IUserSearchManager; > > /** > * Entry point presence container adapter. For setting up listeners for presence >@@ -71,4 +72,14 @@ > * available, returns <code>null</code>. > */ > public IChatRoomManager getChatRoomManager(); >+ >+ /** >+ * Retrieve interface for search on the provide. The returned >+ * IUserSearchManager (if not <code>null</code>) can be used to search users >+ * related to the same provider. >+ * >+ * @return IUserSearchManager. <code>null</code> if no search >+ * available for this provider. >+ */ >+ public IUserSearchManager getUserSearchManager(); > } >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.ecf/framework/bundles/org.eclipse.ecf.presence/META-INF/MANIFEST.MF,v >retrieving revision 1.89 >diff -u -r1.89 MANIFEST.MF >--- META-INF/MANIFEST.MF 8 Sep 2008 23:11:30 -0000 1.89 >+++ META-INF/MANIFEST.MF 14 Jan 2009 22:31:23 -0000 >@@ -12,6 +12,7 @@ > org.eclipse.ecf.presence.history, > org.eclipse.ecf.presence.im, > org.eclipse.ecf.presence.roster, >+ org.eclipse.ecf.presence.search, > org.eclipse.ecf.presence.service > Bundle-ManifestVersion: 2 > Bundle-RequiredExecutionEnvironment: CDC-1.0/Foundation-1.0, >Index: src/org/eclipse/ecf/presence/search/ResultList.java >=================================================================== >RCS file: src/org/eclipse/ecf/presence/search/ResultList.java >diff -N src/org/eclipse/ecf/presence/search/ResultList.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/presence/search/ResultList.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,103 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Marcelo Mayworm. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: Marcelo Mayworm - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.ecf.presence.search; >+ >+import java.util.*; >+import org.eclipse.core.runtime.IAdapterManager; >+import org.eclipse.ecf.internal.presence.PresencePlugin; >+ >+/** >+ * This Class implements {@link IResultList}. Subclasses may be created as >+ * appropriate. >+ * >+ */ >+public class ResultList implements IResultList { >+ >+ protected Set results; >+ >+ /** >+ * Create a new synchronized result list from a existing one >+ * @param existingResults >+ */ >+ public ResultList(Collection /* <IResult> */existingResults) { >+ results = Collections.synchronizedSet(new HashSet()); >+ if (existingResults != null) >+ addAll(existingResults); >+ } >+ >+ /** >+ * Create a new synchronized result list from a existing one >+ * >+ */ >+ public ResultList() { >+ results = Collections.synchronizedSet(new HashSet()); >+ } >+ >+ /** >+ * Add an item for the result list >+ * @param item >+ * @return boolean >+ */ >+ public boolean add(IResult item) { >+ if (item == null) >+ return false; >+ if (results.add(item)) >+ return true; >+ return false; >+ } >+ >+ /** >+ * Add the list for the current result list >+ * @param existingResults >+ */ >+ public void addAll(Collection /* <IResult> */existingResults) { >+ if (existingResults == null) >+ return; >+ synchronized (results) { >+ for (Iterator i = existingResults.iterator(); i.hasNext();) { >+ add((IResult) i.next()); >+ } >+ } >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.ecf.ui.presence.search.IResultList#getEntries() >+ */ >+ public Collection geResults() { >+ return results; >+ } >+ >+ public boolean remove(IResult item) { >+ return results.remove(item); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.ecf.ui.presence.search.IResultList#getResult >+ */ >+ public IResult getResult(String field, String value) { >+ // TODO >+ return null; >+ } >+ >+ public Object getAdapter(Class adapter) { >+ if (adapter.isInstance(this)) { >+ return this; >+ } >+ IAdapterManager adapterManager = PresencePlugin.getDefault().getAdapterManager(); >+ if (adapterManager == null) >+ return null; >+ return adapterManager.loadAdapter(this, adapter.getName()); >+ } >+ >+} >Index: src/org/eclipse/ecf/presence/search/ICriteria.java >=================================================================== >RCS file: src/org/eclipse/ecf/presence/search/ICriteria.java >diff -N src/org/eclipse/ecf/presence/search/ICriteria.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/presence/search/ICriteria.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,52 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Marcelo Mayworm. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: Marcelo Mayworm - initial API and implementation >+ * >+ ******************************************************************************/ >+ >+package org.eclipse.ecf.presence.search; >+ >+import java.util.List; >+ >+/** >+ * Criteria helps for retrieving results from the provider search by composing Criterion objects. >+ * The {@link IUserSearchManager} is a factory for Criteria. Criterion instances are obtained via ISelection methods. >+ * Criteria can deal with different kind of criterion, as logical or just simple expression. >+ * >+ * The typical usage of the Criteria is as >+ * follows: >+ * >+ * <pre> >+ * ISelection selection = ... >+ * ICriterion name = selection.eq("name", "value"); >+ * ICriterion host = selection.eq("host", "value"); >+ * ICriterion and = selection.and(name, host); >+ * ICriteria criteria = ... >+ * criteria.add(and); >+ * </pre> >+ */ >+public interface ICriteria { >+ >+ /** >+ * Add a criterion that composes the criteria >+ * @param criterion >+ */ >+ public void add(ICriterion criterion); >+ >+ /** >+ * A list of all criterion added to the criteria >+ * @return List of {@link ICriterion} >+ */ >+ public List getCriterions(); >+ >+ /** >+ * Notify if there is or not criterion added for this criteria >+ * @return indicate if there are or not criterion >+ */ >+ public boolean isEmpty(); >+ >+} >Index: src/org/eclipse/ecf/presence/search/LogicalCriterion.java >=================================================================== >RCS file: src/org/eclipse/ecf/presence/search/LogicalCriterion.java >diff -N src/org/eclipse/ecf/presence/search/LogicalCriterion.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/presence/search/LogicalCriterion.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,49 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Marcelo Mayworm. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: Marcelo Mayworm - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.ecf.presence.search; >+ >+/** >+ * Base class implementation of {@link ICriterion} for logical criterion. >+ * Subclasses may be created as appropriate. It is just a simple >+ * implementation that can be considered for some provider or even used >+ * as base for some implementation. >+ * >+ */ >+public class LogicalCriterion implements ICriterion { >+ >+ final ICriterion left; >+ final ICriterion right; >+ final String operator; >+ >+ /** >+ * Creates a logic operation for compose a {@link ICrteria} >+ * @param left Criterion on the left side of the expression >+ * @param right Criterion on the right side of the expression >+ * @param operator Operator considered on the logical. Ex: And >+ */ >+ public LogicalCriterion(ICriterion left, ICriterion right, String operator) { >+ this.left = left; >+ this.right = right; >+ this.operator = operator; >+ } >+ >+ public String toExpression() { >+ return left.toExpression() + ' ' + operator + ' ' + right.toExpression(); >+ } >+ >+ public String toString() { >+ StringBuffer sb = new StringBuffer("LogicalCriterion["); //$NON-NLS-1$ >+ sb.append("left=").append(left).append(";"); //$NON-NLS-1$ //$NON-NLS-2$ >+ sb.append("right=").append(right).append(";"); //$NON-NLS-1$ //$NON-NLS-2$ >+ sb.append("operator=").append(operator).append("]"); //$NON-NLS-1$ //$NON-NLS-2$ >+ return sb.toString(); >+ } >+ >+} >Index: src/org/eclipse/ecf/presence/search/IUserSearchManager.java >=================================================================== >RCS file: src/org/eclipse/ecf/presence/search/IUserSearchManager.java >diff -N src/org/eclipse/ecf/presence/search/IUserSearchManager.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/presence/search/IUserSearchManager.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,72 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Marcelo Mayworm. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: Marcelo Mayworm - initial API and implementation >+ * >+ ******************************************************************************/ >+ >+package org.eclipse.ecf.presence.search; >+ >+import org.eclipse.ecf.core.ContainerConnectException; >+ >+/** >+ * Get a search mechanism for an account. >+ * >+ */ >+public interface IUserSearchManager { >+ >+ /** >+ * Execute the search for a specific criteria, blocking until the search returns. >+ * This method can apply search to math the specific criteria in case if the >+ * provider is not able to do it completely >+ * @param criteria >+ * @return ISearch Contain the search results >+ * @throws ContainerConnectException >+ */ >+ public ISearch search(ICriteria criteria) throws ContainerConnectException; >+ >+ /** >+ * Execute the search for a specific criteria, not blocking until the search returns. >+ * This method can apply search to math the specific criteria in case if the >+ * provider is not able to do it completely >+ * @param listener the listener {@link IUserSearchListener} to search. Must not be <code>null</code>. >+ */ >+ public void search(IUserSearchListener listener); >+ >+ /** >+ * Create a specific criteria for the provider. Each provider must >+ * implement a specific Criteria in a convenient approach for keep, >+ * organize and deal with the {@link ICriterion}. >+ * @return {@link ICriteria} >+ */ >+ public ICriteria createCriteria(); >+ >+ /** >+ * Create a specific {@link ISelection} implementation for the provider. >+ * This implementation will provide the methods to created and organize >+ * the {@link ICriterion} that composes the search. The {@link Selection} >+ * is a simple implementation of this, but subclasses or new implementation >+ * may be created as appropriate. >+ * >+ * @return {@link ISelection} >+ */ >+ public ISelection createSelection(); >+ >+ /** >+ * Each provider can inform the user properties fields >+ * to be considered on the user search, allowing the >+ * dynamically user interface for the search. >+ * @return String[] user properties provides by server >+ * @throws ContainerConnectException >+ */ >+ public String[] getUserPropertiesFields() throws ContainerConnectException; >+ >+ /** >+ * Whether this handler is capable of executing at this time. >+ * @return boolean >+ */ >+ public boolean isEnabled(); >+} >Index: src/org/eclipse/ecf/presence/search/ICriterion.java >=================================================================== >RCS file: src/org/eclipse/ecf/presence/search/ICriterion.java >diff -N src/org/eclipse/ecf/presence/search/ICriterion.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/presence/search/ICriterion.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,30 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Marcelo Mayworm. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: Marcelo Mayworm - initial API and implementation >+ * >+ ******************************************************************************/ >+ >+package org.eclipse.ecf.presence.search; >+ >+/** >+ * A representation of a query criterion for a restriction in a Criteria. >+ * A Criteria is formed by one or several criterion, >+ * that together are able to compose an entire expression to project >+ * a result that match the criteria. The instances of this should be >+ * created for {@link ISelection} implementations. >+ * >+ */ >+public interface ICriterion { >+ >+ /** >+ * Returns a expression composed for the search. >+ * The String can be something like 'field' + 'operator' + value, >+ * that it will be interpreted for each specific provider. >+ * @return String >+ */ >+ public String toExpression(); >+} >Index: src/org/eclipse/ecf/presence/search/IUserSearchEvent.java >=================================================================== >RCS file: src/org/eclipse/ecf/presence/search/IUserSearchEvent.java >diff -N src/org/eclipse/ecf/presence/search/IUserSearchEvent.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/presence/search/IUserSearchEvent.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,25 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Marcelo Mayworm. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: Marcelo Mayworm - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.ecf.presence.search; >+ >+/** >+ * An event received by a user search >+ * >+ */ >+public interface IUserSearchEvent { >+ >+ /** >+ * Get ICriteria of user search. >+ * >+ * @return ICriteria for user search in asynchronous mode. Will not return <code>null</code). >+ */ >+ public ICriteria getCriteria(); >+ >+} >Index: src/org/eclipse/ecf/presence/search/ISearch.java >=================================================================== >RCS file: src/org/eclipse/ecf/presence/search/ISearch.java >diff -N src/org/eclipse/ecf/presence/search/ISearch.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/presence/search/ISearch.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,27 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Marcelo Mayworm. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: Marcelo Mayworm - initial API and implementation >+ * >+ ******************************************************************************/ >+ >+package org.eclipse.ecf.presence.search; >+ >+/** >+ * Provide access for the list of matched query results. This interface can be >+ * extended to supply more features around the result list. >+ * >+ */ >+public interface ISearch { >+ >+ /** >+ * Gets a result list. >+ * Will not return <code>null</code>. >+ * @return IResultList list of {@link IResult} >+ */ >+ IResultList getResultList(); >+ >+} >Index: src/org/eclipse/ecf/presence/search/ISelection.java >=================================================================== >RCS file: src/org/eclipse/ecf/presence/search/ISelection.java >diff -N src/org/eclipse/ecf/presence/search/ISelection.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/presence/search/ISelection.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,61 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Marcelo Mayworm. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: Marcelo Mayworm - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.ecf.presence.search; >+ >+/** >+ * Instances implementing this interface provide methods to compose the corrects operations for each >+ * provide >+ * >+ */ >+public interface ISelection { >+ >+ /** >+ * Apply an "add" constraint to the two criterion >+ * @param left >+ * @param right >+ * @return ICriterion >+ */ >+ public ICriterion and(ICriterion left, ICriterion right); >+ >+ /** >+ * Apply an "equal" constraint to the field, ignoring case >+ * @param field >+ * @param value >+ * @return ICriterion >+ */ >+ public ICriterion eq(String field, String value); >+ >+ /** >+ * Apply an "not equal" constraint to the field ignoring case >+ * @param field >+ * @param value >+ * @return ICriterion >+ */ >+ public ICriterion ne(String field, String value); >+ >+ /** >+ * Apply an "equal" constraint to the field, taking into consideration ignore case >+ * @param field >+ * @param value >+ * @param ignoreCase >+ * @return ICriterion >+ */ >+ public ICriterion eq(String field, String value, boolean ignoreCase); >+ >+ /** >+ * Apply an "not equal" constraint to the field, taking into consideration ignore case >+ * @param field >+ * @param value >+ * @param ignoreCase >+ * @return ICriterion >+ */ >+ public ICriterion ne(String field, String value, boolean ignoreCase); >+ >+} >Index: src/org/eclipse/ecf/presence/search/IResult.java >=================================================================== >RCS file: src/org/eclipse/ecf/presence/search/IResult.java >diff -N src/org/eclipse/ecf/presence/search/IResult.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/presence/search/IResult.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,28 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Marcelo Mayworm. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: Marcelo Mayworm - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.ecf.presence.search; >+ >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.ecf.core.user.IUser; >+ >+/** >+ * Each result returned for the search will be reach through this interface. >+ * The result contain the user that match the search. >+ * >+ */ >+public interface IResult extends IAdaptable { >+ >+ /** >+ * Get user for the search. This is the user that comes from the search. >+ * >+ * @return IUser user associated with the search. >+ */ >+ public IUser getUser(); >+} >Index: src/org/eclipse/ecf/presence/search/IUserSearchListener.java >=================================================================== >RCS file: src/org/eclipse/ecf/presence/search/IUserSearchListener.java >diff -N src/org/eclipse/ecf/presence/search/IUserSearchListener.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/presence/search/IUserSearchListener.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,29 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Marcelo Mayworm. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: Marcelo Mayworm - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.ecf.presence.search; >+ >+/** >+ * This Interface allows for implementing classes to execute the search >+ * for users in a non block way. >+ * Note these methods will be called asynchronously not blocking a search action. >+ * The provider is free to call the methods below with an arbitrary thread, so the >+ * implementation of these methods must be appropriately prepared. >+ * >+ */ >+public interface IUserSearchListener { >+ >+ /** >+ * Handle the search asynchronously. Notify that the search was completed >+ * for the specific criteria. >+ * @param criteria the object that contains the composition of {@link ICriterion} >+ */ >+ public void handleSearchComplete(ICriteria criteria); >+ >+} >Index: src/org/eclipse/ecf/presence/search/SimpleCriterion.java >=================================================================== >RCS file: src/org/eclipse/ecf/presence/search/SimpleCriterion.java >diff -N src/org/eclipse/ecf/presence/search/SimpleCriterion.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/presence/search/SimpleCriterion.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,83 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Marcelo Mayworm. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: Marcelo Mayworm - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.ecf.presence.search; >+ >+/** >+ * >+ * Base class implementation of {@link ICriterion} for simple comparisons. Subclasses may be created as >+ * appropriate. >+ * >+ */ >+public class SimpleCriterion implements ICriterion { >+ >+ protected final String field; >+ protected final String value; >+ protected final String operator; >+ protected final boolean ignoreCase; >+ >+ /** >+ * Constructor for a instance of {@link ICriterion} >+ * @param field Name of the field >+ * @param value Value that match the search >+ * @param operator Operator opportune for the search >+ * @param ignoreCase Consider case or not >+ */ >+ public SimpleCriterion(String field, String value, String operator, boolean ignoreCase) { >+ this.field = field; >+ this.value = value; >+ this.operator = operator; >+ this.ignoreCase = ignoreCase; >+ } >+ >+ /** >+ * Constructor for a instance of {@link ICriterion}. This is >+ * ignore case >+ * @param field Name of the field >+ * @param value Value that match the search >+ * @param operator Operator opportune for the search >+ */ >+ public SimpleCriterion(String field, String value, String operator) { >+ this.field = field; >+ this.value = value; >+ this.operator = operator; >+ this.ignoreCase = false; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.ecf.presence.search.ICriterion#toExpression() >+ */ >+ public String toExpression() { >+ return field + ' ' + operator + ' ' + value; >+ } >+ >+ public String toString() { >+ StringBuffer sb = new StringBuffer("SimpleCriterion["); //$NON-NLS-1$ >+ sb.append("field=").append(field).append(";"); //$NON-NLS-1$ //$NON-NLS-2$ >+ sb.append("value=").append(value).append(";"); //$NON-NLS-1$ //$NON-NLS-2$ >+ sb.append("operator=").append(operator).append(";"); //$NON-NLS-1$ //$NON-NLS-2$ >+ sb.append("ignoreCase=").append(ignoreCase).append("]"); //$NON-NLS-1$ //$NON-NLS-2$ >+ return sb.toString(); >+ } >+ >+ public boolean equals(Object o) { >+ if (this == o) { >+ return true; >+ } >+ if (o instanceof String) { >+ return o.equals(field); >+ } >+ return false; >+ } >+ >+ public int hashCode() { >+ return (field != null ? field.hashCode() : 0); >+ } >+} >Index: src/org/eclipse/ecf/presence/search/AbstractUserSearchManager.java >=================================================================== >RCS file: src/org/eclipse/ecf/presence/search/AbstractUserSearchManager.java >diff -N src/org/eclipse/ecf/presence/search/AbstractUserSearchManager.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/presence/search/AbstractUserSearchManager.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,54 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Marcelo Mayworm. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: Marcelo Mayworm - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.ecf.presence.search; >+ >+import java.util.*; >+ >+/** >+ * Abstract implementation of IUserSearchManager. Provides implementations of listener >+ * methods that subsclasses may use to avoid having to implement them >+ * themselves. This class may be subclassed as needed. >+ * >+ */ >+public abstract class AbstractUserSearchManager implements IUserSearchManager { >+ >+ private final List userSearchListeners = new ArrayList(5); >+ >+ public void addListener(IUserSearchListener l) { >+ synchronized (userSearchListeners) { >+ userSearchListeners.add(l); >+ } >+ } >+ >+ public void removeListener(IUserSearchListener l) { >+ synchronized (userSearchListeners) { >+ userSearchListeners.remove(l); >+ } >+ } >+ >+ /** >+ * Fires a user search event >+ * >+ * @param event >+ */ >+ public void fireUserSearchEvent(IUserSearchEvent event) { >+ List toNotify = null; >+ // Copy array >+ synchronized (userSearchListeners) { >+ toNotify = new ArrayList(userSearchListeners); >+ } >+ // Notify all in toNotify >+ for (Iterator i = toNotify.iterator(); i.hasNext();) { >+ IUserSearchListener l = (IUserSearchListener) i.next(); >+ l.handleSearchComplete(event.getCriteria()); >+ } >+ } >+ >+} >Index: src/org/eclipse/ecf/presence/search/Selection.java >=================================================================== >RCS file: src/org/eclipse/ecf/presence/search/Selection.java >diff -N src/org/eclipse/ecf/presence/search/Selection.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/presence/search/Selection.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,71 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Marcelo Mayworm. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: Marcelo Mayworm - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.ecf.presence.search; >+ >+/** >+ * This Class implements {@link ISelection}. Subclasses may be created as >+ * appropriate. It is just a simple implementation that can be considered >+ * for some provider or even used as base for some implementation. >+ * >+ */ >+public class Selection implements ISelection { >+ >+ /** Operator Equal */ >+ public static final String OPERATOR_EQ = "="; //$NON-NLS-1$ >+ >+ /** Operator Not Equal */ >+ public static final String OPERATOR_NE = "!="; //$NON-NLS-1$ >+ >+ /** Operator AND */ >+ public static final String OPERATOR_AND = "&&"; //$NON-NLS-1$ >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.ecf.presence.search.ISelection#and(org.eclipse.ecf.presence.search.ICriterion, org.eclipse.ecf.presence.search.ICriterion) >+ */ >+ public ICriterion and(ICriterion left, ICriterion right) { >+ return new LogicalCriterion(left, right, OPERATOR_AND); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.ecf.presence.search.ISelection#eq(java.lang.String, java.lang.String) >+ */ >+ public ICriterion eq(String field, String value) { >+ return new SimpleCriterion(field, value, OPERATOR_EQ); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.ecf.presence.search.ISelection#ne(java.lang.String, java.lang.String) >+ */ >+ public ICriterion ne(String field, String value) { >+ return new SimpleCriterion(field, value, OPERATOR_NE); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.ecf.presence.search.ISelection#eq(java.lang.String, java.lang.String, boolean) >+ */ >+ public ICriterion eq(String field, String value, boolean ignoreCase) { >+ //TODO implement a criterion that supports ignore case approach >+ return new SimpleCriterion(field, value, OPERATOR_EQ); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.ecf.presence.search.ISelection#ne(java.lang.String, java.lang.String, boolean) >+ */ >+ public ICriterion ne(String field, String value, boolean ignoreCase) { >+ //TODO implement a criterion that supports ignore case approach >+ return new SimpleCriterion(field, value, OPERATOR_NE); >+ } >+ >+} >Index: src/org/eclipse/ecf/presence/search/IResultList.java >=================================================================== >RCS file: src/org/eclipse/ecf/presence/search/IResultList.java >diff -N src/org/eclipse/ecf/presence/search/IResultList.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/presence/search/IResultList.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,38 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Marcelo Mayworm. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: Marcelo Mayworm - initial API and implementation >+ * >+ ******************************************************************************/ >+ >+package org.eclipse.ecf.presence.search; >+ >+import java.util.Collection; >+import org.eclipse.core.runtime.IAdaptable; >+ >+/** >+ * This interface provides methods to handle the result list that match the search. >+ * >+ */ >+public interface IResultList extends IAdaptable { >+ >+ /** >+ * Get results that match the search. Instances of list are of type >+ * {@link IResult} >+ * >+ * @return Collection of IResult. Will not return <code>null</code>. >+ * May return an empty Collection. >+ */ >+ public Collection geResults(); >+ >+ /** >+ * Get the result that math the specific field and value >+ * @param field field's name used as argument to try to match the search >+ * @param value value for the respective field used as argument to try to match the search >+ * @return IResult will be null case it doesn't exist >+ */ >+ public IResult getResult(String field, String value); >+} >#P org.eclipse.ecf.presence.ui >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.ecf/framework/bundles/org.eclipse.ecf.presence.ui/plugin.properties,v >retrieving revision 1.8 >diff -u -r1.8 plugin.properties >--- plugin.properties 22 Mar 2008 17:38:49 -0000 1.8 >+++ plugin.properties 14 Jan 2009 22:31:25 -0000 >@@ -15,6 +15,7 @@ > > views.messages = Messages > views.multiRosterView = Contacts >+views.userSearchView = Search Contacts > > browse.command.label = Open Contact... > browse.command.tooltip = Open Contact >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.ecf/framework/bundles/org.eclipse.ecf.presence.ui/plugin.xml,v >retrieving revision 1.26 >diff -u -r1.26 plugin.xml >--- plugin.xml 29 Nov 2008 10:34:08 -0000 1.26 >+++ plugin.xml 14 Jan 2009 22:31:25 -0000 >@@ -78,6 +78,13 @@ > name="%views.multiRosterView"> > </view> > <view >+ category="org.eclipse.ecf.ui.viewcategory" >+ class="org.eclipse.ecf.presence.ui.UserSearchView" >+ icon="icons/contacts.gif" >+ id="org.eclipse.ecf.presence.ui.UserSearchView" >+ name="%views.userSearchView"> >+ </view> >+ <view > allowMultiple="true" > category="org.eclipse.ecf.ui.viewcategory" > class="org.eclipse.ecf.presence.ui.chatroom.ChatRoomManagerView" >Index: src/org/eclipse/ecf/presence/ui/MultiRosterView.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.ecf/framework/bundles/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/presence/ui/MultiRosterView.java,v >retrieving revision 1.70 >diff -u -r1.70 MultiRosterView.java >--- src/org/eclipse/ecf/presence/ui/MultiRosterView.java 14 Dec 2008 08:00:20 -0000 1.70 >+++ src/org/eclipse/ecf/presence/ui/MultiRosterView.java 14 Jan 2009 22:31:27 -0000 >@@ -97,6 +97,8 @@ > > private IAction addContactAction; > >+ private IAction searchContactAction; >+ > private IAction openChatRoomAction; > > private IAction openAccountChatRoomAction; >@@ -480,6 +482,20 @@ > } > }; > >+ searchContactAction = new Action() { >+ public void run() { >+ IStructuredSelection iss = (IStructuredSelection) treeViewer.getSelection(); >+ IRoster roster = (IRoster) iss.getFirstElement(); >+ MultiRosterAccount account = findAccountForUser(roster.getUser().getID()); >+ if (account != null) { >+ SearchContactDialog dialog = new SearchContactDialog(treeViewer.getControl().getShell(), account); >+ dialog.open(); >+ } >+ } >+ }; >+ >+ searchContactAction.setText(Messages.MultiRosterView_SearchContact); >+ > openChatRoomAction = new Action() { > public void run() { > selectAndJoinChatRoomForAccounts((MultiRosterAccount[]) rosterAccounts.toArray(new MultiRosterAccount[] {})); >@@ -618,6 +634,11 @@ > } > manager.add(addContactAction); > manager.add(new Separator()); >+ //add if the provider supports user search >+ if (((IRoster) element).getPresenceContainerAdapter().getUserSearchManager().isEnabled()) { >+ manager.add(searchContactAction); >+ manager.add(new Separator()); >+ } > manager.add(openAccountChatRoomAction); > manager.add(new Separator()); > manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); >@@ -701,6 +722,7 @@ > showOfflineAction.setEnabled(enabled); > showEmptyGroupsAction.setEnabled(enabled); > addContactAction.setEnabled(enabled); >+ searchContactAction.setEnabled(enabled); > openChatRoomAction.setEnabled(enabled); > disconnectAllAccountsAction.setEnabled(enabled); > } >@@ -722,6 +744,8 @@ > manager.add(new Separator()); > manager.add(addContactAction); > manager.add(new Separator()); >+ manager.add(searchContactAction); >+ manager.add(new Separator()); > manager.add(openChatRoomAction); > manager.add(new Separator()); > manager.add(disconnectAllAccountsAction); >Index: src/org/eclipse/ecf/internal/presence/ui/messages.properties >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.ecf/framework/bundles/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/internal/presence/ui/messages.properties,v >retrieving revision 1.31 >diff -u -r1.31 messages.properties >--- src/org/eclipse/ecf/internal/presence/ui/messages.properties 2 Nov 2008 02:14:28 -0000 1.31 >+++ src/org/eclipse/ecf/internal/presence/ui/messages.properties 14 Jan 2009 22:31:27 -0000 >@@ -40,6 +40,7 @@ > MultiRosterView_CHANGE_PASSWORD_EXCEPTION=changePassword > MultiRosterView_ENTER_CHATROOM_TOOLTIP_TEXT=Show chat rooms for all accounts > MultiRosterView_AddContact = &Add Contact >+MultiRosterView_SearchContact = &Search Contact > > MessagesView_ClearChatLog = &Clear Chat Log > MessagesView_ClearChatLogDialogTitle = Clear Chat Log >@@ -56,6 +57,25 @@ > AddContactDialog_Alias = Alias: > AddContactDialog_Account = Account: > >+SearchContactDialog_DialogTitle = Search Contact >+SearchContactDialog = Search >+SearchContactDialog_InfoSearching = The following fields are available\nfor searching. Wildcard(*)\ncharacters are allowed as part the\nof query. >+SearchContactDialog_InfoSearchFields= Search Fields >+SearchContactDialog_InfoContactFields = Search Results >+SearchContactDialog_ButtonSearch = Search >+SearchContactDialog_ButtonStop = Stop >+SearchContactDialog_ButtonAddContact = Add Contact >+SearchContactDialog_ContactInfo=Contact Info >+SearchContactDialog_RunInBackground=Run in background >+SearchContactDialog_RunInBackGroundToolTip=Run long operations in the background where possible >+SearchContactDialog_TableResultColumnName=Name >+SearchContactDialog_TableResultColumnUsername=ID >+SearchContactDialog_TableSearchColumnField=Field >+SearchContactDialog_TableSearchColumnValue=Value For Search >+SearchContactDialog_AddContactMessage=Do you want to add the contact {0}? >+SearchContactDialog_SearchingMessage=Searching... >+SearchContactDialog_UserSearchJobName=Searching User... >+ > RosterWorkbenchAdapterFactory_Mode = Mode: {0} > RosterWorkbenchAdapterFactory_Type = Type: {0} > RosterWorkbenchAdapterFactory_Account = Account: {0} >@@ -149,3 +169,4 @@ > ChatRoomPreferencePage_CHATROOM_SHOW_USER_PRESENCE_TEXT=&Show user entry and exit messages > > ChatRoomPreferencePage_SCROLL_OUTPUT_ON_INPUT=Scroll &output to bottom on user input >+UserSearchLabelProvider_ContactsFound=\ contacts found >Index: src/org/eclipse/ecf/internal/presence/ui/Messages.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.ecf/framework/bundles/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/internal/presence/ui/Messages.java,v >retrieving revision 1.29 >diff -u -r1.29 Messages.java >--- src/org/eclipse/ecf/internal/presence/ui/Messages.java 2 Nov 2008 02:14:28 -0000 1.29 >+++ src/org/eclipse/ecf/internal/presence/ui/Messages.java 14 Jan 2009 22:31:25 -0000 >@@ -194,6 +194,7 @@ > public static String MultiRosterView_ShowOffline; > public static String MultiRosterView_ShowEmptyGroups; > public static String MultiRosterView_AddContact; >+ public static String MultiRosterView_SearchContact; > > public static String MessagesView_ClearChatLog; > public static String MessagesView_ClearChatLogDialogTitle; >@@ -209,6 +210,35 @@ > public static String AddContactDialog_Alias; > public static String AddContactDialog_Account; > >+ public static String SearchContactDialog_DialogTitle; >+ public static String SearchContactDialog; >+ public static String SearchContactDialog_InfoSearching; >+ public static String SearchContactDialog_InfoSearchFields; >+ public static String SearchContactDialog_InfoContactFields; >+ public static String SearchContactDialog_ButtonSearch; >+ public static String SearchContactDialog_ButtonStop; >+ public static String SearchContactDialog_ButtonAddContact; >+ >+ public static String SearchContactDialog_ContactInfo; >+ >+ public static String SearchContactDialog_AddContactMessage; >+ >+ public static String SearchContactDialog_RunInBackground; >+ >+ public static String SearchContactDialog_RunInBackGroundToolTip; >+ >+ public static String SearchContactDialog_SearchingMessage; >+ >+ public static String SearchContactDialog_TableResultColumnName; >+ >+ public static String SearchContactDialog_TableResultColumnUsername; >+ >+ public static String SearchContactDialog_TableSearchColumnField; >+ >+ public static String SearchContactDialog_TableSearchColumnValue; >+ >+ public static String SearchContactDialog_UserSearchJobName; >+ > public static String ReceiveAuthorizeRequestDialog_AUTH_REQUEST_FROM; > > public static String ReceiveAuthorizeRequestDialog_BUTTON_AUTHORIZE_AND_ADD; >@@ -244,6 +274,8 @@ > > public static String ChatRoomPreferencePage_SCROLL_OUTPUT_ON_INPUT; > >+ public static String UserSearchLabelProvider_ContactsFound; >+ > static { > NLS.initializeMessages(BUNDLE_NAME, Messages.class); > } >Index: src/org/eclipse/ecf/presence/ui/UserSearchView.java >=================================================================== >RCS file: src/org/eclipse/ecf/presence/ui/UserSearchView.java >diff -N src/org/eclipse/ecf/presence/ui/UserSearchView.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/presence/ui/UserSearchView.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,183 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Marcelo Mayworm. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: Marcelo Mayworm - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.ecf.presence.ui; >+ >+import java.util.ArrayList; >+import java.util.List; >+import org.eclipse.core.runtime.Assert; >+import org.eclipse.ecf.core.util.ECFException; >+import org.eclipse.ecf.internal.presence.ui.Activator; >+import org.eclipse.ecf.internal.presence.ui.Messages; >+import org.eclipse.ecf.presence.IPresenceContainerAdapter; >+import org.eclipse.ecf.presence.roster.IRosterSubscriptionSender; >+import org.eclipse.ecf.presence.search.IResult; >+import org.eclipse.ecf.presence.search.IResultList; >+import org.eclipse.ecf.ui.SharedImages; >+import org.eclipse.jface.action.*; >+import org.eclipse.jface.dialogs.MessageDialog; >+import org.eclipse.jface.viewers.*; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.ui.part.PageBook; >+import org.eclipse.ui.part.ViewPart; >+ >+/** >+ * View class for displaying multiple users that match a search in a tree viewer. This view part >+ * provides the ability to display multiple users in a single tree viewer. This class may be subclassed as >+ * desired to add or customize behavior. >+ */ >+public class UserSearchView extends ViewPart { >+ >+ public static final String VIEW_ID = "org.eclipse.ecf.presence.ui.UserSearchView"; //$NON-NLS-1$ >+ >+ protected static final int DEFAULT_EXPAND_LEVEL = 3; >+ >+ protected TreeViewer treeViewer; >+ >+ protected List users = new ArrayList(); >+ >+ private IAction addContactAction; >+ >+ private MultiRosterAccount account; >+ >+ private PageBook pageBook; >+ >+ private Label helpMessageLabel; >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) >+ */ >+ public void createPartControl(Composite parent) { >+ pageBook = new PageBook(parent, SWT.NONE); >+ >+ createHelpMessage(pageBook); >+ setupTreeViewer(pageBook); >+ >+ if (users.size() == 0) >+ pageBook.showPage(helpMessageLabel); >+ } >+ >+ private void createHelpMessage(Composite parent) { >+ if (!parent.isDisposed()) { >+ helpMessageLabel = new Label(parent, SWT.TOP + SWT.LEFT + SWT.WRAP); >+ } >+ } >+ >+ protected void setupTreeViewer(Composite parent) { >+ treeViewer = new TreeViewer(parent, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL); >+ getSite().setSelectionProvider(treeViewer); >+ treeViewer.setContentProvider(new UserSearchContentProvider()); >+ treeViewer.setLabelProvider(new UserSearchLabelProvider()); >+ makeActions(); >+ hookContextMenu(); >+ >+ } >+ >+ private void makeActions() { >+ >+ addContactAction = new Action(Messages.MultiRosterView_AddContact, SharedImages.getImageDescriptor(SharedImages.IMG_ADD_BUDDY)) { >+ public void run() { >+ ITreeSelection selection = (ITreeSelection) treeViewer.getSelection(); >+ IResult contact = (IResult) selection.getFirstElement(); >+ if (MessageDialog.openConfirm(null, Messages.AddContactDialog_DialogTitle, NLS.bind(Messages.SearchContactDialog_AddContactMessage, contact.getUser().getName()))) { >+ IPresenceContainerAdapter ipca = account.getPresenceContainerAdapter(); >+ IRosterSubscriptionSender sender = ipca.getRosterManager().getRosterSubscriptionSender(); >+ try { >+ sender.sendRosterAdd(contact.getUser().getID().getName(), contact.getUser().getName(), null); >+ } catch (ECFException e) { >+ Activator.getDefault().getLog().log(e.getStatus()); >+ } >+ } >+ >+ } >+ }; >+ >+ } >+ >+ private void hookContextMenu() { >+ MenuManager menuMgr = new MenuManager(); >+ menuMgr.setRemoveAllWhenShown(true); >+ menuMgr.addMenuListener(new IMenuListener() { >+ public void menuAboutToShow(IMenuManager manager) { >+ fillContextMenu(manager); >+ } >+ }); >+ Menu menu = menuMgr.createContextMenu(treeViewer.getControl()); >+ treeViewer.getControl().setMenu(menu); >+ getSite().registerContextMenu(menuMgr, treeViewer); >+ } >+ >+ private void fillContextMenu(IMenuManager manager) { >+ IStructuredSelection iss = (IStructuredSelection) treeViewer.getSelection(); >+ Object element = iss.getFirstElement(); >+ if (element instanceof IResult) { >+ manager.add(addContactAction); >+ } >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.ui.part.WorkbenchPart#dispose() >+ */ >+ public void dispose() { >+ treeViewer = null; >+ users.clear(); >+ super.dispose(); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.ui.part.WorkbenchPart#setFocus() >+ */ >+ public void setFocus() { >+ treeViewer.getControl().setFocus(); >+ } >+ >+ /** >+ * Add the list of {@link IResult} that will be display on a tree >+ * @param list >+ * @return boolean >+ */ >+ public boolean addResult(IResultList list) { >+ users.clear(); >+ users.add(list); >+ treeViewer.setInput(users); >+ pageBook.showPage(treeViewer.getControl()); >+ treeViewer.expandToLevel(DEFAULT_EXPAND_LEVEL); >+ helpMessageLabel.setText(""); >+ return true; >+ } >+ >+ /** >+ * Add the MultiRosterAccount for add user contact >+ * @param account >+ * @return boolean >+ */ >+ public boolean addMultiRosterAccount(MultiRosterAccount multiRosterAccount) { >+ Assert.isNotNull(multiRosterAccount); >+ this.account = multiRosterAccount; >+ return true; >+ } >+ >+ /** >+ * Show a message into the view before show the result in a tree view >+ * @param string >+ */ >+ public void showMessage(String message) { >+ helpMessageLabel.setText(message); >+ pageBook.showPage(helpMessageLabel); >+ } >+ >+} >Index: src/org/eclipse/ecf/internal/presence/ui/dialogs/SearchContactDialog.java >=================================================================== >RCS file: src/org/eclipse/ecf/internal/presence/ui/dialogs/SearchContactDialog.java >diff -N src/org/eclipse/ecf/internal/presence/ui/dialogs/SearchContactDialog.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/internal/presence/ui/dialogs/SearchContactDialog.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,259 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Marcelo Mayworm. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: Marcelo Mayworm - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.ecf.internal.presence.ui.dialogs; >+ >+import java.util.Iterator; >+import org.eclipse.core.runtime.*; >+import org.eclipse.ecf.core.ContainerConnectException; >+import org.eclipse.ecf.core.util.ECFException; >+import org.eclipse.ecf.internal.presence.ui.Activator; >+import org.eclipse.ecf.internal.presence.ui.Messages; >+import org.eclipse.ecf.presence.IPresenceContainerAdapter; >+import org.eclipse.ecf.presence.roster.IRosterSubscriptionSender; >+import org.eclipse.ecf.presence.search.*; >+import org.eclipse.ecf.presence.ui.MultiRosterAccount; >+import org.eclipse.ecf.presence.ui.UserSearchView; >+import org.eclipse.jface.dialogs.*; >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.TableEditor; >+import org.eclipse.swt.events.*; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.ui.PartInitException; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.progress.UIJob; >+ >+public class SearchContactDialog extends Dialog { >+ >+ Button closeButton; >+ >+ Button searchButton; >+ >+ MultiRosterAccount account; >+ >+ Button addContactButton; >+ >+ Button runInBackgroundButton; >+ >+ Table tableResult; >+ >+ Table tableFields; >+ >+ public SearchContactDialog(Shell parentShell, MultiRosterAccount account) { >+ super(parentShell); >+ this.account = account; >+ >+ } >+ >+ protected void addListeners() { >+ >+ searchButton.addMouseListener(new MouseAdapter() { >+ public void mouseUp(MouseEvent e) { >+ IUserSearchManager userManager = account.getPresenceContainerAdapter().getUserSearchManager(); >+ try { >+ //selection to build the criteria >+ ISelection selection = userManager.createSelection(); >+ //create a specific criteria >+ final ICriteria criteria = userManager.createCriteria(); >+ //fields to consider on XMPP server side search >+ TableItem items[] = tableFields.getItems(); >+ for (int i = 0; i < items.length; i++) { >+ TableItem item = items[i]; >+ if (item.getChecked()) { >+ //build criterion field=value >+ ICriterion criterion = selection.eq(item.getText(0), item.getText(1)); >+ criteria.add(criterion); >+ } >+ } >+ //Run in a block or non-block way using the criteria built previously >+ if (runInBackgroundButton.getSelection()) { >+ callAsynchronous(userManager, criteria); >+ //close the UI >+ close(); >+ } else { >+ //call the block search >+ ISearch search = userManager.search(criteria); >+ //the collection of IResult >+ IResultList resultList = search.getResultList(); >+ //clean the table for a new result list >+ tableResult.removeAll(); >+ for (Iterator iterator = resultList.geResults().iterator(); iterator.hasNext();) { >+ IResult result = (IResult) iterator.next(); >+ TableItem item = new TableItem(tableResult, SWT.NONE); >+ item.setText(0, result.getUser().getName()); >+ item.setText(1, result.getUser().getID().getName()); >+ } >+ } >+ >+ } catch (ContainerConnectException e1) { >+ Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, e1.getLocalizedMessage(), e1)); >+ } >+ } >+ }); >+ >+ addContactButton.addMouseListener(new MouseAdapter() { >+ public void mouseUp(MouseEvent e) { >+ TableItem contact = tableResult.getSelection()[0]; >+ if (MessageDialog.openConfirm(null, Messages.AddContactDialog_DialogTitle, NLS.bind(Messages.SearchContactDialog_AddContactMessage, contact.getText(0)))) { >+ >+ IPresenceContainerAdapter ipca = account.getPresenceContainerAdapter(); >+ IRosterSubscriptionSender sender = ipca.getRosterManager().getRosterSubscriptionSender(); >+ try { >+ sender.sendRosterAdd(contact.getText(1), contact.getText(0), null); >+ } catch (ECFException e1) { >+ Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, e1.getLocalizedMessage(), e1)); >+ } >+ close(); >+ } >+ } >+ }); >+ >+ } >+ >+ protected void configureShell(Shell newShell) { >+ super.configureShell(newShell); >+ newShell.setText(Messages.SearchContactDialog_DialogTitle); >+ } >+ >+ /* >+ * Create just a close button for the Dialog >+ * (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) >+ */ >+ protected void createButtonsForButtonBar(Composite parent) { >+ createButton(parent, IDialogConstants.OK_ID, IDialogConstants.CLOSE_LABEL, true); >+ closeButton = getButton(IDialogConstants.OK_ID); >+ closeButton.setEnabled(true); >+ } >+ >+ protected Control createDialogArea(Composite parent) { >+ final int editableColumn = 1; >+ try { >+ parent = (Composite) super.createDialogArea(parent); >+ parent.setLayout(new GridLayout(2, false)); >+ String fields[] = null; >+ IUserSearchManager userManager = account.getPresenceContainerAdapter().getUserSearchManager(); >+ fields = userManager.getUserPropertiesFields(); >+ >+ GridData searchButtonData = new GridData(SWT.RIGHT, GridData.FILL_HORIZONTAL, false, false, 1, 1); >+ GridData addContactData = new GridData(SWT.RIGHT, GridData.FILL_HORIZONTAL, true, false, 1, 1); >+ >+ Group group = new Group(parent, SWT.SHADOW_ETCHED_IN); >+ group.setLayout(new GridLayout(2, false)); >+ group.setText(Messages.SearchContactDialog_InfoSearchFields); >+ >+ Group groupContact = new Group(parent, SWT.SHADOW_ETCHED_IN); >+ groupContact.setLayout(new GridLayout(2, false)); >+ groupContact.setText(Messages.SearchContactDialog_InfoContactFields); >+ >+ tableResult = new Table(groupContact, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION); >+ tableResult.setLinesVisible(true); >+ tableResult.setHeaderVisible(true); >+ GridData dataTable = new GridData(GridData.FILL_HORIZONTAL, GridData.FILL_VERTICAL, true, true, 2, 1); >+ dataTable.heightHint = 200; >+ tableResult.setLayoutData(dataTable); >+ >+ new TableColumn(tableResult, SWT.NONE).setText(Messages.SearchContactDialog_TableResultColumnName); >+ new TableColumn(tableResult, SWT.NONE).setText(Messages.SearchContactDialog_TableResultColumnUsername); >+ new TableItem(tableResult, SWT.NONE); >+ >+ for (int i = 0; i < 2; i++) { >+ tableResult.getColumn(i).setWidth(130); >+ } >+ >+ addContactButton = new Button(groupContact, SWT.PUSH | SWT.RIGHT); >+ addContactButton.setText(Messages.SearchContactDialog_ButtonAddContact); >+ addContactButton.setLayoutData(addContactData); >+ >+ tableFields = new Table(group, SWT.BORDER | SWT.MULTI | SWT.CHECK); >+ tableFields.setLinesVisible(true); >+ tableFields.setHeaderVisible(true); >+ dataTable = new GridData(GridData.FILL_HORIZONTAL, GridData.FILL_VERTICAL, true, true, 2, 1); >+ dataTable.heightHint = 200; >+ tableFields.setLayoutData(dataTable); >+ >+ TableColumn colField = new TableColumn(tableFields, SWT.NONE); >+ colField.setText(Messages.SearchContactDialog_TableSearchColumnField); >+ TableColumn colValue = new TableColumn(tableFields, SWT.NONE); >+ colValue.setText(Messages.SearchContactDialog_TableSearchColumnValue); >+ colValue.setWidth(130); >+ >+ for (int i = 0; i < fields.length; i++) { >+ TableItem item = new TableItem(tableFields, SWT.NONE); >+ item.setText(new String[] {fields[i], ""}); //$NON-NLS-1$ >+ item.setChecked(true); >+ } >+ >+ TableItem[] items = tableFields.getItems(); >+ for (int i = 0; i < items.length; i++) { >+ final TableEditor editor = new TableEditor(tableFields); >+ Text text = new Text(tableFields, SWT.NONE); >+ text.setText(items[i].getText(editableColumn)); >+ text.addModifyListener(new ModifyListener() { >+ public void modifyText(ModifyEvent e) { >+ editor.getItem().setText(editableColumn, ((Text) editor.getEditor()).getText()); >+ } >+ }); >+ text.selectAll(); >+ text.setFocus(); >+ editor.grabHorizontal = true; >+ editor.setEditor(text, items[i], editableColumn); >+ >+ } >+ colField.pack(); >+ >+ runInBackgroundButton = new Button(group, SWT.CHECK); >+ runInBackgroundButton.setText(Messages.SearchContactDialog_RunInBackground); >+ runInBackgroundButton.setToolTipText(Messages.SearchContactDialog_RunInBackGroundToolTip); >+ >+ searchButton = new Button(group, SWT.PUSH | SWT.RIGHT); >+ searchButton.setText(Messages.SearchContactDialog_ButtonSearch); >+ searchButton.setLayoutData(searchButtonData); >+ >+ } catch (ContainerConnectException e) { >+ Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, e.getLocalizedMessage(), e)); >+ new Label(parent, SWT.LEFT).setText(e.getLocalizedMessage()); >+ } >+ addListeners(); >+ applyDialogFont(parent); >+ return parent; >+ } >+ >+ /** >+ * Call the user search and open the view >+ * asynchronous >+ * @param userManager >+ * @param criteria >+ */ >+ protected void callAsynchronous(final IUserSearchManager userManager, final ICriteria criteria) { >+ new UIJob(Messages.SearchContactDialog_UserSearchJobName) { >+ public IStatus runInUIThread(IProgressMonitor monitor) { >+ try { >+ final UserSearchView view = (UserSearchView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(UserSearchView.VIEW_ID); >+ view.showMessage(Messages.SearchContactDialog_SearchingMessage); >+ view.addMultiRosterAccount(account); >+ IResultList resultList = userManager.search(criteria).getResultList(); >+ view.addResult(resultList); >+ } catch (PartInitException e) { >+ Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, e.getLocalizedMessage(), e)); >+ return Status.CANCEL_STATUS; >+ } catch (ContainerConnectException e) { >+ Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, e.getLocalizedMessage(), e)); >+ return Status.CANCEL_STATUS; >+ } >+ return Status.OK_STATUS; >+ } >+ }.schedule(3000); >+ } >+ >+} >Index: src/org/eclipse/ecf/presence/ui/UserSearchLabelProvider.java >=================================================================== >RCS file: src/org/eclipse/ecf/presence/ui/UserSearchLabelProvider.java >diff -N src/org/eclipse/ecf/presence/ui/UserSearchLabelProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/presence/ui/UserSearchLabelProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,56 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Marcelo Mayworm. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: Marcelo Mayworm - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.ecf.presence.ui; >+ >+import org.eclipse.ecf.internal.presence.ui.Messages; >+import org.eclipse.ecf.presence.search.IResult; >+import org.eclipse.ecf.presence.search.IResultList; >+import org.eclipse.ecf.ui.SharedImages; >+import org.eclipse.jface.viewers.LabelProvider; >+import org.eclipse.swt.graphics.Image; >+ >+/** >+ * Label provider for multiple users viewer. This label provider implements an >+ * LabelProvider suitable for use by viewers that accepts LabelProvider as >+ * input. This class may be subclassed in order to customize the >+ * behavior/display of other label providers. >+ * >+ */ >+public class UserSearchLabelProvider extends LabelProvider { >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object) >+ */ >+ public Image getImage(Object element) { >+ if (element instanceof IResultList) >+ return SharedImages.getImage(SharedImages.IMG_GROUP); >+ if (element instanceof IResult) >+ return SharedImages.getImage(SharedImages.IMG_USER_AVAILABLE); >+ >+ return null; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object) >+ */ >+ public String getText(Object element) { >+ if (element instanceof IResult) { >+ return ((IResult) element).getUser().getName(); >+ } else if (element instanceof IResultList) { >+ return ((IResultList) element).geResults().size() + Messages.UserSearchLabelProvider_ContactsFound; >+ } >+ return element.toString(); >+ } >+ >+} >Index: src/org/eclipse/ecf/presence/ui/UserSearchContentProvider.java >=================================================================== >RCS file: src/org/eclipse/ecf/presence/ui/UserSearchContentProvider.java >diff -N src/org/eclipse/ecf/presence/ui/UserSearchContentProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ecf/presence/ui/UserSearchContentProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,98 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Marcelo Mayworm. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: Marcelo Mayworm - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.ecf.presence.ui; >+ >+import java.util.List; >+import org.eclipse.ecf.presence.search.IResultList; >+import org.eclipse.jface.viewers.ITreeContentProvider; >+import org.eclipse.jface.viewers.Viewer; >+ >+/** >+ * Content provider for multiple users viewer. This content provider implements >+ * an ITreeContentProvider suitable for use by tree viewers that accepts >+ * ITreeContentProviders as input. This class may be subclassed in order to >+ * customize the behavior/display of other content providers. >+ * >+ */ >+public class UserSearchContentProvider implements ITreeContentProvider { >+ >+ protected static Object[] EMPTY_ARRAY = new Object[0]; >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object) >+ */ >+ public Object[] getChildren(Object parentElement) { >+ if (parentElement instanceof IResultList) { >+ return ((IResultList) parentElement).geResults().toArray(); >+ } >+ return EMPTY_ARRAY; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object) >+ */ >+ public Object getParent(Object element) { >+ if (element == null) { >+ return null; >+ } >+ return element; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object) >+ */ >+ public boolean hasChildren(Object element) { >+ if (element instanceof IResultList) { >+ IResultList list = (IResultList) element; >+ if (list.geResults().size() > 0) >+ return true; >+ } >+ return false; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) >+ */ >+ public Object[] getElements(Object inputElement) { >+ if (inputElement instanceof List) >+ return ((List) inputElement).toArray(); >+ >+ return null; >+ >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.IContentProvider#dispose() >+ */ >+ public void dispose() { >+ // do nothing >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, >+ * java.lang.Object, java.lang.Object) >+ */ >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ // do nothing >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 256696
:
120735
|
122604
|
123016
|
123308